@leafer-draw/miniapp 1.10.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/miniapp.cjs +39 -41
- package/dist/miniapp.esm.js +39 -41
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.esm.min.js.map +1 -1
- package/dist/miniapp.min.cjs +1 -1
- package/dist/miniapp.min.cjs.map +1 -1
- package/dist/miniapp.module.js +90 -70
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +9 -9
package/dist/miniapp.cjs
CHANGED
|
@@ -821,30 +821,31 @@ function fill(fill, ui, canvas, renderOptions) {
|
|
|
821
821
|
}
|
|
822
822
|
|
|
823
823
|
function fills(fills, ui, canvas, renderOptions) {
|
|
824
|
-
let item;
|
|
824
|
+
let item, originPaint, countImage;
|
|
825
825
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
826
|
-
item = fills[i];
|
|
826
|
+
item = fills[i], originPaint = item.originPaint;
|
|
827
827
|
if (item.image) {
|
|
828
|
+
countImage ? countImage++ : countImage = 1;
|
|
828
829
|
if (draw.PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
829
830
|
if (!item.style) {
|
|
830
|
-
if (
|
|
831
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
|
|
831
832
|
continue;
|
|
832
833
|
}
|
|
833
834
|
}
|
|
834
835
|
canvas.fillStyle = item.style;
|
|
835
|
-
if (item.transform ||
|
|
836
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
836
837
|
canvas.save();
|
|
837
838
|
if (item.transform) canvas.transform(item.transform);
|
|
838
|
-
if (
|
|
839
|
+
if (originPaint.scaleFixed) {
|
|
839
840
|
const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
840
|
-
if (
|
|
841
|
+
if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
841
842
|
}
|
|
842
|
-
if (
|
|
843
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
843
844
|
fillPathOrText(ui, canvas, renderOptions);
|
|
844
845
|
canvas.restore();
|
|
845
846
|
} else {
|
|
846
|
-
if (
|
|
847
|
-
canvas.saveBlendMode(
|
|
847
|
+
if (originPaint.blendMode) {
|
|
848
|
+
canvas.saveBlendMode(originPaint.blendMode);
|
|
848
849
|
fillPathOrText(ui, canvas, renderOptions);
|
|
849
850
|
canvas.restoreBlendMode();
|
|
850
851
|
} else fillPathOrText(ui, canvas, renderOptions);
|
|
@@ -997,8 +998,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
|
|
|
997
998
|
const {strokeStyle: strokeStyle} = item;
|
|
998
999
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
999
1000
|
} else canvas.strokeStyle = item.style;
|
|
1000
|
-
if (item.blendMode) {
|
|
1001
|
-
canvas.saveBlendMode(item.blendMode);
|
|
1001
|
+
if (item.originPaint.blendMode) {
|
|
1002
|
+
canvas.saveBlendMode(item.originPaint.blendMode);
|
|
1002
1003
|
isText ? draw.Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
1003
1004
|
canvas.restoreBlendMode();
|
|
1004
1005
|
} else {
|
|
@@ -1095,62 +1096,63 @@ function compute(attrName, ui) {
|
|
|
1095
1096
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
1096
1097
|
isTransparent = true;
|
|
1097
1098
|
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1099
|
+
if (attrName === "fill") {
|
|
1100
|
+
stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
|
|
1101
|
+
stintSet(data, "__isTransparentFill", isTransparent);
|
|
1102
|
+
} else {
|
|
1103
|
+
stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
|
|
1104
|
+
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
1105
|
+
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
1106
|
+
}
|
|
1102
1107
|
} else {
|
|
1103
|
-
|
|
1104
|
-
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
1105
|
-
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
1108
|
+
data.__removePaint(attrName, false);
|
|
1106
1109
|
}
|
|
1107
1110
|
}
|
|
1108
1111
|
|
|
1109
1112
|
function getLeafPaint(attrName, paint, ui) {
|
|
1110
1113
|
if (!core.isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
1111
|
-
let
|
|
1114
|
+
let leafPaint;
|
|
1112
1115
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
1113
1116
|
switch (paint.type) {
|
|
1114
1117
|
case "image":
|
|
1115
|
-
|
|
1118
|
+
leafPaint = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
1116
1119
|
break;
|
|
1117
1120
|
|
|
1118
1121
|
case "linear":
|
|
1119
|
-
|
|
1122
|
+
leafPaint = draw.PaintGradient.linearGradient(paint, boxBounds);
|
|
1120
1123
|
break;
|
|
1121
1124
|
|
|
1122
1125
|
case "radial":
|
|
1123
|
-
|
|
1126
|
+
leafPaint = draw.PaintGradient.radialGradient(paint, boxBounds);
|
|
1124
1127
|
break;
|
|
1125
1128
|
|
|
1126
1129
|
case "angular":
|
|
1127
|
-
|
|
1130
|
+
leafPaint = draw.PaintGradient.conicGradient(paint, boxBounds);
|
|
1128
1131
|
break;
|
|
1129
1132
|
|
|
1130
1133
|
case "solid":
|
|
1131
1134
|
const {type: type, color: color, opacity: opacity} = paint;
|
|
1132
|
-
|
|
1135
|
+
leafPaint = {
|
|
1133
1136
|
type: type,
|
|
1134
1137
|
style: draw.ColorConvert.string(color, opacity)
|
|
1135
1138
|
};
|
|
1136
1139
|
break;
|
|
1137
1140
|
|
|
1138
1141
|
default:
|
|
1139
|
-
if (!core.isUndefined(paint.r))
|
|
1142
|
+
if (!core.isUndefined(paint.r)) leafPaint = {
|
|
1140
1143
|
type: "solid",
|
|
1141
1144
|
style: draw.ColorConvert.string(paint)
|
|
1142
1145
|
};
|
|
1143
1146
|
}
|
|
1144
|
-
if (
|
|
1145
|
-
|
|
1147
|
+
if (leafPaint) {
|
|
1148
|
+
leafPaint.originPaint = paint;
|
|
1149
|
+
if (core.isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
|
|
1146
1150
|
if (paint.style) {
|
|
1147
1151
|
if (paint.style.strokeWidth === 0) return undefined;
|
|
1148
|
-
|
|
1152
|
+
leafPaint.strokeStyle = paint.style;
|
|
1149
1153
|
}
|
|
1150
|
-
if (paint.editing) data.editing = paint.editing;
|
|
1151
|
-
if (paint.blendMode) data.blendMode = paint.blendMode;
|
|
1152
1154
|
}
|
|
1153
|
-
return
|
|
1155
|
+
return leafPaint;
|
|
1154
1156
|
}
|
|
1155
1157
|
|
|
1156
1158
|
const PaintModule = {
|
|
@@ -1283,10 +1285,6 @@ const tempScaleData = {};
|
|
|
1283
1285
|
const tempImage = {};
|
|
1284
1286
|
|
|
1285
1287
|
function createData(leafPaint, image, paint, box) {
|
|
1286
|
-
const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
|
|
1287
|
-
if (changeful) leafPaint.changeful = changeful;
|
|
1288
|
-
if (sync) leafPaint.sync = sync;
|
|
1289
|
-
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
1290
1288
|
leafPaint.data = draw.PaintImage.getPatternData(paint, box, image);
|
|
1291
1289
|
}
|
|
1292
1290
|
|
|
@@ -1546,14 +1544,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
1546
1544
|
|
|
1547
1545
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
1548
1546
|
const {scaleX: scaleX, scaleY: scaleY} = draw.PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
1549
|
-
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
1547
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
1550
1548
|
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
1551
1549
|
return false;
|
|
1552
1550
|
} else {
|
|
1553
1551
|
if (drawImage) {
|
|
1554
1552
|
if (data.repeat) {
|
|
1555
1553
|
drawImage = false;
|
|
1556
|
-
} else if (!(
|
|
1554
|
+
} else if (!(originPaint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || exporting)) {
|
|
1557
1555
|
drawImage = core.Platform.image.isLarge(image, scaleX, scaleY);
|
|
1558
1556
|
}
|
|
1559
1557
|
}
|
|
@@ -1565,16 +1563,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
1565
1563
|
draw.PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
1566
1564
|
return true;
|
|
1567
1565
|
} else {
|
|
1568
|
-
if (!paint.style ||
|
|
1566
|
+
if (!paint.style || originPaint.sync || exporting) draw.PaintImage.createPattern(paint, ui, canvas, renderOptions); else draw.PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
1569
1567
|
return false;
|
|
1570
1568
|
}
|
|
1571
1569
|
}
|
|
1572
1570
|
}
|
|
1573
1571
|
|
|
1574
1572
|
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
1575
|
-
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
1573
|
+
const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
1576
1574
|
let {width: width, height: height} = image, clipUI;
|
|
1577
|
-
if (transform && !transform.onlyScale ||
|
|
1575
|
+
if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
|
|
1578
1576
|
canvas.save();
|
|
1579
1577
|
clipUI && canvas.clipUI(ui);
|
|
1580
1578
|
blendMode && (canvas.blendMode = blendMode);
|
|
@@ -1589,7 +1587,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
|
|
|
1589
1587
|
}
|
|
1590
1588
|
|
|
1591
1589
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
1592
|
-
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
1590
|
+
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
1593
1591
|
if (canvas) {
|
|
1594
1592
|
const {pixelRatio: pixelRatio} = canvas;
|
|
1595
1593
|
scaleData.scaleX *= pixelRatio;
|
package/dist/miniapp.esm.js
CHANGED
|
@@ -825,30 +825,31 @@ function fill(fill, ui, canvas, renderOptions) {
|
|
|
825
825
|
}
|
|
826
826
|
|
|
827
827
|
function fills(fills, ui, canvas, renderOptions) {
|
|
828
|
-
let item;
|
|
828
|
+
let item, originPaint, countImage;
|
|
829
829
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
830
|
-
item = fills[i];
|
|
830
|
+
item = fills[i], originPaint = item.originPaint;
|
|
831
831
|
if (item.image) {
|
|
832
|
+
countImage ? countImage++ : countImage = 1;
|
|
832
833
|
if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
|
|
833
834
|
if (!item.style) {
|
|
834
|
-
if (
|
|
835
|
+
if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
|
|
835
836
|
continue;
|
|
836
837
|
}
|
|
837
838
|
}
|
|
838
839
|
canvas.fillStyle = item.style;
|
|
839
|
-
if (item.transform ||
|
|
840
|
+
if (item.transform || originPaint.scaleFixed) {
|
|
840
841
|
canvas.save();
|
|
841
842
|
if (item.transform) canvas.transform(item.transform);
|
|
842
|
-
if (
|
|
843
|
+
if (originPaint.scaleFixed) {
|
|
843
844
|
const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
|
|
844
|
-
if (
|
|
845
|
+
if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
|
|
845
846
|
}
|
|
846
|
-
if (
|
|
847
|
+
if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
|
|
847
848
|
fillPathOrText(ui, canvas, renderOptions);
|
|
848
849
|
canvas.restore();
|
|
849
850
|
} else {
|
|
850
|
-
if (
|
|
851
|
-
canvas.saveBlendMode(
|
|
851
|
+
if (originPaint.blendMode) {
|
|
852
|
+
canvas.saveBlendMode(originPaint.blendMode);
|
|
852
853
|
fillPathOrText(ui, canvas, renderOptions);
|
|
853
854
|
canvas.restoreBlendMode();
|
|
854
855
|
} else fillPathOrText(ui, canvas, renderOptions);
|
|
@@ -1001,8 +1002,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
|
|
|
1001
1002
|
const {strokeStyle: strokeStyle} = item;
|
|
1002
1003
|
strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
|
|
1003
1004
|
} else canvas.strokeStyle = item.style;
|
|
1004
|
-
if (item.blendMode) {
|
|
1005
|
-
canvas.saveBlendMode(item.blendMode);
|
|
1005
|
+
if (item.originPaint.blendMode) {
|
|
1006
|
+
canvas.saveBlendMode(item.originPaint.blendMode);
|
|
1006
1007
|
isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
|
|
1007
1008
|
canvas.restoreBlendMode();
|
|
1008
1009
|
} else {
|
|
@@ -1099,62 +1100,63 @@ function compute(attrName, ui) {
|
|
|
1099
1100
|
if (leafPaints.some(item => item.image)) isAlphaPixel = true;
|
|
1100
1101
|
isTransparent = true;
|
|
1101
1102
|
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1103
|
+
if (attrName === "fill") {
|
|
1104
|
+
stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
|
|
1105
|
+
stintSet(data, "__isTransparentFill", isTransparent);
|
|
1106
|
+
} else {
|
|
1107
|
+
stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
|
|
1108
|
+
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
1109
|
+
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
1110
|
+
}
|
|
1106
1111
|
} else {
|
|
1107
|
-
|
|
1108
|
-
stintSet(data, "__isTransparentStroke", isTransparent);
|
|
1109
|
-
stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
|
|
1112
|
+
data.__removePaint(attrName, false);
|
|
1110
1113
|
}
|
|
1111
1114
|
}
|
|
1112
1115
|
|
|
1113
1116
|
function getLeafPaint(attrName, paint, ui) {
|
|
1114
1117
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
1115
|
-
let
|
|
1118
|
+
let leafPaint;
|
|
1116
1119
|
const {boxBounds: boxBounds} = ui.__layout;
|
|
1117
1120
|
switch (paint.type) {
|
|
1118
1121
|
case "image":
|
|
1119
|
-
|
|
1122
|
+
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
1120
1123
|
break;
|
|
1121
1124
|
|
|
1122
1125
|
case "linear":
|
|
1123
|
-
|
|
1126
|
+
leafPaint = PaintGradient.linearGradient(paint, boxBounds);
|
|
1124
1127
|
break;
|
|
1125
1128
|
|
|
1126
1129
|
case "radial":
|
|
1127
|
-
|
|
1130
|
+
leafPaint = PaintGradient.radialGradient(paint, boxBounds);
|
|
1128
1131
|
break;
|
|
1129
1132
|
|
|
1130
1133
|
case "angular":
|
|
1131
|
-
|
|
1134
|
+
leafPaint = PaintGradient.conicGradient(paint, boxBounds);
|
|
1132
1135
|
break;
|
|
1133
1136
|
|
|
1134
1137
|
case "solid":
|
|
1135
1138
|
const {type: type, color: color, opacity: opacity} = paint;
|
|
1136
|
-
|
|
1139
|
+
leafPaint = {
|
|
1137
1140
|
type: type,
|
|
1138
1141
|
style: ColorConvert.string(color, opacity)
|
|
1139
1142
|
};
|
|
1140
1143
|
break;
|
|
1141
1144
|
|
|
1142
1145
|
default:
|
|
1143
|
-
if (!isUndefined(paint.r))
|
|
1146
|
+
if (!isUndefined(paint.r)) leafPaint = {
|
|
1144
1147
|
type: "solid",
|
|
1145
1148
|
style: ColorConvert.string(paint)
|
|
1146
1149
|
};
|
|
1147
1150
|
}
|
|
1148
|
-
if (
|
|
1149
|
-
|
|
1151
|
+
if (leafPaint) {
|
|
1152
|
+
leafPaint.originPaint = paint;
|
|
1153
|
+
if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
|
|
1150
1154
|
if (paint.style) {
|
|
1151
1155
|
if (paint.style.strokeWidth === 0) return undefined;
|
|
1152
|
-
|
|
1156
|
+
leafPaint.strokeStyle = paint.style;
|
|
1153
1157
|
}
|
|
1154
|
-
if (paint.editing) data.editing = paint.editing;
|
|
1155
|
-
if (paint.blendMode) data.blendMode = paint.blendMode;
|
|
1156
1158
|
}
|
|
1157
|
-
return
|
|
1159
|
+
return leafPaint;
|
|
1158
1160
|
}
|
|
1159
1161
|
|
|
1160
1162
|
const PaintModule = {
|
|
@@ -1287,10 +1289,6 @@ const tempScaleData = {};
|
|
|
1287
1289
|
const tempImage = {};
|
|
1288
1290
|
|
|
1289
1291
|
function createData(leafPaint, image, paint, box) {
|
|
1290
|
-
const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
|
|
1291
|
-
if (changeful) leafPaint.changeful = changeful;
|
|
1292
|
-
if (sync) leafPaint.sync = sync;
|
|
1293
|
-
if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
|
|
1294
1292
|
leafPaint.data = PaintImage.getPatternData(paint, box, image);
|
|
1295
1293
|
}
|
|
1296
1294
|
|
|
@@ -1550,14 +1548,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
1550
1548
|
|
|
1551
1549
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
1552
1550
|
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
1553
|
-
const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
|
|
1551
|
+
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
|
|
1554
1552
|
if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
|
|
1555
1553
|
return false;
|
|
1556
1554
|
} else {
|
|
1557
1555
|
if (drawImage) {
|
|
1558
1556
|
if (data.repeat) {
|
|
1559
1557
|
drawImage = false;
|
|
1560
|
-
} else if (!(
|
|
1558
|
+
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
1561
1559
|
drawImage = Platform.image.isLarge(image, scaleX, scaleY);
|
|
1562
1560
|
}
|
|
1563
1561
|
}
|
|
@@ -1569,16 +1567,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
1569
1567
|
PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
|
|
1570
1568
|
return true;
|
|
1571
1569
|
} else {
|
|
1572
|
-
if (!paint.style ||
|
|
1570
|
+
if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
|
|
1573
1571
|
return false;
|
|
1574
1572
|
}
|
|
1575
1573
|
}
|
|
1576
1574
|
}
|
|
1577
1575
|
|
|
1578
1576
|
function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
|
|
1579
|
-
const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
1577
|
+
const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
|
|
1580
1578
|
let {width: width, height: height} = image, clipUI;
|
|
1581
|
-
if (transform && !transform.onlyScale ||
|
|
1579
|
+
if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
|
|
1582
1580
|
canvas.save();
|
|
1583
1581
|
clipUI && canvas.clipUI(ui);
|
|
1584
1582
|
blendMode && (canvas.blendMode = blendMode);
|
|
@@ -1593,7 +1591,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
|
|
|
1593
1591
|
}
|
|
1594
1592
|
|
|
1595
1593
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
1596
|
-
const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
|
|
1594
|
+
const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
|
|
1597
1595
|
if (canvas) {
|
|
1598
1596
|
const {pixelRatio: pixelRatio} = canvas;
|
|
1599
1597
|
scaleData.scaleX *= pixelRatio;
|
package/dist/miniapp.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as a,DataHelper as n,canvasSizeAttrs as o,isUndefined as r,ResizeEvent as l,FileHelper as d,Creator as c,LeaferImage as h,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as x,Bounds as v,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as E,isObject as A,BoundsHelper as T,FourNumberHelper as L,Matrix as C,ImageEvent as O,MatrixHelper as W,MathHelper as M,AlignHelper as P,PointHelper as D,getMatrixData as I,AroundHelper as F,Direction4 as z}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{Paint as U,PaintImage as Y,ColorConvert as X,PaintGradient as G,Effect as N,Group as q,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class V extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:e,height:n,pixelRatio:o}=this.config,r={width:e||t.width,height:n||t.height,pixelRatio:o};this.resize(r),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,a,n){this.context.roundRect(t,e,i,a,s(n)?[n]:n)}),a(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,o),this.resize(t),r(this.width)||this.resizeListener(new l(t,e))}}const{mineType:H,fileType:Q}=d;function Z(t,e){i.origin={createCanvas:(t,i,s)=>{const a={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(a):e.createOffScreenCanvas(a)},canvasToDataURL:(t,e,i)=>t.toDataURL(H(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let a=t.toDataURL(H(Q(e)),s);return a=a.substring(a.indexOf("64,")+3),i.origin.download(a,e)},download:(t,s)=>new Promise((a,n)=>{let o;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,o=!0);const r=e.getFileSystemManager();r.writeFile({filePath:s,data:t,encoding:"base64",success(){o?i.miniapp.saveToAlbum(s).then(()=>{r.unlink({filePath:s}),a()}):a()},fail(t){n(t)}})}),loadImage:t=>new Promise((e,s)=>{const a=i.canvas.view.createImage();a.onload=()=>{e(a)},a.onerror=t=>{s(t)},a.src=i.image.getRealURL(t)}),noRepeat:"repeat-x"},i.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=c.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(c,{canvas:(t,e)=>new V(t,e),image:t=>new h(t)}),i.name="miniapp",i.requestRender=function(t){const{view:e}=i.renderCanvas||i.canvas;e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)},u(i,"devicePixelRatio",{get:()=>Math.max(1,wx.getWindowInfo?wx.getWindowInfo().pixelRatio:wx.getSystemInfoSync().pixelRatio)});class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=m,{pushAllChildBranch:et,pushAllParent:it}=y;const{worldBounds:st}=x;class at{constructor(t){this.updatedBounds=new v,this.beforeBounds=new v,this.afterBounds=new v,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:nt,updateAllChange:ot}=m,rt=b.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){rt.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?rt.warn("layouting"):this.times>3?rt.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:o}=B,r=this.getBlocks(s);r.forEach(t=>t.setBefore()),i.emitEvent(new B(a,r,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||K(s[t])}K(i)}})}(this.__levelList),function(t){t.list.forEach(tt)}(s),this.extraBlock&&r.push(this.extraBlock),r.forEach(t=>t.setAfter()),i.emitEvent(new B(n,r,this.times)),i.emitEvent(new B(o,r,this.times)),this.addBlocks(r),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=B,n=this.getBlocks(new f(e));e.emitEvent(new B(i,n,this.times)),lt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,n,this.times)),e.emitEvent(new B(a,n,this.times)),this.addBlocks(n),R.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),ot(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const dt=b.get("Renderer");class ct{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=n.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new v,dt.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,dt.error(t)}dt.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return dt.warn("rendering");if(this.times>3)return dt.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new v,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),a=new v(s);i.save(),s.spread(ct.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,a),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:s}=this,a=t.includes(this.target.__world),n=a?{includes:a}:{bounds:t,includes:a};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),i.render(this.target,s,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new v;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:a}=this;a.length>30&&a.shift(),a.push(t),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new v(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new v(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||dt.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[l.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ht(t,e,i){t.__.__font?U.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ut(t,e,i,s,a){const n=i.__;A(t)?U.drawStrokesStyle(t,e,!1,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&U.strokeArrow(t,i,s,a)}function ft(t,e,i,s,a){const n=i.__;A(t)?U.drawStrokesStyle(t,e,!0,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),U.drawTextStroke(i,s,a))}function pt(t,e,i,s,a){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ft(t,2,i,n,a),n.blendMode="outside"===e?"destination-out":"destination-in",U.fillText(i,n,a),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}ct.clipSpread=10,Object.assign(c,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new ct(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=lt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:gt,copyAndSpread:_t,toOuterOf:wt,getOuterOf:mt,getByMove:yt,move:xt,getIntersectData:vt}=T,St={};let bt;const{stintSet:kt}=n,{hasTransparent:Bt}=X;function Rt(t,i,s){if(!A(i)||!1===i.visible||0===i.opacity)return;let a;const{boxBounds:n}=s.__layout;switch(i.type){case"image":a=Y.image(s,t,i,n,!bt||!bt[i.url]);break;case"linear":a=G.linearGradient(i,n);break;case"radial":a=G.radialGradient(i,n);break;case"angular":a=G.conicGradient(i,n);break;case"solid":const{type:e,color:o,opacity:l}=i;a={type:e,style:X.string(o,l)};break;default:r(i.r)||(a={type:"solid",style:X.string(i)})}if(a){if(e(a.style)&&Bt(a.style)&&(a.isTransparent=!0),i.style){if(0===i.style.strokeWidth)return;a.strokeStyle=i.style}i.editing&&(a.editing=i.editing),i.blendMode&&(a.blendMode=i.blendMode)}return a}const Et={compute:function(t,e){const i=e.__,s=[];let a,n,o,r=i.__input[t];S(r)||(r=[r]),bt=Y.recycleImage(t,i);for(let i,a=0,n=r.length;a<n;a++)(i=Rt(t,r[a],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)&&(a=!0),n=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",a),kt(i,"__isTransparentFill",n)):(kt(i,"__isAlphaPixelStroke",a),kt(i,"__isTransparentStroke",n),kt(i,"__hasMultiStrokeStyle",o))},fill:function(t,e,i,s){i.fillStyle=t,ht(e,i,s)},fills:function(t,e,i,s){let a;for(let n=0,o=t.length;n<o;n++){if(a=t[n],a.image){if(Y.checkImage(a,!e.__.__font,e,i,s))continue;if(!a.style){!n&&a.image.isPlacehold&&e.drawImagePlaceholder(a.image,i,s);continue}}if(i.fillStyle=a.style,a.transform||a.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),a.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===a.scaleFixed||"zoom-in"===a.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}a.blendMode&&(i.blendMode=a.blendMode),ht(e,i,s),i.restore()}else a.blendMode?(i.saveBlendMode(a.blendMode),ht(e,i,s),i.restoreBlendMode()):ht(e,i,s)}},fillPathOrText:ht,fillText:function(t,e,i){const s=t.__,{rows:a,decorationY:n}=s.__textDrawData;let o;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=a.length;t<i;t++)o=a[t],o.text?e.fillText(o.text,o.x,o.y):o.data&&o.data.forEach(t=>{e.fillText(t.char,t.x,o.y)});if(n){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const a=e.__;if(a.__strokeWidth)if(a.__font)U.strokeText(t,e,i,s);else switch(a.strokeAlign){case"center":ut(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),ut(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const a=e.__;if(a.__fillAfterStroke)ut(t,2,e,i,s);else{const{renderBounds:n}=e.__layout,o=i.getSameCanvas(!0,!0);e.__drawRenderPath(o),ut(t,2,e,o,s),o.clipUI(a),o.clearWorld(n),m.copyCanvasByWorld(e,i,o),o.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){U.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":ft(t,1,e,i,s);break;case"inside":pt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?ft(t,2,e,i,s):pt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,a=t.__.__textDrawData;const{rows:n,decorationY:o}=a;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(o){const{decorationHeight:t}=a;n.forEach(i=>o.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,a,n){let o;const r=s.__,{__hasMultiStrokeStyle:l}=r;l||a.setStroke(void 0,r.__strokeWidth*e,r);for(let d=0,c=t.length;d<c;d++)if(o=t[d],(!o.image||!Y.checkImage(o,!1,s,a,n))&&o.style){if(l){const{strokeStyle:t}=o;t?a.setStroke(o.style,r.__getRealStrokeWidth(t)*e,r,t):a.setStroke(o.style,r.__strokeWidth*e,r)}else a.strokeStyle=o.style;o.blendMode?(a.saveBlendMode(o.blendMode),i?U.drawTextStroke(s,a,n):a.stroke(),a.restoreBlendMode()):i?U.drawTextStroke(s,a,n):a.stroke()}},shape:function(t,e,s){const a=e.getSameCanvas(),n=e.bounds,o=t.__nowWorld,r=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let d,c,h,u,f,p;wt(r.strokeSpread?(_t(St,r.boxBounds,r.strokeSpread),St):r.boxBounds,o,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))p=a,d=f=l,c=o;else{let a;if(i.fullImageShadow)a=l;else{const t=r.renderShapeSpread?gt(n,L.swapAndScale(r.renderShapeSpread,g,_)):n;a=vt(t,l)}u=n.getFitMatrix(a);let{a:w,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=mt(l,u),d=yt(f,-u.e,-u.f),c=mt(o,u),xt(c,-u.e,-u.f);const y=s.matrix;y?(h=new C(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(a,s),{canvas:a,matrix:h,fitMatrix:u,bounds:d,renderBounds:c,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let At,Tt=new v;const{isSame:Lt}=T;function Ct(t,e,i,s,a,n){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 a.data||Y.createData(a,s,i,n),!0}function Ot(t,e){Pt(t,O.LOAD,e)}function Wt(t,e){Pt(t,O.LOADED,e)}function Mt(t,e,i){e.error=i,t.forceUpdate("surface"),Pt(t,O.ERROR,e)}function Pt(t,e,i){t.hasEvent(e)&&t.emitEvent(new O(e,i))}function Dt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:It,translate:Ft}=W,zt=new v,Ut={},Yt={};function Xt(t,i,s,a){const n=e(t)||a?(a?s-a*i:s%i)/((a||Math.floor(s/i))-1):t;return"auto"===t&&n<0?0:n}let Gt={},Nt=I();const{get:qt,set:jt,rotateOfOuter:Vt,translate:Ht,scaleOfOuter:Qt,multiplyParent:Zt,scale:$t,rotate:Jt,skew:Kt}=W;function te(t,e,i,s,a,n,o,r){o&&Jt(t,o),r&&Kt(t,r.x,r.y),a&&$t(t,a,n),Ht(t,e.x+i,e.y+s)}function ee(t,e,i,s){return new(i||(i=Promise))(function(a,n){function o(t){try{l(s.next(t))}catch(t){n(t)}}function r(t){try{l(s.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,r)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ie,scale:se,copy:ae}=W,{getFloorScale:ne}=M,{abs:oe}=Math;const re={image:function(t,e,i,s,a){let n,o;const r=E.get(i);return At&&i===At.paint&&Lt(s,At.boxBounds)?n=At.leafPaint:(n={type:i.type,image:r},r.hasAlphaPixel&&(n.isTransparent=!0),At=r.use>1?{leafPaint:n,paint:i,boxBounds:Tt.set(s)}:null),(a||r.loading)&&(o={image:r,attrName:e,attrValue:i}),r.ready?(Ct(t,e,i,r,n,s),a&&(Ot(t,o),Wt(t,o))):r.error?a&&Mt(t,o,r.error):(a&&(Dt(t,!0),Ot(t,o)),n.loadId=r.load(()=>{Dt(t,!1),t.destroyed||(Ct(t,e,i,r,n,s)&&(r.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Wt(t,o)),n.loadId=void 0},e=>{Dt(t,!1),Mt(t,o,e),n.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{r.ready||(r.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):r.isPlacehold=!0)),n},checkImage:function(t,e,s,a,n){const{scaleX:o,scaleY:r}=Y.getImageRenderScaleData(t,s,a,n),{image:d,data:c}=t,{exporting:h}=n;return!(!c||t.patternId===o+"-"+r&&!h)&&(e&&(c.repeat?e=!1:t.changeful||"miniapp"===i.name&&l.isResizing(s)||h||(e=i.image.isLarge(d,o,r))),e?(s.__.__isFastShadow&&(a.fillStyle=t.style||"#000",a.fill()),Y.drawImage(t,o,r,s,a,n),!0):(!t.style||t.sync||h?Y.createPattern(t,s,a,n):Y.createPatternTask(t,s,a,n),!1))},drawImage:function(t,e,i,s,a,n){const{data:o,image:r,blendMode:l}=t,{opacity:d,transform:c}=o,h=r.getFull(o.filters),u=s.__;let f,{width:p,height:g}=r;c&&!c.onlyScale||(f=u.path||u.cornerRadius)||d||l?(a.save(),f&&a.clipUI(s),l&&(a.blendMode=l),d&&(a.opacity*=d),c&&a.transform(c),a.drawImage(h,0,0,p,g),a.restore()):(o.scaleX&&(p*=o.scaleX,g*=o.scaleY),a.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,i,s){const a=e.getRenderScaleData(!0,t.scaleFixed),{data:n}=t;if(i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return n&&n.scaleX&&(a.scaleX*=Math.abs(n.scaleX),a.scaleY*=Math.abs(n.scaleY)),a},recycleImage:function(t,e){const i=e["_"+t];if(S(i)){let s,a,n,o,r;for(let l=0,d=i.length;l<d;l++)s=i[l],a=s.image,r=a&&a.url,r&&(n||(n={}),n[r]=!0,E.recycle(a),a.loading&&(o||(o=e.__input&&e.__input[t]||[],S(o)||(o=[o])),a.unload(i[l].loadId,!o.some(t=>t.url===r))));return n}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=E.patternTasker.add(()=>ee(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&Y.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,e,s,a){let{scaleX:n,scaleY:o}=Y.getImageRenderScaleData(t,e,s,a),r=n+"-"+o;if(t.patternId!==r&&!e.destroyed&&(!i.image.isLarge(t.image,n,o)||t.data.repeat)){const{image:s,data:a}=t,{transform:l,gap:d}=a,c=Y.getPatternFixScale(t,n,o);let h,u,f,{width:p,height:g}=s;c&&(n*=c,o*=c),p*=n,g*=o,d&&(u=d.x*n/oe(a.scaleX||1),f=d.y*o/oe(a.scaleY||1)),(l||1!==n||1!==o)&&(n*=ne(p+(u||0)),o*=ne(g+(f||0)),h=ie(),l&&ae(h,l),se(h,1/n,1/o));const _=s.getCanvas(p,g,a.opacity,a.filters,u,f,e.leafer&&e.leafer.config.smooth),w=s.getPattern(_,a.repeat||i.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=r}},getPatternFixScale:function(t,e,s){const{image:a}=t;let n,o=i.image.maxPatternSize,r=a.width*a.height;return a.isSVG?e>1&&(n=Math.ceil(e)/e):o>r&&(o=r),(r*=e*s)>o&&(n=Math.sqrt(o/r)),n},createData:function(t,e,i,s){const{changeful:a,sync:n,scaleFixed:o}=i;a&&(t.changeful=a),n&&(t.sync=n),o&&(t.scaleFixed=o),t.data=Y.getPatternData(i,s,e)},getPatternData:function(t,i,s){t.padding&&(i=zt.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:n}=s,{opacity:o,mode:r,align:l,offset:d,scale:c,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,m=i.width===a&&i.height===n,y={mode:r},x="center"!==l&&(u||0)%180==90;let v,S;switch(T.set(Yt,0,0,x?n:a,x?a:n),r&&"cover"!==r&&"fit"!==r?((c||h)&&(M.getScaleData(c,h,s,Ut),v=Ut.scaleX,S=Ut.scaleY),(l||_||g)&&(v&&T.scale(Yt,v,S,!0),l&&P.toPoint(l,Yt,i,Yt,!0,!0))):m&&!u||(v=S=T.getFitScale(i,Yt,"fit"!==r),T.put(i,s,l,v,!1,Yt),T.scale(Yt,v,S,!0)),d&&D.move(Yt,d),r){case"stretch":m?v&&(v=S=void 0):(v=i.width/a,S=i.height/n,Y.stretchMode(y,i,v,S));break;case"normal":case"clip":if(Yt.x||Yt.y||v||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),Y.clipMode(y,i,Yt.x,Yt.y,v,S,u,f,t,e),t&&(v=v?v*t:t,S=S?S*e:e)}break;case"repeat":(!m||v||u||f)&&Y.repeatMode(y,i,a,n,Yt.x,Yt.y,v,S,u,f,l,t.freeTransform),g||(y.repeat="repeat");const e=A(g);(_||e)&&(y.gap=function(t,e,i,s,a){let n,o;A(t)?(n=t.x,o=t.y):n=o=t;return{x:Xt(n,i,a.width,e&&e.x),y:Xt(o,s,a.height,e&&e.y)}}(_,e&&g,Yt.width,Yt.height,i));break;default:v&&Y.fillOrFitMode(y,i,Yt.x,Yt.y,v,S,u)}return y.transform||(i.x||i.y)&&Ft(y.transform=It(),i.x,i.y),v&&(y.scaleX=v,y.scaleY=S),o&&o<1&&(y.opacity=o),w&&(y.filters=w),g&&(y.repeat=e(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y},stretchMode:function(t,e,i,s){const a=qt(),{x:n,y:o}=e;n||o?Ht(a,n,o):a.onlyScale=!0,$t(a,i,s),t.transform=a},fillOrFitMode:function(t,e,i,s,a,n,o){const r=qt();Ht(r,e.x+i,e.y+s),$t(r,a,n),o&&Vt(r,{x:e.x+e.width/2,y:e.y+e.height/2},o),t.transform=r},clipMode:function(t,e,i,s,a,n,o,r,l,d){const c=qt();te(c,e,i,s,a,n,o,r),l&&(o||r?(jt(Nt),Qt(Nt,e,l,d),Zt(c,Nt)):Qt(c,e,l,d)),t.transform=c},repeatMode:function(t,e,i,s,a,n,o,r,l,d,c,h){const u=qt();if(h)te(u,e,a,n,o,r,l,d);else{if(l)if("center"===c)Vt(u,{x:i/2,y:s/2},l);else switch(Jt(u,l),l){case 90:Ht(u,s,0);break;case 180:Ht(u,i,s);break;case 270:Ht(u,0,i)}Gt.x=e.x+a,Gt.y=e.y+n,Ht(u,Gt.x,Gt.y),o&&Qt(u,Gt,o,r)}t.transform=u}},{toPoint:le}=F,{hasTransparent:de}=X,ce={},he={};function ue(t,i,s,a){if(s){let n,o,r,l;for(let t=0,d=s.length;t<d;t++)n=s[t],e(n)?(r=t/(d-1),o=X.string(n,a)):(r=n.offset,o=X.string(n.color,a)),i.addColorStop(r,o),!l&&de(o)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:fe,getDistance:pe}=D,{get:ge,rotateOfOuter:_e,scaleOfOuter:we}=W,{toPoint:me}=F,ye={},xe={};function ve(t,e,i,s,a){let n;const{width:o,height:r}=t;if(o!==r||s){const t=fe(e,i);n=ge(),a?(we(n,e,o/r*(s||1),1),_e(n,e,t+90)):(we(n,e,1,o/r*(s||1)),_e(n,e,t))}return n}const{getDistance:Se}=D,{toPoint:be}=F,ke={},Be={};const Re={linearGradient:function(t,e){let{from:s,to:a,type:n,opacity:o}=t;le(s||"top",e,ce),le(a||"bottom",e,he);const r=i.canvas.createLinearGradient(ce.x,ce.y,he.x,he.y),l={type:n,style:r};return ue(l,r,t.stops,o),l},radialGradient:function(t,e){let{from:s,to:a,type:n,opacity:o,stretch:r}=t;me(s||"center",e,ye),me(a||"bottom",e,xe);const l=i.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,pe(ye,xe)),d={type:n,style:l};ue(d,l,t.stops,o);const c=ve(e,ye,xe,r,!0);return c&&(d.transform=c),d},conicGradient:function(t,e){let{from:s,to:a,type:n,opacity:o,stretch:r}=t;be(s||"center",e,ke),be(a||"bottom",e,Be);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,ke.x,ke.y):i.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Se(ke,Be)),d={type:n,style:l};ue(d,l,t.stops,o);const c=ve(e,ke,Be,r||1,i.conicGradientRotate90);return c&&(d.transform=c),d},getTransform:ve},{copy:Ee,move:Ae,toOffsetOutBounds:Te}=T,{max:Le,abs:Ce}=Math,Oe={},We=new C,Me={};function Pe(t,e){let i,s,a,n,o=0,r=0,l=0,d=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=1.5*(t.blur||0),a=Ce(t.spread||0),o=Le(o,a+n-s),r=Le(r,a+n+i),l=Le(l,a+n+s),d=Le(d,a+n-i)}),o===r&&r===l&&l===d?o:[o,r,l,d]}function De(t,e,s){const{shapeBounds:a}=s;let n,o;i.fullImageShadow?(Ee(Oe,t.bounds),Ae(Oe,e.x-a.x,e.y-a.y),n=t.bounds,o=Oe):(n=a,o=e),t.copyWorld(s.canvas,n,o)}const{toOffsetOutBounds:Ie}=T,Fe={};const ze=Pe;const Ue={shadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{shadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=o.length-1;Te(l,Me,d),o.forEach((o,g)=>{let _=1;if(o.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(_=1/t)}f.setWorldShadow(Me.offsetX+(o.x||0)*h*_,Me.offsetY+(o.y||0)*u*_,(o.blur||0)*h*_,X.string(o.color)),a=N.getShadowTransform(t,f,i,o,Me,_),a&&f.setTransform(a),De(f,Me,i),a&&f.resetTransform(),s=d,o.box&&(f.restore(),f.save(),r&&(f.copyWorld(f,d,n,"copy"),s=n),r?f.copyWorld(r,n,n,"destination-out"):f.copyWorld(i.canvas,c,l,"destination-out")),m.copyCanvasByWorld(t,e,f,s,o.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{innerShadow:o}=t.__,{worldCanvas:r,bounds:l,renderBounds:d,shapeBounds:c,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=o.length-1;Ie(l,Fe,d),o.forEach((o,g)=>{let _=1;if(o.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(Fe.offsetX+(o.x||0)*h*_,Fe.offsetY+(o.y||0)*u*_,(o.blur||0)*h*_),a=N.getShadowTransform(t,f,i,o,Fe,_,!0),a&&f.setTransform(a),De(f,Fe,i),f.restore(),r?(f.copyWorld(f,d,n,"copy"),f.copyWorld(r,n,n,"source-out"),s=n):(f.copyWorld(i.canvas,c,l,"source-out"),s=d),f.fillWorld(s,X.string(o.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,o.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Pe,getShadowTransform:function(t,e,i,s,a,n,o){if(s.spread){const i=2*s.spread*n*(o?-1:1),{width:r,height:l}=t.__layout.strokeBounds;return We.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/r,1+i/l),We}},isTransformShadow(t){},getInnerShadowSpread:ze},{excludeRenderBounds:Ye}=x;let Xe;function Ge(t,e,i,s,a,n,o,r){switch(e){case"grayscale":Xe||(Xe=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const o=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,o),n&&s.recycle(o);qe(t,e,i,1,a,n)}(t,i,s,a,o,r);break;case"opacity-path":qe(t,i,s,n,o,r);break;case"path":r&&i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function qe(t,e,i,s,a,n){const o=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,o,void 0,a),n?i.recycle(o):i.clearWorld(o)}q.prototype.__renderMask=function(t,e){let i,s,a,n,o,r;const{children:l}=this;for(let d=0,c=l.length;d<c;d++){if(i=l[d],r=i.__.mask,r){o&&(Ge(this,o,t,a,s,n,void 0,!0),s=a=null),"clipping"!==r&&"clipping-path"!==r||Ye(i,e)||i.__render(t,e),n=i.__.opacity,Xe=!1,"path"===r||"clipping-path"===r?(n<1?(o="opacity-path",a||(a=Ne(t))):(o="path",t.save()),i.__clip(a||t,e)):(o="grayscale"===r?"grayscale":"alpha",s||(s=Ne(t)),a||(a=Ne(t)),i.__render(s,e));continue}const c=1===n&&i.__.__blendMode;c&&Ge(this,o,t,a,s,n,void 0,!1),Ye(i,e)||i.__render(a||t,e),c&&Ge(this,o,t,a,s,n,c,!1)}Ge(this,o,t,a,s,n,void 0,!0)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=je+"_#~&*+\\=|≮≯≈≠=…",He=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 Qe(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Ze=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Je=Qe(je),Ke=Qe(Ve),ti=Qe("- —/~|┆·");var ei;!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"}(ei||(ei={}));const{Letter:ii,Single:si,Before:ai,After:ni,Symbol:oi,Break:ri}=ei;function li(t){return Ze[t]?ii:ti[t]?ri:$e[t]?ai:Je[t]?ni:Ke[t]?oi:He.test(t)?si:ii}const di={trimRight(t){const{words:e}=t;let i,s=0,a=e.length;for(let n=a-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)s++,t.width-=i.width;s&&e.splice(a-s,s)}};function ci(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:hi}=di,{Letter:ui,Single:fi,Before:pi,After:gi,Symbol:_i,Break:wi}=ei;let mi,yi,xi,vi,Si,bi,ki,Bi,Ri,Ei,Ai,Ti,Li,Ci,Oi,Wi,Mi,Pi=[];function Di(t,e){Ri&&!Bi&&(Bi=Ri),mi.data.push({char:t,width:e}),xi+=e}function Ii(){vi+=xi,mi.width=xi,yi.words.push(mi),mi={data:[]},xi=0}function Fi(){Ci&&(Oi.paraNumber++,yi.paraStart=!0,Ci=!1),Ri&&(yi.startCharSize=Bi,yi.endCharSize=Ri,Bi=0),yi.width=vi,Wi.width?hi(yi):Mi&&zi(),Pi.push(yi),yi={words:[]},vi=0}function zi(){vi>(Oi.maxWidth||0)&&(Oi.maxWidth=vi)}const{top:Ui,right:Yi,bottom:Xi,left:Gi}=z;function Ni(t,e,i){const{bounds:s,rows:a}=t;s[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const qi={getDrawData:function(t,s){e(t)||(t=String(t));let a=0,n=0,o=s.__getInput("width")||0,r=s.__getInput("height")||0;const{__padding:l}=s;l&&(o?(a=l[Gi],o-=l[Yi]+l[Gi],!o&&(o=.01)):s.autoSizeAlign||(a=l[Gi]),r?(n=l[Ui],r-=l[Ui]+l[Xi],!r&&(r=.01)):s.autoSizeAlign||(n=l[Ui]));const d={bounds:{x:a,y:n,width:o,height:r},rows:[],paraNumber:0,font:i.canvas.font=s.__font};return function(t,e,s){Oi=t,Pi=t.rows,Wi=t.bounds,Mi=!Wi.width&&!s.autoSizeAlign;const{__letterSpacing:a,paraIndent:n,textCase:o}=s,{canvas:r}=i,{width:l}=Wi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Ci=!0,Ai=null,Bi=ki=Ri=xi=vi=0,mi={data:[]},yi={words:[]},a&&(e=[...e]);for(let s=0,d=e.length;s<d;s++)bi=e[s],"\n"===bi?(xi&&Ii(),yi.paraEnd=!0,Fi(),Ci=!0):(Ei=li(bi),Ei===ui&&"none"!==o&&(bi=ci(bi,o,!xi)),ki=r.measureText(bi).width,a&&(a<0&&(Ri=ki),ki+=a),Ti=Ei===fi&&(Ai===fi||Ai===ui)||Ai===fi&&Ei!==gi,Li=!(Ei!==pi&&Ei!==fi||Ai!==_i&&Ai!==gi),Si=Ci&&n?l-n:l,t&&l&&vi+xi+ki>Si&&(i?(xi&&Ii(),vi&&Fi()):(Li||(Li=Ei===ui&&Ai==gi),Ti||Li||Ei===wi||Ei===pi||Ei===fi||xi+ki>Si?(xi&&Ii(),vi&&Fi()):vi&&Fi()))," "===bi&&!0!==Ci&&vi+xi===0||(Ei===wi?(" "===bi&&xi&&Ii(),Di(bi,ki),Ii()):Ti||Li?(xi&&Ii(),Di(bi,ki)):Di(bi,ki)),Ai=Ei);xi&&Ii(),vi&&Fi(),Pi.length>0&&(Pi[Pi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Oi.paraNumber++,vi=r.measureText(t).width,Pi.push({x:n||0,text:t,width:vi,paraStart:!0}),Mi&&zi()})}(d,t,s),l&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ni(e,"x",t[Gi]);break;case"right":Ni(e,"x",-t[Yi])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ni(e,"y",t[Ui]);break;case"bottom":Ni(e,"y",-t[Xi])}}(l,d,s,o,r),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:o,__letterSpacing:r,__clipText:l,textAlign:d,verticalAlign:c,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=n*a+(h?h*(t.paraNumber-1):0),m=o;if(l&&w>_)w=Math.max(_,n),a>1&&(t.overflow=a);else if(_||u)switch(c){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,x,v,S=g||u?g:t.maxWidth;for(let o=0,c=a;o<c;o++){if(y=i[o],y.x=f,y.width<g||y.width>g&&!l)switch(d){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&o>0&&(m+=h),y.y=m,m+=n,t.overflow>o&&m>w&&(y.isOverflow=!0,t.overflow=o+1),x=y.x,v=y.width,r<0&&(y.width<0?(v=-y.width+e.fontSize+r,x-=v,v+=e.fontSize):v-=r),x<s.x&&(s.x=x),v>s.width&&(s.width=v),l&&g&&g<v&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(d,s),s.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n,letterSpacing:o}=e,r=i&&a.includes("both"),l=r||i&&a.includes("justify"),d=l&&a.includes("letter");let c,h,u,f,p,g,_,w,m,y;s.forEach(t=>{t.words&&(p=n&&t.paraStart?n:0,w=t.words.length,l&&(y=!t.paraEnd||r,h=i-t.width-p,d?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=o||t.isOverflow||d?0:u?1:2,t.isOverflow&&!o&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,c=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(_={char:"",x:c},c=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,c,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):c=function(t,e,i,s,a){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,c,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(c+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(d,s,o),d.overflow&&function(t,e,s,a){if(!a)return;const{rows:n,overflow:o}=t;let{textOverflow:r}=e;if(n.splice(o),r&&"show"!==r){let t,l;"hide"===r?r="":"ellipsis"===r&&(r="...");const d=r?i.canvas.measureText(r).width:0,c=s+a-d;("none"===e.textWrap?n:[n[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<c));s--){if(l<c&&" "!==t.char||!s){e.data.splice(s+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)}})}}(d,s,a,o),"none"!==s.textDecoration&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,A(n)?(i=n.type,n.color&&(t.decorationColor=X.string(n.color)),n.offset&&(s=Math.min(.3*a,Math.max(n.offset,.15*-a)))):i=n,i){case"under":t.decorationY=[.15*a+s];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a+s,.35*-a]}}(d,s),d}};const ji={string:function(t,i){if(!t)return"#000";const a=s(i)&&i<1;if(e(t)){if(!a||!X.object)return t;t=X.object(t)}let n=r(t.a)?1:t.a;a&&(n*=i);const o=t.r+","+t.g+","+t.b;return 1===n?"rgb("+o+")":"rgba("+o+","+n+")"}};Object.assign(j,qi),Object.assign(X,ji),Object.assign(U,Et),Object.assign(Y,re),Object.assign(G,Re),Object.assign(N,Ue);try{wx&&Z(0,wx)}catch(t){}export{lt as Layouter,V as LeaferCanvas,ct as Renderer,$ as Watcher,Z as useCanvas};
|
|
1
|
+
import{LeaferCanvasBase as t,isString as e,Platform as i,isNumber as s,canvasPatch as a,DataHelper as n,canvasSizeAttrs as r,isUndefined as o,ResizeEvent as l,FileHelper as c,Creator as d,LeaferImage as h,defineKey as u,LeafList as f,RenderEvent as p,ChildEvent as g,WatchEvent as _,PropertyEvent as w,LeafHelper as m,BranchHelper as y,LeafBoundsHelper as v,Bounds as x,isArray as S,Debug as b,LeafLevelList as k,LayoutEvent as B,Run as R,ImageManager as E,isObject as A,BoundsHelper as T,FourNumberHelper as L,Matrix as P,ImageEvent as C,MatrixHelper as O,MathHelper as W,AlignHelper as M,PointHelper as D,getMatrixData as I,AroundHelper as z,Direction4 as F}from"@leafer/core";export*from"@leafer/core";export{LeaferImage}from"@leafer/core";import{Paint as U,PaintImage as Y,ColorConvert as X,PaintGradient as G,Effect as N,Group as q,TextConvert as j}from"@leafer-ui/draw";export*from"@leafer-ui/draw";class V extends t{get allowBackgroundColor(){return!1}init(){const{config:t}=this;let s=t.view||t.canvas;s?(e(s)?("#"!==s[0]&&(s="#"+s),this.viewSelect=i.miniapp.select(s)):s.fields?this.viewSelect=s:this.initView(s),this.viewSelect&&i.miniapp.getSizeView(this.viewSelect).then(t=>{this.initView(t)})):this.initView()}initView(t){t?this.view=t.view||t:(t={},this.__createView()),this.view.getContext?this.__createContext():this.unrealCanvas();const{width:e,height:n,pixelRatio:r}=this.config,o={width:e||t.width,height:n||t.height,pixelRatio:r};this.resize(o),this.context&&(this.viewSelect&&(i.renderCanvas=this),this.context.roundRect&&(this.roundRect=function(t,e,i,a,n){this.context.roundRect(t,e,i,a,s(n)?[n]:n)}),a(this.context.__proto__))}__createView(){this.view=i.origin.createCanvas(1,1)}updateViewSize(){if(this.unreal)return;const{width:t,height:e,pixelRatio:i}=this;this.view.width=Math.ceil(t*i),this.view.height=Math.ceil(e*i)}updateClientBounds(t){this.viewSelect&&i.miniapp.getBounds(this.viewSelect).then(e=>{this.clientBounds=e,t&&t()})}startAutoLayout(t,e){this.resizeListener||(this.resizeListener=e,t&&(this.checkSize=this.checkSize.bind(this),i.miniapp.onWindowResize(this.checkSize)))}checkSize(){this.viewSelect&&setTimeout(()=>{this.updateClientBounds(()=>{const{width:t,height:e}=this.clientBounds,{pixelRatio:i}=this,s={width:t,height:e,pixelRatio:i};this.isSameSize(s)||this.emitResize(s)})},500)}stopAutoLayout(){this.autoLayout=!1,this.resizeListener=null,i.miniapp.offWindowResize(this.checkSize)}unrealCanvas(){this.unreal=!0}emitResize(t){const e={};n.copyAttrs(e,this,r),this.resize(t),o(this.width)||this.resizeListener(new l(t,e))}}const{mineType:H,fileType:Q}=c;function Z(t,e){i.origin={createCanvas:(t,i,s)=>{const a={type:"2d",width:t,height:i};return e.createOffscreenCanvas?e.createOffscreenCanvas(a):e.createOffScreenCanvas(a)},canvasToDataURL:(t,e,i)=>t.toDataURL(H(e),i),canvasToBolb:(t,e,i)=>t.toBuffer(e,{quality:i}),canvasSaveAs:(t,e,s)=>{let a=t.toDataURL(H(Q(e)),s);return a=a.substring(a.indexOf("64,")+3),i.origin.download(a,e)},download:(t,s)=>new Promise((a,n)=>{let r;s.includes("/")||(s=`${e.env.USER_DATA_PATH}/`+s,r=!0);const o=e.getFileSystemManager();o.writeFile({filePath:s,data:t,encoding:"base64",success(){r?i.miniapp.saveToAlbum(s).then(()=>{o.unlink({filePath:s}),a()}):a()},fail(t){n(t)}})}),loadImage:t=>new Promise((e,s)=>{const a=i.canvas.view.createImage();a.onload=()=>{e(a)},a.onerror=t=>{s(t)},a.src=i.image.getRealURL(t)}),noRepeat:"repeat-x"},i.miniapp={select:t=>e.createSelectorQuery().select(t),getBounds:t=>new Promise(e=>{t.boundingClientRect().exec(t=>{const i=t[1];e({x:i.top,y:i.left,width:i.width,height:i.height})})}),getSizeView:t=>new Promise(e=>{t.fields({node:!0,size:!0}).exec(t=>{const i=t[0];e({view:i.node,width:i.width,height:i.height})})}),saveToAlbum:t=>new Promise(i=>{e.getSetting({success:s=>{s.authSetting["scope.writePhotosAlbum"]?e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}}):e.authorize({scope:"scope.writePhotosAlbum",success:()=>{e.saveImageToPhotosAlbum({filePath:t,success(){i(!0)}})},fail:()=>{}})}})}),onWindowResize(t){e.onWindowResize(t)},offWindowResize(t){e.offWindowResize(t)}},i.event={stopDefault(t){},stopNow(t){},stop(t){}},i.canvas=d.canvas(),i.conicGradientSupport=!!i.canvas.context.createConicGradient}Object.assign(d,{canvas:(t,e)=>new V(t,e),image:t=>new h(t)}),i.name="miniapp",i.requestRender=function(t){const{view:e}=i.renderCanvas||i.canvas;e.requestAnimationFrame?e.requestAnimationFrame(t):setTimeout(t,16)},u(i,"devicePixelRatio",{get:()=>Math.max(1,wx.getWindowInfo?wx.getWindowInfo().pixelRatio:wx.getSystemInfoSync().pixelRatio)});class ${get childrenChanged(){return this.hasAdd||this.hasRemove||this.hasVisible}get updatedList(){if(this.hasRemove){const t=new f;return this.__updatedList.list.forEach(e=>{e.leafer&&t.add(e)}),t}return this.__updatedList}constructor(t,e){this.totalTimes=0,this.config={},this.__updatedList=new f,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}update(){this.changed=!0,this.running&&this.target.emit(p.REQUEST)}__onAttrChange(t){this.__updatedList.add(t.target),this.update()}__onChildEvent(t){t.type===g.ADD?(this.hasAdd=!0,this.__pushChild(t.child)):(this.hasRemove=!0,this.__updatedList.add(t.parent)),this.update()}__pushChild(t){this.__updatedList.add(t),t.isBranch&&this.__loopChildren(t)}__loopChildren(t){const{children:e}=t;for(let t=0,i=e.length;t<i;t++)this.__pushChild(e[t])}__onRquestData(){this.target.emitEvent(new _(_.DATA,{updatedList:this.updatedList})),this.__updatedList=new f,this.totalTimes++,this.changed=this.hasVisible=this.hasRemove=this.hasAdd=!1}__listenEvents(){this.__eventIds=[this.target.on_([[w.CHANGE,this.__onAttrChange,this],[[g.ADD,g.REMOVE],this.__onChildEvent,this],[_.REQUEST,this.__onRquestData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.__updatedList=null)}}const{updateAllMatrix:J,updateBounds:K,updateChange:tt}=m,{pushAllChildBranch:et,pushAllParent:it}=y;const{worldBounds:st}=v;class at{constructor(t){this.updatedBounds=new x,this.beforeBounds=new x,this.afterBounds=new x,S(t)&&(t=new f(t)),this.updatedList=t}setBefore(){this.beforeBounds.setListWithFn(this.updatedList.list,st)}setAfter(){this.afterBounds.setListWithFn(this.updatedList.list,st),this.updatedBounds.setList([this.beforeBounds,this.afterBounds])}merge(t){this.updatedList.addList(t.updatedList.list),this.beforeBounds.add(t.beforeBounds),this.afterBounds.add(t.afterBounds),this.updatedBounds.add(t.updatedBounds)}destroy(){this.updatedList=null}}const{updateAllMatrix:nt,updateAllChange:rt}=m,ot=b.get("Layouter");class lt{constructor(t,e){this.totalTimes=0,this.config={},this.__levelList=new k,this.target=t,e&&(this.config=n.default(e,this.config)),this.__listenEvents()}start(){this.disabled||(this.running=!0)}stop(){this.running=!1}disable(){this.stop(),this.__removeListenEvents(),this.disabled=!0}layout(){if(this.layouting||!this.running)return;const{target:t}=this;this.times=0;try{t.emit(B.START),this.layoutOnce(),t.emitEvent(new B(B.END,this.layoutedBlocks,this.times))}catch(t){ot.error(t)}this.layoutedBlocks=null}layoutAgain(){this.layouting?this.waitAgain=!0:this.layoutOnce()}layoutOnce(){return this.layouting?ot.warn("layouting"):this.times>3?ot.warn("layout max times"):(this.times++,this.totalTimes++,this.layouting=!0,this.target.emit(_.REQUEST),this.totalTimes>1?this.partLayout():this.fullLayout(),this.layouting=!1,void(this.waitAgain&&(this.waitAgain=!1,this.layoutOnce())))}partLayout(){var t;if(!(null===(t=this.__updatedList)||void 0===t?void 0:t.length))return;const e=R.start("PartLayout"),{target:i,__updatedList:s}=this,{BEFORE:a,LAYOUT:n,AFTER:r}=B,o=this.getBlocks(s);o.forEach(t=>t.setBefore()),i.emitEvent(new B(a,o,this.times)),this.extraBlock=null,s.sort(),function(t,e){let i;t.list.forEach(t=>{i=t.__layout,e.without(t)&&!i.proxyZoom&&(i.matrixChanged?(J(t,!0),e.add(t),t.isBranch&&et(t,e),it(t,e)):i.boundsChanged&&(e.add(t),t.isBranch&&(t.__tempNumber=0),it(t,e)))})}(s,this.__levelList),function(t){let e,i,s;t.sort(!0),t.levels.forEach(a=>{e=t.levelMap[a];for(let t=0,a=e.length;t<a;t++){if(i=e[t],i.isBranch&&i.__tempNumber){s=i.children;for(let t=0,e=s.length;t<e;t++)s[t].isBranch||K(s[t])}K(i)}})}(this.__levelList),function(t){t.list.forEach(tt)}(s),this.extraBlock&&o.push(this.extraBlock),o.forEach(t=>t.setAfter()),i.emitEvent(new B(n,o,this.times)),i.emitEvent(new B(r,o,this.times)),this.addBlocks(o),this.__levelList.reset(),this.__updatedList=null,R.end(e)}fullLayout(){const t=R.start("FullLayout"),{target:e}=this,{BEFORE:i,LAYOUT:s,AFTER:a}=B,n=this.getBlocks(new f(e));e.emitEvent(new B(i,n,this.times)),lt.fullLayout(e),n.forEach(t=>{t.setAfter()}),e.emitEvent(new B(s,n,this.times)),e.emitEvent(new B(a,n,this.times)),this.addBlocks(n),R.end(t)}static fullLayout(t){nt(t,!0),t.isBranch?y.updateBounds(t):m.updateBounds(t),rt(t)}addExtra(t){if(!this.__updatedList.has(t)){const{updatedList:e,beforeBounds:i}=this.extraBlock||(this.extraBlock=new at([]));e.length?i.add(t.__world):i.set(t.__world),e.add(t)}}createBlock(t){return new at(t)}getBlocks(t){return[this.createBlock(t)]}addBlocks(t){this.layoutedBlocks?this.layoutedBlocks.push(...t):this.layoutedBlocks=t}__onReceiveWatchData(t){this.__updatedList=t.data.updatedList}__listenEvents(){this.__eventIds=[this.target.on_([[B.REQUEST,this.layout,this],[B.AGAIN,this.layoutAgain,this],[_.DATA,this.__onReceiveWatchData,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.target=this.config=null)}}const ct=b.get("Renderer");class dt{get needFill(){return!(this.canvas.allowBackgroundColor||!this.config.fill)}constructor(t,e,i){this.FPS=60,this.totalTimes=0,this.times=0,this.config={usePartRender:!0,maxFPS:120},this.frames=[],this.target=t,this.canvas=e,i&&(this.config=n.default(i,this.config)),this.__listenEvents()}start(){this.running=!0,this.update(!1)}stop(){this.running=!1}update(t=!0){this.changed||(this.changed=t),this.__requestRender()}requestLayout(){this.target.emit(B.REQUEST)}checkRender(){if(this.running){const{target:t}=this;t.isApp&&(t.emit(p.CHILD_START,t),t.children.forEach(t=>{t.renderer.FPS=this.FPS,t.renderer.checkRender()}),t.emit(p.CHILD_END,t)),this.changed&&this.canvas.view&&this.render(),this.target.emit(p.NEXT)}}render(t){if(!this.running||!this.canvas.view)return this.update();const{target:e}=this;this.times=0,this.totalBounds=new x,ct.log(e.innerName,"---\x3e");try{this.emitRender(p.START),this.renderOnce(t),this.emitRender(p.END,this.totalBounds),E.clearRecycled()}catch(t){this.rendering=!1,ct.error(t)}ct.log("-------------|")}renderAgain(){this.rendering?this.waitAgain=!0:this.renderOnce()}renderOnce(t){if(this.rendering)return ct.warn("rendering");if(this.times>3)return ct.warn("render max times");if(this.times++,this.totalTimes++,this.rendering=!0,this.changed=!1,this.renderBounds=new x,this.renderOptions={},t)this.emitRender(p.BEFORE),t();else{if(this.requestLayout(),this.ignore)return void(this.ignore=this.rendering=!1);this.emitRender(p.BEFORE),this.config.usePartRender&&this.totalTimes>1?this.partRender():this.fullRender()}this.emitRender(p.RENDER,this.renderBounds,this.renderOptions),this.emitRender(p.AFTER,this.renderBounds,this.renderOptions),this.updateBlocks=null,this.rendering=!1,this.waitAgain&&(this.waitAgain=!1,this.renderOnce())}partRender(){const{canvas:t,updateBlocks:e}=this;e&&(this.mergeBlocks(),e.forEach(e=>{t.bounds.hit(e)&&!e.isEmpty()&&this.clipRender(e)}))}clipRender(t){const e=R.start("PartRender"),{canvas:i}=this,s=t.getIntersect(i.bounds),a=new x(s);i.save(),s.spread(dt.clipSpread).ceil(),i.clearWorld(s),i.clipWorld(s),this.__render(s,a),i.restore(),R.end(e)}fullRender(){const t=R.start("FullRender"),{canvas:e}=this;e.save(),e.clear(),this.__render(e.bounds),e.restore(),R.end(t)}__render(t,e){const{canvas:s}=this,a=t.includes(this.target.__world),n=a?{includes:a}:{bounds:t,includes:a};this.needFill&&s.fillWorld(t,this.config.fill),b.showRepaint&&b.drawRepaint(s,t),i.render(this.target,s,n),this.renderBounds=e=e||t,this.renderOptions=n,this.totalBounds.isEmpty()?this.totalBounds=e:this.totalBounds.add(e),s.updateRender(e)}addBlock(t){this.updateBlocks||(this.updateBlocks=[]),this.updateBlocks.push(t)}mergeBlocks(){const{updateBlocks:t}=this;if(t){const e=new x;e.setList(t),t.length=0,t.push(e)}}__requestRender(){const t=this.target;if(this.requestTime||!t)return;if(t.parentApp)return t.parentApp.requestRender(!1);this.requestTime=this.frameTime||Date.now();const e=()=>{const t=1e3/((this.frameTime=Date.now())-this.requestTime),{maxFPS:s}=this.config;if(s&&t>s)return i.requestRender(e);const{frames:a}=this;a.length>30&&a.shift(),a.push(t),this.FPS=Math.round(a.reduce((t,e)=>t+e,0)/a.length),this.requestTime=0,this.checkRender()};i.requestRender(e)}__onResize(t){if(!this.canvas.unreal){if(t.bigger||!t.samePixelRatio){const{width:e,height:i}=t.old;if(!new x(0,0,e,i).includes(this.target.__world)||this.needFill||!t.samePixelRatio)return this.addBlock(this.canvas.bounds),void this.target.forceUpdate("surface")}this.addBlock(new x(0,0,1,1)),this.update()}}__onLayoutEnd(t){t.data&&t.data.map(t=>{let e;t.updatedList&&t.updatedList.list.some(t=>(e=!t.__world.width||!t.__world.height,e&&(t.isLeafer||ct.tip(t.innerName,": empty"),e=!t.isBranch||t.isBranchLeaf),e)),this.addBlock(e?this.canvas.bounds:t.updatedBounds)})}emitRender(t,e,i){this.target.emitEvent(new p(t,this.times,e,i))}__listenEvents(){this.__eventIds=[this.target.on_([[p.REQUEST,this.update,this],[B.END,this.__onLayoutEnd,this],[p.AGAIN,this.renderAgain,this],[l.RESIZE,this.__onResize,this]])]}__removeListenEvents(){this.target.off_(this.__eventIds)}destroy(){this.target&&(this.stop(),this.__removeListenEvents(),this.config={},this.target=this.canvas=null)}}function ht(t,e,i){t.__.__font?U.fillText(t,e,i):t.__.windingRule?e.fill(t.__.windingRule):e.fill()}function ut(t,e,i,s,a){const n=i.__;A(t)?U.drawStrokesStyle(t,e,!1,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),s.stroke()),n.__useArrow&&U.strokeArrow(t,i,s,a)}function ft(t,e,i,s,a){const n=i.__;A(t)?U.drawStrokesStyle(t,e,!0,i,s,a):(s.setStroke(t,n.__strokeWidth*e,n),U.drawTextStroke(i,s,a))}function pt(t,e,i,s,a){const n=s.getSameCanvas(!0,!0);n.font=i.__.__font,ft(t,2,i,n,a),n.blendMode="outside"===e?"destination-out":"destination-in",U.fillText(i,n,a),n.blendMode="normal",m.copyCanvasByWorld(i,s,n),n.recycle(i.__nowWorld)}dt.clipSpread=10,Object.assign(d,{watcher:(t,e)=>new $(t,e),layouter:(t,e)=>new lt(t,e),renderer:(t,e,i)=>new dt(t,e,i),selector:(t,e)=>{},interaction:(t,e,i,s)=>{}}),i.layout=lt.fullLayout,i.render=function(t,e,i){const s=Object.assign(Object.assign({},i),{topRendering:!0});i.topList=new f,t.__render(e,i),i.topList.length&&i.topList.forEach(t=>t.__render(e,s))};const{getSpread:gt,copyAndSpread:_t,toOuterOf:wt,getOuterOf:mt,getByMove:yt,move:vt,getIntersectData:xt}=T,St={};let bt;const{stintSet:kt}=n,{hasTransparent:Bt}=X;function Rt(t,i,s){if(!A(i)||!1===i.visible||0===i.opacity)return;let a;const{boxBounds:n}=s.__layout;switch(i.type){case"image":a=Y.image(s,t,i,n,!bt||!bt[i.url]);break;case"linear":a=G.linearGradient(i,n);break;case"radial":a=G.radialGradient(i,n);break;case"angular":a=G.conicGradient(i,n);break;case"solid":const{type:e,color:r,opacity:l}=i;a={type:e,style:X.string(r,l)};break;default:o(i.r)||(a={type:"solid",style:X.string(i)})}if(a&&(a.originPaint=i,e(a.style)&&Bt(a.style)&&(a.isTransparent=!0),i.style)){if(0===i.style.strokeWidth)return;a.strokeStyle=i.style}return a}const Et={compute:function(t,e){const i=e.__,s=[];let a,n,r,o=i.__input[t];S(o)||(o=[o]),bt=Y.recycleImage(t,i);for(let i,a=0,n=o.length;a<n;a++)(i=Rt(t,o[a],e))&&(s.push(i),i.strokeStyle&&(r||(r=1),i.strokeStyle.strokeWidth&&(r=Math.max(r,i.strokeStyle.strokeWidth))));i["_"+t]=s.length?s:void 0,s.length?(s.every(t=>t.isTransparent)&&(s.some(t=>t.image)&&(a=!0),n=!0),"fill"===t?(kt(i,"__isAlphaPixelFill",a),kt(i,"__isTransparentFill",n)):(kt(i,"__isAlphaPixelStroke",a),kt(i,"__isTransparentStroke",n),kt(i,"__hasMultiStrokeStyle",r))):i.__removePaint(t,!1)},fill:function(t,e,i,s){i.fillStyle=t,ht(e,i,s)},fills:function(t,e,i,s){let a,n,r;for(let o=0,l=t.length;o<l;o++){if(a=t[o],n=a.originPaint,a.image){if(r?r++:r=1,Y.checkImage(a,!e.__.__font,e,i,s))continue;if(!a.style){1===r&&a.image.isPlacehold&&e.drawImagePlaceholder(a,i,s);continue}}if(i.fillStyle=a.style,a.transform||n.scaleFixed){if(i.save(),a.transform&&i.transform(a.transform),n.scaleFixed){const{scaleX:t,scaleY:s}=e.getRenderScaleData(!0);(!0===n.scaleFixed||"zoom-in"===n.scaleFixed&&t>1&&s>1)&&i.scale(1/t,1/s)}n.blendMode&&(i.blendMode=n.blendMode),ht(e,i,s),i.restore()}else n.blendMode?(i.saveBlendMode(n.blendMode),ht(e,i,s),i.restoreBlendMode()):ht(e,i,s)}},fillPathOrText:ht,fillText:function(t,e,i){const s=t.__,{rows:a,decorationY:n}=s.__textDrawData;let r;s.__isPlacehold&&s.placeholderColor&&(e.fillStyle=s.placeholderColor);for(let t=0,i=a.length;t<i;t++)r=a[t],r.text?e.fillText(r.text,r.x,r.y):r.data&&r.data.forEach(t=>{e.fillText(t.char,t.x,r.y)});if(n){const{decorationColor:t,decorationHeight:i}=s.__textDrawData;t&&(e.fillStyle=t),a.forEach(t=>n.forEach(s=>e.fillRect(t.x,t.y+s,t.width,i)))}},stroke:function(t,e,i,s){const a=e.__;if(a.__strokeWidth)if(a.__font)U.strokeText(t,e,i,s);else switch(a.strokeAlign){case"center":ut(t,1,e,i,s);break;case"inside":!function(t,e,i,s){i.save(),i.clipUI(e),ut(t,2,e,i,s),i.restore()}(t,e,i,s);break;case"outside":!function(t,e,i,s){const a=e.__;if(a.__fillAfterStroke)ut(t,2,e,i,s);else{const{renderBounds:n}=e.__layout,r=i.getSameCanvas(!0,!0);e.__drawRenderPath(r),ut(t,2,e,r,s),r.clipUI(a),r.clearWorld(n),m.copyCanvasByWorld(e,i,r),r.recycle(e.__nowWorld)}}(t,e,i,s)}},strokes:function(t,e,i,s){U.stroke(t,e,i,s)},strokeText:function(t,e,i,s){switch(e.__.strokeAlign){case"center":ft(t,1,e,i,s);break;case"inside":pt(t,"inside",e,i,s);break;case"outside":e.__.__fillAfterStroke?ft(t,2,e,i,s):pt(t,"outside",e,i,s)}},drawTextStroke:function(t,e,i){let s,a=t.__.__textDrawData;const{rows:n,decorationY:r}=a;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(r){const{decorationHeight:t}=a;n.forEach(i=>r.forEach(s=>e.strokeRect(i.x,i.y+s,i.width,t)))}},drawStrokesStyle:function(t,e,i,s,a,n){let r;const o=s.__,{__hasMultiStrokeStyle:l}=o;l||a.setStroke(void 0,o.__strokeWidth*e,o);for(let c=0,d=t.length;c<d;c++)if(r=t[c],(!r.image||!Y.checkImage(r,!1,s,a,n))&&r.style){if(l){const{strokeStyle:t}=r;t?a.setStroke(r.style,o.__getRealStrokeWidth(t)*e,o,t):a.setStroke(r.style,o.__strokeWidth*e,o)}else a.strokeStyle=r.style;r.originPaint.blendMode?(a.saveBlendMode(r.originPaint.blendMode),i?U.drawTextStroke(s,a,n):a.stroke(),a.restoreBlendMode()):i?U.drawTextStroke(s,a,n):a.stroke()}},shape:function(t,e,s){const a=e.getSameCanvas(),n=e.bounds,r=t.__nowWorld,o=t.__layout,l=t.__nowWorldShapeBounds||(t.__nowWorldShapeBounds={});let c,d,h,u,f,p;wt(o.strokeSpread?(_t(St,o.boxBounds,o.strokeSpread),St):o.boxBounds,r,l);let{scaleX:g,scaleY:_}=t.getRenderScaleData(!0);if(n.includes(l))p=a,c=f=l,d=r;else{let a;if(i.fullImageShadow)a=l;else{const t=o.renderShapeSpread?gt(n,L.swapAndScale(o.renderShapeSpread,g,_)):n;a=xt(t,l)}u=n.getFitMatrix(a);let{a:w,d:m}=u;u.a<1&&(p=e.getSameCanvas(),t.__renderShape(p,s),g*=w,_*=m),f=mt(l,u),c=yt(f,-u.e,-u.f),d=mt(r,u),vt(d,-u.e,-u.f);const y=s.matrix;y?(h=new P(u),h.multiply(y),w*=y.scaleX,m*=y.scaleY):h=u,h.withScale(w,m),s=Object.assign(Object.assign({},s),{matrix:h})}return t.__renderShape(a,s),{canvas:a,matrix:h,fitMatrix:u,bounds:c,renderBounds:d,worldCanvas:p,shapeBounds:f,scaleX:g,scaleY:_}}};let At,Tt=new x;const{isSame:Lt}=T;function Pt(t,e,i,s,a,n){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 a.data||Y.createData(a,s,i,n),!0}function Ct(t,e){Mt(t,C.LOAD,e)}function Ot(t,e){Mt(t,C.LOADED,e)}function Wt(t,e,i){e.error=i,t.forceUpdate("surface"),Mt(t,C.ERROR,e)}function Mt(t,e,i){t.hasEvent(e)&&t.emitEvent(new C(e,i))}function Dt(t,e){const{leafer:i}=t;i&&i.viewReady&&(i.renderer.ignore=e)}const{get:It,translate:zt}=O,Ft=new x,Ut={},Yt={};function Xt(t,i,s,a){const n=e(t)||a?(a?s-a*i:s%i)/((a||Math.floor(s/i))-1):t;return"auto"===t&&n<0?0:n}let Gt={},Nt=I();const{get:qt,set:jt,rotateOfOuter:Vt,translate:Ht,scaleOfOuter:Qt,multiplyParent:Zt,scale:$t,rotate:Jt,skew:Kt}=O;function te(t,e,i,s,a,n,r,o){r&&Jt(t,r),o&&Kt(t,o.x,o.y),a&&$t(t,a,n),Ht(t,e.x+i,e.y+s)}function ee(t,e,i,s){return new(i||(i=Promise))(function(a,n){function r(t){try{l(s.next(t))}catch(t){n(t)}}function o(t){try{l(s.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(r,o)}l((s=s.apply(t,e||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const{get:ie,scale:se,copy:ae}=O,{getFloorScale:ne}=W,{abs:re}=Math;const oe={image:function(t,e,i,s,a){let n,r;const o=E.get(i);return At&&i===At.paint&&Lt(s,At.boxBounds)?n=At.leafPaint:(n={type:i.type,image:o},o.hasAlphaPixel&&(n.isTransparent=!0),At=o.use>1?{leafPaint:n,paint:i,boxBounds:Tt.set(s)}:null),(a||o.loading)&&(r={image:o,attrName:e,attrValue:i}),o.ready?(Pt(t,e,i,o,n,s),a&&(Ct(t,r),Ot(t,r))):o.error?a&&Wt(t,r,o.error):(a&&(Dt(t,!0),Ct(t,r)),n.loadId=o.load(()=>{Dt(t,!1),t.destroyed||(Pt(t,e,i,o,n,s)&&(o.hasAlphaPixel&&(t.__layout.hitCanvasChanged=!0),t.forceUpdate("surface")),Ot(t,r)),n.loadId=void 0},e=>{Dt(t,!1),Wt(t,r,e),n.loadId=void 0}),t.placeholderColor&&(t.placeholderDelay?setTimeout(()=>{o.ready||(o.isPlacehold=!0,t.forceUpdate("surface"))},t.placeholderDelay):o.isPlacehold=!0)),n},checkImage:function(t,e,s,a,n){const{scaleX:r,scaleY:o}=Y.getImageRenderScaleData(t,s,a,n),{image:c,data:d,originPaint:h}=t,{exporting:u}=n;return!(!d||t.patternId===r+"-"+o&&!u)&&(e&&(d.repeat?e=!1:h.changeful||"miniapp"===i.name&&l.isResizing(s)||u||(e=i.image.isLarge(c,r,o))),e?(s.__.__isFastShadow&&(a.fillStyle=t.style||"#000",a.fill()),Y.drawImage(t,r,o,s,a,n),!0):(!t.style||h.sync||u?Y.createPattern(t,s,a,n):Y.createPatternTask(t,s,a,n),!1))},drawImage:function(t,e,i,s,a,n){const{data:r,image:o}=t,{blendMode:l}=t.originPaint,{opacity:c,transform:d}=r,h=o.getFull(r.filters),u=s.__;let f,{width:p,height:g}=o;(f=d&&!d.onlyScale||u.path||u.cornerRadius)||c||l?(a.save(),f&&a.clipUI(s),l&&(a.blendMode=l),c&&(a.opacity*=c),d&&a.transform(d),a.drawImage(h,0,0,p,g),a.restore()):(r.scaleX&&(p*=r.scaleX,g*=r.scaleY),a.drawImage(h,0,0,p,g))},getImageRenderScaleData:function(t,e,i,s){const a=e.getRenderScaleData(!0,t.originPaint.scaleFixed),{data:n}=t;if(i){const{pixelRatio:t}=i;a.scaleX*=t,a.scaleY*=t}return n&&n.scaleX&&(a.scaleX*=Math.abs(n.scaleX),a.scaleY*=Math.abs(n.scaleY)),a},recycleImage:function(t,e){const i=e["_"+t];if(S(i)){let s,a,n,r,o;for(let l=0,c=i.length;l<c;l++)s=i[l],a=s.image,o=a&&a.url,o&&(n||(n={}),n[o]=!0,E.recycle(a),a.loading&&(r||(r=e.__input&&e.__input[t]||[],S(r)||(r=[r])),a.unload(i[l].loadId,!r.some(t=>t.url===o))));return n}return null},createPatternTask:function(t,e,i,s){t.patternTask||(t.patternTask=E.patternTasker.add(()=>ee(this,void 0,void 0,function*(){t.patternTask=null,i.bounds.hit(e.__nowWorld)&&Y.createPattern(t,e,i,s),e.forceUpdate("surface")}),300))},createPattern:function(t,e,s,a){let{scaleX:n,scaleY:r}=Y.getImageRenderScaleData(t,e,s,a),o=n+"-"+r;if(t.patternId!==o&&!e.destroyed&&(!i.image.isLarge(t.image,n,r)||t.data.repeat)){const{image:s,data:a}=t,{transform:l,gap:c}=a,d=Y.getPatternFixScale(t,n,r);let h,u,f,{width:p,height:g}=s;d&&(n*=d,r*=d),p*=n,g*=r,c&&(u=c.x*n/re(a.scaleX||1),f=c.y*r/re(a.scaleY||1)),(l||1!==n||1!==r)&&(n*=ne(p+(u||0)),r*=ne(g+(f||0)),h=ie(),l&&ae(h,l),se(h,1/n,1/r));const _=s.getCanvas(p,g,a.opacity,a.filters,u,f,e.leafer&&e.leafer.config.smooth),w=s.getPattern(_,a.repeat||i.origin.noRepeat||"no-repeat",h,t);t.style=w,t.patternId=o}},getPatternFixScale:function(t,e,s){const{image:a}=t;let n,r=i.image.maxPatternSize,o=a.width*a.height;return a.isSVG?e>1&&(n=Math.ceil(e)/e):r>o&&(r=o),(o*=e*s)>r&&(n=Math.sqrt(r/o)),n},createData:function(t,e,i,s){t.data=Y.getPatternData(i,s,e)},getPatternData:function(t,i,s){t.padding&&(i=Ft.set(i).shrink(t.padding)),"strench"===t.mode&&(t.mode="stretch");const{width:a,height:n}=s,{opacity:r,mode:o,align:l,offset:c,scale:d,size:h,rotation:u,skew:f,clipSize:p,repeat:g,gap:_,filters:w}=t,m=i.width===a&&i.height===n,y={mode:o},v="center"!==l&&(u||0)%180==90;let x,S;switch(T.set(Yt,0,0,v?n:a,v?a:n),o&&"cover"!==o&&"fit"!==o?((d||h)&&(W.getScaleData(d,h,s,Ut),x=Ut.scaleX,S=Ut.scaleY),(l||_||g)&&(x&&T.scale(Yt,x,S,!0),l&&M.toPoint(l,Yt,i,Yt,!0,!0))):m&&!u||(x=S=T.getFitScale(i,Yt,"fit"!==o),T.put(i,s,l,x,!1,Yt),T.scale(Yt,x,S,!0)),c&&D.move(Yt,c),o){case"stretch":m?x&&(x=S=void 0):(x=i.width/a,S=i.height/n,Y.stretchMode(y,i,x,S));break;case"normal":case"clip":if(Yt.x||Yt.y||x||p||u||f){let t,e;p&&(t=i.width/p.width,e=i.height/p.height),Y.clipMode(y,i,Yt.x,Yt.y,x,S,u,f,t,e),t&&(x=x?x*t:t,S=S?S*e:e)}break;case"repeat":(!m||x||u||f)&&Y.repeatMode(y,i,a,n,Yt.x,Yt.y,x,S,u,f,l,t.freeTransform),g||(y.repeat="repeat");const e=A(g);(_||e)&&(y.gap=function(t,e,i,s,a){let n,r;A(t)?(n=t.x,r=t.y):n=r=t;return{x:Xt(n,i,a.width,e&&e.x),y:Xt(r,s,a.height,e&&e.y)}}(_,e&&g,Yt.width,Yt.height,i));break;default:x&&Y.fillOrFitMode(y,i,Yt.x,Yt.y,x,S,u)}return y.transform||(i.x||i.y)&&zt(y.transform=It(),i.x,i.y),x&&(y.scaleX=x,y.scaleY=S),r&&r<1&&(y.opacity=r),w&&(y.filters=w),g&&(y.repeat=e(g)?"x"===g?"repeat-x":"repeat-y":"repeat"),y},stretchMode:function(t,e,i,s){const a=qt(),{x:n,y:r}=e;n||r?Ht(a,n,r):a.onlyScale=!0,$t(a,i,s),t.transform=a},fillOrFitMode:function(t,e,i,s,a,n,r){const o=qt();Ht(o,e.x+i,e.y+s),$t(o,a,n),r&&Vt(o,{x:e.x+e.width/2,y:e.y+e.height/2},r),t.transform=o},clipMode:function(t,e,i,s,a,n,r,o,l,c){const d=qt();te(d,e,i,s,a,n,r,o),l&&(r||o?(jt(Nt),Qt(Nt,e,l,c),Zt(d,Nt)):Qt(d,e,l,c)),t.transform=d},repeatMode:function(t,e,i,s,a,n,r,o,l,c,d,h){const u=qt();if(h)te(u,e,a,n,r,o,l,c);else{if(l)if("center"===d)Vt(u,{x:i/2,y:s/2},l);else switch(Jt(u,l),l){case 90:Ht(u,s,0);break;case 180:Ht(u,i,s);break;case 270:Ht(u,0,i)}Gt.x=e.x+a,Gt.y=e.y+n,Ht(u,Gt.x,Gt.y),r&&Qt(u,Gt,r,o)}t.transform=u}},{toPoint:le}=z,{hasTransparent:ce}=X,de={},he={};function ue(t,i,s,a){if(s){let n,r,o,l;for(let t=0,c=s.length;t<c;t++)n=s[t],e(n)?(o=t/(c-1),r=X.string(n,a)):(o=n.offset,r=X.string(n.color,a)),i.addColorStop(o,r),!l&&ce(r)&&(l=!0);l&&(t.isTransparent=!0)}}const{getAngle:fe,getDistance:pe}=D,{get:ge,rotateOfOuter:_e,scaleOfOuter:we}=O,{toPoint:me}=z,ye={},ve={};function xe(t,e,i,s,a){let n;const{width:r,height:o}=t;if(r!==o||s){const t=fe(e,i);n=ge(),a?(we(n,e,r/o*(s||1),1),_e(n,e,t+90)):(we(n,e,1,r/o*(s||1)),_e(n,e,t))}return n}const{getDistance:Se}=D,{toPoint:be}=z,ke={},Be={};const Re={linearGradient:function(t,e){let{from:s,to:a,type:n,opacity:r}=t;le(s||"top",e,de),le(a||"bottom",e,he);const o=i.canvas.createLinearGradient(de.x,de.y,he.x,he.y),l={type:n,style:o};return ue(l,o,t.stops,r),l},radialGradient:function(t,e){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;me(s||"center",e,ye),me(a||"bottom",e,ve);const l=i.canvas.createRadialGradient(ye.x,ye.y,0,ye.x,ye.y,pe(ye,ve)),c={type:n,style:l};ue(c,l,t.stops,r);const d=xe(e,ye,ve,o,!0);return d&&(c.transform=d),c},conicGradient:function(t,e){let{from:s,to:a,type:n,opacity:r,stretch:o}=t;be(s||"center",e,ke),be(a||"bottom",e,Be);const l=i.conicGradientSupport?i.canvas.createConicGradient(0,ke.x,ke.y):i.canvas.createRadialGradient(ke.x,ke.y,0,ke.x,ke.y,Se(ke,Be)),c={type:n,style:l};ue(c,l,t.stops,r);const d=xe(e,ke,Be,o||1,i.conicGradientRotate90);return d&&(c.transform=d),c},getTransform:xe},{copy:Ee,move:Ae,toOffsetOutBounds:Te}=T,{max:Le,abs:Pe}=Math,Ce={},Oe=new P,We={};function Me(t,e){let i,s,a,n,r=0,o=0,l=0,c=0;return e.forEach(t=>{i=t.x||0,s=t.y||0,n=1.5*(t.blur||0),a=Pe(t.spread||0),r=Le(r,a+n-s),o=Le(o,a+n+i),l=Le(l,a+n+s),c=Le(c,a+n-i)}),r===o&&o===l&&l===c?r:[r,o,l,c]}function De(t,e,s){const{shapeBounds:a}=s;let n,r;i.fullImageShadow?(Ee(Ce,t.bounds),Ae(Ce,e.x-a.x,e.y-a.y),n=t.bounds,r=Ce):(n=a,r=e),t.copyWorld(s.canvas,n,r)}const{toOffsetOutBounds:Ie}=T,ze={};const Fe=Me;const Ue={shadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{shadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Te(l,We,c),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(_=1/t)}f.setWorldShadow(We.offsetX+(r.x||0)*h*_,We.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_,X.string(r.color)),a=N.getShadowTransform(t,f,i,r,We,_),a&&f.setTransform(a),De(f,We,i),a&&f.resetTransform(),s=c,r.box&&(f.restore(),f.save(),o&&(f.copyWorld(f,c,n,"copy"),s=n),o?f.copyWorld(o,n,n,"destination-out"):f.copyWorld(i.canvas,d,l,"destination-out")),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},innerShadow:function(t,e,i){let s,a;const{__nowWorld:n}=t,{innerShadow:r}=t.__,{worldCanvas:o,bounds:l,renderBounds:c,shapeBounds:d,scaleX:h,scaleY:u}=i,f=e.getSameCanvas(),p=r.length-1;Ie(l,ze,c),r.forEach((r,g)=>{let _=1;if(r.scaleFixed){const t=Math.abs(n.scaleX);t>1&&(_=1/t)}f.save(),f.setWorldShadow(ze.offsetX+(r.x||0)*h*_,ze.offsetY+(r.y||0)*u*_,(r.blur||0)*h*_),a=N.getShadowTransform(t,f,i,r,ze,_,!0),a&&f.setTransform(a),De(f,ze,i),f.restore(),o?(f.copyWorld(f,c,n,"copy"),f.copyWorld(o,n,n,"source-out"),s=n):(f.copyWorld(i.canvas,d,l,"source-out"),s=c),f.fillWorld(s,X.string(r.color),"source-in"),m.copyCanvasByWorld(t,e,f,s,r.blendMode),p&&g<p&&f.clearWorld(s)}),f.recycle(s)},blur:function(t,e,i){const{blur:s}=t.__;i.setWorldBlur(s*t.__nowWorld.a),i.copyWorldToInner(e,t.__nowWorld,t.__layout.renderBounds),i.filter="none"},backgroundBlur:function(t,e,i){},getShadowRenderSpread:Me,getShadowTransform:function(t,e,i,s,a,n,r){if(s.spread){const i=2*s.spread*n*(r?-1:1),{width:o,height:l}=t.__layout.strokeBounds;return Oe.set().scaleOfOuter({x:(a.x+a.width/2)*e.pixelRatio,y:(a.y+a.height/2)*e.pixelRatio},1+i/o,1+i/l),Oe}},isTransformShadow(t){},getInnerShadowSpread:Fe},{excludeRenderBounds:Ye}=v;let Xe;function Ge(t,e,i,s,a,n,r,o){switch(e){case"grayscale":Xe||(Xe=!0,a.useGrayscaleAlpha(t.__nowWorld));case"alpha":!function(t,e,i,s,a,n){const r=t.__nowWorld;i.resetTransform(),i.opacity=1,i.useMask(s,r),n&&s.recycle(r);qe(t,e,i,1,a,n)}(t,i,s,a,r,o);break;case"opacity-path":qe(t,i,s,n,r,o);break;case"path":o&&i.restore()}}function Ne(t){return t.getSameCanvas(!1,!0)}function qe(t,e,i,s,a,n){const r=t.__nowWorld;e.resetTransform(),e.opacity=s,e.copyWorld(i,r,void 0,a),n?i.recycle(r):i.clearWorld(r)}q.prototype.__renderMask=function(t,e){let i,s,a,n,r,o;const{children:l}=this;for(let c=0,d=l.length;c<d;c++){if(i=l[c],o=i.__.mask,o){r&&(Ge(this,r,t,a,s,n,void 0,!0),s=a=null),"clipping"!==o&&"clipping-path"!==o||Ye(i,e)||i.__render(t,e),n=i.__.opacity,Xe=!1,"path"===o||"clipping-path"===o?(n<1?(r="opacity-path",a||(a=Ne(t))):(r="path",t.save()),i.__clip(a||t,e)):(r="grayscale"===o?"grayscale":"alpha",s||(s=Ne(t)),a||(a=Ne(t)),i.__render(s,e));continue}const d=1===n&&i.__.__blendMode;d&&Ge(this,r,t,a,s,n,void 0,!1),Ye(i,e)||i.__render(a||t,e),d&&Ge(this,r,t,a,s,n,d,!1)}Ge(this,r,t,a,s,n,void 0,!0)};const je=">)]}%!?,.:;'\"》)」〉』〗】〕}┐>’”!?,、。:;‰",Ve=je+"_#~&*+\\=|≮≯≈≠=…",He=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 Qe(t){const e={};return t.split("").forEach(t=>e[t]=!0),e}const Ze=Qe("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"),$e=Qe("{[(<'\"《(「〈『〖【〔{┌<‘“=¥¥$€££¢¢"),Je=Qe(je),Ke=Qe(Ve),ti=Qe("- —/~|┆·");var ei;!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"}(ei||(ei={}));const{Letter:ii,Single:si,Before:ai,After:ni,Symbol:ri,Break:oi}=ei;function li(t){return Ze[t]?ii:ti[t]?oi:$e[t]?ai:Je[t]?ni:Ke[t]?ri:He.test(t)?si:ii}const ci={trimRight(t){const{words:e}=t;let i,s=0,a=e.length;for(let n=a-1;n>-1&&(i=e[n].data[0]," "===i.char);n--)s++,t.width-=i.width;s&&e.splice(a-s,s)}};function di(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:hi}=ci,{Letter:ui,Single:fi,Before:pi,After:gi,Symbol:_i,Break:wi}=ei;let mi,yi,vi,xi,Si,bi,ki,Bi,Ri,Ei,Ai,Ti,Li,Pi,Ci,Oi,Wi,Mi=[];function Di(t,e){Ri&&!Bi&&(Bi=Ri),mi.data.push({char:t,width:e}),vi+=e}function Ii(){xi+=vi,mi.width=vi,yi.words.push(mi),mi={data:[]},vi=0}function zi(){Pi&&(Ci.paraNumber++,yi.paraStart=!0,Pi=!1),Ri&&(yi.startCharSize=Bi,yi.endCharSize=Ri,Bi=0),yi.width=xi,Oi.width?hi(yi):Wi&&Fi(),Mi.push(yi),yi={words:[]},xi=0}function Fi(){xi>(Ci.maxWidth||0)&&(Ci.maxWidth=xi)}const{top:Ui,right:Yi,bottom:Xi,left:Gi}=F;function Ni(t,e,i){const{bounds:s,rows:a}=t;s[e]+=i;for(let t=0;t<a.length;t++)a[t][e]+=i}const qi={getDrawData:function(t,s){e(t)||(t=String(t));let a=0,n=0,r=s.__getInput("width")||0,o=s.__getInput("height")||0;const{__padding:l}=s;l&&(r?(a=l[Gi],r-=l[Yi]+l[Gi],!r&&(r=.01)):s.autoSizeAlign||(a=l[Gi]),o?(n=l[Ui],o-=l[Ui]+l[Xi],!o&&(o=.01)):s.autoSizeAlign||(n=l[Ui]));const c={bounds:{x:a,y:n,width:r,height:o},rows:[],paraNumber:0,font:i.canvas.font=s.__font};return function(t,e,s){Ci=t,Mi=t.rows,Oi=t.bounds,Wi=!Oi.width&&!s.autoSizeAlign;const{__letterSpacing:a,paraIndent:n,textCase:r}=s,{canvas:o}=i,{width:l}=Oi;if(s.__isCharMode){const t="none"!==s.textWrap,i="break"===s.textWrap;Pi=!0,Ai=null,Bi=ki=Ri=vi=xi=0,mi={data:[]},yi={words:[]},a&&(e=[...e]);for(let s=0,c=e.length;s<c;s++)bi=e[s],"\n"===bi?(vi&&Ii(),yi.paraEnd=!0,zi(),Pi=!0):(Ei=li(bi),Ei===ui&&"none"!==r&&(bi=di(bi,r,!vi)),ki=o.measureText(bi).width,a&&(a<0&&(Ri=ki),ki+=a),Ti=Ei===fi&&(Ai===fi||Ai===ui)||Ai===fi&&Ei!==gi,Li=!(Ei!==pi&&Ei!==fi||Ai!==_i&&Ai!==gi),Si=Pi&&n?l-n:l,t&&l&&xi+vi+ki>Si&&(i?(vi&&Ii(),xi&&zi()):(Li||(Li=Ei===ui&&Ai==gi),Ti||Li||Ei===wi||Ei===pi||Ei===fi||vi+ki>Si?(vi&&Ii(),xi&&zi()):xi&&zi()))," "===bi&&!0!==Pi&&xi+vi===0||(Ei===wi?(" "===bi&&vi&&Ii(),Di(bi,ki),Ii()):Ti||Li?(vi&&Ii(),Di(bi,ki)):Di(bi,ki)),Ai=Ei);vi&&Ii(),xi&&zi(),Mi.length>0&&(Mi[Mi.length-1].paraEnd=!0)}else e.split("\n").forEach(t=>{Ci.paraNumber++,xi=o.measureText(t).width,Mi.push({x:n||0,text:t,width:xi,paraStart:!0}),Wi&&Fi()})}(c,t,s),l&&function(t,e,i,s,a){if(!s&&i.autoSizeAlign)switch(i.textAlign){case"left":Ni(e,"x",t[Gi]);break;case"right":Ni(e,"x",-t[Yi])}if(!a&&i.autoSizeAlign)switch(i.verticalAlign){case"top":Ni(e,"y",t[Ui]);break;case"bottom":Ni(e,"y",-t[Xi])}}(l,c,s,r,o),function(t,e){const{rows:i,bounds:s}=t,a=i.length,{__lineHeight:n,__baseLine:r,__letterSpacing:o,__clipText:l,textAlign:c,verticalAlign:d,paraSpacing:h,autoSizeAlign:u}=e;let{x:f,y:p,width:g,height:_}=s,w=n*a+(h?h*(t.paraNumber-1):0),m=r;if(l&&w>_)w=Math.max(_,n),a>1&&(t.overflow=a);else if(_||u)switch(d){case"middle":p+=(_-w)/2;break;case"bottom":p+=_-w}m+=p;let y,v,x,S=g||u?g:t.maxWidth;for(let r=0,d=a;r<d;r++){if(y=i[r],y.x=f,y.width<g||y.width>g&&!l)switch(c){case"center":y.x+=(S-y.width)/2;break;case"right":y.x+=S-y.width}y.paraStart&&h&&r>0&&(m+=h),y.y=m,m+=n,t.overflow>r&&m>w&&(y.isOverflow=!0,t.overflow=r+1),v=y.x,x=y.width,o<0&&(y.width<0?(x=-y.width+e.fontSize+o,v-=x,x+=e.fontSize):x-=o),v<s.x&&(s.x=v),x>s.width&&(s.width=x),l&&g&&g<x&&(y.isOverflow=!0,t.overflow||(t.overflow=i.length))}s.y=p,s.height=w}(c,s),s.__isCharMode&&function(t,e,i){const{rows:s}=t,{textAlign:a,paraIndent:n,letterSpacing:r}=e,o=i&&a.includes("both"),l=o||i&&a.includes("justify"),c=l&&a.includes("letter");let d,h,u,f,p,g,_,w,m,y;s.forEach(t=>{t.words&&(p=n&&t.paraStart?n:0,w=t.words.length,l&&(y=!t.paraEnd||o,h=i-t.width-p,c?f=h/(t.words.reduce((t,e)=>t+e.data.length,0)-1):u=w>1?h/(w-1):0),g=r||t.isOverflow||c?0:u?1:2,t.isOverflow&&!r&&(t.textMode=!0),2===g?(t.x+=p,function(t){t.text="",t.words.forEach(e=>{e.data.forEach(e=>{t.text+=e.char})})}(t)):(t.x+=p,d=t.x,t.data=[],t.words.forEach((e,i)=>{1===g?(_={char:"",x:d},d=function(t,e,i){return t.forEach(t=>{i.char+=t.char,e+=t.width}),e}(e.data,d,_),(t.isOverflow||" "!==_.char)&&t.data.push(_)):d=function(t,e,i,s,a){return t.forEach(t=>{(s||" "!==t.char)&&(t.x=e,i.push(t)),e+=t.width,a&&(e+=a)}),e}(e.data,d,t.data,t.isOverflow,y&&f),y&&(m=i===w-1,u?m||(d+=u,t.width+=u):f&&(t.width+=f*(e.data.length-(m?1:0))))})),t.words=null)})}(c,s,r),c.overflow&&function(t,e,s,a){if(!a)return;const{rows:n,overflow:r}=t;let{textOverflow:o}=e;if(n.splice(r),o&&"show"!==o){let t,l;"hide"===o?o="":"ellipsis"===o&&(o="...");const c=o?i.canvas.measureText(o).width:0,d=s+a-c;("none"===e.textWrap?n:[n[r-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:o,x:l}),e.textMode&&function(t){t.text="",t.data.forEach(e=>{t.text+=e.char}),t.data=null}(e)}})}}(c,s,a,r),"none"!==s.textDecoration&&function(t,e){let i,s=0;const{fontSize:a,textDecoration:n}=e;switch(t.decorationHeight=a/11,A(n)?(i=n.type,n.color&&(t.decorationColor=X.string(n.color)),n.offset&&(s=Math.min(.3*a,Math.max(n.offset,.15*-a)))):i=n,i){case"under":t.decorationY=[.15*a+s];break;case"delete":t.decorationY=[.35*-a];break;case"under-delete":t.decorationY=[.15*a+s,.35*-a]}}(c,s),c}};const ji={string:function(t,i){if(!t)return"#000";const a=s(i)&&i<1;if(e(t)){if(!a||!X.object)return t;t=X.object(t)}let n=o(t.a)?1:t.a;a&&(n*=i);const r=t.r+","+t.g+","+t.b;return 1===n?"rgb("+r+")":"rgba("+r+","+n+")"}};Object.assign(j,qi),Object.assign(X,ji),Object.assign(U,Et),Object.assign(Y,oe),Object.assign(G,Re),Object.assign(N,Ue);try{wx&&Z(0,wx)}catch(t){}export{lt as Layouter,V as LeaferCanvas,dt as Renderer,$ as Watcher,Z as useCanvas};
|
|
2
2
|
//# sourceMappingURL=miniapp.esm.min.js.map
|