@visactor/vrender-core 1.1.11-alpha.1 → 1.1.12

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 (76) hide show
  1. package/cjs/canvas/conical-gradient.js +1 -1
  2. package/cjs/canvas/constants.js +1 -1
  3. package/cjs/canvas/empty-context.js +1 -1
  4. package/cjs/canvas/index.js +1 -1
  5. package/cjs/canvas/util.js +1 -1
  6. package/cjs/common/area-cache.d.ts +11 -0
  7. package/cjs/common/area-cache.js +115 -0
  8. package/cjs/common/area-cache.js.map +1 -0
  9. package/cjs/common/bounds-context.js +2 -1
  10. package/cjs/common/contribution-store-state.js +1 -2
  11. package/cjs/common/generator.d.ts +0 -1
  12. package/cjs/common/generator.js +13 -2
  13. package/cjs/common/generator.js.map +1 -1
  14. package/cjs/common/performance-raf.js +2 -1
  15. package/cjs/common/render-command-list.js +1 -2
  16. package/cjs/common/render-curve.d.ts +3 -0
  17. package/cjs/common/render-curve.js +16 -17
  18. package/cjs/common/render-curve.js.map +1 -1
  19. package/cjs/common/simplify.js +1 -1
  20. package/cjs/common/sort.js +1 -1
  21. package/cjs/common/split-path.js +1 -1
  22. package/cjs/common/text.js +1 -1
  23. package/cjs/graphic/area.js +3 -3
  24. package/cjs/graphic/area.js.map +1 -1
  25. package/cjs/graphic/graphic.js +1 -0
  26. package/cjs/graphic/graphic.js.map +1 -1
  27. package/cjs/graphic/line.js +4 -4
  28. package/cjs/graphic/line.js.map +1 -1
  29. package/cjs/graphic/text.js +17 -7
  30. package/cjs/graphic/text.js.map +1 -1
  31. package/cjs/graphic/wrap-text.js +4 -2
  32. package/cjs/graphic/wrap-text.js.map +1 -1
  33. package/cjs/render/contributions/render/area-render.js +18 -92
  34. package/cjs/render/contributions/render/area-render.js.map +1 -1
  35. package/cjs/render/contributions/render/incremental-area-render.d.ts +5 -1
  36. package/cjs/render/contributions/render/incremental-area-render.js +29 -7
  37. package/cjs/render/contributions/render/incremental-area-render.js.map +1 -1
  38. package/dist/index.es.js +233 -161
  39. package/es/canvas/conical-gradient.js +1 -1
  40. package/es/canvas/constants.js +1 -1
  41. package/es/canvas/empty-context.js +1 -1
  42. package/es/canvas/index.js +1 -1
  43. package/es/canvas/util.js +1 -1
  44. package/es/common/area-cache.d.ts +11 -0
  45. package/es/common/area-cache.js +113 -0
  46. package/es/common/area-cache.js.map +1 -0
  47. package/es/common/bounds-context.js +2 -1
  48. package/es/common/contribution-store-state.js +1 -2
  49. package/es/common/generator.d.ts +0 -1
  50. package/es/common/generator.js +12 -3
  51. package/es/common/generator.js.map +1 -1
  52. package/es/common/performance-raf.js +2 -1
  53. package/es/common/render-command-list.js +1 -2
  54. package/es/common/render-curve.d.ts +3 -0
  55. package/es/common/render-curve.js +15 -16
  56. package/es/common/render-curve.js.map +1 -1
  57. package/es/common/simplify.js +1 -1
  58. package/es/common/sort.js +1 -1
  59. package/es/common/split-path.js +1 -1
  60. package/es/common/text.js +1 -1
  61. package/es/graphic/area.js +3 -3
  62. package/es/graphic/area.js.map +1 -1
  63. package/es/graphic/graphic.js +1 -0
  64. package/es/graphic/graphic.js.map +1 -1
  65. package/es/graphic/line.js +4 -4
  66. package/es/graphic/line.js.map +1 -1
  67. package/es/graphic/text.js +17 -7
  68. package/es/graphic/text.js.map +1 -1
  69. package/es/graphic/wrap-text.js +4 -2
  70. package/es/graphic/wrap-text.js.map +1 -1
  71. package/es/render/contributions/render/area-render.js +18 -92
  72. package/es/render/contributions/render/area-render.js.map +1 -1
  73. package/es/render/contributions/render/incremental-area-render.d.ts +5 -1
  74. package/es/render/contributions/render/incremental-area-render.js +28 -6
  75. package/es/render/contributions/render/incremental-area-render.js.map +1 -1
  76. package/package.json +2 -1
package/dist/index.es.js CHANGED
@@ -133,12 +133,17 @@ class SyncHook extends Hook {
133
133
  }
134
134
  }
135
135
 
136
+ const GENERATOR_STATE_SYMBOL = Symbol.for('@visactor/vrender-core/generator-state');
137
+ function getGeneratorState() {
138
+ const scope = globalThis;
139
+ return scope[GENERATOR_STATE_SYMBOL] || (scope[GENERATOR_STATE_SYMBOL] = { autoIncrementId: 0 });
140
+ }
141
+ const generatorState = getGeneratorState();
136
142
  class Generator {
137
143
  static GenAutoIncrementId() {
138
- return Generator.auto_increment_id++;
144
+ return generatorState.autoIncrementId++;
139
145
  }
140
146
  }
