@visactor/vrender-components 0.21.0-alpha.2 → 0.21.0-alpha.4

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 (86) hide show
  1. package/cjs/axis/circle.js +3 -3
  2. package/cjs/axis/circle.js.map +1 -1
  3. package/cjs/axis/overlap/auto-limit.js +7 -9
  4. package/cjs/axis/overlap/auto-limit.js.map +1 -1
  5. package/cjs/axis/overlap/auto-wrap.js +21 -8
  6. package/cjs/axis/overlap/auto-wrap.js.map +1 -1
  7. package/cjs/axis/type.d.ts +4 -0
  8. package/cjs/axis/type.js.map +1 -1
  9. package/cjs/gif/gif.d.ts +29 -0
  10. package/cjs/gif/gif.js +59 -0
  11. package/cjs/gif/gif.js.map +1 -0
  12. package/cjs/gif/index.d.ts +1 -0
  13. package/cjs/gif/index.js +21 -0
  14. package/cjs/gif/index.js.map +1 -0
  15. package/cjs/index.d.ts +2 -1
  16. package/cjs/index.js +2 -2
  17. package/cjs/index.js.map +1 -1
  18. package/cjs/jsx/component-type.js +1 -2
  19. package/cjs/label/arc.js +2 -1
  20. package/cjs/label/base.d.ts +4 -2
  21. package/cjs/label/base.js +42 -10
  22. package/cjs/label/base.js.map +1 -1
  23. package/cjs/label/overlap/place.js +3 -1
  24. package/cjs/label/overlap/place.js.map +1 -1
  25. package/cjs/label/overlap/scaler.d.ts +6 -0
  26. package/cjs/label/overlap/scaler.js +16 -14
  27. package/cjs/label/overlap/scaler.js.map +1 -1
  28. package/cjs/label/overlap/shiftY.d.ts +8 -0
  29. package/cjs/label/overlap/shiftY.js +47 -0
  30. package/cjs/label/overlap/shiftY.js.map +1 -0
  31. package/cjs/label/polygon.js +1 -1
  32. package/cjs/label/rect.js +1 -1
  33. package/cjs/label/type.d.ts +8 -1
  34. package/cjs/label/type.js.map +1 -1
  35. package/cjs/legend/base.d.ts +1 -0
  36. package/cjs/legend/base.js +7 -6
  37. package/cjs/legend/base.js.map +1 -1
  38. package/cjs/legend/discrete/discrete.d.ts +8 -0
  39. package/cjs/legend/discrete/discrete.js +122 -32
  40. package/cjs/legend/discrete/discrete.js.map +1 -1
  41. package/cjs/legend/discrete/type.d.ts +15 -3
  42. package/cjs/legend/discrete/type.js.map +1 -1
  43. package/dist/index.es.js +1285 -209
  44. package/es/axis/circle.js +3 -3
  45. package/es/axis/circle.js.map +1 -1
  46. package/es/axis/overlap/auto-limit.js +5 -8
  47. package/es/axis/overlap/auto-limit.js.map +1 -1
  48. package/es/axis/overlap/auto-wrap.js +20 -8
  49. package/es/axis/overlap/auto-wrap.js.map +1 -1
  50. package/es/axis/type.d.ts +4 -0
  51. package/es/axis/type.js.map +1 -1
  52. package/es/gif/gif.d.ts +29 -0
  53. package/es/gif/gif.js +55 -0
  54. package/es/gif/gif.js.map +1 -0
  55. package/es/gif/index.d.ts +1 -0
  56. package/es/gif/index.js +2 -0
  57. package/es/gif/index.js.map +1 -0
  58. package/es/index.d.ts +2 -1
  59. package/es/index.js +3 -1
  60. package/es/index.js.map +1 -1
  61. package/es/jsx/component-type.js +1 -2
  62. package/es/label/arc.js +2 -1
  63. package/es/label/base.d.ts +4 -2
  64. package/es/label/base.js +42 -7
  65. package/es/label/base.js.map +1 -1
  66. package/es/label/overlap/place.js +4 -2
  67. package/es/label/overlap/place.js.map +1 -1
  68. package/es/label/overlap/scaler.d.ts +6 -0
  69. package/es/label/overlap/scaler.js +11 -10
  70. package/es/label/overlap/scaler.js.map +1 -1
  71. package/es/label/overlap/shiftY.d.ts +8 -0
  72. package/es/label/overlap/shiftY.js +41 -0
  73. package/es/label/overlap/shiftY.js.map +1 -0
  74. package/es/label/polygon.js +1 -1
  75. package/es/label/rect.js +1 -1
  76. package/es/label/type.d.ts +8 -1
  77. package/es/label/type.js.map +1 -1
  78. package/es/legend/base.d.ts +1 -0
  79. package/es/legend/base.js +7 -5
  80. package/es/legend/base.js.map +1 -1
  81. package/es/legend/discrete/discrete.d.ts +8 -0
  82. package/es/legend/discrete/discrete.js +122 -33
  83. package/es/legend/discrete/discrete.js.map +1 -1
  84. package/es/legend/discrete/type.d.ts +15 -3
  85. package/es/legend/discrete/type.js.map +1 -1
  86. package/package.json +6 -5
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, 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, isNumberClose, 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 {
@@ -860,11 +860,12 @@ function parseSvgPath(str) {
860
860
  for (let i = 0, len = paths.length; i < len; i++) if (currPath = paths[i], coordsStr = currPath.slice(1), commandChar = currPath[0], currCommandData = [commandChar], coordsStrArr = coordsStr.match(rePathCommand), null !== coordsStrArr) {
861
861
  for (let i = 0, len = coordsStrArr.length; i < len; i++) coordStr = coordsStrArr[i], coordNumber = parseFloat(coordStr), Number.isNaN(coordNumber) || currCommandData.push(coordNumber);
862
862
  if (standardCommandLen = commandLengths[commandChar], currCommandData.length - 1 > standardCommandLen) {
863
- let subCommand;
863
+ let subCommand,
864
+ bestCommandChar = commandChar;
864
865
  for (let i = 1, len = currCommandData.length; i < len; i += standardCommandLen) {
865
- subCommand = [commandChar];
866
+ subCommand = [bestCommandChar];
866
867
  for (let j = i, subLen = i + standardCommandLen; j < subLen; j++) subCommand.push(currCommandData[j]);
867
- result.push(subCommand);
868
+ result.push(subCommand), "m" === bestCommandChar ? bestCommandChar = "l" : "M" === bestCommandChar && (bestCommandChar = "L");
868
869
  }
869
870
  } else result.push(currCommandData);
870
871
  } else result.push(currCommandData);
@@ -2075,6 +2076,7 @@ const DefaultAttribute = Object.assign(Object.assign(Object.assign({
2075
2076
  zIndex: 0,
2076
2077
  layout: null,
2077
2078
  boundsPadding: 0,
2079
+ fillStrokeOrder: 0,
2078
2080
  renderStyle: "default",
2079
2081
  pickMode: "accurate",
2080
2082
  customPickShape: null,
@@ -2145,6 +2147,7 @@ const DefaultLineAttribute = Object.assign(Object.assign(Object.assign({}, Defau
2145
2147
  });
2146
2148
  const DefaultPathAttribute = Object.assign(Object.assign({}, DefaultAttribute), {
2147
2149
  path: new CustomPath2D(),
2150
+ fillStrokeOrder: 1,
2148
2151
  customPath: () => {
2149
2152
  Logger.getInstance().warn("空函数");
2150
2153
  }
@@ -2457,6 +2460,14 @@ let ATextMeasure = class {
2457
2460
  return data;
2458
2461
  }
2459
2462
  _clipTextEnd(text, options, width, leftIdx, rightIdx) {
2463
+ if (leftIdx === rightIdx) {
2464
+ Logger.getInstance().warn(`【_clipTextEnd】不应该走到这里${text}, ${leftIdx}, ${rightIdx}`);
2465
+ const subText = text.substring(0, rightIdx + 1);
2466
+ return {
2467
+ str: subText,
2468
+ width: this.measureTextWidth(subText, options)
2469
+ };
2470
+ }
2460
2471
  const middleIdx = Math.floor((leftIdx + rightIdx) / 2),
2461
2472
  subText = text.substring(0, middleIdx + 1),
2462
2473
  strWidth = this.measureTextWidth(subText, options);
@@ -2490,7 +2501,7 @@ let ATextMeasure = class {
2490
2501
  }
2491
2502
  _clipTextStart(text, options, width, leftIdx, rightIdx) {
2492
2503
  const middleIdx = Math.ceil((leftIdx + rightIdx) / 2),
2493
- subText = text.substring(middleIdx - 1, text.length - 1),
2504
+ subText = text.substring(middleIdx - 1, text.length),
2494
2505
  strWidth = this.measureTextWidth(subText, options);
2495
2506
  let length;
2496
2507
  if (strWidth > width) {
@@ -2498,18 +2509,18 @@ let ATextMeasure = class {
2498
2509
  str: "",
2499
2510
  width: 0
2500
2511
  };
2501
- const str = text.substring(middleIdx, text.length - 1);
2512
+ const str = text.substring(middleIdx, text.length);
2502
2513
  return length = this.measureTextWidth(str, options), length <= width ? {
2503
2514
  str: str,
2504
2515
  width: length
2505
- } : this._clipTextStart(text, options, width, middleIdx, text.length - 1);
2516
+ } : this._clipTextStart(text, options, width, middleIdx, text.length);
2506
2517
  }
2507
2518
  if (strWidth < width) {
2508
2519
  if (middleIdx <= 0) return {
2509
2520
  str: text,
2510
2521
  width: this.measureTextWidth(text, options)
2511
2522
  };
2512
- const str = text.substring(middleIdx - 2, text.length - 1);
2523
+ const str = text.substring(middleIdx - 2, text.length);
2513
2524
  return length = this.measureTextWidth(str, options), length >= width ? {
2514
2525
  str: subText,
2515
2526
  width: strWidth
@@ -2817,7 +2828,7 @@ let DefaultWindow = class {
2817
2828
  }
2818
2829
  hasSubView() {
2819
2830
  const viewBox = this._handler.getViewBox();
2820
- return !(0 === viewBox.x1 && 0 === viewBox.y1 && this.width === viewBox.width() && this.height === viewBox.height());
2831
+ return !(0 === viewBox.x1 && 0 === viewBox.y1 && isNumberClose(this.width, viewBox.width()) && isNumberClose(this.height, viewBox.height()));
2821
2832
  }
2822
2833
  isVisible(bbox) {
2823
2834
  return this._handler.isVisible(bbox);
@@ -4361,7 +4372,7 @@ class ResourceLoader {
4361
4372
  }
4362
4373
  static GetFile(url, type) {
4363
4374
  let data = ResourceLoader.cache.get(url);
4364
- return data ? "init" === data.loadState || "fail" === data.loadState ? Promise.reject() : "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
4375
+ return data ? "fail" === data.loadState ? Promise.reject() : "init" === data.loadState || "loading" === data.loadState ? data.dataPromise.then(data => data.data) : Promise.resolve(data.data) : (data = {
4365
4376
  type: type,
4366
4377
  loadState: "init"
4367
4378
  }, 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));
@@ -6506,7 +6517,7 @@ class BaseRender {
6506
6517
  }
6507
6518
  }
6508
6519
 
6509
- const parse = function () {
6520
+ const parse$1 = function () {
6510
6521
  const tokens = {
6511
6522
  linearGradient: /^(linear\-gradient)/i,
6512
6523
  radialGradient: /^(radial\-gradient)/i,
@@ -6659,7 +6670,7 @@ class GradientParser {
6659
6670
  }
6660
6671
  static Parse(c) {
6661
6672
  if (GradientParser.IsGradientStr(c)) try {
6662
- const datum = parse(c)[0];
6673
+ const datum = parse$1(c)[0];
6663
6674
  if (datum) {
6664
6675
  if ("linear" === datum.type) return GradientParser.ParseLinear(datum);
6665
6676
  if ("radial" === datum.type) return GradientParser.ParseRadial(datum);
@@ -7342,8 +7353,9 @@ class DefaultImageRenderContribution extends DefaultRectRenderContribution {
7342
7353
  constructor() {
7343
7354
  super(...arguments), this.time = BaseRenderContributionTime.afterFillStroke, this.useStyle = !0, this.order = 0;
7344
7355
  }
7345
- drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
7346
- return super.drawShape(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
7356
+ drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb) {
7357
+ if (!(image.isGifImage && image.renderFrame && image.playing)) return super.drawShape(image, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
7358
+ image.renderFrame(context, x, y);
7347
7359
  }
7348
7360
  }
7349
7361
  const defaultImageRenderContribution = new DefaultImageRenderContribution();
@@ -7497,7 +7509,8 @@ let DefaultCanvasArcRender = class extends BaseRender {
7497
7509
  fill = arcAttribute.fill,
7498
7510
  stroke = arcAttribute.stroke,
7499
7511
  x: originX = arcAttribute.x,
7500
- y: originY = arcAttribute.y
7512
+ y: originY = arcAttribute.y,
7513
+ fillStrokeOrder = arcAttribute.fillStrokeOrder
7501
7514
  } = arc.attribute,
7502
7515
  data = this.valid(arc, arcAttribute, fillCb, strokeCb);
7503
7516
  if (!data) return;
@@ -7533,7 +7546,17 @@ let DefaultCanvasArcRender = class extends BaseRender {
7533
7546
  isFullStroke: isFullStroke,
7534
7547
  stroke: arrayStroke
7535
7548
  } = parseStroke(stroke);
7536
- if ((doFill || isFullStroke) && (context.beginPath(), drawArcPath(arc, context, x, y, outerRadius, innerRadius), beforeRenderContribitionsRuned = !0, context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute), this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill())), doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.stroke()))), !isFullStroke && doStroke) {
7549
+ if (doFill || isFullStroke) {
7550
+ context.beginPath(), drawArcPath(arc, context, x, y, outerRadius, innerRadius), beforeRenderContribitionsRuned = !0, context.setShadowBlendStyle && context.setShadowBlendStyle(arc, arc.attribute, arcAttribute), this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
7551
+ const _runFill = () => {
7552
+ doFill && (fillCb ? fillCb(context, arc.attribute, arcAttribute) : fVisible && (context.setCommonStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.fill()));
7553
+ },
7554
+ _runStroke = () => {
7555
+ doStroke && isFullStroke && (strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, originX - x, originY - y, arcAttribute), context.stroke()));
7556
+ };
7557
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
7558
+ }
7559
+ if (!isFullStroke && doStroke) {
7537
7560
  context.beginPath();
7538
7561
  drawArcPath(arc, context, x, y, outerRadius, innerRadius, arrayStroke);
7539
7562
  beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), strokeCb ? strokeCb(context, arc.attribute, arcAttribute) : sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke());
@@ -7551,14 +7574,20 @@ let DefaultCanvasArcRender = class extends BaseRender {
7551
7574
  fill = arcAttribute.fill
7552
7575
  } = arc.attribute,
7553
7576
  startAngle = endAngle;
7554
- if (this.drawArcTailCapPath(arc, context, x, y, outerRadius, innerRadius, startAngle, startAngle + capAngle), beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), doFill) {
7555
- const color = fill;
7556
- if ("conical" === color.gradient) {
7557
- const lastColor = getConicGradientAt(0, 0, endAngle, color);
7558
- fillCb || fillVisible && (context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute), context.fillStyle = lastColor, context.fill());
7559
- }
7560
- }
7561
- doStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
7577
+ this.drawArcTailCapPath(arc, context, x, y, outerRadius, innerRadius, startAngle, startAngle + capAngle), beforeRenderContribitionsRuned || this.beforeRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb);
7578
+ const _runFill = () => {
7579
+ if (doFill) {
7580
+ const color = fill;
7581
+ if ("conical" === color.gradient) {
7582
+ const lastColor = getConicGradientAt(0, 0, endAngle, color);
7583
+ fillCb || fillVisible && (context.setCommonStyle(arc, arc.attribute, x, y, arcAttribute), context.fillStyle = lastColor, context.fill());
7584
+ }
7585
+ }
7586
+ },
7587
+ _runStroke = () => {
7588
+ doStroke && (strokeCb || sVisible && (context.setStrokeStyle(arc, arc.attribute, x, y, arcAttribute), context.stroke()));
7589
+ };
7590
+ _runFill(), _runStroke();
7562
7591
  }
7563
7592
  }
7564
7593
  this.afterRenderStep(arc, context, x, y, doFill, doStroke, fVisible, sVisible, arcAttribute, drawContext, fillCb, strokeCb), tempChangeConicalColor && (fill.startAngle += conicalOffset, fill.endAngle += conicalOffset);
@@ -7596,7 +7625,8 @@ let DefaultCanvasCircleRender = class extends BaseRender {
7596
7625
  startAngle = circleAttribute.startAngle,
7597
7626
  endAngle = circleAttribute.endAngle,
7598
7627
  x: originX = circleAttribute.x,
7599
- y: originY = circleAttribute.y
7628
+ y: originY = circleAttribute.y,
7629
+ fillStrokeOrder = circleAttribute.fillStrokeOrder
7600
7630
  } = circle.attribute,
7601
7631
  data = this.valid(circle, circleAttribute, fillCb, strokeCb);
7602
7632
  if (!data) return;
@@ -7606,7 +7636,14 @@ let DefaultCanvasCircleRender = class extends BaseRender {
7606
7636
  doFill: doFill,
7607
7637
  doStroke: doStroke
7608
7638
  } = data;
7609
- context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, circle.attribute, circleAttribute) : fVisible && (context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.fill())), doStroke && (strokeCb ? strokeCb(context, circle.attribute, circleAttribute) : sVisible && (context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.stroke())), this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
7639
+ context.beginPath(), context.arc(x, y, radius, startAngle, endAngle), context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(circle, circle.attribute, circleAttribute), this.beforeRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
7640
+ const _runFill = () => {
7641
+ doFill && (fillCb ? fillCb(context, circle.attribute, circleAttribute) : fVisible && (context.setCommonStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.fill()));
7642
+ },
7643
+ _runStroke = () => {
7644
+ doStroke && (strokeCb ? strokeCb(context, circle.attribute, circleAttribute) : sVisible && (context.setStrokeStyle(circle, circle.attribute, originX - x, originY - y, circleAttribute), context.stroke()));
7645
+ };
7646
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(circle, context, x, y, doFill, doStroke, fVisible, sVisible, circleAttribute, drawContext, fillCb, strokeCb);
7610
7647
  }
7611
7648
  draw(circle, renderService, drawContext, params) {
7612
7649
  const circleAttribute = getTheme(circle, null == params ? void 0 : params.theme).circle;
@@ -8047,7 +8084,7 @@ let DefaultCanvasAreaRender = class extends BaseRender {
8047
8084
  super(), this.areaRenderContribitions = areaRenderContribitions, this.numberType = AREA_NUMBER_TYPE, this.builtinContributions = [defaultAreaTextureRenderContribution, defaultAreaBackgroundRenderContribution], this.init(areaRenderContribitions);
8048
8085
  }
8049
8086
  drawLinearAreaHighPerformance(area, context, fill, stroke, fillOpacity, strokeOpacity, offsetX, offsetY, areaAttribute, drawContext, params, fillCb, strokeCb) {
8050
- var _a, _b, _c, _d, _e;
8087
+ var _a, _b, _c;
8051
8088
  const {
8052
8089
  points: points
8053
8090
  } = area.attribute;
@@ -8071,28 +8108,31 @@ let DefaultCanvasAreaRender = class extends BaseRender {
8071
8108
  x: originX = 0,
8072
8109
  x: originY = 0
8073
8110
  } = area.attribute;
8074
- if (!1 !== fill && (fillCb ? fillCb(context, area.attribute, areaAttribute) : fillOpacity && (context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, areaAttribute, drawContext, fillCb, null, {
8111
+ !1 !== fill && (fillCb ? fillCb(context, area.attribute, areaAttribute) : fillOpacity && (context.setCommonStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, areaAttribute, drawContext, fillCb, null, {
8075
8112
  attribute: area.attribute
8076
- }), stroke) {
8077
- const {
8078
- stroke = areaAttribute && areaAttribute.stroke
8079
- } = area.attribute;
8080
- if (isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
8081
- context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
8082
- for (let i = 1; i < points.length; i++) {
8083
- const p = points[i];
8084
- context.lineTo(p.x + offsetX, p.y + offsetY, z);
8085
- }
8086
- } else if (stroke[2]) {
8087
- const endP = points[points.length - 1];
8088
- context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
8089
- for (let i = points.length - 2; i >= 0; i--) {
8090
- const p = points[i];
8091
- context.lineTo((null !== (_d = p.x1) && void 0 !== _d ? _d : p.x) + offsetX, (null !== (_e = p.y1) && void 0 !== _e ? _e : p.y) + offsetY, z);
8113
+ }), (() => {
8114
+ var _a, _b;
8115
+ if (stroke) {
8116
+ const {
8117
+ stroke = areaAttribute && areaAttribute.stroke
8118
+ } = area.attribute;
8119
+ if (isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1]) if (context.beginPath(), stroke[0]) {
8120
+ context.moveTo(startP.x + offsetX, startP.y + offsetY, z);
8121
+ for (let i = 1; i < points.length; i++) {
8122
+ const p = points[i];
8123
+ context.lineTo(p.x + offsetX, p.y + offsetY, z);
8124
+ }
8125
+ } else if (stroke[2]) {
8126
+ const endP = points[points.length - 1];
8127
+ context.moveTo(endP.x + offsetX, endP.y + offsetY, z);
8128
+ for (let i = points.length - 2; i >= 0; i--) {
8129
+ const p = points[i];
8130
+ context.lineTo((null !== (_a = p.x1) && void 0 !== _a ? _a : p.x) + offsetX, (null !== (_b = p.y1) && void 0 !== _b ? _b : p.y) + offsetY, z);
8131
+ }
8092
8132
  }
8133
+ strokeCb ? strokeCb(context, area.attribute, areaAttribute) : (context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.stroke());
8093
8134
  }
8094
- strokeCb ? strokeCb(context, area.attribute, areaAttribute) : (context.setStrokeStyle(area, area.attribute, originX - offsetX, originY - offsetY, areaAttribute), context.stroke());
8095
- }
8135
+ })();
8096
8136
  }
8097
8137
  drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
8098
8138
  var _a, _b, _c, _d, _e, _f;
@@ -8257,23 +8297,24 @@ let DefaultCanvasAreaRender = class extends BaseRender {
8257
8297
  x: originX = 0,
8258
8298
  x: originY = 0
8259
8299
  } = attribute;
8260
- if (!1 !== fill && (fillCb ? fillCb(context, attribute, defaultAttribute) : fillOpacity && (context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, defaultAttribute, drawContext, fillCb, null, {
8300
+ return !1 !== fill && (fillCb ? fillCb(context, attribute, defaultAttribute) : fillOpacity && (context.setCommonStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.fill())), this.afterRenderStep(area, context, offsetX, offsetY, !!fillOpacity, !1, fill, !1, defaultAttribute, drawContext, fillCb, null, {
8261
8301
  attribute: attribute
8262
- }), !1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute);else {
8263
- const {
8264
- stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
8265
- } = attribute;
8266
- isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? "x" : "y", {
8267
- offsetX: offsetX,
8268
- offsetY: offsetY,
8269
- offsetZ: offsetZ,
8270
- drawConnect: connect,
8271
- mode: connectedType,
8272
- zeroX: connectedX,
8273
- zeroY: connectedY
8274
- })), context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.stroke();
8275
- }
8276
- return !1;
8302
+ }), (() => {
8303
+ if (!1 !== stroke) if (strokeCb) strokeCb(context, attribute, defaultAttribute);else {
8304
+ const {
8305
+ stroke = defaultAttribute && defaultAttribute[1] && defaultAttribute[1].stroke
8306
+ } = attribute;
8307
+ isArray(stroke) && (stroke[0] || stroke[2]) && !1 === stroke[1] && (context.beginPath(), drawSegments(context.camera ? context : context.nativeContext, stroke[0] ? cache.top : cache.bottom, clipRange, direction === Direction$1.ROW ? "x" : "y", {
8308
+ offsetX: offsetX,
8309
+ offsetY: offsetY,
8310
+ offsetZ: offsetZ,
8311
+ drawConnect: connect,
8312
+ mode: connectedType,
8313
+ zeroX: connectedX,
8314
+ zeroY: connectedY
8315
+ })), context.setStrokeStyle(area, connect ? connectedStyle : attribute, originX - offsetX, originY - offsetY, connect ? da : defaultAttribute), context.stroke();
8316
+ }
8317
+ })(), !1;
8277
8318
  }
8278
8319
  };
8279
8320
  DefaultCanvasAreaRender = __decorate$D([injectable(), __param$t(0, inject(ContributionProvider)), __param$t(0, named(AreaRenderContribution)), __metadata$w("design:paramtypes", [Object])], DefaultCanvasAreaRender);
@@ -8305,7 +8346,8 @@ let DefaultCanvasPathRender = class extends BaseRender {
8305
8346
  const pathAttribute = null !== (_a = this.tempTheme) && void 0 !== _a ? _a : getTheme(path, null == params ? void 0 : params.theme).path,
8306
8347
  {
8307
8348
  x: originX = pathAttribute.x,
8308
- y: originY = pathAttribute.y
8349
+ y: originY = pathAttribute.y,
8350
+ fillStrokeOrder = pathAttribute.fillStrokeOrder
8309
8351
  } = path.attribute,
8310
8352
  z = null !== (_b = this.z) && void 0 !== _b ? _b : 0,
8311
8353
  data = this.valid(path, pathAttribute, fillCb, strokeCb);
@@ -8320,7 +8362,14 @@ let DefaultCanvasPathRender = class extends BaseRender {
8320
8362
  const path2D = null !== (_c = path.attribute.path) && void 0 !== _c ? _c : pathAttribute.path;
8321
8363
  renderCommandList(path2D.commandList, context, x, y, 1, 1, z);
8322
8364
  }
8323
- context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb), doStroke && (strokeCb ? strokeCb(context, path.attribute, pathAttribute) : sVisible && (context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.stroke())), doFill && (fillCb ? fillCb(context, path.attribute, pathAttribute) : fVisible && (context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.fill())), this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
8365
+ context.setShadowBlendStyle && context.setShadowBlendStyle(path, path.attribute, pathAttribute), this.beforeRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
8366
+ const _runStroke = () => {
8367
+ doStroke && (strokeCb ? strokeCb(context, path.attribute, pathAttribute) : sVisible && (context.setStrokeStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.stroke()));
8368
+ },
8369
+ _runFill = () => {
8370
+ doFill && (fillCb ? fillCb(context, path.attribute, pathAttribute) : fVisible && (context.setCommonStyle(path, path.attribute, originX - x, originY - y, pathAttribute), context.fill()));
8371
+ };
8372
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(path, context, x, y, doFill, doStroke, fVisible, sVisible, pathAttribute, drawContext, fillCb, strokeCb);
8324
8373
  }
8325
8374
  draw(path, renderService, drawContext, params) {
8326
8375
  const pathAttribute = getTheme(path, null == params ? void 0 : params.theme).path;
@@ -8364,7 +8413,8 @@ let DefaultCanvasRectRender = class extends BaseRender {
8364
8413
  x1: x1,
8365
8414
  y1: y1,
8366
8415
  x: originX = rectAttribute.x,
8367
- y: originY = rectAttribute.y
8416
+ y: originY = rectAttribute.y,
8417
+ fillStrokeOrder = rectAttribute.fillStrokeOrder
8368
8418
  } = rect.attribute;
8369
8419
  let {
8370
8420
  width: width,
@@ -8383,7 +8433,14 @@ let DefaultCanvasRectRender = class extends BaseRender {
8383
8433
  doFill: doFill,
8384
8434
  doStroke: doStroke
8385
8435
  };
8386
- context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke), doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.fill())), doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.stroke())), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
8436
+ context.setShadowBlendStyle && context.setShadowBlendStyle(rect, rect.attribute, rectAttribute), this.beforeRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
8437
+ const _runFill = () => {
8438
+ doFillOrStroke.doFill && (fillCb ? fillCb(context, rect.attribute, rectAttribute) : fVisible && (context.setCommonStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.fill()));
8439
+ },
8440
+ _runStroke = () => {
8441
+ doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, rect.attribute, rectAttribute) : sVisible && (context.setStrokeStyle(rect, rect.attribute, originX - x, originY - y, rectAttribute), context.stroke()));
8442
+ };
8443
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(rect, context, x, y, doFill, doStroke, fVisible, sVisible, rectAttribute, drawContext, fillCb, strokeCb);
8387
8444
  }
