@leafer-editor/worker 2.0.1 → 2.0.2
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/worker.js +151 -88
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +156 -93
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +17 -17
package/dist/worker.js
CHANGED
|
@@ -7,6 +7,42 @@ var LeaferUI = function(exports) {
|
|
|
7
7
|
PathNodeHandleType[PathNodeHandleType["mirrorAngle"] = 3] = "mirrorAngle";
|
|
8
8
|
PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
|
|
9
9
|
})(exports.PathNodeHandleType || (exports.PathNodeHandleType = {}));
|
|
10
|
+
function __decorate(decorators, target, key, desc) {
|
|
11
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
12
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
13
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
14
|
+
}
|
|
15
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
16
|
+
function adopt(value) {
|
|
17
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
22
|
+
function fulfilled(value) {
|
|
23
|
+
try {
|
|
24
|
+
step(generator.next(value));
|
|
25
|
+
} catch (e) {
|
|
26
|
+
reject(e);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function rejected(value) {
|
|
30
|
+
try {
|
|
31
|
+
step(generator["throw"](value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function step(result) {
|
|
37
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
38
|
+
}
|
|
39
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
43
|
+
var e = new Error(message);
|
|
44
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
45
|
+
};
|
|
10
46
|
exports.Answer = void 0;
|
|
11
47
|
(function(Answer) {
|
|
12
48
|
Answer[Answer["No"] = 0] = "No";
|
|
@@ -1803,7 +1839,10 @@ var LeaferUI = function(exports) {
|
|
|
1803
1839
|
list$3[tag] = UI;
|
|
1804
1840
|
},
|
|
1805
1841
|
get(tag, data, x, y, width, height) {
|
|
1806
|
-
if (!list$3[tag])
|
|
1842
|
+
if (!list$3[tag]) {
|
|
1843
|
+
debug$h.warn("not register " + tag);
|
|
1844
|
+
return undefined;
|
|
1845
|
+
}
|
|
1807
1846
|
const ui = new list$3[tag](data);
|
|
1808
1847
|
if (!isUndefined(x)) {
|
|
1809
1848
|
ui.x = x;
|
|
@@ -1888,42 +1927,6 @@ var LeaferUI = function(exports) {
|
|
|
1888
1927
|
this.clear();
|
|
1889
1928
|
}
|
|
1890
1929
|
}
|
|
1891
|
-
function __decorate(decorators, target, key, desc) {
|
|
1892
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1893
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1894
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1895
|
-
}
|
|
1896
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1897
|
-
function adopt(value) {
|
|
1898
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
1899
|
-
resolve(value);
|
|
1900
|
-
});
|
|
1901
|
-
}
|
|
1902
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1903
|
-
function fulfilled(value) {
|
|
1904
|
-
try {
|
|
1905
|
-
step(generator.next(value));
|
|
1906
|
-
} catch (e) {
|
|
1907
|
-
reject(e);
|
|
1908
|
-
}
|
|
1909
|
-
}
|
|
1910
|
-
function rejected(value) {
|
|
1911
|
-
try {
|
|
1912
|
-
step(generator["throw"](value));
|
|
1913
|
-
} catch (e) {
|
|
1914
|
-
reject(e);
|
|
1915
|
-
}
|
|
1916
|
-
}
|
|
1917
|
-
function step(result) {
|
|
1918
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1919
|
-
}
|
|
1920
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1921
|
-
});
|
|
1922
|
-
}
|
|
1923
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
1924
|
-
var e = new Error(message);
|
|
1925
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1926
|
-
};
|
|
1927
1930
|
function contextAttr(realName) {
|
|
1928
1931
|
return (target, key) => {
|
|
1929
1932
|
if (!realName) realName = key;
|
|
@@ -3523,10 +3526,10 @@ var LeaferUI = function(exports) {
|
|
|
3523
3526
|
const FileHelper = {
|
|
3524
3527
|
alphaPixelTypes: [ "png", "webp", "svg" ],
|
|
3525
3528
|
upperCaseTypeMap: {},
|
|
3526
|
-
|
|
3527
|
-
if (!type || type.startsWith(
|
|
3529
|
+
mimeType(type, base = "image") {
|
|
3530
|
+
if (!type || type.startsWith(base)) return type;
|
|
3528
3531
|
if (type === "jpg") type = "jpeg";
|
|
3529
|
-
return "
|
|
3532
|
+
return base + "/" + type;
|
|
3530
3533
|
},
|
|
3531
3534
|
fileType(filename) {
|
|
3532
3535
|
const l = filename.split(".");
|
|
@@ -3557,6 +3560,7 @@ var LeaferUI = function(exports) {
|
|
|
3557
3560
|
}
|
|
3558
3561
|
};
|
|
3559
3562
|
const F$2 = FileHelper;
|
|
3563
|
+
F$2.mineType = F$2.mimeType;
|
|
3560
3564
|
F$2.alphaPixelTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3561
3565
|
const debug$c = Debug.get("TaskProcessor");
|
|
3562
3566
|
class TaskItem {
|
|
@@ -3796,6 +3800,9 @@ var LeaferUI = function(exports) {
|
|
|
3796
3800
|
const debug$b = Debug.get("Resource");
|
|
3797
3801
|
const Resource = {
|
|
3798
3802
|
tasker: new TaskProcessor,
|
|
3803
|
+
queue: new TaskProcessor({
|
|
3804
|
+
parallel: 1
|
|
3805
|
+
}),
|
|
3799
3806
|
map: {},
|
|
3800
3807
|
get isComplete() {
|
|
3801
3808
|
return R.tasker.isComplete;
|
|
@@ -3832,6 +3839,12 @@ var LeaferUI = function(exports) {
|
|
|
3832
3839
|
R.set(key, value);
|
|
3833
3840
|
return value;
|
|
3834
3841
|
},
|
|
3842
|
+
loadFilm(_key, _format) {
|
|
3843
|
+
return undefined;
|
|
3844
|
+
},
|
|
3845
|
+
loadVideo(_key, _format) {
|
|
3846
|
+
return undefined;
|
|
3847
|
+
},
|
|
3835
3848
|
destroy() {
|
|
3836
3849
|
R.map = {};
|
|
3837
3850
|
}
|
|
@@ -3840,12 +3853,10 @@ var LeaferUI = function(exports) {
|
|
|
3840
3853
|
const ImageManager = {
|
|
3841
3854
|
maxRecycled: 10,
|
|
3842
3855
|
recycledList: [],
|
|
3843
|
-
patternTasker:
|
|
3844
|
-
|
|
3845
|
-
}),
|
|
3846
|
-
get(config) {
|
|
3856
|
+
patternTasker: Resource.queue,
|
|
3857
|
+
get(config, type) {
|
|
3847
3858
|
let image = Resource.get(config.url);
|
|
3848
|
-
if (!image) Resource.set(config.url, image = Creator.image(config));
|
|
3859
|
+
if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
|
|
3849
3860
|
image.use++;
|
|
3850
3861
|
return image;
|
|
3851
3862
|
},
|
|
@@ -3880,7 +3891,7 @@ var LeaferUI = function(exports) {
|
|
|
3880
3891
|
if (config.format) return config.format === format;
|
|
3881
3892
|
const {url: url} = config;
|
|
3882
3893
|
if (url.startsWith("data:")) {
|
|
3883
|
-
if (url.startsWith("data:" + FileHelper.
|
|
3894
|
+
if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
|
|
3884
3895
|
} else {
|
|
3885
3896
|
if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
|
|
3886
3897
|
}
|
|
@@ -3893,6 +3904,9 @@ var LeaferUI = function(exports) {
|
|
|
3893
3904
|
const I$1 = ImageManager;
|
|
3894
3905
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
3895
3906
|
class LeaferImage {
|
|
3907
|
+
get tag() {
|
|
3908
|
+
return "Image";
|
|
3909
|
+
}
|
|
3896
3910
|
get url() {
|
|
3897
3911
|
return this.config.url;
|
|
3898
3912
|
}
|
|
@@ -3921,7 +3935,7 @@ var LeaferUI = function(exports) {
|
|
|
3921
3935
|
if (!this.loading) {
|
|
3922
3936
|
this.loading = true;
|
|
3923
3937
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
3924
|
-
return yield Platform.origin.
|
|
3938
|
+
return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
3925
3939
|
if (thumbSize) this.setThumbView(img);
|
|
3926
3940
|
this.setView(img);
|
|
3927
3941
|
}).catch(e => {
|
|
@@ -3995,6 +4009,9 @@ var LeaferUI = function(exports) {
|
|
|
3995
4009
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
3996
4010
|
return pattern;
|
|
3997
4011
|
}
|
|
4012
|
+
render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
|
|
4013
|
+
canvas.drawImage(this.view, x, y, width, height);
|
|
4014
|
+
}
|
|
3998
4015
|
getLoadUrl(_thumbSize) {
|
|
3999
4016
|
return this.url;
|
|
4000
4017
|
}
|
|
@@ -4020,6 +4037,16 @@ var LeaferUI = function(exports) {
|
|
|
4020
4037
|
this.waitComplete.length = 0;
|
|
4021
4038
|
}
|
|
4022
4039
|
}
|
|
4040
|
+
class LeaferFilm extends LeaferImage {
|
|
4041
|
+
get tag() {
|
|
4042
|
+
return "Film";
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
class LeaferVideo extends LeaferImage {
|
|
4046
|
+
get tag() {
|
|
4047
|
+
return "Video";
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4023
4050
|
function defineKey(target, key, descriptor, noConfigurable) {
|
|
4024
4051
|
if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
|
|
4025
4052
|
Object.defineProperty(target, key, descriptor);
|
|
@@ -5758,9 +5785,11 @@ var LeaferUI = function(exports) {
|
|
|
5758
5785
|
if (this.__hasMask) {
|
|
5759
5786
|
this.__renderMask(canvas, options);
|
|
5760
5787
|
} else {
|
|
5788
|
+
let child;
|
|
5761
5789
|
const {children: children} = this;
|
|
5762
5790
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
5763
|
-
|
|
5791
|
+
child = children[i];
|
|
5792
|
+
excludeRenderBounds$1(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
|
|
5764
5793
|
}
|
|
5765
5794
|
}
|
|
5766
5795
|
},
|
|
@@ -6233,6 +6262,7 @@ var LeaferUI = function(exports) {
|
|
|
6233
6262
|
__drawHitPath(_canvas) {}
|
|
6234
6263
|
__updateHitCanvas() {}
|
|
6235
6264
|
__render(_canvas, _options) {}
|
|
6265
|
+
__renderComplex(_canvas, _options) {}
|
|
6236
6266
|
__drawFast(_canvas, _options) {}
|
|
6237
6267
|
__draw(_canvas, _options, _originCanvas) {}
|
|
6238
6268
|
__clip(_canvas, _options) {}
|
|
@@ -6346,6 +6376,7 @@ var LeaferUI = function(exports) {
|
|
|
6346
6376
|
this.add(item, index);
|
|
6347
6377
|
noIndex || index++;
|
|
6348
6378
|
}); else child = UICreator.get(child.tag, child);
|
|
6379
|
+
if (!child) return;
|
|
6349
6380
|
}
|
|
6350
6381
|
if (child.parent) child.parent.remove(child);
|
|
6351
6382
|
child.parent = this;
|
|
@@ -6567,7 +6598,7 @@ var LeaferUI = function(exports) {
|
|
|
6567
6598
|
this.levelMap = null;
|
|
6568
6599
|
}
|
|
6569
6600
|
}
|
|
6570
|
-
const version = "2.0.
|
|
6601
|
+
const version = "2.0.2";
|
|
6571
6602
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6572
6603
|
get allowBackgroundColor() {
|
|
6573
6604
|
return true;
|
|
@@ -6589,7 +6620,6 @@ var LeaferUI = function(exports) {
|
|
|
6589
6620
|
}
|
|
6590
6621
|
canvasPatch(OffscreenCanvasRenderingContext2D.prototype);
|
|
6591
6622
|
canvasPatch(Path2D.prototype);
|
|
6592
|
-
const {mineType: mineType} = FileHelper;
|
|
6593
6623
|
Object.assign(Creator, {
|
|
6594
6624
|
canvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
6595
6625
|
image: options => new LeaferImage(options)
|
|
@@ -6599,7 +6629,7 @@ var LeaferUI = function(exports) {
|
|
|
6599
6629
|
createCanvas: (width, height) => new OffscreenCanvas(width, height),
|
|
6600
6630
|
canvasToDataURL: (canvas, type, quality) => new Promise((resolve, reject) => {
|
|
6601
6631
|
canvas.convertToBlob({
|
|
6602
|
-
type:
|
|
6632
|
+
type: FileHelper.mimeType(type),
|
|
6603
6633
|
quality: quality
|
|
6604
6634
|
}).then(blob => {
|
|
6605
6635
|
var reader = new FileReader;
|
|
@@ -6611,14 +6641,14 @@ var LeaferUI = function(exports) {
|
|
|
6611
6641
|
});
|
|
6612
6642
|
}),
|
|
6613
6643
|
canvasToBolb: (canvas, type, quality) => canvas.convertToBlob({
|
|
6614
|
-
type:
|
|
6644
|
+
type: FileHelper.mimeType(type),
|
|
6615
6645
|
quality: quality
|
|
6616
6646
|
}),
|
|
6617
6647
|
canvasSaveAs: (_canvas, _filename, _quality) => new Promise(resolve => resolve()),
|
|
6618
6648
|
download(_url, _filename) {
|
|
6619
6649
|
return undefined;
|
|
6620
6650
|
},
|
|
6621
|
-
loadImage(src) {
|
|
6651
|
+
loadImage(src, _crossOrigin, _leaferImage) {
|
|
6622
6652
|
return new Promise((resolve, reject) => {
|
|
6623
6653
|
let req = new XMLHttpRequest;
|
|
6624
6654
|
req.open("GET", Platform.image.getRealURL(src), true);
|
|
@@ -6633,6 +6663,13 @@ var LeaferUI = function(exports) {
|
|
|
6633
6663
|
req.onerror = e => reject(e);
|
|
6634
6664
|
req.send();
|
|
6635
6665
|
});
|
|
6666
|
+
},
|
|
6667
|
+
loadContent(url_1) {
|
|
6668
|
+
return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
|
|
6669
|
+
const response = yield fetch(url);
|
|
6670
|
+
if (!response.ok) throw new Error(`${response.status}`);
|
|
6671
|
+
return yield response[responseType]();
|
|
6672
|
+
});
|
|
6636
6673
|
}
|
|
6637
6674
|
};
|
|
6638
6675
|
Platform.canvas = Creator.canvas();
|
|
@@ -7111,7 +7148,7 @@ var LeaferUI = function(exports) {
|
|
|
7111
7148
|
getCellList() {
|
|
7112
7149
|
return undefined;
|
|
7113
7150
|
}
|
|
7114
|
-
addBlock(block) {
|
|
7151
|
+
addBlock(block, _leafList) {
|
|
7115
7152
|
if (!this.updateBlocks) this.updateBlocks = [];
|
|
7116
7153
|
this.updateBlocks.push(block);
|
|
7117
7154
|
}
|
|
@@ -7159,7 +7196,8 @@ var LeaferUI = function(exports) {
|
|
|
7159
7196
|
__onLayoutEnd(event) {
|
|
7160
7197
|
if (event.data) event.data.map(item => {
|
|
7161
7198
|
let empty;
|
|
7162
|
-
|
|
7199
|
+
const {updatedList: updatedList} = item;
|
|
7200
|
+
if (updatedList) updatedList.list.some(leaf => {
|
|
7163
7201
|
empty = !leaf.__world.width || !leaf.__world.height;
|
|
7164
7202
|
if (empty) {
|
|
7165
7203
|
if (!leaf.isLeafer) debug$6.tip(leaf.innerName, ": empty");
|
|
@@ -7167,7 +7205,7 @@ var LeaferUI = function(exports) {
|
|
|
7167
7205
|
}
|
|
7168
7206
|
return empty;
|
|
7169
7207
|
});
|
|
7170
|
-
this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
|
|
7208
|
+
this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
|
|
7171
7209
|
});
|
|
7172
7210
|
}
|
|
7173
7211
|
emitRender(type, bounds, options) {
|
|
@@ -7729,13 +7767,16 @@ var LeaferUI = function(exports) {
|
|
|
7729
7767
|
}
|
|
7730
7768
|
}
|
|
7731
7769
|
class ImageData extends RectData {
|
|
7770
|
+
get __urlType() {
|
|
7771
|
+
return "image";
|
|
7772
|
+
}
|
|
7732
7773
|
setUrl(value) {
|
|
7733
7774
|
this.__setImageFill(value);
|
|
7734
7775
|
this._url = value;
|
|
7735
7776
|
}
|
|
7736
7777
|
__setImageFill(value) {
|
|
7737
7778
|
this.fill = value ? {
|
|
7738
|
-
type:
|
|
7779
|
+
type: this.__urlType,
|
|
7739
7780
|
mode: "stretch",
|
|
7740
7781
|
url: value
|
|
7741
7782
|
} : undefined;
|
|
@@ -8151,7 +8192,10 @@ var LeaferUI = function(exports) {
|
|
|
8151
8192
|
}
|
|
8152
8193
|
toJSON(options) {
|
|
8153
8194
|
const data = super.toJSON(options);
|
|
8154
|
-
if (!this.childlessJSON)
|
|
8195
|
+
if (!this.childlessJSON) {
|
|
8196
|
+
const children = data.children = [];
|
|
8197
|
+
this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
|
|
8198
|
+
}
|
|
8155
8199
|
return data;
|
|
8156
8200
|
}
|
|
8157
8201
|
pick(_hitPoint, _options) {
|
|
@@ -8293,12 +8337,12 @@ var LeaferUI = function(exports) {
|
|
|
8293
8337
|
this.emitLeafer(LeaferEvent.STOP);
|
|
8294
8338
|
}
|
|
8295
8339
|
}
|
|
8296
|
-
unlockLayout() {
|
|
8340
|
+
unlockLayout(updateLayout = true) {
|
|
8297
8341
|
this.layouter.start();
|
|
8298
|
-
this.updateLayout();
|
|
8342
|
+
if (updateLayout) this.updateLayout();
|
|
8299
8343
|
}
|
|
8300
|
-
lockLayout() {
|
|
8301
|
-
this.updateLayout();
|
|
8344
|
+
lockLayout(updateLayout = true) {
|
|
8345
|
+
if (updateLayout) this.updateLayout();
|
|
8302
8346
|
this.layouter.stop();
|
|
8303
8347
|
}
|
|
8304
8348
|
resize(size) {
|
|
@@ -9877,6 +9921,7 @@ var LeaferUI = function(exports) {
|
|
|
9877
9921
|
this.checkPath(data, useDefaultPath);
|
|
9878
9922
|
this.downTime = Date.now();
|
|
9879
9923
|
this.emit(exports.PointerEvent.BEFORE_DOWN, data);
|
|
9924
|
+
if (data.path.needUpdate) this.updateDownData(data);
|
|
9880
9925
|
this.emit(exports.PointerEvent.DOWN, data);
|
|
9881
9926
|
if (PointerButton.left(data)) {
|
|
9882
9927
|
this.tapWait();
|
|
@@ -10726,11 +10771,14 @@ var LeaferUI = function(exports) {
|
|
|
10726
10771
|
function getLeafPaint(attrName, paint, ui) {
|
|
10727
10772
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
10728
10773
|
let leafPaint;
|
|
10729
|
-
const {boxBounds: boxBounds} = ui.__layout;
|
|
10730
|
-
switch (
|
|
10774
|
+
const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
|
|
10775
|
+
switch (type) {
|
|
10731
10776
|
case "image":
|
|
10777
|
+
case "film":
|
|
10778
|
+
case "video":
|
|
10732
10779
|
if (!paint.url) return undefined;
|
|
10733
10780
|
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
10781
|
+
if (type !== "image") PaintImage[type](leafPaint);
|
|
10734
10782
|
break;
|
|
10735
10783
|
|
|
10736
10784
|
case "linear":
|
|
@@ -10746,7 +10794,7 @@ var LeaferUI = function(exports) {
|
|
|
10746
10794
|
break;
|
|
10747
10795
|
|
|
10748
10796
|
case "solid":
|
|
10749
|
-
const {
|
|
10797
|
+
const {color: color, opacity: opacity} = paint;
|
|
10750
10798
|
leafPaint = {
|
|
10751
10799
|
type: type,
|
|
10752
10800
|
style: ColorConvert.string(color, opacity)
|
|
@@ -10786,7 +10834,7 @@ var LeaferUI = function(exports) {
|
|
|
10786
10834
|
const {isSame: isSame} = BoundsHelper;
|
|
10787
10835
|
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
10788
10836
|
let leafPaint, event;
|
|
10789
|
-
const image = ImageManager.get(paint);
|
|
10837
|
+
const image = ImageManager.get(paint, paint.type);
|
|
10790
10838
|
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
10791
10839
|
leafPaint = cache.leafPaint;
|
|
10792
10840
|
} else {
|
|
@@ -10846,8 +10894,8 @@ var LeaferUI = function(exports) {
|
|
|
10846
10894
|
return leafPaint;
|
|
10847
10895
|
}
|
|
10848
10896
|
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
10849
|
-
|
|
10850
|
-
|
|
10897
|
+
const data = ui.__;
|
|
10898
|
+
if (attrName === "fill" && !data.__naturalWidth) {
|
|
10851
10899
|
data.__naturalWidth = image.width / data.pixelRatio;
|
|
10852
10900
|
data.__naturalHeight = image.height / data.pixelRatio;
|
|
10853
10901
|
if (data.__autoSide) {
|
|
@@ -10859,7 +10907,12 @@ var LeaferUI = function(exports) {
|
|
|
10859
10907
|
return false;
|
|
10860
10908
|
}
|
|
10861
10909
|
}
|
|
10862
|
-
if (!leafPaint.data)
|
|
10910
|
+
if (!leafPaint.data) {
|
|
10911
|
+
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
10912
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
|
|
10913
|
+
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
10914
|
+
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
10915
|
+
}
|
|
10863
10916
|
return true;
|
|
10864
10917
|
}
|
|
10865
10918
|
function onLoad(ui, event) {
|
|
@@ -10891,7 +10944,7 @@ var LeaferUI = function(exports) {
|
|
|
10891
10944
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
10892
10945
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
10893
10946
|
const {width: width, height: height} = image;
|
|
10894
|
-
const {
|
|
10947
|
+
const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
|
|
10895
10948
|
const sameBox = box.width === width && box.height === height;
|
|
10896
10949
|
const data = {
|
|
10897
10950
|
mode: mode
|
|
@@ -10954,8 +11007,6 @@ var LeaferUI = function(exports) {
|
|
|
10954
11007
|
data.scaleX = scaleX;
|
|
10955
11008
|
data.scaleY = scaleY;
|
|
10956
11009
|
}
|
|
10957
|
-
if (opacity && opacity < 1) data.opacity = opacity;
|
|
10958
|
-
if (filters) data.filters = filters;
|
|
10959
11010
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
10960
11011
|
if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
|
|
10961
11012
|
type: "x",
|
|
@@ -10981,7 +11032,7 @@ var LeaferUI = function(exports) {
|
|
|
10981
11032
|
const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translate, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper} = MatrixHelper;
|
|
10982
11033
|
function stretchMode(data, box, scaleX, scaleY) {
|
|
10983
11034
|
const transform = get$2(), {x: x, y: y} = box;
|
|
10984
|
-
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
11035
|
+
if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
|
|
10985
11036
|
scaleHelper(transform, scaleX, scaleY);
|
|
10986
11037
|
data.transform = transform;
|
|
10987
11038
|
}
|
|
@@ -11062,10 +11113,10 @@ var LeaferUI = function(exports) {
|
|
|
11062
11113
|
}
|
|
11063
11114
|
}
|
|
11064
11115
|
function createPattern(paint, ui, canvas, renderOptions) {
|
|
11065
|
-
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
11116
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
11066
11117
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
11067
11118
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
11068
|
-
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
11119
|
+
const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
11069
11120
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
11070
11121
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
11071
11122
|
width *= scaleX;
|
|
@@ -11081,7 +11132,7 @@ var LeaferUI = function(exports) {
|
|
|
11081
11132
|
if (transform) copy$4(imageMatrix, transform);
|
|
11082
11133
|
scale$1(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
11083
11134
|
}
|
|
11084
|
-
const imageCanvas = image.getCanvas(width, height,
|
|
11135
|
+
const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
11085
11136
|
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
11086
11137
|
paint.style = pattern;
|
|
11087
11138
|
paint.patternId = id;
|
|
@@ -11100,15 +11151,15 @@ var LeaferUI = function(exports) {
|
|
|
11100
11151
|
return fixScale;
|
|
11101
11152
|
}
|
|
11102
11153
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
11103
|
-
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
11154
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
11104
11155
|
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
11105
|
-
if (!data || paint.patternId ===
|
|
11156
|
+
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
11106
11157
|
return false;
|
|
11107
11158
|
} else {
|
|
11108
11159
|
if (drawImage) {
|
|
11109
11160
|
if (data.repeat) {
|
|
11110
11161
|
drawImage = false;
|
|
11111
|
-
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
11162
|
+
} else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
11112
11163
|
drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
|
|
11113
11164
|
}
|
|
11114
11165
|
}
|
|
@@ -11125,20 +11176,21 @@ var LeaferUI = function(exports) {
|
|
|
11125
11176
|
}
|
|
11126
11177
|
}
|
|
11127
11178
|
}
|
|
11128
|
-
function drawImage(paint,
|
|
11129
|
-
const {data: data, image: image
|
|
11130
|
-
let {width: width, height: height} = image
|
|
11131
|
-
if (
|
|
11179
|
+
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
11180
|
+
const {data: data, image: image, complex: complex} = paint;
|
|
11181
|
+
let {width: width, height: height} = image;
|
|
11182
|
+
if (complex) {
|
|
11183
|
+
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
11132
11184
|
canvas.save();
|
|
11133
|
-
|
|
11185
|
+
complex === 2 && canvas.clipUI(ui);
|
|
11134
11186
|
blendMode && (canvas.blendMode = blendMode);
|
|
11135
11187
|
opacity && (canvas.opacity *= opacity);
|
|
11136
11188
|
transform && canvas.transform(transform);
|
|
11137
|
-
|
|
11189
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
11138
11190
|
canvas.restore();
|
|
11139
11191
|
} else {
|
|
11140
11192
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
11141
|
-
|
|
11193
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
11142
11194
|
}
|
|
11143
11195
|
}
|
|
11144
11196
|
function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
|
|
@@ -12297,6 +12349,7 @@ var LeaferUI = function(exports) {
|
|
|
12297
12349
|
} else {
|
|
12298
12350
|
editor.target = find;
|
|
12299
12351
|
}
|
|
12352
|
+
e.path.needUpdate = true;
|
|
12300
12353
|
} else if (this.allow(e.target)) {
|
|
12301
12354
|
if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null;
|
|
12302
12355
|
}
|
|
@@ -13469,6 +13522,7 @@ var LeaferUI = function(exports) {
|
|
|
13469
13522
|
this.checkChange = true;
|
|
13470
13523
|
this.canChange = true;
|
|
13471
13524
|
this.visible = this.hittable = false;
|
|
13525
|
+
this.skipJSON = true;
|
|
13472
13526
|
this.on(PropertyEvent.CHANGE, event => {
|
|
13473
13527
|
if (this.checkChange && checkMap[event.attrName]) {
|
|
13474
13528
|
const {attrName: attrName, newValue: newValue, oldValue: oldValue} = event;
|
|
@@ -14611,9 +14665,14 @@ var LeaferUI = function(exports) {
|
|
|
14611
14665
|
}), leafer.on_(exports.MoveEvent.END, e => {
|
|
14612
14666
|
LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
|
|
14613
14667
|
}), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, e => {
|
|
14614
|
-
const {zoomLayer: zoomLayer} = leafer;
|
|
14668
|
+
const {zoomLayer: zoomLayer, layouter: layouter} = leafer;
|
|
14615
14669
|
const changeScale = leafer.getValidScale(e.scale);
|
|
14616
|
-
if (changeScale !== 1)
|
|
14670
|
+
if (changeScale !== 1) {
|
|
14671
|
+
layouter.stop();
|
|
14672
|
+
LeafHelper.updateMatrix(leafer);
|
|
14673
|
+
zoomLayer.scaleOfWorld(e, changeScale);
|
|
14674
|
+
layouter.start();
|
|
14675
|
+
}
|
|
14617
14676
|
}));
|
|
14618
14677
|
}
|
|
14619
14678
|
function addViewportConfig(leafer, mergeConfig) {
|
|
@@ -16102,6 +16161,8 @@ var LeaferUI = function(exports) {
|
|
|
16102
16161
|
break;
|
|
16103
16162
|
|
|
16104
16163
|
case "image":
|
|
16164
|
+
case "film":
|
|
16165
|
+
case "video":
|
|
16105
16166
|
break;
|
|
16106
16167
|
|
|
16107
16168
|
case "linear":
|
|
@@ -16496,8 +16557,10 @@ var LeaferUI = function(exports) {
|
|
|
16496
16557
|
exports.LeaferCanvasBase = LeaferCanvasBase;
|
|
16497
16558
|
exports.LeaferData = LeaferData;
|
|
16498
16559
|
exports.LeaferEvent = LeaferEvent;
|
|
16560
|
+
exports.LeaferFilm = LeaferFilm;
|
|
16499
16561
|
exports.LeaferImage = LeaferImage;
|
|
16500
16562
|
exports.LeaferTypeCreator = LeaferTypeCreator;
|
|
16563
|
+
exports.LeaferVideo = LeaferVideo;
|
|
16501
16564
|
exports.LineData = LineData;
|
|
16502
16565
|
exports.MathHelper = MathHelper;
|
|
16503
16566
|
exports.Matrix = Matrix;
|