@leafer-ui/miniapp 1.0.0-rc.6 → 1.0.0-rc.7
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.esm.js +135 -93
- package/dist/miniapp.esm.min.js +1 -1
- package/dist/miniapp.module.js +1613 -1061
- package/dist/miniapp.module.min.js +1 -1
- package/package.json +6 -6
package/dist/miniapp.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper,
|
|
1
|
+
import { LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, Platform, AnimateEvent, ResizeEvent, BoundsHelper, Creator, LeaferCanvasBase, canvasPatch, canvasSizeAttrs, InteractionHelper, InteractionBase, LeaferImage, FileHelper, MatrixHelper, ImageEvent, PointHelper, MathHelper, TaskProcessor } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
|
-
import { ColorConvert as ColorConvert$1, ImageManager as ImageManager$1, Paint, Effect, TextConvert as TextConvert$1, Export as Export$
|
|
4
|
+
import { ColorConvert as ColorConvert$1, ImageManager as ImageManager$1, Paint, Effect, TextConvert as TextConvert$1, Export as Export$2, Platform as Platform$1 } from '@leafer-ui/core';
|
|
5
5
|
export * from '@leafer-ui/core';
|
|
6
6
|
|
|
7
7
|
class Watcher {
|
|
@@ -10,7 +10,7 @@ class Watcher {
|
|
|
10
10
|
if (this.hasRemove) {
|
|
11
11
|
const updatedList = new LeafList();
|
|
12
12
|
this.__updatedList.list.forEach(item => { if (item.leafer)
|
|
13
|
-
updatedList.
|
|
13
|
+
updatedList.add(item); });
|
|
14
14
|
return updatedList;
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
@@ -45,7 +45,7 @@ class Watcher {
|
|
|
45
45
|
this.target.emit(RenderEvent.REQUEST);
|
|
46
46
|
}
|
|
47
47
|
__onAttrChange(event) {
|
|
48
|
-
this.__updatedList.
|
|
48
|
+
this.__updatedList.add(event.target);
|
|
49
49
|
this.update();
|
|
50
50
|
}
|
|
51
51
|
__onChildEvent(event) {
|
|
@@ -55,12 +55,12 @@ class Watcher {
|
|
|
55
55
|
}
|
|
56
56
|
else {
|
|
57
57
|
this.hasRemove = true;
|
|
58
|
-
this.__updatedList.
|
|
58
|
+
this.__updatedList.add(event.parent);
|
|
59
59
|
}
|
|
60
60
|
this.update();
|
|
61
61
|
}
|
|
62
62
|
__pushChild(child) {
|
|
63
|
-
this.__updatedList.
|
|
63
|
+
this.__updatedList.add(child);
|
|
64
64
|
if (child.isBranch)
|
|
65
65
|
this.__loopChildren(child);
|
|
66
66
|
}
|
|
@@ -99,7 +99,7 @@ class Watcher {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
const {
|
|
102
|
+
const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
|
|
103
103
|
const { pushAllChildBranch, pushAllParent } = BranchHelper;
|
|
104
104
|
function updateMatrix(updateList, levelList) {
|
|
105
105
|
let layout;
|
|
@@ -107,14 +107,14 @@ function updateMatrix(updateList, levelList) {
|
|
|
107
107
|
layout = leaf.__layout;
|
|
108
108
|
if (levelList.without(leaf) && !layout.proxyZoom) {
|
|
109
109
|
if (layout.matrixChanged) {
|
|
110
|
-
|
|
111
|
-
levelList.
|
|
110
|
+
updateAllMatrix$1(leaf, true);
|
|
111
|
+
levelList.add(leaf);
|
|
112
112
|
if (leaf.isBranch)
|
|
113
113
|
pushAllChildBranch(leaf, levelList);
|
|
114
114
|
pushAllParent(leaf, levelList);
|
|
115
115
|
}
|
|
116
116
|
else if (layout.boundsChanged) {
|
|
117
|
-
levelList.
|
|
117
|
+
levelList.add(leaf);
|
|
118
118
|
if (leaf.isBranch)
|
|
119
119
|
leaf.__tempNumber = 0;
|
|
120
120
|
pushAllParent(leaf, levelList);
|
|
@@ -123,20 +123,21 @@ function updateMatrix(updateList, levelList) {
|
|
|
123
123
|
});
|
|
124
124
|
}
|
|
125
125
|
function updateBounds(boundsList) {
|
|
126
|
-
let
|
|
126
|
+
let list, branch, children;
|
|
127
127
|
boundsList.sort(true);
|
|
128
128
|
boundsList.levels.forEach(level => {
|
|
129
|
-
|
|
130
|
-
for (let i = 0, len =
|
|
131
|
-
branch =
|
|
129
|
+
list = boundsList.levelMap[level];
|
|
130
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
131
|
+
branch = list[i];
|
|
132
132
|
if (branch.isBranch && branch.__tempNumber) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
children = branch.children;
|
|
134
|
+
for (let j = 0, jLen = children.length; j < jLen; j++) {
|
|
135
|
+
if (!children[j].isBranch) {
|
|
136
|
+
updateOneBounds(children[j]);
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
branch
|
|
140
|
+
updateOneBounds(branch);
|
|
140
141
|
}
|
|
141
142
|
});
|
|
142
143
|
}
|
|
@@ -149,7 +150,7 @@ function updateChange(updateList) {
|
|
|
149
150
|
}
|
|
150
151
|
|
|
151
152
|
const { worldBounds } = LeafBoundsHelper;
|
|
152
|
-
const {
|
|
153
|
+
const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
|
|
153
154
|
class LayoutBlockData {
|
|
154
155
|
constructor(list) {
|
|
155
156
|
this.updatedBounds = new Bounds();
|
|
@@ -160,14 +161,20 @@ class LayoutBlockData {
|
|
|
160
161
|
this.updatedList = list;
|
|
161
162
|
}
|
|
162
163
|
setBefore() {
|
|
163
|
-
|
|
164
|
+
this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
|
|
164
165
|
}
|
|
165
166
|
setAfter() {
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
const { list } = this.updatedList;
|
|
168
|
+
if (list.some(leaf => leaf.noBounds)) {
|
|
169
|
+
this.afterBounds.set(bigBounds);
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
this.afterBounds.setListWithFn(list, worldBounds);
|
|
173
|
+
}
|
|
174
|
+
this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
|
|
168
175
|
}
|
|
169
176
|
merge(data) {
|
|
170
|
-
this.updatedList.
|
|
177
|
+
this.updatedList.addList(data.updatedList.list);
|
|
171
178
|
this.beforeBounds.add(data.beforeBounds);
|
|
172
179
|
this.afterBounds.add(data.afterBounds);
|
|
173
180
|
this.updatedBounds.add(data.updatedBounds);
|
|
@@ -177,8 +184,7 @@ class LayoutBlockData {
|
|
|
177
184
|
}
|
|
178
185
|
}
|
|
179
186
|
|
|
180
|
-
const {
|
|
181
|
-
const { pushAllBranchStack, updateWorldBoundsByBranchStack } = BranchHelper;
|
|
187
|
+
const { updateAllMatrix, updateAllChange } = LeafHelper;
|
|
182
188
|
const debug$1 = Debug.get('Layouter');
|
|
183
189
|
class Layouter {
|
|
184
190
|
constructor(target, userConfig) {
|
|
@@ -255,12 +261,15 @@ class Layouter {
|
|
|
255
261
|
const { target, __updatedList: updateList } = this;
|
|
256
262
|
const { BEFORE, LAYOUT, AFTER } = LayoutEvent;
|
|
257
263
|
const blocks = this.getBlocks(updateList);
|
|
258
|
-
blocks.forEach(item =>
|
|
264
|
+
blocks.forEach(item => item.setBefore());
|
|
259
265
|
target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
|
|
266
|
+
this.extraBlock = null;
|
|
260
267
|
updateList.sort();
|
|
261
268
|
updateMatrix(updateList, this.__levelList);
|
|
262
269
|
updateBounds(this.__levelList);
|
|
263
270
|
updateChange(updateList);
|
|
271
|
+
if (this.extraBlock)
|
|
272
|
+
blocks.push(this.extraBlock);
|
|
264
273
|
blocks.forEach(item => item.setAfter());
|
|
265
274
|
target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
|
|
266
275
|
target.emitEvent(new LayoutEvent(AFTER, blocks, this.times));
|
|
@@ -283,17 +292,20 @@ class Layouter {
|
|
|
283
292
|
Run.end(t);
|
|
284
293
|
}
|
|
285
294
|
static fullLayout(target) {
|
|
286
|
-
|
|
295
|
+
updateAllMatrix(target, true);
|
|
287
296
|
if (target.isBranch) {
|
|
288
|
-
|
|
289
|
-
pushAllBranchStack(target, branchStack);
|
|
290
|
-
updateWorldBoundsByBranchStack(branchStack);
|
|
297
|
+
BranchHelper.updateBounds(target);
|
|
291
298
|
}
|
|
292
299
|
else {
|
|
293
|
-
|
|
300
|
+
LeafHelper.updateBounds(target);
|
|
294
301
|
}
|
|
295
302
|
updateAllChange(target);
|
|
296
303
|
}
|
|
304
|
+
addExtra(leaf) {
|
|
305
|
+
const block = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
|
|
306
|
+
block.updatedList.add(leaf);
|
|
307
|
+
block.beforeBounds.add(leaf.__world);
|
|
308
|
+
}
|
|
297
309
|
createBlock(data) {
|
|
298
310
|
return new LayoutBlockData(data);
|
|
299
311
|
}
|
|
@@ -321,8 +333,7 @@ class Layouter {
|
|
|
321
333
|
if (this.target) {
|
|
322
334
|
this.stop();
|
|
323
335
|
this.__removeListenEvents();
|
|
324
|
-
this.target = null;
|
|
325
|
-
this.config = null;
|
|
336
|
+
this.target = this.config = null;
|
|
326
337
|
}
|
|
327
338
|
}
|
|
328
339
|
}
|
|
@@ -433,7 +444,7 @@ class Renderer {
|
|
|
433
444
|
const { canvas } = this;
|
|
434
445
|
const bounds = block.getIntersect(canvas.bounds);
|
|
435
446
|
const includes = block.includes(this.target.__world);
|
|
436
|
-
const realBounds = new Bounds(
|
|
447
|
+
const realBounds = new Bounds(bounds);
|
|
437
448
|
canvas.save();
|
|
438
449
|
if (includes && !Debug.showRepaint) {
|
|
439
450
|
canvas.clear();
|
|
@@ -483,7 +494,7 @@ class Renderer {
|
|
|
483
494
|
const { updateBlocks: list } = this;
|
|
484
495
|
if (list) {
|
|
485
496
|
const bounds = new Bounds();
|
|
486
|
-
bounds.
|
|
497
|
+
bounds.setList(list);
|
|
487
498
|
list.length = 0;
|
|
488
499
|
list.push(bounds);
|
|
489
500
|
}
|
|
@@ -523,7 +534,7 @@ class Renderer {
|
|
|
523
534
|
empty = (!leaf.__world.width || !leaf.__world.height);
|
|
524
535
|
if (empty) {
|
|
525
536
|
if (!leaf.isLeafer)
|
|
526
|
-
debug.
|
|
537
|
+
debug.tip(leaf.innerName, ': empty');
|
|
527
538
|
empty = (!leaf.isBranch || leaf.isBranchLeaf);
|
|
528
539
|
}
|
|
529
540
|
return empty;
|
|
@@ -557,6 +568,14 @@ class Renderer {
|
|
|
557
568
|
}
|
|
558
569
|
}
|
|
559
570
|
|
|
571
|
+
var AnswerType;
|
|
572
|
+
(function (AnswerType) {
|
|
573
|
+
AnswerType[AnswerType["No"] = 0] = "No";
|
|
574
|
+
AnswerType[AnswerType["Yes"] = 1] = "Yes";
|
|
575
|
+
AnswerType[AnswerType["NoAndSkip"] = 2] = "NoAndSkip";
|
|
576
|
+
AnswerType[AnswerType["YesAndSkip"] = 3] = "YesAndSkip";
|
|
577
|
+
})(AnswerType || (AnswerType = {}));
|
|
578
|
+
|
|
560
579
|
const { hitRadiusPoint } = BoundsHelper;
|
|
561
580
|
class Pather {
|
|
562
581
|
constructor(target, selector) {
|
|
@@ -601,10 +620,10 @@ class Pather {
|
|
|
601
620
|
getPath(leaf) {
|
|
602
621
|
const path = new LeafList();
|
|
603
622
|
while (leaf) {
|
|
604
|
-
path.
|
|
623
|
+
path.add(leaf);
|
|
605
624
|
leaf = leaf.parent;
|
|
606
625
|
}
|
|
607
|
-
path.
|
|
626
|
+
path.add(this.target);
|
|
608
627
|
return path;
|
|
609
628
|
}
|
|
610
629
|
getHitablePath(leaf) {
|
|
@@ -614,7 +633,7 @@ class Pather {
|
|
|
614
633
|
item = path.list[i];
|
|
615
634
|
if (!item.__.hittable)
|
|
616
635
|
break;
|
|
617
|
-
hittablePath.
|
|
636
|
+
hittablePath.addAt(item, 0);
|
|
618
637
|
if (!item.__.hitChildren)
|
|
619
638
|
break;
|
|
620
639
|
}
|
|
@@ -633,7 +652,7 @@ class Pather {
|
|
|
633
652
|
leaf = path.list[j];
|
|
634
653
|
if (nextPath && nextPath.has(leaf))
|
|
635
654
|
break;
|
|
636
|
-
throughPath.
|
|
655
|
+
throughPath.add(leaf);
|
|
637
656
|
}
|
|
638
657
|
}
|
|
639
658
|
return throughPath;
|
|
@@ -675,14 +694,15 @@ class Pather {
|
|
|
675
694
|
}
|
|
676
695
|
}
|
|
677
696
|
|
|
697
|
+
const { Yes, NoAndSkip, YesAndSkip } = AnswerType;
|
|
678
698
|
class Selector {
|
|
679
699
|
constructor(target, userConfig) {
|
|
680
700
|
this.config = {};
|
|
681
701
|
this.innerIdMap = {};
|
|
682
702
|
this.idMap = {};
|
|
683
703
|
this.methods = {
|
|
684
|
-
id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
|
|
685
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
|
|
704
|
+
id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
|
|
705
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
|
|
686
706
|
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
687
707
|
tag: (leaf, name) => leaf.__tag === name ? 1 : 0
|
|
688
708
|
};
|
|
@@ -692,11 +712,6 @@ class Selector {
|
|
|
692
712
|
this.pather = new Pather(target, this);
|
|
693
713
|
this.__listenEvents();
|
|
694
714
|
}
|
|
695
|
-
getByPoint(hitPoint, hitRadius, options) {
|
|
696
|
-
if (Platform.name === 'node')
|
|
697
|
-
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
698
|
-
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
699
|
-
}
|
|
700
715
|
getBy(condition, branch, one, options) {
|
|
701
716
|
switch (typeof condition) {
|
|
702
717
|
case 'number':
|
|
@@ -716,6 +731,11 @@ class Selector {
|
|
|
716
731
|
return this.getByMethod(condition, branch, one, options);
|
|
717
732
|
}
|
|
718
733
|
}
|
|
734
|
+
getByPoint(hitPoint, hitRadius, options) {
|
|
735
|
+
if (Platform.name === 'node')
|
|
736
|
+
this.target.emit(LayoutEvent.CHECK_UPDATE);
|
|
737
|
+
return this.pather.getByPoint(hitPoint, hitRadius, options);
|
|
738
|
+
}
|
|
719
739
|
getByInnerId(innerId, branch) {
|
|
720
740
|
const cache = this.innerIdMap[innerId];
|
|
721
741
|
if (cache)
|
|
@@ -742,10 +762,11 @@ class Selector {
|
|
|
742
762
|
return list || this.findLeaf;
|
|
743
763
|
}
|
|
744
764
|
eachFind(children, method, list, options) {
|
|
745
|
-
let child;
|
|
765
|
+
let child, result;
|
|
746
766
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
747
767
|
child = children[i];
|
|
748
|
-
|
|
768
|
+
result = method(child, options);
|
|
769
|
+
if (result === Yes || result === YesAndSkip) {
|
|
749
770
|
if (list) {
|
|
750
771
|
list.push(child);
|
|
751
772
|
}
|
|
@@ -754,7 +775,7 @@ class Selector {
|
|
|
754
775
|
return;
|
|
755
776
|
}
|
|
756
777
|
}
|
|
757
|
-
if (child.isBranch)
|
|
778
|
+
if (child.isBranch && result < NoAndSkip)
|
|
758
779
|
this.eachFind(child.children, method, list, options);
|
|
759
780
|
}
|
|
760
781
|
}
|
|
@@ -1119,9 +1140,8 @@ function useCanvas(_canvasType, app) {
|
|
|
1119
1140
|
Platform.name = 'miniapp';
|
|
1120
1141
|
Platform.requestRender = function (render) { Platform.canvas.view.requestAnimationFrame(render); };
|
|
1121
1142
|
Platform.devicePixelRatio = wx.getSystemInfoSync().pixelRatio;
|
|
1122
|
-
Platform.realtimeLayout = true;
|
|
1123
1143
|
|
|
1124
|
-
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper
|
|
1144
|
+
const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
|
|
1125
1145
|
function fillOrFitMode(data, mode, box, width, height, rotation) {
|
|
1126
1146
|
const transform = get$4();
|
|
1127
1147
|
const swap = rotation && rotation !== 180;
|
|
@@ -1131,7 +1151,7 @@ function fillOrFitMode(data, mode, box, width, height, rotation) {
|
|
|
1131
1151
|
const x = box.x + (box.width - width * scale) / 2;
|
|
1132
1152
|
const y = box.y + (box.height - height * scale) / 2;
|
|
1133
1153
|
translate$1(transform, x, y);
|
|
1134
|
-
scaleHelper
|
|
1154
|
+
scaleHelper(transform, scale);
|
|
1135
1155
|
if (rotation)
|
|
1136
1156
|
rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
|
|
1137
1157
|
data.scaleX = data.scaleY = scale;
|
|
@@ -1143,7 +1163,7 @@ function clipMode(data, box, offset, scale, rotation) {
|
|
|
1143
1163
|
if (offset)
|
|
1144
1164
|
translate$1(transform, offset.x, offset.y);
|
|
1145
1165
|
if (scale) {
|
|
1146
|
-
typeof scale === 'number' ? scaleHelper
|
|
1166
|
+
typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
|
|
1147
1167
|
data.scaleX = transform.a;
|
|
1148
1168
|
data.scaleY = transform.d;
|
|
1149
1169
|
}
|
|
@@ -1256,6 +1276,10 @@ function hasNaturalSize(ui, attrName, image) {
|
|
|
1256
1276
|
d.__naturalWidth = image.width;
|
|
1257
1277
|
d.__naturalHeight = image.height;
|
|
1258
1278
|
if (!d.__getInput('width') || !d.__getInput('height')) {
|
|
1279
|
+
if (ui.__proxyData) {
|
|
1280
|
+
ui.setProxyAttr('width', ui.__.width);
|
|
1281
|
+
ui.setProxyAttr('height', ui.__.height);
|
|
1282
|
+
}
|
|
1259
1283
|
ui.forceUpdate('width');
|
|
1260
1284
|
return false;
|
|
1261
1285
|
}
|
|
@@ -1299,22 +1323,21 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
1299
1323
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1300
1324
|
};
|
|
1301
1325
|
|
|
1302
|
-
const
|
|
1326
|
+
const Export$1 = {};
|
|
1327
|
+
|
|
1328
|
+
const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
|
|
1303
1329
|
function createPattern(ui, paint, pixelRatio) {
|
|
1304
1330
|
let { scaleX, scaleY } = ui.__world;
|
|
1305
1331
|
const id = scaleX + '-' + scaleY;
|
|
1306
1332
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
1307
|
-
paint.patternId = id;
|
|
1308
1333
|
scaleX = Math.abs(scaleX);
|
|
1309
1334
|
scaleY = Math.abs(scaleY);
|
|
1310
1335
|
const { image, data } = paint;
|
|
1311
|
-
|
|
1312
|
-
const maxHeight = image.isSVG ? 4096 : Math.min(image.height, 4096);
|
|
1313
|
-
let scale, matrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
|
|
1336
|
+
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
|
|
1314
1337
|
if (sx) {
|
|
1315
|
-
|
|
1316
|
-
copy$1(
|
|
1317
|
-
|
|
1338
|
+
imageMatrix = get$2();
|
|
1339
|
+
copy$1(imageMatrix, transform);
|
|
1340
|
+
scale(imageMatrix, 1 / sx, 1 / sy);
|
|
1318
1341
|
scaleX *= sx;
|
|
1319
1342
|
scaleY *= sy;
|
|
1320
1343
|
}
|
|
@@ -1322,38 +1345,49 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1322
1345
|
scaleY *= pixelRatio;
|
|
1323
1346
|
width *= scaleX;
|
|
1324
1347
|
height *= scaleY;
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1348
|
+
const size = width * height;
|
|
1349
|
+
if (paint.data.mode !== 'repeat') {
|
|
1350
|
+
if (size > Platform.image.maxCacheSize)
|
|
1351
|
+
return false;
|
|
1352
|
+
}
|
|
1353
|
+
let maxSize = Platform.image.maxPatternSize;
|
|
1354
|
+
if (!image.isSVG) {
|
|
1355
|
+
const imageSize = image.width * image.height;
|
|
1356
|
+
if (maxSize > imageSize)
|
|
1357
|
+
maxSize = imageSize;
|
|
1358
|
+
}
|
|
1359
|
+
if (size > maxSize)
|
|
1360
|
+
imageScale = Math.sqrt(size / maxSize);
|
|
1361
|
+
if (imageScale) {
|
|
1362
|
+
scaleX /= imageScale;
|
|
1363
|
+
scaleY /= imageScale;
|
|
1364
|
+
width /= imageScale;
|
|
1365
|
+
height /= imageScale;
|
|
1333
1366
|
}
|
|
1334
1367
|
if (sx) {
|
|
1335
1368
|
scaleX /= sx;
|
|
1336
1369
|
scaleY /= sy;
|
|
1337
1370
|
}
|
|
1338
1371
|
if (transform || scaleX !== 1 || scaleY !== 1) {
|
|
1339
|
-
if (!
|
|
1340
|
-
|
|
1372
|
+
if (!imageMatrix) {
|
|
1373
|
+
imageMatrix = get$2();
|
|
1341
1374
|
if (transform)
|
|
1342
|
-
copy$1(
|
|
1375
|
+
copy$1(imageMatrix, transform);
|
|
1343
1376
|
}
|
|
1344
|
-
|
|
1377
|
+
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
1345
1378
|
}
|
|
1346
|
-
const
|
|
1379
|
+
const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), mode === 'repeat' ? 'repeat' : (Platform.origin.noRepeat || 'no-repeat'));
|
|
1347
1380
|
try {
|
|
1348
1381
|
if (paint.transform)
|
|
1349
1382
|
paint.transform = null;
|
|
1350
|
-
if (
|
|
1351
|
-
|
|
1383
|
+
if (imageMatrix)
|
|
1384
|
+
pattern.setTransform ? pattern.setTransform(imageMatrix) : paint.transform = imageMatrix;
|
|
1352
1385
|
}
|
|
1353
1386
|
catch (_a) {
|
|
1354
|
-
paint.transform =
|
|
1387
|
+
paint.transform = imageMatrix;
|
|
1355
1388
|
}
|
|
1356
|
-
paint.style =
|
|
1389
|
+
paint.style = pattern;
|
|
1390
|
+
paint.patternId = id;
|
|
1357
1391
|
return true;
|
|
1358
1392
|
}
|
|
1359
1393
|
else {
|
|
@@ -1361,18 +1395,24 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1361
1395
|
}
|
|
1362
1396
|
}
|
|
1363
1397
|
|
|
1398
|
+
const { abs } = Math;
|
|
1364
1399
|
function checkImage(ui, canvas, paint, allowPaint) {
|
|
1365
1400
|
const { scaleX, scaleY } = ui.__world;
|
|
1366
1401
|
if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
|
|
1367
1402
|
return false;
|
|
1368
1403
|
}
|
|
1369
1404
|
else {
|
|
1405
|
+
const { data } = paint;
|
|
1370
1406
|
if (allowPaint) {
|
|
1371
|
-
if (
|
|
1372
|
-
let { width, height } =
|
|
1373
|
-
width *= scaleX * canvas.pixelRatio;
|
|
1374
|
-
height *= scaleY * canvas.pixelRatio;
|
|
1375
|
-
|
|
1407
|
+
if (data.mode !== 'repeat') {
|
|
1408
|
+
let { width, height } = data;
|
|
1409
|
+
width *= abs(scaleX) * canvas.pixelRatio;
|
|
1410
|
+
height *= abs(scaleY) * canvas.pixelRatio;
|
|
1411
|
+
if (data.scaleX) {
|
|
1412
|
+
width *= data.scaleX;
|
|
1413
|
+
height *= data.scaleY;
|
|
1414
|
+
}
|
|
1415
|
+
allowPaint = width * height > Platform.image.maxCacheSize;
|
|
1376
1416
|
}
|
|
1377
1417
|
else {
|
|
1378
1418
|
allowPaint = false;
|
|
@@ -1381,7 +1421,6 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1381
1421
|
if (allowPaint) {
|
|
1382
1422
|
canvas.save();
|
|
1383
1423
|
canvas.clip();
|
|
1384
|
-
const { data } = paint;
|
|
1385
1424
|
if (paint.blendMode)
|
|
1386
1425
|
canvas.blendMode = paint.blendMode;
|
|
1387
1426
|
if (data.opacity)
|
|
@@ -1393,7 +1432,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1393
1432
|
return true;
|
|
1394
1433
|
}
|
|
1395
1434
|
else {
|
|
1396
|
-
if (!paint.style) {
|
|
1435
|
+
if (!paint.style || Export$1.running) {
|
|
1397
1436
|
createPattern(ui, paint, canvas.pixelRatio);
|
|
1398
1437
|
}
|
|
1399
1438
|
else {
|
|
@@ -1412,7 +1451,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1412
1451
|
}
|
|
1413
1452
|
|
|
1414
1453
|
function recycleImage(attrName, data) {
|
|
1415
|
-
const paints =
|
|
1454
|
+
const paints = data['_' + attrName];
|
|
1416
1455
|
if (paints instanceof Array) {
|
|
1417
1456
|
let image, recycleMap, input, url;
|
|
1418
1457
|
for (let i = 0, len = paints.length; i < len; i++) {
|
|
@@ -1516,7 +1555,7 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
|
|
|
1516
1555
|
out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
|
|
1517
1556
|
fillText(ui, out);
|
|
1518
1557
|
out.blendMode = 'normal';
|
|
1519
|
-
if (ui.
|
|
1558
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1520
1559
|
canvas.copyWorldByReset(out);
|
|
1521
1560
|
}
|
|
1522
1561
|
else {
|
|
@@ -1589,7 +1628,7 @@ function stroke(stroke, ui, canvas, renderOptions) {
|
|
|
1589
1628
|
out.stroke();
|
|
1590
1629
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1591
1630
|
out.clearWorld(ui.__layout.renderBounds);
|
|
1592
|
-
if (ui.
|
|
1631
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1593
1632
|
canvas.copyWorldByReset(out);
|
|
1594
1633
|
}
|
|
1595
1634
|
else {
|
|
@@ -1629,7 +1668,7 @@ function strokes(strokes, ui, canvas, renderOptions) {
|
|
|
1629
1668
|
drawStrokesStyle(strokes, false, ui, out);
|
|
1630
1669
|
options.windingRule ? out.clip(options.windingRule) : out.clip();
|
|
1631
1670
|
out.clearWorld(renderBounds);
|
|
1632
|
-
if (ui.
|
|
1671
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1633
1672
|
canvas.copyWorldByReset(out);
|
|
1634
1673
|
}
|
|
1635
1674
|
else {
|
|
@@ -1853,7 +1892,7 @@ function shadow(ui, current, shape, renderOptions) {
|
|
|
1853
1892
|
}
|
|
1854
1893
|
worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
|
|
1855
1894
|
}
|
|
1856
|
-
if (ui.
|
|
1895
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1857
1896
|
current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
|
|
1858
1897
|
}
|
|
1859
1898
|
else {
|
|
@@ -1917,7 +1956,7 @@ function innerShadow(ui, current, shape, renderOptions) {
|
|
|
1917
1956
|
copyBounds = bounds;
|
|
1918
1957
|
}
|
|
1919
1958
|
other.fillWorld(copyBounds, item.color, 'source-in');
|
|
1920
|
-
if (ui.
|
|
1959
|
+
if (ui.__worldFlipped || renderOptions.matrix) {
|
|
1921
1960
|
current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
|
|
1922
1961
|
}
|
|
1923
1962
|
else {
|
|
@@ -2415,6 +2454,7 @@ const ColorConvert = {
|
|
|
2415
2454
|
|
|
2416
2455
|
const Export = {
|
|
2417
2456
|
export(leaf, filename, options) {
|
|
2457
|
+
Export.running = true;
|
|
2418
2458
|
return addTask((success) => new Promise((resolve) => {
|
|
2419
2459
|
const { leafer } = leaf;
|
|
2420
2460
|
if (leafer) {
|
|
@@ -2452,6 +2492,7 @@ const Export = {
|
|
|
2452
2492
|
}
|
|
2453
2493
|
success({ data });
|
|
2454
2494
|
resolve();
|
|
2495
|
+
Export.running = false;
|
|
2455
2496
|
if (unreal)
|
|
2456
2497
|
canvas.recycle();
|
|
2457
2498
|
}));
|
|
@@ -2459,6 +2500,7 @@ const Export = {
|
|
|
2459
2500
|
else {
|
|
2460
2501
|
success({ data: false });
|
|
2461
2502
|
resolve();
|
|
2503
|
+
Export.running = false;
|
|
2462
2504
|
}
|
|
2463
2505
|
}));
|
|
2464
2506
|
}
|
|
@@ -2476,7 +2518,7 @@ Object.assign(Paint, UIPaint);
|
|
|
2476
2518
|
Object.assign(Effect, UIEffect);
|
|
2477
2519
|
Object.assign(TextConvert$1, TextConvert);
|
|
2478
2520
|
Object.assign(ColorConvert$1, ColorConvert);
|
|
2479
|
-
Object.assign(Export$
|
|
2521
|
+
Object.assign(Export$2, Export);
|
|
2480
2522
|
|
|
2481
2523
|
try {
|
|
2482
2524
|
useCanvas('wx', wx);
|