@leafer-ui/node 1.8.0 → 1.9.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/dist/node.cjs CHANGED
@@ -1,44 +1,50 @@
1
- 'use strict';
2
-
3
- var core = require('@leafer/core');
4
- var fs = require('fs');
5
- var core$1 = require('@leafer-ui/core');
6
- var draw = require('@leafer-ui/draw');
7
-
8
- /******************************************************************************
9
- Copyright (c) Microsoft Corporation.
10
-
11
- Permission to use, copy, modify, and/or distribute this software for any
12
- purpose with or without fee is hereby granted.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
- PERFORMANCE OF THIS SOFTWARE.
21
- ***************************************************************************** */
22
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
23
-
24
-
25
- function __awaiter(thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- }
34
-
35
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
36
- var e = new Error(message);
37
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
1
+ "use strict";
2
+
3
+ var core = require("@leafer/core");
4
+
5
+ var fs = require("fs");
6
+
7
+ var core$1 = require("@leafer-ui/core");
8
+
9
+ var draw = require("@leafer-ui/draw");
10
+
11
+ function __awaiter(thisArg, _arguments, P, generator) {
12
+ function adopt(value) {
13
+ return value instanceof P ? value : new P(function(resolve) {
14
+ resolve(value);
15
+ });
16
+ }
17
+ return new (P || (P = Promise))(function(resolve, reject) {
18
+ function fulfilled(value) {
19
+ try {
20
+ step(generator.next(value));
21
+ } catch (e) {
22
+ reject(e);
23
+ }
24
+ }
25
+ function rejected(value) {
26
+ try {
27
+ step(generator["throw"](value));
28
+ } catch (e) {
29
+ reject(e);
30
+ }
31
+ }
32
+ function step(result) {
33
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
34
+ }
35
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
36
+ });
37
+ }
38
+
39
+ typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
40
+ var e = new Error(message);
41
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
38
42
  };
39
43
 
40
44
  class LeaferCanvas extends core.LeaferCanvasBase {
41
- get allowBackgroundColor() { return true; }
45
+ get allowBackgroundColor() {
46
+ return true;
47
+ }
42
48
  init() {
43
49
  this.__createView();
44
50
  this.__createContext();
@@ -52,84 +58,114 @@ class LeaferCanvas extends core.LeaferCanvasBase {
52
58
  this.view = core.Platform.origin.createCanvas(1, 1);
53
59
  }
54
60
  updateViewSize() {
55
- const { width, height, pixelRatio } = this;
61
+ const {width: width, height: height, pixelRatio: pixelRatio} = this;
56
62
  this.view.width = Math.ceil(width * pixelRatio);
57
63
  this.view.height = Math.ceil(height * pixelRatio);
58
64
  this.clientBounds = this.bounds;
59
65
  }
60
66
  }
61
67
 
62
- const { mineType, fileType } = core.FileHelper;
68
+ const {mineType: mineType, fileType: fileType} = core.FileHelper;
69
+
63
70
  Object.assign(core.Creator, {
64
71
  canvas: (options, manager) => new LeaferCanvas(options, manager),
65
- image: (options) => new core.LeaferImage(options)
72
+ image: options => new core.LeaferImage(options)
66
73
  });
74
+
67
75
  function useCanvas(canvasType, power) {
68
76
  core.Platform.canvasType = canvasType;
69
77
  if (!core.Platform.origin) {
70
- if (canvasType === 'skia') {
71
- const { Canvas, loadImage } = power;
78
+ if (canvasType === "skia") {
79
+ const {Canvas: Canvas, loadImage: loadImage} = power;
72
80
  core.Platform.origin = {
73
81
  createCanvas: (width, height, format) => new Canvas(width, height, format),
74
- canvasToDataURL: (canvas, type, quality) => canvas.toDataURLSync(type, { quality }),
75
- canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
76
- canvasSaveAs: (canvas, filename, quality) => canvas.saveAs(filename, { quality }),
77
- download(_url, _filename) { return undefined; },
78
- loadImage(src) { return loadImage(core.Platform.image.getRealURL(src)); }
82
+ canvasToDataURL: (canvas, type, quality) => canvas.toDataURLSync(type, {
83
+ quality: quality
84
+ }),
85
+ canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, {
86
+ quality: quality
87
+ }),
88
+ canvasSaveAs: (canvas, filename, quality) => canvas.saveAs(filename, {
89
+ quality: quality
90
+ }),
91
+ download(_url, _filename) {
92
+ return undefined;
93
+ },
94
+ loadImage(src) {
95
+ return loadImage(core.Platform.image.getRealURL(src));
96
+ }
79
97
  };
80
98
  core.Platform.roundRectPatch = true;
81
- }
82
- else if (canvasType === 'napi') {
83
- const { Canvas, loadImage } = power;
99
+ } else if (canvasType === "napi") {
100
+ const {Canvas: Canvas, loadImage: loadImage} = power;
84
101
  core.Platform.origin = {
85
102
  createCanvas: (width, height, format) => new Canvas(width, height, format),
86
103
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
87
- canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function* () { return canvas.toBuffer(mineType(type), quality); }),
88
- canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function* () { return fs.writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
89
- download(_url, _filename) { return undefined; },
90
- loadImage(src) { return loadImage(core.Platform.image.getRealURL(src)); }
104
+ canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function*() {
105
+ return canvas.toBuffer(mineType(type), quality);
106
+ }),
107
+ canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function*() {
108
+ return fs.writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality));
109
+ }),
110
+ download(_url, _filename) {
111
+ return undefined;
112
+ },
113
+ loadImage(src) {
114
+ return loadImage(core.Platform.image.getRealURL(src));
115
+ }
91
116
  };
92
117
  }
93
118
  core.Platform.ellipseToCurve = true;
94
119
  core.Platform.event = {
95
- stopDefault(_origin) { },
96
- stopNow(_origin) { },
97
- stop(_origin) { }
120
+ stopDefault(_origin) {},
121
+ stopNow(_origin) {},
122
+ stop(_origin) {}
98
123
  };
99
124
  core.Platform.canvas = core.Creator.canvas();
100
125
  }
101
126
  }
102
- core.Platform.name = 'node';
127
+
128
+ core.Platform.name = "node";
129
+
103
130
  core.Platform.backgrounder = true;
104
- core.Platform.requestRender = function (render) { setTimeout(render, 16); };
105
- core.defineKey(core.Platform, 'devicePixelRatio', { get() { return 1; } });
131
+
132
+ core.Platform.requestRender = function(render) {
133
+ setTimeout(render, 16);
134
+ };
135
+
136
+ core.defineKey(core.Platform, "devicePixelRatio", {
137
+ get() {
138
+ return 1;
139
+ }
140
+ });
141
+
106
142
  core.Platform.conicGradientSupport = true;
107
143
 
