@leafer-game/miniapp 2.1.11 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.module.js +89 -34
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +12 -12
package/dist/miniapp.module.js
CHANGED
|
@@ -817,6 +817,11 @@ const PointHelper = {
|
|
|
817
817
|
toOuterOf(t, matrix, to) {
|
|
818
818
|
toOuterPoint$3(matrix, t, to);
|
|
819
819
|
},
|
|
820
|
+
toVertical(t, rotation, verticalDistance, to) {
|
|
821
|
+
const r = rotation * OneRadian;
|
|
822
|
+
t.x += -Math.sin(r) * verticalDistance;
|
|
823
|
+
t.y += Math.cos(r) * verticalDistance;
|
|
824
|
+
},
|
|
820
825
|
getCenter(t, to) {
|
|
821
826
|
return {
|
|
822
827
|
x: t.x + (to.x - t.x) / 2,
|
|
@@ -6985,7 +6990,7 @@ class LeafLevelList {
|
|
|
6985
6990
|
}
|
|
6986
6991
|
}
|
|
6987
6992
|
|
|
6988
|
-
const version = "2.
|
|
6993
|
+
const version = "2.2.0";
|
|
6989
6994
|
|
|
6990
6995
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6991
6996
|
get allowBackgroundColor() {
|
|
@@ -9788,7 +9793,7 @@ let Text = class Text extends UI {
|
|
|
9788
9793
|
data.__font = `${italic ? "italic " : ""}${textCase === "small-caps" ? "small-caps " : ""}${fontWeight !== "normal" ? fontWeight + " " : ""}${fontSize || 12}px ${fontFamily || "caption"}`;
|
|
9789
9794
|
stintSet$1(data, "__padding", padding && MathHelper.fourNumber(padding));
|
|
9790
9795
|
stintSet$1(data, "__clipText", textOverflow !== "show" && !data.__autoSize);
|
|
9791
|
-
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || textCase !== "none");
|
|
9796
|
+
stintSet$1(data, "__isCharMode", width || height || data.__letterSpacing || data.motionText || textCase !== "none");
|
|
9792
9797
|
data.__textDrawData = TextConvert.getDrawData((data.__isPlacehold = data.placeholder && data.text === "") ? data.placeholder : data.text, this.__);
|
|
9793
9798
|
}
|
|
9794
9799
|
__updateBoxBounds() {
|
|
@@ -9813,7 +9818,7 @@ let Text = class Text extends UI {
|
|
|
9813
9818
|
this.__updateNaturalSize();
|
|
9814
9819
|
} else super.__updateBoxBounds();
|
|
9815
9820
|
if (italic) b.width += fontSize * .16;
|
|
9816
|
-
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds));
|
|
9821
|
+
DataHelper.stintSet(this, "isOverflow", !includes(b, contentBounds) && !data.motionText);
|
|
9817
9822
|
if (this.isOverflow) setList(data.__textBoxBounds = {}, [ b, contentBounds ]), layout.renderChanged = true; else data.__textBoxBounds = b;
|
|
9818
9823
|
}
|
|
9819
9824
|
__updateRenderSpread() {
|
|
@@ -11416,8 +11421,10 @@ ui$5.__hit = function(inner, forceHitFill) {
|
|
|
11416
11421
|
if (!needHitFillPath && !needHitStrokePath) return false;
|
|
11417
11422
|
const radiusWidth = inner.radiusX * 2;
|
|
11418
11423
|
let hitWidth = radiusWidth;
|
|
11424
|
+
let {strokeAlign: strokeAlign} = data;
|
|
11425
|
+
if (data.motionText) hitWidth += data.fontSize / 2, strokeAlign = "center";
|
|
11419
11426
|
if (needHitStrokePath) {
|
|
11420
|
-
switch (
|
|
11427
|
+
switch (strokeAlign) {
|
|
11421
11428
|
case "inside":
|
|
11422
11429
|
hitWidth += strokeWidth * 2;
|
|
11423
11430
|
if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth)) return true;
|
|
@@ -11451,9 +11458,9 @@ rect.__hitFill = box$1.__hitFill = function(inner) {
|
|
|
11451
11458
|
};
|
|
11452
11459
|
|
|
11453
11460
|
Text.prototype.__drawHitPath = function(canvas) {
|
|
11454
|
-
const {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData:
|
|
11461
|
+
const data = this.__, {__lineHeight: __lineHeight, fontSize: fontSize, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __textDrawData: drawData} = data;
|
|
11455
11462
|
canvas.beginPath();
|
|
11456
|
-
if (__letterSpacing < 0) this.__drawPathByBox(canvas); else
|
|
11463
|
+
if (data.motionText) this.__drawPathByData(canvas, data.__pathForMotionText); else if (__letterSpacing < 0) this.__drawPathByBox(canvas); else drawData.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
|
|
11457
11464
|
};
|
|
11458
11465
|
|
|
11459
11466
|
Group.prototype.pick = function(hitPoint, options) {
|
|
@@ -11640,7 +11647,8 @@ function fillPathOrText(ui, canvas, renderOptions) {
|
|
|
11640
11647
|
ui.__.__font ? Paint.fillText(ui, canvas, renderOptions) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
|
|
11641
11648
|
}
|
|
11642
11649
|
|
|
11643
|
-
function fillText(ui, canvas,
|
|
11650
|
+
function fillText(ui, canvas, renderOptions) {
|
|
11651
|
+
if (ui.motionText) return Paint.fillMotionText(ui, canvas, renderOptions);
|
|
11644
11652
|
const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
|
|
11645
11653
|
if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
|
|
11646
11654
|
let row;
|
|
@@ -13002,7 +13010,8 @@ const TextMode = 2;
|
|
|
13002
13010
|
|
|
13003
13011
|
function layoutChar(drawData, style, width, _height) {
|
|
13004
13012
|
const {rows: rows} = drawData;
|
|
13005
|
-
const {textAlign: textAlign, paraIndent: paraIndent
|
|
13013
|
+
const {textAlign: textAlign, paraIndent: paraIndent} = style;
|
|
13014
|
+
const useLetter = style.__letterSpacing || style.motionText;
|
|
13006
13015
|
const justifyLast = width && textAlign.includes("both");
|
|
13007
13016
|
const justify = justifyLast || width && textAlign.includes("justify");
|
|
13008
13017
|
const justifyLetter = justify && textAlign.includes("letter");
|
|
@@ -13015,8 +13024,8 @@ function layoutChar(drawData, style, width, _height) {
|
|
|
13015
13024
|
remainingWidth = width - row.width - indentWidth;
|
|
13016
13025
|
if (justifyLetter) addLetterWidth = remainingWidth / (row.words.reduce((total, item) => total + item.data.length, 0) - 1); else addWordWidth = wordsLength > 1 ? remainingWidth / (wordsLength - 1) : 0;
|
|
13017
13026
|
}
|
|
13018
|
-
mode =
|
|
13019
|
-
if (row.isOverflow && !
|
|
13027
|
+
mode = useLetter || row.isOverflow || justifyLetter ? CharMode : addWordWidth ? WordMode : TextMode;
|
|
13028
|
+
if (row.isOverflow && !useLetter) row.textMode = true;
|
|
13020
13029
|
if (mode === TextMode) {
|
|
13021
13030
|
row.x += indentWidth;
|
|
13022
13031
|
toTextChar$1(row);
|
|
@@ -13217,6 +13226,7 @@ function getDrawData(content, style) {
|
|
|
13217
13226
|
let width = style.__getInput("width") || 0;
|
|
13218
13227
|
let height = style.__getInput("height") || 0;
|
|
13219
13228
|
const {__padding: padding} = style;
|
|
13229
|
+
if (style.motionText) width = height = 0;
|
|
13220
13230
|
if (padding) {
|
|
13221
13231
|
if (width) x = padding[left], width -= padding[right] + padding[left], !width && (width = .01); else if (!style.autoSizeAlign) x = padding[left];
|
|
13222
13232
|
if (height) y = padding[top], height -= padding[top] + padding[bottom], !height && (height = .01); else if (!style.autoSizeAlign) y = padding[top];
|
|
@@ -15017,7 +15027,7 @@ const HighCurveHelper = {
|
|
|
15017
15027
|
},
|
|
15018
15028
|
getMotionPathData(data) {
|
|
15019
15029
|
let total = 0, distance, segments = [];
|
|
15020
|
-
let i = 0, x = 0, y = 0, toX, toY, command;
|
|
15030
|
+
let i = 0, x = 0, y = 0, toX, toY, command, closed;
|
|
15021
15031
|
const len = data.length;
|
|
15022
15032
|
while (i < len) {
|
|
15023
15033
|
command = data[i];
|
|
@@ -15042,6 +15052,7 @@ const HighCurveHelper = {
|
|
|
15042
15052
|
break;
|
|
15043
15053
|
|
|
15044
15054
|
case Z:
|
|
15055
|
+
closed = true;
|
|
15045
15056
|
i += 1;
|
|
15046
15057
|
|
|
15047
15058
|
default:
|
|
@@ -15053,13 +15064,16 @@ const HighCurveHelper = {
|
|
|
15053
15064
|
return {
|
|
15054
15065
|
total: total,
|
|
15055
15066
|
segments: segments,
|
|
15056
|
-
data: data
|
|
15067
|
+
data: data,
|
|
15068
|
+
closed: closed
|
|
15057
15069
|
};
|
|
15058
15070
|
},
|
|
15059
|
-
getDistancePoint(distanceData, motionDistance, motionPrecision) {
|
|
15060
|
-
const {segments: segments, data: data} = distanceData;
|
|
15061
|
-
motionDistance = UnitConvert.number(motionDistance,
|
|
15062
|
-
|
|
15071
|
+
getDistancePoint(distanceData, motionDistance, motionPrecision, offsetX) {
|
|
15072
|
+
const {segments: segments, data: data, total: total} = distanceData;
|
|
15073
|
+
motionDistance = UnitConvert.number(motionDistance, total);
|
|
15074
|
+
if (offsetX) motionDistance += offsetX;
|
|
15075
|
+
if (motionDistance > total) motionDistance = motionDistance % total;
|
|
15076
|
+
let nowDistance = 0, distance, to = {};
|
|
15063
15077
|
let i = 0, index = 0, x = 0, y = 0, toX, toY, command;
|
|
15064
15078
|
let x1, y1, x2, y2, t;
|
|
15065
15079
|
const len = data.length;
|
|
@@ -15071,15 +15085,20 @@ const HighCurveHelper = {
|
|
|
15071
15085
|
toX = data[i + 1];
|
|
15072
15086
|
toY = data[i + 2];
|
|
15073
15087
|
distance = segments[index];
|
|
15074
|
-
if (
|
|
15075
|
-
if (!i) x = toX, y = toY;
|
|
15076
|
-
tempFrom.x = x;
|
|
15077
|
-
tempFrom.y = y;
|
|
15088
|
+
if (nowDistance + distance >= motionDistance || !distanceData.total) {
|
|
15078
15089
|
to.x = toX;
|
|
15079
15090
|
to.y = toY;
|
|
15080
|
-
|
|
15081
|
-
|
|
15082
|
-
|
|
15091
|
+
if (i) {
|
|
15092
|
+
tempFrom.x = x;
|
|
15093
|
+
tempFrom.y = y;
|
|
15094
|
+
PointHelper.getDistancePoint(tempFrom, to, motionDistance - nowDistance, true);
|
|
15095
|
+
to.rotation = PointHelper.getAngle(tempFrom, to);
|
|
15096
|
+
return to;
|
|
15097
|
+
} else {
|
|
15098
|
+
const nextPoint = HighCurveHelper.getDistancePoint(distanceData, motionPrecision, motionPrecision, offsetX);
|
|
15099
|
+
to.rotation = nextPoint.rotation;
|
|
15100
|
+
return to;
|
|
15101
|
+
}
|
|
15083
15102
|
}
|
|
15084
15103
|
x = toX;
|
|
15085
15104
|
y = toY;
|
|
@@ -15090,9 +15109,9 @@ const HighCurveHelper = {
|
|
|
15090
15109
|
toX = data[i + 5];
|
|
15091
15110
|
toY = data[i + 6];
|
|
15092
15111
|
distance = segments[index];
|
|
15093
|
-
if (
|
|
15112
|
+
if (nowDistance + distance >= motionDistance) {
|
|
15094
15113
|
x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4];
|
|
15095
|
-
t = HighBezierHelper.getT(motionDistance -
|
|
15114
|
+
t = HighBezierHelper.getT(motionDistance - nowDistance, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision);
|
|
15096
15115
|
BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to);
|
|
15097
15116
|
to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY);
|
|
15098
15117
|
return to;
|
|
@@ -15109,7 +15128,7 @@ const HighCurveHelper = {
|
|
|
15109
15128
|
distance = 0;
|
|
15110
15129
|
}
|
|
15111
15130
|
index++;
|
|
15112
|
-
|
|
15131
|
+
nowDistance += distance;
|
|
15113
15132
|
}
|
|
15114
15133
|
return to;
|
|
15115
15134
|
},
|
|
@@ -15208,26 +15227,57 @@ const {updateMatrix: updateMatrix, updateAllMatrix: updateAllMatrix} = LeafHelpe
|
|
|
15208
15227
|
|
|
15209
15228
|
const {updateBounds: updateBounds} = BranchHelper;
|
|
15210
15229
|
|
|
15230
|
+
const {toVertical: toVertical} = PointHelper;
|
|
15231
|
+
|
|
15211
15232
|
UI.addAttr("motionPath", undefined, motionPathType);
|
|
15212
15233
|
|
|
15213
15234
|
UI.addAttr("motionPrecision", 1, motionPathType);
|
|
15214
15235
|
|
|
15215
15236
|
UI.addAttr("motion", undefined, motionPathType);
|
|
15216
15237
|
|
|
15238
|
+
UI.addAttr("motionVertical", "below", motionPathType);
|
|
15239
|
+
|
|
15217
15240
|
UI.addAttr("motionRotation", true, motionPathType);
|
|
15218
15241
|
|
|
15242
|
+
ui$1.getMotionPath = function() {
|
|
15243
|
+
return getMotionPath(this);
|
|
15244
|
+
};
|
|
15245
|
+
|
|
15219
15246
|
ui$1.getMotionPathData = function() {
|
|
15220
15247
|
return getMotionPathData(getMotionPath(this));
|
|
15221
15248
|
};
|
|
15222
15249
|
|
|
15223
|
-
ui$1.
|
|
15224
|
-
|
|
15225
|
-
|
|
15250
|
+
ui$1.getMotionContentHeight = function() {
|
|
15251
|
+
return this.__layout.boxBounds.height;
|
|
15252
|
+
};
|
|
15253
|
+
|
|
15254
|
+
ui$1.getMotionPoint = function(motionDistance, motionVertical, pathElement, offsetX = 0, offsetY = 0) {
|
|
15255
|
+
if (!pathElement) pathElement = getMotionPath(this);
|
|
15256
|
+
const data = getMotionPathData(pathElement);
|
|
15226
15257
|
if (!data.total) return {};
|
|
15227
|
-
const point = HighCurveHelper.getDistancePoint(data, motionDistance,
|
|
15228
|
-
MatrixHelper.toOuterPoint(path.localTransform, point);
|
|
15258
|
+
const point = HighCurveHelper.getDistancePoint(data, motionDistance, pathElement.motionPrecision, offsetX);
|
|
15229
15259
|
const {motionRotation: motionRotation} = this;
|
|
15230
|
-
if (
|
|
15260
|
+
if (isNumber(motionRotation)) point.rotation += motionRotation;
|
|
15261
|
+
let verticalType, verticalOffset;
|
|
15262
|
+
if (isObject(motionVertical)) verticalType = motionVertical.type, verticalOffset = motionVertical.offset; else if (isNumber(motionVertical)) verticalOffset = motionVertical; else verticalType = motionVertical;
|
|
15263
|
+
if (verticalType !== "below" || offsetY) {
|
|
15264
|
+
const {rotation: rotation} = point, height = this.getMotionContentHeight();
|
|
15265
|
+
if (verticalOffset) offsetY += verticalType === "above" ? -verticalOffset : verticalOffset;
|
|
15266
|
+
switch (verticalType) {
|
|
15267
|
+
case "above":
|
|
15268
|
+
toVertical(point, rotation, -height + offsetY);
|
|
15269
|
+
break;
|
|
15270
|
+
|
|
15271
|
+
case "center":
|
|
15272
|
+
toVertical(point, rotation, -height / 2 + offsetY);
|
|
15273
|
+
break;
|
|
15274
|
+
|
|
15275
|
+
case "below":
|
|
15276
|
+
default:
|
|
15277
|
+
toVertical(point, rotation, offsetY);
|
|
15278
|
+
}
|
|
15279
|
+
}
|
|
15280
|
+
MatrixHelper.toOuterPoint(pathElement.localTransform, point);
|
|
15231
15281
|
return point;
|
|
15232
15282
|
};
|
|
15233
15283
|
|
|
@@ -15259,7 +15309,11 @@ function updateMotion(leaf) {
|
|
|
15259
15309
|
const data = getMotionPathData(leaf);
|
|
15260
15310
|
if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision);
|
|
15261
15311
|
} else {
|
|
15262
|
-
leaf.
|
|
15312
|
+
if (leaf.motionText) leaf.__updateMotionText(); else {
|
|
15313
|
+
const point = leaf.getMotionPoint(motion);
|
|
15314
|
+
if (leaf.motionRotation === false) delete point.rotation;
|
|
15315
|
+
leaf.set(point);
|
|
15316
|
+
}
|
|
15263
15317
|
if (!leaf.__hasAutoLayout) {
|
|
15264
15318
|
if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf); else updateMatrix(leaf);
|
|
15265
15319
|
}
|
|
@@ -15281,7 +15335,8 @@ function getMotionPath(leaf) {
|
|
|
15281
15335
|
function getMotionPathData(leaf) {
|
|
15282
15336
|
const data = leaf.__;
|
|
15283
15337
|
if (data.__pathForMotion) return data.__pathForMotion;
|
|
15284
|
-
|
|
15338
|
+
const path = data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true));
|
|
15339
|
+
return path;
|
|
15285
15340
|
}
|
|
15286
15341
|
|
|
15287
15342
|
const {Yes: Yes, NoAndSkip: NoAndSkip, YesAndSkip: YesAndSkip} = Answer;
|