@leafer/core 1.4.0 → 1.4.1
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 +126 -86
- package/lib/core.cjs.map +1 -1
- package/lib/core.esm.js +126 -87
- package/lib/core.esm.js.map +1 -1
- 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
|
@@ -1376,7 +1376,7 @@ function getNameList(name) {
|
|
|
1376
1376
|
}
|
|
1377
1377
|
const D$4 = Debug;
|
|
1378
1378
|
|
|
1379
|
-
const debug$
|
|
1379
|
+
const debug$a = Debug.get('RunTime');
|
|
1380
1380
|
const Run = {
|
|
1381
1381
|
currentId: 0,
|
|
1382
1382
|
currentName: '',
|
|
@@ -1385,24 +1385,24 @@ const Run = {
|
|
|
1385
1385
|
nameToIdMap: {},
|
|
1386
1386
|
start(name, microsecond) {
|
|
1387
1387
|
const id = IncrementId.create(IncrementId.RUNTIME);
|
|
1388
|
-
R.currentId = R.idMap[id] = microsecond ? performance.now() : Date.now();
|
|
1389
|
-
R.currentName = R.nameMap[id] = name;
|
|
1390
|
-
R.nameToIdMap[name] = id;
|
|
1388
|
+
R$1.currentId = R$1.idMap[id] = microsecond ? performance.now() : Date.now();
|
|
1389
|
+
R$1.currentName = R$1.nameMap[id] = name;
|
|
1390
|
+
R$1.nameToIdMap[name] = id;
|
|
1391
1391
|
return id;
|
|
1392
1392
|
},
|
|
1393
1393
|
end(id, microsecond) {
|
|
1394
|
-
const time = R.idMap[id], name = R.nameMap[id];
|
|
1394
|
+
const time = R$1.idMap[id], name = R$1.nameMap[id];
|
|
1395
1395
|
const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
|
|
1396
|
-
R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
|
|
1397
|
-
debug$
|
|
1396
|
+
R$1.idMap[id] = R$1.nameMap[id] = R$1.nameToIdMap[name] = undefined;
|
|
1397
|
+
debug$a.log(name, duration, 'ms');
|
|
1398
1398
|
},
|
|
1399
1399
|
endOfName(name, microsecond) {
|
|
1400
|
-
const id = R.nameToIdMap[name];
|
|
1400
|
+
const id = R$1.nameToIdMap[name];
|
|
1401
1401
|
if (id !== undefined)
|
|
1402
|
-
R.end(id, microsecond);
|
|
1402
|
+
R$1.end(id, microsecond);
|
|
1403
1403
|
}
|
|
1404
1404
|
};
|
|
1405
|
-
const R = Run;
|
|
1405
|
+
const R$1 = Run;
|
|
1406
1406
|
|
|
1407
1407
|
const check = [];
|
|
1408
1408
|
const Plugin = {
|
|
@@ -1423,18 +1423,18 @@ const Plugin = {
|
|
|
1423
1423
|
};
|
|
1424
1424
|
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
1425
1425
|
|
|
1426
|
-
const debug$
|
|
1426
|
+
const debug$9 = Debug.get('UICreator');
|
|
1427
1427
|
const UICreator = {
|
|
1428
1428
|
list: {},
|
|
1429
1429
|
register(UI) {
|
|
1430
1430
|
const { __tag: tag } = UI.prototype;
|
|
1431
1431
|
if (list$1[tag])
|
|
1432
|
-
debug$
|
|
1432
|
+
debug$9.repeat(tag);
|
|
1433
1433
|
list$1[tag] = UI;
|
|
1434
1434
|
},
|
|
1435
1435
|
get(tag, data, x, y, width, height) {
|
|
1436
1436
|
if (!list$1[tag])
|
|
1437
|
-
debug$
|
|
1437
|
+
debug$9.error('not register ' + tag);
|
|
1438
1438
|
const ui = new list$1[tag](data);
|
|
1439
1439
|
if (x !== undefined) {
|
|
1440
1440
|
ui.x = x;
|
|
@@ -1450,7 +1450,7 @@ const UICreator = {
|
|
|
1450
1450
|
};
|
|
1451
1451
|
const { list: list$1 } = UICreator;
|
|
1452
1452
|
|
|
1453
|
-
const debug$
|
|
1453
|
+
const debug$8 = Debug.get('EventCreator');
|
|
1454
1454
|
const EventCreator = {
|
|
1455
1455
|
nameList: {},
|
|
1456
1456
|
register(Event) {
|
|
@@ -1458,7 +1458,7 @@ const EventCreator = {
|
|
|
1458
1458
|
Object.keys(Event).forEach(key => {
|
|
1459
1459
|
name = Event[key];
|
|
1460
1460
|
if (typeof name === 'string')
|
|
1461
|
-
nameList[name] && debug$
|
|
1461
|
+
nameList[name] && debug$8.repeat(name), nameList[name] = Event;
|
|
1462
1462
|
});
|
|
1463
1463
|
},
|
|
1464
1464
|
changeName(oldName, newName) {
|
|
@@ -1535,10 +1535,10 @@ const DataHelper = {
|
|
|
1535
1535
|
Object.keys(merge).forEach(key => {
|
|
1536
1536
|
var _a, _b;
|
|
1537
1537
|
value = merge[key];
|
|
1538
|
-
if ((value === null || value ===
|
|
1538
|
+
if ((value === null || value === void 0 ? void 0 : value.constructor) === Object && ((_a = t[key]) === null || _a === void 0 ? void 0 : _a.constructor) === Object)
|
|
1539
1539
|
return assign(t[key], merge[key], exclude && exclude[key]);
|
|
1540
1540
|
if (exclude && (key in exclude)) {
|
|
1541
|
-
if (((_b = exclude[key]) === null || _b ===
|
|
1541
|
+
if (((_b = exclude[key]) === null || _b === void 0 ? void 0 : _b.constructor) === Object)
|
|
1542
1542
|
assign(t[key] = {}, merge[key], exclude[key]);
|
|
1543
1543
|
return;
|
|
1544
1544
|
}
|
|
@@ -1662,7 +1662,7 @@ class LeafData {
|
|
|
1662
1662
|
const t = this;
|
|
1663
1663
|
if (t.blendMode === 'pass-through') {
|
|
1664
1664
|
const leaf = this.__leaf;
|
|
1665
|
-
if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
|
|
1665
|
+
if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser || t.filter) {
|
|
1666
1666
|
t.__single = true;
|
|
1667
1667
|
}
|
|
1668
1668
|
else if (t.__single) {
|
|
@@ -1775,7 +1775,7 @@ class Canvas {
|
|
|
1775
1775
|
}
|
|
1776
1776
|
setTransform(_a, _b, _c, _d, _e, _f) { }
|
|
1777
1777
|
resetTransform() { }
|
|
1778
|
-
getTransform() { return
|
|
1778
|
+
getTransform() { return void 0; }
|
|
1779
1779
|
save() { }
|
|
1780
1780
|
restore() { }
|
|
1781
1781
|
transform(a, b, c, d, e, f) {
|
|
@@ -1832,12 +1832,12 @@ class Canvas {
|
|
|
1832
1832
|
ellipse(_x, _y, _radiusX, _radiusY, _rotation, _startAngle, _endAngle, _anticlockwise) { }
|
|
1833
1833
|
rect(_x, _y, _width, _height) { }
|
|
1834
1834
|
roundRect(_x, _y, _width, _height, _radius) { }
|
|
1835
|
-
createConicGradient(_startAngle, _x, _y) { return
|
|
1836
|
-
createLinearGradient(_x0, _y0, _x1, _y1) { return
|
|
1837
|
-
createPattern(_image, _repetition) { return
|
|
1838
|
-
createRadialGradient(_x0, _y0, _r0, _x1, _y1, _r1) { return
|
|
1835
|
+
createConicGradient(_startAngle, _x, _y) { return void 0; }
|
|
1836
|
+
createLinearGradient(_x0, _y0, _x1, _y1) { return void 0; }
|
|
1837
|
+
createPattern(_image, _repetition) { return void 0; }
|
|
1838
|
+
createRadialGradient(_x0, _y0, _r0, _x1, _y1, _r1) { return void 0; }
|
|
1839
1839
|
fillText(_text, _x, _y, _maxWidth) { }
|
|
1840
|
-
measureText(_text) { return
|
|
1840
|
+
measureText(_text) { return void 0; }
|
|
1841
1841
|
strokeText(_text, _x, _y, _maxWidth) { }
|
|
1842
1842
|
destroy() {
|
|
1843
1843
|
this.context = null;
|
|
@@ -1845,79 +1845,79 @@ class Canvas {
|
|
|
1845
1845
|
}
|
|
1846
1846
|
__decorate([
|
|
1847
1847
|
contextAttr('imageSmoothingEnabled')
|
|
1848
|
-
], Canvas.prototype, "smooth",
|
|
1848
|
+
], Canvas.prototype, "smooth", void 0);
|
|
1849
1849
|
__decorate([
|
|
1850
1850
|
contextAttr('imageSmoothingQuality')
|
|
1851
|
-
], Canvas.prototype, "smoothLevel",
|
|
1851
|
+
], Canvas.prototype, "smoothLevel", void 0);
|
|
1852
1852
|
__decorate([
|
|
1853
1853
|
contextAttr('globalAlpha')
|
|
1854
|
-
], Canvas.prototype, "opacity",
|
|
1854
|
+
], Canvas.prototype, "opacity", void 0);
|
|
1855
1855
|
__decorate([
|
|
1856
1856
|
contextAttr()
|
|
1857
|
-
], Canvas.prototype, "fillStyle",
|
|
1857
|
+
], Canvas.prototype, "fillStyle", void 0);
|
|
1858
1858
|
__decorate([
|
|
1859
1859
|
contextAttr()
|
|
1860
|
-
], Canvas.prototype, "strokeStyle",
|
|
1860
|
+
], Canvas.prototype, "strokeStyle", void 0);
|
|
1861
1861
|
__decorate([
|
|
1862
1862
|
contextAttr('lineWidth')
|
|
1863
|
-
], Canvas.prototype, "strokeWidth",
|
|
1863
|
+
], Canvas.prototype, "strokeWidth", void 0);
|
|
1864
1864
|
__decorate([
|
|
1865
1865
|
contextAttr('lineCap')
|
|
1866
|
-
], Canvas.prototype, "strokeCap",
|
|
1866
|
+
], Canvas.prototype, "strokeCap", void 0);
|
|
1867
1867
|
__decorate([
|
|
1868
1868
|
contextAttr('lineJoin')
|
|
1869
|
-
], Canvas.prototype, "strokeJoin",
|
|
1869
|
+
], Canvas.prototype, "strokeJoin", void 0);
|
|
1870
1870
|
__decorate([
|
|
1871
1871
|
contextAttr('lineDashOffset')
|
|
1872
|
-
], Canvas.prototype, "dashOffset",
|
|
1872
|
+
], Canvas.prototype, "dashOffset", void 0);
|
|
1873
1873
|
__decorate([
|
|
1874
1874
|
contextAttr()
|
|
1875
|
-
], Canvas.prototype, "miterLimit",
|
|
1875
|
+
], Canvas.prototype, "miterLimit", void 0);
|
|
1876
1876
|
__decorate([
|
|
1877
1877
|
contextAttr()
|
|
1878
|
-
], Canvas.prototype, "shadowBlur",
|
|
1878
|
+
], Canvas.prototype, "shadowBlur", void 0);
|
|
1879
1879
|
__decorate([
|
|
1880
1880
|
contextAttr()
|
|
1881
|
-
], Canvas.prototype, "shadowColor",
|
|
1881
|
+
], Canvas.prototype, "shadowColor", void 0);
|
|
1882
1882
|
__decorate([
|
|
1883
1883
|
contextAttr()
|
|
1884
|
-
], Canvas.prototype, "shadowOffsetX",
|
|
1884
|
+
], Canvas.prototype, "shadowOffsetX", void 0);
|
|
1885
1885
|
__decorate([
|
|
1886
1886
|
contextAttr()
|
|
1887
|
-
], Canvas.prototype, "shadowOffsetY",
|
|
1887
|
+
], Canvas.prototype, "shadowOffsetY", void 0);
|
|
1888
1888
|
__decorate([
|
|
1889
1889
|
contextAttr()
|
|
1890
|
-
], Canvas.prototype, "filter",
|
|
1890
|
+
], Canvas.prototype, "filter", void 0);
|
|
1891
1891
|
__decorate([
|
|
1892
1892
|
contextAttr()
|
|
1893
|
-
], Canvas.prototype, "font",
|
|
1893
|
+
], Canvas.prototype, "font", void 0);
|
|
1894
1894
|
__decorate([
|
|
1895
1895
|
contextAttr()
|
|
1896
|
-
], Canvas.prototype, "fontKerning",
|
|
1896
|
+
], Canvas.prototype, "fontKerning", void 0);
|
|
1897
1897
|
__decorate([
|
|
1898
1898
|
contextAttr()
|
|
1899
|
-
], Canvas.prototype, "fontStretch",
|
|
1899
|
+
], Canvas.prototype, "fontStretch", void 0);
|
|
1900
1900
|
__decorate([
|
|
1901
1901
|
contextAttr()
|
|
1902
|
-
], Canvas.prototype, "fontVariantCaps",
|
|
1902
|
+
], Canvas.prototype, "fontVariantCaps", void 0);
|
|
1903
1903
|
__decorate([
|
|
1904
1904
|
contextAttr()
|
|
1905
|
-
], Canvas.prototype, "textAlign",
|
|
1905
|
+
], Canvas.prototype, "textAlign", void 0);
|
|
1906
1906
|
__decorate([
|
|
1907
1907
|
contextAttr()
|
|
1908
|
-
], Canvas.prototype, "textBaseline",
|
|
1908
|
+
], Canvas.prototype, "textBaseline", void 0);
|
|
1909
1909
|
__decorate([
|
|
1910
1910
|
contextAttr()
|
|
1911
|
-
], Canvas.prototype, "textRendering",
|
|
1911
|
+
], Canvas.prototype, "textRendering", void 0);
|
|
1912
1912
|
__decorate([
|
|
1913
1913
|
contextAttr()
|
|
1914
|
-
], Canvas.prototype, "wordSpacing",
|
|
1914
|
+
], Canvas.prototype, "wordSpacing", void 0);
|
|
1915
1915
|
__decorate([
|
|
1916
1916
|
contextAttr()
|
|
1917
|
-
], Canvas.prototype, "letterSpacing",
|
|
1917
|
+
], Canvas.prototype, "letterSpacing", void 0);
|
|
1918
1918
|
__decorate([
|
|
1919
1919
|
contextAttr()
|
|
1920
|
-
], Canvas.prototype, "direction",
|
|
1920
|
+
], Canvas.prototype, "direction", void 0);
|
|
1921
1921
|
__decorate([
|
|
1922
1922
|
contextMethod()
|
|
1923
1923
|
], Canvas.prototype, "setTransform", null);
|
|
@@ -2614,7 +2614,7 @@ const EllipseHelper = {
|
|
|
2614
2614
|
const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
|
|
2615
2615
|
const { rect: rect$1, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$3, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
|
|
2616
2616
|
const { ellipticalArc } = EllipseHelper;
|
|
2617
|
-
const debug$
|
|
2617
|
+
const debug$7 = Debug.get('PathConvert');
|
|
2618
2618
|
const setEndPoint$1 = {};
|
|
2619
2619
|
const PathConvert = {
|
|
2620
2620
|
current: { dot: 0 },
|
|
@@ -2855,7 +2855,7 @@ const PathConvert = {
|
|
|
2855
2855
|
i += 6;
|
|
2856
2856
|
break;
|
|
2857
2857
|
default:
|
|
2858
|
-
debug$
|
|
2858
|
+
debug$7.error(`command: ${command} [index:${i}]`, old);
|
|
2859
2859
|
return data;
|
|
2860
2860
|
}
|
|
2861
2861
|
lastCommand = command;
|
|
@@ -2964,12 +2964,10 @@ const PathCommandDataHelper = {
|
|
|
2964
2964
|
},
|
|
2965
2965
|
arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
|
|
2966
2966
|
if (lastX !== undefined) {
|
|
2967
|
-
const
|
|
2968
|
-
|
|
2969
|
-
}
|
|
2970
|
-
else {
|
|
2971
|
-
data.push(U$2, x1, y1, x2, y2, radius);
|
|
2967
|
+
const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
|
|
2968
|
+
radius = min(radius, min(d / 2, d / 2 * abs(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
|
|
2972
2969
|
}
|
|
2970
|
+
data.push(U$2, x1, y1, x2, y2, radius);
|
|
2973
2971
|
},
|
|
2974
2972
|
drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
|
|
2975
2973
|
BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation === undefined ? 0 : rotation, startAngle === undefined ? 0 : startAngle, endAngle === undefined ? 360 : endAngle, anticlockwise, null, null, startPoint);
|
|
@@ -3080,7 +3078,7 @@ class PathCreator {
|
|
|
3080
3078
|
}
|
|
3081
3079
|
|
|
3082
3080
|
const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
|
|
3083
|
-
const debug$
|
|
3081
|
+
const debug$6 = Debug.get('PathDrawer');
|
|
3084
3082
|
const PathDrawer = {
|
|
3085
3083
|
drawPathByData(drawer, data) {
|
|
3086
3084
|
if (!data)
|
|
@@ -3143,7 +3141,7 @@ const PathDrawer = {
|
|
|
3143
3141
|
i += 6;
|
|
3144
3142
|
break;
|
|
3145
3143
|
default:
|
|
3146
|
-
debug$
|
|
3144
|
+
debug$6.error(`command: ${command} [index:${i}]`, data);
|
|
3147
3145
|
return;
|
|
3148
3146
|
}
|
|
3149
3147
|
}
|
|
@@ -3153,7 +3151,7 @@ const PathDrawer = {
|
|
|
3153
3151
|
const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
|
|
3154
3152
|
const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse } = BezierHelper;
|
|
3155
3153
|
const { addPointBounds, copy: copy$4, addPoint, setPoint, addBounds, toBounds: toBounds$1 } = TwoPointBoundsHelper;
|
|
3156
|
-
const debug$
|
|
3154
|
+
const debug$5 = Debug.get('PathBounds');
|
|
3157
3155
|
let radius, radiusX, radiusY;
|
|
3158
3156
|
const tempPointBounds = {};
|
|
3159
3157
|
const setPointBounds = {};
|
|
@@ -3261,7 +3259,7 @@ const PathBounds = {
|
|
|
3261
3259
|
i += 6;
|
|
3262
3260
|
break;
|
|
3263
3261
|
default:
|
|
3264
|
-
debug$
|
|
3262
|
+
debug$5.error(`command: ${command} [index:${i}]`, data);
|
|
3265
3263
|
return;
|
|
3266
3264
|
}
|
|
3267
3265
|
}
|
|
@@ -3377,7 +3375,7 @@ const FileHelper = {
|
|
|
3377
3375
|
const F = FileHelper;
|
|
3378
3376
|
F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3379
3377
|
|
|
3380
|
-
const debug$
|
|
3378
|
+
const debug$4 = Debug.get('TaskProcessor');
|
|
3381
3379
|
class TaskItem {
|
|
3382
3380
|
constructor(task) {
|
|
3383
3381
|
this.parallel = true;
|
|
@@ -3386,13 +3384,13 @@ class TaskItem {
|
|
|
3386
3384
|
this.task = task;
|
|
3387
3385
|
}
|
|
3388
3386
|
run() {
|
|
3389
|
-
return __awaiter(this,
|
|
3387
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3390
3388
|
try {
|
|
3391
3389
|
if (this.task && !this.isComplete && this.parent.running)
|
|
3392
3390
|
yield this.task();
|
|
3393
3391
|
}
|
|
3394
3392
|
catch (error) {
|
|
3395
|
-
debug$
|
|
3393
|
+
debug$4.error(error);
|
|
3396
3394
|
}
|
|
3397
3395
|
});
|
|
3398
3396
|
}
|
|
@@ -3625,18 +3623,52 @@ class TaskProcessor {
|
|
|
3625
3623
|
}
|
|
3626
3624
|
}
|
|
3627
3625
|
|
|
3628
|
-
const
|
|
3626
|
+
const debug$3 = Debug.get('Resource');
|
|
3627
|
+
const Resource = {
|
|
3628
|
+
tasker: new TaskProcessor(),
|
|
3629
3629
|
map: {},
|
|
3630
|
+
get isComplete() { return R.tasker.isComplete; },
|
|
3631
|
+
set(key, value) {
|
|
3632
|
+
if (R.map[key])
|
|
3633
|
+
debug$3.repeat(key);
|
|
3634
|
+
R.map[key] = value;
|
|
3635
|
+
},
|
|
3636
|
+
get(key) {
|
|
3637
|
+
return R.map[key];
|
|
3638
|
+
},
|
|
3639
|
+
remove(key) {
|
|
3640
|
+
delete R.map[key];
|
|
3641
|
+
},
|
|
3642
|
+
loadImage(key, format) {
|
|
3643
|
+
return new Promise((resolve, reject) => {
|
|
3644
|
+
const image = this.setImage(key, key, format);
|
|
3645
|
+
image.load(() => resolve(image), (e) => reject(e));
|
|
3646
|
+
});
|
|
3647
|
+
},
|
|
3648
|
+
setImage(key, value, format) {
|
|
3649
|
+
let config;
|
|
3650
|
+
if (typeof value === 'string')
|
|
3651
|
+
config = { url: value };
|
|
3652
|
+
else if (!value.url)
|
|
3653
|
+
config = { url: key, view: value };
|
|
3654
|
+
if (config)
|
|
3655
|
+
format && (config.format = format), value = Creator.image(config);
|
|
3656
|
+
R.set(key, value);
|
|
3657
|
+
return value;
|
|
3658
|
+
},
|
|
3659
|
+
destroy() {
|
|
3660
|
+
R.map = {};
|
|
3661
|
+
}
|
|
3662
|
+
};
|
|
3663
|
+
const R = Resource;
|
|
3664
|
+
|
|
3665
|
+
const ImageManager = {
|
|
3630
3666
|
recycledList: [],
|
|
3631
|
-
tasker: new TaskProcessor(),
|
|
3632
3667
|
patternTasker: new TaskProcessor(),
|
|
3633
|
-
get isComplete() { return I.tasker.isComplete; },
|
|
3634
3668
|
get(config) {
|
|
3635
|
-
let image =
|
|
3636
|
-
if (!image)
|
|
3637
|
-
image = Creator.image(config);
|
|
3638
|
-
I.map[config.url] = image;
|
|
3639
|
-
}
|
|
3669
|
+
let image = Resource.get(config.url);
|
|
3670
|
+
if (!image)
|
|
3671
|
+
Resource.set(config.url, image = Creator.image(config));
|
|
3640
3672
|
image.use++;
|
|
3641
3673
|
return image;
|
|
3642
3674
|
},
|
|
@@ -3650,7 +3682,7 @@ const ImageManager = {
|
|
|
3650
3682
|
if (list.length > 100) {
|
|
3651
3683
|
list.forEach(image => {
|
|
3652
3684
|
if (!image.use && image.url) {
|
|
3653
|
-
|
|
3685
|
+
Resource.remove(image.url);
|
|
3654
3686
|
image.destroy();
|
|
3655
3687
|
}
|
|
3656
3688
|
});
|
|
@@ -3677,7 +3709,6 @@ const ImageManager = {
|
|
|
3677
3709
|
return false;
|
|
3678
3710
|
},
|
|
3679
3711
|
destroy() {
|
|
3680
|
-
I.map = {};
|
|
3681
3712
|
I.recycledList = [];
|
|
3682
3713
|
}
|
|
3683
3714
|
};
|
|
@@ -3691,21 +3722,19 @@ class LeaferImage {
|
|
|
3691
3722
|
this.use = 0;
|
|
3692
3723
|
this.waitComplete = [];
|
|
3693
3724
|
this.innerId = create$1(IMAGE);
|
|
3694
|
-
this.config = config || { url: '' };
|
|
3695
|
-
|
|
3696
|
-
|
|
3725
|
+
this.config = config || (config = { url: '' });
|
|
3726
|
+
if (config.view) {
|
|
3727
|
+
const { view } = config;
|
|
3728
|
+
this.setView(view.config ? view.view : view);
|
|
3729
|
+
}
|
|
3730
|
+
ImageManager.isFormat('svg', config) && (this.isSVG = true);
|
|
3731
|
+
ImageManager.hasOpacityPixel(config) && (this.hasOpacityPixel = true);
|
|
3697
3732
|
}
|
|
3698
3733
|
load(onSuccess, onError) {
|
|
3699
3734
|
if (!this.loading) {
|
|
3700
3735
|
this.loading = true;
|
|
3701
|
-
|
|
3702
|
-
return yield Platform.origin.loadImage(this.url).then((img) => {
|
|
3703
|
-
this.ready = true;
|
|
3704
|
-
this.width = img.naturalWidth || img.width;
|
|
3705
|
-
this.height = img.naturalHeight || img.height;
|
|
3706
|
-
this.view = img;
|
|
3707
|
-
this.onComplete(true);
|
|
3708
|
-
}).catch((e) => {
|
|
3736
|
+
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
3737
|
+
return yield Platform.origin.loadImage(this.url).then(img => this.setView(img)).catch((e) => {
|
|
3709
3738
|
this.error = e;
|
|
3710
3739
|
this.onComplete(false);
|
|
3711
3740
|
});
|
|
@@ -3723,6 +3752,13 @@ class LeaferImage {
|
|
|
3723
3752
|
}
|
|
3724
3753
|
l[index] = l[index + 1] = undefined;
|
|
3725
3754
|
}
|
|
3755
|
+
setView(img) {
|
|
3756
|
+
this.ready = true;
|
|
3757
|
+
this.width = img.naturalWidth || img.width;
|
|
3758
|
+
this.height = img.naturalHeight || img.height;
|
|
3759
|
+
this.view = img;
|
|
3760
|
+
this.onComplete(true);
|
|
3761
|
+
}
|
|
3726
3762
|
onComplete(isSuccess) {
|
|
3727
3763
|
let odd;
|
|
3728
3764
|
this.waitComplete.forEach((item, index) => {
|
|
@@ -3741,6 +3777,9 @@ class LeaferImage {
|
|
|
3741
3777
|
this.waitComplete.length = 0;
|
|
3742
3778
|
this.loading = false;
|
|
3743
3779
|
}
|
|
3780
|
+
getFull(_filters) {
|
|
3781
|
+
return this.view;
|
|
3782
|
+
}
|
|
3744
3783
|
getCanvas(width, height, opacity, _filters) {
|
|
3745
3784
|
width || (width = this.width);
|
|
3746
3785
|
height || (height = this.height);
|
|
@@ -5221,7 +5260,7 @@ const LeafRender = {
|
|
|
5221
5260
|
if (this.__.eraser === 'path')
|
|
5222
5261
|
return this.__renderEraser(canvas, options);
|
|
5223
5262
|
const tempCanvas = canvas.getSameCanvas(true, true);
|
|
5224
|
-
this.__draw(tempCanvas, options);
|
|
5263
|
+
this.__draw(tempCanvas, options, canvas);
|
|
5225
5264
|
if (this.__worldFlipped) {
|
|
5226
5265
|
canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, this.__.__blendMode, true);
|
|
5227
5266
|
}
|
|
@@ -6014,7 +6053,7 @@ class LeafLevelList {
|
|
|
6014
6053
|
}
|
|
6015
6054
|
}
|
|
6016
6055
|
|
|
6017
|
-
const version = "1.4.
|
|
6056
|
+
const version = "1.4.1";
|
|
6018
6057
|
|
|
6019
6058
|
exports.AlignHelper = AlignHelper;
|
|
6020
6059
|
exports.AroundHelper = AroundHelper;
|
|
@@ -6077,6 +6116,7 @@ exports.PropertyEvent = PropertyEvent;
|
|
|
6077
6116
|
exports.RectHelper = RectHelper;
|
|
6078
6117
|
exports.RenderEvent = RenderEvent;
|
|
6079
6118
|
exports.ResizeEvent = ResizeEvent;
|
|
6119
|
+
exports.Resource = Resource;
|
|
6080
6120
|
exports.Run = Run;
|
|
6081
6121
|
exports.StringNumberMap = StringNumberMap;
|
|
6082
6122
|
exports.TaskItem = TaskItem;
|