@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.module.js
CHANGED
|
@@ -7,6 +7,45 @@ var PathNodeHandleType;
|
|
|
7
7
|
PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
|
|
8
8
|
})(PathNodeHandleType || (PathNodeHandleType = {}));
|
|
9
9
|
|
|
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
|
+
|
|
16
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) {
|
|
18
|
+
return value instanceof P ? value : new P(function(resolve) {
|
|
19
|
+
resolve(value);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return new (P || (P = Promise))(function(resolve, reject) {
|
|
23
|
+
function fulfilled(value) {
|
|
24
|
+
try {
|
|
25
|
+
step(generator.next(value));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
reject(e);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function rejected(value) {
|
|
31
|
+
try {
|
|
32
|
+
step(generator["throw"](value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function step(result) {
|
|
38
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
39
|
+
}
|
|
40
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
45
|
+
var e = new Error(message);
|
|
46
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
47
|
+
};
|
|
48
|
+
|
|
10
49
|
var Answer;
|
|
11
50
|
|
|
12
51
|
(function(Answer) {
|
|
@@ -1897,7 +1936,10 @@ const UICreator = {
|
|
|
1897
1936
|
list$3[tag] = UI;
|
|
1898
1937
|
},
|
|
1899
1938
|
get(tag, data, x, y, width, height) {
|
|
1900
|
-
if (!list$3[tag])
|
|
1939
|
+
if (!list$3[tag]) {
|
|
1940
|
+
debug$h.warn("not register " + tag);
|
|
1941
|
+
return undefined;
|
|
1942
|
+
}
|
|
1901
1943
|
const ui = new list$3[tag](data);
|
|
1902
1944
|
if (!isUndefined(x)) {
|
|
1903
1945
|
ui.x = x;
|
|
@@ -1988,45 +2030,6 @@ class CanvasManager {
|
|
|
1988
2030
|
}
|
|
1989
2031
|
}
|
|
1990
2032
|
|
|
1991
|
-
function __decorate(decorators, target, key, desc) {
|
|
1992
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1993
|
-
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;
|
|
1994
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1998
|
-
function adopt(value) {
|
|
1999
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
2000
|
-
resolve(value);
|
|
2001
|
-
});
|
|
2002
|
-
}
|
|
2003
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
2004
|
-
function fulfilled(value) {
|
|
2005
|
-
try {
|
|
2006
|
-
step(generator.next(value));
|
|
2007
|
-
} catch (e) {
|
|
2008
|
-
reject(e);
|
|
2009
|
-
}
|
|
2010
|
-
}
|
|
2011
|
-
function rejected(value) {
|
|
2012
|
-
try {
|
|
2013
|
-
step(generator["throw"](value));
|
|
2014
|
-
} catch (e) {
|
|
2015
|
-
reject(e);
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
function step(result) {
|
|
2019
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
2020
|
-
}
|
|
2021
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
2026
|
-
var e = new Error(message);
|
|
2027
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2028
|
-
};
|
|
2029
|
-
|
|
2030
2033
|
function contextAttr(realName) {
|
|
2031
2034
|
return (target, key) => {
|
|
2032
2035
|
if (!realName) realName = key;
|
|
@@ -3754,10 +3757,10 @@ function canvasPatch(drawer) {
|
|
|
3754
3757
|
const FileHelper = {
|
|
3755
3758
|
alphaPixelTypes: [ "png", "webp", "svg" ],
|
|
3756
3759
|
upperCaseTypeMap: {},
|
|
3757
|
-
|
|
3758
|
-
if (!type || type.startsWith(
|
|
3760
|
+
mimeType(type, base = "image") {
|
|
3761
|
+
if (!type || type.startsWith(base)) return type;
|
|
3759
3762
|
if (type === "jpg") type = "jpeg";
|
|
3760
|
-
return "
|
|
3763
|
+
return base + "/" + type;
|
|
3761
3764
|
},
|
|
3762
3765
|
fileType(filename) {
|
|
3763
3766
|
const l = filename.split(".");
|
|
@@ -3790,6 +3793,8 @@ const FileHelper = {
|
|
|
3790
3793
|
|
|
3791
3794
|
const F$2 = FileHelper;
|
|
3792
3795
|
|
|
3796
|
+
F$2.mineType = F$2.mimeType;
|
|
3797
|
+
|
|
3793
3798
|
F$2.alphaPixelTypes.forEach(type => F$2.upperCaseTypeMap[type] = type.toUpperCase());
|
|
3794
3799
|
|
|
3795
3800
|
const debug$c = Debug.get("TaskProcessor");
|
|
@@ -4034,6 +4039,9 @@ const debug$b = Debug.get("Resource");
|
|
|
4034
4039
|
|
|
4035
4040
|
const Resource = {
|
|
4036
4041
|
tasker: new TaskProcessor,
|
|
4042
|
+
queue: new TaskProcessor({
|
|
4043
|
+
parallel: 1
|
|
4044
|
+
}),
|
|
4037
4045
|
map: {},
|
|
4038
4046
|
get isComplete() {
|
|
4039
4047
|
return R.tasker.isComplete;
|
|
@@ -4070,6 +4078,12 @@ const Resource = {
|
|
|
4070
4078
|
R.set(key, value);
|
|
4071
4079
|
return value;
|
|
4072
4080
|
},
|
|
4081
|
+
loadFilm(_key, _format) {
|
|
4082
|
+
return undefined;
|
|
4083
|
+
},
|
|
4084
|
+
loadVideo(_key, _format) {
|
|
4085
|
+
return undefined;
|
|
4086
|
+
},
|
|
4073
4087
|
destroy() {
|
|
4074
4088
|
R.map = {};
|
|
4075
4089
|
}
|
|
@@ -4080,12 +4094,10 @@ const R = Resource;
|
|
|
4080
4094
|
const ImageManager = {
|
|
4081
4095
|
maxRecycled: 10,
|
|
4082
4096
|
recycledList: [],
|
|
4083
|
-
patternTasker:
|
|
4084
|
-
|
|
4085
|
-
}),
|
|
4086
|
-
get(config) {
|
|
4097
|
+
patternTasker: Resource.queue,
|
|
4098
|
+
get(config, type) {
|
|
4087
4099
|
let image = Resource.get(config.url);
|
|
4088
|
-
if (!image) Resource.set(config.url, image = Creator.image(config));
|
|
4100
|
+
if (!image) Resource.set(config.url, image = type === "film" ? Creator.film(config) : Creator.image(config));
|
|
4089
4101
|
image.use++;
|
|
4090
4102
|
return image;
|
|
4091
4103
|
},
|
|
@@ -4120,7 +4132,7 @@ const ImageManager = {
|
|
|
4120
4132
|
if (config.format) return config.format === format;
|
|
4121
4133
|
const {url: url} = config;
|
|
4122
4134
|
if (url.startsWith("data:")) {
|
|
4123
|
-
if (url.startsWith("data:" + FileHelper.
|
|
4135
|
+
if (url.startsWith("data:" + FileHelper.mimeType(format))) return true;
|
|
4124
4136
|
} else {
|
|
4125
4137
|
if (url.includes("." + format) || url.includes("." + FileHelper.upperCaseTypeMap[format])) return true; else if (format === "png" && !url.includes(".")) return true;
|
|
4126
4138
|
}
|
|
@@ -4136,6 +4148,9 @@ const I$1 = ImageManager;
|
|
|
4136
4148
|
const {IMAGE: IMAGE, create: create$1} = IncrementId;
|
|
4137
4149
|
|
|
4138
4150
|
class LeaferImage {
|
|
4151
|
+
get tag() {
|
|
4152
|
+
return "Image";
|
|
4153
|
+
}
|
|
4139
4154
|
get url() {
|
|
4140
4155
|
return this.config.url;
|
|
4141
4156
|
}
|
|
@@ -4164,7 +4179,7 @@ class LeaferImage {
|
|
|
4164
4179
|
if (!this.loading) {
|
|
4165
4180
|
this.loading = true;
|
|
4166
4181
|
Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
|
|
4167
|
-
return yield Platform.origin.
|
|
4182
|
+
return yield Platform.origin["load" + this.tag](this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
|
|
4168
4183
|
if (thumbSize) this.setThumbView(img);
|
|
4169
4184
|
this.setView(img);
|
|
4170
4185
|
}).catch(e => {
|
|
@@ -4238,6 +4253,9 @@ class LeaferImage {
|
|
|
4238
4253
|
Platform.image.setPatternTransform(pattern, transform, paint);
|
|
4239
4254
|
return pattern;
|
|
4240
4255
|
}
|
|
4256
|
+
render(canvas, x, y, width, height, _leaf, _paint, _imageScaleX, _imageScaleY) {
|
|
4257
|
+
canvas.drawImage(this.view, x, y, width, height);
|
|
4258
|
+
}
|
|
4241
4259
|
getLoadUrl(_thumbSize) {
|
|
4242
4260
|
return this.url;
|
|
4243
4261
|
}
|
|
@@ -4264,6 +4282,18 @@ class LeaferImage {
|
|
|
4264
4282
|
}
|
|
4265
4283
|
}
|
|
4266
4284
|
|
|
4285
|
+
class LeaferFilm extends LeaferImage {
|
|
4286
|
+
get tag() {
|
|
4287
|
+
return "Film";
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4290
|
+
|
|
4291
|
+
class LeaferVideo extends LeaferImage {
|
|
4292
|
+
get tag() {
|
|
4293
|
+
return "Video";
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
|
|
4267
4297
|
function defineKey(target, key, descriptor, noConfigurable) {
|
|
4268
4298
|
if (!noConfigurable) descriptor.configurable = descriptor.enumerable = true;
|
|
4269
4299
|
Object.defineProperty(target, key, descriptor);
|
|
@@ -6152,9 +6182,11 @@ const BranchRender = {
|
|
|
6152
6182
|
if (this.__hasMask) {
|
|
6153
6183
|
this.__renderMask(canvas, options);
|
|
6154
6184
|
} else {
|
|
6185
|
+
let child;
|
|
6155
6186
|
const {children: children} = this;
|
|
6156
6187
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
6157
|
-
|
|
6188
|
+
child = children[i];
|
|
6189
|
+
excludeRenderBounds$1(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
|
|
6158
6190
|
}
|
|
6159
6191
|
}
|
|
6160
6192
|
},
|
|
@@ -6635,6 +6667,7 @@ let Leaf = class Leaf {
|
|
|
6635
6667
|
__drawHitPath(_canvas) {}
|
|
6636
6668
|
__updateHitCanvas() {}
|
|
6637
6669
|
__render(_canvas, _options) {}
|
|
6670
|
+
__renderComplex(_canvas, _options) {}
|
|
6638
6671
|
__drawFast(_canvas, _options) {}
|
|
6639
6672
|
__draw(_canvas, _options, _originCanvas) {}
|
|
6640
6673
|
__clip(_canvas, _options) {}
|
|
@@ -6754,6 +6787,7 @@ let Branch = class Branch extends Leaf {
|
|
|
6754
6787
|
this.add(item, index);
|
|
6755
6788
|
noIndex || index++;
|
|
6756
6789
|
}); else child = UICreator.get(child.tag, child);
|
|
6790
|
+
if (!child) return;
|
|
6757
6791
|
}
|
|
6758
6792
|
if (child.parent) child.parent.remove(child);
|
|
6759
6793
|
child.parent = this;
|
|
@@ -6979,7 +7013,7 @@ class LeafLevelList {
|
|
|
6979
7013
|
}
|
|
6980
7014
|
}
|
|
6981
7015
|
|
|
6982
|
-
const version = "2.0.
|
|
7016
|
+
const version = "2.0.2";
|
|
6983
7017
|
|
|
6984
7018
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6985
7019
|
get allowBackgroundColor() {
|
|
@@ -7005,8 +7039,6 @@ canvasPatch(OffscreenCanvasRenderingContext2D.prototype);
|
|
|
7005
7039
|
|
|
7006
7040
|
canvasPatch(Path2D.prototype);
|
|
7007
7041
|
|
|
7008
|
-
const {mineType: mineType} = FileHelper;
|
|
7009
|
-
|
|
7010
7042
|
Object.assign(Creator, {
|
|
7011
7043
|
canvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
7012
7044
|
image: options => new LeaferImage(options)
|
|
@@ -7017,7 +7049,7 @@ function useCanvas(_canvasType, _power) {
|
|
|
7017
7049
|
createCanvas: (width, height) => new OffscreenCanvas(width, height),
|
|
7018
7050
|
canvasToDataURL: (canvas, type, quality) => new Promise((resolve, reject) => {
|
|
7019
7051
|
canvas.convertToBlob({
|
|
7020
|
-
type:
|
|
7052
|
+
type: FileHelper.mimeType(type),
|
|
7021
7053
|
quality: quality
|
|
7022
7054
|
}).then(blob => {
|
|
7023
7055
|
var reader = new FileReader;
|
|
@@ -7029,14 +7061,14 @@ function useCanvas(_canvasType, _power) {
|
|
|
7029
7061
|
});
|
|
7030
7062
|
}),
|
|
7031
7063
|
canvasToBolb: (canvas, type, quality) => canvas.convertToBlob({
|
|
7032
|
-
type:
|
|
7064
|
+
type: FileHelper.mimeType(type),
|
|
7033
7065
|
quality: quality
|
|
7034
7066
|
}),
|
|
7035
7067
|
canvasSaveAs: (_canvas, _filename, _quality) => new Promise(resolve => resolve()),
|
|
7036
7068
|
download(_url, _filename) {
|
|
7037
7069
|
return undefined;
|
|
7038
7070
|
},
|
|
7039
|
-
loadImage(src) {
|
|
7071
|
+
loadImage(src, _crossOrigin, _leaferImage) {
|
|
7040
7072
|
return new Promise((resolve, reject) => {
|
|
7041
7073
|
let req = new XMLHttpRequest;
|
|
7042
7074
|
req.open("GET", Platform.image.getRealURL(src), true);
|
|
@@ -7051,6 +7083,13 @@ function useCanvas(_canvasType, _power) {
|
|
|
7051
7083
|
req.onerror = e => reject(e);
|
|
7052
7084
|
req.send();
|
|
7053
7085
|
});
|
|
7086
|
+
},
|
|
7087
|
+
loadContent(url_1) {
|
|
7088
|
+
return __awaiter(this, arguments, void 0, function*(url, responseType = "text") {
|
|
7089
|
+
const response = yield fetch(url);
|
|
7090
|
+
if (!response.ok) throw new Error(`${response.status}`);
|
|
7091
|
+
return yield response[responseType]();
|
|
7092
|
+
});
|
|
7054
7093
|
}
|
|
7055
7094
|
};
|
|
7056
7095
|
Platform.canvas = Creator.canvas();
|
|
@@ -7550,7 +7589,7 @@ class Renderer {
|
|
|
7550
7589
|
getCellList() {
|
|
7551
7590
|
return undefined;
|
|
7552
7591
|
}
|
|
7553
|
-
addBlock(block) {
|
|
7592
|
+
addBlock(block, _leafList) {
|
|
7554
7593
|
if (!this.updateBlocks) this.updateBlocks = [];
|
|
7555
7594
|
this.updateBlocks.push(block);
|
|
7556
7595
|
}
|
|
@@ -7598,7 +7637,8 @@ class Renderer {
|
|
|
7598
7637
|
__onLayoutEnd(event) {
|
|
7599
7638
|
if (event.data) event.data.map(item => {
|
|
7600
7639
|
let empty;
|
|
7601
|
-
|
|
7640
|
+
const {updatedList: updatedList} = item;
|
|
7641
|
+
if (updatedList) updatedList.list.some(leaf => {
|
|
7602
7642
|
empty = !leaf.__world.width || !leaf.__world.height;
|
|
7603
7643
|
if (empty) {
|
|
7604
7644
|
if (!leaf.isLeafer) debug$6.tip(leaf.innerName, ": empty");
|
|
@@ -7606,7 +7646,7 @@ class Renderer {
|
|
|
7606
7646
|
}
|
|
7607
7647
|
return empty;
|
|
7608
7648
|
});
|
|
7609
|
-
this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
|
|
7649
|
+
this.addBlock(empty ? this.canvas.bounds : item.updatedBounds, updatedList);
|
|
7610
7650
|
});
|
|
7611
7651
|
}
|
|
7612
7652
|
emitRender(type, bounds, options) {
|
|
@@ -8214,13 +8254,16 @@ class TextData extends UIData {
|
|
|
8214
8254
|
}
|
|
8215
8255
|
|
|
8216
8256
|
class ImageData extends RectData {
|
|
8257
|
+
get __urlType() {
|
|
8258
|
+
return "image";
|
|
8259
|
+
}
|
|
8217
8260
|
setUrl(value) {
|
|
8218
8261
|
this.__setImageFill(value);
|
|
8219
8262
|
this._url = value;
|
|
8220
8263
|
}
|
|
8221
8264
|
__setImageFill(value) {
|
|
8222
8265
|
this.fill = value ? {
|
|
8223
|
-
type:
|
|
8266
|
+
type: this.__urlType,
|
|
8224
8267
|
mode: "stretch",
|
|
8225
8268
|
url: value
|
|
8226
8269
|
} : undefined;
|
|
@@ -8720,7 +8763,10 @@ let Group = class Group extends UI {
|
|
|
8720
8763
|
}
|
|
8721
8764
|
toJSON(options) {
|
|
8722
8765
|
const data = super.toJSON(options);
|
|
8723
|
-
if (!this.childlessJSON)
|
|
8766
|
+
if (!this.childlessJSON) {
|
|
8767
|
+
const children = data.children = [];
|
|
8768
|
+
this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)));
|
|
8769
|
+
}
|
|
8724
8770
|
return data;
|
|
8725
8771
|
}
|
|
8726
8772
|
pick(_hitPoint, _options) {
|
|
@@ -8869,12 +8915,12 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8869
8915
|
this.emitLeafer(LeaferEvent.STOP);
|
|
8870
8916
|
}
|
|
8871
8917
|
}
|
|
8872
|
-
unlockLayout() {
|
|
8918
|
+
unlockLayout(updateLayout = true) {
|
|
8873
8919
|
this.layouter.start();
|
|
8874
|
-
this.updateLayout();
|
|
8920
|
+
if (updateLayout) this.updateLayout();
|
|
8875
8921
|
}
|
|
8876
|
-
lockLayout() {
|
|
8877
|
-
this.updateLayout();
|
|
8922
|
+
lockLayout(updateLayout = true) {
|
|
8923
|
+
if (updateLayout) this.updateLayout();
|
|
8878
8924
|
this.layouter.stop();
|
|
8879
8925
|
}
|
|
8880
8926
|
resize(size) {
|
|
@@ -10667,6 +10713,7 @@ class InteractionBase {
|
|
|
10667
10713
|
this.checkPath(data, useDefaultPath);
|
|
10668
10714
|
this.downTime = Date.now();
|
|
10669
10715
|
this.emit(PointerEvent.BEFORE_DOWN, data);
|
|
10716
|
+
if (data.path.needUpdate) this.updateDownData(data);
|
|
10670
10717
|
this.emit(PointerEvent.DOWN, data);
|
|
10671
10718
|
if (PointerButton.left(data)) {
|
|
10672
10719
|
this.tapWait();
|
|
@@ -11564,11 +11611,14 @@ function compute(attrName, ui) {
|
|
|
11564
11611
|
function getLeafPaint(attrName, paint, ui) {
|
|
11565
11612
|
if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
|
|
11566
11613
|
let leafPaint;
|
|
11567
|
-
const {boxBounds: boxBounds} = ui.__layout;
|
|
11568
|
-
switch (
|
|
11614
|
+
const {boxBounds: boxBounds} = ui.__layout, {type: type} = paint;
|
|
11615
|
+
switch (type) {
|
|
11569
11616
|
case "image":
|
|
11617
|
+
case "film":
|
|
11618
|
+
case "video":
|
|
11570
11619
|
if (!paint.url) return undefined;
|
|
11571
11620
|
leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
|
|
11621
|
+
if (type !== "image") PaintImage[type](leafPaint);
|
|
11572
11622
|
break;
|
|
11573
11623
|
|
|
11574
11624
|
case "linear":
|
|
@@ -11584,7 +11634,7 @@ function getLeafPaint(attrName, paint, ui) {
|
|
|
11584
11634
|
break;
|
|
11585
11635
|
|
|
11586
11636
|
case "solid":
|
|
11587
|
-
const {
|
|
11637
|
+
const {color: color, opacity: opacity} = paint;
|
|
11588
11638
|
leafPaint = {
|
|
11589
11639
|
type: type,
|
|
11590
11640
|
style: ColorConvert.string(color, opacity)
|
|
@@ -11628,7 +11678,7 @@ const {isSame: isSame} = BoundsHelper;
|
|
|
11628
11678
|
|
|
11629
11679
|
function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
11630
11680
|
let leafPaint, event;
|
|
11631
|
-
const image = ImageManager.get(paint);
|
|
11681
|
+
const image = ImageManager.get(paint, paint.type);
|
|
11632
11682
|
if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
|
|
11633
11683
|
leafPaint = cache.leafPaint;
|
|
11634
11684
|
} else {
|
|
@@ -11689,8 +11739,8 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
11689
11739
|
}
|
|
11690
11740
|
|
|
11691
11741
|
function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
|
|
11692
|
-
|
|
11693
|
-
|
|
11742
|
+
const data = ui.__;
|
|
11743
|
+
if (attrName === "fill" && !data.__naturalWidth) {
|
|
11694
11744
|
data.__naturalWidth = image.width / data.pixelRatio;
|
|
11695
11745
|
data.__naturalHeight = image.height / data.pixelRatio;
|
|
11696
11746
|
if (data.__autoSide) {
|
|
@@ -11702,7 +11752,12 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
|
|
|
11702
11752
|
return false;
|
|
11703
11753
|
}
|
|
11704
11754
|
}
|
|
11705
|
-
if (!leafPaint.data)
|
|
11755
|
+
if (!leafPaint.data) {
|
|
11756
|
+
PaintImage.createData(leafPaint, image, paint, boxBounds);
|
|
11757
|
+
const {transform: transform} = leafPaint.data, {opacity: opacity, blendMode: blendMode} = paint;
|
|
11758
|
+
const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
|
|
11759
|
+
if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
|
|
11760
|
+
}
|
|
11706
11761
|
return true;
|
|
11707
11762
|
}
|
|
11708
11763
|
|
|
@@ -11745,7 +11800,7 @@ function getPatternData(paint, box, image) {
|
|
|
11745
11800
|
if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
|
|
11746
11801
|
if (paint.mode === "strench") paint.mode = "stretch";
|
|
11747
11802
|
const {width: width, height: height} = image;
|
|
11748
|
-
const {
|
|
11803
|
+
const {mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, interlace: interlace} = paint;
|
|
11749
11804
|
const sameBox = box.width === width && box.height === height;
|
|
11750
11805
|
const data = {
|
|
11751
11806
|
mode: mode
|
|
@@ -11808,8 +11863,6 @@ function getPatternData(paint, box, image) {
|
|
|
11808
11863
|
data.scaleX = scaleX;
|
|
11809
11864
|
data.scaleY = scaleY;
|
|
11810
11865
|
}
|
|
11811
|
-
if (opacity && opacity < 1) data.opacity = opacity;
|
|
11812
|
-
if (filters) data.filters = filters;
|
|
11813
11866
|
if (repeat) data.repeat = isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
|
|
11814
11867
|
if (interlace) data.interlace = isNumber(interlace) || interlace.type === "percent" ? {
|
|
11815
11868
|
type: "x",
|
|
@@ -11840,7 +11893,7 @@ const {get: get$2, set: set, rotateOfOuter: rotateOfOuter$1, translate: translat
|
|
|
11840
11893
|
|
|
11841
11894
|
function stretchMode(data, box, scaleX, scaleY) {
|
|
11842
11895
|
const transform = get$2(), {x: x, y: y} = box;
|
|
11843
|
-
if (x || y) translate(transform, x, y); else transform.onlyScale = true;
|
|
11896
|
+
if (x || y) translate(transform, x, y); else if (scaleX > 0 && scaleY > 0) transform.onlyScale = true;
|
|
11844
11897
|
scaleHelper(transform, scaleX, scaleY);
|
|
11845
11898
|
data.transform = transform;
|
|
11846
11899
|
}
|
|
@@ -11929,10 +11982,10 @@ function createPatternTask(paint, ui, canvas, renderOptions) {
|
|
|
11929
11982
|
}
|
|
11930
11983
|
|
|
11931
11984
|
function createPattern(paint, ui, canvas, renderOptions) {
|
|
11932
|
-
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = scaleX + "-" + scaleY;
|
|
11985
|
+
let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
11933
11986
|
if (paint.patternId !== id && !ui.destroyed) {
|
|
11934
11987
|
if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
|
|
11935
|
-
const {image: image, data: data} = paint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
11988
|
+
const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
|
|
11936
11989
|
let imageMatrix, xGap, yGap, {width: width, height: height} = image;
|
|
11937
11990
|
if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
|
|
11938
11991
|
width *= scaleX;
|
|
@@ -11948,7 +12001,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
|
|
|
11948
12001
|
if (transform) copy$4(imageMatrix, transform);
|
|
11949
12002
|
scale$1(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
11950
12003
|
}
|
|
11951
|
-
const imageCanvas = image.getCanvas(width, height,
|
|
12004
|
+
const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
|
|
11952
12005
|
const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
|
|
11953
12006
|
paint.style = pattern;
|
|
11954
12007
|
paint.patternId = id;
|
|
@@ -11969,15 +12022,15 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
|
|
|
11969
12022
|
}
|
|
11970
12023
|
|
|
11971
12024
|
function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
11972
|
-
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
|
|
12025
|
+
const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
|
|
11973
12026
|
const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting, snapshot: snapshot} = renderOptions;
|
|
11974
|
-
if (!data || paint.patternId ===
|
|
12027
|
+
if (!data || paint.patternId === id && !exporting || snapshot) {
|
|
11975
12028
|
return false;
|
|
11976
12029
|
} else {
|
|
11977
12030
|
if (drawImage) {
|
|
11978
12031
|
if (data.repeat) {
|
|
11979
12032
|
drawImage = false;
|
|
11980
|
-
} else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
12033
|
+
} else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
|
|
11981
12034
|
drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
|
|
11982
12035
|
}
|
|
11983
12036
|
}
|
|
@@ -11995,20 +12048,21 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
|
|
|
11995
12048
|
}
|
|
11996
12049
|
}
|
|
11997
12050
|
|
|
11998
|
-
function drawImage(paint,
|
|
11999
|
-
const {data: data, image: image
|
|
12000
|
-
let {width: width, height: height} = image
|
|
12001
|
-
if (
|
|
12051
|
+
function drawImage(paint, imageScaleX, imageScaleY, ui, canvas, _renderOptions) {
|
|
12052
|
+
const {data: data, image: image, complex: complex} = paint;
|
|
12053
|
+
let {width: width, height: height} = image;
|
|
12054
|
+
if (complex) {
|
|
12055
|
+
const {blendMode: blendMode, opacity: opacity} = paint.originPaint, {transform: transform} = data;
|
|
12002
12056
|
canvas.save();
|
|
12003
|
-
|
|
12057
|
+
complex === 2 && canvas.clipUI(ui);
|
|
12004
12058
|
blendMode && (canvas.blendMode = blendMode);
|
|
12005
12059
|
opacity && (canvas.opacity *= opacity);
|
|
12006
12060
|
transform && canvas.transform(transform);
|
|
12007
|
-
|
|
12061
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
12008
12062
|
canvas.restore();
|
|
12009
12063
|
} else {
|
|
12010
12064
|
if (data.scaleX) width *= data.scaleX, height *= data.scaleY;
|
|
12011
|
-
|
|
12065
|
+
image.render(canvas, 0, 0, width, height, ui, paint, imageScaleX, imageScaleY);
|
|
12012
12066
|
}
|
|
12013
12067
|
}
|
|
12014
12068
|
|
|
@@ -13293,6 +13347,7 @@ class EditSelect extends Group {
|
|
|
13293
13347
|
} else {
|
|
13294
13348
|
editor.target = find;
|
|
13295
13349
|
}
|
|
13350
|
+
e.path.needUpdate = true;
|
|
13296
13351
|
} else if (this.allow(e.target)) {
|
|
13297
13352
|
if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null;
|
|
13298
13353
|
}
|
|
@@ -14511,6 +14566,7 @@ class SimulateElement extends Rect {
|
|
|
14511
14566
|
this.checkChange = true;
|
|
14512
14567
|
this.canChange = true;
|
|
14513
14568
|
this.visible = this.hittable = false;
|
|
14569
|
+
this.skipJSON = true;
|
|
14514
14570
|
this.on(PropertyEvent.CHANGE, event => {
|
|
14515
14571
|
if (this.checkChange && checkMap[event.attrName]) {
|
|
14516
14572
|
const {attrName: attrName, newValue: newValue, oldValue: oldValue} = event;
|
|
@@ -15713,9 +15769,14 @@ function addViewport(leafer, mergeConfig, custom) {
|
|
|
15713
15769
|
}), leafer.on_(MoveEvent.END, e => {
|
|
15714
15770
|
LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
|
|
15715
15771
|
}), leafer.on_(ZoomEvent.BEFORE_ZOOM, e => {
|
|
15716
|
-
const {zoomLayer: zoomLayer} = leafer;
|
|
15772
|
+
const {zoomLayer: zoomLayer, layouter: layouter} = leafer;
|
|
15717
15773
|
const changeScale = leafer.getValidScale(e.scale);
|
|
15718
|
-
if (changeScale !== 1)
|
|
15774
|
+
if (changeScale !== 1) {
|
|
15775
|
+
layouter.stop();
|
|
15776
|
+
LeafHelper.updateMatrix(leafer);
|
|
15777
|
+
zoomLayer.scaleOfWorld(e, changeScale);
|
|
15778
|
+
layouter.start();
|
|
15779
|
+
}
|
|
15719
15780
|
}));
|
|
15720
15781
|
}
|
|
15721
15782
|
|
|
@@ -17328,6 +17389,8 @@ function setFill(style, fill) {
|
|
|
17328
17389
|
break;
|
|
17329
17390
|
|
|
17330
17391
|
case "image":
|
|
17392
|
+
case "film":
|
|
17393
|
+
case "video":
|
|
17331
17394
|
break;
|
|
17332
17395
|
|
|
17333
17396
|
case "linear":
|
|
@@ -17660,4 +17723,4 @@ HTMLText = __decorate([ registerUI() ], HTMLText);
|
|
|
17660
17723
|
|
|
17661
17724
|
Plugin.add("html");
|
|
17662
17725
|
|
|
17663
|
-
export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
17726
|
+
export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferTypeCreator, LeaferVideo, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
|