108
144
  class Watcher {
109
- get childrenChanged() { return this.hasAdd || this.hasRemove || this.hasVisible; }
145
+ get childrenChanged() {
146
+ return this.hasAdd || this.hasRemove || this.hasVisible;
147
+ }
110
148
  get updatedList() {
111
149
  if (this.hasRemove) {
112
- const updatedList = new core.LeafList();
113
- this.__updatedList.list.forEach(item => { if (item.leafer)
114
- updatedList.add(item); });
150
+ const updatedList = new core.LeafList;
151
+ this.__updatedList.list.forEach(item => {
152
+ if (item.leafer) updatedList.add(item);
153
+ });
115
154
  return updatedList;
116
- }
117
- else {
155
+ } else {
118
156
  return this.__updatedList;
119
157
  }
120
158
  }
121
159
  constructor(target, userConfig) {
122
160
  this.totalTimes = 0;
123
161
  this.config = {};
124
- this.__updatedList = new core.LeafList();
162
+ this.__updatedList = new core.LeafList;
125
163
  this.target = target;
126
- if (userConfig)
127
- this.config = core.DataHelper.default(userConfig, this.config);
164
+ if (userConfig) this.config = core.DataHelper.default(userConfig, this.config);
128
165
  this.__listenEvents();
129
166
  }
130
167
  start() {
131
- if (this.disabled)
132
- return;
168
+ if (this.disabled) return;
133
169
  this.running = true;
134
170
  }
135
171
  stop() {
@@ -142,8 +178,7 @@ class Watcher {
142
178
  }
143
179
  update() {
144
180
  this.changed = true;
145
- if (this.running)
146
- this.target.emit(core.RenderEvent.REQUEST);
181
+ if (this.running) this.target.emit(core.RenderEvent.REQUEST);
147
182
  }
148
183
  __onAttrChange(event) {
149
184
  this.__updatedList.add(event.target);
@@ -153,8 +188,7 @@ class Watcher {
153
188
  if (event.type === core.ChildEvent.ADD) {
154
189
  this.hasAdd = true;
155
190
  this.__pushChild(event.child);
156
- }
157
- else {
191
+ } else {
158
192
  this.hasRemove = true;
159
193
  this.__updatedList.add(event.parent);
160
194
  }
@@ -162,28 +196,22 @@ class Watcher {
162
196
  }
163
197
  __pushChild(child) {
164
198
  this.__updatedList.add(child);
165
- if (child.isBranch)
166
- this.__loopChildren(child);
199
+ if (child.isBranch) this.__loopChildren(child);
167
200
  }
168
201
  __loopChildren(parent) {
169
- const { children } = parent;
170
- for (let i = 0, len = children.length; i < len; i++)
171
- this.__pushChild(children[i]);
202
+ const {children: children} = parent;
203
+ for (let i = 0, len = children.length; i < len; i++) this.__pushChild(children[i]);
172
204
  }
173
205
  __onRquestData() {
174
- this.target.emitEvent(new core.WatchEvent(core.WatchEvent.DATA, { updatedList: this.updatedList }));
175
- this.__updatedList = new core.LeafList();
206
+ this.target.emitEvent(new core.WatchEvent(core.WatchEvent.DATA, {
207
+ updatedList: this.updatedList
208
+ }));
209
+ this.__updatedList = new core.LeafList;
176
210
  this.totalTimes++;
177
211
  this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
178
212
  }
179
213
  __listenEvents() {
180
- this.__eventIds = [
181
- this.target.on_([
182
- [core.PropertyEvent.CHANGE, this.__onAttrChange, this],
183
- [[core.ChildEvent.ADD, core.ChildEvent.REMOVE], this.__onChildEvent, this],
184
- [core.WatchEvent.REQUEST, this.__onRquestData, this]
185
- ])
186
- ];
214
+ this.__eventIds = [ this.target.on_([ [ core.PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ core.ChildEvent.ADD, core.ChildEvent.REMOVE ], this.__onChildEvent, this ], [ core.WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
187
215
  }
188
216
  __removeListenEvents() {
189
217
  this.target.off_(this.__eventIds);
@@ -197,8 +225,10 @@ class Watcher {
197
225
  }
198
226
  }
199
227
 
200
- const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange } = core.LeafHelper;
201
- const { pushAllChildBranch, pushAllParent } = core.BranchHelper;
228
+ const {updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateChange: updateOneChange} = core.LeafHelper;
229
+
230
+ const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = core.BranchHelper;
231
+
202
232
  function updateMatrix(updateList, levelList) {
203
233
  let layout;
204
234
  updateList.list.forEach(leaf => {
@@ -207,19 +237,17 @@ function updateMatrix(updateList, levelList) {
207
237
  if (layout.matrixChanged) {
208
238
  updateAllMatrix$1(leaf, true);
209
239
  levelList.add(leaf);
210
- if (leaf.isBranch)
211
- pushAllChildBranch(leaf, levelList);
240
+ if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
212
241
  pushAllParent(leaf, levelList);
213
- }
214
- else if (layout.boundsChanged) {
242
+ } else if (layout.boundsChanged) {
215
243
  levelList.add(leaf);
216
- if (leaf.isBranch)
217
- leaf.__tempNumber = 0;
244
+ if (leaf.isBranch) leaf.__tempNumber = 0;
218
245
  pushAllParent(leaf, levelList);
219
246
  }
220
247
  }
221
248
  });
222
249
  }
250
+
223
251
  function updateBounds(boundsList) {
224
252
  let list, branch, children;
225
253
  boundsList.sort(true);
@@ -239,18 +267,19 @@ function updateBounds(boundsList) {
239
267
  }
240
268
  });
241
269
  }
270
+
242
271
  function updateChange(updateList) {
243
272
  updateList.list.forEach(updateOneChange);
244
273
  }
245
274
 
246
- const { worldBounds } = core.LeafBoundsHelper;
275
+ const {worldBounds: worldBounds} = core.LeafBoundsHelper;
276
+
247
277
  class LayoutBlockData {
248
278
  constructor(list) {
249
- this.updatedBounds = new core.Bounds();
250
- this.beforeBounds = new core.Bounds();
251
- this.afterBounds = new core.Bounds();
252
- if (list instanceof Array)
253
- list = new core.LeafList(list);
279
+ this.updatedBounds = new core.Bounds;
280
+ this.beforeBounds = new core.Bounds;
281
+ this.afterBounds = new core.Bounds;
282
+ if (core.isArray(list)) list = new core.LeafList(list);
254
283
  this.updatedList = list;
255
284
  }
256
285
  setBefore() {
@@ -258,7 +287,7 @@ class LayoutBlockData {
258
287
  }
259
288
  setAfter() {
260
289
  this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
261
- this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
290
+ this.updatedBounds.setList([ this.beforeBounds, this.afterBounds ]);
262
291
  }
263
292
  merge(data) {
264
293
  this.updatedList.addList(data.updatedList.list);
@@ -271,21 +300,21 @@ class LayoutBlockData {
271
300
  }
272
301
  }
273
302
 
274
- const { updateAllMatrix, updateAllChange } = core.LeafHelper;
275
- const debug$2 = core.Debug.get('Layouter');
303
+ const {updateAllMatrix: updateAllMatrix, updateAllChange: updateAllChange} = core.LeafHelper;
304
+
305
+ const debug$2 = core.Debug.get("Layouter");
306
+
276
307
  class Layouter {
277
308
  constructor(target, userConfig) {
278
309
  this.totalTimes = 0;
279
310
  this.config = {};
280
- this.__levelList = new core.LeafLevelList();
311
+ this.__levelList = new core.LeafLevelList;
281
312
  this.target = target;
282
- if (userConfig)
283
- this.config = core.DataHelper.default(userConfig, this.config);
313
+ if (userConfig) this.config = core.DataHelper.default(userConfig, this.config);
284
314
  this.__listenEvents();
285
315
  }
286
316
  start() {
287
- if (this.disabled)
288
- return;
317
+ if (this.disabled) return;
289
318
  this.running = true;
290
319
  }
291
320
  stop() {
@@ -297,16 +326,14 @@ class Layouter {
297
326
  this.disabled = true;
298
327
  }
299
328
  layout() {
300
- if (this.layouting || !this.running)
301
- return;
302
- const { target } = this;
329
+ if (this.layouting || !this.running) return;
330
+ const {target: target} = this;
303
331
  this.times = 0;
304
332
  try {
305
333
  target.emit(core.LayoutEvent.START);
306
334
  this.layoutOnce();
307
335
  target.emitEvent(new core.LayoutEvent(core.LayoutEvent.END, this.layoutedBlocks, this.times));
308
- }
309
- catch (e) {
336
+ } catch (e) {
310
337
  debug$2.error(e);
311
338
  }
312
339
  this.layoutedBlocks = null;
@@ -314,24 +341,20 @@ class Layouter {
314
341
  layoutAgain() {
315
342
  if (this.layouting) {
316
343
  this.waitAgain = true;
317
- }
318
- else {
344
+ } else {
319
345
  this.layoutOnce();
320
346
  }
321
347
  }
322
348
  layoutOnce() {
323
- if (this.layouting)
324
- return debug$2.warn('layouting');
325
- if (this.times > 3)
326
- return debug$2.warn('layout max times');
349
+ if (this.layouting) return debug$2.warn("layouting");
350
+ if (this.times > 3) return debug$2.warn("layout max times");
327
351
  this.times++;
328
352
  this.totalTimes++;
329
353
  this.layouting = true;
330
354
  this.target.emit(core.WatchEvent.REQUEST);
331
355
  if (this.totalTimes > 1) {
332
356
  this.partLayout();
333
- }
334
- else {
357
+ } else {
335
358
  this.fullLayout();
336
359
  }
337
360
  this.layouting = false;
@@ -342,11 +365,10 @@ class Layouter {
342
365
  }
343
366
  partLayout() {
344
367
  var _a;
345
- if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
346
- return;
347
- const t = core.Run.start('PartLayout');
348
- const { target, __updatedList: updateList } = this;
349
- const { BEFORE, LAYOUT, AFTER } = core.LayoutEvent;
368
+ if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length)) return;
369
+ const t = core.Run.start("PartLayout");
370
+ const {target: target, __updatedList: updateList} = this;
371
+ const {BEFORE: BEFORE, LAYOUT: LAYOUT, AFTER: AFTER} = core.LayoutEvent;
350
372
  const blocks = this.getBlocks(updateList);
351
373
  blocks.forEach(item => item.setBefore());
352
374
  target.emitEvent(new core.LayoutEvent(BEFORE, blocks, this.times));
@@ -355,8 +377,7 @@ class Layouter {
355
377
  updateMatrix(updateList, this.__levelList);
356
378
  updateBounds(this.__levelList);
357
379
  updateChange(updateList);
358
- if (this.extraBlock)
359
- blocks.push(this.extraBlock);
380
+ if (this.extraBlock) blocks.push(this.extraBlock);
360
381
  blocks.forEach(item => item.setAfter());
361
382
  target.emitEvent(new core.LayoutEvent(LAYOUT, blocks, this.times));
362
383
  target.emitEvent(new core.LayoutEvent(AFTER, blocks, this.times));
@@ -366,13 +387,15 @@ class Layouter {
366
387
  core.Run.end(t);
367
388
  }
368
389
  fullLayout() {
369
- const t = core.Run.start('FullLayout');
370
- const { target } = this;
371
- const { BEFORE, LAYOUT, AFTER } = core.LayoutEvent;
390
+ const t = core.Run.start("FullLayout");
391
+ const {target: target} = this;
392
+ const {BEFORE: BEFORE, LAYOUT: LAYOUT, AFTER: AFTER} = core.LayoutEvent;
372
393
  const blocks = this.getBlocks(new core.LeafList(target));
373
394
  target.emitEvent(new core.LayoutEvent(BEFORE, blocks, this.times));
374
395
  Layouter.fullLayout(target);
375
- blocks.forEach(item => { item.setAfter(); });
396
+ blocks.forEach(item => {
397
+ item.setAfter();
398
+ });
376
399
  target.emitEvent(new core.LayoutEvent(LAYOUT, blocks, this.times));
377
400
  target.emitEvent(new core.LayoutEvent(AFTER, blocks, this.times));
378
401
  this.addBlocks(blocks);
@@ -380,15 +403,12 @@ class Layouter {
380
403
  }
381
404
  static fullLayout(target) {
382
405
  updateAllMatrix(target, true);
383
- if (target.isBranch)
384
- core.BranchHelper.updateBounds(target);
385
- else
386
- core.LeafHelper.updateBounds(target);
406
+ if (target.isBranch) core.BranchHelper.updateBounds(target); else core.LeafHelper.updateBounds(target);
387
407
  updateAllChange(target);
388
408
  }
389
409
  addExtra(leaf) {
390
410
  if (!this.__updatedList.has(leaf)) {
391
- const { updatedList, beforeBounds } = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
411
+ const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
392
412
  updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
393
413
  updatedList.add(leaf);
394
414
  }
@@ -397,7 +417,7 @@ class Layouter {
397
417
  return new LayoutBlockData(data);
398
418
  }
399
419
  getBlocks(list) {
400
- return [this.createBlock(list)];
420
+ return [ this.createBlock(list) ];
401
421
  }
402
422
  addBlocks(current) {
403
423
  this.layoutedBlocks ? this.layoutedBlocks.push(...current) : this.layoutedBlocks = current;
@@ -406,13 +426,7 @@ class Layouter {
406
426
  this.__updatedList = event.data.updatedList;
407
427
  }
408
428
  __listenEvents() {
409
- this.__eventIds = [
410
- this.target.on_([
411
- [core.LayoutEvent.REQUEST, this.layout, this],
412
- [core.LayoutEvent.AGAIN, this.layoutAgain, this],
413
- [core.WatchEvent.DATA, this.__onReceiveWatchData, this]
414
- ])
415
- ];
429
+ this.__eventIds = [ this.target.on_([ [ core.LayoutEvent.REQUEST, this.layout, this ], [ core.LayoutEvent.AGAIN, this.layoutAgain, this ], [ core.WatchEvent.DATA, this.__onReceiveWatchData, this ] ]) ];
416
430
  }
417
431
  __removeListenEvents() {
418
432
  this.target.off_(this.__eventIds);
@@ -426,9 +440,12 @@ class Layouter {
426
440
  }
427
441
  }
428
442
 
429
- const debug$1 = core.Debug.get('Renderer');
443
+ const debug$1 = core.Debug.get("Renderer");
444
+
430
445
  class Renderer {
431
- get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
446
+ get needFill() {
447
+ return !!(!this.canvas.allowBackgroundColor && this.config.fill);
448
+ }
432
449
  constructor(target, canvas, userConfig) {
433
450
  this.FPS = 60;
434
451
  this.totalTimes = 0;
@@ -439,8 +456,7 @@ class Renderer {
439
456
  };
440
457
  this.target = target;
441
458
  this.canvas = canvas;
442
- if (userConfig)
443
- this.config = core.DataHelper.default(userConfig, this.config);
459
+ if (userConfig) this.config = core.DataHelper.default(userConfig, this.config);
444
460
  this.__listenEvents();
445
461
  }
446
462
  start() {
@@ -451,8 +467,7 @@ class Renderer {
451
467
  this.running = false;
452
468
  }
453
469
  update(change = true) {
454
- if (!this.changed)
455
- this.changed = change;
470
+ if (!this.changed) this.changed = change;
456
471
  this.__requestRender();
457
472
  }
458
473
  requestLayout() {
@@ -460,7 +475,7 @@ class Renderer {
460
475
  }
461
476
  checkRender() {
462
477
  if (this.running) {
463
- const { target } = this;
478
+ const {target: target} = this;
464
479
  if (target.isApp) {
465
480
  target.emit(core.RenderEvent.CHILD_START, target);
466
481
  target.children.forEach(leafer => {
@@ -469,54 +484,47 @@ class Renderer {
469
484
  });
470
485
  target.emit(core.RenderEvent.CHILD_END, target);
471
486
  }
472
- if (this.changed && this.canvas.view)
473
- this.render();
487
+ if (this.changed && this.canvas.view) this.render();
474
488
  this.target.emit(core.RenderEvent.NEXT);
475
489
  }
476
490
  }
477
491
  render(callback) {
478
- if (!(this.running && this.canvas.view))
479
- return this.update();
480
- const { target } = this;
492
+ if (!(this.running && this.canvas.view)) return this.update();
493
+ const {target: target} = this;
481
494
  this.times = 0;
482
- this.totalBounds = new core.Bounds();
483
- debug$1.log(target.innerName, '--->');
495
+ this.totalBounds = new core.Bounds;
496
+ debug$1.log(target.innerName, "---\x3e");
484
497
  try {
485
498
  this.emitRender(core.RenderEvent.START);
486
499
  this.renderOnce(callback);
487
500
  this.emitRender(core.RenderEvent.END, this.totalBounds);
488
501
  core.ImageManager.clearRecycled();
489
- }
490
- catch (e) {
502
+ } catch (e) {
491
503
  this.rendering = false;
492
504
  debug$1.error(e);
493
505
  }
494
- debug$1.log('-------------|');
506
+ debug$1.log("-------------|");
495
507
  }
496
508
  renderAgain() {
497
509
  if (this.rendering) {
498
510
  this.waitAgain = true;
499
- }
500
- else {
511
+ } else {
501
512
  this.renderOnce();
502
513
  }
503
514
  }
504
515
  renderOnce(callback) {
505
- if (this.rendering)
506
- return debug$1.warn('rendering');
507
- if (this.times > 3)
508
- return debug$1.warn('render max times');
516
+ if (this.rendering) return debug$1.warn("rendering");
517
+ if (this.times > 3) return debug$1.warn("render max times");
509
518
  this.times++;
510
519
  this.totalTimes++;
511
520
  this.rendering = true;
512
521
  this.changed = false;
513
- this.renderBounds = new core.Bounds();
522
+ this.renderBounds = new core.Bounds;
514
523
  this.renderOptions = {};
515
524
  if (callback) {
516
525
  this.emitRender(core.RenderEvent.BEFORE);
517
526
  callback();
518
- }
519
- else {
527
+ } else {
520
528
  this.requestLayout();
521
529
  if (this.ignore) {
522
530
  this.ignore = this.rendering = false;
@@ -525,8 +533,7 @@ class Renderer {
525
533
  this.emitRender(core.RenderEvent.BEFORE);
526
534
  if (this.config.usePartRender && this.totalTimes > 1) {
527
535
  this.partRender();
528
- }
529
- else {
536
+ } else {
530
537
  this.fullRender();
531
538
  }
532
539
  }
@@ -540,16 +547,16 @@ class Renderer {
540
547
  }
541
548
  }
542
549
  partRender() {
543
- const { canvas, updateBlocks: list } = this;
544
- if (!list)
545
- return;
550
+ const {canvas: canvas, updateBlocks: list} = this;
551
+ if (!list) return;
546
552
  this.mergeBlocks();
547
- list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
548
- this.clipRender(block); });
553
+ list.forEach(block => {
554
+ if (canvas.bounds.hit(block) && !block.isEmpty()) this.clipRender(block);
555
+ });
549
556
  }
550
557
  clipRender(block) {
551
- const t = core.Run.start('PartRender');
552
- const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
558
+ const t = core.Run.start("PartRender");
559
+ const {canvas: canvas} = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
553
560
  canvas.save();
554
561
  bounds.spread(Renderer.clipSpread).ceil();
555
562
  canvas.clearWorld(bounds, true);
@@ -559,8 +566,8 @@ class Renderer {
559
566
  core.Run.end(t);
560
567
  }
561
568
  fullRender() {
562
- const t = core.Run.start('FullRender');
563
- const { canvas } = this;
569
+ const t = core.Run.start("FullRender");
570
+ const {canvas: canvas} = this;
564
571
  canvas.save();
565
572
  canvas.clear();
566
573
  this.__render(canvas.bounds);
@@ -568,11 +575,14 @@ class Renderer {
568
575
  core.Run.end(t);
569
576
  }
570
577
  __render(bounds, realBounds) {
571
- const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
572
- if (this.needFill)
573
- canvas.fillWorld(bounds, this.config.fill);
574
- if (core.Debug.showRepaint)
575
- core.Debug.drawRepaint(canvas, bounds);
578
+ const {canvas: canvas} = this, includes = bounds.includes(this.target.__world), options = includes ? {
579
+ includes: includes
580
+ } : {
581
+ bounds: bounds,
582
+ includes: includes
583
+ };
584
+ if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
585
+ if (core.Debug.showRepaint) core.Debug.drawRepaint(canvas, bounds);
576
586
  this.target.__render(canvas, options);
577
587
  this.renderBounds = realBounds = realBounds || bounds;
578
588
  this.renderOptions = options;
@@ -580,14 +590,13 @@ class Renderer {
580
590
  canvas.updateRender(realBounds);
581
591
  }
582
592
  addBlock(block) {
583
- if (!this.updateBlocks)
584
- this.updateBlocks = [];
593
+ if (!this.updateBlocks) this.updateBlocks = [];
585
594
  this.updateBlocks.push(block);
586
595
  }
587
596
  mergeBlocks() {
588
- const { updateBlocks: list } = this;
597
+ const {updateBlocks: list} = this;
589
598
  if (list) {
590
- const bounds = new core.Bounds();
599
+ const bounds = new core.Bounds;
591
600
  bounds.setList(list);
592
601
  list.length = 0;
593
602
  list.push(bounds);
@@ -595,26 +604,23 @@ class Renderer {
595
604
  }
596
605
  __requestRender() {
597
606
  const target = this.target;
598
- if (this.requestTime || !target)
599
- return;
600
- if (target.parentApp)
601
- return target.parentApp.requestRender(false);
607
+ if (this.requestTime || !target) return;
608
+ if (target.parentApp) return target.parentApp.requestRender(false);
602
609
  const requestTime = this.requestTime = Date.now();
603
610
  core.Platform.requestRender(() => {
604
- this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
611
+ this.FPS = Math.min(60, Math.ceil(1e3 / (Date.now() - requestTime)));
605
612
  this.requestTime = 0;
606
613
  this.checkRender();
607
614
  });
608
615
  }
609
616
  __onResize(e) {
610
- if (this.canvas.unreal)
611
- return;
617
+ if (this.canvas.unreal) return;
612
618
  if (e.bigger || !e.samePixelRatio) {
613
- const { width, height } = e.old;
619
+ const {width: width, height: height} = e.old;
614
620
  const bounds = new core.Bounds(0, 0, width, height);
615
621
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
616
622
  this.addBlock(this.canvas.bounds);
617
- this.target.forceUpdate('surface');
623
+ this.target.forceUpdate("surface");
618
624
  return;
619
625
  }
620
626
  }
@@ -622,34 +628,24 @@ class Renderer {
622
628
  this.update();
623
629
  }
624
630
  __onLayoutEnd(event) {
625
- if (event.data)
626
- event.data.map(item => {
627
- let empty;
628
- if (item.updatedList)
629
- item.updatedList.list.some(leaf => {
630
- empty = (!leaf.__world.width || !leaf.__world.height);
631
- if (empty) {
632
- if (!leaf.isLeafer)
633
- debug$1.tip(leaf.innerName, ': empty');
634
- empty = (!leaf.isBranch || leaf.isBranchLeaf);
635
- }
636
- return empty;
637
- });
638
- this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
631
+ if (event.data) event.data.map(item => {
632
+ let empty;
633
+ if (item.updatedList) item.updatedList.list.some(leaf => {
634
+ empty = !leaf.__world.width || !leaf.__world.height;
635
+ if (empty) {
636
+ if (!leaf.isLeafer) debug$1.tip(leaf.innerName, ": empty");
637
+ empty = !leaf.isBranch || leaf.isBranchLeaf;
638
+ }
639
+ return empty;
639
640
  });
641
+ this.addBlock(empty ? this.canvas.bounds : item.updatedBounds);
642
+ });
640
643
  }
641
644
  emitRender(type, bounds, options) {
642
645
  this.target.emitEvent(new core.RenderEvent(type, this.times, bounds, options));
643
646
  }
644
647
  __listenEvents() {
645
- this.__eventIds = [
646
- this.target.on_([
647
- [core.RenderEvent.REQUEST, this.update, this],
648
- [core.LayoutEvent.END, this.__onLayoutEnd, this],
649
- [core.RenderEvent.AGAIN, this.renderAgain, this],
650
- [core.ResizeEvent.RESIZE, this.__onResize, this]
651
- ])
652
- ];
648
+ this.__eventIds = [ this.target.on_([ [ core.RenderEvent.REQUEST, this.update, this ], [ core.LayoutEvent.END, this.__onLayoutEnd, this ], [ core.RenderEvent.AGAIN, this.renderAgain, this ], [ core.ResizeEvent.RESIZE, this.__onResize, this ] ]) ];
653
649
  }
654
650
  __removeListenEvents() {
655
651
  this.target.off_(this.__eventIds);
@@ -662,82 +658,104 @@ class Renderer {
662
658
  }
663
659
  }
664
660
  }
661
+
665
662
  Renderer.clipSpread = 10;
666
663
 
667
- const { hitRadiusPoint } = core.BoundsHelper;
664
+ const {hitRadiusPoint: hitRadiusPoint} = core.BoundsHelper;
665
+
668
666
  class Picker {
669
667
  constructor(target, selector) {
670
668
  this.target = target;
671
669
  this.selector = selector;
672
670
  }
673
671
  getByPoint(hitPoint, hitRadius, options) {
674
- if (!hitRadius)
675
- hitRadius = 0;
676
- if (!options)
677
- options = {};
672
+ if (!hitRadius) hitRadius = 0;
673
+ if (!options) options = {};
678
674
  const through = options.through || false;
679
675
  const ignoreHittable = options.ignoreHittable || false;
680
676
  const target = options.target || this.target;
681
677
  this.exclude = options.exclude || null;
682
- this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
678
+ this.point = {
679
+ x: hitPoint.x,
680
+ y: hitPoint.y,
681
+ radiusX: hitRadius,
682
+ radiusY: hitRadius
683
+ };
683
684
  this.findList = new core.LeafList(options.findList);
684
- if (!options.findList)
685
- this.hitBranch(target);
686
- const { list } = this.findList;
685
+ if (!options.findList) this.hitBranch(target.isBranchLeaf ? {
686
+ children: [ target ]
687
+ } : target);
688
+ const {list: list} = this.findList;
687
689
  const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
688
690
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
689
691
  this.clear();
690
- return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
692
+ return through ? {
693
+ path: path,
694
+ target: leaf,
695
+ throughPath: list.length ? this.getThroughPath(list) : path
696
+ } : {
697
+ path: path,
698
+ target: leaf
699
+ };
700
+ }
701
+ hitPoint(hitPoint, hitRadius, options) {
702
+ return !!this.getByPoint(hitPoint, hitRadius, options).target;
691
703
  }
692
704
  getBestMatchLeaf(list, bottomList, ignoreHittable) {
705
+ const findList = this.findList = new core.LeafList;
693
706
  if (list.length) {
694
707
  let find;
695
- this.findList = new core.LeafList();
696
- const { x, y } = this.point;
697
- const point = { x, y, radiusX: 0, radiusY: 0 };
708
+ const {x: x, y: y} = this.point;
709
+ const point = {
710
+ x: x,
711
+ y: y,
712
+ radiusX: 0,
713
+ radiusY: 0
714
+ };
698
715
  for (let i = 0, len = list.length; i < len; i++) {
699
716
  find = list[i];
700
717
  if (ignoreHittable || core.LeafHelper.worldHittable(find)) {
701
718
  this.hitChild(find, point);
702
- if (this.findList.length)
703
- return this.findList.list[0];
719
+ if (findList.length) {
720
+ if (find.isBranchLeaf && list.some(item => item !== find && core.LeafHelper.hasParent(item, find))) {
721
+ findList.reset();
722
+ break;
723
+ }
724
+ return findList.list[0];
725
+ }
704
726
  }
705
727
  }
706
728
  }
707
729
  if (bottomList) {
708
730
  for (let i = 0, len = bottomList.length; i < len; i++) {
709
731
  this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
710
- if (this.findList.length)
711
- return this.findList.list[0];
732
+ if (findList.length) return findList.list[0];
712
733
  }
713
734
  }
714
- return list[0];
735
+ return ignoreHittable ? list[0] : list.find(item => core.LeafHelper.worldHittable(item));
715
736
  }
716
737
  getPath(leaf) {
717
- const path = new core.LeafList();
738
+ const path = new core.LeafList;
718
739
  while (leaf) {
719
740
  path.add(leaf);
720
741
  leaf = leaf.parent;
721
742
  }
722
- if (this.target)
723
- path.add(this.target);
743
+ if (this.target) path.add(this.target);
724
744
  return path;
725
745
  }
726
746
  getHitablePath(leaf) {
727
747
  const path = this.getPath(leaf && leaf.hittable ? leaf : null);
728
- let item, hittablePath = new core.LeafList();
748
+ let item, hittablePath = new core.LeafList;
729
749
  for (let i = path.list.length - 1; i > -1; i--) {
730
750
  item = path.list[i];
731
- if (!item.__.hittable)
732
- break;
751
+ if (!item.__.hittable) break;
733
752
  hittablePath.addAt(item, 0);
734
- if (!item.__.hitChildren)
735
- break;
753
+ if (!item.__.hitChildren) break;
736
754
  }
737
755
  return hittablePath;
738
756
  }
739
757
  getThroughPath(list) {
740
- const throughPath = new core.LeafList();
758
+ const throughPath = new core.LeafList;
741
759
  const pathList = [];
742
760
  for (let i = list.length - 1; i > -1; i--) {
743
761
  pathList.push(this.getPath(list[i]));
@@ -747,8 +765,7 @@ class Picker {
747
765
  path = pathList[i], nextPath = pathList[i + 1];
748
766
  for (let j = 0, jLen = path.length; j < jLen; j++) {
749
767
  leaf = path.list[j];
750
- if (nextPath && nextPath.has(leaf))
751
- break;
768
+ if (nextPath && nextPath.has(leaf)) break;
752
769
  throughPath.add(leaf);
753
770
  }
754
771
  }
@@ -759,32 +776,37 @@ class Picker {
759
776
  }
760
777
  eachFind(children, hitMask) {
761
778
  let child, hit;
762
- const { point } = this, len = children.length;
779
+ const {point: point} = this, len = children.length;
763
780
  for (let i = len - 1; i > -1; i--) {
764
781
  child = children[i];
765
- if (!child.__.visible || (hitMask && !child.__.mask))
766
- continue;
782
+ if (!child.__.visible || hitMask && !child.__.mask) continue;
767
783
  hit = child.__.hitRadius ? true : hitRadiusPoint(child.__world, point);
768
784
  if (child.isBranch) {
769
785
  if (hit || child.__ignoreHitWorld) {
770
786
  this.eachFind(child.children, child.__onlyHitMask);
771
- if (child.isBranchLeaf)
772
- this.hitChild(child, point);
787
+ if (child.isBranchLeaf) this.hitChild(child, point);
773
788
  }
774
- }
775
- else {
776
- if (hit)
777
- this.hitChild(child, point);
789
+ } else {
790
+ if (hit) this.hitChild(child, point);
778
791
  }
779
792
  }
780
793
  }
781
794
  hitChild(child, point, proxy) {
782
- if (this.exclude && this.exclude.has(child))
783
- return;
795
+ if (this.exclude && this.exclude.has(child)) return;
784
796
  if (child.__hitWorld(point)) {
785
- const { parent } = child;
786
- if (parent && parent.__hasMask && !child.__.mask && !parent.children.some(item => item.__.mask && item.__hitWorld(point)))
787
- return;
797
+ const {parent: parent} = child;
798
+ if (parent && parent.__hasMask && !child.__.mask) {
799
+ let findMasks = [], item;
800
+ const {children: children} = parent;
801
+ for (let i = 0, len = children.length; i < len; i++) {
802
+ item = children[i];
803
+ if (item.__.mask) findMasks.push(item);
804
+ if (item === child) {
805
+ if (findMasks && !findMasks.every(value => value.__hitWorld(point))) return;
806
+ break;
807
+ }
808
+ }
809
+ }
788
810
  this.findList.add(proxy || child);
789
811
  }
790
812
  }
@@ -801,24 +823,24 @@ class Picker {
801
823
  class Selector {
802
824
  constructor(target, userConfig) {
803
825
  this.config = {};
804
- if (userConfig)
805
- this.config = core.DataHelper.default(userConfig, this.config);
826
+ if (userConfig) this.config = core.DataHelper.default(userConfig, this.config);
806
827
  this.picker = new Picker(this.target = target, this);
807
828
  this.finder = core.Creator.finder && core.Creator.finder();
808
829
  }
809
830
  getByPoint(hitPoint, hitRadius, options) {
810
- const { target, picker } = this;
811
- if (core.Platform.backgrounder)
812
- target && target.updateLayout();
831
+ const {target: target, picker: picker} = this;
832
+ if (core.Platform.backgrounder) target && target.updateLayout();
813
833
  return picker.getByPoint(hitPoint, hitRadius, options);
814
834
  }
835
+ hitPoint(hitPoint, hitRadius, options) {
836
+ return this.picker.hitPoint(hitPoint, hitRadius, options);
837
+ }
815
838
  getBy(condition, branch, one, options) {
816
- return this.finder ? this.finder.getBy(condition, branch, one, options) : core.Plugin.need('find');
839
+ return this.finder ? this.finder.getBy(condition, branch, one, options) : core.Plugin.need("find");
817
840
  }
818
841
  destroy() {
819
842
  this.picker.destroy();
820
- if (this.finder)
821
- this.finder.destroy();
843
+ if (this.finder) this.finder.destroy();
822
844
  }
823
845
  }
824
846
 
@@ -828,24 +850,22 @@ Object.assign(core.Creator, {
828
850
  renderer: (target, canvas, options) => new Renderer(target, canvas, options),
829
851
  selector: (target, options) => new Selector(target, options)
830
852
  });
853
+
831
854
  core.Platform.layout = Layouter.fullLayout;
832
855
 
833
856
  function fillText(ui, canvas) {
834
- const data = ui.__, { rows, decorationY } = data.__textDrawData;
835
- if (data.__isPlacehold && data.placeholderColor)
836
- canvas.fillStyle = data.placeholderColor;
857
+ const data = ui.__, {rows: rows, decorationY: decorationY} = data.__textDrawData;
858
+ if (data.__isPlacehold && data.placeholderColor) canvas.fillStyle = data.placeholderColor;
837
859
  let row;
838
860
  for (let i = 0, len = rows.length; i < len; i++) {
839
861
  row = rows[i];
840
- if (row.text)
841
- canvas.fillText(row.text, row.x, row.y);
842
- else if (row.data)
843
- row.data.forEach(charData => { canvas.fillText(charData.char, charData.x, row.y); });
862
+ if (row.text) canvas.fillText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
863
+ canvas.fillText(charData.char, charData.x, row.y);
864
+ });
844
865
  }
845
866
  if (decorationY) {
846
- const { decorationColor, decorationHeight } = data.__textDrawData;
847
- if (decorationColor)
848
- canvas.fillStyle = decorationColor;
867
+ const {decorationColor: decorationColor, decorationHeight: decorationHeight} = data.__textDrawData;
868
+ if (decorationColor) canvas.fillStyle = decorationColor;
849
869
  rows.forEach(row => decorationY.forEach(value => canvas.fillRect(row.x, row.y + value, row.width, decorationHeight)));
850
870
  }
851
871
  }
@@ -854,117 +874,112 @@ function fill(fill, ui, canvas) {
854
874
  canvas.fillStyle = fill;
855
875
  fillPathOrText(ui, canvas);
856
876
  }
877
+
857
878
  function fills(fills, ui, canvas) {
858
879
  let item;
859
880
  for (let i = 0, len = fills.length; i < len; i++) {
860
881
  item = fills[i];
861
882
  if (item.image) {
862
- if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font))
863
- continue;
883
+ if (draw.PaintImage.checkImage(ui, canvas, item, !ui.__.__font)) continue;
864
884
  if (!item.style) {
865
- if (!i && item.image.isPlacehold)
866
- ui.drawImagePlaceholder(canvas, item.image);
885
+ if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(canvas, item.image);
867
886
  continue;
868
887
  }
869
888
  }
870
889
  canvas.fillStyle = item.style;
871
890
  if (item.transform || item.scaleFixed) {
872
891
  canvas.save();
873
- if (item.transform)
874
- canvas.transform(item.transform);
892
+ if (item.transform) canvas.transform(item.transform);
875
893
  if (item.scaleFixed) {
876
- const { scaleX, scaleY } = ui.getRenderScaleData(true);
877
- canvas.scale(1 / scaleX, 1 / scaleY);
894
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
895
+ if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
878
896
  }
879
- if (item.blendMode)
880
- canvas.blendMode = item.blendMode;
897
+ if (item.blendMode) canvas.blendMode = item.blendMode;
881
898
  fillPathOrText(ui, canvas);
882
899
  canvas.restore();
883
- }
884
- else {
900
+ } else {
885
901
  if (item.blendMode) {
886
902
  canvas.saveBlendMode(item.blendMode);
887
903
  fillPathOrText(ui, canvas);
888
904
  canvas.restoreBlendMode();
889
- }
890
- else
891
- fillPathOrText(ui, canvas);
905
+ } else fillPathOrText(ui, canvas);
892
906
  }
893
907
  }
894
908
  }
909
+
895
910
  function fillPathOrText(ui, canvas) {
896
- ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
911
+ ui.__.__font ? fillText(ui, canvas) : ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill();
897
912
  }
898
913
 
899
914
  function strokeText(stroke, ui, canvas) {
900
915
  switch (ui.__.strokeAlign) {
901
- case 'center':
902
- drawCenter$1(stroke, 1, ui, canvas);
903
- break;
904
- case 'inside':
905
- drawAlign(stroke, 'inside', ui, canvas);
906
- break;
907
- case 'outside':
908
- ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, 'outside', ui, canvas);
909
- break;
916
+ case "center":
917
+ drawCenter$1(stroke, 1, ui, canvas);
918
+ break;
919
+
920
+ case "inside":
921
+ drawAlign(stroke, "inside", ui, canvas);
922
+ break;
923
+
924
+ case "outside":
925
+ ui.__.__fillAfterStroke ? drawCenter$1(stroke, 2, ui, canvas) : drawAlign(stroke, "outside", ui, canvas);
926
+ break;
910
927
  }
911
928
  }
929
+
912
930
  function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
913
931
  const data = ui.__;
914
- if (typeof stroke === 'object') {
932
+ if (core.isObject(stroke)) {
915
933
  drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
916
- }
917
- else {
934
+ } else {
918
935
  canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
919
936
  drawTextStroke(ui, canvas);
920
937
  }
921
938
  }
939
+
922
940
  function drawAlign(stroke, align, ui, canvas) {
923
941
  const out = canvas.getSameCanvas(true, true);
924
942
  out.font = ui.__.__font;
925
943
  drawCenter$1(stroke, 2, ui, out);
926
- out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
944
+ out.blendMode = align === "outside" ? "destination-out" : "destination-in";
927
945
  fillText(ui, out);
928
- out.blendMode = 'normal';
946
+ out.blendMode = "normal";
929
947
  core.LeafHelper.copyCanvasByWorld(ui, canvas, out);
930
948
  out.recycle(ui.__nowWorld);
931
949
  }
950
+
932
951
  function drawTextStroke(ui, canvas) {
933
952
  let row, data = ui.__.__textDrawData;
934
- const { rows, decorationY } = data;
953
+ const {rows: rows, decorationY: decorationY} = data;
935
954
  for (let i = 0, len = rows.length; i < len; i++) {
936
955
  row = rows[i];
937
- if (row.text)
938
- canvas.strokeText(row.text, row.x, row.y);
939
- else if (row.data)
940
- row.data.forEach(charData => { canvas.strokeText(charData.char, charData.x, row.y); });
956
+ if (row.text) canvas.strokeText(row.text, row.x, row.y); else if (row.data) row.data.forEach(charData => {
957
+ canvas.strokeText(charData.char, charData.x, row.y);
958
+ });
941
959
  }
942
960
  if (decorationY) {
943
- const { decorationHeight } = data;
961
+ const {decorationHeight: decorationHeight} = data;
944
962
  rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
945
963
  }
946
964
  }
965
+
947
966
  function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
948
967
  let item;
949
- const data = ui.__, { __hasMultiStrokeStyle } = data;
968
+ const data = ui.__, {__hasMultiStrokeStyle: __hasMultiStrokeStyle} = data;
950
969
  __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
951
970
  for (let i = 0, len = strokes.length; i < len; i++) {
952
971
  item = strokes[i];
953
- if (item.image && draw.PaintImage.checkImage(ui, canvas, item, false))
954
- continue;
972
+ if (item.image && draw.PaintImage.checkImage(ui, canvas, item, false)) continue;
955
973
  if (item.style) {
956
974
  if (__hasMultiStrokeStyle) {
957
- const { strokeStyle } = item;
975
+ const {strokeStyle: strokeStyle} = item;
958
976
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
959
- }
960
- else
961
- canvas.strokeStyle = item.style;
977
+ } else canvas.strokeStyle = item.style;
962
978
  if (item.blendMode) {
963
979
  canvas.saveBlendMode(item.blendMode);
964
980
  isText ? drawTextStroke(ui, canvas) : canvas.stroke();
965
981
  canvas.restoreBlendMode();
966
- }
967
- else {
982
+ } else {
968
983
  isText ? drawTextStroke(ui, canvas) : canvas.stroke();
969
984
  }
970
985
  }
@@ -973,53 +988,54 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
973
988
 
974
989
  function stroke(stroke, ui, canvas) {
975
990
  const data = ui.__;
976
- if (!data.__strokeWidth)
977
- return;
991
+ if (!data.__strokeWidth) return;
978
992
  if (data.__font) {
979
993
  strokeText(stroke, ui, canvas);
980
- }
981
- else {
994
+ } else {
982
995
  switch (data.strokeAlign) {
983
- case 'center':
984
- drawCenter(stroke, 1, ui, canvas);
985
- break;
986
- case 'inside':
987
- drawInside(stroke, ui, canvas);
988
- break;
989
- case 'outside':
990
- drawOutside(stroke, ui, canvas);
991
- break;
996
+ case "center":
997
+ drawCenter(stroke, 1, ui, canvas);
998
+ break;
999
+
1000
+ case "inside":
1001
+ drawInside(stroke, ui, canvas);
1002
+ break;
1003
+
1004
+ case "outside":
1005
+ drawOutside(stroke, ui, canvas);
1006
+ break;
992
1007
  }
993
1008
  }
994
1009
  }
1010
+
995
1011
  function strokes(strokes, ui, canvas) {
996
1012
  stroke(strokes, ui, canvas);
997
1013
  }
1014
+
998
1015
  function drawCenter(stroke, strokeWidthScale, ui, canvas) {
999
1016
  const data = ui.__;
1000
- if (typeof stroke === 'object') {
1017
+ if (core.isObject(stroke)) {
1001
1018
  drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
1002
- }
1003
- else {
1019
+ } else {
1004
1020
  canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
1005
1021
  canvas.stroke();
1006
1022
  }
1007
- if (data.__useArrow)
1008
- draw.Paint.strokeArrow(stroke, ui, canvas);
1023
+ if (data.__useArrow) draw.Paint.strokeArrow(stroke, ui, canvas);
1009
1024
  }
1025
+
1010
1026
  function drawInside(stroke, ui, canvas) {
1011
1027
  canvas.save();
1012
1028
  canvas.clipUI(ui);
1013
1029
  drawCenter(stroke, 2, ui, canvas);
1014
1030
  canvas.restore();
1015
1031
  }
1032
+
1016
1033
  function drawOutside(stroke, ui, canvas) {
1017
1034
  const data = ui.__;
1018
1035
  if (data.__fillAfterStroke) {
1019
1036
  drawCenter(stroke, 2, ui, canvas);
1020
- }
1021
- else {
1022
- const { renderBounds } = ui.__layout;
1037
+ } else {
1038
+ const {renderBounds: renderBounds} = ui.__layout;
1023
1039
  const out = canvas.getSameCanvas(true, true);
1024
1040
  ui.__drawRenderPath(out);
1025
1041
  drawCenter(stroke, 2, ui, out);
@@ -1030,25 +1046,23 @@ function drawOutside(stroke, ui, canvas) {
1030
1046
  }
1031
1047
  }
1032
1048
 
1033
- const { getSpread, getOuterOf, getByMove, getIntersectData } = core.BoundsHelper;
1049
+ const {getSpread: getSpread, getOuterOf: getOuterOf, getByMove: getByMove, getIntersectData: getIntersectData} = core.BoundsHelper;
1050
+
1034
1051
  function shape(ui, current, options) {
1035
1052
  const canvas = current.getSameCanvas();
1036
1053
  const nowWorld = ui.__nowWorld;
1037
- let bounds, fitMatrix, shapeBounds, worldCanvas;
1038
- let { scaleX, scaleY } = nowWorld;
1039
- if (scaleX < 0)
1040
- scaleX = -scaleX;
1041
- if (scaleY < 0)
1042
- scaleY = -scaleY;
1054
+ let bounds, matrix, fitMatrix, shapeBounds, worldCanvas;
1055
+ let {scaleX: scaleX, scaleY: scaleY} = nowWorld;
1056
+ if (scaleX < 0) scaleX = -scaleX;
1057
+ if (scaleY < 0) scaleY = -scaleY;
1043
1058
  if (current.bounds.includes(nowWorld)) {
1044
1059
  worldCanvas = canvas;
1045
1060
  bounds = shapeBounds = nowWorld;
1046
- }
1047
- else {
1048
- const { renderShapeSpread: spread } = ui.__layout;
1049
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
1061
+ } else {
1062
+ const {renderShapeSpread: spread} = ui.__layout;
1063
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [ spread * scaleY, spread * scaleX ]) : current.bounds, nowWorld);
1050
1064
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
1051
- let { a: fitScaleX, d: fitScaleY } = fitMatrix;
1065
+ let {a: fitScaleX, d: fitScaleY} = fitMatrix;
1052
1066
  if (fitMatrix.a < 1) {
1053
1067
  worldCanvas = current.getSameCanvas();
1054
1068
  ui.__renderShape(worldCanvas, options);
@@ -1057,28 +1071,39 @@ function shape(ui, current, options) {
1057
1071
  }
1058
1072
  shapeBounds = getOuterOf(nowWorld, fitMatrix);
1059
1073
  bounds = getByMove(shapeBounds, -fitMatrix.e, -fitMatrix.f);
1060
- if (options.matrix) {
1061
- const { matrix } = options;
1062
- fitMatrix.multiply(matrix);
1063
- fitScaleX *= matrix.scaleX;
1064
- fitScaleY *= matrix.scaleY;
1065
- }
1066
- options = Object.assign(Object.assign({}, options), { matrix: fitMatrix.withScale(fitScaleX, fitScaleY) });
1074
+ const userMatrix = options.matrix;
1075
+ if (userMatrix) {
1076
+ matrix = new core.Matrix(fitMatrix);
1077
+ matrix.multiply(userMatrix);
1078
+ fitScaleX *= userMatrix.scaleX;
1079
+ fitScaleY *= userMatrix.scaleY;
1080
+ } else matrix = fitMatrix;
1081
+ matrix.withScale(fitScaleX, fitScaleY);
1082
+ options = Object.assign(Object.assign({}, options), {
1083
+ matrix: matrix
1084
+ });
1067
1085
  }
1068
1086
  ui.__renderShape(canvas, options);
1069
1087
  return {
1070
- canvas, matrix: fitMatrix, bounds,
1071
- worldCanvas, shapeBounds, scaleX, scaleY
1088
+ canvas: canvas,
1089
+ matrix: matrix,
1090
+ fitMatrix: fitMatrix,
1091
+ bounds: bounds,
1092
+ worldCanvas: worldCanvas,
1093
+ shapeBounds: shapeBounds,
1094
+ scaleX: scaleX,
1095
+ scaleY: scaleY
1072
1096
  };
1073
1097
  }
1074
1098
 
1075
1099
  let recycleMap;
1076
- const { stintSet } = core.DataHelper, { hasTransparent: hasTransparent$1 } = draw.ColorConvert;
1100
+
1101
+ const {stintSet: stintSet} = core.DataHelper, {hasTransparent: hasTransparent$1} = draw.ColorConvert;
1102
+
1077
1103
  function compute(attrName, ui) {
1078
1104
  const data = ui.__, leafPaints = [];
1079
1105
  let paints = data.__input[attrName], isAlphaPixel, isTransparent;
1080
- if (!(paints instanceof Array))
1081
- paints = [paints];
1106
+ if (!core.isArray(paints)) paints = [ paints ];
1082
1107
  recycleMap = draw.PaintImage.recycleImage(attrName, data);
1083
1108
  let maxChildStrokeWidth;
1084
1109
  for (let i = 0, len = paints.length, item; i < len; i++) {
@@ -1086,206 +1111,222 @@ function compute(attrName, ui) {
1086
1111
  leafPaints.push(item);
1087
1112
  if (item.strokeStyle) {
1088
1113
  maxChildStrokeWidth || (maxChildStrokeWidth = 1);
1089
- if (item.strokeStyle.strokeWidth)
1090
- maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
1114
+ if (item.strokeStyle.strokeWidth) maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
1091
1115
  }
1092
1116
  }
1093
1117
  }
1094
- data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
1118
+ data["_" + attrName] = leafPaints.length ? leafPaints : undefined;
1095
1119
  if (leafPaints.length) {
1096
1120
  if (leafPaints.every(item => item.isTransparent)) {
1097
- if (leafPaints.some(item => item.image))
1098
- isAlphaPixel = true;
1121
+ if (leafPaints.some(item => item.image)) isAlphaPixel = true;
1099
1122
  isTransparent = true;
1100
1123
  }
1101
1124
  }
1102
- if (attrName === 'fill') {
1103
- stintSet(data, '__isAlphaPixelFill', isAlphaPixel);
1104
- stintSet(data, '__isTransparentFill', isTransparent);
1105
- }
1106
- else {
1107
- stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
1108
- stintSet(data, '__isTransparentStroke', isTransparent);
1109
- stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
1125
+ if (attrName === "fill") {
1126
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
1127
+ stintSet(data, "__isTransparentFill", isTransparent);
1128
+ } else {
1129
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
1130
+ stintSet(data, "__isTransparentStroke", isTransparent);
1131
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
1110
1132
  }
1111
1133
  }
1134
+
1112
1135
  function getLeafPaint(attrName, paint, ui) {
1113
- if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
1114
- return undefined;
1136
+ if (!core.isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
1115
1137
  let data;
1116
- const { boxBounds } = ui.__layout;
1138
+ const {boxBounds: boxBounds} = ui.__layout;
1117
1139
  switch (paint.type) {
1118
- case 'image':
1119
- data = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1120
- break;
1121
- case 'linear':
1122
- data = draw.PaintGradient.linearGradient(paint, boxBounds);
1123
- break;
1124
- case 'radial':
1125
- data = draw.PaintGradient.radialGradient(paint, boxBounds);
1126
- break;
1127
- case 'angular':
1128
- data = draw.PaintGradient.conicGradient(paint, boxBounds);
1129
- break;
1130
- case 'solid':
1131
- const { type, color, opacity } = paint;
1132
- data = { type, style: draw.ColorConvert.string(color, opacity) };
1133
- break;
1134
- default:
1135
- if (paint.r !== undefined)
1136
- data = { type: 'solid', style: draw.ColorConvert.string(paint) };
1140
+ case "image":
1141
+ data = draw.PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
1142
+ break;
1143
+
1144
+ case "linear":
1145
+ data = draw.PaintGradient.linearGradient(paint, boxBounds);
1146
+ break;
1147
+
1148
+ case "radial":
1149
+ data = draw.PaintGradient.radialGradient(paint, boxBounds);
1150
+ break;
1151
+
1152
+ case "angular":
1153
+ data = draw.PaintGradient.conicGradient(paint, boxBounds);
1154
+ break;
1155
+
1156
+ case "solid":
1157
+ const {type: type, color: color, opacity: opacity} = paint;
1158
+ data = {
1159
+ type: type,
1160
+ style: draw.ColorConvert.string(color, opacity)
1161
+ };
1162
+ break;
1163
+
1164
+ default:
1165
+ if (!core.isUndefined(paint.r)) data = {
1166
+ type: "solid",
1167
+ style: draw.ColorConvert.string(paint)
1168
+ };
1137
1169
  }
1138
1170
  if (data) {
1139
- if (typeof data.style === 'string' && hasTransparent$1(data.style))
1140
- data.isTransparent = true;
1171
+ if (core.isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
1141
1172
  if (paint.style) {
1142
- if (paint.style.strokeWidth === 0)
1143
- return undefined;
1173
+ if (paint.style.strokeWidth === 0) return undefined;
1144
1174
  data.strokeStyle = paint.style;
1145
1175
  }
1146
- if (paint.blendMode)
1147
- data.blendMode = paint.blendMode;
1176
+ if (paint.editing) data.editing = paint.editing;
1177
+ if (paint.blendMode) data.blendMode = paint.blendMode;
1148
1178
  }
1149
1179
  return data;
1150
1180
  }
1151
1181
 
1152
1182
  const PaintModule = {
1153
- compute,
1154
- fill,
1155
- fills,
1156
- fillPathOrText,
1157
- fillText,
1158
- stroke,
1159
- strokes,
1160
- strokeText,
1161
- drawTextStroke,
1162
- shape
1183
+ compute: compute,
1184
+ fill: fill,
1185
+ fills: fills,
1186
+ fillPathOrText: fillPathOrText,
1187
+ fillText: fillText,
1188
+ stroke: stroke,
1189
+ strokes: strokes,
1190
+ strokeText: strokeText,
1191
+ drawTextStroke: drawTextStroke,
1192
+ shape: shape
1163
1193
  };
1164
1194
 
1165
1195
  let origin = {}, tempMatrix = core.getMatrixData();
1166
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = core.MatrixHelper;
1196
+
1197
+ const {get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent: multiplyParent, scale: scaleHelper, rotate: rotate, skew: skewHelper} = core.MatrixHelper;
1198
+
1167
1199
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
1168
1200
  const transform = get$3();
1169
1201
  translate$1(transform, box.x + x, box.y + y);
1170
1202
  scaleHelper(transform, scaleX, scaleY);
1171
- if (rotation)
1172
- rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
1203
+ if (rotation) rotateOfOuter$1(transform, {
1204
+ x: box.x + box.width / 2,
1205
+ y: box.y + box.height / 2
1206
+ }, rotation);
1173
1207
  data.transform = transform;
1174
1208
  }
1209
+
1175
1210
  function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
1176
1211
  const transform = get$3();
1177
- if (rotation)
1178
- rotate(transform, rotation);
1179
- if (skew)
1180
- skewHelper(transform, skew.x, skew.y);
1181
- if (scaleX)
1182
- scaleHelper(transform, scaleX, scaleY);
1183
- translate$1(transform, box.x + x, box.y + y);
1212
+ layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1184
1213
  if (clipSize) {
1185
1214
  tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
1186
1215
  multiplyParent(transform, tempMatrix);
1187
1216
  }
1188
1217
  data.transform = transform;
1189
1218
  }
1190
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
1219
+
1220
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, skew, align, freeTransform) {
1191
1221
  const transform = get$3();
1192
- if (rotation) {
1193
- if (align === 'center') {
1194
- rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
1195
- }
1196
- else {
1197
- rotate(transform, rotation);
1198
- switch (rotation) {
1199
- case 90:
1222
+ if (freeTransform) {
1223
+ layout(transform, box, x, y, scaleX, scaleY, rotation, skew);
1224
+ } else {
1225
+ if (rotation) {
1226
+ if (align === "center") {
1227
+ rotateOfOuter$1(transform, {
1228
+ x: width / 2,
1229
+ y: height / 2
1230
+ }, rotation);
1231
+ } else {
1232
+ rotate(transform, rotation);
1233
+ switch (rotation) {
1234
+ case 90:
1200
1235
  translate$1(transform, height, 0);
1201
1236
  break;
1202
- case 180:
1237
+
1238
+ case 180:
1203
1239
  translate$1(transform, width, height);
1204
1240
  break;
1205
- case 270:
1241
+
1242
+ case 270:
1206
1243
  translate$1(transform, 0, width);
1207
1244
  break;
1245
+ }
1208
1246
  }
1209
1247
  }
1248
+ origin.x = box.x + x;
1249
+ origin.y = box.y + y;
1250
+ translate$1(transform, origin.x, origin.y);
1251
+ if (scaleX) scaleOfOuter$1(transform, origin, scaleX, scaleY);
1210
1252
  }
1211
- origin.x = box.x + x;
1212
- origin.y = box.y + y;
1213
- translate$1(transform, origin.x, origin.y);
1214
- if (scaleX)
1215
- scaleOfOuter$1(transform, origin, scaleX, scaleY);
1216
1253
  data.transform = transform;
1217
1254
  }
1218
1255
 
1219
- const { get: get$2, translate } = core.MatrixHelper;
1220
- const tempBox = new core.Bounds();
1256
+ function layout(transform, box, x, y, scaleX, scaleY, rotation, skew) {
1257
+ if (rotation) rotate(transform, rotation);
1258
+ if (skew) skewHelper(transform, skew.x, skew.y);
1259
+ if (scaleX) scaleHelper(transform, scaleX, scaleY);
1260
+ translate$1(transform, box.x + x, box.y + y);
1261
+ }
1262
+
1263
+ const {get: get$2, translate: translate} = core.MatrixHelper;
1264
+
1265
+ const tempBox = new core.Bounds;
1266
+
1221
1267
  const tempScaleData = {};
1268
+
1222
1269
  const tempImage = {};
1270
+
1223
1271
  function createData(leafPaint, image, paint, box) {
1224
- const { changeful, sync, editing, scaleFixed } = paint;
1225
- if (changeful)
1226
- leafPaint.changeful = changeful;
1227
- if (sync)
1228
- leafPaint.sync = sync;
1229
- if (editing)
1230
- leafPaint.editing = editing;
1231
- if (scaleFixed)
1232
- leafPaint.scaleFixed = scaleFixed;
1272
+ const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
1273
+ if (changeful) leafPaint.changeful = changeful;
1274
+ if (sync) leafPaint.sync = sync;
1275
+ if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
1233
1276
  leafPaint.data = getPatternData(paint, box, image);
1234
1277
  }
1278
+
1235
1279
  function getPatternData(paint, box, image) {
1236
- if (paint.padding)
1237
- box = tempBox.set(box).shrink(paint.padding);
1238
- if (paint.mode === 'strench')
1239
- paint.mode = 'stretch';
1240
- let { width, height } = image;
1241
- const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
1280
+ if (paint.padding) box = tempBox.set(box).shrink(paint.padding);
1281
+ if (paint.mode === "strench") paint.mode = "stretch";
1282
+ let {width: width, height: height} = image;
1283
+ const {opacity: opacity, mode: mode, align: align, offset: offset, scale: scale, size: size, rotation: rotation, skew: skew, clipSize: clipSize, repeat: repeat, gap: gap, filters: filters} = paint;
1242
1284
  const sameBox = box.width === width && box.height === height;
1243
- const data = { mode };
1244
- const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
1285
+ const data = {
1286
+ mode: mode
1287
+ };
1288
+ const swapSize = align !== "center" && (rotation || 0) % 180 === 90;
1245
1289
  core.BoundsHelper.set(tempImage, 0, 0, swapSize ? height : width, swapSize ? width : height);
1246
1290
  let scaleX, scaleY;
1247
- if (!mode || mode === 'cover' || mode === 'fit') {
1291
+ if (!mode || mode === "cover" || mode === "fit") {
1248
1292
  if (!sameBox || rotation) {
1249
- scaleX = scaleY = core.BoundsHelper.getFitScale(box, tempImage, mode !== 'fit');
1293
+ scaleX = scaleY = core.BoundsHelper.getFitScale(box, tempImage, mode !== "fit");
1250
1294
  core.BoundsHelper.put(box, image, align, scaleX, false, tempImage);
1251
1295
  core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
1252
1296
  }
1253
- }
1254
- else {
1297
+ } else {
1255
1298
  if (scale || size) {
1256
1299
  core.MathHelper.getScaleData(scale, size, image, tempScaleData);
1257
1300
  scaleX = tempScaleData.scaleX;
1258
1301
  scaleY = tempScaleData.scaleY;
1259
1302
  }
1260
- if (align) {
1261
- if (scaleX)
1262
- core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
1263
- core.AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
1303
+ if (align || gap || repeat) {
1304
+ if (scaleX) core.BoundsHelper.scale(tempImage, scaleX, scaleY, true);
1305
+ if (align) core.AlignHelper.toPoint(align, tempImage, box, tempImage, true, true);
1264
1306
  }
1265
1307
  }
1266
- if (offset)
1267
- core.PointHelper.move(tempImage, offset);
1308
+ if (offset) core.PointHelper.move(tempImage, offset);
1268
1309
  switch (mode) {
1269
- case 'stretch':
1270
- if (!sameBox)
1271
- width = box.width, height = box.height;
1272
- break;
1273
- case 'normal':
1274
- case 'clip':
1275
- if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
1276
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
1277
- break;
1278
- case 'repeat':
1279
- if (!sameBox || scaleX || rotation)
1280
- repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, align);
1281
- if (!repeat)
1282
- data.repeat = 'repeat';
1283
- break;
1284
- case 'fit':
1285
- case 'cover':
1286
- default:
1287
- if (scaleX)
1288
- fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1310
+ case "stretch":
1311
+ if (!sameBox) width = box.width, height = box.height;
1312
+ break;
1313
+
1314
+ case "normal":
1315
+ case "clip":
1316
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew) clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
1317
+ break;
1318
+
1319
+ case "repeat":
1320
+ if (!sameBox || scaleX || rotation || skew) repeatMode(data, box, width, height, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, align, paint.freeTransform);
1321
+ if (!repeat) data.repeat = "repeat";
1322
+ const count = core.isObject(repeat);
1323
+ if (gap || count) data.gap = getGapData(gap, count && repeat, tempImage.width, tempImage.height, box);
1324
+ break;
1325
+
1326
+ case "fit":
1327
+ case "cover":
1328
+ default:
1329
+ if (scaleX) fillOrFitMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
1289
1330
  }
1290
1331
  if (!data.transform) {
1291
1332
  if (box.x || box.y) {
@@ -1293,49 +1334,69 @@ function getPatternData(paint, box, image) {
1293
1334
  translate(data.transform, box.x, box.y);
1294
1335
  }
1295
1336
  }
1296
- if (scaleX && mode !== 'stretch') {
1337
+ if (scaleX && mode !== "stretch") {
1297
1338
  data.scaleX = scaleX;
1298
1339
  data.scaleY = scaleY;
1299
1340
  }
1300
1341
  data.width = width;
1301
1342
  data.height = height;
1302
- if (opacity)
1303
- data.opacity = opacity;
1304
- if (filters)
1305
- data.filters = filters;
1306
- if (repeat)
1307
- data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
1343
+ if (opacity) data.opacity = opacity;
1344
+ if (filters) data.filters = filters;
1345
+ if (repeat) data.repeat = core.isString(repeat) ? repeat === "x" ? "repeat-x" : "repeat-y" : "repeat";
1308
1346
  return data;
1309
1347
  }
1310
1348
 
1311
- let cache, box = new core.Bounds();
1312
- const { isSame } = core.BoundsHelper;
1349
+ function getGapData(gap, repeat, width, height, box) {
1350
+ let xGap, yGap;
1351
+ if (core.isObject(gap)) xGap = gap.x, yGap = gap.y; else xGap = yGap = gap;
1352
+ return {
1353
+ x: getGapValue(xGap, width, box.width, repeat && repeat.x),
1354
+ y: getGapValue(yGap, height, box.height, repeat && repeat.y)
1355
+ };
1356
+ }
1357
+
1358
+ function getGapValue(gap, size, totalSize, rows) {
1359
+ const auto = core.isString(gap) || rows;
1360
+ const remain = rows ? totalSize - rows * size : totalSize % size;
1361
+ const value = auto ? remain / ((rows || Math.floor(totalSize / size)) - 1) : gap;
1362
+ return gap === "auto" ? value < 0 ? 0 : value : value;
1363
+ }
1364
+
1365
+ let cache, box = new core.Bounds;
1366
+
1367
+ const {isSame: isSame} = core.BoundsHelper;
1368
+
1313
1369
  function image(ui, attrName, paint, boxBounds, firstUse) {
1314
1370
  let leafPaint, event;
1315
1371
  const image = core.ImageManager.get(paint);
1316
1372
  if (cache && paint === cache.paint && isSame(boxBounds, cache.boxBounds)) {
1317
1373
  leafPaint = cache.leafPaint;
1318
- }
1319
- else {
1320
- leafPaint = { type: paint.type, image };
1321
- if (image.hasAlphaPixel)
1322
- leafPaint.isTransparent = true;
1323
- cache = image.use > 1 ? { leafPaint, paint, boxBounds: box.set(boxBounds) } : null;
1324
- }
1325
- if (firstUse || image.loading)
1326
- event = { image, attrName, attrValue: paint };
1374
+ } else {
1375
+ leafPaint = {
1376
+ type: paint.type,
1377
+ image: image
1378
+ };
1379
+ if (image.hasAlphaPixel) leafPaint.isTransparent = true;
1380
+ cache = image.use > 1 ? {
1381
+ leafPaint: leafPaint,
1382
+ paint: paint,
1383
+ boxBounds: box.set(boxBounds)
1384
+ } : null;
1385
+ }
1386
+ if (firstUse || image.loading) event = {
1387
+ image: image,
1388
+ attrName: attrName,
1389
+ attrValue: paint
1390
+ };
1327
1391
  if (image.ready) {
1328
1392
  checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds);
1329
1393
  if (firstUse) {
1330
1394
  onLoad(ui, event);
1331
1395
  onLoadSuccess(ui, event);
1332
1396
  }
1333
- }
1334
- else if (image.error) {
1335
- if (firstUse)
1336
- onLoadError(ui, event, image.error);
1337
- }
1338
- else {
1397
+ } else if (image.error) {
1398
+ if (firstUse) onLoadError(ui, event, image.error);
1399
+ } else {
1339
1400
  if (firstUse) {
1340
1401
  ignoreRender(ui, true);
1341
1402
  onLoad(ui, event);
@@ -1344,79 +1405,84 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
1344
1405
  ignoreRender(ui, false);
1345
1406
  if (!ui.destroyed) {
1346
1407
  if (checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds)) {
1347
- if (image.hasAlphaPixel)
1348
- ui.__layout.hitCanvasChanged = true;
1349
- ui.forceUpdate('surface');
1408
+ if (image.hasAlphaPixel) ui.__layout.hitCanvasChanged = true;
1409
+ ui.forceUpdate("surface");
1350
1410
  }
1351
1411
  onLoadSuccess(ui, event);
1352
1412
  }
1353
1413
  leafPaint.loadId = undefined;
1354
- }, (error) => {
1414
+ }, error => {
1355
1415
  ignoreRender(ui, false);
1356
1416
  onLoadError(ui, event, error);
1357
1417
  leafPaint.loadId = undefined;
1358
1418
  });
1359
1419
  if (ui.placeholderColor) {
1360
- if (!ui.placeholderDelay)
1361
- image.isPlacehold = true;
1362
- else
1363
- setTimeout(() => {
1364
- if (!image.ready) {
1365
- image.isPlacehold = true;
1366
- ui.forceUpdate('surface');
1367
- }
1368
- }, ui.placeholderDelay);
1420
+ if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
1421
+ if (!image.ready) {
1422
+ image.isPlacehold = true;
1423
+ ui.forceUpdate("surface");
1424
+ }
1425
+ }, ui.placeholderDelay);
1369
1426
  }
1370
1427
  }
1371
1428
  return leafPaint;
1372
1429
  }
1430
+
1373
1431
  function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds) {
1374
- if (attrName === 'fill' && !ui.__.__naturalWidth) {
1432
+ if (attrName === "fill" && !ui.__.__naturalWidth) {
1375
1433
  const data = ui.__;
1376
1434
  data.__naturalWidth = image.width / data.pixelRatio;
1377
1435
  data.__naturalHeight = image.height / data.pixelRatio;
1378
1436
  if (data.__autoSide) {
1379
- ui.forceUpdate('width');
1437
+ ui.forceUpdate("width");
1380
1438
  if (ui.__proxyData) {
1381
- ui.setProxyAttr('width', data.width);
1382
- ui.setProxyAttr('height', data.height);
1439
+ ui.setProxyAttr("width", data.width);
1440
+ ui.setProxyAttr("height", data.height);
1383
1441
  }
1384
1442
  return false;
1385
1443
  }
1386
1444
  }
1387
- if (!leafPaint.data)
1388
- createData(leafPaint, image, paint, boxBounds);
1445
+ if (!leafPaint.data) createData(leafPaint, image, paint, boxBounds);
1389
1446
  return true;
1390
1447
  }
1448
+
1391
1449
  function onLoad(ui, event) {
1392
1450
  emit(ui, core.ImageEvent.LOAD, event);
1393
1451
  }
1452
+
1394
1453
  function onLoadSuccess(ui, event) {
1395
1454
  emit(ui, core.ImageEvent.LOADED, event);
1396
1455
  }
1456
+
1397
1457
  function onLoadError(ui, event, error) {
1398
1458
  event.error = error;
1399
- ui.forceUpdate('surface');
1459
+ ui.forceUpdate("surface");
1400
1460
  emit(ui, core.ImageEvent.ERROR, event);
1401
1461
  }
1462
+
1402
1463
  function emit(ui, type, data) {
1403
- if (ui.hasEvent(type))
1404
- ui.emitEvent(new core.ImageEvent(type, data));
1464
+ if (ui.hasEvent(type)) ui.emitEvent(new core.ImageEvent(type, data));
1405
1465
  }
1466
+
1406
1467
  function ignoreRender(ui, value) {
1407
- const { leafer } = ui;
1408
- if (leafer && leafer.viewReady)
1409
- leafer.renderer.ignore = value;
1468
+ const {leafer: leafer} = ui;
1469
+ if (leafer && leafer.viewReady) leafer.renderer.ignore = value;
1410
1470
  }
1411
1471
 
1412
- const { get: get$1, scale, copy: copy$1 } = core.MatrixHelper;
1413
- const { ceil, abs } = Math;
1472
+ const {get: get$1, scale: scale, copy: copy$1} = core.MatrixHelper;
1473
+
1474
+ const {floor: floor, max: max, abs: abs} = Math;
1475
+
1414
1476
  function createPattern(ui, paint, pixelRatio) {
1415
- let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
1416
- const id = scaleX + '-' + scaleY + '-' + pixelRatio;
1477
+ let {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
1478
+ const id = scaleX + "-" + scaleY + "-" + pixelRatio;
1417
1479
  if (paint.patternId !== id && !ui.destroyed) {
1418
- const { image, data } = paint;
1419
- let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1480
+ const {image: image, data: data} = paint;
1481
+ let imageScale, imageMatrix, {width: width, height: height, scaleX: sx, scaleY: sy, transform: transform, repeat: repeat, gap: gap} = data;
1482
+ scaleX *= pixelRatio;
1483
+ scaleY *= pixelRatio;
1484
+ const xGap = gap && gap.x * scaleX;
1485
+ const yGap = gap && gap.y * scaleY;
1420
1486
  if (sx) {
1421
1487
  sx = abs(sx);
1422
1488
  sy = abs(sy);
@@ -1426,23 +1492,18 @@ function createPattern(ui, paint, pixelRatio) {
1426
1492
  scaleX *= sx;
1427
1493
  scaleY *= sy;
1428
1494
  }
1429
- scaleX *= pixelRatio;
1430
- scaleY *= pixelRatio;
1431
1495
  width *= scaleX;
1432
1496
  height *= scaleY;
1433
1497
  const size = width * height;
1434
1498
  if (!repeat) {
1435
- if (size > core.Platform.image.maxCacheSize)
1436
- return false;
1499
+ if (size > core.Platform.image.maxCacheSize) return false;
1437
1500
  }
1438
1501
  let maxSize = core.Platform.image.maxPatternSize;
1439
1502
  if (!image.isSVG) {
1440
1503
  const imageSize = image.width * image.height;
1441
- if (maxSize > imageSize)
1442
- maxSize = imageSize;
1504
+ if (maxSize > imageSize) maxSize = imageSize;
1443
1505
  }
1444
- if (size > maxSize)
1445
- imageScale = Math.sqrt(size / maxSize);
1506
+ if (size > maxSize) imageScale = Math.sqrt(size / maxSize);
1446
1507
  if (imageScale) {
1447
1508
  scaleX /= imageScale;
1448
1509
  scaleY /= imageScale;
@@ -1456,65 +1517,62 @@ function createPattern(ui, paint, pixelRatio) {
1456
1517
  if (transform || scaleX !== 1 || scaleY !== 1) {
1457
1518
  if (!imageMatrix) {
1458
1519
  imageMatrix = get$1();
1459
- if (transform)
1460
- copy$1(imageMatrix, transform);
1520
+ if (transform) copy$1(imageMatrix, transform);
1461
1521
  }
1462
1522
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1463
1523
  }
1464
- const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, data.opacity, data.filters);
1465
- const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
1524
+ if (imageMatrix) {
1525
+ const canvasWidth = width + (xGap || 0), canvasHeight = height + (yGap || 0);
1526
+ scale(imageMatrix, canvasWidth / max(floor(canvasWidth), 1), canvasHeight / max(floor(canvasHeight), 1));
1527
+ }
1528
+ const canvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap);
1529
+ const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
1466
1530
  paint.style = pattern;
1467
1531
  paint.patternId = id;
1468
1532
  return true;
1469
- }
1470
- else {
1533
+ } else {
1471
1534
  return false;
1472
1535
  }
1473
1536
  }
1474
1537
 
1475
1538
  function checkImage(ui, canvas, paint, allowDraw) {
1476
- const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
1477
- const { pixelRatio } = canvas, { data } = paint;
1478
- if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
1539
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, paint.scaleFixed);
1540
+ const {pixelRatio: pixelRatio} = canvas, {data: data} = paint;
1541
+ if (!data || paint.patternId === scaleX + "-" + scaleY + "-" + pixelRatio && !draw.Export.running) {
1479
1542
  return false;
1480
- }
1481
- else {
1543
+ } else {
1482
1544
  if (allowDraw) {
1483
1545
  if (data.repeat) {
1484
1546
  allowDraw = false;
1485
- }
1486
- else {
1487
- if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
1488
- let { width, height } = data;
1547
+ } else {
1548
+ if (!(paint.changeful || core.Platform.name === "miniapp" && core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
1549
+ let {width: width, height: height} = data;
1489
1550
  width *= scaleX * pixelRatio;
1490
1551
  height *= scaleY * pixelRatio;
1491
1552
  if (data.scaleX) {
1492
1553
  width *= data.scaleX;
1493
1554
  height *= data.scaleY;
1494
1555
  }
1495
- allowDraw = (width * height > core.Platform.image.maxCacheSize);
1556
+ allowDraw = width * height > core.Platform.image.maxCacheSize;
1496
1557
  }
1497
1558
  }
1498
1559
  }
1499
1560
  if (allowDraw) {
1500
1561
  if (ui.__.__isFastShadow) {
1501
- canvas.fillStyle = paint.style || '#000';
1562
+ canvas.fillStyle = paint.style || "#000";
1502
1563
  canvas.fill();
1503
1564
  }
1504
1565
  drawImage(ui, canvas, paint, data);
1505
1566
  return true;
1506
- }
1507
- else {
1567
+ } else {
1508
1568
  if (!paint.style || paint.sync || draw.Export.running) {
1509
1569
  createPattern(ui, paint, pixelRatio);
1510
- }
1511
- else {
1570
+ } else {
1512
1571
  if (!paint.patternTask) {
1513
- paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1572
+ paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function*() {
1514
1573
  paint.patternTask = null;
1515
- if (canvas.bounds.hit(ui.__nowWorld))
1516
- createPattern(ui, paint, pixelRatio);
1517
- ui.forceUpdate('surface');
1574
+ if (canvas.bounds.hit(ui.__nowWorld)) createPattern(ui, paint, pixelRatio);
1575
+ ui.forceUpdate("surface");
1518
1576
  }), 300);
1519
1577
  }
1520
1578
  }
@@ -1522,39 +1580,35 @@ function checkImage(ui, canvas, paint, allowDraw) {
1522
1580
  }
1523
1581
  }
1524
1582
  }
1583
+
1525
1584
  function drawImage(ui, canvas, paint, data) {
1526
1585
  canvas.save();
1527
1586
  canvas.clipUI(ui);
1528
- if (paint.blendMode)
1529
- canvas.blendMode = paint.blendMode;
1530
- if (data.opacity)
1531
- canvas.opacity *= data.opacity;
1532
- if (data.transform)
1533
- canvas.transform(data.transform);
1587
+ if (paint.blendMode) canvas.blendMode = paint.blendMode;
1588
+ if (data.opacity) canvas.opacity *= data.opacity;
1589
+ if (data.transform) canvas.transform(data.transform);
1534
1590
  canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
1535
1591
  canvas.restore();
1536
1592
  }
1537
1593
 
1538
1594
  function recycleImage(attrName, data) {
1539
- const paints = data['_' + attrName];
1540
- if (paints instanceof Array) {
1595
+ const paints = data["_" + attrName];
1596
+ if (core.isArray(paints)) {
1541
1597
  let paint, image, recycleMap, input, url;
1542
1598
  for (let i = 0, len = paints.length; i < len; i++) {
1543
1599
  paint = paints[i];
1544
1600
  image = paint.image;
1545
1601
  url = image && image.url;
1546
1602
  if (url) {
1547
- if (!recycleMap)
1548
- recycleMap = {};
1603
+ if (!recycleMap) recycleMap = {};
1549
1604
  recycleMap[url] = true;
1550
1605
  core.ImageManager.recycle(image);
1551
1606
  if (image.loading) {
1552
1607
  if (!input) {
1553
- input = (data.__input && data.__input[attrName]) || [];
1554
- if (!(input instanceof Array))
1555
- input = [input];
1608
+ input = data.__input && data.__input[attrName] || [];
1609
+ if (!core.isArray(input)) input = [ input ];
1556
1610
  }
1557
- image.unload(paints[i].loadId, !input.some((item) => item.url === url));
1611
+ image.unload(paints[i].loadId, !input.some(item => item.url === url));
1558
1612
  }
1559
1613
  }
1560
1614
  }
@@ -1564,75 +1618,85 @@ function recycleImage(attrName, data) {
1564
1618
  }
1565
1619
 
1566
1620
  const PaintImageModule = {
1567
- image,
1568
- checkImage,
1569
- createPattern,
1570
- recycleImage,
1571
- createData,
1572
- getPatternData,
1573
- fillOrFitMode,
1574
- clipMode,
1575
- repeatMode
1621
+ image: image,
1622
+ checkImage: checkImage,
1623
+ createPattern: createPattern,
1624
+ recycleImage: recycleImage,
1625
+ createData: createData,
1626
+ getPatternData: getPatternData,
1627
+ fillOrFitMode: fillOrFitMode,
1628
+ clipMode: clipMode,
1629
+ repeatMode: repeatMode
1576
1630
  };
1577
1631
 
1578
- const { toPoint: toPoint$2 } = core.AroundHelper, { hasTransparent } = draw.ColorConvert;
1632
+ const {toPoint: toPoint$2} = core.AroundHelper, {hasTransparent: hasTransparent} = draw.ColorConvert;
1633
+
1579
1634
  const realFrom$2 = {};
1635
+
1580
1636
  const realTo$2 = {};
1637
+
1581
1638
  function linearGradient(paint, box) {
1582
- let { from, to, type, opacity } = paint;
1583
- toPoint$2(from || 'top', box, realFrom$2);
1584
- toPoint$2(to || 'bottom', box, realTo$2);
1639
+ let {from: from, to: to, type: type, opacity: opacity} = paint;
1640
+ toPoint$2(from || "top", box, realFrom$2);
1641
+ toPoint$2(to || "bottom", box, realTo$2);
1585
1642
  const style = core.Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
1586
- const data = { type, style };
1643
+ const data = {
1644
+ type: type,
1645
+ style: style
1646
+ };
1587
1647
  applyStops(data, style, paint.stops, opacity);
1588
1648
  return data;
1589
1649
  }
1650
+
1590
1651
  function applyStops(data, gradient, stops, opacity) {
1591
1652
  if (stops) {
1592
1653
  let stop, color, offset, isTransparent;
1593
1654
  for (let i = 0, len = stops.length; i < len; i++) {
1594
1655
  stop = stops[i];
1595
- if (typeof stop === 'string')
1596
- offset = i / (len - 1), color = draw.ColorConvert.string(stop, opacity);
1597
- else
1598
- offset = stop.offset, color = draw.ColorConvert.string(stop.color, opacity);
1656
+ if (core.isString(stop)) offset = i / (len - 1), color = draw.ColorConvert.string(stop, opacity); else offset = stop.offset,
1657
+ color = draw.ColorConvert.string(stop.color, opacity);
1599
1658
  gradient.addColorStop(offset, color);
1600
- if (!isTransparent && hasTransparent(color))
1601
- isTransparent = true;
1659
+ if (!isTransparent && hasTransparent(color)) isTransparent = true;
1602
1660
  }
1603
- if (isTransparent)
1604
- data.isTransparent = true;
1661
+ if (isTransparent) data.isTransparent = true;
1605
1662
  }
1606
1663
  }
1607
1664
 
1608
- const { getAngle, getDistance: getDistance$1 } = core.PointHelper;
1609
- const { get, rotateOfOuter, scaleOfOuter } = core.MatrixHelper;
1610
- const { toPoint: toPoint$1 } = core.AroundHelper;
1665
+ const {getAngle: getAngle, getDistance: getDistance$1} = core.PointHelper;
1666
+
1667
+ const {get: get, rotateOfOuter: rotateOfOuter, scaleOfOuter: scaleOfOuter} = core.MatrixHelper;
1668
+
1669
+ const {toPoint: toPoint$1} = core.AroundHelper;
1670
+
1611
1671
  const realFrom$1 = {};
1672
+
1612
1673
  const realTo$1 = {};
1674
+
1613
1675
  function radialGradient(paint, box) {
1614
- let { from, to, type, opacity, stretch } = paint;
1615
- toPoint$1(from || 'center', box, realFrom$1);
1616
- toPoint$1(to || 'bottom', box, realTo$1);
1676
+ let {from: from, to: to, type: type, opacity: opacity, stretch: stretch} = paint;
1677
+ toPoint$1(from || "center", box, realFrom$1);
1678
+ toPoint$1(to || "bottom", box, realTo$1);
1617
1679
  const style = core.Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
1618
- const data = { type, style };
1680
+ const data = {
1681
+ type: type,
1682
+ style: style
1683
+ };
1619
1684
  applyStops(data, style, paint.stops, opacity);
1620
1685
  const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
1621
- if (transform)
1622
- data.transform = transform;
1686
+ if (transform) data.transform = transform;
1623
1687
  return data;
1624
1688
  }
1689
+
1625
1690
  function getTransform(box, from, to, stretch, rotate90) {
1626
1691
  let transform;
1627
- const { width, height } = box;
1692
+ const {width: width, height: height} = box;
1628
1693
  if (width !== height || stretch) {
1629
1694
  const angle = getAngle(from, to);
1630
1695
  transform = get();
1631
1696
  if (rotate90) {
1632
1697
  scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
1633
1698
  rotateOfOuter(transform, from, angle + 90);
1634
- }
1635
- else {
1699
+ } else {
1636
1700
  scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
1637
1701
  rotateOfOuter(transform, from, angle);
1638
1702
  }
@@ -1640,81 +1704,94 @@ function getTransform(box, from, to, stretch, rotate90) {
1640
1704
  return transform;
1641
1705
  }
1642
1706
 
1643
- const { getDistance } = core.PointHelper;
1644
- const { toPoint } = core.AroundHelper;
1707
+ const {getDistance: getDistance} = core.PointHelper;
1708
+
1709
+ const {toPoint: toPoint} = core.AroundHelper;
1710
+
1645
1711
  const realFrom = {};
1712
+
1646
1713
  const realTo = {};
1714
+
1647
1715
  function conicGradient(paint, box) {
1648
- let { from, to, type, opacity, stretch } = paint;
1649
- toPoint(from || 'center', box, realFrom);
1650
- toPoint(to || 'bottom', box, realTo);
1716
+ let {from: from, to: to, type: type, opacity: opacity, stretch: stretch} = paint;
1717
+ toPoint(from || "center", box, realFrom);
1718
+ toPoint(to || "bottom", box, realTo);
1651
1719
  const style = core.Platform.conicGradientSupport ? core.Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : core.Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
1652
- const data = { type, style };
1720
+ const data = {
1721
+ type: type,
1722
+ style: style
1723
+ };
1653
1724
  applyStops(data, style, paint.stops, opacity);
1654
1725
  const transform = getTransform(box, realFrom, realTo, stretch || 1, core.Platform.conicGradientRotate90);
1655
- if (transform)
1656
- data.transform = transform;
1726
+ if (transform) data.transform = transform;
1657
1727
  return data;
1658
1728
  }
1659
1729
 
1660
1730
  const PaintGradientModule = {
1661
- linearGradient,
1662
- radialGradient,
1663
- conicGradient,
1664
- getTransform
1731
+ linearGradient: linearGradient,
1732
+ radialGradient: radialGradient,
1733
+ conicGradient: conicGradient,
1734
+ getTransform: getTransform
1665
1735
  };
1666
1736
 
1667
- const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = core.BoundsHelper;
1737
+ const {copy: copy, toOffsetOutBounds: toOffsetOutBounds$1} = core.BoundsHelper;
1738
+
1668
1739
  const tempBounds = {};
1740
+
1669
1741
  const offsetOutBounds$1 = {};
1742
+
1670
1743
  function shadow(ui, current, shape) {
1671
1744
  let copyBounds, spreadScale;
1672
- const { __nowWorld: nowWorld, __layout } = ui;
1673
- const { shadow } = ui.__;
1674
- const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
1745
+ const {__nowWorld: nowWorld, __layout: __layout} = ui;
1746
+ const {shadow: shadow} = ui.__;
1747
+ const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
1675
1748
  const other = current.getSameCanvas();
1676
1749
  const end = shadow.length - 1;
1677
1750
  toOffsetOutBounds$1(bounds, offsetOutBounds$1);
1678
1751
  shadow.forEach((item, index) => {
1679
- other.setWorldShadow((offsetOutBounds$1.offsetX + item.x * scaleX), (offsetOutBounds$1.offsetY + item.y * scaleY), item.blur * scaleX, draw.ColorConvert.string(item.color));
1680
- spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
1752
+ let otherScale = 1;
1753
+ if (item.scaleFixed) {
1754
+ const sx = Math.abs(nowWorld.scaleX);
1755
+ if (sx > 1) otherScale = 1 / sx;
1756
+ }
1757
+ other.setWorldShadow(offsetOutBounds$1.offsetX + item.x * scaleX * otherScale, offsetOutBounds$1.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale, draw.ColorConvert.string(item.color));
1758
+ spreadScale = item.spread ? 1 + item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
1681
1759
  drawWorldShadow(other, offsetOutBounds$1, spreadScale, shape);
1682
1760
  copyBounds = bounds;
1683
1761
  if (item.box) {
1684
1762
  other.restore();
1685
1763
  other.save();
1686
1764
  if (worldCanvas) {
1687
- other.copyWorld(other, bounds, nowWorld, 'copy');
1765
+ other.copyWorld(other, bounds, nowWorld, "copy");
1688
1766
  copyBounds = nowWorld;
1689
1767
  }
1690
- worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
1768
+ worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, "destination-out") : other.copyWorld(shape.canvas, shapeBounds, bounds, "destination-out");
1691
1769
  }
1692
1770
  core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1693
- if (end && index < end)
1694
- other.clearWorld(copyBounds, true);
1771
+ if (end && index < end) other.clearWorld(copyBounds, true);
1695
1772
  });
1696
1773
  other.recycle(copyBounds);
1697
1774
  }
1775
+
1698
1776
  function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1699
- const { bounds, shapeBounds } = shape;
1777
+ const {bounds: bounds, shapeBounds: shapeBounds} = shape;
1700
1778
  if (core.Platform.fullImageShadow) {
1701
1779
  copy(tempBounds, canvas.bounds);
1702
- tempBounds.x += (outBounds.x - shapeBounds.x);
1703
- tempBounds.y += (outBounds.y - shapeBounds.y);
1780
+ tempBounds.x += outBounds.x - shapeBounds.x;
1781
+ tempBounds.y += outBounds.y - shapeBounds.y;
1704
1782
  if (spreadScale) {
1705
- const { matrix } = shape;
1706
- tempBounds.x -= (bounds.x + (matrix ? matrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
1707
- tempBounds.y -= (bounds.y + (matrix ? matrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
1783
+ const {fitMatrix: fitMatrix} = shape;
1784
+ tempBounds.x -= (bounds.x + (fitMatrix ? fitMatrix.e : 0) + bounds.width / 2) * (spreadScale - 1);
1785
+ tempBounds.y -= (bounds.y + (fitMatrix ? fitMatrix.f : 0) + bounds.height / 2) * (spreadScale - 1);
1708
1786
  tempBounds.width *= spreadScale;
1709
1787
  tempBounds.height *= spreadScale;
1710
1788
  }
1711
1789
  canvas.copyWorld(shape.canvas, canvas.bounds, tempBounds);
1712
- }
1713
- else {
1790
+ } else {
1714
1791
  if (spreadScale) {
1715
1792
  copy(tempBounds, outBounds);
1716
- tempBounds.x -= (outBounds.width / 2) * (spreadScale - 1);
1717
- tempBounds.y -= (outBounds.height / 2) * (spreadScale - 1);
1793
+ tempBounds.x -= outBounds.width / 2 * (spreadScale - 1);
1794
+ tempBounds.y -= outBounds.height / 2 * (spreadScale - 1);
1718
1795
  tempBounds.width *= spreadScale;
1719
1796
  tempBounds.height *= spreadScale;
1720
1797
  }
@@ -1722,174 +1799,184 @@ function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
1722
1799
  }
1723
1800
  }
1724
1801
 
1725
- const { toOffsetOutBounds } = core.BoundsHelper;
1802
+ const {toOffsetOutBounds: toOffsetOutBounds} = core.BoundsHelper;
1803
+
1726
1804
  const offsetOutBounds = {};
1805
+
1727
1806
  function innerShadow(ui, current, shape) {
1728
1807
  let copyBounds, spreadScale;
1729
- const { __nowWorld: nowWorld, __layout } = ui;
1730
- const { innerShadow } = ui.__;
1731
- const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
1808
+ const {__nowWorld: nowWorld, __layout: __layout} = ui;
1809
+ const {innerShadow: innerShadow} = ui.__;
1810
+ const {worldCanvas: worldCanvas, bounds: bounds, shapeBounds: shapeBounds, scaleX: scaleX, scaleY: scaleY} = shape;
1732
1811
  const other = current.getSameCanvas();
1733
1812
  const end = innerShadow.length - 1;
1734
1813
  toOffsetOutBounds(bounds, offsetOutBounds);
1735
1814
  innerShadow.forEach((item, index) => {
1815
+ let otherScale = 1;
1816
+ if (item.scaleFixed) {
1817
+ const sx = Math.abs(nowWorld.scaleX);
1818
+ if (sx > 1) otherScale = 1 / sx;
1819
+ }
1736
1820
  other.save();
1737
- other.setWorldShadow((offsetOutBounds.offsetX + item.x * scaleX), (offsetOutBounds.offsetY + item.y * scaleY), item.blur * scaleX);
1738
- spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) : 0;
1821
+ other.setWorldShadow(offsetOutBounds.offsetX + item.x * scaleX * otherScale, offsetOutBounds.offsetY + item.y * scaleY * otherScale, item.blur * scaleX * otherScale);
1822
+ spreadScale = item.spread ? 1 - item.spread * 2 / (__layout.boxBounds.width + (__layout.strokeBoxSpread || 0) * 2) * otherScale : 0;
1739
1823
  drawWorldShadow(other, offsetOutBounds, spreadScale, shape);
1740
1824
  other.restore();
1741
1825
  if (worldCanvas) {
1742
- other.copyWorld(other, bounds, nowWorld, 'copy');
1743
- other.copyWorld(worldCanvas, nowWorld, nowWorld, 'source-out');
1826
+ other.copyWorld(other, bounds, nowWorld, "copy");
1827
+ other.copyWorld(worldCanvas, nowWorld, nowWorld, "source-out");
1744
1828
  copyBounds = nowWorld;
1745
- }
1746
- else {
1747
- other.copyWorld(shape.canvas, shapeBounds, bounds, 'source-out');
1829
+ } else {
1830
+ other.copyWorld(shape.canvas, shapeBounds, bounds, "source-out");
1748
1831
  copyBounds = bounds;
1749
1832
  }
1750
- other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), 'source-in');
1833
+ other.fillWorld(copyBounds, draw.ColorConvert.string(item.color), "source-in");
1751
1834
  core.LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
1752
- if (end && index < end)
1753
- other.clearWorld(copyBounds, true);
1835
+ if (end && index < end) other.clearWorld(copyBounds, true);
1754
1836
  });
1755
1837
  other.recycle(copyBounds);
1756
1838
  }
1757
1839
 
1758
1840
  function blur(ui, current, origin) {
1759
- const { blur } = ui.__;
1841
+ const {blur: blur} = ui.__;
1760
1842
  origin.setWorldBlur(blur * ui.__nowWorld.a);
1761
1843
  origin.copyWorldToInner(current, ui.__nowWorld, ui.__layout.renderBounds);
1762
- origin.filter = 'none';
1844
+ origin.filter = "none";
1763
1845
  }
1764
1846
 
1765
- function backgroundBlur(_ui, _current, _shape) {
1766
- }
1847
+ function backgroundBlur(_ui, _current, _shape) {}
1767
1848
 
1768
1849
  const EffectModule = {
1769
- shadow,
1770
- innerShadow,
1771
- blur,
1772
- backgroundBlur
1850
+ shadow: shadow,
1851
+ innerShadow: innerShadow,
1852
+ blur: blur,
1853
+ backgroundBlur: backgroundBlur
1773
1854
  };
1774
1855
 
1775
- const { excludeRenderBounds } = core.LeafBoundsHelper;
1776
- draw.Group.prototype.__renderMask = function (canvas, options) {
1856
+ const {excludeRenderBounds: excludeRenderBounds} = core.LeafBoundsHelper;
1857
+
1858
+ let usedGrayscaleAlpha;
1859
+
1860
+ draw.Group.prototype.__renderMask = function(canvas, options) {
1777
1861
  let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
1778
- const { children } = this;
1862
+ const {children: children} = this;
1779
1863
  for (let i = 0, len = children.length; i < len; i++) {
1780
1864
  child = children[i], mask = child.__.mask;
1781
1865
  if (mask) {
1782
1866
  if (currentMask) {
1783
- maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
1867
+ maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
1784
1868
  maskCanvas = contentCanvas = null;
1785
1869
  }
1786
- if (mask === 'path' || mask === 'clipping-path') {
1787
- if (child.opacity < 1) {
1788
- currentMask = 'opacity-path';
1789
- maskOpacity = child.opacity;
1790
- if (!contentCanvas)
1791
- contentCanvas = getCanvas(canvas);
1792
- }
1793
- else {
1794
- currentMask = 'path';
1870
+ maskOpacity = child.__.opacity;
1871
+ usedGrayscaleAlpha = false;
1872
+ if (mask === "path" || mask === "clipping-path") {
1873
+ if (maskOpacity < 1) {
1874
+ currentMask = "opacity-path";
1875
+ if (!contentCanvas) contentCanvas = getCanvas(canvas);
1876
+ } else {
1877
+ currentMask = "path";
1795
1878
  canvas.save();
1796
1879
  }
1797
1880
  child.__clip(contentCanvas || canvas, options);
1798
- }
1799
- else {
1800
- currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
1801
- if (!maskCanvas)
1802
- maskCanvas = getCanvas(canvas);
1803
- if (!contentCanvas)
1804
- contentCanvas = getCanvas(canvas);
1881
+ } else {
1882
+ currentMask = mask === "grayscale" ? "grayscale" : "alpha";
1883
+ if (!maskCanvas) maskCanvas = getCanvas(canvas);
1884
+ if (!contentCanvas) contentCanvas = getCanvas(canvas);
1805
1885
  child.__render(maskCanvas, options);
1806
1886
  }
1807
- if (mask === 'clipping' || mask === 'clipping-path')
1808
- excludeRenderBounds(child, options) || child.__render(canvas, options);
1887
+ if (mask === "clipping" || mask === "clipping-path") excludeRenderBounds(child, options) || child.__render(canvas, options);
1809
1888
  continue;
1810
1889
  }
1890
+ const childBlendMode = maskOpacity === 1 && child.__.__blendMode;
1891
+ if (childBlendMode) maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, false);
1811
1892
  excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
1893
+ if (childBlendMode) maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, childBlendMode, false);
1812
1894
  }
1813
- maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
1895
+ maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity, undefined, true);
1814
1896
  };
1815
- function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
1897
+
1898
+ function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity, blendMode, recycle) {
1816
1899
  switch (maskMode) {
1817
- case 'grayscale':
1818
- maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
1819
- case 'alpha':
1820
- usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
1821
- break;
1822
- case 'opacity-path':
1823
- copyContent(leaf, canvas, contentCanvas, maskOpacity);
1824
- break;
1825
- case 'path':
1826
- canvas.restore();
1900
+ case "grayscale":
1901
+ if (!usedGrayscaleAlpha) usedGrayscaleAlpha = true, maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
1902
+
1903
+ case "alpha":
1904
+ usePixelMask(leaf, canvas, contentCanvas, maskCanvas, blendMode, recycle);
1905
+ break;
1906
+
1907
+ case "opacity-path":
1908
+ copyContent(leaf, canvas, contentCanvas, maskOpacity, blendMode, recycle);
1909
+ break;
1910
+
1911
+ case "path":
1912
+ if (recycle) canvas.restore();
1827
1913
  }
1828
1914
  }
1915
+
1829
1916
  function getCanvas(canvas) {
1830
1917
  return canvas.getSameCanvas(false, true);
1831
1918
  }
1832
- function usePixelMask(leaf, canvas, content, mask) {
1919
+
1920
+ function usePixelMask(leaf, canvas, content, mask, blendMode, recycle) {
1833
1921
  const realBounds = leaf.__nowWorld;
1834
1922
  content.resetTransform();
1835
1923
  content.opacity = 1;
1836
1924
  content.useMask(mask, realBounds);
1837
- mask.recycle(realBounds);
1838
- copyContent(leaf, canvas, content, 1);
1925
+ if (recycle) mask.recycle(realBounds);
1926
+ copyContent(leaf, canvas, content, 1, blendMode, recycle);
1839
1927
  }
1840
- function copyContent(leaf, canvas, content, maskOpacity) {
1928
+
1929
+ function copyContent(leaf, canvas, content, maskOpacity, blendMode, recycle) {
1841
1930
  const realBounds = leaf.__nowWorld;
1842
1931
  canvas.resetTransform();
1843
1932
  canvas.opacity = maskOpacity;
1844
- canvas.copyWorld(content, realBounds);
1845
- content.recycle(realBounds);
1846
- }
1847
-
1848
- const money = '¥¥$€££¢¢';
1849
- const letter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz';
1850
- const langBefore = '《(「〈『〖【〔{┌<‘“=' + money;
1851
- const langAfter = '》)」〉』〗】〕}┐>’”!?,、。:;‰';
1852
- const langSymbol = '≮≯≈≠=…';
1853
- const langBreak$1 = '—/~|┆·';
1854
- const beforeChar = '{[(<\'"' + langBefore;
1855
- const afterChar = '>)]}%!?,.:;\'"' + langAfter;
1856
- const symbolChar = afterChar + '_#~&*+\\=|' + langSymbol;
1857
- const breakChar = '- ' + langBreak$1;
1858
- const cjkRangeList = [
1859
- [0x4E00, 0x9FFF],
1860
- [0x3400, 0x4DBF],
1861
- [0x20000, 0x2A6DF],
1862
- [0x2A700, 0x2B73F],
1863
- [0x2B740, 0x2B81F],
1864
- [0x2B820, 0x2CEAF],
1865
- [0x2CEB0, 0x2EBEF],
1866
- [0x30000, 0x3134F],
1867
- [0x31350, 0x323AF],
1868
- [0x2E80, 0x2EFF],
1869
- [0x2F00, 0x2FDF],
1870
- [0x2FF0, 0x2FFF],
1871
- [0x3000, 0x303F],
1872
- [0x31C0, 0x31EF],
1873
- [0x3200, 0x32FF],
1874
- [0x3300, 0x33FF],
1875
- [0xF900, 0xFAFF],
1876
- [0xFE30, 0xFE4F],
1877
- [0x1F200, 0x1F2FF],
1878
- [0x2F800, 0x2FA1F],
1879
- ];
1880
- const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u${start.toString(16)}-\\u${end.toString(16)}]`).join('|'));
1933
+ canvas.copyWorld(content, realBounds, undefined, blendMode);
1934
+ recycle ? content.recycle(realBounds) : content.clearWorld(realBounds, true);
1935
+ }
1936
+
1937
+ const money = "¥¥$€££¢¢";
1938
+
1939
+ const letter = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
1940
+
1941
+ const langBefore = "《(「〈『〖【〔{┌<‘“=" + money;
1942
+
1943
+ const langAfter = "》)」〉』〗】〕}┐>’”!?,、。:;‰";
1944
+
1945
+ const langSymbol = "≮≯≈≠=…";
1946
+
1947
+ const langBreak$1 = "—/~|┆·";
1948
+
1949
+ const beforeChar = "{[(<'\"" + langBefore;
1950
+
1951
+ const afterChar = ">)]}%!?,.:;'\"" + langAfter;
1952
+
1953
+ const symbolChar = afterChar + "_#~&*+\\=|" + langSymbol;
1954
+
1955
+ const breakChar = "- " + langBreak$1;
1956
+
1957
+ const cjkRangeList = [ [ 19968, 40959 ], [ 13312, 19903 ], [ 131072, 173791 ], [ 173824, 177983 ], [ 177984, 178207 ], [ 178208, 183983 ], [ 183984, 191471 ], [ 196608, 201551 ], [ 201552, 205743 ], [ 11904, 12031 ], [ 12032, 12255 ], [ 12272, 12287 ], [ 12288, 12351 ], [ 12736, 12783 ], [ 12800, 13055 ], [ 13056, 13311 ], [ 63744, 64255 ], [ 65072, 65103 ], [ 127488, 127743 ], [ 194560, 195103 ] ];
1958
+
1959
+ const cjkReg = new RegExp(cjkRangeList.map(([start, end]) => `[\\u${start.toString(16)}-\\u${end.toString(16)}]`).join("|"));
1960
+
1881
1961
  function mapChar(str) {
1882
1962
  const map = {};
1883
- str.split('').forEach(char => map[char] = true);
1963
+ str.split("").forEach(char => map[char] = true);
1884
1964
  return map;
1885
1965
  }
1966
+
1886
1967
  const letterMap = mapChar(letter);
1968
+
1887
1969
  const beforeMap = mapChar(beforeChar);
1970
+
1888
1971
  const afterMap = mapChar(afterChar);
1972
+
1889
1973
  const symbolMap = mapChar(symbolChar);
1974
+
1890
1975
  const breakMap = mapChar(breakChar);
1976
+
1891
1977
  var CharType;
1892
- (function (CharType) {
1978
+
1979
+ (function(CharType) {
1893
1980
  CharType[CharType["Letter"] = 0] = "Letter";
1894
1981
  CharType[CharType["Single"] = 1] = "Single";
1895
1982
  CharType[CharType["Before"] = 2] = "Before";
@@ -1897,179 +1984,175 @@ var CharType;
1897
1984
  CharType[CharType["Symbol"] = 4] = "Symbol";
1898
1985
  CharType[CharType["Break"] = 5] = "Break";
1899
1986
  })(CharType || (CharType = {}));
1900
- const { Letter: Letter$1, Single: Single$1, Before: Before$1, After: After$1, Symbol: Symbol$1, Break: Break$1 } = CharType;
1987
+
1988
+ const {Letter: Letter$1, Single: Single$1, Before: Before$1, After: After$1, Symbol: Symbol$1, Break: Break$1} = CharType;
1989
+
1901
1990
  function getCharType(char) {
1902
1991
  if (letterMap[char]) {
1903
1992
  return Letter$1;
1904
- }
1905
- else if (breakMap[char]) {
1993
+ } else if (breakMap[char]) {
1906
1994
  return Break$1;
1907
- }
1908
- else if (beforeMap[char]) {
1995
+ } else if (beforeMap[char]) {
1909
1996
  return Before$1;
1910
- }
1911
- else if (afterMap[char]) {
1997
+ } else if (afterMap[char]) {
1912
1998
  return After$1;
1913
- }
1914
- else if (symbolMap[char]) {
1999
+ } else if (symbolMap[char]) {
1915
2000
  return Symbol$1;
1916
- }
1917
- else if (cjkReg.test(char)) {
2001
+ } else if (cjkReg.test(char)) {
1918
2002
  return Single$1;
1919
- }
1920
- else {
2003
+ } else {
1921
2004
  return Letter$1;
1922
2005
  }
1923
2006
  }
1924
2007
 
1925
2008
  const TextRowHelper = {
1926
2009
  trimRight(row) {
1927
- const { words } = row;
2010
+ const {words: words} = row;
1928
2011
  let trimRight = 0, len = words.length, char;
1929
2012
  for (let i = len - 1; i > -1; i--) {
1930
2013
  char = words[i].data[0];
1931
- if (char.char === ' ') {
2014
+ if (char.char === " ") {
1932
2015
  trimRight++;
1933
2016
  row.width -= char.width;
1934
- }
1935
- else {
2017
+ } else {
1936
2018
  break;
1937
2019
  }
1938
2020
  }
1939
- if (trimRight)
1940
- words.splice(len - trimRight, trimRight);
2021
+ if (trimRight) words.splice(len - trimRight, trimRight);
1941
2022
  }
1942
2023
  };
1943
2024
 
1944
2025
  function getTextCase(char, textCase, firstChar) {
1945
2026
  switch (textCase) {
1946
- case 'title':
1947
- return firstChar ? char.toUpperCase() : char;
1948
- case 'upper':
1949
- return char.toUpperCase();
1950
- case 'lower':
1951
- return char.toLowerCase();
1952
- default:
1953
- return char;
2027
+ case "title":
2028
+ return firstChar ? char.toUpperCase() : char;
2029
+
2030
+ case "upper":
2031
+ return char.toUpperCase();
2032
+
2033
+ case "lower":
2034
+ return char.toLowerCase();
2035
+
2036
+ default:
2037
+ return char;
1954
2038
  }
1955
2039
  }
1956
2040
 
1957
- const { trimRight } = TextRowHelper;
1958
- const { Letter, Single, Before, After, Symbol, Break } = CharType;
2041
+ const {trimRight: trimRight} = TextRowHelper;
2042
+
2043
+ const {Letter: Letter, Single: Single, Before: Before, After: After, Symbol: Symbol, Break: Break} = CharType;
2044
+
1959
2045
  let word, row, wordWidth, rowWidth, realWidth;
2046
+
1960
2047
  let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
2048
+
1961
2049
  let textDrawData, rows = [], bounds, findMaxWidth;
2050
+
1962
2051
  function createRows(drawData, content, style) {
1963
2052
  textDrawData = drawData;
1964
2053
  rows = drawData.rows;
1965
2054
  bounds = drawData.bounds;
1966
2055
  findMaxWidth = !bounds.width && !style.autoSizeAlign;
1967
- const { __letterSpacing, paraIndent, textCase } = style;
1968
- const { canvas } = core.Platform;
1969
- const { width, height } = bounds;
1970
- const charMode = width || height || __letterSpacing || (textCase !== 'none');
2056
+ const {__letterSpacing: __letterSpacing, paraIndent: paraIndent, textCase: textCase} = style;
2057
+ const {canvas: canvas} = core.Platform;
2058
+ const {width: width, height: height} = bounds;
2059
+ const charMode = width || height || __letterSpacing || textCase !== "none";
1971
2060
  if (charMode) {
1972
- const wrap = style.textWrap !== 'none';
1973
- const breakAll = style.textWrap === 'break';
2061
+ const wrap = style.textWrap !== "none";
2062
+ const breakAll = style.textWrap === "break";
1974
2063
  paraStart = true;
1975
2064
  lastCharType = null;
1976
2065
  startCharSize = charWidth = charSize = wordWidth = rowWidth = 0;
1977
- word = { data: [] }, row = { words: [] };
1978
- if (__letterSpacing)
1979
- content = [...content];
2066
+ word = {
2067
+ data: []
2068
+ }, row = {
2069
+ words: []
2070
+ };
2071
+ if (__letterSpacing) content = [ ...content ];
1980
2072
  for (let i = 0, len = content.length; i < len; i++) {
1981
2073
  char = content[i];
1982
- if (char === '\n') {
1983
- if (wordWidth)
1984
- addWord();
2074
+ if (char === "\n") {
2075
+ if (wordWidth) addWord();
1985
2076
  row.paraEnd = true;
1986
2077
  addRow();
1987
2078
  paraStart = true;
1988
- }
1989
- else {
2079
+ } else {
1990
2080
  charType = getCharType(char);
1991
- if (charType === Letter && textCase !== 'none')
1992
- char = getTextCase(char, textCase, !wordWidth);
2081
+ if (charType === Letter && textCase !== "none") char = getTextCase(char, textCase, !wordWidth);
1993
2082
  charWidth = canvas.measureText(char).width;
1994
2083
  if (__letterSpacing) {
1995
- if (__letterSpacing < 0)
1996
- charSize = charWidth;
2084
+ if (__letterSpacing < 0) charSize = charWidth;
1997
2085
  charWidth += __letterSpacing;
1998
2086
  }
1999
- langBreak = (charType === Single && (lastCharType === Single || lastCharType === Letter)) || (lastCharType === Single && charType !== After);
2000
- afterBreak = ((charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After));
2087
+ langBreak = charType === Single && (lastCharType === Single || lastCharType === Letter) || lastCharType === Single && charType !== After;
2088
+ afterBreak = (charType === Before || charType === Single) && (lastCharType === Symbol || lastCharType === After);
2001
2089
  realWidth = paraStart && paraIndent ? width - paraIndent : width;
2002
2090
  if (wrap && (width && rowWidth + wordWidth + charWidth > realWidth)) {
2003
2091
  if (breakAll) {
2004
- if (wordWidth)
2005
- addWord();
2006
- if (rowWidth)
2007
- addRow();
2008
- }
2009
- else {
2010
- if (!afterBreak)
2011
- afterBreak = charType === Letter && lastCharType == After;
2012
- if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
2013
- if (wordWidth)
2014
- addWord();
2015
- if (rowWidth)
2016
- addRow();
2017
- }
2018
- else {
2019
- if (rowWidth)
2020
- addRow();
2092
+ if (wordWidth) addWord();
2093
+ if (rowWidth) addRow();
2094
+ } else {
2095
+ if (!afterBreak) afterBreak = charType === Letter && lastCharType == After;
2096
+ if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || wordWidth + charWidth > realWidth) {
2097
+ if (wordWidth) addWord();
2098
+ if (rowWidth) addRow();
2099
+ } else {
2100
+ if (rowWidth) addRow();
2021
2101
  }
2022
2102
  }
2023
2103
  }
2024
- if (char === ' ' && paraStart !== true && (rowWidth + wordWidth) === 0) ;
2025
- else {
2104
+ if (char === " " && paraStart !== true && rowWidth + wordWidth === 0) ; else {
2026
2105
  if (charType === Break) {
2027
- if (char === ' ' && wordWidth)
2028
- addWord();
2106
+ if (char === " " && wordWidth) addWord();
2029
2107
  addChar(char, charWidth);
2030
2108
  addWord();
2031
- }
2032
- else if (langBreak || afterBreak) {
2033
- if (wordWidth)
2034
- addWord();
2109
+ } else if (langBreak || afterBreak) {
2110
+ if (wordWidth) addWord();
2035
2111
  addChar(char, charWidth);
2036
- }
2037
- else {
2112
+ } else {
2038
2113
  addChar(char, charWidth);
2039
2114
  }
2040
2115
  }
2041
2116
  lastCharType = charType;
2042
2117
  }
2043
2118
  }
2044
- if (wordWidth)
2045
- addWord();
2046
- if (rowWidth)
2047
- addRow();
2119
+ if (wordWidth) addWord();
2120
+ if (rowWidth) addRow();
2048
2121
  rows.length > 0 && (rows[rows.length - 1].paraEnd = true);
2049
- }
2050
- else {
2051
- content.split('\n').forEach(content => {
2122
+ } else {
2123
+ content.split("\n").forEach(content => {
2052
2124
  textDrawData.paraNumber++;
2053
2125
  rowWidth = canvas.measureText(content).width;
2054
- rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
2055
- if (findMaxWidth)
2056
- setMaxWidth();
2126
+ rows.push({
2127
+ x: paraIndent || 0,
2128
+ text: content,
2129
+ width: rowWidth,
2130
+ paraStart: true
2131
+ });
2132
+ if (findMaxWidth) setMaxWidth();
2057
2133
  });
2058
2134
  }
2059
2135
  }
2136
+
2060
2137
  function addChar(char, width) {
2061
- if (charSize && !startCharSize)
2062
- startCharSize = charSize;
2063
- word.data.push({ char, width });
2138
+ if (charSize && !startCharSize) startCharSize = charSize;
2139
+ word.data.push({
2140
+ char: char,
2141
+ width: width
2142
+ });
2064
2143
  wordWidth += width;
2065
2144
  }
2145
+
2066
2146
  function addWord() {
2067
2147
  rowWidth += wordWidth;
2068
2148
  word.width = wordWidth;
2069
2149
  row.words.push(word);
2070
- word = { data: [] };
2150
+ word = {
2151
+ data: []
2152
+ };
2071
2153
  wordWidth = 0;
2072
2154
  }
2155
+
2073
2156
  function addRow() {
2074
2157
  if (paraStart) {
2075
2158
  textDrawData.paraNumber++;
@@ -2082,52 +2165,53 @@ function addRow() {
2082
2165
  startCharSize = 0;
2083
2166
  }
2084
2167
  row.width = rowWidth;
2085
- if (bounds.width)
2086
- trimRight(row);
2087
- else if (findMaxWidth)
2088
- setMaxWidth();
2168
+ if (bounds.width) trimRight(row); else if (findMaxWidth) setMaxWidth();
2089
2169
  rows.push(row);
2090
- row = { words: [] };
2170
+ row = {
2171
+ words: []
2172
+ };
2091
2173
  rowWidth = 0;
2092
2174
  }
2175
+
2093
2176
  function setMaxWidth() {
2094
- if (rowWidth > (textDrawData.maxWidth || 0))
2095
- textDrawData.maxWidth = rowWidth;
2177
+ if (rowWidth > (textDrawData.maxWidth || 0)) textDrawData.maxWidth = rowWidth;
2096
2178
  }
2097
2179
 
2098
2180
  const CharMode = 0;
2181
+
2099
2182
  const WordMode = 1;
2183
+
2100
2184
  const TextMode = 2;
2185
+
2101
2186
  function layoutChar(drawData, style, width, _height) {
2102
- const { rows } = drawData;
2103
- const { textAlign, paraIndent, letterSpacing } = style;
2187
+ const {rows: rows} = drawData;
2188
+ const {textAlign: textAlign, paraIndent: paraIndent, letterSpacing: letterSpacing} = style;
2104
2189
  let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
2105
2190
  rows.forEach(row => {
2106
2191
  if (row.words) {
2107
2192
  indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
2108
- addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
2109
- mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
2110
- if (row.isOverflow && !letterSpacing)
2111
- row.textMode = true;
2193
+ addWordWidth = width && (textAlign === "justify" || textAlign === "both") && wordsLength > 1 ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
2194
+ mode = letterSpacing || row.isOverflow ? CharMode : addWordWidth > .01 ? WordMode : TextMode;
2195
+ if (row.isOverflow && !letterSpacing) row.textMode = true;
2112
2196
  if (mode === TextMode) {
2113
2197
  row.x += indentWidth;
2114
2198
  toTextChar$1(row);
2115
- }
2116
- else {
2199
+ } else {
2117
2200
  row.x += indentWidth;
2118
2201
  charX = row.x;
2119
2202
  row.data = [];
2120
2203
  row.words.forEach((word, index) => {
2121
2204
  if (mode === WordMode) {
2122
- wordChar = { char: '', x: charX };
2205
+ wordChar = {
2206
+ char: "",
2207
+ x: charX
2208
+ };
2123
2209
  charX = toWordChar(word.data, charX, wordChar);
2124
- if (row.isOverflow || wordChar.char !== ' ')
2125
- row.data.push(wordChar);
2126
- }
2127
- else {
2210
+ if (row.isOverflow || wordChar.char !== " ") row.data.push(wordChar);
2211
+ } else {
2128
2212
  charX = toChar(word.data, charX, row.data, row.isOverflow);
2129
2213
  }
2130
- if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
2214
+ if (addWordWidth && (!row.paraEnd || textAlign === "both") && index !== wordsLength - 1) {
2131
2215
  charX += addWordWidth;
2132
2216
  row.width += addWordWidth;
2133
2217
  }
@@ -2137,14 +2221,16 @@ function layoutChar(drawData, style, width, _height) {
2137
2221
  }
2138
2222
  });
2139
2223
  }
2224
+
2140
2225
  function toTextChar$1(row) {
2141
- row.text = '';
2226
+ row.text = "";
2142
2227
  row.words.forEach(word => {
2143
2228
  word.data.forEach(char => {
2144
2229
  row.text += char.char;
2145
2230
  });
2146
2231
  });
2147
2232
  }
2233
+
2148
2234
  function toWordChar(data, charX, wordChar) {
2149
2235
  data.forEach(char => {
2150
2236
  wordChar.char += char.char;
@@ -2152,9 +2238,10 @@ function toWordChar(data, charX, wordChar) {
2152
2238
  });
2153
2239
  return charX;
2154
2240
  }
2241
+
2155
2242
  function toChar(data, charX, rowData, isOverflow) {
2156
2243
  data.forEach(char => {
2157
- if (isOverflow || char.char !== ' ') {
2244
+ if (isOverflow || char.char !== " ") {
2158
2245
  char.x = charX;
2159
2246
  rowData.push(char);
2160
2247
  }
@@ -2164,38 +2251,39 @@ function toChar(data, charX, rowData, isOverflow) {
2164
2251
  }
2165
2252
 
2166
2253
  function layoutText(drawData, style) {
2167
- const { rows, bounds } = drawData, countRows = rows.length;
2168
- const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
2169
- let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2254
+ const {rows: rows, bounds: bounds} = drawData, countRows = rows.length;
2255
+ const {__lineHeight: __lineHeight, __baseLine: __baseLine, __letterSpacing: __letterSpacing, __clipText: __clipText, textAlign: textAlign, verticalAlign: verticalAlign, paraSpacing: paraSpacing, autoSizeAlign: autoSizeAlign} = style;
2256
+ let {x: x, y: y, width: width, height: height} = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
2170
2257
  let starY = __baseLine;
2171
2258
  if (__clipText && realHeight > height) {
2172
2259
  realHeight = Math.max(height, __lineHeight);
2173
- if (countRows > 1)
2174
- drawData.overflow = countRows;
2175
- }
2176
- else if (height || autoSizeAlign) {
2260
+ if (countRows > 1) drawData.overflow = countRows;
2261
+ } else if (height || autoSizeAlign) {
2177
2262
  switch (verticalAlign) {
2178
- case 'middle':
2179
- y += (height - realHeight) / 2;
2180
- break;
2181
- case 'bottom': y += (height - realHeight);
2263
+ case "middle":
2264
+ y += (height - realHeight) / 2;
2265
+ break;
2266
+
2267
+ case "bottom":
2268
+ y += height - realHeight;
2182
2269
  }
2183
2270
  }
2184
2271
  starY += y;
2185
- let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
2272
+ let row, rowX, rowWidth, layoutWidth = width || autoSizeAlign ? width : drawData.maxWidth;
2186
2273
  for (let i = 0, len = countRows; i < len; i++) {
2187
2274
  row = rows[i];
2188
2275
  row.x = x;
2189
- if (row.width < width || (row.width > width && !__clipText)) {
2276
+ if (row.width < width || row.width > width && !__clipText) {
2190
2277
  switch (textAlign) {
2191
- case 'center':
2192
- row.x += (layoutWidth - row.width) / 2;
2193
- break;
2194
- case 'right': row.x += layoutWidth - row.width;
2278
+ case "center":
2279
+ row.x += (layoutWidth - row.width) / 2;
2280
+ break;
2281
+
2282
+ case "right":
2283
+ row.x += layoutWidth - row.width;
2195
2284
  }
2196
2285
  }
2197
- if (row.paraStart && paraSpacing && i > 0)
2198
- starY += paraSpacing;
2286
+ if (row.paraStart && paraSpacing && i > 0) starY += paraSpacing;
2199
2287
  row.y = starY;
2200
2288
  starY += __lineHeight;
2201
2289
  if (drawData.overflow > i && starY > realHeight) {
@@ -2209,19 +2297,15 @@ function layoutText(drawData, style) {
2209
2297
  rowWidth = -row.width + style.fontSize + __letterSpacing;
2210
2298
  rowX -= rowWidth;
2211
2299
  rowWidth += style.fontSize;
2212
- }
2213
- else {
2300
+ } else {
2214
2301
  rowWidth -= __letterSpacing;
2215
2302
  }
2216
2303
  }
2217
- if (rowX < bounds.x)
2218
- bounds.x = rowX;
2219
- if (rowWidth > bounds.width)
2220
- bounds.width = rowWidth;
2304
+ if (rowX < bounds.x) bounds.x = rowX;
2305
+ if (rowWidth > bounds.width) bounds.width = rowWidth;
2221
2306
  if (__clipText && width && width < rowWidth) {
2222
2307
  row.isOverflow = true;
2223
- if (!drawData.overflow)
2224
- drawData.overflow = rows.length;
2308
+ if (!drawData.overflow) drawData.overflow = rows.length;
2225
2309
  }
2226
2310
  }
2227
2311
  bounds.y = y;
@@ -2229,20 +2313,16 @@ function layoutText(drawData, style) {
2229
2313
  }
2230
2314
 
2231
2315
  function clipText(drawData, style, x, width) {
2232
- if (!width)
2233
- return;
2234
- const { rows, overflow } = drawData;
2235
- let { textOverflow } = style;
2316
+ if (!width) return;
2317
+ const {rows: rows, overflow: overflow} = drawData;
2318
+ let {textOverflow: textOverflow} = style;
2236
2319
  rows.splice(overflow);
2237
- if (textOverflow && textOverflow !== 'show') {
2238
- if (textOverflow === 'hide')
2239
- textOverflow = '';
2240
- else if (textOverflow === 'ellipsis')
2241
- textOverflow = '...';
2320
+ if (textOverflow && textOverflow !== "show") {
2321
+ if (textOverflow === "hide") textOverflow = ""; else if (textOverflow === "ellipsis") textOverflow = "...";
2242
2322
  let char, charRight;
2243
2323
  const ellipsisWidth = textOverflow ? core.Platform.canvas.measureText(textOverflow).width : 0;
2244
2324
  const right = x + width - ellipsisWidth;
2245
- const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
2325
+ const list = style.textWrap === "none" ? rows : [ rows[overflow - 1] ];
2246
2326
  list.forEach(row => {
2247
2327
  if (row.isOverflow && row.data) {
2248
2328
  let end = row.data.length - 1;
@@ -2251,8 +2331,7 @@ function clipText(drawData, style, x, width) {
2251
2331
  charRight = char.x + char.width;
2252
2332
  if (i === end && charRight < right) {
2253
2333
  break;
2254
- }
2255
- else if ((charRight < right && char.char !== ' ') || !i) {
2334
+ } else if (charRight < right && char.char !== " " || !i) {
2256
2335
  row.data.splice(i + 1);
2257
2336
  row.width -= char.width;
2258
2337
  break;
@@ -2260,15 +2339,18 @@ function clipText(drawData, style, x, width) {
2260
2339
  row.width -= char.width;
2261
2340
  }
2262
2341
  row.width += ellipsisWidth;
2263
- row.data.push({ char: textOverflow, x: charRight });
2264
- if (row.textMode)
2265
- toTextChar(row);
2342
+ row.data.push({
2343
+ char: textOverflow,
2344
+ x: charRight
2345
+ });
2346
+ if (row.textMode) toTextChar(row);
2266
2347
  }
2267
2348
  });
2268
2349
  }
2269
2350
  }
2351
+
2270
2352
  function toTextChar(row) {
2271
- row.text = '';
2353
+ row.text = "";
2272
2354
  row.data.forEach(char => {
2273
2355
  row.text += char.char;
2274
2356
  });
@@ -2277,121 +2359,123 @@ function toTextChar(row) {
2277
2359
 
2278
2360
  function decorationText(drawData, style) {
2279
2361
  let type;
2280
- const { fontSize, textDecoration } = style;
2362
+ const {fontSize: fontSize, textDecoration: textDecoration} = style;
2281
2363
  drawData.decorationHeight = fontSize / 11;
2282
- if (typeof textDecoration === 'object') {
2364
+ if (core.isObject(textDecoration)) {
2283
2365
  type = textDecoration.type;
2284
- if (textDecoration.color)
2285
- drawData.decorationColor = draw.ColorConvert.string(textDecoration.color);
2286
- }
2287
- else
2288
- type = textDecoration;
2366
+ if (textDecoration.color) drawData.decorationColor = draw.ColorConvert.string(textDecoration.color);
2367
+ } else type = textDecoration;
2289
2368
  switch (type) {
2290
- case 'under':
2291
- drawData.decorationY = [fontSize * 0.15];
2292
- break;
2293
- case 'delete':
2294
- drawData.decorationY = [-fontSize * 0.35];
2295
- break;
2296
- case 'under-delete':
2297
- drawData.decorationY = [fontSize * 0.15, -fontSize * 0.35];
2369
+ case "under":
2370
+ drawData.decorationY = [ fontSize * .15 ];
2371
+ break;
2372
+
2373
+ case "delete":
2374
+ drawData.decorationY = [ -fontSize * .35 ];
2375
+ break;
2376
+
2377
+ case "under-delete":
2378
+ drawData.decorationY = [ fontSize * .15, -fontSize * .35 ];
2298
2379
  }
2299
2380
  }
2300
2381
 
2301
- const { top, right, bottom, left } = core.Direction4;
2382
+ const {top: top, right: right, bottom: bottom, left: left} = core.Direction4;
2383
+
2302
2384
  function getDrawData(content, style) {
2303
- if (typeof content !== 'string')
2304
- content = String(content);
2385
+ if (!core.isString(content)) content = String(content);
2305
2386
  let x = 0, y = 0;
2306
- let width = style.__getInput('width') || 0;
2307
- let height = style.__getInput('height') || 0;
2308
- const { textDecoration, __font, __padding: padding } = style;
2387
+ let width = style.__getInput("width") || 0;
2388
+ let height = style.__getInput("height") || 0;
2389
+ const {textDecoration: textDecoration, __font: __font, __padding: padding} = style;
2309
2390
  if (padding) {
2310
- if (width)
2311
- x = padding[left], width -= (padding[right] + padding[left]);
2312
- else if (!style.autoSizeAlign)
2313
- x = padding[left];
2314
- if (height)
2315
- y = padding[top], height -= (padding[top] + padding[bottom]);
2316
- else if (!style.autoSizeAlign)
2317
- y = padding[top];
2391
+ if (width) x = padding[left], width -= padding[right] + padding[left]; else if (!style.autoSizeAlign) x = padding[left];
2392
+ if (height) y = padding[top], height -= padding[top] + padding[bottom]; else if (!style.autoSizeAlign) y = padding[top];
2318
2393
  }
2319
2394
  const drawData = {
2320
- bounds: { x, y, width, height },
2395
+ bounds: {
2396
+ x: x,
2397
+ y: y,
2398
+ width: width,
2399
+ height: height
2400
+ },
2321
2401
  rows: [],
2322
2402
  paraNumber: 0,
2323
2403
  font: core.Platform.canvas.font = __font
2324
2404
  };
2325
2405
  createRows(drawData, content, style);
2326
- if (padding)
2327
- padAutoText(padding, drawData, style, width, height);
2406
+ if (padding) padAutoText(padding, drawData, style, width, height);
2328
2407
  layoutText(drawData, style);
2329
2408
  layoutChar(drawData, style, width);
2330
- if (drawData.overflow)
2331
- clipText(drawData, style, x, width);
2332
- if (textDecoration !== 'none')
2333
- decorationText(drawData, style);
2409
+ if (drawData.overflow) clipText(drawData, style, x, width);
2410
+ if (textDecoration !== "none") decorationText(drawData, style);
2334
2411
  return drawData;
2335
2412
  }
2413
+
2336
2414
  function padAutoText(padding, drawData, style, width, height) {
2337
2415
  if (!width && style.autoSizeAlign) {
2338
2416
  switch (style.textAlign) {
2339
- case 'left':
2340
- offsetText(drawData, 'x', padding[left]);
2341
- break;
2342
- case 'right': offsetText(drawData, 'x', -padding[right]);
2417
+ case "left":
2418
+ offsetText(drawData, "x", padding[left]);
2419
+ break;
2420
+
2421
+ case "right":
2422
+ offsetText(drawData, "x", -padding[right]);
2343
2423
  }
2344
2424
  }
2345
2425
  if (!height && style.autoSizeAlign) {
2346
2426
  switch (style.verticalAlign) {
2347
- case 'top':
2348
- offsetText(drawData, 'y', padding[top]);
2349
- break;
2350
- case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
2427
+ case "top":
2428
+ offsetText(drawData, "y", padding[top]);
2429
+ break;
2430
+
2431
+ case "bottom":
2432
+ offsetText(drawData, "y", -padding[bottom]);
2351
2433
  }
2352
2434
  }
2353
2435
  }
2436
+
2354
2437
  function offsetText(drawData, attrName, value) {
2355
- const { bounds, rows } = drawData;
2438
+ const {bounds: bounds, rows: rows} = drawData;
2356
2439
  bounds[attrName] += value;
2357
- for (let i = 0; i < rows.length; i++)
2358
- rows[i][attrName] += value;
2440
+ for (let i = 0; i < rows.length; i++) rows[i][attrName] += value;
2359
2441
  }
2360
2442
 
2361
2443
  const TextConvertModule = {
2362
- getDrawData
2444
+ getDrawData: getDrawData
2363
2445
  };
2364
2446
 
2365
2447
  function string(color, opacity) {
2366
- const doOpacity = typeof opacity === 'number' && opacity !== 1;
2367
- if (typeof color === 'string') {
2368
- if (doOpacity && draw.ColorConvert.object)
2369
- color = draw.ColorConvert.object(color);
2370
- else
2371
- return color;
2448
+ const doOpacity = core.isNumber(opacity) && opacity < 1;
2449
+ if (core.isString(color)) {
2450
+ if (doOpacity && draw.ColorConvert.object) color = draw.ColorConvert.object(color); else return color;
2372
2451
  }
2373
- let a = color.a === undefined ? 1 : color.a;
2374
- if (doOpacity)
2375
- a *= opacity;
2376
- const rgb = color.r + ',' + color.g + ',' + color.b;
2377
- return a === 1 ? 'rgb(' + rgb + ')' : 'rgba(' + rgb + ',' + a + ')';
2452
+ let a = core.isUndefined(color.a) ? 1 : color.a;
2453
+ if (doOpacity) a *= opacity;
2454
+ const rgb = color.r + "," + color.g + "," + color.b;
2455
+ return a === 1 ? "rgb(" + rgb + ")" : "rgba(" + rgb + "," + a + ")";
2378
2456
  }
2379
2457
 
2380
2458
  const ColorConvertModule = {
2381
- string
2459
+ string: string
2382
2460
  };
2383
2461
 
2384
2462
  Object.assign(draw.TextConvert, TextConvertModule);
2463
+
2385
2464
  Object.assign(draw.ColorConvert, ColorConvertModule);
2465
+
2386
2466
  Object.assign(draw.Paint, PaintModule);
2467
+
2387
2468
  Object.assign(draw.PaintImage, PaintImageModule);
2469
+
2388
2470
  Object.assign(draw.PaintGradient, PaintGradientModule);
2471
+
2389
2472
  Object.assign(draw.Effect, EffectModule);
2390
2473
 
2391
- const { setPoint, addPoint, toBounds } = draw.TwoPointBoundsHelper;
2474
+ const {setPoint: setPoint, addPoint: addPoint, toBounds: toBounds} = draw.TwoPointBoundsHelper;
2475
+
2392
2476
  function getTrimBounds(canvas) {
2393
- const { width, height } = canvas.view;
2394
- const { data } = canvas.context.getImageData(0, 0, width, height);
2477
+ const {width: width, height: height} = canvas.view;
2478
+ const {data: data} = canvas.context.getImageData(0, 0, width, height);
2395
2479
  let x, y, pointBounds, index = 0;
2396
2480
  for (let i = 0; i < data.length; i += 4) {
2397
2481
  if (data[i + 3] !== 0) {
@@ -2401,7 +2485,7 @@ function getTrimBounds(canvas) {
2401
2485
  }
2402
2486
  index++;
2403
2487
  }
2404
- const bounds = new draw.Bounds();
2488
+ const bounds = new draw.Bounds;
2405
2489
  if (pointBounds) {
2406
2490
  toBounds(pointBounds, bounds);
2407
2491
  bounds.scale(1 / canvas.pixelRatio).ceil();
@@ -2415,64 +2499,80 @@ const ExportModule = {
2415
2499
  let result;
2416
2500
  try {
2417
2501
  const fileType = draw.FileHelper.fileType(filename);
2418
- const isDownload = filename.includes('.');
2502
+ const isDownload = filename.includes(".");
2419
2503
  options = draw.FileHelper.getExportOptions(options);
2420
- const { toURL } = draw.Platform;
2421
- const { download } = draw.Platform.origin;
2422
- if (fileType === 'json') {
2423
- isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
2424
- result = { data: isDownload ? true : leaf.toJSON(options.json) };
2425
- }
2426
- else if (fileType === 'svg') {
2427
- isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
2428
- result = { data: isDownload ? true : leaf.toSVG() };
2429
- }
2430
- else {
2504
+ const {toURL: toURL} = draw.Platform;
2505
+ const {download: download} = draw.Platform.origin;
2506
+ if (fileType === "json") {
2507
+ isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), "text"), filename);
2508
+ result = {
2509
+ data: isDownload ? true : leaf.toJSON(options.json)
2510
+ };
2511
+ } else if (fileType === "svg") {
2512
+ isDownload && download(toURL(leaf.toSVG(), "svg"), filename);
2513
+ result = {
2514
+ data: isDownload ? true : leaf.toSVG()
2515
+ };
2516
+ } else {
2431
2517
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
2432
- const { worldTransform, isLeafer, leafer, isFrame } = leaf;
2433
- const { slice, clip, trim, screenshot, padding, onCanvas } = options;
2434
- const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
2518
+ const {worldTransform: worldTransform, isLeafer: isLeafer, leafer: leafer, isFrame: isFrame} = leaf;
2519
+ const {slice: slice, clip: clip, trim: trim, screenshot: screenshot, padding: padding, onCanvas: onCanvas} = options;
2520
+ const smooth = draw.isUndefined(options.smooth) ? leafer ? leafer.config.smooth : true : options.smooth;
2435
2521
  const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
2436
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
2437
- const needFill = draw.FileHelper.isOpaqueImage(filename) || fill, matrix = new draw.Matrix();
2522
+ const fill = isLeafer && screenshot ? draw.isUndefined(options.fill) ? leaf.fill : options.fill : options.fill;
2523
+ const needFill = draw.FileHelper.isOpaqueImage(filename) || fill, matrix = new draw.Matrix;
2438
2524
  if (screenshot) {
2439
- renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
2440
- }
2441
- else {
2442
- let relative = options.relative || (isLeafer ? 'inner' : 'local');
2525
+ renderBounds = screenshot === true ? isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds : screenshot;
2526
+ } else {
2527
+ let relative = options.relative || (isLeafer ? "inner" : "local");
2443
2528
  scaleX = worldTransform.scaleX;
2444
2529
  scaleY = worldTransform.scaleY;
2445
2530
  switch (relative) {
2446
- case 'inner':
2447
- matrix.set(worldTransform);
2448
- break;
2449
- case 'local':
2450
- matrix.set(worldTransform).divide(leaf.localTransform);
2451
- scaleX /= leaf.scaleX;
2452
- scaleY /= leaf.scaleY;
2453
- break;
2454
- case 'world':
2455
- scaleX = 1;
2456
- scaleY = 1;
2457
- break;
2458
- case 'page':
2459
- relative = leafer || leaf;
2460
- default:
2461
- matrix.set(worldTransform).divide(leaf.getTransform(relative));
2462
- const l = relative.worldTransform;
2463
- scaleX /= scaleX / l.scaleX;
2464
- scaleY /= scaleY / l.scaleY;
2531
+ case "inner":
2532
+ matrix.set(worldTransform);
2533
+ break;
2534
+
2535
+ case "local":
2536
+ matrix.set(worldTransform).divide(leaf.localTransform);
2537
+ scaleX /= leaf.scaleX;
2538
+ scaleY /= leaf.scaleY;
2539
+ break;
2540
+
2541
+ case "world":
2542
+ scaleX = 1;
2543
+ scaleY = 1;
2544
+ break;
2545
+
2546
+ case "page":
2547
+ relative = leafer || leaf;
2548
+
2549
+ default:
2550
+ matrix.set(worldTransform).divide(leaf.getTransform(relative));
2551
+ const l = relative.worldTransform;
2552
+ scaleX /= scaleX / l.scaleX;
2553
+ scaleY /= scaleY / l.scaleY;
2465
2554
  }
2466
- renderBounds = leaf.getBounds('render', relative);
2555
+ renderBounds = leaf.getBounds("render", relative);
2467
2556
  }
2468
- const scaleData = { scaleX: 1, scaleY: 1 };
2557
+ const scaleData = {
2558
+ scaleX: 1,
2559
+ scaleY: 1
2560
+ };
2469
2561
  draw.MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
2470
2562
  let pixelRatio = options.pixelRatio || 1;
2471
- let { x, y, width, height } = new draw.Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
2472
- if (clip)
2473
- x += clip.x, y += clip.y, width = clip.width, height = clip.height;
2474
- const renderOptions = { exporting: true, matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
2475
- let canvas = draw.Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
2563
+ let {x: x, y: y, width: width, height: height} = new draw.Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
2564
+ if (clip) x += clip.x, y += clip.y, width = clip.width, height = clip.height;
2565
+ const renderOptions = {
2566
+ exporting: true,
2567
+ matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY)
2568
+ };
2569
+ let canvas = draw.Creator.canvas({
2570
+ width: Math.floor(width),
2571
+ height: Math.floor(height),
2572
+ pixelRatio: pixelRatio,
2573
+ smooth: smooth,
2574
+ contextSettings: contextSettings
2575
+ });
2476
2576
  let sliceLeaf;
2477
2577
  if (slice) {
2478
2578
  sliceLeaf = leaf;
@@ -2481,152 +2581,190 @@ const ExportModule = {
2481
2581
  renderOptions.bounds = canvas.bounds;
2482
2582
  }
2483
2583
  canvas.save();
2484
- if (isFrame && fill !== undefined) {
2485
- const oldFill = leaf.get('fill');
2486
- leaf.fill = '';
2584
+ if (isFrame && !draw.isUndefined(fill)) {
2585
+ const oldFill = leaf.get("fill");
2586
+ leaf.fill = "";
2487
2587
  leaf.__render(canvas, renderOptions);
2488
2588
  leaf.fill = oldFill;
2489
- }
2490
- else {
2589
+ } else {
2491
2590
  leaf.__render(canvas, renderOptions);
2492
2591
  }
2493
2592
  canvas.restore();
2494
- if (sliceLeaf)
2495
- sliceLeaf.__updateWorldOpacity();
2593
+ if (sliceLeaf) sliceLeaf.__updateWorldOpacity();
2496
2594
  if (trim) {
2497
2595
  trimBounds = getTrimBounds(canvas);
2498
- const old = canvas, { width, height } = trimBounds;
2499
- const config = { x: 0, y: 0, width, height, pixelRatio };
2596
+ const old = canvas, {width: width, height: height} = trimBounds;
2597
+ const config = {
2598
+ x: 0,
2599
+ y: 0,
2600
+ width: width,
2601
+ height: height,
2602
+ pixelRatio: pixelRatio
2603
+ };
2500
2604
  canvas = draw.Creator.canvas(config);
2501
2605
  canvas.copyWorld(old, trimBounds, config);
2606
+ old.destroy();
2502
2607
  }
2503
2608
  if (padding) {
2504
2609
  const [top, right, bottom, left] = draw.MathHelper.fourNumber(padding);
2505
- const old = canvas, { width, height } = old;
2506
- canvas = draw.Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
2507
- canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
2610
+ const old = canvas, {width: width, height: height} = old;
2611
+ canvas = draw.Creator.canvas({
2612
+ width: width + left + right,
2613
+ height: height + top + bottom,
2614
+ pixelRatio: pixelRatio
2615
+ });
2616
+ canvas.copyWorld(old, old.bounds, {
2617
+ x: left,
2618
+ y: top,
2619
+ width: width,
2620
+ height: height
2621
+ });
2622
+ old.destroy();
2508
2623
  }
2509
- if (needFill)
2510
- canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
2511
- if (onCanvas)
2512
- onCanvas(canvas);
2513
- const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
2514
- result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
2624
+ if (needFill) canvas.fillWorld(canvas.bounds, fill || "#FFFFFF", "destination-over");
2625
+ if (onCanvas) onCanvas(canvas);
2626
+ const data = filename === "canvas" ? canvas : canvas.export(filename, options);
2627
+ result = {
2628
+ data: data,
2629
+ width: canvas.pixelWidth,
2630
+ height: canvas.pixelHeight,
2631
+ renderBounds: renderBounds,
2632
+ trimBounds: trimBounds
2633
+ };
2515
2634
  }
2516
- }
2517
- catch (error) {
2518
- result = { data: '', error };
2635
+ } catch (error) {
2636
+ result = {
2637
+ data: "",
2638
+ error: error
2639
+ };
2519
2640
  }
2520
2641
  draw.Export.running = false;
2521
2642
  return result;
2522
2643
  },
2523
2644
  export(leaf, filename, options) {
2524
2645
  draw.Export.running = true;
2525
- return addTask((success) => new Promise((resolve) => {
2526
- const getResult = () => __awaiter(this, void 0, void 0, function* () {
2527
- if (!draw.Resource.isComplete)
2528
- return draw.Platform.requestRender(getResult);
2646
+ return addTask(success => new Promise(resolve => {
2647
+ const getResult = () => __awaiter(this, void 0, void 0, function*() {
2648
+ if (!draw.Resource.isComplete) return draw.Platform.requestRender(getResult);
2529
2649
  const result = draw.Export.syncExport(leaf, filename, options);
2530
- if (result.data instanceof Promise)
2531
- result.data = yield result.data;
2650
+ if (result.data instanceof Promise) result.data = yield result.data;
2532
2651
  success(result);
2533
2652
  resolve();
2534
2653
  });
2535
2654
  leaf.updateLayout();
2536
2655
  checkLazy(leaf);
2537
- const { leafer } = leaf;
2538
- if (leafer)
2539
- leafer.waitViewCompleted(getResult);
2540
- else
2541
- getResult();
2656
+ const {leafer: leafer} = leaf;
2657
+ if (leafer) leafer.waitViewCompleted(getResult); else getResult();
2542
2658
  }));
2543
2659
  }
2544
2660
  };
2661
+
2545
2662
  let tasker;
2663
+
2546
2664
  function addTask(task) {
2547
- if (!tasker)
2548
- tasker = new draw.TaskProcessor();
2549
- return new Promise((resolve) => {
2550
- tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
2665
+ if (!tasker) tasker = new draw.TaskProcessor;
2666
+ return new Promise(resolve => {
2667
+ tasker.add(() => __awaiter(this, void 0, void 0, function*() {
2668
+ return yield task(resolve);
2669
+ }), {
2670
+ parallel: false
2671
+ });
2551
2672
  });
2552
2673
  }
2674
+
2553
2675
  function checkLazy(leaf) {
2554
- if (leaf.__.__needComputePaint)
2555
- leaf.__.__computePaint();
2556
- if (leaf.isBranch)
2557
- leaf.children.forEach(child => checkLazy(child));
2676
+ if (leaf.__.__needComputePaint) leaf.__.__computePaint();
2677
+ if (leaf.isBranch) leaf.children.forEach(child => checkLazy(child));
2558
2678
  }
2559
2679
 
2560
2680
  const canvas = draw.LeaferCanvasBase.prototype;
2561
- const debug = draw.Debug.get('@leafer-in/export');
2562
- canvas.export = function (filename, options) {
2563
- const { quality, blob } = draw.FileHelper.getExportOptions(options);
2564
- if (filename.includes('.'))
2565
- return this.saveAs(filename, quality);
2566
- else if (blob)
2567
- return this.toBlob(filename, quality);
2568
- else
2569
- return this.toDataURL(filename, quality);
2681
+
2682
+ const debug = draw.Debug.get("@leafer-in/export");
2683
+
2684
+ canvas.export = function(filename, options) {
2685
+ const {quality: quality, blob: blob} = draw.FileHelper.getExportOptions(options);
2686
+ if (filename.includes(".")) return this.saveAs(filename, quality); else if (blob) return this.toBlob(filename, quality); else return this.toDataURL(filename, quality);
2570
2687
  };
2571
- canvas.toBlob = function (type, quality) {
2572
- return new Promise((resolve) => {
2573
- draw.Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
2688
+
2689
+ canvas.toBlob = function(type, quality) {
2690
+ return new Promise(resolve => {
2691
+ draw.Platform.origin.canvasToBolb(this.view, type, quality).then(blob => {
2574
2692
  resolve(blob);
2575
- }).catch((e) => {
2693
+ }).catch(e => {
2576
2694
  debug.error(e);
2577
2695
  resolve(null);
2578
2696
  });
2579
2697
  });
2580
2698
  };
2581
- canvas.toDataURL = function (type, quality) {
2699
+
2700
+ canvas.toDataURL = function(type, quality) {
2582
2701
  return draw.Platform.origin.canvasToDataURL(this.view, type, quality);
2583
2702
  };
2584
- canvas.saveAs = function (filename, quality) {
2585
- return new Promise((resolve) => {
2703
+
2704
+ canvas.saveAs = function(filename, quality) {
2705
+ return new Promise(resolve => {
2586
2706
  draw.Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
2587
2707
  resolve(true);
2588
- }).catch((e) => {
2708
+ }).catch(e => {
2589
2709
  debug.error(e);
2590
2710
  resolve(false);
2591
2711
  });
2592
2712
  });
2593
2713
  };
2594
2714
 
2595
- draw.Plugin.add('export');
2715
+ draw.Plugin.add("export");
2716
+
2596
2717
  Object.assign(draw.Export, ExportModule);
2597
- draw.UI.prototype.export = function (filename, options) {
2718
+
2719
+ draw.UI.prototype.export = function(filename, options) {
2598
2720
  return draw.Export.export(this, filename, options);
2599
2721
  };
2600
- draw.UI.prototype.syncExport = function (filename, options) {
2722
+
2723
+ draw.UI.prototype.syncExport = function(filename, options) {
2601
2724
  return draw.Export.syncExport(this, filename, options);
2602
2725
  };
2603
2726
 
2604
2727
  Object.assign(core.Creator, {
2605
- interaction: (target, canvas, selector, options) => { return new core$1.InteractionBase(target, canvas, selector, options); },
2728
+ interaction: (target, canvas, selector, options) => new core$1.InteractionBase(target, canvas, selector, options),
2606
2729
  hitCanvas: (options, manager) => new LeaferCanvas(options, manager),
2607
- hitCanvasManager: () => new core$1.HitCanvasManager()
2730
+ hitCanvasManager: () => new core$1.HitCanvasManager
2608
2731
  });
2609
2732
 
2610
2733
  Object.defineProperty(exports, "LeaferImage", {
2611
2734
  enumerable: true,
2612
- get: function () { return core.LeaferImage; }
2735
+ get: function() {
2736
+ return core.LeaferImage;
2737
+ }
2613
2738
  });
2739
+
2614
2740
  exports.Layouter = Layouter;
2741
+
2615
2742
  exports.LeaferCanvas = LeaferCanvas;
2743
+
2616
2744
  exports.Picker = Picker;
2745
+
2617
2746
  exports.Renderer = Renderer;
2747
+
2618
2748
  exports.Selector = Selector;
2749
+
2619
2750
  exports.Watcher = Watcher;
2751
+
2620
2752
  exports.useCanvas = useCanvas;
2621
- Object.keys(core).forEach(function (k) {
2622
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
2753
+
2754
+ Object.keys(core).forEach(function(k) {
2755
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
2623
2756
  enumerable: true,
2624
- get: function () { return core[k]; }
2757
+ get: function() {
2758
+ return core[k];
2759
+ }
2625
2760
  });
2626
2761
  });
2627
- Object.keys(core$1).forEach(function (k) {
2628
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
2762
+
2763
+ Object.keys(core$1).forEach(function(k) {
2764
+ if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
2629
2765
  enumerable: true,
2630
- get: function () { return core$1[k]; }
2766
+ get: function() {
2767
+ return core$1[k];
2768
+ }
2631
2769
  });
2632
2770
  });