leafer-ui 1.0.0-rc.6 → 1.0.0-rc.7

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/web.js CHANGED
@@ -2,7 +2,11 @@ var LeaferUI = (function (exports) {
2
2
  'use strict';
3
3
 
4
4
  const Platform = {
5
- imageSuffix: 'leaf'
5
+ image: {
6
+ maxCacheSize: 2560 * 1600,
7
+ maxPatternSize: 4096 * 2160,
8
+ suffix: 'leaf'
9
+ }
6
10
  };
7
11
 
8
12
  const Creator = {};
@@ -27,6 +31,7 @@ var LeaferUI = (function (exports) {
27
31
  };
28
32
  const I$2 = IncrementId;
29
33
 
34
+ const { round, pow: pow$1, PI: PI$4 } = Math;
30
35
  const MathHelper = {
31
36
  within(value, min, max) {
32
37
  if (value < min)
@@ -35,20 +40,18 @@ var LeaferUI = (function (exports) {
35
40
  value = max;
36
41
  return value;
37
42
  },
38
- fourNumber(num) {
39
- let one, two, three, four;
43
+ fourNumber(num, maxValue) {
44
+ let data;
40
45
  if (num instanceof Array) {
41
46
  switch (num.length) {
42
47
  case 4:
43
- return num;
48
+ data = num;
49
+ break;
44
50
  case 2:
45
- one = three = num[0];
46
- two = four = num[1];
51
+ data = [num[0], num[1], num[0], num[1]];
47
52
  break;
48
53
  case 3:
49
- one = num[0];
50
- two = four = num[1];
51
- three = num[2];
54
+ data = [num[0], num[1], num[2], num[1]];
52
55
  break;
53
56
  case 1:
54
57
  num = num[0];
@@ -57,7 +60,13 @@ var LeaferUI = (function (exports) {
57
60
  num = 0;
58
61
  }
59
62
  }
60
- return one === undefined ? [num, num, num, num] : [one, two, three, four];
63
+ if (!data)
64
+ data = [num, num, num, num];
65
+ if (maxValue)
66
+ for (let i = 0; i < 4; i++)
67
+ if (data[i] > maxValue)
68
+ data[i] = maxValue;
69
+ return data;
61
70
  },
62
71
  formatRotation(rotation, unsign) {
63
72
  rotation %= 360;
@@ -73,29 +82,37 @@ var LeaferUI = (function (exports) {
73
82
  }
74
83
  return rotation;
75
84
  },
76
- getGapRotation(rotation, gap) {
85
+ getGapRotation(addRotation, gap, oldRotation = 0) {
86
+ let rotation = addRotation + oldRotation;
77
87
  if (gap > 1) {
78
88
  const r = Math.abs(rotation % gap);
79
89
  if (r < 1 || r > gap - 1)
80
90
  rotation = Math.round(rotation / gap) * gap;
81
91
  }
82
- return rotation;
92
+ return rotation - oldRotation;
83
93
  },
84
- formatSkew(skew) {
85
- return MathHelper.within(skew, -90, 90);
94
+ float(num, maxLength) {
95
+ const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
96
+ num = round(num * a) / a;
97
+ return num === -0 ? 0 : num;
86
98
  }
87
99
  };
88
- const OneRadian = Math.PI / 180;
89
- const PI2 = Math.PI * 2;
90
- const PI_2 = Math.PI / 2;
100
+ const OneRadian = PI$4 / 180;
101
+ const PI2 = PI$4 * 2;
102
+ const PI_2 = PI$4 / 2;
91
103
 
92
- const { sin: sin$6, cos: cos$6, acos, atan, sqrt: sqrt$3, PI: PI$3 } = Math;
93
- const tempPoint$1 = {};
104
+ const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
105
+ const { float } = MathHelper;
106
+ const tempPoint$2 = {};
94
107
  function get$5() {
95
108
  return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
96
109
  }
110
+ function getWorld() {
111
+ return Object.assign(Object.assign({}, get$5()), { x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
112
+ }
97
113
  const MatrixHelper = {
98
114
  defaultMatrix: get$5(),
115
+ defaultWorld: getWorld(),
99
116
  tempMatrix: {},
100
117
  set(t, a = 1, b = 0, c = 0, d = 1, e = 0, f = 0) {
101
118
  t.a = a;
@@ -106,6 +123,7 @@ var LeaferUI = (function (exports) {
106
123
  t.f = f;
107
124
  },
108
125
  get: get$5,
126
+ getWorld,
109
127
  copy(t, matrix) {
110
128
  t.a = matrix.a;
111
129
  t.b = matrix.b;
@@ -122,115 +140,163 @@ var LeaferUI = (function (exports) {
122
140
  t.e += t.a * x + t.c * y;
123
141
  t.f += t.b * x + t.d * y;
124
142
  },
125
- scale(t, x, y = x) {
126
- t.a *= x;
127
- t.b *= x;
128
- t.c *= y;
129
- t.d *= y;
130
- },
131
- scaleOfOuter(t, origin, x, y = x) {
132
- M$6.toInnerPoint(t, origin, tempPoint$1);
133
- M$6.scaleOfInner(t, tempPoint$1, x, y);
134
- },
135
- scaleOfInner(t, origin, x, y = x) {
136
- M$6.translateInner(t, origin.x, origin.y);
137
- M$6.scale(t, x, y);
138
- M$6.translateInner(t, -origin.x, -origin.y);
139
- },
140
- rotate(t, angle) {
141
- angle *= OneRadian;
142
- const cosR = cos$6(angle);
143
- const sinR = sin$6(angle);
144
- const { a, b, c, d } = t;
145
- t.a = (a * cosR) - (b * sinR);
146
- t.b = (a * sinR) + (b * cosR);
147
- t.c = (c * cosR) - (d * sinR);
148
- t.d = (c * sinR) + (d * cosR);
143
+ scale(t, scaleX, scaleY = scaleX) {
144
+ t.a *= scaleX;
145
+ t.b *= scaleX;
146
+ t.c *= scaleY;
147
+ t.d *= scaleY;
149
148
  },
150
- rotateOfOuter(t, origin, angle) {
151
- M$6.toInnerPoint(t, origin, tempPoint$1);
152
- M$6.rotateOfInner(t, tempPoint$1, angle);
149
+ scaleOfOuter(t, origin, scaleX, scaleY) {
150
+ M$7.toInnerPoint(t, origin, tempPoint$2);
151
+ M$7.scaleOfInner(t, tempPoint$2, scaleX, scaleY);
153
152
  },
154
- rotateOfInner(t, origin, angle) {
155
- M$6.translateInner(t, origin.x, origin.y);
156
- M$6.rotate(t, angle);
157
- M$6.translateInner(t, -origin.x, -origin.y);
153
+ scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
154
+ M$7.translateInner(t, origin.x, origin.y);
155
+ M$7.scale(t, scaleX, scaleY);
156
+ M$7.translateInner(t, -origin.x, -origin.y);
158
157
  },
159
- skew(t, x, y) {
158
+ rotate(t, rotation) {
159
+ const { a, b, c, d } = t;
160
+ rotation *= OneRadian;
161
+ const cosR = cos$5(rotation);
162
+ const sinR = sin$5(rotation);
163
+ t.a = a * cosR - b * sinR;
164
+ t.b = a * sinR + b * cosR;
165
+ t.c = c * cosR - d * sinR;
166
+ t.d = c * sinR + d * cosR;
167
+ },
168
+ rotateOfOuter(t, origin, rotation) {
169
+ M$7.toInnerPoint(t, origin, tempPoint$2);
170
+ M$7.rotateOfInner(t, tempPoint$2, rotation);
171
+ },
172
+ rotateOfInner(t, origin, rotation) {
173
+ M$7.translateInner(t, origin.x, origin.y);
174
+ M$7.rotate(t, rotation);
175
+ M$7.translateInner(t, -origin.x, -origin.y);
176
+ },
177
+ skew(t, skewX, skewY) {
160
178
  const { a, b, c, d } = t;
161
- if (y) {
162
- y *= OneRadian;
163
- t.a = a + c * y;
164
- t.b = b + d * y;
179
+ if (skewY) {
180
+ skewY *= OneRadian;
181
+ t.a = a + c * skewY;
182
+ t.b = b + d * skewY;
165
183
  }
166
- if (x) {
167
- x *= OneRadian;
168
- t.c = c + a * x;
169
- t.d = d + b * x;
184
+ if (skewX) {
185
+ skewX *= OneRadian;
186
+ t.c = c + a * skewX;
187
+ t.d = d + b * skewX;
170
188
  }
171
189
  },
172
- skewOfOuter(t, origin, x, y) {
173
- M$6.toInnerPoint(t, origin, tempPoint$1);
174
- M$6.skewOfInner(t, tempPoint$1, x, y);
190
+ skewOfOuter(t, origin, skewX, skewY) {
191
+ M$7.toInnerPoint(t, origin, tempPoint$2);
192
+ M$7.skewOfInner(t, tempPoint$2, skewX, skewY);
175
193
  },
176
- skewOfInner(t, origin, x, y) {
177
- M$6.translateInner(t, origin.x, origin.y);
178
- M$6.skew(t, x, y);
179
- M$6.translateInner(t, -origin.x, -origin.y);
194
+ skewOfInner(t, origin, skewX, skewY = 0) {
195
+ M$7.translateInner(t, origin.x, origin.y);
196
+ M$7.skew(t, skewX, skewY);
197
+ M$7.translateInner(t, -origin.x, -origin.y);
180
198
  },
181
- multiply(t, matrix) {
199
+ multiply(t, child) {
182
200
  const { a, b, c, d, e, f } = t;
183
- t.a = matrix.a * a + matrix.b * c;
184
- t.b = matrix.a * b + matrix.b * d;
185
- t.c = matrix.c * a + matrix.d * c;
186
- t.d = matrix.c * b + matrix.d * d;
187
- t.e = matrix.e * a + matrix.f * c + e;
188
- t.f = matrix.e * b + matrix.f * d + f;
189
- },
190
- preMultiply(t, matrix) {
191
- const { a, b, c, d, e, f } = t;
192
- if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) {
193
- t.a = (a * matrix.a) + (b * matrix.c);
194
- t.b = (a * matrix.b) + (b * matrix.d);
195
- t.c = (c * matrix.a) + (d * matrix.c);
196
- t.d = (c * matrix.b) + (d * matrix.d);
201
+ t.a = child.a * a + child.b * c;
202
+ t.b = child.a * b + child.b * d;
203
+ t.c = child.c * a + child.d * c;
204
+ t.d = child.c * b + child.d * d;
205
+ t.e = child.e * a + child.f * c + e;
206
+ t.f = child.e * b + child.f * d + f;
207
+ },
208
+ multiplyParent(t, parent, to, abcdChanged, childLayout) {
209
+ const { e, f } = t;
210
+ to || (to = t);
211
+ if (abcdChanged === undefined)
212
+ abcdChanged = t.a !== 1 || t.b || t.c || t.d !== 1;
213
+ if (abcdChanged) {
214
+ const { a, b, c, d } = t;
215
+ to.a = a * parent.a + b * parent.c;
216
+ to.b = a * parent.b + b * parent.d;
217
+ to.c = c * parent.a + d * parent.c;
218
+ to.d = c * parent.b + d * parent.d;
219
+ if (childLayout)
220
+ M$7.multiplyParentLayout(to, parent, childLayout);
221
+ }
222
+ else {
223
+ to.a = parent.a;
224
+ to.b = parent.b;
225
+ to.c = parent.c;
226
+ to.d = parent.d;
227
+ if (childLayout)
228
+ M$7.multiplyParentLayout(to, parent);
229
+ }
230
+ to.e = e * parent.a + f * parent.c + parent.e;
231
+ to.f = e * parent.b + f * parent.d + parent.f;
232
+ },
233
+ multiplyParentLayout(t, parent, child) {
234
+ if (child) {
235
+ t.scaleX = parent.scaleX * child.scaleX;
236
+ t.scaleY = parent.scaleY * child.scaleY;
237
+ t.rotation = parent.rotation + child.rotation;
238
+ t.skewX = parent.skewX + child.skewX;
239
+ t.skewY = parent.skewY + child.skewY;
240
+ }
241
+ else {
242
+ t.scaleX = parent.scaleX;
243
+ t.scaleY = parent.scaleY;
244
+ t.rotation = parent.rotation;
245
+ t.skewX = parent.skewX;
246
+ t.skewY = parent.skewY;
197
247
  }
198
- t.e = (e * matrix.a) + (f * matrix.c) + matrix.e;
199
- t.f = (e * matrix.b) + (f * matrix.d) + matrix.f;
200
248
  },
201
- divide(t, matrix) {
202
- M$6.preMultiply(t, M$6.tempInvert(matrix));
249
+ divide(t, child) {
250
+ M$7.multiply(t, M$7.tempInvert(child));
251
+ },
252
+ divideParent(t, parent) {
253
+ M$7.multiplyParent(t, M$7.tempInvert(parent));
203
254
  },
204
255
  tempInvert(t) {
205
- const { tempMatrix: temp } = M$6;
206
- M$6.copy(temp, t);
207
- M$6.invert(temp);
208
- return temp;
256
+ const { tempMatrix } = M$7;
257
+ M$7.copy(tempMatrix, t);
258
+ M$7.invert(tempMatrix);
259
+ return tempMatrix;
209
260
  },
210
261
  invert(t) {
211
262
  const { a, b, c, d, e, f } = t;
212
- const s = 1 / (a * d - b * c);
213
- t.a = d * s;
214
- t.b = -b * s;
215
- t.c = -c * s;
216
- t.d = a * s;
217
- t.e = -(e * d - f * c) * s;
218
- t.f = -(f * a - e * b) * s;
263
+ if (!b && !c) {
264
+ if (a === 1 && d === 1) {
265
+ t.e = -e;
266
+ t.f = -f;
267
+ }
268
+ else {
269
+ const s = 1 / (a * d);
270
+ t.a = d * s;
271
+ t.d = a * s;
272
+ t.e = -e * d * s;
273
+ t.f = -f * a * s;
274
+ }
275
+ }
276
+ else {
277
+ const s = 1 / (a * d - b * c);
278
+ t.a = d * s;
279
+ t.b = -b * s;
280
+ t.c = -c * s;
281
+ t.d = a * s;
282
+ t.e = -(e * d - f * c) * s;
283
+ t.f = -(f * a - e * b) * s;
284
+ }
219
285
  },
220
286
  toOuterPoint(t, inner, to, distance) {
221
287
  const { x, y } = inner;
222
288
  to || (to = inner);
223
- to.x = (x * t.a) + (y * t.c);
224
- to.y = (x * t.b) + (y * t.d);
289
+ to.x = x * t.a + y * t.c;
290
+ to.y = x * t.b + y * t.d;
225
291
  if (!distance) {
226
292
  to.x += t.e;
227
293
  to.y += t.f;
228
294
  }
229
295
  },
230
296
  toInnerPoint(t, outer, to, distance) {
231
- const { x, y } = outer;
232
297
  const { a, b, c, d } = t;
233
298
  const s = 1 / (a * d - b * c);
299
+ const { x, y } = outer;
234
300
  to || (to = outer);
235
301
  to.x = (x * d - y * c) * s;
236
302
  to.y = (y * a - x * b) * s;
@@ -240,40 +306,84 @@ var LeaferUI = (function (exports) {
240
306
  to.y -= (f * a - e * b) * s;
241
307
  }
242
308
  },
243
- decompose(t) {
244
- const { a, b, c, d } = t;
245
- let scaleX = a, scaleY = d, rotation = 0, skewX = 0, skewY = 0;
309
+ setLayout(t, layout, origin, bcChanged) {
310
+ const { x, y, scaleX, scaleY } = layout;
311
+ if (bcChanged === undefined)
312
+ bcChanged = layout.rotation || layout.skewX || layout.skewY;
313
+ if (bcChanged) {
314
+ const { rotation, skewX, skewY } = layout;
315
+ const r = rotation * OneRadian;
316
+ const cosR = cos$5(r);
317
+ const sinR = sin$5(r);
318
+ if (skewX || skewY) {
319
+ const sx = skewX * OneRadian;
320
+ const sy = skewY * OneRadian;
321
+ t.a = (cosR + sy * -sinR) * scaleX;
322
+ t.b = (sinR + sy * cosR) * scaleX;
323
+ t.c = (-sinR + sx * cosR) * scaleY;
324
+ t.d = (cosR + sx * sinR) * scaleY;
325
+ }
326
+ else {
327
+ t.a = cosR * scaleX;
328
+ t.b = sinR * scaleX;
329
+ t.c = -sinR * scaleY;
330
+ t.d = cosR * scaleY;
331
+ }
332
+ }
333
+ else {
334
+ t.a = scaleX;
335
+ t.b = 0;
336
+ t.c = 0;
337
+ t.d = scaleY;
338
+ }
339
+ t.e = x;
340
+ t.f = y;
341
+ if (origin)
342
+ M$7.translateInner(t, -origin.x, -origin.y);
343
+ },
344
+ getLayout(t, origin, firstSkewY) {
345
+ const { a, b, c, d, e, f } = t;
346
+ let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
246
347
  if (b || c) {
247
348
  const s = a * d - b * c;
248
- const k = a * c + b * d;
249
- if (b) {
250
- const ab = a * a + b * b;
251
- scaleX = sqrt$3(ab);
349
+ if (c && !firstSkewY) {
350
+ scaleX = sqrt$3(a * a + b * b);
252
351
  scaleY = s / scaleX;
253
- const r = a / scaleX;
254
- rotation = b > 0 ? acos(r) : -acos(r);
255
- skewX = atan(k / ab) / OneRadian;
352
+ const cosR = a / scaleX;
353
+ rotation = b > 0 ? acos(cosR) : -acos(cosR);
256
354
  }
257
355
  else {
258
- const cd = c * c + d * d;
259
- scaleY = sqrt$3(cd);
356
+ scaleY = sqrt$3(c * c + d * d);
260
357
  scaleX = s / scaleY;
261
- const r = c / scaleY;
262
- rotation = PI$3 / 2 - (d > 0 ? acos(-r) : -acos(r));
263
- skewY = atan(k / cd) / OneRadian;
358
+ const cosR = c / scaleY;
359
+ rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
264
360
  }
265
- rotation /= OneRadian;
361
+ const cosR = cos$5(rotation);
362
+ const sinR = sin$5(rotation);
363
+ scaleX = float(scaleX), scaleY = float(scaleY);
364
+ skewX = float((c / scaleY + sinR) / cosR / OneRadian);
365
+ skewY = float((b / scaleX - sinR) / cosR / OneRadian);
366
+ rotation = float(rotation / OneRadian);
367
+ }
368
+ else {
369
+ scaleX = a;
370
+ scaleY = d;
371
+ rotation = skewX = skewY = 0;
372
+ }
373
+ if (origin) {
374
+ x += origin.x * a + origin.y * c;
375
+ y += origin.x * b + origin.y * d;
266
376
  }
267
- return { x: t.e, y: t.f, scaleX, scaleY, rotation, skewX, skewY };
377
+ return { x, y, scaleX, scaleY, rotation, skewX, skewY };
268
378
  },
269
379
  reset(t) {
270
- M$6.set(t);
380
+ M$7.set(t);
271
381
  }
272
382
  };
273
- const M$6 = MatrixHelper;
383
+ const M$7 = MatrixHelper;
274
384
 
275
385
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$2 } = MatrixHelper;
276
- const { sin: sin$5, cos: cos$5, abs: abs$1, sqrt: sqrt$2, atan2: atan2$2 } = Math;
386
+ const { sin: sin$4, cos: cos$4, abs: abs$3, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
277
387
  const PointHelper = {
278
388
  defaultPoint: { x: 0, y: 0 },
279
389
  tempPoint: {},
@@ -294,32 +404,33 @@ var LeaferUI = (function (exports) {
294
404
  t.x += x;
295
405
  t.y += y;
296
406
  },
297
- rotate(t, rotation, center) {
298
- if (!center)
299
- center = P$5.defaultPoint;
300
- const cosR = cos$5(rotation * OneRadian);
301
- const sinR = sin$5(rotation * OneRadian);
302
- const rx = t.x - center.x;
303
- const ry = t.y - center.y;
304
- t.x = center.x + rx * cosR - ry * sinR;
305
- t.y = center.y + rx * sinR + ry * cosR;
407
+ rotate(t, rotation, origin) {
408
+ if (!origin)
409
+ origin = P$6.defaultPoint;
410
+ rotation *= OneRadian;
411
+ const cosR = cos$4(rotation);
412
+ const sinR = sin$4(rotation);
413
+ const rx = t.x - origin.x;
414
+ const ry = t.y - origin.y;
415
+ t.x = origin.x + rx * cosR - ry * sinR;
416
+ t.y = origin.y + rx * sinR + ry * cosR;
306
417
  },
307
418
  tempToInnerOf(t, matrix) {
308
- const { tempPoint: temp } = P$5;
309
- P$5.copy(temp, t);
419
+ const { tempPoint: temp } = P$6;
420
+ P$6.copy(temp, t);
310
421
  toInnerPoint$2(matrix, temp, temp);
311
422
  return temp;
312
423
  },
313
424
  tempToOuterOf(t, matrix) {
314
- const { tempPoint: temp } = P$5;
315
- P$5.copy(temp, t);
425
+ const { tempPoint: temp } = P$6;
426
+ P$6.copy(temp, t);
316
427
  toOuterPoint$2(matrix, temp, temp);
317
428
  return temp;
318
429
  },
319
430
  tempToInnerRadiusPointOf(t, matrix) {
320
- const { tempRadiusPoint: temp } = P$5;
321
- P$5.copy(temp, t);
322
- P$5.toInnerRadiusPointOf(t, matrix, temp);
431
+ const { tempRadiusPoint: temp } = P$6;
432
+ P$6.copy(temp, t);
433
+ P$6.toInnerRadiusPointOf(t, matrix, temp);
323
434
  return temp;
324
435
  },
325
436
  toInnerRadiusPointOf(t, matrix, to) {
@@ -337,53 +448,78 @@ var LeaferUI = (function (exports) {
337
448
  getCenter(t, to) {
338
449
  return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
339
450
  },
451
+ getCenterX(x1, x2) {
452
+ return x1 + (x2 - x1) / 2;
453
+ },
454
+ getCenterY(y1, y2) {
455
+ return y1 + (y2 - y1) / 2;
456
+ },
340
457
  getDistance(t, point) {
341
- const x = abs$1(point.x - t.x);
342
- const y = abs$1(point.y - t.y);
458
+ return P$6.getDistanceFrom(t.x, t.y, point.x, point.y);
459
+ },
460
+ getDistanceFrom(x1, y1, x2, y2) {
461
+ const x = abs$3(x2 - x1);
462
+ const y = abs$3(y2 - y1);
343
463
  return sqrt$2(x * x + y * y);
344
464
  },
465
+ getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
466
+ return min$1(P$6.getDistanceFrom(x1, y1, x2, y2), P$6.getDistanceFrom(x2, y2, x3, y3));
467
+ },
345
468
  getAngle(t, to) {
346
- return P$5.getAtan2(t, to) / OneRadian;
469
+ return P$6.getAtan2(t, to) / OneRadian;
347
470
  },
348
- getChangeAngle(t, orign, to, toOrigin) {
471
+ getRotation(t, origin, to, toOrigin) {
349
472
  if (!toOrigin)
350
- toOrigin = orign;
351
- let fromAngle = P$5.getAngle(t, orign);
352
- let toAngle = P$5.getAngle(to, toOrigin);
353
- const angle = toAngle - fromAngle;
354
- return angle < -180 ? angle + 360 : angle;
473
+ toOrigin = origin;
474
+ return P$6.getRadianFrom(t.x, t.y, origin.x, origin.y, to.x, to.y, toOrigin.x, toOrigin.y) / OneRadian;
475
+ },
476
+ getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
477
+ if (toOriginX === undefined)
478
+ toOriginX = originX, toOriginY = originY;
479
+ let fromAngle = atan2$2(fromY - originY, fromX - originX);
480
+ let toAngle = atan2$2(toY - toOriginY, toX - toOriginX);
481
+ const radian = toAngle - fromAngle;
482
+ return radian < -PI$3 ? radian + PI2 : radian;
355
483
  },
356
484
  getAtan2(t, to) {
357
485
  return atan2$2(to.y - t.y, to.x - t.x);
358
486
  },
359
487
  getDistancePoint(t, to, distance) {
360
- const r = P$5.getAtan2(t, to);
361
- return { x: t.x + cos$5(r) * distance, y: t.y + sin$5(r) * distance };
488
+ const r = P$6.getAtan2(t, to);
489
+ return { x: t.x + cos$4(r) * distance, y: t.y + sin$4(r) * distance };
362
490
  },
363
491
  reset(t) {
364
- P$5.reset(t);
492
+ P$6.reset(t);
365
493
  }
366
494
  };
367
- const P$5 = PointHelper;
495
+ const P$6 = PointHelper;
368
496
 
369
497
  class Point {
370
498
  constructor(x, y) {
371
- typeof x === 'object' ? PointHelper.copy(this, x) : PointHelper.set(this, x, y);
499
+ this.set(x, y);
372
500
  }
373
501
  set(x, y) {
374
- PointHelper.set(this, x, y);
375
- }
376
- copy(point) {
377
- PointHelper.copy(this, point);
502
+ typeof x === 'object' ? PointHelper.copy(this, x) : PointHelper.set(this, x, y);
378
503
  return this;
379
504
  }
505
+ get() {
506
+ const { x, y } = this;
507
+ return { x, y };
508
+ }
380
509
  clone() {
381
510
  return new Point(this);
382
511
  }
383
- rotate(angle, center) {
384
- PointHelper.rotate(this, angle, center);
512
+ rotate(rotation, origin) {
513
+ PointHelper.rotate(this, rotation, origin);
514
+ return this;
515
+ }
516
+ rotateOf(origin, rotation) {
517
+ PointHelper.rotate(this, rotation, origin);
385
518
  return this;
386
519
  }
520
+ getRotation(origin, to, toOrigin) {
521
+ return PointHelper.getRotation(this, origin, to, toOrigin);
522
+ }
387
523
  toInnerOf(matrix, to) {
388
524
  PointHelper.toInnerOf(this, matrix, to);
389
525
  return this;
@@ -393,11 +529,14 @@ var LeaferUI = (function (exports) {
393
529
  return this;
394
530
  }
395
531
  getCenter(to) {
396
- return PointHelper.getCenter(this, to);
532
+ return new Point(PointHelper.getCenter(this, to));
397
533
  }
398
534
  getDistance(to) {
399
535
  return PointHelper.getDistance(this, to);
400
536
  }
537
+ getDistancePoint(to, distance) {
538
+ return new Point(PointHelper.getDistancePoint(this, to, distance));
539
+ }
401
540
  getAngle(to) {
402
541
  return PointHelper.getAngle(this, to);
403
542
  }
@@ -406,20 +545,22 @@ var LeaferUI = (function (exports) {
406
545
  }
407
546
  reset() {
408
547
  PointHelper.reset(this);
548
+ return this;
409
549
  }
410
550
  }
411
551
 
412
552
  class Matrix {
413
553
  constructor(a, b, c, d, e, f) {
414
- typeof a === 'object' ? MatrixHelper.copy(this, a) : MatrixHelper.set(this, a, b, c, d, e, f);
554
+ this.set(a, b, c, d, e, f);
415
555
  }
416
556
  set(a, b, c, d, e, f) {
417
- MatrixHelper.set(this, a, b, c, d, e, f);
418
- }
419
- copy(matrix) {
420
- MatrixHelper.copy(this, matrix);
557
+ typeof a === 'object' ? MatrixHelper.copy(this, a) : MatrixHelper.set(this, a, b, c, d, e, f);
421
558
  return this;
422
559
  }
560
+ get() {
561
+ const { a, b, c, d, e, f } = this;
562
+ return { a, b, c, d, e, f };
563
+ }
423
564
  clone() {
424
565
  return new Matrix(this);
425
566
  }
@@ -467,16 +608,20 @@ var LeaferUI = (function (exports) {
467
608
  MatrixHelper.skewOfInner(this, origin, x, y);
468
609
  return this;
469
610
  }
470
- multiply(matrix) {
471
- MatrixHelper.multiply(this, matrix);
611
+ multiply(child) {
612
+ MatrixHelper.multiply(this, child);
472
613
  return this;
473
614
  }
474
- preMultiply(matrix) {
475
- MatrixHelper.preMultiply(this, matrix);
615
+ multiplyParent(parent) {
616
+ MatrixHelper.multiplyParent(this, parent);
476
617
  return this;
477
618
  }
478
- divide(matrix) {
479
- MatrixHelper.divide(this, matrix);
619
+ divide(child) {
620
+ MatrixHelper.divide(this, child);
621
+ return this;
622
+ }
623
+ divideParent(parent) {
624
+ MatrixHelper.divideParent(this, parent);
480
625
  return this;
481
626
  }
482
627
  invert() {
@@ -489,8 +634,12 @@ var LeaferUI = (function (exports) {
489
634
  toInnerPoint(outer, to, distance) {
490
635
  MatrixHelper.toInnerPoint(this, outer, to, distance);
491
636
  }
492
- decompose() {
493
- return MatrixHelper.decompose(this);
637
+ setLayout(data, origin) {
638
+ MatrixHelper.setLayout(this, data, origin);
639
+ return this;
640
+ }
641
+ getLayout(origin, firstSkewY) {
642
+ return MatrixHelper.getLayout(this, origin, firstSkewY);
494
643
  }
495
644
  reset() {
496
645
  MatrixHelper.reset(this);
@@ -519,7 +668,7 @@ var LeaferUI = (function (exports) {
519
668
  t.maxX = pb.maxX;
520
669
  t.maxY = pb.maxY;
521
670
  },
522
- add(t, pb) {
671
+ addPointBounds(t, pb) {
523
672
  t.minX = pb.minX < t.minX ? pb.minX : t.minX;
524
673
  t.minY = pb.minY < t.minY ? pb.minY : t.minY;
525
674
  t.maxX = pb.maxX > t.maxX ? pb.maxX : t.maxX;
@@ -534,11 +683,11 @@ var LeaferUI = (function (exports) {
534
683
  };
535
684
  const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
536
685
 
537
- const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$4 } = TwoPointBoundsHelper;
686
+ const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
538
687
  const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
539
688
  let right, bottom, boundsRight, boundsBottom;
540
689
  const point = {};
541
- const toPoint = {};
690
+ const toPoint$1 = {};
542
691
  const BoundsHelper = {
543
692
  tempBounds: {},
544
693
  set(t, x = 0, y = 0, width = 0, height = 0) {
@@ -558,12 +707,10 @@ var LeaferUI = (function (exports) {
558
707
  spreadY = spreadX;
559
708
  B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2);
560
709
  },
561
- right(t) {
562
- return t.x + t.width;
563
- },
564
- bottom(t) {
565
- return t.y + t.height;
566
- },
710
+ minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
711
+ minY(t) { return t.height > 0 ? t.y : t.y + t.height; },
712
+ maxX(t) { return t.width > 0 ? t.x + t.width : t.x; },
713
+ maxY(t) { return t.height > 0 ? t.y + t.height : t.y; },
567
714
  move(t, x, y) {
568
715
  t.x += x;
569
716
  t.y += y;
@@ -581,8 +728,8 @@ var LeaferUI = (function (exports) {
581
728
  copy$7(to, t);
582
729
  }
583
730
  if (parent) {
584
- to.offsetX = -(B.right(parent) - t.x);
585
- to.offsetY = -(B.bottom(parent) - t.y);
731
+ to.offsetX = -(B.maxX(parent) - t.x);
732
+ to.offsetY = -(B.maxY(parent) - t.y);
586
733
  }
587
734
  else {
588
735
  to.offsetX = t.x + t.width;
@@ -638,18 +785,18 @@ var LeaferUI = (function (exports) {
638
785
  else {
639
786
  point.x = t.x;
640
787
  point.y = t.y;
641
- toOuterPoint$1(matrix, point, toPoint);
642
- setPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
788
+ toOuterPoint$1(matrix, point, toPoint$1);
789
+ setPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
643
790
  point.x = t.x + t.width;
644
- toOuterPoint$1(matrix, point, toPoint);
645
- addPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
791
+ toOuterPoint$1(matrix, point, toPoint$1);
792
+ addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
646
793
  point.y = t.y + t.height;
647
- toOuterPoint$1(matrix, point, toPoint);
648
- addPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
794
+ toOuterPoint$1(matrix, point, toPoint$1);
795
+ addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
649
796
  point.x = t.x;
650
- toOuterPoint$1(matrix, point, toPoint);
651
- addPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
652
- toBounds$4(tempPointBounds$1, to);
797
+ toOuterPoint$1(matrix, point, toPoint$1);
798
+ addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
799
+ toBounds$3(tempPointBounds$1, to);
653
800
  }
654
801
  },
655
802
  getFitMatrix(t, put) {
@@ -693,18 +840,18 @@ var LeaferUI = (function (exports) {
693
840
  t.height = bottom - t.y;
694
841
  },
695
842
  addList(t, list) {
696
- B.setByListWithHandle(t, list, undefined, true);
843
+ B.setListWithFn(t, list, undefined, true);
697
844
  },
698
- setByList(t, list, addMode = false) {
699
- B.setByListWithHandle(t, list, undefined, addMode);
845
+ setList(t, list, addMode = false) {
846
+ B.setListWithFn(t, list, undefined, addMode);
700
847
  },
701
- addListWithHandle(t, list, boundsDataHandle) {
702
- B.setByListWithHandle(t, list, boundsDataHandle, true);
848
+ addListWithFn(t, list, boundsDataFn) {
849
+ B.setListWithFn(t, list, boundsDataFn, true);
703
850
  },
704
- setByListWithHandle(t, list, boundsDataHandle, addMode = false) {
851
+ setListWithFn(t, list, boundsDataFn, addMode = false) {
705
852
  let bounds, first = true;
706
853
  for (let i = 0, len = list.length; i < len; i++) {
707
- bounds = boundsDataHandle ? boundsDataHandle(list[i]) : list[i];
854
+ bounds = boundsDataFn ? boundsDataFn(list[i]) : list[i];
708
855
  if (bounds && (bounds.width || bounds.height)) {
709
856
  if (first) {
710
857
  first = false;
@@ -712,18 +859,25 @@ var LeaferUI = (function (exports) {
712
859
  copy$7(t, bounds);
713
860
  }
714
861
  else {
715
- add$2(t, bounds);
862
+ add$1(t, bounds);
716
863
  }
717
864
  }
718
865
  }
719
866
  if (first)
720
867
  B.reset(t);
721
868
  },
722
- setByPoints(t, points) {
723
- points.forEach((point, index) => {
724
- index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y);
725
- });
726
- toBounds$4(tempPointBounds$1, t);
869
+ setPoints(t, points) {
870
+ points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
871
+ toBounds$3(tempPointBounds$1, t);
872
+ },
873
+ getPoints(t) {
874
+ const { x, y, width, height } = t;
875
+ return [
876
+ { x, y },
877
+ { x: x + width, y },
878
+ { x: x + width, y: y + height },
879
+ { x, y: y + height }
880
+ ];
727
881
  },
728
882
  hitRadiusPoint(t, point, pointMatrix) {
729
883
  if (pointMatrix)
@@ -775,19 +929,24 @@ var LeaferUI = (function (exports) {
775
929
  }
776
930
  };
777
931
  const B = BoundsHelper;
778
- const { add: add$2, copy: copy$7 } = B;
932
+ const { add: add$1, copy: copy$7 } = B;
779
933
 
780
934
  class Bounds {
935
+ get minX() { return BoundsHelper.minX(this); }
936
+ get minY() { return BoundsHelper.minY(this); }
937
+ get maxX() { return BoundsHelper.maxX(this); }
938
+ get maxY() { return BoundsHelper.maxY(this); }
781
939
  constructor(x, y, width, height) {
782
- typeof x === 'object' ? BoundsHelper.copy(this, x) : BoundsHelper.set(this, x, y, width, height);
940
+ this.set(x, y, width, height);
783
941
  }
784
942
  set(x, y, width, height) {
785
- BoundsHelper.set(this, x, y, width, height);
786
- }
787
- copy(bounds) {
788
- BoundsHelper.copy(this, bounds);
943
+ typeof x === 'object' ? BoundsHelper.copy(this, x) : BoundsHelper.set(this, x, y, width, height);
789
944
  return this;
790
945
  }
946
+ get() {
947
+ const { x, y, width, height } = this;
948
+ return { x, y, width, height };
949
+ }
791
950
  clone() {
792
951
  return new Bounds(this);
793
952
  }
@@ -823,25 +982,28 @@ var LeaferUI = (function (exports) {
823
982
  return this;
824
983
  }
825
984
  addList(boundsList) {
826
- BoundsHelper.setByList(this, boundsList, true);
985
+ BoundsHelper.setList(this, boundsList, true);
827
986
  return this;
828
987
  }
829
- setByList(boundsList, addMode) {
830
- BoundsHelper.setByList(this, boundsList, addMode);
988
+ setList(boundsList) {
989
+ BoundsHelper.setList(this, boundsList);
831
990
  return this;
832
991
  }
833
- addListWithHandle(list, boundsDataHandle) {
834
- BoundsHelper.setByListWithHandle(this, list, boundsDataHandle, true);
992
+ addListWithFn(list, boundsDataFn) {
993
+ BoundsHelper.setListWithFn(this, list, boundsDataFn, true);
835
994
  return this;
836
995
  }
837
- setByListWithHandle(list, boundsDataHandle, addMode) {
838
- BoundsHelper.setByListWithHandle(this, list, boundsDataHandle, addMode);
996
+ setListWithFn(list, boundsDataFn) {
997
+ BoundsHelper.setListWithFn(this, list, boundsDataFn);
839
998
  return this;
840
999
  }
841
- setByPoints(points) {
842
- BoundsHelper.setByPoints(this, points);
1000
+ setPoints(points) {
1001
+ BoundsHelper.setPoints(this, points);
843
1002
  return this;
844
1003
  }
1004
+ getPoints() {
1005
+ return BoundsHelper.getPoints(this);
1006
+ }
845
1007
  hitPoint(point, pointMatrix) {
846
1008
  return BoundsHelper.hitPoint(this, point, pointMatrix);
847
1009
  }
@@ -894,20 +1056,25 @@ var LeaferUI = (function (exports) {
894
1056
  }
895
1057
  }
896
1058
 
897
- class TwoPointBounds {
898
- constructor(x, y) {
899
- TwoPointBoundsHelper.setPoint(this, x, y);
900
- }
901
- addPoint(x, y) {
902
- TwoPointBoundsHelper.addPoint(this, x, y);
903
- }
904
- addBounds(x, y, width, height) {
905
- TwoPointBoundsHelper.addBounds(this, x, y, width, height);
906
- }
907
- add(pb) {
908
- TwoPointBoundsHelper.add(this, pb);
1059
+ const center = { x: 0.5, y: 0.5 };
1060
+ const AroundHelper = {
1061
+ center,
1062
+ tempPoint: {},
1063
+ toPoint(around, bounds, to, onlySize) {
1064
+ to || (to = {});
1065
+ switch (around) {
1066
+ case 'center':
1067
+ around = center;
1068
+ break;
1069
+ }
1070
+ to.x = around.x * bounds.width;
1071
+ to.y = around.y * bounds.height;
1072
+ if (!onlySize) {
1073
+ to.x += bounds.x;
1074
+ to.y += bounds.y;
1075
+ }
909
1076
  }
910
- }
1077
+ };
911
1078
 
912
1079
  const StringNumberMap = {
913
1080
  '0': 1,
@@ -948,18 +1115,21 @@ var LeaferUI = (function (exports) {
948
1115
  this.excludeList = name;
949
1116
  }
950
1117
  log(...messages) {
951
- if (D$4.enable) {
952
- if (D$4.filterList.length && D$4.filterList.every(name => name !== this.name))
1118
+ if (D$5.enable) {
1119
+ if (D$5.filterList.length && D$5.filterList.every(name => name !== this.name))
953
1120
  return;
954
- if (D$4.excludeList.length && D$4.excludeList.some(name => name === this.name))
1121
+ if (D$5.excludeList.length && D$5.excludeList.some(name => name === this.name))
955
1122
  return;
956
1123
  console.log('%c' + this.name, 'color:#21ae62', ...messages);
957
1124
  }
958
1125
  }
959
- warn(...messages) {
960
- if (D$4.enable)
1126
+ tip(...messages) {
1127
+ if (D$5.enable)
961
1128
  console.warn(this.name, ...messages);
962
1129
  }
1130
+ warn(...messages) {
1131
+ console.warn(this.name, ...messages);
1132
+ }
963
1133
  repeat(name, ...messages) {
964
1134
  if (!this.repeatMap[name]) {
965
1135
  this.warn('repeat:' + name, ...messages);
@@ -977,46 +1147,43 @@ var LeaferUI = (function (exports) {
977
1147
  }
978
1148
  Debug.filterList = [];
979
1149
  Debug.excludeList = [];
980
- const D$4 = Debug;
981
-
982
- const debug$f = Debug.get('RunTime');
983
- class Run {
984
- static start(name, microsecond) {
1150
+ const D$5 = Debug;
1151
+
1152
+ const debug$g = Debug.get('RunTime');
1153
+ const Run = {
1154
+ currentId: 0,
1155
+ currentName: '',
1156
+ idMap: {},
1157
+ nameMap: {},
1158
+ nameToIdMap: {},
1159
+ start(name, microsecond) {
985
1160
  const id = IncrementId.create(IncrementId.RUNTIME);
986
1161
  R.currentId = R.idMap[id] = microsecond ? performance.now() : Date.now();
987
1162
  R.currentName = R.nameMap[id] = name;
988
1163
  R.nameToIdMap[name] = id;
989
1164
  return id;
990
- }
991
- static end(id, microsecond) {
992
- const time = R.idMap[id];
993
- const name = R.nameMap[id];
1165
+ },
1166
+ end(id, microsecond) {
1167
+ const time = R.idMap[id], name = R.nameMap[id];
1168
+ const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
994
1169
  R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
995
- if (microsecond) {
996
- debug$f.log(name, performance.now() - time, 'µs');
997
- }
998
- else {
999
- debug$f.log(name, Date.now() - time, 'ms');
1000
- }
1001
- }
1002
- static endOfName(name, microsecond) {
1170
+ debug$g.log(name, duration, 'ms');
1171
+ },
1172
+ endOfName(name, microsecond) {
1003
1173
  const id = R.nameToIdMap[name];
1004
1174
  if (id !== undefined)
1005
1175
  R.end(id, microsecond);
1006
1176
  }
1007
- }
1008
- Run.idMap = {};
1009
- Run.nameMap = {};
1010
- Run.nameToIdMap = {};
1177
+ };
1011
1178
  const R = Run;
1012
1179
 
1013
- const debug$e = Debug.get('UICreator');
1180
+ const debug$f = Debug.get('UICreator');
1014
1181
  const UICreator = {
1015
1182
  list: {},
1016
1183
  register(UI) {
1017
1184
  const { __tag: tag } = UI.prototype;
1018
1185
  if (list$2[tag]) {
1019
- debug$e.repeat(tag);
1186
+ debug$f.repeat(tag);
1020
1187
  }
1021
1188
  else {
1022
1189
  list$2[tag] = UI;
@@ -1038,7 +1205,7 @@ var LeaferUI = (function (exports) {
1038
1205
  };
1039
1206
  const { list: list$2 } = UICreator;
1040
1207
 
1041
- const debug$d = Debug.get('EventCreator');
1208
+ const debug$e = Debug.get('EventCreator');
1042
1209
  const EventCreator = {
1043
1210
  nameList: {},
1044
1211
  register(Event) {
@@ -1046,7 +1213,7 @@ var LeaferUI = (function (exports) {
1046
1213
  Object.keys(Event).forEach(key => {
1047
1214
  name = Event[key];
1048
1215
  if (typeof name === 'string')
1049
- nameList[name] ? debug$d.repeat(name) : nameList[name] = Event;
1216
+ nameList[name] ? debug$e.repeat(name) : nameList[name] = Event;
1050
1217
  });
1051
1218
  },
1052
1219
  changeName(oldName, newName) {
@@ -1120,7 +1287,7 @@ var LeaferUI = (function (exports) {
1120
1287
  constructor(item) {
1121
1288
  this.reset();
1122
1289
  if (item)
1123
- item instanceof Array ? this.pushList(item) : this.push(item);
1290
+ item instanceof Array ? this.addList(item) : this.add(item);
1124
1291
  }
1125
1292
  has(leaf) {
1126
1293
  return leaf && this.keys[leaf.innerId] !== undefined;
@@ -1132,36 +1299,34 @@ var LeaferUI = (function (exports) {
1132
1299
  const index = this.keys[leaf.innerId];
1133
1300
  return index === undefined ? -1 : index;
1134
1301
  }
1135
- pushList(list) {
1136
- list.forEach(leaf => { this.push(leaf); });
1137
- }
1138
- unshift(leaf) {
1139
- const { keys } = this;
1140
- if (keys[leaf.innerId] === undefined) {
1141
- this.list.unshift(leaf);
1142
- Object.keys(keys).forEach(innerId => {
1143
- if (keys[innerId] !== undefined)
1144
- keys[innerId]++;
1145
- });
1146
- keys[leaf.innerId] = 0;
1147
- }
1148
- }
1149
- push(leaf) {
1302
+ add(leaf) {
1150
1303
  const { list, keys } = this;
1151
1304
  if (keys[leaf.innerId] === undefined) {
1152
1305
  list.push(leaf);
1153
1306
  keys[leaf.innerId] = list.length - 1;
1154
1307
  }
1155
1308
  }
1156
- sort(reverse) {
1157
- const { list } = this;
1158
- if (reverse) {
1159
- list.sort((a, b) => b.__level - a.__level);
1160
- }
1161
- else {
1162
- list.sort((a, b) => a.__level - b.__level);
1309
+ addAt(leaf, index = 0) {
1310
+ const { keys } = this;
1311
+ if (keys[leaf.innerId] === undefined) {
1312
+ const { list } = this;
1313
+ for (let i = index, len = list.length; i < len; i++)
1314
+ keys[list[i].innerId]++;
1315
+ if (index === 0) {
1316
+ list.unshift(leaf);
1317
+ }
1318
+ else {
1319
+ if (index > list.length)
1320
+ index = list.length;
1321
+ list.splice(index, 0, leaf);
1322
+ }
1323
+ keys[leaf.innerId] = index;
1163
1324
  }
1164
1325
  }
1326
+ addList(list) {
1327
+ for (let i = 0; i < list.length; i++)
1328
+ this.add(list[i]);
1329
+ }
1165
1330
  remove(leaf) {
1166
1331
  const { list } = this;
1167
1332
  let findIndex;
@@ -1177,20 +1342,36 @@ var LeaferUI = (function (exports) {
1177
1342
  if (findIndex !== undefined)
1178
1343
  list.splice(findIndex, 1);
1179
1344
  }
1345
+ sort(reverse) {
1346
+ const { list } = this;
1347
+ if (reverse) {
1348
+ list.sort((a, b) => b.__level - a.__level);
1349
+ }
1350
+ else {
1351
+ list.sort((a, b) => a.__level - b.__level);
1352
+ }
1353
+ }
1180
1354
  forEach(itemCallback) {
1181
1355
  this.list.forEach(itemCallback);
1182
1356
  }
1183
1357
  clone() {
1184
1358
  const list = new LeafList();
1185
- this.list.forEach(item => { list.push(item); });
1359
+ list.list = [...this.list];
1360
+ list.keys = Object.assign({}, this.keys);
1186
1361
  return list;
1187
1362
  }
1363
+ update() {
1364
+ this.keys = {};
1365
+ const { list, keys } = this;
1366
+ for (let i = 0, len = list.length; i < len; i++)
1367
+ keys[list[i].innerId] = i;
1368
+ }
1188
1369
  reset() {
1189
1370
  this.list = [];
1190
1371
  this.keys = {};
1191
1372
  }
1192
1373
  destroy() {
1193
- this.list = null;
1374
+ this.reset();
1194
1375
  }
1195
1376
  }
1196
1377
 
@@ -1200,7 +1381,7 @@ var LeaferUI = (function (exports) {
1200
1381
  this._length = 0;
1201
1382
  this.reset();
1202
1383
  if (item)
1203
- item instanceof Array ? this.pushList(item) : this.push(item);
1384
+ item instanceof Array ? this.addList(item) : this.add(item);
1204
1385
  }
1205
1386
  has(leaf) {
1206
1387
  return this.keys[leaf.innerId] !== undefined;
@@ -1217,10 +1398,10 @@ var LeaferUI = (function (exports) {
1217
1398
  levels.sort((a, b) => a - b);
1218
1399
  }
1219
1400
  }
1220
- pushList(list) {
1221
- list.forEach(leaf => { this.push(leaf); });
1401
+ addList(list) {
1402
+ list.forEach(leaf => { this.add(leaf); });
1222
1403
  }
1223
- push(leaf) {
1404
+ add(leaf) {
1224
1405
  const { keys, levelMap } = this;
1225
1406
  if (!keys[leaf.innerId]) {
1226
1407
  keys[leaf.innerId] = 1;
@@ -1261,11 +1442,11 @@ var LeaferUI = (function (exports) {
1261
1442
  this.imageTypeList = new LeafList();
1262
1443
  }
1263
1444
  getImageType(leaf, size) {
1264
- this.imageTypeList.push(leaf);
1445
+ this.imageTypeList.add(leaf);
1265
1446
  return Creator.hitCanvas(size);
1266
1447
  }
1267
1448
  getPathType(leaf) {
1268
- this.pathTypeList.push(leaf);
1449
+ this.pathTypeList.add(leaf);
1269
1450
  return Creator.hitCanvas();
1270
1451
  }
1271
1452
  clearImageType() {
@@ -1335,6 +1516,17 @@ var LeaferUI = (function (exports) {
1335
1516
  }
1336
1517
  return this[name];
1337
1518
  }
1519
+ __getData() {
1520
+ const data = { tag: this.__leaf.tag }, { __input } = this;
1521
+ let inputValue;
1522
+ for (let key in this) {
1523
+ if (key[0] !== '_') {
1524
+ inputValue = __input ? __input[key] : undefined;
1525
+ data[key] = (inputValue === undefined) ? this[key] : inputValue;
1526
+ }
1527
+ }
1528
+ return data;
1529
+ }
1338
1530
  __setInput(name, value) {
1339
1531
  this.__input || (this.__input = {});
1340
1532
  this.__input[name] = value;
@@ -1351,21 +1543,15 @@ var LeaferUI = (function (exports) {
1351
1543
  if (this.__input && this.__input[name] !== undefined)
1352
1544
  this.__input[name] = undefined;
1353
1545
  }
1354
- __getInputData(options) {
1546
+ __getInputData() {
1355
1547
  const data = { tag: this.__leaf.tag }, { __input } = this;
1356
- if (options) {
1357
- for (let key in this) {
1358
- if (key[0] !== '_')
1359
- data[key] = this[key];
1360
- }
1361
- }
1362
- else {
1363
- let realKey, value;
1364
- for (let key in this) {
1365
- realKey = key.substring(1);
1366
- if (this[realKey] !== undefined) {
1367
- value = __input ? __input[realKey] : undefined;
1368
- data[realKey] = value === undefined ? this[key] : value;
1548
+ let value, inputValue;
1549
+ for (let key in this) {
1550
+ if (key[0] !== '_') {
1551
+ value = this['_' + key];
1552
+ if (value !== undefined) {
1553
+ inputValue = __input ? __input[key] : undefined;
1554
+ data[key] = (inputValue === undefined) ? value : inputValue;
1369
1555
  }
1370
1556
  }
1371
1557
  }
@@ -1456,11 +1642,10 @@ var LeaferUI = (function (exports) {
1456
1642
  return (target, key) => {
1457
1643
  if (!realName)
1458
1644
  realName = key;
1459
- const property = {
1645
+ Object.defineProperty(target, key, {
1460
1646
  get() { return this.context[realName]; },
1461
1647
  set(value) { this.context[realName] = value; }
1462
- };
1463
- Object.defineProperty(target, key, property);
1648
+ });
1464
1649
  };
1465
1650
  }
1466
1651
  const contextMethodNameList = [];
@@ -1738,7 +1923,7 @@ var LeaferUI = (function (exports) {
1738
1923
 
1739
1924
  const temp = new Bounds();
1740
1925
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
1741
- const debug$c = Debug.get('LeaferCanvasBase');
1926
+ const debug$d = Debug.get('LeaferCanvasBase');
1742
1927
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
1743
1928
  class LeaferCanvasBase extends Canvas {
1744
1929
  get pixelWidth() { return this.width * this.pixelRatio; }
@@ -1771,7 +1956,7 @@ var LeaferUI = (function (exports) {
1771
1956
  canvas.recycle();
1772
1957
  resolve(blob);
1773
1958
  }).catch((e) => {
1774
- debug$c.error(e);
1959
+ debug$d.error(e);
1775
1960
  resolve(null);
1776
1961
  });
1777
1962
  });
@@ -1789,7 +1974,7 @@ var LeaferUI = (function (exports) {
1789
1974
  canvas.recycle();
1790
1975
  resolve(true);
1791
1976
  }).catch((e) => {
1792
- debug$c.error(e);
1977
+ debug$d.error(e);
1793
1978
  resolve(false);
1794
1979
  });
1795
1980
  });
@@ -1940,7 +2125,7 @@ var LeaferUI = (function (exports) {
1940
2125
  if (blendMode)
1941
2126
  this.blendMode = blendMode;
1942
2127
  this.fillStyle = color;
1943
- temp.copy(bounds).scale(this.pixelRatio);
2128
+ temp.set(bounds).scale(this.pixelRatio);
1944
2129
  this.fillRect(temp.x, temp.y, temp.width, temp.height);
1945
2130
  if (blendMode)
1946
2131
  this.blendMode = 'source-over';
@@ -1949,20 +2134,20 @@ var LeaferUI = (function (exports) {
1949
2134
  if (blendMode)
1950
2135
  this.blendMode = blendMode;
1951
2136
  this.strokeStyle = color;
1952
- temp.copy(bounds).scale(this.pixelRatio);
2137
+ temp.set(bounds).scale(this.pixelRatio);
1953
2138
  this.strokeRect(temp.x, temp.y, temp.width, temp.height);
1954
2139
  if (blendMode)
1955
2140
  this.blendMode = 'source-over';
1956
2141
  }
1957
2142
  clearWorld(bounds, ceilPixel) {
1958
- temp.copy(bounds).scale(this.pixelRatio);
2143
+ temp.set(bounds).scale(this.pixelRatio);
1959
2144
  if (ceilPixel)
1960
2145
  temp.ceil();
1961
2146
  this.clearRect(temp.x, temp.y, temp.width, temp.height);
1962
2147
  }
1963
2148
  clipWorld(bounds, ceilPixel) {
1964
2149
  this.beginPath();
1965
- temp.copy(bounds).scale(this.pixelRatio);
2150
+ temp.set(bounds).scale(this.pixelRatio);
1966
2151
  if (ceilPixel)
1967
2152
  temp.ceil();
1968
2153
  this.rect(temp.x, temp.y, temp.width, temp.height);
@@ -1975,13 +2160,15 @@ var LeaferUI = (function (exports) {
1975
2160
  isSameSize(size) {
1976
2161
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
1977
2162
  }
1978
- getSameCanvas(useSameWorldTransform) {
2163
+ getSameCanvas(useSameWorldTransform, useSameSmooth) {
1979
2164
  const { width, height, pixelRatio } = this;
1980
2165
  const options = { width, height, pixelRatio };
1981
2166
  const canvas = this.manager ? this.manager.get(options) : Creator.canvas(options);
1982
2167
  canvas.save();
1983
2168
  if (useSameWorldTransform)
1984
2169
  canvas.useWorldTransform(Object.assign({}, this.worldTransform));
2170
+ if (useSameSmooth)
2171
+ canvas.smooth = this.smooth;
1985
2172
  return canvas;
1986
2173
  }
1987
2174
  getBiggerCanvas(addWidth, addHeight) {
@@ -2072,44 +2259,37 @@ var LeaferUI = (function (exports) {
2072
2259
  a: 90,
2073
2260
  };
2074
2261
  const NeedConvertToCurveCommandMap = Object.assign(Object.assign({}, NeedConvertToCanvasCommandMap), CanvasCommandOnlyMap);
2075
- const P$4 = PathCommandMap;
2262
+ const P$5 = PathCommandMap;
2076
2263
  const PathNumberCommandMap = {};
2077
- for (let key in P$4) {
2078
- PathNumberCommandMap[P$4[key]] = key;
2264
+ for (let key in P$5) {
2265
+ PathNumberCommandMap[P$5[key]] = key;
2079
2266
  }
2080
2267
  const PathNumberCommandLengthMap = {};
2081
- for (let key in P$4) {
2082
- PathNumberCommandLengthMap[P$4[key]] = PathCommandLengthMap[key];
2268
+ for (let key in P$5) {
2269
+ PathNumberCommandLengthMap[P$5[key]] = PathCommandLengthMap[key];
2083
2270
  }
2084
2271
 
2085
2272
  const RectHelper = {
2086
2273
  drawRoundRect(drawer, x, y, width, height, cornerRadius) {
2087
- let [topLeft, topRight, bottomRight, bottomLeft] = MathHelper.fourNumber(cornerRadius);
2088
- const max = Math.min(width / 2, height / 2);
2089
- if (topLeft > max)
2090
- topLeft = max;
2091
- if (topRight > max)
2092
- topRight = max;
2093
- if (bottomRight > max)
2094
- bottomRight = max;
2095
- if (bottomLeft > max)
2096
- bottomLeft = max;
2097
- topLeft ? drawer.moveTo(x + topLeft, y) : drawer.moveTo(x, y);
2098
- topRight ? drawer.arcTo(x + width, y, x + width, y + height, topRight) : drawer.lineTo(x + width, y);
2099
- bottomRight ? drawer.arcTo(x + width, y + height, x, y + height, bottomRight) : drawer.lineTo(x + width, y + height);
2100
- bottomLeft ? drawer.arcTo(x, y + height, x, y, bottomLeft) : drawer.lineTo(x, y + height);
2101
- topLeft ? drawer.arcTo(x, y, x + width, y, topLeft) : drawer.lineTo(x, y);
2274
+ const data = MathHelper.fourNumber(cornerRadius, Math.min(width / 2, height / 2));
2275
+ const right = x + width;
2276
+ const bottom = y + height;
2277
+ data[0] ? drawer.moveTo(x + data[0], y) : drawer.moveTo(x, y);
2278
+ data[1] ? drawer.arcTo(right, y, right, bottom, data[1]) : drawer.lineTo(right, y);
2279
+ data[2] ? drawer.arcTo(right, bottom, x, bottom, data[2]) : drawer.lineTo(right, bottom);
2280
+ data[3] ? drawer.arcTo(x, bottom, x, y, data[3]) : drawer.lineTo(x, bottom);
2281
+ data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
2102
2282
  }
2103
2283
  };
2104
2284
 
2105
- const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil, abs, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2285
+ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2106
2286
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2107
2287
  const { set: set$2 } = PointHelper;
2108
- const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2109
- const tempPoint = {};
2288
+ const { M: M$6, L: L$7, C: C$6, Q: Q$5, Z: Z$6 } = PathCommandMap;
2289
+ const tempPoint$1 = {};
2110
2290
  const BezierHelper = {
2111
2291
  points(data, points, curve, close) {
2112
- data.push(M$5, points[0], points[1]);
2292
+ data.push(M$6, points[0], points[1]);
2113
2293
  if (curve && points.length > 5) {
2114
2294
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
2115
2295
  let ba, cb, d, len = points.length;
@@ -2136,24 +2316,24 @@ var LeaferUI = (function (exports) {
2136
2316
  c1Y = bY - ba * cY;
2137
2317
  if (i === 2) {
2138
2318
  if (!close)
2139
- data.push(Q$4, c1X, c1Y, bX, bY);
2319
+ data.push(Q$5, c1X, c1Y, bX, bY);
2140
2320
  }
2141
2321
  else {
2142
- data.push(C$5, c2X, c2Y, c1X, c1Y, bX, bY);
2322
+ data.push(C$6, c2X, c2Y, c1X, c1Y, bX, bY);
2143
2323
  }
2144
2324
  c2X = bX + cb * cX;
2145
2325
  c2Y = bY + cb * cY;
2146
2326
  }
2147
2327
  if (!close)
2148
- data.push(Q$4, c2X, c2Y, points[len - 2], points[len - 1]);
2328
+ data.push(Q$5, c2X, c2Y, points[len - 2], points[len - 1]);
2149
2329
  }
2150
2330
  else {
2151
2331
  for (let i = 2, len = points.length; i < len; i += 2) {
2152
- data.push(L$6, points[i], points[i + 1]);
2332
+ data.push(L$7, points[i], points[i + 1]);
2153
2333
  }
2154
2334
  }
2155
2335
  if (close)
2156
- data.push(Z$5);
2336
+ data.push(Z$6);
2157
2337
  },
2158
2338
  rect(data, x, y, width, height) {
2159
2339
  PathHelper.creator.path = data;
@@ -2174,9 +2354,9 @@ var LeaferUI = (function (exports) {
2174
2354
  let totalRadian = endRadian - startRadian;
2175
2355
  if (totalRadian < 0)
2176
2356
  totalRadian += PI2;
2177
- if (totalRadian === PI$2 || (abs(BAx + BAy) < 1.e-12) || (abs(CBx + CBy) < 1.e-12)) {
2357
+ if (totalRadian === PI$2 || (abs$2(BAx + BAy) < 1.e-12) || (abs$2(CBx + CBy) < 1.e-12)) {
2178
2358
  if (data)
2179
- data.push(L$6, x1, y1);
2359
+ data.push(L$7, x1, y1);
2180
2360
  if (setPointBounds) {
2181
2361
  setPoint$1(setPointBounds, fromX, fromY);
2182
2362
  addPoint$1(setPointBounds, x1, y1);
@@ -2189,9 +2369,9 @@ var LeaferUI = (function (exports) {
2189
2369
  }
2190
2370
  const anticlockwise = BAx * CBy - CBx * BAy < 0;
2191
2371
  const sign = anticlockwise ? -1 : 1;
2192
- const c = radius / cos$4(totalRadian / 2);
2193
- const centerX = x1 + c * cos$4(startRadian + totalRadian / 2 + PI_2 * sign);
2194
- const centerY = y1 + c * sin$4(startRadian + totalRadian / 2 + PI_2 * sign);
2372
+ const c = radius / cos$3(totalRadian / 2);
2373
+ const centerX = x1 + c * cos$3(startRadian + totalRadian / 2 + PI_2 * sign);
2374
+ const centerY = y1 + c * sin$3(startRadian + totalRadian / 2 + PI_2 * sign);
2195
2375
  startRadian -= PI_2 * sign;
2196
2376
  endRadian -= PI_2 * sign;
2197
2377
  return ellipse$6(data, centerX, centerY, radius, radius, 0, startRadian / OneRadian, endRadian / OneRadian, anticlockwise, setPointBounds, setEndPoint, setStartPoint);
@@ -2201,8 +2381,8 @@ var LeaferUI = (function (exports) {
2201
2381
  },
2202
2382
  ellipse(data, cx, cy, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, setPointBounds, setEndPoint, setStartPoint) {
2203
2383
  const rotationRadian = rotation * OneRadian;
2204
- const rotationSin = sin$4(rotationRadian);
2205
- const rotationCos = cos$4(rotationRadian);
2384
+ const rotationSin = sin$3(rotationRadian);
2385
+ const rotationCos = cos$3(rotationRadian);
2206
2386
  let startRadian = startAngle * OneRadian;
2207
2387
  let endRadian = endAngle * OneRadian;
2208
2388
  if (startRadian > PI$2)
@@ -2216,27 +2396,27 @@ var LeaferUI = (function (exports) {
2216
2396
  totalRadian -= PI2;
2217
2397
  if (anticlockwise)
2218
2398
  totalRadian -= PI2;
2219
- const parts = ceil(abs(totalRadian / PI_2));
2399
+ const parts = ceil(abs$2(totalRadian / PI_2));
2220
2400
  const partRadian = totalRadian / parts;
2221
- const partRadian4Sin = sin$4(partRadian / 4);
2222
- const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
2401
+ const partRadian4Sin = sin$3(partRadian / 4);
2402
+ const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
2223
2403
  endRadian = startRadian + partRadian;
2224
- let startCos = cos$4(startRadian);
2225
- let startSin = sin$4(startRadian);
2404
+ let startCos = cos$3(startRadian);
2405
+ let startSin = sin$3(startRadian);
2226
2406
  let endCos, endSin;
2227
2407
  let x, y, x1, y1, x2, y2;
2228
2408
  let startX = x = rotationCos * radiusX * startCos - rotationSin * radiusY * startSin;
2229
2409
  let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
2230
2410
  let fromX = cx + x, fromY = cy + y;
2231
2411
  if (data)
2232
- data.push(L$6, fromX, fromY);
2412
+ data.push(L$7, fromX, fromY);
2233
2413
  if (setPointBounds)
2234
2414
  setPoint$1(setPointBounds, fromX, fromY);
2235
2415
  if (setStartPoint)
2236
2416
  set$2(setStartPoint, fromX, fromY);
2237
2417
  for (let i = 0; i < parts; i++) {
2238
- endCos = cos$4(endRadian);
2239
- endSin = sin$4(endRadian);
2418
+ endCos = cos$3(endRadian);
2419
+ endSin = sin$3(endRadian);
2240
2420
  x = rotationCos * radiusX * endCos - rotationSin * radiusY * endSin;
2241
2421
  y = rotationSin * radiusX * endCos + rotationCos * radiusY * endSin;
2242
2422
  x1 = cx + startX - control * (rotationCos * radiusX * startSin + rotationSin * radiusY * startCos);
@@ -2244,7 +2424,7 @@ var LeaferUI = (function (exports) {
2244
2424
  x2 = cx + x + control * (rotationCos * radiusX * endSin + rotationSin * radiusY * endCos);
2245
2425
  y2 = cy + y + control * (rotationSin * radiusX * endSin - rotationCos * radiusY * endCos);
2246
2426
  if (data)
2247
- data.push(C$5, x1, y1, x2, y2, cx + x, cy + y);
2427
+ data.push(C$6, x1, y1, x2, y2, cx + x, cy + y);
2248
2428
  if (setPointBounds)
2249
2429
  toTwoPointBounds$1(cx + startX, cy + startY, x1, y1, x2, y2, cx + x, cy + y, setPointBounds, true);
2250
2430
  startX = x;
@@ -2258,7 +2438,7 @@ var LeaferUI = (function (exports) {
2258
2438
  set$2(setEndPoint, cx + x, cy + y);
2259
2439
  },
2260
2440
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2261
- data.push(C$5, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2441
+ data.push(C$6, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2262
2442
  },
2263
2443
  toTwoPointBoundsByQuadraticCurve(fromX, fromY, x1, y1, toX, toY, pointBounds, addMode) {
2264
2444
  toTwoPointBounds$1(fromX, fromY, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY, pointBounds, addMode);
@@ -2296,8 +2476,8 @@ var LeaferUI = (function (exports) {
2296
2476
  addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
2297
2477
  addPoint$1(pointBounds, toX, toY);
2298
2478
  for (let i = 0, len = tList.length; i < len; i++) {
2299
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint);
2300
- addPoint$1(pointBounds, tempPoint.x, tempPoint.y);
2479
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2480
+ addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
2301
2481
  }
2302
2482
  },
2303
2483
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2313,15 +2493,15 @@ var LeaferUI = (function (exports) {
2313
2493
  };
2314
2494
  const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$6 } = BezierHelper;
2315
2495
 
2316
- const { sin: sin$3, cos: cos$3, sqrt, atan2 } = Math;
2496
+ const { sin: sin$2, cos: cos$2, sqrt, atan2 } = Math;
2317
2497
  const { ellipse: ellipse$5 } = BezierHelper;
2318
2498
  const EllipseHelper = {
2319
2499
  ellipticalArc(data, fromX, fromY, radiusX, radiusY, rotation, largeFlag, sweepFlag, toX, toY, curveMode) {
2320
2500
  const halfX = (toX - fromX) / 2;
2321
2501
  const halfY = (toY - fromY) / 2;
2322
2502
  const rotationRadian = rotation * OneRadian;
2323
- const rotationSin = sin$3(rotationRadian);
2324
- const rotationCos = cos$3(rotationRadian);
2503
+ const rotationSin = sin$2(rotationRadian);
2504
+ const rotationCos = cos$2(rotationRadian);
2325
2505
  const px = -rotationCos * halfX - rotationSin * halfY;
2326
2506
  const py = -rotationCos * halfY + rotationSin * halfX;
2327
2507
  const rxSquare = radiusX * radiusX;
@@ -2366,10 +2546,10 @@ var LeaferUI = (function (exports) {
2366
2546
  }
2367
2547
  };
2368
2548
 
2369
- const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$3, O: O$3, P: P$3, U: U$4 } = PathCommandMap;
2370
- const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$2, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2549
+ const { M: M$5, m, L: L$6, l, H, h, V, v, C: C$5, c, S, s, Q: Q$4, q, T, t, A, a, Z: Z$5, z, N: N$4, D: D$4, X: X$4, G: G$4, F: F$4, O: O$4, P: P$4, U: U$4 } = PathCommandMap;
2550
+ const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2371
2551
  const { ellipticalArc } = EllipseHelper;
2372
- const debug$b = Debug.get('PathConvert');
2552
+ const debug$c = Debug.get('PathConvert');
2373
2553
  const setEndPoint$1 = {};
2374
2554
  const PathConvert = {
2375
2555
  current: { dot: 0 },
@@ -2454,33 +2634,33 @@ var LeaferUI = (function (exports) {
2454
2634
  case m:
2455
2635
  old[i + 1] += x;
2456
2636
  old[i + 2] += y;
2457
- case M$4:
2637
+ case M$5:
2458
2638
  x = old[i + 1];
2459
2639
  y = old[i + 2];
2460
- data.push(M$4, x, y);
2640
+ data.push(M$5, x, y);
2461
2641
  i += 3;
2462
2642
  break;
2463
2643
  case h:
2464
2644
  old[i + 1] += x;
2465
2645
  case H:
2466
2646
  x = old[i + 1];
2467
- data.push(L$5, x, y);
2647
+ data.push(L$6, x, y);
2468
2648
  i += 2;
2469
2649
  break;
2470
2650
  case v:
2471
2651
  old[i + 1] += y;
2472
2652
  case V:
2473
2653
  y = old[i + 1];
2474
- data.push(L$5, x, y);
2654
+ data.push(L$6, x, y);
2475
2655
  i += 2;
2476
2656
  break;
2477
2657
  case l:
2478
2658
  old[i + 1] += x;
2479
2659
  old[i + 2] += y;
2480
- case L$5:
2660
+ case L$6:
2481
2661
  x = old[i + 1];
2482
2662
  y = old[i + 2];
2483
- data.push(L$5, x, y);
2663
+ data.push(L$6, x, y);
2484
2664
  i += 3;
2485
2665
  break;
2486
2666
  case s:
@@ -2490,14 +2670,14 @@ var LeaferUI = (function (exports) {
2490
2670
  old[i + 4] += y;
2491
2671
  command = S;
2492
2672
  case S:
2493
- smooth = (lastCommand === C$4) || (lastCommand === S);
2673
+ smooth = (lastCommand === C$5) || (lastCommand === S);
2494
2674
  x1 = smooth ? (x * 2 - controlX) : old[i + 1];
2495
2675
  y1 = smooth ? (y * 2 - controlY) : old[i + 2];
2496
2676
  controlX = old[i + 1];
2497
2677
  controlY = old[i + 2];
2498
2678
  x = old[i + 3];
2499
2679
  y = old[i + 4];
2500
- data.push(C$4, x1, y1, controlX, controlY, x, y);
2680
+ data.push(C$5, x1, y1, controlX, controlY, x, y);
2501
2681
  i += 5;
2502
2682
  break;
2503
2683
  case c:
@@ -2507,13 +2687,13 @@ var LeaferUI = (function (exports) {
2507
2687
  old[i + 4] += y;
2508
2688
  old[i + 5] += x;
2509
2689
  old[i + 6] += y;
2510
- command = C$4;
2511
- case C$4:
2690
+ command = C$5;
2691
+ case C$5:
2512
2692
  controlX = old[i + 3];
2513
2693
  controlY = old[i + 4];
2514
2694
  x = old[i + 5];
2515
2695
  y = old[i + 6];
2516
- data.push(C$4, old[i + 1], old[i + 2], controlX, controlY, x, y);
2696
+ data.push(C$5, old[i + 1], old[i + 2], controlX, controlY, x, y);
2517
2697
  i += 7;
2518
2698
  break;
2519
2699
  case t:
@@ -2521,10 +2701,10 @@ var LeaferUI = (function (exports) {
2521
2701
  old[i + 2] += y;
2522
2702
  command = T;
2523
2703
  case T:
2524
- smooth = (lastCommand === Q$3) || (lastCommand === T);
2704
+ smooth = (lastCommand === Q$4) || (lastCommand === T);
2525
2705
  controlX = smooth ? (x * 2 - controlX) : old[i + 1];
2526
2706
  controlY = smooth ? (y * 2 - controlY) : old[i + 2];
2527
- curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 1], old[i + 2]) : data.push(Q$3, controlX, controlY, old[i + 1], old[i + 2]);
2707
+ curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 1], old[i + 2]) : data.push(Q$4, controlX, controlY, old[i + 1], old[i + 2]);
2528
2708
  x = old[i + 1];
2529
2709
  y = old[i + 2];
2530
2710
  i += 3;
@@ -2534,11 +2714,11 @@ var LeaferUI = (function (exports) {
2534
2714
  old[i + 2] += y;
2535
2715
  old[i + 3] += x;
2536
2716
  old[i + 4] += y;
2537
- command = Q$3;
2538
- case Q$3:
2717
+ command = Q$4;
2718
+ case Q$4:
2539
2719
  controlX = old[i + 1];
2540
2720
  controlY = old[i + 2];
2541
- curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 3], old[i + 4]) : data.push(Q$3, controlX, controlY, old[i + 3], old[i + 4]);
2721
+ curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 3], old[i + 4]) : data.push(Q$4, controlX, controlY, old[i + 3], old[i + 4]);
2542
2722
  x = old[i + 3];
2543
2723
  y = old[i + 4];
2544
2724
  i += 5;
@@ -2553,60 +2733,60 @@ var LeaferUI = (function (exports) {
2553
2733
  i += 8;
2554
2734
  break;
2555
2735
  case z:
2556
- case Z$4:
2557
- data.push(Z$4);
2736
+ case Z$5:
2737
+ data.push(Z$5);
2558
2738
  i++;
2559
2739
  break;
2560
- case N$3:
2740
+ case N$4:
2561
2741
  x = old[i + 1];
2562
2742
  y = old[i + 2];
2563
2743
  curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2564
2744
  i += 5;
2565
2745
  break;
2566
- case D$3:
2746
+ case D$4:
2567
2747
  x = old[i + 1];
2568
2748
  y = old[i + 2];
2569
2749
  curveMode ? roundRect$2(data, x, y, old[i + 3], old[i + 4], [old[i + 5], old[i + 6], old[i + 7], old[i + 8]]) : copyData(data, old, i, 9);
2570
2750
  i += 9;
2571
2751
  break;
2572
- case X$3:
2752
+ case X$4:
2573
2753
  x = old[i + 1];
2574
2754
  y = old[i + 2];
2575
2755
  curveMode ? roundRect$2(data, x, y, old[i + 3], old[i + 4], old[i + 5]) : copyData(data, old, i, 6);
2576
2756
  i += 6;
2577
2757
  break;
2578
- case G$3:
2758
+ case G$4:
2579
2759
  ellipse$4(curveMode ? data : copyData(data, old, i, 9), old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], old[i + 6], old[i + 7], old[i + 8], null, setEndPoint$1);
2580
2760
  x = setEndPoint$1.x;
2581
2761
  y = setEndPoint$1.y;
2582
2762
  i += 9;
2583
2763
  break;
2584
- case F$3:
2764
+ case F$4:
2585
2765
  curveMode ? ellipse$4(data, old[i + 1], old[i + 2], old[i + 3], old[i + 4], 0, 0, 360, false) : copyData(data, old, i, 5);
2586
2766
  x = old[i + 1] + old[i + 3];
2587
2767
  y = old[i + 2];
2588
2768
  i += 5;
2589
2769
  break;
2590
- case O$3:
2770
+ case O$4:
2591
2771
  arc$3(curveMode ? data : copyData(data, old, i, 7), old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], old[i + 6], null, setEndPoint$1);
2592
2772
  x = setEndPoint$1.x;
2593
2773
  y = setEndPoint$1.y;
2594
2774
  i += 7;
2595
2775
  break;
2596
- case P$3:
2776
+ case P$4:
2597
2777
  curveMode ? arc$3(data, old[i + 1], old[i + 2], old[i + 3], 0, 360, false) : copyData(data, old, i, 4);
2598
2778
  x = old[i + 1] + old[i + 3];
2599
2779
  y = old[i + 2];
2600
2780
  i += 4;
2601
2781
  break;
2602
2782
  case U$4:
2603
- arcTo$2(curveMode ? data : copyData(data, old, i, 6), x, y, old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], null, setEndPoint$1);
2783
+ arcTo$3(curveMode ? data : copyData(data, old, i, 6), x, y, old[i + 1], old[i + 2], old[i + 3], old[i + 4], old[i + 5], null, setEndPoint$1);
2604
2784
  x = setEndPoint$1.x;
2605
2785
  y = setEndPoint$1.y;
2606
2786
  i += 6;
2607
2787
  break;
2608
2788
  default:
2609
- debug$b.error(`command: ${command} [index:${i}]`, old);
2789
+ debug$c.error(`command: ${command} [index:${i}]`, old);
2610
2790
  return data;
2611
2791
  }
2612
2792
  lastCommand = command;
@@ -2630,68 +2810,76 @@ var LeaferUI = (function (exports) {
2630
2810
  };
2631
2811
  const { current, pushData, copyData } = PathConvert;
2632
2812
 
2633
- const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$2, O: O$2, P: P$2, U: U$3 } = PathCommandMap;
2813
+ const { M: M$4, L: L$5, C: C$4, Q: Q$3, Z: Z$4, N: N$3, D: D$3, X: X$3, G: G$3, F: F$3, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2814
+ const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2815
+ const { tan, min, abs: abs$1 } = Math;
2634
2816
  const startPoint = {};
2635
2817
  const PathCommandDataHelper = {
2636
2818
  beginPath(data) {
2637
2819
  data.length = 0;
2638
2820
  },
2639
2821
  moveTo(data, x, y) {
2640
- data.push(M$3, x, y);
2822
+ data.push(M$4, x, y);
2641
2823
  },
2642
2824
  lineTo(data, x, y) {
2643
- data.push(L$4, x, y);
2825
+ data.push(L$5, x, y);
2644
2826
  },
2645
2827
  bezierCurveTo(data, x1, y1, x2, y2, x, y) {
2646
- data.push(C$3, x1, y1, x2, y2, x, y);
2828
+ data.push(C$4, x1, y1, x2, y2, x, y);
2647
2829
  },
2648
2830
  quadraticCurveTo(data, x1, y1, x, y) {
2649
- data.push(Q$2, x1, y1, x, y);
2831
+ data.push(Q$3, x1, y1, x, y);
2650
2832
  },
2651
2833
  closePath(data) {
2652
- data.push(Z$3);
2834
+ data.push(Z$4);
2653
2835
  },
2654
2836
  rect(data, x, y, width, height) {
2655
- data.push(N$2, x, y, width, height);
2837
+ data.push(N$3, x, y, width, height);
2656
2838
  },
2657
2839
  roundRect(data, x, y, width, height, cornerRadius) {
2658
2840
  if (typeof cornerRadius === 'number') {
2659
- data.push(X$2, x, y, width, height, cornerRadius);
2841
+ data.push(X$3, x, y, width, height, cornerRadius);
2660
2842
  }
2661
2843
  else {
2662
2844
  const fourCorners = MathHelper.fourNumber(cornerRadius);
2663
2845
  if (fourCorners) {
2664
- data.push(D$2, x, y, width, height, ...fourCorners);
2846
+ data.push(D$3, x, y, width, height, ...fourCorners);
2665
2847
  }
2666
2848
  else {
2667
- data.push(N$2, x, y, width, height);
2849
+ data.push(N$3, x, y, width, height);
2668
2850
  }
2669
2851
  }
2670
2852
  },
2671
2853
  ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2672
2854
  if (rotation === undefined) {
2673
- data.push(F$2, x, y, radiusX, radiusY);
2855
+ data.push(F$3, x, y, radiusX, radiusY);
2674
2856
  }
2675
2857
  else {
2676
2858
  if (startAngle === undefined)
2677
2859
  startAngle = 0;
2678
2860
  if (endAngle === undefined)
2679
2861
  endAngle = 360;
2680
- data.push(G$2, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise ? 1 : 0);
2862
+ data.push(G$3, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise ? 1 : 0);
2681
2863
  }
2682
2864
  },
2683
2865
  arc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
2684
2866
  if (startAngle === undefined) {
2685
- data.push(P$2, x, y, radius);
2867
+ data.push(P$3, x, y, radius);
2686
2868
  }
2687
2869
  else {
2688
2870
  if (endAngle === undefined)
2689
2871
  endAngle = 360;
2690
- data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
2872
+ data.push(O$3, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
2691
2873
  }
2692
2874
  },
2693
- arcTo(data, x1, y1, x2, y2, radius) {
2694
- data.push(U$3, x1, y1, x2, y2, radius);
2875
+ arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
2876
+ if (lastX !== undefined) {
2877
+ const maxRadius = tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2) * (getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / 2);
2878
+ data.push(U$3, x1, y1, x2, y2, min(radius, abs$1(maxRadius)));
2879
+ }
2880
+ else {
2881
+ data.push(U$3, x1, y1, x2, y2, radius);
2882
+ }
2695
2883
  },
2696
2884
  drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2697
2885
  if (rotation === undefined)
@@ -2701,7 +2889,7 @@ var LeaferUI = (function (exports) {
2701
2889
  if (endAngle === undefined)
2702
2890
  endAngle = 360;
2703
2891
  BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, null, null, startPoint);
2704
- data.push(M$3, startPoint.x, startPoint.y);
2892
+ data.push(M$4, startPoint.x, startPoint.y);
2705
2893
  ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2706
2894
  },
2707
2895
  drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
@@ -2710,7 +2898,7 @@ var LeaferUI = (function (exports) {
2710
2898
  if (endAngle === undefined)
2711
2899
  endAngle = 360;
2712
2900
  BezierHelper.arc(null, x, y, radius, startAngle, endAngle, anticlockwise, null, null, startPoint);
2713
- data.push(M$3, startPoint.x, startPoint.y);
2901
+ data.push(M$4, startPoint.x, startPoint.y);
2714
2902
  arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
2715
2903
  },
2716
2904
  drawPoints(data, points, curve, close) {
@@ -2719,7 +2907,7 @@ var LeaferUI = (function (exports) {
2719
2907
  };
2720
2908
  const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
2721
2909
 
2722
- const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$1, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2910
+ const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2723
2911
  class PathCreator {
2724
2912
  constructor(path) {
2725
2913
  if (path) {
@@ -2770,7 +2958,7 @@ var LeaferUI = (function (exports) {
2770
2958
  return this;
2771
2959
  }
2772
2960
  arcTo(x1, y1, x2, y2, radius) {
2773
- arcTo$1(this.path, x1, y1, x2, y2, radius);
2961
+ arcTo$2(this.path, x1, y1, x2, y2, radius);
2774
2962
  return this;
2775
2963
  }
2776
2964
  drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
@@ -2787,8 +2975,8 @@ var LeaferUI = (function (exports) {
2787
2975
  }
2788
2976
  }
2789
2977
 
2790
- const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$1, P: P$1, U: U$2 } = PathCommandMap;
2791
- const debug$a = Debug.get('PathDrawer');
2978
+ const { M: M$3, L: L$4, C: C$3, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$2, O: O$2, P: P$2, U: U$2 } = PathCommandMap;
2979
+ const debug$b = Debug.get('PathDrawer');
2792
2980
  const PathDrawer = {
2793
2981
  drawPathByData(drawer, data) {
2794
2982
  if (!data)
@@ -2798,51 +2986,51 @@ var LeaferUI = (function (exports) {
2798
2986
  while (i < len) {
2799
2987
  command = data[i];
2800
2988
  switch (command) {
2801
- case M$2:
2989
+ case M$3:
2802
2990
  drawer.moveTo(data[i + 1], data[i + 2]);
2803
2991
  i += 3;
2804
2992
  break;
2805
- case L$3:
2993
+ case L$4:
2806
2994
  drawer.lineTo(data[i + 1], data[i + 2]);
2807
2995
  i += 3;
2808
2996
  break;
2809
- case C$2:
2997
+ case C$3:
2810
2998
  drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
2811
2999
  i += 7;
2812
3000
  break;
2813
- case Q$1:
3001
+ case Q$2:
2814
3002
  drawer.quadraticCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
2815
3003
  i += 5;
2816
3004
  break;
2817
- case Z$2:
3005
+ case Z$3:
2818
3006
  drawer.closePath();
2819
3007
  i += 1;
2820
3008
  break;
2821
- case N$1:
3009
+ case N$2:
2822
3010
  drawer.rect(data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
2823
3011
  i += 5;
2824
3012
  break;
2825
- case D$1:
3013
+ case D$2:
2826
3014
  drawer.roundRect(data[i + 1], data[i + 2], data[i + 3], data[i + 4], [data[i + 5], data[i + 6], data[i + 7], data[i + 8]]);
2827
3015
  i += 9;
2828
3016
  break;
2829
- case X$1:
3017
+ case X$2:
2830
3018
  drawer.roundRect(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5]);
2831
3019
  i += 6;
2832
3020
  break;
2833
- case G$1:
3021
+ case G$2:
2834
3022
  drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5] * OneRadian, data[i + 6] * OneRadian, data[i + 7] * OneRadian, data[i + 8]);
2835
3023
  i += 9;
2836
3024
  break;
2837
- case F$1:
3025
+ case F$2:
2838
3026
  drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], 0, 0, PI2, false);
2839
3027
  i += 5;
2840
3028
  break;
2841
- case O$1:
3029
+ case O$2:
2842
3030
  drawer.arc(data[i + 1], data[i + 2], data[i + 3], data[i + 4] * OneRadian, data[i + 5] * OneRadian, data[i + 6]);
2843
3031
  i += 7;
2844
3032
  break;
2845
- case P$1:
3033
+ case P$2:
2846
3034
  drawer.arc(data[i + 1], data[i + 2], data[i + 3], 0, PI2, false);
2847
3035
  i += 4;
2848
3036
  break;
@@ -2851,17 +3039,97 @@ var LeaferUI = (function (exports) {
2851
3039
  i += 6;
2852
3040
  break;
2853
3041
  default:
2854
- debug$a.error(`command: ${command} [index:${i}]`, data);
3042
+ debug$b.error(`command: ${command} [index:${i}]`, data);
2855
3043
  return;
2856
3044
  }
2857
3045
  }
2858
3046
  }
2859
3047
  };
2860
3048
 
2861
- const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U: U$1 } = PathCommandMap;
2862
- const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo, arc, ellipse: ellipse$1 } = BezierHelper;
2863
- const { add: add$1, copy: copy$6, addPoint, setPoint, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
2864
- const debug$9 = Debug.get('PathBounds');
3049
+ const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$1, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
3050
+ const PathScaler = {
3051
+ scale(data, scaleX, scaleY) {
3052
+ if (!data)
3053
+ return;
3054
+ let command;
3055
+ let i = 0, len = data.length;
3056
+ while (i < len) {
3057
+ command = data[i];
3058
+ switch (command) {
3059
+ case M$2:
3060
+ scalePoints(data, scaleX, scaleY, i, 1);
3061
+ i += 3;
3062
+ break;
3063
+ case L$3:
3064
+ scalePoints(data, scaleX, scaleY, i, 1);
3065
+ i += 3;
3066
+ break;
3067
+ case C$2:
3068
+ scalePoints(data, scaleX, scaleY, i, 3);
3069
+ i += 7;
3070
+ break;
3071
+ case Q$1:
3072
+ scalePoints(data, scaleX, scaleY, i, 2);
3073
+ i += 5;
3074
+ break;
3075
+ case Z$2:
3076
+ i += 1;
3077
+ break;
3078
+ case N$1:
3079
+ scalePoints(data, scaleX, scaleY, i, 2);
3080
+ i += 5;
3081
+ break;
3082
+ case D$1:
3083
+ scalePoints(data, scaleX, scaleY, i, 2);
3084
+ i += 9;
3085
+ break;
3086
+ case X$1:
3087
+ scalePoints(data, scaleX, scaleY, i, 2);
3088
+ i += 6;
3089
+ break;
3090
+ case G$1:
3091
+ scalePoints(data, scaleX, scaleY, i, 2);
3092
+ console.log('G');
3093
+ i += 9;
3094
+ break;
3095
+ case F$1:
3096
+ scalePoints(data, scaleX, scaleY, i, 2);
3097
+ i += 5;
3098
+ break;
3099
+ case O$1:
3100
+ data[i] = G$1;
3101
+ data.splice(i + 4, 0, data[i + 3], 0);
3102
+ scalePoints(data, scaleX, scaleY, i, 2);
3103
+ i += 7 + 2;
3104
+ len += 2;
3105
+ break;
3106
+ case P$1:
3107
+ data[i] = F$1;
3108
+ data.splice(i + 4, 0, data[i + 3]);
3109
+ scalePoints(data, scaleX, scaleY, i, 2);
3110
+ i += 4 + 1;
3111
+ len += 1;
3112
+ break;
3113
+ case U$1:
3114
+ scalePoints(data, scaleX, scaleY, i, 2);
3115
+ i += 6;
3116
+ break;
3117
+ }
3118
+ }
3119
+ },
3120
+ scalePoints(data, scaleX, scaleY, start, pointCount) {
3121
+ for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
3122
+ data[i] *= scaleX;
3123
+ data[i + 1] *= scaleY;
3124
+ }
3125
+ }
3126
+ };
3127
+ const { scalePoints } = PathScaler;
3128
+
3129
+ const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U } = PathCommandMap;
3130
+ const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3131
+ const { addPointBounds, copy: copy$6, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
3132
+ const debug$a = Debug.get('PathBounds');
2865
3133
  let radius, radiusX, radiusY;
2866
3134
  const tempPointBounds = {};
2867
3135
  const setPointBounds = {};
@@ -2869,7 +3137,7 @@ var LeaferUI = (function (exports) {
2869
3137
  const PathBounds = {
2870
3138
  toBounds(data, setBounds) {
2871
3139
  PathBounds.toTwoPointBounds(data, setPointBounds);
2872
- toBounds$3(setPointBounds, setBounds);
3140
+ toBounds$2(setPointBounds, setBounds);
2873
3141
  },
2874
3142
  toTwoPointBounds(data, setPointBounds) {
2875
3143
  if (!data || !data.length)
@@ -2899,7 +3167,7 @@ var LeaferUI = (function (exports) {
2899
3167
  toX = data[i + 5];
2900
3168
  toY = data[i + 6];
2901
3169
  toTwoPointBounds(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY, tempPointBounds);
2902
- add$1(setPointBounds, tempPointBounds);
3170
+ addPointBounds(setPointBounds, tempPointBounds);
2903
3171
  x = toX;
2904
3172
  y = toY;
2905
3173
  i += 7;
@@ -2910,7 +3178,7 @@ var LeaferUI = (function (exports) {
2910
3178
  toX = data[i + 3];
2911
3179
  toY = data[i + 4];
2912
3180
  toTwoPointBoundsByQuadraticCurve(x, y, x1, y1, toX, toY, tempPointBounds);
2913
- add$1(setPointBounds, tempPointBounds);
3181
+ addPointBounds(setPointBounds, tempPointBounds);
2914
3182
  x = toX;
2915
3183
  y = toY;
2916
3184
  i += 5;
@@ -2933,7 +3201,7 @@ var LeaferUI = (function (exports) {
2933
3201
  break;
2934
3202
  case G:
2935
3203
  ellipse$1(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], data[i + 7], data[i + 8], tempPointBounds, setEndPoint);
2936
- i === 0 ? copy$6(setPointBounds, tempPointBounds) : add$1(setPointBounds, tempPointBounds);
3204
+ i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
2937
3205
  x = setEndPoint.x;
2938
3206
  y = setEndPoint.y;
2939
3207
  i += 9;
@@ -2949,7 +3217,7 @@ var LeaferUI = (function (exports) {
2949
3217
  break;
2950
3218
  case O:
2951
3219
  arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
2952
- i === 0 ? copy$6(setPointBounds, tempPointBounds) : add$1(setPointBounds, tempPointBounds);
3220
+ i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
2953
3221
  x = setEndPoint.x;
2954
3222
  y = setEndPoint.y;
2955
3223
  i += 7;
@@ -2962,39 +3230,41 @@ var LeaferUI = (function (exports) {
2962
3230
  x += radius;
2963
3231
  i += 4;
2964
3232
  break;
2965
- case U$1:
2966
- arcTo(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
2967
- i === 0 ? copy$6(setPointBounds, tempPointBounds) : add$1(setPointBounds, tempPointBounds);
3233
+ case U:
3234
+ arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
3235
+ i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
2968
3236
  x = setEndPoint.x;
2969
3237
  y = setEndPoint.y;
2970
3238
  i += 6;
2971
3239
  break;
2972
3240
  default:
2973
- debug$9.error(`command: ${command} [index:${i}]`, data);
3241
+ debug$a.error(`command: ${command} [index:${i}]`, data);
2974
3242
  return;
2975
3243
  }
2976
3244
  }
2977
3245
  }
2978
3246
  };
2979
3247
 
2980
- const { M, L: L$1, C, Z, U } = PathCommandMap;
3248
+ const { M, L: L$1, C, Z } = PathCommandMap;
3249
+ const { getCenterX, getCenterY } = PointHelper;
3250
+ const { arcTo } = PathCommandDataHelper;
2981
3251
  const PathCorner = {
2982
3252
  smooth(data, cornerRadius, _cornerSmoothing) {
2983
3253
  let command;
2984
- let i = 0, x = 0, y = 0, startX, startY = 0, centerX = 0, centerY = 0;
3254
+ let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
2985
3255
  const len = data.length;
2986
3256
  const smooth = [];
2987
3257
  while (i < len) {
2988
3258
  command = data[i];
2989
3259
  switch (command) {
2990
3260
  case M:
2991
- startX = data[i + 1];
2992
- startY = data[i + 2];
3261
+ startX = lastX = data[i + 1];
3262
+ startY = lastY = data[i + 2];
2993
3263
  i += 3;
2994
3264
  if (data[i] === L$1) {
2995
- centerX = startX + (data[i + 1] - startX) / 2;
2996
- centerY = startY + (data[i + 2] - startY) / 2;
2997
- smooth.push(M, centerX, centerY);
3265
+ secondX = data[i + 1];
3266
+ secondY = data[i + 2];
3267
+ smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
2998
3268
  }
2999
3269
  else {
3000
3270
  smooth.push(M, startX, startY);
@@ -3006,21 +3276,23 @@ var LeaferUI = (function (exports) {
3006
3276
  i += 3;
3007
3277
  switch (data[i]) {
3008
3278
  case L$1:
3009
- smooth.push(U, x, y, data[i + 1], data[i + 2], cornerRadius);
3279
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
3010
3280
  break;
3011
3281
  case Z:
3012
- smooth.push(U, x, y, startX, startY, cornerRadius);
3282
+ arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
3013
3283
  break;
3014
3284
  default:
3015
3285
  smooth.push(L$1, x, y);
3016
3286
  }
3287
+ lastX = x;
3288
+ lastY = y;
3017
3289
  break;
3018
3290
  case C:
3019
3291
  smooth.push(C, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
3020
3292
  i += 7;
3021
3293
  break;
3022
3294
  case Z:
3023
- smooth.push(U, startX, startY, centerX, centerY, cornerRadius);
3295
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3024
3296
  smooth.push(Z);
3025
3297
  i += 1;
3026
3298
  break;
@@ -3051,7 +3323,7 @@ var LeaferUI = (function (exports) {
3051
3323
  roundRect(drawer);
3052
3324
  }
3053
3325
 
3054
- const debug$8 = Debug.get('TaskProcessor');
3326
+ const debug$9 = Debug.get('TaskProcessor');
3055
3327
  class TaskItem {
3056
3328
  constructor(task) {
3057
3329
  this.parallel = true;
@@ -3066,7 +3338,7 @@ var LeaferUI = (function (exports) {
3066
3338
  yield this.task();
3067
3339
  }
3068
3340
  catch (error) {
3069
- debug$8.error(error);
3341
+ debug$9.error(error);
3070
3342
  }
3071
3343
  });
3072
3344
  }
@@ -3304,7 +3576,7 @@ var LeaferUI = (function (exports) {
3304
3576
  recycledList: [],
3305
3577
  tasker: new TaskProcessor(),
3306
3578
  patternTasker: new TaskProcessor(),
3307
- get isComplete() { return I$1.tasker.isComplete && I$1.patternTasker.isComplete; },
3579
+ get isComplete() { return I$1.tasker.isComplete; },
3308
3580
  get(config) {
3309
3581
  let image = I$1.map[config.url];
3310
3582
  if (!image) {
@@ -3635,16 +3907,6 @@ var LeaferUI = (function (exports) {
3635
3907
  return Object.getOwnPropertyNames(object);
3636
3908
  }
3637
3909
 
3638
- function aliasType(name) {
3639
- return (target, key) => {
3640
- defineKey(target, key, {
3641
- get() { return this.__getAttr(name); },
3642
- set(value) {
3643
- this.__setAttr(name, value);
3644
- }
3645
- });
3646
- };
3647
- }
3648
3910
  function defineLeafAttr(target, key, defaultValue, mergeDescriptor) {
3649
3911
  const defaultDescriptor = {
3650
3912
  get() { return this.__getAttr(key); },
@@ -3670,6 +3932,17 @@ var LeaferUI = (function (exports) {
3670
3932
  });
3671
3933
  };
3672
3934
  }
3935
+ function autoLayoutType(defaultValue) {
3936
+ return (target, key) => {
3937
+ defineLeafAttr(target, key, defaultValue, {
3938
+ set(value) {
3939
+ this.__setAttr(key, value);
3940
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3941
+ this.__hasAutoLayout = !!value;
3942
+ }
3943
+ });
3944
+ };
3945
+ }
3673
3946
  function scaleType(defaultValue) {
3674
3947
  return (target, key) => {
3675
3948
  defineLeafAttr(target, key, defaultValue, {
@@ -3696,7 +3969,7 @@ var LeaferUI = (function (exports) {
3696
3969
  set(value) {
3697
3970
  this.__setAttr(key, value);
3698
3971
  this.__layout.boxChanged || this.__layout.boxChange();
3699
- if (this.__.around)
3972
+ if (this.__hasAutoLayout)
3700
3973
  this.__layout.matrixChanged || this.__layout.matrixChange();
3701
3974
  }
3702
3975
  });
@@ -3818,9 +4091,6 @@ var LeaferUI = (function (exports) {
3818
4091
  function getSetMethodName(key) {
3819
4092
  return 'set' + key.charAt(0).toUpperCase() + key.slice(1);
3820
4093
  }
3821
- function setDefaultValue(target, key, defaultValue) {
3822
- defineDataProcessor(target.prototype, key, defaultValue);
3823
- }
3824
4094
  function defineDataProcessor(target, key, defaultValue) {
3825
4095
  const data = target.__DataProcessor.prototype;
3826
4096
  const computedKey = '_' + key;
@@ -3851,7 +4121,11 @@ var LeaferUI = (function (exports) {
3851
4121
  return v === undefined ? (this.__naturalHeight || defaultValue) : v;
3852
4122
  };
3853
4123
  }
3854
- const descriptor = getDescriptor(data, key);
4124
+ let descriptor, find = data;
4125
+ while (!descriptor && find) {
4126
+ descriptor = getDescriptor(find, key);
4127
+ find = find.__proto__;
4128
+ }
3855
4129
  if (descriptor && descriptor.set)
3856
4130
  property.set = descriptor.set;
3857
4131
  if (data[setMethodName]) {
@@ -3861,7 +4135,7 @@ var LeaferUI = (function (exports) {
3861
4135
  Object.defineProperty(data, key, property);
3862
4136
  }
3863
4137
 
3864
- const debug$7 = new Debug('rewrite');
4138
+ const debug$8 = new Debug('rewrite');
3865
4139
  const list$1 = [];
3866
4140
  const excludeNames = ['destroy', 'constructor'];
3867
4141
  function rewrite(method) {
@@ -3878,7 +4152,7 @@ var LeaferUI = (function (exports) {
3878
4152
  if (list$1.length) {
3879
4153
  list$1.forEach(item => {
3880
4154
  if (error)
3881
- debug$7.error(item.name, '需在Class上装饰@rewriteAble()');
4155
+ debug$8.error(item.name, '需在Class上装饰@rewriteAble()');
3882
4156
  item.run();
3883
4157
  });
3884
4158
  list$1.length = 0;
@@ -4121,17 +4395,43 @@ var LeaferUI = (function (exports) {
4121
4395
  }
4122
4396
  }
4123
4397
 
4124
- const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter } = MatrixHelper;
4125
- const matrix = {};
4398
+ const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$1, divideParent, getLayout } = MatrixHelper;
4399
+ const matrix$1 = {};
4126
4400
  const LeafHelper = {
4127
- updateAllWorldMatrix(leaf) {
4128
- leaf.__updateWorldMatrix();
4401
+ updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4402
+ if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
4403
+ waitAutoLayout = true;
4404
+ updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
4129
4405
  if (leaf.isBranch) {
4130
4406
  const { children } = leaf;
4131
4407
  for (let i = 0, len = children.length; i < len; i++) {
4132
- updateAllWorldMatrix$2(children[i]);
4408
+ updateAllMatrix$3(children[i], checkAutoLayout, waitAutoLayout);
4409
+ }
4410
+ }
4411
+ },
4412
+ updateMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4413
+ const layout = leaf.__layout;
4414
+ if (checkAutoLayout) {
4415
+ if (waitAutoLayout) {
4416
+ layout.waitAutoLayout = true;
4417
+ if (leaf.__hasAutoLayout)
4418
+ layout.matrixChanged = false;
4133
4419
  }
4134
4420
  }
4421
+ else if (layout.waitAutoLayout) {
4422
+ layout.waitAutoLayout = false;
4423
+ }
4424
+ if (layout.matrixChanged)
4425
+ leaf.__updateLocalMatrix();
4426
+ if (!layout.waitAutoLayout)
4427
+ leaf.__updateWorldMatrix();
4428
+ },
4429
+ updateBounds(leaf) {
4430
+ const layout = leaf.__layout;
4431
+ if (layout.boundsChanged)
4432
+ leaf.__updateLocalBounds();
4433
+ if (!layout.waitAutoLayout)
4434
+ leaf.__updateWorldBounds();
4135
4435
  },
4136
4436
  updateAllWorldOpacity(leaf) {
4137
4437
  leaf.__updateWorldOpacity();
@@ -4173,62 +4473,78 @@ var LeaferUI = (function (exports) {
4173
4473
  t.x += x;
4174
4474
  t.y += y;
4175
4475
  },
4176
- zoomOfWorld(t, origin, scaleX, scaleY) {
4177
- this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY);
4476
+ zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4477
+ this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
4178
4478
  },
4179
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX) {
4180
- copy$5(matrix, t.__local);
4181
- scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4182
- moveByMatrix(t, matrix);
4183
- t.scaleX *= scaleX;
4184
- t.scaleY *= scaleY;
4479
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4480
+ copy$5(matrix$1, t.__localMatrix);
4481
+ scaleOfOuter$3(matrix$1, origin, scaleX, scaleY);
4482
+ moveByMatrix(t, matrix$1);
4483
+ t.scaleResize(scaleX, scaleY, resize !== true);
4185
4484
  },
4186
4485
  rotateOfWorld(t, origin, angle) {
4187
4486
  this.rotateOfLocal(t, getTempLocal(t, origin), angle);
4188
4487
  },
4189
4488
  rotateOfLocal(t, origin, angle) {
4190
- copy$5(matrix, t.__local);
4191
- rotateOfOuter$3(matrix, origin, angle);
4192
- moveByMatrix(t, matrix);
4489
+ copy$5(matrix$1, t.__localMatrix);
4490
+ rotateOfOuter$3(matrix$1, origin, angle);
4491
+ moveByMatrix(t, matrix$1);
4193
4492
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
4194
4493
  },
4195
- skewOfWorld(t, origin, skewX, skewY) {
4196
- this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY);
4494
+ skewOfWorld(t, origin, skewX, skewY, resize) {
4495
+ this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
4496
+ },
4497
+ skewOfLocal(t, origin, skewX, skewY = 0, resize) {
4498
+ copy$5(matrix$1, t.__localMatrix);
4499
+ skewOfOuter(matrix$1, origin, skewX, skewY);
4500
+ L.setTransform(t, matrix$1, resize);
4501
+ },
4502
+ transform(t, transform, resize) {
4503
+ copy$5(matrix$1, t.localTransform);
4504
+ multiplyParent$1(matrix$1, transform);
4505
+ L.setTransform(t, matrix$1, resize);
4197
4506
  },
4198
- skewOfLocal(t, origin, skewX, skewY) {
4199
- copy$5(matrix, t.__local);
4200
- skewOfOuter(matrix, origin, skewX, skewY);
4201
- moveByMatrix(t, matrix);
4202
- t.skewX = MathHelper.formatSkew(t.skewX + skewX);
4203
- t.skewY = MathHelper.formatSkew(t.skewY + skewY);
4507
+ setTransform(t, transform, resize) {
4508
+ const layout = getLayout(transform);
4509
+ if (resize) {
4510
+ t.scaleResize(layout.scaleX / t.scaleX, layout.scaleY / t.scaleY, resize !== true);
4511
+ delete layout.scaleX;
4512
+ delete layout.scaleY;
4513
+ }
4514
+ t.set(layout);
4204
4515
  },
4205
- drop(t, parent) {
4206
- const position = { x: t.x, y: t.y };
4207
- t.localToWorld(position);
4208
- parent.worldToInner(position);
4209
- t.set(position);
4210
- parent.add(t);
4516
+ drop(t, parent, index, resize) {
4517
+ copy$5(matrix$1, t.worldTransform);
4518
+ divideParent(matrix$1, parent.worldTransform);
4519
+ t.setTransform(matrix$1, resize);
4520
+ parent.add(t, index);
4211
4521
  },
4212
- hasParent(t, parent) {
4522
+ hasParent(p, parent) {
4213
4523
  if (!parent)
4214
4524
  return false;
4215
- let p = t;
4216
4525
  while (p) {
4217
4526
  if (parent === p)
4218
4527
  return true;
4219
4528
  p = p.parent;
4220
4529
  }
4221
- return false;
4530
+ },
4531
+ hasParentAutoLayout(p) {
4532
+ while (p.parent) {
4533
+ p = p.parent;
4534
+ if (p.__hasAutoLayout)
4535
+ return true;
4536
+ }
4222
4537
  }
4223
4538
  };
4224
4539
  const L = LeafHelper;
4225
- const { updateAllWorldMatrix: updateAllWorldMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4540
+ const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4226
4541
  function moveByMatrix(t, matrix) {
4227
- t.x += matrix.e - t.__local.e;
4228
- t.y += matrix.f - t.__local.f;
4542
+ const { e, f } = t.__localMatrix;
4543
+ t.x += matrix.e - e;
4544
+ t.y += matrix.f - f;
4229
4545
  }
4230
4546
  function getTempLocal(t, world) {
4231
- t.__layout.checkUpdate();
4547
+ t.__layout.update();
4232
4548
  return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
4233
4549
  }
4234
4550
 
@@ -4237,18 +4553,18 @@ var LeaferUI = (function (exports) {
4237
4553
  return target.__world;
4238
4554
  },
4239
4555
  localBoxBounds(target) {
4240
- return target.__.isEraser ? null : target.__local;
4556
+ return target.__.isEraser ? null : (target.__local || target.__);
4241
4557
  },
4242
- localEventBounds(target) {
4558
+ localStrokeBounds(target) {
4243
4559
  return target.__.isEraser ? null : target.__layout.localStrokeBounds;
4244
4560
  },
4245
4561
  localRenderBounds(target) {
4246
4562
  return target.__.isEraser ? null : target.__layout.localRenderBounds;
4247
4563
  },
4248
4564
  maskLocalBoxBounds(target) {
4249
- return target.__.isMask ? target.__local : null;
4565
+ return target.__.isMask ? target.__localBounds : null;
4250
4566
  },
4251
- maskLocalEventBounds(target) {
4567
+ maskLocalStrokeBounds(target) {
4252
4568
  return target.__.isMask ? target.__layout.localStrokeBounds : null;
4253
4569
  },
4254
4570
  maskLocalRenderBounds(target) {
@@ -4256,11 +4572,12 @@ var LeaferUI = (function (exports) {
4256
4572
  }
4257
4573
  };
4258
4574
 
4575
+ const { updateBounds: updateBounds$2 } = LeafHelper;
4259
4576
  const BranchHelper = {
4260
4577
  sort(a, b) {
4261
4578
  return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
4262
4579
  },
4263
- pushAllChildBranch(branch, pushList) {
4580
+ pushAllChildBranch(branch, leafList) {
4264
4581
  branch.__tempNumber = 1;
4265
4582
  if (branch.__.__childBranchNumber) {
4266
4583
  const { children } = branch;
@@ -4268,18 +4585,18 @@ var LeaferUI = (function (exports) {
4268
4585
  branch = children[i];
4269
4586
  if (branch.isBranch) {
4270
4587
  branch.__tempNumber = 1;
4271
- pushList.push(branch);
4272
- pushAllChildBranch$1(branch, pushList);
4588
+ leafList.add(branch);
4589
+ pushAllChildBranch$1(branch, leafList);
4273
4590
  }
4274
4591
  }
4275
4592
  }
4276
4593
  },
4277
- pushAllParent(leaf, pushList) {
4278
- const { keys } = pushList;
4594
+ pushAllParent(leaf, leafList) {
4595
+ const { keys } = leafList;
4279
4596
  if (keys) {
4280
4597
  while (leaf.parent) {
4281
4598
  if (keys[leaf.parent.innerId] === undefined) {
4282
- pushList.push(leaf.parent);
4599
+ leafList.add(leaf.parent);
4283
4600
  leaf = leaf.parent;
4284
4601
  }
4285
4602
  else {
@@ -4289,7 +4606,7 @@ var LeaferUI = (function (exports) {
4289
4606
  }
4290
4607
  else {
4291
4608
  while (leaf.parent) {
4292
- pushList.push(leaf.parent);
4609
+ leafList.add(leaf.parent);
4293
4610
  leaf = leaf.parent;
4294
4611
  }
4295
4612
  }
@@ -4303,21 +4620,29 @@ var LeaferUI = (function (exports) {
4303
4620
  }
4304
4621
  }
4305
4622
  for (let i = start, len = pushList.length; i < len; i++) {
4306
- pushAllBranchStack$1(pushList[i], pushList);
4623
+ pushAllBranchStack(pushList[i], pushList);
4307
4624
  }
4308
4625
  },
4309
- updateWorldBoundsByBranchStack(branchStack) {
4310
- let branch;
4626
+ updateBounds(branch, exclude) {
4627
+ const branchStack = [branch];
4628
+ pushAllBranchStack(branch, branchStack);
4629
+ updateBoundsByBranchStack(branchStack, exclude);
4630
+ },
4631
+ updateBoundsByBranchStack(branchStack, exclude) {
4632
+ let branch, children;
4311
4633
  for (let i = branchStack.length - 1; i > -1; i--) {
4312
4634
  branch = branchStack[i];
4313
- for (let j = 0, len = branch.children.length; j < len; j++) {
4314
- branch.children[j].__updateWorldBounds();
4635
+ children = branch.children;
4636
+ for (let j = 0, len = children.length; j < len; j++) {
4637
+ updateBounds$2(children[j]);
4315
4638
  }
4639
+ if (exclude && exclude === branch)
4640
+ continue;
4641
+ updateBounds$2(branch);
4316
4642
  }
4317
- branch.__updateWorldBounds();
4318
4643
  }
4319
4644
  };
4320
- const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack: pushAllBranchStack$1 } = BranchHelper;
4645
+ const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack, updateBoundsByBranchStack } = BranchHelper;
4321
4646
 
4322
4647
  const WaitHelper = {
4323
4648
  run(wait) {
@@ -4385,7 +4710,7 @@ var LeaferUI = (function (exports) {
4385
4710
  const { list } = path;
4386
4711
  for (let i = 0, len = list.length; i < len; i++) {
4387
4712
  if (list[i].hasEvent(type))
4388
- find.push(list[i]);
4713
+ find.add(list[i]);
4389
4714
  }
4390
4715
  return find;
4391
4716
  }
@@ -4402,7 +4727,8 @@ var LeaferUI = (function (exports) {
4402
4727
  this.dragData = getDragEventData(data, data, data);
4403
4728
  }
4404
4729
  getList() {
4405
- return this.dragging ? (exports.DragEvent.list || this.interaction.selector.list || this.dragableList || emptyList) : emptyList;
4730
+ const { proxy } = this.interaction.selector;
4731
+ return this.dragging && (!proxy || !proxy.list.length) ? (exports.DragEvent.list || this.dragableList || emptyList) : emptyList;
4406
4732
  }
4407
4733
  checkDrag(data, canDrag) {
4408
4734
  const { interaction } = this;
@@ -4413,8 +4739,7 @@ var LeaferUI = (function (exports) {
4413
4739
  }
4414
4740
  const { dragData } = this;
4415
4741
  if (!this.moving) {
4416
- const moveOnDragEmpty = interaction.config.move.dragEmpty && downData.target.isLeafer;
4417
- this.moving = (PointerButton.middle(data) || interaction.moveMode || moveOnDragEmpty) && canDrag;
4742
+ this.moving = (PointerButton.middle(data) || interaction.moveMode) && canDrag;
4418
4743
  if (this.moving)
4419
4744
  interaction.emit(exports.MoveEvent.START, dragData);
4420
4745
  }
@@ -4449,7 +4774,7 @@ var LeaferUI = (function (exports) {
4449
4774
  let leaf;
4450
4775
  for (let i = 0, len = path.length; i < len; i++) {
4451
4776
  leaf = path.list[i];
4452
- if (leaf.__.draggable && leaf.__.hitSelf) {
4777
+ if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf) {
4453
4778
  this.dragableList = new LeafList(leaf);
4454
4779
  break;
4455
4780
  }
@@ -4460,9 +4785,7 @@ var LeaferUI = (function (exports) {
4460
4785
  const list = this.getList();
4461
4786
  if (list.length && running) {
4462
4787
  const { moveX, moveY } = this.dragData;
4463
- list.forEach(leaf => {
4464
- LeafHelper.moveWorld(leaf, moveX, moveY);
4465
- });
4788
+ list.forEach(leaf => LeafHelper.moveWorld(leaf, moveX, moveY));
4466
4789
  }
4467
4790
  }
4468
4791
  dragOverOrOut(data) {
@@ -4540,8 +4863,8 @@ var LeaferUI = (function (exports) {
4540
4863
  return;
4541
4864
  const bounds = interaction.shrinkCanvasBounds;
4542
4865
  const { x, y } = bounds;
4543
- const right = BoundsHelper.right(bounds);
4544
- const bottom = BoundsHelper.bottom(bounds);
4866
+ const right = BoundsHelper.maxX(bounds);
4867
+ const bottom = BoundsHelper.maxY(bounds);
4545
4868
  const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
4546
4869
  const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
4547
4870
  let totalX = 0, totalY = 0;
@@ -4565,6 +4888,7 @@ var LeaferUI = (function (exports) {
4565
4888
  }
4566
4889
  }
4567
4890
 
4891
+ const debug$7 = Debug.get('emit');
4568
4892
  function emit$1(type, data, path, excludePath) {
4569
4893
  if (!path && !data.path)
4570
4894
  return;
@@ -4577,24 +4901,29 @@ var LeaferUI = (function (exports) {
4577
4901
  path = data.path;
4578
4902
  }
4579
4903
  data.target = path.indexAt(0);
4580
- for (let i = path.length - 1; i > -1; i--) {
4581
- leaf = path.list[i];
4582
- if (emitEvent(leaf, type, data, true, excludePath))
4583
- return;
4584
- if (leaf.isApp)
4585
- emitAppChildren(leaf, type, data, true, excludePath);
4586
- }
4587
- for (let i = 0, len = path.length; i < len; i++) {
4588
- leaf = path.list[i];
4589
- if (leaf.isApp)
4590
- emitAppChildren(leaf, type, data, false, excludePath);
4591
- if (emitEvent(leaf, type, data, false, excludePath))
4592
- return;
4593
- }
4594
- }
4595
- const allowTypes = ['move', 'zoom', 'rotate', 'key'];
4596
- function emitAppChildren(leaf, type, data, capture, excludePath) {
4597
- if (allowTypes.some(name => type.startsWith(name)) && leaf.__.hitChildren && !exclude(leaf, excludePath)) {
4904
+ try {
4905
+ for (let i = path.length - 1; i > -1; i--) {
4906
+ leaf = path.list[i];
4907
+ if (emitEvent(leaf, type, data, true, excludePath))
4908
+ return;
4909
+ if (leaf.isApp)
4910
+ emitAppChildren(leaf, type, data, true, excludePath);
4911
+ }
4912
+ for (let i = 0, len = path.length; i < len; i++) {
4913
+ leaf = path.list[i];
4914
+ if (leaf.isApp)
4915
+ emitAppChildren(leaf, type, data, false, excludePath);
4916
+ if (emitEvent(leaf, type, data, false, excludePath))
4917
+ return;
4918
+ }
4919
+ }
4920
+ catch (e) {
4921
+ debug$7.error(e);
4922
+ }
4923
+ }
4924
+ const allowTypes = ['move', 'zoom', 'rotate', 'key'];
4925
+ function emitAppChildren(leaf, type, data, capture, excludePath) {
4926
+ if (allowTypes.some(name => type.startsWith(name)) && leaf.__.hitChildren && !exclude(leaf, excludePath)) {
4598
4927
  let child;
4599
4928
  for (let i = 0, len = leaf.children.length; i < len; i++) {
4600
4929
  child = leaf.children[i];
@@ -4629,39 +4958,42 @@ var LeaferUI = (function (exports) {
4629
4958
  const lastDistance = PointHelper.getDistance(a.from, b.from);
4630
4959
  const distance = PointHelper.getDistance(a.to, b.to);
4631
4960
  const scale = distance / lastDistance;
4632
- const angle = PointHelper.getChangeAngle(a.from, b.from, a.to, b.to);
4961
+ const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
4633
4962
  return { move, scale, angle, center };
4634
4963
  }
4635
4964
  };
4636
4965
 
4966
+ const config = {
4967
+ wheel: {
4968
+ zoomMode: false,
4969
+ zoomSpeed: 0.5,
4970
+ moveSpeed: 0.5,
4971
+ rotateSpeed: 0.5,
4972
+ delta: Platform.os === 'Windows' ? { x: 150 / 4, y: 150 / 4 } : { x: 80 / 4, y: 8.0 },
4973
+ preventDefault: true
4974
+ },
4975
+ pointer: {
4976
+ hitRadius: 5,
4977
+ through: false,
4978
+ tapTime: 120,
4979
+ longPressTime: 800,
4980
+ transformTime: 500,
4981
+ dragHover: true,
4982
+ dragDistance: 2,
4983
+ swipeDistance: 20,
4984
+ ignoreMove: false
4985
+ },
4986
+ cursor: {}
4987
+ };
4988
+
4637
4989
  const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1 } = InteractionHelper;
4638
4990
  class InteractionBase {
4639
4991
  get dragging() { return this.dragger.dragging; }
4640
- get moveMode() { return (Keyboard.isHoldSpaceKey() && this.config.move.holdSpaceKey) || (this.downData && PointerButton.middle(this.downData)); }
4992
+ get isDragEmpty() { return this.config.move.dragEmpty && (this.hoverData && this.hoverData.path.list[0].isLeafer) && (!this.downData || this.downData.path.list[0].isLeafer); }
4993
+ get moveMode() { return this.config.move.drag || (this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey()) || (this.downData && PointerButton.middle(this.downData)) || this.isDragEmpty; }
4641
4994
  get hitRadius() { return this.config.pointer.hitRadius; }
4642
4995
  constructor(target, canvas, selector, userConfig) {
4643
- this.config = {
4644
- wheel: {
4645
- zoomMode: false,
4646
- zoomSpeed: 0.5,
4647
- moveSpeed: 0.5,
4648
- rotateSpeed: 0.5,
4649
- delta: Platform.os === 'Windows' ? { x: 150 / 4, y: 150 / 4 } : { x: 80 / 4, y: 8.0 },
4650
- preventDefault: true
4651
- },
4652
- pointer: {
4653
- hitRadius: 5,
4654
- through: false,
4655
- tapTime: 120,
4656
- longPressTime: 800,
4657
- transformTime: 500,
4658
- dragHover: true,
4659
- dragDistance: 2,
4660
- swipeDistance: 20,
4661
- ignoreMove: false
4662
- },
4663
- cursor: {}
4664
- };
4996
+ this.config = config;
4665
4997
  this.tapCount = 0;
4666
4998
  this.downKeyMap = {};
4667
4999
  this.target = target;
@@ -4687,10 +5019,10 @@ var LeaferUI = (function (exports) {
4687
5019
  if (!data)
4688
5020
  return;
4689
5021
  PointerButton.defaultLeft(data);
4690
- this.emit(exports.PointerEvent.BEFORE_DOWN, data, this.defaultPath);
4691
5022
  this.updateDownData(data);
4692
5023
  if (useDefaultPath)
4693
5024
  data.path = this.defaultPath;
5025
+ this.emit(exports.PointerEvent.BEFORE_DOWN, data);
4694
5026
  this.emit(exports.PointerEvent.DOWN, data);
4695
5027
  this.downTime = Date.now();
4696
5028
  this.dragger.setDragData(data);
@@ -4721,7 +5053,8 @@ var LeaferUI = (function (exports) {
4721
5053
  const canDrag = PointHelper.getDistance(this.downData, data) > this.config.pointer.dragDistance;
4722
5054
  if (this.waitTap && canDrag)
4723
5055
  this.pointerWaitCancel();
4724
- this.dragger.checkDrag(data, canDrag);
5056
+ if (!PointerButton.right(this.downData))
5057
+ this.dragger.checkDrag(data, canDrag);
4725
5058
  }
4726
5059
  if (this.dragger.moving || this.config.pointer.ignoreMove)
4727
5060
  return;
@@ -4741,8 +5074,8 @@ var LeaferUI = (function (exports) {
4741
5074
  if (!this.downData)
4742
5075
  return;
4743
5076
  PointerButton.defaultLeft(data);
4744
- this.emit(exports.PointerEvent.BEFORE_UP, data, this.defaultPath);
4745
5077
  this.findPath(data);
5078
+ this.emit(exports.PointerEvent.BEFORE_UP, data);
4746
5079
  this.emit(exports.PointerEvent.UP, data);
4747
5080
  this.emit(exports.PointerEvent.UP, this.downData, undefined, data.path);
4748
5081
  this.touchLeave(data);
@@ -5002,20 +5335,27 @@ var LeaferUI = (function (exports) {
5002
5335
  }
5003
5336
  Cursor.custom = {};
5004
5337
 
5005
- const { toOuterOf: toOuterOf$1 } = BoundsHelper;
5338
+ const { toOuterOf: toOuterOf$1, getPoints } = BoundsHelper;
5006
5339
  class LeafLayout {
5340
+ get a() { return 1; }
5341
+ get b() { return 0; }
5342
+ get c() { return 0; }
5343
+ get d() { return 1; }
5344
+ get e() { return this.leaf.__.x; }
5345
+ get f() { return this.leaf.__.y; }
5007
5346
  constructor(leaf) {
5008
5347
  this.leaf = leaf;
5009
5348
  this.renderBounds = this.strokeBounds = this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
5010
- this.localRenderBounds = this.localStrokeBounds = leaf.__local;
5349
+ if (leaf.__local)
5350
+ this.localRenderBounds = this.localStrokeBounds = leaf.__local;
5011
5351
  this.boxChange();
5012
5352
  this.matrixChange();
5013
5353
  }
5014
- checkUpdate(force) {
5354
+ update() {
5015
5355
  const { leafer } = this.leaf;
5016
5356
  if (leafer) {
5017
5357
  if (leafer.ready) {
5018
- if ((Platform.realtimeLayout || force) && leafer.watcher.changed)
5358
+ if (leafer.watcher.changed)
5019
5359
  leafer.layouter.layout();
5020
5360
  }
5021
5361
  else {
@@ -5024,59 +5364,141 @@ var LeaferUI = (function (exports) {
5024
5364
  }
5025
5365
  else {
5026
5366
  let root = this.leaf;
5027
- while (root.parent) {
5367
+ while (root.parent && !root.parent.leafer) {
5028
5368
  root = root.parent;
5029
5369
  }
5030
5370
  Platform.layout(root);
5031
5371
  }
5032
5372
  }
5033
- getTransform(locationType) {
5034
- this.checkUpdate();
5035
- return locationType === 'world' ? this.leaf.__world : this.leaf.__local;
5036
- }
5037
- getBounds(type, locationType) {
5038
- this.checkUpdate();
5039
- if (locationType === 'world') {
5040
- switch (type) {
5041
- case 'render':
5042
- return this.leaf.__world;
5043
- case 'content':
5044
- if (this.contentBounds)
5045
- return this.getWorldContentBounds();
5046
- case 'margin':
5047
- case 'box':
5048
- return this.getWorldBoxBounds();
5049
- case 'margin':
5050
- case 'stroke':
5051
- return this.getWorldStrokeBounds();
5052
- }
5053
- }
5054
- else if (locationType === 'inner') {
5055
- switch (type) {
5056
- case 'render':
5057
- return this.renderBounds;
5058
- case 'content':
5059
- if (this.contentBounds)
5060
- return this.contentBounds;
5061
- case 'margin':
5062
- case 'box':
5063
- return this.boxBounds;
5064
- case 'stroke':
5065
- return this.strokeBounds;
5066
- }
5067
- }
5068
- else {
5069
- switch (type) {
5070
- case 'render':
5373
+ getTransform(relative = 'world') {
5374
+ this.update();
5375
+ switch (relative) {
5376
+ case 'world':
5377
+ return this.leaf.__world;
5378
+ case 'local':
5379
+ return this.leaf.__localMatrix;
5380
+ case 'inner':
5381
+ return MatrixHelper.defaultMatrix;
5382
+ default:
5383
+ return new Matrix(this.leaf.__world).divideParent(relative.__world);
5384
+ }
5385
+ }
5386
+ getBounds(type, relative = 'world') {
5387
+ this.update();
5388
+ switch (relative) {
5389
+ case 'world':
5390
+ return this.getWorldBounds(type);
5391
+ case 'local':
5392
+ return this.getLocalBounds(type);
5393
+ case 'inner':
5394
+ return this.getInnerBounds(type);
5395
+ default:
5396
+ return new Bounds(this.getInnerBounds(type)).toOuterOf(this.getTransform(relative));
5397
+ }
5398
+ }
5399
+ getInnerBounds(type = 'box') {
5400
+ switch (type) {
5401
+ case 'render':
5402
+ return this.renderBounds;
5403
+ case 'content':
5404
+ if (this.contentBounds)
5405
+ return this.contentBounds;
5406
+ case 'margin':
5407
+ case 'box':
5408
+ return this.boxBounds;
5409
+ case 'stroke':
5410
+ return this.strokeBounds;
5411
+ }
5412
+ }
5413
+ getLocalBounds(type = 'box') {
5414
+ switch (type) {
5415
+ case 'render':
5416
+ if (this.localRenderBounds)
5071
5417
  return this.localRenderBounds;
5072
- case 'margin':
5073
- case 'content':
5074
- case 'box':
5075
- return this.leaf.__local;
5076
- case 'stroke':
5418
+ case 'stroke':
5419
+ if (this.localStrokeBounds)
5077
5420
  return this.localStrokeBounds;
5078
- }
5421
+ case 'margin':
5422
+ case 'content':
5423
+ case 'box':
5424
+ return this.leaf.__localBounds;
5425
+ }
5426
+ }
5427
+ getWorldBounds(type = 'box') {
5428
+ switch (type) {
5429
+ case 'render':
5430
+ return this.leaf.__world;
5431
+ case 'content':
5432
+ if (this.contentBounds)
5433
+ return this.getWorldContentBounds();
5434
+ case 'margin':
5435
+ case 'box':
5436
+ return this.getWorldBoxBounds();
5437
+ case 'margin':
5438
+ case 'stroke':
5439
+ return this.getWorldStrokeBounds();
5440
+ }
5441
+ }
5442
+ getLayoutBounds(type, relative = 'world', unscale) {
5443
+ const { leaf } = this;
5444
+ let point, layout;
5445
+ let bounds = this.getInnerBounds(type);
5446
+ switch (relative) {
5447
+ case 'world':
5448
+ point = leaf.getWorldPoint(bounds);
5449
+ layout = leaf.__world;
5450
+ break;
5451
+ case 'local':
5452
+ point = leaf.getLocalPointByInner(bounds);
5453
+ layout = leaf.__;
5454
+ break;
5455
+ case 'inner':
5456
+ point = bounds;
5457
+ layout = MatrixHelper.defaultWorld;
5458
+ break;
5459
+ default:
5460
+ point = leaf.getWorldPoint(bounds, relative);
5461
+ layout = leaf.__world;
5462
+ }
5463
+ let { scaleX, scaleY, rotation, skewX, skewY } = layout;
5464
+ let { width, height } = bounds;
5465
+ if (typeof relative === 'object') {
5466
+ const r = relative.__world;
5467
+ scaleX /= r.scaleX;
5468
+ scaleY /= r.scaleY;
5469
+ rotation -= r.rotation;
5470
+ skewX -= r.skewX;
5471
+ skewY -= r.skewY;
5472
+ }
5473
+ if (unscale) {
5474
+ const uScaleX = scaleX < 0 ? -scaleX : scaleX;
5475
+ const uScaleY = scaleY < 0 ? -scaleY : scaleY;
5476
+ scaleX /= uScaleX;
5477
+ scaleY /= uScaleY;
5478
+ width *= uScaleX;
5479
+ height *= uScaleY;
5480
+ }
5481
+ return { x: point.x, y: point.y, scaleX, scaleY, rotation, skewX, skewY, width, height };
5482
+ }
5483
+ getLayoutPoints(type, relative = 'world') {
5484
+ const { leaf } = this;
5485
+ const points = getPoints(this.getInnerBounds(type));
5486
+ let relativeLeaf;
5487
+ switch (relative) {
5488
+ case 'world':
5489
+ relativeLeaf = null;
5490
+ break;
5491
+ case 'local':
5492
+ relativeLeaf = leaf.parent;
5493
+ break;
5494
+ case 'inner':
5495
+ break;
5496
+ default:
5497
+ relativeLeaf = relative;
5079
5498
  }
5499
+ if (relativeLeaf !== undefined)
5500
+ points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
5501
+ return points;
5080
5502
  }
5081
5503
  getWorldContentBounds() {
5082
5504
  this._worldContentBounds || (this._worldContentBounds = {});
@@ -5096,7 +5518,7 @@ var LeaferUI = (function (exports) {
5096
5518
  spreadStrokeCancel() {
5097
5519
  const same = this.renderBounds === this.strokeBounds;
5098
5520
  this.strokeBounds = this.boxBounds;
5099
- this.localStrokeBounds = this.leaf.__local;
5521
+ this.localStrokeBounds = this.leaf.__localBounds;
5100
5522
  if (same)
5101
5523
  this.spreadRenderCancel();
5102
5524
  }
@@ -5223,13 +5645,13 @@ var LeaferUI = (function (exports) {
5223
5645
  if (bind)
5224
5646
  listener = listener.bind(bind);
5225
5647
  this.on(type, listener, options);
5226
- return { type, listener, options };
5648
+ return { type, current: this, listener, options };
5227
5649
  },
5228
5650
  off_(id) {
5229
5651
  if (!id)
5230
5652
  return;
5231
5653
  const list = id instanceof Array ? id : [id];
5232
- list.forEach(item => this.off(item.type, item.listener, item.options));
5654
+ list.forEach(item => item.current.off(item.type, item.listener, item.options));
5233
5655
  list.length = 0;
5234
5656
  },
5235
5657
  once(type, listener, capture) {
@@ -5295,7 +5717,7 @@ var LeaferUI = (function (exports) {
5295
5717
  const oldValue = this.__.__getInput(name);
5296
5718
  if (typeof newValue === 'object' || oldValue !== newValue) {
5297
5719
  this.__[name] = newValue;
5298
- if (this.proxyData)
5720
+ if (this.__proxyData)
5299
5721
  this.setProxyAttr(name, newValue);
5300
5722
  const { CHANGE } = PropertyEvent;
5301
5723
  const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
@@ -5306,191 +5728,121 @@ var LeaferUI = (function (exports) {
5306
5728
  }
5307
5729
  else {
5308
5730
  this.__[name] = newValue;
5309
- if (this.proxyData)
5731
+ if (this.__proxyData)
5310
5732
  this.setProxyAttr(name, newValue);
5311
5733
  }
5312
5734
  },
5313
5735
  __getAttr(name) {
5314
- if (this.proxyData)
5736
+ if (this.__proxyData)
5315
5737
  return this.getProxyAttr(name);
5316
5738
  return this.__.__get(name);
5317
- },
5318
- setProxyAttr(name, newValue) {
5319
- if (this.proxyData[name] !== newValue)
5320
- this.proxyData[name] = newValue;
5321
- },
5322
- getProxyAttr(name) {
5323
- return this.proxyData[name];
5324
5739
  }
5325
5740
  };
5326
5741
 
5327
- const { sin: sin$2, cos: cos$2 } = Math;
5328
- const defaultWorld = Object.assign(Object.assign({}, MatrixHelper.defaultMatrix), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
5329
- const defaultCenter = { x: 0.5, y: 0.5 };
5742
+ const { setLayout, multiplyParent, translateInner, defaultWorld } = MatrixHelper;
5743
+ const { toPoint, tempPoint } = AroundHelper;
5330
5744
  const LeafMatrix = {
5331
5745
  __updateWorldMatrix() {
5332
- const pw = this.parent ? this.parent.__world : defaultWorld;
5333
- const r = this.__local;
5334
- const w = this.__world;
5335
- if (this.__layout.matrixChanged)
5336
- this.__updateLocalMatrix();
5337
- if (this.__layout.affectScaleOrRotation) {
5338
- w.a = r.a * pw.a + r.b * pw.c;
5339
- w.b = r.a * pw.b + r.b * pw.d;
5340
- w.c = r.c * pw.a + r.d * pw.c;
5341
- w.d = r.c * pw.b + r.d * pw.d;
5342
- w.e = r.e * pw.a + r.f * pw.c + pw.e;
5343
- w.f = r.e * pw.b + r.f * pw.d + pw.f;
5344
- const data = this.__;
5345
- w.scaleX = pw.scaleX * data.scaleX;
5346
- w.scaleY = pw.scaleY * data.scaleY;
5347
- w.rotation = pw.rotation + data.rotation;
5348
- w.skewX = pw.skewX + data.skewX;
5349
- w.skewY = pw.skewY + data.skewY;
5350
- }
5351
- else {
5352
- w.a = pw.a;
5353
- w.b = pw.b;
5354
- w.c = pw.c;
5355
- w.d = pw.d;
5356
- w.e = r.e * pw.a + r.f * pw.c + pw.e;
5357
- w.f = r.e * pw.b + r.f * pw.d + pw.f;
5358
- w.scaleX = pw.scaleX;
5359
- w.scaleY = pw.scaleY;
5360
- w.rotation = pw.rotation;
5361
- w.skewX = pw.skewX;
5362
- w.skewY = pw.skewY;
5363
- }
5746
+ multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
5364
5747
  },
5365
5748
  __updateLocalMatrix() {
5366
- const r = this.__local;
5367
- const layout = this.__layout;
5368
- if (layout.affectScaleOrRotation) {
5369
- const { scaleX, scaleY } = this.__;
5370
- if (layout.affectRotation) {
5749
+ if (this.__local) {
5750
+ const layout = this.__layout, local = this.__local, data = this.__;
5751
+ if (layout.affectScaleOrRotation) {
5371
5752
  if (layout.scaleChanged || layout.rotationChanged) {
5372
- let { rotation, skewX, skewY } = this.__;
5373
- if (rotation || skewX || skewY) {
5374
- rotation *= OneRadian;
5375
- if (skewX)
5376
- skewX *= OneRadian;
5377
- if (skewY)
5378
- skewY *= OneRadian;
5379
- r.a = scaleX * cos$2(rotation + skewY);
5380
- r.b = scaleX * sin$2(rotation + skewY);
5381
- r.c = scaleY * -sin$2(rotation - skewX);
5382
- r.d = scaleY * cos$2(rotation - skewX);
5383
- }
5384
- else {
5385
- r.a = scaleX;
5386
- r.b = 0;
5387
- r.c = 0;
5388
- r.d = scaleY;
5389
- layout.affectRotation = false;
5390
- }
5391
- layout.scaleChanged = false;
5392
- layout.rotationChanged = false;
5393
- }
5394
- }
5395
- else {
5396
- if (layout.scaleChanged) {
5397
- r.a = scaleX;
5398
- r.d = scaleY;
5399
- layout.scaleChanged = false;
5753
+ setLayout(local, data, null, layout.affectRotation);
5754
+ layout.scaleChanged = layout.rotationChanged = false;
5400
5755
  }
5401
5756
  }
5402
- }
5403
- const { x, y, around } = this.__;
5404
- r.e = x;
5405
- r.f = y;
5406
- if (around) {
5407
- const { width, height } = this.__;
5408
- if (width && height) {
5409
- const origin = (around === 'center') ? defaultCenter : around;
5410
- const offsetX = width * origin.x, offsetY = height * origin.y;
5411
- r.e -= offsetX * r.a + offsetY * r.c;
5412
- r.f -= offsetX * r.b + offsetY * r.d;
5757
+ local.e = data.x;
5758
+ local.f = data.y;
5759
+ if (data.around) {
5760
+ toPoint(data.around, layout.boxBounds, tempPoint);
5761
+ translateInner(local, -tempPoint.x, -tempPoint.y);
5413
5762
  }
5414
5763
  }
5415
5764
  this.__layout.matrixChanged = false;
5416
5765
  }
5417
5766
  };
5418
5767
 
5768
+ const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2, hasParentAutoLayout } = LeafHelper;
5769
+ const { updateBounds: updateBounds$1 } = BranchHelper;
5419
5770
  const { toOuterOf, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
5420
5771
  const LeafBounds = {
5421
5772
  __updateWorldBounds() {
5422
- var _a;
5423
- if (this.__layout.boundsChanged) {
5424
- let resize;
5425
- const layout = this.__layout;
5426
- if (layout.boxChanged) {
5427
- this.__updatePath();
5428
- this.__updateRenderPath();
5429
- this.__updateBoxBounds();
5430
- layout.boxChanged = false;
5431
- resize = true;
5432
- }
5433
- if (layout.localBoxChanged) {
5773
+ toOuterOf(this.__layout.renderBounds, this.__world, this.__world);
5774
+ if (this.__layout.resized) {
5775
+ this.__onUpdateSize();
5776
+ this.__layout.resized = false;
5777
+ }
5778
+ },
5779
+ __updateLocalBounds() {
5780
+ const layout = this.__layout;
5781
+ if (layout.boxChanged) {
5782
+ this.__updatePath();
5783
+ this.__updateRenderPath();
5784
+ this.__updateBoxBounds();
5785
+ layout.boxChanged = false;
5786
+ layout.resized = true;
5787
+ }
5788
+ if (layout.localBoxChanged) {
5789
+ if (this.__local)
5434
5790
  this.__updateLocalBoxBounds();
5435
- layout.localBoxChanged = false;
5436
- if (layout.strokeSpread)
5437
- layout.strokeChanged = true;
5438
- if (layout.renderSpread)
5439
- layout.renderChanged = true;
5440
- (_a = this.parent) === null || _a === void 0 ? void 0 : _a.__layout.boxChange();
5441
- }
5442
- if (layout.strokeChanged) {
5443
- layout.strokeSpread = this.__updateStrokeSpread();
5444
- if (layout.strokeSpread) {
5445
- if (layout.strokeBounds === layout.boxBounds) {
5446
- layout.spreadStroke();
5447
- }
5448
- this.__updateStrokeBounds();
5449
- this.__updateLocalStrokeBounds();
5450
- }
5451
- else {
5452
- layout.spreadStrokeCancel();
5453
- }
5454
- layout.strokeChanged = false;
5455
- if (layout.renderSpread)
5456
- layout.renderChanged = true;
5457
- if (this.parent)
5458
- this.parent.__layout.strokeChange();
5459
- resize || (resize = true);
5460
- }
5461
- if (layout.renderChanged) {
5462
- layout.renderSpread = this.__updateRenderSpread();
5463
- if (layout.renderSpread) {
5464
- if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
5465
- layout.spreadRender();
5466
- }
5467
- this.__updateRenderBounds();
5468
- this.__updateLocalRenderBounds();
5791
+ layout.localBoxChanged = false;
5792
+ if (layout.strokeSpread)
5793
+ layout.strokeChanged = true;
5794
+ if (layout.renderSpread)
5795
+ layout.renderChanged = true;
5796
+ if (this.parent)
5797
+ this.parent.__layout.boxChange();
5798
+ }
5799
+ if (layout.strokeChanged) {
5800
+ layout.strokeSpread = this.__updateStrokeSpread();
5801
+ if (layout.strokeSpread) {
5802
+ if (layout.strokeBounds === layout.boxBounds) {
5803
+ layout.spreadStroke();
5469
5804
  }
5470
- else {
5471
- layout.spreadRenderCancel();
5805
+ this.__updateStrokeBounds();
5806
+ this.__updateLocalStrokeBounds();
5807
+ }
5808
+ else {
5809
+ layout.spreadStrokeCancel();
5810
+ }
5811
+ layout.strokeChanged = false;
5812
+ if (layout.renderSpread)
5813
+ layout.renderChanged = true;
5814
+ if (this.parent)
5815
+ this.parent.__layout.strokeChange();
5816
+ layout.resized = true;
5817
+ }
5818
+ if (layout.renderChanged) {
5819
+ layout.renderSpread = this.__updateRenderSpread();
5820
+ if (layout.renderSpread) {
5821
+ if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
5822
+ layout.spreadRender();
5472
5823
  }
5473
- layout.renderChanged = false;
5474
- if (this.parent)
5475
- this.parent.__layout.renderChange();
5824
+ this.__updateRenderBounds();
5825
+ this.__updateLocalRenderBounds();
5476
5826
  }
5477
- layout.boundsChanged = false;
5478
- toOuterOf(this.__layout.renderBounds, this.__world, this.__world);
5479
- if (resize)
5480
- this.__onUpdateSize();
5481
- }
5482
- else {
5483
- toOuterOf(this.__layout.renderBounds, this.__world, this.__world);
5827
+ else {
5828
+ layout.spreadRenderCancel();
5829
+ }
5830
+ layout.renderChanged = false;
5831
+ if (this.parent)
5832
+ this.parent.__layout.renderChange();
5484
5833
  }
5834
+ layout.boundsChanged = false;
5485
5835
  },
5486
5836
  __updateLocalBoxBounds() {
5837
+ if (this.__hasAutoLayout)
5838
+ this.__updateAutoLayout();
5487
5839
  toOuterOf(this.__layout.boxBounds, this.__local, this.__local);
5488
5840
  },
5489
5841
  __updateLocalStrokeBounds() {
5490
- toOuterOf(this.__layout.strokeBounds, this.__local, this.__layout.localStrokeBounds);
5842
+ toOuterOf(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5491
5843
  },
5492
5844
  __updateLocalRenderBounds() {
5493
- toOuterOf(this.__layout.renderBounds, this.__local, this.__layout.localRenderBounds);
5845
+ toOuterOf(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5494
5846
  },
5495
5847
  __updateBoxBounds() {
5496
5848
  const b = this.__layout.boxBounds;
@@ -5500,14 +5852,27 @@ var LeaferUI = (function (exports) {
5500
5852
  b.width = width;
5501
5853
  b.height = height;
5502
5854
  },
5855
+ __updateAutoLayout() {
5856
+ this.__layout.matrixChanged = true;
5857
+ if (this.isBranch) {
5858
+ if (this.leafer)
5859
+ this.leafer.layouter.addExtra(this);
5860
+ if (hasParentAutoLayout(this)) {
5861
+ updateMatrix$1(this);
5862
+ }
5863
+ else {
5864
+ updateAllMatrix$2(this);
5865
+ updateBounds$1(this, this);
5866
+ }
5867
+ }
5868
+ else {
5869
+ updateMatrix$1(this);
5870
+ }
5871
+ },
5503
5872
  __updateNaturalSize() {
5504
5873
  const { __: data, __layout: layout } = this;
5505
5874
  data.__naturalWidth = layout.boxBounds.width;
5506
5875
  data.__naturalHeight = layout.boxBounds.height;
5507
- if (this.around) {
5508
- layout.matrixChanged = true;
5509
- this.__updateWorldMatrix();
5510
- }
5511
5876
  },
5512
5877
  __updateStrokeBounds() {
5513
5878
  copyAndSpread$1(this.__layout.strokeBounds, this.__layout.boxBounds, this.__layout.strokeSpread);
@@ -5550,7 +5915,7 @@ var LeaferUI = (function (exports) {
5550
5915
  const tempCanvas = canvas.getSameCanvas(true);
5551
5916
  this.__draw(tempCanvas, options);
5552
5917
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5553
- if (this.__hasMirror || options.matrix) {
5918
+ if (this.__worldFlipped || options.matrix) {
5554
5919
  canvas.copyWorldByReset(tempCanvas, null, null, blendMode);
5555
5920
  }
5556
5921
  else {
@@ -5628,7 +5993,7 @@ var LeaferUI = (function (exports) {
5628
5993
  this.__renderBranch(tempCanvas, options);
5629
5994
  canvas.opacity = this.__worldOpacity;
5630
5995
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5631
- if (this.__hasMirror || options.matrix) {
5996
+ if (this.__worldFlipped || options.matrix) {
5632
5997
  canvas.copyWorld(tempCanvas, null, null, blendMode);
5633
5998
  }
5634
5999
  else {
@@ -5646,8 +6011,8 @@ var LeaferUI = (function (exports) {
5646
6011
  const { children } = this;
5647
6012
  if (this.__hasMask && children.length > 1) {
5648
6013
  let mask;
5649
- const maskCanvas = canvas.getSameCanvas();
5650
- const contentCanvas = canvas.getSameCanvas();
6014
+ const maskCanvas = canvas.getSameCanvas(false, true);
6015
+ const contentCanvas = canvas.getSameCanvas(false, true);
5651
6016
  for (let i = 0, len = children.length; i < len; i++) {
5652
6017
  child = children[i];
5653
6018
  if (child.isMask) {
@@ -5681,7 +6046,7 @@ var LeaferUI = (function (exports) {
5681
6046
  const { LEAF, create } = IncrementId;
5682
6047
  const { toInnerPoint, toOuterPoint } = MatrixHelper;
5683
6048
  const { tempToOuterOf, copy: copy$3 } = PointHelper;
5684
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal } = LeafHelper;
6049
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, transform, setTransform, drop } = LeafHelper;
5685
6050
  exports.Leaf = class Leaf {
5686
6051
  get tag() { return this.__tag; }
5687
6052
  set tag(_value) { }
@@ -5689,15 +6054,16 @@ var LeaferUI = (function (exports) {
5689
6054
  get innerName() { return this.__.name || this.tag + this.innerId; }
5690
6055
  get __DataProcessor() { return LeafData; }
5691
6056
  get __LayoutProcessor() { return LeafLayout; }
6057
+ get __localMatrix() { return this.__local || this.__layout; }
6058
+ get __localBounds() { return this.__local || this.__; }
5692
6059
  get worldTransform() { return this.__layout.getTransform('world'); }
5693
6060
  get localTransform() { return this.__layout.getTransform('local'); }
5694
6061
  get boxBounds() { return this.getBounds('box', 'inner'); }
5695
6062
  get worldBoxBounds() { return this.getBounds('box'); }
5696
6063
  get worldStrokeBounds() { return this.getBounds('stroke'); }
5697
6064
  get worldRenderBounds() { return this.getBounds('render'); }
5698
- get worldOpacity() { this.__layout.checkUpdate(); return this.__worldOpacity; }
5699
- get resizeable() { return true; }
5700
- get __hasMirror() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
6065
+ get worldOpacity() { this.__layout.update(); return this.__worldOpacity; }
6066
+ get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
5701
6067
  get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
5702
6068
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5703
6069
  constructor(data) {
@@ -5706,20 +6072,15 @@ var LeaferUI = (function (exports) {
5706
6072
  }
5707
6073
  reset(data) {
5708
6074
  this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 };
5709
- this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
6075
+ if (data !== null)
6076
+ this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
5710
6077
  this.__worldOpacity = 1;
5711
6078
  this.__ = new this.__DataProcessor(this);
5712
6079
  this.__layout = new this.__LayoutProcessor(this);
5713
6080
  if (this.__level)
5714
6081
  this.resetCustom();
5715
- if (data) {
5716
- if (data.children) {
5717
- this.set(data);
5718
- }
5719
- else {
5720
- Object.assign(this, data);
5721
- }
5722
- }
6082
+ if (data)
6083
+ data.children ? this.set(data) : Object.assign(this, data);
5723
6084
  }
5724
6085
  resetCustom() {
5725
6086
  this.__hasMask = this.__hasEraser = null;
@@ -5756,7 +6117,7 @@ var LeaferUI = (function (exports) {
5756
6117
  }
5757
6118
  }
5758
6119
  set(_data) { }
5759
- get(_options) { return undefined; }
6120
+ get() { return undefined; }
5760
6121
  toJSON() {
5761
6122
  return this.__.__getInputData();
5762
6123
  }
@@ -5767,8 +6128,8 @@ var LeaferUI = (function (exports) {
5767
6128
  __getAttr(_attrName) { return undefined; }
5768
6129
  setProxyAttr(_attrName, _newValue) { }
5769
6130
  getProxyAttr(_attrName) { return undefined; }
5770
- find(_condition) { return undefined; }
5771
- findOne(_condition) { return undefined; }
6131
+ find(_condition, _options) { return undefined; }
6132
+ findOne(_condition, _options) { return undefined; }
5772
6133
  forceUpdate(attrName) {
5773
6134
  if (attrName === undefined)
5774
6135
  attrName = 'width';
@@ -5778,15 +6139,20 @@ var LeaferUI = (function (exports) {
5778
6139
  this.__[attrName] = value === undefined ? null : undefined;
5779
6140
  this[attrName] = value;
5780
6141
  }
6142
+ updateLayout() {
6143
+ this.__layout.update();
6144
+ }
5781
6145
  __updateWorldMatrix() { }
5782
6146
  __updateLocalMatrix() { }
5783
6147
  __updateWorldBounds() { }
6148
+ __updateLocalBounds() { }
5784
6149
  __updateLocalBoxBounds() { }
5785
6150
  __updateLocalStrokeBounds() { }
5786
6151
  __updateLocalRenderBounds() { }
5787
6152
  __updateBoxBounds() { }
5788
6153
  __updateStrokeBounds() { }
5789
6154
  __updateRenderBounds() { }
6155
+ __updateAutoLayout() { }
5790
6156
  __updateNaturalSize() { }
5791
6157
  __updateStrokeSpread() { return 0; }
5792
6158
  __updateRenderSpread() { return 0; }
@@ -5796,15 +6162,21 @@ var LeaferUI = (function (exports) {
5796
6162
  __renderMask(_canvas, _content, _mask, _recycle) { }
5797
6163
  __removeMask(_child) { }
5798
6164
  getWorld(attrName) {
5799
- this.__layout.checkUpdate();
6165
+ this.__layout.update();
5800
6166
  if (attrName === 'x')
5801
6167
  return this.__world.e;
5802
6168
  if (attrName === 'y')
5803
6169
  return this.__world.f;
5804
6170
  return this.__world[attrName];
5805
6171
  }
5806
- getBounds(type, locationType = 'world') {
5807
- return this.__layout.getBounds(type, locationType);
6172
+ getBounds(type, relative) {
6173
+ return this.__layout.getBounds(type, relative);
6174
+ }
6175
+ getLayoutBounds(type, relative, unscale) {
6176
+ return this.__layout.getLayoutBounds(type, relative, unscale);
6177
+ }
6178
+ getLayoutPoints(type, relative) {
6179
+ return this.__layout.getLayoutPoints(type, relative);
5808
6180
  }
5809
6181
  worldToLocal(world, to, distance, relative) {
5810
6182
  if (this.parent) {
@@ -5862,17 +6234,43 @@ var LeaferUI = (function (exports) {
5862
6234
  this.localToWorld(local, point, distance, relative);
5863
6235
  return point;
5864
6236
  }
6237
+ setTransform(matrix, resize) {
6238
+ setTransform(this, matrix, resize);
6239
+ }
6240
+ transform(matrix, resize) {
6241
+ transform(this, matrix, resize);
6242
+ }
5865
6243
  move(x, y) {
5866
6244
  moveLocal(this, x, y);
5867
6245
  }
5868
- scaleOf(origin, x, y) {
5869
- zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), x, y);
6246
+ scaleOf(origin, scaleX, scaleY, resize) {
6247
+ zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize);
5870
6248
  }
5871
- rotateOf(origin, angle) {
5872
- rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), angle);
6249
+ rotateOf(origin, rotation) {
6250
+ rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation);
6251
+ }
6252
+ skewOf(origin, skewX, skewY, resize) {
6253
+ skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize);
6254
+ }
6255
+ scaleResize(scaleX, scaleY = scaleX, noResize) {
6256
+ const data = this;
6257
+ if (noResize) {
6258
+ data.scaleX *= scaleX;
6259
+ data.scaleY *= scaleY;
6260
+ }
6261
+ else {
6262
+ if (scaleX < 0)
6263
+ data.scaleX *= -1, scaleX = -scaleX;
6264
+ if (scaleY < 0)
6265
+ data.scaleY *= -1, scaleY = -scaleY;
6266
+ this.__scaleResize(scaleX, scaleY);
6267
+ }
5873
6268
  }
5874
- skewOf(origin, x, y) {
5875
- skewOfLocal(this, tempToOuterOf(origin, this.localTransform), x, y);
6269
+ __scaleResize(scaleX, scaleY) {
6270
+ if (scaleX !== 1)
6271
+ this.width *= scaleX;
6272
+ if (scaleY !== 1)
6273
+ this.height *= scaleY;
5876
6274
  }
5877
6275
  __hitWorld(_point) { return true; }
5878
6276
  __hit(_local) { return true; }
@@ -5894,6 +6292,9 @@ var LeaferUI = (function (exports) {
5894
6292
  if (this.parent)
5895
6293
  this.parent.remove(this, destroy);
5896
6294
  }
6295
+ dropTo(parent, index, resize) {
6296
+ drop(this, parent, index, resize);
6297
+ }
5897
6298
  on(_type, _listener, _options) { }
5898
6299
  off(_type, _listener, _options) { }
5899
6300
  on_(_type, _listener, _bind, _options) { return undefined; }
@@ -5902,6 +6303,14 @@ var LeaferUI = (function (exports) {
5902
6303
  emit(_type, _event, _capture) { }
5903
6304
  emitEvent(_event, _capture) { }
5904
6305
  hasEvent(_type, _capture) { return false; }
6306
+ static changeAttr(attrName, defaultValue) {
6307
+ defineDataProcessor(this.prototype, attrName, defaultValue);
6308
+ }
6309
+ static addAttr(attrName, defaultValue, fn) {
6310
+ if (!fn)
6311
+ fn = boundsType;
6312
+ fn(defaultValue)(this.prototype, attrName);
6313
+ }
5905
6314
  destroy() {
5906
6315
  if (!this.destroyed) {
5907
6316
  if (this.parent)
@@ -5924,9 +6333,9 @@ var LeaferUI = (function (exports) {
5924
6333
  useModule(LeafRender)
5925
6334
  ], exports.Leaf);
5926
6335
 
5927
- const { setByListWithHandle: setByListWithHandle$1 } = BoundsHelper;
6336
+ const { setListWithFn } = BoundsHelper;
5928
6337
  const { sort } = BranchHelper;
5929
- const { localBoxBounds, localEventBounds, localRenderBounds, maskLocalBoxBounds, maskLocalEventBounds, maskLocalRenderBounds } = LeafBoundsHelper;
6338
+ const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5930
6339
  exports.Branch = class Branch extends exports.Leaf {
5931
6340
  constructor() {
5932
6341
  super();
@@ -5950,13 +6359,13 @@ var LeaferUI = (function (exports) {
5950
6359
  return 0;
5951
6360
  }
5952
6361
  __updateBoxBounds() {
5953
- setByListWithHandle$1(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
6362
+ setListWithFn(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
5954
6363
  }
5955
6364
  __updateStrokeBounds() {
5956
- setByListWithHandle$1(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalEventBounds : localEventBounds);
6365
+ setListWithFn(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalStrokeBounds : localStrokeBounds);
5957
6366
  }
5958
6367
  __updateRenderBounds() {
5959
- setByListWithHandle$1(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
6368
+ setListWithFn(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
5960
6369
  }
5961
6370
  __updateSortChildren() {
5962
6371
  let affectSort;
@@ -6102,7 +6511,7 @@ var LeaferUI = (function (exports) {
6102
6511
  if (this.hasRemove) {
6103
6512
  const updatedList = new LeafList();
6104
6513
  this.__updatedList.list.forEach(item => { if (item.leafer)
6105
- updatedList.push(item); });
6514
+ updatedList.add(item); });
6106
6515
  return updatedList;
6107
6516
  }
6108
6517
  else {
@@ -6137,7 +6546,7 @@ var LeaferUI = (function (exports) {
6137
6546
  this.target.emit(RenderEvent.REQUEST);
6138
6547
  }
6139
6548
  __onAttrChange(event) {
6140
- this.__updatedList.push(event.target);
6549
+ this.__updatedList.add(event.target);
6141
6550
  this.update();
6142
6551
  }
6143
6552
  __onChildEvent(event) {
@@ -6147,12 +6556,12 @@ var LeaferUI = (function (exports) {
6147
6556
  }
6148
6557
  else {
6149
6558
  this.hasRemove = true;
6150
- this.__updatedList.push(event.parent);
6559
+ this.__updatedList.add(event.parent);
6151
6560
  }
6152
6561
  this.update();
6153
6562
  }
6154
6563
  __pushChild(child) {
6155
- this.__updatedList.push(child);
6564
+ this.__updatedList.add(child);
6156
6565
  if (child.isBranch)
6157
6566
  this.__loopChildren(child);
6158
6567
  }
@@ -6191,7 +6600,7 @@ var LeaferUI = (function (exports) {
6191
6600
  }
6192
6601
  }
6193
6602
 
6194
- const { updateAllWorldMatrix: updateAllWorldMatrix$1, updateAllWorldOpacity } = LeafHelper;
6603
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6195
6604
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6196
6605
  function updateMatrix(updateList, levelList) {
6197
6606
  let layout;
@@ -6199,14 +6608,14 @@ var LeaferUI = (function (exports) {
6199
6608
  layout = leaf.__layout;
6200
6609
  if (levelList.without(leaf) && !layout.proxyZoom) {
6201
6610
  if (layout.matrixChanged) {
6202
- updateAllWorldMatrix$1(leaf);
6203
- levelList.push(leaf);
6611
+ updateAllMatrix$1(leaf, true);
6612
+ levelList.add(leaf);
6204
6613
  if (leaf.isBranch)
6205
6614
  pushAllChildBranch(leaf, levelList);
6206
6615
  pushAllParent(leaf, levelList);
6207
6616
  }
6208
6617
  else if (layout.boundsChanged) {
6209
- levelList.push(leaf);
6618
+ levelList.add(leaf);
6210
6619
  if (leaf.isBranch)
6211
6620
  leaf.__tempNumber = 0;
6212
6621
  pushAllParent(leaf, levelList);
@@ -6215,20 +6624,21 @@ var LeaferUI = (function (exports) {
6215
6624
  });
6216
6625
  }
6217
6626
  function updateBounds(boundsList) {
6218
- let itemList, branch;
6627
+ let list, branch, children;
6219
6628
  boundsList.sort(true);
6220
6629
  boundsList.levels.forEach(level => {
6221
- itemList = boundsList.levelMap[level];
6222
- for (let i = 0, len = itemList.length; i < len; i++) {
6223
- branch = itemList[i];
6630
+ list = boundsList.levelMap[level];
6631
+ for (let i = 0, len = list.length; i < len; i++) {
6632
+ branch = list[i];
6224
6633
  if (branch.isBranch && branch.__tempNumber) {
6225
- for (let j = 0, jLen = branch.children.length; j < jLen; j++) {
6226
- if (!branch.children[j].isBranch) {
6227
- branch.children[j].__updateWorldBounds();
6634
+ children = branch.children;
6635
+ for (let j = 0, jLen = children.length; j < jLen; j++) {
6636
+ if (!children[j].isBranch) {
6637
+ updateOneBounds(children[j]);
6228
6638
  }
6229
6639
  }
6230
6640
  }
6231
- branch.__updateWorldBounds();
6641
+ updateOneBounds(branch);
6232
6642
  }
6233
6643
  });
6234
6644
  }
@@ -6241,7 +6651,7 @@ var LeaferUI = (function (exports) {
6241
6651
  }
6242
6652
 
6243
6653
  const { worldBounds } = LeafBoundsHelper;
6244
- const { setByListWithHandle } = BoundsHelper;
6654
+ const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
6245
6655
  class LayoutBlockData {
6246
6656
  constructor(list) {
6247
6657
  this.updatedBounds = new Bounds();
@@ -6252,14 +6662,20 @@ var LeaferUI = (function (exports) {
6252
6662
  this.updatedList = list;
6253
6663
  }
6254
6664
  setBefore() {
6255
- setByListWithHandle(this.beforeBounds, this.updatedList.list, worldBounds);
6665
+ this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
6256
6666
  }
6257
6667
  setAfter() {
6258
- setByListWithHandle(this.afterBounds, this.updatedList.list, worldBounds);
6259
- this.updatedBounds.setByList([this.beforeBounds, this.afterBounds]);
6668
+ const { list } = this.updatedList;
6669
+ if (list.some(leaf => leaf.noBounds)) {
6670
+ this.afterBounds.set(bigBounds);
6671
+ }
6672
+ else {
6673
+ this.afterBounds.setListWithFn(list, worldBounds);
6674
+ }
6675
+ this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
6260
6676
  }
6261
6677
  merge(data) {
6262
- this.updatedList.pushList(data.updatedList.list);
6678
+ this.updatedList.addList(data.updatedList.list);
6263
6679
  this.beforeBounds.add(data.beforeBounds);
6264
6680
  this.afterBounds.add(data.afterBounds);
6265
6681
  this.updatedBounds.add(data.updatedBounds);
@@ -6269,8 +6685,7 @@ var LeaferUI = (function (exports) {
6269
6685
  }
6270
6686
  }
6271
6687
 
6272
- const { updateAllWorldMatrix, updateAllChange } = LeafHelper;
6273
- const { pushAllBranchStack, updateWorldBoundsByBranchStack } = BranchHelper;
6688
+ const { updateAllMatrix, updateAllChange } = LeafHelper;
6274
6689
  const debug$5 = Debug.get('Layouter');
6275
6690
  class Layouter {
6276
6691
  constructor(target, userConfig) {
@@ -6347,12 +6762,15 @@ var LeaferUI = (function (exports) {
6347
6762
  const { target, __updatedList: updateList } = this;
6348
6763
  const { BEFORE, LAYOUT, AFTER } = LayoutEvent;
6349
6764
  const blocks = this.getBlocks(updateList);
6350
- blocks.forEach(item => { item.setBefore(); });
6765
+ blocks.forEach(item => item.setBefore());
6351
6766
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
6767
+ this.extraBlock = null;
6352
6768
  updateList.sort();
6353
6769
  updateMatrix(updateList, this.__levelList);
6354
6770
  updateBounds(this.__levelList);
6355
6771
  updateChange(updateList);
6772
+ if (this.extraBlock)
6773
+ blocks.push(this.extraBlock);
6356
6774
  blocks.forEach(item => item.setAfter());
6357
6775
  target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
6358
6776
  target.emitEvent(new LayoutEvent(AFTER, blocks, this.times));
@@ -6375,17 +6793,20 @@ var LeaferUI = (function (exports) {
6375
6793
  Run.end(t);
6376
6794
  }
6377
6795
  static fullLayout(target) {
6378
- updateAllWorldMatrix(target);
6796
+ updateAllMatrix(target, true);
6379
6797
  if (target.isBranch) {
6380
- const branchStack = [target];
6381
- pushAllBranchStack(target, branchStack);
6382
- updateWorldBoundsByBranchStack(branchStack);
6798
+ BranchHelper.updateBounds(target);
6383
6799
  }
6384
6800
  else {
6385
- target.__updateWorldBounds();
6801
+ LeafHelper.updateBounds(target);
6386
6802
  }
6387
6803
  updateAllChange(target);
6388
6804
  }
6805
+ addExtra(leaf) {
6806
+ const block = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
6807
+ block.updatedList.add(leaf);
6808
+ block.beforeBounds.add(leaf.__world);
6809
+ }
6389
6810
  createBlock(data) {
6390
6811
  return new LayoutBlockData(data);
6391
6812
  }
@@ -6413,8 +6834,7 @@ var LeaferUI = (function (exports) {
6413
6834
  if (this.target) {
6414
6835
  this.stop();
6415
6836
  this.__removeListenEvents();
6416
- this.target = null;
6417
- this.config = null;
6837
+ this.target = this.config = null;
6418
6838
  }
6419
6839
  }
6420
6840
  }
@@ -6525,7 +6945,7 @@ var LeaferUI = (function (exports) {
6525
6945
  const { canvas } = this;
6526
6946
  const bounds = block.getIntersect(canvas.bounds);
6527
6947
  const includes = block.includes(this.target.__world);
6528
- const realBounds = new Bounds().copy(bounds);
6948
+ const realBounds = new Bounds(bounds);
6529
6949
  canvas.save();
6530
6950
  if (includes && !Debug.showRepaint) {
6531
6951
  canvas.clear();
@@ -6575,7 +6995,7 @@ var LeaferUI = (function (exports) {
6575
6995
  const { updateBlocks: list } = this;
6576
6996
  if (list) {
6577
6997
  const bounds = new Bounds();
6578
- bounds.setByList(list);
6998
+ bounds.setList(list);
6579
6999
  list.length = 0;
6580
7000
  list.push(bounds);
6581
7001
  }
@@ -6615,7 +7035,7 @@ var LeaferUI = (function (exports) {
6615
7035
  empty = (!leaf.__world.width || !leaf.__world.height);
6616
7036
  if (empty) {
6617
7037
  if (!leaf.isLeafer)
6618
- debug$4.warn(leaf.innerName, ': empty');
7038
+ debug$4.tip(leaf.innerName, ': empty');
6619
7039
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6620
7040
  }
6621
7041
  return empty;
@@ -6649,6 +7069,14 @@ var LeaferUI = (function (exports) {
6649
7069
  }
6650
7070
  }
6651
7071
 
7072
+ var AnswerType;
7073
+ (function (AnswerType) {
7074
+ AnswerType[AnswerType["No"] = 0] = "No";
7075
+ AnswerType[AnswerType["Yes"] = 1] = "Yes";
7076
+ AnswerType[AnswerType["NoAndSkip"] = 2] = "NoAndSkip";
7077
+ AnswerType[AnswerType["YesAndSkip"] = 3] = "YesAndSkip";
7078
+ })(AnswerType || (AnswerType = {}));
7079
+
6652
7080
  const { hitRadiusPoint } = BoundsHelper;
6653
7081
  class Pather {
6654
7082
  constructor(target, selector) {
@@ -6693,10 +7121,10 @@ var LeaferUI = (function (exports) {
6693
7121
  getPath(leaf) {
6694
7122
  const path = new LeafList();
6695
7123
  while (leaf) {
6696
- path.push(leaf);
7124
+ path.add(leaf);
6697
7125
  leaf = leaf.parent;
6698
7126
  }
6699
- path.push(this.target);
7127
+ path.add(this.target);
6700
7128
  return path;
6701
7129
  }
6702
7130
  getHitablePath(leaf) {
@@ -6706,7 +7134,7 @@ var LeaferUI = (function (exports) {
6706
7134
  item = path.list[i];
6707
7135
  if (!item.__.hittable)
6708
7136
  break;
6709
- hittablePath.unshift(item);
7137
+ hittablePath.addAt(item, 0);
6710
7138
  if (!item.__.hitChildren)
6711
7139
  break;
6712
7140
  }
@@ -6725,7 +7153,7 @@ var LeaferUI = (function (exports) {
6725
7153
  leaf = path.list[j];
6726
7154
  if (nextPath && nextPath.has(leaf))
6727
7155
  break;
6728
- throughPath.push(leaf);
7156
+ throughPath.add(leaf);
6729
7157
  }
6730
7158
  }
6731
7159
  return throughPath;
@@ -6767,14 +7195,15 @@ var LeaferUI = (function (exports) {
6767
7195
  }
6768
7196
  }
6769
7197
 
7198
+ const { Yes, NoAndSkip, YesAndSkip } = AnswerType;
6770
7199
  class Selector {
6771
7200
  constructor(target, userConfig) {
6772
7201
  this.config = {};
6773
7202
  this.innerIdMap = {};
6774
7203
  this.idMap = {};
6775
7204
  this.methods = {
6776
- id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
6777
- innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
7205
+ id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
7206
+ innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6778
7207
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6779
7208
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0
6780
7209
  };
@@ -6784,11 +7213,6 @@ var LeaferUI = (function (exports) {
6784
7213
  this.pather = new Pather(target, this);
6785
7214
  this.__listenEvents();
6786
7215
  }
6787
- getByPoint(hitPoint, hitRadius, options) {
6788
- if (Platform.name === 'node')
6789
- this.target.emit(LayoutEvent.CHECK_UPDATE);
6790
- return this.pather.getByPoint(hitPoint, hitRadius, options);
6791
- }
6792
7216
  getBy(condition, branch, one, options) {
6793
7217
  switch (typeof condition) {
6794
7218
  case 'number':
@@ -6808,6 +7232,11 @@ var LeaferUI = (function (exports) {
6808
7232
  return this.getByMethod(condition, branch, one, options);
6809
7233
  }
6810
7234
  }
7235
+ getByPoint(hitPoint, hitRadius, options) {
7236
+ if (Platform.name === 'node')
7237
+ this.target.emit(LayoutEvent.CHECK_UPDATE);
7238
+ return this.pather.getByPoint(hitPoint, hitRadius, options);
7239
+ }
6811
7240
  getByInnerId(innerId, branch) {
6812
7241
  const cache = this.innerIdMap[innerId];
6813
7242
  if (cache)
@@ -6834,10 +7263,11 @@ var LeaferUI = (function (exports) {
6834
7263
  return list || this.findLeaf;
6835
7264
  }
6836
7265
  eachFind(children, method, list, options) {
6837
- let child;
7266
+ let child, result;
6838
7267
  for (let i = 0, len = children.length; i < len; i++) {
6839
7268
  child = children[i];
6840
- if (method(child, options)) {
7269
+ result = method(child, options);
7270
+ if (result === Yes || result === YesAndSkip) {
6841
7271
  if (list) {
6842
7272
  list.push(child);
6843
7273
  }
@@ -6846,7 +7276,7 @@ var LeaferUI = (function (exports) {
6846
7276
  return;
6847
7277
  }
6848
7278
  }
6849
- if (child.isBranch)
7279
+ if (child.isBranch && result < NoAndSkip)
6850
7280
  this.eachFind(child.children, method, list, options);
6851
7281
  }
6852
7282
  }
@@ -7417,8 +7847,8 @@ var LeaferUI = (function (exports) {
7417
7847
  img.crossOrigin = 'anonymous';
7418
7848
  img.onload = () => { resolve(img); };
7419
7849
  img.onerror = (e) => { reject(e); };
7420
- if (!src.startsWith('data:') && Platform.imageSuffix)
7421
- src += (src.includes("?") ? "&" : "?") + Platform.imageSuffix;
7850
+ if (!src.startsWith('data:') && Platform.image.suffix)
7851
+ src += (src.includes("?") ? "&" : "?") + Platform.image.suffix;
7422
7852
  img.src = src;
7423
7853
  });
7424
7854
  }
@@ -7434,8 +7864,7 @@ var LeaferUI = (function (exports) {
7434
7864
  Platform.name = 'web';
7435
7865
  Platform.isMobile = 'ontouchstart' in window;
7436
7866
  Platform.requestRender = function (render) { window.requestAnimationFrame(render); };
7437
- Platform.devicePixelRatio = devicePixelRatio;
7438
- Platform.realtimeLayout = true;
7867
+ Platform.devicePixelRatio = Math.max(1, devicePixelRatio);
7439
7868
  const { userAgent } = navigator;
7440
7869
  if (userAgent.indexOf("Firefox") > -1) {
7441
7870
  Platform.conicGradientRotate90 = true;
@@ -7465,7 +7894,7 @@ var LeaferUI = (function (exports) {
7465
7894
  if (leafer.isApp)
7466
7895
  return;
7467
7896
  leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, (e) => { LeafHelper.moveWorld(leafer.zoomLayer, e.moveX, e.moveY); }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, (e) => {
7468
- const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.config.zoom;
7897
+ const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.app.config.zoom;
7469
7898
  let { scale } = e;
7470
7899
  if (scale * Math.abs(scaleX) < min)
7471
7900
  scale = min / scaleX;
@@ -7512,6 +7941,9 @@ var LeaferUI = (function (exports) {
7512
7941
  const emptyPaint = {};
7513
7942
  const debug$1 = Debug.get('UIData');
7514
7943
  class UIData extends LeafData {
7944
+ get __autoWidth() { return !this._width; }
7945
+ get __autoHeight() { return !this._height; }
7946
+ get __autoBounds() { return !this._width && !this._height; }
7515
7947
  setVisible(value) {
7516
7948
  if (this.__leaf.leafer)
7517
7949
  this.__leaf.leafer.watcher.hasVisible = true;
@@ -7688,6 +8120,9 @@ var LeaferUI = (function (exports) {
7688
8120
  class ImageData extends RectData {
7689
8121
  }
7690
8122
 
8123
+ class CanvasData extends RectData {
8124
+ }
8125
+
7691
8126
  function effectType(defaultValue) {
7692
8127
  return (target, key) => {
7693
8128
  defineLeafAttr(target, key, defaultValue, {
@@ -7898,6 +8333,7 @@ var LeaferUI = (function (exports) {
7898
8333
 
7899
8334
  var UI_1;
7900
8335
  exports.UI = UI_1 = class UI extends exports.Leaf {
8336
+ get app() { return this.leafer && this.leafer.app; }
7901
8337
  set scale(value) {
7902
8338
  if (typeof value === 'number') {
7903
8339
  this.scaleX = this.scaleY = value;
@@ -7911,22 +8347,25 @@ var LeaferUI = (function (exports) {
7911
8347
  const { scaleX, scaleY } = this;
7912
8348
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
7913
8349
  }
8350
+ constructor(data) {
8351
+ super(data);
8352
+ }
7914
8353
  reset(_data) { }
7915
8354
  set(data) {
7916
8355
  Object.assign(this, data);
7917
8356
  }
7918
- get(options) {
7919
- return this.__.__getInputData(options);
8357
+ get() {
8358
+ return this.__.__getInputData();
7920
8359
  }
7921
- getProxyData() { return undefined; }
7922
- find(condition) {
7923
- return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
8360
+ createProxyData() { return undefined; }
8361
+ find(condition, options) {
8362
+ return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
7924
8363
  }
7925
- findOne(condition) {
7926
- return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
8364
+ findOne(condition, options) {
8365
+ return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
7927
8366
  }
7928
8367
  getPath(curve) {
7929
- const path = this.__.path;
8368
+ const { path } = this.__;
7930
8369
  if (!path)
7931
8370
  return [];
7932
8371
  return curve ? PathConvert.toCanvasData(path, true) : path;
@@ -7958,6 +8397,15 @@ var LeaferUI = (function (exports) {
7958
8397
  this.__drawPathByData(canvas, this.__.path);
7959
8398
  }
7960
8399
  __drawPathByData(_drawer, _data) { }
8400
+ __drawPathByBox(drawer) {
8401
+ const { x, y, width, height } = this.__layout.boxBounds;
8402
+ if (this.__.cornerRadius) {
8403
+ drawer.roundRect(x, y, width, height, this.__.cornerRadius);
8404
+ }
8405
+ else {
8406
+ drawer.rect(x, y, width, height);
8407
+ }
8408
+ }
7961
8409
  export(filename, options) {
7962
8410
  return Export$1.export(this, filename, options);
7963
8411
  }
@@ -7999,12 +8447,12 @@ var LeaferUI = (function (exports) {
7999
8447
  __decorate([
8000
8448
  eraserType(false)
8001
8449
  ], exports.UI.prototype, "isEraser", void 0);
8450
+ __decorate([
8451
+ dataType(false)
8452
+ ], exports.UI.prototype, "locked", void 0);
8002
8453
  __decorate([
8003
8454
  sortType(0)
8004
8455
  ], exports.UI.prototype, "zIndex", void 0);
8005
- __decorate([
8006
- dataType()
8007
- ], exports.UI.prototype, "locked", void 0);
8008
8456
  __decorate([
8009
8457
  positionType(0)
8010
8458
  ], exports.UI.prototype, "x", void 0);
@@ -8033,11 +8481,17 @@ var LeaferUI = (function (exports) {
8033
8481
  rotationType(0)
8034
8482
  ], exports.UI.prototype, "skewY", void 0);
8035
8483
  __decorate([
8036
- positionType()
8484
+ autoLayoutType()
8037
8485
  ], exports.UI.prototype, "around", void 0);
8038
8486
  __decorate([
8039
8487
  dataType(false)
8040
8488
  ], exports.UI.prototype, "draggable", void 0);
8489
+ __decorate([
8490
+ dataType(false)
8491
+ ], exports.UI.prototype, "editable", void 0);
8492
+ __decorate([
8493
+ dataType('size')
8494
+ ], exports.UI.prototype, "editSize", void 0);
8041
8495
  __decorate([
8042
8496
  hitType(true)
8043
8497
  ], exports.UI.prototype, "hittable", void 0);
@@ -8090,7 +8544,7 @@ var LeaferUI = (function (exports) {
8090
8544
  strokeType(10)
8091
8545
  ], exports.UI.prototype, "miterLimit", void 0);
8092
8546
  __decorate([
8093
- pathType()
8547
+ pathType(0)
8094
8548
  ], exports.UI.prototype, "cornerRadius", void 0);
8095
8549
  __decorate([
8096
8550
  pathType()
@@ -8123,9 +8577,9 @@ var LeaferUI = (function (exports) {
8123
8577
  rewriteAble()
8124
8578
  ], exports.UI);
8125
8579
 
8580
+ const matrix = MatrixHelper.get();
8126
8581
  exports.Group = class Group extends exports.UI {
8127
8582
  get __tag() { return 'Group'; }
8128
- get resizeable() { return false; }
8129
8583
  set mask(child) {
8130
8584
  if (this.__hasMask)
8131
8585
  this.__removeMask();
@@ -8173,6 +8627,14 @@ var LeaferUI = (function (exports) {
8173
8627
  data.children = this.children.map(child => child.toJSON());
8174
8628
  return data;
8175
8629
  }
8630
+ __scaleResize(scaleX, scaleY) {
8631
+ const { children } = this;
8632
+ for (let i = 0; i < children.length; i++) {
8633
+ matrix.a = scaleX;
8634
+ matrix.d = scaleY;
8635
+ children[i].transform(matrix, true);
8636
+ }
8637
+ }
8176
8638
  addAt(child, index) {
8177
8639
  this.add(child, index);
8178
8640
  }
@@ -8200,21 +8662,17 @@ var LeaferUI = (function (exports) {
8200
8662
  constructor(data) {
8201
8663
  super(data);
8202
8664
  }
8203
- __drawPathByData(drawer, _data) {
8204
- const { width, height, cornerRadius } = this.__;
8205
- if (cornerRadius) {
8206
- drawer.roundRect(0, 0, width, height, cornerRadius);
8207
- }
8208
- else {
8209
- drawer.rect(0, 0, width, height);
8210
- }
8211
- }
8665
+ __drawPathByData(_drawer, _data) { }
8212
8666
  };
8213
8667
  __decorate([
8214
8668
  dataProcessor(RectData)
8215
8669
  ], exports.Rect.prototype, "__", void 0);
8670
+ __decorate([
8671
+ rewrite(exports.UI.prototype.__drawPathByBox)
8672
+ ], exports.Rect.prototype, "__drawPathByData", null);
8216
8673
  exports.Rect = __decorate([
8217
8674
  useModule(RectRender),
8675
+ rewriteAble(),
8218
8676
  registerUI()
8219
8677
  ], exports.Rect);
8220
8678
 
@@ -8224,12 +8682,20 @@ var LeaferUI = (function (exports) {
8224
8682
  const { copy: copy$2, add } = BoundsHelper;
8225
8683
  exports.Box = class Box extends exports.Group {
8226
8684
  get __tag() { return 'Box'; }
8227
- get resizeable() { return true; }
8228
8685
  constructor(data) {
8229
8686
  super(data);
8230
8687
  this.isBranchLeaf = true;
8231
8688
  this.__layout.renderChanged || this.__layout.renderChange();
8232
8689
  }
8690
+ __scaleResize(scaleX, scaleY) {
8691
+ if (this.__.__autoBounds && this.children.length) {
8692
+ super.__scaleResize(scaleX, scaleY);
8693
+ }
8694
+ else {
8695
+ this.width *= scaleX;
8696
+ this.height *= scaleY;
8697
+ }
8698
+ }
8233
8699
  __updateStrokeSpread() { return 0; }
8234
8700
  __updateRectRenderSpread() { return 0; }
8235
8701
  __updateRenderSpread() {
@@ -8239,7 +8705,15 @@ var LeaferUI = (function (exports) {
8239
8705
  width = this.__.__drawAfterFill ? 0 : 1;
8240
8706
  return width;
8241
8707
  }
8242
- __updateBoxBounds() { }
8708
+ __updateRectBoxBounds() { }
8709
+ __updateBoxBounds() {
8710
+ if (this.__.__autoBounds && this.children.length) {
8711
+ super.__updateBoxBounds();
8712
+ }
8713
+ else {
8714
+ this.__updateRectBoxBounds();
8715
+ }
8716
+ }
8243
8717
  __updateStrokeBounds() { }
8244
8718
  __updateRenderBounds() {
8245
8719
  this.__updateRectRenderBounds();
@@ -8291,7 +8765,7 @@ var LeaferUI = (function (exports) {
8291
8765
  ], exports.Box.prototype, "__updateRectRenderSpread", null);
8292
8766
  __decorate([
8293
8767
  rewrite(rect.__updateBoxBounds)
8294
- ], exports.Box.prototype, "__updateBoxBounds", null);
8768
+ ], exports.Box.prototype, "__updateRectBoxBounds", null);
8295
8769
  __decorate([
8296
8770
  rewrite(rect.__updateStrokeBounds)
8297
8771
  ], exports.Box.prototype, "__updateStrokeBounds", null);
@@ -8319,6 +8793,7 @@ var LeaferUI = (function (exports) {
8319
8793
  get __tag() { return 'Frame'; }
8320
8794
  constructor(data) {
8321
8795
  super(data);
8796
+ this.isFrame = true;
8322
8797
  if (!this.__.fill)
8323
8798
  this.__.fill = '#FFFFFF';
8324
8799
  }
@@ -8359,7 +8834,7 @@ var LeaferUI = (function (exports) {
8359
8834
  ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
8360
8835
  }
8361
8836
  if (Platform.ellipseToCurve)
8362
- this.__.path = PathConvert.toCanvasData(path, true);
8837
+ this.__.path = this.getPath(true);
8363
8838
  }
8364
8839
  else {
8365
8840
  if (startAngle || endAngle) {
@@ -8389,47 +8864,118 @@ var LeaferUI = (function (exports) {
8389
8864
  registerUI()
8390
8865
  ], exports.Ellipse);
8391
8866
 
8392
- const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
8393
- const { moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8394
- const { toBounds: toBounds$2 } = PathBounds;
8395
- exports.Polygon = class Polygon extends exports.UI {
8396
- get __tag() { return 'Polygon'; }
8397
- get resizeable() { return !this.points; }
8867
+ const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8868
+ const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
8869
+ const { toBounds: toBounds$1 } = PathBounds;
8870
+ exports.Line = class Line extends exports.UI {
8871
+ get __tag() { return 'Line'; }
8872
+ get toPoint() {
8873
+ const { width, rotation } = this.__;
8874
+ const to = { x: 0, y: 0 };
8875
+ if (width)
8876
+ to.x = width;
8877
+ if (rotation)
8878
+ rotate$1(to, rotation);
8879
+ return to;
8880
+ }
8881
+ set toPoint(value) {
8882
+ this.width = getDistance$2(defaultPoint, value);
8883
+ this.rotation = getAngle$2(defaultPoint, value);
8884
+ if (this.height)
8885
+ this.height = 0;
8886
+ }
8398
8887
  constructor(data) {
8399
8888
  super(data);
8400
8889
  }
8401
8890
  __updatePath() {
8402
8891
  const path = this.__.path = [];
8403
8892
  if (this.__.points) {
8404
- drawPoints$1(path, this.__.points, false, true);
8893
+ drawPoints$1(path, this.__.points, false);
8405
8894
  }
8406
8895
  else {
8407
- const { width, height, sides } = this.__;
8408
- const rx = width / 2, ry = height / 2;
8409
- moveTo$2(path, rx, 0);
8410
- for (let i = 1; i < sides; i++) {
8411
- lineTo$2(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
8412
- }
8896
+ moveTo$2(path, 0, 0);
8897
+ lineTo$2(path, this.width, 0);
8413
8898
  }
8414
- closePath$1(path);
8415
8899
  }
8416
8900
  __updateRenderPath() {
8417
8901
  if (this.__.points && this.__.curve) {
8418
- drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, true);
8902
+ drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
8419
8903
  }
8420
8904
  else {
8421
8905
  super.__updateRenderPath();
8422
8906
  }
8423
8907
  }
8424
8908
  __updateBoxBounds() {
8425
- if (this.__.points) {
8426
- toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
8427
- this.__updateNaturalSize();
8909
+ if (this.points) {
8910
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8428
8911
  }
8429
8912
  else {
8430
8913
  super.__updateBoxBounds();
8431
8914
  }
8432
8915
  }
8916
+ __scaleResize(scaleX, scaleY) {
8917
+ if (this.points) {
8918
+ PathScaler.scalePoints(this.__.points, scaleX, scaleY);
8919
+ this.points = this.__.points;
8920
+ }
8921
+ else {
8922
+ if (this.__tag === 'Line') {
8923
+ const point = this.toPoint;
8924
+ point.x *= scaleX;
8925
+ point.y *= scaleY;
8926
+ this.toPoint = point;
8927
+ }
8928
+ else {
8929
+ super.__scaleResize(scaleX, scaleY);
8930
+ }
8931
+ }
8932
+ }
8933
+ };
8934
+ __decorate([
8935
+ dataProcessor(LineData)
8936
+ ], exports.Line.prototype, "__", void 0);
8937
+ __decorate([
8938
+ affectStrokeBoundsType('center')
8939
+ ], exports.Line.prototype, "strokeAlign", void 0);
8940
+ __decorate([
8941
+ boundsType(0)
8942
+ ], exports.Line.prototype, "height", void 0);
8943
+ __decorate([
8944
+ pathType()
8945
+ ], exports.Line.prototype, "points", void 0);
8946
+ __decorate([
8947
+ pathType(0)
8948
+ ], exports.Line.prototype, "curve", void 0);
8949
+ exports.Line = __decorate([
8950
+ registerUI()
8951
+ ], exports.Line);
8952
+
8953
+ const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
8954
+ const { moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints } = PathCommandDataHelper;
8955
+ const line = exports.Line.prototype;
8956
+ exports.Polygon = class Polygon extends exports.UI {
8957
+ get __tag() { return 'Polygon'; }
8958
+ constructor(data) {
8959
+ super(data);
8960
+ }
8961
+ __updatePath() {
8962
+ const path = this.__.path = [];
8963
+ if (this.__.points) {
8964
+ drawPoints(path, this.__.points, false, true);
8965
+ }
8966
+ else {
8967
+ const { width, height, sides } = this.__;
8968
+ const rx = width / 2, ry = height / 2;
8969
+ moveTo$1(path, rx, 0);
8970
+ for (let i = 1; i < sides; i++) {
8971
+ lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
8972
+ }
8973
+ }
8974
+ closePath$1(path);
8975
+ }
8976
+ __updateRenderPath() { }
8977
+ __updateBoxBounds() { }
8978
+ __scaleResize(_scaleX, _scaleY) { }
8433
8979
  };
8434
8980
  __decorate([
8435
8981
  dataProcessor(PolygonData)
@@ -8443,12 +8989,22 @@ var LeaferUI = (function (exports) {
8443
8989
  __decorate([
8444
8990
  pathType(0)
8445
8991
  ], exports.Polygon.prototype, "curve", void 0);
8992
+ __decorate([
8993
+ rewrite(line.__updateRenderPath)
8994
+ ], exports.Polygon.prototype, "__updateRenderPath", null);
8995
+ __decorate([
8996
+ rewrite(line.__updateBoxBounds)
8997
+ ], exports.Polygon.prototype, "__updateBoxBounds", null);
8998
+ __decorate([
8999
+ rewrite(line.__scaleResize)
9000
+ ], exports.Polygon.prototype, "__scaleResize", null);
8446
9001
  exports.Polygon = __decorate([
9002
+ rewriteAble(),
8447
9003
  registerUI()
8448
9004
  ], exports.Polygon);
8449
9005
 
8450
9006
  const { sin, cos, PI } = Math;
8451
- const { moveTo: moveTo$1, lineTo: lineTo$1, closePath } = PathCommandDataHelper;
9007
+ const { moveTo, lineTo, closePath } = PathCommandDataHelper;
8452
9008
  exports.Star = class Star extends exports.UI {
8453
9009
  get __tag() { return 'Star'; }
8454
9010
  constructor(data) {
@@ -8458,9 +9014,9 @@ var LeaferUI = (function (exports) {
8458
9014
  const { width, height, corners, innerRadius } = this.__;
8459
9015
  const rx = width / 2, ry = height / 2;
8460
9016
  const path = this.__.path = [];
8461
- moveTo$1(path, rx, 0);
9017
+ moveTo(path, rx, 0);
8462
9018
  for (let i = 1; i < corners * 2; i++) {
8463
- lineTo$1(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
9019
+ lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
8464
9020
  }
8465
9021
  closePath(path);
8466
9022
  }
@@ -8478,77 +9034,6 @@ var LeaferUI = (function (exports) {
8478
9034
  registerUI()
8479
9035
  ], exports.Star);
8480
9036
 
8481
- const { moveTo, lineTo, drawPoints } = PathCommandDataHelper;
8482
- const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
8483
- const { toBounds: toBounds$1 } = PathBounds;
8484
- exports.Line = class Line extends exports.UI {
8485
- get __tag() { return 'Line'; }
8486
- get resizeable() { return !this.points; }
8487
- get toPoint() {
8488
- const { width, rotation } = this.__;
8489
- const to = { x: 0, y: 0 };
8490
- if (width)
8491
- to.x = width;
8492
- if (rotation)
8493
- rotate$1(to, rotation);
8494
- return to;
8495
- }
8496
- set toPoint(value) {
8497
- this.width = getDistance$2(defaultPoint, value);
8498
- this.rotation = getAngle$2(defaultPoint, value);
8499
- if (this.height)
8500
- this.height = 0;
8501
- }
8502
- constructor(data) {
8503
- super(data);
8504
- }
8505
- __updatePath() {
8506
- const path = this.__.path = [];
8507
- if (this.__.points) {
8508
- drawPoints(path, this.__.points, false);
8509
- }
8510
- else {
8511
- moveTo(path, 0, 0);
8512
- lineTo(path, this.width, 0);
8513
- }
8514
- }
8515
- __updateRenderPath() {
8516
- if (this.__.points && this.__.curve) {
8517
- drawPoints(this.__.__pathForRender = [], this.__.points, this.__.curve, false);
8518
- }
8519
- else {
8520
- super.__updateRenderPath();
8521
- }
8522
- }
8523
- __updateBoxBounds() {
8524
- if (this.points) {
8525
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8526
- this.__updateNaturalSize();
8527
- }
8528
- else {
8529
- super.__updateBoxBounds();
8530
- }
8531
- }
8532
- };
8533
- __decorate([
8534
- dataProcessor(LineData)
8535
- ], exports.Line.prototype, "__", void 0);
8536
- __decorate([
8537
- affectStrokeBoundsType('center')
8538
- ], exports.Line.prototype, "strokeAlign", void 0);
8539
- __decorate([
8540
- boundsType(0)
8541
- ], exports.Line.prototype, "height", void 0);
8542
- __decorate([
8543
- pathType()
8544
- ], exports.Line.prototype, "points", void 0);
8545
- __decorate([
8546
- pathType(0)
8547
- ], exports.Line.prototype, "curve", void 0);
8548
- exports.Line = __decorate([
8549
- registerUI()
8550
- ], exports.Line);
8551
-
8552
9037
  exports.Image = class Image extends exports.Rect {
8553
9038
  get __tag() { return 'Image'; }
8554
9039
  get ready() { return this.image ? this.image.ready : false; }
@@ -8599,7 +9084,7 @@ var LeaferUI = (function (exports) {
8599
9084
  this.__.__drawAfterFill = true;
8600
9085
  }
8601
9086
  draw(ui, offset, scale, rotation) {
8602
- ui.__layout.checkUpdate();
9087
+ ui.__layout.update();
8603
9088
  const matrix = new Matrix(ui.__world);
8604
9089
  matrix.invert();
8605
9090
  const m = new Matrix();
@@ -8609,7 +9094,7 @@ var LeaferUI = (function (exports) {
8609
9094
  typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
8610
9095
  if (rotation)
8611
9096
  m.rotate(rotation);
8612
- matrix.preMultiply(m);
9097
+ matrix.multiplyParent(m);
8613
9098
  ui.__render(this.canvas, { matrix });
8614
9099
  this.paint();
8615
9100
  }
@@ -8669,11 +9154,11 @@ var LeaferUI = (function (exports) {
8669
9154
  registerUI()
8670
9155
  ], exports.Canvas);
8671
9156
 
8672
- const { copyAndSpread, includes, spread, setByList } = BoundsHelper;
9157
+ const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8673
9158
  exports.Text = class Text extends exports.UI {
8674
9159
  get __tag() { return 'Text'; }
8675
9160
  get textDrawData() {
8676
- this.__layout.checkUpdate();
9161
+ this.__layout.update();
8677
9162
  return this.__.__textDrawData;
8678
9163
  }
8679
9164
  constructor(data) {
@@ -8704,33 +9189,45 @@ var LeaferUI = (function (exports) {
8704
9189
  const data = this.__;
8705
9190
  const layout = this.__layout;
8706
9191
  const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
8707
- const width = data.__getInput('width');
8708
- const height = data.__getInput('height');
9192
+ const autoWidth = data.__autoWidth;
9193
+ const autoHeight = data.__autoHeight;
8709
9194
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
8710
9195
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
8711
9196
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8712
9197
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8713
- data.__clipText = textOverflow !== 'show' && (width || height);
9198
+ data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
8714
9199
  this.__updateTextDrawData();
8715
9200
  const { bounds } = data.__textDrawData;
8716
9201
  const b = layout.boxBounds;
8717
9202
  if (data.__lineHeight < fontSize)
8718
9203
  spread(bounds, fontSize / 2);
8719
- if (width && height) {
8720
- super.__updateBoxBounds();
9204
+ if (autoWidth || autoHeight) {
9205
+ b.x = autoWidth ? bounds.x : 0;
9206
+ b.y = autoHeight ? bounds.y : 0;
9207
+ b.width = autoWidth ? bounds.width : data.width;
9208
+ b.height = autoHeight ? bounds.height : data.height;
9209
+ const { padding } = data;
9210
+ if (padding) {
9211
+ const [top, right, bottom, left] = MathHelper.fourNumber(padding);
9212
+ if (autoWidth) {
9213
+ b.x -= left;
9214
+ b.width += (right + left);
9215
+ }
9216
+ if (autoHeight) {
9217
+ b.y -= top;
9218
+ b.height += (bottom + top);
9219
+ }
9220
+ }
9221
+ this.__updateNaturalSize();
8721
9222
  }
8722
9223
  else {
8723
- b.x = width ? 0 : bounds.x;
8724
- b.y = height ? 0 : bounds.y;
8725
- b.width = width ? width : bounds.width;
8726
- b.height = height ? height : bounds.height;
8727
- this.__updateNaturalSize();
9224
+ super.__updateBoxBounds();
8728
9225
  }
8729
9226
  const contentBounds = includes(b, bounds) ? b : bounds;
8730
9227
  if (contentBounds !== layout.contentBounds) {
8731
9228
  layout.contentBounds = contentBounds;
8732
9229
  layout.renderChanged = true;
8733
- setByList(data.__textBoxBounds = {}, [b, bounds]);
9230
+ setList(data.__textBoxBounds = {}, [b, bounds]);
8734
9231
  }
8735
9232
  else {
8736
9233
  data.__textBoxBounds = contentBounds;
@@ -8758,6 +9255,9 @@ var LeaferUI = (function (exports) {
8758
9255
  __decorate([
8759
9256
  boundsType(0)
8760
9257
  ], exports.Text.prototype, "padding", void 0);
9258
+ __decorate([
9259
+ surfaceType('#000000')
9260
+ ], exports.Text.prototype, "fill", void 0);
8761
9261
  __decorate([
8762
9262
  affectStrokeBoundsType('outside')
8763
9263
  ], exports.Text.prototype, "strokeAlign", void 0);
@@ -8816,13 +9316,15 @@ var LeaferUI = (function (exports) {
8816
9316
  const { toBounds } = PathBounds;
8817
9317
  exports.Path = class Path extends exports.UI {
8818
9318
  get __tag() { return 'Path'; }
8819
- get resizeable() { return false; }
8820
9319
  constructor(data) {
8821
9320
  super(data);
8822
9321
  }
9322
+ __scaleResize(scaleX, scaleY) {
9323
+ PathScaler.scale(this.__.path, scaleX, scaleY);
9324
+ this.path = this.__.path;
9325
+ }
8823
9326
  __updateBoxBounds() {
8824
9327
  toBounds(this.__.path, this.__layout.boxBounds);
8825
- this.__updateNaturalSize();
8826
9328
  }
8827
9329
  };
8828
9330
  __decorate([
@@ -8891,6 +9393,7 @@ var LeaferUI = (function (exports) {
8891
9393
  get __tag() { return 'Leafer'; }
8892
9394
  get isApp() { return false; }
8893
9395
  get app() { return this.parent || this; }
9396
+ get layoutLocked() { return !this.layouter.running; }
8894
9397
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
8895
9398
  constructor(userConfig, data) {
8896
9399
  super(data);
@@ -8983,13 +9486,18 @@ var LeaferUI = (function (exports) {
8983
9486
  this.emitLeafer(LeaferEvent.STOP);
8984
9487
  }
8985
9488
  }
9489
+ unlockLayout() {
9490
+ this.layouter.start();
9491
+ this.updateLayout();
9492
+ }
9493
+ lockLayout() {
9494
+ this.updateLayout();
9495
+ this.layouter.stop();
9496
+ }
8986
9497
  resize(size) {
8987
9498
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
8988
9499
  Object.keys(data).forEach(key => this[key] = data[key]);
8989
9500
  }
8990
- forceLayout() {
8991
- this.__layout.checkUpdate(true);
8992
- }
8993
9501
  forceFullRender() {
8994
9502
  this.renderer.addBlock(this.canvas.bounds);
8995
9503
  if (this.viewReady)
@@ -9135,7 +9643,7 @@ var LeaferUI = (function (exports) {
9135
9643
  }
9136
9644
  }
9137
9645
  __checkUpdateLayout() {
9138
- this.__layout.checkUpdate();
9646
+ this.__layout.update();
9139
9647
  }
9140
9648
  emitLeafer(type) {
9141
9649
  this.emitEvent(new LeaferEvent(type, this));
@@ -9195,6 +9703,22 @@ var LeaferUI = (function (exports) {
9195
9703
  exports.App = class App extends exports.Leafer {
9196
9704
  get __tag() { return 'App'; }
9197
9705
  get isApp() { return true; }
9706
+ constructor(userConfig, data) {
9707
+ super(userConfig, data);
9708
+ if (userConfig) {
9709
+ const { ground, tree, sky, editor } = userConfig;
9710
+ if (ground)
9711
+ this.ground = this.addLeafer(ground);
9712
+ if (tree || editor)
9713
+ this.tree = this.addLeafer(tree);
9714
+ if (sky || editor)
9715
+ this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
9716
+ if (editor) {
9717
+ this.editor = Creator.editor(editor);
9718
+ this.sky.add(this.editor);
9719
+ }
9720
+ }
9721
+ }
9198
9722
  __setApp() {
9199
9723
  const { canvas } = this;
9200
9724
  const { realCanvas, view } = this.config;
@@ -9211,12 +9735,20 @@ var LeaferUI = (function (exports) {
9211
9735
  }
9212
9736
  start() {
9213
9737
  super.start();
9214
- this.children.forEach(leafer => { leafer.start(); });
9738
+ this.children.forEach(leafer => leafer.start());
9215
9739
  }
9216
9740
  stop() {
9217
- this.children.forEach(leafer => { leafer.stop(); });
9741
+ this.children.forEach(leafer => leafer.stop());
9218
9742
  super.stop();
9219
9743
  }
9744
+ unlockLayout() {
9745
+ super.unlockLayout();
9746
+ this.children.forEach(leafer => leafer.unlockLayout());
9747
+ }
9748
+ lockLayout() {
9749
+ super.lockLayout();
9750
+ this.children.forEach(leafer => leafer.lockLayout());
9751
+ }
9220
9752
  addLeafer(merge) {
9221
9753
  const leafer = new exports.Leafer(merge);
9222
9754
  this.add(leafer);
@@ -9235,7 +9767,7 @@ var LeaferUI = (function (exports) {
9235
9767
  }
9236
9768
  __onPropertyChange() {
9237
9769
  if (Debug.showHitView)
9238
- this.children.forEach(leafer => { leafer.forceUpdate('surface'); });
9770
+ this.children.forEach(leafer => leafer.forceUpdate('surface'));
9239
9771
  }
9240
9772
  __onCreated() {
9241
9773
  this.created = this.children.every(child => child.created);
@@ -9257,14 +9789,14 @@ var LeaferUI = (function (exports) {
9257
9789
  this.renderer.update();
9258
9790
  }
9259
9791
  __render(canvas, _options) {
9260
- this.children.forEach(leafer => { canvas.copyWorld(leafer.canvas); });
9792
+ this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
9261
9793
  }
9262
9794
  __onResize(event) {
9263
- this.children.forEach(leafer => { leafer.resize(event); });
9795
+ this.children.forEach(leafer => leafer.resize(event));
9264
9796
  super.__onResize(event);
9265
9797
  }
9266
9798
  __checkUpdateLayout() {
9267
- this.children.forEach(leafer => { leafer.__layout.checkUpdate(); });
9799
+ this.children.forEach(leafer => leafer.__layout.update());
9268
9800
  }
9269
9801
  __getChildConfig(userConfig) {
9270
9802
  let config = Object.assign({}, this.config);
@@ -9289,7 +9821,7 @@ var LeaferUI = (function (exports) {
9289
9821
  registerUI()
9290
9822
  ], exports.App);
9291
9823
 
9292
- const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper$1, rotate } = MatrixHelper;
9824
+ const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
9293
9825
  function fillOrFitMode(data, mode, box, width, height, rotation) {
9294
9826
  const transform = get$4();
9295
9827
  const swap = rotation && rotation !== 180;
@@ -9299,7 +9831,7 @@ var LeaferUI = (function (exports) {
9299
9831
  const x = box.x + (box.width - width * scale) / 2;
9300
9832
  const y = box.y + (box.height - height * scale) / 2;
9301
9833
  translate$1(transform, x, y);
9302
- scaleHelper$1(transform, scale);
9834
+ scaleHelper(transform, scale);
9303
9835
  if (rotation)
9304
9836
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
9305
9837
  data.scaleX = data.scaleY = scale;
@@ -9311,7 +9843,7 @@ var LeaferUI = (function (exports) {
9311
9843
  if (offset)
9312
9844
  translate$1(transform, offset.x, offset.y);
9313
9845
  if (scale) {
9314
- typeof scale === 'number' ? scaleHelper$1(transform, scale) : scaleHelper$1(transform, scale.x, scale.y);
9846
+ typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
9315
9847
  data.scaleX = transform.a;
9316
9848
  data.scaleY = transform.d;
9317
9849
  }
@@ -9424,6 +9956,10 @@ var LeaferUI = (function (exports) {
9424
9956
  d.__naturalWidth = image.width;
9425
9957
  d.__naturalHeight = image.height;
9426
9958
  if (!d.__getInput('width') || !d.__getInput('height')) {
9959
+ if (ui.__proxyData) {
9960
+ ui.setProxyAttr('width', ui.__.width);
9961
+ ui.setProxyAttr('height', ui.__.height);
9962
+ }
9427
9963
  ui.forceUpdate('width');
9428
9964
  return false;
9429
9965
  }
@@ -9435,22 +9971,19 @@ var LeaferUI = (function (exports) {
9435
9971
  data.target.emitEvent(new ImageEvent(type, data));
9436
9972
  }
9437
9973
 
9438
- const { get: get$2, scale: scaleHelper, copy: copy$1 } = MatrixHelper;
9974
+ const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
9439
9975
  function createPattern(ui, paint, pixelRatio) {
9440
9976
  let { scaleX, scaleY } = ui.__world;
9441
9977
  const id = scaleX + '-' + scaleY;
9442
9978
  if (paint.patternId !== id && !ui.destroyed) {
9443
- paint.patternId = id;
9444
9979
  scaleX = Math.abs(scaleX);
9445
9980
  scaleY = Math.abs(scaleY);
9446
9981
  const { image, data } = paint;
9447
- const maxWidth = image.isSVG ? 4096 : Math.min(image.width, 4096);
9448
- const maxHeight = image.isSVG ? 4096 : Math.min(image.height, 4096);
9449
- let scale, matrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
9982
+ let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
9450
9983
  if (sx) {
9451
- matrix = get$2();
9452
- copy$1(matrix, transform);
9453
- scaleHelper(matrix, 1 / sx, 1 / sy);
9984
+ imageMatrix = get$2();
9985
+ copy$1(imageMatrix, transform);
9986
+ scale(imageMatrix, 1 / sx, 1 / sy);
9454
9987
  scaleX *= sx;
9455
9988
  scaleY *= sy;
9456
9989
  }
@@ -9458,38 +9991,49 @@ var LeaferUI = (function (exports) {
9458
9991
  scaleY *= pixelRatio;
9459
9992
  width *= scaleX;
9460
9993
  height *= scaleY;
9461
- if (width > maxWidth || height > maxHeight) {
9462
- scale = Math.max(width / maxWidth, height / maxHeight);
9994
+ const size = width * height;
9995
+ if (paint.data.mode !== 'repeat') {
9996
+ if (size > Platform.image.maxCacheSize)
9997
+ return false;
9998
+ }
9999
+ let maxSize = Platform.image.maxPatternSize;
10000
+ if (!image.isSVG) {
10001
+ const imageSize = image.width * image.height;
10002
+ if (maxSize > imageSize)
10003
+ maxSize = imageSize;
9463
10004
  }
9464
- if (scale) {
9465
- scaleX /= scale;
9466
- scaleY /= scale;
9467
- width /= scale;
9468
- height /= scale;
10005
+ if (size > maxSize)
10006
+ imageScale = Math.sqrt(size / maxSize);
10007
+ if (imageScale) {
10008
+ scaleX /= imageScale;
10009
+ scaleY /= imageScale;
10010
+ width /= imageScale;
10011
+ height /= imageScale;
9469
10012
  }
9470
10013
  if (sx) {
9471
10014
  scaleX /= sx;
9472
10015
  scaleY /= sy;
9473
10016
  }
9474
10017
  if (transform || scaleX !== 1 || scaleY !== 1) {
9475
- if (!matrix) {
9476
- matrix = get$2();
10018
+ if (!imageMatrix) {
10019
+ imageMatrix = get$2();
9477
10020
  if (transform)
9478
- copy$1(matrix, transform);
10021
+ copy$1(imageMatrix, transform);
9479
10022
  }
9480
- scaleHelper(matrix, 1 / scaleX, 1 / scaleY);
10023
+ scale(imageMatrix, 1 / scaleX, 1 / scaleY);
9481
10024
  }
9482
- const style = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), mode === 'repeat' ? 'repeat' : (Platform.origin.noRepeat || 'no-repeat'));
10025
+ const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), mode === 'repeat' ? 'repeat' : (Platform.origin.noRepeat || 'no-repeat'));
9483
10026
  try {
9484
10027
  if (paint.transform)
9485
10028
  paint.transform = null;
9486
- if (matrix)
9487
- style.setTransform ? style.setTransform(matrix) : paint.transform = matrix;
10029
+ if (imageMatrix)
10030
+ pattern.setTransform ? pattern.setTransform(imageMatrix) : paint.transform = imageMatrix;
9488
10031
  }
9489
10032
  catch (_a) {
9490
- paint.transform = matrix;
10033
+ paint.transform = imageMatrix;
9491
10034
  }
9492
- paint.style = style;
10035
+ paint.style = pattern;
10036
+ paint.patternId = id;
9493
10037
  return true;
9494
10038
  }
9495
10039
  else {
@@ -9497,18 +10041,24 @@ var LeaferUI = (function (exports) {
9497
10041
  }
9498
10042
  }
9499
10043
 
10044
+ const { abs } = Math;
9500
10045
  function checkImage(ui, canvas, paint, allowPaint) {
9501
10046
  const { scaleX, scaleY } = ui.__world;
9502
10047
  if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
9503
10048
  return false;
9504
10049
  }
9505
10050
  else {
10051
+ const { data } = paint;
9506
10052
  if (allowPaint) {
9507
- if (paint.image.isSVG && paint.data.mode !== 'repeat') {
9508
- let { width, height } = paint.data;
9509
- width *= scaleX * canvas.pixelRatio;
9510
- height *= scaleY * canvas.pixelRatio;
9511
- allowPaint = width > 4096 || height > 4096;
10053
+ if (data.mode !== 'repeat') {
10054
+ let { width, height } = data;
10055
+ width *= abs(scaleX) * canvas.pixelRatio;
10056
+ height *= abs(scaleY) * canvas.pixelRatio;
10057
+ if (data.scaleX) {
10058
+ width *= data.scaleX;
10059
+ height *= data.scaleY;
10060
+ }
10061
+ allowPaint = width * height > Platform.image.maxCacheSize;
9512
10062
  }
9513
10063
  else {
9514
10064
  allowPaint = false;
@@ -9517,7 +10067,6 @@ var LeaferUI = (function (exports) {
9517
10067
  if (allowPaint) {
9518
10068
  canvas.save();
9519
10069
  canvas.clip();
9520
- const { data } = paint;
9521
10070
  if (paint.blendMode)
9522
10071
  canvas.blendMode = paint.blendMode;
9523
10072
  if (data.opacity)
@@ -9529,7 +10078,7 @@ var LeaferUI = (function (exports) {
9529
10078
  return true;
9530
10079
  }
9531
10080
  else {
9532
- if (!paint.style) {
10081
+ if (!paint.style || Export$1.running) {
9533
10082
  createPattern(ui, paint, canvas.pixelRatio);
9534
10083
  }
9535
10084
  else {
@@ -9548,7 +10097,7 @@ var LeaferUI = (function (exports) {
9548
10097
  }
9549
10098
 
9550
10099
  function recycleImage(attrName, data) {
9551
- const paints = (attrName === 'fill' ? data._fill : data._stroke);
10100
+ const paints = data['_' + attrName];
9552
10101
  if (paints instanceof Array) {
9553
10102
  let image, recycleMap, input, url;
9554
10103
  for (let i = 0, len = paints.length; i < len; i++) {
@@ -9652,7 +10201,7 @@ var LeaferUI = (function (exports) {
9652
10201
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
9653
10202
  fillText(ui, out);
9654
10203
  out.blendMode = 'normal';
9655
- if (ui.__hasMirror || renderOptions.matrix) {
10204
+ if (ui.__worldFlipped || renderOptions.matrix) {
9656
10205
  canvas.copyWorldByReset(out);
9657
10206
  }
9658
10207
  else {
@@ -9725,7 +10274,7 @@ var LeaferUI = (function (exports) {
9725
10274
  out.stroke();
9726
10275
  options.windingRule ? out.clip(options.windingRule) : out.clip();
9727
10276
  out.clearWorld(ui.__layout.renderBounds);
9728
- if (ui.__hasMirror || renderOptions.matrix) {
10277
+ if (ui.__worldFlipped || renderOptions.matrix) {
9729
10278
  canvas.copyWorldByReset(out);
9730
10279
  }
9731
10280
  else {
@@ -9765,7 +10314,7 @@ var LeaferUI = (function (exports) {
9765
10314
  drawStrokesStyle(strokes, false, ui, out);
9766
10315
  options.windingRule ? out.clip(options.windingRule) : out.clip();
9767
10316
  out.clearWorld(renderBounds);
9768
- if (ui.__hasMirror || renderOptions.matrix) {
10317
+ if (ui.__worldFlipped || renderOptions.matrix) {
9769
10318
  canvas.copyWorldByReset(out);
9770
10319
  }
9771
10320
  else {
@@ -9989,7 +10538,7 @@ var LeaferUI = (function (exports) {
9989
10538
  }
9990
10539
  worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
9991
10540
  }
9992
- if (ui.__hasMirror || renderOptions.matrix) {
10541
+ if (ui.__worldFlipped || renderOptions.matrix) {
9993
10542
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
9994
10543
  }
9995
10544
  else {
@@ -10053,7 +10602,7 @@ var LeaferUI = (function (exports) {
10053
10602
  copyBounds = bounds;
10054
10603
  }
10055
10604
  other.fillWorld(copyBounds, item.color, 'source-in');
10056
- if (ui.__hasMirror || renderOptions.matrix) {
10605
+ if (ui.__worldFlipped || renderOptions.matrix) {
10057
10606
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
10058
10607
  }
10059
10608
  else {
@@ -10551,6 +11100,7 @@ var LeaferUI = (function (exports) {
10551
11100
 
10552
11101
  const Export = {
10553
11102
  export(leaf, filename, options) {
11103
+ Export.running = true;
10554
11104
  return addTask((success) => new Promise((resolve) => {
10555
11105
  const { leafer } = leaf;
10556
11106
  if (leafer) {
@@ -10588,6 +11138,7 @@ var LeaferUI = (function (exports) {
10588
11138
  }
10589
11139
  success({ data });
10590
11140
  resolve();
11141
+ Export.running = false;
10591
11142
  if (unreal)
10592
11143
  canvas.recycle();
10593
11144
  }));
@@ -10595,6 +11146,7 @@ var LeaferUI = (function (exports) {
10595
11146
  else {
10596
11147
  success({ data: false });
10597
11148
  resolve();
11149
+ Export.running = false;
10598
11150
  }
10599
11151
  }));
10600
11152
  }
@@ -10618,12 +11170,15 @@ var LeaferUI = (function (exports) {
10618
11170
 
10619
11171
  exports.Animate = Animate;
10620
11172
  exports.AnimateEvent = AnimateEvent;
11173
+ exports.AroundHelper = AroundHelper;
10621
11174
  exports.AutoBounds = AutoBounds;
10622
11175
  exports.BezierHelper = BezierHelper;
10623
11176
  exports.Bounds = Bounds;
10624
11177
  exports.BoundsHelper = BoundsHelper;
11178
+ exports.BoxData = BoxData;
10625
11179
  exports.BranchHelper = BranchHelper;
10626
11180
  exports.BranchRender = BranchRender;
11181
+ exports.CanvasData = CanvasData;
10627
11182
  exports.CanvasManager = CanvasManager;
10628
11183
  exports.ChildEvent = ChildEvent;
10629
11184
  exports.ColorConvert = ColorConvert$1;
@@ -10632,12 +11187,16 @@ var LeaferUI = (function (exports) {
10632
11187
  exports.DataHelper = DataHelper;
10633
11188
  exports.Debug = Debug;
10634
11189
  exports.Effect = Effect;
11190
+ exports.EllipseData = EllipseData;
10635
11191
  exports.EllipseHelper = EllipseHelper;
10636
11192
  exports.Event = Event;
10637
11193
  exports.EventCreator = EventCreator;
10638
11194
  exports.Export = Export$1;
10639
11195
  exports.FileHelper = FileHelper;
11196
+ exports.FrameData = FrameData;
11197
+ exports.GroupData = GroupData;
10640
11198
  exports.HitCanvasManager = HitCanvasManager;
11199
+ exports.ImageData = ImageData;
10641
11200
  exports.ImageEvent = ImageEvent;
10642
11201
  exports.ImageManager = ImageManager;
10643
11202
  exports.IncrementId = IncrementId;
@@ -10662,9 +11221,11 @@ var LeaferUI = (function (exports) {
10662
11221
  exports.LeafRender = LeafRender;
10663
11222
  exports.LeaferCanvas = LeaferCanvas;
10664
11223
  exports.LeaferCanvasBase = LeaferCanvasBase;
11224
+ exports.LeaferData = LeaferData;
10665
11225
  exports.LeaferEvent = LeaferEvent;
10666
11226
  exports.LeaferImage = LeaferImage;
10667
11227
  exports.LeaferTypeCreator = LeaferTypeCreator;
11228
+ exports.LineData = LineData;
10668
11229
  exports.MathHelper = MathHelper;
10669
11230
  exports.Matrix = Matrix;
10670
11231
  exports.MatrixHelper = MatrixHelper;
@@ -10680,16 +11241,21 @@ var LeaferUI = (function (exports) {
10680
11241
  exports.PathConvert = PathConvert;
10681
11242
  exports.PathCorner = PathCorner;
10682
11243
  exports.PathCreator = PathCreator;
11244
+ exports.PathData = PathData;
10683
11245
  exports.PathDrawer = PathDrawer;
10684
11246
  exports.PathHelper = PathHelper;
10685
11247
  exports.PathNumberCommandLengthMap = PathNumberCommandLengthMap;
10686
11248
  exports.PathNumberCommandMap = PathNumberCommandMap;
11249
+ exports.PathScaler = PathScaler;
11250
+ exports.PenData = PenData;
10687
11251
  exports.Platform = Platform;
10688
11252
  exports.PluginManager = PluginManager;
10689
11253
  exports.Point = Point;
10690
11254
  exports.PointHelper = PointHelper;
10691
11255
  exports.PointerButton = PointerButton;
11256
+ exports.PolygonData = PolygonData;
10692
11257
  exports.PropertyEvent = PropertyEvent;
11258
+ exports.RectData = RectData;
10693
11259
  exports.RectHelper = RectHelper;
10694
11260
  exports.RectRender = RectRender;
10695
11261
  exports.RenderEvent = RenderEvent;
@@ -10697,23 +11263,26 @@ var LeaferUI = (function (exports) {
10697
11263
  exports.ResizeEvent = ResizeEvent;
10698
11264
  exports.Run = Run;
10699
11265
  exports.Selector = Selector;
11266
+ exports.StarData = StarData;
10700
11267
  exports.StringNumberMap = StringNumberMap;
10701
11268
  exports.TaskItem = TaskItem;
10702
11269
  exports.TaskProcessor = TaskProcessor;
10703
11270
  exports.TextConvert = TextConvert$1;
10704
- exports.TwoPointBounds = TwoPointBounds;
11271
+ exports.TextData = TextData;
10705
11272
  exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
10706
11273
  exports.UIBounds = UIBounds;
10707
11274
  exports.UICreator = UICreator;
11275
+ exports.UIData = UIData;
10708
11276
  exports.UIEvent = UIEvent;
10709
11277
  exports.UIHit = UIHit;
10710
11278
  exports.UIRender = UIRender;
11279
+ exports.UnitConvert = UnitConvert;
10711
11280
  exports.WaitHelper = WaitHelper;
10712
11281
  exports.WatchEvent = WatchEvent;
10713
11282
  exports.Watcher = Watcher;
10714
11283
  exports.affectRenderBoundsType = affectRenderBoundsType;
10715
11284
  exports.affectStrokeBoundsType = affectStrokeBoundsType;
10716
- exports.aliasType = aliasType;
11285
+ exports.autoLayoutType = autoLayoutType;
10717
11286
  exports.boundsType = boundsType;
10718
11287
  exports.canvasPatch = canvasPatch;
10719
11288
  exports.canvasSizeAttrs = canvasSizeAttrs;
@@ -10739,7 +11308,6 @@ var LeaferUI = (function (exports) {
10739
11308
  exports.rewriteAble = rewriteAble;
10740
11309
  exports.rotationType = rotationType;
10741
11310
  exports.scaleType = scaleType;
10742
- exports.setDefaultValue = setDefaultValue;
10743
11311
  exports.sortType = sortType;
10744
11312
  exports.strokeType = strokeType;
10745
11313
  exports.surfaceType = surfaceType;