@leafer-ui/miniapp 1.6.1 → 1.6.3
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 +207 -201
- package/dist/miniapp.esm.js +211 -205
- 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 +609 -449
- package/dist/miniapp.module.min.js +1 -1
- package/dist/miniapp.module.min.js.map +1 -1
- package/package.json +12 -12
- package/dist/miniapp.cjs.map +0 -1
- package/dist/miniapp.esm.js.map +0 -1
- package/dist/miniapp.module.js.map +0 -1
package/dist/miniapp.esm.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Plugin, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper,
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Plugin, MatrixHelper, MathHelper, AlignHelper, PointHelper, ImageEvent, AroundHelper, Direction4 } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
|
-
import { InteractionHelper, InteractionBase, HitCanvasManager } from '@leafer-ui/core';
|
|
4
|
+
import { InteractionHelper, InteractionBase, Platform as Platform$1, HitCanvasManager } from '@leafer-ui/core';
|
|
5
5
|
export * from '@leafer-ui/core';
|
|
6
|
-
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, Leafer } from '@leafer-ui/draw';
|
|
6
|
+
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint as Paint$1, Effect, Leafer } from '@leafer-ui/draw';
|
|
7
7
|
|
|
8
8
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
9
9
|
get allowBackgroundColor() { return false; }
|
|
@@ -301,17 +301,15 @@ class Watcher {
|
|
|
301
301
|
this.target.emitEvent(new WatchEvent(WatchEvent.DATA, { updatedList: this.updatedList }));
|
|
302
302
|
this.__updatedList = new LeafList();
|
|
303
303
|
this.totalTimes++;
|
|
304
|
-
this.changed = false;
|
|
305
|
-
this.hasVisible = false;
|
|
306
|
-
this.hasRemove = false;
|
|
307
|
-
this.hasAdd = false;
|
|
304
|
+
this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
|
|
308
305
|
}
|
|
309
306
|
__listenEvents() {
|
|
310
|
-
const { target } = this;
|
|
311
307
|
this.__eventIds = [
|
|
312
|
-
target.on_(
|
|
313
|
-
|
|
314
|
-
|
|
308
|
+
this.target.on_([
|
|
309
|
+
[PropertyEvent.CHANGE, this.__onAttrChange, this],
|
|
310
|
+
[[ChildEvent.ADD, ChildEvent.REMOVE], this.__onChildEvent, this],
|
|
311
|
+
[WatchEvent.REQUEST, this.__onRquestData, this]
|
|
312
|
+
])
|
|
315
313
|
];
|
|
316
314
|
}
|
|
317
315
|
__removeListenEvents() {
|
|
@@ -321,13 +319,12 @@ class Watcher {
|
|
|
321
319
|
if (this.target) {
|
|
322
320
|
this.stop();
|
|
323
321
|
this.__removeListenEvents();
|
|
324
|
-
this.target = null;
|
|
325
|
-
this.__updatedList = null;
|
|
322
|
+
this.target = this.__updatedList = null;
|
|
326
323
|
}
|
|
327
324
|
}
|
|
328
325
|
}
|
|
329
326
|
|
|
330
|
-
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds,
|
|
327
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = LeafHelper;
|
|
331
328
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
332
329
|
function updateMatrix(updateList, levelList) {
|
|
333
330
|
let layout;
|
|
@@ -370,15 +367,7 @@ function updateBounds(boundsList) {
|
|
|
370
367
|
});
|
|
371
368
|
}
|
|
372
369
|
function updateChange(updateList) {
|
|
373
|
-
|
|
374
|
-
updateList.list.forEach(leaf => {
|
|
375
|
-
layout = leaf.__layout;
|
|
376
|
-
if (layout.opacityChanged)
|
|
377
|
-
updateAllWorldOpacity(leaf);
|
|
378
|
-
if (layout.stateStyleChanged)
|
|
379
|
-
setTimeout(() => layout.stateStyleChanged && leaf.updateState());
|
|
380
|
-
leaf.__updateChange();
|
|
381
|
-
});
|
|
370
|
+
updateList.list.forEach(updateOneChange);
|
|
382
371
|
}
|
|
383
372
|
|
|
384
373
|
const { worldBounds } = LeafBoundsHelper;
|
|
@@ -435,7 +424,7 @@ class Layouter {
|
|
|
435
424
|
this.disabled = true;
|
|
436
425
|
}
|
|
437
426
|
layout() {
|
|
438
|
-
if (!this.running)
|
|
427
|
+
if (this.layouting || !this.running)
|
|
439
428
|
return;
|
|
440
429
|
const { target } = this;
|
|
441
430
|
this.times = 0;
|
|
@@ -518,12 +507,10 @@ class Layouter {
|
|
|
518
507
|
}
|
|
519
508
|
static fullLayout(target) {
|
|
520
509
|
updateAllMatrix(target, true);
|
|
521
|
-
if (target.isBranch)
|
|
510
|
+
if (target.isBranch)
|
|
522
511
|
BranchHelper.updateBounds(target);
|
|
523
|
-
|
|
524
|
-
else {
|
|
512
|
+
else
|
|
525
513
|
LeafHelper.updateBounds(target);
|
|
526
|
-
}
|
|
527
514
|
updateAllChange(target);
|
|
528
515
|
}
|
|
529
516
|
addExtra(leaf) {
|
|
@@ -546,11 +533,12 @@ class Layouter {
|
|
|
546
533
|
this.__updatedList = event.data.updatedList;
|
|
547
534
|
}
|
|
548
535
|
__listenEvents() {
|
|
549
|
-
const { target } = this;
|
|
550
536
|
this.__eventIds = [
|
|
551
|
-
target.on_(
|
|
552
|
-
|
|
553
|
-
|
|
537
|
+
this.target.on_([
|
|
538
|
+
[LayoutEvent.REQUEST, this.layout, this],
|
|
539
|
+
[LayoutEvent.AGAIN, this.layoutAgain, this],
|
|
540
|
+
[WatchEvent.DATA, this.__onReceiveWatchData, this]
|
|
541
|
+
])
|
|
554
542
|
];
|
|
555
543
|
}
|
|
556
544
|
__removeListenEvents() {
|
|
@@ -781,12 +769,13 @@ class Renderer {
|
|
|
781
769
|
this.target.emitEvent(new RenderEvent(type, this.times, bounds, options));
|
|
782
770
|
}
|
|
783
771
|
__listenEvents() {
|
|
784
|
-
const { target } = this;
|
|
785
772
|
this.__eventIds = [
|
|
786
|
-
target.on_(
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
773
|
+
this.target.on_([
|
|
774
|
+
[RenderEvent.REQUEST, this.update, this],
|
|
775
|
+
[LayoutEvent.END, this.__onLayoutEnd, this],
|
|
776
|
+
[RenderEvent.AGAIN, this.renderAgain, this],
|
|
777
|
+
[ResizeEvent.RESIZE, this.__onResize, this]
|
|
778
|
+
])
|
|
790
779
|
];
|
|
791
780
|
}
|
|
792
781
|
__removeListenEvents() {
|
|
@@ -1074,8 +1063,10 @@ class Interaction extends InteractionBase {
|
|
|
1074
1063
|
}
|
|
1075
1064
|
|
|
1076
1065
|
function fillText(ui, canvas) {
|
|
1077
|
-
|
|
1078
|
-
|
|
1066
|
+
const data = ui.__, { rows, decorationY } = data.__textDrawData;
|
|
1067
|
+
if (data.__isPlacehold && data.placeholderColor)
|
|
1068
|
+
canvas.fillStyle = data.placeholderColor;
|
|
1069
|
+
let row;
|
|
1079
1070
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
1080
1071
|
row = rows[i];
|
|
1081
1072
|
if (row.text)
|
|
@@ -1084,7 +1075,7 @@ function fillText(ui, canvas) {
|
|
|
1084
1075
|
row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
|
|
1085
1076
|
}
|
|
1086
1077
|
if (decorationY) {
|
|
1087
|
-
const { decorationColor, decorationHeight } = data;
|
|
1078
|
+
const { decorationColor, decorationHeight } = data.__textDrawData;
|
|
1088
1079
|
if (decorationColor)
|
|
1089
1080
|
canvas.fillStyle = decorationColor;
|
|
1090
1081
|
rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
|
|
@@ -1093,65 +1084,73 @@ function fillText(ui, canvas) {
|
|
|
1093
1084
|
|
|
1094
1085
|
function fill(fill, ui, canvas) {
|
|
1095
1086
|
canvas.fillStyle = fill;
|
|
1096
|
-
|
|
1087
|
+
fillPathOrText(ui, canvas);
|
|
1097
1088
|
}
|
|
1098
1089
|
function fills(fills, ui, canvas) {
|
|
1099
1090
|
let item;
|
|
1100
|
-
const { windingRule, __font } = ui.__;
|
|
1101
1091
|
for (let i = 0, len = fills.length; i < len; i++) {
|
|
1102
1092
|
item = fills[i];
|
|
1103
|
-
if (item.image
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
if (item.blendMode)
|
|
1111
|
-
canvas.blendMode = item.blendMode;
|
|
1112
|
-
__font ? fillText(ui, canvas) : (windingRule ? canvas.fill(windingRule) : canvas.fill());
|
|
1113
|
-
canvas.restore();
|
|
1093
|
+
if (item.image) {
|
|
1094
|
+
if (PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
|
|
1095
|
+
continue;
|
|
1096
|
+
if (!item.style) {
|
|
1097
|
+
if (!i && item.image.isPlacehold)
|
|
1098
|
+
ui.drawImagePlaceholder(canvas, item.image);
|
|
1099
|
+
continue;
|
|
1114
1100
|
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1101
|
+
}
|
|
1102
|
+
canvas.fillStyle = item.style;
|
|
1103
|
+
if (item.transform) {
|
|
1104
|
+
canvas.save();
|
|
1105
|
+
canvas.transform(item.transform);
|
|
1106
|
+
if (item.blendMode)
|
|
1107
|
+
canvas.blendMode = item.blendMode;
|
|
1108
|
+
fillPathOrText(ui, canvas);
|
|
1109
|
+
canvas.restore();
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
if (item.blendMode) {
|
|
1113
|
+
canvas.saveBlendMode(item.blendMode);
|
|
1114
|
+
fillPathOrText(ui, canvas);
|
|
1115
|
+
canvas.restoreBlendMode();
|
|
1124
1116
|
}
|
|
1117
|
+
else
|
|
1118
|
+
fillPathOrText(ui, canvas);
|
|
1125
1119
|
}
|
|
1126
1120
|
}
|
|
1127
1121
|
}
|
|
1122
|
+
function fillPathOrText(ui, canvas) {
|
|
1123
|
+
ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
const Paint = {};
|
|
1128
1127
|
|
|
1129
1128
|
function strokeText(stroke, ui, canvas) {
|
|
1130
|
-
|
|
1131
|
-
const isStrokes = typeof stroke !== 'string';
|
|
1132
|
-
switch (strokeAlign) {
|
|
1129
|
+
switch (ui.__.strokeAlign) {
|
|
1133
1130
|
case 'center':
|
|
1134
|
-
|
|
1135
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
1131
|
+
drawCenter$1(stroke, 1, ui, canvas);
|
|
1136
1132
|
break;
|
|
1137
1133
|
case 'inside':
|
|
1138
|
-
|
|
1134
|
+
drawAlign(stroke, 'inside', ui, canvas);
|
|
1139
1135
|
break;
|
|
1140
1136
|
case 'outside':
|
|
1141
|
-
|
|
1137
|
+
ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
|
|
1142
1138
|
break;
|
|
1143
1139
|
}
|
|
1144
1140
|
}
|
|
1145
|
-
function
|
|
1146
|
-
const
|
|
1141
|
+
function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
|
|
1142
|
+
const data = ui.__;
|
|
1143
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
|
|
1144
|
+
data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
|
|
1145
|
+
}
|
|
1146
|
+
function drawAlign(stroke, align, ui, canvas) {
|
|
1147
1147
|
const out = canvas.getSameCanvas(true, true);
|
|
1148
|
-
out.
|
|
1149
|
-
|
|
1150
|
-
isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
|
|
1148
|
+
out.font = ui.__.__font;
|
|
1149
|
+
drawCenter$1(stroke, 2, ui, out);
|
|
1151
1150
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
1152
1151
|
fillText(ui, out);
|
|
1153
1152
|
out.blendMode = 'normal';
|
|
1154
|
-
if (ui.__worldFlipped)
|
|
1153
|
+
if (ui.__worldFlipped || Platform$1.fullImageShadow)
|
|
1155
1154
|
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1156
1155
|
else
|
|
1157
1156
|
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
@@ -1193,90 +1192,60 @@ function drawStrokesStyle(strokes, isText, ui, canvas) {
|
|
|
1193
1192
|
}
|
|
1194
1193
|
|
|
1195
1194
|
function stroke(stroke, ui, canvas) {
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1198
|
-
if (!__strokeWidth)
|
|
1195
|
+
const data = ui.__;
|
|
1196
|
+
if (!data.__strokeWidth)
|
|
1199
1197
|
return;
|
|
1200
|
-
if (__font) {
|
|
1198
|
+
if (data.__font) {
|
|
1201
1199
|
strokeText(stroke, ui, canvas);
|
|
1202
1200
|
}
|
|
1203
1201
|
else {
|
|
1204
|
-
switch (strokeAlign) {
|
|
1202
|
+
switch (data.strokeAlign) {
|
|
1205
1203
|
case 'center':
|
|
1206
|
-
|
|
1207
|
-
canvas.stroke();
|
|
1208
|
-
if (options.__useArrow)
|
|
1209
|
-
strokeArrow(ui, canvas);
|
|
1204
|
+
drawCenter(stroke, 1, ui, canvas);
|
|
1210
1205
|
break;
|
|
1211
1206
|
case 'inside':
|
|
1212
|
-
canvas
|
|
1213
|
-
canvas.setStroke(stroke, __strokeWidth * 2, options);
|
|
1214
|
-
options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
|
|
1215
|
-
canvas.stroke();
|
|
1216
|
-
canvas.restore();
|
|
1207
|
+
drawInside(stroke, ui, canvas);
|
|
1217
1208
|
break;
|
|
1218
1209
|
case 'outside':
|
|
1219
|
-
|
|
1220
|
-
out.setStroke(stroke, __strokeWidth * 2, options);
|
|
1221
|
-
ui.__drawRenderPath(out);
|
|
1222
|
-
out.stroke();
|
|
1223
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1224
|
-
out.clearWorld(ui.__layout.renderBounds);
|
|
1225
|
-
if (ui.__worldFlipped)
|
|
1226
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1227
|
-
else
|
|
1228
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
|
|
1229
|
-
out.recycle(ui.__nowWorld);
|
|
1210
|
+
drawOutside(stroke, ui, canvas);
|
|
1230
1211
|
break;
|
|
1231
1212
|
}
|
|
1232
1213
|
}
|
|
1233
1214
|
}
|
|
1234
1215
|
function strokes(strokes, ui, canvas) {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1216
|
+
stroke(strokes, ui, canvas);
|
|
1217
|
+
}
|
|
1218
|
+
function drawCenter(stroke, strokeWidthScale, ui, canvas) {
|
|
1219
|
+
const data = ui.__;
|
|
1220
|
+
canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
|
|
1221
|
+
data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
|
|
1222
|
+
if (data.__useArrow)
|
|
1223
|
+
Paint.strokeArrow(stroke, ui, canvas);
|
|
1224
|
+
}
|
|
1225
|
+
function drawInside(stroke, ui, canvas) {
|
|
1226
|
+
const data = ui.__;
|
|
1227
|
+
canvas.save();
|
|
1228
|
+
data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
|
|
1229
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
1230
|
+
canvas.restore();
|
|
1231
|
+
}
|
|
1232
|
+
function drawOutside(stroke, ui, canvas) {
|
|
1233
|
+
const data = ui.__;
|
|
1234
|
+
if (data.__fillAfterStroke) {
|
|
1235
|
+
drawCenter(stroke, 2, ui, canvas);
|
|
1241
1236
|
}
|
|
1242
1237
|
else {
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
drawStrokesStyle(strokes, false, ui, canvas);
|
|
1255
|
-
canvas.restore();
|
|
1256
|
-
break;
|
|
1257
|
-
case 'outside':
|
|
1258
|
-
const { renderBounds } = ui.__layout;
|
|
1259
|
-
const out = canvas.getSameCanvas(true, true);
|
|
1260
|
-
ui.__drawRenderPath(out);
|
|
1261
|
-
out.setStroke(undefined, __strokeWidth * 2, options);
|
|
1262
|
-
drawStrokesStyle(strokes, false, ui, out);
|
|
1263
|
-
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1264
|
-
out.clearWorld(renderBounds);
|
|
1265
|
-
if (ui.__worldFlipped)
|
|
1266
|
-
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1267
|
-
else
|
|
1268
|
-
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
1269
|
-
out.recycle(ui.__nowWorld);
|
|
1270
|
-
break;
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
}
|
|
1274
|
-
function strokeArrow(ui, canvas) {
|
|
1275
|
-
if (ui.__.dashPattern) {
|
|
1276
|
-
canvas.beginPath();
|
|
1277
|
-
ui.__drawPathByData(canvas, ui.__.__pathForArrow);
|
|
1278
|
-
canvas.dashPattern = null;
|
|
1279
|
-
canvas.stroke();
|
|
1238
|
+
const { renderBounds } = ui.__layout;
|
|
1239
|
+
const out = canvas.getSameCanvas(true, true);
|
|
1240
|
+
ui.__drawRenderPath(out);
|
|
1241
|
+
drawCenter(stroke, 2, ui, out);
|
|
1242
|
+
data.windingRule ? out.clip(data.windingRule) : out.clip();
|
|
1243
|
+
out.clearWorld(renderBounds);
|
|
1244
|
+
if (ui.__worldFlipped || Platform$1.fullImageShadow)
|
|
1245
|
+
canvas.copyWorldByReset(out, ui.__nowWorld);
|
|
1246
|
+
else
|
|
1247
|
+
canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
|
|
1248
|
+
out.recycle(ui.__nowWorld);
|
|
1280
1249
|
}
|
|
1281
1250
|
}
|
|
1282
1251
|
|
|
@@ -1323,9 +1292,10 @@ function shape(ui, current, options) {
|
|
|
1323
1292
|
}
|
|
1324
1293
|
|
|
1325
1294
|
let recycleMap;
|
|
1295
|
+
const { stintSet } = DataHelper, { hasTransparent: hasTransparent$1 } = ColorConvert;
|
|
1326
1296
|
function compute(attrName, ui) {
|
|
1327
1297
|
const data = ui.__, leafPaints = [];
|
|
1328
|
-
let paints = data.__input[attrName],
|
|
1298
|
+
let paints = data.__input[attrName], isAlphaPixel, isTransparent;
|
|
1329
1299
|
if (!(paints instanceof Array))
|
|
1330
1300
|
paints = [paints];
|
|
1331
1301
|
recycleMap = PaintImage.recycleImage(attrName, data);
|
|
@@ -1335,35 +1305,62 @@ function compute(attrName, ui) {
|
|
|
1335
1305
|
leafPaints.push(item);
|
|
1336
1306
|
}
|
|
1337
1307
|
data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
|
|
1338
|
-
if (leafPaints.length
|
|
1339
|
-
|
|
1340
|
-
|
|
1308
|
+
if (leafPaints.length) {
|
|
1309
|
+
if (leafPaints.every(item => item.isTransparent)) {
|
|
1310
|
+
if (leafPaints.some(item => item.image))
|
|
1311
|
+
isAlphaPixel = true;
|
|
1312
|
+
isTransparent = true;
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
if (attrName === 'fill') {
|
|
1316
|
+
stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
|
|
1317
|
+
stintSet(data, '__isTransparentFill', isTransparent);
|
|
1318
|
+
}
|
|
1319
|
+
else {
|
|
1320
|
+
stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
|
|
1321
|
+
stintSet(data, '__isTransparentStroke', isTransparent);
|
|
1322
|
+
}
|
|
1341
1323
|
}
|
|
1342
1324
|
function getLeafPaint(attrName, paint, ui) {
|
|
1343
1325
|
if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
|
|
1344
1326
|
return undefined;
|
|
1327
|
+
let data;
|
|
1345
1328
|
const { boxBounds } = ui.__layout;
|
|
1346
1329
|
switch (paint.type) {
|
|
1347
|
-
case 'solid':
|
|
1348
|
-
let { type, blendMode, color, opacity } = paint;
|
|
1349
|
-
return { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
1350
1330
|
case 'image':
|
|
1351
|
-
|
|
1331
|
+
data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
1332
|
+
break;
|
|
1352
1333
|
case 'linear':
|
|
1353
|
-
|
|
1334
|
+
data = PaintGradient.linearGradient(paint, boxBounds);
|
|
1335
|
+
break;
|
|
1354
1336
|
case 'radial':
|
|
1355
|
-
|
|
1337
|
+
data = PaintGradient.radialGradient(paint, boxBounds);
|
|
1338
|
+
break;
|
|
1356
1339
|
case 'angular':
|
|
1357
|
-
|
|
1340
|
+
data = PaintGradient.conicGradient(paint, boxBounds);
|
|
1341
|
+
break;
|
|
1342
|
+
case 'solid':
|
|
1343
|
+
const { type, blendMode, color, opacity } = paint;
|
|
1344
|
+
data = { type, blendMode, style: ColorConvert.string(color, opacity) };
|
|
1345
|
+
break;
|
|
1358
1346
|
default:
|
|
1359
|
-
|
|
1347
|
+
if (paint.r !== undefined)
|
|
1348
|
+
data = { type: 'solid', style: ColorConvert.string(paint) };
|
|
1349
|
+
}
|
|
1350
|
+
if (data) {
|
|
1351
|
+
if (typeof data.style === 'string' && hasTransparent$1(data.style))
|
|
1352
|
+
data.isTransparent = true;
|
|
1353
|
+
if (paint.blendMode)
|
|
1354
|
+
data.blendMode = paint.blendMode;
|
|
1360
1355
|
}
|
|
1356
|
+
return data;
|
|
1361
1357
|
}
|
|
1362
1358
|
|
|
1363
1359
|
const PaintModule = {
|
|
1364
1360
|
compute,
|
|
1365
1361
|
fill,
|
|
1366
1362
|
fills,
|
|
1363
|
+
fillPathOrText,
|
|
1367
1364
|
fillText,
|
|
1368
1365
|
stroke,
|
|
1369
1366
|
strokes,
|
|
@@ -1422,12 +1419,10 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
|
|
|
1422
1419
|
|
|
1423
1420
|
const { get: get$2, translate } = MatrixHelper;
|
|
1424
1421
|
const tempBox = new Bounds();
|
|
1425
|
-
const tempPoint = {};
|
|
1426
1422
|
const tempScaleData = {};
|
|
1423
|
+
const tempImage = {};
|
|
1427
1424
|
function createData(leafPaint, image, paint, box) {
|
|
1428
|
-
const {
|
|
1429
|
-
if (blendMode)
|
|
1430
|
-
leafPaint.blendMode = blendMode;
|
|
1425
|
+
const { changeful, sync } = paint;
|
|
1431
1426
|
if (changeful)
|
|
1432
1427
|
leafPaint.changeful = changeful;
|
|
1433
1428
|
if (sync)
|
|
@@ -1435,38 +1430,38 @@ function createData(leafPaint, image, paint, box) {
|
|
|
1435
1430
|
leafPaint.data = getPatternData(paint, box, image);
|
|
1436
1431
|
}
|
|
1437
1432
|
function getPatternData(paint, box, image) {
|
|
1438
|
-
let { width, height } = image;
|
|
1439
1433
|
if (paint.padding)
|
|
1440
1434
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1441
1435
|
if (paint.mode === 'strench')
|
|
1442
1436
|
paint.mode = 'stretch';
|
|
1437
|
+
let { width, height } = image;
|
|
1443
1438
|
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1444
1439
|
const sameBox = box.width === width && box.height === height;
|
|
1445
1440
|
const data = { mode };
|
|
1446
1441
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
1447
|
-
|
|
1448
|
-
let
|
|
1442
|
+
BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
|
|
1443
|
+
let scaleX, scaleY;
|
|
1449
1444
|
if (!mode || mode === 'cover' || mode === 'fit') {
|
|
1450
1445
|
if (!sameBox || rotation) {
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1446
|
+
scaleX = scaleY = BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
|
|
1447
|
+
BoundsHelper.put(box, image, align, scaleX, false, tempImage);
|
|
1448
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
1454
1449
|
}
|
|
1455
1450
|
}
|
|
1456
|
-
else
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1451
|
+
else {
|
|
1452
|
+
if (scale || size) {
|
|
1453
|
+
MathHelper.getScaleData(scale, size, image, tempScaleData);
|
|
1454
|
+
scaleX = tempScaleData.scaleX;
|
|
1455
|
+
scaleY = tempScaleData.scaleY;
|
|
1456
|
+
}
|
|
1457
|
+
if (align) {
|
|
1458
|
+
if (scaleX)
|
|
1459
|
+
BoundsHelper.scale(tempImage, scaleX, scaleY, true);
|
|
1460
|
+
AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
|
|
1461
|
+
}
|
|
1467
1462
|
}
|
|
1468
1463
|
if (offset)
|
|
1469
|
-
|
|
1464
|
+
PointHelper.move(tempImage, offset);
|
|
1470
1465
|
switch (mode) {
|
|
1471
1466
|
case 'stretch':
|
|
1472
1467
|
if (!sameBox)
|
|
@@ -1474,12 +1469,12 @@ function getPatternData(paint, box, image) {
|
|
|
1474
1469
|
break;
|
|
1475
1470
|
case 'normal':
|
|
1476
1471
|
case 'clip':
|
|
1477
|
-
if (x || y || scaleX || rotation)
|
|
1478
|
-
clipMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1472
|
+
if (tempImage.x || tempImage.y || scaleX || rotation)
|
|
1473
|
+
clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1479
1474
|
break;
|
|
1480
1475
|
case 'repeat':
|
|
1481
1476
|
if (!sameBox || scaleX || rotation)
|
|
1482
|
-
repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
|
|
1477
|
+
repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
|
|
1483
1478
|
if (!repeat)
|
|
1484
1479
|
data.repeat = 'repeat';
|
|
1485
1480
|
break;
|
|
@@ -1487,7 +1482,7 @@ function getPatternData(paint, box, image) {
|
|
|
1487
1482
|
case 'cover':
|
|
1488
1483
|
default:
|
|
1489
1484
|
if (scaleX)
|
|
1490
|
-
fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
|
|
1485
|
+
fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
|
|
1491
1486
|
}
|
|
1492
1487
|
if (!data.transform) {
|
|
1493
1488
|
if (box.x || box.y) {
|
|
@@ -1520,6 +1515,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1520
1515
|
}
|
|
1521
1516
|
else {
|
|
1522
1517
|
leafPaint = { type: paint.type, image };
|
|
1518
|
+
if (image.hasAlphaPixel)
|
|
1519
|
+
leafPaint.isTransparent = true;
|
|
1523
1520
|
cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
|
|
1524
1521
|
}
|
|
1525
1522
|
if (firstUse || image.loading)
|
|
@@ -1544,7 +1541,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1544
1541
|
ignoreRender(ui, false);
|
|
1545
1542
|
if (!ui.destroyed) {
|
|
1546
1543
|
if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
|
|
1547
|
-
if (image.
|
|
1544
|
+
if (image.hasAlphaPixel)
|
|
1548
1545
|
ui.__layout.hitCanvasChanged = true;
|
|
1549
1546
|
ui.forceUpdate('surface');
|
|
1550
1547
|
}
|
|
@@ -1556,6 +1553,17 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
1556
1553
|
onLoadError(ui, event, error);
|
|
1557
1554
|
leafPaint.loadId = null;
|
|
1558
1555
|
});
|
|
1556
|
+
if (ui.placeholderColor) {
|
|
1557
|
+
if (!ui.placeholderDelay)
|
|
1558
|
+
image.isPlacehold = true;
|
|
1559
|
+
else
|
|
1560
|
+
setTimeout(() => {
|
|
1561
|
+
if (!image.ready) {
|
|
1562
|
+
image.isPlacehold = true;
|
|
1563
|
+
ui.forceUpdate('surface');
|
|
1564
|
+
}
|
|
1565
|
+
}, ui.placeholderDelay);
|
|
1566
|
+
}
|
|
1559
1567
|
}
|
|
1560
1568
|
return leafPaint;
|
|
1561
1569
|
}
|
|
@@ -1793,32 +1801,33 @@ const PaintImageModule = {
|
|
|
1793
1801
|
repeatMode
|
|
1794
1802
|
};
|
|
1795
1803
|
|
|
1796
|
-
const { toPoint: toPoint$2 } = AroundHelper;
|
|
1804
|
+
const { toPoint: toPoint$2 } = AroundHelper, { hasTransparent } = ColorConvert;
|
|
1797
1805
|
const realFrom$2 = {};
|
|
1798
1806
|
const realTo$2 = {};
|
|
1799
1807
|
function linearGradient(paint, box) {
|
|
1800
|
-
let { from, to, type,
|
|
1808
|
+
let { from, to, type, opacity } = paint;
|
|
1801
1809
|
toPoint$2(from || 'top', box, realFrom$2);
|
|
1802
1810
|
toPoint$2(to || 'bottom', box, realTo$2);
|
|
1803
1811
|
const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
|
|
1804
|
-
applyStops(style, paint.stops, opacity);
|
|
1805
1812
|
const data = { type, style };
|
|
1806
|
-
|
|
1807
|
-
data.blendMode = blendMode;
|
|
1813
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1808
1814
|
return data;
|
|
1809
1815
|
}
|
|
1810
|
-
function applyStops(gradient, stops, opacity) {
|
|
1816
|
+
function applyStops(data, gradient, stops, opacity) {
|
|
1811
1817
|
if (stops) {
|
|
1812
|
-
let stop;
|
|
1818
|
+
let stop, color, offset, isTransparent;
|
|
1813
1819
|
for (let i = 0, len = stops.length; i < len; i++) {
|
|
1814
1820
|
stop = stops[i];
|
|
1815
|
-
if (typeof stop === 'string')
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
+
if (typeof stop === 'string')
|
|
1822
|
+
offset = i / (len - 1), color = ColorConvert.string(stop, opacity);
|
|
1823
|
+
else
|
|
1824
|
+
offset = stop.offset, color = ColorConvert.string(stop.color, opacity);
|
|
1825
|
+
gradient.addColorStop(offset, color);
|
|
1826
|
+
if (!isTransparent && hasTransparent(color))
|
|
1827
|
+
isTransparent = true;
|
|
1821
1828
|
}
|
|
1829
|
+
if (isTransparent)
|
|
1830
|
+
data.isTransparent = true;
|
|
1822
1831
|
}
|
|
1823
1832
|
}
|
|
1824
1833
|
|
|
@@ -1828,17 +1837,15 @@ const { toPoint: toPoint$1 } = AroundHelper;
|
|
|
1828
1837
|
const realFrom$1 = {};
|
|
1829
1838
|
const realTo$1 = {};
|
|
1830
1839
|
function radialGradient(paint, box) {
|
|
1831
|
-
let { from, to, type, opacity,
|
|
1840
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
1832
1841
|
toPoint$1(from || 'center', box, realFrom$1);
|
|
1833
1842
|
toPoint$1(to || 'bottom', box, realTo$1);
|
|
1834
1843
|
const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
|
|
1835
|
-
applyStops(style, paint.stops, opacity);
|
|
1836
1844
|
const data = { type, style };
|
|
1845
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1837
1846
|
const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
|
|
1838
1847
|
if (transform)
|
|
1839
1848
|
data.transform = transform;
|
|
1840
|
-
if (blendMode)
|
|
1841
|
-
data.blendMode = blendMode;
|
|
1842
1849
|
return data;
|
|
1843
1850
|
}
|
|
1844
1851
|
function getTransform(box, from, to, stretch, rotate90) {
|
|
@@ -1864,17 +1871,15 @@ const { toPoint } = AroundHelper;
|
|
|
1864
1871
|
const realFrom = {};
|
|
1865
1872
|
const realTo = {};
|
|
1866
1873
|
function conicGradient(paint, box) {
|
|
1867
|
-
let { from, to, type, opacity,
|
|
1874
|
+
let { from, to, type, opacity, stretch } = paint;
|
|
1868
1875
|
toPoint(from || 'center', box, realFrom);
|
|
1869
1876
|
toPoint(to || 'bottom', box, realTo);
|
|
1870
1877
|
const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
|
|
1871
|
-
applyStops(style, paint.stops, opacity);
|
|
1872
1878
|
const data = { type, style };
|
|
1879
|
+
applyStops(data, style, paint.stops, opacity);
|
|
1873
1880
|
const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
|
|
1874
1881
|
if (transform)
|
|
1875
1882
|
data.transform = transform;
|
|
1876
|
-
if (blendMode)
|
|
1877
|
-
data.blendMode = blendMode;
|
|
1878
1883
|
return data;
|
|
1879
1884
|
}
|
|
1880
1885
|
|
|
@@ -2207,6 +2212,8 @@ function createRows(drawData, content, style) {
|
|
|
2207
2212
|
lastCharType = null;
|
|
2208
2213
|
startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
|
|
2209
2214
|
word = { data: [] }, row = { words: [] };
|
|
2215
|
+
if (__letterSpacing)
|
|
2216
|
+
content = [...content];
|
|
2210
2217
|
for (let i = 0, len = content.length; i < len; i++) {
|
|
2211
2218
|
char = content[i];
|
|
2212
2219
|
if (char === '\n') {
|
|
@@ -2613,7 +2620,7 @@ const ColorConvertModule = {
|
|
|
2613
2620
|
|
|
2614
2621
|
Object.assign(TextConvert, TextConvertModule);
|
|
2615
2622
|
Object.assign(ColorConvert, ColorConvertModule);
|
|
2616
|
-
Object.assign(Paint, PaintModule);
|
|
2623
|
+
Object.assign(Paint$1, PaintModule);
|
|
2617
2624
|
Object.assign(PaintImage, PaintImageModule);
|
|
2618
2625
|
Object.assign(PaintGradient, PaintGradientModule);
|
|
2619
2626
|
Object.assign(Effect, EffectModule);
|
|
@@ -2633,4 +2640,3 @@ try {
|
|
|
2633
2640
|
catch (_a) { }
|
|
2634
2641
|
|
|
2635
2642
|
export { Interaction, Layouter, LeaferCanvas, Picker, Renderer, Selector, Watcher, useCanvas };
|
|
2636
|
-
//# sourceMappingURL=miniapp.esm.js.map
|