@leafer-draw/miniapp 1.9.7 → 1.9.8
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.cjs +106 -79
- package/dist/miniapp.esm.js +108 -81
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +237 -167
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/miniapp.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { LeaferCanvasBase, isString, Platform, isNumber, canvasPatch, DataHelper, canvasSizeAttrs, isUndefined, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, isObject, BoundsHelper, Matrix, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from "@leafer/core";
|
|
1
|
+
import { LeaferCanvasBase, isString, Platform, isNumber, canvasPatch, DataHelper, canvasSizeAttrs, isUndefined, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, isObject, BoundsHelper, FourNumberHelper, Matrix, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from "@leafer/core";
|
|
2
2
|
|
|
3
3
|
export * from "@leafer/core";
|
|
4
4
|
|
|
5
5
|
export { LeaferImage } from "@leafer/core";
|
|
6
6
|
|
|
7
|
-
import { PaintImage, Paint, ColorConvert, PaintGradient, Export,
|
|
7
|
+
import { PaintImage, Paint, ColorConvert, PaintGradient, Export, Group, TextConvert, Effect } from "@leafer-ui/draw";
|
|
8
8
|
|
|
9
9
|
export * from "@leafer-ui/draw";
|
|
10
10
|
|
|
@@ -584,6 +584,7 @@ class Renderer {
|
|
|
584
584
|
usePartRender: true,
|
|
585
585
|
maxFPS: 120
|
|
586
586
|
};
|
|
587
|
+
this.frames = [];
|
|
587
588
|
this.target = target;
|
|
588
589
|
this.canvas = canvas;
|
|
589
590
|
if (userConfig) this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -736,12 +737,15 @@ class Renderer {
|
|
|
736
737
|
const target = this.target;
|
|
737
738
|
if (this.requestTime || !target) return;
|
|
738
739
|
if (target.parentApp) return target.parentApp.requestRender(false);
|
|
739
|
-
|
|
740
|
+
this.requestTime = this.frameTime || Date.now();
|
|
740
741
|
const render = () => {
|
|
741
|
-
const nowFPS = 1e3 / (Date.now() - requestTime);
|
|
742
|
+
const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
|
|
742
743
|
const {maxFPS: maxFPS} = this.config;
|
|
743
|
-
if (maxFPS && nowFPS > maxFPS
|
|
744
|
-
|
|
744
|
+
if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
|
|
745
|
+
const {frames: frames} = this;
|
|
746
|
+
if (frames.length > 30) frames.shift();
|
|
747
|
+
frames.push(nowFPS);
|
|
748
|
+
this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
|
|
745
749
|
this.requestTime = 0;
|
|
746
750
|
this.checkRender();
|
|
747
751
|
};
|
|
@@ -1008,24 +1012,29 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
1008
1012
|
}
|
|
1009
1013
|
}
|
|
1010
1014
|
|
|
1011
|
-
const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
|
|
1015
|
+
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
1016
|
+
|
|
1017
|
+
const tempBounds$1 = {};
|
|
1012
1018
|
|
|
1013
1019
|
function shape(ui, current, options) {
|
|
1014
1020
|
const canvas = current.getSameCanvas();
|
|
1015
|
-
const nowWorld = ui.__nowWorld,
|
|
1016
|
-
|
|
1021
|
+
const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
|
|
1022
|
+
const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
|
|
1023
|
+
toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds$1, layout.boxBounds, layout.strokeSpread),
|
|
1024
|
+
tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
|
|
1025
|
+
let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
|
|
1017
1026
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
1018
|
-
if (currentBounds.includes(
|
|
1027
|
+
if (currentBounds.includes(nowWorldShapeBounds)) {
|
|
1019
1028
|
worldCanvas = canvas;
|
|
1020
|
-
bounds = shapeBounds =
|
|
1029
|
+
bounds = shapeBounds = nowWorldShapeBounds;
|
|
1030
|
+
renderBounds = nowWorld;
|
|
1021
1031
|
} else {
|
|
1022
|
-
const {renderShapeSpread: spread} = ui.__layout;
|
|
1023
1032
|
let worldClipBounds;
|
|
1024
1033
|
if (Platform.fullImageShadow) {
|
|
1025
|
-
worldClipBounds =
|
|
1034
|
+
worldClipBounds = nowWorldShapeBounds;
|
|
1026
1035
|
} else {
|
|
1027
|
-
const spreadBounds =
|
|
1028
|
-
worldClipBounds = getIntersectData(spreadBounds,
|
|
1036
|
+
const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
|
|
1037
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
|
|
1029
1038
|
}
|
|
1030
1039
|
fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
|
|
1031
1040
|
let {a: fitScaleX, d: fitScaleY} = fitMatrix;
|
|
@@ -1035,8 +1044,10 @@ function shape(ui, current, options) {
|
|
|
1035
1044
|
scaleX *= fitScaleX;
|
|
1036
1045
|
scaleY *= fitScaleY;
|
|
1037
1046
|
}
|
|
1038
|
-
shapeBounds = getOuterOf(
|
|
1047
|
+
shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
|
|
1039
1048
|
bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
|
|
1049
|
+
renderBounds = getOuterOf(nowWorld, fitMatrix);
|
|
1050
|
+
move$1(renderBounds, -fitMatrix.e, -fitMatrix.f);
|
|
1040
1051
|
const userMatrix = options.matrix;
|
|
1041
1052
|
if (userMatrix) {
|
|
1042
1053
|
matrix = new Matrix(fitMatrix);
|
|
@@ -1055,6 +1066,7 @@ function shape(ui, current, options) {
|
|
|
1055
1066
|
matrix: matrix,
|
|
1056
1067
|
fitMatrix: fitMatrix,
|
|
1057
1068
|
bounds: bounds,
|
|
1069
|
+
renderBounds: renderBounds,
|
|
1058
1070
|
worldCanvas: worldCanvas,
|
|
1059
1071
|
shapeBounds: shapeBounds,
|
|
1060
1072
|
scaleX: scaleX,
|
|
@@ -1158,7 +1170,7 @@ const PaintModule = {
|
|
|
1158
1170
|
shape: shape
|
|
1159
1171
|
};
|
|
1160
1172
|
|
|
1161
|
-
let origin = {}, tempMatrix = getMatrixData();
|
|
1173
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
1162
1174
|
|
|
1163
1175
|
const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
1164
1176
|
|
|
@@ -1173,12 +1185,12 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1173
1185
|
data.transform = transform;
|
|
1174
1186
|
}
|
|
1175
1187
|
|
|
1176
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew,
|
|
1188
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
1177
1189
|
const transform = get$3();
|
|
1178
1190
|
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
1179
|
-
if (
|
|
1180
|
-
tempMatrix.a =
|
|
1181
|
-
multiplyParent(transform, tempMatrix);
|
|
1191
|
+
if (clipScaleX) {
|
|
1192
|
+
tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
|
|
1193
|
+
multiplyParent(transform, tempMatrix$1);
|
|
1182
1194
|
}
|
|
1183
1195
|
data.transform = transform;
|
|
1184
1196
|
}
|
|
@@ -1279,7 +1291,12 @@ function getPatternData(paint, box, image) {
|
|
|
1279
1291
|
|
|
1280
1292
|
case "normal":
|
|
1281
1293
|
case "clip":
|
|
1282
|
-
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1294
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
1295
|
+
let clipScaleX, clipScaleY;
|
|
1296
|
+
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
1297
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
1298
|
+
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
1299
|
+
}
|
|
1283
1300
|
break;
|
|
1284
1301
|
|
|
1285
1302
|
case "repeat":
|
|
@@ -1437,7 +1454,7 @@ function ignoreRender(ui, value) {
|
|
|
1437
1454
|
|
|
1438
1455
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
1439
1456
|
|
|
1440
|
-
const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
|
|
1457
|
+
const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
|
|
1441
1458
|
|
|
1442
1459
|
function createPattern(ui, paint, pixelRatio) {
|
|
1443
1460
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
@@ -1486,8 +1503,8 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1486
1503
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
1487
1504
|
const canvasWidth = width + (xGap || 0);
|
|
1488
1505
|
const canvasHeight = height + (yGap || 0);
|
|
1489
|
-
scaleX /= canvasWidth / max(floor(canvasWidth), 1);
|
|
1490
|
-
scaleY /= canvasHeight / max(floor(canvasHeight), 1);
|
|
1506
|
+
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
1507
|
+
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
1491
1508
|
if (!imageMatrix) {
|
|
1492
1509
|
imageMatrix = get$1();
|
|
1493
1510
|
if (transform) copy$1(imageMatrix, transform);
|
|
@@ -1546,17 +1563,15 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1546
1563
|
if (allowDraw) {
|
|
1547
1564
|
if (data.repeat) {
|
|
1548
1565
|
allowDraw = false;
|
|
1549
|
-
} else {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
height *= data.scaleY;
|
|
1557
|
-
}
|
|
1558
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
1566
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1567
|
+
let {width: width, height: height} = data;
|
|
1568
|
+
width *= scaleX * pixelRatio;
|
|
1569
|
+
height *= scaleY * pixelRatio;
|
|
1570
|
+
if (data.scaleX) {
|
|
1571
|
+
width *= data.scaleX;
|
|
1572
|
+
height *= data.scaleY;
|
|
1559
1573
|
}
|
|
1574
|
+
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
1560
1575
|
}
|
|
1561
1576
|
}
|
|
1562
1577
|
if (allowDraw) {
|
|
@@ -1736,20 +1751,20 @@ const PaintGradientModule = {
|
|
|
1736
1751
|
getTransform: getTransform
|
|
1737
1752
|
};
|
|
1738
1753
|
|
|
1739
|
-
const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
|
|
1754
|
+
const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
|
|
1740
1755
|
|
|
1741
|
-
const tempBounds = {};
|
|
1756
|
+
const tempBounds = {}, tempMatrix = new Matrix;
|
|
1742
1757
|
|
|
1743
1758
|
const offsetOutBounds$1 = {};
|
|
1744
1759
|
|
|
1745
1760
|
function shadow(ui, current, shape) {
|
|
1746
|
-
let copyBounds,
|
|
1747
|
-
const {__nowWorld: nowWorld
|
|
1761
|
+
let copyBounds, transform;
|
|
1762
|
+
const {__nowWorld: nowWorld} = ui;
|
|
1748
1763
|
const {shadow: shadow} = ui.__;
|
|
1749
|
-
const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
1764
|
+
const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
1750
1765
|
const other = current.getSameCanvas();
|
|
1751
1766
|
const end = shadow.length - 1;
|
|
1752
|
-
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
1767
|
+
toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
|
|
1753
1768
|
shadow.forEach((item, index) => {
|
|
1754
1769
|
let otherScale = 1;
|
|
1755
1770
|
if (item.scaleFixed) {
|
|
@@ -1757,54 +1772,61 @@ function shadow(ui, current, shape) {
|
|
|
1757
1772
|
if (sx > 1) otherScale = 1 / sx;
|
|
1758
1773
|
}
|
|
1759
1774
|
other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1775
|
+
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
1776
|
+
if (transform) other.setTransform(transform);
|
|
1777
|
+
drawWorldShadow(other, offsetOutBounds$1, shape);
|
|
1778
|
+
if (transform) other.resetTransform();
|
|
1779
|
+
copyBounds = renderBounds;
|
|
1763
1780
|
if (item.box) {
|
|
1764
1781
|
other.restore();
|
|
1765
1782
|
other.save();
|
|
1766
1783
|
if (worldCanvas) {
|
|
1767
|
-
other.copyWorld(other,
|
|
1784
|
+
other.copyWorld(other, renderBounds, nowWorld, "copy");
|
|
1768
1785
|
copyBounds = nowWorld;
|
|
1769
1786
|
}
|
|
1770
1787
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
|
|
1771
1788
|
}
|
|
1772
|
-
|
|
1789
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1773
1790
|
if (end && index < end) other.clearWorld(copyBounds);
|
|
1774
1791
|
});
|
|
1775
1792
|
other.recycle(copyBounds);
|
|
1776
1793
|
}
|
|
1777
1794
|
|
|
1778
|
-
function
|
|
1779
|
-
let
|
|
1780
|
-
shadow.forEach(item =>
|
|
1781
|
-
|
|
1795
|
+
function getShadowRenderSpread(_ui, shadow) {
|
|
1796
|
+
let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
|
|
1797
|
+
shadow.forEach(item => {
|
|
1798
|
+
x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
|
|
1799
|
+
top = max(top, spread + blur - y);
|
|
1800
|
+
right = max(right, spread + blur + x);
|
|
1801
|
+
bottom = max(bottom, spread + blur + y);
|
|
1802
|
+
left = max(left, spread + blur - x);
|
|
1803
|
+
});
|
|
1804
|
+
return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1807
|
+
function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
|
|
1808
|
+
if (shadow.spread) {
|
|
1809
|
+
const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
|
|
1810
|
+
tempMatrix.set().scaleOfOuter({
|
|
1811
|
+
x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
|
|
1812
|
+
y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
|
|
1813
|
+
}, spreadScale);
|
|
1814
|
+
return tempMatrix;
|
|
1815
|
+
}
|
|
1816
|
+
return undefined;
|
|
1782
1817
|
}
|
|
1783
1818
|
|
|
1784
|
-
function drawWorldShadow(canvas, outBounds,
|
|
1785
|
-
const {
|
|
1819
|
+
function drawWorldShadow(canvas, outBounds, shape) {
|
|
1820
|
+
const {shapeBounds: shapeBounds} = shape;
|
|
1821
|
+
let from, to;
|
|
1786
1822
|
if (Platform.fullImageShadow) {
|
|
1787
1823
|
copy(tempBounds, canvas.bounds);
|
|
1788
|
-
tempBounds.x
|
|
1789
|
-
|
|
1790
|
-
if (spreadScale) {
|
|
1791
|
-
const {fitMatrix: fitMatrix} = shape;
|
|
1792
|
-
tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
|
|
1793
|
-
tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
|
|
1794
|
-
tempBounds.width *= spreadScale;
|
|
1795
|
-
tempBounds.height *= spreadScale;
|
|
1796
|
-
}
|
|
1797
|
-
canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
|
|
1824
|
+
move(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
|
|
1825
|
+
from = canvas.bounds, to = tempBounds;
|
|
1798
1826
|
} else {
|
|
1799
|
-
|
|
1800
|
-
copy(tempBounds, outBounds);
|
|
1801
|
-
tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
|
|
1802
|
-
tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
|
|
1803
|
-
tempBounds.width *= spreadScale;
|
|
1804
|
-
tempBounds.height *= spreadScale;
|
|
1805
|
-
}
|
|
1806
|
-
canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
|
|
1827
|
+
from = shapeBounds, to = outBounds;
|
|
1807
1828
|
}
|
|
1829
|
+
canvas.copyWorld(shape.canvas, from, to);
|
|
1808
1830
|
}
|
|
1809
1831
|
|
|
1810
1832
|
const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
|
|
@@ -1812,13 +1834,13 @@ const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
|
|
|
1812
1834
|
const offsetOutBounds = {};
|
|
1813
1835
|
|
|
1814
1836
|
function innerShadow(ui, current, shape) {
|
|
1815
|
-
let copyBounds,
|
|
1816
|
-
const {__nowWorld: nowWorld
|
|
1837
|
+
let copyBounds, transform;
|
|
1838
|
+
const {__nowWorld: nowWorld} = ui;
|
|
1817
1839
|
const {innerShadow: innerShadow} = ui.__;
|
|
1818
|
-
const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
1840
|
+
const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
1819
1841
|
const other = current.getSameCanvas();
|
|
1820
1842
|
const end = innerShadow.length - 1;
|
|
1821
|
-
toOffsetOutBounds(bounds, offsetOutBounds);
|
|
1843
|
+
toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
|
|
1822
1844
|
innerShadow.forEach((item, index) => {
|
|
1823
1845
|
let otherScale = 1;
|
|
1824
1846
|
if (item.scaleFixed) {
|
|
@@ -1827,16 +1849,17 @@ function innerShadow(ui, current, shape) {
|
|
|
1827
1849
|
}
|
|
1828
1850
|
other.save();
|
|
1829
1851
|
other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
|
|
1830
|
-
|
|
1831
|
-
|
|
1852
|
+
transform = getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
1853
|
+
if (transform) other.setTransform(transform);
|
|
1854
|
+
drawWorldShadow(other, offsetOutBounds, shape);
|
|
1832
1855
|
other.restore();
|
|
1833
1856
|
if (worldCanvas) {
|
|
1834
|
-
other.copyWorld(other,
|
|
1857
|
+
other.copyWorld(other, renderBounds, nowWorld, "copy");
|
|
1835
1858
|
other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
|
|
1836
1859
|
copyBounds = nowWorld;
|
|
1837
1860
|
} else {
|
|
1838
1861
|
other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
|
|
1839
|
-
copyBounds =
|
|
1862
|
+
copyBounds = renderBounds;
|
|
1840
1863
|
}
|
|
1841
1864
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
|
|
1842
1865
|
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
@@ -1845,6 +1868,8 @@ function innerShadow(ui, current, shape) {
|
|
|
1845
1868
|
other.recycle(copyBounds);
|
|
1846
1869
|
}
|
|
1847
1870
|
|
|
1871
|
+
const getInnerShadowSpread = getShadowRenderSpread;
|
|
1872
|
+
|
|
1848
1873
|
function blur(ui, current, origin) {
|
|
1849
1874
|
const {blur: blur} = ui.__;
|
|
1850
1875
|
origin.setWorldBlur(blur * ui.__nowWorld.a);
|
|
@@ -1859,10 +1884,12 @@ const EffectModule = {
|
|
|
1859
1884
|
innerShadow: innerShadow,
|
|
1860
1885
|
blur: blur,
|
|
1861
1886
|
backgroundBlur: backgroundBlur,
|
|
1862
|
-
|
|
1887
|
+
getShadowRenderSpread: getShadowRenderSpread,
|
|
1888
|
+
getShadowTransform: getShadowTransform,
|
|
1863
1889
|
isTransformShadow(_shadow) {
|
|
1864
1890
|
return undefined;
|
|
1865
|
-
}
|
|
1891
|
+
},
|
|
1892
|
+
getInnerShadowSpread: getInnerShadowSpread
|
|
1866
1893
|
};
|
|
1867
1894
|
|
|
1868
1895
|
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
|
|
@@ -1879,6 +1906,7 @@ Group.prototype.__renderMask = function(canvas, options) {
|
|
|
1879
1906
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
|
|
1880
1907
|
maskCanvas = contentCanvas = null;
|
|
1881
1908
|
}
|
|
1909
|
+
if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1882
1910
|
maskOpacity = child.__.opacity;
|
|
1883
1911
|
usedGrayscaleAlpha = false;
|
|
1884
1912
|
if (mask === "path" || mask === "clipping-path") {
|
|
@@ -1896,7 +1924,6 @@ Group.prototype.__renderMask = function(canvas, options) {
|
|
|
1896
1924
|
if (!contentCanvas) contentCanvas = getCanvas(canvas);
|
|
1897
1925
|
child.__render(maskCanvas, options);
|
|
1898
1926
|
}
|
|
1899
|
-
if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1900
1927
|
continue;
|
|
1901
1928
|
}
|
|
1902
1929
|
const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as n,DataHelper as a,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as l,FileHelper as c,Creator as h,LeaferImage as d,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as x,Bounds as v,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as E,isObject as A,BoundsHelper as L,Matrix as T,getMatrixData as C,MatrixHelper as W,MathHelper as O,AlignHelper as M,PointHelper as P,ImageEvent as D,AroundHelper as z,Direction4 as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as F,Paint as U,ColorConvert as Y,PaintGradient as G,Export as N,Effect as X,Group as q,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class V extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:e,height:a,pixelRatio:o}=this.config,r={width:e||t.width,height:a||t.height,pixelRatio:o};this.resize(r),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,a){this.context.roundRect(t,e,i,n,s(a)?[a]:a)}),n(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};a.copyAttrs(e,this,o),this.resize(t),r(this.width)||this.resizeListener(new l(t,e))}}const{mineType:H,fileType:Q}=c;function Z(t,e){i.origin={createCanvas:(t,i,s)=>{const n={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(n):e.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(H(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(H(Q(e)),s);return n=n.substring(n.indexOf("64,")+3),i.origin.download(n,e)},download:(t,s)=>new Promise((n,a)=>{let o;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,o=!0);const r=e.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){o?i.miniapp.saveToAlbum(s).then(()=>{r.unlink({filePath:s}),n()}):n()},fail(t){a(t)}})}),loadImage:t=>new Promise((e,s)=>{const n=i.canvas.view.createImage();n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),noRepeat:"repeat-x"},i.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=h.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(h,{canvas:(t,e)=>new V(t,e),image:t=>new d(t)}),i.name="miniapp",i.requestRender=function(t){const{view:e}=i.renderCanvas||i.canvas;e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)},u(i,"devicePixelRatio",{get:()=>Math.max(1,wx.getWindowInfo?wx.getWindowInfo().pixelRatio:wx.getSystemInfoSync().pixelRatio)});class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=a.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=m,{pushAllChildBranch:et,pushAllParent:it}=y;const{worldBounds:st}=x;class nt{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:at,updateAllChange:ot}=m,rt=b.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=a.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=B,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new B(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||K(s[t])}K(i)}})}(this.__levelList),function(t){t.list.forEach(tt)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new B(a,r,this.times)),i.emitEvent(new B(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),lt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),R.end(t)}static fullLayout(t){at(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new nt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new nt(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=b.get("Renderer");class ht{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.target=t,this.canvas=e,i&&(this.config=a.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,ct.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new v,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new v(s);i.save(),s.spread(ht.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),i.render(this.target,s,a),this.renderBounds=e=e||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);const e=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-e),{maxFPS:n}=this.config;if(n&&t>n-.5)return i.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};i.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new v(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[l.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function dt(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function ut(t,e){t.__.__font?dt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ft(t,e,i){switch(e.__.strokeAlign){case"center":pt(t,1,e,i);break;case"inside":gt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?pt(t,2,e,i):gt(t,"outside",e,i)}}function pt(t,e,i,s){const n=i.__;A(t)?wt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),_t(i,s))}function gt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,pt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",dt(i,n),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function _t(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function wt(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,c=t.length;l<c;l++)if(a=t[l],(!a.image||!F.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?_t(s,n):n.stroke(),n.restoreBlendMode()):i?_t(s,n):n.stroke()}}function mt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)ft(t,e,i);else switch(s.strokeAlign){case"center":yt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),yt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)yt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),yt(t,2,e,a),a.clipUI(s),a.clearWorld(n),m.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function yt(t,e,i,s){const n=i.__;A(t)?wt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&U.strokeArrow(t,i,s)}ht.clipSpread=10,Object.assign(h,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ht(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=lt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:xt,getOuterOf:vt,getByMove:St,getIntersectData:bt}=L;let kt;const{stintSet:Bt}=a,{hasTransparent:Rt}=Y;function Et(t,i,s){if(!A(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout;switch(i.type){case"image":n=F.image(s,t,i,a,!kt||!kt[i.url]);break;case"linear":n=G.linearGradient(i,a);break;case"radial":n=G.radialGradient(i,a);break;case"angular":n=G.conicGradient(i,a);break;case"solid":const{type:e,color:o,opacity:l}=i;n={type:e,style:Y.string(o,l)};break;default:r(i.r)||(n={type:"solid",style:Y.string(i)})}if(n){if(e(n.style)&&Rt(n.style)&&(n.isTransparent=!0),i.style){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}i.editing&&(n.editing=i.editing),i.blendMode&&(n.blendMode=i.blendMode)}return n}const At={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];S(r)||(r=[r]),kt=F.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=Et(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Bt(i,"__isAlphaPixelFill",n),Bt(i,"__isTransparentFill",a)):(Bt(i,"__isAlphaPixelStroke",n),Bt(i,"__isTransparentStroke",a),Bt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,ut(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(F.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),ut(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),ut(e,i),i.restoreBlendMode()):ut(e,i)}},fillPathOrText:ut,fillText:dt,stroke:mt,strokes:function(t,e,i){mt(t,e,i)},strokeText:ft,drawTextStroke:_t,shape:function(t,e,s){const n=e.getSameCanvas(),a=t.__nowWorld,o=e.bounds;let r,l,c,h,d,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))d=n,r=h=a;else{const{renderShapeSpread:n}=t.__layout;let p;if(i.fullImageShadow)p=a;else{const t=n?xt(o,u===f?n*u:[n*f,n*u]):o;p=bt(t,a)}c=o.getFitMatrix(p);let{a:g,d:_}=c;c.a<1&&(d=e.getSameCanvas(),t.__renderShape(d,s),u*=g,f*=_),h=vt(a,c),r=St(h,-c.e,-c.f);const w=s.matrix;w?(l=new T(c),l.multiply(w),g*=w.scaleX,_*=w.scaleY):l=c,l.withScale(g,_),s=Object.assign(Object.assign({},s),{matrix:l})}return t.__renderShape(n,s),{canvas:n,matrix:l,fitMatrix:c,bounds:r,worldCanvas:d,shapeBounds:h,scaleX:u,scaleY:f}}};let Lt={},Tt=C();const{get:Ct,rotateOfOuter:Wt,translate:Ot,scaleOfOuter:Mt,multiplyParent:Pt,scale:Dt,rotate:zt,skew:It}=W;function Ft(t,e,i,s,n,a,o){const r=Ct();Ot(r,e.x+i,e.y+s),Dt(r,n,a),o&&Wt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Ut(t,e,i,s,n,a,o,r,l){const c=Ct();Gt(c,e,i,s,n,a,o,r),l&&(Tt.a=e.width/l.width,Tt.d=e.height/l.height,Pt(c,Tt)),t.transform=c}function Yt(t,e,i,s,n,a,o,r,l,c,h,d){const u=Ct();if(d)Gt(u,e,n,a,o,r,l,c);else{if(l)if("center"===h)Wt(u,{x:i/2,y:s/2},l);else switch(zt(u,l),l){case 90:Ot(u,s,0);break;case 180:Ot(u,i,s);break;case 270:Ot(u,0,i)}Lt.x=e.x+n,Lt.y=e.y+a,Ot(u,Lt.x,Lt.y),o&&Mt(u,Lt,o,r)}t.transform=u}function Gt(t,e,i,s,n,a,o,r){o&&zt(t,o),r&&It(t,r.x,r.y),n&&Dt(t,n,a),Ot(t,e.x+i,e.y+s)}const{get:Nt,translate:Xt}=W,qt=new v,jt={},Vt={};function Ht(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=Qt(i,s,e)}function Qt(t,i,s){t.padding&&(i=qt.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:a}=s;const{opacity:o,mode:r,align:l,offset:c,scale:h,size:d,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,m=i.width===n&&i.height===a,y={mode:r},x="center"!==l&&(u||0)%180==90;let v,S;switch(L.set(Vt,0,0,x?a:n,x?n:a),r&&"cover"!==r&&"fit"!==r?((h||d)&&(O.getScaleData(h,d,s,jt),v=jt.scaleX,S=jt.scaleY),(l||_||g)&&(v&&L.scale(Vt,v,S,!0),l&&M.toPoint(l,Vt,i,Vt,!0,!0))):m&&!u||(v=S=L.getFitScale(i,Vt,"fit"!==r),L.put(i,s,l,v,!1,Vt),L.scale(Vt,v,S,!0)),c&&P.move(Vt,c),r){case"stretch":m||(n=i.width,a=i.height);break;case"normal":case"clip":(Vt.x||Vt.y||v||p||u||f)&&Ut(y,i,Vt.x,Vt.y,v,S,u,f,t.clipSize);break;case"repeat":(!m||v||u||f)&&Yt(y,i,n,a,Vt.x,Vt.y,v,S,u,f,l,t.freeTransform),g||(y.repeat="repeat");const e=A(g);(_||e)&&(y.gap=function(t,e,i,s,n){let a,o;A(t)?(a=t.x,o=t.y):a=o=t;return{x:Zt(a,i,n.width,e&&e.x),y:Zt(o,s,n.height,e&&e.y)}}(_,e&&g,Vt.width,Vt.height,i));break;default:v&&Ft(y,i,Vt.x,Vt.y,v,S,u)}return y.transform||(i.x||i.y)&&(y.transform=Nt(),Xt(y.transform,i.x,i.y)),v&&"stretch"!==r&&(y.scaleX=v,y.scaleY=S),y.width=n,y.height=a,o&&(y.opacity=o),w&&(y.filters=w),g&&(y.repeat=e(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function Zt(t,i,s,n){const a=e(t)||n?(n?s-n*i:s%i)/((n||Math.floor(s/i))-1):t;return"auto"===t&&a<0?0:a}let $t,Jt=new v;const{isSame:Kt}=L;function te(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Ht(n,s,i,a),!0}function ee(t,e){ne(t,D.LOAD,e)}function ie(t,e){ne(t,D.LOADED,e)}function se(t,e,i){e.error=i,t.forceUpdate("surface"),ne(t,D.ERROR,e)}function ne(t,e,i){t.hasEvent(e)&&t.emitEvent(new D(e,i))}function ae(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:oe,scale:re,copy:le}=W,{floor:ce,ceil:he,max:de,abs:ue}=Math;function fe(t,e,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,e.scaleFixed);const o=n+"-"+a+"-"+s;if(e.patternId===o||t.destroyed)return!1;{const{image:r,data:l}=e;let c,h,{width:d,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=ue(f),p=ue(p),h=oe(),le(h,g),re(h,1/f,1/p),n*=f,a*=p),d*=n,u*=a;const m=d*u;if(!_&&m>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(r.isSVG){const t=d/r.width;t>1&&(c=t/he(t))}else{const t=r.width*r.height;y>t&&(y=t)}m>y&&(c=Math.sqrt(m/y)),c&&(n/=c,a/=c,d/=c,u/=c),f&&(n/=f,a/=p);const x=w&&w.x*n,v=w&&w.y*a;if(g||1!==n||1!==a){const t=d+(x||0),e=u+(v||0);n/=t/de(ce(t),1),a/=e/de(ce(e),1),h||(h=oe(),g&&le(h,g)),re(h,1/n,1/a)}const S=r.getCanvas(d,u,l.opacity,l.filters,x,v,t.leafer&&t.leafer.config.smooth),b=r.getPattern(S,_||i.origin.noRepeat||"no-repeat",h,e);return e.style=b,e.patternId=o,!0}}function pe(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const ge={image:function(t,e,i,s,n){let a,o;const r=E.get(i);return $t&&i===$t.paint&&Kt(s,$t.boxBounds)?a=$t.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),$t=r.use>1?{leafPaint:a,paint:i,boxBounds:Jt.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(te(t,e,i,r,a,s),n&&(ee(t,o),ie(t,o))):r.error?n&&se(t,o,r.error):(n&&(ae(t,!0),ee(t,o)),a.loadId=r.load(()=>{ae(t,!1),t.destroyed||(te(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),ie(t,o)),a.loadId=void 0},e=>{ae(t,!1),se(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=e,{data:c}=s;if(!c||s.patternId===a+"-"+o+"-"+r&&!N.running)return!1;if(n)if(c.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&l.isResizing(t)||N.running)){let{width:t,height:e}=c;t*=a*r,e*=o*r,c.scaleX&&(t*=c.scaleX,e*=c.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,c),!0):(!s.style||s.sync||N.running?fe(t,s,r):s.patternTask||(s.patternTask=E.patternTasker.add(()=>pe(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&fe(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:fe,recycleImage:function(t,e){const i=e["_"+t];if(S(i)){let s,n,a,o,r;for(let l=0,c=i.length;l<c;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,E.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],S(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:Ht,getPatternData:Qt,fillOrFitMode:Ft,clipMode:Ut,repeatMode:Yt},{toPoint:_e}=z,{hasTransparent:we}=Y,me={},ye={};function xe(t,i,s,n){if(s){let a,o,r,l;for(let t=0,c=s.length;t<c;t++)a=s[t],e(a)?(r=t/(c-1),o=Y.string(a,n)):(r=a.offset,o=Y.string(a.color,n)),i.addColorStop(r,o),!l&&we(o)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:ve,getDistance:Se}=P,{get:be,rotateOfOuter:ke,scaleOfOuter:Be}=W,{toPoint:Re}=z,Ee={},Ae={};function Le(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=ve(e,i);a=be(),n?(Be(a,e,o/r*(s||1),1),ke(a,e,t+90)):(Be(a,e,1,o/r*(s||1)),ke(a,e,t))}return a}const{getDistance:Te}=P,{toPoint:Ce}=z,We={},Oe={};const Me={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;_e(s||"top",e,me),_e(n||"bottom",e,ye);const r=i.canvas.createLinearGradient(me.x,me.y,ye.x,ye.y),l={type:a,style:r};return xe(l,r,t.stops,o),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Re(s||"center",e,Ee),Re(n||"bottom",e,Ae);const l=i.canvas.createRadialGradient(Ee.x,Ee.y,0,Ee.x,Ee.y,Se(Ee,Ae)),c={type:a,style:l};xe(c,l,t.stops,o);const h=Le(e,Ee,Ae,r,!0);return h&&(c.transform=h),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ce(s||"center",e,We),Ce(n||"bottom",e,Oe);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,We.x,We.y):i.canvas.createRadialGradient(We.x,We.y,0,We.x,We.y,Te(We,Oe)),c={type:a,style:l};xe(c,l,t.stops,o);const h=Le(e,We,Oe,r||1,i.conicGradientRotate90);return h&&(c.transform=h),c},getTransform:Le},{copy:Pe,toOffsetOutBounds:De}=L,ze={},Ie={};function Fe(t,e,s,n){const{bounds:a,shapeBounds:o}=n;if(i.fullImageShadow){if(Pe(ze,t.bounds),ze.x+=e.x-o.x,ze.y+=e.y-o.y,s){const{fitMatrix:t}=n;ze.x-=(a.x+(t?t.e:0)+a.width/2)*(s-1),ze.y-=(a.y+(t?t.f:0)+a.height/2)*(s-1),ze.width*=s,ze.height*=s}t.copyWorld(n.canvas,t.bounds,ze)}else s&&(Pe(ze,e),ze.x-=e.width/2*(s-1),ze.y-=e.height/2*(s-1),ze.width*=s,ze.height*=s),t.copyWorld(n.canvas,o,s?ze:e)}const{toOffsetOutBounds:Ue}=L,Ye={};const Ge={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:c,shapeBounds:h,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;De(c,Ie),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Ie.offsetX+r.x*d*_,Ie.offsetY+r.y*u*_,r.blur*d*_,Y.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Fe(f,Ie,n,i),s=c,r.box&&(f.restore(),f.save(),l&&(f.copyWorld(f,c,a,"copy"),s=a),l?f.copyWorld(l,a,a,"destination-out"):f.copyWorld(i.canvas,h,c,"destination-out")),X.isTransformShadow(r)?X.renderTransformShadow(t,e,f,s,r):m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:c,shapeBounds:h,scaleX:d,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ue(c,Ye),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Ye.offsetX+r.x*d*_,Ye.offsetY+r.y*u*_,r.blur*d*_),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*_:0,Fe(f,Ye,n,i),f.restore(),l?(f.copyWorld(f,c,a,"copy"),f.copyWorld(l,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,h,c,"source-out"),s=c),f.fillWorld(s,Y.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowSpread:function(t,e){let i=0;return e.forEach(t=>i=Math.max(i,Math.max(Math.abs(t.y),Math.abs(t.x))+(t.spread>0?t.spread:0)+1.5*t.blur)),i},isTransformShadow(t){}},{excludeRenderBounds:Ne}=x;let Xe;function qe(t,e,i,s,n,a,o,r){switch(e){case"grayscale":Xe||(Xe=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);Ve(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":Ve(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function je(t){return t.getSameCanvas(!1,!0)}function Ve(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}q.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let c=0,h=l.length;c<h;c++){if(i=l[c],r=i.__.mask,r){o&&(qe(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,Xe=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=je(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=je(t)),n||(n=je(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||Ne(i,e)||i.__render(t,e);continue}const h=1===a&&i.__.__blendMode;h&&qe(this,o,t,n,s,a,void 0,!1),Ne(i,e)||i.__render(n||t,e),h&&qe(this,o,t,n,s,a,h,!1)}qe(this,o,t,n,s,a,void 0,!0)};const He=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Qe=He+"_#~&*+\\=|≮≯≈≠=…",Ze=new RegExp([[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]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function $e(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Je=$e("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ke=$e("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),ti=$e(He),ei=$e(Qe),ii=$e("- —/~|┆·");var si;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(si||(si={}));const{Letter:ni,Single:ai,Before:oi,After:ri,Symbol:li,Break:ci}=si;function hi(t){return Je[t]?ni:ii[t]?ci:Ke[t]?oi:ti[t]?ri:ei[t]?li:Ze.test(t)?ai:ni}const di={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function ui(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:fi}=di,{Letter:pi,Single:gi,Before:_i,After:wi,Symbol:mi,Break:yi}=si;let xi,vi,Si,bi,ki,Bi,Ri,Ei,Ai,Li,Ti,Ci,Wi,Oi,Mi,Pi,Di,zi=[];function Ii(t,e){Ai&&!Ei&&(Ei=Ai),xi.data.push({char:t,width:e}),Si+=e}function Fi(){bi+=Si,xi.width=Si,vi.words.push(xi),xi={data:[]},Si=0}function Ui(){Oi&&(Mi.paraNumber++,vi.paraStart=!0,Oi=!1),Ai&&(vi.startCharSize=Ei,vi.endCharSize=Ai,Ei=0),vi.width=bi,Pi.width?fi(vi):Di&&Yi(),zi.push(vi),vi={words:[]},bi=0}function Yi(){bi>(Mi.maxWidth||0)&&(Mi.maxWidth=bi)}const{top:Gi,right:Ni,bottom:Xi,left:qi}=I;function ji(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const Vi={getDrawData:function(t,s){e(t)||(t=String(t));let n=0,a=0,o=s.__getInput("width")||0,r=s.__getInput("height")||0;const{textDecoration:l,__font:c,__padding:h}=s;h&&(o?(n=h[qi],o-=h[Ni]+h[qi]):s.autoSizeAlign||(n=h[qi]),r?(a=h[Gi],r-=h[Gi]+h[Xi]):s.autoSizeAlign||(a=h[Gi]));const d={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=c};return function(t,e,s){Mi=t,zi=t.rows,Pi=t.bounds,Di=!Pi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:l,height:c}=Pi;if(l||c||n||"none"!==o){const t="none"!==s.textWrap,i="break"===s.textWrap;Oi=!0,Ti=null,Ei=Ri=Ai=Si=bi=0,xi={data:[]},vi={words:[]},n&&(e=[...e]);for(let s=0,c=e.length;s<c;s++)Bi=e[s],"\n"===Bi?(Si&&Fi(),vi.paraEnd=!0,Ui(),Oi=!0):(Li=hi(Bi),Li===pi&&"none"!==o&&(Bi=ui(Bi,o,!Si)),Ri=r.measureText(Bi).width,n&&(n<0&&(Ai=Ri),Ri+=n),Ci=Li===gi&&(Ti===gi||Ti===pi)||Ti===gi&&Li!==wi,Wi=!(Li!==_i&&Li!==gi||Ti!==mi&&Ti!==wi),ki=Oi&&a?l-a:l,t&&l&&bi+Si+Ri>ki&&(i?(Si&&Fi(),bi&&Ui()):(Wi||(Wi=Li===pi&&Ti==wi),Ci||Wi||Li===yi||Li===_i||Li===gi||Si+Ri>ki?(Si&&Fi(),bi&&Ui()):bi&&Ui()))," "===Bi&&!0!==Oi&&bi+Si===0||(Li===yi?(" "===Bi&&Si&&Fi(),Ii(Bi,Ri),Fi()):Ci||Wi?(Si&&Fi(),Ii(Bi,Ri)):Ii(Bi,Ri)),Ti=Li);Si&&Fi(),bi&&Ui(),zi.length>0&&(zi[zi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Mi.paraNumber++,bi=r.measureText(t).width,zi.push({x:a||0,text:t,width:bi,paraStart:!0}),Di&&Yi()})}(d,t,s),h&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ji(e,"x",t[qi]);break;case"right":ji(e,"x",-t[Ni])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ji(e,"y",t[Gi]);break;case"bottom":ji(e,"y",-t[Xi])}}(h,d,s,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:c,verticalAlign:h,paraSpacing:d,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(d?d*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(h){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,S=g||u?g:t.maxWidth;for(let o=0,h=n;o<h;o++){if(y=i[o],y.x=f,y.width<g||y.width>g&&!l)switch(c){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&d&&o>0&&(m+=d),y.y=m,m+=a,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),x=y.x,v=y.width,r<0&&(y.width<0?(v=-y.width+e.fontSize+r,x-=v,v+=e.fontSize):v-=r),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(d,s),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,c,h,d,u;s.forEach(t=>{t.words&&(c=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-c)/(u-1):0,h=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===h?(t.x+=c,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=c,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===h?(d={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,d),(t.isOverflow||" "!==d.char)&&t.data.push(d)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)})),t.words=null)})}(d,s,o),d.overflow&&function(t,e,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=e;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const c=r?i.canvas.measureText(r).width:0,h=s+n-c;("none"===e.textWrap?a:[a[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<h));s--){if(l<h&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=c,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(d,s,n,o),"none"!==l&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,A(a)?(i=a.type,a.color&&(t.decorationColor=Y.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(d,s),d}};const Hi={string:function(t,i){const n=s(i)&&i<1;if(e(t)){if(!n||!Y.object)return t;t=Y.object(t)}let a=r(t.a)?1:t.a;n&&(a*=i);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}};Object.assign(j,Vi),Object.assign(Y,Hi),Object.assign(U,At),Object.assign(F,ge),Object.assign(G,Me),Object.assign(X,Ge);try{wx&&Z(0,wx)}catch(t){}export{lt as Layouter,V as LeaferCanvas,ht as Renderer,$ as Watcher,Z as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as n,DataHelper as a,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as l,FileHelper as c,Creator as d,LeaferImage as h,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as v,Bounds as x,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as E,isObject as A,BoundsHelper as L,FourNumberHelper as T,Matrix as C,getMatrixData as O,MatrixHelper as W,MathHelper as M,AlignHelper as P,PointHelper as D,ImageEvent as I,AroundHelper as z,Direction4 as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{PaintImage as U,Paint as Y,ColorConvert as G,PaintGradient as N,Export as q,Group as X,TextConvert as j,Effect as V}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class H extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:e,height:a,pixelRatio:o}=this.config,r={width:e||t.width,height:a||t.height,pixelRatio:o};this.resize(r),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,n,a){this.context.roundRect(t,e,i,n,s(a)?[a]:a)}),n(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};a.copyAttrs(e,this,o),this.resize(t),r(this.width)||this.resizeListener(new l(t,e))}}const{mineType:Q,fileType:Z}=c;function $(t,e){i.origin={createCanvas:(t,i,s)=>{const n={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(n):e.createOffScreenCanvas(n)},canvasToDataURL:(t,e,i)=>t.toDataURL(Q(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let n=t.toDataURL(Q(Z(e)),s);return n=n.substring(n.indexOf("64,")+3),i.origin.download(n,e)},download:(t,s)=>new Promise((n,a)=>{let o;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,o=!0);const r=e.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){o?i.miniapp.saveToAlbum(s).then(()=>{r.unlink({filePath:s}),n()}):n()},fail(t){a(t)}})}),loadImage:t=>new Promise((e,s)=>{const n=i.canvas.view.createImage();n.onload=()=>{e(n)},n.onerror=t=>{s(t)},n.src=i.image.getRealURL(t)}),noRepeat:"repeat-x"},i.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=d.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(d,{canvas:(t,e)=>new H(t,e),image:t=>new h(t)}),i.name="miniapp",i.requestRender=function(t){const{view:e}=i.renderCanvas||i.canvas;e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)},u(i,"devicePixelRatio",{get:()=>Math.max(1,wx.getWindowInfo?wx.getWindowInfo().pixelRatio:wx.getSystemInfoSync().pixelRatio)});class J{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=a.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:K,updateBounds:tt,updateChange:et}=m,{pushAllChildBranch:it,pushAllParent:st}=y;const{worldBounds:nt}=v;class at{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,nt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,nt),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:ot,updateAllChange:rt}=m,lt=b.get("Layouter");class ct{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=a.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){lt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?lt.warn("layouting"):this.times>3?lt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=B,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new B(n,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(K(t,!0),e.add(t),t.isBranch&&it(t,e),st(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),st(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||tt(s[t])}tt(i)}})}(this.__levelList),function(t){t.list.forEach(et)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new B(a,r,this.times)),i.emitEvent(new B(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=B,a=this.getBlocks(new f(e));e.emitEvent(new B(i,a,this.times)),ct.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,a,this.times)),e.emitEvent(new B(n,a,this.times)),this.addBlocks(a),R.end(t)}static fullLayout(t){ot(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=b.get("Renderer");class ht{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=a.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,dt.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new x(s);i.save(),s.spread(ht.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:s}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),i.render(this.target,s,a),this.renderBounds=e=e||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:n}=this;n.length>30&&n.shift(),n.push(t),this.FPS=Math.round(n.reduce((t,e)=>t+e,0)/n.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[l.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ut(t,e){const i=t.__,{rows:s,decorationY:n}=i.__textDrawData;let a;i.__isPlacehold&&i.placeholderColor&&(e.fillStyle=i.placeholderColor);for(let t=0,i=s.length;t<i;t++)a=s[t],a.text?e.fillText(a.text,a.x,a.y):a.data&&a.data.forEach(t=>{e.fillText(t.char,t.x,a.y)});if(n){const{decorationColor:t,decorationHeight:a}=i.__textDrawData;t&&(e.fillStyle=t),s.forEach(t=>n.forEach(i=>e.fillRect(t.x,t.y+i,t.width,a)))}}function ft(t,e){t.__.__font?ut(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function pt(t,e,i){switch(e.__.strokeAlign){case"center":gt(t,1,e,i);break;case"inside":_t(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?gt(t,2,e,i):_t(t,"outside",e,i)}}function gt(t,e,i,s){const n=i.__;A(t)?mt(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),wt(i,s))}function _t(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,gt(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",ut(i,n),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function wt(t,e){let i,s=t.__.__textDrawData;const{rows:n,decorationY:a}=s;for(let t=0,s=n.length;t<s;t++)i=n[t],i.text?e.strokeText(i.text,i.x,i.y):i.data&&i.data.forEach(t=>{e.strokeText(t.char,t.x,i.y)});if(a){const{decorationHeight:t}=s;n.forEach(i=>a.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}}function mt(t,e,i,s,n){let a;const o=s.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,c=t.length;l<c;l++)if(a=t[l],(!a.image||!U.checkImage(s,n,a,!1))&&a.style){if(r){const{strokeStyle:t}=a;t?n.setStroke(a.style,o.__getRealStrokeWidth(t)*e,o,t):n.setStroke(a.style,o.__strokeWidth*e,o)}else n.strokeStyle=a.style;a.blendMode?(n.saveBlendMode(a.blendMode),i?wt(s,n):n.stroke(),n.restoreBlendMode()):i?wt(s,n):n.stroke()}}function yt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)pt(t,e,i);else switch(s.strokeAlign){case"center":vt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),vt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)vt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),vt(t,2,e,a),a.clipUI(s),a.clearWorld(n),m.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function vt(t,e,i,s){const n=i.__;A(t)?mt(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&Y.strokeArrow(t,i,s)}ht.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new J(t,e),layouter:(t,e)=>new ct(t,e),renderer:(t,e,i)=>new ht(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=ct.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:xt,copyAndSpread:St,toOuterOf:bt,getOuterOf:kt,getByMove:Bt,move:Rt,getIntersectData:Et}=L,At={};let Lt;const{stintSet:Tt}=a,{hasTransparent:Ct}=G;function Ot(t,i,s){if(!A(i)||!1===i.visible||0===i.opacity)return;let n;const{boxBounds:a}=s.__layout;switch(i.type){case"image":n=U.image(s,t,i,a,!Lt||!Lt[i.url]);break;case"linear":n=N.linearGradient(i,a);break;case"radial":n=N.radialGradient(i,a);break;case"angular":n=N.conicGradient(i,a);break;case"solid":const{type:e,color:o,opacity:l}=i;n={type:e,style:G.string(o,l)};break;default:r(i.r)||(n={type:"solid",style:G.string(i)})}if(n){if(e(n.style)&&Ct(n.style)&&(n.isTransparent=!0),i.style){if(0===i.style.strokeWidth)return;n.strokeStyle=i.style}i.editing&&(n.editing=i.editing),i.blendMode&&(n.blendMode=i.blendMode)}return n}const Wt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];S(r)||(r=[r]),Lt=U.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=Ot(t,r[n],e))&&(s.push(i),i.strokeStyle&&(o||(o=1),i.strokeStyle.strokeWidth&&(o=Math.max(o,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length&&s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(Tt(i,"__isAlphaPixelFill",n),Tt(i,"__isTransparentFill",a)):(Tt(i,"__isAlphaPixelStroke",n),Tt(i,"__isTransparentStroke",a),Tt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,ft(e,i)},fills:function(t,e,i){let s;for(let n=0,a=t.length;n<a;n++){if(s=t[n],s.image){if(U.checkImage(e,i,s,!e.__.__font))continue;if(!s.style){!n&&s.image.isPlacehold&&e.drawImagePlaceholder(i,s.image);continue}}if(i.fillStyle=s.style,s.transform||s.scaleFixed){if(i.save(),s.transform&&i.transform(s.transform),s.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===s.scaleFixed||"zoom-in"===s.scaleFixed&&t>1&&n>1)&&i.scale(1/t,1/n)}s.blendMode&&(i.blendMode=s.blendMode),ft(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),ft(e,i),i.restoreBlendMode()):ft(e,i)}},fillPathOrText:ft,fillText:ut,stroke:yt,strokes:function(t,e,i){yt(t,e,i)},strokeText:pt,drawTextStroke:wt,shape:function(t,e,s){const n=e.getSameCanvas(),a=e.bounds,o=t.__nowWorld,r=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let c,d,h,u,f,p;bt(r.strokeSpread?(St(At,r.boxBounds,r.strokeSpread),At):r.boxBounds,o,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,c=f=l,d=o;else{let n;if(i.fullImageShadow)n=l;else{const t=r.renderShapeSpread?xt(a,T.swapAndScale(r.renderShapeSpread,g,_)):a;n=Et(t,l)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=kt(l,u),c=Bt(f,-u.e,-u.f),d=kt(o,u),Rt(d,-u.e,-u.f);const y=s.matrix;y?(h=new C(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(n,s),{canvas:n,matrix:h,fitMatrix:u,bounds:c,renderBounds:d,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Mt={},Pt=O();const{get:Dt,rotateOfOuter:It,translate:zt,scaleOfOuter:Ft,multiplyParent:Ut,scale:Yt,rotate:Gt,skew:Nt}=W;function qt(t,e,i,s,n,a,o){const r=Dt();zt(r,e.x+i,e.y+s),Yt(r,n,a),o&&It(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function Xt(t,e,i,s,n,a,o,r,l,c){const d=Dt();Vt(d,e,i,s,n,a,o,r),l&&(Pt.a=l,Pt.d=c,Ut(d,Pt)),t.transform=d}function jt(t,e,i,s,n,a,o,r,l,c,d,h){const u=Dt();if(h)Vt(u,e,n,a,o,r,l,c);else{if(l)if("center"===d)It(u,{x:i/2,y:s/2},l);else switch(Gt(u,l),l){case 90:zt(u,s,0);break;case 180:zt(u,i,s);break;case 270:zt(u,0,i)}Mt.x=e.x+n,Mt.y=e.y+a,zt(u,Mt.x,Mt.y),o&&Ft(u,Mt,o,r)}t.transform=u}function Vt(t,e,i,s,n,a,o,r){o&&Gt(t,o),r&&Nt(t,r.x,r.y),n&&Yt(t,n,a),zt(t,e.x+i,e.y+s)}const{get:Ht,translate:Qt}=W,Zt=new x,$t={},Jt={};function Kt(t,e,i,s){const{changeful:n,sync:a,scaleFixed:o}=i;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=te(i,s,e)}function te(t,i,s){t.padding&&(i=Zt.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:n,height:a}=s;const{opacity:o,mode:r,align:l,offset:c,scale:d,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,m=i.width===n&&i.height===a,y={mode:r},v="center"!==l&&(u||0)%180==90;let x,S;switch(L.set(Jt,0,0,v?a:n,v?n:a),r&&"cover"!==r&&"fit"!==r?((d||h)&&(M.getScaleData(d,h,s,$t),x=$t.scaleX,S=$t.scaleY),(l||_||g)&&(x&&L.scale(Jt,x,S,!0),l&&P.toPoint(l,Jt,i,Jt,!0,!0))):m&&!u||(x=S=L.getFitScale(i,Jt,"fit"!==r),L.put(i,s,l,x,!1,Jt),L.scale(Jt,x,S,!0)),c&&D.move(Jt,c),r){case"stretch":m||(n=i.width,a=i.height);break;case"normal":case"clip":if(Jt.x||Jt.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),Xt(y,i,Jt.x,Jt.y,x,S,u,f,t,e),t&&(x=x?x*t:x,S=S?S*e:e)}break;case"repeat":(!m||x||u||f)&&jt(y,i,n,a,Jt.x,Jt.y,x,S,u,f,l,t.freeTransform),g||(y.repeat="repeat");const e=A(g);(_||e)&&(y.gap=function(t,e,i,s,n){let a,o;A(t)?(a=t.x,o=t.y):a=o=t;return{x:ee(a,i,n.width,e&&e.x),y:ee(o,s,n.height,e&&e.y)}}(_,e&&g,Jt.width,Jt.height,i));break;default:x&&qt(y,i,Jt.x,Jt.y,x,S,u)}return y.transform||(i.x||i.y)&&(y.transform=Ht(),Qt(y.transform,i.x,i.y)),x&&"stretch"!==r&&(y.scaleX=x,y.scaleY=S),y.width=n,y.height=a,o&&(y.opacity=o),w&&(y.filters=w),g&&(y.repeat=e(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y}function ee(t,i,s,n){const a=e(t)||n?(n?s-n*i:s%i)/((n||Math.floor(s/i))-1):t;return"auto"===t&&a<0?0:a}let ie,se=new x;const{isSame:ne}=L;function ae(t,e,i,s,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=s.width/e.pixelRatio,e.__naturalHeight=s.height/e.pixelRatio,e.__autoSide)return t.forceUpdate("width"),t.__proxyData&&(t.setProxyAttr("width",e.width),t.setProxyAttr("height",e.height)),!1}return n.data||Kt(n,s,i,a),!0}function oe(t,e){ce(t,I.LOAD,e)}function re(t,e){ce(t,I.LOADED,e)}function le(t,e,i){e.error=i,t.forceUpdate("surface"),ce(t,I.ERROR,e)}function ce(t,e,i){t.hasEvent(e)&&t.emitEvent(new I(e,i))}function de(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:he,scale:ue,copy:fe}=W,{floor:pe,ceil:ge,max:_e,abs:we}=Math;function me(t,e,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,e.scaleFixed);const o=n+"-"+a+"-"+s;if(e.patternId===o||t.destroyed)return!1;{const{image:r,data:l}=e;let c,d,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=we(f),p=we(p),d=he(),fe(d,g),ue(d,1/f,1/p),n*=f,a*=p),h*=n,u*=a;const m=h*u;if(!_&&m>i.image.maxCacheSize)return!1;let y=i.image.maxPatternSize;if(r.isSVG){const t=h/r.width;t>1&&(c=t/ge(t))}else{const t=r.width*r.height;y>t&&(y=t)}m>y&&(c=Math.sqrt(m/y)),c&&(n/=c,a/=c,h/=c,u/=c),f&&(n/=f,a/=p);const v=w&&w.x*n,x=w&&w.y*a;if(g||1!==n||1!==a){const t=h+(v||0),e=u+(x||0);n/=t/_e(pe(t),1),a/=e/_e(pe(e),1),d||(d=he(),g&&fe(d,g)),ue(d,1/n,1/a)}const S=r.getCanvas(h,u,l.opacity,l.filters,v,x,t.leafer&&t.leafer.config.smooth),b=r.getPattern(S,_||i.origin.noRepeat||"no-repeat",d,e);return e.style=b,e.patternId=o,!0}}function ye(t,e,i,s){return new(i||(i=Promise))(function(n,a){function o(t){try{l(s.next(t))}catch(t){a(t)}}function r(t){try{l(s.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const ve={image:function(t,e,i,s,n){let a,o;const r=E.get(i);return ie&&i===ie.paint&&ne(s,ie.boxBounds)?a=ie.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),ie=r.use>1?{leafPaint:a,paint:i,boxBounds:se.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ae(t,e,i,r,a,s),n&&(oe(t,o),re(t,o))):r.error?n&&le(t,o,r.error):(n&&(de(t,!0),oe(t,o)),a.loadId=r.load(()=>{de(t,!1),t.destroyed||(ae(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),re(t,o)),a.loadId=void 0},e=>{de(t,!1),le(t,o,e),a.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),a},checkImage:function(t,e,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=e,{data:c}=s;if(!c||s.patternId===a+"-"+o+"-"+r&&!q.running)return!1;if(n)if(c.repeat)n=!1;else if(!(s.changeful||"miniapp"===i.name&&l.isResizing(t)||q.running)){let{width:t,height:e}=c;t*=a*r,e*=o*r,c.scaleX&&(t*=c.scaleX,e*=c.scaleY),n=t*e>i.image.maxCacheSize}return n?(t.__.__isFastShadow&&(e.fillStyle=s.style||"#000",e.fill()),function(t,e,i,s){e.save(),e.clipUI(t),i.blendMode&&(e.blendMode=i.blendMode);s.opacity&&(e.opacity*=s.opacity);s.transform&&e.transform(s.transform);e.drawImage(i.image.getFull(s.filters),0,0,s.width,s.height),e.restore()}(t,e,s,c),!0):(!s.style||s.sync||q.running?me(t,s,r):s.patternTask||(s.patternTask=E.patternTasker.add(()=>ye(this,void 0,void 0,function*(){s.patternTask=null,e.bounds.hit(t.__nowWorld)&&me(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:me,recycleImage:function(t,e){const i=e["_"+t];if(S(i)){let s,n,a,o,r;for(let l=0,c=i.length;l<c;l++)s=i[l],n=s.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,E.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],S(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:Kt,getPatternData:te,fillOrFitMode:qt,clipMode:Xt,repeatMode:jt},{toPoint:xe}=z,{hasTransparent:Se}=G,be={},ke={};function Be(t,i,s,n){if(s){let a,o,r,l;for(let t=0,c=s.length;t<c;t++)a=s[t],e(a)?(r=t/(c-1),o=G.string(a,n)):(r=a.offset,o=G.string(a.color,n)),i.addColorStop(r,o),!l&&Se(o)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:Re,getDistance:Ee}=D,{get:Ae,rotateOfOuter:Le,scaleOfOuter:Te}=W,{toPoint:Ce}=z,Oe={},We={};function Me(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=Re(e,i);a=Ae(),n?(Te(a,e,o/r*(s||1),1),Le(a,e,t+90)):(Te(a,e,1,o/r*(s||1)),Le(a,e,t))}return a}const{getDistance:Pe}=D,{toPoint:De}=z,Ie={},ze={};const Fe={linearGradient:function(t,e){let{from:s,to:n,type:a,opacity:o}=t;xe(s||"top",e,be),xe(n||"bottom",e,ke);const r=i.canvas.createLinearGradient(be.x,be.y,ke.x,ke.y),l={type:a,style:r};return Be(l,r,t.stops,o),l},radialGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ce(s||"center",e,Oe),Ce(n||"bottom",e,We);const l=i.canvas.createRadialGradient(Oe.x,Oe.y,0,Oe.x,Oe.y,Ee(Oe,We)),c={type:a,style:l};Be(c,l,t.stops,o);const d=Me(e,Oe,We,r,!0);return d&&(c.transform=d),c},conicGradient:function(t,e){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;De(s||"center",e,Ie),De(n||"bottom",e,ze);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,Ie.x,Ie.y):i.canvas.createRadialGradient(Ie.x,Ie.y,0,Ie.x,Ie.y,Pe(Ie,ze)),c={type:a,style:l};Be(c,l,t.stops,o);const d=Me(e,Ie,ze,r||1,i.conicGradientRotate90);return d&&(c.transform=d),c},getTransform:Me},{copy:Ue,move:Ye,toOffsetOutBounds:Ge}=L,{max:Ne}=Math,qe={},Xe=new C,je={};function Ve(t,e){let i,s,n,a,o=0,r=0,l=0,c=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=t.spread||0,a=1.5*(t.blur||0),o=Ne(o,n+a-s),r=Ne(r,n+a+i),l=Ne(l,n+a+s),c=Ne(c,n+a-i)}),o===r&&r===l&&l===c?o:[o,r,l,c]}function He(t,e,i,s,n,a,o){if(s.spread){const i=1+2*s.spread/t.__layout.strokeBounds.width*a*(o?-1:1);return Xe.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},i),Xe}}function Qe(t,e,s){const{shapeBounds:n}=s;let a,o;i.fullImageShadow?(Ue(qe,t.bounds),Ye(qe,e.x-n.x,e.y-n.y),a=t.bounds,o=qe):(a=n,o=e),t.copyWorld(s.canvas,a,o)}const{toOffsetOutBounds:Ze}=L,$e={};const Je=Ve;const Ke={shadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=o.length-1;Ge(l,je,c),o.forEach((o,g)=>{let _=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.setWorldShadow(je.offsetX+o.x*h*_,je.offsetY+o.y*u*_,o.blur*h*_,G.string(o.color)),n=He(t,f,i,o,je,_),n&&f.setTransform(n),Qe(f,je,i),n&&f.resetTransform(),s=c,o.box&&(f.restore(),f.save(),r&&(f.copyWorld(f,c,a,"copy"),s=a),r?f.copyWorld(r,a,a,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),m.copyCanvasByWorld(t,e,f,s,o.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=o.length-1;Ze(l,$e,c),o.forEach((o,g)=>{let _=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow($e.offsetX+o.x*h*_,$e.offsetY+o.y*u*_,o.blur*h*_),n=He(t,f,0,o,$e,_,!0),n&&f.setTransform(n),Qe(f,$e,i),f.restore(),r?(f.copyWorld(f,c,a,"copy"),f.copyWorld(r,a,a,"source-out"),s=a):(f.copyWorld(i.canvas,d,l,"source-out"),s=c),f.fillWorld(s,G.string(o.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,o.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Ve,getShadowTransform:He,isTransformShadow(t){},getInnerShadowSpread:Je},{excludeRenderBounds:ti}=v;let ei;function ii(t,e,i,s,n,a,o,r){switch(e){case"grayscale":ei||(ei=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,n,a){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),a&&s.recycle(o);ni(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":ni(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function si(t){return t.getSameCanvas(!1,!0)}function ni(t,e,i,s,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,n),a?i.recycle(o):i.clearWorld(o)}X.prototype.__renderMask=function(t,e){let i,s,n,a,o,r;const{children:l}=this;for(let c=0,d=l.length;c<d;c++){if(i=l[c],r=i.__.mask,r){o&&(ii(this,o,t,n,s,a,void 0,!0),s=n=null),"clipping"!==r&&"clipping-path"!==r||ti(i,e)||i.__render(t,e),a=i.__.opacity,ei=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=si(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=si(t)),n||(n=si(t)),i.__render(s,e));continue}const d=1===a&&i.__.__blendMode;d&&ii(this,o,t,n,s,a,void 0,!1),ti(i,e)||i.__render(n||t,e),d&&ii(this,o,t,n,s,a,d,!1)}ii(this,o,t,n,s,a,void 0,!0)};const ai=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",oi=ai+"_#~&*+\\=|≮≯≈≠=…",ri=new RegExp([[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]].map(([t,e])=>`[\\u${t.toString(16)}-\\u${e.toString(16)}]`).join("|"));function li(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ci=li("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),di=li("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),hi=li(ai),ui=li(oi),fi=li("- —/~|┆·");var pi;!function(t){t[t.Letter=0]="Letter",t[t.Single=1]="Single",t[t.Before=2]="Before",t[t.After=3]="After",t[t.Symbol=4]="Symbol",t[t.Break=5]="Break"}(pi||(pi={}));const{Letter:gi,Single:_i,Before:wi,After:mi,Symbol:yi,Break:vi}=pi;function xi(t){return ci[t]?gi:fi[t]?vi:di[t]?wi:hi[t]?mi:ui[t]?yi:ri.test(t)?_i:gi}const Si={trimRight(t){const{words:e}=t;let i,s=0,n=e.length;for(let a=n-1;a>-1&&(i=e[a].data[0]," "===i.char);a--)s++,t.width-=i.width;s&&e.splice(n-s,s)}};function bi(t,e,i){switch(e){case"title":return i?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:ki}=Si,{Letter:Bi,Single:Ri,Before:Ei,After:Ai,Symbol:Li,Break:Ti}=pi;let Ci,Oi,Wi,Mi,Pi,Di,Ii,zi,Fi,Ui,Yi,Gi,Ni,qi,Xi,ji,Vi,Hi=[];function Qi(t,e){Fi&&!zi&&(zi=Fi),Ci.data.push({char:t,width:e}),Wi+=e}function Zi(){Mi+=Wi,Ci.width=Wi,Oi.words.push(Ci),Ci={data:[]},Wi=0}function $i(){qi&&(Xi.paraNumber++,Oi.paraStart=!0,qi=!1),Fi&&(Oi.startCharSize=zi,Oi.endCharSize=Fi,zi=0),Oi.width=Mi,ji.width?ki(Oi):Vi&&Ji(),Hi.push(Oi),Oi={words:[]},Mi=0}function Ji(){Mi>(Xi.maxWidth||0)&&(Xi.maxWidth=Mi)}const{top:Ki,right:ts,bottom:es,left:is}=F;function ss(t,e,i){const{bounds:s,rows:n}=t;s[e]+=i;for(let t=0;t<n.length;t++)n[t][e]+=i}const ns={getDrawData:function(t,s){e(t)||(t=String(t));let n=0,a=0,o=s.__getInput("width")||0,r=s.__getInput("height")||0;const{textDecoration:l,__font:c,__padding:d}=s;d&&(o?(n=d[is],o-=d[ts]+d[is]):s.autoSizeAlign||(n=d[is]),r?(a=d[Ki],r-=d[Ki]+d[es]):s.autoSizeAlign||(a=d[Ki]));const h={bounds:{x:n,y:a,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=c};return function(t,e,s){Xi=t,Hi=t.rows,ji=t.bounds,Vi=!ji.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=i,{width:l,height:c}=ji;if(l||c||n||"none"!==o){const t="none"!==s.textWrap,i="break"===s.textWrap;qi=!0,Yi=null,zi=Ii=Fi=Wi=Mi=0,Ci={data:[]},Oi={words:[]},n&&(e=[...e]);for(let s=0,c=e.length;s<c;s++)Di=e[s],"\n"===Di?(Wi&&Zi(),Oi.paraEnd=!0,$i(),qi=!0):(Ui=xi(Di),Ui===Bi&&"none"!==o&&(Di=bi(Di,o,!Wi)),Ii=r.measureText(Di).width,n&&(n<0&&(Fi=Ii),Ii+=n),Gi=Ui===Ri&&(Yi===Ri||Yi===Bi)||Yi===Ri&&Ui!==Ai,Ni=!(Ui!==Ei&&Ui!==Ri||Yi!==Li&&Yi!==Ai),Pi=qi&&a?l-a:l,t&&l&&Mi+Wi+Ii>Pi&&(i?(Wi&&Zi(),Mi&&$i()):(Ni||(Ni=Ui===Bi&&Yi==Ai),Gi||Ni||Ui===Ti||Ui===Ei||Ui===Ri||Wi+Ii>Pi?(Wi&&Zi(),Mi&&$i()):Mi&&$i()))," "===Di&&!0!==qi&&Mi+Wi===0||(Ui===Ti?(" "===Di&&Wi&&Zi(),Qi(Di,Ii),Zi()):Gi||Ni?(Wi&&Zi(),Qi(Di,Ii)):Qi(Di,Ii)),Yi=Ui);Wi&&Zi(),Mi&&$i(),Hi.length>0&&(Hi[Hi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Xi.paraNumber++,Mi=r.measureText(t).width,Hi.push({x:a||0,text:t,width:Mi,paraStart:!0}),Vi&&Ji()})}(h,t,s),d&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":ss(e,"x",t[is]);break;case"right":ss(e,"x",-t[ts])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":ss(e,"y",t[Ki]);break;case"bottom":ss(e,"y",-t[es])}}(d,h,s,o,r),function(t,e){const{rows:i,bounds:s}=t,n=i.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:c,verticalAlign:d,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=a*n+(h?h*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,a),n>1&&(t.overflow=n);else if(_||u)switch(d){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,S=g||u?g:t.maxWidth;for(let o=0,d=n;o<d;o++){if(y=i[o],y.x=f,y.width<g||y.width>g&&!l)switch(c){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&o>0&&(m+=h),y.y=m,m+=a,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),v=y.x,x=y.width,r<0&&(y.width<0?(x=-y.width+e.fontSize+r,v-=x,x+=e.fontSize):x-=r),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(h,s),function(t,e,i){const{rows:s}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,c,d,h,u;s.forEach(t=>{t.words&&(c=a&&t.paraStart?a:0,u=t.words.length,l=i&&("justify"===n||"both"===n)&&u>1?(i-t.width-c)/(u-1):0,d=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===d?(t.x+=c,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=c,r=t.x,t.data=[],t.words.forEach((e,i)=>{1===d?(h={char:"",x:r},r=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,i,s){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||i===u-1||(r+=l,t.width+=l)})),t.words=null)})}(h,s,o),h.overflow&&function(t,e,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=e;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const c=r?i.canvas.measureText(r).width:0,d=s+n-c;("none"===e.textWrap?a:[a[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let i=e.data.length-1;for(let s=i;s>-1&&(t=e.data[s],l=t.x+t.width,!(s===i&&l<d));s--){if(l<d&&" "!==t.char||!s){e.data.splice(s+1),e.width-=t.width;break}e.width-=t.width}e.width+=c,e.data.push({char:r,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(h,s,n,o),"none"!==l&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,A(a)?(i=a.type,a.color&&(t.decorationColor=G.string(a.color)),a.offset&&(s=Math.min(.3*n,Math.max(a.offset,.15*-n)))):i=a,i){case"under":t.decorationY=[.15*n+s];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+s,.35*-n]}}(h,s),h}};const as={string:function(t,i){const n=s(i)&&i<1;if(e(t)){if(!n||!G.object)return t;t=G.object(t)}let a=r(t.a)?1:t.a;n&&(a*=i);const o=t.r+","+t.g+","+t.b;return 1===a?"rgb("+o+")":"rgba("+o+","+a+")"}};Object.assign(j,ns),Object.assign(G,as),Object.assign(Y,Wt),Object.assign(U,ve),Object.assign(N,Fe),Object.assign(V,Ke);try{wx&&$(0,wx)}catch(t){}export{ct as Layouter,H as LeaferCanvas,ht as Renderer,J as Watcher,$ as useCanvas};
|
|
2
2
|
//# sourceMappingURL=miniapp.esm.min.js.map
|