8388
8445
  draw(rect, renderService, drawContext, params) {
8389
8446
  const rectAttribute = getTheme(rect, null == params ? void 0 : params.theme).rect;
@@ -8419,7 +8476,8 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
8419
8476
  x: originX = symbolAttribute.x,
8420
8477
  y: originY = symbolAttribute.y,
8421
8478
  scaleX = symbolAttribute.scaleX,
8422
- scaleY = symbolAttribute.scaleY
8479
+ scaleY = symbolAttribute.scaleY,
8480
+ fillStrokeOrder = symbolAttribute.fillStrokeOrder
8423
8481
  } = symbol.attribute,
8424
8482
  data = this.valid(symbol, symbolAttribute, fillCb, strokeCb);
8425
8483
  if (!data) return;
@@ -8442,14 +8500,27 @@ let DefaultCanvasSymbolRender = class extends BaseRender {
8442
8500
  const obj = Object.assign({}, a);
8443
8501
  obj.fill = null !== (_a = a.fill) && void 0 !== _a ? _a : symbol.attribute.fill, obj.opacity = null !== (_b = a.opacity) && void 0 !== _b ? _b : symbol.attribute.opacity, obj.fillOpacity = symbol.attribute.fillOpacity, obj.stroke = null !== (_c = a.stroke) && void 0 !== _c ? _c : symbol.attribute.stroke, a = obj;
8444
8502
  }
