@leafer-draw/node 1.9.7 → 1.9.9
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/node.cjs +109 -81
- package/dist/node.esm.js +110 -82
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +10 -10
package/dist/node.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, isObject, BoundsHelper, Matrix, isUndefined, isString, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, isArray, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, isObject, BoundsHelper, FourNumberHelper, Matrix, isUndefined, isString, getMatrixData, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4, isNumber } from "@leafer/core";
|
|
2
2
|
|
|
3
3
|
export * from "@leafer/core";
|
|
4
4
|
|
|
@@ -456,6 +456,7 @@ class Renderer {
|
|
|
456
456
|
usePartRender: true,
|
|
457
457
|
maxFPS: 120
|
|
458
458
|
};
|
|
459
|
+
this.frames = [];
|
|
459
460
|
this.target = target;
|
|
460
461
|
this.canvas = canvas;
|
|
461
462
|
if (userConfig) this.config = DataHelper.default(userConfig, this.config);
|
|
@@ -608,12 +609,15 @@ class Renderer {
|
|
|
608
609
|
const target = this.target;
|
|
609
610
|
if (this.requestTime || !target) return;
|
|
610
611
|
if (target.parentApp) return target.parentApp.requestRender(false);
|
|
611
|
-
|
|
612
|
+
this.requestTime = this.frameTime || Date.now();
|
|
612
613
|
const render = () => {
|
|
613
|
-
const nowFPS = 1e3 / (Date.now() - requestTime);
|
|
614
|
+
const nowFPS = 1e3 / ((this.frameTime = Date.now()) - this.requestTime);
|
|
614
615
|
const {maxFPS: maxFPS} = this.config;
|
|
615
|
-
if (maxFPS && nowFPS > maxFPS
|
|
616
|
-
|
|
616
|
+
if (maxFPS && nowFPS > maxFPS) return Platform.requestRender(render);
|
|
617
|
+
const {frames: frames} = this;
|
|
618
|
+
if (frames.length > 30) frames.shift();
|
|
619
|
+
frames.push(nowFPS);
|
|
620
|
+
this.FPS = Math.round(frames.reduce((a, b) => a + b, 0) / frames.length);
|
|
617
621
|
this.requestTime = 0;
|
|
618
622
|
this.checkRender();
|
|
619
623
|
};
|
|
@@ -880,24 +884,29 @@ function drawOutside(stroke, ui, canvas) {
|
|
|
880
884
|
}
|
|
881
885
|
}
|
|
882
886
|
|
|
883
|
-
const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = BoundsHelper;
|
|
887
|
+
const {getSpread: getSpread, copyAndSpread: copyAndSpread, toOuterOf: toOuterOf, getOuterOf: getOuterOf, getByMove: getByMove, move: move$1, getIntersectData: getIntersectData} = BoundsHelper;
|
|
888
|
+
|
|
889
|
+
const tempBounds$1 = {};
|
|
884
890
|
|
|
885
891
|
function shape(ui, current, options) {
|
|
886
892
|
const canvas = current.getSameCanvas();
|
|
887
|
-
const nowWorld = ui.__nowWorld,
|
|
888
|
-
|
|
893
|
+
const currentBounds = current.bounds, nowWorld = ui.__nowWorld, layout = ui.__layout;
|
|
894
|
+
const nowWorldShapeBounds = ui.__nowWorldShapeBounds || (ui.__nowWorldShapeBounds = {});
|
|
895
|
+
toOuterOf(layout.strokeSpread ? (copyAndSpread(tempBounds$1, layout.boxBounds, layout.strokeSpread),
|
|
896
|
+
tempBounds$1) : layout.boxBounds, nowWorld, nowWorldShapeBounds);
|
|
897
|
+
let bounds, renderBounds, matrix, fitMatrix, shapeBounds, worldCanvas;
|
|
889
898
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
890
|
-
if (currentBounds.includes(
|
|
899
|
+
if (currentBounds.includes(nowWorldShapeBounds)) {
|
|
891
900
|
worldCanvas = canvas;
|
|
892
|
-
bounds = shapeBounds =
|
|
901
|
+
bounds = shapeBounds = nowWorldShapeBounds;
|
|
902
|
+
renderBounds = nowWorld;
|
|
893
903
|
} else {
|
|
894
|
-
const {renderShapeSpread: spread} = ui.__layout;
|
|
895
904
|
let worldClipBounds;
|
|
896
905
|
if (Platform.fullImageShadow) {
|
|
897
|
-
worldClipBounds =
|
|
906
|
+
worldClipBounds = nowWorldShapeBounds;
|
|
898
907
|
} else {
|
|
899
|
-
const spreadBounds =
|
|
900
|
-
worldClipBounds = getIntersectData(spreadBounds,
|
|
908
|
+
const spreadBounds = layout.renderShapeSpread ? getSpread(currentBounds, FourNumberHelper.swapAndScale(layout.renderShapeSpread, scaleX, scaleY)) : currentBounds;
|
|
909
|
+
worldClipBounds = getIntersectData(spreadBounds, nowWorldShapeBounds);
|
|
901
910
|
}
|
|
902
911
|
fitMatrix = currentBounds.getFitMatrix(worldClipBounds);
|
|
903
912
|
let {a: fitScaleX, d: fitScaleY} = fitMatrix;
|
|
@@ -907,8 +916,10 @@ function shape(ui, current, options) {
|
|
|
907
916
|
scaleX *= fitScaleX;
|
|
908
917
|
scaleY *= fitScaleY;
|
|
909
918
|
}
|
|
910
|
-
shapeBounds = getOuterOf(
|
|
919
|
+
shapeBounds = getOuterOf(nowWorldShapeBounds, fitMatrix);
|
|
911
920
|
bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
|
|
921
|
+
renderBounds = getOuterOf(nowWorld, fitMatrix);
|
|
922
|
+
move$1(renderBounds, -fitMatrix.e, -fitMatrix.f);
|
|
912
923
|
const userMatrix = options.matrix;
|
|
913
924
|
if (userMatrix) {
|
|
914
925
|
matrix = new Matrix(fitMatrix);
|
|
@@ -927,6 +938,7 @@ function shape(ui, current, options) {
|
|
|
927
938
|
matrix: matrix,
|
|
928
939
|
fitMatrix: fitMatrix,
|
|
929
940
|
bounds: bounds,
|
|
941
|
+
renderBounds: renderBounds,
|
|
930
942
|
worldCanvas: worldCanvas,
|
|
931
943
|
shapeBounds: shapeBounds,
|
|
932
944
|
scaleX: scaleX,
|
|
@@ -1030,7 +1042,7 @@ const PaintModule = {
|
|
|
1030
1042
|
shape: shape
|
|
1031
1043
|
};
|
|
1032
1044
|
|
|
1033
|
-
let origin = {}, tempMatrix = getMatrixData();
|
|
1045
|
+
let origin = {}, tempMatrix$1 = getMatrixData();
|
|
1034
1046
|
|
|
1035
1047
|
const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = MatrixHelper;
|
|
1036
1048
|
|
|
@@ -1045,12 +1057,12 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
|
|
|
1045
1057
|
data.transform = transform;
|
|
1046
1058
|
}
|
|
1047
1059
|
|
|
1048
|
-
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew,
|
|
1060
|
+
function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY) {
|
|
1049
1061
|
const transform = get$3();
|
|
1050
1062
|
layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
|
|
1051
|
-
if (
|
|
1052
|
-
tempMatrix.a =
|
|
1053
|
-
multiplyParent(transform, tempMatrix);
|
|
1063
|
+
if (clipScaleX) {
|
|
1064
|
+
tempMatrix$1.a = clipScaleX, tempMatrix$1.d = clipScaleY;
|
|
1065
|
+
multiplyParent(transform, tempMatrix$1);
|
|
1054
1066
|
}
|
|
1055
1067
|
data.transform = transform;
|
|
1056
1068
|
}
|
|
@@ -1151,7 +1163,12 @@ function getPatternData(paint, box, image) {
|
|
|
1151
1163
|
|
|
1152
1164
|
case "normal":
|
|
1153
1165
|
case "clip":
|
|
1154
|
-
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
|
|
1166
|
+
if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) {
|
|
1167
|
+
let clipScaleX, clipScaleY;
|
|
1168
|
+
if (clipSize) clipScaleX = box.width / clipSize.width, clipScaleY = box.height / clipSize.height;
|
|
1169
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, clipScaleX, clipScaleY);
|
|
1170
|
+
if (clipScaleX) scaleX = scaleX ? scaleX * clipScaleX : scaleX, scaleY = scaleY ? scaleY * clipScaleY : clipScaleY;
|
|
1171
|
+
}
|
|
1155
1172
|
break;
|
|
1156
1173
|
|
|
1157
1174
|
case "repeat":
|
|
@@ -1309,7 +1326,7 @@ function ignoreRender(ui, value) {
|
|
|
1309
1326
|
|
|
1310
1327
|
const {get: get$1, scale: scale, copy: copy$1} = MatrixHelper;
|
|
1311
1328
|
|
|
1312
|
-
const {floor: floor, ceil: ceil, max: max, abs: abs} = Math;
|
|
1329
|
+
const {floor: floor, ceil: ceil, max: max$1, abs: abs} = Math;
|
|
1313
1330
|
|
|
1314
1331
|
function createPattern(ui, paint, pixelRatio) {
|
|
1315
1332
|
let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
|
|
@@ -1358,8 +1375,8 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1358
1375
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
1359
1376
|
const canvasWidth = width + (xGap || 0);
|
|
1360
1377
|
const canvasHeight = height + (yGap || 0);
|
|
1361
|
-
scaleX /= canvasWidth / max(floor(canvasWidth), 1);
|
|
1362
|
-
scaleY /= canvasHeight / max(floor(canvasHeight), 1);
|
|
1378
|
+
scaleX /= canvasWidth / max$1(floor(canvasWidth), 1);
|
|
1379
|
+
scaleY /= canvasHeight / max$1(floor(canvasHeight), 1);
|
|
1363
1380
|
if (!imageMatrix) {
|
|
1364
1381
|
imageMatrix = get$1();
|
|
1365
1382
|
if (transform) copy$1(imageMatrix, transform);
|
|
@@ -1385,17 +1402,15 @@ function checkImage(ui, canvas, paint, allowDraw) {
|
|
|
1385
1402
|
if (allowDraw) {
|
|
1386
1403
|
if (data.repeat) {
|
|
1387
1404
|
allowDraw = false;
|
|
1388
|
-
} else {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
height *= data.scaleY;
|
|
1396
|
-
}
|
|
1397
|
-
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
1405
|
+
} else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || Export.running)) {
|
|
1406
|
+
let {width: width, height: height} = data;
|
|
1407
|
+
width *= scaleX * pixelRatio;
|
|
1408
|
+
height *= scaleY * pixelRatio;
|
|
1409
|
+
if (data.scaleX) {
|
|
1410
|
+
width *= data.scaleX;
|
|
1411
|
+
height *= data.scaleY;
|
|
1398
1412
|
}
|
|
1413
|
+
allowDraw = width * height > Platform.image.maxCacheSize;
|
|
1399
1414
|
}
|
|
1400
1415
|
}
|
|
1401
1416
|
if (allowDraw) {
|
|
@@ -1575,75 +1590,82 @@ const PaintGradientModule = {
|
|
|
1575
1590
|
getTransform: getTransform
|
|
1576
1591
|
};
|
|
1577
1592
|
|
|
1578
|
-
const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper;
|
|
1593
|
+
const {copy: copy, move: move, toOffsetOutBounds: toOffsetOutBounds$1} = BoundsHelper, {max: max} = Math;
|
|
1579
1594
|
|
|
1580
|
-
const tempBounds = {};
|
|
1595
|
+
const tempBounds = {}, tempMatrix = new Matrix;
|
|
1581
1596
|
|
|
1582
1597
|
const offsetOutBounds$1 = {};
|
|
1583
1598
|
|
|
1584
1599
|
function shadow(ui, current, shape) {
|
|
1585
|
-
let copyBounds,
|
|
1586
|
-
const {__nowWorld: nowWorld
|
|
1600
|
+
let copyBounds, transform;
|
|
1601
|
+
const {__nowWorld: nowWorld} = ui;
|
|
1587
1602
|
const {shadow: shadow} = ui.__;
|
|
1588
|
-
const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
1603
|
+
const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
1589
1604
|
const other = current.getSameCanvas();
|
|
1590
1605
|
const end = shadow.length - 1;
|
|
1591
|
-
toOffsetOutBounds$1(bounds, offsetOutBounds$1);
|
|
1606
|
+
toOffsetOutBounds$1(bounds, offsetOutBounds$1, renderBounds);
|
|
1592
1607
|
shadow.forEach((item, index) => {
|
|
1593
1608
|
let otherScale = 1;
|
|
1594
1609
|
if (item.scaleFixed) {
|
|
1595
1610
|
const sx = Math.abs(nowWorld.scaleX);
|
|
1596
1611
|
if (sx > 1) otherScale = 1 / sx;
|
|
1597
1612
|
}
|
|
1598
|
-
other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, ColorConvert.string(item.color));
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1613
|
+
other.setWorldShadow(offsetOutBounds$1.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds$1.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale, ColorConvert.string(item.color));
|
|
1614
|
+
transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds$1, otherScale);
|
|
1615
|
+
if (transform) other.setTransform(transform);
|
|
1616
|
+
drawWorldShadow(other, offsetOutBounds$1, shape);
|
|
1617
|
+
if (transform) other.resetTransform();
|
|
1618
|
+
copyBounds = renderBounds;
|
|
1602
1619
|
if (item.box) {
|
|
1603
1620
|
other.restore();
|
|
1604
1621
|
other.save();
|
|
1605
1622
|
if (worldCanvas) {
|
|
1606
|
-
other.copyWorld(other,
|
|
1623
|
+
other.copyWorld(other, renderBounds, nowWorld, "copy");
|
|
1607
1624
|
copyBounds = nowWorld;
|
|
1608
1625
|
}
|
|
1609
1626
|
worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
|
|
1610
1627
|
}
|
|
1611
|
-
|
|
1628
|
+
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
1612
1629
|
if (end && index < end) other.clearWorld(copyBounds);
|
|
1613
1630
|
});
|
|
1614
1631
|
other.recycle(copyBounds);
|
|
1615
1632
|
}
|
|
1616
1633
|
|
|
1617
|
-
function
|
|
1618
|
-
let
|
|
1619
|
-
shadow.forEach(item =>
|
|
1620
|
-
|
|
1634
|
+
function getShadowRenderSpread(_ui, shadow) {
|
|
1635
|
+
let top = 0, right = 0, bottom = 0, left = 0, x, y, spread, blur;
|
|
1636
|
+
shadow.forEach(item => {
|
|
1637
|
+
x = item.x || 0, y = item.y || 0, spread = item.spread || 0, blur = (item.blur || 0) * 1.5;
|
|
1638
|
+
top = max(top, spread + blur - y);
|
|
1639
|
+
right = max(right, spread + blur + x);
|
|
1640
|
+
bottom = max(bottom, spread + blur + y);
|
|
1641
|
+
left = max(left, spread + blur - x);
|
|
1642
|
+
});
|
|
1643
|
+
return top === right && right === bottom && bottom === left ? top : [ top, right, bottom, left ];
|
|
1621
1644
|
}
|
|
1622
1645
|
|
|
1623
|
-
function
|
|
1624
|
-
|
|
1646
|
+
function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
|
|
1647
|
+
if (shadow.spread) {
|
|
1648
|
+
const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
|
|
1649
|
+
tempMatrix.set().scaleOfOuter({
|
|
1650
|
+
x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
|
|
1651
|
+
y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
|
|
1652
|
+
}, spreadScale);
|
|
1653
|
+
return tempMatrix;
|
|
1654
|
+
}
|
|
1655
|
+
return undefined;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
function drawWorldShadow(canvas, outBounds, shape) {
|
|
1659
|
+
const {shapeBounds: shapeBounds} = shape;
|
|
1660
|
+
let from, to;
|
|
1625
1661
|
if (Platform.fullImageShadow) {
|
|
1626
1662
|
copy(tempBounds, canvas.bounds);
|
|
1627
|
-
tempBounds.x
|
|
1628
|
-
|
|
1629
|
-
if (spreadScale) {
|
|
1630
|
-
const {fitMatrix: fitMatrix} = shape;
|
|
1631
|
-
tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
|
|
1632
|
-
tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
|
|
1633
|
-
tempBounds.width *= spreadScale;
|
|
1634
|
-
tempBounds.height *= spreadScale;
|
|
1635
|
-
}
|
|
1636
|
-
canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
|
|
1663
|
+
move(tempBounds, outBounds.x - shapeBounds.x, outBounds.y - shapeBounds.y);
|
|
1664
|
+
from = canvas.bounds, to = tempBounds;
|
|
1637
1665
|
} else {
|
|
1638
|
-
|
|
1639
|
-
copy(tempBounds, outBounds);
|
|
1640
|
-
tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
|
|
1641
|
-
tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
|
|
1642
|
-
tempBounds.width *= spreadScale;
|
|
1643
|
-
tempBounds.height *= spreadScale;
|
|
1644
|
-
}
|
|
1645
|
-
canvas.copyWorld(shape.canvas, shapeBounds, spreadScale ? tempBounds : outBounds);
|
|
1666
|
+
from = shapeBounds, to = outBounds;
|
|
1646
1667
|
}
|
|
1668
|
+
canvas.copyWorld(shape.canvas, from, to);
|
|
1647
1669
|
}
|
|
1648
1670
|
|
|
1649
1671
|
const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
|
|
@@ -1651,13 +1673,13 @@ const {toOffsetOutBounds: toOffsetOutBounds} = BoundsHelper;
|
|
|
1651
1673
|
const offsetOutBounds = {};
|
|
1652
1674
|
|
|
1653
1675
|
function innerShadow(ui, current, shape) {
|
|
1654
|
-
let copyBounds,
|
|
1655
|
-
const {__nowWorld: nowWorld
|
|
1676
|
+
let copyBounds, transform;
|
|
1677
|
+
const {__nowWorld: nowWorld} = ui;
|
|
1656
1678
|
const {innerShadow: innerShadow} = ui.__;
|
|
1657
|
-
const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
1679
|
+
const {worldCanvas: worldCanvas, bounds: bounds, renderBounds: renderBounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
|
|
1658
1680
|
const other = current.getSameCanvas();
|
|
1659
1681
|
const end = innerShadow.length - 1;
|
|
1660
|
-
toOffsetOutBounds(bounds, offsetOutBounds);
|
|
1682
|
+
toOffsetOutBounds(bounds, offsetOutBounds, renderBounds);
|
|
1661
1683
|
innerShadow.forEach((item, index) => {
|
|
1662
1684
|
let otherScale = 1;
|
|
1663
1685
|
if (item.scaleFixed) {
|
|
@@ -1665,17 +1687,18 @@ function innerShadow(ui, current, shape) {
|
|
|
1665
1687
|
if (sx > 1) otherScale = 1 / sx;
|
|
1666
1688
|
}
|
|
1667
1689
|
other.save();
|
|
1668
|
-
other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
|
|
1669
|
-
|
|
1670
|
-
|
|
1690
|
+
other.setWorldShadow(offsetOutBounds.offsetX + (item.x || 0) * scaleX * otherScale, offsetOutBounds.offsetY + (item.y || 0) * scaleY * otherScale, (item.blur || 0) * scaleX * otherScale);
|
|
1691
|
+
transform = Effect.getShadowTransform(ui, other, shape, item, offsetOutBounds, otherScale, true);
|
|
1692
|
+
if (transform) other.setTransform(transform);
|
|
1693
|
+
drawWorldShadow(other, offsetOutBounds, shape);
|
|
1671
1694
|
other.restore();
|
|
1672
1695
|
if (worldCanvas) {
|
|
1673
|
-
other.copyWorld(other,
|
|
1696
|
+
other.copyWorld(other, renderBounds, nowWorld, "copy");
|
|
1674
1697
|
other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
|
|
1675
1698
|
copyBounds = nowWorld;
|
|
1676
1699
|
} else {
|
|
1677
1700
|
other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
|
|
1678
|
-
copyBounds =
|
|
1701
|
+
copyBounds = renderBounds;
|
|
1679
1702
|
}
|
|
1680
1703
|
other.fillWorld(copyBounds, ColorConvert.string(item.color), "source-in");
|
|
1681
1704
|
LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
|
|
@@ -1684,6 +1707,8 @@ function innerShadow(ui, current, shape) {
|
|
|
1684
1707
|
other.recycle(copyBounds);
|
|
1685
1708
|
}
|
|
1686
1709
|
|
|
1710
|
+
const getInnerShadowSpread = getShadowRenderSpread;
|
|
1711
|
+
|
|
1687
1712
|
function blur(ui, current, origin) {
|
|
1688
1713
|
const {blur: blur} = ui.__;
|
|
1689
1714
|
origin.setWorldBlur(blur * ui.__nowWorld.a);
|
|
@@ -1698,10 +1723,12 @@ const EffectModule = {
|
|
|
1698
1723
|
innerShadow: innerShadow,
|
|
1699
1724
|
blur: blur,
|
|
1700
1725
|
backgroundBlur: backgroundBlur,
|
|
1701
|
-
|
|
1726
|
+
getShadowRenderSpread: getShadowRenderSpread,
|
|
1727
|
+
getShadowTransform: getShadowTransform,
|
|
1702
1728
|
isTransformShadow(_shadow) {
|
|
1703
1729
|
return undefined;
|
|
1704
|
-
}
|
|
1730
|
+
},
|
|
1731
|
+
getInnerShadowSpread: getInnerShadowSpread
|
|
1705
1732
|
};
|
|
1706
1733
|
|
|
1707
1734
|
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
|
|
@@ -1718,6 +1745,7 @@ Group.prototype.__renderMask = function(canvas, options) {
|
|
|
1718
1745
|
maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
|
|
1719
1746
|
maskCanvas = contentCanvas = null;
|
|
1720
1747
|
}
|
|
1748
|
+
if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1721
1749
|
maskOpacity = child.__.opacity;
|
|
1722
1750
|
usedGrayscaleAlpha = false;
|
|
1723
1751
|
if (mask === "path" || mask === "clipping-path") {
|
|
@@ -1735,7 +1763,6 @@ Group.prototype.__renderMask = function(canvas, options) {
|
|
|
1735
1763
|
if (!contentCanvas) contentCanvas = getCanvas(canvas);
|
|
1736
1764
|
child.__render(maskCanvas, options);
|
|
1737
1765
|
}
|
|
1738
|
-
if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
|
|
1739
1766
|
continue;
|
|
1740
1767
|
}
|
|
1741
1768
|
const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
|
|
@@ -2297,6 +2324,7 @@ const TextConvertModule = {
|
|
|
2297
2324
|
};
|
|
2298
2325
|
|
|
2299
2326
|
function string(color, opacity) {
|
|
2327
|
+
if (!color) return "#000";
|
|
2300
2328
|
const doOpacity = isNumber(opacity) && opacity < 1;
|
|
2301
2329
|
if (isString(color)) {
|
|
2302
2330
|
if (doOpacity && ColorConvert.object) color = ColorConvert.object(color); else return color;
|
package/dist/node.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,Platform as e,canvasPatch as i,FileHelper as s,Creator as n,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as c,ChildEvent as d,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as y,LeafLevelList as m,LayoutEvent as v,Run as x,ImageManager as b,ResizeEvent as S,isObject as B,BoundsHelper as k,Matrix as R,isUndefined as E,isString as L,getMatrixData as A,MatrixHelper as T,MathHelper as O,AlignHelper as C,PointHelper as M,ImageEvent as W,AroundHelper as D,Direction4 as P,isNumber as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as I}from"fs";import{PaintImage as U,Paint as Y,ColorConvert as X,PaintGradient as z,Export as N,Effect as j,Group as q,TextConvert as G,TwoPointBoundsHelper as H,Bounds as V,FileHelper as Q,Platform as J,isUndefined as Z,Matrix as $,MathHelper as K,Creator as tt,TaskProcessor as et,Resource as it,LeaferCanvasBase as st,Debug as nt,Plugin as at,UI as ot}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function rt(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;class lt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,i(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i),this.clientBounds=this.bounds}}const{mineType:ct,fileType:dt}=s;function ht(t,i){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURLSync(e,{quality:i}),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,i)=>t.saveAs(e,{quality:i}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:s}=i;e.origin={createCanvas:(e,i,s)=>new t(e,i,s),canvasToDataURL:(t,e,i)=>t.toDataURL(ct(e),i),canvasToBolb:(t,e,i)=>rt(this,void 0,void 0,function*(){return t.toBuffer(ct(e),i)}),canvasSaveAs:(t,e,i)=>rt(this,void 0,void 0,function*(){return I(e,t.toBuffer(ct(dt(e)),i))}),download(t,e){},loadImage:t=>s(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new lt(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ut{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=l.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(c.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===d.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 h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[d.ADD,d.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:ft,updateBounds:pt,updateChange:gt}=f,{pushAllChildBranch:_t,pushAllParent:wt}=p;const{worldBounds:yt}=g;class mt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,yt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,yt),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:vt,updateAllChange:xt}=f,bt=y.get("Layouter");class St{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new m,this.target=t,e&&(this.config=l.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(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){bt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?bt.warn("layouting"):this.times>3?bt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.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=x.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=v,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new v(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?(ft(t,!0),e.add(t),t.isBranch&&_t(t,e),wt(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),wt(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||pt(s[t])}pt(i)}})}(this.__levelList),function(t){t.list.forEach(gt)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new v(a,r,this.times)),i.emitEvent(new v(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:n}=v,a=this.getBlocks(new r(e));e.emitEvent(new v(i,a,this.times)),St.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new v(s,a,this.times)),e.emitEvent(new v(n,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){vt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),xt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new mt([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new mt(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_([[v.REQUEST,this.layout,this],[v.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const Bt=y.get("Renderer");class kt{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=l.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(v.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(c.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(c.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(c.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,Bt.log(e.innerName,"---\x3e");try{this.emitRender(c.START),this.renderOnce(t),this.emitRender(c.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,Bt.error(t)}Bt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return Bt.warn("rendering");if(this.times>3)return Bt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(c.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(c.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(c.RENDER,this.renderBounds,this.renderOptions),this.emitRender(c.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=x.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),n=new _(s);i.save(),s.spread(kt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,n),i.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,i){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),y.showRepaint&&y.drawRepaint(s,t),e.render(this.target,s,a),this.renderBounds=i=i||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=i:this.totalBounds.add(i),s.updateRender(i)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;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 i=this.requestTime=Date.now(),s=()=>{const t=1e3/(Date.now()-i),{maxFPS:n}=this.config;if(n&&t>n-.5)return e.requestRender(s);this.FPS=Math.min(120,Math.ceil(t)),this.requestTime=0,this.checkRender()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new _(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 _(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||Bt.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 c(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[c.REQUEST,this.update,this],[v.END,this.__onLayoutEnd,this],[c.AGAIN,this.renderAgain,this],[S.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 Rt(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 Et(t,e){t.__.__font?Rt(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Lt(t,e,i){switch(e.__.strokeAlign){case"center":At(t,1,e,i);break;case"inside":Tt(t,"inside",e,i);break;case"outside":e.__.__fillAfterStroke?At(t,2,e,i):Tt(t,"outside",e,i)}}function At(t,e,i,s){const n=i.__;B(t)?Ct(t,e,!0,i,s):(s.setStroke(t,n.__strokeWidth*e,n),Ot(i,s))}function Tt(t,e,i,s){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,At(t,2,i,n),n.blendMode="outside"===e?"destination-out":"destination-in",Rt(i,n),n.blendMode="normal",f.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}function Ot(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 Ct(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?Ot(s,n):n.stroke(),n.restoreBlendMode()):i?Ot(s,n):n.stroke()}}function Mt(t,e,i){const s=e.__;if(s.__strokeWidth)if(s.__font)Lt(t,e,i);else switch(s.strokeAlign){case"center":Wt(t,1,e,i);break;case"inside":!function(t,e,i){i.save(),i.clipUI(e),Wt(t,2,e,i),i.restore()}(t,e,i);break;case"outside":!function(t,e,i){const s=e.__;if(s.__fillAfterStroke)Wt(t,2,e,i);else{const{renderBounds:n}=e.__layout,a=i.getSameCanvas(!0,!0);e.__drawRenderPath(a),Wt(t,2,e,a),a.clipUI(s),a.clearWorld(n),f.copyCanvasByWorld(e,i,a),a.recycle(e.__nowWorld)}}(t,e,i)}}function Wt(t,e,i,s){const n=i.__;B(t)?Ct(t,e,!1,i,s):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&Y.strokeArrow(t,i,s)}kt.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new ut(t,e),layouter:(t,e)=>new St(t,e),renderer:(t,e,i)=>new kt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),e.layout=St.fullLayout,e.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new r,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:Dt,getOuterOf:Pt,getByMove:Ft,getIntersectData:It}=k;let Ut;const{stintSet:Yt}=l,{hasTransparent:Xt}=X;function zt(t,e,i){if(!B(e)||!1===e.visible||0===e.opacity)return;let s;const{boxBounds:n}=i.__layout;switch(e.type){case"image":s=U.image(i,t,e,n,!Ut||!Ut[e.url]);break;case"linear":s=z.linearGradient(e,n);break;case"radial":s=z.radialGradient(e,n);break;case"angular":s=z.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;s={type:a,style:X.string(o,r)};break;default:E(e.r)||(s={type:"solid",style:X.string(e)})}if(s){if(L(s.style)&&Xt(s.style)&&(s.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;s.strokeStyle=e.style}e.editing&&(s.editing=e.editing),e.blendMode&&(s.blendMode=e.blendMode)}return s}const Nt={compute:function(t,e){const i=e.__,s=[];let n,a,o,r=i.__input[t];w(r)||(r=[r]),Ut=U.recycleImage(t,i);for(let i,n=0,a=r.length;n<a;n++)(i=zt(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?(Yt(i,"__isAlphaPixelFill",n),Yt(i,"__isTransparentFill",a)):(Yt(i,"__isAlphaPixelStroke",n),Yt(i,"__isTransparentStroke",a),Yt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i){i.fillStyle=t,Et(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),Et(e,i),i.restore()}else s.blendMode?(i.saveBlendMode(s.blendMode),Et(e,i),i.restoreBlendMode()):Et(e,i)}},fillPathOrText:Et,fillText:Rt,stroke:Mt,strokes:function(t,e,i){Mt(t,e,i)},strokeText:Lt,drawTextStroke:Ot,shape:function(t,i,s){const n=i.getSameCanvas(),a=t.__nowWorld,o=i.bounds;let r,l,c,d,h,{scaleX:u,scaleY:f}=t.getRenderScaleData(!0);if(o.includes(a))h=n,r=d=a;else{const{renderShapeSpread:n}=t.__layout;let p;if(e.fullImageShadow)p=a;else{const t=n?Dt(o,u===f?n*u:[n*f,n*u]):o;p=It(t,a)}c=o.getFitMatrix(p);let{a:g,d:_}=c;c.a<1&&(h=i.getSameCanvas(),t.__renderShape(h,s),u*=g,f*=_),d=Pt(a,c),r=Ft(d,-c.e,-c.f);const w=s.matrix;w?(l=new R(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:h,shapeBounds:d,scaleX:u,scaleY:f}}};let jt={},qt=A();const{get:Gt,rotateOfOuter:Ht,translate:Vt,scaleOfOuter:Qt,multiplyParent:Jt,scale:Zt,rotate:$t,skew:Kt}=T;function te(t,e,i,s,n,a,o){const r=Gt();Vt(r,e.x+i,e.y+s),Zt(r,n,a),o&&Ht(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function ee(t,e,i,s,n,a,o,r,l){const c=Gt();se(c,e,i,s,n,a,o,r),l&&(qt.a=e.width/l.width,qt.d=e.height/l.height,Jt(c,qt)),t.transform=c}function ie(t,e,i,s,n,a,o,r,l,c,d,h){const u=Gt();if(h)se(u,e,n,a,o,r,l,c);else{if(l)if("center"===d)Ht(u,{x:i/2,y:s/2},l);else switch($t(u,l),l){case 90:Vt(u,s,0);break;case 180:Vt(u,i,s);break;case 270:Vt(u,0,i)}jt.x=e.x+n,jt.y=e.y+a,Vt(u,jt.x,jt.y),o&&Qt(u,jt,o,r)}t.transform=u}function se(t,e,i,s,n,a,o,r){o&&$t(t,o),r&&Kt(t,r.x,r.y),n&&Zt(t,n,a),Vt(t,e.x+i,e.y+s)}const{get:ne,translate:ae}=T,oe=new _,re={},le={};function ce(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=de(i,s,e)}function de(t,e,i){t.padding&&(e=oe.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:s,height:n}=i;const{opacity:a,mode:o,align:r,offset:l,scale:c,size:d,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===s&&e.height===n,y={mode:o},m="center"!==r&&(h||0)%180==90;let v,x;switch(k.set(le,0,0,m?n:s,m?s:n),o&&"cover"!==o&&"fit"!==o?((c||d)&&(O.getScaleData(c,d,i,re),v=re.scaleX,x=re.scaleY),(r||g||p)&&(v&&k.scale(le,v,x,!0),r&&C.toPoint(r,le,e,le,!0,!0))):w&&!h||(v=x=k.getFitScale(e,le,"fit"!==o),k.put(e,i,r,v,!1,le),k.scale(le,v,x,!0)),l&&M.move(le,l),o){case"stretch":w||(s=e.width,n=e.height);break;case"normal":case"clip":(le.x||le.y||v||f||h||u)&&ee(y,e,le.x,le.y,v,x,h,u,t.clipSize);break;case"repeat":(!w||v||h||u)&&ie(y,e,s,n,le.x,le.y,v,x,h,u,r,t.freeTransform),p||(y.repeat="repeat");const i=B(p);(g||i)&&(y.gap=function(t,e,i,s,n){let a,o;B(t)?(a=t.x,o=t.y):a=o=t;return{x:he(a,i,n.width,e&&e.x),y:he(o,s,n.height,e&&e.y)}}(g,i&&p,le.width,le.height,e));break;default:v&&te(y,e,le.x,le.y,v,x,h)}return y.transform||(e.x||e.y)&&(y.transform=ne(),ae(y.transform,e.x,e.y)),v&&"stretch"!==o&&(y.scaleX=v,y.scaleY=x),y.width=s,y.height=n,a&&(y.opacity=a),_&&(y.filters=_),p&&(y.repeat=L(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),y}function he(t,e,i,s){const n=L(t)||s?(s?i-s*e:i%e)/((s||Math.floor(i/e))-1):t;return"auto"===t&&n<0?0:n}let ue,fe=new _;const{isSame:pe}=k;function ge(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||ce(n,s,i,a),!0}function _e(t,e){me(t,W.LOAD,e)}function we(t,e){me(t,W.LOADED,e)}function ye(t,e,i){e.error=i,t.forceUpdate("surface"),me(t,W.ERROR,e)}function me(t,e,i){t.hasEvent(e)&&t.emitEvent(new W(e,i))}function ve(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:xe,scale:be,copy:Se}=T,{floor:Be,ceil:ke,max:Re,abs:Ee}=Math;function Le(t,i,s){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,i.scaleFixed);const o=n+"-"+a+"-"+s;if(i.patternId===o||t.destroyed)return!1;{const{image:r,data:l}=i;let c,d,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=s,a*=s,f&&(f=Ee(f),p=Ee(p),d=xe(),Se(d,g),be(d,1/f,1/p),n*=f,a*=p),h*=n,u*=a;const y=h*u;if(!_&&y>e.image.maxCacheSize)return!1;let m=e.image.maxPatternSize;if(r.isSVG){const t=h/r.width;t>1&&(c=t/ke(t))}else{const t=r.width*r.height;m>t&&(m=t)}y>m&&(c=Math.sqrt(y/m)),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/Re(Be(t),1),a/=e/Re(Be(e),1),d||(d=xe(),g&&Se(d,g)),be(d,1/n,1/a)}const b=r.getCanvas(h,u,l.opacity,l.filters,v,x,t.leafer&&t.leafer.config.smooth),S=r.getPattern(b,_||e.origin.noRepeat||"no-repeat",d,i);return i.style=S,i.patternId=o,!0}}const Ae={image:function(t,e,i,s,n){let a,o;const r=b.get(i);return ue&&i===ue.paint&&pe(s,ue.boxBounds)?a=ue.leafPaint:(a={type:i.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),ue=r.use>1?{leafPaint:a,paint:i,boxBounds:fe.set(s)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(ge(t,e,i,r,a,s),n&&(_e(t,o),we(t,o))):r.error?n&&ye(t,o,r.error):(n&&(ve(t,!0),_e(t,o)),a.loadId=r.load(()=>{ve(t,!1),t.destroyed||(ge(t,e,i,r,a,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),we(t,o)),a.loadId=void 0},e=>{ve(t,!1),ye(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,i,s,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,s.scaleFixed),{pixelRatio:r}=i,{data:l}=s;if(!l||s.patternId===a+"-"+o+"-"+r&&!N.running)return!1;if(n)if(l.repeat)n=!1;else if(!(s.changeful||"miniapp"===e.name&&S.isResizing(t)||N.running)){let{width:t,height:i}=l;t*=a*r,i*=o*r,l.scaleX&&(t*=l.scaleX,i*=l.scaleY),n=t*i>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(i.fillStyle=s.style||"#000",i.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,i,s,l),!0):(!s.style||s.sync||N.running?Le(t,s,r):s.patternTask||(s.patternTask=b.patternTasker.add(()=>rt(this,void 0,void 0,function*(){s.patternTask=null,i.bounds.hit(t.__nowWorld)&&Le(t,s,r),t.forceUpdate("surface")}),300)),!1)},createPattern:Le,recycleImage:function(t,e){const i=e["_"+t];if(w(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,b.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],w(o)||(o=[o])),n.unload(i[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:ce,getPatternData:de,fillOrFitMode:te,clipMode:ee,repeatMode:ie},{toPoint:Te}=D,{hasTransparent:Oe}=X,Ce={},Me={};function We(t,e,i,s){if(i){let n,a,o,r;for(let t=0,l=i.length;t<l;t++)n=i[t],L(n)?(o=t/(l-1),a=X.string(n,s)):(o=n.offset,a=X.string(n.color,s)),e.addColorStop(o,a),!r&&Oe(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:De,getDistance:Pe}=M,{get:Fe,rotateOfOuter:Ie,scaleOfOuter:Ue}=T,{toPoint:Ye}=D,Xe={},ze={};function Ne(t,e,i,s,n){let a;const{width:o,height:r}=t;if(o!==r||s){const t=De(e,i);a=Fe(),n?(Ue(a,e,o/r*(s||1),1),Ie(a,e,t+90)):(Ue(a,e,1,o/r*(s||1)),Ie(a,e,t))}return a}const{getDistance:je}=M,{toPoint:qe}=D,Ge={},He={};const Ve={linearGradient:function(t,i){let{from:s,to:n,type:a,opacity:o}=t;Te(s||"top",i,Ce),Te(n||"bottom",i,Me);const r=e.canvas.createLinearGradient(Ce.x,Ce.y,Me.x,Me.y),l={type:a,style:r};return We(l,r,t.stops,o),l},radialGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;Ye(s||"center",i,Xe),Ye(n||"bottom",i,ze);const l=e.canvas.createRadialGradient(Xe.x,Xe.y,0,Xe.x,Xe.y,Pe(Xe,ze)),c={type:a,style:l};We(c,l,t.stops,o);const d=Ne(i,Xe,ze,r,!0);return d&&(c.transform=d),c},conicGradient:function(t,i){let{from:s,to:n,type:a,opacity:o,stretch:r}=t;qe(s||"center",i,Ge),qe(n||"bottom",i,He);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ge.x,Ge.y):e.canvas.createRadialGradient(Ge.x,Ge.y,0,Ge.x,Ge.y,je(Ge,He)),c={type:a,style:l};We(c,l,t.stops,o);const d=Ne(i,Ge,He,r||1,e.conicGradientRotate90);return d&&(c.transform=d),c},getTransform:Ne},{copy:Qe,toOffsetOutBounds:Je}=k,Ze={},$e={};function Ke(t,i,s,n){const{bounds:a,shapeBounds:o}=n;if(e.fullImageShadow){if(Qe(Ze,t.bounds),Ze.x+=i.x-o.x,Ze.y+=i.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&&(Qe(Ze,i),Ze.x-=i.width/2*(s-1),Ze.y-=i.height/2*(s-1),Ze.width*=s,Ze.height*=s),t.copyWorld(n.canvas,o,s?Ze:i)}const{toOffsetOutBounds:ti}=k,ei={};const ii={shadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{shadow:r}=t.__,{worldCanvas:l,bounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=r.length-1;Je(c,$e),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow($e.offsetX+r.x*h*w,$e.offsetY+r.y*u*w,r.blur*h*w,X.string(r.color)),n=r.spread?1+2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*w:0,Ke(p,$e,n,i),s=c,r.box&&(p.restore(),p.save(),l&&(p.copyWorld(p,c,a,"copy"),s=a),l?p.copyWorld(l,a,a,"destination-out"):p.copyWorld(i.canvas,d,c,"destination-out")),j.isTransformShadow(r)?j.renderTransformShadow(t,e,p,s,r):f.copyCanvasByWorld(t,e,p,s,r.blendMode),g&&_<g&&p.clearWorld(s)}),p.recycle(s)},innerShadow:function(t,e,i){let s,n;const{__nowWorld:a,__layout:o}=t,{innerShadow:r}=t.__,{worldCanvas:l,bounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,p=e.getSameCanvas(),g=r.length-1;ti(c,ei),r.forEach((r,_)=>{let w=1;if(r.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(ei.offsetX+r.x*h*w,ei.offsetY+r.y*u*w,r.blur*h*w),n=r.spread?1-2*r.spread/(o.boxBounds.width+2*(o.strokeBoxSpread||0))*w:0,Ke(p,ei,n,i),p.restore(),l?(p.copyWorld(p,c,a,"copy"),p.copyWorld(l,a,a,"source-out"),s=a):(p.copyWorld(i.canvas,d,c,"source-out"),s=c),p.fillWorld(s,X.string(r.color),"source-in"),f.copyCanvasByWorld(t,e,p,s,r.blendMode),g&&_<g&&p.clearWorld(s)}),p.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:si}=g;let ni;function ai(t,e,i,s,n,a,o,r){switch(e){case"grayscale":ni||(ni=!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);ri(t,e,i,1,n,a)}(t,i,s,n,o,r);break;case"opacity-path":ri(t,i,s,a,o,r);break;case"path":r&&i.restore()}}function oi(t){return t.getSameCanvas(!1,!0)}function ri(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,d=l.length;c<d;c++){if(i=l[c],r=i.__.mask,r){o&&(ai(this,o,t,n,s,a,void 0,!0),s=n=null),a=i.__.opacity,ni=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=oi(t))):(o="path",t.save()),i.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=oi(t)),n||(n=oi(t)),i.__render(s,e)),"clipping"!==r&&"clipping-path"!==r||si(i,e)||i.__render(t,e);continue}const d=1===a&&i.__.__blendMode;d&&ai(this,o,t,n,s,a,void 0,!1),si(i,e)||i.__render(n||t,e),d&&ai(this,o,t,n,s,a,d,!1)}ai(this,o,t,n,s,a,void 0,!0)};const li=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ci=li+"_#~&*+\\=|≮≯≈≠=…",di=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 hi(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const ui=hi("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),fi=hi("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),pi=hi(li),gi=hi(ci),_i=hi("- —/~|┆·");var wi;!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"}(wi||(wi={}));const{Letter:yi,Single:mi,Before:vi,After:xi,Symbol:bi,Break:Si}=wi;function Bi(t){return ui[t]?yi:_i[t]?Si:fi[t]?vi:pi[t]?xi:gi[t]?bi:di.test(t)?mi:yi}const ki={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 Ri(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:Ei}=ki,{Letter:Li,Single:Ai,Before:Ti,After:Oi,Symbol:Ci,Break:Mi}=wi;let Wi,Di,Pi,Fi,Ii,Ui,Yi,Xi,zi,Ni,ji,qi,Gi,Hi,Vi,Qi,Ji,Zi=[];function $i(t,e){zi&&!Xi&&(Xi=zi),Wi.data.push({char:t,width:e}),Pi+=e}function Ki(){Fi+=Pi,Wi.width=Pi,Di.words.push(Wi),Wi={data:[]},Pi=0}function ts(){Hi&&(Vi.paraNumber++,Di.paraStart=!0,Hi=!1),zi&&(Di.startCharSize=Xi,Di.endCharSize=zi,Xi=0),Di.width=Fi,Qi.width?Ei(Di):Ji&&es(),Zi.push(Di),Di={words:[]},Fi=0}function es(){Fi>(Vi.maxWidth||0)&&(Vi.maxWidth=Fi)}const{top:is,right:ss,bottom:ns,left:as}=P;function os(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 rs={getDrawData:function(t,i){L(t)||(t=String(t));let s=0,n=0,a=i.__getInput("width")||0,o=i.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:c}=i;c&&(a?(s=c[as],a-=c[ss]+c[as]):i.autoSizeAlign||(s=c[as]),o?(n=c[is],o-=c[is]+c[ns]):i.autoSizeAlign||(n=c[is]));const d={bounds:{x:s,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,i,s){Vi=t,Zi=t.rows,Qi=t.bounds,Ji=!Qi.width&&!s.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=s,{canvas:r}=e,{width:l,height:c}=Qi;if(l||c||n||"none"!==o){const t="none"!==s.textWrap,e="break"===s.textWrap;Hi=!0,ji=null,Xi=Yi=zi=Pi=Fi=0,Wi={data:[]},Di={words:[]},n&&(i=[...i]);for(let s=0,c=i.length;s<c;s++)Ui=i[s],"\n"===Ui?(Pi&&Ki(),Di.paraEnd=!0,ts(),Hi=!0):(Ni=Bi(Ui),Ni===Li&&"none"!==o&&(Ui=Ri(Ui,o,!Pi)),Yi=r.measureText(Ui).width,n&&(n<0&&(zi=Yi),Yi+=n),qi=Ni===Ai&&(ji===Ai||ji===Li)||ji===Ai&&Ni!==Oi,Gi=!(Ni!==Ti&&Ni!==Ai||ji!==Ci&&ji!==Oi),Ii=Hi&&a?l-a:l,t&&l&&Fi+Pi+Yi>Ii&&(e?(Pi&&Ki(),Fi&&ts()):(Gi||(Gi=Ni===Li&&ji==Oi),qi||Gi||Ni===Mi||Ni===Ti||Ni===Ai||Pi+Yi>Ii?(Pi&&Ki(),Fi&&ts()):Fi&&ts()))," "===Ui&&!0!==Hi&&Fi+Pi===0||(Ni===Mi?(" "===Ui&&Pi&&Ki(),$i(Ui,Yi),Ki()):qi||Gi?(Pi&&Ki(),$i(Ui,Yi)):$i(Ui,Yi)),ji=Ni);Pi&&Ki(),Fi&&ts(),Zi.length>0&&(Zi[Zi.length-1].paraEnd=!0)}else i.split("\n").forEach(t=>{Vi.paraNumber++,Fi=r.measureText(t).width,Zi.push({x:a||0,text:t,width:Fi,paraStart:!0}),Ji&&es()})}(d,t,i),c&&function(t,e,i,s,n){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":os(e,"x",t[as]);break;case"right":os(e,"x",-t[ss])}if(!n&&i.autoSizeAlign)switch(i.verticalAlign){case"top":os(e,"y",t[is]);break;case"bottom":os(e,"y",-t[ns])}}(c,d,i,a,o),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),y=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}y+=p;let m,v,x,b=g||u?g:t.maxWidth;for(let o=0,d=n;o<d;o++){if(m=i[o],m.x=f,m.width<g||m.width>g&&!l)switch(c){case"center":m.x+=(b-m.width)/2;break;case"right":m.x+=b-m.width}m.paraStart&&h&&o>0&&(y+=h),m.y=y,y+=a,t.overflow>o&&y>w&&(m.isOverflow=!0,t.overflow=o+1),v=m.x,x=m.width,r<0&&(m.width<0?(x=-m.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&&(m.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(d,i),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)})}(d,i,a),d.overflow&&function(t,i,s,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=i;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const c=r?e.canvas.measureText(r).width:0,d=s+n-c;("none"===i.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)}})}}(d,i,s,a),"none"!==r&&function(t,e){let i,s=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,B(a)?(i=a.type,a.color&&(t.decorationColor=X.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,i),d}};const ls={string:function(t,e){const i=F(e)&&e<1;if(L(t)){if(!i||!X.object)return t;t=X.object(t)}let s=E(t.a)?1:t.a;i&&(s*=e);const n=t.r+","+t.g+","+t.b;return 1===s?"rgb("+n+")":"rgba("+n+","+s+")"}};Object.assign(G,rs),Object.assign(X,ls),Object.assign(Y,Nt),Object.assign(U,Ae),Object.assign(z,Ve),Object.assign(j,ii);const{setPoint:cs,addPoint:ds,toBounds:hs}=H;const us={syncExport(t,e,i){let s;N.running=!0;try{const n=Q.fileType(e),a=e.includes(".");i=Q.getExportOptions(i);const{toURL:o}=J,{download:r}=J.origin;if("json"===n)a&&r(o(JSON.stringify(t.toJSON(i.json)),"text"),e),s={data:!!a||t.toJSON(i.json)};else if("svg"===n)a&&r(o(t.toSVG(),"svg"),e),s={data:!!a||t.toSVG()};else{let n,a,o=1,r=1;const{worldTransform:l,isLeafer:c,leafer:d,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=i,y=Z(i.smooth)?!d||d.config.smooth:i.smooth,m=i.contextSettings||(d?d.config.contextSettings:void 0),v=c&&g&&Z(i.fill)?t.fill:i.fill,x=Q.isOpaqueImage(e)||v,b=new $;if(g)n=!0===g?c?d.canvas.bounds:t.worldRenderBounds:g;else{let e=i.relative||(c?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=d||t;default:b.set(l).divide(t.getTransform(e));const i=e.worldTransform;o/=o/i.scaleX,r/=r/i.scaleY}n=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};K.getScaleData(i.scale,i.size,n,S);let B=i.pixelRatio||1,{x:k,y:R,width:E,height:L}=new V(n).scale(S.scaleX,S.scaleY);f&&(k+=f.x,R+=f.y,E=f.width,L=f.height);const A={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-k,-R).withScale(1/o*S.scaleX,1/r*S.scaleY)};let T,O=tt.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:B,smooth:y,contextSettings:m});u&&(T=t,T.__worldOpacity=0,t=d||t,A.bounds=O.bounds),O.save();const C=h&&!Z(v),M=t.get("fill");if(C&&(t.fill=""),J.render(t,O,A),C&&(t.fill=M),O.restore(),T&&T.__updateWorldOpacity(),p){a=function(t){const{width:e,height:i}=t.view,{data:s}=t.context.getImageData(0,0,e,i);let n,a,o,r=0;for(let t=0;t<s.length;t+=4)0!==s[t+3]&&(n=r%e,a=(r-n)/e,o?ds(o,n,a):cs(o={},n,a)),r++;const l=new V;return o&&(hs(o,l),l.scale(1/t.pixelRatio).ceil()),l}(O);const t=O,{width:e,height:i}=a,s={x:0,y:0,width:e,height:i,pixelRatio:B};O=tt.canvas(s),O.copyWorld(t,a,s),t.destroy()}if(_){const[t,e,i,s]=K.fourNumber(_),n=O,{width:a,height:o}=n;O=tt.canvas({width:a+s+e,height:o+t+i,pixelRatio:B}),O.copyWorld(n,n.bounds,{x:s,y:t,width:a,height:o}),n.destroy()}x&&O.fillWorld(O.bounds,v||"#FFFFFF","destination-over"),w&&w(O);s={data:"canvas"===e?O:O.export(e,i),width:O.pixelWidth,height:O.pixelHeight,renderBounds:n,trimBounds:a};const W=d&&d.app;W&&W.canvasManager&&W.canvasManager.clearRecycled()}}catch(t){s={data:"",error:t}}return N.running=!1,s},export(t,e,i){return N.running=!0,function(t){fs||(fs=new et);return new Promise(e=>{fs.add(()=>rt(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(s=>new Promise(n=>{const a=()=>rt(this,void 0,void 0,function*(){if(!it.isComplete)return J.requestRender(a);const o=N.syncExport(t,e,i);o.data instanceof Promise&&(o.data=yield o.data),s(o),n()});t.updateLayout(),ps(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))}};let fs;function ps(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>ps(t))}const gs=st.prototype,_s=nt.get("@leafer-in/export");gs.export=function(t,e){const{quality:i,blob:s}=Q.getExportOptions(e);return t.includes(".")?this.saveAs(t,i):s?this.toBlob(t,i):this.toDataURL(t,i)},gs.toBlob=function(t,e){return new Promise(i=>{J.origin.canvasToBolb(this.view,t,e).then(t=>{i(t)}).catch(t=>{_s.error(t),i(null)})})},gs.toDataURL=function(t,e){return J.origin.canvasToDataURL(this.view,t,e)},gs.saveAs=function(t,e){return new Promise(i=>{J.origin.canvasSaveAs(this.view,t,e).then(()=>{i(!0)}).catch(t=>{_s.error(t),i(!1)})})},at.add("export"),Object.assign(N,us),ot.prototype.export=function(t,e){return N.export(this,t,e)},ot.prototype.syncExport=function(t,e){return N.syncExport(this,t,e)};export{St as Layouter,lt as LeaferCanvas,kt as Renderer,ut as Watcher,ht as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,Platform as e,canvasPatch as s,FileHelper as i,Creator as n,LeaferImage as a,defineKey as o,LeafList as r,DataHelper as l,RenderEvent as d,ChildEvent as c,WatchEvent as h,PropertyEvent as u,LeafHelper as f,BranchHelper as p,LeafBoundsHelper as g,Bounds as _,isArray as w,Debug as m,LeafLevelList as y,LayoutEvent as v,Run as x,ImageManager as b,ResizeEvent as S,isObject as B,BoundsHelper as k,FourNumberHelper as R,Matrix as E,isUndefined as L,isString as T,getMatrixData as A,MatrixHelper as O,MathHelper as C,AlignHelper as W,PointHelper as M,ImageEvent as D,AroundHelper as P,Direction4 as F,isNumber as I}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{writeFileSync as U}from"fs";import{PaintImage as Y,Paint as X,ColorConvert as z,PaintGradient as N,Export as q,Effect as j,Group as G,TextConvert as H,TwoPointBoundsHelper as V,Bounds as Q,FileHelper as J,Platform as Z,isUndefined as $,Matrix as K,MathHelper as tt,Creator as et,TaskProcessor as st,Resource as it,LeaferCanvasBase as nt,Debug as at,Plugin as ot,UI as rt}from"@leafer-ui/draw";export*from"@leafer-ui/draw";function lt(t,e,s,i){return new(s||(s=Promise))(function(n,a){function o(t){try{l(i.next(t))}catch(t){a(t)}}function r(t){try{l(i.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof s?e:new s(function(t){t(e)})).then(o,r)}l((i=i.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class dt extends t{get allowBackgroundColor(){return!0}init(){this.__createView(),this.__createContext(),this.resize(this.config),e.roundRectPatch&&(this.context.__proto__.roundRect=null,s(this.context.__proto__))}__createView(){this.view=e.origin.createCanvas(1,1)}updateViewSize(){const{width:t,height:e,pixelRatio:s}=this;this.view.width=Math.ceil(t*s),this.view.height=Math.ceil(e*s),this.clientBounds=this.bounds}}const{mineType:ct,fileType:ht}=i;function ut(t,s){if(e.canvasType=t,!e.origin){if("skia"===t){const{Canvas:t,loadImage:i}=s;e.origin={createCanvas:(e,s,i)=>new t(e,s,i),canvasToDataURL:(t,e,s)=>t.toDataURLSync(e,{quality:s}),canvasToBolb:(t,e,s)=>t.toBuffer(e,{quality:s}),canvasSaveAs:(t,e,s)=>t.saveAs(e,{quality:s}),download(t,e){},loadImage:t=>i(e.image.getRealURL(t))},e.roundRectPatch=!0}else if("napi"===t){const{Canvas:t,loadImage:i}=s;e.origin={createCanvas:(e,s,i)=>new t(e,s,i),canvasToDataURL:(t,e,s)=>t.toDataURL(ct(e),s),canvasToBolb:(t,e,s)=>lt(this,void 0,void 0,function*(){return t.toBuffer(ct(e),s)}),canvasSaveAs:(t,e,s)=>lt(this,void 0,void 0,function*(){return U(e,t.toBuffer(ct(ht(e)),s))}),download(t,e){},loadImage:t=>i(e.image.getRealURL(t))}}e.ellipseToCurve=!0,e.event={stopDefault(t){},stopNow(t){},stop(t){}},e.canvas=n.canvas()}}Object.assign(n,{canvas:(t,e)=>new dt(t,e),image:t=>new a(t)}),e.name="node",e.backgrounder=!0,e.requestRender=function(t){setTimeout(t,16)},o(e,"devicePixelRatio",{get:()=>1}),e.conicGradientSupport=!0;class ft{get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new r;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 r,this.target=t,e&&(this.config=l.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(d.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===c.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,s=e.length;t<s;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new h(h.DATA,{updatedList:this.updatedList})),this.__updatedList=new r,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[u.CHANGE,this.__onAttrChange,this],[[c.ADD,c.REMOVE],this.__onChildEvent,this],[h.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:pt,updateBounds:gt,updateChange:_t}=f,{pushAllChildBranch:wt,pushAllParent:mt}=p;const{worldBounds:yt}=g;class vt{constructor(t){this.updatedBounds=new _,this.beforeBounds=new _,this.afterBounds=new _,w(t)&&(t=new r(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,yt)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,yt),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:xt,updateAllChange:bt}=f,St=m.get("Layouter");class Bt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new y,this.target=t,e&&(this.config=l.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(v.START),this.layoutOnce(),t.emitEvent(new v(v.END,this.layoutedBlocks,this.times))}catch(t){St.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?St.warn("layouting"):this.times>3?St.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(h.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=x.start("PartLayout"),{target:s,__updatedList:i}=this,{BEFORE:n,LAYOUT:a,AFTER:o}=v,r=this.getBlocks(i);r.forEach(t=>t.setBefore()),s.emitEvent(new v(n,r,this.times)),this.extraBlock=null,i.sort(),function(t,e){let s;t.list.forEach(t=>{s=t.__layout,e.without(t)&&!s.proxyZoom&&(s.matrixChanged?(pt(t,!0),e.add(t),t.isBranch&&wt(t,e),mt(t,e)):s.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),mt(t,e)))})}(i,this.__levelList),function(t){let e,s,i;t.sort(!0),t.levels.forEach(n=>{e=t.levelMap[n];for(let t=0,n=e.length;t<n;t++){if(s=e[t],s.isBranch&&s.__tempNumber){i=s.children;for(let t=0,e=i.length;t<e;t++)i[t].isBranch||gt(i[t])}gt(s)}})}(this.__levelList),function(t){t.list.forEach(_t)}(i),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),s.emitEvent(new v(a,r,this.times)),s.emitEvent(new v(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,x.end(e)}fullLayout(){const t=x.start("FullLayout"),{target:e}=this,{BEFORE:s,LAYOUT:i,AFTER:n}=v,a=this.getBlocks(new r(e));e.emitEvent(new v(s,a,this.times)),Bt.fullLayout(e),a.forEach(t=>{t.setAfter()}),e.emitEvent(new v(i,a,this.times)),e.emitEvent(new v(n,a,this.times)),this.addBlocks(a),x.end(t)}static fullLayout(t){xt(t,!0),t.isBranch?p.updateBounds(t):f.updateBounds(t),bt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:s}=this.extraBlock||(this.extraBlock=new vt([]));e.length?s.add(t.__world):s.set(t.__world),e.add(t)}}createBlock(t){return new vt(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_([[v.REQUEST,this.layout,this],[v.AGAIN,this.layoutAgain,this],[h.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const kt=m.get("Renderer");class Rt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,s){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,s&&(this.config=l.default(s,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(v.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(d.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(d.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(d.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new _,kt.log(e.innerName,"---\x3e");try{this.emitRender(d.START),this.renderOnce(t),this.emitRender(d.END,this.totalBounds),b.clearRecycled()}catch(t){this.rendering=!1,kt.error(t)}kt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return kt.warn("rendering");if(this.times>3)return kt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new _,this.renderOptions={},t)this.emitRender(d.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(d.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(d.RENDER,this.renderBounds,this.renderOptions),this.emitRender(d.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=x.start("PartRender"),{canvas:s}=this,i=t.getIntersect(s.bounds),n=new _(i);s.save(),i.spread(Rt.clipSpread).ceil(),s.clearWorld(i),s.clipWorld(i),this.__render(i,n),s.restore(),x.end(e)}fullRender(){const t=x.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),x.end(t)}__render(t,s){const{canvas:i}=this,n=t.includes(this.target.__world),a=n?{includes:n}:{bounds:t,includes:n};this.needFill&&i.fillWorld(t,this.config.fill),m.showRepaint&&m.drawRepaint(i,t),e.render(this.target,i,a),this.renderBounds=s=s||t,this.renderOptions=a,this.totalBounds.isEmpty()?this.totalBounds=s:this.totalBounds.add(s),i.updateRender(s)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new _;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 s=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:i}=this.config;if(i&&t>i)return e.requestRender(s);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()};e.requestRender(s)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:s}=t.old;if(!new _(0,0,e,s).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new _(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||kt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,s){this.target.emitEvent(new d(t,this.times,e,s))}__listenEvents(){this.__eventIds=[this.target.on_([[d.REQUEST,this.update,this],[v.END,this.__onLayoutEnd,this],[d.AGAIN,this.renderAgain,this],[S.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 Et(t,e){const s=t.__,{rows:i,decorationY:n}=s.__textDrawData;let a;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,s=i.length;t<s;t++)a=i[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}=s.__textDrawData;t&&(e.fillStyle=t),i.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,a)))}}function Lt(t,e){t.__.__font?Et(t,e):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function Tt(t,e,s){switch(e.__.strokeAlign){case"center":At(t,1,e,s);break;case"inside":Ot(t,"inside",e,s);break;case"outside":e.__.__fillAfterStroke?At(t,2,e,s):Ot(t,"outside",e,s)}}function At(t,e,s,i){const n=s.__;B(t)?Wt(t,e,!0,s,i):(i.setStroke(t,n.__strokeWidth*e,n),Ct(s,i))}function Ot(t,e,s,i){const n=i.getSameCanvas(!0,!0);n.font=s.__.__font,At(t,2,s,n),n.blendMode="outside"===e?"destination-out":"destination-in",Et(s,n),n.blendMode="normal",f.copyCanvasByWorld(s,i,n),n.recycle(s.__nowWorld)}function Ct(t,e){let s,i=t.__.__textDrawData;const{rows:n,decorationY:a}=i;for(let t=0,i=n.length;t<i;t++)s=n[t],s.text?e.strokeText(s.text,s.x,s.y):s.data&&s.data.forEach(t=>{e.strokeText(t.char,t.x,s.y)});if(a){const{decorationHeight:t}=i;n.forEach(s=>a.forEach(i=>e.strokeRect(s.x,s.y+i,s.width,t)))}}function Wt(t,e,s,i,n){let a;const o=i.__,{__hasMultiStrokeStyle:r}=o;r||n.setStroke(void 0,o.__strokeWidth*e,o);for(let l=0,d=t.length;l<d;l++)if(a=t[l],(!a.image||!Y.checkImage(i,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),s?Ct(i,n):n.stroke(),n.restoreBlendMode()):s?Ct(i,n):n.stroke()}}function Mt(t,e,s){const i=e.__;if(i.__strokeWidth)if(i.__font)Tt(t,e,s);else switch(i.strokeAlign){case"center":Dt(t,1,e,s);break;case"inside":!function(t,e,s){s.save(),s.clipUI(e),Dt(t,2,e,s),s.restore()}(t,e,s);break;case"outside":!function(t,e,s){const i=e.__;if(i.__fillAfterStroke)Dt(t,2,e,s);else{const{renderBounds:n}=e.__layout,a=s.getSameCanvas(!0,!0);e.__drawRenderPath(a),Dt(t,2,e,a),a.clipUI(i),a.clearWorld(n),f.copyCanvasByWorld(e,s,a),a.recycle(e.__nowWorld)}}(t,e,s)}}function Dt(t,e,s,i){const n=s.__;B(t)?Wt(t,e,!1,s,i):(i.setStroke(t,n.__strokeWidth*e,n),i.stroke()),n.__useArrow&&X.strokeArrow(t,s,i)}Rt.clipSpread=10,Object.assign(n,{watcher:(t,e)=>new ft(t,e),layouter:(t,e)=>new Bt(t,e),renderer:(t,e,s)=>new Rt(t,e,s),selector:(t,e)=>{},interaction:(t,e,s,i)=>{}}),e.layout=Bt.fullLayout,e.render=function(t,e,s){const i=Object.assign(Object.assign({},s),{topRendering:!0});s.topList=new r,t.__render(e,s),s.topList.length&&s.topList.forEach(t=>t.__render(e,i))};const{getSpread:Pt,copyAndSpread:Ft,toOuterOf:It,getOuterOf:Ut,getByMove:Yt,move:Xt,getIntersectData:zt}=k,Nt={};let qt;const{stintSet:jt}=l,{hasTransparent:Gt}=z;function Ht(t,e,s){if(!B(e)||!1===e.visible||0===e.opacity)return;let i;const{boxBounds:n}=s.__layout;switch(e.type){case"image":i=Y.image(s,t,e,n,!qt||!qt[e.url]);break;case"linear":i=N.linearGradient(e,n);break;case"radial":i=N.radialGradient(e,n);break;case"angular":i=N.conicGradient(e,n);break;case"solid":const{type:a,color:o,opacity:r}=e;i={type:a,style:z.string(o,r)};break;default:L(e.r)||(i={type:"solid",style:z.string(e)})}if(i){if(T(i.style)&&Gt(i.style)&&(i.isTransparent=!0),e.style){if(0===e.style.strokeWidth)return;i.strokeStyle=e.style}e.editing&&(i.editing=e.editing),e.blendMode&&(i.blendMode=e.blendMode)}return i}const Vt={compute:function(t,e){const s=e.__,i=[];let n,a,o,r=s.__input[t];w(r)||(r=[r]),qt=Y.recycleImage(t,s);for(let s,n=0,a=r.length;n<a;n++)(s=Ht(t,r[n],e))&&(i.push(s),s.strokeStyle&&(o||(o=1),s.strokeStyle.strokeWidth&&(o=Math.max(o,s.strokeStyle.strokeWidth))));s["_"+t]=i.length?i:void 0,i.length&&i.every(t=>t.isTransparent)&&(i.some(t=>t.image)&&(n=!0),a=!0),"fill"===t?(jt(s,"__isAlphaPixelFill",n),jt(s,"__isTransparentFill",a)):(jt(s,"__isAlphaPixelStroke",n),jt(s,"__isTransparentStroke",a),jt(s,"__hasMultiStrokeStyle",o))},fill:function(t,e,s){s.fillStyle=t,Lt(e,s)},fills:function(t,e,s){let i;for(let n=0,a=t.length;n<a;n++){if(i=t[n],i.image){if(Y.checkImage(e,s,i,!e.__.__font))continue;if(!i.style){!n&&i.image.isPlacehold&&e.drawImagePlaceholder(s,i.image);continue}}if(s.fillStyle=i.style,i.transform||i.scaleFixed){if(s.save(),i.transform&&s.transform(i.transform),i.scaleFixed){const{scaleX:t,scaleY:n}=e.getRenderScaleData(!0);(!0===i.scaleFixed||"zoom-in"===i.scaleFixed&&t>1&&n>1)&&s.scale(1/t,1/n)}i.blendMode&&(s.blendMode=i.blendMode),Lt(e,s),s.restore()}else i.blendMode?(s.saveBlendMode(i.blendMode),Lt(e,s),s.restoreBlendMode()):Lt(e,s)}},fillPathOrText:Lt,fillText:Et,stroke:Mt,strokes:function(t,e,s){Mt(t,e,s)},strokeText:Tt,drawTextStroke:Ct,shape:function(t,s,i){const n=s.getSameCanvas(),a=s.bounds,o=t.__nowWorld,r=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;It(r.strokeSpread?(Ft(Nt,r.boxBounds,r.strokeSpread),Nt):r.boxBounds,o,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(a.includes(l))p=n,d=f=l,c=o;else{let n;if(e.fullImageShadow)n=l;else{const t=r.renderShapeSpread?Pt(a,R.swapAndScale(r.renderShapeSpread,g,_)):a;n=zt(t,l)}u=a.getFitMatrix(n);let{a:w,d:m}=u;u.a<1&&(p=s.getSameCanvas(),t.__renderShape(p,i),g*=w,_*=m),f=Ut(l,u),d=Yt(f,-u.e,-u.f),c=Ut(o,u),Xt(c,-u.e,-u.f);const y=i.matrix;y?(h=new E(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),i=Object.assign(Object.assign({},i),{matrix:h})}return t.__renderShape(n,i),{canvas:n,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let Qt={},Jt=A();const{get:Zt,rotateOfOuter:$t,translate:Kt,scaleOfOuter:te,multiplyParent:ee,scale:se,rotate:ie,skew:ne}=O;function ae(t,e,s,i,n,a,o){const r=Zt();Kt(r,e.x+s,e.y+i),se(r,n,a),o&&$t(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r}function oe(t,e,s,i,n,a,o,r,l,d){const c=Zt();le(c,e,s,i,n,a,o,r),l&&(Jt.a=l,Jt.d=d,ee(c,Jt)),t.transform=c}function re(t,e,s,i,n,a,o,r,l,d,c,h){const u=Zt();if(h)le(u,e,n,a,o,r,l,d);else{if(l)if("center"===c)$t(u,{x:s/2,y:i/2},l);else switch(ie(u,l),l){case 90:Kt(u,i,0);break;case 180:Kt(u,s,i);break;case 270:Kt(u,0,s)}Qt.x=e.x+n,Qt.y=e.y+a,Kt(u,Qt.x,Qt.y),o&&te(u,Qt,o,r)}t.transform=u}function le(t,e,s,i,n,a,o,r){o&&ie(t,o),r&&ne(t,r.x,r.y),n&&se(t,n,a),Kt(t,e.x+s,e.y+i)}const{get:de,translate:ce}=O,he=new _,ue={},fe={};function pe(t,e,s,i){const{changeful:n,sync:a,scaleFixed:o}=s;n&&(t.changeful=n),a&&(t.sync=a),o&&(t.scaleFixed=o),t.data=ge(s,i,e)}function ge(t,e,s){t.padding&&(e=he.set(e).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");let{width:i,height:n}=s;const{opacity:a,mode:o,align:r,offset:l,scale:d,size:c,rotation:h,skew:u,clipSize:f,repeat:p,gap:g,filters:_}=t,w=e.width===i&&e.height===n,m={mode:o},y="center"!==r&&(h||0)%180==90;let v,x;switch(k.set(fe,0,0,y?n:i,y?i:n),o&&"cover"!==o&&"fit"!==o?((d||c)&&(C.getScaleData(d,c,s,ue),v=ue.scaleX,x=ue.scaleY),(r||g||p)&&(v&&k.scale(fe,v,x,!0),r&&W.toPoint(r,fe,e,fe,!0,!0))):w&&!h||(v=x=k.getFitScale(e,fe,"fit"!==o),k.put(e,s,r,v,!1,fe),k.scale(fe,v,x,!0)),l&&M.move(fe,l),o){case"stretch":w||(i=e.width,n=e.height);break;case"normal":case"clip":if(fe.x||fe.y||v||f||h||u){let t,s;f&&(t=e.width/f.width,s=e.height/f.height),oe(m,e,fe.x,fe.y,v,x,h,u,t,s),t&&(v=v?v*t:v,x=x?x*s:s)}break;case"repeat":(!w||v||h||u)&&re(m,e,i,n,fe.x,fe.y,v,x,h,u,r,t.freeTransform),p||(m.repeat="repeat");const s=B(p);(g||s)&&(m.gap=function(t,e,s,i,n){let a,o;B(t)?(a=t.x,o=t.y):a=o=t;return{x:_e(a,s,n.width,e&&e.x),y:_e(o,i,n.height,e&&e.y)}}(g,s&&p,fe.width,fe.height,e));break;default:v&&ae(m,e,fe.x,fe.y,v,x,h)}return m.transform||(e.x||e.y)&&(m.transform=de(),ce(m.transform,e.x,e.y)),v&&"stretch"!==o&&(m.scaleX=v,m.scaleY=x),m.width=i,m.height=n,a&&(m.opacity=a),_&&(m.filters=_),p&&(m.repeat=T(p)?"x"===p?"repeat-x":"repeat-y":"repeat"),m}function _e(t,e,s,i){const n=T(t)||i?(i?s-i*e:s%e)/((i||Math.floor(s/e))-1):t;return"auto"===t&&n<0?0:n}let we,me=new _;const{isSame:ye}=k;function ve(t,e,s,i,n,a){if("fill"===e&&!t.__.__naturalWidth){const e=t.__;if(e.__naturalWidth=i.width/e.pixelRatio,e.__naturalHeight=i.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||pe(n,i,s,a),!0}function xe(t,e){Be(t,D.LOAD,e)}function be(t,e){Be(t,D.LOADED,e)}function Se(t,e,s){e.error=s,t.forceUpdate("surface"),Be(t,D.ERROR,e)}function Be(t,e,s){t.hasEvent(e)&&t.emitEvent(new D(e,s))}function ke(t,e){const{leafer:s}=t;s&&s.viewReady&&(s.renderer.ignore=e)}const{get:Re,scale:Ee,copy:Le}=O,{floor:Te,ceil:Ae,max:Oe,abs:Ce}=Math;function We(t,s,i){let{scaleX:n,scaleY:a}=t.getRenderScaleData(!0,s.scaleFixed);const o=n+"-"+a+"-"+i;if(s.patternId===o||t.destroyed)return!1;{const{image:r,data:l}=s;let d,c,{width:h,height:u,scaleX:f,scaleY:p,transform:g,repeat:_,gap:w}=l;n*=i,a*=i,f&&(f=Ce(f),p=Ce(p),c=Re(),Le(c,g),Ee(c,1/f,1/p),n*=f,a*=p),h*=n,u*=a;const m=h*u;if(!_&&m>e.image.maxCacheSize)return!1;let y=e.image.maxPatternSize;if(r.isSVG){const t=h/r.width;t>1&&(d=t/Ae(t))}else{const t=r.width*r.height;y>t&&(y=t)}m>y&&(d=Math.sqrt(m/y)),d&&(n/=d,a/=d,h/=d,u/=d),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/Oe(Te(t),1),a/=e/Oe(Te(e),1),c||(c=Re(),g&&Le(c,g)),Ee(c,1/n,1/a)}const b=r.getCanvas(h,u,l.opacity,l.filters,v,x,t.leafer&&t.leafer.config.smooth),S=r.getPattern(b,_||e.origin.noRepeat||"no-repeat",c,s);return s.style=S,s.patternId=o,!0}}const Me={image:function(t,e,s,i,n){let a,o;const r=b.get(s);return we&&s===we.paint&&ye(i,we.boxBounds)?a=we.leafPaint:(a={type:s.type,image:r},r.hasAlphaPixel&&(a.isTransparent=!0),we=r.use>1?{leafPaint:a,paint:s,boxBounds:me.set(i)}:null),(n||r.loading)&&(o={image:r,attrName:e,attrValue:s}),r.ready?(ve(t,e,s,r,a,i),n&&(xe(t,o),be(t,o))):r.error?n&&Se(t,o,r.error):(n&&(ke(t,!0),xe(t,o)),a.loadId=r.load(()=>{ke(t,!1),t.destroyed||(ve(t,e,s,r,a,i)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),be(t,o)),a.loadId=void 0},e=>{ke(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,s,i,n){const{scaleX:a,scaleY:o}=t.getRenderScaleData(!0,i.scaleFixed),{pixelRatio:r}=s,{data:l}=i;if(!l||i.patternId===a+"-"+o+"-"+r&&!q.running)return!1;if(n)if(l.repeat)n=!1;else if(!(i.changeful||"miniapp"===e.name&&S.isResizing(t)||q.running)){let{width:t,height:s}=l;t*=a*r,s*=o*r,l.scaleX&&(t*=l.scaleX,s*=l.scaleY),n=t*s>e.image.maxCacheSize}return n?(t.__.__isFastShadow&&(s.fillStyle=i.style||"#000",s.fill()),function(t,e,s,i){e.save(),e.clipUI(t),s.blendMode&&(e.blendMode=s.blendMode);i.opacity&&(e.opacity*=i.opacity);i.transform&&e.transform(i.transform);e.drawImage(s.image.getFull(i.filters),0,0,i.width,i.height),e.restore()}(t,s,i,l),!0):(!i.style||i.sync||q.running?We(t,i,r):i.patternTask||(i.patternTask=b.patternTasker.add(()=>lt(this,void 0,void 0,function*(){i.patternTask=null,s.bounds.hit(t.__nowWorld)&&We(t,i,r),t.forceUpdate("surface")}),300)),!1)},createPattern:We,recycleImage:function(t,e){const s=e["_"+t];if(w(s)){let i,n,a,o,r;for(let l=0,d=s.length;l<d;l++)i=s[l],n=i.image,r=n&&n.url,r&&(a||(a={}),a[r]=!0,b.recycle(n),n.loading&&(o||(o=e.__input&&e.__input[t]||[],w(o)||(o=[o])),n.unload(s[l].loadId,!o.some(t=>t.url===r))));return a}return null},createData:pe,getPatternData:ge,fillOrFitMode:ae,clipMode:oe,repeatMode:re},{toPoint:De}=P,{hasTransparent:Pe}=z,Fe={},Ie={};function Ue(t,e,s,i){if(s){let n,a,o,r;for(let t=0,l=s.length;t<l;t++)n=s[t],T(n)?(o=t/(l-1),a=z.string(n,i)):(o=n.offset,a=z.string(n.color,i)),e.addColorStop(o,a),!r&&Pe(a)&&(r=!0);r&&(t.isTransparent=!0)}}const{getAngle:Ye,getDistance:Xe}=M,{get:ze,rotateOfOuter:Ne,scaleOfOuter:qe}=O,{toPoint:je}=P,Ge={},He={};function Ve(t,e,s,i,n){let a;const{width:o,height:r}=t;if(o!==r||i){const t=Ye(e,s);a=ze(),n?(qe(a,e,o/r*(i||1),1),Ne(a,e,t+90)):(qe(a,e,1,o/r*(i||1)),Ne(a,e,t))}return a}const{getDistance:Qe}=M,{toPoint:Je}=P,Ze={},$e={};const Ke={linearGradient:function(t,s){let{from:i,to:n,type:a,opacity:o}=t;De(i||"top",s,Fe),De(n||"bottom",s,Ie);const r=e.canvas.createLinearGradient(Fe.x,Fe.y,Ie.x,Ie.y),l={type:a,style:r};return Ue(l,r,t.stops,o),l},radialGradient:function(t,s){let{from:i,to:n,type:a,opacity:o,stretch:r}=t;je(i||"center",s,Ge),je(n||"bottom",s,He);const l=e.canvas.createRadialGradient(Ge.x,Ge.y,0,Ge.x,Ge.y,Xe(Ge,He)),d={type:a,style:l};Ue(d,l,t.stops,o);const c=Ve(s,Ge,He,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,s){let{from:i,to:n,type:a,opacity:o,stretch:r}=t;Je(i||"center",s,Ze),Je(n||"bottom",s,$e);const l=e.conicGradientSupport?e.canvas.createConicGradient(0,Ze.x,Ze.y):e.canvas.createRadialGradient(Ze.x,Ze.y,0,Ze.x,Ze.y,Qe(Ze,$e)),d={type:a,style:l};Ue(d,l,t.stops,o);const c=Ve(s,Ze,$e,r||1,e.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:Ve},{copy:ts,move:es,toOffsetOutBounds:ss}=k,{max:is}=Math,ns={},as=new E,os={};function rs(t,e){let s,i,n,a,o=0,r=0,l=0,d=0;return e.forEach(t=>{s=t.x||0,i=t.y||0,n=t.spread||0,a=1.5*(t.blur||0),o=is(o,n+a-i),r=is(r,n+a+s),l=is(l,n+a+i),d=is(d,n+a-s)}),o===r&&r===l&&l===d?o:[o,r,l,d]}function ls(t,s,i){const{shapeBounds:n}=i;let a,o;e.fullImageShadow?(ts(ns,t.bounds),es(ns,s.x-n.x,s.y-n.y),a=t.bounds,o=ns):(a=n,o=s),t.copyWorld(i.canvas,a,o)}const{toOffsetOutBounds:ds}=k,cs={};const hs=rs;const us={shadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=o.length-1;ss(l,os,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.setWorldShadow(os.offsetX+(o.x||0)*h*w,os.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w,z.string(o.color)),n=j.getShadowTransform(t,p,s,o,os,w),n&&p.setTransform(n),ls(p,os,s),n&&p.resetTransform(),i=d,o.box&&(p.restore(),p.save(),r&&(p.copyWorld(p,d,a,"copy"),i=a),r?p.copyWorld(r,a,a,"destination-out"):p.copyWorld(s.canvas,c,l,"destination-out")),f.copyCanvasByWorld(t,e,p,i,o.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},innerShadow:function(t,e,s){let i,n;const{__nowWorld:a}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=s,p=e.getSameCanvas(),g=o.length-1;ds(l,cs,d),o.forEach((o,_)=>{let w=1;if(o.scaleFixed){const t=Math.abs(a.scaleX);t>1&&(w=1/t)}p.save(),p.setWorldShadow(cs.offsetX+(o.x||0)*h*w,cs.offsetY+(o.y||0)*u*w,(o.blur||0)*h*w),n=j.getShadowTransform(t,p,s,o,cs,w,!0),n&&p.setTransform(n),ls(p,cs,s),p.restore(),r?(p.copyWorld(p,d,a,"copy"),p.copyWorld(r,a,a,"source-out"),i=a):(p.copyWorld(s.canvas,c,l,"source-out"),i=d),p.fillWorld(i,z.string(o.color),"source-in"),f.copyCanvasByWorld(t,e,p,i,o.blendMode),g&&_<g&&p.clearWorld(i)}),p.recycle(i)},blur:function(t,e,s){const{blur:i}=t.__;s.setWorldBlur(i*t.__nowWorld.a),s.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),s.filter="none"},backgroundBlur:function(t,e,s){},getShadowRenderSpread:rs,getShadowTransform:function(t,e,s,i,n,a,o){if(i.spread){const s=1+2*i.spread/t.__layout.strokeBounds.width*a*(o?-1:1);return as.set().scaleOfOuter({x:(n.x+n.width/2)*e.pixelRatio,y:(n.y+n.height/2)*e.pixelRatio},s),as}},isTransformShadow(t){},getInnerShadowSpread:hs},{excludeRenderBounds:fs}=g;let ps;function gs(t,e,s,i,n,a,o,r){switch(e){case"grayscale":ps||(ps=!0,n.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,s,i,n,a){const o=t.__nowWorld;s.resetTransform(),s.opacity=1,s.useMask(i,o),a&&i.recycle(o);ws(t,e,s,1,n,a)}(t,s,i,n,o,r);break;case"opacity-path":ws(t,s,i,a,o,r);break;case"path":r&&s.restore()}}function _s(t){return t.getSameCanvas(!1,!0)}function ws(t,e,s,i,n,a){const o=t.__nowWorld;e.resetTransform(),e.opacity=i,e.copyWorld(s,o,void 0,n),a?s.recycle(o):s.clearWorld(o)}G.prototype.__renderMask=function(t,e){let s,i,n,a,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(s=l[d],r=s.__.mask,r){o&&(gs(this,o,t,n,i,a,void 0,!0),i=n=null),"clipping"!==r&&"clipping-path"!==r||fs(s,e)||s.__render(t,e),a=s.__.opacity,ps=!1,"path"===r||"clipping-path"===r?(a<1?(o="opacity-path",n||(n=_s(t))):(o="path",t.save()),s.__clip(n||t,e)):(o="grayscale"===r?"grayscale":"alpha",i||(i=_s(t)),n||(n=_s(t)),s.__render(i,e));continue}const c=1===a&&s.__.__blendMode;c&&gs(this,o,t,n,i,a,void 0,!1),fs(s,e)||s.__render(n||t,e),c&&gs(this,o,t,n,i,a,c,!1)}gs(this,o,t,n,i,a,void 0,!0)};const ms=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",ys=ms+"_#~&*+\\=|≮≯≈≠=…",vs=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 xs(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const bs=xs("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),Ss=xs("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Bs=xs(ms),ks=xs(ys),Rs=xs("- —/~|┆·");var Es;!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"}(Es||(Es={}));const{Letter:Ls,Single:Ts,Before:As,After:Os,Symbol:Cs,Break:Ws}=Es;function Ms(t){return bs[t]?Ls:Rs[t]?Ws:Ss[t]?As:Bs[t]?Os:ks[t]?Cs:vs.test(t)?Ts:Ls}const Ds={trimRight(t){const{words:e}=t;let s,i=0,n=e.length;for(let a=n-1;a>-1&&(s=e[a].data[0]," "===s.char);a--)i++,t.width-=s.width;i&&e.splice(n-i,i)}};function Ps(t,e,s){switch(e){case"title":return s?t.toUpperCase():t;case"upper":return t.toUpperCase();case"lower":return t.toLowerCase();default:return t}}const{trimRight:Fs}=Ds,{Letter:Is,Single:Us,Before:Ys,After:Xs,Symbol:zs,Break:Ns}=Es;let qs,js,Gs,Hs,Vs,Qs,Js,Zs,$s,Ks,ti,ei,si,ii,ni,ai,oi,ri=[];function li(t,e){$s&&!Zs&&(Zs=$s),qs.data.push({char:t,width:e}),Gs+=e}function di(){Hs+=Gs,qs.width=Gs,js.words.push(qs),qs={data:[]},Gs=0}function ci(){ii&&(ni.paraNumber++,js.paraStart=!0,ii=!1),$s&&(js.startCharSize=Zs,js.endCharSize=$s,Zs=0),js.width=Hs,ai.width?Fs(js):oi&&hi(),ri.push(js),js={words:[]},Hs=0}function hi(){Hs>(ni.maxWidth||0)&&(ni.maxWidth=Hs)}const{top:ui,right:fi,bottom:pi,left:gi}=F;function _i(t,e,s){const{bounds:i,rows:n}=t;i[e]+=s;for(let t=0;t<n.length;t++)n[t][e]+=s}const wi={getDrawData:function(t,s){T(t)||(t=String(t));let i=0,n=0,a=s.__getInput("width")||0,o=s.__getInput("height")||0;const{textDecoration:r,__font:l,__padding:d}=s;d&&(a?(i=d[gi],a-=d[fi]+d[gi]):s.autoSizeAlign||(i=d[gi]),o?(n=d[ui],o-=d[ui]+d[pi]):s.autoSizeAlign||(n=d[ui]));const c={bounds:{x:i,y:n,width:a,height:o},rows:[],paraNumber:0,font:e.canvas.font=l};return function(t,s,i){ni=t,ri=t.rows,ai=t.bounds,oi=!ai.width&&!i.autoSizeAlign;const{__letterSpacing:n,paraIndent:a,textCase:o}=i,{canvas:r}=e,{width:l,height:d}=ai;if(l||d||n||"none"!==o){const t="none"!==i.textWrap,e="break"===i.textWrap;ii=!0,ti=null,Zs=Js=$s=Gs=Hs=0,qs={data:[]},js={words:[]},n&&(s=[...s]);for(let i=0,d=s.length;i<d;i++)Qs=s[i],"\n"===Qs?(Gs&&di(),js.paraEnd=!0,ci(),ii=!0):(Ks=Ms(Qs),Ks===Is&&"none"!==o&&(Qs=Ps(Qs,o,!Gs)),Js=r.measureText(Qs).width,n&&(n<0&&($s=Js),Js+=n),ei=Ks===Us&&(ti===Us||ti===Is)||ti===Us&&Ks!==Xs,si=!(Ks!==Ys&&Ks!==Us||ti!==zs&&ti!==Xs),Vs=ii&&a?l-a:l,t&&l&&Hs+Gs+Js>Vs&&(e?(Gs&&di(),Hs&&ci()):(si||(si=Ks===Is&&ti==Xs),ei||si||Ks===Ns||Ks===Ys||Ks===Us||Gs+Js>Vs?(Gs&&di(),Hs&&ci()):Hs&&ci()))," "===Qs&&!0!==ii&&Hs+Gs===0||(Ks===Ns?(" "===Qs&&Gs&&di(),li(Qs,Js),di()):ei||si?(Gs&&di(),li(Qs,Js)):li(Qs,Js)),ti=Ks);Gs&&di(),Hs&&ci(),ri.length>0&&(ri[ri.length-1].paraEnd=!0)}else s.split("\n").forEach(t=>{ni.paraNumber++,Hs=r.measureText(t).width,ri.push({x:a||0,text:t,width:Hs,paraStart:!0}),oi&&hi()})}(c,t,s),d&&function(t,e,s,i,n){if(!i&&s.autoSizeAlign)switch(s.textAlign){case"left":_i(e,"x",t[gi]);break;case"right":_i(e,"x",-t[fi])}if(!n&&s.autoSizeAlign)switch(s.verticalAlign){case"top":_i(e,"y",t[ui]);break;case"bottom":_i(e,"y",-t[pi])}}(d,c,s,a,o),function(t,e){const{rows:s,bounds:i}=t,n=s.length,{__lineHeight:a,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=i,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(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,b=g||u?g:t.maxWidth;for(let o=0,c=n;o<c;o++){if(y=s[o],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(b-y.width)/2;break;case"right":y.x+=b-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<i.x&&(i.x=v),x>i.width&&(i.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=s.length))}i.y=p,i.height=w}(c,s),function(t,e,s){const{rows:i}=t,{textAlign:n,paraIndent:a,letterSpacing:o}=e;let r,l,d,c,h,u;i.forEach(t=>{t.words&&(d=a&&t.paraStart?a:0,u=t.words.length,l=s&&("justify"===n||"both"===n)&&u>1?(s-t.width-d)/(u-1):0,c=o||t.isOverflow?0:l>.01?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===c?(t.x+=d,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=d,r=t.x,t.data=[],t.words.forEach((e,s)=>{1===c?(h={char:"",x:r},r=function(t,e,s){return t.forEach(t=>{s.char+=t.char,e+=t.width}),e}(e.data,r,h),(t.isOverflow||" "!==h.char)&&t.data.push(h)):r=function(t,e,s,i){return t.forEach(t=>{(i||" "!==t.char)&&(t.x=e,s.push(t)),e+=t.width}),e}(e.data,r,t.data,t.isOverflow),!l||t.paraEnd&&"both"!==n||s===u-1||(r+=l,t.width+=l)})),t.words=null)})}(c,s,a),c.overflow&&function(t,s,i,n){if(!n)return;const{rows:a,overflow:o}=t;let{textOverflow:r}=s;if(a.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?e.canvas.measureText(r).width:0,c=i+n-d;("none"===s.textWrap?a:[a[o-1]]).forEach(e=>{if(e.isOverflow&&e.data){let s=e.data.length-1;for(let i=s;i>-1&&(t=e.data[i],l=t.x+t.width,!(i===s&&l<c));i--){if(l<c&&" "!==t.char||!i){e.data.splice(i+1),e.width-=t.width;break}e.width-=t.width}e.width+=d,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)}})}}(c,s,i,a),"none"!==r&&function(t,e){let s,i=0;const{fontSize:n,textDecoration:a}=e;switch(t.decorationHeight=n/11,B(a)?(s=a.type,a.color&&(t.decorationColor=z.string(a.color)),a.offset&&(i=Math.min(.3*n,Math.max(a.offset,.15*-n)))):s=a,s){case"under":t.decorationY=[.15*n+i];break;case"delete":t.decorationY=[.35*-n];break;case"under-delete":t.decorationY=[.15*n+i,.35*-n]}}(c,s),c}};const mi={string:function(t,e){if(!t)return"#000";const s=I(e)&&e<1;if(T(t)){if(!s||!z.object)return t;t=z.object(t)}let i=L(t.a)?1:t.a;s&&(i*=e);const n=t.r+","+t.g+","+t.b;return 1===i?"rgb("+n+")":"rgba("+n+","+i+")"}};Object.assign(H,wi),Object.assign(z,mi),Object.assign(X,Vt),Object.assign(Y,Me),Object.assign(N,Ke),Object.assign(j,us);const{setPoint:yi,addPoint:vi,toBounds:xi}=V;const bi={syncExport(t,e,s){let i;q.running=!0;try{const n=J.fileType(e),a=e.includes(".");s=J.getExportOptions(s);const{toURL:o}=Z,{download:r}=Z.origin;if("json"===n)a&&r(o(JSON.stringify(t.toJSON(s.json)),"text"),e),i={data:!!a||t.toJSON(s.json)};else if("svg"===n)a&&r(o(t.toSVG(),"svg"),e),i={data:!!a||t.toSVG()};else{let n,a,o=1,r=1;const{worldTransform:l,isLeafer:d,leafer:c,isFrame:h}=t,{slice:u,clip:f,trim:p,screenshot:g,padding:_,onCanvas:w}=s,m=$(s.smooth)?!c||c.config.smooth:s.smooth,y=s.contextSettings||(c?c.config.contextSettings:void 0),v=d&&g&&$(s.fill)?t.fill:s.fill,x=J.isOpaqueImage(e)||v,b=new K;if(g)n=!0===g?d?c.canvas.bounds:t.worldRenderBounds:g;else{let e=s.relative||(d?"inner":"local");switch(o=l.scaleX,r=l.scaleY,e){case"inner":b.set(l);break;case"local":b.set(l).divide(t.localTransform),o/=t.scaleX,r/=t.scaleY;break;case"world":o=1,r=1;break;case"page":e=c||t;default:b.set(l).divide(t.getTransform(e));const s=e.worldTransform;o/=o/s.scaleX,r/=r/s.scaleY}n=t.getBounds("render",e)}const S={scaleX:1,scaleY:1};tt.getScaleData(s.scale,s.size,n,S);let B=s.pixelRatio||1,{x:k,y:R,width:E,height:L}=new Q(n).scale(S.scaleX,S.scaleY);f&&(k+=f.x,R+=f.y,E=f.width,L=f.height);const T={exporting:!0,matrix:b.scale(1/S.scaleX,1/S.scaleY).invert().translate(-k,-R).withScale(1/o*S.scaleX,1/r*S.scaleY)};let A,O=et.canvas({width:Math.floor(E),height:Math.floor(L),pixelRatio:B,smooth:m,contextSettings:y});u&&(A=t,A.__worldOpacity=0,t=c||t,T.bounds=O.bounds),O.save();const C=h&&!$(v),W=t.get("fill");if(C&&(t.fill=""),Z.render(t,O,T),C&&(t.fill=W),O.restore(),A&&A.__updateWorldOpacity(),p){a=function(t){const{width:e,height:s}=t.view,{data:i}=t.context.getImageData(0,0,e,s);let n,a,o,r=0;for(let t=0;t<i.length;t+=4)0!==i[t+3]&&(n=r%e,a=(r-n)/e,o?vi(o,n,a):yi(o={},n,a)),r++;const l=new Q;return o&&(xi(o,l),l.scale(1/t.pixelRatio).ceil()),l}(O);const t=O,{width:e,height:s}=a,i={x:0,y:0,width:e,height:s,pixelRatio:B};O=et.canvas(i),O.copyWorld(t,a,i),t.destroy()}if(_){const[t,e,s,i]=tt.fourNumber(_),n=O,{width:a,height:o}=n;O=et.canvas({width:a+i+e,height:o+t+s,pixelRatio:B}),O.copyWorld(n,n.bounds,{x:i,y:t,width:a,height:o}),n.destroy()}x&&O.fillWorld(O.bounds,v||"#FFFFFF","destination-over"),w&&w(O);i={data:"canvas"===e?O:O.export(e,s),width:O.pixelWidth,height:O.pixelHeight,renderBounds:n,trimBounds:a};const M=c&&c.app;M&&M.canvasManager&&M.canvasManager.clearRecycled()}}catch(t){i={data:"",error:t}}return q.running=!1,i},export(t,e,s){return q.running=!0,function(t){Si||(Si=new st);return new Promise(e=>{Si.add(()=>lt(this,void 0,void 0,function*(){return yield t(e)}),{parallel:!1})})}(i=>new Promise(n=>{const a=()=>lt(this,void 0,void 0,function*(){if(!it.isComplete)return Z.requestRender(a);const o=q.syncExport(t,e,s);o.data instanceof Promise&&(o.data=yield o.data),i(o),n()});t.updateLayout(),Bi(t);const{leafer:o}=t;o?o.waitViewCompleted(a):a()}))}};let Si;function Bi(t){t.__.__needComputePaint&&t.__.__computePaint(),t.isBranch&&t.children.forEach(t=>Bi(t))}const ki=nt.prototype,Ri=at.get("@leafer-in/export");ki.export=function(t,e){const{quality:s,blob:i}=J.getExportOptions(e);return t.includes(".")?this.saveAs(t,s):i?this.toBlob(t,s):this.toDataURL(t,s)},ki.toBlob=function(t,e){return new Promise(s=>{Z.origin.canvasToBolb(this.view,t,e).then(t=>{s(t)}).catch(t=>{Ri.error(t),s(null)})})},ki.toDataURL=function(t,e){return Z.origin.canvasToDataURL(this.view,t,e)},ki.saveAs=function(t,e){return new Promise(s=>{Z.origin.canvasSaveAs(this.view,t,e).then(()=>{s(!0)}).catch(t=>{Ri.error(t),s(!1)})})},ot.add("export"),Object.assign(q,bi),rt.prototype.export=function(t,e){return q.export(this,t,e)},rt.prototype.syncExport=function(t,e){return q.syncExport(this,t,e)};export{Bt as Layouter,dt as LeaferCanvas,Rt as Renderer,ft as Watcher,ut as useCanvas};
|
|
2
2
|
//# sourceMappingURL=node.esm.min.js.map
|