@leafer-ui/worker 1.5.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.2";
6128
+ const version = "1.6.0";
6075
6129
 
6076
6130
  class LeaferCanvas extends LeaferCanvasBase {
6077
6131
  get allowBackgroundColor() { return true; }
@@ -6311,7 +6365,6 @@ function updateChange(updateList) {
6311
6365
  }
6312
6366
 
6313
6367
  const { worldBounds } = LeafBoundsHelper;
6314
- const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
6315
6368
  class LayoutBlockData {
6316
6369
  constructor(list) {
6317
6370
  this.updatedBounds = new Bounds();
@@ -6325,13 +6378,7 @@ class LayoutBlockData {
6325
6378
  this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
6326
6379
  }
6327
6380
  setAfter() {
6328
- const { list } = this.updatedList;
6329
- if (list.some(leaf => leaf.noBounds)) {
6330
- this.afterBounds.set(bigBounds);
6331
- }
6332
- else {
6333
- this.afterBounds.setListWithFn(list, worldBounds);
6334
- }
6381
+ this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
6335
6382
  this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
6336
6383
  }
6337
6384
  merge(data) {
@@ -6533,6 +6580,13 @@ class Renderer {
6533
6580
  requestLayout() {
6534
6581
  this.target.emit(LayoutEvent.REQUEST);
6535
6582
  }
6583
+ checkRender() {
6584
+ if (this.running) {
6585
+ if (this.changed && this.canvas.view)
6586
+ this.render();
6587
+ this.target.emit(RenderEvent.NEXT);
6588
+ }
6589
+ }
6536
6590
  render(callback) {
6537
6591
  if (!(this.running && this.canvas.view))
6538
6592
  return this.update();
@@ -6541,8 +6595,6 @@ class Renderer {
6541
6595
  this.totalBounds = new Bounds();
6542
6596
  debug$3.log(target.innerName, '--->');
6543
6597
  try {
6544
- if (!target.isApp)
6545
- target.app.emit(RenderEvent.CHILD_START, target);
6546
6598
  this.emitRender(RenderEvent.START);
6547
6599
  this.renderOnce(callback);
6548
6600
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6610,20 +6662,12 @@ class Renderer {
6610
6662
  }
6611
6663
  clipRender(block) {
6612
6664
  const t = Run.start('PartRender');
6613
- const { canvas } = this;
6614
- const bounds = block.getIntersect(canvas.bounds);
6615
- const includes = block.includes(this.target.__world);
6616
- const realBounds = new Bounds(bounds);
6665
+ const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new Bounds(bounds);
6617
6666
  canvas.save();
6618
- if (includes && !Debug.showRepaint) {
6619
- canvas.clear();
6620
- }
6621
- else {
6622
- bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
6623
- canvas.clearWorld(bounds, true);
6624
- canvas.clipWorld(bounds, true);
6625
- }
6626
- this.__render(bounds, includes, realBounds);
6667
+ bounds.spread(Renderer.clipSpread).ceil();
6668
+ canvas.clearWorld(bounds, true);
6669
+ canvas.clipWorld(bounds, true);
6670
+ this.__render(bounds, block.includes(this.target.__world), realBounds);
6627
6671
  canvas.restore();
6628
6672
  Run.end(t);
6629
6673
  }
@@ -6637,23 +6681,17 @@ class Renderer {
6637
6681
  Run.end(t);
6638
6682
  }
6639
6683
  __render(bounds, includes, realBounds) {
6640
- const options = bounds.includes(this.target.__world) ? { includes } : { bounds, includes };
6684
+ const { canvas } = this, options = includes ? { includes } : { bounds, includes };
6641
6685
  if (this.needFill)
6642
- this.canvas.fillWorld(bounds, this.config.fill);
6686
+ canvas.fillWorld(bounds, this.config.fill);
6643
6687
  if (Debug.showRepaint)
6644
- this.canvas.strokeWorld(bounds, 'red');
6645
- this.target.__render(this.canvas, options);
6688
+ Debug.drawRepaint(canvas, bounds);
6689
+ this.target.__render(canvas, options);
6646
6690
  this.renderBounds = realBounds = realBounds || bounds;
6647
6691
  this.renderOptions = options;
6648
6692
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
6649
- if (Debug.showHitView)
6650
- this.renderHitView(options);
6651
- if (Debug.showBoundsView)
6652
- this.renderBoundsView(options);
6653
- this.canvas.updateRender(realBounds);
6654
- }
6655
- renderHitView(_options) { }
6656
- renderBoundsView(_options) { }
6693
+ canvas.updateRender(realBounds);
6694
+ }
6657
6695
  addBlock(block) {
6658
6696
  if (!this.updateBlocks)
6659
6697
  this.updateBlocks = [];
@@ -6669,17 +6707,24 @@ class Renderer {
6669
6707
  }
6670
6708
  }
6671
6709
  __requestRender() {
6710
+ const target = this.target;
6711
+ if (target.parentApp)
6712
+ return target.parentApp.renderer.update(false);
6672
6713
  if (this.requestTime)
6673
6714
  return;
6674
6715
  const requestTime = this.requestTime = Date.now();
6675
6716
  Platform.requestRender(() => {
6676
6717
  this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
6677
6718
  this.requestTime = 0;
6678
- if (this.running) {
6679
- if (this.changed && this.canvas.view)
6680
- this.render();
6681
- this.target.emit(RenderEvent.NEXT);
6719
+ if (target.isApp) {
6720
+ target.emit(RenderEvent.CHILD_START, target);
6721
+ target.children.forEach(leafer => {
6722
+ leafer.renderer.FPS = this.FPS;
6723
+ leafer.renderer.checkRender();
6724
+ });
6725
+ target.emit(RenderEvent.CHILD_END, target);
6682
6726
  }
6727
+ this.checkRender();
6683
6728
  });
6684
6729
  }
6685
6730
  __onResize(e) {
@@ -6737,6 +6782,7 @@ class Renderer {
6737
6782
  }
6738
6783
  }
6739
6784
  }
6785
+ Renderer.clipSpread = 10;
6740
6786
 
6741
6787
  const { hitRadiusPoint } = BoundsHelper;
6742
6788
  class Picker {
@@ -6982,6 +7028,7 @@ class UIData extends LeafData {
6982
7028
  return strokeWidth;
6983
7029
  }
6984
7030
  get __hasStroke() { return this.stroke && this.strokeWidth; }
7031
+ get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
6985
7032
  get __hasMultiPaint() {
6986
7033
  const t = this;
6987
7034
  if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
@@ -7026,14 +7073,14 @@ class UIData extends LeafData {
7026
7073
  this.__removeInput('fill');
7027
7074
  PaintImage.recycleImage('fill', this);
7028
7075
  this.__isFills = false;
7029
- if (this.__pixelFill)
7030
- this.__pixelFill = false;
7076
+ this.__pixelFill && (this.__pixelFill = false);
7031
7077
  }
7032
7078
  this._fill = value;
7033
7079
  }
7034
7080
  else if (typeof value === 'object') {
7035
7081
  this.__setInput('fill', value);
7036
- this.__leaf.__layout.boxChanged || this.__leaf.__layout.boxChange();
7082
+ const layout = this.__leaf.__layout;
7083
+ layout.boxChanged || layout.boxChange();
7037
7084
  this.__isFills = true;
7038
7085
  this._fill || (this._fill = emptyPaint);
7039
7086
  }
@@ -7044,14 +7091,14 @@ class UIData extends LeafData {
7044
7091
  this.__removeInput('stroke');
7045
7092
  PaintImage.recycleImage('stroke', this);
7046
7093
  this.__isStrokes = false;
7047
- if (this.__pixelStroke)
7048
- this.__pixelStroke = false;
7094
+ this.__pixelStroke && (this.__pixelStroke = false);
7049
7095
  }
7050
7096
  this._stroke = value;
7051
7097
  }
7052
7098
  else if (typeof value === 'object') {
7053
7099
  this.__setInput('stroke', value);
7054
- this.__leaf.__layout.boxChanged || this.__leaf.__layout.boxChange();
7100
+ const layout = this.__leaf.__layout;
7101
+ layout.boxChanged || layout.boxChange();
7055
7102
  this.__isStrokes = true;
7056
7103
  this._stroke || (this._stroke = emptyPaint);
7057
7104
  }
@@ -7166,6 +7213,31 @@ class TextData extends UIData {
7166
7213
  this._fontWeight = value;
7167
7214
  }
7168
7215
  }
7216
+ setBoxStyle(value) {
7217
+ let t = this.__leaf, box = t.__box;
7218
+ if (value) {
7219
+ const { boxStyle } = this;
7220
+ if (box)
7221
+ for (let key in boxStyle)
7222
+ box[key] = undefined;
7223
+ else
7224
+ box = t.__box = UICreator.get('Rect', 0);
7225
+ const layout = t.__layout, boxLayout = box.__layout;
7226
+ if (!boxStyle)
7227
+ box.parent = t, box.__world = t.__world, boxLayout.boxBounds = layout.boxBounds;
7228
+ box.set(value);
7229
+ if (boxLayout.strokeChanged)
7230
+ layout.strokeChange();
7231
+ if (boxLayout.renderChanged)
7232
+ layout.renderChange();
7233
+ box.__updateChange();
7234
+ }
7235
+ else if (box) {
7236
+ t.__box = box.parent = null;
7237
+ box.destroy();
7238
+ }
7239
+ this._boxStyle = value;
7240
+ }
7169
7241
  }
7170
7242
 
7171
7243
  class ImageData extends RectData {
@@ -7203,7 +7275,7 @@ class CanvasData extends RectData {
7203
7275
  const UIBounds = {
7204
7276
  __updateStrokeSpread() {
7205
7277
  let width = 0, boxWidth = 0;
7206
- const data = this.__, { strokeAlign, strokeWidth } = data;
7278
+ const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
7207
7279
  if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
7208
7280
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
7209
7281
  if (!data.__boxStroke) {
@@ -7214,6 +7286,10 @@ const UIBounds = {
7214
7286
  }
7215
7287
  if (data.__useArrow)
7216
7288
  width += strokeWidth * 5;
7289
+ if (box) {
7290
+ width = Math.max(box.__layout.strokeSpread = box.__updateStrokeSpread(), width);
7291
+ boxWidth = box.__layout.strokeBoxSpread;
7292
+ }
7217
7293
  this.__layout.strokeBoxSpread = boxWidth;
7218
7294
  return width;
7219
7295
  },
@@ -7232,25 +7308,26 @@ const UIBounds = {
7232
7308
  if (backgroundBlur)
7233
7309
  shapeWidth = Math.max(shapeWidth, backgroundBlur);
7234
7310
  this.__layout.renderShapeSpread = shapeWidth;
7235
- return width + (this.__layout.strokeSpread || 0);
7311
+ width += this.__layout.strokeSpread || 0;
7312
+ return this.__box ? Math.max(this.__box.__updateRenderSpread(), width) : width;
7236
7313
  }
7237
7314
  };
7238
7315
 
7239
7316
  const UIRender = {
7240
7317
  __updateChange() {
7241
- const data = this.__;
7318
+ const data = this.__, w = this.__world;
7242
7319
  if (data.__useEffect) {
7243
7320
  const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7244
7321
  data.__useEffect = !!(shadow || innerShadow || blur || backgroundBlur || filter);
7245
7322
  }
7323
+ const half = data.__hasHalf;
7324
+ w.half !== half && (w.half = half);
7246
7325
  data.__checkSingle();
7247
7326
  const complex = data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect;
7248
- if (complex) {
7327
+ if (complex)
7249
7328
  data.__complex = true;
7250
- }
7251
- else {
7329
+ else
7252
7330
  data.__complex && (data.__complex = false);
7253
- }
7254
7331
  },
7255
7332
  __drawFast(canvas, options) {
7256
7333
  drawFast(this, canvas, options);
@@ -7337,10 +7414,11 @@ function drawFast(ui, canvas, options) {
7337
7414
 
7338
7415
  const RectRender = {
7339
7416
  __drawFast(canvas, options) {
7340
- let { width, height, fill, stroke, __drawAfterFill } = this.__;
7417
+ let { x, y, width, height } = this.__layout.boxBounds;
7418
+ const { fill, stroke, __drawAfterFill } = this.__;
7341
7419
  if (fill) {
7342
7420
  canvas.fillStyle = fill;
7343
- canvas.fillRect(0, 0, width, height);
7421
+ canvas.fillRect(x, y, width, height);
7344
7422
  }
7345
7423
  if (__drawAfterFill)
7346
7424
  this.__drawAfterFill(canvas, options);
@@ -7359,14 +7437,14 @@ const RectRender = {
7359
7437
  if (width < 0 || height < 0) {
7360
7438
  canvas.save();
7361
7439
  this.__clip(canvas, options);
7362
- canvas.strokeRect(half, half, width, height);
7440
+ canvas.strokeRect(x + half, y + half, width, height);
7363
7441
  canvas.restore();
7364
7442
  }
7365
7443
  else
7366
- canvas.strokeRect(half, half, width, height);
7444
+ canvas.strokeRect(x + half, y + half, width, height);
7367
7445
  break;
7368
7446
  case 'outside':
7369
- canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
7447
+ canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
7370
7448
  break;
7371
7449
  }
7372
7450
  }
@@ -7522,6 +7600,12 @@ __decorate([
7522
7600
  __decorate([
7523
7601
  surfaceType(false)
7524
7602
  ], UI.prototype, "locked", void 0);
7603
+ __decorate([
7604
+ surfaceType(false)
7605
+ ], UI.prototype, "dim", void 0);
7606
+ __decorate([
7607
+ surfaceType(false)
7608
+ ], UI.prototype, "dimskip", void 0);
7525
7609
  __decorate([
7526
7610
  sortType(0)
7527
7611
  ], UI.prototype, "zIndex", void 0);
@@ -7783,7 +7867,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7783
7867
  start: true,
7784
7868
  hittable: true,
7785
7869
  smooth: true,
7786
- lazySpeard: 100
7870
+ lazySpeard: 100,
7787
7871
  };
7788
7872
  this.leafs = 0;
7789
7873
  this.__eventIds = [];
@@ -8207,13 +8291,13 @@ let Box = class Box extends Group {
8207
8291
  super.__updateRenderBounds();
8208
8292
  copy$3(childrenRenderBounds, renderBounds);
8209
8293
  this.__updateRectRenderBounds();
8210
- isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8294
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
8211
8295
  if (isOverflow && this.__.overflow !== 'hide')
8212
8296
  add(renderBounds, childrenRenderBounds);
8213
8297
  }
8214
8298
  else
8215
8299
  this.__updateRectRenderBounds();
8216
- !this.isOverflow !== !isOverflow && (this.isOverflow = isOverflow);
8300
+ this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8217
8301
  }
8218
8302
  __updateRectRenderBounds() { }
8219
8303
  __updateRectChange() { }
@@ -8621,33 +8705,13 @@ Canvas = __decorate([
8621
8705
  registerUI()
8622
8706
  ], Canvas);
8623
8707
 
8624
- const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
8708
+ const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8625
8709
  let Text = class Text extends UI {
8626
8710
  get __tag() { return 'Text'; }
8627
- get textDrawData() {
8628
- this.__layout.update();
8629
- return this.__.__textDrawData;
8630
- }
8711
+ get textDrawData() { this.updateLayout(); return this.__.__textDrawData; }
8631
8712
  constructor(data) {
8632
8713
  super(data);
8633
8714
  }
8634
- __drawHitPath(canvas) {
8635
- const { __lineHeight, fontSize, __baseLine, __textDrawData: data } = this.__;
8636
- canvas.beginPath();
8637
- if (this.__.__letterSpacing < 0) {
8638
- this.__drawPathByData(canvas);
8639
- }
8640
- else {
8641
- data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
8642
- }
8643
- }
8644
- __drawPathByData(drawer, _data) {
8645
- const { x, y, width, height } = this.__layout.boxBounds;
8646
- drawer.rect(x, y, width, height);
8647
- }
8648
- __drawRenderPath(canvas) {
8649
- canvas.font = this.__.__font;
8650
- }
8651
8715
  __updateTextDrawData() {
8652
8716
  const data = this.__;
8653
8717
  const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data;
@@ -8664,15 +8728,16 @@ let Text = class Text extends UI {
8664
8728
  const layout = this.__layout;
8665
8729
  const { fontSize, italic, padding, __autoWidth: autoWidth, __autoHeight: autoHeight } = data;
8666
8730
  this.__updateTextDrawData();
8667
- const { bounds } = data.__textDrawData;
8731
+ const { bounds: contentBounds } = data.__textDrawData;
8668
8732
  const b = layout.boxBounds;
8733
+ layout.contentBounds = contentBounds;
8669
8734
  if (data.__lineHeight < fontSize)
8670
- spread(bounds, fontSize / 2);
8735
+ spread(contentBounds, fontSize / 2);
8671
8736
  if (autoWidth || autoHeight) {
8672
- b.x = autoWidth ? bounds.x : 0;
8673
- b.y = autoHeight ? bounds.y : 0;
8674
- b.width = autoWidth ? bounds.width : data.width;
8675
- b.height = autoHeight ? bounds.height : data.height;
8737
+ b.x = autoWidth ? contentBounds.x : 0;
8738
+ b.y = autoHeight ? contentBounds.y : 0;
8739
+ b.width = autoWidth ? contentBounds.width : data.width;
8740
+ b.height = autoHeight ? contentBounds.height : data.height;
8676
8741
  if (padding) {
8677
8742
  const [top, right, bottom, left] = data.__padding;
8678
8743
  if (autoWidth)
@@ -8686,23 +8751,45 @@ let Text = class Text extends UI {
8686
8751
  super.__updateBoxBounds();
8687
8752
  if (italic)
8688
8753
  b.width += fontSize * 0.16;
8689
- const contentBounds = includes(b, bounds) ? b : bounds;
8690
- if (!isSame$1(contentBounds, layout.contentBounds)) {
8691
- layout.contentBounds = contentBounds;
8692
- layout.renderChanged = true;
8693
- setList(data.__textBoxBounds = {}, [b, bounds]);
8694
- }
8754
+ const isOverflow = !includes(b, contentBounds) || undefined;
8755
+ if (isOverflow)
8756
+ setList(data.__textBoxBounds = {}, [b, contentBounds]), layout.renderChanged = true;
8695
8757
  else
8696
- data.__textBoxBounds = contentBounds;
8758
+ data.__textBoxBounds = b;
8759
+ this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
8760
+ }
8761
+ __onUpdateSize() {
8762
+ if (this.__box)
8763
+ this.__box.__onUpdateSize();
8764
+ super.__onUpdateSize();
8697
8765
  }
8698
8766
  __updateRenderSpread() {
8699
8767
  let width = super.__updateRenderSpread();
8700
8768
  if (!width)
8701
- width = this.__layout.boxBounds === this.__layout.contentBounds ? 0 : 1;
8769
+ width = this.isOverflow ? 1 : 0;
8702
8770
  return width;
8703
8771
  }
8704
8772
  __updateRenderBounds() {
8705
- copyAndSpread(this.__layout.renderBounds, this.__.__textBoxBounds, this.__layout.renderSpread);
8773
+ const { renderBounds, renderSpread } = this.__layout;
8774
+ copyAndSpread(renderBounds, this.__.__textBoxBounds, renderSpread);
8775
+ if (this.__box)
8776
+ this.__box.__layout.renderBounds = renderBounds;
8777
+ }
8778
+ __drawRenderPath(canvas) {
8779
+ canvas.font = this.__.__font;
8780
+ }
8781
+ __draw(canvas, options, originCanvas) {
8782
+ const box = this.__box;
8783
+ if (box)
8784
+ box.__nowWorld = this.__nowWorld, box.__draw(canvas, options, originCanvas);
8785
+ if (this.textEditing && !Export.running)
8786
+ return;
8787
+ super.__draw(canvas, options, originCanvas);
8788
+ }
8789
+ destroy() {
8790
+ if (this.boxStyle)
8791
+ this.boxStyle = null;
8792
+ super.destroy();
8706
8793
  }
8707
8794
  };
8708
8795
  __decorate([
@@ -8714,6 +8801,9 @@ __decorate([
8714
8801
  __decorate([
8715
8802
  boundsType(0)
8716
8803
  ], Text.prototype, "height", void 0);
8804
+ __decorate([
8805
+ surfaceType()
8806
+ ], Text.prototype, "boxStyle", void 0);
8717
8807
  __decorate([
8718
8808
  dataType(false)
8719
8809
  ], Text.prototype, "resizeFontSize", void 0);
@@ -8877,26 +8967,25 @@ let App = class App extends Leafer {
8877
8967
  this.leafer = this;
8878
8968
  this.watcher.disable();
8879
8969
  this.layouter.disable();
8880
- this.__eventIds.push(this.on_(PropertyEvent.CHANGE, this.__onPropertyChange, this));
8881
8970
  }
8882
8971
  start() {
8883
8972
  super.start();
8884
- this.children.forEach(leafer => leafer.start());
8973
+ this.forEach(leafer => leafer.start());
8885
8974
  }
8886
8975
  stop() {
8887
- this.children.forEach(leafer => leafer.stop());
8976
+ this.forEach(leafer => leafer.stop());
8888
8977
  super.stop();
8889
8978
  }
8890
8979
  unlockLayout() {
8891
8980
  super.unlockLayout();
8892
- this.children.forEach(leafer => leafer.unlockLayout());
8981
+ this.forEach(leafer => leafer.unlockLayout());
8893
8982
  }
8894
8983
  lockLayout() {
8895
8984
  super.lockLayout();
8896
- this.children.forEach(leafer => leafer.lockLayout());
8985
+ this.forEach(leafer => leafer.lockLayout());
8897
8986
  }
8898
8987
  forceRender(bounds, sync) {
8899
- this.children.forEach(leafer => leafer.forceRender(bounds, sync));
8988
+ this.forEach(leafer => leafer.forceRender(bounds, sync));
8900
8989
  }
8901
8990
  addLeafer(merge) {
8902
8991
  const leafer = new Leafer(merge);
@@ -8916,9 +9005,8 @@ let App = class App extends Leafer {
8916
9005
  leafer.canvas.childIndex = index;
8917
9006
  this.__listenChildEvents(leafer);
8918
9007
  }
8919
- __onPropertyChange() {
8920
- if (Debug.showHitView)
8921
- this.children.forEach(leafer => leafer.forceUpdate('surface'));
9008
+ forEach(fn) {
9009
+ this.children.forEach(fn);
8922
9010
  }
8923
9011
  __onCreated() {
8924
9012
  this.created = this.children.every(child => child.created);
@@ -8941,18 +9029,18 @@ let App = class App extends Leafer {
8941
9029
  const m = options.matrix;
8942
9030
  if (m)
8943
9031
  canvas.setTransform(m.a, m.b, m.c, m.d, m.e, m.f);
8944
- this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
9032
+ this.forEach(leafer => canvas.copyWorld(leafer.canvas));
8945
9033
  }
8946
9034
  }
8947
9035
  __onResize(event) {
8948
- this.children.forEach(leafer => leafer.resize(event));
9036
+ this.forEach(leafer => leafer.resize(event));
8949
9037
  super.__onResize(event);
8950
9038
  }
8951
9039
  updateLayout() {
8952
- this.children.forEach(leafer => leafer.updateLayout());
9040
+ this.forEach(leafer => leafer.updateLayout());
8953
9041
  }
8954
9042
  __getChildConfig(userConfig) {
8955
- let config = Object.assign({}, this.config);
9043
+ const config = Object.assign({}, this.config);
8956
9044
  config.hittable = config.realCanvas = undefined;
8957
9045
  if (userConfig)
8958
9046
  DataHelper.assign(config, userConfig);
@@ -9511,6 +9599,7 @@ const config = {
9511
9599
  delta: { x: 80 / 4, y: 8.0 },
9512
9600
  },
9513
9601
  pointer: {
9602
+ snap: true,
9514
9603
  hitRadius: 5,
9515
9604
  tapTime: 120,
9516
9605
  longPressTime: 800,
@@ -9605,7 +9694,7 @@ class InteractionBase {
9605
9694
  if (this.downData) {
9606
9695
  const canDrag = PointHelper.getDistance(this.downData, data) > this.p.dragDistance;
9607
9696
  if (canDrag) {
9608
- if (this.waitTap)
9697
+ if (this.waitTap || this.longPressTimer)
9609
9698
  this.pointerWaitCancel();
9610
9699
  this.waitRightTap = false;
9611
9700
  }
@@ -9866,7 +9955,10 @@ class InteractionBase {
9866
9955
  }
9867
9956
  getLocal(clientPoint, updateClient) {
9868
9957
  const clientBounds = this.canvas.getClientBounds(updateClient);
9869
- return { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y };
9958
+ const point = { x: clientPoint.clientX - clientBounds.x, y: clientPoint.clientY - clientBounds.y };
9959
+ if (this.p.snap)
9960
+ PointHelper.round(point);
9961
+ return point;
9870
9962
  }
9871
9963
  emitTap(data) {
9872
9964
  this.emit(PointerEvent.TAP, data);
@@ -9998,25 +10090,26 @@ const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
9998
10090
  const inner = {};
9999
10091
  const leaf = Leaf.prototype;
10000
10092
  leaf.__hitWorld = function (point) {
10001
- if (!this.__.hitSelf)
10093
+ const data = this.__;
10094
+ if (!data.hitSelf)
10002
10095
  return false;
10003
- if (this.__.hitRadius) {
10096
+ const world = this.__world, layout = this.__layout;
10097
+ const isSmall = world.width < 10 && world.height < 10;
10098
+ if (data.hitRadius) {
10004
10099
  copy$2(inner, point), point = inner;
10005
- setRadius(point, this.__.hitRadius);
10100
+ setRadius(point, data.hitRadius);
10006
10101
  }
10007
- toInnerRadiusPointOf(point, this.__world, inner);
10008
- const { width, height } = this.__world;
10009
- const isSmall = width < 10 && height < 10;
10010
- if (this.__.hitBox || isSmall) {
10011
- if (BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner))
10102
+ toInnerRadiusPointOf(point, world, inner);
10103
+ if (data.hitBox || isSmall) {
10104
+ if (BoundsHelper.hitRadiusPoint(layout.boxBounds, inner))
10012
10105
  return true;
10013
10106
  if (isSmall)
10014
10107
  return false;
10015
10108
  }
10016
- if (this.__layout.hitCanvasChanged || !this.__hitCanvas) {
10109
+ if (layout.hitCanvasChanged || !this.__hitCanvas) {
10017
10110
  this.__updateHitCanvas();
10018
- if (!this.__layout.boundsChanged)
10019
- this.__layout.hitCanvasChanged = false;
10111
+ if (!layout.boundsChanged)
10112
+ layout.hitCanvasChanged = false;
10020
10113
  }
10021
10114
  return this.__hit(inner);
10022
10115
  };
@@ -10029,7 +10122,9 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
10029
10122
  const matrix = new Matrix();
10030
10123
  const ui$1 = UI.prototype;
10031
10124
  ui$1.__updateHitCanvas = function () {
10032
- const data = this.__, { hitCanvasManager } = this.leafer;
10125
+ if (this.__box)
10126
+ this.__box.__updateHitCanvas();
10127
+ const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10033
10128
  const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10034
10129
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
10035
10130
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -10056,6 +10151,8 @@ ui$1.__updateHitCanvas = function () {
10056
10151
  h.setStrokeOptions(data);
10057
10152
  };
10058
10153
  ui$1.__hit = function (inner) {
10154
+ if (this.__box && this.__box.__hit(inner))
10155
+ return true;
10059
10156
  const data = this.__;
10060
10157
  if (data.__isHitPixel && this.__hitPixel(inner))
10061
10158
  return true;
@@ -10104,6 +10201,15 @@ rect.__hitFill = box$1.__hitFill = function (inner) {
10104
10201
  return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10105
10202
  };
10106
10203
 
10204
+ Text.prototype.__drawHitPath = function (canvas) {
10205
+ const { __lineHeight, fontSize, __baseLine, __letterSpacing, __textDrawData: data } = this.__;
10206
+ canvas.beginPath();
10207
+ if (__letterSpacing < 0)
10208
+ this.__drawPathByBox(canvas);
10209
+ else
10210
+ data.rows.forEach(row => canvas.rect(row.x, row.y - __baseLine, row.width, __lineHeight < fontSize ? fontSize : __lineHeight));
10211
+ };
10212
+
10107
10213
  function getSelector(ui) {
10108
10214
  return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10109
10215
  }
@@ -10486,9 +10592,11 @@ const tempBox = new Bounds();
10486
10592
  const tempPoint = {};
10487
10593
  const tempScaleData = {};
10488
10594
  function createData(leafPaint, image, paint, box) {
10489
- const { blendMode, sync } = paint;
10595
+ const { blendMode, changeful, sync } = paint;
10490
10596
  if (blendMode)
10491
10597
  leafPaint.blendMode = blendMode;
10598
+ if (changeful)
10599
+ leafPaint.changeful = changeful;
10492
10600
  if (sync)
10493
10601
  leafPaint.sync = sync;
10494
10602
  leafPaint.data = getPatternData(paint, box, image);
@@ -10721,40 +10829,32 @@ function createPattern(ui, paint, pixelRatio) {
10721
10829
  }
10722
10830
 
10723
10831
  const { abs } = Math;
10724
- function checkImage(ui, canvas, paint, allowPaint) {
10832
+ function checkImage(ui, canvas, paint, allowDraw) {
10725
10833
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
10726
- const { pixelRatio } = canvas;
10727
- if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
10834
+ const { pixelRatio } = canvas, { data } = paint;
10835
+ if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
10728
10836
  return false;
10729
10837
  }
10730
10838
  else {
10731
- const { data } = paint;
10732
- if (allowPaint) {
10733
- if (!data.repeat) {
10734
- let { width, height } = data;
10735
- width *= abs(scaleX) * pixelRatio;
10736
- height *= abs(scaleY) * pixelRatio;
10737
- if (data.scaleX) {
10738
- width *= data.scaleX;
10739
- height *= data.scaleY;
10740
- }
10741
- allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
10839
+ if (allowDraw) {
10840
+ if (data.repeat) {
10841
+ allowDraw = false;
10742
10842
  }
10743
10843
  else {
10744
- allowPaint = false;
10844
+ if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
10845
+ let { width, height } = data;
10846
+ width *= abs(scaleX) * pixelRatio;
10847
+ height *= abs(scaleY) * pixelRatio;
10848
+ if (data.scaleX) {
10849
+ width *= data.scaleX;
10850
+ height *= data.scaleY;
10851
+ }
10852
+ allowDraw = (width * height > Platform.image.maxCacheSize);
10853
+ }
10745
10854
  }
10746
10855
  }
10747
- if (allowPaint) {
10748
- canvas.save();
10749
- ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
10750
- if (paint.blendMode)
10751
- canvas.blendMode = paint.blendMode;
10752
- if (data.opacity)
10753
- canvas.opacity *= data.opacity;
10754
- if (data.transform)
10755
- canvas.transform(data.transform);
10756
- canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
10757
- canvas.restore();
10856
+ if (allowDraw) {
10857
+ drawImage(ui, canvas, paint, data);
10758
10858
  return true;
10759
10859
  }
10760
10860
  else {
@@ -10775,13 +10875,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
10775
10875
  }
10776
10876
  }
10777
10877
  }
10878
+ function drawImage(ui, canvas, paint, data) {
10879
+ canvas.save();
10880
+ ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
10881
+ if (paint.blendMode)
10882
+ canvas.blendMode = paint.blendMode;
10883
+ if (data.opacity)
10884
+ canvas.opacity *= data.opacity;
10885
+ if (data.transform)
10886
+ canvas.transform(data.transform);
10887
+ canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
10888
+ canvas.restore();
10889
+ }
10778
10890
 
10779
10891
  function recycleImage(attrName, data) {
10780
10892
  const paints = data['_' + attrName];
10781
10893
  if (paints instanceof Array) {
10782
- let image, recycleMap, input, url;
10894
+ let paint, image, recycleMap, input, url;
10783
10895
  for (let i = 0, len = paints.length; i < len; i++) {
10784
- image = paints[i].image;
10896
+ paint = paints[i];
10897
+ image = paint.image;
10785
10898
  url = image && image.url;
10786
10899
  if (url) {
10787
10900
  if (!recycleMap)
@@ -10796,8 +10909,6 @@ function recycleImage(attrName, data) {
10796
10909
  }
10797
10910
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
10798
10911
  }
10799
- else
10800
- paints[i].style = null;
10801
10912
  }
10802
10913
  }
10803
10914
  return recycleMap;
@@ -10976,7 +11087,7 @@ const { toOffsetOutBounds } = BoundsHelper;
10976
11087
  const offsetOutBounds = {};
10977
11088
  function innerShadow(ui, current, shape) {
10978
11089
  let copyBounds, spreadScale;
10979
- const { __nowWorld: nowWorld, __layout: __layout } = ui;
11090
+ const { __nowWorld: nowWorld, __layout } = ui;
10980
11091
  const { innerShadow } = ui.__;
10981
11092
  const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
10982
11093
  const other = current.getSameCanvas();