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