141
- Generator.auto_increment_id = 0;
142
147
 
143
148
  class Application {
144
149
  }
@@ -11020,6 +11025,7 @@ class Graphic extends Node {
11020
11025
  this.commitBaseAttributeBySingleKey(key, value, !!forceUpdateTag, context);
11021
11026
  }
11022
11027
  else {
11028
+ this.detachAttributeFromBaseAttributes();
11023
11029
  const nextAttrs = { [key]: value };
11024
11030
  this.applyBaseAttributes(nextAttrs);
11025
11031
  this.commitBaseAttributeMutation(!!forceUpdateTag, context);
@@ -12752,6 +12758,8 @@ const TEXT_UPDATE_TAG_KEY = [
12752
12758
  'fontSize',
12753
12759
  'fontFamily',
12754
12760
  'fontWeight',
12761
+ 'fontStyle',
12762
+ 'fontVariant',
12755
12763
  'ellipsis',
12756
12764
  'lineHeight',
12757
12765
  'direction',
@@ -12921,7 +12929,7 @@ class Text extends Graphic {
12921
12929
  var _a, _b;
12922
12930
  const textTheme = this.getGraphicTheme();
12923
12931
  const attribute = this.attribute;
12924
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, wrap = textTheme.wrap, measureMode = textTheme.measureMode, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace, suffixPosition = textTheme.suffixPosition, ignoreBuf = textTheme.ignoreBuf, keepCenterInLine = textTheme.keepCenterInLine } = attribute;
12932
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontStyle = textTheme.fontStyle, fontVariant = textTheme.fontVariant, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, wrap = textTheme.wrap, measureMode = textTheme.measureMode, lineWidth = textTheme.lineWidth, whiteSpace = textTheme.whiteSpace, suffixPosition = textTheme.suffixPosition, ignoreBuf = textTheme.ignoreBuf, keepCenterInLine = textTheme.keepCenterInLine } = attribute;
12925
12933
  const buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize);
12926
12934
  const lineHeight = this.getLineHeight(attribute, textTheme, buf);
12927
12935
  if (whiteSpace === 'normal' || wrap) {
@@ -12936,7 +12944,7 @@ class Text extends Graphic {
12936
12944
  return this._AABBBounds;
12937
12945
  }
12938
12946
  const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || ((_b = this.stage) === null || _b === void 0 ? void 0 : _b.textMeasureId));
12939
- const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily, lineHeight }, textMeasure);
12947
+ const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily, fontStyle, fontVariant, lineHeight }, textMeasure);
12940
12948
  const layoutData = layoutObj.GetLayoutByLines(text, textAlign, textBaseline, lineHeight, ellipsis === true ? textTheme.ellipsis : ellipsis || undefined, false, {
12941
12949
  lineWidth: maxLineWidth,
12942
12950
  suffixPosition,
@@ -12955,7 +12963,7 @@ class Text extends Graphic {
12955
12963
  updateWrapAABBBounds(text) {
12956
12964
  var _a, _b, _c, _d;
12957
12965
  const textTheme = this.getGraphicTheme();
12958
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, measureMode = textTheme.measureMode, suffixPosition = textTheme.suffixPosition, heightLimit = 0, lineClamp, keepCenterInLine = textTheme.keepCenterInLine } = this.attribute;
12966
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, fontStyle = textTheme.fontStyle, fontVariant = textTheme.fontVariant, ignoreBuf = textTheme.ignoreBuf, measureMode = textTheme.measureMode, suffixPosition = textTheme.suffixPosition, heightLimit = 0, lineClamp, keepCenterInLine = textTheme.keepCenterInLine } = this.attribute;
12959
12967
  const buf = ignoreBuf ? 0 : this.guessLineHeightBuf(fontSize);
12960
12968
  const lineHeight = this.getLineHeight(this.attribute, textTheme, buf);
12961
12969
  if (!this.shouldUpdateShape() && ((_a = this.cache) === null || _a === void 0 ? void 0 : _a.layoutData)) {
@@ -12967,7 +12975,7 @@ class Text extends Graphic {
12967
12975
  return this._AABBBounds;
12968
12976
  }
12969
12977
  const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || ((_b = this.stage) === null || _b === void 0 ? void 0 : _b.textMeasureId));
12970
- const textOptions = { fontSize, fontWeight, fontFamily, lineHeight };
12978
+ const textOptions = { fontSize, fontWeight, fontFamily, fontStyle, fontVariant, lineHeight };
12971
12979
  const layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure);
12972
12980
  const lines = isArray(text) ? text.map(l => l.toString()) : [text.toString()];
12973
12981
  const linesLayout = [];
@@ -13087,7 +13095,7 @@ class Text extends Graphic {
13087
13095
  const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || ((_a = this.stage) === null || _a === void 0 ? void 0 : _a.textMeasureId));
13088
13096
  let width;
13089
13097
  const attribute = this.attribute;
13090
- const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode, suffixPosition = textTheme.suffixPosition } = attribute;
13098
+ const { maxLineWidth = textTheme.maxLineWidth, ellipsis = textTheme.ellipsis, fontFamily = textTheme.fontFamily, fontSize = textTheme.fontSize, fontWeight = textTheme.fontWeight, fontStyle = textTheme.fontStyle, fontVariant = textTheme.fontVariant, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, verticalMode = textTheme.verticalMode, suffixPosition = textTheme.suffixPosition } = attribute;
13091
13099
  const lineHeight = this.getLineHeight(attribute, textTheme, 0);
