leafer-ui 1.5.3 → 1.6.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.
@@ -45,7 +45,7 @@ const IncrementId = {
45
45
  };
46
46
  const I$2 = IncrementId;
47
47
 
48
- const { round, pow: pow$1, PI: PI$4 } = Math;
48
+ const { round: round$3, pow: pow$1, PI: PI$4 } = Math;
49
49
  const MathHelper = {
50
50
  within(value, min, max) {
51
51
  if (typeof min === 'object')
@@ -109,7 +109,7 @@ const MathHelper = {
109
109
  },
110
110
  float(num, maxLength) {
111
111
  const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
112
- num = round(num * a) / a;
112
+ num = round$3(num * a) / a;
113
113
  return num === -0 ? 0 : num;
114
114
  },
115
115
  getScaleData(scale, size, originSize, scaleData) {
@@ -132,8 +132,15 @@ const MathHelper = {
132
132
  scaleData.scaleX = scale.x;
133
133
  scaleData.scaleY = scale.y;
134
134
  }
135
+ },
136
+ randInt,
137
+ randColor(opacity) {
138
+ return `rgba(${randInt(255)},${randInt(255)},${randInt(255)},${opacity || 1})`;
135
139
  }
136
140
  };
141
+ function randInt(num) {
142
+ return Math.round(Math.random() * num);
143
+ }
137
144
  const OneRadian = PI$4 / 180;
138
145
  const PI2 = PI$4 * 2;
139
146
  const PI_2 = PI$4 / 2;
@@ -431,7 +438,7 @@ const MatrixHelper = {
431
438
  const M$6 = MatrixHelper;
432
439
 
433
440
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
434
- const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
441
+ const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2, PI: PI$3 } = Math;
435
442
  const PointHelper = {
436
443
  defaultPoint: getPointData(),
437
444
  tempPoint: {},
@@ -452,6 +459,10 @@ const PointHelper = {
452
459
  t.x = x;
453
460
  t.y = y;
454
461
  },
462
+ round(t, halfPixel) {
463
+ t.x = halfPixel ? round$2(t.x - 0.5) + 0.5 : round$2(t.x);
464
+ t.y = halfPixel ? round$2(t.y - 0.5) + 0.5 : round$2(t.y);
465
+ },
455
466
  move(t, x, y) {
456
467
  t.x += x;
457
468
  t.y += y;
@@ -1317,6 +1328,7 @@ const StringNumberMap = {
1317
1328
  'E': 1
1318
1329
  };
1319
1330
 
1331
+ const { randColor } = MathHelper;
1320
1332
  class Debug {
1321
1333
  constructor(name) {
1322
1334
  this.repeatMap = {};
@@ -1331,6 +1343,19 @@ class Debug {
1331
1343
  static set exclude(name) {
1332
1344
  this.excludeList = getNameList(name);
1333
1345
  }
1346
+ static drawRepaint(canvas, bounds) {
1347
+ const color = randColor();
1348
+ canvas.fillWorld(bounds, color.replace('1)', '.1)'));
1349
+ canvas.strokeWorld(bounds, color);
1350
+ }
1351
+ static drawBounds(leaf, canvas, _options) {
1352
+ const showHit = Debug.showBounds === 'hit', w = leaf.__nowWorld, color = randColor();
1353
+ if (showHit)
1354
+ canvas.setWorld(w), leaf.__drawHitPath(canvas), canvas.fillStyle = color.replace('1)', '.2)'), canvas.fill();
1355
+ canvas.resetTransform();
1356
+ canvas.setStroke(color, 2);
1357
+ showHit ? canvas.stroke() : canvas.strokeWorld(w, color);
1358
+ }
1334
1359
  log(...messages) {
1335
1360
  if (D$4.enable) {
1336
1361
  if (D$4.filterList.length && D$4.filterList.every(name => name !== this.name))
@@ -1417,7 +1442,7 @@ const Plugin = {
1417
1442
  return rs;
1418
1443
  },
1419
1444
  need(name) {
1420
- console.error('need plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1445
+ console.error('please install plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1421
1446
  }
1422
1447
  };
1423
1448
  setTimeout(() => check.forEach(name => Plugin.has(name, true)));
@@ -2017,7 +2042,7 @@ __decorate([
2017
2042
  contextMethod()
2018
2043
  ], Canvas$1.prototype, "strokeText", null);
2019
2044
 
2020
- const { copy: copy$9 } = MatrixHelper;
2045
+ const { copy: copy$9, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
2021
2046
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
2022
2047
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
2023
2048
  class LeaferCanvasBase extends Canvas$1 {
@@ -2026,6 +2051,8 @@ class LeaferCanvasBase extends Canvas$1 {
2026
2051
  get pixelRatio() { return this.size.pixelRatio; }
2027
2052
  get pixelWidth() { return this.width * this.pixelRatio; }
2028
2053
  get pixelHeight() { return this.height * this.pixelRatio; }
2054
+ get pixelSnap() { return this.config.pixelSnap; }
2055
+ set pixelSnap(value) { this.config.pixelSnap = value; }
2029
2056
  get allowBackgroundColor() { return this.view && this.parentView; }
2030
2057
  constructor(config, manager) {
2031
2058
  super();
@@ -2086,15 +2113,22 @@ class LeaferCanvasBase extends Canvas$1 {
2086
2113
  stopAutoLayout() { }
2087
2114
  setCursor(_cursor) { }
2088
2115
  setWorld(matrix, parentMatrix) {
2089
- const { pixelRatio } = this;
2090
- const w = this.worldTransform;
2091
- if (parentMatrix) {
2092
- const { a, b, c, d, e, f } = parentMatrix;
2093
- this.setTransform(w.a = ((matrix.a * a) + (matrix.b * c)) * pixelRatio, w.b = ((matrix.a * b) + (matrix.b * d)) * pixelRatio, w.c = ((matrix.c * a) + (matrix.d * c)) * pixelRatio, w.d = ((matrix.c * b) + (matrix.d * d)) * pixelRatio, w.e = (((matrix.e * a) + (matrix.f * c) + e)) * pixelRatio, w.f = (((matrix.e * b) + (matrix.f * d) + f)) * pixelRatio);
2094
- }
2095
- else {
2096
- this.setTransform(w.a = matrix.a * pixelRatio, w.b = matrix.b * pixelRatio, w.c = matrix.c * pixelRatio, w.d = matrix.d * pixelRatio, w.e = matrix.e * pixelRatio, w.f = matrix.f * pixelRatio);
2116
+ const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
2117
+ if (parentMatrix)
2118
+ multiplyParent$3(matrix, parentMatrix, w);
2119
+ w.a = matrix.a * pixelRatio;
2120
+ w.b = matrix.b * pixelRatio;
2121
+ w.c = matrix.c * pixelRatio;
2122
+ w.d = matrix.d * pixelRatio;
2123
+ w.e = matrix.e * pixelRatio;
2124
+ w.f = matrix.f * pixelRatio;
2125
+ if (pixelSnap) {
2126
+ if (matrix.half && (matrix.half * pixelRatio) % 2)
2127
+ w.e = round$1(w.e - 0.5) + 0.5, w.f = round$1(w.f - 0.5) + 0.5;
2128
+ else
2129
+ w.e = round$1(w.e), w.f = round$1(w.f);
2097
2130
  }
2131
+ this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
2098
2132
  }
2099
2133
  useWorldTransform(worldTransform) {
2100
2134
  if (worldTransform)
@@ -2237,12 +2271,13 @@ class LeaferCanvasBase extends Canvas$1 {
2237
2271
  return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
2238
2272
  }
2239
2273
  getSameCanvas(useSameWorldTransform, useSameSmooth) {
2240
- const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
2274
+ const { size, pixelSnap } = this, canvas = this.manager ? this.manager.get(size) : Creator.canvas(Object.assign({}, size));
2241
2275
  canvas.save();
2242
2276
  if (useSameWorldTransform)
2243
2277
  copy$9(canvas.worldTransform, this.worldTransform), canvas.useWorldTransform();
2244
2278
  if (useSameSmooth)
2245
2279
  canvas.smooth = this.smooth;
2280
+ canvas.pixelSnap !== pixelSnap && (canvas.pixelSnap = pixelSnap);
2246
2281
  return canvas;
2247
2282
  }
2248
2283
  recycle(clearBounds) {
@@ -3669,7 +3704,7 @@ const Resource = {
3669
3704
  const R = Resource;
3670
3705
 
3671
3706
  const ImageManager = {
3672
- maxRecycled: 100,
3707
+ maxRecycled: 10,
3673
3708
  recycledList: [],
3674
3709
  patternTasker: new TaskProcessor(),
3675
3710
  get(config) {
@@ -4022,9 +4057,8 @@ function hitType(defaultValue) {
4022
4057
  set(value) {
4023
4058
  if (this.__setAttr(key, value)) {
4024
4059
  this.__layout.hitCanvasChanged = true;
4025
- if (Debug.showHitView) {
4060
+ if (Debug.showBounds === 'hit')
4026
4061
  this.__layout.surfaceChanged || this.__layout.surfaceChange();
4027
- }
4028
4062
  if (this.leafer)
4029
4063
  this.leafer.updateCursor();
4030
4064
  }
@@ -4185,7 +4219,7 @@ function registerUIEvent() {
4185
4219
  }
4186
4220
 
4187
4221
  const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
4188
- const matrix$1 = {};
4222
+ const matrix$1 = {}, { round } = Math;
4189
4223
  const LeafHelper = {
4190
4224
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4191
4225
  if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
@@ -4259,6 +4293,8 @@ const LeafHelper = {
4259
4293
  y = x.y, x = x.x;
4260
4294
  x += t.x;
4261
4295
  y += t.y;
4296
+ if (t.leafer && t.leafer.config.pointSnap)
4297
+ x = round(x), y = round(y);
4262
4298
  transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4263
4299
  },
4264
4300
  zoomOfWorld(t, origin, scaleX, scaleY, resize, transition) {
@@ -4497,6 +4533,7 @@ class LeafLayout {
4497
4533
  set contentBounds(bounds) { this._contentBounds = bounds; }
4498
4534
  get strokeBounds() { return this._strokeBounds || this.boxBounds; }
4499
4535
  get renderBounds() { return this._renderBounds || this.boxBounds; }
4536
+ set renderBounds(bounds) { this._renderBounds = bounds; }
4500
4537
  get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
4501
4538
  get localStrokeBounds() { return this._localStrokeBounds || this; }
4502
4539
  get localRenderBounds() { return this._localRenderBounds || this; }
@@ -4515,11 +4552,13 @@ class LeafLayout {
4515
4552
  get height() { return this.boxBounds.height; }
4516
4553
  constructor(leaf) {
4517
4554
  this.leaf = leaf;
4518
- this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
4519
4555
  if (this.leaf.__local)
4520
4556
  this._localRenderBounds = this._localStrokeBounds = this.leaf.__local;
4521
- this.boxChange();
4522
- this.matrixChange();
4557
+ if (leaf.__world) {
4558
+ this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
4559
+ this.boxChange();
4560
+ this.matrixChange();
4561
+ }
4523
4562
  }
4524
4563
  createLocal() {
4525
4564
  const local = this.leaf.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
@@ -4851,6 +4890,9 @@ class ResizeEvent extends Event {
4851
4890
  }
4852
4891
  this.old = oldSize;
4853
4892
  }
4893
+ static isResizing(leaf) {
4894
+ return this.resizingKeys && this.resizingKeys[leaf.innerId] !== undefined;
4895
+ }
4854
4896
  }
4855
4897
  ResizeEvent.RESIZE = 'resize';
4856
4898
 
@@ -4893,6 +4935,7 @@ class RenderEvent extends Event {
4893
4935
  }
4894
4936
  RenderEvent.REQUEST = 'render.request';
4895
4937
  RenderEvent.CHILD_START = 'render.child_start';
4938
+ RenderEvent.CHILD_END = 'render.child_end';
4896
4939
  RenderEvent.START = 'render.start';
4897
4940
  RenderEvent.BEFORE = 'render.before';
4898
4941
  RenderEvent.RENDER = 'render';
@@ -5272,24 +5315,27 @@ const LeafBounds = {
5272
5315
  const LeafRender = {
5273
5316
  __render(canvas, options) {
5274
5317
  if (this.__worldOpacity) {
5318
+ const data = this.__;
5275
5319
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5276
- canvas.opacity = this.__.opacity;
5320
+ canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5277
5321
  if (this.__.__single) {
5278
- if (this.__.eraser === 'path')
5322
+ if (data.eraser === 'path')
5279
5323
  return this.__renderEraser(canvas, options);
5280
5324
  const tempCanvas = canvas.getSameCanvas(true, true);
5281
5325
  this.__draw(tempCanvas, options, canvas);
5282
5326
  if (this.__worldFlipped) {
5283
- canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, this.__.__blendMode, true);
5327
+ canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
5284
5328
  }
5285
5329
  else {
5286
- canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, this.__.__blendMode);
5330
+ canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
5287
5331
  }
5288
5332
  tempCanvas.recycle(this.__nowWorld);
5289
5333
  }
5290
5334
  else {
5291
5335
  this.__draw(canvas, options);
5292
5336
  }
5337
+ if (Debug.showBounds)
5338
+ Debug.drawBounds(this, canvas, options);
5293
5339
  }
5294
5340
  },
5295
5341
  __clip(canvas, options) {
@@ -5319,14 +5365,19 @@ const BranchRender = {
5319
5365
  __render(canvas, options) {
5320
5366
  this.__nowWorld = this.__getNowWorld(options);
5321
5367
  if (this.__worldOpacity) {
5322
- if (this.__.__single) {
5323
- if (this.__.eraser === 'path')
5368
+ const data = this.__;
5369
+ if (data.dim)
5370
+ options.dimOpacity = data.dim === true ? 0.2 : data.dim;
5371
+ else if (data.dimskip)
5372
+ options.dimOpacity && (options.dimOpacity = 0);
5373
+ if (data.__single) {
5374
+ if (data.eraser === 'path')
5324
5375
  return this.__renderEraser(canvas, options);
5325
5376
  const tempCanvas = canvas.getSameCanvas(false, true);
5326
5377
  this.__renderBranch(tempCanvas, options);
5327
5378
  const nowWorld = this.__nowWorld;
5328
- canvas.opacity = this.__.opacity;
5329
- canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
5379
+ canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
5380
+ canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
5330
5381
  tempCanvas.recycle(nowWorld);
5331
5382
  }
5332
5383
  else {
@@ -5401,9 +5452,11 @@ let Leaf = class Leaf {
5401
5452
  reset(data) {
5402
5453
  if (this.leafer)
5403
5454
  this.leafer.forceRender(this.__world);
5404
- this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 };
5405
- if (data !== null)
5406
- this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
5455
+ if (data !== 0) {
5456
+ this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1 };
5457
+ if (data !== null)
5458
+ this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
5459
+ }
5407
5460
  this.__worldOpacity = 1;
5408
5461
  this.__ = new this.__DataProcessor(this);
5409
5462
  this.__layout = new this.__LayoutProcessor(this);
@@ -5539,9 +5592,10 @@ let Leaf = class Leaf {
5539
5592
  if (options.matrix) {
5540
5593
  if (!this.__cameraWorld)
5541
5594
  this.__cameraWorld = {};
5542
- const cameraWorld = this.__cameraWorld;
5543
- multiplyParent(this.__world, options.matrix, cameraWorld, undefined, this.__world);
5595
+ const cameraWorld = this.__cameraWorld, world = this.__world;
5596
+ multiplyParent(world, options.matrix, cameraWorld, undefined, world);
5544
5597
  toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
5598
+ cameraWorld.half !== world.half && (cameraWorld.half = world.half);
5545
5599
  return cameraWorld;
5546
5600
  }
5547
5601
  else {
@@ -5701,7 +5755,7 @@ let Leaf = class Leaf {
5701
5755
  __updateHitCanvas() { }
5702
5756
  __render(_canvas, _options) { }
5703
5757
  __drawFast(_canvas, _options) { }
5704
- __draw(_canvas, _options) { }
5758
+ __draw(_canvas, _options, _originCanvas) { }
5705
5759
  __clip(_canvas, _options) { }
5706
5760
  __renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
5707
5761
  __updateWorldOpacity() { }
@@ -6071,7 +6125,7 @@ class LeafLevelList {
6071
6125
  }
6072
6126
  }
6073
6127
 
6074
- const version = "1.5.3";
6128
+ const version = "1.6.1";
6075
6129
 
6076
6130
  const debug$5 = Debug.get('LeaferCanvas');
6077
6131
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6492,7 +6546,6 @@ function updateChange(updateList) {
6492
6546
  }
6493
6547
 
6494
6548
  const { worldBounds } = LeafBoundsHelper;
6495
- const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
6496
6549
  class LayoutBlockData {
6497
6550
  constructor(list) {
6498
6551
  this.updatedBounds = new Bounds();
@@ -6506,13 +6559,7 @@ class LayoutBlockData {
6506
6559
  this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
6507
6560
  }
6508
6561
  setAfter() {
6509
- const { list } = this.updatedList;
6510
- if (list.some(leaf => leaf.noBounds)) {
6511
- this.afterBounds.set(bigBounds);
6512
- }
6513
- else {
6514
- this.afterBounds.setListWithFn(list, worldBounds);
6515
- }
6562
+ this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
6516
6563
  this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
6517
6564
  }
6518
6565
  merge(data) {
@@ -6714,6 +6761,22 @@ class Renderer {
6714
6761
  requestLayout() {
6715
6762
  this.target.emit(LayoutEvent.REQUEST);
6716
6763
  }
6764
+ checkRender() {
6765
+ if (this.running) {
6766
+ const { target } = this;
6767
+ if (target.isApp) {
6768
+ target.emit(RenderEvent.CHILD_START, target);
6769
+ target.children.forEach(leafer => {
6770
+ leafer.renderer.FPS = this.FPS;
6771
+ leafer.renderer.checkRender();
6772
+ });
6773
+ target.emit(RenderEvent.CHILD_END, target);
6774
+ }
6775
+ if (this.changed && this.canvas.view)
6776
+ this.render();
6777
+ this.target.emit(RenderEvent.NEXT);
6778
+ }
6779
+ }
6717
6780
  render(callback) {
6718
6781
  if (!(this.running && this.canvas.view))
6719
6782
  return this.update();
@@ -6722,8 +6785,6 @@ class Renderer {
6722
6785
  this.totalBounds = new Bounds();
6723
6786
  debug$3.log(target.innerName, '--->');
6724
6787
  try {
6725
- if (!target.isApp)
6726
- target.app.emit(RenderEvent.CHILD_START, target);
6727
6788
  this.emitRender(RenderEvent.START);
6728
6789
  this.renderOnce(callback);
6729
6790
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6791,20 +6852,12 @@ class Renderer {
6791
6852
  }
6792
6853
  clipRender(block) {
6793
6854
  const t = Run.start('PartRender');
6794
- const { canvas } = this;
6795
- const bounds = block.getIntersect(canvas.bounds);
6796
- const includes = block.includes(this.target.__world);
6797
- const realBounds = new Bounds(bounds);
6855
+ const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
6798
6856
  canvas.save();
6799
- if (includes && !Debug.showRepaint) {
6800
- canvas.clear();
6801
- }
6802
- else {
6803
- bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
6804
- canvas.clearWorld(bounds, true);
6805
- canvas.clipWorld(bounds, true);
6806
- }
6807
- this.__render(bounds, includes, realBounds);
6857
+ bounds.spread(Renderer.clipSpread).ceil();
6858
+ canvas.clearWorld(bounds, true);
6859
+ canvas.clipWorld(bounds, true);
6860
+ this.__render(bounds, realBounds);
6808
6861
  canvas.restore();
6809
6862
  Run.end(t);
6810
6863
  }
@@ -6813,28 +6866,22 @@ class Renderer {
6813
6866
  const { canvas } = this;
6814
6867
  canvas.save();
6815
6868
  canvas.clear();
6816
- this.__render(canvas.bounds, true);
6869
+ this.__render(canvas.bounds);
6817
6870
  canvas.restore();
6818
6871
  Run.end(t);
6819
6872
  }
6820
- __render(bounds, includes, realBounds) {
6821
- const options = bounds.includes(this.target.__world) ? { includes } : { bounds, includes };
6873
+ __render(bounds, realBounds) {
6874
+ const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
6822
6875
  if (this.needFill)
6823
- this.canvas.fillWorld(bounds, this.config.fill);
6876
+ canvas.fillWorld(bounds, this.config.fill);
6824
6877
  if (Debug.showRepaint)
6825
- this.canvas.strokeWorld(bounds, 'red');
6826
- this.target.__render(this.canvas, options);
6878
+ Debug.drawRepaint(canvas, bounds);
6879
+ this.target.__render(canvas, options);
6827
6880
  this.renderBounds = realBounds = realBounds || bounds;
6828
6881
  this.renderOptions = options;
6829
6882
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
6830
- if (Debug.showHitView)
6831
- this.renderHitView(options);
6832
- if (Debug.showBoundsView)
6833
- this.renderBoundsView(options);
6834
- this.canvas.updateRender(realBounds);
6835
- }
6836
- renderHitView(_options) { }
6837
- renderBoundsView(_options) { }
6883
+ canvas.updateRender(realBounds);
6884
+ }
6838
6885
  addBlock(block) {
6839
6886
  if (!this.updateBlocks)
6840
6887
  this.updateBlocks = [];
@@ -6850,17 +6897,16 @@ class Renderer {
6850
6897
  }
6851
6898
  }
6852
6899
  __requestRender() {
6853
- if (this.requestTime)
6900
+ const target = this.target;
6901
+ if (this.requestTime || !target)
6854
6902
  return;
6903
+ if (target.parentApp)
6904
+ return target.parentApp.requestRender(false);
6855
6905
  const requestTime = this.requestTime = Date.now();
6856
6906
  Platform.requestRender(() => {
6857
6907
  this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
6858
6908
  this.requestTime = 0;
6859
- if (this.running) {
6860
- if (this.changed && this.canvas.view)
6861
- this.render();
6862
- this.target.emit(RenderEvent.NEXT);
6863
- }
6909
+ this.checkRender();
6864
6910
  });
6865
6911
  }
6866
6912
  __onResize(e) {
@@ -6918,6 +6964,7 @@ class Renderer {
6918
6964
  }
6919
6965
  }
6920
6966
  }
6967
+ Renderer.clipSpread = 10;
6921
6968
 
6922
6969
  const { hitRadiusPoint } = BoundsHelper;
6923
6970
  class Picker {
@@ -7163,6 +7210,7 @@ class UIData extends LeafData {
7163
7210
  return strokeWidth;
7164
7211
  }
7165
7212
  get __hasStroke() { return this.stroke && this.strokeWidth; }
7213
+ get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
7166
7214
  get __hasMultiPaint() {
7167
7215
  const t = this;
7168
7216
  if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
@@ -7207,14 +7255,14 @@ class UIData extends LeafData {
7207
7255
  this.__removeInput('fill');
7208
7256
  PaintImage.recycleImage('fill', this);
7209
7257
  this.__isFills = false;
7210
- if (this.__pixelFill)
7211
- this.__pixelFill = false;
7258
+ this.__pixelFill && (this.__pixelFill = false);
7212
7259
  }
7213
7260
  this._fill = value;
7214
7261
  }
7215
7262
  else if (typeof value === 'object') {
7216
7263
  this.__setInput('fill', value);
7217
- this.__leaf.__layout.boxChanged || this.__leaf.__layout.boxChange();
7264
+ const layout = this.__leaf.__layout;
7265
+ layout.boxChanged || layout.boxChange();
7218
7266
  this.__isFills = true;
7219
7267
  this._fill || (this._fill = emptyPaint);
7220
7268
  }
@@ -7225,14 +7273,14 @@ class UIData extends LeafData {
7225
7273
  this.__removeInput('stroke');
7226
7274
  PaintImage.recycleImage('stroke', this);
7227
7275
  this.__isStrokes = false;
7228
- if (this.__pixelStroke)
7229
- this.__pixelStroke = false;
7276
+ this.__pixelStroke && (this.__pixelStroke = false);
7230
7277
  }
7231
7278
  this._stroke = value;
7232
7279
  }
7233
7280
  else if (typeof value === 'object') {
7234
7281
  this.__setInput('stroke', value);
7235
- this.__leaf.__layout.boxChanged || this.__leaf.__layout.boxChange();
7282
+ const layout = this.__leaf.__layout;
7283
+ layout.boxChanged || layout.boxChange();
7236
7284
  this.__isStrokes = true;
7237
7285
  this._stroke || (this._stroke = emptyPaint);
7238
7286
  }
@@ -7347,6 +7395,31 @@ class TextData extends UIData {
7347
7395
  this._fontWeight = value;
7348
7396
  }
7349
7397
  }
7398
+ setBoxStyle(value) {
7399
+ let t = this.__leaf, box = t.__box;
7400
+ if (value) {
7401
+ const { boxStyle } = this;
7402
+ if (box)
7403
+ for (let key in boxStyle)
7404
+ box[key] = undefined;
7405
+ else
7406
+ box = t.__box = UICreator.get('Rect', 0);
7407
+ const layout = t.__layout, boxLayout = box.__layout;
7408
+ if (!boxStyle)
7409
+ box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7410
+ box.set(value);
7411
+ if (boxLayout.strokeChanged)
7412
+ layout.strokeChange();
7413
+ if (boxLayout.renderChanged)
7414
+ layout.renderChange();
7415
+ box.__updateChange();
7416
+ }
7417
+ else if (box) {
7418
+ t.__box = box.parent = null;
7419
+ box.destroy();
7420
+ }
7421
+ this._boxStyle = value;
7422
+ }
7350
7423
  }
7351
7424
 
7352
7425
  class ImageData extends RectData {
@@ -7384,7 +7457,7 @@ class CanvasData extends RectData {
7384
7457
  const UIBounds = {
7385
7458
  __updateStrokeSpread() {
7386
7459
  let width = 0, boxWidth = 0;
7387
- const data = this.__, { strokeAlign, strokeWidth } = data;
7460
+ const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
7388
7461
  if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
7389
7462
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
7390
7463
  if (!data.__boxStroke) {
@@ -7395,6 +7468,10 @@ const UIBounds = {
7395
7468
  }
7396
7469
  if (data.__useArrow)
7397
7470
  width += strokeWidth * 5;
7471
+ if (box) {
7472
+ width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
7473
+ boxWidth = box.__layout.strokeBoxSpread;
7474
+ }
7398
7475
  this.__layout.strokeBoxSpread = boxWidth;
7399
7476
  return width;
7400
7477
  },
@@ -7413,25 +7490,26 @@ const UIBounds = {
7413
7490
  if (backgroundBlur)
7414
7491
  shapeWidth = Math.max(shapeWidth, backgroundBlur);
7415
7492
  this.__layout.renderShapeSpread = shapeWidth;
7416
- return width + (this.__layout.strokeSpread || 0);
7493
+ width += this.__layout.strokeSpread || 0;
7494
+ return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7417
7495
  }
7418
7496
  };
7419
7497
 
7420
7498
  const UIRender = {
7421
7499
  __updateChange() {
7422
- const data = this.__;
7500
+ const data = this.__, w = this.__world;
7423
7501
  if (data.__useEffect) {
7424
7502
  const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7425
7503
  data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7426
7504
  }
7505
+ const half = data.__hasHalf;
7506
+ w.half !== half && (w.half = half);
7427
7507
  data.__checkSingle();
7428
7508
  const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7429
- if (complex) {
7509
+ if (complex)
7430
7510
  data.__complex = true;
7431
- }
7432
- else {
7511
+ else
7433
7512
  data.__complex && (data.__complex = false);
7434
- }
7435
7513
  },
7436
7514
  __drawFast(canvas, options) {
7437
7515
  drawFast(this, canvas, options);
@@ -7518,10 +7596,11 @@ function drawFast(ui, canvas, options) {
7518
7596
 
7519
7597
  const RectRender = {
7520
7598
  __drawFast(canvas, options) {
7521
- let { width, height, fill, stroke, __drawAfterFill } = this.__;
7599
+ let { x, y, width, height } = this.__layout.boxBounds;
7600
+ const { fill, stroke, __drawAfterFill } = this.__;
7522
7601
  if (fill) {
7523
7602
  canvas.fillStyle = fill;
7524
- canvas.fillRect(0, 0, width, height);
7603
+ canvas.fillRect(x, y, width, height);
7525
7604
  }
7526
7605
  if (__drawAfterFill)
7527
7606
  this.__drawAfterFill(canvas, options);
@@ -7540,14 +7619,14 @@ const RectRender = {
7540
7619
  if (width < 0 || height < 0) {
7541
7620
  canvas.save();
7542
7621
  this.__clip(canvas, options);
7543
- canvas.strokeRect(half, half, width, height);
7622
+ canvas.strokeRect(x + half, y + half, width, height);
7544
7623
  canvas.restore();
7545
7624
  }
7546
7625
  else
7547
- canvas.strokeRect(half, half, width, height);
7626
+ canvas.strokeRect(x + half, y + half, width, height);
7548
7627
  break;
7549
7628
  case 'outside':
7550
- canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
7629
+ canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
7551
7630
  break;
7552
7631
  }
7553
7632
  }
@@ -7703,6 +7782,12 @@ __decorate([
7703
7782
  __decorate([
7704
7783
  surfaceType(false)
7705
7784
  ], UI.prototype, "locked", void 0);
7785
+ __decorate([
7786
+ surfaceType(false)
7787
+ ], UI.prototype, "dim", void 0);
7788
+ __decorate([
7789
+ surfaceType(false)
7790
+ ], UI.prototype, "dimskip", void 0);
7706
7791
  __decorate([
7707
7792
  sortType(0)
7708
7793
  ], UI.prototype, "zIndex", void 0);
@@ -7964,7 +8049,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7964
8049
  start: true,
7965
8050
  hittable: true,
7966
8051
  smooth: true,
7967
- lazySpeard: 100
8052
+ lazySpeard: 100,
7968
8053
  };
7969
8054
  this.leafs = 0;
7970
8055
  this.__eventIds = [];
@@ -8388,13 +8473,13 @@ let Box = class Box extends Group {
8388
8473
  super.__updateRenderBounds();
8389
8474
  copy$3(childrenRenderBounds, renderBounds);
8390
8475
  this.__updateRectRenderBounds();
8391
- isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8476
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8392
8477
  if (isOverflow && this.__.overflow !== 'hide')
8393
8478
  add(renderBounds, childrenRenderBounds);
8394
8479
  }
8395
8480
  else
8396
8481
  this.__updateRectRenderBounds();
8397
- !this.isOverflow !== !isOverflow && (this.isOverflow = isOverflow);
8482
+ this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8398
8483
  }
8399
8484
  __updateRectRenderBounds() { }
8400
8485
  __updateRectChange() { }
@@ -8802,33 +8887,13 @@ Canvas = __decorate([
8802
8887
  registerUI()
8803
8888
  ], Canvas);
8804
8889
 
8805
- const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
8890
+ const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8806
8891
  let Text = class Text extends UI {
8807
8892
  get __tag() { return 'Text'; }
8808
- get textDrawData() {
8809
- this.__layout.update();
8810
- return this.__.__textDrawData;
8811
- }
8893
+ get textDrawData() { this.updateLayout(); return this.__.__textDrawData; }
8812
8894
  constructor(data) {
8813
8895
  super(data);
8814
8896
  }
8815
- __drawHitPath(canvas) {
8816
- const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
8817
- canvas.beginPath();
8818
- if (this.__.__letterSpacing < 0) {
8819
- this.__drawPathByData(canvas);
8820
- }
8821
- else {
8822
- data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
8823
- }
8824
- }
8825
- __drawPathByData(drawer, _data) {
8826
- const { x, y, width, height } = this.__layout.boxBounds;
8827
- drawer.rect(x, y, width, height);
8828
- }
8829
- __drawRenderPath(canvas) {
8830
- canvas.font = this.__.__font;
8831
- }
8832
8897
  __updateTextDrawData() {
8833
8898
  const data = this.__;
8834
8899
  const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
@@ -8845,15 +8910,16 @@ let Text = class Text extends UI {
8845
8910
  const layout = this.__layout;
8846
8911
  const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
8847
8912
  this.__updateTextDrawData();
8848
- const { bounds } = data.__textDrawData;
8913
+ const { bounds: contentBounds } = data.__textDrawData;
8849
8914
  const b = layout.boxBounds;
8915
+ layout.contentBounds = contentBounds;
8850
8916
  if (data.__lineHeight < fontSize)
8851
- spread(bounds, fontSize / 2);
8917
+ spread(contentBounds, fontSize / 2);
8852
8918
  if (autoWidth || autoHeight) {
8853
- b.x = autoWidth ? bounds.x : 0;
8854
- b.y = autoHeight ? bounds.y : 0;
8855
- b.width = autoWidth ? bounds.width : data.width;
8856
- b.height = autoHeight ? bounds.height : data.height;
8919
+ b.x = autoWidth ? contentBounds.x : 0;
8920
+ b.y = autoHeight ? contentBounds.y : 0;
8921
+ b.width = autoWidth ? contentBounds.width : data.width;
8922
+ b.height = autoHeight ? contentBounds.height : data.height;
8857
8923
  if (padding) {
8858
8924
  const [top, right, bottom, left] = data.__padding;
8859
8925
  if (autoWidth)
@@ -8867,23 +8933,45 @@ let Text = class Text extends UI {
8867
8933
  super.__updateBoxBounds();
8868
8934
  if (italic)
8869
8935
  b.width += fontSize * 0.16;
8870
- const contentBounds = includes(b, bounds) ? b : bounds;
8871
- if (!isSame$1(contentBounds, layout.contentBounds)) {
8872
- layout.contentBounds = contentBounds;
8873
- layout.renderChanged = true;
8874
- setList(data.__textBoxBounds = {}, [b, bounds]);
8875
- }
8936
+ const isOverflow = !includes(b, contentBounds) || undefined;
8937
+ if (isOverflow)
8938
+ setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8876
8939
  else
8877
- data.__textBoxBounds = contentBounds;
8940
+ data.__textBoxBounds = b;
8941
+ this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8942
+ }
8943
+ __onUpdateSize() {
8944
+ if (this.__box)
8945
+ this.__box.__onUpdateSize();
8946
+ super.__onUpdateSize();
8878
8947
  }
8879
8948
  __updateRenderSpread() {
8880
8949
  let width = super.__updateRenderSpread();
8881
8950
  if (!width)
8882
- width = this.__layout.boxBounds === this.__layout.contentBounds ? 0 : 1;
8951
+ width = this.isOverflow ? 1 : 0;
8883
8952
  return width;
8884
8953
  }
8885
8954
  __updateRenderBounds() {
8886
- copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
8955
+ const { renderBounds, renderSpread } = this.__layout;
8956
+ copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8957
+ if (this.__box)
8958
+ this.__box.__layout.renderBounds = renderBounds;
8959
+ }
8960
+ __drawRenderPath(canvas) {
8961
+ canvas.font = this.__.__font;
8962
+ }
8963
+ __draw(canvas, options, originCanvas) {
8964
+ const box = this.__box;
8965
+ if (box)
8966
+ box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
8967
+ if (this.textEditing && !Export.running)
8968
+ return;
8969
+ super.__draw(canvas, options, originCanvas);
8970
+ }
8971
+ destroy() {
8972
+ if (this.boxStyle)
8973
+ this.boxStyle = null;
8974
+ super.destroy();
8887
8975
  }
8888
8976
  };
8889
8977
  __decorate([
@@ -8895,6 +8983,9 @@ __decorate([
8895
8983
  __decorate([
8896
8984
  boundsType(0)
8897
8985
  ], Text.prototype, "height", void 0);
8986
+ __decorate([
8987
+ surfaceType()
8988
+ ], Text.prototype, "boxStyle", void 0);
8898
8989
  __decorate([
8899
8990
  dataType(false)
8900
8991
  ], Text.prototype, "resizeFontSize", void 0);
@@ -9058,26 +9149,25 @@ let App = class App extends Leafer {
9058
9149
  this.leafer = this;
9059
9150
  this.watcher.disable();
9060
9151
  this.layouter.disable();
9061
- this.__eventIds.push(this.on_(PropertyEvent.CHANGE, this.__onPropertyChange, this));
9062
9152
  }
9063
9153
  start() {
9064
9154
  super.start();
9065
- this.children.forEach(leafer => leafer.start());
9155
+ this.forEach(leafer => leafer.start());
9066
9156
  }
9067
9157
  stop() {
9068
- this.children.forEach(leafer => leafer.stop());
9158
+ this.forEach(leafer => leafer.stop());
9069
9159
  super.stop();
9070
9160
  }
9071
9161
  unlockLayout() {
9072
9162
  super.unlockLayout();
9073
- this.children.forEach(leafer => leafer.unlockLayout());
9163
+ this.forEach(leafer => leafer.unlockLayout());
9074
9164
  }
9075
9165
  lockLayout() {
9076
9166
  super.lockLayout();
9077
- this.children.forEach(leafer => leafer.lockLayout());
9167
+ this.forEach(leafer => leafer.lockLayout());
9078
9168
  }
9079
9169
  forceRender(bounds, sync) {
9080
- this.children.forEach(leafer => leafer.forceRender(bounds, sync));
9170
+ this.forEach(leafer => leafer.forceRender(bounds, sync));
9081
9171
  }
9082
9172
  addLeafer(merge) {
9083
9173
  const leafer = new Leafer(merge);
@@ -9097,9 +9187,8 @@ let App = class App extends Leafer {
9097
9187
  leafer.canvas.childIndex = index;
9098
9188
  this.__listenChildEvents(leafer);
9099
9189
  }
9100
- __onPropertyChange() {
9101
- if (Debug.showHitView)
9102
- this.children.forEach(leafer => leafer.forceUpdate('surface'));
9190
+ forEach(fn) {
9191
+ this.children.forEach(fn);
9103
9192
  }
9104
9193
  __onCreated() {
9105
9194
  this.created = this.children.every(child => child.created);
@@ -9122,18 +9211,18 @@ let App = class App extends Leafer {
9122
9211
  const m = options.matrix;
9123
9212
  if (m)
9124
9213
  canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
9125
- this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
9214
+ this.forEach(leafer => canvas.copyWorld(leafer.canvas));
9126
9215
  }
9127
9216
  }
9128
9217
  __onResize(event) {
9129
- this.children.forEach(leafer => leafer.resize(event));
9218
+ this.forEach(leafer => leafer.resize(event));
9130
9219
  super.__onResize(event);
9131
9220
  }
9132
9221
  updateLayout() {
9133
- this.children.forEach(leafer => leafer.updateLayout());
9222
+ this.forEach(leafer => leafer.updateLayout());
9134
9223
  }
9135
9224
  __getChildConfig(userConfig) {
9136
- let config = Object.assign({}, this.config);
9225
+ const config = Object.assign({}, this.config);
9137
9226
  config.hittable = config.realCanvas = undefined;
9138
9227
  if (userConfig)
9139
9228
  DataHelper.assign(config, userConfig);
@@ -9692,6 +9781,7 @@ const config = {
9692
9781
  delta: { x: 80 / 4, y: 8.0 },
9693
9782
  },
9694
9783
  pointer: {
9784
+ snap: true,
9695
9785
  hitRadius: 5,
9696
9786
  tapTime: 120,
9697
9787
  longPressTime: 800,
@@ -9786,8 +9876,7 @@ class InteractionBase {
9786
9876
  if (this.downData) {
9787
9877
  const canDrag = PointHelper.getDistance(this.downData, data) > this.p.dragDistance;
9788
9878
  if (canDrag) {
9789
- if (this.waitTap)
9790
- this.pointerWaitCancel();
9879
+ this.pointerWaitCancel();
9791
9880
  this.waitRightTap = false;
9792
9881
  }
9793
9882
  this.dragger.checkDrag(data, canDrag);
@@ -10047,7 +10136,10 @@ class InteractionBase {
10047
10136
  }
10048
10137
  getLocal(clientPoint, updateClient) {
10049
10138
  const clientBounds = this.canvas.getClientBounds(updateClient);
10050
- return { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y };
10139
+ const point = { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y };
10140
+ if (this.p.snap)
10141
+ PointHelper.round(point);
10142
+ return point;
10051
10143
  }
10052
10144
  emitTap(data) {
10053
10145
  this.emit(PointerEvent$1.TAP, data);
@@ -10066,9 +10158,11 @@ class InteractionBase {
10066
10158
  this.waitTap = true;
10067
10159
  }
10068
10160
  tapWaitCancel() {
10069
- clearTimeout(this.tapTimer);
10070
- this.waitTap = false;
10071
- this.tapCount = 0;
10161
+ if (this.waitTap) {
10162
+ clearTimeout(this.tapTimer);
10163
+ this.waitTap = false;
10164
+ this.tapCount = 0;
10165
+ }
10072
10166
  }
10073
10167
  longPressWait(data) {
10074
10168
  clearTimeout(this.longPressTimer);
@@ -10088,8 +10182,10 @@ class InteractionBase {
10088
10182
  return hasLong;
10089
10183
  }
10090
10184
  longPressWaitCancel() {
10091
- clearTimeout(this.longPressTimer);
10092
- this.longPressed = false;
10185
+ if (this.longPressTimer) {
10186
+ clearTimeout(this.longPressTimer);
10187
+ this.longPressed = false;
10188
+ }
10093
10189
  }
10094
10190
  __onResize() {
10095
10191
  const { dragOut } = this.m;
@@ -10179,25 +10275,26 @@ const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
10179
10275
  const inner = {};
10180
10276
  const leaf = Leaf.prototype;
10181
10277
  leaf.__hitWorld = function (point) {
10182
- if (!this.__.hitSelf)
10278
+ const data = this.__;
10279
+ if (!data.hitSelf)
10183
10280
  return false;
10184
- if (this.__.hitRadius) {
10281
+ const world = this.__world, layout = this.__layout;
10282
+ const isSmall = world.width < 10 && world.height < 10;
10283
+ if (data.hitRadius) {
10185
10284
  copy$2(inner, point), point = inner;
10186
- setRadius(point, this.__.hitRadius);
10285
+ setRadius(point, data.hitRadius);
10187
10286
  }
10188
- toInnerRadiusPointOf(point, this.__world, inner);
10189
- const { width, height } = this.__world;
10190
- const isSmall = width < 10 && height < 10;
10191
- if (this.__.hitBox || isSmall) {
10192
- if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
10287
+ toInnerRadiusPointOf(point, world, inner);
10288
+ if (data.hitBox || isSmall) {
10289
+ if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
10193
10290
  return true;
10194
10291
  if (isSmall)
10195
10292
  return false;
10196
10293
  }
10197
- if (this.__layout.hitCanvasChanged || !this.__hitCanvas) {
10294
+ if (layout.hitCanvasChanged || !this.__hitCanvas) {
10198
10295
  this.__updateHitCanvas();
10199
- if (!this.__layout.boundsChanged)
10200
- this.__layout.hitCanvasChanged = false;
10296
+ if (!layout.boundsChanged)
10297
+ layout.hitCanvasChanged = false;
10201
10298
  }
10202
10299
  return this.__hit(inner);
10203
10300
  };
@@ -10210,7 +10307,9 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
10210
10307
  const matrix = new Matrix();
10211
10308
  const ui$1 = UI.prototype;
10212
10309
  ui$1.__updateHitCanvas = function () {
10213
- const data = this.__, { hitCanvasManager } = this.leafer;
10310
+ if (this.__box)
10311
+ this.__box.__updateHitCanvas();
10312
+ const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10214
10313
  const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10215
10314
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
10216
10315
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -10237,6 +10336,8 @@ ui$1.__updateHitCanvas = function () {
10237
10336
  h.setStrokeOptions(data);
10238
10337
  };
10239
10338
  ui$1.__hit = function (inner) {
10339
+ if (this.__box && this.__box.__hit(inner))
10340
+ return true;
10240
10341
  const data = this.__;
10241
10342
  if (data.__isHitPixel && this.__hitPixel(inner))
10242
10343
  return true;
@@ -10285,6 +10386,15 @@ rect.__hitFill = box$1.__hitFill = function (inner) {
10285
10386
  return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10286
10387
  };
10287
10388
 
10389
+ Text.prototype.__drawHitPath = function (canvas) {
10390
+ const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
10391
+ canvas.beginPath();
10392
+ if (__letterSpacing < 0)
10393
+ this.__drawPathByBox(canvas);
10394
+ else
10395
+ data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
10396
+ };
10397
+
10288
10398
  function getSelector(ui) {
10289
10399
  return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10290
10400
  }
@@ -10976,9 +11086,11 @@ const tempBox = new Bounds();
10976
11086
  const tempPoint = {};
10977
11087
  const tempScaleData = {};
10978
11088
  function createData(leafPaint, image, paint, box) {
10979
- const { blendMode, sync } = paint;
11089
+ const { blendMode, changeful, sync } = paint;
10980
11090
  if (blendMode)
10981
11091
  leafPaint.blendMode = blendMode;
11092
+ if (changeful)
11093
+ leafPaint.changeful = changeful;
10982
11094
  if (sync)
10983
11095
  leafPaint.sync = sync;
10984
11096
  leafPaint.data = getPatternData(paint, box, image);
@@ -11211,40 +11323,32 @@ function createPattern(ui, paint, pixelRatio) {
11211
11323
  }
11212
11324
 
11213
11325
  const { abs } = Math;
11214
- function checkImage(ui, canvas, paint, allowPaint) {
11326
+ function checkImage(ui, canvas, paint, allowDraw) {
11215
11327
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11216
- const { pixelRatio } = canvas;
11217
- if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
11328
+ const { pixelRatio } = canvas, { data } = paint;
11329
+ if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
11218
11330
  return false;
11219
11331
  }
11220
11332
  else {
11221
- const { data } = paint;
11222
- if (allowPaint) {
11223
- if (!data.repeat) {
11224
- let { width, height } = data;
11225
- width *= abs(scaleX) * pixelRatio;
11226
- height *= abs(scaleY) * pixelRatio;
11227
- if (data.scaleX) {
11228
- width *= data.scaleX;
11229
- height *= data.scaleY;
11230
- }
11231
- allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
11333
+ if (allowDraw) {
11334
+ if (data.repeat) {
11335
+ allowDraw = false;
11232
11336
  }
11233
11337
  else {
11234
- allowPaint = false;
11338
+ if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
11339
+ let { width, height } = data;
11340
+ width *= abs(scaleX) * pixelRatio;
11341
+ height *= abs(scaleY) * pixelRatio;
11342
+ if (data.scaleX) {
11343
+ width *= data.scaleX;
11344
+ height *= data.scaleY;
11345
+ }
11346
+ allowDraw = (width * height > Platform.image.maxCacheSize);
11347
+ }
11235
11348
  }
11236
11349
  }
11237
- if (allowPaint) {
11238
- canvas.save();
11239
- ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
11240
- if (paint.blendMode)
11241
- canvas.blendMode = paint.blendMode;
11242
- if (data.opacity)
11243
- canvas.opacity *= data.opacity;
11244
- if (data.transform)
11245
- canvas.transform(data.transform);
11246
- canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
11247
- canvas.restore();
11350
+ if (allowDraw) {
11351
+ drawImage(ui, canvas, paint, data);
11248
11352
  return true;
11249
11353
  }
11250
11354
  else {
@@ -11265,13 +11369,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
11265
11369
  }
11266
11370
  }
11267
11371
  }
11372
+ function drawImage(ui, canvas, paint, data) {
11373
+ canvas.save();
11374
+ ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
11375
+ if (paint.blendMode)
11376
+ canvas.blendMode = paint.blendMode;
11377
+ if (data.opacity)
11378
+ canvas.opacity *= data.opacity;
11379
+ if (data.transform)
11380
+ canvas.transform(data.transform);
11381
+ canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
11382
+ canvas.restore();
11383
+ }
11268
11384
 
11269
11385
  function recycleImage(attrName, data) {
11270
11386
  const paints = data['_' + attrName];
11271
11387
  if (paints instanceof Array) {
11272
- let image, recycleMap, input, url;
11388
+ let paint, image, recycleMap, input, url;
11273
11389
  for (let i = 0, len = paints.length; i < len; i++) {
11274
- image = paints[i].image;
11390
+ paint = paints[i];
11391
+ image = paint.image;
11275
11392
  url = image && image.url;
11276
11393
  if (url) {
11277
11394
  if (!recycleMap)
@@ -11286,8 +11403,6 @@ function recycleImage(attrName, data) {
11286
11403
  }
11287
11404
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
11288
11405
  }
11289
- else
11290
- paints[i].style = null;
11291
11406
  }
11292
11407
  }
11293
11408
  return recycleMap;
@@ -11466,7 +11581,7 @@ const { toOffsetOutBounds } = BoundsHelper;
11466
11581
  const offsetOutBounds = {};
11467
11582
  function innerShadow(ui, current, shape) {
11468
11583
  let copyBounds, spreadScale;
11469
- const { __nowWorld: nowWorld, __layout: __layout } = ui;
11584
+ const { __nowWorld: nowWorld, __layout } = ui;
11470
11585
  const { innerShadow } = ui.__;
11471
11586
  const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
11472
11587
  const other = current.getSameCanvas();