8445
- a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute), context.fill())), a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
8503
+ const _runFill = () => {
8504
+ a.fill && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : (context.setCommonStyle(symbol, a, originX - x, originY - y, symbolAttribute), context.fill()));
8505
+ },
8506
+ _runStroke = () => {
8507
+ a.stroke && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : (context.setStrokeStyle(symbol, a, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
8508
+ };
8509
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke());
8446
8510
  };
8447
8511
  if (keepDirIn3d && context.camera && context.project) {
8448
8512
  const p = context.project(x, y, z),
8449
8513
  camera = context.camera;
8450
8514
  context.camera = null, !1 === parsedPath.draw(context, isArray(size) ? [size[0] * scaleX, size[1] * scaleY] : size * scaleX, p.x, p.y, void 0, callback) && context.closePath(), context.camera = camera;
8451
8515
  } else !1 === parsedPath.draw(context, size, x, y, z, callback) && context.closePath();
8452
- context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb), doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute), context.fill())), doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke())), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
8516
+ context.setShadowBlendStyle && context.setShadowBlendStyle(symbol, symbol.attribute, symbolAttribute), this.beforeRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
8517
+ const _runFill = () => {
8518
+ doFill && !parsedPath.isSvg && (fillCb ? fillCb(context, symbol.attribute, symbolAttribute) : fVisible && (context.setCommonStyle(symbol, symbol.attribute, originX - x, originY - y, symbolAttribute), context.fill()));
8519
+ },
8520
+ _runStroke = () => {
8521
+ doStroke && !parsedPath.isSvg && (strokeCb ? strokeCb(context, symbol.attribute, symbolAttribute) : sVisible && (context.setStrokeStyle(symbol, symbol.attribute, (originX - x) / scaleX, (originY - y) / scaleY, symbolAttribute), context.stroke()));
8522
+ };
8523
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(symbol, context, x, y, doFill, doStroke, fVisible, sVisible, symbolAttribute, drawContext, fillCb, strokeCb);
8453
8524
  }
8454
8525
  draw(symbol, renderService, drawContext, params) {
8455
8526
  const symbolAttribute = getTheme(symbol, null == params ? void 0 : params.theme).symbol;
@@ -8823,7 +8894,8 @@ let DefaultCanvasPolygonRender = class extends BaseRender {
8823
8894
  cornerRadius = polygonAttribute.cornerRadius,
8824
8895
  x: originX = polygonAttribute.x,
8825
8896
  y: originY = polygonAttribute.y,
8826
- closePath = polygonAttribute.closePath
8897
+ closePath = polygonAttribute.closePath,
8898
+ fillStrokeOrder = polygonAttribute.fillStrokeOrder
8827
8899
  } = polygon.attribute,
8828
8900
  data = this.valid(polygon, polygonAttribute, fillCb, strokeCb);
8829
8901
  if (!data) return;
@@ -8833,7 +8905,14 @@ let DefaultCanvasPolygonRender = class extends BaseRender {
8833
8905
  doFill: doFill,
8834
8906
  doStroke: doStroke
8835
8907
  } = data;
8836
- context.beginPath(), cornerRadius <= 0 || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb), doFill && (fillCb ? fillCb(context, polygon.attribute, polygonAttribute) : fVisible && (context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.fill())), doStroke && (strokeCb ? strokeCb(context, polygon.attribute, polygonAttribute) : sVisible && (context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.stroke())), this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
8908
+ context.beginPath(), cornerRadius <= 0 || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) ? drawPolygon(context.camera ? context : context.nativeContext, points, x, y) : drawRoundedPolygon(context.camera ? context : context.nativeContext, points, x, y, cornerRadius, closePath), closePath && context.closePath(), context.setShadowBlendStyle && context.setShadowBlendStyle(polygon, polygon.attribute, polygonAttribute), this.beforeRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
8909
+ const _runFill = () => {
8910
+ doFill && (fillCb ? fillCb(context, polygon.attribute, polygonAttribute) : fVisible && (context.setCommonStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.fill()));
8911
+ },
8912
+ _runStroke = () => {
8913
+ doStroke && (strokeCb ? strokeCb(context, polygon.attribute, polygonAttribute) : sVisible && (context.setStrokeStyle(polygon, polygon.attribute, originX - x, originY - y, polygonAttribute), context.stroke()));
8914
+ };
8915
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(polygon, context, x, y, doFill, doStroke, fVisible, sVisible, polygonAttribute, drawContext, fillCb, strokeCb);
8837
8916
  }
8838
8917
  draw(polygon, renderService, drawContext, params) {
8839
8918
  const polygonAttribute = getTheme(polygon, null == params ? void 0 : params.theme).polygon;
@@ -8876,7 +8955,10 @@ let DefaultCanvasGroupRender = class {
8876
8955
  cornerRadius = groupAttribute.cornerRadius,
8877
8956
  path = groupAttribute.path,
8878
8957
  lineWidth = groupAttribute.lineWidth,
8879
- visible = groupAttribute.visible
8958
+ visible = groupAttribute.visible,
8959
+ fillStrokeOrder = groupAttribute.fillStrokeOrder,
8960
+ x: originX = groupAttribute.x,
8961
+ y: originY = groupAttribute.y
8880
8962
  } = group.attribute,
8881
8963
  fVisible = rectFillVisible(opacity, fillOpacity, width, height, fill),
8882
8964
  sVisible = rectStrokeVisible(opacity, strokeOpacity, width, height),
@@ -8902,7 +8984,14 @@ let DefaultCanvasGroupRender = class {
8902
8984
  };
8903
8985
  this._groupRenderContribitions.forEach(c => {
8904
8986
  c.time === BaseRenderContributionTime.beforeFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb, doFillOrStroke);
8905
- }), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute), doFillOrStroke.doFill && (fillCb ? fillCb(context, group.attribute, groupAttribute) : fVisible && (context.setCommonStyle(group, group.attribute, x, y, groupAttribute), context.fill())), doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, group.attribute, groupAttribute) : sVisible && (context.setStrokeStyle(group, group.attribute, x, y, groupAttribute), context.stroke())), this._groupRenderContribitions.forEach(c => {
8987
+ }), clip && context.clip(), context.setShadowBlendStyle && context.setShadowBlendStyle(group, group.attribute, groupAttribute);
8988
+ const _runFill = () => {
8989
+ doFillOrStroke.doFill && (fillCb ? fillCb(context, group.attribute, groupAttribute) : fVisible && (context.setCommonStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.fill()));
8990
+ },
8991
+ _runStroke = () => {
8992
+ doFillOrStroke.doStroke && (strokeCb ? strokeCb(context, group.attribute, groupAttribute) : sVisible && (context.setStrokeStyle(group, group.attribute, originX - x, originY - y, groupAttribute), context.stroke()));
8993
+ };
8994
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this._groupRenderContribitions.forEach(c => {
8906
8995
  c.time === BaseRenderContributionTime.afterFillStroke && c.drawShape(group, context, x, y, doFill, doStroke, fVisible, sVisible, groupAttribute, drawContext, fillCb, strokeCb);
8907
8996
  });
8908
8997
  }
@@ -8968,6 +9057,7 @@ let DefaultCanvasImageRender = class extends BaseRender {
8968
9057
  x: originX = imageAttribute.x,
8969
9058
  y: originY = imageAttribute.y,
8970
9059
  cornerRadius = imageAttribute.cornerRadius,
9060
+ fillStrokeOrder = imageAttribute.fillStrokeOrder,
8971
9061
  image: url
8972
9062
  } = image.attribute,
8973
9063
  data = this.valid(image, imageAttribute, fillCb);
@@ -8978,29 +9068,37 @@ let DefaultCanvasImageRender = class extends BaseRender {
8978
9068
  doFill: doFill,
8979
9069
  doStroke: doStroke
8980
9070
  } = data;
8981
- if (context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb), doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
8982
- if (!url || !image.resources) return;
8983
- const res = image.resources.get(url);
8984
- if ("success" !== res.state) return;
8985
- let needRestore = !1;
8986
- 0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) || (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
8987
- let repeat = 0;
8988
- if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
8989
- const pattern = context.createPattern(res.data, repeatStr[repeat]);
8990
- context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
8991
- } else context.drawImage(res.data, x, y, width, height);
8992
- needRestore && context.restore();
8993
- }
8994
- doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke())), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
9071
+ context.setShadowBlendStyle && context.setShadowBlendStyle(image, imageAttribute), this.beforeRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
9072
+ const _runFill = () => {
9073
+ if (doFill) if (fillCb) fillCb(context, image.attribute, imageAttribute);else if (fVisible) {
9074
+ if (!url || !image.resources) return;
9075
+ const res = image.resources.get(url);
9076
+ if ("success" !== res.state) return;
9077
+ let needRestore = !1;
9078
+ 0 === cornerRadius || isArray(cornerRadius) && cornerRadius.every(num => 0 === num) || (context.beginPath(), createRectPath(context, x, y, width, height, cornerRadius), context.save(), context.clip(), needRestore = !0), context.setCommonStyle(image, image.attribute, x, y, imageAttribute);
9079
+ let repeat = 0;
9080
+ if ("repeat" === repeatX && (repeat |= 1), "repeat" === repeatY && (repeat |= 2), repeat) {
9081
+ const pattern = context.createPattern(res.data, repeatStr[repeat]);
9082
+ context.fillStyle = pattern, context.translate(x, y, !0), context.fillRect(0, 0, width, height), context.translate(-x, -y, !0);
9083
+ } else context.drawImage(res.data, x, y, width, height);
9084
+ needRestore && context.restore();
9085
+ }
9086
+ },
9087
+ _runStroke = () => {
9088
+ doStroke && (strokeCb ? strokeCb(context, image.attribute, imageAttribute) : sVisible && (context.setStrokeStyle(image, image.attribute, originX - x, originY - y, imageAttribute), context.stroke()));
9089
+ };
9090
+ fillStrokeOrder ? (_runStroke(), _runFill()) : (_runFill(), _runStroke()), this.afterRenderStep(image, context, x, y, doFill, !1, fVisible, !1, imageAttribute, drawContext, fillCb);
8995
9091
  }
