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

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$2 = {};
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$2);
859
+ setPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.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$2);
862
+ addPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.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$2);
865
+ addPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.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$2);
868
+ addPoint$3(tempPointBounds$1, toPoint$2.x, toPoint$2.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$1 } = AroundHelper;
1242
+ const AlignHelper = {
1243
+ toPoint(align, contentBounds, bounds, to, onlySize) {
1244
+ toPoint$1(align, bounds, to, onlySize, contentBounds);
1245
+ }
1246
+ };
1247
+
1235
1248
  const StringNumberMap = {
1236
1249
  '0': 1,
1237
1250
  '1': 1,
@@ -1464,13 +1477,19 @@ 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 {
1472
1491
  get __blendMode() {
1473
- if (this.eraser)
1492
+ if (this.eraser && this.eraser !== 'path')
1474
1493
  return 'destination-out';
1475
1494
  const { blendMode } = this;
1476
1495
  return blendMode === 'pass-through' ? null : blendMode;
@@ -2100,7 +2119,7 @@ var LeaferUI = (function (exports) {
2100
2119
  }
2101
2120
  clear() {
2102
2121
  const { pixelRatio } = this;
2103
- this.clearRect(0, 0, this.width * pixelRatio, this.height * pixelRatio);
2122
+ this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
2104
2123
  }
2105
2124
  isSameSize(size) {
2106
2125
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
@@ -3756,6 +3775,8 @@ var LeaferUI = (function (exports) {
3756
3775
  this.__setAttr(key, value);
3757
3776
  this.__layout.boxChanged || this.__layout.boxChange();
3758
3777
  this.waitParent(() => { this.parent.__updateMask(value); });
3778
+ if (typeof value === 'string')
3779
+ this.maskType = value;
3759
3780
  }
3760
3781
  }));
3761
3782
  }
@@ -4185,11 +4206,19 @@ var LeaferUI = (function (exports) {
4185
4206
 
4186
4207
  const { getRelativeWorld: getRelativeWorld$1 } = LeafHelper;
4187
4208
  const { toOuterOf: toOuterOf$2, getPoints, copy: copy$5 } = BoundsHelper;
4209
+ const localContent = '_localContentBounds';
4210
+ const worldContent = '_worldContentBounds', worldBox = '_worldBoxBounds', worldStroke = '_worldStrokeBounds';
4188
4211
  class LeafLayout {
4212
+ get contentBounds() { return this._contentBounds || this.boxBounds; }
4213
+ set contentBounds(bounds) { this._contentBounds = bounds; }
4189
4214
  get strokeBounds() { return this._strokeBounds || this.boxBounds; }
4190
4215
  get renderBounds() { return this._renderBounds || this.boxBounds; }
4216
+ get localContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__localMatrix, this[localContent] || (this[localContent] = {})); return this[localContent]; }
4191
4217
  get localStrokeBounds() { return this._localStrokeBounds || this; }
4192
4218
  get localRenderBounds() { return this._localRenderBounds || this; }
4219
+ get worldContentBounds() { toOuterOf$2(this.contentBounds, this.leaf.__world, this[worldContent] || (this[worldContent] = {})); return this[worldContent]; }
4220
+ get worldBoxBounds() { toOuterOf$2(this.boxBounds, this.leaf.__world, this[worldBox] || (this[worldBox] = {})); return this[worldBox]; }
4221
+ get worldStrokeBounds() { toOuterOf$2(this.strokeBounds, this.leaf.__world, this[worldStroke] || (this[worldStroke] = {})); return this[worldStroke]; }
4193
4222
  get a() { return 1; }
4194
4223
  get b() { return 0; }
4195
4224
  get c() { return 0; }
@@ -4272,7 +4301,6 @@ var LeaferUI = (function (exports) {
4272
4301
  case 'content':
4273
4302
  if (this.contentBounds)
4274
4303
  return this.contentBounds;
4275
- case 'margin':
4276
4304
  case 'box':
4277
4305
  return this.boxBounds;
4278
4306
  case 'stroke':
@@ -4285,8 +4313,9 @@ var LeaferUI = (function (exports) {
4285
4313
  return this.localRenderBounds;
4286
4314
  case 'stroke':
4287
4315
  return this.localStrokeBounds;
4288
- case 'margin':
4289
4316
  case 'content':
4317
+ if (this.contentBounds)
4318
+ return this.localContentBounds;
4290
4319
  case 'box':
4291
4320
  return this.leaf.__localBoxBounds;
4292
4321
  }
@@ -4295,15 +4324,13 @@ var LeaferUI = (function (exports) {
4295
4324
  switch (type) {
4296
4325
  case 'render':
4297
4326
  return this.leaf.__world;
4327
+ case 'stroke':
4328
+ return this.worldStrokeBounds;
4298
4329
  case 'content':
4299
4330
  if (this.contentBounds)
4300
- return this.getWorldContentBounds();
4301
- case 'margin':
4331
+ return this.worldContentBounds;
4302
4332
  case 'box':
4303
- return this.getWorldBoxBounds();
4304
- case 'margin':
4305
- case 'stroke':
4306
- return this.getWorldStrokeBounds();
4333
+ return this.worldBoxBounds;
4307
4334
  }
4308
4335
  }
4309
4336
  getLayoutBounds(type, relative = 'world', unscale) {
@@ -4366,20 +4393,24 @@ var LeaferUI = (function (exports) {
4366
4393
  points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
4367
4394
  return points;
4368
4395
  }
4369
- getWorldContentBounds() {
4370
- this._worldContentBounds || (this._worldContentBounds = {});
4371
- toOuterOf$2(this.contentBounds, this.leaf.__world, this._worldContentBounds);
4372
- return this._worldContentBounds;
4396
+ shrinkContent() {
4397
+ const { x, y, width, height } = this.boxBounds;
4398
+ this._contentBounds = { x, y, width, height };
4373
4399
  }
4374
- getWorldBoxBounds() {
4375
- this._worldBoxBounds || (this._worldBoxBounds = {});
4376
- toOuterOf$2(this.boxBounds, this.leaf.__world, this._worldBoxBounds);
4377
- return this._worldBoxBounds;
4400
+ spreadStroke() {
4401
+ const { x, y, width, height } = this.strokeBounds;
4402
+ this._strokeBounds = { x, y, width, height };
4403
+ this._localStrokeBounds = { x, y, width, height };
4404
+ if (!this.renderSpread)
4405
+ this.spreadRenderCancel();
4406
+ }
4407
+ spreadRender() {
4408
+ const { x, y, width, height } = this.renderBounds;
4409
+ this._renderBounds = { x, y, width, height };
4410
+ this._localRenderBounds = { x, y, width, height };
4378
4411
  }
4379
- getWorldStrokeBounds() {
4380
- this._worldStrokeBounds || (this._worldStrokeBounds = {});
4381
- toOuterOf$2(this.strokeBounds, this.leaf.__world, this._worldStrokeBounds);
4382
- return this._worldStrokeBounds;
4412
+ shrinkContentCancel() {
4413
+ this._contentBounds = undefined;
4383
4414
  }
4384
4415
  spreadStrokeCancel() {
4385
4416
  const same = this.renderBounds === this.strokeBounds;
@@ -4392,18 +4423,6 @@ var LeaferUI = (function (exports) {
4392
4423
  this._renderBounds = this._strokeBounds;
4393
4424
  this._localRenderBounds = this._localStrokeBounds;
4394
4425
  }
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
4426
  boxChange() {
4408
4427
  this.boxChanged = true;
4409
4428
  this.localBoxChanged || this.localBoxChange();
@@ -4490,24 +4509,40 @@ var LeaferUI = (function (exports) {
4490
4509
  });
4491
4510
  },
4492
4511
  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
- }
4512
+ if (type) {
4513
+ const typeList = typeof type === 'string' ? type.split(' ') : type;
4514
+ if (listener) {
4515
+ let capture;
4516
+ if (options)
4517
+ capture = typeof options === 'boolean' ? options : options.capture;
4518
+ let events, index;
4519
+ const map = __getListenerMap(this, capture);
4520
+ typeList.forEach(type => {
4521
+ if (type) {
4522
+ events = map[type];
4523
+ if (events) {
4524
+ index = events.findIndex(item => item.listener === listener);
4525
+ if (index > -1)
4526
+ events.splice(index, 1);
4527
+ if (!events.length)
4528
+ delete map[type];
4529
+ }
4530
+ }
4531
+ });
4509
4532
  }
4510
- });
4533
+ else {
4534
+ const { __bubbleMap: b, __captureMap: c } = this;
4535
+ typeList.forEach(type => {
4536
+ if (b)
4537
+ delete b[type];
4538
+ if (c)
4539
+ delete c[type];
4540
+ });
4541
+ }
4542
+ }
4543
+ else {
4544
+ this.__bubbleMap = this.__captureMap = undefined;
4545
+ }
4511
4546
  },
4512
4547
  on_(type, listener, bind, options) {
4513
4548
  if (bind)
@@ -4774,7 +4809,7 @@ var LeaferUI = (function (exports) {
4774
4809
  const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
4775
4810
  const LeafMatrix = {
4776
4811
  __updateWorldMatrix() {
4777
- multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
4812
+ multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
4778
4813
  },
4779
4814
  __updateLocalMatrix() {
4780
4815
  if (this.__local) {
@@ -4785,11 +4820,11 @@ var LeaferUI = (function (exports) {
4785
4820
  layout.scaleChanged = layout.rotationChanged = false;
4786
4821
  }
4787
4822
  }
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);
4823
+ local.e = data.x + data.offsetX;
4824
+ local.f = data.y + data.offsetY;
4825
+ if (data.around || data.origin) {
4826
+ toPoint(data.around || data.origin, layout.boxBounds, tempPoint$1);
4827
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.origin);
4793
4828
  }
4794
4829
  }
4795
4830
  this.__layout.matrixChanged = false;
@@ -4895,6 +4930,8 @@ var LeaferUI = (function (exports) {
4895
4930
  if (this.isBranch) {
4896
4931
  if (this.leafer)
4897
4932
  this.leafer.layouter.addExtra(this);
4933
+ if (this.__.flow)
4934
+ this.__updateFlowLayout();
4898
4935
  if (hasParentAutoLayout(this)) {
4899
4936
  updateMatrix$1(this);
4900
4937
  }
@@ -4927,6 +4964,8 @@ var LeaferUI = (function (exports) {
4927
4964
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
4928
4965
  canvas.opacity = this.__.opacity;
4929
4966
  if (this.__.__single) {
4967
+ if (this.__.eraser === 'path')
4968
+ return this.__renderEraser(canvas, options);
4930
4969
  const tempCanvas = canvas.getSameCanvas(true, true);
4931
4970
  this.__draw(tempCanvas, options);
4932
4971
  if (this.__worldFlipped) {
@@ -4969,6 +5008,8 @@ var LeaferUI = (function (exports) {
4969
5008
  __render(canvas, options) {
4970
5009
  if (this.__worldOpacity) {
4971
5010
  if (this.__.__single) {
5011
+ if (this.__.eraser === 'path')
5012
+ return this.__renderEraser(canvas, options);
4972
5013
  const tempCanvas = canvas.getSameCanvas(false, true);
4973
5014
  this.__renderBranch(tempCanvas, options);
4974
5015
  const nowWorld = this.__getNowWorld(options);
@@ -5108,7 +5149,9 @@ var LeaferUI = (function (exports) {
5108
5149
  setProxyAttr(_attrName, _newValue) { }
5109
5150
  getProxyAttr(_attrName) { return undefined; }
5110
5151
  find(_condition, _options) { return undefined; }
5152
+ findTag(_tag) { return undefined; }
5111
5153
  findOne(_condition, _options) { return undefined; }
5154
+ findId(_id) { return undefined; }
5112
5155
  focus(_value) { }
5113
5156
  forceUpdate(attrName) {
5114
5157
  if (attrName === undefined)
@@ -5130,9 +5173,11 @@ var LeaferUI = (function (exports) {
5130
5173
  __updateLocalStrokeBounds() { }
5131
5174
  __updateLocalRenderBounds() { }
5132
5175
  __updateBoxBounds() { }
5176
+ __updateContentBounds() { }
5133
5177
  __updateStrokeBounds() { }
5134
5178
  __updateRenderBounds() { }
5135
5179
  __updateAutoLayout() { }
5180
+ __updateFlowLayout() { }
5136
5181
  __updateNaturalSize() { }
5137
5182
  __updateStrokeSpread() { return 0; }
5138
5183
  __updateRenderSpread() { return 0; }
@@ -5140,6 +5185,13 @@ var LeaferUI = (function (exports) {
5140
5185
  __updateEraser(value) {
5141
5186
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
5142
5187
  }
5188
+ __renderEraser(canvas, options) {
5189
+ canvas.save();
5190
+ this.__clip(canvas, options);
5191
+ const { renderBounds: r } = this.__layout;
5192
+ canvas.clearRect(r.x, r.y, r.width, r.height);
5193
+ canvas.restore();
5194
+ }
5143
5195
  __updateMask(value) {
5144
5196
  this.__hasMask = value ? true : this.children.some(item => item.__.mask);
5145
5197
  }
@@ -5320,8 +5372,8 @@ var LeaferUI = (function (exports) {
5320
5372
  emit(_type, _event, _capture) { }
5321
5373
  emitEvent(_event, _capture) { }
5322
5374
  hasEvent(_type, _capture) { return false; }
5323
- static changeAttr(attrName, defaultValue) {
5324
- defineDataProcessor(this.prototype, attrName, defaultValue);
5375
+ static changeAttr(attrName, defaultValue, fn) {
5376
+ fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5325
5377
  }
5326
5378
  static addAttr(attrName, defaultValue, fn) {
5327
5379
  if (!fn)
@@ -6248,8 +6300,11 @@ var LeaferUI = (function (exports) {
6248
6300
  if (!bounds.includes(this.target.__world) || this.needFill || !e.samePixelRatio) {
6249
6301
  this.addBlock(this.canvas.bounds);
6250
6302
  this.target.forceUpdate('surface');
6303
+ return;
6251
6304
  }
6252
6305
  }
6306
+ this.addBlock(new Bounds(0, 0, 1, 1));
6307
+ this.changed = true;
6253
6308
  }
6254
6309
  __onLayoutEnd(event) {
6255
6310
  if (event.data)
@@ -6499,7 +6554,7 @@ var LeaferUI = (function (exports) {
6499
6554
  const UnitConvert = {
6500
6555
  number(value, percentRefer) {
6501
6556
  if (typeof value === 'object')
6502
- return value.type === 'percent' ? value.value / 100 * percentRefer : value.value;
6557
+ return value.type === 'percent' ? (value.value > 49 ? value.value / 100 : value.value) * percentRefer : value.value;
6503
6558
  return value;
6504
6559
  }
6505
6560
  };
@@ -6780,7 +6835,9 @@ var LeaferUI = (function (exports) {
6780
6835
  }
6781
6836
  createProxyData() { return undefined; }
6782
6837
  find(_condition, _options) { return undefined; }
6838
+ findTag(tag) { return this.find({ tag }); }
6783
6839
  findOne(_condition, _options) { return undefined; }
6840
+ findId(id) { return this.findOne({ id }); }
6784
6841
  getPath(curve, pathForRender) {
6785
6842
  this.__layout.update();
6786
6843
  let path = pathForRender ? this.__.__pathForRender : this.__.path;
@@ -6931,9 +6988,75 @@ var LeaferUI = (function (exports) {
6931
6988
  __decorate([
6932
6989
  rotationType(0, true)
6933
6990
  ], exports.UI.prototype, "skewY", void 0);
6991
+ __decorate([
6992
+ positionType(0, true)
6993
+ ], exports.UI.prototype, "offsetX", void 0);
6994
+ __decorate([
6995
+ positionType(0, true)
6996
+ ], exports.UI.prototype, "offsetY", void 0);
6997
+ __decorate([
6998
+ positionType(0, true)
6999
+ ], exports.UI.prototype, "scrollX", void 0);
7000
+ __decorate([
7001
+ positionType(0, true)
7002
+ ], exports.UI.prototype, "scrollY", void 0);
7003
+ __decorate([
7004
+ autoLayoutType()
7005
+ ], exports.UI.prototype, "origin", void 0);
6934
7006
  __decorate([
6935
7007
  autoLayoutType()
6936
7008
  ], exports.UI.prototype, "around", void 0);
7009
+ __decorate([
7010
+ dataType(false)
7011
+ ], exports.UI.prototype, "lazy", void 0);
7012
+ __decorate([
7013
+ naturalBoundsType(1)
7014
+ ], exports.UI.prototype, "pixelRatio", void 0);
7015
+ __decorate([
7016
+ pathInputType()
7017
+ ], exports.UI.prototype, "path", void 0);
7018
+ __decorate([
7019
+ pathType()
7020
+ ], exports.UI.prototype, "windingRule", void 0);
7021
+ __decorate([
7022
+ pathType(true)
7023
+ ], exports.UI.prototype, "closed", void 0);
7024
+ __decorate([
7025
+ autoLayoutType(false)
7026
+ ], exports.UI.prototype, "flow", void 0);
7027
+ __decorate([
7028
+ boundsType(0)
7029
+ ], exports.UI.prototype, "padding", void 0);
7030
+ __decorate([
7031
+ boundsType(0)
7032
+ ], exports.UI.prototype, "gap", void 0);
7033
+ __decorate([
7034
+ boundsType('top-left')
7035
+ ], exports.UI.prototype, "align", void 0);
7036
+ __decorate([
7037
+ boundsType(false)
7038
+ ], exports.UI.prototype, "wrap", void 0);
7039
+ __decorate([
7040
+ boundsType('box')
7041
+ ], exports.UI.prototype, "itemBox", void 0);
7042
+ __decorate([
7043
+ boundsType(true)
7044
+ ], exports.UI.prototype, "inFlow", void 0);
7045
+ __decorate([
7046
+ boundsType()
7047
+ ], exports.UI.prototype, "autoWidth", void 0);
7048
+ __decorate([
7049
+ boundsType()
7050
+ ], exports.UI.prototype, "autoHeight", void 0);
7051
+ __decorate([
7052
+ boundsType()
7053
+ ], exports.UI.prototype, "autoBox", void 0);
7054
+ __decorate([
7055
+ boundsType()
7056
+ ], exports.UI.prototype, "widthRange", void 0);
7057
+ __decorate([
7058
+ boundsType()
7059
+ ], exports.UI.prototype, "heightRange", void 0);
6937
7060
  __decorate([
6938
7061
  dataType(false)
6939
7062
  ], exports.UI.prototype, "draggable", void 0);
@@ -6943,9 +7066,6 @@ var LeaferUI = (function (exports) {
6943
7066
  __decorate([
6944
7067
  dataType(false)
6945
7068
  ], exports.UI.prototype, "editable", void 0);
6946
- __decorate([
6947
- dataType('size')
6948
- ], exports.UI.prototype, "editSize", void 0);
6949
7069
  __decorate([
6950
7070
  hitType(true)
6951
7071
  ], exports.UI.prototype, "hittable", void 0);
@@ -7000,21 +7120,6 @@ var LeaferUI = (function (exports) {
7000
7120
  __decorate([
7001
7121
  strokeType(10)
7002
7122
  ], 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
7123
  __decorate([
7019
7124
  arrowType('none')
7020
7125
  ], exports.UI.prototype, "startArrow", void 0);
@@ -7248,9 +7353,6 @@ var LeaferUI = (function (exports) {
7248
7353
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
7249
7354
  Object.keys(data).forEach(key => this[key] = data[key]);
7250
7355
  }
7251
- forceFullRender() {
7252
- this.forceRender();
7253
- }
7254
7356
  forceRender(bounds) {
7255
7357
  this.renderer.addBlock(bounds ? new Bounds(bounds) : this.canvas.bounds);
7256
7358
  if (this.viewReady)
@@ -7328,7 +7430,7 @@ var LeaferUI = (function (exports) {
7328
7430
  this.canvas.backgroundColor = newValue;
7329
7431
  }
7330
7432
  else {
7331
- this.forceFullRender();
7433
+ this.forceRender();
7332
7434
  }
7333
7435
  }
7334
7436
  __onCreated() {
@@ -7539,6 +7641,8 @@ var LeaferUI = (function (exports) {
7539
7641
  else {
7540
7642
  this.__updateRectBoxBounds();
7541
7643
  }
7644
+ if (data.flow)
7645
+ this.__updateContentBounds();
7542
7646
  }
7543
7647
  __updateStrokeBounds() { }
7544
7648
  __updateRenderBounds() {
@@ -7948,7 +8052,7 @@ var LeaferUI = (function (exports) {
7948
8052
  registerUI()
7949
8053
  ], exports.Canvas);
7950
8054
 
7951
- const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8055
+ const { copyAndSpread, includes, isSame: isSame$1, spread, setList } = BoundsHelper;
7952
8056
  exports.Text = class Text extends exports.UI {
7953
8057
  get __tag() { return 'Text'; }
7954
8058
  get editInner() { return 'TextEditor'; }
@@ -8021,7 +8125,7 @@ var LeaferUI = (function (exports) {
8021
8125
  if (italic)
8022
8126
  b.width += fontSize * 0.16;
8023
8127
  const contentBounds = includes(b, bounds) ? b : bounds;
8024
- if (contentBounds !== layout.contentBounds) {
8128
+ if (!isSame$1(contentBounds, layout.contentBounds)) {
8025
8129
  layout.contentBounds = contentBounds;
8026
8130
  layout.renderChanged = true;
8027
8131
  setList(data.__textBoxBounds = {}, [b, bounds]);
@@ -8049,9 +8153,6 @@ var LeaferUI = (function (exports) {
8049
8153
  __decorate([
8050
8154
  boundsType(0)
8051
8155
  ], exports.Text.prototype, "height", void 0);
8052
- __decorate([
8053
- boundsType(0)
8054
- ], exports.Text.prototype, "padding", void 0);
8055
8156
  __decorate([
8056
8157
  surfaceType('#000000')
8057
8158
  ], exports.Text.prototype, "fill", void 0);
@@ -8180,7 +8281,7 @@ var LeaferUI = (function (exports) {
8180
8281
  };
8181
8282
  }
8182
8283
 
8183
- const version = "1.0.0-rc.21";
8284
+ const version = "1.0.0-rc.23";
8184
8285
 
8185
8286
  function fillText(ui, canvas) {
8186
8287
  let row;
@@ -8401,7 +8502,7 @@ var LeaferUI = (function (exports) {
8401
8502
  }
8402
8503
  else {
8403
8504
  const { renderShapeSpread: spread } = ui.__layout;
8404
- const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, spread * scaleX, spread * scaleY) : current.bounds, nowWorld);
8505
+ const worldClipBounds = getIntersectData(spread ? getSpread(current.bounds, scaleX === scaleY ? spread * scaleX : [spread * scaleY, spread * scaleX]) : current.bounds, nowWorld);
8405
8506
  fitMatrix = current.bounds.getFitMatrix(worldClipBounds);
8406
8507
  let { a: fitScaleX, d: fitScaleY } = fitMatrix;
8407
8508
  if (fitMatrix.a < 1) {
@@ -8501,10 +8602,10 @@ var LeaferUI = (function (exports) {
8501
8602
  rotate(transform, rotation);
8502
8603
  data.transform = transform;
8503
8604
  }
8504
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
8605
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
8505
8606
  const transform = get$4();
8506
8607
  if (rotation) {
8507
- if (around === 'center') {
8608
+ if (align === 'center') {
8508
8609
  rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
8509
8610
  }
8510
8611
  else {
@@ -8537,12 +8638,12 @@ var LeaferUI = (function (exports) {
8537
8638
  let { width, height } = image;
8538
8639
  if (paint.padding)
8539
8640
  box = tempBox.set(box).shrink(paint.padding);
8540
- const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
8641
+ const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
8541
8642
  const sameBox = box.width === width && box.height === height;
8542
8643
  if (blendMode)
8543
8644
  leafPaint.blendMode = blendMode;
8544
8645
  const data = leafPaint.data = { mode };
8545
- const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
8646
+ const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
8546
8647
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
8547
8648
  let x = 0, y = 0, scaleX, scaleY;
8548
8649
  if (!mode || mode === 'cover' || mode === 'fit') {
@@ -8560,11 +8661,11 @@ var LeaferUI = (function (exports) {
8560
8661
  scaleX = typeof scale === 'number' ? scale : scale.x;
8561
8662
  scaleY = typeof scale === 'number' ? scale : scale.y;
8562
8663
  }
8563
- if (around) {
8664
+ if (align) {
8564
8665
  const imageBounds = { x, y, width: swapWidth, height: swapHeight };
8565
8666
  if (scaleX)
8566
8667
  imageBounds.width *= scaleX, imageBounds.height *= scaleY;
8567
- AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
8668
+ AlignHelper.toPoint(align, imageBounds, box, tempPoint, true);
8568
8669
  x += tempPoint.x, y += tempPoint.y;
8569
8670
  }
8570
8671
  if (offset)
@@ -8581,7 +8682,7 @@ var LeaferUI = (function (exports) {
8581
8682
  break;
8582
8683
  case 'repeat':
8583
8684
  if (!sameBox || scaleX || rotation)
8584
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
8685
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align);
8585
8686
  if (!repeat)
8586
8687
  data.repeat = 'repeat';
8587
8688
  break;
@@ -9498,11 +9599,13 @@ var LeaferUI = (function (exports) {
9498
9599
  const { rows, overflow } = drawData;
9499
9600
  let { textOverflow } = style;
9500
9601
  rows.splice(overflow);
9501
- if (textOverflow !== 'hide') {
9502
- if (textOverflow === 'ellipsis')
9602
+ if (textOverflow && textOverflow !== 'show') {
9603
+ if (textOverflow === 'hide')
9604
+ textOverflow = '';
9605
+ else if (textOverflow === 'ellipsis')
9503
9606
  textOverflow = '...';
9504
9607
  let char, charRight;
9505
- const ellipsisWidth = Platform.canvas.measureText(textOverflow).width;
9608
+ const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
9506
9609
  const right = style.x + style.width - ellipsisWidth;
9507
9610
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
9508
9611
  list.forEach(row => {
@@ -9670,8 +9773,12 @@ var LeaferUI = (function (exports) {
9670
9773
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
9671
9774
  const { worldTransform, isLeafer, isFrame } = leaf;
9672
9775
  const { slice, trim, onCanvas } = options;
9673
- const scale = options.scale || 1;
9674
- const pixelRatio = options.pixelRatio || 1;
9776
+ let scale = options.scale || 1;
9777
+ let pixelRatio = options.pixelRatio || 1;
9778
+ if (leaf.isApp) {
9779
+ scale *= pixelRatio;
9780
+ pixelRatio = leaf.app.pixelRatio;
9781
+ }
9675
9782
  const screenshot = options.screenshot || leaf.isApp;
9676
9783
  const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
9677
9784
  const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
@@ -9801,6 +9908,7 @@ var LeaferUI = (function (exports) {
9801
9908
 
9802
9909
  useCanvas();
9803
9910
 
9911
+ exports.AlignHelper = AlignHelper;
9804
9912
  exports.AnimateEvent = AnimateEvent;
9805
9913
  exports.AroundHelper = AroundHelper;
9806
9914
  exports.AutoBounds = AutoBounds;