@leafer-draw/miniapp 1.8.0 → 1.9.1

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