@leafer/core 1.12.3 → 2.0.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 +94 -71
- package/lib/core.esm.js +93 -72
- 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
|
@@ -209,57 +209,6 @@ class LeafData {
|
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
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
212
|
const IncrementId = {
|
|
264
213
|
RUNTIME: "runtime",
|
|
265
214
|
LEAF: "leaf",
|
|
@@ -282,7 +231,7 @@ const I$1 = IncrementId;
|
|
|
282
231
|
|
|
283
232
|
let tempA, tempB, tempTo;
|
|
284
233
|
|
|
285
|
-
const {max: max$
|
|
234
|
+
const {max: max$2} = Math, tempFour = [ 0, 0, 0, 0 ];
|
|
286
235
|
|
|
287
236
|
const FourNumberHelper = {
|
|
288
237
|
zero: [ ...tempFour ],
|
|
@@ -334,9 +283,9 @@ const FourNumberHelper = {
|
|
|
334
283
|
return data;
|
|
335
284
|
},
|
|
336
285
|
max(t, other, change) {
|
|
337
|
-
if (isNumber(t) && isNumber(other)) return max$
|
|
286
|
+
if (isNumber(t) && isNumber(other)) return max$2(t, other);
|
|
338
287
|
toTempAB(t, other, change);
|
|
339
|
-
return set$1(tempTo, max$
|
|
288
|
+
return set$1(tempTo, max$2(tempA[0], tempB[0]), max$2(tempA[1], tempB[1]), max$2(tempA[2], tempB[2]), max$2(tempA[3], tempB[3]));
|
|
340
289
|
},
|
|
341
290
|
add(t, other, change) {
|
|
342
291
|
if (isNumber(t) && isNumber(other)) return t + other;
|
|
@@ -353,7 +302,7 @@ const FourNumberHelper = {
|
|
|
353
302
|
|
|
354
303
|
const {set: set$1, get: get$1, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
355
304
|
|
|
356
|
-
const {round: round$3, pow: pow$1, max: max, floor: floor$
|
|
305
|
+
const {round: round$3, pow: pow$1, max: max$1, floor: floor$2, PI: PI$1} = Math;
|
|
357
306
|
|
|
358
307
|
const MathHelper = {
|
|
359
308
|
within(value, min, max) {
|
|
@@ -407,7 +356,7 @@ const MathHelper = {
|
|
|
407
356
|
}
|
|
408
357
|
},
|
|
409
358
|
getFloorScale(num, min = 1) {
|
|
410
|
-
return max(floor$
|
|
359
|
+
return max$1(floor$2(num), min) / num;
|
|
411
360
|
},
|
|
412
361
|
randInt: randInt,
|
|
413
362
|
randColor(opacity) {
|
|
@@ -1252,7 +1201,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
|
1252
1201
|
|
|
1253
1202
|
const {float: float, fourNumber: fourNumber} = MathHelper;
|
|
1254
1203
|
|
|
1255
|
-
const {floor: floor, ceil: ceil$1} = Math;
|
|
1204
|
+
const {floor: floor$1, ceil: ceil$1} = Math;
|
|
1256
1205
|
|
|
1257
1206
|
let right, bottom, boundsRight, boundsBottom;
|
|
1258
1207
|
|
|
@@ -1409,8 +1358,8 @@ const BoundsHelper = {
|
|
|
1409
1358
|
},
|
|
1410
1359
|
ceil(t) {
|
|
1411
1360
|
const {x: x, y: y} = t;
|
|
1412
|
-
t.x = floor(t.x);
|
|
1413
|
-
t.y = floor(t.y);
|
|
1361
|
+
t.x = floor$1(t.x);
|
|
1362
|
+
t.y = floor$1(t.y);
|
|
1414
1363
|
t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
|
|
1415
1364
|
t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
|
|
1416
1365
|
},
|
|
@@ -1542,6 +1491,9 @@ const BoundsHelper = {
|
|
|
1542
1491
|
isEmpty(t) {
|
|
1543
1492
|
return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0;
|
|
1544
1493
|
},
|
|
1494
|
+
hasSize(t) {
|
|
1495
|
+
return t.width && t.height;
|
|
1496
|
+
},
|
|
1545
1497
|
reset(t) {
|
|
1546
1498
|
B.set(t);
|
|
1547
1499
|
}
|
|
@@ -1718,6 +1670,12 @@ class AutoBounds {
|
|
|
1718
1670
|
}
|
|
1719
1671
|
}
|
|
1720
1672
|
|
|
1673
|
+
const UnitConvertHelper = {
|
|
1674
|
+
number(value, percentRefer) {
|
|
1675
|
+
return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
|
|
1676
|
+
}
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1721
1679
|
const StringNumberMap = {
|
|
1722
1680
|
0: 1,
|
|
1723
1681
|
1: 1,
|
|
@@ -1734,6 +1692,69 @@ const StringNumberMap = {
|
|
|
1734
1692
|
E: 1
|
|
1735
1693
|
};
|
|
1736
1694
|
|
|
1695
|
+
const {floor: floor, max: max} = Math;
|
|
1696
|
+
|
|
1697
|
+
const Platform = {
|
|
1698
|
+
toURL(text, fileType) {
|
|
1699
|
+
let url = encodeURIComponent(text);
|
|
1700
|
+
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
1701
|
+
return url;
|
|
1702
|
+
},
|
|
1703
|
+
image: {
|
|
1704
|
+
hitCanvasSize: 100,
|
|
1705
|
+
maxCacheSize: 2560 * 1600,
|
|
1706
|
+
maxPatternSize: 4096 * 2160,
|
|
1707
|
+
crossOrigin: "anonymous",
|
|
1708
|
+
isLarge(size, scaleX, scaleY, largeSize) {
|
|
1709
|
+
return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize);
|
|
1710
|
+
},
|
|
1711
|
+
isSuperLarge(size, scaleX, scaleY) {
|
|
1712
|
+
return image.isLarge(size, scaleX, scaleY, image.maxPatternSize);
|
|
1713
|
+
},
|
|
1714
|
+
getRealURL(url) {
|
|
1715
|
+
const {prefix: prefix, suffix: suffix} = image;
|
|
1716
|
+
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
1717
|
+
if (prefix && url[0] === "/") url = prefix + url;
|
|
1718
|
+
return url;
|
|
1719
|
+
},
|
|
1720
|
+
resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
|
|
1721
|
+
const realWidth = max(floor(width + (xGap || 0)), 1), realHeight = max(floor(height + (yGap || 0)), 1);
|
|
1722
|
+
let interlaceX, interlaceY, interlaceOffset;
|
|
1723
|
+
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
|
|
1724
|
+
const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
|
|
1725
|
+
const ctx = canvas.getContext("2d");
|
|
1726
|
+
if (opacity) ctx.globalAlpha = opacity;
|
|
1727
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
1728
|
+
if (image.canUse(view)) {
|
|
1729
|
+
if (clip) {
|
|
1730
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
1731
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
1732
|
+
ctx.drawImage(view, 0, 0, view.width, view.height);
|
|
1733
|
+
} else ctx.drawImage(view, 0, 0, width, height);
|
|
1734
|
+
if (interlaceOffset) {
|
|
1735
|
+
ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset - realWidth : realWidth, interlaceX ? realHeight : interlaceOffset - realHeight, realWidth, realHeight);
|
|
1736
|
+
ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset : realWidth, interlaceX ? realHeight : interlaceOffset, realWidth, realHeight);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
return canvas;
|
|
1740
|
+
},
|
|
1741
|
+
canUse(view) {
|
|
1742
|
+
return view && view.width && !view.__closed;
|
|
1743
|
+
},
|
|
1744
|
+
setPatternTransform(pattern, transform, paint) {
|
|
1745
|
+
try {
|
|
1746
|
+
if (transform && pattern.setTransform) {
|
|
1747
|
+
pattern.setTransform(transform);
|
|
1748
|
+
transform = undefined;
|
|
1749
|
+
}
|
|
1750
|
+
} catch (_a) {}
|
|
1751
|
+
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1756
|
+
const {image: image} = Platform;
|
|
1757
|
+
|
|
1737
1758
|
const {randColor: randColor} = MathHelper;
|
|
1738
1759
|
|
|
1739
1760
|
class Debug {
|
|
@@ -3776,9 +3797,10 @@ class TaskItem {
|
|
|
3776
3797
|
run() {
|
|
3777
3798
|
return __awaiter(this, void 0, void 0, function*() {
|
|
3778
3799
|
try {
|
|
3779
|
-
if (this.isComplete) return;
|
|
3800
|
+
if (this.isComplete || this.runing) return;
|
|
3801
|
+
this.runing = true;
|
|
3780
3802
|
if (this.canUse && !this.canUse()) return this.cancel();
|
|
3781
|
-
if (this.task
|
|
3803
|
+
if (this.task) yield this.task();
|
|
3782
3804
|
} catch (error) {
|
|
3783
3805
|
debug$4.error(error);
|
|
3784
3806
|
}
|
|
@@ -3894,7 +3916,7 @@ class TaskProcessor {
|
|
|
3894
3916
|
stop() {
|
|
3895
3917
|
this.isComplete = true;
|
|
3896
3918
|
this.list.forEach(task => {
|
|
3897
|
-
if (!task.isComplete) task.
|
|
3919
|
+
if (!task.isComplete) task.run();
|
|
3898
3920
|
});
|
|
3899
3921
|
this.pause();
|
|
3900
3922
|
this.empty();
|
|
@@ -4184,7 +4206,7 @@ class LeaferImage {
|
|
|
4184
4206
|
getFull(_filters) {
|
|
4185
4207
|
return this.view;
|
|
4186
4208
|
}
|
|
4187
|
-
getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
|
|
4209
|
+
getCanvas(width, height, opacity, filters, xGap, yGap, smooth, interlace) {
|
|
4188
4210
|
width || (width = this.width);
|
|
4189
4211
|
height || (height = this.height);
|
|
4190
4212
|
if (this.cache) {
|
|
@@ -4197,7 +4219,7 @@ class LeaferImage {
|
|
|
4197
4219
|
}
|
|
4198
4220
|
if (data) return data;
|
|
4199
4221
|
}
|
|
4200
|
-
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
|
|
4222
|
+
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters, interlace);
|
|
4201
4223
|
this.cache = this.use > 1 ? {
|
|
4202
4224
|
data: canvas,
|
|
4203
4225
|
params: arguments
|
|
@@ -4213,13 +4235,13 @@ class LeaferImage {
|
|
|
4213
4235
|
return this.url;
|
|
4214
4236
|
}
|
|
4215
4237
|
setThumbView(_view) {}
|
|
4216
|
-
getThumbSize() {
|
|
4238
|
+
getThumbSize(_lod) {
|
|
4217
4239
|
return undefined;
|
|
4218
4240
|
}
|
|
4219
4241
|
getMinLevel() {
|
|
4220
4242
|
return undefined;
|
|
4221
4243
|
}
|
|
4222
|
-
getLevelData(_level) {
|
|
4244
|
+
getLevelData(_level, _width, _height) {
|
|
4223
4245
|
return undefined;
|
|
4224
4246
|
}
|
|
4225
4247
|
clearLevels(_checkUse) {}
|
|
@@ -6089,7 +6111,7 @@ const LeafRender = {
|
|
|
6089
6111
|
}
|
|
6090
6112
|
};
|
|
6091
6113
|
|
|
6092
|
-
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
|
|
6114
|
+
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
|
|
6093
6115
|
|
|
6094
6116
|
const BranchRender = {
|
|
6095
6117
|
__updateChange() {
|
|
@@ -6101,8 +6123,8 @@ const BranchRender = {
|
|
|
6101
6123
|
this.__.__checkSingle();
|
|
6102
6124
|
},
|
|
6103
6125
|
__render(canvas, options) {
|
|
6104
|
-
this.__nowWorld = this.__getNowWorld(options);
|
|
6105
|
-
if (this.__worldOpacity) {
|
|
6126
|
+
const nowWorld = this.__nowWorld = this.__getNowWorld(options);
|
|
6127
|
+
if (this.__worldOpacity && hasSize(nowWorld)) {
|
|
6106
6128
|
const data = this.__;
|
|
6107
6129
|
if (data.__useDim) {
|
|
6108
6130
|
if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
|
|
@@ -6111,7 +6133,6 @@ const BranchRender = {
|
|
|
6111
6133
|
if (data.eraser === "path") return this.__renderEraser(canvas, options);
|
|
6112
6134
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
6113
6135
|
this.__renderBranch(tempCanvas, options);
|
|
6114
|
-
const nowWorld = this.__nowWorld;
|
|
6115
6136
|
canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
|
|
6116
6137
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
|
|
6117
6138
|
tempCanvas.recycle(nowWorld);
|
|
@@ -6951,7 +6972,7 @@ class LeafLevelList {
|
|
|
6951
6972
|
}
|
|
6952
6973
|
}
|
|
6953
6974
|
|
|
6954
|
-
const version = "
|
|
6975
|
+
const version = "2.0.0";
|
|
6955
6976
|
|
|
6956
6977
|
exports.AlignHelper = AlignHelper;
|
|
6957
6978
|
|
|
@@ -7095,6 +7116,8 @@ exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
|
|
|
7095
7116
|
|
|
7096
7117
|
exports.UICreator = UICreator;
|
|
7097
7118
|
|
|
7119
|
+
exports.UnitConvertHelper = UnitConvertHelper;
|
|
7120
|
+
|
|
7098
7121
|
exports.WaitHelper = WaitHelper;
|
|
7099
7122
|
|
|
7100
7123
|
exports.WatchEvent = WatchEvent;
|
package/lib/core.esm.js
CHANGED
|
@@ -207,57 +207,6 @@ class LeafData {
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
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
210
|
const IncrementId = {
|
|
262
211
|
RUNTIME: "runtime",
|
|
263
212
|
LEAF: "leaf",
|
|
@@ -280,7 +229,7 @@ const I$1 = IncrementId;
|
|
|
280
229
|
|
|
281
230
|
let tempA, tempB, tempTo;
|
|
282
231
|
|
|
283
|
-
const {max: max$
|
|
232
|
+
const {max: max$2} = Math, tempFour = [ 0, 0, 0, 0 ];
|
|
284
233
|
|
|
285
234
|
const FourNumberHelper = {
|
|
286
235
|
zero: [ ...tempFour ],
|
|
@@ -332,9 +281,9 @@ const FourNumberHelper = {
|
|
|
332
281
|
return data;
|
|
333
282
|
},
|
|
334
283
|
max(t, other, change) {
|
|
335
|
-
if (isNumber(t) && isNumber(other)) return max$
|
|
284
|
+
if (isNumber(t) && isNumber(other)) return max$2(t, other);
|
|
336
285
|
toTempAB(t, other, change);
|
|
337
|
-
return set$1(tempTo, max$
|
|
286
|
+
return set$1(tempTo, max$2(tempA[0], tempB[0]), max$2(tempA[1], tempB[1]), max$2(tempA[2], tempB[2]), max$2(tempA[3], tempB[3]));
|
|
338
287
|
},
|
|
339
288
|
add(t, other, change) {
|
|
340
289
|
if (isNumber(t) && isNumber(other)) return t + other;
|
|
@@ -351,7 +300,7 @@ const FourNumberHelper = {
|
|
|
351
300
|
|
|
352
301
|
const {set: set$1, get: get$1, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
|
|
353
302
|
|
|
354
|
-
const {round: round$3, pow: pow$1, max: max, floor: floor$
|
|
303
|
+
const {round: round$3, pow: pow$1, max: max$1, floor: floor$2, PI: PI$1} = Math;
|
|
355
304
|
|
|
356
305
|
const MathHelper = {
|
|
357
306
|
within(value, min, max) {
|
|
@@ -405,7 +354,7 @@ const MathHelper = {
|
|
|
405
354
|
}
|
|
406
355
|
},
|
|
407
356
|
getFloorScale(num, min = 1) {
|
|
408
|
-
return max(floor$
|
|
357
|
+
return max$1(floor$2(num), min) / num;
|
|
409
358
|
},
|
|
410
359
|
randInt: randInt,
|
|
411
360
|
randColor(opacity) {
|
|
@@ -1250,7 +1199,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
|
|
|
1250
1199
|
|
|
1251
1200
|
const {float: float, fourNumber: fourNumber} = MathHelper;
|
|
1252
1201
|
|
|
1253
|
-
const {floor: floor, ceil: ceil$1} = Math;
|
|
1202
|
+
const {floor: floor$1, ceil: ceil$1} = Math;
|
|
1254
1203
|
|
|
1255
1204
|
let right, bottom, boundsRight, boundsBottom;
|
|
1256
1205
|
|
|
@@ -1407,8 +1356,8 @@ const BoundsHelper = {
|
|
|
1407
1356
|
},
|
|
1408
1357
|
ceil(t) {
|
|
1409
1358
|
const {x: x, y: y} = t;
|
|
1410
|
-
t.x = floor(t.x);
|
|
1411
|
-
t.y = floor(t.y);
|
|
1359
|
+
t.x = floor$1(t.x);
|
|
1360
|
+
t.y = floor$1(t.y);
|
|
1412
1361
|
t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
|
|
1413
1362
|
t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
|
|
1414
1363
|
},
|
|
@@ -1540,6 +1489,9 @@ const BoundsHelper = {
|
|
|
1540
1489
|
isEmpty(t) {
|
|
1541
1490
|
return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0;
|
|
1542
1491
|
},
|
|
1492
|
+
hasSize(t) {
|
|
1493
|
+
return t.width && t.height;
|
|
1494
|
+
},
|
|
1543
1495
|
reset(t) {
|
|
1544
1496
|
B.set(t);
|
|
1545
1497
|
}
|
|
@@ -1716,6 +1668,12 @@ class AutoBounds {
|
|
|
1716
1668
|
}
|
|
1717
1669
|
}
|
|
1718
1670
|
|
|
1671
|
+
const UnitConvertHelper = {
|
|
1672
|
+
number(value, percentRefer) {
|
|
1673
|
+
return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
|
|
1674
|
+
}
|
|
1675
|
+
};
|
|
1676
|
+
|
|
1719
1677
|
const StringNumberMap = {
|
|
1720
1678
|
0: 1,
|
|
1721
1679
|
1: 1,
|
|
@@ -1732,6 +1690,69 @@ const StringNumberMap = {
|
|
|
1732
1690
|
E: 1
|
|
1733
1691
|
};
|
|
1734
1692
|
|
|
1693
|
+
const {floor: floor, max: max} = Math;
|
|
1694
|
+
|
|
1695
|
+
const Platform = {
|
|
1696
|
+
toURL(text, fileType) {
|
|
1697
|
+
let url = encodeURIComponent(text);
|
|
1698
|
+
if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
|
|
1699
|
+
return url;
|
|
1700
|
+
},
|
|
1701
|
+
image: {
|
|
1702
|
+
hitCanvasSize: 100,
|
|
1703
|
+
maxCacheSize: 2560 * 1600,
|
|
1704
|
+
maxPatternSize: 4096 * 2160,
|
|
1705
|
+
crossOrigin: "anonymous",
|
|
1706
|
+
isLarge(size, scaleX, scaleY, largeSize) {
|
|
1707
|
+
return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize);
|
|
1708
|
+
},
|
|
1709
|
+
isSuperLarge(size, scaleX, scaleY) {
|
|
1710
|
+
return image.isLarge(size, scaleX, scaleY, image.maxPatternSize);
|
|
1711
|
+
},
|
|
1712
|
+
getRealURL(url) {
|
|
1713
|
+
const {prefix: prefix, suffix: suffix} = image;
|
|
1714
|
+
if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
|
|
1715
|
+
if (prefix && url[0] === "/") url = prefix + url;
|
|
1716
|
+
return url;
|
|
1717
|
+
},
|
|
1718
|
+
resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
|
|
1719
|
+
const realWidth = max(floor(width + (xGap || 0)), 1), realHeight = max(floor(height + (yGap || 0)), 1);
|
|
1720
|
+
let interlaceX, interlaceY, interlaceOffset;
|
|
1721
|
+
if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
|
|
1722
|
+
const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
|
|
1723
|
+
const ctx = canvas.getContext("2d");
|
|
1724
|
+
if (opacity) ctx.globalAlpha = opacity;
|
|
1725
|
+
ctx.imageSmoothingEnabled = smooth === false ? false : true;
|
|
1726
|
+
if (image.canUse(view)) {
|
|
1727
|
+
if (clip) {
|
|
1728
|
+
const scaleX = width / clip.width, scaleY = height / clip.height;
|
|
1729
|
+
ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
|
|
1730
|
+
ctx.drawImage(view, 0, 0, view.width, view.height);
|
|
1731
|
+
} else ctx.drawImage(view, 0, 0, width, height);
|
|
1732
|
+
if (interlaceOffset) {
|
|
1733
|
+
ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset - realWidth : realWidth, interlaceX ? realHeight : interlaceOffset - realHeight, realWidth, realHeight);
|
|
1734
|
+
ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset : realWidth, interlaceX ? realHeight : interlaceOffset, realWidth, realHeight);
|
|
1735
|
+
}
|
|
1736
|
+
}
|
|
1737
|
+
return canvas;
|
|
1738
|
+
},
|
|
1739
|
+
canUse(view) {
|
|
1740
|
+
return view && view.width && !view.__closed;
|
|
1741
|
+
},
|
|
1742
|
+
setPatternTransform(pattern, transform, paint) {
|
|
1743
|
+
try {
|
|
1744
|
+
if (transform && pattern.setTransform) {
|
|
1745
|
+
pattern.setTransform(transform);
|
|
1746
|
+
transform = undefined;
|
|
1747
|
+
}
|
|
1748
|
+
} catch (_a) {}
|
|
1749
|
+
if (paint) DataHelper.stintSet(paint, "transform", transform);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
};
|
|
1753
|
+
|
|
1754
|
+
const {image: image} = Platform;
|
|
1755
|
+
|
|
1735
1756
|
const {randColor: randColor} = MathHelper;
|
|
1736
1757
|
|
|
1737
1758
|
class Debug {
|
|
@@ -3774,9 +3795,10 @@ class TaskItem {
|
|
|
3774
3795
|
run() {
|
|
3775
3796
|
return __awaiter(this, void 0, void 0, function*() {
|
|
3776
3797
|
try {
|
|
3777
|
-
if (this.isComplete) return;
|
|
3798
|
+
if (this.isComplete || this.runing) return;
|
|
3799
|
+
this.runing = true;
|
|
3778
3800
|
if (this.canUse && !this.canUse()) return this.cancel();
|
|
3779
|
-
if (this.task
|
|
3801
|
+
if (this.task) yield this.task();
|
|
3780
3802
|
} catch (error) {
|
|
3781
3803
|
debug$4.error(error);
|
|
3782
3804
|
}
|
|
@@ -3892,7 +3914,7 @@ class TaskProcessor {
|
|
|
3892
3914
|
stop() {
|
|
3893
3915
|
this.isComplete = true;
|
|
3894
3916
|
this.list.forEach(task => {
|
|
3895
|
-
if (!task.isComplete) task.
|
|
3917
|
+
if (!task.isComplete) task.run();
|
|
3896
3918
|
});
|
|
3897
3919
|
this.pause();
|
|
3898
3920
|
this.empty();
|
|
@@ -4182,7 +4204,7 @@ class LeaferImage {
|
|
|
4182
4204
|
getFull(_filters) {
|
|
4183
4205
|
return this.view;
|
|
4184
4206
|
}
|
|
4185
|
-
getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
|
|
4207
|
+
getCanvas(width, height, opacity, filters, xGap, yGap, smooth, interlace) {
|
|
4186
4208
|
width || (width = this.width);
|
|
4187
4209
|
height || (height = this.height);
|
|
4188
4210
|
if (this.cache) {
|
|
@@ -4195,7 +4217,7 @@ class LeaferImage {
|
|
|
4195
4217
|
}
|
|
4196
4218
|
if (data) return data;
|
|
4197
4219
|
}
|
|
4198
|
-
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
|
|
4220
|
+
const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters, interlace);
|
|
4199
4221
|
this.cache = this.use > 1 ? {
|
|
4200
4222
|
data: canvas,
|
|
4201
4223
|
params: arguments
|
|
@@ -4211,13 +4233,13 @@ class LeaferImage {
|
|
|
4211
4233
|
return this.url;
|
|
4212
4234
|
}
|
|
4213
4235
|
setThumbView(_view) {}
|
|
4214
|
-
getThumbSize() {
|
|
4236
|
+
getThumbSize(_lod) {
|
|
4215
4237
|
return undefined;
|
|
4216
4238
|
}
|
|
4217
4239
|
getMinLevel() {
|
|
4218
4240
|
return undefined;
|
|
4219
4241
|
}
|
|
4220
|
-
getLevelData(_level) {
|
|
4242
|
+
getLevelData(_level, _width, _height) {
|
|
4221
4243
|
return undefined;
|
|
4222
4244
|
}
|
|
4223
4245
|
clearLevels(_checkUse) {}
|
|
@@ -6087,7 +6109,7 @@ const LeafRender = {
|
|
|
6087
6109
|
}
|
|
6088
6110
|
};
|
|
6089
6111
|
|
|
6090
|
-
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
|
|
6112
|
+
const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
|
|
6091
6113
|
|
|
6092
6114
|
const BranchRender = {
|
|
6093
6115
|
__updateChange() {
|
|
@@ -6099,8 +6121,8 @@ const BranchRender = {
|
|
|
6099
6121
|
this.__.__checkSingle();
|
|
6100
6122
|
},
|
|
6101
6123
|
__render(canvas, options) {
|
|
6102
|
-
this.__nowWorld = this.__getNowWorld(options);
|
|
6103
|
-
if (this.__worldOpacity) {
|
|
6124
|
+
const nowWorld = this.__nowWorld = this.__getNowWorld(options);
|
|
6125
|
+
if (this.__worldOpacity && hasSize(nowWorld)) {
|
|
6104
6126
|
const data = this.__;
|
|
6105
6127
|
if (data.__useDim) {
|
|
6106
6128
|
if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
|
|
@@ -6109,7 +6131,6 @@ const BranchRender = {
|
|
|
6109
6131
|
if (data.eraser === "path") return this.__renderEraser(canvas, options);
|
|
6110
6132
|
const tempCanvas = canvas.getSameCanvas(false, true);
|
|
6111
6133
|
this.__renderBranch(tempCanvas, options);
|
|
6112
|
-
const nowWorld = this.__nowWorld;
|
|
6113
6134
|
canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
|
|
6114
6135
|
canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
|
|
6115
6136
|
tempCanvas.recycle(nowWorld);
|
|
@@ -6949,6 +6970,6 @@ class LeafLevelList {
|
|
|
6949
6970
|
}
|
|
6950
6971
|
}
|
|
6951
6972
|
|
|
6952
|
-
const version = "
|
|
6973
|
+
const version = "2.0.0";
|
|
6953
6974
|
|
|
6954
|
-
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, PathCommandNodeHelper, 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 };
|
|
6975
|
+
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, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, UnitConvertHelper, 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 };
|