8996
9092
  draw(image, renderService, drawContext) {
8997
9093
  const {
8998
9094
  image: url
8999
9095
  } = image.attribute;
9000
- if (!url || !image.resources) return;
9001
- const res = image.resources.get(url);
9002
- if ("loading" === res.state && isString(url)) return void ResourceLoader.improveImageLoading(url);
9003
- if ("success" !== res.state) return;
9096
+ if (!image.isGifImage) {
9097
+ if (!url || !image.resources) return;
9098
+ const res = image.resources.get(url);
9099
+ if ("loading" === res.state && isString(url)) return void ResourceLoader.improveImageLoading(url);
9100
+ if ("success" !== res.state) return;
9101
+ }
9004
9102
  const {
9005
9103
  context: context
9006
9104
  } = renderService.drawParams;
@@ -12925,27 +13023,9 @@ function simplifyRadialDist(points, sqTolerance) {
12925
13023
  for (let i = 1, len = points.length; i < len; i++) deltaX = points[i].x - lastX, deltaY = points[i].y - lastY, deltaX * deltaX + deltaY * deltaY > sqTolerance && (lastX = points[i].x, lastY = points[i].y, newPoints.push(points[i]));
12926
13024
  return points[points.length - 1].x === lastX && points[points.length - 1].y === lastY || newPoints.push(points[points.length - 1]), newPoints;
12927
13025
  }
12928
- function simplifyDPStep(points, startIdx, endIdx, sqTolerance, simplified) {
12929
- let maxSqDist = sqTolerance,
12930
- nextIdx = startIdx;
12931
- const startX = points[startIdx].x,
12932
- startY = points[startIdx].y,
12933
- vecX2 = points[endIdx].x - startX,
12934
- vecY2 = points[endIdx].y - startY,
12935
- sqLength = vecX2 * vecX2 + vecY2 * vecY2;
12936
- let area, sqArea, sqDistance, vecX1, vecY1;
12937
- for (let i = startIdx + 1, len = endIdx - 1; i < len; i++) vecX1 = points[i].x - startX, vecY1 = points[i].y - startY, area = vecX1 * vecY2 - vecX2 * vecY1, sqArea = area * area, sqDistance = sqArea / sqLength, sqDistance > maxSqDist && (maxSqDist = sqDistance, nextIdx = i);
12938
- maxSqDist > sqTolerance && (nextIdx - startIdx > 2 && simplifyDPStep(points, startIdx, nextIdx, sqTolerance, simplified), simplified.push(points[nextIdx], points[nextIdx + 1]), endIdx - nextIdx > 2 && simplifyDPStep(points, nextIdx, endIdx, sqTolerance, simplified));
12939
- }
12940
- function simplifyDouglasPeucker(points, sqTolerance) {
12941
- const lastIdx = points.length - 1,
12942
- simplified = [points[0]];
12943
- return simplifyDPStep(points, 0, lastIdx, sqTolerance, simplified), simplified.push(points[lastIdx]), simplified;
12944
- }
12945
13026
  function flatten_simplify(points, tolerance, highestQuality) {
12946
13027
  if (points.length <= 10) return points;
12947
- const sqTolerance = void 0 !== tolerance ? tolerance * tolerance : 1;
12948
- return points = simplifyDouglasPeucker(points = highestQuality ? points : simplifyRadialDist(points, sqTolerance), sqTolerance);
13028
+ return points = highestQuality ? points : simplifyRadialDist(points, void 0 !== tolerance ? tolerance * tolerance : 1);
12949
13029
  }
12950
13030
 
12951
13031
  let loadArcModule = !1;
@@ -15807,19 +15887,22 @@ function bitmapTool(width, height, padding = { top: 0, left: 0, right: 0, bottom
15807
15887
  scale.height = height;
15808
15888
  return scale;
15809
15889
  }
15810
- function boundToRange($, bound, clamp$1 = false) {
15811
- if (clamp$1) {
15812
- const { x1, x2, y1, y2 } = bound;
15813
- const _x1 = clamp(x1, 0, $.width);
15814
- const _x2 = clamp(x2, 0, $.width);
15815
- const _y1 = clamp(y1, 0, $.height);
15816
- const _y2 = clamp(y2, 0, $.height);
15817
- return {
15818
- x1: $.x(_x1),
15819
- x2: $.x(_x2),
15820
- y1: $.y(_y1),
15821
- y2: $.y(_y2)
15822
- };
15890
+ function clampRangeByBitmap($, range) {
15891
+ const { x1, x2, y1, y2 } = range;
15892
+ const _x1 = clamp(x1, 0, $.width);
15893
+ const _x2 = clamp(x2, 0, $.width);
15894
+ const _y1 = clamp(y1, 0, $.height);
15895
+ const _y2 = clamp(y2, 0, $.height);
15896
+ return {
15897
+ x1: $.x(_x1),
15898
+ x2: $.x(_x2),
15899
+ y1: $.y(_y1),
15900
+ y2: $.y(_y2)
15901
+ };
15902
+ }
15903
+ function boundToRange($, bound, clamp = false) {
15904
+ if (clamp) {
15905
+ return clampRangeByBitmap($, bound);
15823
15906
  }
15824
15907
  return {
15825
15908
  x1: $.x(bound.x1),
@@ -15840,10 +15923,13 @@ function canPlace($, bitmap, bound, checkBound = true, pad = 0) {
15840
15923
  };
15841
15924
  }
15842
15925
  range = boundToRange($, range);
15843
- const outOfBounds = checkBound && bitmap.outOfBounds(range);
15844
- if (outOfBounds) {
15926
+ const outOfBounds = bitmap.outOfBounds(range);
15927
+ if (checkBound && outOfBounds) {
15845
15928
  return false;
15846
15929
  }
15930
+ if (outOfBounds) {
15931
+ range = clampRangeByBitmap($, range);
15932
+ }
15847
15933
  return !bitmap.getRange(range);
15848
15934
  }
15849
15935
  function placeToCandidates($, bitmap, text, candidates = [], clampForce = true, pad = 0) {
@@ -16224,6 +16310,71 @@ function loadLabelComponent() {
16224
16310
  registerLine();
16225
16311
  }
16226
16312
 
16313
+ function shiftY(texts, option = {}) {
16314
+ const { maxIterations = 10, maxError = 0.1, padding = 1, maxY = Number.MAX_VALUE } = option;
16315
+ const n = texts.length;
16316
+ if (n <= 1) {
16317
+ return texts;
16318
+ }
16319
+ const isIntersect = ([a, b], [c, d]) => {
16320
+ return d > a && b > c;
16321
+ };
16322
+ const textInformation = new Map();
16323
+ const getY0 = (text) => textInformation.get(text).y0;
16324
+ const getY = (text) => textInformation.get(text).y;
16325
+ const getHeight = (text) => textInformation.get(text).height;
16326
+ const getX1 = (text) => textInformation.get(text).x1;
16327
+ const getX2 = (text) => textInformation.get(text).x2;
16328
+ const setY = (text, y) => {
16329
+ textInformation.get(text).y = y;
16330
+ };
16331
+ for (const text of texts) {
16332
+ const { y1, y2, x1, x2 } = text.AABBBounds;
16333
+ textInformation.set(text, { y0: y1, y: y1, height: y2 - y1, x1, x2 });
16334
+ }
16335
+ for (let iter = 0; iter < maxIterations; iter++) {
16336
+ texts.sort((a, b) => getY(a) - getY(b));
16337
+ let error = 0;
16338
+ for (let i = 0; i < n - 1; i++) {
16339
+ const curText = texts[i];
16340
+ let j = i + 1;
16341
+ let nextText;
16342
+ while ((nextText = texts[j]) &&
16343
+ !isIntersect([getX1(curText), getX2(curText)], [getX1(nextText), getX2(nextText)])) {
16344
+ j += 1;
16345
+ }
16346
+ if (nextText) {
16347
+ const y0 = getY(curText);
16348
+ const h0 = getHeight(curText);
16349
+ const y1 = getY(nextText);
16350
+ const delta = y1 - (y0 + h0);
16351
+ if (delta < padding) {
16352
+ const newDelta = (padding - delta) / 2;
16353
+ error = Math.max(error, newDelta);
16354
+ if (y1 + newDelta + getHeight(nextText) > maxY) {
16355
+ setY(curText, y0 - (padding - delta));
16356
+ }
16357
+ else if (y0 - newDelta < 0) {
16358
+ setY(nextText, y1 + (padding - delta));
16359
+ }
16360
+ else {
16361
+ setY(curText, y0 - newDelta);
16362
+ setY(nextText, y1 + newDelta);
16363
+ }
16364
+ }
16365
+ }
16366
+ }
16367
+ if (error < maxError) {
16368
+ break;
16369
+ }
16370
+ }
16371
+ for (const text of texts) {
16372
+ const finalY = text.attribute.y + getY(text) - getY0(text);
16373
+ text.setAttribute('y', finalY);
16374
+ }
16375
+ return texts;
16376
+ }
16377
+
16227
16378
  loadLabelComponent();
16228
16379
  class LabelBase extends AbstractComponent {
16229
16380
  setBitmap(bitmap) {
@@ -16537,12 +16688,11 @@ class LabelBase extends AbstractComponent {
16537
16688
  return texts;
16538
16689
  }
16539
16690
  _overlapping(labels) {
16540
- var _a, _b, _c, _d;
16691
+ var _a, _b, _c;
16541
16692
  if (labels.length === 0) {
16542
16693
  return [];
16543
16694
  }
16544
16695
  const option = (isObject(this.attribute.overlap) ? this.attribute.overlap : {});
16545
- const result = [];
16546
16696
  const baseMarkGroup = this.getBaseMarkGroup();
16547
16697
  const size = (_a = option.size) !== null && _a !== void 0 ? _a : {
16548
16698
  width: (_b = baseMarkGroup === null || baseMarkGroup === void 0 ? void 0 : baseMarkGroup.AABBBounds.width()) !== null && _b !== void 0 ? _b : 0,
@@ -16551,12 +16701,55 @@ class LabelBase extends AbstractComponent {
16551
16701
  if (size.width === 0 || size.height === 0) {
16552
16702
  return labels;
16553
16703
  }
16554
- const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [], overlapPadding } = option;
16704
+ const { strategy, priority } = option;
16555
16705
  const bmpTool = this._bmpTool || bitmapTool(size.width, size.height);
16556
16706
  const bitmap = this._bitmap || bmpTool.bitmap();
16707
+ if (priority) {
16708
+ labels = labels.sort((a, b) => priority(b.attribute.data) - priority(a.attribute.data));
16709
+ }
16710
+ if ((strategy === null || strategy === void 0 ? void 0 : strategy.type) === 'shiftY') {
16711
+ return this._overlapGlobal(labels, option, bmpTool, bitmap);
16712
+ }
16713
+ return this._overlapByStrategy(labels, option, bmpTool, bitmap);
16714
+ }
16715
+ _overlapGlobal(labels, option, bmpTool, bitmap) {
16716
+ let result = labels.filter(label => label.attribute.visible && label.attribute.opacity !== 0);
16717
+ const { clampForce = true, hideOnHit = true, overlapPadding, strategy } = option;
16718
+ if (clampForce) {
16719
+ for (let i = 0; i < result.length; i++) {
16720
+ const text = labels[i];
16721
+ const { dx = 0, dy = 0 } = clampText(text, bmpTool.width, bmpTool.height);
16722
+ if (dx !== 0 || dy !== 0) {
16723
+ text.setAttributes({ x: text.attribute.x + dx, y: text.attribute.y + dy });
16724
+ }
16725
+ }
16726
+ }
16727
+ result = shiftY(result, Object.assign({ maxY: bmpTool.height }, strategy));
16728
+ for (let i = 0; i < result.length; i++) {
16729
+ const text = result[i];
16730
+ const bounds = text.AABBBounds;
16731
+ const range = boundToRange(bmpTool, bounds, true);
16732
+ if (canPlace(bmpTool, bitmap, bounds, clampForce, overlapPadding)) {
16733
+ bitmap.setRange(range);
16734
+ }
16735
+ else {
16736
+ if (hideOnHit) {
16737
+ text.setAttributes({ visible: false });
16738
+ }
16739
+ else {
16740
+ bitmap.setRange(range);
16741
+ }
16742
+ }
16743
+ }
16744
+ return result;
16745
+ }
16746
+ _overlapByStrategy(labels, option, bmpTool, bitmap) {
16747
+ var _a;
16748
+ const { avoidBaseMark, strategy = [], hideOnHit = true, clampForce = true, avoidMarks = [], overlapPadding } = option;
16749
+ const result = [];
16557
16750
  const checkBounds = strategy.some(s => s.type === 'bound');
16558
16751
  if (avoidBaseMark) {
16559
- (_d = this._baseMarks) === null || _d === void 0 ? void 0 : _d.forEach(mark => {
16752
+ (_a = this._baseMarks) === null || _a === void 0 ? void 0 : _a.forEach(mark => {
16560
16753
  mark.AABBBounds && bitmap.setRange(boundToRange(bmpTool, mark.AABBBounds, true));
16561
16754
  });
16562
16755
  }
@@ -16573,7 +16766,7 @@ class LabelBase extends AbstractComponent {
16573
16766
  });
16574
16767
  }
16575
16768
  for (let i = 0; i < labels.length; i++) {
16576
- if (labels[i].visible === false) {
16769
+ if (labels[i].attribute.visible === false) {
16577
16770
  continue;
16578
16771
  }
16579
16772
  const text = labels[i];
@@ -16840,7 +17033,7 @@ class LabelBase extends AbstractComponent {
16840
17033
  return listener;
16841
17034
  }
16842
17035
  _smartInvert(labels) {
16843
- var _a, _b, _c, _d, _e;
17036
+ var _a, _b, _c, _d, _e, _f, _g;
16844
17037
  const option = (isObject(this.attribute.smartInvert) ? this.attribute.smartInvert : {});
16845
17038
  const { textType, contrastRatiosThreshold, alternativeColors, mode, interactInvertType } = option;
16846
17039
  const fillStrategy = (_a = option.fillStrategy) !== null && _a !== void 0 ? _a : 'invertBase';
@@ -16857,8 +17050,15 @@ class LabelBase extends AbstractComponent {
16857
17050
  continue;
16858
17051
  }
16859
17052
  const baseMark = this.getRelatedGraphic(label.attribute);
16860
- const backgroundColor = baseMark.attribute.fill;
16861
- const foregroundColor = label.attribute.fill;
17053
+ let backgroundColor = baseMark.attribute.fill;
17054
+ let foregroundColor = label.attribute.fill;
17055
+ if (isObject(backgroundColor) && backgroundColor.gradient) {
17056
+ const firstStopColor = (_g = (_f = backgroundColor.stops) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.color;
17057
+ if (firstStopColor) {
17058
+ backgroundColor = firstStopColor;
17059
+ foregroundColor = firstStopColor;
17060
+ }
17061
+ }
16862
17062
  const invertColor = labelSmartInvert(foregroundColor, backgroundColor, textType, contrastRatiosThreshold, alternativeColors, mode);
16863
17063
  const similarColor = contrastAccessibilityChecker(invertColor, brightColor) ? brightColor : darkColor;
16864
17064
  const isInside = this._canPlaceInside(label.AABBBounds, baseMark.AABBBounds);
@@ -19107,15 +19307,24 @@ function autoLimit(labels, config) {
19107
19307
  return;
19108
19308
  }
19109
19309
  const overflowLimitLength = normalizeOverflowLimitLength(config.overflowLimitLength);
19310
+ const firstLabel = labels[0];
19311
+ const angle = firstLabel.attribute.angle;
19312
+ const hasAngle = !isNil(angle);
19313
+ const cos = hasAngle ? Math.cos(angle) : 1;
19314
+ const sin = hasAngle ? Math.sin(angle) : 0;
19315
+ const isHorizontal = isAngleHorizontal(angle);
19316
+ const isVertical = isAngleVertical(angle);
19317
+ const isX = orient === 'top' || orient === 'bottom';
19318
+ const direction = firstLabel.attribute.direction;
19319
+ const THRESHOLD = 2;
19320
+ const checkBox = !isHorizontal &&
19321
+ !isVertical &&
19322
+ isX &&
19323
+ (labels.length < 2 ||
19324
+ labels.some(label => Math.abs(label.AABBBounds.width() - firstLabel.AABBBounds.width()) >= THRESHOLD)) &&
19325
+ firstLabel.AABBBounds.width() > Math.abs(limitLength / sin);
19110
19326
  labels.forEach(label => {
19111
19327
  var _a;
19112
- const angle = label.attribute.angle;
19113
- const hasAngle = !isNil(angle);
19114
- const cos = hasAngle ? Math.cos(angle) : 1;
19115
- const sin = hasAngle ? Math.sin(angle) : 0;
19116
- const isHorizontal = isAngleHorizontal(angle);
19117
- const isVertical = isAngleVertical(angle);
19118
- const isX = orient === 'top' || orient === 'bottom';
19119
19328
  if (isX) {
19120
19329
  if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {
19121
19330
  return;
@@ -19124,7 +19333,6 @@ function autoLimit(labels, config) {
19124
19333
  return;
19125
19334
  }
19126
19335
  }
19127
- const direction = label.attribute.direction;
19128
19336
  if (!isX) {
19129
19337
  if (direction === 'vertical' && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {
19130
19338
  return;
@@ -19144,12 +19352,18 @@ function autoLimit(labels, config) {
19144
19352
  const { x1, x2 } = label.AABBBounds;
19145
19353
  const tan = sin / cos;
19146
19354
  const verticalSizeLimit = Math.abs(limitLength / sin);
19147
- if (tan > 0 && x1 <= axisLength && limitLength / tan + x1 > axisLength) {
19148
- const lengthLimit = (axisLength - x1) / Math.abs(cos) + overflowLimitLength.right;
19355
+ if (checkBox &&
19356
+ tan > 0 &&
19357
+ x1 <= axisLength + overflowLimitLength.right &&
19358
+ limitLength / tan + x1 > axisLength + overflowLimitLength.right) {
19359
+ const lengthLimit = (axisLength - x1 + overflowLimitLength.right) / Math.abs(cos);
19149
19360
  limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
19150
19361
  }
19151
- else if (tan < 0 && x2 >= 0 && limitLength / tan + x2 < 0) {
19152
- const lengthLimit = x2 / Math.abs(cos) + overflowLimitLength.left;
19362
+ else if (checkBox &&
19363
+ tan < 0 &&
19364
+ x2 >= -overflowLimitLength.left &&
19365
+ limitLength / tan + x2 < -overflowLimitLength.left) {
19366
+ const lengthLimit = (x2 + overflowLimitLength.left) / Math.abs(cos);
19153
19367
  limitLabelLength = Math.min(lengthLimit, verticalSizeLimit);
19154
19368
  }
19155
19369
  else {
@@ -19183,24 +19397,37 @@ function autoWrap(labels, config) {
19183
19397
  if (isEmpty(labels) || !isValidNumber(limitLength)) {
19184
19398
  return;
19185
19399
  }
19186
- const verticalLimitLength = axisLength / labels.length;
19187
- labels.forEach(label => {
19188
- var _a;
19189
- const angle = label.attribute.angle;
19190
- const isHorizontal = isAngleHorizontal(angle);
19191
- const isVertical = isAngleVertical(angle);
19192
- const isX = orient === 'top' || orient === 'bottom';
19400
+ const firstLabel = labels[0];
19401
+ const angle = firstLabel.attribute.angle;
19402
+ const isHorizontal = isAngleHorizontal(angle);
19403
+ const isVertical = isAngleVertical(angle);
19404
+ const isX = orient === 'top' || orient === 'bottom';
19405
+ let verticalLimitLength = axisLength / labels.length;
19406
+ labels.forEach((label, index) => {
19407
+ var _a, _b, _c, _d, _e;
19193
19408
  if (isX) {
19194
19409
  if (isVertical && Math.floor(label.AABBBounds.height()) <= limitLength) {
19195
19410
  return;
19196
19411
  }
19197
- if (isHorizontal && Math.floor(label.AABBBounds.width()) <= verticalLimitLength) {
19198
- return;
19412
+ if (isHorizontal) {
19413
+ const curLabelX = label.attribute.x;
19414
+ const nextLabelX = (_a = labels[index + 1]) === null || _a === void 0 ? void 0 : _a.attribute.x;
19415
+ const lastLabelX = (_b = labels[index - 1]) === null || _b === void 0 ? void 0 : _b.attribute.x;
19416
+ const minGap = getLabelMinGap(curLabelX, nextLabelX, lastLabelX);
19417
+ if (isValidNumber(minGap)) {
19418
+ verticalLimitLength = min(verticalLimitLength, minGap);
19419
+ }
19199
19420
  }
19200
19421
  }
19201
19422
  else {
19202
- if (isVertical && Math.floor(label.AABBBounds.height()) <= verticalLimitLength) {
19203
- return;
19423
+ if (isVertical) {
19424
+ const curLabelY = label.attribute.y;
19425
+ const nextLabelY = (_c = labels[index + 1]) === null || _c === void 0 ? void 0 : _c.attribute.y;
19426
+ const lastLabelY = (_d = labels[index - 1]) === null || _d === void 0 ? void 0 : _d.attribute.y;
19427
+ const minGap = getLabelMinGap(curLabelY, nextLabelY, lastLabelY);
19428
+ if (isValidNumber(minGap)) {
19429
+ verticalLimitLength = min(verticalLimitLength, minGap);
19430
+ }
19204
19431
  }
19205
19432
  if (isHorizontal && Math.floor(label.AABBBounds.width()) <= limitLength) {
19206
19433
  return;
@@ -19230,12 +19457,27 @@ function autoWrap(labels, config) {
19230
19457
  }
19231
19458
  label.setAttributes({
19232
19459
  maxLineWidth: limitLabelLength,
19233
- ellipsis: (_a = label.attribute.ellipsis) !== null && _a !== void 0 ? _a : ellipsis,
19460
+ ellipsis: (_e = label.attribute.ellipsis) !== null && _e !== void 0 ? _e : ellipsis,
19234
19461
  whiteSpace: 'normal',
19235
19462
  heightLimit
19236
19463
  });
19237
19464
  });
19238
19465
  }
19466
+ function getLabelMinGap(current, next, prev) {
19467
+ let minGap;
19468
+ if (isValidNumber(next)) {
19469
+ minGap = Math.abs(next - current);
19470
+ }
19471
+ if (isValidNumber(prev)) {
19472
+ if (isValidNumber(minGap)) {
19473
+ minGap = Math.min(Math.abs(current - prev), minGap);
19474
+ }
19475
+ else {
19476
+ minGap = Math.abs(current - prev);
19477
+ }
19478
+ }
19479
+ return minGap;
19480
+ }
19239
19481
 
19240
19482
  function alignAxisLabels(labels, start, containerSize, orient, align) {
19241
19483
  if (orient === 'left' || orient === 'right') {
@@ -20058,13 +20300,13 @@ class CircleAxis extends AxisBase {
20058
20300
  if (isEmpty(labelShapes)) {
20059
20301
  return;
20060
20302
  }
20061
- const { inside, radius, center, width, height, label, orient } = this.attribute;
20062
- const bounds = width && height
20303
+ const { inside, radius, center, size, label, orient } = this.attribute;
20304
+ const bounds = size
20063
20305
  ? {
20064
20306
  x1: 0,
20065
20307
  y1: 0,
20066
- x2: width,
20067
- y2: height
20308
+ x2: size.width,
20309
+ y2: size.height
20068
20310
  }
20069
20311
  : {
20070
20312
  x1: center.x - radius,
@@ -24172,10 +24414,10 @@ class LegendBase extends AbstractComponent {
24172
24414
  render() {
24173
24415
  this.removeAllChild(true);
24174
24416
  const { interactive = true, title, padding = 0 } = this.attribute;
24175
- const parsedPadding = normalizePadding(padding);
24417
+ this._parsedPadding = normalizePadding(padding);
24176
24418
  const innerView = graphicCreator.group({
24177
- x: parsedPadding[3],
24178
- y: parsedPadding[0],
24419
+ x: this._parsedPadding[3],
24420
+ y: this._parsedPadding[0],
24179
24421
  pickable: interactive,
24180
24422
  childrenPickable: interactive
24181
24423
  });
@@ -24191,8 +24433,8 @@ class LegendBase extends AbstractComponent {
24191
24433
  this._bindEvents();
24192
24434
  }
24193
24435
  const viewBounds = this._innerView.AABBBounds;
24194
- this.attribute.width = viewBounds.width() + parsedPadding[1] + parsedPadding[3];
24195
- this.attribute.height = viewBounds.height() + parsedPadding[0] + parsedPadding[2];
24436
+ this.attribute.width = viewBounds.width() + this._parsedPadding[1] + this._parsedPadding[3];
24437
+ this.attribute.height = viewBounds.height() + this._parsedPadding[0] + this._parsedPadding[2];
24196
24438
  }
24197
24439
  _renderTitle(title) {
24198
24440
  const { text = '', textStyle, padding = 0, background, minWidth, maxWidth, shape } = title;
@@ -24277,6 +24519,7 @@ class DiscreteLegend extends LegendBase {
24277
24519
  this._itemHeightByUser = undefined;
24278
24520
  this._itemHeight = 0;
24279
24521
  this._itemMaxWidth = 0;
24522
+ this._contentMaxHeight = 0;
24280
24523
  this._onHover = (e) => {
24281
24524
  const target = e.target;
24282
24525
  if (target && target.name && target.name.startsWith(LEGEND_ELEMENT_NAME.item)) {
@@ -24381,11 +24624,12 @@ class DiscreteLegend extends LegendBase {
24381
24624
  });
24382
24625
  }
24383
24626
  _renderItems() {
24384
- const { item: itemAttrs = {}, maxCol = 1, maxRow = 2, maxWidth, maxHeight, defaultSelected, lazyload, autoPage } = this.attribute;
24627
+ const { item: itemAttrs = {}, maxCol = 1, maxRow = 2, maxWidth, defaultSelected, lazyload, autoPage } = this.attribute;
24385
24628
  const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = itemAttrs;
24386
24629
  const itemsContainer = this._itemsContainer;
24387
24630
  const { items: legendItems, isHorizontal, startIndex, isScrollbar } = this._itemContext;
24388
24631
  const maxPages = isScrollbar ? 1 : isHorizontal ? maxRow : maxCol;
24632
+ const maxHeight = this._contentMaxHeight;
24389
24633
  let { doWrap, maxWidthInCol, startX, startY, pages } = this._itemContext;
24390
24634
  let item;
24391
24635
  let lastItemWidth = 0;
@@ -24482,7 +24726,7 @@ class DiscreteLegend extends LegendBase {
24482
24726
  return this._itemContext;
24483
24727
  }
24484
24728
  _renderContent() {
24485
- const { item = {}, items, reversed, maxWidth } = this.attribute;
24729
+ const { item = {}, items, reversed, maxWidth, maxHeight } = this.attribute;
24486
24730
  if (item.visible === false || isEmpty(items)) {
24487
24731
  return;
24488
24732
  }
@@ -24490,6 +24734,7 @@ class DiscreteLegend extends LegendBase {
24490
24734
  if (reversed) {
24491
24735
  legendItems = items === null || items === void 0 ? void 0 : items.reverse();
24492
24736
  }
24737
+ this._contentMaxHeight = Math.max(0, maxHeight - this._parsedPadding[0] - this._parsedPadding[2]);
24493
24738
  const itemsContainer = graphicCreator.group({
24494
24739
  x: 0,
24495
24740
  y: 0
@@ -24527,7 +24772,8 @@ class DiscreteLegend extends LegendBase {
24527
24772
  items: legendItems,
24528
24773
  isHorizontal,
24529
24774
  totalPage: Infinity,
24530
- isScrollbar: pager && pager.type === 'scrollbar'
24775
+ isScrollbar: pager && pager.type === 'scrollbar',
24776
+ clipContainer: undefined
24531
24777
  };
24532
24778
  this._itemContext = this._renderItems();
24533
24779
  let pagerRendered = false;
@@ -24548,11 +24794,21 @@ class DiscreteLegend extends LegendBase {
24548
24794
  }
24549
24795
  const { hover = true, select = true } = this.attribute;
24550
24796
  if (hover) {
24551
- this._itemsContainer.addEventListener('pointermove', this._onHover);
24552
- this._itemsContainer.addEventListener('pointerleave', this._onUnHover);
24797
+ let trigger = 'pointermove';
24798
+ let triggerOff = 'pointerleave';
24799
+ if (isObject(hover)) {
24800
+ hover.trigger && (trigger = hover.trigger);
24801
+ hover.triggerOff && (triggerOff = hover.triggerOff);
24802
+ }
24803
+ this._itemsContainer.addEventListener(trigger, this._onHover);
24804
+ this._itemsContainer.addEventListener(triggerOff, this._onUnHover);
24553
24805
  }
24554
24806
  if (select) {
24555
- this._itemsContainer.addEventListener('pointerdown', this._onClick);
24807
+ let trigger = 'pointerdown';
24808
+ if (isObject(select) && select.trigger) {
24809
+ trigger = select.trigger;
24810
+ }
24811
+ this._itemsContainer.addEventListener(trigger, this._onClick);
24556
24812
  }
24557
24813
  }
24558
24814
  _autoEllipsis(autoEllipsisStrategy, layoutWidth, labelShape, valueShape) {
@@ -24757,8 +25013,8 @@ class DiscreteLegend extends LegendBase {
24757
25013
  _createScrollbar(compStyle, compSize) {
24758
25014
  const { disableTriggerEvent } = this.attribute;
24759
25015
  return this._itemContext.isHorizontal
24760
- ? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: 12 }, compStyle), { width: compSize }))
24761
- : new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
25016
+ ? new ScrollBar(Object.assign(Object.assign({ direction: 'horizontal', disableTriggerEvent, range: [0, 0.5], height: compStyle.visible === false ? 0 : 12 }, compStyle), { width: compSize }))
25017
+ : new ScrollBar(Object.assign(Object.assign({ direction: 'vertical', width: compStyle.visible === false ? 0 : 12, range: [0, 0.5] }, compStyle), { height: compSize, disableTriggerEvent }));
24762
25018
  }
24763
25019
  _updatePositionOfPager(renderStartY, compWidth, compHeight) {
24764
25020
  const { pager } = this.attribute;
@@ -24798,9 +25054,26 @@ class DiscreteLegend extends LegendBase {
24798
25054
  });
24799
25055
  }
24800
25056
  }
25057
+ _computeScrollbarDelta() {
25058
+ const { isHorizontal, clipContainer } = this._itemContext;
25059
+ const itemContainerBounds = this._itemsContainer.AABBBounds;
25060
+ const clipContainerBounds = clipContainer.AABBBounds;
25061
+ let delta;
25062
+ let innerViewSize;
25063
+ if (isHorizontal) {
25064
+ innerViewSize = clipContainerBounds.width();
25065
+ delta = innerViewSize / itemContainerBounds.width();
25066
+ }
25067
+ else {
25068
+ innerViewSize = clipContainerBounds.height();
25069
+ delta = innerViewSize / itemContainerBounds.height();
25070
+ }
25071
+ return delta;
25072
+ }
24801
25073
  _updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY) {
24802
- const { currentPage, totalPage, isHorizontal } = this._itemContext;
24803
- this._pagerComponent.setScrollRange([(currentPage - 1) / totalPage, currentPage / totalPage]);
25074
+ const { isHorizontal, currentPage, totalPage } = this._itemContext;
25075
+ const start = (currentPage - 1) / totalPage;
25076
+ this._pagerComponent.setScrollRange([start, start + this._computeScrollbarDelta()]);
24804
25077
  if (isHorizontal) {
24805
25078
  this._pagerComponent.setAttributes({
24806
25079
  x: 0,
@@ -24828,13 +25101,7 @@ class DiscreteLegend extends LegendBase {
24828
25101
  newPage = this._itemContext.totalPage;
24829
25102
  }
24830
25103
  else {
24831
- newPage = value[0] * this._itemContext.totalPage;
24832
- if (pager.scrollByPosition) {
24833
- newPage = newPage + 1;
24834
- }
24835
- else {
24836
- newPage = Math.floor(newPage) + 1;
24837
- }
25104
+ newPage = value[0] * this._itemContext.totalPage + 1;
24838
25105
  }
24839
25106
  return newPage;
24840
25107
  }
@@ -24848,6 +25115,7 @@ class DiscreteLegend extends LegendBase {
24848
25115
  const { width, height } = scrollComponent.getSliderRenderBounds();
24849
25116
  const currentScrollValue = direction === 'vertical' ? e.deltaY / height : e.deltaX / width;
24850
25117
  scrollComponent.setScrollRange([preScrollRange[0] + currentScrollValue, preScrollRange[1] + currentScrollValue], true);
25118
+ this.updateScrollMask();
24851
25119
  };
24852
25120
  const onPaging = (e) => {
24853
25121
  const newPage = pageParser(e);
@@ -24859,15 +25127,39 @@ class DiscreteLegend extends LegendBase {
24859
25127
  this._renderItems();
24860
25128
  const newTotalPage = Math.ceil(this._itemContext.pages / this._itemContext.maxPages);
24861
25129
  this._itemContext.totalPage = newTotalPage;
24862
- this._pagerComponent.setScrollRange([(newPage - 1) / newTotalPage, newPage / newTotalPage]);
25130
+ if (this._itemContext.isScrollbar && this._pagerComponent) {
25131
+ const newDelta = this._computeScrollbarDelta();
25132
+ const [start] = this._pagerComponent.getScrollRange();
25133
+ this._pagerComponent.setScrollRange([start, start + newDelta]);
25134
+ }
24863
25135
  }
24864
- if (animation) {
24865
- this._itemsContainer
24866
- .animate()
24867
- .to({ [channel]: -(newPage - 1) * pageSize }, animationDuration, animationEasing);
25136
+ if (!this._itemContext.isScrollbar) {
25137
+ if (animation) {
25138
+ this._itemsContainer
25139
+ .animate()
25140
+ .to({ [channel]: -(newPage - 1) * pageSize }, animationDuration, animationEasing);
25141
+ }
25142
+ else {
25143
+ this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
25144
+ }
24868
25145
  }
24869
25146
  else {
24870
- this._itemsContainer.setAttribute(channel, -(newPage - 1) * pageSize);
25147
+ const [start] = this._pagerComponent.getScrollRange();
25148
+ let containerSize;
25149
+ if (this._itemContext.isHorizontal) {
25150
+ containerSize = this._itemsContainer.AABBBounds.width();
25151
+ }
25152
+ else {
25153
+ containerSize = this._itemsContainer.AABBBounds.height();
25154
+ }
25155
+ const startOffset = containerSize * start;
25156
+ this.updateScrollMask();
25157
+ if (animation) {
25158
+ this._itemsContainer.animate().to({ [channel]: -startOffset }, animationDuration, animationEasing);
25159
+ }
25160
+ else {
25161
+ this._itemsContainer.setAttribute(channel, -startOffset);
25162
+ }
24871
25163
  }
24872
25164
  };
24873
25165
  if (this._itemContext.isScrollbar) {
@@ -24886,11 +25178,12 @@ class DiscreteLegend extends LegendBase {
24886
25178
  }
24887
25179
  _renderPager() {
24888
25180
  const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', 8) : 0;
24889
- const { maxWidth, maxHeight, maxCol = 1, maxRow = 2, item = {}, pager = {} } = this.attribute;
25181
+ const { maxWidth, maxCol = 1, maxRow = 2, item = {}, pager = {} } = this.attribute;
24890
25182
  const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = item;
24891
25183
  const itemsContainer = this._itemsContainer;
24892
25184
  const { space: pagerSpace = DEFAULT_PAGER_SPACE, defaultCurrent = 1 } = pager, compStyle = __rest(pager, ["space", "defaultCurrent"]);
24893
25185
  const { isHorizontal } = this._itemContext;
25186
+ const maxHeight = this._contentMaxHeight;
24894
25187
  let comp;
24895
25188
  let compWidth = 0;
24896
25189
  let compHeight = 0;
@@ -24981,57 +25274,76 @@ class DiscreteLegend extends LegendBase {
24981
25274
  });
24982
25275
  clipGroup.add(itemsContainer);
24983
25276
  this._innerView.add(clipGroup);
25277
+ this._itemContext.clipContainer = clipGroup;
24984
25278
  this._bindEventsOfPager(isHorizontal ? compHeight + spaceRow : compWidth + spaceCol, isHorizontal ? 'y' : 'x');
24985
25279
  return true;
24986
25280
  }
24987
25281
  _renderScrollbar() {
25282
+ var _a;
24988
25283
  const renderStartY = this._title ? this._title.AABBBounds.height() + get(this.attribute, 'title.space', 8) : 0;
24989
- const { maxWidth, maxHeight, item = {}, pager = {} } = this.attribute;
25284
+ const { maxWidth, item = {}, pager = {} } = this.attribute;
24990
25285
  const { spaceCol = DEFAULT_ITEM_SPACE_COL, spaceRow = DEFAULT_ITEM_SPACE_ROW } = item;
24991
25286
  const itemsContainer = this._itemsContainer;
24992
25287
  const { space: pagerSpace = DEFAULT_PAGER_SPACE, defaultCurrent = 1 } = pager, compStyle = __rest(pager, ["space", "defaultCurrent"]);
24993
25288
  const { isHorizontal } = this._itemContext;
25289
+ const maxHeight = this._contentMaxHeight;
24994
25290
  let comp;
24995
- let compSize = 0;
24996
25291
  let contentWidth = 0;
24997
25292
  let contentHeight = 0;
24998
25293
  let startY = 0;
24999
25294
  let pages = 1;
25000
25295
  if (isHorizontal) {
25001
- compSize = maxWidth;
25002
25296
  contentWidth = maxWidth;
25003
25297
  contentHeight = this._itemHeight;
25004
- comp = this._createScrollbar(compStyle, compSize);
25298
+ comp = this._createScrollbar(compStyle, contentWidth);
25005
25299
  this._pagerComponent = comp;
25006
25300
  this._innerView.add(comp);
25007
- this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
25008
25301
  }
25009
25302
  else {
25010
- compSize = maxHeight;
25011
- comp = this._createScrollbar(compStyle, compSize);
25012
- this._pagerComponent = comp;
25013
- this._innerView.add(comp);
25014
25303
  contentHeight = maxHeight - renderStartY;
25015
25304
  contentWidth = this._itemMaxWidth;
25305
+ comp = this._createScrollbar(compStyle, contentHeight);
25306
+ this._pagerComponent = comp;
25307
+ this._innerView.add(comp);
25016
25308
  if (contentHeight <= 0) {
25017
25309
  this._innerView.removeChild(comp);
25018
25310
  return false;
25019
25311
  }
25020
- itemsContainer.getChildren().forEach((item, index) => {
25021
- const { height } = item.attribute;
25022
- pages = Math.floor((startY + height) / contentHeight) + 1;
25023
- startY += spaceRow + height;
25024
- });
25312
+ const items = itemsContainer.getChildren();
25313
+ const itemsHeightArr = items.map((item) => item.attribute.height);
25314
+ if (itemsHeightArr.length === 1 || itemsHeightArr.every(entry => entry === itemsHeightArr[0])) {
25315
+ const itemHeight = itemsHeightArr[0];
25316
+ const maxContentHeight = contentHeight;
25317
+ const pageItemsCount = Math.floor(maxContentHeight / (spaceRow + itemHeight));
25318
+ contentHeight = pageItemsCount * (spaceRow + itemHeight);
25319
+ pages = Math.ceil(items.length / pageItemsCount);
25320
+ }
25321
+ else {
25322
+ items.forEach((item, index) => {
25323
+ const { height } = item.attribute;
25324
+ const prePages = pages;
25325
+ const preStartY = startY;
25326
+ pages = Math.floor((startY + height) / contentHeight) + 1;
25327
+ startY += spaceRow + height;
25328
+ if (prePages !== pages &&
25329
+ index === itemsContainer.getChildren().length - 1 &&
25330
+ startY - contentHeight >= (1 / 3) * height) {
25331
+ contentHeight = preStartY + height;
25332
+ pages -= 1;
25333
+ }
25334
+ });
25335
+ }
25025
25336
  this._itemContext.totalPage = pages;
25026
25337
  this._itemContext.pages = pages;
25027
- this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
25028
25338
  }
25029
25339
  if (defaultCurrent > 1) {
25030
25340
  if (isHorizontal) {
25031
- itemsContainer.setAttribute('x', -(defaultCurrent - 1) * (contentWidth + spaceCol));
25341
+ const maxOffset = this._itemsContainer.AABBBounds.width() - contentWidth;
25342
+ itemsContainer.setAttribute('x', -Math.min((defaultCurrent - 1) * (contentWidth + spaceCol), maxOffset));
25032
25343
  }
25033
25344
  else {
25034
- itemsContainer.setAttribute('y', -(defaultCurrent - 1) * (contentHeight + spaceRow));
25345
+ const maxOffset = this._itemsContainer.AABBBounds.height() - contentHeight;
25346
+ itemsContainer.setAttribute('y', -Math.min((defaultCurrent - 1) * (contentHeight + spaceRow), maxOffset));
25035
25347
  }
25036
25348
  }
25037
25349
  const clipGroup = graphicCreator.group({
@@ -25044,9 +25356,89 @@ class DiscreteLegend extends LegendBase {
25044
25356
  });
25045
25357
  clipGroup.add(itemsContainer);
25046
25358
  this._innerView.add(clipGroup);
25359
+ this._itemContext.clipContainer = clipGroup;
25360
+ this._updatePositionOfScrollbar(contentWidth, contentHeight, renderStartY);
25361
+ if ((_a = pager.scrollMask) === null || _a === void 0 ? void 0 : _a.visible) {
25362
+ this.renderScrollMask(clipGroup);
25363
+ }
25047
25364
  this._bindEventsOfPager(isHorizontal ? contentWidth : contentHeight, isHorizontal ? 'x' : 'y');
25048
25365
  return true;
25049
25366
  }
25367
+ renderScrollMask(clipGroup) {
25368
+ const { scrollMask = {} } = this.attribute
25369
+ .pager;
25370
+ const { visible = true, gradientLength = 16, gradientStops } = scrollMask;
25371
+ if (!visible || !gradientStops) {
25372
+ return;
25373
+ }
25374
+ const width = clipGroup.AABBBounds.width();
25375
+ const height = clipGroup.AABBBounds.height();
25376
+ const totalLength = this._itemContext.isHorizontal ? width : height;
25377
+ const startStops = gradientStops.map(stop => {
25378
+ return {
25379
+ offset: (gradientLength * stop.offset) / totalLength,
25380
+ color: stop.color
25381
+ };
25382
+ });
25383
+ const endStops = gradientStops.map(stop => {
25384
+ return {
25385
+ offset: (totalLength - gradientLength * stop.offset) / totalLength,
25386
+ color: stop.color
25387
+ };
25388
+ });
25389
+ const mask = graphicCreator.rect({
25390
+ x: 0,
25391
+ y: 0,
25392
+ width,
25393
+ height
25394
+ });
25395
+ this._scrollMask = mask;
25396
+ this._scrollMaskContext = { startStops, endStops };
25397
+ this.updateScrollMask();
25398
+ clipGroup.add(mask);
25399
+ }
25400
+ updateScrollMask() {
25401
+ if (!this._scrollMask || !this._pagerComponent) {
25402
+ return;
25403
+ }
25404
+ if (!this._itemContext.isScrollbar) {
25405
+ return;
25406
+ }
25407
+ const [start, end] = this._pagerComponent.getScrollRange();
25408
+ const stops = [];
25409
+ if (!isNumberClose(clamp(end, 0, 1), 1)) {
25410
+ stops.push(...this._scrollMaskContext.endStops);
25411
+ }
25412
+ if (!isNumberClose(clamp(start, 0, 1), 0)) {
25413
+ stops.push(...this._scrollMaskContext.startStops);
25414
+ }
25415
+ if (stops.length) {
25416
+ if (this._itemContext.isHorizontal) {
25417
+ this._scrollMask.setAttributes({
25418
+ fill: {
25419
+ gradient: 'linear',
25420
+ x0: 0,
25421
+ y0: 0,
25422
+ x1: 1,
25423
+ y1: 0,
25424
+ stops
25425
+ }
25426
+ });
25427
+ }
25428
+ else {
25429
+ this._scrollMask.setAttributes({
25430
+ fill: {
25431
+ gradient: 'linear',
25432
+ x0: 0,
25433
+ y0: 0,
25434
+ x1: 0,
25435
+ y1: 1,
25436
+ stops
25437
+ }
25438
+ });
25439
+ }
25440
+ }
25441
+ }
25050
25442
  _renderPagerComponent() {
25051
25443
  if (this._itemContext.isScrollbar) {
25052
25444
  this._renderScrollbar();
@@ -29160,6 +29552,690 @@ EmptyTip.defaultAttributes = {
29160
29552
  }
29161
29553
  };
29162
29554
 
29163
- const version = "0.21.0-alpha.2";
29555
+ var lib$1 = {};
29556
+
29557
+ var gif = {};
29558
+
29559
+ var lib = {};
29560
+
29561
+ Object.defineProperty(lib, "__esModule", {
29562
+ value: true
29563
+ });
29564
+ lib.loop = lib.conditional = lib.parse = void 0;
29565
+ var parse = function parse(stream, schema) {
29566
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
29567
+ var parent = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : result;
29568
+ if (Array.isArray(schema)) {
29569
+ schema.forEach(function (partSchema) {
29570
+ return parse(stream, partSchema, result, parent);
29571
+ });
29572
+ } else if (typeof schema === 'function') {
29573
+ schema(stream, result, parent, parse);
29574
+ } else {
29575
+ var key = Object.keys(schema)[0];
29576
+ if (Array.isArray(schema[key])) {
29577
+ parent[key] = {};
29578
+ parse(stream, schema[key], result, parent[key]);
29579
+ } else {
29580
+ parent[key] = schema[key](stream, result, parent, parse);
29581
+ }
29582
+ }
29583
+ return result;
29584
+ };
29585
+ lib.parse = parse;
29586
+ var conditional = function conditional(schema, conditionFunc) {
29587
+ return function (stream, result, parent, parse) {
29588
+ if (conditionFunc(stream, result, parent)) {
29589
+ parse(stream, schema, result, parent);
29590
+ }
29591
+ };
29592
+ };
29593
+ lib.conditional = conditional;
29594
+ var loop = function loop(schema, continueFunc) {
29595
+ return function (stream, result, parent, parse) {
29596
+ var arr = [];
29597
+ var lastStreamPos = stream.pos;
29598
+ while (continueFunc(stream, result, parent)) {
29599
+ var newParent = {};
29600
+ 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
29601
+ // it falls into infinite recursion, null check to avoid the same
29602
+
29603
+ if (stream.pos === lastStreamPos) {
29604
+ break;
29605
+ }
29606
+ lastStreamPos = stream.pos;
29607
+ arr.push(newParent);
29608
+ }
29609
+ return arr;
29610
+ };
29611
+ };
29612
+ lib.loop = loop;
29613
+
29614
+ var uint8 = {};
29615
+
29616
+ Object.defineProperty(uint8, "__esModule", {
29617
+ value: true
29618
+ });
29619
+ uint8.readBits = uint8.readArray = uint8.readUnsigned = uint8.readString = uint8.peekBytes = uint8.readBytes = uint8.peekByte = uint8.readByte = uint8.buildStream = void 0;
29620
+
29621
+ // Default stream and parsers for Uint8TypedArray data type
29622
+ var buildStream = function buildStream(uint8Data) {
29623
+ return {
29624
+ data: uint8Data,
29625
+ pos: 0
29626
+ };
29627
+ };
29628
+ uint8.buildStream = buildStream;
29629
+ var readByte = function readByte() {
29630
+ return function (stream) {
29631
+ return stream.data[stream.pos++];
29632
+ };
29633
+ };
29634
+ uint8.readByte = readByte;
29635
+ var peekByte = function peekByte() {
29636
+ var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
29637
+ return function (stream) {
29638
+ return stream.data[stream.pos + offset];
29639
+ };
29640
+ };
29641
+ uint8.peekByte = peekByte;
29642
+ var readBytes = function readBytes(length) {
29643
+ return function (stream) {
29644
+ return stream.data.subarray(stream.pos, stream.pos += length);
29645
+ };
29646
+ };
29647
+ uint8.readBytes = readBytes;
29648
+ var peekBytes = function peekBytes(length) {
29649
+ return function (stream) {
29650
+ return stream.data.subarray(stream.pos, stream.pos + length);
29651
+ };
29652
+ };
29653
+ uint8.peekBytes = peekBytes;
29654
+ var readString = function readString(length) {
29655
+ return function (stream) {
29656
+ return Array.from(readBytes(length)(stream)).map(function (value) {
29657
+ return String.fromCharCode(value);
29658
+ }).join('');
29659
+ };
29660
+ };
29661
+ uint8.readString = readString;
29662
+ var readUnsigned = function readUnsigned(littleEndian) {
29663
+ return function (stream) {
29664
+ var bytes = readBytes(2)(stream);
29665
+ return littleEndian ? (bytes[1] << 8) + bytes[0] : (bytes[0] << 8) + bytes[1];
29666
+ };
29667
+ };
29668
+ uint8.readUnsigned = readUnsigned;
29669
+ var readArray = function readArray(byteSize, totalOrFunc) {
29670
+ return function (stream, result, parent) {
29671
+ var total = typeof totalOrFunc === 'function' ? totalOrFunc(stream, result, parent) : totalOrFunc;
29672
+ var parser = readBytes(byteSize);
29673
+ var arr = new Array(total);
29674
+ for (var i = 0; i < total; i++) {
29675
+ arr[i] = parser(stream);
29676
+ }
29677
+ return arr;
29678
+ };
29679
+ };
29680
+ uint8.readArray = readArray;
29681
+ var subBitsTotal = function subBitsTotal(bits, startIndex, length) {
29682
+ var result = 0;
29683
+ for (var i = 0; i < length; i++) {
29684
+ result += bits[startIndex + i] && Math.pow(2, length - i - 1);
29685
+ }
29686
+ return result;
29687
+ };
29688
+ var readBits = function readBits(schema) {
29689
+ return function (stream) {
29690
+ var _byte = readByte()(stream); // convert the byte to bit array
29691
+
29692
+ var bits = new Array(8);
29693
+ for (var i = 0; i < 8; i++) {
29694
+ bits[7 - i] = !!(_byte & 1 << i);
29695
+ } // convert the bit array to values based on the schema
29696
+
29697
+ return Object.keys(schema).reduce(function (res, key) {
29698
+ var def = schema[key];
29699
+ if (def.length) {
29700
+ res[key] = subBitsTotal(bits, def.index, def.length);
29701
+ } else {
29702
+ res[key] = bits[def.index];
29703
+ }
29704
+ return res;
29705
+ }, {});
29706
+ };
29707
+ };
29708
+ uint8.readBits = readBits;
29709
+
29710
+ (function (exports) {
29711
+
29712
+ Object.defineProperty(exports, "__esModule", {
29713
+ value: true
29714
+ });
29715
+ exports["default"] = void 0;
29716
+ var _ = lib;
29717
+ var _uint = uint8;
29718
+
29719
+ // a set of 0x00 terminated subblocks
29720
+ var subBlocksSchema = {
29721
+ blocks: function blocks(stream) {
29722
+ var terminator = 0x00;
29723
+ var chunks = [];
29724
+ var streamSize = stream.data.length;
29725
+ var total = 0;
29726
+ for (var size = (0, _uint.readByte)()(stream); size !== terminator; size = (0, _uint.readByte)()(stream)) {
29727
+ // size becomes undefined for some case when file is corrupted and terminator is not proper
29728
+ // null check to avoid recursion
29729
+ if (!size) break; // catch corrupted files with no terminator
29730
+
29731
+ if (stream.pos + size >= streamSize) {
29732
+ var availableSize = streamSize - stream.pos;
29733
+ chunks.push((0, _uint.readBytes)(availableSize)(stream));
29734
+ total += availableSize;
29735
+ break;
29736
+ }
29737
+ chunks.push((0, _uint.readBytes)(size)(stream));
29738
+ total += size;
29739
+ }
29740
+ var result = new Uint8Array(total);
29741
+ var offset = 0;
29742
+ for (var i = 0; i < chunks.length; i++) {
29743
+ result.set(chunks[i], offset);
29744
+ offset += chunks[i].length;
29745
+ }
29746
+ return result;
29747
+ }
29748
+ }; // global control extension
29749
+
29750
+ var gceSchema = (0, _.conditional)({
29751
+ gce: [{
29752
+ codes: (0, _uint.readBytes)(2)
29753
+ }, {
29754
+ byteSize: (0, _uint.readByte)()
29755
+ }, {
29756
+ extras: (0, _uint.readBits)({
29757
+ future: {
29758
+ index: 0,
29759
+ length: 3
29760
+ },
29761
+ disposal: {
29762
+ index: 3,
29763
+ length: 3
29764
+ },
29765
+ userInput: {
29766
+ index: 6
29767
+ },
29768
+ transparentColorGiven: {
29769
+ index: 7
29770
+ }
29771
+ })
29772
+ }, {
29773
+ delay: (0, _uint.readUnsigned)(true)
29774
+ }, {
29775
+ transparentColorIndex: (0, _uint.readByte)()
29776
+ }, {
29777
+ terminator: (0, _uint.readByte)()
29778
+ }]
29779
+ }, function (stream) {
29780
+ var codes = (0, _uint.peekBytes)(2)(stream);
29781
+ return codes[0] === 0x21 && codes[1] === 0xf9;
29782
+ }); // image pipeline block
29783
+
29784
+ var imageSchema = (0, _.conditional)({
29785
+ image: [{
29786
+ code: (0, _uint.readByte)()
29787
+ }, {
29788
+ descriptor: [{
29789
+ left: (0, _uint.readUnsigned)(true)
29790
+ }, {
29791
+ top: (0, _uint.readUnsigned)(true)
29792
+ }, {
29793
+ width: (0, _uint.readUnsigned)(true)
29794
+ }, {
29795
+ height: (0, _uint.readUnsigned)(true)
29796
+ }, {
29797
+ lct: (0, _uint.readBits)({
29798
+ exists: {
29799
+ index: 0
29800
+ },
29801
+ interlaced: {
29802
+ index: 1
29803
+ },
29804
+ sort: {
29805
+ index: 2
29806
+ },
29807
+ future: {
29808
+ index: 3,
29809
+ length: 2
29810
+ },
29811
+ size: {
29812
+ index: 5,
29813
+ length: 3
29814
+ }
29815
+ })
29816
+ }]
29817
+ }, (0, _.conditional)({
29818
+ lct: (0, _uint.readArray)(3, function (stream, result, parent) {
29819
+ return Math.pow(2, parent.descriptor.lct.size + 1);
29820
+ })
29821
+ }, function (stream, result, parent) {
29822
+ return parent.descriptor.lct.exists;
29823
+ }), {
29824
+ data: [{
29825
+ minCodeSize: (0, _uint.readByte)()
29826
+ }, subBlocksSchema]
29827
+ }]
29828
+ }, function (stream) {
29829
+ return (0, _uint.peekByte)()(stream) === 0x2c;
29830
+ }); // plain text block
29831
+
29832
+ var textSchema = (0, _.conditional)({
29833
+ text: [{
29834
+ codes: (0, _uint.readBytes)(2)
29835
+ }, {
29836
+ blockSize: (0, _uint.readByte)()
29837
+ }, {
29838
+ preData: function preData(stream, result, parent) {
29839
+ return (0, _uint.readBytes)(parent.text.blockSize)(stream);
29840
+ }
29841
+ }, subBlocksSchema]
29842
+ }, function (stream) {
29843
+ var codes = (0, _uint.peekBytes)(2)(stream);
29844
+ return codes[0] === 0x21 && codes[1] === 0x01;
29845
+ }); // application block
29846
+
29847
+ var applicationSchema = (0, _.conditional)({
29848
+ application: [{
29849
+ codes: (0, _uint.readBytes)(2)
29850
+ }, {
29851
+ blockSize: (0, _uint.readByte)()
29852
+ }, {
29853
+ id: function id(stream, result, parent) {
29854
+ return (0, _uint.readString)(parent.blockSize)(stream);
29855
+ }
29856
+ }, subBlocksSchema]
29857
+ }, function (stream) {
29858
+ var codes = (0, _uint.peekBytes)(2)(stream);
29859
+ return codes[0] === 0x21 && codes[1] === 0xff;
29860
+ }); // comment block
29861
+
29862
+ var commentSchema = (0, _.conditional)({
29863
+ comment: [{
29864
+ codes: (0, _uint.readBytes)(2)
29865
+ }, subBlocksSchema]
29866
+ }, function (stream) {
29867
+ var codes = (0, _uint.peekBytes)(2)(stream);
29868
+ return codes[0] === 0x21 && codes[1] === 0xfe;
29869
+ });
29870
+ var schema = [{
29871
+ header: [{
29872
+ signature: (0, _uint.readString)(3)
29873
+ }, {
29874
+ version: (0, _uint.readString)(3)
29875
+ }]
29876
+ }, {
29877
+ lsd: [{
29878
+ width: (0, _uint.readUnsigned)(true)
29879
+ }, {
29880
+ height: (0, _uint.readUnsigned)(true)
29881
+ }, {
29882
+ gct: (0, _uint.readBits)({
29883
+ exists: {
29884
+ index: 0
29885
+ },
29886
+ resolution: {
29887
+ index: 1,
29888
+ length: 3
29889
+ },
29890
+ sort: {
29891
+ index: 4
29892
+ },
29893
+ size: {
29894
+ index: 5,
29895
+ length: 3
29896
+ }
29897
+ })
29898
+ }, {
29899
+ backgroundColorIndex: (0, _uint.readByte)()
29900
+ }, {
29901
+ pixelAspectRatio: (0, _uint.readByte)()
29902
+ }]
29903
+ }, (0, _.conditional)({
29904
+ gct: (0, _uint.readArray)(3, function (stream, result) {
29905
+ return Math.pow(2, result.lsd.gct.size + 1);
29906
+ })
29907
+ }, function (stream, result) {
29908
+ return result.lsd.gct.exists;
29909
+ }),
29910
+ // content frames
29911
+ {
29912
+ frames: (0, _.loop)([gceSchema, applicationSchema, commentSchema, imageSchema, textSchema], function (stream) {
29913
+ var nextCode = (0, _uint.peekByte)()(stream); // rather than check for a terminator, we should check for the existence
29914
+ // of an ext or image block to avoid infinite loops
29915
+ //var terminator = 0x3B;
29916
+ //return nextCode !== terminator;
29917
+
29918
+ return nextCode === 0x21 || nextCode === 0x2c;
29919
+ })
29920
+ }];
29921
+ var _default = schema;
29922
+ exports["default"] = _default;
29923
+ })(gif);
29924
+
29925
+ var deinterlace$1 = {};
29926
+
29927
+ Object.defineProperty(deinterlace$1, "__esModule", {
29928
+ value: true
29929
+ });
29930
+ deinterlace$1.deinterlace = void 0;
29931
+
29932
+ /**
29933
+ * Deinterlace function from https://github.com/shachaf/jsgif
29934
+ */
29935
+ var deinterlace = function deinterlace(pixels, width) {
29936
+ var newPixels = new Array(pixels.length);
29937
+ var rows = pixels.length / width;
29938
+ var cpRow = function cpRow(toRow, fromRow) {
29939
+ var fromPixels = pixels.slice(fromRow * width, (fromRow + 1) * width);
29940
+ newPixels.splice.apply(newPixels, [toRow * width, width].concat(fromPixels));
29941
+ }; // See appendix E.
29942
+
29943
+ var offsets = [0, 4, 2, 1];
29944
+ var steps = [8, 8, 4, 2];
29945
+ var fromRow = 0;
29946
+ for (var pass = 0; pass < 4; pass++) {
29947
+ for (var toRow = offsets[pass]; toRow < rows; toRow += steps[pass]) {
29948
+ cpRow(toRow, fromRow);
29949
+ fromRow++;
29950
+ }
29951
+ }
29952
+ return newPixels;
29953
+ };
29954
+ deinterlace$1.deinterlace = deinterlace;
29955
+
29956
+ var lzw$1 = {};
29957
+
29958
+ Object.defineProperty(lzw$1, "__esModule", {
29959
+ value: true
29960
+ });
29961
+ lzw$1.lzw = void 0;
29962
+
29963
+ /**
29964
+ * javascript port of java LZW decompression
29965
+ * Original java author url: https://gist.github.com/devunwired/4479231
29966
+ */
29967
+ var lzw = function lzw(minCodeSize, data, pixelCount) {
29968
+ var MAX_STACK_SIZE = 4096;
29969
+ var nullCode = -1;
29970
+ var npix = pixelCount;
29971
+ var available, clear, code_mask, code_size, end_of_information, in_code, old_code, bits, code, i, datum, data_size, first, top, bi, pi;
29972
+ var dstPixels = new Array(pixelCount);
29973
+ var prefix = new Array(MAX_STACK_SIZE);
29974
+ var suffix = new Array(MAX_STACK_SIZE);
29975
+ var pixelStack = new Array(MAX_STACK_SIZE + 1); // Initialize GIF data stream decoder.
29976
+
29977
+ data_size = minCodeSize;
29978
+ clear = 1 << data_size;
29979
+ end_of_information = clear + 1;
29980
+ available = clear + 2;
29981
+ old_code = nullCode;
29982
+ code_size = data_size + 1;
29983
+ code_mask = (1 << code_size) - 1;
29984
+ for (code = 0; code < clear; code++) {
29985
+ prefix[code] = 0;
29986
+ suffix[code] = code;
29987
+ } // Decode GIF pixel stream.
29988
+
29989
+ var datum, bits, first, top, pi, bi;
29990
+ datum = bits = first = top = pi = bi = 0;
29991
+ for (i = 0; i < npix;) {
29992
+ if (top === 0) {
29993
+ if (bits < code_size) {
29994
+ // get the next byte
29995
+ datum += data[bi] << bits;
29996
+ bits += 8;
29997
+ bi++;
29998
+ continue;
29999
+ } // Get the next code.
30000
+
30001
+ code = datum & code_mask;
30002
+ datum >>= code_size;
30003
+ bits -= code_size; // Interpret the code
30004
+
30005
+ if (code > available || code == end_of_information) {
30006
+ break;
30007
+ }
30008
+ if (code == clear) {
30009
+ // Reset decoder.
30010
+ code_size = data_size + 1;
30011
+ code_mask = (1 << code_size) - 1;
30012
+ available = clear + 2;
30013
+ old_code = nullCode;
30014
+ continue;
30015
+ }
30016
+ if (old_code == nullCode) {
30017
+ pixelStack[top++] = suffix[code];
30018
+ old_code = code;
30019
+ first = code;
30020
+ continue;
30021
+ }
30022
+ in_code = code;
30023
+ if (code == available) {
30024
+ pixelStack[top++] = first;
30025
+ code = old_code;
30026
+ }
30027
+ while (code > clear) {
30028
+ pixelStack[top++] = suffix[code];
30029
+ code = prefix[code];
30030
+ }
30031
+ first = suffix[code] & 0xff;
30032
+ pixelStack[top++] = first; // add a new string to the table, but only if space is available
30033
+ // if not, just continue with current table until a clear code is found
30034
+ // (deferred clear code implementation as per GIF spec)
30035
+
30036
+ if (available < MAX_STACK_SIZE) {
30037
+ prefix[available] = old_code;
30038
+ suffix[available] = first;
30039
+ available++;
30040
+ if ((available & code_mask) === 0 && available < MAX_STACK_SIZE) {
30041
+ code_size++;
30042
+ code_mask += available;
30043
+ }
30044
+ }
30045
+ old_code = in_code;
30046
+ } // Pop a pixel off the pixel stack.
30047
+
30048
+ top--;
30049
+ dstPixels[pi++] = pixelStack[top];
30050
+ i++;
30051
+ }
30052
+ for (i = pi; i < npix; i++) {
30053
+ dstPixels[i] = 0; // clear missing pixels
30054
+ }
30055
+
30056
+ return dstPixels;
30057
+ };
30058
+ lzw$1.lzw = lzw;
30059
+
30060
+ Object.defineProperty(lib$1, "__esModule", {
30061
+ value: true
30062
+ });
30063
+ var decompressFrames_1 = lib$1.decompressFrames = lib$1.decompressFrame = parseGIF_1 = lib$1.parseGIF = void 0;
30064
+ var _gif = _interopRequireDefault(gif);
30065
+ var _jsBinarySchemaParser = lib;
30066
+ var _uint = uint8;
30067
+ var _deinterlace = deinterlace$1;
30068
+ var _lzw = lzw$1;
30069
+ function _interopRequireDefault(obj) {
30070
+ return obj && obj.__esModule ? obj : {
30071
+ "default": obj
30072
+ };
30073
+ }
30074
+ var parseGIF = function parseGIF(arrayBuffer) {
30075
+ var byteData = new Uint8Array(arrayBuffer);
30076
+ return (0, _jsBinarySchemaParser.parse)((0, _uint.buildStream)(byteData), _gif["default"]);
30077
+ };
30078
+ var parseGIF_1 = lib$1.parseGIF = parseGIF;
30079
+ var generatePatch = function generatePatch(image) {
30080
+ var totalPixels = image.pixels.length;
30081
+ var patchData = new Uint8ClampedArray(totalPixels * 4);
30082
+ for (var i = 0; i < totalPixels; i++) {
30083
+ var pos = i * 4;
30084
+ var colorIndex = image.pixels[i];
30085
+ var color = image.colorTable[colorIndex] || [0, 0, 0];
30086
+ patchData[pos] = color[0];
30087
+ patchData[pos + 1] = color[1];
30088
+ patchData[pos + 2] = color[2];
30089
+ patchData[pos + 3] = colorIndex !== image.transparentIndex ? 255 : 0;
30090
+ }
30091
+ return patchData;
30092
+ };
30093
+ var decompressFrame = function decompressFrame(frame, gct, buildImagePatch) {
30094
+ if (!frame.image) {
30095
+ console.warn('gif frame does not have associated image.');
30096
+ return;
30097
+ }
30098
+ var image = frame.image; // get the number of pixels
30099
+
30100
+ var totalPixels = image.descriptor.width * image.descriptor.height; // do lzw decompression
30101
+
30102
+ var pixels = (0, _lzw.lzw)(image.data.minCodeSize, image.data.blocks, totalPixels); // deal with interlacing if necessary
30103
+
30104
+ if (image.descriptor.lct.interlaced) {
30105
+ pixels = (0, _deinterlace.deinterlace)(pixels, image.descriptor.width);
30106
+ }
30107
+ var resultImage = {
30108
+ pixels: pixels,
30109
+ dims: {
30110
+ top: frame.image.descriptor.top,
30111
+ left: frame.image.descriptor.left,
30112
+ width: frame.image.descriptor.width,
30113
+ height: frame.image.descriptor.height
30114
+ }
30115
+ }; // color table
30116
+
30117
+ if (image.descriptor.lct && image.descriptor.lct.exists) {
30118
+ resultImage.colorTable = image.lct;
30119
+ } else {
30120
+ resultImage.colorTable = gct;
30121
+ } // add per frame relevant gce information
30122
+
30123
+ if (frame.gce) {
30124
+ resultImage.delay = (frame.gce.delay || 10) * 10; // convert to ms
30125
+
30126
+ resultImage.disposalType = frame.gce.extras.disposal; // transparency
30127
+
30128
+ if (frame.gce.extras.transparentColorGiven) {
30129
+ resultImage.transparentIndex = frame.gce.transparentColorIndex;
30130
+ }
30131
+ } // create canvas usable imagedata if desired
30132
+
30133
+ if (buildImagePatch) {
30134
+ resultImage.patch = generatePatch(resultImage);
30135
+ }
30136
+ return resultImage;
30137
+ };
30138
+ lib$1.decompressFrame = decompressFrame;
30139
+ var decompressFrames = function decompressFrames(parsedGif, buildImagePatches) {
30140
+ return parsedGif.frames.filter(function (f) {
30141
+ return f.image;
30142
+ }).map(function (f) {
30143
+ return decompressFrame(f, parsedGif.gct, buildImagePatches);
30144
+ });
30145
+ };
30146
+ decompressFrames_1 = lib$1.decompressFrames = decompressFrames;
30147
+
30148
+ class GifImage extends Image {
30149
+ constructor(params) {
30150
+ super(params);
30151
+ this.isGifImage = true;
30152
+ this.loadGif();
30153
+ }
30154
+ loadGif() {
30155
+ if (isString(this.attribute.gifImage)) {
30156
+ ResourceLoader.GetFile(this.attribute.gifImage, 'arrayBuffer')
30157
+ .then((res) => {
30158
+ const gif = parseGIF_1(res);
30159
+ const frames = decompressFrames_1(gif, true);
30160
+ this.renderGIF(frames);
30161
+ })
30162
+ .catch(e => {
30163
+ console.error('Gif load error: ', e);
30164
+ });
30165
+ }
30166
+ else if (this.attribute.gifImage instanceof ArrayBuffer) {
30167
+ const gif = parseGIF_1(this.attribute.gifImage);
30168
+ const frames = decompressFrames_1(gif, true);
30169
+ this.renderGIF(frames);
30170
+ }
30171
+ }
30172
+ renderGIF(frames) {
30173
+ this.loadedFrames = frames;
30174
+ this.frameIndex = 0;
30175
+ if (!this.tempCanvas) {
30176
+ this.tempCanvas = application.global.createCanvas({});
30177
+ this.tempCtx = this.tempCanvas.getContext('2d');
30178
+ }
30179
+ if (!this.gifCanvas) {
30180
+ this.gifCanvas = application.global.createCanvas({});
30181
+ this.gifCtx = this.gifCanvas.getContext('2d');
30182
+ }
30183
+ this.gifCanvas.width = frames[0].dims.width;
30184
+ this.gifCanvas.height = frames[0].dims.height;
30185
+ this.playing = true;
30186
+ this.lastTime = new Date().getTime();
30187
+ const animation = this.animate();
30188
+ if (this.attribute.timeline) {
30189
+ animation.setTimeline(this.attribute.timeline);
30190
+ }
30191
+ animation.to({}, 1000, 'linear').loop(Infinity);
30192
+ }
30193
+ renderFrame(context, x, y) {
30194
+ const frame = this.loadedFrames[this.frameIndex || 0];
30195
+ if (frame.disposalType === 2) {
30196
+ this.gifCtx.clearRect(0, 0, this.gifCanvas.width, this.gifCanvas.height);
30197
+ }
30198
+ this.drawPatch(frame);
30199
+ this.manipulate(context, x, y);
30200
+ const diff = new Date().getTime() - this.lastTime;
30201
+ if (frame.delay < diff) {
30202
+ this.frameIndex++;
30203
+ this.lastTime = new Date().getTime();
30204
+ }
30205
+ if (this.frameIndex >= this.loadedFrames.length) {
30206
+ this.frameIndex = 0;
30207
+ }
30208
+ }
30209
+ drawPatch(frame) {
30210
+ const dims = frame.dims;
30211
+ if (!this.frameImageData ||
30212
+ dims.width !== this.frameImageData.width ||
30213
+ dims.height !== this.frameImageData.height) {
30214
+ this.tempCanvas.width = dims.width;
30215
+ this.tempCanvas.height = dims.height;
30216
+ this.frameImageData = this.tempCtx.createImageData(dims.width, dims.height);
30217
+ }
30218
+ this.frameImageData.data.set(frame.patch);
30219
+ this.tempCtx.putImageData(this.frameImageData, 0, 0);
30220
+ this.gifCtx.drawImage(this.tempCanvas, dims.left, dims.top);
30221
+ }
30222
+ manipulate(context, x, y) {
30223
+ context.drawImage(this.gifCanvas, 0, 0, this.gifCanvas.width, this.gifCanvas.height, x, y, this.attribute.width, this.attribute.height);
30224
+ }
30225
+ setAttribute(key, value, forceUpdateTag, context) {
30226
+ super.setAttribute(key, value, forceUpdateTag, context);
30227
+ if (key === 'gifImage') {
30228
+ this.loadGif();
30229
+ }
30230
+ }
30231
+ setAttributes(params, forceUpdateTag, context) {
30232
+ super.setAttributes(params, forceUpdateTag, context);
30233
+ if (params.gifImage) {
30234
+ this.loadGif();
30235
+ }
30236
+ }
30237
+ }
30238
+
30239
+ const version = "0.21.0-alpha.4";
29164
30240
 
29165
- 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, measureTextSize, normalize, polarAngleAxisDiscreteTicks, polarTicks, reactAttributeTransform, registerArcDataLabel, registerLineDataLabel, registerMarkArcAreaAnimate, registerMarkArcLineAnimate, registerMarkAreaAnimate, registerMarkLineAnimate, registerMarkPointAnimate, registerRectDataLabel, registerSymbolDataLabel, removeRepeatPoint, richTextAttributeTransform, scale, setPoptipTheme, smartInvertStrategy, tan2AngleToAngle, textIntersect, ticks, traverseGroup, version };
30241
+ 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 };