@leafer-game/miniapp 2.2.9 → 2.2.10

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.
@@ -7046,7 +7046,7 @@ class LeafLevelList {
7046
7046
  }
7047
7047
  }
7048
7048
 
7049
- const version = "2.2.9";
7049
+ const version = "2.2.10";
7050
7050
 
7051
7051
  class LeaferCanvas extends LeaferCanvasBase {
7052
7052
  get allowBackgroundColor() {
@@ -8750,7 +8750,7 @@ let UI = UI_1 = class UI extends Leaf {
8750
8750
  getPath(curve, pathForRender) {
8751
8751
  this.__layout.update();
8752
8752
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
8753
- if (!path) pen.set(path = []), this.__drawPathByBox(pen, !pathForRender);
8753
+ if (!path) pen.set(path = []), this.__drawPathByBox(pen, "box", !pathForRender);
8754
8754
  return curve ? PathConvert.toCanvasData(path, true) : path;
8755
8755
  }
8756
8756
  getPathString(curve, pathForRender, floatLength) {
@@ -8788,10 +8788,10 @@ let UI = UI_1 = class UI extends Leaf {
8788
8788
  data.__usePointsMode ? PathDrawer.drawPathByPoints(canvas, data.points, data.closed) : this.__drawPathByData(canvas, data.path, true);
8789
8789
  }
8790
8790
  __drawPathByData(drawer, data, ignoreCornerRadius) {
8791
- data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, ignoreCornerRadius);
8791
+ data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer, "box", ignoreCornerRadius);
8792
8792
  }
8793
- __drawPathByBox(drawer, ignoreCornerRadius) {
8794
- const {x: x, y: y, width: width, height: height} = this.__layout.boxBounds;
8793
+ __drawPathByBox(drawer, boundsType = "box", ignoreCornerRadius) {
8794
+ const {x: x, y: y, width: width, height: height} = this.__layout[boundsType + "Bounds"];
8795
8795
  if (this.__.cornerRadius && !ignoreCornerRadius) {
8796
8796
  const {cornerRadius: cornerRadius} = this.__;
8797
8797
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
@@ -9873,14 +9873,15 @@ let Text = class Text extends UI {
9873
9873
  }
9874
9874
  __updateTextDrawData() {
9875
9875
  const data = this.__;
9876
- const {lineHeight: lineHeight, letterSpacing: letterSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
9876
+ const {lineHeight: lineHeight, letterSpacing: letterSpacing, wordSpacing: wordSpacing, fontFamily: fontFamily, fontSize: fontSize, fontWeight: fontWeight, italic: italic, textCase: textCase, textOverflow: textOverflow, padding: padding, width: width, height: height} = data;
9877
9877
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
9878
9878
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
9879
+ data.__wordSpacing = UnitConvert.number(wordSpacing, fontSize);
9879
9880
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * .7) / 2;
9880
9881
  data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
9881
9882
  stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
9882
9883
  stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
9883
- stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
9884
+ stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.__wordSpacing || data.motionText || textCase !== "none");
9884
9885
  data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
9885
9886
  }
9886
9887
  __updateBoxBounds() {
@@ -9978,6 +9979,8 @@ __decorate([ boundsType("none") ], Text.prototype, "textDecoration", void 0);
9978
9979
 
9979
9980
  __decorate([ boundsType(0) ], Text.prototype, "letterSpacing", void 0);
9980
9981
 
9982
+ __decorate([ boundsType(0) ], Text.prototype, "wordSpacing", void 0);
9983
+
9981
9984
  __decorate([ boundsType({
9982
9985
  type: "percent",
9983
9986
  value: 1.5
@@ -11720,7 +11723,7 @@ function fills(fills, ui, canvas, renderOptions) {
11720
11723
  if (scaleX !== 1) canvas.scale(scaleX, scaleY);
11721
11724
  }
11722
11725
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
11723
- fillPathOrText(ui, canvas, renderOptions);
11726
+ fillPathOrText(ui, canvas, renderOptions, true);
11724
11727
  canvas.restore();
11725
11728
  } else {
11726
11729
  if (originPaint.blendMode) {
@@ -11732,25 +11735,46 @@ function fills(fills, ui, canvas, renderOptions) {
11732
11735
  }
11733
11736
  }
11734
11737
 
11735
- function fillPathOrText(ui, canvas, renderOptions) {
11736
- ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11738
+ function fillPathOrText(ui, canvas, renderOptions, complexPaint) {
11739
+ ui.__.__font ? Paint.fillText(ui, canvas, renderOptions, complexPaint) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
11737
11740
  }
11738
11741
 
11739
- function fillText(ui, canvas, renderOptions) {
11740
- if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
11741
- const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
11742
+ function fillText(ui, canvas, renderOptions, complexPaint) {
11743
+ const data = ui.__;
11742
11744
  if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
11743
- let row;
11744
- for (let i = 0, len = rows.length; i < len; i++) {
11745
- row = rows[i];
11746
- if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
11747
- canvas.fillText(charData.char, charData.x, row.y);
11748
- });
11745
+ let originCanvas;
11746
+ if (complexPaint) {
11747
+ originCanvas = canvas;
11748
+ canvas = canvas.getSameCanvas(true, true);
11749
+ canvas.font = ui.__.__font;
11750
+ canvas.fillStyle = "#000";
11751
+ }
11752
+ if (ui.motionText) {
11753
+ Paint.fillMotionText(ui, canvas, renderOptions);
11754
+ } else {
11755
+ let row;
11756
+ const {rows: rows, decorationY: decorationY} = data.__textDrawData;
11757
+ for (let i = 0, len = rows.length; i < len; i++) {
11758
+ row = rows[i];
11759
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
11760
+ canvas.fillText(charData.char, charData.x, row.y);
11761
+ });
11762
+ }
11763
+ if (decorationY) {
11764
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
11765
+ if (decorationColor) canvas.fillStyle = decorationColor;
11766
+ rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
11767
+ }
11749
11768
  }
11750
- if (decorationY) {
11751
- const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
11752
- if (decorationColor) canvas.fillStyle = decorationColor;
11753
- rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
11769
+ if (complexPaint) {
11770
+ canvas.beginPath();
11771
+ ui.__drawPathByBox(canvas, "render");
11772
+ canvas.fillStyle = originCanvas.fillStyle;
11773
+ canvas.setTransform(originCanvas.getTransform());
11774
+ canvas.blendMode = "source-in";
11775
+ canvas.fill();
11776
+ originCanvas.copyWorldByReset(canvas, ui.__nowWorld);
11777
+ canvas.recycle(ui.__nowWorld);
11754
11778
  }
11755
11779
  }
11756
11780
 
@@ -12870,9 +12894,9 @@ const symbolChar = afterChar + "_#~&*+\\=|" + langSymbol;
12870
12894
 
12871
12895
  const breakChar = "- " + langBreak$1;
12872
12896
 
12873
- const cjkRangeList = [ [ 19968, 40959 ], [ 13312, 19903 ], [ 131072, 173791 ], [ 173824, 177983 ], [ 177984, 178207 ], [ 178208, 183983 ], [ 183984, 191471 ], [ 196608, 201551 ], [ 201552, 205743 ], [ 11904, 12031 ], [ 12032, 12255 ], [ 12272, 12287 ], [ 12288, 12351 ], [ 12736, 12783 ], [ 12800, 13055 ], [ 13056, 13311 ], [ 63744, 64255 ], [ 65072, 65103 ], [ 127488, 127743 ], [ 194560, 195103 ] ];
12897
+ const cjkRangeList = [ [ 19968, 40959 ], [ 13312, 19903 ], [ 131072, 173791 ], [ 173824, 177983 ], [ 177984, 178207 ], [ 178208, 183983 ], [ 183984, 191471 ], [ 196608, 201551 ], [ 201552, 205743 ], [ 11904, 12031 ], [ 12032, 12255 ], [ 12272, 12287 ], [ 12288, 12351 ], [ 4352, 4607 ], [ 12352, 12447 ], [ 12448, 12543 ], [ 12544, 12591 ], [ 12592, 12687 ], [ 12688, 12703 ], [ 12704, 12735 ], [ 12784, 12799 ], [ 12736, 12783 ], [ 12800, 13055 ], [ 13056, 13311 ], [ 63744, 64255 ], [ 65072, 65103 ], [ 127488, 127743 ], [ 194560, 195103 ] ];
12874
12898
 
12875
- const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u${start.toString(16)}-\\u${end.toString(16)}]`).join("|"));
12899
+ const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u{${start.toString(16)}}-\\u{${end.toString(16)}}]`).join("|"), "u");
12876
12900
 
12877
12901
  function mapChar(str) {
12878
12902
  const map = {};
@@ -12969,11 +12993,13 @@ function createRows(drawData, content, style) {
12969
12993
  rows = drawData.rows;
12970
12994
  bounds = drawData.bounds;
12971
12995
  findMaxWidth = !bounds.width && !style.autoSizeAlign;
12972
- const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
12996
+ const {paraIndent: paraIndent, textCase: textCase} = style;
12973
12997
  const {canvas: canvas} = Platform, {width: width} = bounds;
12974
12998
  if (style.__isCharMode) {
12975
12999
  const wrap = style.textWrap !== "none";
12976
13000
  const breakAll = style.textWrap === "break";
13001
+ const letterSpacing = style.__letterSpacing;
13002
+ const wordSpacing = style.__wordSpacing;
12977
13003
  paraStart = true;
12978
13004
  lastCharType = null;
12979
13005
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
@@ -12994,9 +13020,9 @@ function createRows(drawData, content, style) {
12994
13020
  charType = getCharType(char);
12995
13021
  if (charType === Letter && textCase !== "none") char = getTextCase(char, textCase, !wordWidth);
12996
13022
  charWidth = canvas.measureText(char).width;
12997
- if (__letterSpacing) {
12998
- if (__letterSpacing < 0) charSize = charWidth;
12999
- charWidth += __letterSpacing;
13023
+ if (letterSpacing) {
13024
+ if (letterSpacing < 0) charSize = charWidth;
13025
+ charWidth += letterSpacing;
13000
13026
  }
13001
13027
  langBreak = charType === Single && (lastCharType === Single || lastCharType === Letter) || lastCharType === Single && charType !== After;
13002
13028
  afterBreak = (charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After);
@@ -13017,11 +13043,11 @@ function createRows(drawData, content, style) {
13017
13043
  }
13018
13044
  if (char === " " && paraStart !== true && rowWidth + wordWidth === 0) ; else {
13019
13045
  if (charType === Break) {
13020
- if (char === " " && wordWidth) addWord();
13046
+ if (char === " " && wordWidth) addWord(wordSpacing);
13021
13047
  addChar(char, charWidth);
13022
13048
  addWord();
13023
13049
  } else if (langBreak || afterBreak) {
13024
- if (wordWidth) addWord();
13050
+ if (wordWidth) addWord(wordSpacing);
13025
13051
  addChar(char, charWidth);
13026
13052
  } else {
13027
13053
  addChar(char, charWidth);
@@ -13057,7 +13083,11 @@ function addChar(char, width) {
13057
13083
  wordWidth += width;
13058
13084
  }
13059
13085
 
13060
- function addWord() {
13086
+ function addWord(wordSpacing) {
13087
+ if (wordSpacing) {
13088
+ rowWidth += wordSpacing;
13089
+ word.addWidth = wordSpacing;
13090
+ }
13061
13091
  rowWidth += wordWidth;
13062
13092
  word.width = wordWidth;
13063
13093
  row.words.push(word);
@@ -13101,6 +13131,7 @@ function layoutChar(drawData, style, width, _height) {
13101
13131
  const {rows: rows} = drawData;
13102
13132
  const {textAlign: textAlign, paraIndent: paraIndent} = style;
13103
13133
  const useLetter = style.__letterSpacing || style.motionText;
13134
+ const wordSpacing = style.__wordSpacing;
13104
13135
  const justifyLast = width && textAlign.includes("both");
13105
13136
  const justify = justifyLast || width && textAlign.includes("justify");
13106
13137
  const justifyLetter = justify && textAlign.includes("letter");
@@ -13113,7 +13144,7 @@ function layoutChar(drawData, style, width, _height) {
13113
13144
  remainingWidth = width - row.width - indentWidth;
13114
13145
  if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
13115
13146
  }
13116
- mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
13147
+ mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth || wordSpacing ? WordMode : TextMode;
13117
13148
  if (row.isOverflow && !useLetter) row.textMode = true;
13118
13149
  if (mode === TextMode) {
13119
13150
  row.x += indentWidth;
@@ -13133,6 +13164,7 @@ function layoutChar(drawData, style, width, _height) {
13133
13164
  } else {
13134
13165
  charX = toChar(word.data, charX, row.data, row.isOverflow, canJustify && addLetterWidth);
13135
13166
  }
13167
+ if (word.addWidth) charX += word.addWidth;
13136
13168
  if (canJustify) {
13137
13169
  isLastWord = index === wordsLength - 1;
13138
13170
  if (addWordWidth) {