@leafer-draw/worker 1.0.0-rc.22 → 1.0.0-rc.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -6,7 +6,7 @@ var LeaferUI = (function (exports) {
6
6
  hitCanvasSize: 100,
7
7
  maxCacheSize: 2560 * 1600,
8
8
  maxPatternSize: 4096 * 2160,
9
- suffix: 'leaf',
9
+ suffix: '',
10
10
  crossOrigin: 'anonymous'
11
11
  }
12
12
  };
@@ -36,24 +36,12 @@ var LeaferUI = (function (exports) {
36
36
  const { round, pow: pow$1, PI: PI$4 } = Math;
37
37
  const MathHelper = {
38
38
  within(value, min, max) {
39
- if (value < min)
39
+ if (min !== undefined && value < min)
40
40
  value = min;
41
- if (value > max)
41
+ if (max !== undefined && value > max)
42
42
  value = max;
43
43
  return value;
44
44
  },
45
- minus(value, isFourNumber) {
46
- if (value instanceof Array) {
47
- if (isFourNumber)
48
- value = MathHelper.fourNumber(value, 0);
49
- for (let i = 0; i < value.length; i++)
50
- value[i] = -value[i];
51
- }
52
- else {
53
- value = -value;
54
- }
55
- return value;
56
- },
57
45
  fourNumber(num, maxValue) {
58
46
  let data;
59
47
  if (num instanceof Array) {
@@ -150,9 +138,11 @@ var LeaferUI = (function (exports) {
150
138
  t.e += x;
151
139
  t.f += y;
152
140
  },
153
- translateInner(t, x, y) {
141
+ translateInner(t, x, y, isMoveOrigin) {
154
142
  t.e += t.a * x + t.c * y;
155
143
  t.f += t.b * x + t.d * y;
144
+ if (isMoveOrigin)
145
+ t.e -= x, t.f -= y;
156
146
  },
157
147
  scale(t, scaleX, scaleY = scaleX) {
158
148
  t.a *= scaleX;
@@ -219,8 +209,10 @@ var LeaferUI = (function (exports) {
219
209
  t.e = child.e * a + child.f * c + e;
220
210
  t.f = child.e * b + child.f * d + f;
221
211
  },
222
- multiplyParent(t, parent, to, abcdChanged, childScaleData) {
223
- const { e, f } = t;
212
+ multiplyParent(t, parent, to, abcdChanged, childScaleData, scrollData) {
213
+ let { e, f } = t;
214
+ if (scrollData)
215
+ e += scrollData.scrollX, f += scrollData.scrollY;
224
216
  to || (to = t);
225
217
  if (abcdChanged === undefined)
226
218
  abcdChanged = t.a !== 1 || t.b || t.c || t.d !== 1;
@@ -341,7 +333,7 @@ var LeaferUI = (function (exports) {
341
333
  t.e = x;
342
334
  t.f = y;
343
335
  if (origin)
344
- M$6.translateInner(t, -origin.x, -origin.y);
336
+ M$6.translateInner(t, -origin.x, -origin.y, true);
345
337
  },
346
338
  getLayout(t, origin, firstSkewY) {
347
339
  const { a, b, c, d, e, f } = t;
@@ -761,7 +753,7 @@ var LeaferUI = (function (exports) {
761
753
  const { floor, ceil: ceil$2 } = Math;
762
754
  let right$1, bottom$1, boundsRight, boundsBottom;
763
755
  const point = {};
764
- const toPoint$1 = {};
756
+ const toPoint$5 = {};
765
757
  const BoundsHelper = {
766
758
  tempBounds: {},
767
759
  set(t, x = 0, y = 0, width = 0, height = 0) {
@@ -776,15 +768,17 @@ var LeaferUI = (function (exports) {
776
768
  t.width = bounds.width;
777
769
  t.height = bounds.height;
778
770
  },
779
- copyAndSpread(t, bounds, spreadX, spreadY) {
780
- if (spreadX instanceof Array) {
781
- const four = fourNumber(spreadX);
782
- B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
771
+ copyAndSpread(t, bounds, spread, isShrink) {
772
+ if (spread instanceof Array) {
773
+ const four = fourNumber(spread);
774
+ isShrink
775
+ ? B.set(t, bounds.x + four[3], bounds.y + four[0], bounds.width - four[1] - four[3], bounds.height - four[2] - four[0])
776
+ : B.set(t, bounds.x - four[3], bounds.y - four[0], bounds.width + four[1] + four[3], bounds.height + four[2] + four[0]);
783
777
  }
784
778
  else {
785
- if (!spreadY)
786
- spreadY = spreadX;
787
- B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2);
779
+ if (isShrink)
780
+ spread = -spread;
781
+ B.set(t, bounds.x - spread, bounds.y - spread, bounds.width + spread * 2, bounds.height + spread * 2);
788
782
  }
789
783
  },
790
784
  minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
@@ -861,17 +855,17 @@ var LeaferUI = (function (exports) {
861
855
  else {
862
856
  point.x = t.x;
863
857
  point.y = t.y;
864
- toOuterPoint$1(matrix, point, toPoint$1);
865
- setPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
858
+ toOuterPoint$1(matrix, point, toPoint$5);
859
+ setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
866
860
  point.x = t.x + t.width;
867
- toOuterPoint$1(matrix, point, toPoint$1);
868
- addPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
861
+ toOuterPoint$1(matrix, point, toPoint$5);
862
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
869
863
  point.y = t.y + t.height;
870
- toOuterPoint$1(matrix, point, toPoint$1);
871
- addPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
864
+ toOuterPoint$1(matrix, point, toPoint$5);
865
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
872
866
  point.x = t.x;
873
- toOuterPoint$1(matrix, point, toPoint$1);
874
- addPoint$3(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
867
+ toOuterPoint$1(matrix, point, toPoint$5);
868
+ addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
875
869
  toBounds$4(tempPointBounds$1, to);
876
870
  }
877
871
  },
@@ -884,13 +878,16 @@ var LeaferUI = (function (exports) {
884
878
  const scale = Math.min(baseScale, Math.min(t.width / put.width, t.height / put.height));
885
879
  return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
886
880
  },
887
- getSpread(t, spreadX, spreadY) {
881
+ getSpread(t, spread) {
888
882
  const n = {};
889
- B.copyAndSpread(n, t, spreadX, spreadY);
883
+ B.copyAndSpread(n, t, spread);
890
884
  return n;
891
885
  },
892
- spread(t, spreadX, spreadY = spreadX) {
893
- B.copyAndSpread(t, t, spreadX, spreadY);
886
+ spread(t, spread) {
887
+ B.copyAndSpread(t, t, spread);
888
+ },
889
+ shrink(t, shrink) {
890
+ B.copyAndSpread(t, t, shrink, true);
894
891
  },
895
892
  ceil(t) {
896
893
  const { x, y } = t;
@@ -1070,12 +1067,12 @@ var LeaferUI = (function (exports) {
1070
1067
  getFitMatrix(put, baseScale) {
1071
1068
  return BoundsHelper.getFitMatrix(this, put, baseScale);
1072
1069
  }
1073
- spread(fourNumber, spreadY) {
1074
- BoundsHelper.spread(this, fourNumber, spreadY);
1070
+ spread(fourNumber) {
1071
+ BoundsHelper.spread(this, fourNumber);
1075
1072
  return this;
1076
1073
  }
1077
1074
  shrink(fourNumber) {
1078
- BoundsHelper.spread(this, MathHelper.minus(fourNumber, true));
1075
+ BoundsHelper.shrink(this, fourNumber);
1079
1076
  return this;
1080
1077
  }
1081
1078
  ceil() {
@@ -1192,6 +1189,10 @@ var LeaferUI = (function (exports) {
1192
1189
  Direction9[Direction9["bottomLeft"] = 6] = "bottomLeft";
1193
1190
  Direction9[Direction9["left"] = 7] = "left";
1194
1191
  Direction9[Direction9["center"] = 8] = "center";
1192
+ Direction9[Direction9["top-left"] = 0] = "top-left";
1193
+ Direction9[Direction9["top-right"] = 2] = "top-right";
1194
+ Direction9[Direction9["bottom-right"] = 4] = "bottom-right";
1195
+ Direction9[Direction9["bottom-left"] = 6] = "bottom-left";
1195
1196
  })(exports.Direction9 || (exports.Direction9 = {}));
1196
1197
 
1197
1198
  const directionData = [
@@ -1205,6 +1206,7 @@ var LeaferUI = (function (exports) {
1205
1206
  { x: 0, y: 0.5 },
1206
1207
  { x: 0.5, y: 0.5 }
1207
1208
  ];
1209
+ directionData.forEach(item => item.type = 'percent');
1208
1210
  const AroundHelper = {
1209
1211
  directionData,
1210
1212
  tempPoint: {},
@@ -1212,15 +1214,19 @@ var LeaferUI = (function (exports) {
1212
1214
  toPoint(around, bounds, to, onlySize, pointBounds) {
1213
1215
  to || (to = {});
1214
1216
  const point = get$5(around);
1215
- to.x = point.x * bounds.width;
1216
- to.y = point.y * bounds.height;
1217
- if (pointBounds) {
1218
- to.x -= pointBounds.x;
1219
- to.y -= pointBounds.y;
1220
- if (point.x)
1221
- to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1222
- if (point.y)
1223
- to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1217
+ to.x = point.x;
1218
+ to.y = point.y;
1219
+ if (point.type === 'percent') {
1220
+ to.x *= bounds.width;
1221
+ to.y *= bounds.height;
1222
+ if (pointBounds) {
1223
+ to.x -= pointBounds.x;
1224
+ to.y -= pointBounds.y;
1225
+ if (point.x)
1226
+ to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1227
+ if (point.y)
1228
+ to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1229
+ }
1224
1230
  }
1225
1231
  if (!onlySize) {
1226
1232
  to.x += bounds.x;
@@ -1232,6 +1238,13 @@ var LeaferUI = (function (exports) {
1232
1238
  return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
1233
1239
  }
1234
1240
 
1241
+ const { toPoint: toPoint$4 } = AroundHelper;
1242
+ const AlignHelper = {
1243
+ toPoint(align, contentBounds, bounds, to, onlySize) {
1244
+ toPoint$4(align, bounds, to, onlySize, contentBounds);
1245
+ }
1246
+ };
1247
+
1235
1248
  const StringNumberMap = {
1236
1249
  '0': 1,
1237
1250
  '1': 1,
@@ -1464,13 +1477,21 @@ var LeaferUI = (function (exports) {
1464
1477
  },
1465
1478
  clone(data) {
1466
1479
  return JSON.parse(JSON.stringify(data));
1480
+ },
1481
+ toMap(list) {
1482
+ const map = {};
1483
+ for (let i = 0, len = list.length; i < len; i++)
1484
+ map[list[i]] = true;
1485
+ return map;
1467
1486
  }
1468
1487
  };
1469
1488
  const { assign } = DataHelper;
1470
1489
 
1471
1490
  class LeafData {
1491
+ get __useNaturalRatio() { return true; }
1492
+ get __isLinePath() { return this.path && this.path.length === 6; }
1472
1493
  get __blendMode() {
1473
- if (this.eraser)
1494
+ if (this.eraser && this.eraser !== 'path')
1474
1495
  return 'destination-out';
1475
1496
  const { blendMode } = this;
1476
1497
  return blendMode === 'pass-through' ? null : blendMode;
@@ -1966,6 +1987,11 @@ var LeaferUI = (function (exports) {
1966
1987
  }
1967
1988
  updateViewSize() { }
1968
1989
  updateClientBounds() { }
1990
+ getClientBounds(update) {
1991
+ if (update)
1992
+ this.updateClientBounds();
1993
+ return this.clientBounds || this.bounds;
1994
+ }
1969
1995
  startAutoLayout(_autoBounds, _listener) { }
1970
1996
  stopAutoLayout() { }
1971
1997
  setCursor(_cursor) { }
@@ -2100,7 +2126,7 @@ var LeaferUI = (function (exports) {
2100
2126
  }
2101
2127
  clear() {
2102
2128
  const { pixelRatio } = this;
2103
- this.clearRect(0, 0, this.width * pixelRatio, this.height * pixelRatio);
2129
+ this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
2104
2130
  }
2105
2131
  isSameSize(size) {
2106
2132
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
@@ -2217,7 +2243,7 @@ var LeaferUI = (function (exports) {
2217
2243
 
2218
2244
  const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2219
2245
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2220
- const { set: set$2 } = PointHelper;
2246
+ const { set } = PointHelper;
2221
2247
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2222
2248
  const tempPoint$2 = {};
2223
2249
  const BezierHelper = {
@@ -2295,9 +2321,9 @@ var LeaferUI = (function (exports) {
2295
2321
  addPoint$2(setPointBounds, x1, y1);
2296
2322
  }
2297
2323
  if (setStartPoint)
2298
- set$2(setStartPoint, fromX, fromY);
2324
+ set(setStartPoint, fromX, fromY);
2299
2325
  if (setEndPoint)
2300
- set$2(setEndPoint, x1, y1);
2326
+ set(setEndPoint, x1, y1);
2301
2327
  return;
2302
2328
  }
2303
2329
  const anticlockwise = BAx * CBy - CBx * BAy < 0;
@@ -2346,7 +2372,7 @@ var LeaferUI = (function (exports) {
2346
2372
  if (setPointBounds)
2347
2373
  setPoint$2(setPointBounds, fromX, fromY);
2348
2374
  if (setStartPoint)
2349
- set$2(setStartPoint, fromX, fromY);
2375
+ set(setStartPoint, fromX, fromY);
2350
2376
  for (let i = 0; i < parts; i++) {
2351
2377
  endCos = cos$3(endRadian);
2352
2378
  endSin = sin$3(endRadian);
@@ -2368,7 +2394,7 @@ var LeaferUI = (function (exports) {
2368
2394
  endRadian += partRadian;
2369
2395
  }
2370
2396
  if (setEndPoint)
2371
- set$2(setEndPoint, cx + x, cy + y);
2397
+ set(setEndPoint, cx + x, cy + y);
2372
2398
  },
2373
2399
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2374
2400
  data.push(C$5, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
@@ -2514,11 +2540,15 @@ var LeaferUI = (function (exports) {
2514
2540
  char = pathString[i];
2515
2541
  if (StringNumberMap[char]) {
2516
2542
  if (char === '.') {
2517
- current.dot++;
2518
- if (current.dot > 1) {
2543
+ if (current.dot) {
2519
2544
  pushData(data, num);
2520
2545
  num = '';
2521
2546
  }
2547
+ current.dot++;
2548
+ }
2549
+ if (num === '0' && char !== '.') {
2550
+ pushData(data, num);
2551
+ num = '';
2522
2552
  }
2523
2553
  num += char;
2524
2554
  }
@@ -3608,7 +3638,9 @@ var LeaferUI = (function (exports) {
3608
3638
  }
3609
3639
  }
3610
3640
 
3611
- function defineKey(target, key, descriptor) {
3641
+ function defineKey(target, key, descriptor, noConfigurable) {
3642
+ if (!noConfigurable)
3643
+ descriptor.configurable = descriptor.enumerable = true;
3612
3644
  Object.defineProperty(target, key, descriptor);
3613
3645
  }
3614
3646
  function getDescriptor(object, name) {
@@ -3627,9 +3659,7 @@ var LeaferUI = (function (exports) {
3627
3659
  function defineLeafAttr(target, key, defaultValue, partDescriptor) {
3628
3660
  const defaultDescriptor = {
3629
3661
  get() { return this.__getAttr(key); },
3630
- set(value) { this.__setAttr(key, value); },
3631
- configurable: true,
3632
- enumerable: true
3662
+ set(value) { this.__setAttr(key, value); }
3633
3663
  };
3634
3664
  defineKey(target, key, Object.assign(defaultDescriptor, partDescriptor || {}));
3635
3665
  defineDataProcessor(target, key, defaultValue);
@@ -3640,35 +3670,33 @@ var LeaferUI = (function (exports) {
3640
3670
  function positionType(defaultValue, checkFiniteNumber) {
3641
3671
  return decorateLeafAttr(defaultValue, (key) => attr({
3642
3672
  set(value) {
3643
- this.__setAttr(key, value, checkFiniteNumber);
3644
- this.__layout.matrixChanged || this.__layout.matrixChange();
3673
+ this.__setAttr(key, value, checkFiniteNumber) && (this.__layout.matrixChanged || this.__layout.matrixChange());
3645
3674
  }
3646
3675
  }));
3647
3676
  }
3648
3677
  function autoLayoutType(defaultValue) {
3649
3678
  return decorateLeafAttr(defaultValue, (key) => attr({
3650
3679
  set(value) {
3651
- this.__setAttr(key, value);
3652
- this.__layout.matrixChanged || this.__layout.matrixChange();
3653
- this.__hasAutoLayout = !!value;
3654
- if (!this.__local)
3655
- this.__layout.createLocal();
3680
+ if (this.__setAttr(key, value)) {
3681
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3682
+ this.__hasAutoLayout = !!value;
3683
+ if (!this.__local)
3684
+ this.__layout.createLocal();
3685
+ }
3656
3686
  }
3657
3687
  }));
3658
3688
  }
3659
3689
  function scaleType(defaultValue, checkFiniteNumber) {
3660
3690
  return decorateLeafAttr(defaultValue, (key) => attr({
3661
3691
  set(value) {
3662
- this.__setAttr(key, value, checkFiniteNumber);
3663
- this.__layout.scaleChanged || this.__layout.scaleChange();
3692
+ this.__setAttr(key, value, checkFiniteNumber) && (this.__layout.scaleChanged || this.__layout.scaleChange());
3664
3693
  }
3665
3694
  }));
3666
3695
  }
3667
3696
  function rotationType(defaultValue, checkFiniteNumber) {
3668
3697
  return decorateLeafAttr(defaultValue, (key) => attr({
3669
3698
  set(value) {
3670
- this.__setAttr(key, value, checkFiniteNumber);
3671
- this.__layout.rotationChanged || this.__layout.rotationChange();
3699
+ this.__setAttr(key, value, checkFiniteNumber) && (this.__layout.rotationChanged || this.__layout.rotationChange());
3672
3700
  }
3673
3701
  }));
3674
3702
  }
@@ -3682,9 +3710,7 @@ var LeaferUI = (function (exports) {
3682
3710
  function naturalBoundsType(defaultValue) {
3683
3711
  return decorateLeafAttr(defaultValue, (key) => attr({
3684
3712
  set(value) {
3685
- this.__setAttr(key, value);
3686
- doBoundsType(this);
3687
- this.__.__removeNaturalSize();
3713
+ this.__setAttr(key, value) && (doBoundsType(this), this.__.__removeNaturalSize());
3688
3714
  }
3689
3715
  }));
3690
3716
  }
@@ -3696,8 +3722,11 @@ var LeaferUI = (function (exports) {
3696
3722
  function pathInputType(defaultValue) {
3697
3723
  return decorateLeafAttr(defaultValue, (key) => attr({
3698
3724
  set(value) {
3699
- if (this.__.__pathInputed !== 2)
3700
- this.__.__pathInputed = value ? 1 : 0;
3725
+ const data = this.__;
3726
+ if (data.__pathInputed !== 2)
3727
+ data.__pathInputed = value ? 1 : 0;
3728
+ if (!value)
3729
+ data.__pathForRender = undefined;
3701
3730
  this.__setAttr(key, value);
3702
3731
  doBoundsType(this);
3703
3732
  }
@@ -3728,54 +3757,66 @@ var LeaferUI = (function (exports) {
3728
3757
  function surfaceType(defaultValue) {
3729
3758
  return decorateLeafAttr(defaultValue, (key) => attr({
3730
3759
  set(value) {
3731
- this.__setAttr(key, value);
3732
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3760
+ this.__setAttr(key, value) && (this.__layout.surfaceChanged || this.__layout.surfaceChange());
3733
3761
  }
3734
3762
  }));
3735
3763
  }
3736
3764
  function opacityType(defaultValue) {
3737
3765
  return decorateLeafAttr(defaultValue, (key) => attr({
3738
3766
  set(value) {
3739
- this.__setAttr(key, value);
3740
- this.__layout.opacityChanged || this.__layout.opacityChange();
3767
+ this.__setAttr(key, value) && (this.__layout.opacityChanged || this.__layout.opacityChange());
3768
+ }
3769
+ }));
3770
+ }
3771
+ function visibleType(defaultValue) {
3772
+ return decorateLeafAttr(defaultValue, (key) => attr({
3773
+ set(value) {
3774
+ const oldValue = this.visible;
3775
+ if (this.__setAttr(key, value)) {
3776
+ this.__layout.opacityChanged || this.__layout.opacityChange();
3777
+ if (oldValue === 0 || value === 0)
3778
+ doBoundsType(this);
3779
+ }
3741
3780
  }
3742
3781
  }));
3743
3782
  }
3744
3783
  function sortType(defaultValue) {
3745
3784
  return decorateLeafAttr(defaultValue, (key) => attr({
3746
3785
  set(value) {
3747
- this.__setAttr(key, value);
3748
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3749
- this.waitParent(() => { this.parent.__layout.childrenSortChange(); });
3786
+ if (this.__setAttr(key, value)) {
3787
+ this.__layout.surfaceChanged || this.__layout.surfaceChange();
3788
+ this.waitParent(() => { this.parent.__layout.childrenSortChange(); });
3789
+ }
3750
3790
  }
3751
3791
  }));
3752
3792
  }
3753
3793
  function maskType(defaultValue) {
3754
3794
  return decorateLeafAttr(defaultValue, (key) => attr({
3755
3795
  set(value) {
3756
- this.__setAttr(key, value);
3757
- this.__layout.boxChanged || this.__layout.boxChange();
3758
- this.waitParent(() => { this.parent.__updateMask(value); });
3796
+ if (this.__setAttr(key, value)) {
3797
+ this.__layout.boxChanged || this.__layout.boxChange();
3798
+ this.waitParent(() => { this.parent.__updateMask(value); });
3799
+ }
3759
3800
  }
3760
3801
  }));
3761
3802
  }
3762
3803
  function eraserType(defaultValue) {
3763
3804
  return decorateLeafAttr(defaultValue, (key) => attr({
3764
3805
  set(value) {
3765
- this.__setAttr(key, value);
3766
- this.waitParent(() => { this.parent.__updateEraser(value); });
3806
+ this.__setAttr(key, value) && this.waitParent(() => { this.parent.__updateEraser(value); });
3767
3807
  }
3768
3808
  }));
3769
3809
  }
3770
3810
  function hitType(defaultValue) {
3771
3811
  return decorateLeafAttr(defaultValue, (key) => attr({
3772
3812
  set(value) {
3773
- this.__setAttr(key, value);
3774
- if (Debug.showHitView) {
3775
- this.__layout.surfaceChanged || this.__layout.surfaceChange();
3813
+ if (this.__setAttr(key, value)) {
3814
+ if (Debug.showHitView) {
3815
+ this.__layout.surfaceChanged || this.__layout.surfaceChange();
3816
+ }
3817
+ if (this.leafer)
3818
+ this.leafer.updateCursor();
3776
3819
  }
3777
- if (this.leafer)
3778
- this.leafer.updateCursor();
3779
3820
  }
3780
3821
  }));
3781
3822
  }
@@ -3816,9 +3857,7 @@ var LeaferUI = (function (exports) {
3816
3857
  },
3817
3858
  set(value) {
3818
3859
  this[computedKey] = value;
3819
- },
3820
- configurable: true,
3821
- enumerable: true
3860
+ }
3822
3861
  };
3823
3862
  if (defaultValue === undefined) {
3824
3863
  property.get = function () { return this[computedKey]; };
@@ -3826,13 +3865,25 @@ var LeaferUI = (function (exports) {
3826
3865
  else if (key === 'width') {
3827
3866
  property.get = function () {
3828
3867
  const v = this[computedKey];
3829
- return v === undefined ? (this.__naturalWidth || defaultValue) : v;
3868
+ if (v === undefined) {
3869
+ const t = this;
3870
+ return t._height && t.__naturalWidth && t.__useNaturalRatio ? t._height * t.__naturalWidth / t.__naturalHeight : t.__naturalWidth || defaultValue;
3871
+ }
3872
+ else {
3873
+ return v;
3874
+ }
3830
3875
  };
3831
3876
  }
3832
3877
  else if (key === 'height') {
3833
3878
  property.get = function () {
3834
3879
  const v = this[computedKey];
3835
- return v === undefined ? (this.__naturalHeight || defaultValue) : v;
3880
+ if (v === undefined) {
3881
+ const t = this;
3882
+ return t._width && t.__naturalHeight && t.__useNaturalRatio ? t._width * t.__naturalHeight / t.__naturalWidth : t.__naturalHeight || defaultValue;
3883
+ }
3884
+ else {
3885
+ return v;
3886
+ }
3836
3887
  };
3837
3888
  }
3838
3889
  let descriptor, find = data;
@@ -3846,7 +3897,7 @@ var LeaferUI = (function (exports) {
3846
3897
  property.set = data[setMethodName];
3847
3898
  delete data[setMethodName];
3848
3899
  }
3849
- Object.defineProperty(data, key, property);
3900
+ defineKey(data, key, property);
3850
3901
  }
3851
3902
 
3852
3903
  const debug$6 = new Debug('rewrite');
@@ -4047,13 +4098,6 @@ var LeaferUI = (function (exports) {
4047
4098
  return true;
4048
4099
  p = p.parent;
4049
4100
  }
4050
- },
4051
- hasParentAutoLayout(p) {
4052
- while (p.parent) {
4053
- p = p.parent;
4054
- if (p.__hasAutoLayout)
4055
- return true;
4056
- }
4057
4101
  }
4058
4102
  };
4059
4103
  const L = LeafHelper;
@@ -4073,13 +4117,13 @@ var LeaferUI = (function (exports) {
4073
4117
  return target.__world;
4074
4118
  },
4075
4119
  localBoxBounds(target) {
4076
- return target.__.eraser ? null : (target.__local || target.__layout);
4120
+ return target.__.eraser || target.__.visible === 0 ? null : (target.__local || target.__layout);
4077
4121
  },
4078
4122
  localStrokeBounds(target) {
4079
- return target.__.eraser ? null : target.__layout.localStrokeBounds;
4123
+ return target.__.eraser || target.__.visible === 0 ? null : target.__layout.localStrokeBounds;
4080
4124
  },
4081
4125
  localRenderBounds(target) {
4082
- return target.__.eraser ? null : target.__layout.localRenderBounds;
4126
+ return target.__.eraser || target.__.visible === 0 ? null : target.__layout.localRenderBounds;
4083
4127
  },
4084
4128
  maskLocalBoxBounds(target) {
4085
4129
  return target.__.mask ? target.__localBoxBounds : null;
@@ -4185,11 +4229,19 @@ var LeaferUI = (function (exports) {
4185
4229
 
4186
4230
  const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4187
4231
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = BoundsHelper;
4232
+ const localContent = '_localContentBounds';
4233
+ const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
4188
4234
  class LeafLayout {
4235
+ get contentBounds() { return this._contentBounds || this.boxBounds; }
4236
+ set contentBounds(bounds) { this._contentBounds = bounds; }
4189
4237
  get strokeBounds() { return this._strokeBounds || this.boxBounds; }
4190
4238
  get renderBounds() { return this._renderBounds || this.boxBounds; }
4239
+ get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
4191
4240
  get localStrokeBounds() { return this._localStrokeBounds || this; }
4192
4241
  get localRenderBounds() { return this._localRenderBounds || this; }
4242
+ get worldContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {})); return this[worldContent]; }
4243
+ get worldBoxBounds() { toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {})); return this[worldBox]; }
4244
+ get worldStrokeBounds() { toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {})); return this[worldStroke]; }
4193
4245
  get a() { return 1; }
4194
4246
  get b() { return 0; }
4195
4247
  get c() { return 0; }
@@ -4272,7 +4324,6 @@ var LeaferUI = (function (exports) {
4272
4324
  case 'content':
4273
4325
  if (this.contentBounds)
4274
4326
  return this.contentBounds;
4275
- case 'margin':
4276
4327
  case 'box':
4277
4328
  return this.boxBounds;
4278
4329
  case 'stroke':
@@ -4285,8 +4336,9 @@ var LeaferUI = (function (exports) {
4285
4336
  return this.localRenderBounds;
4286
4337
  case 'stroke':
4287
4338
  return this.localStrokeBounds;
4288
- case 'margin':
4289
4339
  case 'content':
4340
+ if (this.contentBounds)
4341
+ return this.localContentBounds;
4290
4342
  case 'box':
4291
4343
  return this.leaf.__localBoxBounds;
4292
4344
  }
@@ -4295,15 +4347,13 @@ var LeaferUI = (function (exports) {
4295
4347
  switch (type) {
4296
4348
  case 'render':
4297
4349
  return this.leaf.__world;
4350
+ case 'stroke':
4351
+ return this.worldStrokeBounds;
4298
4352
  case 'content':
4299
4353
  if (this.contentBounds)
4300
- return this.getWorldContentBounds();
4301
- case 'margin':
4354
+ return this.worldContentBounds;
4302
4355
  case 'box':
4303
- return this.getWorldBoxBounds();
4304
- case 'margin':
4305
- case 'stroke':
4306
- return this.getWorldStrokeBounds();
4356
+ return this.worldBoxBounds;
4307
4357
  }
4308
4358
  }
4309
4359
  getLayoutBounds(type, relative = 'world', unscale) {
@@ -4366,20 +4416,24 @@ var LeaferUI = (function (exports) {
4366
4416
  points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
4367
4417
  return points;
4368
4418
  }
4369
- getWorldContentBounds() {
4370
- this._worldContentBounds || (this._worldContentBounds = {});
4371
- toOuterOf$2(this.contentBounds, this.leaf.__world, this._worldContentBounds);
4372
- return this._worldContentBounds;
4419
+ shrinkContent() {
4420
+ const { x, y, width, height } = this.boxBounds;
4421
+ this._contentBounds = { x, y, width, height };
4422
+ }
4423
+ spreadStroke() {
4424
+ const { x, y, width, height } = this.strokeBounds;
4425
+ this._strokeBounds = { x, y, width, height };
4426
+ this._localStrokeBounds = { x, y, width, height };
4427
+ if (!this.renderSpread)
4428
+ this.spreadRenderCancel();
4373
4429
  }
4374
- getWorldBoxBounds() {
4375
- this._worldBoxBounds || (this._worldBoxBounds = {});
4376
- toOuterOf$2(this.boxBounds, this.leaf.__world, this._worldBoxBounds);
4377
- return this._worldBoxBounds;
4430
+ spreadRender() {
4431
+ const { x, y, width, height } = this.renderBounds;
4432
+ this._renderBounds = { x, y, width, height };
4433
+ this._localRenderBounds = { x, y, width, height };
4378
4434
  }
4379
- getWorldStrokeBounds() {
4380
- this._worldStrokeBounds || (this._worldStrokeBounds = {});
4381
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this._worldStrokeBounds);
4382
- return this._worldStrokeBounds;
4435
+ shrinkContentCancel() {
4436
+ this._contentBounds = undefined;
4383
4437
  }
4384
4438
  spreadStrokeCancel() {
4385
4439
  const same = this.renderBounds === this.strokeBounds;
@@ -4392,18 +4446,6 @@ var LeaferUI = (function (exports) {
4392
4446
  this._renderBounds = this._strokeBounds;
4393
4447
  this._localRenderBounds = this._localStrokeBounds;
4394
4448
  }
4395
- spreadStroke() {
4396
- const { x, y, width, height } = this.strokeBounds;
4397
- this._strokeBounds = { x, y, width, height };
4398
- this._localStrokeBounds = { x, y, width, height };
4399
- if (!this.renderSpread)
4400
- this.spreadRenderCancel();
4401
- }
4402
- spreadRender() {
4403
- const { x, y, width, height } = this.renderBounds;
4404
- this._renderBounds = { x, y, width, height };
4405
- this._localRenderBounds = { x, y, width, height };
4406
- }
4407
4449
  boxChange() {
4408
4450
  this.boxChanged = true;
4409
4451
  this.localBoxChanged || this.localBoxChange();
@@ -4490,24 +4532,40 @@ var LeaferUI = (function (exports) {
4490
4532
  });
4491
4533
  },
4492
4534
  off(type, listener, options) {
4493
- let capture;
4494
- if (options)
4495
- capture = typeof options === 'boolean' ? options : options.capture;
4496
- let events, index;
4497
- const map = __getListenerMap(this, capture);
4498
- const typeList = typeof type === 'string' ? type.split(' ') : type;
4499
- typeList.forEach(type => {
4500
- if (type) {
4501
- events = map[type];
4502
- if (events) {
4503
- index = events.findIndex(item => item.listener === listener);
4504
- if (index > -1)
4505
- events.splice(index, 1);
4506
- if (!events.length)
4507
- delete map[type];
4508
- }
4535
+ if (type) {
4536
+ const typeList = typeof type === 'string' ? type.split(' ') : type;
4537
+ if (listener) {
4538
+ let capture;
4539
+ if (options)
4540
+ capture = typeof options === 'boolean' ? options : options.capture;
4541
+ let events, index;
4542
+ const map = __getListenerMap(this, capture);
4543
+ typeList.forEach(type => {
4544
+ if (type) {
4545
+ events = map[type];
4546
+ if (events) {
4547
+ index = events.findIndex(item => item.listener === listener);
4548
+ if (index > -1)
4549
+ events.splice(index, 1);
4550
+ if (!events.length)
4551
+ delete map[type];
4552
+ }
4553
+ }
4554
+ });
4509
4555
  }
4510
- });
4556
+ else {
4557
+ const { __bubbleMap: b, __captureMap: c } = this;
4558
+ typeList.forEach(type => {
4559
+ if (b)
4560
+ delete b[type];
4561
+ if (c)
4562
+ delete c[type];
4563
+ });
4564
+ }
4565
+ }
4566
+ else {
4567
+ this.__bubbleMap = this.__captureMap = undefined;
4568
+ }
4511
4569
  },
4512
4570
  on_(type, listener, bind, options) {
4513
4571
  if (bind)
@@ -4771,10 +4829,10 @@ var LeaferUI = (function (exports) {
4771
4829
  };
4772
4830
 
4773
4831
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
4774
- const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
4832
+ const { toPoint: toPoint$3, tempPoint: tempPoint$1 } = AroundHelper;
4775
4833
  const LeafMatrix = {
4776
4834
  __updateWorldMatrix() {
4777
- multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
4835
+ multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
4778
4836
  },
4779
4837
  __updateLocalMatrix() {
4780
4838
  if (this.__local) {
@@ -4785,18 +4843,18 @@ var LeaferUI = (function (exports) {
4785
4843
  layout.scaleChanged = layout.rotationChanged = false;
4786
4844
  }
4787
4845
  }
4788
- local.e = data.x;
4789
- local.f = data.y;
4790
- if (data.around) {
4791
- toPoint(data.around, layout.boxBounds, tempPoint$1);
4792
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y);
4846
+ local.e = data.x + data.offsetX;
4847
+ local.f = data.y + data.offsetY;
4848
+ if (data.around || data.origin) {
4849
+ toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
4850
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.origin);
4793
4851
  }
4794
4852
  }
4795
4853
  this.__layout.matrixChanged = false;
4796
4854
  }
4797
4855
  };
4798
4856
 
4799
- const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2, hasParentAutoLayout } = LeafHelper;
4857
+ const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
4800
4858
  const { updateBounds: updateBounds$1 } = BranchHelper;
4801
4859
  const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4 } = BoundsHelper;
4802
4860
  const { toBounds: toBounds$2 } = PathBounds;
@@ -4815,7 +4873,6 @@ var LeaferUI = (function (exports) {
4815
4873
  this.__updatePath();
4816
4874
  this.__updateRenderPath();
4817
4875
  this.__updateBoxBounds();
4818
- layout.boxChanged = false;
4819
4876
  layout.resized = true;
4820
4877
  }
4821
4878
  if (layout.localBoxChanged) {
@@ -4829,12 +4886,12 @@ var LeaferUI = (function (exports) {
4829
4886
  if (this.parent)
4830
4887
  this.parent.__layout.boxChange();
4831
4888
  }
4889
+ layout.boxChanged = false;
4832
4890
  if (layout.strokeChanged) {
4833
4891
  layout.strokeSpread = this.__updateStrokeSpread();
4834
4892
  if (layout.strokeSpread) {
4835
- if (layout.strokeBounds === layout.boxBounds) {
4893
+ if (layout.strokeBounds === layout.boxBounds)
4836
4894
  layout.spreadStroke();
4837
- }
4838
4895
  this.__updateStrokeBounds();
4839
4896
  this.__updateLocalStrokeBounds();
4840
4897
  }
@@ -4842,7 +4899,7 @@ var LeaferUI = (function (exports) {
4842
4899
  layout.spreadStrokeCancel();
4843
4900
  }
4844
4901
  layout.strokeChanged = false;
4845
- if (layout.renderSpread)
4902
+ if (layout.renderSpread || layout.strokeSpread !== layout.strokeBoxSpread)
4846
4903
  layout.renderChanged = true;
4847
4904
  if (this.parent)
4848
4905
  this.parent.__layout.strokeChange();
@@ -4851,9 +4908,8 @@ var LeaferUI = (function (exports) {
4851
4908
  if (layout.renderChanged) {
4852
4909
  layout.renderSpread = this.__updateRenderSpread();
4853
4910
  if (layout.renderSpread) {
4854
- if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
4911
+ if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds)
4855
4912
  layout.spreadRender();
4856
- }
4857
4913
  this.__updateRenderBounds();
4858
4914
  this.__updateLocalRenderBounds();
4859
4915
  }
@@ -4893,10 +4949,15 @@ var LeaferUI = (function (exports) {
4893
4949
  __updateAutoLayout() {
4894
4950
  this.__layout.matrixChanged = true;
4895
4951
  if (this.isBranch) {
4896
- if (this.leafer)
4952
+ if (this.leafer && this.leafer.ready)
4897
4953
  this.leafer.layouter.addExtra(this);
4898
- if (hasParentAutoLayout(this)) {
4899
- updateMatrix$1(this);
4954
+ if (this.__.flow) {
4955
+ if (this.__layout.boxChanged)
4956
+ this.__updateFlowLayout();
4957
+ updateAllMatrix$2(this);
4958
+ updateBounds$1(this, this);
4959
+ if (this.__.__autoSide)
4960
+ this.__updateBoxBounds();
4900
4961
  }
4901
4962
  else {
4902
4963
  updateAllMatrix$2(this);
@@ -4913,12 +4974,13 @@ var LeaferUI = (function (exports) {
4913
4974
  data.__naturalHeight = layout.boxBounds.height;
4914
4975
  },
4915
4976
  __updateStrokeBounds() {
4916
- copyAndSpread$1(this.__layout.strokeBounds, this.__layout.boxBounds, this.__layout.strokeSpread);
4977
+ const layout = this.__layout;
4978
+ copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
4917
4979
  },
4918
4980
  __updateRenderBounds() {
4919
- const { renderSpread, strokeBounds, renderBounds } = this.__layout;
4920
- renderSpread > 0 ? copyAndSpread$1(renderBounds, strokeBounds, renderSpread) : copy$4(renderBounds, strokeBounds);
4921
- },
4981
+ const layout = this.__layout;
4982
+ layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$4(layout.renderBounds, layout.strokeBounds);
4983
+ }
4922
4984
  };
4923
4985
 
4924
4986
  const LeafRender = {
@@ -4927,6 +4989,8 @@ var LeaferUI = (function (exports) {
4927
4989
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
4928
4990
  canvas.opacity = this.__.opacity;
4929
4991
  if (this.__.__single) {
4992
+ if (this.__.eraser === 'path')
4993
+ return this.__renderEraser(canvas, options);
4930
4994
  const tempCanvas = canvas.getSameCanvas(true, true);
4931
4995
  this.__draw(tempCanvas, options);
4932
4996
  if (this.__worldFlipped) {
@@ -4969,6 +5033,8 @@ var LeaferUI = (function (exports) {
4969
5033
  __render(canvas, options) {
4970
5034
  if (this.__worldOpacity) {
4971
5035
  if (this.__.__single) {
5036
+ if (this.__.eraser === 'path')
5037
+ return this.__renderEraser(canvas, options);
4972
5038
  const tempCanvas = canvas.getSameCanvas(false, true);
4973
5039
  this.__renderBranch(tempCanvas, options);
4974
5040
  const nowWorld = this.__getNowWorld(options);
@@ -5034,7 +5100,7 @@ var LeaferUI = (function (exports) {
5034
5100
  get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
5035
5101
  get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
5036
5102
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5037
- get pathInputed() { return !!this.__.__pathInputed; }
5103
+ get pathInputed() { return this.__.__pathInputed; }
5038
5104
  constructor(data) {
5039
5105
  this.innerId = create(LEAF);
5040
5106
  this.reset(data);
@@ -5108,7 +5174,9 @@ var LeaferUI = (function (exports) {
5108
5174
  setProxyAttr(_attrName, _newValue) { }
5109
5175
  getProxyAttr(_attrName) { return undefined; }
5110
5176
  find(_condition, _options) { return undefined; }
5177
+ findTag(_tag) { return undefined; }
5111
5178
  findOne(_condition, _options) { return undefined; }
5179
+ findId(_id) { return undefined; }
5112
5180
  focus(_value) { }
5113
5181
  forceUpdate(attrName) {
5114
5182
  if (attrName === undefined)
@@ -5130,9 +5198,11 @@ var LeaferUI = (function (exports) {
5130
5198
  __updateLocalStrokeBounds() { }
5131
5199
  __updateLocalRenderBounds() { }
5132
5200
  __updateBoxBounds() { }
5201
+ __updateContentBounds() { }
5133
5202
  __updateStrokeBounds() { }
5134
5203
  __updateRenderBounds() { }
5135
5204
  __updateAutoLayout() { }
5205
+ __updateFlowLayout() { }
5136
5206
  __updateNaturalSize() { }
5137
5207
  __updateStrokeSpread() { return 0; }
5138
5208
  __updateRenderSpread() { return 0; }
@@ -5140,6 +5210,13 @@ var LeaferUI = (function (exports) {
5140
5210
  __updateEraser(value) {
5141
5211
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
5142
5212
  }
5213
+ __renderEraser(canvas, options) {
5214
+ canvas.save();
5215
+ this.__clip(canvas, options);
5216
+ const { renderBounds: r } = this.__layout;
5217
+ canvas.clearRect(r.x, r.y, r.width, r.height);
5218
+ canvas.restore();
5219
+ }
5143
5220
  __updateMask(value) {
5144
5221
  this.__hasMask = value ? true : this.children.some(item => item.__.mask);
5145
5222
  }
@@ -5320,8 +5397,8 @@ var LeaferUI = (function (exports) {
5320
5397
  emit(_type, _event, _capture) { }
5321
5398
  emitEvent(_event, _capture) { }
5322
5399
  hasEvent(_type, _capture) { return false; }
5323
- static changeAttr(attrName, defaultValue) {
5324
- defineDataProcessor(this.prototype, attrName, defaultValue);
5400
+ static changeAttr(attrName, defaultValue, fn) {
5401
+ fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5325
5402
  }
5326
5403
  static addAttr(attrName, defaultValue, fn) {
5327
5404
  if (!fn)
@@ -5635,6 +5712,9 @@ var LeaferUI = (function (exports) {
5635
5712
  }
5636
5713
  }
5637
5714
 
5715
+ const version = "1.0.0-rc.24";
5716
+ const inviteCode = {};
5717
+
5638
5718
  class LeaferCanvas extends LeaferCanvasBase {
5639
5719
  get allowBackgroundColor() { return true; }
5640
5720
  init() {
@@ -6176,7 +6256,7 @@ var LeaferUI = (function (exports) {
6176
6256
  canvas.clear();
6177
6257
  }
6178
6258
  else {
6179
- bounds.spread(1 + 1 / this.canvas.pixelRatio).ceil();
6259
+ bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
6180
6260
  canvas.clearWorld(bounds, true);
6181
6261
  canvas.clipWorld(bounds, true);
6182
6262
  }
@@ -6248,8 +6328,11 @@ var LeaferUI = (function (exports) {
6248
6328
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
6249
6329
  this.addBlock(this.canvas.bounds);
6250
6330
  this.target.forceUpdate('surface');
6331
+ return;
6251
6332
  }
6252
6333
  }
6334
+ this.addBlock(new Bounds(0, 0, 1, 1));
6335
+ this.changed = true;
6253
6336
  }
6254
6337
  __onLayoutEnd(event) {
6255
6338
  if (event.data)
@@ -6323,10 +6406,11 @@ var LeaferUI = (function (exports) {
6323
6406
  function arrowType(defaultValue) {
6324
6407
  return decorateLeafAttr(defaultValue, (key) => attr({
6325
6408
  set(value) {
6326
- this.__setAttr(key, value);
6327
- const data = this.__;
6328
- data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6329
- doStrokeType(this);
6409
+ if (this.__setAttr(key, value)) {
6410
+ const data = this.__;
6411
+ data.__useArrow = data.startArrow !== 'none' || data.endArrow !== 'none';
6412
+ doStrokeType(this);
6413
+ }
6330
6414
  }
6331
6415
  }));
6332
6416
  }
@@ -6499,7 +6583,7 @@ var LeaferUI = (function (exports) {
6499
6583
  const UnitConvert = {
6500
6584
  number(value, percentRefer) {
6501
6585
  if (typeof value === 'object')
6502
- return value.type === 'percent' ? value.value / 100 * percentRefer : value.value;
6586
+ return value.type === 'percent' ? value.value * percentRefer : value.value;
6503
6587
  return value;
6504
6588
  }
6505
6589
  };
@@ -6508,7 +6592,7 @@ var LeaferUI = (function (exports) {
6508
6592
  }
6509
6593
 
6510
6594
  class BoxData extends GroupData {
6511
- get __boxStroke() { return true; }
6595
+ get __boxStroke() { return !this.__pathInputed; }
6512
6596
  }
6513
6597
 
6514
6598
  class LeaferData extends GroupData {
@@ -6521,11 +6605,11 @@ var LeaferUI = (function (exports) {
6521
6605
  }
6522
6606
 
6523
6607
  class RectData extends UIData {
6524
- get __boxStroke() { return true; }
6608
+ get __boxStroke() { return !this.__pathInputed; }
6525
6609
  }
6526
6610
 
6527
6611
  class EllipseData extends UIData {
6528
- get __boxStroke() { return true; }
6612
+ get __boxStroke() { return !this.__pathInputed; }
6529
6613
  }
6530
6614
 
6531
6615
  class PolygonData extends UIData {
@@ -6552,6 +6636,7 @@ var LeaferUI = (function (exports) {
6552
6636
  'black': 900
6553
6637
  };
6554
6638
  class TextData extends UIData {
6639
+ get __useNaturalRatio() { return false; }
6555
6640
  setFontWeight(value) {
6556
6641
  if (typeof value === 'string') {
6557
6642
  this.__setInput('fontWeight', value);
@@ -6593,19 +6678,18 @@ var LeaferUI = (function (exports) {
6593
6678
  const UIBounds = {
6594
6679
  __updateStrokeSpread() {
6595
6680
  let width = 0, boxWidth = 0;
6596
- const { stroke, hitStroke, strokeAlign, strokeWidth } = this.__;
6597
- if ((stroke || hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
6681
+ const data = this.__, { strokeAlign, strokeWidth } = data;
6682
+ if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
6598
6683
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
6599
- if (!this.__.__boxStroke) {
6600
- const { miterLimit, strokeCap } = this.__;
6601
- const miterLimitAddWidth = this.__tag !== 'Line' ? 1 / Math.sin(miterLimit * OneRadian / 2) * Math.sqrt(strokeWidth) - width : 0;
6602
- const storkeCapAddWidth = strokeCap === 'none' ? 0 : strokeWidth;
6684
+ if (!data.__boxStroke) {
6685
+ const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * width;
6686
+ const storkeCapAddWidth = data.strokeCap === 'none' ? 0 : strokeWidth;
6603
6687
  width += Math.max(miterLimitAddWidth, storkeCapAddWidth);
6604
6688
  }
6605
6689
  }
6606
- this.__layout.strokeBoxSpread = boxWidth;
6607
- if (this.__.__useArrow)
6690
+ if (data.__useArrow)
6608
6691
  width += strokeWidth * 5;
6692
+ this.__layout.strokeBoxSpread = boxWidth;
6609
6693
  return width;
6610
6694
  },
6611
6695
  __updateRenderSpread() {
@@ -6625,7 +6709,7 @@ var LeaferUI = (function (exports) {
6625
6709
  if (backgroundBlur)
6626
6710
  shapeWidth = Math.max(shapeWidth, backgroundBlur);
6627
6711
  this.__layout.renderShapeSpread = shapeWidth;
6628
- return width;
6712
+ return width + (this.__layout.strokeSpread || 0);
6629
6713
  }
6630
6714
  };
6631
6715
 
@@ -6716,7 +6800,7 @@ var LeaferUI = (function (exports) {
6716
6800
 
6717
6801
  const RectRender = {
6718
6802
  __drawFast(canvas, options) {
6719
- const { width, height, fill, stroke, __drawAfterFill } = this.__;
6803
+ let { width, height, fill, stroke, __drawAfterFill } = this.__;
6720
6804
  if (fill) {
6721
6805
  canvas.fillStyle = fill;
6722
6806
  canvas.fillRect(0, 0, width, height);
@@ -6734,7 +6818,16 @@ var LeaferUI = (function (exports) {
6734
6818
  canvas.strokeRect(0, 0, width, height);
6735
6819
  break;
6736
6820
  case 'inside':
6737
- canvas.strokeRect(half, half, width - __strokeWidth, height - __strokeWidth);
6821
+ width -= __strokeWidth, height -= __strokeWidth;
6822
+ if (width < 0 || height < 0) {
6823
+ canvas.save();
6824
+ this.__clip(canvas, options);
6825
+ canvas.strokeRect(half, half, width, height);
6826
+ canvas.restore();
6827
+ }
6828
+ else {
6829
+ canvas.strokeRect(half, half, width, height);
6830
+ }
6738
6831
  break;
6739
6832
  case 'outside':
6740
6833
  canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
@@ -6762,11 +6855,14 @@ var LeaferUI = (function (exports) {
6762
6855
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
6763
6856
  }
6764
6857
  get pen() {
6765
- pen.set(this.path = this.__.path || []);
6858
+ const { path } = this.__;
6859
+ pen.set(this.path = path || []);
6860
+ if (!path)
6861
+ this.__drawPathByBox(pen);
6766
6862
  return pen;
6767
6863
  }
6768
6864
  get editConfig() { return undefined; }
6769
- get editOuter() { return 'EditTool'; }
6865
+ get editOuter() { return this.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }
6770
6866
  get editInner() { return 'PathEditor'; }
6771
6867
  constructor(data) {
6772
6868
  super(data);
@@ -6780,22 +6876,22 @@ var LeaferUI = (function (exports) {
6780
6876
  }
6781
6877
  createProxyData() { return undefined; }
6782
6878
  find(_condition, _options) { return undefined; }
6879
+ findTag(tag) { return this.find({ tag }); }
6783
6880
  findOne(_condition, _options) { return undefined; }
6881
+ findId(id) { return this.findOne({ id }); }
6784
6882
  getPath(curve, pathForRender) {
6785
6883
  this.__layout.update();
6786
6884
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
6787
- if (!path) {
6788
- const { width, height } = this.boxBounds;
6789
- if (width || height) {
6790
- pen.set(path = []);
6791
- this.__drawPathByBox(pen);
6792
- }
6793
- }
6885
+ if (!path)
6886
+ pen.set(path = []), this.__drawPathByBox(pen);
6794
6887
  return curve ? PathConvert.toCanvasData(path, true) : path;
6795
6888
  }
6796
6889
  getPathString(curve, pathForRender) {
6797
6890
  return PathConvert.stringify(this.getPath(curve, pathForRender));
6798
6891
  }
6892
+ load() {
6893
+ this.__.__computePaint();
6894
+ }
6799
6895
  __onUpdateSize() {
6800
6896
  if (this.__.__input) {
6801
6897
  const data = this.__;
@@ -6881,7 +6977,7 @@ var LeaferUI = (function (exports) {
6881
6977
  opacityType(1)
6882
6978
  ], exports.UI.prototype, "opacity", void 0);
6883
6979
  __decorate([
6884
- opacityType(true)
6980
+ visibleType(true)
6885
6981
  ], exports.UI.prototype, "visible", void 0);
6886
6982
  __decorate([
6887
6983
  stateType(false)
@@ -6898,9 +6994,6 @@ var LeaferUI = (function (exports) {
6898
6994
  __decorate([
6899
6995
  maskType(false)
6900
6996
  ], exports.UI.prototype, "mask", void 0);
6901
- __decorate([
6902
- surfaceType('pixel')
6903
- ], exports.UI.prototype, "maskType", void 0);
6904
6997
  __decorate([
6905
6998
  eraserType(false)
6906
6999
  ], exports.UI.prototype, "eraser", void 0);
@@ -6931,9 +7024,75 @@ var LeaferUI = (function (exports) {
6931
7024
  __decorate([
6932
7025
  rotationType(0, true)
6933
7026
  ], exports.UI.prototype, "skewY", void 0);
7027
+ __decorate([
7028
+ positionType(0, true)
7029
+ ], exports.UI.prototype, "offsetX", void 0);
7030
+ __decorate([
7031
+ positionType(0, true)
7032
+ ], exports.UI.prototype, "offsetY", void 0);
7033
+ __decorate([
7034
+ positionType(0, true)
7035
+ ], exports.UI.prototype, "scrollX", void 0);
7036
+ __decorate([
7037
+ positionType(0, true)
7038
+ ], exports.UI.prototype, "scrollY", void 0);
7039
+ __decorate([
7040
+ autoLayoutType()
7041
+ ], exports.UI.prototype, "origin", void 0);
6934
7042
  __decorate([
6935
7043
  autoLayoutType()
6936
7044
  ], exports.UI.prototype, "around", void 0);
7045
+ __decorate([
7046
+ dataType(false)
7047
+ ], exports.UI.prototype, "lazy", void 0);
7048
+ __decorate([
7049
+ naturalBoundsType(1)
7050
+ ], exports.UI.prototype, "pixelRatio", void 0);
7051
+ __decorate([
7052
+ pathInputType()
7053
+ ], exports.UI.prototype, "path", void 0);
7054
+ __decorate([
7055
+ pathType()
7056
+ ], exports.UI.prototype, "windingRule", void 0);
7057
+ __decorate([
7058
+ pathType(true)
7059
+ ], exports.UI.prototype, "closed", void 0);
7060
+ __decorate([
7061
+ autoLayoutType(false)
7062
+ ], exports.UI.prototype, "flow", void 0);
7063
+ __decorate([
7064
+ boundsType(0)
7065
+ ], exports.UI.prototype, "padding", void 0);
7066
+ __decorate([
7067
+ boundsType(0)
7068
+ ], exports.UI.prototype, "gap", void 0);
7069
+ __decorate([
7070
+ boundsType('top-left')
7071
+ ], exports.UI.prototype, "align", void 0);
7072
+ __decorate([
7073
+ boundsType(false)
7074
+ ], exports.UI.prototype, "wrap", void 0);
7075
+ __decorate([
7076
+ boundsType('box')
7077
+ ], exports.UI.prototype, "itemBox", void 0);
7078
+ __decorate([
7079
+ boundsType(true)
7080
+ ], exports.UI.prototype, "inFlow", void 0);
7081
+ __decorate([
7082
+ boundsType()
7083
+ ], exports.UI.prototype, "autoWidth", void 0);
7084
+ __decorate([
7085
+ boundsType()
7086
+ ], exports.UI.prototype, "autoHeight", void 0);
7087
+ __decorate([
7088
+ boundsType()
7089
+ ], exports.UI.prototype, "autoBox", void 0);
7090
+ __decorate([
7091
+ boundsType()
7092
+ ], exports.UI.prototype, "widthRange", void 0);
7093
+ __decorate([
7094
+ boundsType()
7095
+ ], exports.UI.prototype, "heightRange", void 0);
6937
7096
  __decorate([
6938
7097
  dataType(false)
6939
7098
  ], exports.UI.prototype, "draggable", void 0);
@@ -6943,9 +7102,6 @@ var LeaferUI = (function (exports) {
6943
7102
  __decorate([
6944
7103
  dataType(false)
6945
7104
  ], exports.UI.prototype, "editable", void 0);
6946
- __decorate([
6947
- dataType('size')
6948
- ], exports.UI.prototype, "editSize", void 0);
6949
7105
  __decorate([
6950
7106
  hitType(true)
6951
7107
  ], exports.UI.prototype, "hittable", void 0);
@@ -7000,21 +7156,6 @@ var LeaferUI = (function (exports) {
7000
7156
  __decorate([
7001
7157
  strokeType(10)
7002
7158
  ], exports.UI.prototype, "miterLimit", void 0);
7003
- __decorate([
7004
- dataType(false)
7005
- ], exports.UI.prototype, "lazy", void 0);
7006
- __decorate([
7007
- naturalBoundsType(1)
7008
- ], exports.UI.prototype, "pixelRatio", void 0);
7009
- __decorate([
7010
- pathInputType()
7011
- ], exports.UI.prototype, "path", void 0);
7012
- __decorate([
7013
- pathType()
7014
- ], exports.UI.prototype, "windingRule", void 0);
7015
- __decorate([
7016
- pathType(true)
7017
- ], exports.UI.prototype, "closed", void 0);
7018
7159
  __decorate([
7019
7160
  arrowType('none')
7020
7161
  ], exports.UI.prototype, "startArrow", void 0);
@@ -7145,6 +7286,7 @@ var LeaferUI = (function (exports) {
7145
7286
  get layoutLocked() { return !this.layouter.running; }
7146
7287
  get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7147
7288
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7289
+ get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
7148
7290
  constructor(userConfig, data) {
7149
7291
  super(data);
7150
7292
  this.config = {
@@ -7248,9 +7390,6 @@ var LeaferUI = (function (exports) {
7248
7390
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7249
7391
  Object.keys(data).forEach(key => this[key] = data[key]);
7250
7392
  }
7251
- forceFullRender() {
7252
- this.forceRender();
7253
- }
7254
7393
  forceRender(bounds) {
7255
7394
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7256
7395
  if (this.viewReady)
@@ -7305,7 +7444,8 @@ var LeaferUI = (function (exports) {
7305
7444
  this.__changeFill(newValue);
7306
7445
  }
7307
7446
  else if (attrName === 'hittable') {
7308
- this.canvas.hittable = newValue;
7447
+ if (!this.parent)
7448
+ this.canvas.hittable = newValue;
7309
7449
  }
7310
7450
  }
7311
7451
  return super.__setAttr(attrName, newValue);
@@ -7328,7 +7468,7 @@ var LeaferUI = (function (exports) {
7328
7468
  this.canvas.backgroundColor = newValue;
7329
7469
  }
7330
7470
  else {
7331
- this.forceFullRender();
7471
+ this.forceRender();
7332
7472
  }
7333
7473
  }
7334
7474
  __onCreated() {
@@ -7423,6 +7563,9 @@ var LeaferUI = (function (exports) {
7423
7563
  zoom(_zoomType, _padding, _fixedScale) { return undefined; }
7424
7564
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
7425
7565
  getValidScale(changeScale) { return changeScale; }
7566
+ getWorldPointByClient(clientPoint, updateClient) {
7567
+ return this.interaction && this.interaction.getLocal(clientPoint, updateClient);
7568
+ }
7426
7569
  __checkUpdateLayout() {
7427
7570
  this.__layout.update();
7428
7571
  }
@@ -7505,8 +7648,8 @@ var LeaferUI = (function (exports) {
7505
7648
 
7506
7649
  const rect = exports.Rect.prototype;
7507
7650
  const group = exports.Group.prototype;
7508
- const bounds$1 = {};
7509
- const { copy: copy$2, add } = BoundsHelper;
7651
+ const childrenRenderBounds = {};
7652
+ const { copy: copy$2, add, includes: includes$1 } = BoundsHelper;
7510
7653
  exports.Box = class Box extends exports.Group {
7511
7654
  get __tag() { return 'Box'; }
7512
7655
  get isBranchLeaf() { return true; }
@@ -7517,24 +7660,29 @@ var LeaferUI = (function (exports) {
7517
7660
  __updateStrokeSpread() { return 0; }
7518
7661
  __updateRectRenderSpread() { return 0; }
7519
7662
  __updateRenderSpread() {
7520
- const width = this.__updateRectRenderSpread();
7521
- const hide = this.__.__drawAfterFill = this.__.overflow === 'hide';
7522
- return (width || hide) ? width : -1;
7663
+ return this.__updateRectRenderSpread() || -1;
7523
7664
  }
7524
7665
  __updateRectBoxBounds() { }
7525
7666
  __updateBoxBounds() {
7526
7667
  const data = this.__;
7527
- if (data.__autoSide && this.children.length) {
7528
- if (this.leafer)
7529
- this.leafer.layouter.addExtra(this);
7530
- super.__updateBoxBounds();
7531
- if (!data.__autoSize) {
7532
- const b = this.__layout.boxBounds;
7533
- if (!data.__autoWidth)
7534
- b.x = 0, b.width = data.width;
7535
- if (!data.__autoHeight)
7536
- b.y = 0, b.height = data.height;
7668
+ if (this.children.length) {
7669
+ if (data.__autoSide) {
7670
+ if (this.leafer && this.leafer.ready)
7671
+ this.leafer.layouter.addExtra(this);
7672
+ super.__updateBoxBounds();
7673
+ if (!data.__autoSize) {
7674
+ const b = this.__layout.boxBounds;
7675
+ if (!data.__autoWidth)
7676
+ b.x = 0, b.width = data.width;
7677
+ if (!data.__autoHeight)
7678
+ b.y = 0, b.height = data.height;
7679
+ }
7680
+ }
7681
+ else {
7682
+ this.__updateRectBoxBounds();
7537
7683
  }
7684
+ if (data.flow)
7685
+ this.__updateContentBounds();
7538
7686
  }
7539
7687
  else {
7540
7688
  this.__updateRectBoxBounds();
@@ -7542,13 +7690,20 @@ var LeaferUI = (function (exports) {
7542
7690
  }
7543
7691
  __updateStrokeBounds() { }
7544
7692
  __updateRenderBounds() {
7545
- this.__updateRectRenderBounds();
7546
- if (!this.__.__drawAfterFill) {
7547
- const { renderBounds } = this.__layout;
7548
- copy$2(bounds$1, renderBounds);
7693
+ let isOverflow;
7694
+ const { renderBounds } = this.__layout;
7695
+ if (this.children.length) {
7549
7696
  super.__updateRenderBounds();
7550
- add(renderBounds, bounds$1);
7697
+ copy$2(childrenRenderBounds, renderBounds);
7698
+ this.__updateRectRenderBounds();
7699
+ isOverflow = !includes$1(renderBounds, childrenRenderBounds) || undefined;
7700
+ }
7701
+ else {
7702
+ this.__updateRectRenderBounds();
7551
7703
  }
7704
+ this.isOverflow !== isOverflow && (this.isOverflow = isOverflow);
7705
+ if (isOverflow && !(this.__.__drawAfterFill = this.__.overflow === 'hide'))
7706
+ add(renderBounds, childrenRenderBounds);
7552
7707
  }
7553
7708
  __updateRectRenderBounds() { }
7554
7709
  __updateRectChange() { }
@@ -7564,16 +7719,27 @@ var LeaferUI = (function (exports) {
7564
7719
  }
7565
7720
  else {
7566
7721
  this.__renderRect(canvas, options);
7567
- this.__renderGroup(canvas, options);
7722
+ if (this.children.length)
7723
+ this.__renderGroup(canvas, options);
7568
7724
  }
7569
7725
  }
7570
7726
  __drawAfterFill(canvas, options) {
7571
- canvas.save();
7572
- canvas.clip();
7573
- this.__renderGroup(canvas, options);
7574
- canvas.restore();
7575
- if (this.__.stroke)
7727
+ const { length } = this.children;
7728
+ if (this.isOverflow) {
7729
+ canvas.save();
7730
+ canvas.clip();
7731
+ if (length)
7732
+ this.__renderGroup(canvas, options);
7733
+ canvas.restore();
7734
+ }
7735
+ else {
7736
+ if (length)
7737
+ this.__renderGroup(canvas, options);
7738
+ }
7739
+ if (this.__.stroke && length) {
7740
+ canvas.setWorld(this.__nowWorld);
7576
7741
  this.__drawRenderPath(canvas);
7742
+ }
7577
7743
  }
7578
7744
  };
7579
7745
  __decorate([
@@ -7711,9 +7877,10 @@ var LeaferUI = (function (exports) {
7711
7877
  super(data);
7712
7878
  }
7713
7879
  __updatePath() {
7714
- const path = this.__.path = [];
7715
- if (this.__.points) {
7716
- drawPoints$1(path, this.__.points, this.__.closed);
7880
+ const data = this.__;
7881
+ const path = data.path = [];
7882
+ if (data.points) {
7883
+ drawPoints$1(path, data.points, false, data.closed);
7717
7884
  }
7718
7885
  else {
7719
7886
  moveTo$2(path, 0, 0);
@@ -7948,7 +8115,7 @@ var LeaferUI = (function (exports) {
7948
8115
  registerUI()
7949
8116
  ], exports.Canvas);
7950
8117
 
7951
- const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8118
+ const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
7952
8119
  exports.Text = class Text extends exports.UI {
7953
8120
  get __tag() { return 'Text'; }
7954
8121
  get editInner() { return 'TextEditor'; }
@@ -8021,7 +8188,7 @@ var LeaferUI = (function (exports) {
8021
8188
  if (italic)
8022
8189
  b.width += fontSize * 0.16;
8023
8190
  const contentBounds = includes(b, bounds) ? b : bounds;
8024
- if (contentBounds !== layout.contentBounds) {
8191
+ if (!isSame$1(contentBounds, layout.contentBounds)) {
8025
8192
  layout.contentBounds = contentBounds;
8026
8193
  layout.renderChanged = true;
8027
8194
  setList(data.__textBoxBounds = {}, [b, bounds]);
@@ -8049,9 +8216,6 @@ var LeaferUI = (function (exports) {
8049
8216
  __decorate([
8050
8217
  boundsType(0)
8051
8218
  ], exports.Text.prototype, "height", void 0);
8052
- __decorate([
8053
- boundsType(0)
8054
- ], exports.Text.prototype, "padding", void 0);
8055
8219
  __decorate([
8056
8220
  surfaceType('#000000')
8057
8221
  ], exports.Text.prototype, "fill", void 0);
@@ -8086,7 +8250,7 @@ var LeaferUI = (function (exports) {
8086
8250
  boundsType(0)
8087
8251
  ], exports.Text.prototype, "letterSpacing", void 0);
8088
8252
  __decorate([
8089
- boundsType({ type: 'percent', value: 150 })
8253
+ boundsType({ type: 'percent', value: 1.5 })
8090
8254
  ], exports.Text.prototype, "lineHeight", void 0);
8091
8255
  __decorate([
8092
8256
  boundsType(0)
@@ -8180,8 +8344,6 @@ var LeaferUI = (function (exports) {
8180
8344
  };
8181
8345
  }
8182
8346
 
8183
- const version = "1.0.0-rc.21";
8184
-
8185
8347
  function fillText(ui, canvas) {
8186
8348
  let row;
8187
8349
  const { rows, decorationY, decorationHeight } = ui.__.__textDrawData;
@@ -8401,7 +8563,7 @@ var LeaferUI = (function (exports) {
8401
8563
  }
8402
8564
  else {
8403
8565
  const { renderShapeSpread: spread } = ui.__layout;
8404
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, spread * scaleX, spread * scaleY) : current.bounds, nowWorld);
8566
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
8405
8567
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
8406
8568
  let { a: fitScaleX, d: fitScaleY } = fitMatrix;
8407
8569
  if (fitMatrix.a < 1) {
@@ -8501,10 +8663,10 @@ var LeaferUI = (function (exports) {
8501
8663
  rotate(transform, rotation);
8502
8664
  data.transform = transform;
8503
8665
  }
8504
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
8666
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
8505
8667
  const transform = get$4();
8506
8668
  if (rotation) {
8507
- if (around === 'center') {
8669
+ if (align === 'center') {
8508
8670
  rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
8509
8671
  }
8510
8672
  else {
@@ -8537,12 +8699,12 @@ var LeaferUI = (function (exports) {
8537
8699
  let { width, height } = image;
8538
8700
  if (paint.padding)
8539
8701
  box = tempBox.set(box).shrink(paint.padding);
8540
- const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
8702
+ const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
8541
8703
  const sameBox = box.width === width && box.height === height;
8542
8704
  if (blendMode)
8543
8705
  leafPaint.blendMode = blendMode;
8544
8706
  const data = leafPaint.data = { mode };
8545
- const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
8707
+ const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
8546
8708
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
8547
8709
  let x = 0, y = 0, scaleX, scaleY;
8548
8710
  if (!mode || mode === 'cover' || mode === 'fit') {
@@ -8560,11 +8722,11 @@ var LeaferUI = (function (exports) {
8560
8722
  scaleX = typeof scale === 'number' ? scale : scale.x;
8561
8723
  scaleY = typeof scale === 'number' ? scale : scale.y;
8562
8724
  }
8563
- if (around) {
8725
+ if (align) {
8564
8726
  const imageBounds = { x, y, width: swapWidth, height: swapHeight };
8565
8727
  if (scaleX)
8566
8728
  imageBounds.width *= scaleX, imageBounds.height *= scaleY;
8567
- AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
8729
+ AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
8568
8730
  x += tempPoint.x, y += tempPoint.y;
8569
8731
  }
8570
8732
  if (offset)
@@ -8581,7 +8743,7 @@ var LeaferUI = (function (exports) {
8581
8743
  break;
8582
8744
  case 'repeat':
8583
8745
  if (!sameBox || scaleX || rotation)
8584
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
8746
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
8585
8747
  if (!repeat)
8586
8748
  data.repeat = 'repeat';
8587
8749
  break;
@@ -8852,13 +9014,14 @@ var LeaferUI = (function (exports) {
8852
9014
  recycleImage
8853
9015
  };
8854
9016
 
8855
- const defaultFrom$2 = { x: 0.5, y: 0 };
8856
- const defaultTo$2 = { x: 0.5, y: 1 };
9017
+ const { toPoint: toPoint$2 } = AroundHelper;
9018
+ const realFrom$2 = {};
9019
+ const realTo$2 = {};
8857
9020
  function linearGradient(paint, box) {
8858
9021
  let { from, to, type, blendMode, opacity } = paint;
8859
- from || (from = defaultFrom$2);
8860
- to || (to = defaultTo$2);
8861
- const style = Platform.canvas.createLinearGradient(box.x + from.x * box.width, box.y + from.y * box.height, box.x + to.x * box.width, box.y + to.y * box.height);
9022
+ toPoint$2(from || 'top', box, realFrom$2);
9023
+ toPoint$2(to || 'bottom', box, realTo$2);
9024
+ const style = Platform.canvas.createLinearGradient(realFrom$2.x, realFrom$2.y, realTo$2.x, realTo$2.y);
8862
9025
  applyStops(style, paint.stops, opacity);
8863
9026
  const data = { type, style };
8864
9027
  if (blendMode)
@@ -8869,23 +9032,25 @@ var LeaferUI = (function (exports) {
8869
9032
  let stop;
8870
9033
  for (let i = 0, len = stops.length; i < len; i++) {
8871
9034
  stop = stops[i];
8872
- gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
9035
+ if (typeof stop === 'string') {
9036
+ gradient.addColorStop(i / (len - 1), ColorConvert.string(stop, opacity));
9037
+ }
9038
+ else {
9039
+ gradient.addColorStop(stop.offset, ColorConvert.string(stop.color, opacity));
9040
+ }
8873
9041
  }
8874
9042
  }
8875
9043
 
8876
- const { set: set$1, getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
9044
+ const { getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
8877
9045
  const { get: get$1, rotateOfOuter: rotateOfOuter$1, scaleOfOuter: scaleOfOuter$1 } = MatrixHelper;
8878
- const defaultFrom$1 = { x: 0.5, y: 0.5 };
8879
- const defaultTo$1 = { x: 0.5, y: 1 };
9046
+ const { toPoint: toPoint$1 } = AroundHelper;
8880
9047
  const realFrom$1 = {};
8881
9048
  const realTo$1 = {};
8882
9049
  function radialGradient(paint, box) {
8883
9050
  let { from, to, type, opacity, blendMode, stretch } = paint;
8884
- from || (from = defaultFrom$1);
8885
- to || (to = defaultTo$1);
8886
- const { x, y, width, height } = box;
8887
- set$1(realFrom$1, x + from.x * width, y + from.y * height);
8888
- set$1(realTo$1, x + to.x * width, y + to.y * height);
9051
+ toPoint$1(from || 'center', box, realFrom$1);
9052
+ toPoint$1(to || 'bottom', box, realTo$1);
9053
+ const { width, height } = box;
8889
9054
  let transform;
8890
9055
  if (width !== height || stretch) {
8891
9056
  transform = get$1();
@@ -8900,19 +9065,16 @@ var LeaferUI = (function (exports) {
8900
9065
  return data;
8901
9066
  }
8902
9067
 
8903
- const { set, getAngle, getDistance } = PointHelper;
9068
+ const { getAngle, getDistance } = PointHelper;
8904
9069
  const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
8905
- const defaultFrom = { x: 0.5, y: 0.5 };
8906
- const defaultTo = { x: 0.5, y: 1 };
9070
+ const { toPoint } = AroundHelper;
8907
9071
  const realFrom = {};
8908
9072
  const realTo = {};
8909
9073
  function conicGradient(paint, box) {
8910
9074
  let { from, to, type, opacity, blendMode, stretch } = paint;
8911
- from || (from = defaultFrom);
8912
- to || (to = defaultTo);
8913
- const { x, y, width, height } = box;
8914
- set(realFrom, x + from.x * width, y + from.y * height);
8915
- set(realTo, x + to.x * width, y + to.y * height);
9075
+ toPoint(from || 'center', box, realFrom);
9076
+ toPoint(to || 'bottom', box, realTo);
9077
+ const { width, height } = box;
8916
9078
  const transform = get();
8917
9079
  const angle = getAngle(realFrom, realTo);
8918
9080
  if (Platform.conicGradientRotate90) {
@@ -9066,7 +9228,7 @@ var LeaferUI = (function (exports) {
9066
9228
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
9067
9229
  maskCanvas = contentCanvas = null;
9068
9230
  }
9069
- if (child.__.maskType === 'path') {
9231
+ if (child.__.mask === 'path') {
9070
9232
  if (child.opacity < 1) {
9071
9233
  currentMask = 'opacity-path';
9072
9234
  maskOpacity = child.opacity;
@@ -9087,7 +9249,7 @@ var LeaferUI = (function (exports) {
9087
9249
  contentCanvas = getCanvas(canvas);
9088
9250
  child.__render(maskCanvas, options);
9089
9251
  }
9090
- if (child.__.maskType !== 'clipping')
9252
+ if (child.__.mask !== 'clipping')
9091
9253
  continue;
9092
9254
  }
9093
9255
  if (excludeRenderBounds(child, options))
@@ -9388,11 +9550,11 @@ var LeaferUI = (function (exports) {
9388
9550
  if (mode === WordMode) {
9389
9551
  wordChar = { char: '', x: charX };
9390
9552
  charX = toWordChar(word.data, charX, wordChar);
9391
- if (wordChar.char !== ' ')
9553
+ if (row.isOverflow || wordChar.char !== ' ')
9392
9554
  row.data.push(wordChar);
9393
9555
  }
9394
9556
  else {
9395
- charX = toChar(word.data, charX, row.data);
9557
+ charX = toChar(word.data, charX, row.data, row.isOverflow);
9396
9558
  }
9397
9559
  if (!row.paraEnd && addWordWidth) {
9398
9560
  charX += addWordWidth;
@@ -9419,9 +9581,9 @@ var LeaferUI = (function (exports) {
9419
9581
  });
9420
9582
  return charX;
9421
9583
  }
9422
- function toChar(data, charX, rowData) {
9584
+ function toChar(data, charX, rowData, isOverflow) {
9423
9585
  data.forEach(char => {
9424
- if (char.char !== ' ') {
9586
+ if (isOverflow || char.char !== ' ') {
9425
9587
  char.x = charX;
9426
9588
  rowData.push(char);
9427
9589
  }
@@ -9453,12 +9615,14 @@ var LeaferUI = (function (exports) {
9453
9615
  for (let i = 0, len = rows.length; i < len; i++) {
9454
9616
  row = rows[i];
9455
9617
  row.x = x;
9456
- switch (textAlign) {
9457
- case 'center':
9458
- row.x += (width - row.width) / 2;
9459
- break;
9460
- case 'right':
9461
- row.x += width - row.width;
9618
+ if (row.width < width || (row.width > width && !__clipText)) {
9619
+ switch (textAlign) {
9620
+ case 'center':
9621
+ row.x += (width - row.width) / 2;
9622
+ break;
9623
+ case 'right':
9624
+ row.x += width - row.width;
9625
+ }
9462
9626
  }
9463
9627
  if (row.paraStart && paraSpacing && i > 0)
9464
9628
  starY += paraSpacing;
@@ -9498,11 +9662,13 @@ var LeaferUI = (function (exports) {
9498
9662
  const { rows, overflow } = drawData;
9499
9663
  let { textOverflow } = style;
9500
9664
  rows.splice(overflow);
9501
- if (textOverflow !== 'hide') {
9502
- if (textOverflow === 'ellipsis')
9665
+ if (textOverflow && textOverflow !== 'show') {
9666
+ if (textOverflow === 'hide')
9667
+ textOverflow = '';
9668
+ else if (textOverflow === 'ellipsis')
9503
9669
  textOverflow = '...';
9504
9670
  let char, charRight;
9505
- const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
9671
+ const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
9506
9672
  const right = style.x + style.width - ellipsisWidth;
9507
9673
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
9508
9674
  list.forEach(row => {
@@ -9670,8 +9836,12 @@ var LeaferUI = (function (exports) {
9670
9836
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
9671
9837
  const { worldTransform, isLeafer, isFrame } = leaf;
9672
9838
  const { slice, trim, onCanvas } = options;
9673
- const scale = options.scale || 1;
9674
- const pixelRatio = options.pixelRatio || 1;
9839
+ let scale = options.scale || 1;
9840
+ let pixelRatio = options.pixelRatio || 1;
9841
+ if (leaf.isApp) {
9842
+ scale *= pixelRatio;
9843
+ pixelRatio = leaf.app.pixelRatio;
9844
+ }
9675
9845
  const screenshot = options.screenshot || leaf.isApp;
9676
9846
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
9677
9847
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -9801,6 +9971,7 @@ var LeaferUI = (function (exports) {
9801
9971
 
9802
9972
  useCanvas();
9803
9973
 
9974
+ exports.AlignHelper = AlignHelper;
9804
9975
  exports.AnimateEvent = AnimateEvent;
9805
9976
  exports.AroundHelper = AroundHelper;
9806
9977
  exports.AutoBounds = AutoBounds;
@@ -9925,6 +10096,7 @@ var LeaferUI = (function (exports) {
9925
10096
  exports.getMatrixData = getMatrixData;
9926
10097
  exports.getPointData = getPointData;
9927
10098
  exports.hitType = hitType;
10099
+ exports.inviteCode = inviteCode;
9928
10100
  exports.layoutProcessor = layoutProcessor;
9929
10101
  exports.maskType = maskType;
9930
10102
  exports.naturalBoundsType = naturalBoundsType;
@@ -9950,6 +10122,7 @@ var LeaferUI = (function (exports) {
9950
10122
  exports.useCanvas = useCanvas;
9951
10123
  exports.useModule = useModule;
9952
10124
  exports.version = version;
10125
+ exports.visibleType = visibleType;
9953
10126
  exports.zoomLayerType = zoomLayerType;
9954
10127
 
9955
10128
  return exports;