@leafer/core 1.9.11 → 1.10.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/lib/core.cjs +102 -86
- package/lib/core.esm.js +102 -86
- package/lib/core.esm.min.js +1 -1
- package/lib/core.esm.min.js.map +1 -1
- package/lib/core.min.cjs +1 -1
- package/lib/core.min.cjs.map +1 -1
- package/package.json +17 -17
- package/src/index.ts +1 -1
- package/types/index.d.ts +1 -1
package/lib/core.cjs
CHANGED
|
@@ -1,45 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const Platform = {
|
|
4
|
-
toURL(text, fileType) {
|
|
5
|
-
let url = encodeURIComponent(text);
|
|
6
|
-
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
7
|
-
return url;
|
|
8
|
-
},
|
|
9
|
-
image: {
|
|
10
|
-
hitCanvasSize: 100,
|
|
11
|
-
maxCacheSize: 2560 * 1600,
|
|
12
|
-
maxPatternSize: 4096 * 2160,
|
|
13
|
-
crossOrigin: "anonymous",
|
|
14
|
-
getRealURL(url) {
|
|
15
|
-
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
16
|
-
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
17
|
-
if (prefix && url[0] === "/") url = prefix + url;
|
|
18
|
-
return url;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const IncrementId = {
|
|
24
|
-
RUNTIME: "runtime",
|
|
25
|
-
LEAF: "leaf",
|
|
26
|
-
TASK: "task",
|
|
27
|
-
CNAVAS: "canvas",
|
|
28
|
-
IMAGE: "image",
|
|
29
|
-
types: {},
|
|
30
|
-
create(typeName) {
|
|
31
|
-
const {types: types} = I$1;
|
|
32
|
-
if (types[typeName]) {
|
|
33
|
-
return types[typeName]++;
|
|
34
|
-
} else {
|
|
35
|
-
types[typeName] = 1;
|
|
36
|
-
return 0;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const I$1 = IncrementId;
|
|
42
|
-
|
|
43
3
|
exports.Answer = void 0;
|
|
44
4
|
|
|
45
5
|
(function(Answer) {
|
|
@@ -249,6 +209,77 @@ class LeafData {
|
|
|
249
209
|
}
|
|
250
210
|
}
|
|
251
211
|
|
|
212
|
+
const {floor: floor$2, max: max$2} = Math;
|
|
213
|
+
|
|
214
|
+
const Platform = {
|
|
215
|
+
toURL(text, fileType) {
|
|
216
|
+
let url = encodeURIComponent(text);
|
|
217
|
+
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
218
|
+
return url;
|
|
219
|
+
},
|
|
220
|
+
image: {
|
|
221
|
+
hitCanvasSize: 100,
|
|
222
|
+
maxCacheSize: 2560 * 1600,
|
|
223
|
+
maxPatternSize: 4096 * 2160,
|
|
224
|
+
crossOrigin: "anonymous",
|
|
225
|
+
isLarge(size, scaleX, scaleY, largeSize) {
|
|
226
|
+
return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize);
|
|
227
|
+
},
|
|
228
|
+
isSuperLarge(size, scaleX, scaleY) {
|
|
229
|
+
return image.isLarge(size, scaleX, scaleY, image.maxPatternSize);
|
|
230
|
+
},
|
|
231
|
+
getRealURL(url) {
|
|
232
|
+
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
233
|
+
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
234
|
+
if (prefix && url[0] === "/") url = prefix + url;
|
|
235
|
+
return url;
|
|
236
|
+
},
|
|
237
|
+
resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
|
|
238
|
+
const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
|
|
239
|
+
const ctx = canvas.getContext("2d");
|
|
240
|
+
if (opacity) ctx.globalAlpha = opacity;
|
|
241
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
242
|
+
if (clip) {
|
|
243
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
244
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
245
|
+
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
246
|
+
} else ctx.drawImage(image, 0, 0, width, height);
|
|
247
|
+
return canvas;
|
|
248
|
+
},
|
|
249
|
+
setPatternTransform(pattern, transform, paint) {
|
|
250
|
+
try {
|
|
251
|
+
if (transform && pattern.setTransform) {
|
|
252
|
+
pattern.setTransform(transform);
|
|
253
|
+
transform = undefined;
|
|
254
|
+
}
|
|
255
|
+
} catch (_a) {}
|
|
256
|
+
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
const {image: image} = Platform;
|
|
262
|
+
|
|
263
|
+
const IncrementId = {
|
|
264
|
+
RUNTIME: "runtime",
|
|
265
|
+
LEAF: "leaf",
|
|
266
|
+
TASK: "task",
|
|
267
|
+
CNAVAS: "canvas",
|
|
268
|
+
IMAGE: "image",
|
|
269
|
+
types: {},
|
|
270
|
+
create(typeName) {
|
|
271
|
+
const {types: types} = I$1;
|
|
272
|
+
if (types[typeName]) {
|
|
273
|
+
return types[typeName]++;
|
|
274
|
+
} else {
|
|
275
|
+
types[typeName] = 1;
|
|
276
|
+
return 0;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
const I$1 = IncrementId;
|
|
282
|
+
|
|
252
283
|
let tempA, tempB, tempTo;
|
|
253
284
|
|
|
254
285
|
const {max: max$1} = Math, tempFour = [ 0, 0, 0, 0 ];
|
|
@@ -322,7 +353,7 @@ const FourNumberHelper = {
|
|
|
322
353
|
|
|
323
354
|
const {set: set$1, get: get$1, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
324
355
|
|
|
325
|
-
const {round: round$3, pow: pow$1, PI: PI$1} = Math;
|
|
356
|
+
const {round: round$3, pow: pow$1, max: max, floor: floor$1, PI: PI$1} = Math;
|
|
326
357
|
|
|
327
358
|
const MathHelper = {
|
|
328
359
|
within(value, min, max) {
|
|
@@ -375,6 +406,9 @@ const MathHelper = {
|
|
|
375
406
|
scaleData.scaleY = scale.y;
|
|
376
407
|
}
|
|
377
408
|
},
|
|
409
|
+
getFloorScale(num, min = 1) {
|
|
410
|
+
return max(floor$1(num), min) / num;
|
|
411
|
+
},
|
|
378
412
|
randInt: randInt,
|
|
379
413
|
randColor(opacity) {
|
|
380
414
|
return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
|
|
@@ -1204,7 +1238,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
|
1204
1238
|
|
|
1205
1239
|
const {float: float, fourNumber: fourNumber} = MathHelper;
|
|
1206
1240
|
|
|
1207
|
-
const {floor: floor
|
|
1241
|
+
const {floor: floor, ceil: ceil$1} = Math;
|
|
1208
1242
|
|
|
1209
1243
|
let right, bottom, boundsRight, boundsBottom;
|
|
1210
1244
|
|
|
@@ -1296,20 +1330,20 @@ const BoundsHelper = {
|
|
|
1296
1330
|
toOuterOf(t, matrix, to) {
|
|
1297
1331
|
to || (to = t);
|
|
1298
1332
|
if (matrix.b === 0 && matrix.c === 0) {
|
|
1299
|
-
const {a: a, d: d} = matrix;
|
|
1333
|
+
const {a: a, d: d, e: e, f: f} = matrix;
|
|
1300
1334
|
if (a > 0) {
|
|
1301
1335
|
to.width = t.width * a;
|
|
1302
|
-
to.x =
|
|
1336
|
+
to.x = e + t.x * a;
|
|
1303
1337
|
} else {
|
|
1304
1338
|
to.width = t.width * -a;
|
|
1305
|
-
to.x =
|
|
1339
|
+
to.x = e + t.x * a - to.width;
|
|
1306
1340
|
}
|
|
1307
1341
|
if (d > 0) {
|
|
1308
1342
|
to.height = t.height * d;
|
|
1309
|
-
to.y =
|
|
1343
|
+
to.y = f + t.y * d;
|
|
1310
1344
|
} else {
|
|
1311
1345
|
to.height = t.height * -d;
|
|
1312
|
-
to.y =
|
|
1346
|
+
to.y = f + t.y * d - to.height;
|
|
1313
1347
|
}
|
|
1314
1348
|
} else {
|
|
1315
1349
|
point.x = t.x;
|
|
@@ -1361,8 +1395,8 @@ const BoundsHelper = {
|
|
|
1361
1395
|
},
|
|
1362
1396
|
ceil(t) {
|
|
1363
1397
|
const {x: x, y: y} = t;
|
|
1364
|
-
t.x = floor
|
|
1365
|
-
t.y = floor
|
|
1398
|
+
t.x = floor(t.x);
|
|
1399
|
+
t.y = floor(t.y);
|
|
1366
1400
|
t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
|
|
1367
1401
|
t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
|
|
1368
1402
|
},
|
|
@@ -3710,7 +3744,9 @@ class TaskItem {
|
|
|
3710
3744
|
run() {
|
|
3711
3745
|
return __awaiter(this, void 0, void 0, function*() {
|
|
3712
3746
|
try {
|
|
3713
|
-
if (this.
|
|
3747
|
+
if (this.isComplete) return;
|
|
3748
|
+
if (this.canUse && !this.canUse()) return this.cancel();
|
|
3749
|
+
if (this.task && this.parent.running) yield this.task();
|
|
3714
3750
|
} catch (error) {
|
|
3715
3751
|
debug$4.error(error);
|
|
3716
3752
|
}
|
|
@@ -3718,8 +3754,7 @@ class TaskItem {
|
|
|
3718
3754
|
}
|
|
3719
3755
|
complete() {
|
|
3720
3756
|
this.isComplete = true;
|
|
3721
|
-
this.parent = null;
|
|
3722
|
-
this.task = null;
|
|
3757
|
+
this.parent = this.task = this.canUse = null;
|
|
3723
3758
|
}
|
|
3724
3759
|
cancel() {
|
|
3725
3760
|
this.isCancel = true;
|
|
@@ -3762,7 +3797,7 @@ class TaskProcessor {
|
|
|
3762
3797
|
if (config) DataHelper.assign(this.config, config);
|
|
3763
3798
|
this.empty();
|
|
3764
3799
|
}
|
|
3765
|
-
add(taskCallback, options) {
|
|
3800
|
+
add(taskCallback, options, canUse) {
|
|
3766
3801
|
let start, parallel, time, delay;
|
|
3767
3802
|
const task = new TaskItem(taskCallback);
|
|
3768
3803
|
task.parent = this;
|
|
@@ -3773,9 +3808,11 @@ class TaskProcessor {
|
|
|
3773
3808
|
start = options.start;
|
|
3774
3809
|
time = options.time;
|
|
3775
3810
|
delay = options.delay;
|
|
3811
|
+
if (!canUse) canUse = options.canUse;
|
|
3776
3812
|
}
|
|
3777
3813
|
if (time) task.time = time;
|
|
3778
3814
|
if (parallel === false) task.parallel = false;
|
|
3815
|
+
if (canUse) task.canUse = canUse;
|
|
3779
3816
|
if (isUndefined(delay)) {
|
|
3780
3817
|
this.push(task, start);
|
|
3781
3818
|
} else {
|
|
@@ -3845,15 +3882,10 @@ class TaskProcessor {
|
|
|
3845
3882
|
this.timer = setTimeout(() => this.nextTask());
|
|
3846
3883
|
return;
|
|
3847
3884
|
}
|
|
3848
|
-
if (task.isCancel) {
|
|
3849
|
-
this.index++;
|
|
3850
|
-
this.runTask();
|
|
3851
|
-
return;
|
|
3852
|
-
}
|
|
3853
3885
|
task.run().then(() => {
|
|
3854
3886
|
this.onTask(task);
|
|
3855
3887
|
this.index++;
|
|
3856
|
-
this.nextTask();
|
|
3888
|
+
task.isCancel ? this.runTask() : this.nextTask();
|
|
3857
3889
|
}).catch(error => {
|
|
3858
3890
|
this.onError(error);
|
|
3859
3891
|
});
|
|
@@ -4029,8 +4061,6 @@ const I = ImageManager;
|
|
|
4029
4061
|
|
|
4030
4062
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
4031
4063
|
|
|
4032
|
-
const {floor: floor, max: max} = Math;
|
|
4033
|
-
|
|
4034
4064
|
class LeaferImage {
|
|
4035
4065
|
get url() {
|
|
4036
4066
|
return this.config.url;
|
|
@@ -4055,10 +4085,9 @@ class LeaferImage {
|
|
|
4055
4085
|
load(onSuccess, onError) {
|
|
4056
4086
|
if (!this.loading) {
|
|
4057
4087
|
this.loading = true;
|
|
4058
|
-
|
|
4059
|
-
if (onProgress) loadImage = loadImageWithProgress;
|
|
4088
|
+
const {crossOrigin: crossOrigin} = this.config;
|
|
4060
4089
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4061
|
-
return yield loadImage(this.url,
|
|
4090
|
+
return yield Platform.origin.loadImage(this.url, isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin, this).then(img => this.setView(img)).catch(e => {
|
|
4062
4091
|
this.error = e;
|
|
4063
4092
|
this.onComplete(false);
|
|
4064
4093
|
});
|
|
@@ -4084,9 +4113,6 @@ class LeaferImage {
|
|
|
4084
4113
|
this.view = img;
|
|
4085
4114
|
this.onComplete(true);
|
|
4086
4115
|
}
|
|
4087
|
-
onProgress(progress) {
|
|
4088
|
-
this.progress = progress;
|
|
4089
|
-
}
|
|
4090
4116
|
onComplete(isSuccess) {
|
|
4091
4117
|
let odd;
|
|
4092
4118
|
this.waitComplete.forEach((item, index) => {
|
|
@@ -4105,7 +4131,7 @@ class LeaferImage {
|
|
|
4105
4131
|
getFull(_filters) {
|
|
4106
4132
|
return this.view;
|
|
4107
4133
|
}
|
|
4108
|
-
getCanvas(width, height, opacity,
|
|
4134
|
+
getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
|
|
4109
4135
|
width || (width = this.width);
|
|
4110
4136
|
height || (height = this.height);
|
|
4111
4137
|
if (this.cache) {
|
|
@@ -4118,11 +4144,7 @@ class LeaferImage {
|
|
|
4118
4144
|
}
|
|
4119
4145
|
if (data) return data;
|
|
4120
4146
|
}
|
|
4121
|
-
const canvas = Platform.
|
|
4122
|
-
const ctx = canvas.getContext("2d");
|
|
4123
|
-
if (opacity) ctx.globalAlpha = opacity;
|
|
4124
|
-
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
4125
|
-
ctx.drawImage(this.view, 0, 0, width, height);
|
|
4147
|
+
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
|
|
4126
4148
|
this.cache = this.use > 1 ? {
|
|
4127
4149
|
data: canvas,
|
|
4128
4150
|
params: arguments
|
|
@@ -4131,13 +4153,7 @@ class LeaferImage {
|
|
|
4131
4153
|
}
|
|
4132
4154
|
getPattern(canvas, repeat, transform, paint) {
|
|
4133
4155
|
const pattern = Platform.canvas.createPattern(canvas, repeat);
|
|
4134
|
-
|
|
4135
|
-
if (transform && pattern.setTransform) {
|
|
4136
|
-
pattern.setTransform(transform);
|
|
4137
|
-
transform = undefined;
|
|
4138
|
-
}
|
|
4139
|
-
} catch (_a) {}
|
|
4140
|
-
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
4156
|
+
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4141
4157
|
return pattern;
|
|
4142
4158
|
}
|
|
4143
4159
|
destroy() {
|
|
@@ -5811,12 +5827,12 @@ const {toBounds: toBounds} = PathBounds;
|
|
|
5811
5827
|
|
|
5812
5828
|
const LeafBounds = {
|
|
5813
5829
|
__updateWorldBounds() {
|
|
5814
|
-
const
|
|
5815
|
-
toOuterOf$1(
|
|
5816
|
-
if (
|
|
5817
|
-
if (
|
|
5830
|
+
const {__layout: __layout, __world: __world} = this;
|
|
5831
|
+
toOuterOf$1(__layout.renderBounds, __world, __world);
|
|
5832
|
+
if (__layout.resized) {
|
|
5833
|
+
if (__layout.resized === "inner") this.__onUpdateSize();
|
|
5818
5834
|
if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
|
|
5819
|
-
|
|
5835
|
+
__layout.resized = undefined;
|
|
5820
5836
|
}
|
|
5821
5837
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
5822
5838
|
},
|
|
@@ -6821,7 +6837,7 @@ class LeafLevelList {
|
|
|
6821
6837
|
}
|
|
6822
6838
|
}
|
|
6823
6839
|
|
|
6824
|
-
const version = "1.
|
|
6840
|
+
const version = "1.10.0";
|
|
6825
6841
|
|
|
6826
6842
|
exports.AlignHelper = AlignHelper;
|
|
6827
6843
|
|
package/lib/core.esm.js
CHANGED
|
@@ -1,43 +1,3 @@
|
|
|
1
|
-
const Platform = {
|
|
2
|
-
toURL(text, fileType) {
|
|
3
|
-
let url = encodeURIComponent(text);
|
|
4
|
-
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
5
|
-
return url;
|
|
6
|
-
},
|
|
7
|
-
image: {
|
|
8
|
-
hitCanvasSize: 100,
|
|
9
|
-
maxCacheSize: 2560 * 1600,
|
|
10
|
-
maxPatternSize: 4096 * 2160,
|
|
11
|
-
crossOrigin: "anonymous",
|
|
12
|
-
getRealURL(url) {
|
|
13
|
-
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
14
|
-
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
15
|
-
if (prefix && url[0] === "/") url = prefix + url;
|
|
16
|
-
return url;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const IncrementId = {
|
|
22
|
-
RUNTIME: "runtime",
|
|
23
|
-
LEAF: "leaf",
|
|
24
|
-
TASK: "task",
|
|
25
|
-
CNAVAS: "canvas",
|
|
26
|
-
IMAGE: "image",
|
|
27
|
-
types: {},
|
|
28
|
-
create(typeName) {
|
|
29
|
-
const {types: types} = I$1;
|
|
30
|
-
if (types[typeName]) {
|
|
31
|
-
return types[typeName]++;
|
|
32
|
-
} else {
|
|
33
|
-
types[typeName] = 1;
|
|
34
|
-
return 0;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const I$1 = IncrementId;
|
|
40
|
-
|
|
41
1
|
var Answer;
|
|
42
2
|
|
|
43
3
|
(function(Answer) {
|
|
@@ -247,6 +207,77 @@ class LeafData {
|
|
|
247
207
|
}
|
|
248
208
|
}
|
|
249
209
|
|
|
210
|
+
const {floor: floor$2, max: max$2} = Math;
|
|
211
|
+
|
|
212
|
+
const Platform = {
|
|
213
|
+
toURL(text, fileType) {
|
|
214
|
+
let url = encodeURIComponent(text);
|
|
215
|
+
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
216
|
+
return url;
|
|
217
|
+
},
|
|
218
|
+
image: {
|
|
219
|
+
hitCanvasSize: 100,
|
|
220
|
+
maxCacheSize: 2560 * 1600,
|
|
221
|
+
maxPatternSize: 4096 * 2160,
|
|
222
|
+
crossOrigin: "anonymous",
|
|
223
|
+
isLarge(size, scaleX, scaleY, largeSize) {
|
|
224
|
+
return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize);
|
|
225
|
+
},
|
|
226
|
+
isSuperLarge(size, scaleX, scaleY) {
|
|
227
|
+
return image.isLarge(size, scaleX, scaleY, image.maxPatternSize);
|
|
228
|
+
},
|
|
229
|
+
getRealURL(url) {
|
|
230
|
+
const {prefix: prefix, suffix: suffix} = Platform.image;
|
|
231
|
+
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
232
|
+
if (prefix && url[0] === "/") url = prefix + url;
|
|
233
|
+
return url;
|
|
234
|
+
},
|
|
235
|
+
resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
|
|
236
|
+
const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
|
|
237
|
+
const ctx = canvas.getContext("2d");
|
|
238
|
+
if (opacity) ctx.globalAlpha = opacity;
|
|
239
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
240
|
+
if (clip) {
|
|
241
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
242
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
243
|
+
ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
244
|
+
} else ctx.drawImage(image, 0, 0, width, height);
|
|
245
|
+
return canvas;
|
|
246
|
+
},
|
|
247
|
+
setPatternTransform(pattern, transform, paint) {
|
|
248
|
+
try {
|
|
249
|
+
if (transform && pattern.setTransform) {
|
|
250
|
+
pattern.setTransform(transform);
|
|
251
|
+
transform = undefined;
|
|
252
|
+
}
|
|
253
|
+
} catch (_a) {}
|
|
254
|
+
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const {image: image} = Platform;
|
|
260
|
+
|
|
261
|
+
const IncrementId = {
|
|
262
|
+
RUNTIME: "runtime",
|
|
263
|
+
LEAF: "leaf",
|
|
264
|
+
TASK: "task",
|
|
265
|
+
CNAVAS: "canvas",
|
|
266
|
+
IMAGE: "image",
|
|
267
|
+
types: {},
|
|
268
|
+
create(typeName) {
|
|
269
|
+
const {types: types} = I$1;
|
|
270
|
+
if (types[typeName]) {
|
|
271
|
+
return types[typeName]++;
|
|
272
|
+
} else {
|
|
273
|
+
types[typeName] = 1;
|
|
274
|
+
return 0;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
const I$1 = IncrementId;
|
|
280
|
+
|
|
250
281
|
let tempA, tempB, tempTo;
|
|
251
282
|
|
|
252
283
|
const {max: max$1} = Math, tempFour = [ 0, 0, 0, 0 ];
|
|
@@ -320,7 +351,7 @@ const FourNumberHelper = {
|
|
|
320
351
|
|
|
321
352
|
const {set: set$1, get: get$1, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
322
353
|
|
|
323
|
-
const {round: round$3, pow: pow$1, PI: PI$1} = Math;
|
|
354
|
+
const {round: round$3, pow: pow$1, max: max, floor: floor$1, PI: PI$1} = Math;
|
|
324
355
|
|
|
325
356
|
const MathHelper = {
|
|
326
357
|
within(value, min, max) {
|
|
@@ -373,6 +404,9 @@ const MathHelper = {
|
|
|
373
404
|
scaleData.scaleY = scale.y;
|
|
374
405
|
}
|
|
375
406
|
},
|
|
407
|
+
getFloorScale(num, min = 1) {
|
|
408
|
+
return max(floor$1(num), min) / num;
|
|
409
|
+
},
|
|
376
410
|
randInt: randInt,
|
|
377
411
|
randColor(opacity) {
|
|
378
412
|
return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
|
|
@@ -1202,7 +1236,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
|
1202
1236
|
|
|
1203
1237
|
const {float: float, fourNumber: fourNumber} = MathHelper;
|
|
1204
1238
|
|
|
1205
|
-
const {floor: floor
|
|
1239
|
+
const {floor: floor, ceil: ceil$1} = Math;
|
|
1206
1240
|
|
|
1207
1241
|
let right, bottom, boundsRight, boundsBottom;
|
|
1208
1242
|
|
|
@@ -1294,20 +1328,20 @@ const BoundsHelper = {
|
|
|
1294
1328
|
toOuterOf(t, matrix, to) {
|
|
1295
1329
|
to || (to = t);
|
|
1296
1330
|
if (matrix.b === 0 && matrix.c === 0) {
|
|
1297
|
-
const {a: a, d: d} = matrix;
|
|
1331
|
+
const {a: a, d: d, e: e, f: f} = matrix;
|
|
1298
1332
|
if (a > 0) {
|
|
1299
1333
|
to.width = t.width * a;
|
|
1300
|
-
to.x =
|
|
1334
|
+
to.x = e + t.x * a;
|
|
1301
1335
|
} else {
|
|
1302
1336
|
to.width = t.width * -a;
|
|
1303
|
-
to.x =
|
|
1337
|
+
to.x = e + t.x * a - to.width;
|
|
1304
1338
|
}
|
|
1305
1339
|
if (d > 0) {
|
|
1306
1340
|
to.height = t.height * d;
|
|
1307
|
-
to.y =
|
|
1341
|
+
to.y = f + t.y * d;
|
|
1308
1342
|
} else {
|
|
1309
1343
|
to.height = t.height * -d;
|
|
1310
|
-
to.y =
|
|
1344
|
+
to.y = f + t.y * d - to.height;
|
|
1311
1345
|
}
|
|
1312
1346
|
} else {
|
|
1313
1347
|
point.x = t.x;
|
|
@@ -1359,8 +1393,8 @@ const BoundsHelper = {
|
|
|
1359
1393
|
},
|
|
1360
1394
|
ceil(t) {
|
|
1361
1395
|
const {x: x, y: y} = t;
|
|
1362
|
-
t.x = floor
|
|
1363
|
-
t.y = floor
|
|
1396
|
+
t.x = floor(t.x);
|
|
1397
|
+
t.y = floor(t.y);
|
|
1364
1398
|
t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
|
|
1365
1399
|
t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
|
|
1366
1400
|
},
|
|
@@ -3708,7 +3742,9 @@ class TaskItem {
|
|
|
3708
3742
|
run() {
|
|
3709
3743
|
return __awaiter(this, void 0, void 0, function*() {
|
|
3710
3744
|
try {
|
|
3711
|
-
if (this.
|
|
3745
|
+
if (this.isComplete) return;
|
|
3746
|
+
if (this.canUse && !this.canUse()) return this.cancel();
|
|
3747
|
+
if (this.task && this.parent.running) yield this.task();
|
|
3712
3748
|
} catch (error) {
|
|
3713
3749
|
debug$4.error(error);
|
|
3714
3750
|
}
|
|
@@ -3716,8 +3752,7 @@ class TaskItem {
|
|
|
3716
3752
|
}
|
|
3717
3753
|
complete() {
|
|
3718
3754
|
this.isComplete = true;
|
|
3719
|
-
this.parent = null;
|
|
3720
|
-
this.task = null;
|
|
3755
|
+
this.parent = this.task = this.canUse = null;
|
|
3721
3756
|
}
|
|
3722
3757
|
cancel() {
|
|
3723
3758
|
this.isCancel = true;
|
|
@@ -3760,7 +3795,7 @@ class TaskProcessor {
|
|
|
3760
3795
|
if (config) DataHelper.assign(this.config, config);
|
|
3761
3796
|
this.empty();
|
|
3762
3797
|
}
|
|
3763
|
-
add(taskCallback, options) {
|
|
3798
|
+
add(taskCallback, options, canUse) {
|
|
3764
3799
|
let start, parallel, time, delay;
|
|
3765
3800
|
const task = new TaskItem(taskCallback);
|
|
3766
3801
|
task.parent = this;
|
|
@@ -3771,9 +3806,11 @@ class TaskProcessor {
|
|
|
3771
3806
|
start = options.start;
|
|
3772
3807
|
time = options.time;
|
|
3773
3808
|
delay = options.delay;
|
|
3809
|
+
if (!canUse) canUse = options.canUse;
|
|
3774
3810
|
}
|
|
3775
3811
|
if (time) task.time = time;
|
|
3776
3812
|
if (parallel === false) task.parallel = false;
|
|
3813
|
+
if (canUse) task.canUse = canUse;
|
|
3777
3814
|
if (isUndefined(delay)) {
|
|
3778
3815
|
this.push(task, start);
|
|
3779
3816
|
} else {
|
|
@@ -3843,15 +3880,10 @@ class TaskProcessor {
|
|
|
3843
3880
|
this.timer = setTimeout(() => this.nextTask());
|
|
3844
3881
|
return;
|
|
3845
3882
|
}
|
|
3846
|
-
if (task.isCancel) {
|
|
3847
|
-
this.index++;
|
|
3848
|
-
this.runTask();
|
|
3849
|
-
return;
|
|
3850
|
-
}
|
|
3851
3883
|
task.run().then(() => {
|
|
3852
3884
|
this.onTask(task);
|
|
3853
3885
|
this.index++;
|
|
3854
|
-
this.nextTask();
|
|
3886
|
+
task.isCancel ? this.runTask() : this.nextTask();
|
|
3855
3887
|
}).catch(error => {
|
|
3856
3888
|
this.onError(error);
|
|
3857
3889
|
});
|
|
@@ -4027,8 +4059,6 @@ const I = ImageManager;
|
|
|
4027
4059
|
|
|
4028
4060
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
4029
4061
|
|
|
4030
|
-
const {floor: floor, max: max} = Math;
|
|
4031
|
-
|
|
4032
4062
|
class LeaferImage {
|
|
4033
4063
|
get url() {
|
|
4034
4064
|
return this.config.url;
|
|
@@ -4053,10 +4083,9 @@ class LeaferImage {
|
|
|
4053
4083
|
load(onSuccess, onError) {
|
|
4054
4084
|
if (!this.loading) {
|
|
4055
4085
|
this.loading = true;
|
|
4056
|
-
|
|
4057
|
-
if (onProgress) loadImage = loadImageWithProgress;
|
|
4086
|
+
const {crossOrigin: crossOrigin} = this.config;
|
|
4058
4087
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4059
|
-
return yield loadImage(this.url,
|
|
4088
|
+
return yield Platform.origin.loadImage(this.url, isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin, this).then(img => this.setView(img)).catch(e => {
|
|
4060
4089
|
this.error = e;
|
|
4061
4090
|
this.onComplete(false);
|
|
4062
4091
|
});
|
|
@@ -4082,9 +4111,6 @@ class LeaferImage {
|
|
|
4082
4111
|
this.view = img;
|
|
4083
4112
|
this.onComplete(true);
|
|
4084
4113
|
}
|
|
4085
|
-
onProgress(progress) {
|
|
4086
|
-
this.progress = progress;
|
|
4087
|
-
}
|
|
4088
4114
|
onComplete(isSuccess) {
|
|
4089
4115
|
let odd;
|
|
4090
4116
|
this.waitComplete.forEach((item, index) => {
|
|
@@ -4103,7 +4129,7 @@ class LeaferImage {
|
|
|
4103
4129
|
getFull(_filters) {
|
|
4104
4130
|
return this.view;
|
|
4105
4131
|
}
|
|
4106
|
-
getCanvas(width, height, opacity,
|
|
4132
|
+
getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
|
|
4107
4133
|
width || (width = this.width);
|
|
4108
4134
|
height || (height = this.height);
|
|
4109
4135
|
if (this.cache) {
|
|
@@ -4116,11 +4142,7 @@ class LeaferImage {
|
|
|
4116
4142
|
}
|
|
4117
4143
|
if (data) return data;
|
|
4118
4144
|
}
|
|
4119
|
-
const canvas = Platform.
|
|
4120
|
-
const ctx = canvas.getContext("2d");
|
|
4121
|
-
if (opacity) ctx.globalAlpha = opacity;
|
|
4122
|
-
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
4123
|
-
ctx.drawImage(this.view, 0, 0, width, height);
|
|
4145
|
+
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
|
|
4124
4146
|
this.cache = this.use > 1 ? {
|
|
4125
4147
|
data: canvas,
|
|
4126
4148
|
params: arguments
|
|
@@ -4129,13 +4151,7 @@ class LeaferImage {
|
|
|
4129
4151
|
}
|
|
4130
4152
|
getPattern(canvas, repeat, transform, paint) {
|
|
4131
4153
|
const pattern = Platform.canvas.createPattern(canvas, repeat);
|
|
4132
|
-
|
|
4133
|
-
if (transform && pattern.setTransform) {
|
|
4134
|
-
pattern.setTransform(transform);
|
|
4135
|
-
transform = undefined;
|
|
4136
|
-
}
|
|
4137
|
-
} catch (_a) {}
|
|
4138
|
-
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
4154
|
+
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4139
4155
|
return pattern;
|
|
4140
4156
|
}
|
|
4141
4157
|
destroy() {
|
|
@@ -5809,12 +5825,12 @@ const {toBounds: toBounds} = PathBounds;
|
|
|
5809
5825
|
|
|
5810
5826
|
const LeafBounds = {
|
|
5811
5827
|
__updateWorldBounds() {
|
|
5812
|
-
const
|
|
5813
|
-
toOuterOf$1(
|
|
5814
|
-
if (
|
|
5815
|
-
if (
|
|
5828
|
+
const {__layout: __layout, __world: __world} = this;
|
|
5829
|
+
toOuterOf$1(__layout.renderBounds, __world, __world);
|
|
5830
|
+
if (__layout.resized) {
|
|
5831
|
+
if (__layout.resized === "inner") this.__onUpdateSize();
|
|
5816
5832
|
if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
|
|
5817
|
-
|
|
5833
|
+
__layout.resized = undefined;
|
|
5818
5834
|
}
|
|
5819
5835
|
if (this.__hasWorldEvent) BoundsEvent.emitWorld(this);
|
|
5820
5836
|
},
|
|
@@ -6819,6 +6835,6 @@ class LeafLevelList {
|
|
|
6819
6835
|
}
|
|
6820
6836
|
}
|
|
6821
6837
|
|
|
6822
|
-
const version = "1.
|
|
6838
|
+
const version = "1.10.0";
|
|
6823
6839
|
|
|
6824
6840
|
export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, FourNumberHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };
|