13092
13100
  let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;
13093
13101
  if (!verticalMode) {
@@ -13117,12 +13125,12 @@ class Text extends Graphic {
13117
13125
  if (Number.isFinite(maxLineWidth)) {
13118
13126
  if (ellipsis) {
13119
13127
  const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis);
13120
- const data = textMeasure.clipTextWithSuffixVertical(verticalData, { fontSize, fontWeight, fontFamily }, maxLineWidth, strEllipsis, false, suffixPosition);
13128
+ const data = textMeasure.clipTextWithSuffixVertical(verticalData, { fontSize, fontWeight, fontFamily, fontStyle, fontVariant }, maxLineWidth, strEllipsis, false, suffixPosition);
13121
13129
  verticalLists[i] = data.verticalList;
13122
13130
  width = data.width;
13123
13131
  }
13124
13132
  else {
13125
- const data = textMeasure.clipTextVertical(verticalData, { fontSize, fontWeight, fontFamily }, maxLineWidth, false);
13133
+ const data = textMeasure.clipTextVertical(verticalData, { fontSize, fontWeight, fontFamily, fontStyle, fontVariant }, maxLineWidth, false);
13126
13134
  verticalLists[i] = data.verticalList;
13127
13135
  width = data.width;
13128
13136
  }
@@ -13132,7 +13140,7 @@ class Text extends Graphic {
13132
13140
  verticalData.forEach(t => {
13133
13141
  const w = t.direction === TextDirection.HORIZONTAL
13134
13142
  ? fontSize
13135
- : textMeasure.measureTextWidth(t.text, { fontSize, fontWeight, fontFamily });
13143
+ : textMeasure.measureTextWidth(t.text, { fontSize, fontWeight, fontFamily, fontStyle, fontVariant });
13136
13144
  width += w;
13137
13145
  t.width = w;
13138
13146
  });
@@ -13217,7 +13225,7 @@ class WrapText extends Text {
13217
13225
  updateMultilineAABBBounds(text) {
13218
13226
  var _a, _b, _c, _d, _e;
13219
13227
  const textTheme = this.getGraphicTheme();
13220
- const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, suffixPosition = textTheme.suffixPosition, lineClamp } = this.attribute;
13228
+ const { fontFamily = textTheme.fontFamily, textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline, fontSize = textTheme.fontSize, ellipsis = textTheme.ellipsis, maxLineWidth, stroke = textTheme.stroke, lineWidth = textTheme.lineWidth, wordBreak = textTheme.wordBreak, fontWeight = textTheme.fontWeight, fontStyle = textTheme.fontStyle, fontVariant = textTheme.fontVariant, ignoreBuf = textTheme.ignoreBuf, heightLimit = 0, suffixPosition = textTheme.suffixPosition, lineClamp } = this.attribute;
13221
13229
  const lineHeight = (_a = calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize)) !== null && _a !== void 0 ? _a : (this.attribute.fontSize || textTheme.fontSize);
13222
13230
  const buf = ignoreBuf ? 0 : 2;
13223
13231
  if (!this.shouldUpdateShape() && ((_b = this.cache) === null || _b === void 0 ? void 0 : _b.layoutData)) {
@@ -13229,7 +13237,7 @@ class WrapText extends Text {
13229
13237
  return this._AABBBounds;
13230
13238
  }
13231
13239
  const textMeasure = application.graphicUtil.getTextMeasureInstance(this.textMeasureId || ((_c = this.stage) === null || _c === void 0 ? void 0 : _c.textMeasureId));
13232
- const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);
13240
+ const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily, fontStyle, fontVariant }, textMeasure);
13233
13241
  const lines = text.map(l => l.toString());
13234
13242
  const linesLayout = [];
13235
13243
  const bboxWH = [0, 0];
@@ -13538,21 +13546,21 @@ let Line$1 = class Line extends Graphic {
13538
13546
  return aabbBounds;
13539
13547
  }
13540
13548
  updateLineAABBBoundsByPoints(attribute, lineTheme, aabbBounds, graphic) {
13541
- const { points = lineTheme.points, connectedType } = attribute;
13549
+ const { points = lineTheme.points } = attribute;
13542
13550
  const b = aabbBounds;
13543
13551
  points.forEach(p => {
13544
- if (p.defined !== false || connectedType === 'connect') {
13552
+ if (p.defined !== false) {
13545
13553
  b.add(p.x, p.y);
13546
13554
  }
13547
13555
  });
13548
13556
  return b;
13549
13557
  }
13550
13558
  updateLineAABBBoundsBySegments(attribute, lineTheme, aabbBounds, graphic) {
13551
- const { segments = lineTheme.segments, connectedType } = attribute;
13559
+ const { segments = lineTheme.segments } = attribute;
13552
13560
  const b = aabbBounds;
13553
13561
  segments.forEach(s => {
13554
13562
  s.points.forEach(p => {
13555
- if (p.defined !== false || connectedType === 'connect') {
13563
+ if (p.defined !== false) {
13556
13564
  b.add(p.x, p.y);
13557
13565
  }
13558
13566
  });
@@ -15905,7 +15913,14 @@ function createPath(attributes) {
15905
15913
  return new Path(attributes);
15906
15914
  }
15907
15915
 
15908
- const AREA_UPDATE_TAG_KEY = ['segments', 'points', 'curveType', 'curveTension', ...GRAPHIC_UPDATE_TAG_KEY];
15916
+ const AREA_UPDATE_TAG_KEY = [
15917
+ 'segments',
15918
+ 'points',
15919
+ 'curveType',
15920
+ 'curveTension',
15921
+ 'connectedType',
15922
+ ...GRAPHIC_UPDATE_TAG_KEY
15923
+ ];
15909
15924
  class Area extends Graphic {
15910
15925
  constructor(params) {
15911
15926
  super(params);
@@ -15954,6 +15969,9 @@ class Area extends Graphic {
15954
15969
  const b = aabbBounds;
15955
15970
  points.forEach(p => {
15956
15971
  var _a, _b;
15972
+ if (p.defined === false) {
15973
+ return;
15974
+ }
15957
15975
  b.add(p.x, p.y);
15958
15976
  b.add((_a = p.x1) !== null && _a !== void 0 ? _a : p.x, (_b = p.y1) !== null && _b !== void 0 ? _b : p.y);
15959
15977
  });
@@ -15965,6 +15983,9 @@ class Area extends Graphic {
15965
15983
  segments.forEach(s => {
15966
15984
  s.points.forEach(p => {
15967
15985
  var _a, _b;
15986
+ if (p.defined === false) {
15987
+ return;
15988
+ }
15968
15989
  b.add(p.x, p.y);
15969
15990
  b.add((_a = p.x1) !== null && _a !== void 0 ? _a : p.x, (_b = p.y1) !== null && _b !== void 0 ? _b : p.y);
15970
15991
  });
@@ -24877,6 +24898,142 @@ function drawSegItem(ctx, curve, endPercent, params) {
24877
24898
  }
24878
24899
  }
24879
24900
 
24901
+ function getAreaPointRuns(points, connectedType, startPoint) {
24902
+ const runs = [];
24903
+ if (!points.some(p => p.defined === false)) {
24904
+ const run = startPoint ? [startPoint, ...points] : points;
24905
+ if (run.length) {
24906
+ runs.push(run);
24907
+ }
24908
+ return { runs, tail: run[run.length - 1] };
24909
+ }
24910
+ let run = startPoint ? [startPoint] : [];
24911
+ for (let i = 0; i < points.length; i++) {
24912
+ const point = points[i];
24913
+ if (point.defined !== false) {
24914
+ run.push(point);
24915
+ }
24916
+ else if (connectedType !== 'connect') {
24917
+ if (run.length) {
24918
+ runs.push(run);
24919
+ }
24920
+ run = [];
24921
+ }
24922
+ }
24923
+ if (run.length) {
24924
+ runs.push(run);
24925
+ }
24926
+ return { runs, tail: run[run.length - 1] };
24927
+ }
24928
+ function joinAreaPaths(paths) {
24929
+ var _a;
24930
+ if (paths.length === 1) {
24931
+ return paths[0];
24932
+ }
24933
+ const curves = [];
24934
+ for (let i = 0; i < paths.length; i++) {
24935
+ const next = paths[i].curves;
24936
+ if (curves.length) {
24937
+ const previous = curves[curves.length - 1];
24938
+ const gap = new LineCurve((_a = previous.p3) !== null && _a !== void 0 ? _a : previous.p1, next[0].p0);
24939
+ gap.defined = false;
24940
+ gap.originP1 = previous.originP2;
24941
+ gap.originP2 = next[0].originP1;
24942
+ curves.push(gap);
24943
+ }
24944
+ for (let j = 0; j < next.length; j++) {
24945
+ curves.push(next[j]);
24946
+ }
24947
+ }
24948
+ const path = paths[paths.length - 1];
24949
+ path.curves = curves;
24950
+ path.length = NaN;
24951
+ return path;
24952
+ }
24953
+ function compileAreaRuns(runs, curveType, curveTension, sourceSegmentIndex, topStart, bottomStart) {
24954
+ var _a, _b, _c, _d;
24955
+ const tops = [];
24956
+ const bottoms = [];
24957
+ const bottomType = curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType;
24958
+ for (let i = 0; i < runs.length; i++) {
24959
+ const points = runs[i];
24960
+ const startPoint = i === 0 ? topStart : undefined;
24961
+ if (points.length < 2 - Number(!!startPoint)) {
24962
+ continue;
24963
+ }
24964
+ const bottomPoints = [];
24965
+ for (let j = points.length - 1; j >= 0; j--) {
24966
+ const p = points[j];
24967
+ bottomPoints.push({ x: (_a = p.x1) !== null && _a !== void 0 ? _a : p.x, y: (_b = p.y1) !== null && _b !== void 0 ? _b : p.y });
24968
+ }
24969
+ if (i === 0 && bottomStart) {
24970
+ bottomPoints.push({ x: (_c = bottomStart.x1) !== null && _c !== void 0 ? _c : bottomStart.x, y: (_d = bottomStart.y1) !== null && _d !== void 0 ? _d : bottomStart.y });
24971
+ }
24972
+ const top = calcLineCache(points, curveType, { startPoint, curveTension });
24973
+ const bottom = calcLineCache(bottomPoints, bottomType, { curveTension });
24974
+ if ((top === null || top === void 0 ? void 0 : top.curves.length) && (bottom === null || bottom === void 0 ? void 0 : bottom.curves.length)) {
24975
+ tops.push(top);
24976
+ bottoms.push(bottom);
24977
+ }
24978
+ }
24979
+ if (!tops.length) {
24980
+ return null;
24981
+ }
24982
+ return {
24983
+ top: joinAreaPaths(tops),
24984
+ bottom: joinAreaPaths(bottoms.reverse()),
24985
+ sourceSegmentIndex,
24986
+ direction: Direction.ROW
24987
+ };
24988
+ }
24989
+ function calcAreaCache(points, segments, curveType, connectedType, curveTension) {
24990
+ var _a;
24991
+ const caches = [];
24992
+ let tail;
24993
+ let topTail;
24994
+ let first;
24995
+ let last;
24996
+ const count = segments ? segments.length : 1;
24997
+ for (let i = 0; i < count; i++) {
24998
+ const segmentPoints = segments ? segments[i].points : points !== null && points !== void 0 ? points : [];
24999
+ const result = getAreaPointRuns(segmentPoints, connectedType);
25000
+ const canContinue = connectedType === 'connect' || ((_a = segmentPoints[0]) === null || _a === void 0 ? void 0 : _a.defined) !== false;
25001
+ if (result.runs.length) {
25002
+ first = first !== null && first !== void 0 ? first : result.runs[0][0];
25003
+ const lastRun = result.runs[result.runs.length - 1];
25004
+ last = lastRun[lastRun.length - 1];
25005
+ }
25006
+ const cache = compileAreaRuns(result.runs, curveType, curveTension, i, canContinue ? topTail : undefined, canContinue ? tail : undefined);
25007
+ if (cache) {
25008
+ caches.push(cache);
25009
+ }
25010
+ if (result.tail) {
25011
+ tail = result.tail;
25012
+ const lastRun = result.runs[result.runs.length - 1];
25013
+ topTail =
25014
+ cache && (result.runs.length === 1 || lastRun.length > 1) ? { x: cache.top.endX, y: cache.top.endY } : tail;
25015
+ }
25016
+ else if (connectedType !== 'connect' && segmentPoints.length) {
25017
+ tail = topTail = undefined;
25018
+ }
25019
+ }
25020
+ if (!caches.length) {
25021
+ return null;
25022
+ }
25023
+ let direction = Direction.ROW;
25024
+ if (last.x1 != null) {
25025
+ const dx = abs(last.x - first.x);
25026
+ const dy = abs(last.y - first.y);
25027
+ if (last.y1 == null || (Number.isFinite(dx + dy) && dy >= dx)) {
25028
+ direction = Direction.COLUMN;
25029
+ }
25030
+ }
25031
+ for (let i = 0; i < caches.length; i++) {
25032
+ caches[i].direction = direction;
25033
+ }
25034
+ return segments ? caches : caches[0];
25035
+ }
25036
+
24880
25037
  function drawEachCurve(path, curve, lastCurve, defined0, offsetX, offsetY, offsetZ) {
24881
25038
  var _a;
24882
25039
  let p0 = curve.p0;
@@ -25012,31 +25169,27 @@ function drawIncrementalSegments(path, lastSeg, segments, params) {
25012
25169
  });
25013
25170
  }
25014
25171
  function drawIncrementalAreaSegments(path, lastSeg, segments, params) {
25015
- const { offsetX = 0, offsetY = 0 } = params || {};
25016
- const { points } = segments;
25017
- const definedPointsList = [];
25018
- for (let i = 0; i < points.length; i++) {
25019
- if (points[i].defined === false) ;
25020
- }
25021
- definedPointsList.push(points);
25022
- definedPointsList.forEach((points, i) => {
25023
- var _a, _b, _c, _d;
25024
- const startP = lastSeg && i === 0 ? lastSeg.points[lastSeg.points.length - 1] : points[0];
25025
- path.moveTo(startP.x + offsetX, startP.y + offsetY);
25026
- points.forEach(p => {
25027
- if (p.defined === false) {
25028
- path.moveTo(p.x + offsetX, p.y + offsetY);
25029
- return;
25030
- }
25031
- path.lineTo(p.x + offsetX, p.y + offsetY);
25032
- });
25033
- for (let i = points.length - 1; i >= 0; i--) {
25034
- const p = points[i];
25172
+ var _a, _b;
25173
+ const { offsetX = 0, offsetY = 0, connectedType = 'none' } = params || {};
25174
+ const startPoint = params && 'startPoint' in params
25175
+ ? params.startPoint
25176
+ : lastSeg && getAreaPointRuns(lastSeg.points, connectedType).tail;
25177
+ const { runs } = getAreaPointRuns(segments.points, connectedType, startPoint);
25178
+ for (let i = 0; i < runs.length; i++) {
25179
+ const points = runs[i];
25180
+ if (points.length < 2) {
25181
+ continue;
25182
+ }
25183
+ path.moveTo(points[0].x + offsetX, points[0].y + offsetY);
25184
+ for (let j = 1; j < points.length; j++) {
25185
+ path.lineTo(points[j].x + offsetX, points[j].y + offsetY);
25186
+ }
25187
+ for (let j = points.length - 1; j >= 0; j--) {
25188
+ const p = points[j];
25035
25189
  path.lineTo((_a = p.x1) !== null && _a !== void 0 ? _a : p.x, (_b = p.y1) !== null && _b !== void 0 ? _b : p.y);
25036
25190
  }
25037
- path.lineTo((_c = startP.x1) !== null && _c !== void 0 ? _c : startP.x, (_d = startP.y1) !== null && _d !== void 0 ? _d : startP.y);
25038
25191
  path.closePath();
25039
- });
25192
+ }
25040
25193
  }
25041
25194
 
25042
25195
  class DefaultCanvasLineRender extends BaseRender {
@@ -25465,7 +25618,6 @@ class DefaultCanvasAreaRender extends BaseRender {
25465
25618
  _runStroke();
25466
25619
  }
25467
25620
  drawShape(area, context, x, y, drawContext, params, fillCb, strokeCb) {
25468
- var _a, _b, _c, _d, _e, _f;
25469
25621
  const areaAttribute = getTheme(area, params === null || params === void 0 ? void 0 : params.theme).area;
25470
25622
  const { fill = areaAttribute.fill, stroke = areaAttribute.stroke, fillOpacity = areaAttribute.fillOpacity, z = areaAttribute.z, strokeOpacity = areaAttribute.strokeOpacity, curveTension = areaAttribute.curveTension, connectedType = areaAttribute.connectedType } = area.attribute;
25471
25623
  const data = this.valid(area, areaAttribute, fillCb, strokeCb);
@@ -25479,104 +25631,24 @@ class DefaultCanvasAreaRender extends BaseRender {
25479
25631
  if (closePath && curveType === 'linear') {
25480
25632
  curveType = 'linearClosed';
25481
25633
  }
25482
- function parsePoint(points, connectedType) {
25483
- if (connectedType !== 'connect') {
25484
- return points;
25485
- }
25486
- return points.filter(p => p.defined !== false);
25487
- }
25488
25634
  if (clipRange === 1 && !segments && !points.some(p => p.defined === false) && curveType === 'linear') {
25489
25635
  return this.drawLinearAreaHighPerformance(area, context, !!fill, doStroke, fillOpacity, strokeOpacity, x, y, areaAttribute, drawContext, params, fillCb, strokeCb);
25490
25636
  }
25491
25637
  if (area.shouldUpdateShape()) {
25492
- if (segments && segments.length) {
25493
- let startPoint;
25494
- let lastTopSeg;
25495
- const topCaches = segments
25496
- .map((seg, index) => {
25497
- if (seg.points.length <= 1) {
25498
- if (index === 0) {
25499
- seg.points[0] && (lastTopSeg = { endX: seg.points[0].x, endY: seg.points[0].y });
25500
- return null;
25501
- }
25502
- }
25503
- if (index === 1) {
25504
- startPoint = { x: lastTopSeg.endX, y: lastTopSeg.endY };
25505
- }
25506
- else if (index > 1) {
25507
- startPoint.x = lastTopSeg.endX;
25508
- startPoint.y = lastTopSeg.endY;
25509
- }
25510
- const data = calcLineCache(parsePoint(seg.points, connectedType), curveType, {
25511
- startPoint,
25512
- curveTension
25513
- });
25514
- lastTopSeg = data;
25515
- return data;
25516
- })
25517
- .filter(item => !!item);
25518
- let lastBottomSeg;
25519
- const bottomCaches = [];
25520
- for (let i = segments.length - 1; i >= 0; i--) {
25521
- const points = segments[i].points;
25522
- const bottomPoints = [];
25523
- for (let i = points.length - 1; i >= 0; i--) {
25524
- bottomPoints.push({
25525
- x: (_a = points[i].x1) !== null && _a !== void 0 ? _a : points[i].x,
25526
- y: (_b = points[i].y1) !== null && _b !== void 0 ? _b : points[i].y
25527
- });
25528
- }
25529
- if (i !== 0) {
25530
- const lastSegmentPoints = segments[i - 1].points;
25531
- const endPoint = lastSegmentPoints[lastSegmentPoints.length - 1];
25532
- endPoint &&
25533
- bottomPoints.push({
25534
- x: (_c = endPoint.x1) !== null && _c !== void 0 ? _c : endPoint.x,
25535
- y: (_d = endPoint.y1) !== null && _d !== void 0 ? _d : endPoint.y
25536
- });
25537
- }
25538
- if (bottomPoints.length > 1) {
25539
- lastBottomSeg = calcLineCache(parsePoint(bottomPoints, connectedType), curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType, { curveTension });
25540
- bottomCaches.unshift(lastBottomSeg);
25541
- }
25542
- }
25543
- area.cacheArea = bottomCaches.map((item, index) => ({
25544
- top: topCaches[index],
25545
- bottom: item
25546
- }));
25547
- }
25548
- else if (points && points.length) {
25549
- const topPoints = parsePoint(points, connectedType);
25550
- const bottomPoints = [];
25551
- for (let i = topPoints.length - 1; i >= 0; i--) {
25552
- bottomPoints.push({
25553
- x: (_e = topPoints[i].x1) !== null && _e !== void 0 ? _e : topPoints[i].x,
25554
- y: (_f = topPoints[i].y1) !== null && _f !== void 0 ? _f : topPoints[i].y
25555
- });
25556
- }
25557
- const topCache = calcLineCache(topPoints, curveType, { curveTension });
25558
- const bottomCache = calcLineCache(bottomPoints, curveType === 'stepBefore' ? 'stepAfter' : curveType === 'stepAfter' ? 'stepBefore' : curveType, { curveTension });
25559
- area.cacheArea = { top: topCache, bottom: bottomCache };
25560
- }
25561
- else {
25562
- area.cacheArea = null;
25563
- area.clearUpdateShapeTag();
25564
- return;
25565
- }
25638
+ area.cacheArea = calcAreaCache(points, segments, curveType, connectedType, curveTension);
25566
25639
  area.clearUpdateShapeTag();
25567
25640
  }
25641
+ if (!area.cacheArea) {
25642
+ return;
25643
+ }
25568
25644
  if (Array.isArray(area.cacheArea)) {
25569
- const segments = area.attribute.segments.filter(item => item.points.length);
25570
- if (segments[0].points.length === 1) {
25571
- segments.shift();
25572
- }
25573
25645
  if (clipRange === 1) {
25574
25646
  let skip = false;
25575
- area.cacheArea.forEach((cache, index) => {
25647
+ area.cacheArea.forEach(cache => {
25576
25648
  if (skip) {
25577
25649
  return;
25578
25650
  }
25579
- skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[index], [areaAttribute, area.attribute], clipRange, x, y, z, area, drawContext, fillCb, strokeCb);
25651
+ skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[cache.sourceSegmentIndex], [areaAttribute, area.attribute], clipRange, x, y, z, area, drawContext, fillCb, strokeCb);
25580
25652
  });
25581
25653
  }
25582
25654
  else {
@@ -25584,7 +25656,7 @@ class DefaultCanvasAreaRender extends BaseRender {
25584
25656
  const totalDrawLength = clipRange * totalLength;
25585
25657
  let drawedLengthUntilLast = 0;
25586
25658
  let skip = false;
25587
- area.cacheArea.forEach((cache, index) => {
25659
+ area.cacheArea.forEach(cache => {
25588
25660
  if (skip) {
25589
25661
  return;
25590
25662
  }
@@ -25592,7 +25664,7 @@ class DefaultCanvasAreaRender extends BaseRender {
25592
25664
  const _cr = (totalDrawLength - drawedLengthUntilLast) / curSegLength;
25593
25665
  drawedLengthUntilLast += curSegLength;
25594
25666
  if (_cr > 0) {
25595
- skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[index], [areaAttribute, area.attribute], min(_cr, 1), x, y, z, area, drawContext, fillCb, strokeCb);
25667
+ skip = this.drawSegmentItem(context, cache, doFill, fillOpacity, doStroke, strokeOpacity, segments[cache.sourceSegmentIndex], [areaAttribute, area.attribute], min(_cr, 1), x, y, z, area, drawContext, fillCb, strokeCb);
25596
25668
  }
25597
25669
  });
25598
25670
  }
@@ -25609,6 +25681,7 @@ class DefaultCanvasAreaRender extends BaseRender {
25609
25681
  return this._drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb);
25610
25682
  }
25611
25683
  _drawSegmentItem(context, cache, fill, fillOpacity, stroke, strokeOpacity, attribute, defaultAttribute, clipRange, offsetX, offsetY, offsetZ, area, drawContext, fillCb, strokeCb) {
25684
+ var _a;
25612
25685
  if (!(cache &&
25613
25686
  cache.top &&
25614
25687
  cache.bottom &&
@@ -25620,34 +25693,7 @@ class DefaultCanvasAreaRender extends BaseRender {
25620
25693
  }
25621
25694
  context.beginPath();
25622
25695
  const ret = false;
25623
- const { points, segments } = area.attribute;
25624
- let direction = Direction.ROW;
25625
- let endP;
25626
- let startP;
25627
- if (segments) {
25628
- const endSeg = segments[segments.length - 1];
25629
- const startSeg = segments[0];
25630
- startP = startSeg.points[0];
25631
- endP = endSeg.points[endSeg.points.length - 1];
25632
- }
25633
- else {
25634
- startP = points[0];
25635
- endP = points[points.length - 1];
25636
- }
25637
- const xTotalLength = abs(endP.x - startP.x);
25638
- const yTotalLength = abs(endP.y - startP.y);
25639
- if (endP.x1 == null) {
25640
- direction = Direction.ROW;
25641
- }
25642
- else if (endP.y1 == null) {
25643
- direction = Direction.COLUMN;
25644
- }
25645
- else if (!Number.isFinite(xTotalLength + yTotalLength)) {
25646
- direction = Direction.ROW;
25647
- }
25648
- else {
25649
- direction = xTotalLength > yTotalLength ? Direction.ROW : Direction.COLUMN;
25650
- }
25696
+ const direction = (_a = cache.direction) !== null && _a !== void 0 ? _a : cache.top.direction;
25651
25697
  drawAreaSegments(context, cache, clipRange, {
25652
25698
  offsetX,
25653
25699
  offsetY,
@@ -27288,6 +27334,21 @@ function createMiniappApp(options = {}) {
27288
27334
  return new MiniappEntry(options);
27289
27335
  }
27290
27336
 
27337
+ function previousPoint(segments, index, connectedType) {
27338
+ for (let i = index - 1; i >= 0; i--) {
27339
+ const points = segments[i].points;
27340
+ for (let j = points.length - 1; j >= 0; j--) {
27341
+ const point = points[j];
27342
+ if (point.defined !== false) {
27343
+ return point;
27344
+ }
27345
+ if (connectedType !== 'connect') {
27346
+ return undefined;
27347
+ }
27348
+ }
27349
+ }
27350
+ return undefined;
27351
+ }
27291
27352
  class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender {
27292
27353
  constructor() {
27293
27354
  super(...arguments);
@@ -27301,7 +27362,7 @@ class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender {
27301
27362
  return;
27302
27363
  }
27303
27364
  const areaAttribute = getTheme(area).area;
27304
- const { fill = areaAttribute.fill, fillOpacity = areaAttribute.fillOpacity, opacity = areaAttribute.opacity, visible = areaAttribute.visible } = area.attribute;
27365
+ const { fill = areaAttribute.fill, fillOpacity = areaAttribute.fillOpacity, opacity = areaAttribute.opacity, visible = areaAttribute.visible, connectedType = areaAttribute.connectedType } = area.attribute;
27305
27366
  const fVisible = fillVisible(opacity, fillOpacity, fill);
27306
27367
  const doFill = runFill(fill);
27307
27368
  if (!(area.valid && visible)) {
@@ -27313,22 +27374,33 @@ class DefaultIncrementalCanvasAreaRender extends DefaultCanvasAreaRender {
27313
27374
  if (!(fVisible || fillCb)) {
27314
27375
  return;
27315
27376
  }
27316
- for (let i = startAtIdx; i < startAtIdx + length; i++) {
27317
- this.drawIncreaseSegment(area, context, segments[i - 1], segments[i], area.attribute.segments[i], [areaAttribute, area.attribute], x, y);
27377
+ const endIndex = Math.min(startAtIdx + length, segments.length);
27378
+ for (let i = startAtIdx; i < endIndex; i++) {
27379
+ if (!segments[i].points.some(p => p.defined !== false)) {
27380
+ continue;
27381
+ }
27382
+ this.drawIncreaseSegment(area, context, segments[i - 1], segments[i], area.attribute.segments[i], [areaAttribute, area.attribute], x, y, { connectedType, startPoint: previousPoint(segments, i, connectedType) });
27318
27383
  }
27319
27384
  }
27320
27385
  else {
27321
27386
  super.drawShape(area, context, x, y, drawContext, params, fillCb);
27322
27387
  }
27323
27388
  }
27324
- drawIncreaseSegment(area, context, lastSeg, seg, attribute, defaultAttribute, offsetX, offsetY) {
27389
+ drawIncreaseSegment(area, context, lastSeg, seg, attribute, defaultAttribute, offsetX, offsetY, continuity) {
27390
+ var _a, _b;
27325
27391
  if (!seg) {
27326
27392
  return;
27327
27393
  }
27394
+ const connectedType = (_b = (_a = continuity === null || continuity === void 0 ? void 0 : continuity.connectedType) !== null && _a !== void 0 ? _a : area.attribute.connectedType) !== null && _b !== void 0 ? _b : getTheme(area).area.connectedType;
27395
+ const startPoint = continuity
27396
+ ? continuity.startPoint
27397
+ : lastSeg && getAreaPointRuns(lastSeg.points, connectedType).tail;
27328
27398
  context.beginPath();
27329
27399
  drawIncrementalAreaSegments(context.camera ? context : context.nativeContext, lastSeg, seg, {
27330
27400
  offsetX,
27331
- offsetY
27401
+ offsetY,
27402
+ connectedType,
27403
+ startPoint
27332
27404
  });
27333
27405
  context.setShadowBlendStyle && context.setShadowBlendStyle(area, attribute, defaultAttribute);
27334
27406
  context.setCommonStyle(area, attribute, offsetX, offsetY, defaultAttribute);
@@ -123,4 +123,4 @@ export function createConicalGradient(context, stops, x, y, deltaAngle, startAng
123
123
  pattern && ConicalPatternStore.Set(stops, x, y, startAngle, endAngle, pattern, width, height),
124
124
  pattern;
125
125
  }
126
- //# sourceMappingURL=conical-gradient.js.map
126
+ //# sourceMappingURL=conical-gradient.js.map
@@ -1,4 +1,4 @@
1
1
  export const CanvasFactory = Symbol.for("CanvasFactory");
2
2
 
3
3
  export const Context2dFactory = Symbol.for("Context2dFactory");
4
- //# sourceMappingURL=constants.js.map
4
+ //# sourceMappingURL=constants.js.map
@@ -206,4 +206,4 @@ export class EmptyContext2d {
206
206
  this.stack.forEach((m => matrixAllocate.free(m))), this.stack.length = 0;
207
207
  }
208
208
  }
209
- //# sourceMappingURL=empty-context.js.map
209
+ //# sourceMappingURL=empty-context.js.map
@@ -5,4 +5,4 @@ export * from "./empty-context";
5
5
  export * from "./contributions/base-canvas";
6
6
 
7
7
  export * from "./conical-gradient";
8
- //# sourceMappingURL=index.js.map
8
+ //# sourceMappingURL=index.js.map
package/es/canvas/util.js CHANGED
@@ -382,4 +382,4 @@ export function contain(commands, x, y) {
382
382
  export function containStroke(commands, lineWidth, x, y) {
383
383
  return containPath(commands, lineWidth, !0, x, y);
384
384
  }
385
- //# sourceMappingURL=util.js.map
385
+ //# sourceMappingURL=util.js.map