@leafer-ui/miniapp 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.
@@ -1,5 +1,9 @@
1
1
  const Platform = {
2
- imageSuffix: 'leaf'
2
+ image: {
3
+ maxCacheSize: 2560 * 1600,
4
+ maxPatternSize: 4096 * 2160,
5
+ suffix: 'leaf'
6
+ }
3
7
  };
4
8
 
5
9
  const Creator = {};
@@ -24,6 +28,7 @@ const IncrementId = {
24
28
  };
25
29
  const I$2 = IncrementId;
26
30
 
31
+ const { round, pow: pow$1, PI: PI$4 } = Math;
27
32
  const MathHelper = {
28
33
  within(value, min, max) {
29
34
  if (value < min)
@@ -32,20 +37,18 @@ const MathHelper = {
32
37
  value = max;
33
38
  return value;
34
39
  },
35
- fourNumber(num) {
36
- let one, two, three, four;
40
+ fourNumber(num, maxValue) {
41
+ let data;
37
42
  if (num instanceof Array) {
38
43
  switch (num.length) {
39
44
  case 4:
40
- return num;
45
+ data = num;
46
+ break;
41
47
  case 2:
42
- one = three = num[0];
43
- two = four = num[1];
48
+ data = [num[0], num[1], num[0], num[1]];
44
49
  break;
45
50
  case 3:
46
- one = num[0];
47
- two = four = num[1];
48
- three = num[2];
51
+ data = [num[0], num[1], num[2], num[1]];
49
52
  break;
50
53
  case 1:
51
54
  num = num[0];
@@ -54,7 +57,13 @@ const MathHelper = {
54
57
  num = 0;
55
58
  }
56
59
  }
57
- return one === undefined ? [num, num, num, num] : [one, two, three, four];
60
+ if (!data)
61
+ data = [num, num, num, num];
62
+ if (maxValue)
63
+ for (let i = 0; i < 4; i++)
64
+ if (data[i] > maxValue)
65
+ data[i] = maxValue;
66
+ return data;
58
67
  },
59
68
  formatRotation(rotation, unsign) {
60
69
  rotation %= 360;
@@ -70,29 +79,37 @@ const MathHelper = {
70
79
  }
71
80
  return rotation;
72
81
  },
73
- getGapRotation(rotation, gap) {
82
+ getGapRotation(addRotation, gap, oldRotation = 0) {
83
+ let rotation = addRotation + oldRotation;
74
84
  if (gap > 1) {
75
85
  const r = Math.abs(rotation % gap);
76
86
  if (r < 1 || r > gap - 1)
77
87
  rotation = Math.round(rotation / gap) * gap;
78
88
  }
79
- return rotation;
89
+ return rotation - oldRotation;
80
90
  },
81
- formatSkew(skew) {
82
- return MathHelper.within(skew, -90, 90);
91
+ float(num, maxLength) {
92
+ const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
93
+ num = round(num * a) / a;
94
+ return num === -0 ? 0 : num;
83
95
  }
84
96
  };
85
- const OneRadian = Math.PI / 180;
86
- const PI2 = Math.PI * 2;
87
- const PI_2 = Math.PI / 2;
97
+ const OneRadian = PI$4 / 180;
98
+ const PI2 = PI$4 * 2;
99
+ const PI_2 = PI$4 / 2;
88
100
 
89
- const { sin: sin$6, cos: cos$6, acos, atan, sqrt: sqrt$3, PI: PI$3 } = Math;
90
- const tempPoint$1 = {};
101
+ const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
102
+ const { float } = MathHelper;
103
+ const tempPoint$2 = {};
91
104
  function get$5() {
92
105
  return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
93
106
  }
107
+ function getWorld() {
108
+ 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 });
109
+ }
94
110
  const MatrixHelper = {
95
111
  defaultMatrix: get$5(),
112
+ defaultWorld: getWorld(),
96
113
  tempMatrix: {},
97
114
  set(t, a = 1, b = 0, c = 0, d = 1, e = 0, f = 0) {
98
115
  t.a = a;
@@ -103,6 +120,7 @@ const MatrixHelper = {
103
120
  t.f = f;
104
121
  },
105
122
  get: get$5,
123
+ getWorld,
106
124
  copy(t, matrix) {
107
125
  t.a = matrix.a;
108
126
  t.b = matrix.b;
@@ -119,115 +137,163 @@ const MatrixHelper = {
119
137
  t.e += t.a * x + t.c * y;
120
138
  t.f += t.b * x + t.d * y;
121
139
  },
122
- scale(t, x, y = x) {
123
- t.a *= x;
124
- t.b *= x;
125
- t.c *= y;
126
- t.d *= y;
127
- },
128
- scaleOfOuter(t, origin, x, y = x) {
129
- M$6.toInnerPoint(t, origin, tempPoint$1);
130
- M$6.scaleOfInner(t, tempPoint$1, x, y);
131
- },
132
- scaleOfInner(t, origin, x, y = x) {
133
- M$6.translateInner(t, origin.x, origin.y);
134
- M$6.scale(t, x, y);
135
- M$6.translateInner(t, -origin.x, -origin.y);
136
- },
137
- rotate(t, angle) {
138
- angle *= OneRadian;
139
- const cosR = cos$6(angle);
140
- const sinR = sin$6(angle);
141
- const { a, b, c, d } = t;
142
- t.a = (a * cosR) - (b * sinR);
143
- t.b = (a * sinR) + (b * cosR);
144
- t.c = (c * cosR) - (d * sinR);
145
- t.d = (c * sinR) + (d * cosR);
140
+ scale(t, scaleX, scaleY = scaleX) {
141
+ t.a *= scaleX;
142
+ t.b *= scaleX;
143
+ t.c *= scaleY;
144
+ t.d *= scaleY;
146
145
  },
147
- rotateOfOuter(t, origin, angle) {
148
- M$6.toInnerPoint(t, origin, tempPoint$1);
149
- M$6.rotateOfInner(t, tempPoint$1, angle);
146
+ scaleOfOuter(t, origin, scaleX, scaleY) {
147
+ M$7.toInnerPoint(t, origin, tempPoint$2);
148
+ M$7.scaleOfInner(t, tempPoint$2, scaleX, scaleY);
150
149
  },
151
- rotateOfInner(t, origin, angle) {
152
- M$6.translateInner(t, origin.x, origin.y);
153
- M$6.rotate(t, angle);
154
- M$6.translateInner(t, -origin.x, -origin.y);
150
+ scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
151
+ M$7.translateInner(t, origin.x, origin.y);
152
+ M$7.scale(t, scaleX, scaleY);
153
+ M$7.translateInner(t, -origin.x, -origin.y);
155
154
  },
156
- skew(t, x, y) {
155
+ rotate(t, rotation) {
156
+ const { a, b, c, d } = t;
157
+ rotation *= OneRadian;
158
+ const cosR = cos$5(rotation);
159
+ const sinR = sin$5(rotation);
160
+ t.a = a * cosR - b * sinR;
161
+ t.b = a * sinR + b * cosR;
162
+ t.c = c * cosR - d * sinR;
163
+ t.d = c * sinR + d * cosR;
164
+ },
165
+ rotateOfOuter(t, origin, rotation) {
166
+ M$7.toInnerPoint(t, origin, tempPoint$2);
167
+ M$7.rotateOfInner(t, tempPoint$2, rotation);
168
+ },
169
+ rotateOfInner(t, origin, rotation) {
170
+ M$7.translateInner(t, origin.x, origin.y);
171
+ M$7.rotate(t, rotation);
172
+ M$7.translateInner(t, -origin.x, -origin.y);
173
+ },
174
+ skew(t, skewX, skewY) {
157
175
  const { a, b, c, d } = t;
158
- if (y) {
159
- y *= OneRadian;
160
- t.a = a + c * y;
161
- t.b = b + d * y;
176
+ if (skewY) {
177
+ skewY *= OneRadian;
178
+ t.a = a + c * skewY;
179
+ t.b = b + d * skewY;
162
180
  }
163
- if (x) {
164
- x *= OneRadian;
165
- t.c = c + a * x;
166
- t.d = d + b * x;
181
+ if (skewX) {
182
+ skewX *= OneRadian;
183
+ t.c = c + a * skewX;
184
+ t.d = d + b * skewX;
167
185
  }
168
186
  },
169
- skewOfOuter(t, origin, x, y) {
170
- M$6.toInnerPoint(t, origin, tempPoint$1);
171
- M$6.skewOfInner(t, tempPoint$1, x, y);
187
+ skewOfOuter(t, origin, skewX, skewY) {
188
+ M$7.toInnerPoint(t, origin, tempPoint$2);
189
+ M$7.skewOfInner(t, tempPoint$2, skewX, skewY);
172
190
  },
173
- skewOfInner(t, origin, x, y) {
174
- M$6.translateInner(t, origin.x, origin.y);
175
- M$6.skew(t, x, y);
176
- M$6.translateInner(t, -origin.x, -origin.y);
191
+ skewOfInner(t, origin, skewX, skewY = 0) {
192
+ M$7.translateInner(t, origin.x, origin.y);
193
+ M$7.skew(t, skewX, skewY);
194
+ M$7.translateInner(t, -origin.x, -origin.y);
177
195
  },
178
- multiply(t, matrix) {
196
+ multiply(t, child) {
179
197
  const { a, b, c, d, e, f } = t;
180
- t.a = matrix.a * a + matrix.b * c;
181
- t.b = matrix.a * b + matrix.b * d;
182
- t.c = matrix.c * a + matrix.d * c;
183
- t.d = matrix.c * b + matrix.d * d;
184
- t.e = matrix.e * a + matrix.f * c + e;
185
- t.f = matrix.e * b + matrix.f * d + f;
186
- },
187
- preMultiply(t, matrix) {
188
- const { a, b, c, d, e, f } = t;
189
- if (matrix.a !== 1 || matrix.b !== 0 || matrix.c !== 0 || matrix.d !== 1) {
190
- t.a = (a * matrix.a) + (b * matrix.c);
191
- t.b = (a * matrix.b) + (b * matrix.d);
192
- t.c = (c * matrix.a) + (d * matrix.c);
193
- t.d = (c * matrix.b) + (d * matrix.d);
198
+ t.a = child.a * a + child.b * c;
199
+ t.b = child.a * b + child.b * d;
200
+ t.c = child.c * a + child.d * c;
201
+ t.d = child.c * b + child.d * d;
202
+ t.e = child.e * a + child.f * c + e;
203
+ t.f = child.e * b + child.f * d + f;
204
+ },
205
+ multiplyParent(t, parent, to, abcdChanged, childLayout) {
206
+ const { e, f } = t;
207
+ to || (to = t);
208
+ if (abcdChanged === undefined)
209
+ abcdChanged = t.a !== 1 || t.b || t.c || t.d !== 1;
210
+ if (abcdChanged) {
211
+ const { a, b, c, d } = t;
212
+ to.a = a * parent.a + b * parent.c;
213
+ to.b = a * parent.b + b * parent.d;
214
+ to.c = c * parent.a + d * parent.c;
215
+ to.d = c * parent.b + d * parent.d;
216
+ if (childLayout)
217
+ M$7.multiplyParentLayout(to, parent, childLayout);
218
+ }
219
+ else {
220
+ to.a = parent.a;
221
+ to.b = parent.b;
222
+ to.c = parent.c;
223
+ to.d = parent.d;
224
+ if (childLayout)
225
+ M$7.multiplyParentLayout(to, parent);
226
+ }
227
+ to.e = e * parent.a + f * parent.c + parent.e;
228
+ to.f = e * parent.b + f * parent.d + parent.f;
229
+ },
230
+ multiplyParentLayout(t, parent, child) {
231
+ if (child) {
232
+ t.scaleX = parent.scaleX * child.scaleX;
233
+ t.scaleY = parent.scaleY * child.scaleY;
234
+ t.rotation = parent.rotation + child.rotation;
235
+ t.skewX = parent.skewX + child.skewX;
236
+ t.skewY = parent.skewY + child.skewY;
237
+ }
238
+ else {
239
+ t.scaleX = parent.scaleX;
240
+ t.scaleY = parent.scaleY;
241
+ t.rotation = parent.rotation;
242
+ t.skewX = parent.skewX;
243
+ t.skewY = parent.skewY;
194
244
  }
195
- t.e = (e * matrix.a) + (f * matrix.c) + matrix.e;
196
- t.f = (e * matrix.b) + (f * matrix.d) + matrix.f;
197
245
  },
198
- divide(t, matrix) {
199
- M$6.preMultiply(t, M$6.tempInvert(matrix));
246
+ divide(t, child) {
247
+ M$7.multiply(t, M$7.tempInvert(child));
248
+ },
249
+ divideParent(t, parent) {
250
+ M$7.multiplyParent(t, M$7.tempInvert(parent));
200
251
  },
201
252
  tempInvert(t) {
202
- const { tempMatrix: temp } = M$6;
203
- M$6.copy(temp, t);
204
- M$6.invert(temp);
205
- return temp;
253
+ const { tempMatrix } = M$7;
254
+ M$7.copy(tempMatrix, t);
255
+ M$7.invert(tempMatrix);
256
+ return tempMatrix;
206
257
  },
207
258
  invert(t) {
208
259
  const { a, b, c, d, e, f } = t;
209
- const s = 1 / (a * d - b * c);
210
- t.a = d * s;
211
- t.b = -b * s;
212
- t.c = -c * s;
213
- t.d = a * s;
214
- t.e = -(e * d - f * c) * s;
215
- t.f = -(f * a - e * b) * s;
260
+ if (!b && !c) {
261
+ if (a === 1 && d === 1) {
262
+ t.e = -e;
263
+ t.f = -f;
264
+ }
265
+ else {
266
+ const s = 1 / (a * d);
267
+ t.a = d * s;
268
+ t.d = a * s;
269
+ t.e = -e * d * s;
270
+ t.f = -f * a * s;
271
+ }
272
+ }
273
+ else {
274
+ const s = 1 / (a * d - b * c);
275
+ t.a = d * s;
276
+ t.b = -b * s;
277
+ t.c = -c * s;
278
+ t.d = a * s;
279
+ t.e = -(e * d - f * c) * s;
280
+ t.f = -(f * a - e * b) * s;
281
+ }
216
282
  },
217
283
  toOuterPoint(t, inner, to, distance) {
218
284
  const { x, y } = inner;
219
285
  to || (to = inner);
220
- to.x = (x * t.a) + (y * t.c);
221
- to.y = (x * t.b) + (y * t.d);
286
+ to.x = x * t.a + y * t.c;
287
+ to.y = x * t.b + y * t.d;
222
288
  if (!distance) {
223
289
  to.x += t.e;
224
290
  to.y += t.f;
225
291
  }
226
292
  },
227
293
  toInnerPoint(t, outer, to, distance) {
228
- const { x, y } = outer;
229
294
  const { a, b, c, d } = t;
230
295
  const s = 1 / (a * d - b * c);
296
+ const { x, y } = outer;
231
297
  to || (to = outer);
232
298
  to.x = (x * d - y * c) * s;
233
299
  to.y = (y * a - x * b) * s;
@@ -237,40 +303,84 @@ const MatrixHelper = {
237
303
  to.y -= (f * a - e * b) * s;
238
304
  }
239
305
  },
240
- decompose(t) {
241
- const { a, b, c, d } = t;
242
- let scaleX = a, scaleY = d, rotation = 0, skewX = 0, skewY = 0;
306
+ setLayout(t, layout, origin, bcChanged) {
307
+ const { x, y, scaleX, scaleY } = layout;
308
+ if (bcChanged === undefined)
309
+ bcChanged = layout.rotation || layout.skewX || layout.skewY;
310
+ if (bcChanged) {
311
+ const { rotation, skewX, skewY } = layout;
312
+ const r = rotation * OneRadian;
313
+ const cosR = cos$5(r);
314
+ const sinR = sin$5(r);
315
+ if (skewX || skewY) {
316
+ const sx = skewX * OneRadian;
317
+ const sy = skewY * OneRadian;
318
+ t.a = (cosR + sy * -sinR) * scaleX;
319
+ t.b = (sinR + sy * cosR) * scaleX;
320
+ t.c = (-sinR + sx * cosR) * scaleY;
321
+ t.d = (cosR + sx * sinR) * scaleY;
322
+ }
323
+ else {
324
+ t.a = cosR * scaleX;
325
+ t.b = sinR * scaleX;
326
+ t.c = -sinR * scaleY;
327
+ t.d = cosR * scaleY;
328
+ }
329
+ }
330
+ else {
331
+ t.a = scaleX;
332
+ t.b = 0;
333
+ t.c = 0;
334
+ t.d = scaleY;
335
+ }
336
+ t.e = x;
337
+ t.f = y;
338
+ if (origin)
339
+ M$7.translateInner(t, -origin.x, -origin.y);
340
+ },
341
+ getLayout(t, origin, firstSkewY) {
342
+ const { a, b, c, d, e, f } = t;
343
+ let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
243
344
  if (b || c) {
244
345
  const s = a * d - b * c;
245
- const k = a * c + b * d;
246
- if (b) {
247
- const ab = a * a + b * b;
248
- scaleX = sqrt$3(ab);
346
+ if (c && !firstSkewY) {
347
+ scaleX = sqrt$3(a * a + b * b);
249
348
  scaleY = s / scaleX;
250
- const r = a / scaleX;
251
- rotation = b > 0 ? acos(r) : -acos(r);
252
- skewX = atan(k / ab) / OneRadian;
349
+ const cosR = a / scaleX;
350
+ rotation = b > 0 ? acos(cosR) : -acos(cosR);
253
351
  }
254
352
  else {
255
- const cd = c * c + d * d;
256
- scaleY = sqrt$3(cd);
353
+ scaleY = sqrt$3(c * c + d * d);
257
354
  scaleX = s / scaleY;
258
- const r = c / scaleY;
259
- rotation = PI$3 / 2 - (d > 0 ? acos(-r) : -acos(r));
260
- skewY = atan(k / cd) / OneRadian;
355
+ const cosR = c / scaleY;
356
+ rotation = PI_2 - (d > 0 ? acos(-cosR) : -acos(cosR));
261
357
  }
262
- rotation /= OneRadian;
358
+ const cosR = cos$5(rotation);
359
+ const sinR = sin$5(rotation);
360
+ scaleX = float(scaleX), scaleY = float(scaleY);
361
+ skewX = float((c / scaleY + sinR) / cosR / OneRadian);
362
+ skewY = float((b / scaleX - sinR) / cosR / OneRadian);
363
+ rotation = float(rotation / OneRadian);
364
+ }
365
+ else {
366
+ scaleX = a;
367
+ scaleY = d;
368
+ rotation = skewX = skewY = 0;
369
+ }
370
+ if (origin) {
371
+ x += origin.x * a + origin.y * c;
372
+ y += origin.x * b + origin.y * d;
263
373
  }
264
- return { x: t.e, y: t.f, scaleX, scaleY, rotation, skewX, skewY };
374
+ return { x, y, scaleX, scaleY, rotation, skewX, skewY };
265
375
  },
266
376
  reset(t) {
267
- M$6.set(t);
377
+ M$7.set(t);
268
378
  }
269
379
  };
270
- const M$6 = MatrixHelper;
380
+ const M$7 = MatrixHelper;
271
381
 
272
382
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$2 } = MatrixHelper;
273
- const { sin: sin$5, cos: cos$5, abs: abs$1, sqrt: sqrt$2, atan2: atan2$2 } = Math;
383
+ const { sin: sin$4, cos: cos$4, abs: abs$3, sqrt: sqrt$2, atan2: atan2$2, min: min$1, PI: PI$3 } = Math;
274
384
  const PointHelper = {
275
385
  defaultPoint: { x: 0, y: 0 },
276
386
  tempPoint: {},
@@ -291,32 +401,33 @@ const PointHelper = {
291
401
  t.x += x;
292
402
  t.y += y;
293
403
  },
294
- rotate(t, rotation, center) {
295
- if (!center)
296
- center = P$5.defaultPoint;
297
- const cosR = cos$5(rotation * OneRadian);
298
- const sinR = sin$5(rotation * OneRadian);
299
- const rx = t.x - center.x;
300
- const ry = t.y - center.y;
301
- t.x = center.x + rx * cosR - ry * sinR;
302
- t.y = center.y + rx * sinR + ry * cosR;
404
+ rotate(t, rotation, origin) {
405
+ if (!origin)
406
+ origin = P$6.defaultPoint;
407
+ rotation *= OneRadian;
408
+ const cosR = cos$4(rotation);
409
+ const sinR = sin$4(rotation);
410
+ const rx = t.x - origin.x;
411
+ const ry = t.y - origin.y;
412
+ t.x = origin.x + rx * cosR - ry * sinR;
413
+ t.y = origin.y + rx * sinR + ry * cosR;
303
414
  },
304
415
  tempToInnerOf(t, matrix) {
305
- const { tempPoint: temp } = P$5;
306
- P$5.copy(temp, t);
416
+ const { tempPoint: temp } = P$6;
417
+ P$6.copy(temp, t);
307
418
  toInnerPoint$2(matrix, temp, temp);
308
419
  return temp;
309
420
  },
310
421
  tempToOuterOf(t, matrix) {
311
- const { tempPoint: temp } = P$5;
312
- P$5.copy(temp, t);
422
+ const { tempPoint: temp } = P$6;
423
+ P$6.copy(temp, t);
313
424
  toOuterPoint$2(matrix, temp, temp);
314
425
  return temp;
315
426
  },
316
427
  tempToInnerRadiusPointOf(t, matrix) {
317
- const { tempRadiusPoint: temp } = P$5;
318
- P$5.copy(temp, t);
319
- P$5.toInnerRadiusPointOf(t, matrix, temp);
428
+ const { tempRadiusPoint: temp } = P$6;
429
+ P$6.copy(temp, t);
430
+ P$6.toInnerRadiusPointOf(t, matrix, temp);
320
431
  return temp;
321
432
  },
322
433
  toInnerRadiusPointOf(t, matrix, to) {
@@ -334,53 +445,78 @@ const PointHelper = {
334
445
  getCenter(t, to) {
335
446
  return { x: t.x + (to.x - t.x) / 2, y: t.y + (to.y - t.y) / 2 };
336
447
  },
448
+ getCenterX(x1, x2) {
449
+ return x1 + (x2 - x1) / 2;
450
+ },
451
+ getCenterY(y1, y2) {
452
+ return y1 + (y2 - y1) / 2;
453
+ },
337
454
  getDistance(t, point) {
338
- const x = abs$1(point.x - t.x);
339
- const y = abs$1(point.y - t.y);
455
+ return P$6.getDistanceFrom(t.x, t.y, point.x, point.y);
456
+ },
457
+ getDistanceFrom(x1, y1, x2, y2) {
458
+ const x = abs$3(x2 - x1);
459
+ const y = abs$3(y2 - y1);
340
460
  return sqrt$2(x * x + y * y);
341
461
  },
462
+ getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
463
+ return min$1(P$6.getDistanceFrom(x1, y1, x2, y2), P$6.getDistanceFrom(x2, y2, x3, y3));
464
+ },
342
465
  getAngle(t, to) {
343
- return P$5.getAtan2(t, to) / OneRadian;
466
+ return P$6.getAtan2(t, to) / OneRadian;
344
467
  },
345
- getChangeAngle(t, orign, to, toOrigin) {
468
+ getRotation(t, origin, to, toOrigin) {
346
469
  if (!toOrigin)
347
- toOrigin = orign;
348
- let fromAngle = P$5.getAngle(t, orign);
349
- let toAngle = P$5.getAngle(to, toOrigin);
350
- const angle = toAngle - fromAngle;
351
- return angle < -180 ? angle + 360 : angle;
470
+ toOrigin = origin;
471
+ return P$6.getRadianFrom(t.x, t.y, origin.x, origin.y, to.x, to.y, toOrigin.x, toOrigin.y) / OneRadian;
472
+ },
473
+ getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
474
+ if (toOriginX === undefined)
475
+ toOriginX = originX, toOriginY = originY;
476
+ let fromAngle = atan2$2(fromY - originY, fromX - originX);
477
+ let toAngle = atan2$2(toY - toOriginY, toX - toOriginX);
478
+ const radian = toAngle - fromAngle;
479
+ return radian < -PI$3 ? radian + PI2 : radian;
352
480
  },
353
481
  getAtan2(t, to) {
354
482
  return atan2$2(to.y - t.y, to.x - t.x);
355
483
  },
356
484
  getDistancePoint(t, to, distance) {
357
- const r = P$5.getAtan2(t, to);
358
- return { x: t.x + cos$5(r) * distance, y: t.y + sin$5(r) * distance };
485
+ const r = P$6.getAtan2(t, to);
486
+ return { x: t.x + cos$4(r) * distance, y: t.y + sin$4(r) * distance };
359
487
  },
360
488
  reset(t) {
361
- P$5.reset(t);
489
+ P$6.reset(t);
362
490
  }
363
491
  };
364
- const P$5 = PointHelper;
492
+ const P$6 = PointHelper;
365
493
 
366
494
  class Point {
367
495
  constructor(x, y) {
368
- typeof x === 'object' ? PointHelper.copy(this, x) : PointHelper.set(this, x, y);
496
+ this.set(x, y);
369
497
  }
370
498
  set(x, y) {
371
- PointHelper.set(this, x, y);
372
- }
373
- copy(point) {
374
- PointHelper.copy(this, point);
499
+ typeof x === 'object' ? PointHelper.copy(this, x) : PointHelper.set(this, x, y);
375
500
  return this;
376
501
  }
502
+ get() {
503
+ const { x, y } = this;
504
+ return { x, y };
505
+ }
377
506
  clone() {
378
507
  return new Point(this);
379
508
  }
380
- rotate(angle, center) {
381
- PointHelper.rotate(this, angle, center);
509
+ rotate(rotation, origin) {
510
+ PointHelper.rotate(this, rotation, origin);
511
+ return this;
512
+ }
513
+ rotateOf(origin, rotation) {
514
+ PointHelper.rotate(this, rotation, origin);
382
515
  return this;
383
516
  }
517
+ getRotation(origin, to, toOrigin) {
518
+ return PointHelper.getRotation(this, origin, to, toOrigin);
519
+ }
384
520
  toInnerOf(matrix, to) {
385
521
  PointHelper.toInnerOf(this, matrix, to);
386
522
  return this;
@@ -390,11 +526,14 @@ class Point {
390
526
  return this;
391
527
  }
392
528
  getCenter(to) {
393
- return PointHelper.getCenter(this, to);
529
+ return new Point(PointHelper.getCenter(this, to));
394
530
  }
395
531
  getDistance(to) {
396
532
  return PointHelper.getDistance(this, to);
397
533
  }
534
+ getDistancePoint(to, distance) {
535
+ return new Point(PointHelper.getDistancePoint(this, to, distance));
536
+ }
398
537
  getAngle(to) {
399
538
  return PointHelper.getAngle(this, to);
400
539
  }
@@ -403,20 +542,22 @@ class Point {
403
542
  }
404
543
  reset() {
405
544
  PointHelper.reset(this);
545
+ return this;
406
546
  }
407
547
  }
408
548
 
409
549
  class Matrix {
410
550
  constructor(a, b, c, d, e, f) {
411
- typeof a === 'object' ? MatrixHelper.copy(this, a) : MatrixHelper.set(this, a, b, c, d, e, f);
551
+ this.set(a, b, c, d, e, f);
412
552
  }
413
553
  set(a, b, c, d, e, f) {
414
- MatrixHelper.set(this, a, b, c, d, e, f);
415
- }
416
- copy(matrix) {
417
- MatrixHelper.copy(this, matrix);
554
+ typeof a === 'object' ? MatrixHelper.copy(this, a) : MatrixHelper.set(this, a, b, c, d, e, f);
418
555
  return this;
419
556
  }
557
+ get() {
558
+ const { a, b, c, d, e, f } = this;
559
+ return { a, b, c, d, e, f };
560
+ }
420
561
  clone() {
421
562
  return new Matrix(this);
422
563
  }
@@ -464,16 +605,20 @@ class Matrix {
464
605
  MatrixHelper.skewOfInner(this, origin, x, y);
465
606
  return this;
466
607
  }
467
- multiply(matrix) {
468
- MatrixHelper.multiply(this, matrix);
608
+ multiply(child) {
609
+ MatrixHelper.multiply(this, child);
469
610
  return this;
470
611
  }
471
- preMultiply(matrix) {
472
- MatrixHelper.preMultiply(this, matrix);
612
+ multiplyParent(parent) {
613
+ MatrixHelper.multiplyParent(this, parent);
473
614
  return this;
474
615
  }
475
- divide(matrix) {
476
- MatrixHelper.divide(this, matrix);
616
+ divide(child) {
617
+ MatrixHelper.divide(this, child);
618
+ return this;
619
+ }
620
+ divideParent(parent) {
621
+ MatrixHelper.divideParent(this, parent);
477
622
  return this;
478
623
  }
479
624
  invert() {
@@ -486,8 +631,12 @@ class Matrix {
486
631
  toInnerPoint(outer, to, distance) {
487
632
  MatrixHelper.toInnerPoint(this, outer, to, distance);
488
633
  }
489
- decompose() {
490
- return MatrixHelper.decompose(this);
634
+ setLayout(data, origin) {
635
+ MatrixHelper.setLayout(this, data, origin);
636
+ return this;
637
+ }
638
+ getLayout(origin, firstSkewY) {
639
+ return MatrixHelper.getLayout(this, origin, firstSkewY);
491
640
  }
492
641
  reset() {
493
642
  MatrixHelper.reset(this);
@@ -516,7 +665,7 @@ const TwoPointBoundsHelper = {
516
665
  t.maxX = pb.maxX;
517
666
  t.maxY = pb.maxY;
518
667
  },
519
- add(t, pb) {
668
+ addPointBounds(t, pb) {
520
669
  t.minX = pb.minX < t.minX ? pb.minX : t.minX;
521
670
  t.minY = pb.minY < t.minY ? pb.minY : t.minY;
522
671
  t.maxX = pb.maxX > t.maxX ? pb.maxX : t.maxX;
@@ -531,11 +680,11 @@ const TwoPointBoundsHelper = {
531
680
  };
532
681
  const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
533
682
 
534
- const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$4 } = TwoPointBoundsHelper;
683
+ const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
535
684
  const { toOuterPoint: toOuterPoint$1 } = MatrixHelper;
536
685
  let right, bottom, boundsRight, boundsBottom;
537
686
  const point = {};
538
- const toPoint = {};
687
+ const toPoint$1 = {};
539
688
  const BoundsHelper = {
540
689
  tempBounds: {},
541
690
  set(t, x = 0, y = 0, width = 0, height = 0) {
@@ -555,12 +704,10 @@ const BoundsHelper = {
555
704
  spreadY = spreadX;
556
705
  B.set(t, bounds.x - spreadX, bounds.y - spreadY, bounds.width + spreadX * 2, bounds.height + spreadY * 2);
557
706
  },
558
- right(t) {
559
- return t.x + t.width;
560
- },
561
- bottom(t) {
562
- return t.y + t.height;
563
- },
707
+ minX(t) { return t.width > 0 ? t.x : t.x + t.width; },
708
+ minY(t) { return t.height > 0 ? t.y : t.y + t.height; },
709
+ maxX(t) { return t.width > 0 ? t.x + t.width : t.x; },
710
+ maxY(t) { return t.height > 0 ? t.y + t.height : t.y; },
564
711
  move(t, x, y) {
565
712
  t.x += x;
566
713
  t.y += y;
@@ -578,8 +725,8 @@ const BoundsHelper = {
578
725
  copy$7(to, t);
579
726
  }
580
727
  if (parent) {
581
- to.offsetX = -(B.right(parent) - t.x);
582
- to.offsetY = -(B.bottom(parent) - t.y);
728
+ to.offsetX = -(B.maxX(parent) - t.x);
729
+ to.offsetY = -(B.maxY(parent) - t.y);
583
730
  }
584
731
  else {
585
732
  to.offsetX = t.x + t.width;
@@ -635,18 +782,18 @@ const BoundsHelper = {
635
782
  else {
636
783
  point.x = t.x;
637
784
  point.y = t.y;
638
- toOuterPoint$1(matrix, point, toPoint);
639
- setPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
785
+ toOuterPoint$1(matrix, point, toPoint$1);
786
+ setPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
640
787
  point.x = t.x + t.width;
641
- toOuterPoint$1(matrix, point, toPoint);
642
- addPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
788
+ toOuterPoint$1(matrix, point, toPoint$1);
789
+ addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
643
790
  point.y = t.y + t.height;
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.x = t.x;
647
- toOuterPoint$1(matrix, point, toPoint);
648
- addPoint$2(tempPointBounds$1, toPoint.x, toPoint.y);
649
- toBounds$4(tempPointBounds$1, to);
794
+ toOuterPoint$1(matrix, point, toPoint$1);
795
+ addPoint$2(tempPointBounds$1, toPoint$1.x, toPoint$1.y);
796
+ toBounds$3(tempPointBounds$1, to);
650
797
  }
651
798
  },
652
799
  getFitMatrix(t, put) {
@@ -690,18 +837,18 @@ const BoundsHelper = {
690
837
  t.height = bottom - t.y;
691
838
  },
692
839
  addList(t, list) {
693
- B.setByListWithHandle(t, list, undefined, true);
840
+ B.setListWithFn(t, list, undefined, true);
694
841
  },
695
- setByList(t, list, addMode = false) {
696
- B.setByListWithHandle(t, list, undefined, addMode);
842
+ setList(t, list, addMode = false) {
843
+ B.setListWithFn(t, list, undefined, addMode);
697
844
  },
698
- addListWithHandle(t, list, boundsDataHandle) {
699
- B.setByListWithHandle(t, list, boundsDataHandle, true);
845
+ addListWithFn(t, list, boundsDataFn) {
846
+ B.setListWithFn(t, list, boundsDataFn, true);
700
847
  },
701
- setByListWithHandle(t, list, boundsDataHandle, addMode = false) {
848
+ setListWithFn(t, list, boundsDataFn, addMode = false) {
702
849
  let bounds, first = true;
703
850
  for (let i = 0, len = list.length; i < len; i++) {
704
- bounds = boundsDataHandle ? boundsDataHandle(list[i]) : list[i];
851
+ bounds = boundsDataFn ? boundsDataFn(list[i]) : list[i];
705
852
  if (bounds && (bounds.width || bounds.height)) {
706
853
  if (first) {
707
854
  first = false;
@@ -709,18 +856,25 @@ const BoundsHelper = {
709
856
  copy$7(t, bounds);
710
857
  }
711
858
  else {
712
- add$2(t, bounds);
859
+ add$1(t, bounds);
713
860
  }
714
861
  }
715
862
  }
716
863
  if (first)
717
864
  B.reset(t);
718
865
  },
719
- setByPoints(t, points) {
720
- points.forEach((point, index) => {
721
- index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y);
722
- });
723
- toBounds$4(tempPointBounds$1, t);
866
+ setPoints(t, points) {
867
+ points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
868
+ toBounds$3(tempPointBounds$1, t);
869
+ },
870
+ getPoints(t) {
871
+ const { x, y, width, height } = t;
872
+ return [
873
+ { x, y },
874
+ { x: x + width, y },
875
+ { x: x + width, y: y + height },
876
+ { x, y: y + height }
877
+ ];
724
878
  },
725
879
  hitRadiusPoint(t, point, pointMatrix) {
726
880
  if (pointMatrix)
@@ -772,19 +926,24 @@ const BoundsHelper = {
772
926
  }
773
927
  };
774
928
  const B = BoundsHelper;
775
- const { add: add$2, copy: copy$7 } = B;
929
+ const { add: add$1, copy: copy$7 } = B;
776
930
 
777
931
  class Bounds {
932
+ get minX() { return BoundsHelper.minX(this); }
933
+ get minY() { return BoundsHelper.minY(this); }
934
+ get maxX() { return BoundsHelper.maxX(this); }
935
+ get maxY() { return BoundsHelper.maxY(this); }
778
936
  constructor(x, y, width, height) {
779
- typeof x === 'object' ? BoundsHelper.copy(this, x) : BoundsHelper.set(this, x, y, width, height);
937
+ this.set(x, y, width, height);
780
938
  }
781
939
  set(x, y, width, height) {
782
- BoundsHelper.set(this, x, y, width, height);
783
- }
784
- copy(bounds) {
785
- BoundsHelper.copy(this, bounds);
940
+ typeof x === 'object' ? BoundsHelper.copy(this, x) : BoundsHelper.set(this, x, y, width, height);
786
941
  return this;
787
942
  }
943
+ get() {
944
+ const { x, y, width, height } = this;
945
+ return { x, y, width, height };
946
+ }
788
947
  clone() {
789
948
  return new Bounds(this);
790
949
  }
@@ -820,25 +979,28 @@ class Bounds {
820
979
  return this;
821
980
  }
822
981
  addList(boundsList) {
823
- BoundsHelper.setByList(this, boundsList, true);
982
+ BoundsHelper.setList(this, boundsList, true);
824
983
  return this;
825
984
  }
826
- setByList(boundsList, addMode) {
827
- BoundsHelper.setByList(this, boundsList, addMode);
985
+ setList(boundsList) {
986
+ BoundsHelper.setList(this, boundsList);
828
987
  return this;
829
988
  }
830
- addListWithHandle(list, boundsDataHandle) {
831
- BoundsHelper.setByListWithHandle(this, list, boundsDataHandle, true);
989
+ addListWithFn(list, boundsDataFn) {
990
+ BoundsHelper.setListWithFn(this, list, boundsDataFn, true);
832
991
  return this;
833
992
  }
834
- setByListWithHandle(list, boundsDataHandle, addMode) {
835
- BoundsHelper.setByListWithHandle(this, list, boundsDataHandle, addMode);
993
+ setListWithFn(list, boundsDataFn) {
994
+ BoundsHelper.setListWithFn(this, list, boundsDataFn);
836
995
  return this;
837
996
  }
838
- setByPoints(points) {
839
- BoundsHelper.setByPoints(this, points);
997
+ setPoints(points) {
998
+ BoundsHelper.setPoints(this, points);
840
999
  return this;
841
1000
  }
1001
+ getPoints() {
1002
+ return BoundsHelper.getPoints(this);
1003
+ }
842
1004
  hitPoint(point, pointMatrix) {
843
1005
  return BoundsHelper.hitPoint(this, point, pointMatrix);
844
1006
  }
@@ -891,20 +1053,25 @@ class AutoBounds {
891
1053
  }
892
1054
  }
893
1055
 
894
- class TwoPointBounds {
895
- constructor(x, y) {
896
- TwoPointBoundsHelper.setPoint(this, x, y);
897
- }
898
- addPoint(x, y) {
899
- TwoPointBoundsHelper.addPoint(this, x, y);
900
- }
901
- addBounds(x, y, width, height) {
902
- TwoPointBoundsHelper.addBounds(this, x, y, width, height);
903
- }
904
- add(pb) {
905
- TwoPointBoundsHelper.add(this, pb);
1056
+ const center = { x: 0.5, y: 0.5 };
1057
+ const AroundHelper = {
1058
+ center,
1059
+ tempPoint: {},
1060
+ toPoint(around, bounds, to, onlySize) {
1061
+ to || (to = {});
1062
+ switch (around) {
1063
+ case 'center':
1064
+ around = center;
1065
+ break;
1066
+ }
1067
+ to.x = around.x * bounds.width;
1068
+ to.y = around.y * bounds.height;
1069
+ if (!onlySize) {
1070
+ to.x += bounds.x;
1071
+ to.y += bounds.y;
1072
+ }
906
1073
  }
907
- }
1074
+ };
908
1075
 
909
1076
  const StringNumberMap = {
910
1077
  '0': 1,
@@ -945,18 +1112,21 @@ class Debug {
945
1112
  this.excludeList = name;
946
1113
  }
947
1114
  log(...messages) {
948
- if (D$4.enable) {
949
- if (D$4.filterList.length && D$4.filterList.every(name => name !== this.name))
1115
+ if (D$5.enable) {
1116
+ if (D$5.filterList.length && D$5.filterList.every(name => name !== this.name))
950
1117
  return;
951
- if (D$4.excludeList.length && D$4.excludeList.some(name => name === this.name))
1118
+ if (D$5.excludeList.length && D$5.excludeList.some(name => name === this.name))
952
1119
  return;
953
1120
  console.log('%c' + this.name, 'color:#21ae62', ...messages);
954
1121
  }
955
1122
  }
956
- warn(...messages) {
957
- if (D$4.enable)
1123
+ tip(...messages) {
1124
+ if (D$5.enable)
958
1125
  console.warn(this.name, ...messages);
959
1126
  }
1127
+ warn(...messages) {
1128
+ console.warn(this.name, ...messages);
1129
+ }
960
1130
  repeat(name, ...messages) {
961
1131
  if (!this.repeatMap[name]) {
962
1132
  this.warn('repeat:' + name, ...messages);
@@ -974,46 +1144,43 @@ class Debug {
974
1144
  }
975
1145
  Debug.filterList = [];
976
1146
  Debug.excludeList = [];
977
- const D$4 = Debug;
978
-
979
- const debug$e = Debug.get('RunTime');
980
- class Run {
981
- static start(name, microsecond) {
1147
+ const D$5 = Debug;
1148
+
1149
+ const debug$f = Debug.get('RunTime');
1150
+ const Run = {
1151
+ currentId: 0,
1152
+ currentName: '',
1153
+ idMap: {},
1154
+ nameMap: {},
1155
+ nameToIdMap: {},
1156
+ start(name, microsecond) {
982
1157
  const id = IncrementId.create(IncrementId.RUNTIME);
983
1158
  R.currentId = R.idMap[id] = microsecond ? performance.now() : Date.now();
984
1159
  R.currentName = R.nameMap[id] = name;
985
1160
  R.nameToIdMap[name] = id;
986
1161
  return id;
987
- }
988
- static end(id, microsecond) {
989
- const time = R.idMap[id];
990
- const name = R.nameMap[id];
1162
+ },
1163
+ end(id, microsecond) {
1164
+ const time = R.idMap[id], name = R.nameMap[id];
1165
+ const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
991
1166
  R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
992
- if (microsecond) {
993
- debug$e.log(name, performance.now() - time, 'µs');
994
- }
995
- else {
996
- debug$e.log(name, Date.now() - time, 'ms');
997
- }
998
- }
999
- static endOfName(name, microsecond) {
1167
+ debug$f.log(name, duration, 'ms');
1168
+ },
1169
+ endOfName(name, microsecond) {
1000
1170
  const id = R.nameToIdMap[name];
1001
1171
  if (id !== undefined)
1002
1172
  R.end(id, microsecond);
1003
1173
  }
1004
- }
1005
- Run.idMap = {};
1006
- Run.nameMap = {};
1007
- Run.nameToIdMap = {};
1174
+ };
1008
1175
  const R = Run;
1009
1176
 
1010
- const debug$d = Debug.get('UICreator');
1177
+ const debug$e = Debug.get('UICreator');
1011
1178
  const UICreator = {
1012
1179
  list: {},
1013
1180
  register(UI) {
1014
1181
  const { __tag: tag } = UI.prototype;
1015
1182
  if (list$2[tag]) {
1016
- debug$d.repeat(tag);
1183
+ debug$e.repeat(tag);
1017
1184
  }
1018
1185
  else {
1019
1186
  list$2[tag] = UI;
@@ -1035,7 +1202,7 @@ const UICreator = {
1035
1202
  };
1036
1203
  const { list: list$2 } = UICreator;
1037
1204
 
1038
- const debug$c = Debug.get('EventCreator');
1205
+ const debug$d = Debug.get('EventCreator');
1039
1206
  const EventCreator = {
1040
1207
  nameList: {},
1041
1208
  register(Event) {
@@ -1043,7 +1210,7 @@ const EventCreator = {
1043
1210
  Object.keys(Event).forEach(key => {
1044
1211
  name = Event[key];
1045
1212
  if (typeof name === 'string')
1046
- nameList[name] ? debug$c.repeat(name) : nameList[name] = Event;
1213
+ nameList[name] ? debug$d.repeat(name) : nameList[name] = Event;
1047
1214
  });
1048
1215
  },
1049
1216
  changeName(oldName, newName) {
@@ -1117,7 +1284,7 @@ class LeafList {
1117
1284
  constructor(item) {
1118
1285
  this.reset();
1119
1286
  if (item)
1120
- item instanceof Array ? this.pushList(item) : this.push(item);
1287
+ item instanceof Array ? this.addList(item) : this.add(item);
1121
1288
  }
1122
1289
  has(leaf) {
1123
1290
  return leaf && this.keys[leaf.innerId] !== undefined;
@@ -1129,36 +1296,34 @@ class LeafList {
1129
1296
  const index = this.keys[leaf.innerId];
1130
1297
  return index === undefined ? -1 : index;
1131
1298
  }
1132
- pushList(list) {
1133
- list.forEach(leaf => { this.push(leaf); });
1134
- }
1135
- unshift(leaf) {
1136
- const { keys } = this;
1137
- if (keys[leaf.innerId] === undefined) {
1138
- this.list.unshift(leaf);
1139
- Object.keys(keys).forEach(innerId => {
1140
- if (keys[innerId] !== undefined)
1141
- keys[innerId]++;
1142
- });
1143
- keys[leaf.innerId] = 0;
1144
- }
1145
- }
1146
- push(leaf) {
1299
+ add(leaf) {
1147
1300
  const { list, keys } = this;
1148
1301
  if (keys[leaf.innerId] === undefined) {
1149
1302
  list.push(leaf);
1150
1303
  keys[leaf.innerId] = list.length - 1;
1151
1304
  }
1152
1305
  }
1153
- sort(reverse) {
1154
- const { list } = this;
1155
- if (reverse) {
1156
- list.sort((a, b) => b.__level - a.__level);
1157
- }
1158
- else {
1159
- list.sort((a, b) => a.__level - b.__level);
1306
+ addAt(leaf, index = 0) {
1307
+ const { keys } = this;
1308
+ if (keys[leaf.innerId] === undefined) {
1309
+ const { list } = this;
1310
+ for (let i = index, len = list.length; i < len; i++)
1311
+ keys[list[i].innerId]++;
1312
+ if (index === 0) {
1313
+ list.unshift(leaf);
1314
+ }
1315
+ else {
1316
+ if (index > list.length)
1317
+ index = list.length;
1318
+ list.splice(index, 0, leaf);
1319
+ }
1320
+ keys[leaf.innerId] = index;
1160
1321
  }
1161
1322
  }
1323
+ addList(list) {
1324
+ for (let i = 0; i < list.length; i++)
1325
+ this.add(list[i]);
1326
+ }
1162
1327
  remove(leaf) {
1163
1328
  const { list } = this;
1164
1329
  let findIndex;
@@ -1174,20 +1339,36 @@ class LeafList {
1174
1339
  if (findIndex !== undefined)
1175
1340
  list.splice(findIndex, 1);
1176
1341
  }
1342
+ sort(reverse) {
1343
+ const { list } = this;
1344
+ if (reverse) {
1345
+ list.sort((a, b) => b.__level - a.__level);
1346
+ }
1347
+ else {
1348
+ list.sort((a, b) => a.__level - b.__level);
1349
+ }
1350
+ }
1177
1351
  forEach(itemCallback) {
1178
1352
  this.list.forEach(itemCallback);
1179
1353
  }
1180
1354
  clone() {
1181
1355
  const list = new LeafList();
1182
- this.list.forEach(item => { list.push(item); });
1356
+ list.list = [...this.list];
1357
+ list.keys = Object.assign({}, this.keys);
1183
1358
  return list;
1184
1359
  }
1360
+ update() {
1361
+ this.keys = {};
1362
+ const { list, keys } = this;
1363
+ for (let i = 0, len = list.length; i < len; i++)
1364
+ keys[list[i].innerId] = i;
1365
+ }
1185
1366
  reset() {
1186
1367
  this.list = [];
1187
1368
  this.keys = {};
1188
1369
  }
1189
1370
  destroy() {
1190
- this.list = null;
1371
+ this.reset();
1191
1372
  }
1192
1373
  }
1193
1374
 
@@ -1197,7 +1378,7 @@ class LeafLevelList {
1197
1378
  this._length = 0;
1198
1379
  this.reset();
1199
1380
  if (item)
1200
- item instanceof Array ? this.pushList(item) : this.push(item);
1381
+ item instanceof Array ? this.addList(item) : this.add(item);
1201
1382
  }
1202
1383
  has(leaf) {
1203
1384
  return this.keys[leaf.innerId] !== undefined;
@@ -1214,10 +1395,10 @@ class LeafLevelList {
1214
1395
  levels.sort((a, b) => a - b);
1215
1396
  }
1216
1397
  }
1217
- pushList(list) {
1218
- list.forEach(leaf => { this.push(leaf); });
1398
+ addList(list) {
1399
+ list.forEach(leaf => { this.add(leaf); });
1219
1400
  }
1220
- push(leaf) {
1401
+ add(leaf) {
1221
1402
  const { keys, levelMap } = this;
1222
1403
  if (!keys[leaf.innerId]) {
1223
1404
  keys[leaf.innerId] = 1;
@@ -1258,11 +1439,11 @@ class HitCanvasManager extends CanvasManager {
1258
1439
  this.imageTypeList = new LeafList();
1259
1440
  }
1260
1441
  getImageType(leaf, size) {
1261
- this.imageTypeList.push(leaf);
1442
+ this.imageTypeList.add(leaf);
1262
1443
  return Creator.hitCanvas(size);
1263
1444
  }
1264
1445
  getPathType(leaf) {
1265
- this.pathTypeList.push(leaf);
1446
+ this.pathTypeList.add(leaf);
1266
1447
  return Creator.hitCanvas();
1267
1448
  }
1268
1449
  clearImageType() {
@@ -1332,6 +1513,17 @@ class LeafData {
1332
1513
  }
1333
1514
  return this[name];
1334
1515
  }
1516
+ __getData() {
1517
+ const data = { tag: this.__leaf.tag }, { __input } = this;
1518
+ let inputValue;
1519
+ for (let key in this) {
1520
+ if (key[0] !== '_') {
1521
+ inputValue = __input ? __input[key] : undefined;
1522
+ data[key] = (inputValue === undefined) ? this[key] : inputValue;
1523
+ }
1524
+ }
1525
+ return data;
1526
+ }
1335
1527
  __setInput(name, value) {
1336
1528
  this.__input || (this.__input = {});
1337
1529
  this.__input[name] = value;
@@ -1348,21 +1540,15 @@ class LeafData {
1348
1540
  if (this.__input && this.__input[name] !== undefined)
1349
1541
  this.__input[name] = undefined;
1350
1542
  }
1351
- __getInputData(options) {
1543
+ __getInputData() {
1352
1544
  const data = { tag: this.__leaf.tag }, { __input } = this;
1353
- if (options) {
1354
- for (let key in this) {
1355
- if (key[0] !== '_')
1356
- data[key] = this[key];
1357
- }
1358
- }
1359
- else {
1360
- let realKey, value;
1361
- for (let key in this) {
1362
- realKey = key.substring(1);
1363
- if (this[realKey] !== undefined) {
1364
- value = __input ? __input[realKey] : undefined;
1365
- data[realKey] = value === undefined ? this[key] : value;
1545
+ let value, inputValue;
1546
+ for (let key in this) {
1547
+ if (key[0] !== '_') {
1548
+ value = this['_' + key];
1549
+ if (value !== undefined) {
1550
+ inputValue = __input ? __input[key] : undefined;
1551
+ data[key] = (inputValue === undefined) ? value : inputValue;
1366
1552
  }
1367
1553
  }
1368
1554
  }
@@ -1453,11 +1639,10 @@ function contextAttr(realName) {
1453
1639
  return (target, key) => {
1454
1640
  if (!realName)
1455
1641
  realName = key;
1456
- const property = {
1642
+ Object.defineProperty(target, key, {
1457
1643
  get() { return this.context[realName]; },
1458
1644
  set(value) { this.context[realName] = value; }
1459
- };
1460
- Object.defineProperty(target, key, property);
1645
+ });
1461
1646
  };
1462
1647
  }
1463
1648
  const contextMethodNameList = [];
@@ -1735,7 +1920,7 @@ __decorate([
1735
1920
 
1736
1921
  const temp = new Bounds();
1737
1922
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
1738
- const debug$b = Debug.get('LeaferCanvasBase');
1923
+ const debug$c = Debug.get('LeaferCanvasBase');
1739
1924
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
1740
1925
  class LeaferCanvasBase extends Canvas$1 {
1741
1926
  get pixelWidth() { return this.width * this.pixelRatio; }
@@ -1768,7 +1953,7 @@ class LeaferCanvasBase extends Canvas$1 {
1768
1953
  canvas.recycle();
1769
1954
  resolve(blob);
1770
1955
  }).catch((e) => {
1771
- debug$b.error(e);
1956
+ debug$c.error(e);
1772
1957
  resolve(null);
1773
1958
  });
1774
1959
  });
@@ -1786,7 +1971,7 @@ class LeaferCanvasBase extends Canvas$1 {
1786
1971
  canvas.recycle();
1787
1972
  resolve(true);
1788
1973
  }).catch((e) => {
1789
- debug$b.error(e);
1974
+ debug$c.error(e);
1790
1975
  resolve(false);
1791
1976
  });
1792
1977
  });
@@ -1937,7 +2122,7 @@ class LeaferCanvasBase extends Canvas$1 {
1937
2122
  if (blendMode)
1938
2123
  this.blendMode = blendMode;
1939
2124
  this.fillStyle = color;
1940
- temp.copy(bounds).scale(this.pixelRatio);
2125
+ temp.set(bounds).scale(this.pixelRatio);
1941
2126
  this.fillRect(temp.x, temp.y, temp.width, temp.height);
1942
2127
  if (blendMode)
1943
2128
  this.blendMode = 'source-over';
@@ -1946,20 +2131,20 @@ class LeaferCanvasBase extends Canvas$1 {
1946
2131
  if (blendMode)
1947
2132
  this.blendMode = blendMode;
1948
2133
  this.strokeStyle = color;
1949
- temp.copy(bounds).scale(this.pixelRatio);
2134
+ temp.set(bounds).scale(this.pixelRatio);
1950
2135
  this.strokeRect(temp.x, temp.y, temp.width, temp.height);
1951
2136
  if (blendMode)
1952
2137
  this.blendMode = 'source-over';
1953
2138
  }
1954
2139
  clearWorld(bounds, ceilPixel) {
1955
- temp.copy(bounds).scale(this.pixelRatio);
2140
+ temp.set(bounds).scale(this.pixelRatio);
1956
2141
  if (ceilPixel)
1957
2142
  temp.ceil();
1958
2143
  this.clearRect(temp.x, temp.y, temp.width, temp.height);
1959
2144
  }
1960
2145
  clipWorld(bounds, ceilPixel) {
1961
2146
  this.beginPath();
1962
- temp.copy(bounds).scale(this.pixelRatio);
2147
+ temp.set(bounds).scale(this.pixelRatio);
1963
2148
  if (ceilPixel)
1964
2149
  temp.ceil();
1965
2150
  this.rect(temp.x, temp.y, temp.width, temp.height);
@@ -1972,13 +2157,15 @@ class LeaferCanvasBase extends Canvas$1 {
1972
2157
  isSameSize(size) {
1973
2158
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
1974
2159
  }
1975
- getSameCanvas(useSameWorldTransform) {
2160
+ getSameCanvas(useSameWorldTransform, useSameSmooth) {
1976
2161
  const { width, height, pixelRatio } = this;
1977
2162
  const options = { width, height, pixelRatio };
1978
2163
  const canvas = this.manager ? this.manager.get(options) : Creator.canvas(options);
1979
2164
  canvas.save();
1980
2165
  if (useSameWorldTransform)
1981
2166
  canvas.useWorldTransform(Object.assign({}, this.worldTransform));
2167
+ if (useSameSmooth)
2168
+ canvas.smooth = this.smooth;
1982
2169
  return canvas;
1983
2170
  }
1984
2171
  getBiggerCanvas(addWidth, addHeight) {
@@ -2069,44 +2256,37 @@ const NeedConvertToCanvasCommandMap = {
2069
2256
  a: 90,
2070
2257
  };
2071
2258
  const NeedConvertToCurveCommandMap = Object.assign(Object.assign({}, NeedConvertToCanvasCommandMap), CanvasCommandOnlyMap);
2072
- const P$4 = PathCommandMap;
2259
+ const P$5 = PathCommandMap;
2073
2260
  const PathNumberCommandMap = {};
2074
- for (let key in P$4) {
2075
- PathNumberCommandMap[P$4[key]] = key;
2261
+ for (let key in P$5) {
2262
+ PathNumberCommandMap[P$5[key]] = key;
2076
2263
  }
2077
2264
  const PathNumberCommandLengthMap = {};
2078
- for (let key in P$4) {
2079
- PathNumberCommandLengthMap[P$4[key]] = PathCommandLengthMap[key];
2265
+ for (let key in P$5) {
2266
+ PathNumberCommandLengthMap[P$5[key]] = PathCommandLengthMap[key];
2080
2267
  }
2081
2268
 
2082
2269
  const RectHelper = {
2083
2270
  drawRoundRect(drawer, x, y, width, height, cornerRadius) {
2084
- let [topLeft, topRight, bottomRight, bottomLeft] = MathHelper.fourNumber(cornerRadius);
2085
- const max = Math.min(width / 2, height / 2);
2086
- if (topLeft > max)
2087
- topLeft = max;
2088
- if (topRight > max)
2089
- topRight = max;
2090
- if (bottomRight > max)
2091
- bottomRight = max;
2092
- if (bottomLeft > max)
2093
- bottomLeft = max;
2094
- topLeft ? drawer.moveTo(x + topLeft, y) : drawer.moveTo(x, y);
2095
- topRight ? drawer.arcTo(x + width, y, x + width, y + height, topRight) : drawer.lineTo(x + width, y);
2096
- bottomRight ? drawer.arcTo(x + width, y + height, x, y + height, bottomRight) : drawer.lineTo(x + width, y + height);
2097
- bottomLeft ? drawer.arcTo(x, y + height, x, y, bottomLeft) : drawer.lineTo(x, y + height);
2098
- topLeft ? drawer.arcTo(x, y, x + width, y, topLeft) : drawer.lineTo(x, y);
2271
+ const data = MathHelper.fourNumber(cornerRadius, Math.min(width / 2, height / 2));
2272
+ const right = x + width;
2273
+ const bottom = y + height;
2274
+ data[0] ? drawer.moveTo(x + data[0], y) : drawer.moveTo(x, y);
2275
+ data[1] ? drawer.arcTo(right, y, right, bottom, data[1]) : drawer.lineTo(right, y);
2276
+ data[2] ? drawer.arcTo(right, bottom, x, bottom, data[2]) : drawer.lineTo(right, bottom);
2277
+ data[3] ? drawer.arcTo(x, bottom, x, y, data[3]) : drawer.lineTo(x, bottom);
2278
+ data[0] ? drawer.arcTo(x, y, right, y, data[0]) : drawer.lineTo(x, y);
2099
2279
  }
2100
2280
  };
2101
2281
 
2102
- const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil, abs, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2282
+ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2103
2283
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2104
2284
  const { set: set$2 } = PointHelper;
2105
- const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2106
- const tempPoint = {};
2285
+ const { M: M$6, L: L$7, C: C$6, Q: Q$5, Z: Z$6 } = PathCommandMap;
2286
+ const tempPoint$1 = {};
2107
2287
  const BezierHelper = {
2108
2288
  points(data, points, curve, close) {
2109
- data.push(M$5, points[0], points[1]);
2289
+ data.push(M$6, points[0], points[1]);
2110
2290
  if (curve && points.length > 5) {
2111
2291
  let aX, aY, bX, bY, cX, cY, c1X, c1Y, c2X, c2Y;
2112
2292
  let ba, cb, d, len = points.length;
@@ -2133,24 +2313,24 @@ const BezierHelper = {
2133
2313
  c1Y = bY - ba * cY;
2134
2314
  if (i === 2) {
2135
2315
  if (!close)
2136
- data.push(Q$4, c1X, c1Y, bX, bY);
2316
+ data.push(Q$5, c1X, c1Y, bX, bY);
2137
2317
  }
2138
2318
  else {
2139
- data.push(C$5, c2X, c2Y, c1X, c1Y, bX, bY);
2319
+ data.push(C$6, c2X, c2Y, c1X, c1Y, bX, bY);
2140
2320
  }
2141
2321
  c2X = bX + cb * cX;
2142
2322
  c2Y = bY + cb * cY;
2143
2323
  }
2144
2324
  if (!close)
2145
- data.push(Q$4, c2X, c2Y, points[len - 2], points[len - 1]);
2325
+ data.push(Q$5, c2X, c2Y, points[len - 2], points[len - 1]);
2146
2326
  }
2147
2327
  else {
2148
2328
  for (let i = 2, len = points.length; i < len; i += 2) {
2149
- data.push(L$6, points[i], points[i + 1]);
2329
+ data.push(L$7, points[i], points[i + 1]);
2150
2330
  }
2151
2331
  }
2152
2332
  if (close)
2153
- data.push(Z$5);
2333
+ data.push(Z$6);
2154
2334
  },
2155
2335
  rect(data, x, y, width, height) {
2156
2336
  PathHelper.creator.path = data;
@@ -2171,9 +2351,9 @@ const BezierHelper = {
2171
2351
  let totalRadian = endRadian - startRadian;
2172
2352
  if (totalRadian < 0)
2173
2353
  totalRadian += PI2;
2174
- if (totalRadian === PI$2 || (abs(BAx + BAy) < 1.e-12) || (abs(CBx + CBy) < 1.e-12)) {
2354
+ if (totalRadian === PI$2 || (abs$2(BAx + BAy) < 1.e-12) || (abs$2(CBx + CBy) < 1.e-12)) {
2175
2355
  if (data)
2176
- data.push(L$6, x1, y1);
2356
+ data.push(L$7, x1, y1);
2177
2357
  if (setPointBounds) {
2178
2358
  setPoint$1(setPointBounds, fromX, fromY);
2179
2359
  addPoint$1(setPointBounds, x1, y1);
@@ -2186,9 +2366,9 @@ const BezierHelper = {
2186
2366
  }
2187
2367
  const anticlockwise = BAx * CBy - CBx * BAy < 0;
2188
2368
  const sign = anticlockwise ? -1 : 1;
2189
- const c = radius / cos$4(totalRadian / 2);
2190
- const centerX = x1 + c * cos$4(startRadian + totalRadian / 2 + PI_2 * sign);
2191
- const centerY = y1 + c * sin$4(startRadian + totalRadian / 2 + PI_2 * sign);
2369
+ const c = radius / cos$3(totalRadian / 2);
2370
+ const centerX = x1 + c * cos$3(startRadian + totalRadian / 2 + PI_2 * sign);
2371
+ const centerY = y1 + c * sin$3(startRadian + totalRadian / 2 + PI_2 * sign);
2192
2372
  startRadian -= PI_2 * sign;
2193
2373
  endRadian -= PI_2 * sign;
2194
2374
  return ellipse$6(data, centerX, centerY, radius, radius, 0, startRadian / OneRadian, endRadian / OneRadian, anticlockwise, setPointBounds, setEndPoint, setStartPoint);
@@ -2198,8 +2378,8 @@ const BezierHelper = {
2198
2378
  },
2199
2379
  ellipse(data, cx, cy, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, setPointBounds, setEndPoint, setStartPoint) {
2200
2380
  const rotationRadian = rotation * OneRadian;
2201
- const rotationSin = sin$4(rotationRadian);
2202
- const rotationCos = cos$4(rotationRadian);
2381
+ const rotationSin = sin$3(rotationRadian);
2382
+ const rotationCos = cos$3(rotationRadian);
2203
2383
  let startRadian = startAngle * OneRadian;
2204
2384
  let endRadian = endAngle * OneRadian;
2205
2385
  if (startRadian > PI$2)
@@ -2213,27 +2393,27 @@ const BezierHelper = {
2213
2393
  totalRadian -= PI2;
2214
2394
  if (anticlockwise)
2215
2395
  totalRadian -= PI2;
2216
- const parts = ceil(abs(totalRadian / PI_2));
2396
+ const parts = ceil(abs$2(totalRadian / PI_2));
2217
2397
  const partRadian = totalRadian / parts;
2218
- const partRadian4Sin = sin$4(partRadian / 4);
2219
- const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
2398
+ const partRadian4Sin = sin$3(partRadian / 4);
2399
+ const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
2220
2400
  endRadian = startRadian + partRadian;
2221
- let startCos = cos$4(startRadian);
2222
- let startSin = sin$4(startRadian);
2401
+ let startCos = cos$3(startRadian);
2402
+ let startSin = sin$3(startRadian);
2223
2403
  let endCos, endSin;
2224
2404
  let x, y, x1, y1, x2, y2;
2225
2405
  let startX = x = rotationCos * radiusX * startCos - rotationSin * radiusY * startSin;
2226
2406
  let startY = y = rotationSin * radiusX * startCos + rotationCos * radiusY * startSin;
2227
2407
  let fromX = cx + x, fromY = cy + y;
2228
2408
  if (data)
2229
- data.push(L$6, fromX, fromY);
2409
+ data.push(L$7, fromX, fromY);
2230
2410
  if (setPointBounds)
2231
2411
  setPoint$1(setPointBounds, fromX, fromY);
2232
2412
  if (setStartPoint)
2233
2413
  set$2(setStartPoint, fromX, fromY);
2234
2414
  for (let i = 0; i < parts; i++) {
2235
- endCos = cos$4(endRadian);
2236
- endSin = sin$4(endRadian);
2415
+ endCos = cos$3(endRadian);
2416
+ endSin = sin$3(endRadian);
2237
2417
  x = rotationCos * radiusX * endCos - rotationSin * radiusY * endSin;
2238
2418
  y = rotationSin * radiusX * endCos + rotationCos * radiusY * endSin;
2239
2419
  x1 = cx + startX - control * (rotationCos * radiusX * startSin + rotationSin * radiusY * startCos);
@@ -2241,7 +2421,7 @@ const BezierHelper = {
2241
2421
  x2 = cx + x + control * (rotationCos * radiusX * endSin + rotationSin * radiusY * endCos);
2242
2422
  y2 = cy + y + control * (rotationSin * radiusX * endSin - rotationCos * radiusY * endCos);
2243
2423
  if (data)
2244
- data.push(C$5, x1, y1, x2, y2, cx + x, cy + y);
2424
+ data.push(C$6, x1, y1, x2, y2, cx + x, cy + y);
2245
2425
  if (setPointBounds)
2246
2426
  toTwoPointBounds$1(cx + startX, cy + startY, x1, y1, x2, y2, cx + x, cy + y, setPointBounds, true);
2247
2427
  startX = x;
@@ -2255,7 +2435,7 @@ const BezierHelper = {
2255
2435
  set$2(setEndPoint, cx + x, cy + y);
2256
2436
  },
2257
2437
  quadraticCurveTo(data, fromX, fromY, x1, y1, toX, toY) {
2258
- data.push(C$5, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2438
+ data.push(C$6, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY);
2259
2439
  },
2260
2440
  toTwoPointBoundsByQuadraticCurve(fromX, fromY, x1, y1, toX, toY, pointBounds, addMode) {
2261
2441
  toTwoPointBounds$1(fromX, fromY, (fromX + 2 * x1) / 3, (fromY + 2 * y1) / 3, (toX + 2 * x1) / 3, (toY + 2 * y1) / 3, toX, toY, pointBounds, addMode);
@@ -2293,8 +2473,8 @@ const BezierHelper = {
2293
2473
  addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
2294
2474
  addPoint$1(pointBounds, toX, toY);
2295
2475
  for (let i = 0, len = tList.length; i < len; i++) {
2296
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint);
2297
- addPoint$1(pointBounds, tempPoint.x, tempPoint.y);
2476
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2477
+ addPoint$1(pointBounds, tempPoint$1.x, tempPoint$1.y);
2298
2478
  }
2299
2479
  },
2300
2480
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2310,15 +2490,15 @@ const BezierHelper = {
2310
2490
  };
2311
2491
  const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$6 } = BezierHelper;
2312
2492
 
2313
- const { sin: sin$3, cos: cos$3, sqrt, atan2 } = Math;
2493
+ const { sin: sin$2, cos: cos$2, sqrt, atan2 } = Math;
2314
2494
  const { ellipse: ellipse$5 } = BezierHelper;
2315
2495
  const EllipseHelper = {
2316
2496
  ellipticalArc(data, fromX, fromY, radiusX, radiusY, rotation, largeFlag, sweepFlag, toX, toY, curveMode) {
2317
2497
  const halfX = (toX - fromX) / 2;
2318
2498
  const halfY = (toY - fromY) / 2;
2319
2499
  const rotationRadian = rotation * OneRadian;
2320
- const rotationSin = sin$3(rotationRadian);
2321
- const rotationCos = cos$3(rotationRadian);
2500
+ const rotationSin = sin$2(rotationRadian);
2501
+ const rotationCos = cos$2(rotationRadian);
2322
2502
  const px = -rotationCos * halfX - rotationSin * halfY;
2323
2503
  const py = -rotationCos * halfY + rotationSin * halfX;
2324
2504
  const rxSquare = radiusX * radiusX;
@@ -2363,10 +2543,10 @@ const EllipseHelper = {
2363
2543
  }
2364
2544
  };
2365
2545
 
2366
- 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;
2367
- const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$2, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2546
+ 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;
2547
+ const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2368
2548
  const { ellipticalArc } = EllipseHelper;
2369
- const debug$a = Debug.get('PathConvert');
2549
+ const debug$b = Debug.get('PathConvert');
2370
2550
  const setEndPoint$1 = {};
2371
2551
  const PathConvert = {
2372
2552
  current: { dot: 0 },
@@ -2451,33 +2631,33 @@ const PathConvert = {
2451
2631
  case m:
2452
2632
  old[i + 1] += x;
2453
2633
  old[i + 2] += y;
2454
- case M$4:
2634
+ case M$5:
2455
2635
  x = old[i + 1];
2456
2636
  y = old[i + 2];
2457
- data.push(M$4, x, y);
2637
+ data.push(M$5, x, y);
2458
2638
  i += 3;
2459
2639
  break;
2460
2640
  case h:
2461
2641
  old[i + 1] += x;
2462
2642
  case H:
2463
2643
  x = old[i + 1];
2464
- data.push(L$5, x, y);
2644
+ data.push(L$6, x, y);
2465
2645
  i += 2;
2466
2646
  break;
2467
2647
  case v:
2468
2648
  old[i + 1] += y;
2469
2649
  case V:
2470
2650
  y = old[i + 1];
2471
- data.push(L$5, x, y);
2651
+ data.push(L$6, x, y);
2472
2652
  i += 2;
2473
2653
  break;
2474
2654
  case l:
2475
2655
  old[i + 1] += x;
2476
2656
  old[i + 2] += y;
2477
- case L$5:
2657
+ case L$6:
2478
2658
  x = old[i + 1];
2479
2659
  y = old[i + 2];
2480
- data.push(L$5, x, y);
2660
+ data.push(L$6, x, y);
2481
2661
  i += 3;
2482
2662
  break;
2483
2663
  case s:
@@ -2487,14 +2667,14 @@ const PathConvert = {
2487
2667
  old[i + 4] += y;
2488
2668
  command = S;
2489
2669
  case S:
2490
- smooth = (lastCommand === C$4) || (lastCommand === S);
2670
+ smooth = (lastCommand === C$5) || (lastCommand === S);
2491
2671
  x1 = smooth ? (x * 2 - controlX) : old[i + 1];
2492
2672
  y1 = smooth ? (y * 2 - controlY) : old[i + 2];
2493
2673
  controlX = old[i + 1];
2494
2674
  controlY = old[i + 2];
2495
2675
  x = old[i + 3];
2496
2676
  y = old[i + 4];
2497
- data.push(C$4, x1, y1, controlX, controlY, x, y);
2677
+ data.push(C$5, x1, y1, controlX, controlY, x, y);
2498
2678
  i += 5;
2499
2679
  break;
2500
2680
  case c:
@@ -2504,13 +2684,13 @@ const PathConvert = {
2504
2684
  old[i + 4] += y;
2505
2685
  old[i + 5] += x;
2506
2686
  old[i + 6] += y;
2507
- command = C$4;
2508
- case C$4:
2687
+ command = C$5;
2688
+ case C$5:
2509
2689
  controlX = old[i + 3];
2510
2690
  controlY = old[i + 4];
2511
2691
  x = old[i + 5];
2512
2692
  y = old[i + 6];
2513
- data.push(C$4, old[i + 1], old[i + 2], controlX, controlY, x, y);
2693
+ data.push(C$5, old[i + 1], old[i + 2], controlX, controlY, x, y);
2514
2694
  i += 7;
2515
2695
  break;
2516
2696
  case t:
@@ -2518,10 +2698,10 @@ const PathConvert = {
2518
2698
  old[i + 2] += y;
2519
2699
  command = T;
2520
2700
  case T:
2521
- smooth = (lastCommand === Q$3) || (lastCommand === T);
2701
+ smooth = (lastCommand === Q$4) || (lastCommand === T);
2522
2702
  controlX = smooth ? (x * 2 - controlX) : old[i + 1];
2523
2703
  controlY = smooth ? (y * 2 - controlY) : old[i + 2];
2524
- 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]);
2704
+ 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]);
2525
2705
  x = old[i + 1];
2526
2706
  y = old[i + 2];
2527
2707
  i += 3;
@@ -2531,11 +2711,11 @@ const PathConvert = {
2531
2711
  old[i + 2] += y;
2532
2712
  old[i + 3] += x;
2533
2713
  old[i + 4] += y;
2534
- command = Q$3;
2535
- case Q$3:
2714
+ command = Q$4;
2715
+ case Q$4:
2536
2716
  controlX = old[i + 1];
2537
2717
  controlY = old[i + 2];
2538
- 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]);
2718
+ 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]);
2539
2719
  x = old[i + 3];
2540
2720
  y = old[i + 4];
2541
2721
  i += 5;
@@ -2550,60 +2730,60 @@ const PathConvert = {
2550
2730
  i += 8;
2551
2731
  break;
2552
2732
  case z:
2553
- case Z$4:
2554
- data.push(Z$4);
2733
+ case Z$5:
2734
+ data.push(Z$5);
2555
2735
  i++;
2556
2736
  break;
2557
- case N$3:
2737
+ case N$4:
2558
2738
  x = old[i + 1];
2559
2739
  y = old[i + 2];
2560
2740
  curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2561
2741
  i += 5;
2562
2742
  break;
2563
- case D$3:
2743
+ case D$4:
2564
2744
  x = old[i + 1];
2565
2745
  y = old[i + 2];
2566
2746
  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);
2567
2747
  i += 9;
2568
2748
  break;
2569
- case X$3:
2749
+ case X$4:
2570
2750
  x = old[i + 1];
2571
2751
  y = old[i + 2];
2572
2752
  curveMode ? roundRect$2(data, x, y, old[i + 3], old[i + 4], old[i + 5]) : copyData(data, old, i, 6);
2573
2753
  i += 6;
2574
2754
  break;
2575
- case G$3:
2755
+ case G$4:
2576
2756
  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);
2577
2757
  x = setEndPoint$1.x;
2578
2758
  y = setEndPoint$1.y;
2579
2759
  i += 9;
2580
2760
  break;
2581
- case F$3:
2761
+ case F$4:
2582
2762
  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);
2583
2763
  x = old[i + 1] + old[i + 3];
2584
2764
  y = old[i + 2];
2585
2765
  i += 5;
2586
2766
  break;
2587
- case O$3:
2767
+ case O$4:
2588
2768
  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);
2589
2769
  x = setEndPoint$1.x;
2590
2770
  y = setEndPoint$1.y;
2591
2771
  i += 7;
2592
2772
  break;
2593
- case P$3:
2773
+ case P$4:
2594
2774
  curveMode ? arc$3(data, old[i + 1], old[i + 2], old[i + 3], 0, 360, false) : copyData(data, old, i, 4);
2595
2775
  x = old[i + 1] + old[i + 3];
2596
2776
  y = old[i + 2];
2597
2777
  i += 4;
2598
2778
  break;
2599
2779
  case U$4:
2600
- 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);
2780
+ 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);
2601
2781
  x = setEndPoint$1.x;
2602
2782
  y = setEndPoint$1.y;
2603
2783
  i += 6;
2604
2784
  break;
2605
2785
  default:
2606
- debug$a.error(`command: ${command} [index:${i}]`, old);
2786
+ debug$b.error(`command: ${command} [index:${i}]`, old);
2607
2787
  return data;
2608
2788
  }
2609
2789
  lastCommand = command;
@@ -2627,68 +2807,76 @@ const PathConvert = {
2627
2807
  };
2628
2808
  const { current, pushData, copyData } = PathConvert;
2629
2809
 
2630
- 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;
2810
+ 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;
2811
+ const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2812
+ const { tan, min, abs: abs$1 } = Math;
2631
2813
  const startPoint = {};
2632
2814
  const PathCommandDataHelper = {
2633
2815
  beginPath(data) {
2634
2816
  data.length = 0;
2635
2817
  },
2636
2818
  moveTo(data, x, y) {
2637
- data.push(M$3, x, y);
2819
+ data.push(M$4, x, y);
2638
2820
  },
2639
2821
  lineTo(data, x, y) {
2640
- data.push(L$4, x, y);
2822
+ data.push(L$5, x, y);
2641
2823
  },
2642
2824
  bezierCurveTo(data, x1, y1, x2, y2, x, y) {
2643
- data.push(C$3, x1, y1, x2, y2, x, y);
2825
+ data.push(C$4, x1, y1, x2, y2, x, y);
2644
2826
  },
2645
2827
  quadraticCurveTo(data, x1, y1, x, y) {
2646
- data.push(Q$2, x1, y1, x, y);
2828
+ data.push(Q$3, x1, y1, x, y);
2647
2829
  },
2648
2830
  closePath(data) {
2649
- data.push(Z$3);
2831
+ data.push(Z$4);
2650
2832
  },
2651
2833
  rect(data, x, y, width, height) {
2652
- data.push(N$2, x, y, width, height);
2834
+ data.push(N$3, x, y, width, height);
2653
2835
  },
2654
2836
  roundRect(data, x, y, width, height, cornerRadius) {
2655
2837
  if (typeof cornerRadius === 'number') {
2656
- data.push(X$2, x, y, width, height, cornerRadius);
2838
+ data.push(X$3, x, y, width, height, cornerRadius);
2657
2839
  }
2658
2840
  else {
2659
2841
  const fourCorners = MathHelper.fourNumber(cornerRadius);
2660
2842
  if (fourCorners) {
2661
- data.push(D$2, x, y, width, height, ...fourCorners);
2843
+ data.push(D$3, x, y, width, height, ...fourCorners);
2662
2844
  }
2663
2845
  else {
2664
- data.push(N$2, x, y, width, height);
2846
+ data.push(N$3, x, y, width, height);
2665
2847
  }
2666
2848
  }
2667
2849
  },
2668
2850
  ellipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2669
2851
  if (rotation === undefined) {
2670
- data.push(F$2, x, y, radiusX, radiusY);
2852
+ data.push(F$3, x, y, radiusX, radiusY);
2671
2853
  }
2672
2854
  else {
2673
2855
  if (startAngle === undefined)
2674
2856
  startAngle = 0;
2675
2857
  if (endAngle === undefined)
2676
2858
  endAngle = 360;
2677
- data.push(G$2, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise ? 1 : 0);
2859
+ data.push(G$3, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise ? 1 : 0);
2678
2860
  }
2679
2861
  },
2680
2862
  arc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
2681
2863
  if (startAngle === undefined) {
2682
- data.push(P$2, x, y, radius);
2864
+ data.push(P$3, x, y, radius);
2683
2865
  }
2684
2866
  else {
2685
2867
  if (endAngle === undefined)
2686
2868
  endAngle = 360;
2687
- data.push(O$2, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
2869
+ data.push(O$3, x, y, radius, startAngle, endAngle, anticlockwise ? 1 : 0);
2688
2870
  }
2689
2871
  },
2690
- arcTo(data, x1, y1, x2, y2, radius) {
2691
- data.push(U$3, x1, y1, x2, y2, radius);
2872
+ arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
2873
+ if (lastX !== undefined) {
2874
+ const maxRadius = tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2) * (getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2) / 2);
2875
+ data.push(U$3, x1, y1, x2, y2, min(radius, abs$1(maxRadius)));
2876
+ }
2877
+ else {
2878
+ data.push(U$3, x1, y1, x2, y2, radius);
2879
+ }
2692
2880
  },
2693
2881
  drawEllipse(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
2694
2882
  if (rotation === undefined)
@@ -2698,7 +2886,7 @@ const PathCommandDataHelper = {
2698
2886
  if (endAngle === undefined)
2699
2887
  endAngle = 360;
2700
2888
  BezierHelper.ellipse(null, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise, null, null, startPoint);
2701
- data.push(M$3, startPoint.x, startPoint.y);
2889
+ data.push(M$4, startPoint.x, startPoint.y);
2702
2890
  ellipse$3(data, x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
2703
2891
  },
2704
2892
  drawArc(data, x, y, radius, startAngle, endAngle, anticlockwise) {
@@ -2707,7 +2895,7 @@ const PathCommandDataHelper = {
2707
2895
  if (endAngle === undefined)
2708
2896
  endAngle = 360;
2709
2897
  BezierHelper.arc(null, x, y, radius, startAngle, endAngle, anticlockwise, null, null, startPoint);
2710
- data.push(M$3, startPoint.x, startPoint.y);
2898
+ data.push(M$4, startPoint.x, startPoint.y);
2711
2899
  arc$2(data, x, y, radius, startAngle, endAngle, anticlockwise);
2712
2900
  },
2713
2901
  drawPoints(data, points, curve, close) {
@@ -2716,7 +2904,7 @@ const PathCommandDataHelper = {
2716
2904
  };
2717
2905
  const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
2718
2906
 
2719
- 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;
2907
+ 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;
2720
2908
  class PathCreator {
2721
2909
  constructor(path) {
2722
2910
  if (path) {
@@ -2767,7 +2955,7 @@ class PathCreator {
2767
2955
  return this;
2768
2956
  }
2769
2957
  arcTo(x1, y1, x2, y2, radius) {
2770
- arcTo$1(this.path, x1, y1, x2, y2, radius);
2958
+ arcTo$2(this.path, x1, y1, x2, y2, radius);
2771
2959
  return this;
2772
2960
  }
2773
2961
  drawEllipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
@@ -2784,8 +2972,8 @@ class PathCreator {
2784
2972
  }
2785
2973
  }
2786
2974
 
2787
- 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;
2788
- const debug$9 = Debug.get('PathDrawer');
2975
+ 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;
2976
+ const debug$a = Debug.get('PathDrawer');
2789
2977
  const PathDrawer = {
2790
2978
  drawPathByData(drawer, data) {
2791
2979
  if (!data)
@@ -2795,51 +2983,51 @@ const PathDrawer = {
2795
2983
  while (i < len) {
2796
2984
  command = data[i];
2797
2985
  switch (command) {
2798
- case M$2:
2986
+ case M$3:
2799
2987
  drawer.moveTo(data[i + 1], data[i + 2]);
2800
2988
  i += 3;
2801
2989
  break;
2802
- case L$3:
2990
+ case L$4:
2803
2991
  drawer.lineTo(data[i + 1], data[i + 2]);
2804
2992
  i += 3;
2805
2993
  break;
2806
- case C$2:
2994
+ case C$3:
2807
2995
  drawer.bezierCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
2808
2996
  i += 7;
2809
2997
  break;
2810
- case Q$1:
2998
+ case Q$2:
2811
2999
  drawer.quadraticCurveTo(data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
2812
3000
  i += 5;
2813
3001
  break;
2814
- case Z$2:
3002
+ case Z$3:
2815
3003
  drawer.closePath();
2816
3004
  i += 1;
2817
3005
  break;
2818
- case N$1:
3006
+ case N$2:
2819
3007
  drawer.rect(data[i + 1], data[i + 2], data[i + 3], data[i + 4]);
2820
3008
  i += 5;
2821
3009
  break;
2822
- case D$1:
3010
+ case D$2:
2823
3011
  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]]);
2824
3012
  i += 9;
2825
3013
  break;
2826
- case X$1:
3014
+ case X$2:
2827
3015
  drawer.roundRect(data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5]);
2828
3016
  i += 6;
2829
3017
  break;
2830
- case G$1:
3018
+ case G$2:
2831
3019
  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]);
2832
3020
  i += 9;
2833
3021
  break;
2834
- case F$1:
3022
+ case F$2:
2835
3023
  drawer.ellipse(data[i + 1], data[i + 2], data[i + 3], data[i + 4], 0, 0, PI2, false);
2836
3024
  i += 5;
2837
3025
  break;
2838
- case O$1:
3026
+ case O$2:
2839
3027
  drawer.arc(data[i + 1], data[i + 2], data[i + 3], data[i + 4] * OneRadian, data[i + 5] * OneRadian, data[i + 6]);
2840
3028
  i += 7;
2841
3029
  break;
2842
- case P$1:
3030
+ case P$2:
2843
3031
  drawer.arc(data[i + 1], data[i + 2], data[i + 3], 0, PI2, false);
2844
3032
  i += 4;
2845
3033
  break;
@@ -2848,17 +3036,97 @@ const PathDrawer = {
2848
3036
  i += 6;
2849
3037
  break;
2850
3038
  default:
2851
- debug$9.error(`command: ${command} [index:${i}]`, data);
3039
+ debug$a.error(`command: ${command} [index:${i}]`, data);
2852
3040
  return;
2853
3041
  }
2854
3042
  }
2855
3043
  }
2856
3044
  };
2857
3045
 
2858
- 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;
2859
- const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo, arc, ellipse: ellipse$1 } = BezierHelper;
2860
- const { add: add$1, copy: copy$6, addPoint, setPoint, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
2861
- const debug$8 = Debug.get('PathBounds');
3046
+ 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;
3047
+ const PathScaler = {
3048
+ scale(data, scaleX, scaleY) {
3049
+ if (!data)
3050
+ return;
3051
+ let command;
3052
+ let i = 0, len = data.length;
3053
+ while (i < len) {
3054
+ command = data[i];
3055
+ switch (command) {
3056
+ case M$2:
3057
+ scalePoints(data, scaleX, scaleY, i, 1);
3058
+ i += 3;
3059
+ break;
3060
+ case L$3:
3061
+ scalePoints(data, scaleX, scaleY, i, 1);
3062
+ i += 3;
3063
+ break;
3064
+ case C$2:
3065
+ scalePoints(data, scaleX, scaleY, i, 3);
3066
+ i += 7;
3067
+ break;
3068
+ case Q$1:
3069
+ scalePoints(data, scaleX, scaleY, i, 2);
3070
+ i += 5;
3071
+ break;
3072
+ case Z$2:
3073
+ i += 1;
3074
+ break;
3075
+ case N$1:
3076
+ scalePoints(data, scaleX, scaleY, i, 2);
3077
+ i += 5;
3078
+ break;
3079
+ case D$1:
3080
+ scalePoints(data, scaleX, scaleY, i, 2);
3081
+ i += 9;
3082
+ break;
3083
+ case X$1:
3084
+ scalePoints(data, scaleX, scaleY, i, 2);
3085
+ i += 6;
3086
+ break;
3087
+ case G$1:
3088
+ scalePoints(data, scaleX, scaleY, i, 2);
3089
+ console.log('G');
3090
+ i += 9;
3091
+ break;
3092
+ case F$1:
3093
+ scalePoints(data, scaleX, scaleY, i, 2);
3094
+ i += 5;
3095
+ break;
3096
+ case O$1:
3097
+ data[i] = G$1;
3098
+ data.splice(i + 4, 0, data[i + 3], 0);
3099
+ scalePoints(data, scaleX, scaleY, i, 2);
3100
+ i += 7 + 2;
3101
+ len += 2;
3102
+ break;
3103
+ case P$1:
3104
+ data[i] = F$1;
3105
+ data.splice(i + 4, 0, data[i + 3]);
3106
+ scalePoints(data, scaleX, scaleY, i, 2);
3107
+ i += 4 + 1;
3108
+ len += 1;
3109
+ break;
3110
+ case U$1:
3111
+ scalePoints(data, scaleX, scaleY, i, 2);
3112
+ i += 6;
3113
+ break;
3114
+ }
3115
+ }
3116
+ },
3117
+ scalePoints(data, scaleX, scaleY, start, pointCount) {
3118
+ for (let i = pointCount ? start + 1 : 0, end = pointCount ? i + pointCount * 2 : data.length; i < end; i += 2) {
3119
+ data[i] *= scaleX;
3120
+ data[i + 1] *= scaleY;
3121
+ }
3122
+ }
3123
+ };
3124
+ const { scalePoints } = PathScaler;
3125
+
3126
+ const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F, O, P, U } = PathCommandMap;
3127
+ const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3128
+ const { addPointBounds, copy: copy$6, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
3129
+ const debug$9 = Debug.get('PathBounds');
2862
3130
  let radius, radiusX, radiusY;
2863
3131
  const tempPointBounds = {};
2864
3132
  const setPointBounds = {};
@@ -2866,7 +3134,7 @@ const setEndPoint = {};
2866
3134
  const PathBounds = {
2867
3135
  toBounds(data, setBounds) {
2868
3136
  PathBounds.toTwoPointBounds(data, setPointBounds);
2869
- toBounds$3(setPointBounds, setBounds);
3137
+ toBounds$2(setPointBounds, setBounds);
2870
3138
  },
2871
3139
  toTwoPointBounds(data, setPointBounds) {
2872
3140
  if (!data || !data.length)
@@ -2896,7 +3164,7 @@ const PathBounds = {
2896
3164
  toX = data[i + 5];
2897
3165
  toY = data[i + 6];
2898
3166
  toTwoPointBounds(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY, tempPointBounds);
2899
- add$1(setPointBounds, tempPointBounds);
3167
+ addPointBounds(setPointBounds, tempPointBounds);
2900
3168
  x = toX;
2901
3169
  y = toY;
2902
3170
  i += 7;
@@ -2907,7 +3175,7 @@ const PathBounds = {
2907
3175
  toX = data[i + 3];
2908
3176
  toY = data[i + 4];
2909
3177
  toTwoPointBoundsByQuadraticCurve(x, y, x1, y1, toX, toY, tempPointBounds);
2910
- add$1(setPointBounds, tempPointBounds);
3178
+ addPointBounds(setPointBounds, tempPointBounds);
2911
3179
  x = toX;
2912
3180
  y = toY;
2913
3181
  i += 5;
@@ -2930,7 +3198,7 @@ const PathBounds = {
2930
3198
  break;
2931
3199
  case G:
2932
3200
  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);
2933
- i === 0 ? copy$6(setPointBounds, tempPointBounds) : add$1(setPointBounds, tempPointBounds);
3201
+ i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
2934
3202
  x = setEndPoint.x;
2935
3203
  y = setEndPoint.y;
2936
3204
  i += 9;
@@ -2946,7 +3214,7 @@ const PathBounds = {
2946
3214
  break;
2947
3215
  case O:
2948
3216
  arc(null, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6], tempPointBounds, setEndPoint);
2949
- i === 0 ? copy$6(setPointBounds, tempPointBounds) : add$1(setPointBounds, tempPointBounds);
3217
+ i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
2950
3218
  x = setEndPoint.x;
2951
3219
  y = setEndPoint.y;
2952
3220
  i += 7;
@@ -2959,39 +3227,41 @@ const PathBounds = {
2959
3227
  x += radius;
2960
3228
  i += 4;
2961
3229
  break;
2962
- case U$1:
2963
- arcTo(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
2964
- i === 0 ? copy$6(setPointBounds, tempPointBounds) : add$1(setPointBounds, tempPointBounds);
3230
+ case U:
3231
+ arcTo$1(null, x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], tempPointBounds, setEndPoint);
3232
+ i === 0 ? copy$6(setPointBounds, tempPointBounds) : addPointBounds(setPointBounds, tempPointBounds);
2965
3233
  x = setEndPoint.x;
2966
3234
  y = setEndPoint.y;
2967
3235
  i += 6;
2968
3236
  break;
2969
3237
  default:
2970
- debug$8.error(`command: ${command} [index:${i}]`, data);
3238
+ debug$9.error(`command: ${command} [index:${i}]`, data);
2971
3239
  return;
2972
3240
  }
2973
3241
  }
2974
3242
  }
2975
3243
  };
2976
3244
 
2977
- const { M, L: L$1, C, Z, U } = PathCommandMap;
3245
+ const { M, L: L$1, C, Z } = PathCommandMap;
3246
+ const { getCenterX, getCenterY } = PointHelper;
3247
+ const { arcTo } = PathCommandDataHelper;
2978
3248
  const PathCorner = {
2979
3249
  smooth(data, cornerRadius, _cornerSmoothing) {
2980
3250
  let command;
2981
- let i = 0, x = 0, y = 0, startX, startY = 0, centerX = 0, centerY = 0;
3251
+ let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
2982
3252
  const len = data.length;
2983
3253
  const smooth = [];
2984
3254
  while (i < len) {
2985
3255
  command = data[i];
2986
3256
  switch (command) {
2987
3257
  case M:
2988
- startX = data[i + 1];
2989
- startY = data[i + 2];
3258
+ startX = lastX = data[i + 1];
3259
+ startY = lastY = data[i + 2];
2990
3260
  i += 3;
2991
3261
  if (data[i] === L$1) {
2992
- centerX = startX + (data[i + 1] - startX) / 2;
2993
- centerY = startY + (data[i + 2] - startY) / 2;
2994
- smooth.push(M, centerX, centerY);
3262
+ secondX = data[i + 1];
3263
+ secondY = data[i + 2];
3264
+ smooth.push(M, getCenterX(startX, secondX), getCenterY(startY, secondY));
2995
3265
  }
2996
3266
  else {
2997
3267
  smooth.push(M, startX, startY);
@@ -3003,21 +3273,23 @@ const PathCorner = {
3003
3273
  i += 3;
3004
3274
  switch (data[i]) {
3005
3275
  case L$1:
3006
- smooth.push(U, x, y, data[i + 1], data[i + 2], cornerRadius);
3276
+ arcTo(smooth, x, y, data[i + 1], data[i + 2], cornerRadius, lastX, lastY);
3007
3277
  break;
3008
3278
  case Z:
3009
- smooth.push(U, x, y, startX, startY, cornerRadius);
3279
+ arcTo(smooth, x, y, startX, startY, cornerRadius, lastX, lastY);
3010
3280
  break;
3011
3281
  default:
3012
3282
  smooth.push(L$1, x, y);
3013
3283
  }
3284
+ lastX = x;
3285
+ lastY = y;
3014
3286
  break;
3015
3287
  case C:
3016
3288
  smooth.push(C, data[i + 1], data[i + 2], data[i + 3], data[i + 4], data[i + 5], data[i + 6]);
3017
3289
  i += 7;
3018
3290
  break;
3019
3291
  case Z:
3020
- smooth.push(U, startX, startY, centerX, centerY, cornerRadius);
3292
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3021
3293
  smooth.push(Z);
3022
3294
  i += 1;
3023
3295
  break;
@@ -3048,7 +3320,7 @@ function canvasPatch(drawer) {
3048
3320
  roundRect(drawer);
3049
3321
  }
3050
3322
 
3051
- const debug$7 = Debug.get('TaskProcessor');
3323
+ const debug$8 = Debug.get('TaskProcessor');
3052
3324
  class TaskItem {
3053
3325
  constructor(task) {
3054
3326
  this.parallel = true;
@@ -3063,7 +3335,7 @@ class TaskItem {
3063
3335
  yield this.task();
3064
3336
  }
3065
3337
  catch (error) {
3066
- debug$7.error(error);
3338
+ debug$8.error(error);
3067
3339
  }
3068
3340
  });
3069
3341
  }
@@ -3301,7 +3573,7 @@ const ImageManager = {
3301
3573
  recycledList: [],
3302
3574
  tasker: new TaskProcessor(),
3303
3575
  patternTasker: new TaskProcessor(),
3304
- get isComplete() { return I$1.tasker.isComplete && I$1.patternTasker.isComplete; },
3576
+ get isComplete() { return I$1.tasker.isComplete; },
3305
3577
  get(config) {
3306
3578
  let image = I$1.map[config.url];
3307
3579
  if (!image) {
@@ -3632,16 +3904,6 @@ function getNames(object) {
3632
3904
  return Object.getOwnPropertyNames(object);
3633
3905
  }
3634
3906
 
3635
- function aliasType(name) {
3636
- return (target, key) => {
3637
- defineKey(target, key, {
3638
- get() { return this.__getAttr(name); },
3639
- set(value) {
3640
- this.__setAttr(name, value);
3641
- }
3642
- });
3643
- };
3644
- }
3645
3907
  function defineLeafAttr(target, key, defaultValue, mergeDescriptor) {
3646
3908
  const defaultDescriptor = {
3647
3909
  get() { return this.__getAttr(key); },
@@ -3667,6 +3929,17 @@ function positionType(defaultValue) {
3667
3929
  });
3668
3930
  };
3669
3931
  }
3932
+ function autoLayoutType(defaultValue) {
3933
+ return (target, key) => {
3934
+ defineLeafAttr(target, key, defaultValue, {
3935
+ set(value) {
3936
+ this.__setAttr(key, value);
3937
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3938
+ this.__hasAutoLayout = !!value;
3939
+ }
3940
+ });
3941
+ };
3942
+ }
3670
3943
  function scaleType(defaultValue) {
3671
3944
  return (target, key) => {
3672
3945
  defineLeafAttr(target, key, defaultValue, {
@@ -3693,7 +3966,7 @@ function boundsType(defaultValue) {
3693
3966
  set(value) {
3694
3967
  this.__setAttr(key, value);
3695
3968
  this.__layout.boxChanged || this.__layout.boxChange();
3696
- if (this.__.around)
3969
+ if (this.__hasAutoLayout)
3697
3970
  this.__layout.matrixChanged || this.__layout.matrixChange();
3698
3971
  }
3699
3972
  });
@@ -3815,9 +4088,6 @@ function layoutProcessor(processor) {
3815
4088
  function getSetMethodName(key) {
3816
4089
  return 'set' + key.charAt(0).toUpperCase() + key.slice(1);
3817
4090
  }
3818
- function setDefaultValue(target, key, defaultValue) {
3819
- defineDataProcessor(target.prototype, key, defaultValue);
3820
- }
3821
4091
  function defineDataProcessor(target, key, defaultValue) {
3822
4092
  const data = target.__DataProcessor.prototype;
3823
4093
  const computedKey = '_' + key;
@@ -3848,7 +4118,11 @@ function defineDataProcessor(target, key, defaultValue) {
3848
4118
  return v === undefined ? (this.__naturalHeight || defaultValue) : v;
3849
4119
  };
3850
4120
  }
3851
- const descriptor = getDescriptor(data, key);
4121
+ let descriptor, find = data;
4122
+ while (!descriptor && find) {
4123
+ descriptor = getDescriptor(find, key);
4124
+ find = find.__proto__;
4125
+ }
3852
4126
  if (descriptor && descriptor.set)
3853
4127
  property.set = descriptor.set;
3854
4128
  if (data[setMethodName]) {
@@ -3858,7 +4132,7 @@ function defineDataProcessor(target, key, defaultValue) {
3858
4132
  Object.defineProperty(data, key, property);
3859
4133
  }
3860
4134
 
3861
- const debug$6 = new Debug('rewrite');
4135
+ const debug$7 = new Debug('rewrite');
3862
4136
  const list$1 = [];
3863
4137
  const excludeNames = ['destroy', 'constructor'];
3864
4138
  function rewrite(method) {
@@ -3875,7 +4149,7 @@ function doRewrite(error) {
3875
4149
  if (list$1.length) {
3876
4150
  list$1.forEach(item => {
3877
4151
  if (error)
3878
- debug$6.error(item.name, '需在Class上装饰@rewriteAble()');
4152
+ debug$7.error(item.name, '需在Class上装饰@rewriteAble()');
3879
4153
  item.run();
3880
4154
  });
3881
4155
  list$1.length = 0;
@@ -4118,17 +4392,43 @@ class Transformer {
4118
4392
  }
4119
4393
  }
4120
4394
 
4121
- const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter } = MatrixHelper;
4122
- const matrix = {};
4395
+ const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$1, divideParent, getLayout } = MatrixHelper;
4396
+ const matrix$1 = {};
4123
4397
  const LeafHelper = {
4124
- updateAllWorldMatrix(leaf) {
4125
- leaf.__updateWorldMatrix();
4398
+ updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4399
+ if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged)
4400
+ waitAutoLayout = true;
4401
+ updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
4126
4402
  if (leaf.isBranch) {
4127
4403
  const { children } = leaf;
4128
4404
  for (let i = 0, len = children.length; i < len; i++) {
4129
- updateAllWorldMatrix$2(children[i]);
4405
+ updateAllMatrix$3(children[i], checkAutoLayout, waitAutoLayout);
4406
+ }
4407
+ }
4408
+ },
4409
+ updateMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4410
+ const layout = leaf.__layout;
4411
+ if (checkAutoLayout) {
4412
+ if (waitAutoLayout) {
4413
+ layout.waitAutoLayout = true;
4414
+ if (leaf.__hasAutoLayout)
4415
+ layout.matrixChanged = false;
4130
4416
  }
4131
4417
  }
4418
+ else if (layout.waitAutoLayout) {
4419
+ layout.waitAutoLayout = false;
4420
+ }
4421
+ if (layout.matrixChanged)
4422
+ leaf.__updateLocalMatrix();
4423
+ if (!layout.waitAutoLayout)
4424
+ leaf.__updateWorldMatrix();
4425
+ },
4426
+ updateBounds(leaf) {
4427
+ const layout = leaf.__layout;
4428
+ if (layout.boundsChanged)
4429
+ leaf.__updateLocalBounds();
4430
+ if (!layout.waitAutoLayout)
4431
+ leaf.__updateWorldBounds();
4132
4432
  },
4133
4433
  updateAllWorldOpacity(leaf) {
4134
4434
  leaf.__updateWorldOpacity();
@@ -4170,62 +4470,78 @@ const LeafHelper = {
4170
4470
  t.x += x;
4171
4471
  t.y += y;
4172
4472
  },
4173
- zoomOfWorld(t, origin, scaleX, scaleY) {
4174
- this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY);
4473
+ zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4474
+ this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
4175
4475
  },
4176
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX) {
4177
- copy$5(matrix, t.__local);
4178
- scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4179
- moveByMatrix(t, matrix);
4180
- t.scaleX *= scaleX;
4181
- t.scaleY *= scaleY;
4476
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4477
+ copy$5(matrix$1, t.__localMatrix);
4478
+ scaleOfOuter$3(matrix$1, origin, scaleX, scaleY);
4479
+ moveByMatrix(t, matrix$1);
4480
+ t.scaleResize(scaleX, scaleY, resize !== true);
4182
4481
  },
4183
4482
  rotateOfWorld(t, origin, angle) {
4184
4483
  this.rotateOfLocal(t, getTempLocal(t, origin), angle);
4185
4484
  },
4186
4485
  rotateOfLocal(t, origin, angle) {
4187
- copy$5(matrix, t.__local);
4188
- rotateOfOuter$3(matrix, origin, angle);
4189
- moveByMatrix(t, matrix);
4486
+ copy$5(matrix$1, t.__localMatrix);
4487
+ rotateOfOuter$3(matrix$1, origin, angle);
4488
+ moveByMatrix(t, matrix$1);
4190
4489
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
4191
4490
  },
4192
- skewOfWorld(t, origin, skewX, skewY) {
4193
- this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY);
4491
+ skewOfWorld(t, origin, skewX, skewY, resize) {
4492
+ this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
4493
+ },
4494
+ skewOfLocal(t, origin, skewX, skewY = 0, resize) {
4495
+ copy$5(matrix$1, t.__localMatrix);
4496
+ skewOfOuter(matrix$1, origin, skewX, skewY);
4497
+ L.setTransform(t, matrix$1, resize);
4498
+ },
4499
+ transform(t, transform, resize) {
4500
+ copy$5(matrix$1, t.localTransform);
4501
+ multiplyParent$1(matrix$1, transform);
4502
+ L.setTransform(t, matrix$1, resize);
4194
4503
  },
4195
- skewOfLocal(t, origin, skewX, skewY) {
4196
- copy$5(matrix, t.__local);
4197
- skewOfOuter(matrix, origin, skewX, skewY);
4198
- moveByMatrix(t, matrix);
4199
- t.skewX = MathHelper.formatSkew(t.skewX + skewX);
4200
- t.skewY = MathHelper.formatSkew(t.skewY + skewY);
4504
+ setTransform(t, transform, resize) {
4505
+ const layout = getLayout(transform);
4506
+ if (resize) {
4507
+ t.scaleResize(layout.scaleX / t.scaleX, layout.scaleY / t.scaleY, resize !== true);
4508
+ delete layout.scaleX;
4509
+ delete layout.scaleY;
4510
+ }
4511
+ t.set(layout);
4201
4512
  },
4202
- drop(t, parent) {
4203
- const position = { x: t.x, y: t.y };
4204
- t.localToWorld(position);
4205
- parent.worldToInner(position);
4206
- t.set(position);
4207
- parent.add(t);
4513
+ drop(t, parent, index, resize) {
4514
+ copy$5(matrix$1, t.worldTransform);
4515
+ divideParent(matrix$1, parent.worldTransform);
4516
+ t.setTransform(matrix$1, resize);
4517
+ parent.add(t, index);
4208
4518
  },
4209
- hasParent(t, parent) {
4519
+ hasParent(p, parent) {
4210
4520
  if (!parent)
4211
4521
  return false;
4212
- let p = t;
4213
4522
  while (p) {
4214
4523
  if (parent === p)
4215
4524
  return true;
4216
4525
  p = p.parent;
4217
4526
  }
4218
- return false;
4527
+ },
4528
+ hasParentAutoLayout(p) {
4529
+ while (p.parent) {
4530
+ p = p.parent;
4531
+ if (p.__hasAutoLayout)
4532
+ return true;
4533
+ }
4219
4534
  }
4220
4535
  };
4221
4536
  const L = LeafHelper;
4222
- const { updateAllWorldMatrix: updateAllWorldMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4537
+ const { updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4223
4538
  function moveByMatrix(t, matrix) {
4224
- t.x += matrix.e - t.__local.e;
4225
- t.y += matrix.f - t.__local.f;
4539
+ const { e, f } = t.__localMatrix;
4540
+ t.x += matrix.e - e;
4541
+ t.y += matrix.f - f;
4226
4542
  }
4227
4543
  function getTempLocal(t, world) {
4228
- t.__layout.checkUpdate();
4544
+ t.__layout.update();
4229
4545
  return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
4230
4546
  }
4231
4547
 
@@ -4234,18 +4550,18 @@ const LeafBoundsHelper = {
4234
4550
  return target.__world;
4235
4551
  },
4236
4552
  localBoxBounds(target) {
4237
- return target.__.isEraser ? null : target.__local;
4553
+ return target.__.isEraser ? null : (target.__local || target.__);
4238
4554
  },
4239
- localEventBounds(target) {
4555
+ localStrokeBounds(target) {
4240
4556
  return target.__.isEraser ? null : target.__layout.localStrokeBounds;
4241
4557
  },
4242
4558
  localRenderBounds(target) {
4243
4559
  return target.__.isEraser ? null : target.__layout.localRenderBounds;
4244
4560
  },
4245
4561
  maskLocalBoxBounds(target) {
4246
- return target.__.isMask ? target.__local : null;
4562
+ return target.__.isMask ? target.__localBounds : null;
4247
4563
  },
4248
- maskLocalEventBounds(target) {
4564
+ maskLocalStrokeBounds(target) {
4249
4565
  return target.__.isMask ? target.__layout.localStrokeBounds : null;
4250
4566
  },
4251
4567
  maskLocalRenderBounds(target) {
@@ -4253,11 +4569,12 @@ const LeafBoundsHelper = {
4253
4569
  }
4254
4570
  };
4255
4571
 
4572
+ const { updateBounds: updateBounds$2 } = LeafHelper;
4256
4573
  const BranchHelper = {
4257
4574
  sort(a, b) {
4258
4575
  return (a.__.zIndex === b.__.zIndex) ? (a.__tempNumber - b.__tempNumber) : (a.__.zIndex - b.__.zIndex);
4259
4576
  },
4260
- pushAllChildBranch(branch, pushList) {
4577
+ pushAllChildBranch(branch, leafList) {
4261
4578
  branch.__tempNumber = 1;
4262
4579
  if (branch.__.__childBranchNumber) {
4263
4580
  const { children } = branch;
@@ -4265,18 +4582,18 @@ const BranchHelper = {
4265
4582
  branch = children[i];
4266
4583
  if (branch.isBranch) {
4267
4584
  branch.__tempNumber = 1;
4268
- pushList.push(branch);
4269
- pushAllChildBranch$1(branch, pushList);
4585
+ leafList.add(branch);
4586
+ pushAllChildBranch$1(branch, leafList);
4270
4587
  }
4271
4588
  }
4272
4589
  }
4273
4590
  },
4274
- pushAllParent(leaf, pushList) {
4275
- const { keys } = pushList;
4591
+ pushAllParent(leaf, leafList) {
4592
+ const { keys } = leafList;
4276
4593
  if (keys) {
4277
4594
  while (leaf.parent) {
4278
4595
  if (keys[leaf.parent.innerId] === undefined) {
4279
- pushList.push(leaf.parent);
4596
+ leafList.add(leaf.parent);
4280
4597
  leaf = leaf.parent;
4281
4598
  }
4282
4599
  else {
@@ -4286,7 +4603,7 @@ const BranchHelper = {
4286
4603
  }
4287
4604
  else {
4288
4605
  while (leaf.parent) {
4289
- pushList.push(leaf.parent);
4606
+ leafList.add(leaf.parent);
4290
4607
  leaf = leaf.parent;
4291
4608
  }
4292
4609
  }
@@ -4300,21 +4617,29 @@ const BranchHelper = {
4300
4617
  }
4301
4618
  }
4302
4619
  for (let i = start, len = pushList.length; i < len; i++) {
4303
- pushAllBranchStack$1(pushList[i], pushList);
4620
+ pushAllBranchStack(pushList[i], pushList);
4304
4621
  }
4305
4622
  },
4306
- updateWorldBoundsByBranchStack(branchStack) {
4307
- let branch;
4623
+ updateBounds(branch, exclude) {
4624
+ const branchStack = [branch];
4625
+ pushAllBranchStack(branch, branchStack);
4626
+ updateBoundsByBranchStack(branchStack, exclude);
4627
+ },
4628
+ updateBoundsByBranchStack(branchStack, exclude) {
4629
+ let branch, children;
4308
4630
  for (let i = branchStack.length - 1; i > -1; i--) {
4309
4631
  branch = branchStack[i];
4310
- for (let j = 0, len = branch.children.length; j < len; j++) {
4311
- branch.children[j].__updateWorldBounds();
4632
+ children = branch.children;
4633
+ for (let j = 0, len = children.length; j < len; j++) {
4634
+ updateBounds$2(children[j]);
4312
4635
  }
4636
+ if (exclude && exclude === branch)
4637
+ continue;
4638
+ updateBounds$2(branch);
4313
4639
  }
4314
- branch.__updateWorldBounds();
4315
4640
  }
4316
4641
  };
4317
- const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack: pushAllBranchStack$1 } = BranchHelper;
4642
+ const { pushAllChildBranch: pushAllChildBranch$1, pushAllBranchStack, updateBoundsByBranchStack } = BranchHelper;
4318
4643
 
4319
4644
  const WaitHelper = {
4320
4645
  run(wait) {
@@ -4382,7 +4707,7 @@ const InteractionHelper = {
4382
4707
  const { list } = path;
4383
4708
  for (let i = 0, len = list.length; i < len; i++) {
4384
4709
  if (list[i].hasEvent(type))
4385
- find.push(list[i]);
4710
+ find.add(list[i]);
4386
4711
  }
4387
4712
  return find;
4388
4713
  }
@@ -4399,7 +4724,8 @@ class Dragger {
4399
4724
  this.dragData = getDragEventData(data, data, data);
4400
4725
  }
4401
4726
  getList() {
4402
- return this.dragging ? (DragEvent.list || this.interaction.selector.list || this.dragableList || emptyList) : emptyList;
4727
+ const { proxy } = this.interaction.selector;
4728
+ return this.dragging && (!proxy || !proxy.list.length) ? (DragEvent.list || this.dragableList || emptyList) : emptyList;
4403
4729
  }
4404
4730
  checkDrag(data, canDrag) {
4405
4731
  const { interaction } = this;
@@ -4410,8 +4736,7 @@ class Dragger {
4410
4736
  }
4411
4737
  const { dragData } = this;
4412
4738
  if (!this.moving) {
4413
- const moveOnDragEmpty = interaction.config.move.dragEmpty && downData.target.isLeafer;
4414
- this.moving = (PointerButton.middle(data) || interaction.moveMode || moveOnDragEmpty) && canDrag;
4739
+ this.moving = (PointerButton.middle(data) || interaction.moveMode) && canDrag;
4415
4740
  if (this.moving)
4416
4741
  interaction.emit(MoveEvent.START, dragData);
4417
4742
  }
@@ -4446,7 +4771,7 @@ class Dragger {
4446
4771
  let leaf;
4447
4772
  for (let i = 0, len = path.length; i < len; i++) {
4448
4773
  leaf = path.list[i];
4449
- if (leaf.__.draggable && leaf.__.hitSelf) {
4774
+ if ((leaf.__.draggable || leaf.__.editable) && leaf.__.hitSelf) {
4450
4775
  this.dragableList = new LeafList(leaf);
4451
4776
  break;
4452
4777
  }
@@ -4457,9 +4782,7 @@ class Dragger {
4457
4782
  const list = this.getList();
4458
4783
  if (list.length && running) {
4459
4784
  const { moveX, moveY } = this.dragData;
4460
- list.forEach(leaf => {
4461
- LeafHelper.moveWorld(leaf, moveX, moveY);
4462
- });
4785
+ list.forEach(leaf => LeafHelper.moveWorld(leaf, moveX, moveY));
4463
4786
  }
4464
4787
  }
4465
4788
  dragOverOrOut(data) {
@@ -4537,8 +4860,8 @@ class Dragger {
4537
4860
  return;
4538
4861
  const bounds = interaction.shrinkCanvasBounds;
4539
4862
  const { x, y } = bounds;
4540
- const right = BoundsHelper.right(bounds);
4541
- const bottom = BoundsHelper.bottom(bounds);
4863
+ const right = BoundsHelper.maxX(bounds);
4864
+ const bottom = BoundsHelper.maxY(bounds);
4542
4865
  const moveX = data.x < x ? autoDistance : (right < data.x ? -autoDistance : 0);
4543
4866
  const moveY = data.y < y ? autoDistance : (bottom < data.y ? -autoDistance : 0);
4544
4867
  let totalX = 0, totalY = 0;
@@ -4562,6 +4885,7 @@ class Dragger {
4562
4885
  }
4563
4886
  }
4564
4887
 
4888
+ const debug$6 = Debug.get('emit');
4565
4889
  function emit$1(type, data, path, excludePath) {
4566
4890
  if (!path && !data.path)
4567
4891
  return;
@@ -4574,24 +4898,29 @@ function emit$1(type, data, path, excludePath) {
4574
4898
  path = data.path;
4575
4899
  }
4576
4900
  data.target = path.indexAt(0);
4577
- for (let i = path.length - 1; i > -1; i--) {
4578
- leaf = path.list[i];
4579
- if (emitEvent(leaf, type, data, true, excludePath))
4580
- return;
4581
- if (leaf.isApp)
4582
- emitAppChildren(leaf, type, data, true, excludePath);
4583
- }
4584
- for (let i = 0, len = path.length; i < len; i++) {
4585
- leaf = path.list[i];
4586
- if (leaf.isApp)
4587
- emitAppChildren(leaf, type, data, false, excludePath);
4588
- if (emitEvent(leaf, type, data, false, excludePath))
4589
- return;
4590
- }
4591
- }
4592
- const allowTypes = ['move', 'zoom', 'rotate', 'key'];
4593
- function emitAppChildren(leaf, type, data, capture, excludePath) {
4594
- if (allowTypes.some(name => type.startsWith(name)) && leaf.__.hitChildren && !exclude(leaf, excludePath)) {
4901
+ try {
4902
+ for (let i = path.length - 1; i > -1; i--) {
4903
+ leaf = path.list[i];
4904
+ if (emitEvent(leaf, type, data, true, excludePath))
4905
+ return;
4906
+ if (leaf.isApp)
4907
+ emitAppChildren(leaf, type, data, true, excludePath);
4908
+ }
4909
+ for (let i = 0, len = path.length; i < len; i++) {
4910
+ leaf = path.list[i];
4911
+ if (leaf.isApp)
4912
+ emitAppChildren(leaf, type, data, false, excludePath);
4913
+ if (emitEvent(leaf, type, data, false, excludePath))
4914
+ return;
4915
+ }
4916
+ }
4917
+ catch (e) {
4918
+ debug$6.error(e);
4919
+ }
4920
+ }
4921
+ const allowTypes = ['move', 'zoom', 'rotate', 'key'];
4922
+ function emitAppChildren(leaf, type, data, capture, excludePath) {
4923
+ if (allowTypes.some(name => type.startsWith(name)) && leaf.__.hitChildren && !exclude(leaf, excludePath)) {
4595
4924
  let child;
4596
4925
  for (let i = 0, len = leaf.children.length; i < len; i++) {
4597
4926
  child = leaf.children[i];
@@ -4626,39 +4955,42 @@ const MultiTouchHelper = {
4626
4955
  const lastDistance = PointHelper.getDistance(a.from, b.from);
4627
4956
  const distance = PointHelper.getDistance(a.to, b.to);
4628
4957
  const scale = distance / lastDistance;
4629
- const angle = PointHelper.getChangeAngle(a.from, b.from, a.to, b.to);
4958
+ const angle = PointHelper.getRotation(a.from, b.from, a.to, b.to);
4630
4959
  return { move, scale, angle, center };
4631
4960
  }
4632
4961
  };
4633
4962
 
4963
+ const config = {
4964
+ wheel: {
4965
+ zoomMode: false,
4966
+ zoomSpeed: 0.5,
4967
+ moveSpeed: 0.5,
4968
+ rotateSpeed: 0.5,
4969
+ delta: Platform.os === 'Windows' ? { x: 150 / 4, y: 150 / 4 } : { x: 80 / 4, y: 8.0 },
4970
+ preventDefault: true
4971
+ },
4972
+ pointer: {
4973
+ hitRadius: 5,
4974
+ through: false,
4975
+ tapTime: 120,
4976
+ longPressTime: 800,
4977
+ transformTime: 500,
4978
+ dragHover: true,
4979
+ dragDistance: 2,
4980
+ swipeDistance: 20,
4981
+ ignoreMove: false
4982
+ },
4983
+ cursor: {}
4984
+ };
4985
+
4634
4986
  const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
4635
4987
  class InteractionBase {
4636
4988
  get dragging() { return this.dragger.dragging; }
4637
- get moveMode() { return (Keyboard.isHoldSpaceKey() && this.config.move.holdSpaceKey) || (this.downData && PointerButton.middle(this.downData)); }
4989
+ get isDragEmpty() { return this.config.move.dragEmpty && (this.hoverData && this.hoverData.path.list[0].isLeafer) && (!this.downData || this.downData.path.list[0].isLeafer); }
4990
+ get moveMode() { return this.config.move.drag || (this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey()) || (this.downData && PointerButton.middle(this.downData)) || this.isDragEmpty; }
4638
4991
  get hitRadius() { return this.config.pointer.hitRadius; }
4639
4992
  constructor(target, canvas, selector, userConfig) {
4640
- this.config = {
4641
- wheel: {
4642
- zoomMode: false,
4643
- zoomSpeed: 0.5,
4644
- moveSpeed: 0.5,
4645
- rotateSpeed: 0.5,
4646
- delta: Platform.os === 'Windows' ? { x: 150 / 4, y: 150 / 4 } : { x: 80 / 4, y: 8.0 },
4647
- preventDefault: true
4648
- },
4649
- pointer: {
4650
- hitRadius: 5,
4651
- through: false,
4652
- tapTime: 120,
4653
- longPressTime: 800,
4654
- transformTime: 500,
4655
- dragHover: true,
4656
- dragDistance: 2,
4657
- swipeDistance: 20,
4658
- ignoreMove: false
4659
- },
4660
- cursor: {}
4661
- };
4993
+ this.config = config;
4662
4994
  this.tapCount = 0;
4663
4995
  this.downKeyMap = {};
4664
4996
  this.target = target;
@@ -4684,10 +5016,10 @@ class InteractionBase {
4684
5016
  if (!data)
4685
5017
  return;
4686
5018
  PointerButton.defaultLeft(data);
4687
- this.emit(PointerEvent.BEFORE_DOWN, data, this.defaultPath);
4688
5019
  this.updateDownData(data);
4689
5020
  if (useDefaultPath)
4690
5021
  data.path = this.defaultPath;
5022
+ this.emit(PointerEvent.BEFORE_DOWN, data);
4691
5023
  this.emit(PointerEvent.DOWN, data);
4692
5024
  this.downTime = Date.now();
4693
5025
  this.dragger.setDragData(data);
@@ -4718,7 +5050,8 @@ class InteractionBase {
4718
5050
  const canDrag = PointHelper.getDistance(this.downData, data) > this.config.pointer.dragDistance;
4719
5051
  if (this.waitTap && canDrag)
4720
5052
  this.pointerWaitCancel();
4721
- this.dragger.checkDrag(data, canDrag);
5053
+ if (!PointerButton.right(this.downData))
5054
+ this.dragger.checkDrag(data, canDrag);
4722
5055
  }
4723
5056
  if (this.dragger.moving || this.config.pointer.ignoreMove)
4724
5057
  return;
@@ -4738,8 +5071,8 @@ class InteractionBase {
4738
5071
  if (!this.downData)
4739
5072
  return;
4740
5073
  PointerButton.defaultLeft(data);
4741
- this.emit(PointerEvent.BEFORE_UP, data, this.defaultPath);
4742
5074
  this.findPath(data);
5075
+ this.emit(PointerEvent.BEFORE_UP, data);
4743
5076
  this.emit(PointerEvent.UP, data);
4744
5077
  this.emit(PointerEvent.UP, this.downData, undefined, data.path);
4745
5078
  this.touchLeave(data);
@@ -4999,20 +5332,27 @@ class Cursor {
4999
5332
  }
5000
5333
  Cursor.custom = {};
5001
5334
 
5002
- const { toOuterOf: toOuterOf$1 } = BoundsHelper;
5335
+ const { toOuterOf: toOuterOf$1, getPoints } = BoundsHelper;
5003
5336
  class LeafLayout {
5337
+ get a() { return 1; }
5338
+ get b() { return 0; }
5339
+ get c() { return 0; }
5340
+ get d() { return 1; }
5341
+ get e() { return this.leaf.__.x; }
5342
+ get f() { return this.leaf.__.y; }
5004
5343
  constructor(leaf) {
5005
5344
  this.leaf = leaf;
5006
5345
  this.renderBounds = this.strokeBounds = this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
5007
- this.localRenderBounds = this.localStrokeBounds = leaf.__local;
5346
+ if (leaf.__local)
5347
+ this.localRenderBounds = this.localStrokeBounds = leaf.__local;
5008
5348
  this.boxChange();
5009
5349
  this.matrixChange();
5010
5350
  }
5011
- checkUpdate(force) {
5351
+ update() {
5012
5352
  const { leafer } = this.leaf;
5013
5353
  if (leafer) {
5014
5354
  if (leafer.ready) {
5015
- if ((Platform.realtimeLayout || force) && leafer.watcher.changed)
5355
+ if (leafer.watcher.changed)
5016
5356
  leafer.layouter.layout();
5017
5357
  }
5018
5358
  else {
@@ -5021,59 +5361,141 @@ class LeafLayout {
5021
5361
  }
5022
5362
  else {
5023
5363
  let root = this.leaf;
5024
- while (root.parent) {
5364
+ while (root.parent && !root.parent.leafer) {
5025
5365
  root = root.parent;
5026
5366
  }
5027
5367
  Platform.layout(root);
5028
5368
  }
5029
5369
  }
5030
- getTransform(locationType) {
5031
- this.checkUpdate();
5032
- return locationType === 'world' ? this.leaf.__world : this.leaf.__local;
5033
- }
5034
- getBounds(type, locationType) {
5035
- this.checkUpdate();
5036
- if (locationType === 'world') {
5037
- switch (type) {
5038
- case 'render':
5039
- return this.leaf.__world;
5040
- case 'content':
5041
- if (this.contentBounds)
5042
- return this.getWorldContentBounds();
5043
- case 'margin':
5044
- case 'box':
5045
- return this.getWorldBoxBounds();
5046
- case 'margin':
5047
- case 'stroke':
5048
- return this.getWorldStrokeBounds();
5049
- }
5050
- }
5051
- else if (locationType === 'inner') {
5052
- switch (type) {
5053
- case 'render':
5054
- return this.renderBounds;
5055
- case 'content':
5056
- if (this.contentBounds)
5057
- return this.contentBounds;
5058
- case 'margin':
5059
- case 'box':
5060
- return this.boxBounds;
5061
- case 'stroke':
5062
- return this.strokeBounds;
5063
- }
5064
- }
5065
- else {
5066
- switch (type) {
5067
- case 'render':
5370
+ getTransform(relative = 'world') {
5371
+ this.update();
5372
+ switch (relative) {
5373
+ case 'world':
5374
+ return this.leaf.__world;
5375
+ case 'local':
5376
+ return this.leaf.__localMatrix;
5377
+ case 'inner':
5378
+ return MatrixHelper.defaultMatrix;
5379
+ default:
5380
+ return new Matrix(this.leaf.__world).divideParent(relative.__world);
5381
+ }
5382
+ }
5383
+ getBounds(type, relative = 'world') {
5384
+ this.update();
5385
+ switch (relative) {
5386
+ case 'world':
5387
+ return this.getWorldBounds(type);
5388
+ case 'local':
5389
+ return this.getLocalBounds(type);
5390
+ case 'inner':
5391
+ return this.getInnerBounds(type);
5392
+ default:
5393
+ return new Bounds(this.getInnerBounds(type)).toOuterOf(this.getTransform(relative));
5394
+ }
5395
+ }
5396
+ getInnerBounds(type = 'box') {
5397
+ switch (type) {
5398
+ case 'render':
5399
+ return this.renderBounds;
5400
+ case 'content':
5401
+ if (this.contentBounds)
5402
+ return this.contentBounds;
5403
+ case 'margin':
5404
+ case 'box':
5405
+ return this.boxBounds;
5406
+ case 'stroke':
5407
+ return this.strokeBounds;
5408
+ }
5409
+ }
5410
+ getLocalBounds(type = 'box') {
5411
+ switch (type) {
5412
+ case 'render':
5413
+ if (this.localRenderBounds)
5068
5414
  return this.localRenderBounds;
5069
- case 'margin':
5070
- case 'content':
5071
- case 'box':
5072
- return this.leaf.__local;
5073
- case 'stroke':
5415
+ case 'stroke':
5416
+ if (this.localStrokeBounds)
5074
5417
  return this.localStrokeBounds;
5075
- }
5418
+ case 'margin':
5419
+ case 'content':
5420
+ case 'box':
5421
+ return this.leaf.__localBounds;
5422
+ }
5423
+ }
5424
+ getWorldBounds(type = 'box') {
5425
+ switch (type) {
5426
+ case 'render':
5427
+ return this.leaf.__world;
5428
+ case 'content':
5429
+ if (this.contentBounds)
5430
+ return this.getWorldContentBounds();
5431
+ case 'margin':
5432
+ case 'box':
5433
+ return this.getWorldBoxBounds();
5434
+ case 'margin':
5435
+ case 'stroke':
5436
+ return this.getWorldStrokeBounds();
5437
+ }
5438
+ }
5439
+ getLayoutBounds(type, relative = 'world', unscale) {
5440
+ const { leaf } = this;
5441
+ let point, layout;
5442
+ let bounds = this.getInnerBounds(type);
5443
+ switch (relative) {
5444
+ case 'world':
5445
+ point = leaf.getWorldPoint(bounds);
5446
+ layout = leaf.__world;
5447
+ break;
5448
+ case 'local':
5449
+ point = leaf.getLocalPointByInner(bounds);
5450
+ layout = leaf.__;
5451
+ break;
5452
+ case 'inner':
5453
+ point = bounds;
5454
+ layout = MatrixHelper.defaultWorld;
5455
+ break;
5456
+ default:
5457
+ point = leaf.getWorldPoint(bounds, relative);
5458
+ layout = leaf.__world;
5459
+ }
5460
+ let { scaleX, scaleY, rotation, skewX, skewY } = layout;
5461
+ let { width, height } = bounds;
5462
+ if (typeof relative === 'object') {
5463
+ const r = relative.__world;
5464
+ scaleX /= r.scaleX;
5465
+ scaleY /= r.scaleY;
5466
+ rotation -= r.rotation;
5467
+ skewX -= r.skewX;
5468
+ skewY -= r.skewY;
5469
+ }
5470
+ if (unscale) {
5471
+ const uScaleX = scaleX < 0 ? -scaleX : scaleX;
5472
+ const uScaleY = scaleY < 0 ? -scaleY : scaleY;
5473
+ scaleX /= uScaleX;
5474
+ scaleY /= uScaleY;
5475
+ width *= uScaleX;
5476
+ height *= uScaleY;
5477
+ }
5478
+ return { x: point.x, y: point.y, scaleX, scaleY, rotation, skewX, skewY, width, height };
5479
+ }
5480
+ getLayoutPoints(type, relative = 'world') {
5481
+ const { leaf } = this;
5482
+ const points = getPoints(this.getInnerBounds(type));
5483
+ let relativeLeaf;
5484
+ switch (relative) {
5485
+ case 'world':
5486
+ relativeLeaf = null;
5487
+ break;
5488
+ case 'local':
5489
+ relativeLeaf = leaf.parent;
5490
+ break;
5491
+ case 'inner':
5492
+ break;
5493
+ default:
5494
+ relativeLeaf = relative;
5076
5495
  }
5496
+ if (relativeLeaf !== undefined)
5497
+ points.forEach(point => leaf.innerToWorld(point, null, false, relativeLeaf));
5498
+ return points;
5077
5499
  }
5078
5500
  getWorldContentBounds() {
5079
5501
  this._worldContentBounds || (this._worldContentBounds = {});
@@ -5093,7 +5515,7 @@ class LeafLayout {
5093
5515
  spreadStrokeCancel() {
5094
5516
  const same = this.renderBounds === this.strokeBounds;
5095
5517
  this.strokeBounds = this.boxBounds;
5096
- this.localStrokeBounds = this.leaf.__local;
5518
+ this.localStrokeBounds = this.leaf.__localBounds;
5097
5519
  if (same)
5098
5520
  this.spreadRenderCancel();
5099
5521
  }
@@ -5220,13 +5642,13 @@ const LeafEventer = {
5220
5642
  if (bind)
5221
5643
  listener = listener.bind(bind);
5222
5644
  this.on(type, listener, options);
5223
- return { type, listener, options };
5645
+ return { type, current: this, listener, options };
5224
5646
  },
5225
5647
  off_(id) {
5226
5648
  if (!id)
5227
5649
  return;
5228
5650
  const list = id instanceof Array ? id : [id];
5229
- list.forEach(item => this.off(item.type, item.listener, item.options));
5651
+ list.forEach(item => item.current.off(item.type, item.listener, item.options));
5230
5652
  list.length = 0;
5231
5653
  },
5232
5654
  once(type, listener, capture) {
@@ -5292,7 +5714,7 @@ const LeafDataProxy = {
5292
5714
  const oldValue = this.__.__getInput(name);
5293
5715
  if (typeof newValue === 'object' || oldValue !== newValue) {
5294
5716
  this.__[name] = newValue;
5295
- if (this.proxyData)
5717
+ if (this.__proxyData)
5296
5718
  this.setProxyAttr(name, newValue);
5297
5719
  const { CHANGE } = PropertyEvent;
5298
5720
  const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
@@ -5303,191 +5725,121 @@ const LeafDataProxy = {
5303
5725
  }
5304
5726
  else {
5305
5727
  this.__[name] = newValue;
5306
- if (this.proxyData)
5728
+ if (this.__proxyData)
5307
5729
  this.setProxyAttr(name, newValue);
5308
5730
  }
5309
5731
  },
5310
5732
  __getAttr(name) {
5311
- if (this.proxyData)
5733
+ if (this.__proxyData)
5312
5734
  return this.getProxyAttr(name);
5313
5735
  return this.__.__get(name);
5314
- },
5315
- setProxyAttr(name, newValue) {
5316
- if (this.proxyData[name] !== newValue)
5317
- this.proxyData[name] = newValue;
5318
- },
5319
- getProxyAttr(name) {
5320
- return this.proxyData[name];
5321
5736
  }
5322
5737
  };
5323
5738
 
5324
- const { sin: sin$2, cos: cos$2 } = Math;
5325
- const defaultWorld = Object.assign(Object.assign({}, MatrixHelper.defaultMatrix), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
5326
- const defaultCenter = { x: 0.5, y: 0.5 };
5739
+ const { setLayout, multiplyParent, translateInner, defaultWorld } = MatrixHelper;
5740
+ const { toPoint, tempPoint } = AroundHelper;
5327
5741
  const LeafMatrix = {
5328
5742
  __updateWorldMatrix() {
5329
- const pw = this.parent ? this.parent.__world : defaultWorld;
5330
- const r = this.__local;
5331
- const w = this.__world;
5332
- if (this.__layout.matrixChanged)
5333
- this.__updateLocalMatrix();
5334
- if (this.__layout.affectScaleOrRotation) {
5335
- w.a = r.a * pw.a + r.b * pw.c;
5336
- w.b = r.a * pw.b + r.b * pw.d;
5337
- w.c = r.c * pw.a + r.d * pw.c;
5338
- w.d = r.c * pw.b + r.d * pw.d;
5339
- w.e = r.e * pw.a + r.f * pw.c + pw.e;
5340
- w.f = r.e * pw.b + r.f * pw.d + pw.f;
5341
- const data = this.__;
5342
- w.scaleX = pw.scaleX * data.scaleX;
5343
- w.scaleY = pw.scaleY * data.scaleY;
5344
- w.rotation = pw.rotation + data.rotation;
5345
- w.skewX = pw.skewX + data.skewX;
5346
- w.skewY = pw.skewY + data.skewY;
5347
- }
5348
- else {
5349
- w.a = pw.a;
5350
- w.b = pw.b;
5351
- w.c = pw.c;
5352
- w.d = pw.d;
5353
- w.e = r.e * pw.a + r.f * pw.c + pw.e;
5354
- w.f = r.e * pw.b + r.f * pw.d + pw.f;
5355
- w.scaleX = pw.scaleX;
5356
- w.scaleY = pw.scaleY;
5357
- w.rotation = pw.rotation;
5358
- w.skewX = pw.skewX;
5359
- w.skewY = pw.skewY;
5360
- }
5743
+ multiplyParent(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
5361
5744
  },
5362
5745
  __updateLocalMatrix() {
5363
- const r = this.__local;
5364
- const layout = this.__layout;
5365
- if (layout.affectScaleOrRotation) {
5366
- const { scaleX, scaleY } = this.__;
5367
- if (layout.affectRotation) {
5746
+ if (this.__local) {
5747
+ const layout = this.__layout, local = this.__local, data = this.__;
5748
+ if (layout.affectScaleOrRotation) {
5368
5749
  if (layout.scaleChanged || layout.rotationChanged) {
5369
- let { rotation, skewX, skewY } = this.__;
5370
- if (rotation || skewX || skewY) {
5371
- rotation *= OneRadian;
5372
- if (skewX)
5373
- skewX *= OneRadian;
5374
- if (skewY)
5375
- skewY *= OneRadian;
5376
- r.a = scaleX * cos$2(rotation + skewY);
5377
- r.b = scaleX * sin$2(rotation + skewY);
5378
- r.c = scaleY * -sin$2(rotation - skewX);
5379
- r.d = scaleY * cos$2(rotation - skewX);
5380
- }
5381
- else {
5382
- r.a = scaleX;
5383
- r.b = 0;
5384
- r.c = 0;
5385
- r.d = scaleY;
5386
- layout.affectRotation = false;
5387
- }
5388
- layout.scaleChanged = false;
5389
- layout.rotationChanged = false;
5390
- }
5391
- }
5392
- else {
5393
- if (layout.scaleChanged) {
5394
- r.a = scaleX;
5395
- r.d = scaleY;
5396
- layout.scaleChanged = false;
5750
+ setLayout(local, data, null, layout.affectRotation);
5751
+ layout.scaleChanged = layout.rotationChanged = false;
5397
5752
  }
5398
5753
  }
5399
- }
5400
- const { x, y, around } = this.__;
5401
- r.e = x;
5402
- r.f = y;
5403
- if (around) {
5404
- const { width, height } = this.__;
5405
- if (width && height) {
5406
- const origin = (around === 'center') ? defaultCenter : around;
5407
- const offsetX = width * origin.x, offsetY = height * origin.y;
5408
- r.e -= offsetX * r.a + offsetY * r.c;
5409
- r.f -= offsetX * r.b + offsetY * r.d;
5754
+ local.e = data.x;
5755
+ local.f = data.y;
5756
+ if (data.around) {
5757
+ toPoint(data.around, layout.boxBounds, tempPoint);
5758
+ translateInner(local, -tempPoint.x, -tempPoint.y);
5410
5759
  }
5411
5760
  }
5412
5761
  this.__layout.matrixChanged = false;
5413
5762
  }
5414
5763
  };
5415
5764
 
5765
+ const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2, hasParentAutoLayout } = LeafHelper;
5766
+ const { updateBounds: updateBounds$1 } = BranchHelper;
5416
5767
  const { toOuterOf, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
5417
5768
  const LeafBounds = {
5418
5769
  __updateWorldBounds() {
5419
- var _a;
5420
- if (this.__layout.boundsChanged) {
5421
- let resize;
5422
- const layout = this.__layout;
5423
- if (layout.boxChanged) {
5424
- this.__updatePath();
5425
- this.__updateRenderPath();
5426
- this.__updateBoxBounds();
5427
- layout.boxChanged = false;
5428
- resize = true;
5429
- }
5430
- if (layout.localBoxChanged) {
5770
+ toOuterOf(this.__layout.renderBounds, this.__world, this.__world);
5771
+ if (this.__layout.resized) {
5772
+ this.__onUpdateSize();
5773
+ this.__layout.resized = false;
5774
+ }
5775
+ },
5776
+ __updateLocalBounds() {
5777
+ const layout = this.__layout;
5778
+ if (layout.boxChanged) {
5779
+ this.__updatePath();
5780
+ this.__updateRenderPath();
5781
+ this.__updateBoxBounds();
5782
+ layout.boxChanged = false;
5783
+ layout.resized = true;
5784
+ }
5785
+ if (layout.localBoxChanged) {
5786
+ if (this.__local)
5431
5787
  this.__updateLocalBoxBounds();
5432
- layout.localBoxChanged = false;
5433
- if (layout.strokeSpread)
5434
- layout.strokeChanged = true;
5435
- if (layout.renderSpread)
5436
- layout.renderChanged = true;
5437
- (_a = this.parent) === null || _a === void 0 ? void 0 : _a.__layout.boxChange();
5438
- }
5439
- if (layout.strokeChanged) {
5440
- layout.strokeSpread = this.__updateStrokeSpread();
5441
- if (layout.strokeSpread) {
5442
- if (layout.strokeBounds === layout.boxBounds) {
5443
- layout.spreadStroke();
5444
- }
5445
- this.__updateStrokeBounds();
5446
- this.__updateLocalStrokeBounds();
5447
- }
5448
- else {
5449
- layout.spreadStrokeCancel();
5450
- }
5451
- layout.strokeChanged = false;
5452
- if (layout.renderSpread)
5453
- layout.renderChanged = true;
5454
- if (this.parent)
5455
- this.parent.__layout.strokeChange();
5456
- resize || (resize = true);
5457
- }
5458
- if (layout.renderChanged) {
5459
- layout.renderSpread = this.__updateRenderSpread();
5460
- if (layout.renderSpread) {
5461
- if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
5462
- layout.spreadRender();
5463
- }
5464
- this.__updateRenderBounds();
5465
- this.__updateLocalRenderBounds();
5788
+ layout.localBoxChanged = false;
5789
+ if (layout.strokeSpread)
5790
+ layout.strokeChanged = true;
5791
+ if (layout.renderSpread)
5792
+ layout.renderChanged = true;
5793
+ if (this.parent)
5794
+ this.parent.__layout.boxChange();
5795
+ }
5796
+ if (layout.strokeChanged) {
5797
+ layout.strokeSpread = this.__updateStrokeSpread();
5798
+ if (layout.strokeSpread) {
5799
+ if (layout.strokeBounds === layout.boxBounds) {
5800
+ layout.spreadStroke();
5466
5801
  }
5467
- else {
5468
- layout.spreadRenderCancel();
5802
+ this.__updateStrokeBounds();
5803
+ this.__updateLocalStrokeBounds();
5804
+ }
5805
+ else {
5806
+ layout.spreadStrokeCancel();
5807
+ }
5808
+ layout.strokeChanged = false;
5809
+ if (layout.renderSpread)
5810
+ layout.renderChanged = true;
5811
+ if (this.parent)
5812
+ this.parent.__layout.strokeChange();
5813
+ layout.resized = true;
5814
+ }
5815
+ if (layout.renderChanged) {
5816
+ layout.renderSpread = this.__updateRenderSpread();
5817
+ if (layout.renderSpread) {
5818
+ if (layout.renderBounds === layout.boxBounds || layout.renderBounds === layout.strokeBounds) {
5819
+ layout.spreadRender();
5469
5820
  }
5470
- layout.renderChanged = false;
5471
- if (this.parent)
5472
- this.parent.__layout.renderChange();
5821
+ this.__updateRenderBounds();
5822
+ this.__updateLocalRenderBounds();
5473
5823
  }
5474
- layout.boundsChanged = false;
5475
- toOuterOf(this.__layout.renderBounds, this.__world, this.__world);
5476
- if (resize)
5477
- this.__onUpdateSize();
5478
- }
5479
- else {
5480
- toOuterOf(this.__layout.renderBounds, this.__world, this.__world);
5824
+ else {
5825
+ layout.spreadRenderCancel();
5826
+ }
5827
+ layout.renderChanged = false;
5828
+ if (this.parent)
5829
+ this.parent.__layout.renderChange();
5481
5830
  }
5831
+ layout.boundsChanged = false;
5482
5832
  },
5483
5833
  __updateLocalBoxBounds() {
5834
+ if (this.__hasAutoLayout)
5835
+ this.__updateAutoLayout();
5484
5836
  toOuterOf(this.__layout.boxBounds, this.__local, this.__local);
5485
5837
  },
5486
5838
  __updateLocalStrokeBounds() {
5487
- toOuterOf(this.__layout.strokeBounds, this.__local, this.__layout.localStrokeBounds);
5839
+ toOuterOf(this.__layout.strokeBounds, this.__localMatrix, this.__layout.localStrokeBounds);
5488
5840
  },
5489
5841
  __updateLocalRenderBounds() {
5490
- toOuterOf(this.__layout.renderBounds, this.__local, this.__layout.localRenderBounds);
5842
+ toOuterOf(this.__layout.renderBounds, this.__localMatrix, this.__layout.localRenderBounds);
5491
5843
  },
5492
5844
  __updateBoxBounds() {
5493
5845
  const b = this.__layout.boxBounds;
@@ -5497,14 +5849,27 @@ const LeafBounds = {
5497
5849
  b.width = width;
5498
5850
  b.height = height;
5499
5851
  },
5852
+ __updateAutoLayout() {
5853
+ this.__layout.matrixChanged = true;
5854
+ if (this.isBranch) {
5855
+ if (this.leafer)
5856
+ this.leafer.layouter.addExtra(this);
5857
+ if (hasParentAutoLayout(this)) {
5858
+ updateMatrix$1(this);
5859
+ }
5860
+ else {
5861
+ updateAllMatrix$2(this);
5862
+ updateBounds$1(this, this);
5863
+ }
5864
+ }
5865
+ else {
5866
+ updateMatrix$1(this);
5867
+ }
5868
+ },
5500
5869
  __updateNaturalSize() {
5501
5870
  const { __: data, __layout: layout } = this;
5502
5871
  data.__naturalWidth = layout.boxBounds.width;
5503
5872
  data.__naturalHeight = layout.boxBounds.height;
5504
- if (this.around) {
5505
- layout.matrixChanged = true;
5506
- this.__updateWorldMatrix();
5507
- }
5508
5873
  },
5509
5874
  __updateStrokeBounds() {
5510
5875
  copyAndSpread$1(this.__layout.strokeBounds, this.__layout.boxBounds, this.__layout.strokeSpread);
@@ -5547,7 +5912,7 @@ const LeafRender = {
5547
5912
  const tempCanvas = canvas.getSameCanvas(true);
5548
5913
  this.__draw(tempCanvas, options);
5549
5914
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5550
- if (this.__hasMirror || options.matrix) {
5915
+ if (this.__worldFlipped || options.matrix) {
5551
5916
  canvas.copyWorldByReset(tempCanvas, null, null, blendMode);
5552
5917
  }
5553
5918
  else {
@@ -5625,7 +5990,7 @@ const BranchRender = {
5625
5990
  this.__renderBranch(tempCanvas, options);
5626
5991
  canvas.opacity = this.__worldOpacity;
5627
5992
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5628
- if (this.__hasMirror || options.matrix) {
5993
+ if (this.__worldFlipped || options.matrix) {
5629
5994
  canvas.copyWorld(tempCanvas, null, null, blendMode);
5630
5995
  }
5631
5996
  else {
@@ -5643,8 +6008,8 @@ const BranchRender = {
5643
6008
  const { children } = this;
5644
6009
  if (this.__hasMask && children.length > 1) {
5645
6010
  let mask;
5646
- const maskCanvas = canvas.getSameCanvas();
5647
- const contentCanvas = canvas.getSameCanvas();
6011
+ const maskCanvas = canvas.getSameCanvas(false, true);
6012
+ const contentCanvas = canvas.getSameCanvas(false, true);
5648
6013
  for (let i = 0, len = children.length; i < len; i++) {
5649
6014
  child = children[i];
5650
6015
  if (child.isMask) {
@@ -5678,7 +6043,7 @@ const BranchRender = {
5678
6043
  const { LEAF, create } = IncrementId;
5679
6044
  const { toInnerPoint, toOuterPoint } = MatrixHelper;
5680
6045
  const { tempToOuterOf, copy: copy$3 } = PointHelper;
5681
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal } = LeafHelper;
6046
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, transform, setTransform, drop } = LeafHelper;
5682
6047
  let Leaf = class Leaf {
5683
6048
  get tag() { return this.__tag; }
5684
6049
  set tag(_value) { }
@@ -5686,15 +6051,16 @@ let Leaf = class Leaf {
5686
6051
  get innerName() { return this.__.name || this.tag + this.innerId; }
5687
6052
  get __DataProcessor() { return LeafData; }
5688
6053
  get __LayoutProcessor() { return LeafLayout; }
6054
+ get __localMatrix() { return this.__local || this.__layout; }
6055
+ get __localBounds() { return this.__local || this.__; }
5689
6056
  get worldTransform() { return this.__layout.getTransform('world'); }
5690
6057
  get localTransform() { return this.__layout.getTransform('local'); }
5691
6058
  get boxBounds() { return this.getBounds('box', 'inner'); }
5692
6059
  get worldBoxBounds() { return this.getBounds('box'); }
5693
6060
  get worldStrokeBounds() { return this.getBounds('stroke'); }
5694
6061
  get worldRenderBounds() { return this.getBounds('render'); }
5695
- get worldOpacity() { this.__layout.checkUpdate(); return this.__worldOpacity; }
5696
- get resizeable() { return true; }
5697
- get __hasMirror() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
6062
+ get worldOpacity() { this.__layout.update(); return this.__worldOpacity; }
6063
+ get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
5698
6064
  get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
5699
6065
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5700
6066
  constructor(data) {
@@ -5703,20 +6069,15 @@ let Leaf = class Leaf {
5703
6069
  }
5704
6070
  reset(data) {
5705
6071
  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 };
5706
- this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
6072
+ if (data !== null)
6073
+ this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
5707
6074
  this.__worldOpacity = 1;
5708
6075
  this.__ = new this.__DataProcessor(this);
5709
6076
  this.__layout = new this.__LayoutProcessor(this);
5710
6077
  if (this.__level)
5711
6078
  this.resetCustom();
5712
- if (data) {
5713
- if (data.children) {
5714
- this.set(data);
5715
- }
5716
- else {
5717
- Object.assign(this, data);
5718
- }
5719
- }
6079
+ if (data)
6080
+ data.children ? this.set(data) : Object.assign(this, data);
5720
6081
  }
5721
6082
  resetCustom() {
5722
6083
  this.__hasMask = this.__hasEraser = null;
@@ -5753,7 +6114,7 @@ let Leaf = class Leaf {
5753
6114
  }
5754
6115
  }
5755
6116
  set(_data) { }
5756
- get(_options) { return undefined; }
6117
+ get() { return undefined; }
5757
6118
  toJSON() {
5758
6119
  return this.__.__getInputData();
5759
6120
  }
@@ -5764,8 +6125,8 @@ let Leaf = class Leaf {
5764
6125
  __getAttr(_attrName) { return undefined; }
5765
6126
  setProxyAttr(_attrName, _newValue) { }
5766
6127
  getProxyAttr(_attrName) { return undefined; }
5767
- find(_condition) { return undefined; }
5768
- findOne(_condition) { return undefined; }
6128
+ find(_condition, _options) { return undefined; }
6129
+ findOne(_condition, _options) { return undefined; }
5769
6130
  forceUpdate(attrName) {
5770
6131
  if (attrName === undefined)
5771
6132
  attrName = 'width';
@@ -5775,15 +6136,20 @@ let Leaf = class Leaf {
5775
6136
  this.__[attrName] = value === undefined ? null : undefined;
5776
6137
  this[attrName] = value;
5777
6138
  }
6139
+ updateLayout() {
6140
+ this.__layout.update();
6141
+ }
5778
6142
  __updateWorldMatrix() { }
5779
6143
  __updateLocalMatrix() { }
5780
6144
  __updateWorldBounds() { }
6145
+ __updateLocalBounds() { }
5781
6146
  __updateLocalBoxBounds() { }
5782
6147
  __updateLocalStrokeBounds() { }
5783
6148
  __updateLocalRenderBounds() { }
5784
6149
  __updateBoxBounds() { }
5785
6150
  __updateStrokeBounds() { }
5786
6151
  __updateRenderBounds() { }
6152
+ __updateAutoLayout() { }
5787
6153
  __updateNaturalSize() { }
5788
6154
  __updateStrokeSpread() { return 0; }
5789
6155
  __updateRenderSpread() { return 0; }
@@ -5793,15 +6159,21 @@ let Leaf = class Leaf {
5793
6159
  __renderMask(_canvas, _content, _mask, _recycle) { }
5794
6160
  __removeMask(_child) { }
5795
6161
  getWorld(attrName) {
5796
- this.__layout.checkUpdate();
6162
+ this.__layout.update();
5797
6163
  if (attrName === 'x')
5798
6164
  return this.__world.e;
5799
6165
  if (attrName === 'y')
5800
6166
  return this.__world.f;
5801
6167
  return this.__world[attrName];
5802
6168
  }
5803
- getBounds(type, locationType = 'world') {
5804
- return this.__layout.getBounds(type, locationType);
6169
+ getBounds(type, relative) {
6170
+ return this.__layout.getBounds(type, relative);
6171
+ }
6172
+ getLayoutBounds(type, relative, unscale) {
6173
+ return this.__layout.getLayoutBounds(type, relative, unscale);
6174
+ }
6175
+ getLayoutPoints(type, relative) {
6176
+ return this.__layout.getLayoutPoints(type, relative);
5805
6177
  }
5806
6178
  worldToLocal(world, to, distance, relative) {
5807
6179
  if (this.parent) {
@@ -5859,17 +6231,43 @@ let Leaf = class Leaf {
5859
6231
  this.localToWorld(local, point, distance, relative);
5860
6232
  return point;
5861
6233
  }
6234
+ setTransform(matrix, resize) {
6235
+ setTransform(this, matrix, resize);
6236
+ }
6237
+ transform(matrix, resize) {
6238
+ transform(this, matrix, resize);
6239
+ }
5862
6240
  move(x, y) {
5863
6241
  moveLocal(this, x, y);
5864
6242
  }
5865
- scaleOf(origin, x, y) {
5866
- zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), x, y);
6243
+ scaleOf(origin, scaleX, scaleY, resize) {
6244
+ zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize);
5867
6245
  }
5868
- rotateOf(origin, angle) {
5869
- rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), angle);
6246
+ rotateOf(origin, rotation) {
6247
+ rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation);
6248
+ }
6249
+ skewOf(origin, skewX, skewY, resize) {
6250
+ skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize);
6251
+ }
6252
+ scaleResize(scaleX, scaleY = scaleX, noResize) {
6253
+ const data = this;
6254
+ if (noResize) {
6255
+ data.scaleX *= scaleX;
6256
+ data.scaleY *= scaleY;
6257
+ }
6258
+ else {
6259
+ if (scaleX < 0)
6260
+ data.scaleX *= -1, scaleX = -scaleX;
6261
+ if (scaleY < 0)
6262
+ data.scaleY *= -1, scaleY = -scaleY;
6263
+ this.__scaleResize(scaleX, scaleY);
6264
+ }
5870
6265
  }
5871
- skewOf(origin, x, y) {
5872
- skewOfLocal(this, tempToOuterOf(origin, this.localTransform), x, y);
6266
+ __scaleResize(scaleX, scaleY) {
6267
+ if (scaleX !== 1)
6268
+ this.width *= scaleX;
6269
+ if (scaleY !== 1)
6270
+ this.height *= scaleY;
5873
6271
  }
5874
6272
  __hitWorld(_point) { return true; }
5875
6273
  __hit(_local) { return true; }
@@ -5891,6 +6289,9 @@ let Leaf = class Leaf {
5891
6289
  if (this.parent)
5892
6290
  this.parent.remove(this, destroy);
5893
6291
  }
6292
+ dropTo(parent, index, resize) {
6293
+ drop(this, parent, index, resize);
6294
+ }
5894
6295
  on(_type, _listener, _options) { }
5895
6296
  off(_type, _listener, _options) { }
5896
6297
  on_(_type, _listener, _bind, _options) { return undefined; }
@@ -5899,6 +6300,14 @@ let Leaf = class Leaf {
5899
6300
  emit(_type, _event, _capture) { }
5900
6301
  emitEvent(_event, _capture) { }
5901
6302
  hasEvent(_type, _capture) { return false; }
6303
+ static changeAttr(attrName, defaultValue) {
6304
+ defineDataProcessor(this.prototype, attrName, defaultValue);
6305
+ }
6306
+ static addAttr(attrName, defaultValue, fn) {
6307
+ if (!fn)
6308
+ fn = boundsType;
6309
+ fn(defaultValue)(this.prototype, attrName);
6310
+ }
5902
6311
  destroy() {
5903
6312
  if (!this.destroyed) {
5904
6313
  if (this.parent)
@@ -5921,9 +6330,9 @@ Leaf = __decorate([
5921
6330
  useModule(LeafRender)
5922
6331
  ], Leaf);
5923
6332
 
5924
- const { setByListWithHandle: setByListWithHandle$1 } = BoundsHelper;
6333
+ const { setListWithFn } = BoundsHelper;
5925
6334
  const { sort } = BranchHelper;
5926
- const { localBoxBounds, localEventBounds, localRenderBounds, maskLocalBoxBounds, maskLocalEventBounds, maskLocalRenderBounds } = LeafBoundsHelper;
6335
+ const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5927
6336
  let Branch = class Branch extends Leaf {
5928
6337
  constructor() {
5929
6338
  super();
@@ -5947,13 +6356,13 @@ let Branch = class Branch extends Leaf {
5947
6356
  return 0;
5948
6357
  }
5949
6358
  __updateBoxBounds() {
5950
- setByListWithHandle$1(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
6359
+ setListWithFn(this.__layout.boxBounds, this.children, this.__hasMask ? maskLocalBoxBounds : localBoxBounds);
5951
6360
  }
5952
6361
  __updateStrokeBounds() {
5953
- setByListWithHandle$1(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalEventBounds : localEventBounds);
6362
+ setListWithFn(this.__layout.strokeBounds, this.children, this.__hasMask ? maskLocalStrokeBounds : localStrokeBounds);
5954
6363
  }
5955
6364
  __updateRenderBounds() {
5956
- setByListWithHandle$1(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
6365
+ setListWithFn(this.__layout.renderBounds, this.children, this.__hasMask ? maskLocalRenderBounds : localRenderBounds);
5957
6366
  }
5958
6367
  __updateSortChildren() {
5959
6368
  let affectSort;
@@ -6099,7 +6508,7 @@ class Watcher {
6099
6508
  if (this.hasRemove) {
6100
6509
  const updatedList = new LeafList();
6101
6510
  this.__updatedList.list.forEach(item => { if (item.leafer)
6102
- updatedList.push(item); });
6511
+ updatedList.add(item); });
6103
6512
  return updatedList;
6104
6513
  }
6105
6514
  else {
@@ -6134,7 +6543,7 @@ class Watcher {
6134
6543
  this.target.emit(RenderEvent.REQUEST);
6135
6544
  }
6136
6545
  __onAttrChange(event) {
6137
- this.__updatedList.push(event.target);
6546
+ this.__updatedList.add(event.target);
6138
6547
  this.update();
6139
6548
  }
6140
6549
  __onChildEvent(event) {
@@ -6144,12 +6553,12 @@ class Watcher {
6144
6553
  }
6145
6554
  else {
6146
6555
  this.hasRemove = true;
6147
- this.__updatedList.push(event.parent);
6556
+ this.__updatedList.add(event.parent);
6148
6557
  }
6149
6558
  this.update();
6150
6559
  }
6151
6560
  __pushChild(child) {
6152
- this.__updatedList.push(child);
6561
+ this.__updatedList.add(child);
6153
6562
  if (child.isBranch)
6154
6563
  this.__loopChildren(child);
6155
6564
  }
@@ -6188,7 +6597,7 @@ class Watcher {
6188
6597
  }
6189
6598
  }
6190
6599
 
6191
- const { updateAllWorldMatrix: updateAllWorldMatrix$1, updateAllWorldOpacity } = LeafHelper;
6600
+ const { updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, updateAllWorldOpacity } = LeafHelper;
6192
6601
  const { pushAllChildBranch, pushAllParent } = BranchHelper;
6193
6602
  function updateMatrix(updateList, levelList) {
6194
6603
  let layout;
@@ -6196,14 +6605,14 @@ function updateMatrix(updateList, levelList) {
6196
6605
  layout = leaf.__layout;
6197
6606
  if (levelList.without(leaf) && !layout.proxyZoom) {
6198
6607
  if (layout.matrixChanged) {
6199
- updateAllWorldMatrix$1(leaf);
6200
- levelList.push(leaf);
6608
+ updateAllMatrix$1(leaf, true);
6609
+ levelList.add(leaf);
6201
6610
  if (leaf.isBranch)
6202
6611
  pushAllChildBranch(leaf, levelList);
6203
6612
  pushAllParent(leaf, levelList);
6204
6613
  }
6205
6614
  else if (layout.boundsChanged) {
6206
- levelList.push(leaf);
6615
+ levelList.add(leaf);
6207
6616
  if (leaf.isBranch)
6208
6617
  leaf.__tempNumber = 0;
6209
6618
  pushAllParent(leaf, levelList);
@@ -6212,20 +6621,21 @@ function updateMatrix(updateList, levelList) {
6212
6621
  });
6213
6622
  }
6214
6623
  function updateBounds(boundsList) {
6215
- let itemList, branch;
6624
+ let list, branch, children;
6216
6625
  boundsList.sort(true);
6217
6626
  boundsList.levels.forEach(level => {
6218
- itemList = boundsList.levelMap[level];
6219
- for (let i = 0, len = itemList.length; i < len; i++) {
6220
- branch = itemList[i];
6627
+ list = boundsList.levelMap[level];
6628
+ for (let i = 0, len = list.length; i < len; i++) {
6629
+ branch = list[i];
6221
6630
  if (branch.isBranch && branch.__tempNumber) {
6222
- for (let j = 0, jLen = branch.children.length; j < jLen; j++) {
6223
- if (!branch.children[j].isBranch) {
6224
- branch.children[j].__updateWorldBounds();
6631
+ children = branch.children;
6632
+ for (let j = 0, jLen = children.length; j < jLen; j++) {
6633
+ if (!children[j].isBranch) {
6634
+ updateOneBounds(children[j]);
6225
6635
  }
6226
6636
  }
6227
6637
  }
6228
- branch.__updateWorldBounds();
6638
+ updateOneBounds(branch);
6229
6639
  }
6230
6640
  });
6231
6641
  }
@@ -6238,7 +6648,7 @@ function updateChange(updateList) {
6238
6648
  }
6239
6649
 
6240
6650
  const { worldBounds } = LeafBoundsHelper;
6241
- const { setByListWithHandle } = BoundsHelper;
6651
+ const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
6242
6652
  class LayoutBlockData {
6243
6653
  constructor(list) {
6244
6654
  this.updatedBounds = new Bounds();
@@ -6249,14 +6659,20 @@ class LayoutBlockData {
6249
6659
  this.updatedList = list;
6250
6660
  }
6251
6661
  setBefore() {
6252
- setByListWithHandle(this.beforeBounds, this.updatedList.list, worldBounds);
6662
+ this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
6253
6663
  }
6254
6664
  setAfter() {
6255
- setByListWithHandle(this.afterBounds, this.updatedList.list, worldBounds);
6256
- this.updatedBounds.setByList([this.beforeBounds, this.afterBounds]);
6665
+ const { list } = this.updatedList;
6666
+ if (list.some(leaf => leaf.noBounds)) {
6667
+ this.afterBounds.set(bigBounds);
6668
+ }
6669
+ else {
6670
+ this.afterBounds.setListWithFn(list, worldBounds);
6671
+ }
6672
+ this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
6257
6673
  }
6258
6674
  merge(data) {
6259
- this.updatedList.pushList(data.updatedList.list);
6675
+ this.updatedList.addList(data.updatedList.list);
6260
6676
  this.beforeBounds.add(data.beforeBounds);
6261
6677
  this.afterBounds.add(data.afterBounds);
6262
6678
  this.updatedBounds.add(data.updatedBounds);
@@ -6266,8 +6682,7 @@ class LayoutBlockData {
6266
6682
  }
6267
6683
  }
6268
6684
 
6269
- const { updateAllWorldMatrix, updateAllChange } = LeafHelper;
6270
- const { pushAllBranchStack, updateWorldBoundsByBranchStack } = BranchHelper;
6685
+ const { updateAllMatrix, updateAllChange } = LeafHelper;
6271
6686
  const debug$4 = Debug.get('Layouter');
6272
6687
  class Layouter {
6273
6688
  constructor(target, userConfig) {
@@ -6344,12 +6759,15 @@ class Layouter {
6344
6759
  const { target, __updatedList: updateList } = this;
6345
6760
  const { BEFORE, LAYOUT, AFTER } = LayoutEvent;
6346
6761
  const blocks = this.getBlocks(updateList);
6347
- blocks.forEach(item => { item.setBefore(); });
6762
+ blocks.forEach(item => item.setBefore());
6348
6763
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
6764
+ this.extraBlock = null;
6349
6765
  updateList.sort();
6350
6766
  updateMatrix(updateList, this.__levelList);
6351
6767
  updateBounds(this.__levelList);
6352
6768
  updateChange(updateList);
6769
+ if (this.extraBlock)
6770
+ blocks.push(this.extraBlock);
6353
6771
  blocks.forEach(item => item.setAfter());
6354
6772
  target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
6355
6773
  target.emitEvent(new LayoutEvent(AFTER, blocks, this.times));
@@ -6372,17 +6790,20 @@ class Layouter {
6372
6790
  Run.end(t);
6373
6791
  }
6374
6792
  static fullLayout(target) {
6375
- updateAllWorldMatrix(target);
6793
+ updateAllMatrix(target, true);
6376
6794
  if (target.isBranch) {
6377
- const branchStack = [target];
6378
- pushAllBranchStack(target, branchStack);
6379
- updateWorldBoundsByBranchStack(branchStack);
6795
+ BranchHelper.updateBounds(target);
6380
6796
  }
6381
6797
  else {
6382
- target.__updateWorldBounds();
6798
+ LeafHelper.updateBounds(target);
6383
6799
  }
6384
6800
  updateAllChange(target);
6385
6801
  }
6802
+ addExtra(leaf) {
6803
+ const block = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
6804
+ block.updatedList.add(leaf);
6805
+ block.beforeBounds.add(leaf.__world);
6806
+ }
6386
6807
  createBlock(data) {
6387
6808
  return new LayoutBlockData(data);
6388
6809
  }
@@ -6410,8 +6831,7 @@ class Layouter {
6410
6831
  if (this.target) {
6411
6832
  this.stop();
6412
6833
  this.__removeListenEvents();
6413
- this.target = null;
6414
- this.config = null;
6834
+ this.target = this.config = null;
6415
6835
  }
6416
6836
  }
6417
6837
  }
@@ -6522,7 +6942,7 @@ class Renderer {
6522
6942
  const { canvas } = this;
6523
6943
  const bounds = block.getIntersect(canvas.bounds);
6524
6944
  const includes = block.includes(this.target.__world);
6525
- const realBounds = new Bounds().copy(bounds);
6945
+ const realBounds = new Bounds(bounds);
6526
6946
  canvas.save();
6527
6947
  if (includes && !Debug.showRepaint) {
6528
6948
  canvas.clear();
@@ -6572,7 +6992,7 @@ class Renderer {
6572
6992
  const { updateBlocks: list } = this;
6573
6993
  if (list) {
6574
6994
  const bounds = new Bounds();
6575
- bounds.setByList(list);
6995
+ bounds.setList(list);
6576
6996
  list.length = 0;
6577
6997
  list.push(bounds);
6578
6998
  }
@@ -6612,7 +7032,7 @@ class Renderer {
6612
7032
  empty = (!leaf.__world.width || !leaf.__world.height);
6613
7033
  if (empty) {
6614
7034
  if (!leaf.isLeafer)
6615
- debug$3.warn(leaf.innerName, ': empty');
7035
+ debug$3.tip(leaf.innerName, ': empty');
6616
7036
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6617
7037
  }
6618
7038
  return empty;
@@ -6646,6 +7066,14 @@ class Renderer {
6646
7066
  }
6647
7067
  }
6648
7068
 
7069
+ var AnswerType;
7070
+ (function (AnswerType) {
7071
+ AnswerType[AnswerType["No"] = 0] = "No";
7072
+ AnswerType[AnswerType["Yes"] = 1] = "Yes";
7073
+ AnswerType[AnswerType["NoAndSkip"] = 2] = "NoAndSkip";
7074
+ AnswerType[AnswerType["YesAndSkip"] = 3] = "YesAndSkip";
7075
+ })(AnswerType || (AnswerType = {}));
7076
+
6649
7077
  const { hitRadiusPoint } = BoundsHelper;
6650
7078
  class Pather {
6651
7079
  constructor(target, selector) {
@@ -6690,10 +7118,10 @@ class Pather {
6690
7118
  getPath(leaf) {
6691
7119
  const path = new LeafList();
6692
7120
  while (leaf) {
6693
- path.push(leaf);
7121
+ path.add(leaf);
6694
7122
  leaf = leaf.parent;
6695
7123
  }
6696
- path.push(this.target);
7124
+ path.add(this.target);
6697
7125
  return path;
6698
7126
  }
6699
7127
  getHitablePath(leaf) {
@@ -6703,7 +7131,7 @@ class Pather {
6703
7131
  item = path.list[i];
6704
7132
  if (!item.__.hittable)
6705
7133
  break;
6706
- hittablePath.unshift(item);
7134
+ hittablePath.addAt(item, 0);
6707
7135
  if (!item.__.hitChildren)
6708
7136
  break;
6709
7137
  }
@@ -6722,7 +7150,7 @@ class Pather {
6722
7150
  leaf = path.list[j];
6723
7151
  if (nextPath && nextPath.has(leaf))
6724
7152
  break;
6725
- throughPath.push(leaf);
7153
+ throughPath.add(leaf);
6726
7154
  }
6727
7155
  }
6728
7156
  return throughPath;
@@ -6764,14 +7192,15 @@ class Pather {
6764
7192
  }
6765
7193
  }
6766
7194
 
7195
+ const { Yes, NoAndSkip, YesAndSkip } = AnswerType;
6767
7196
  class Selector {
6768
7197
  constructor(target, userConfig) {
6769
7198
  this.config = {};
6770
7199
  this.innerIdMap = {};
6771
7200
  this.idMap = {};
6772
7201
  this.methods = {
6773
- id: (leaf, name) => leaf.id === name ? this.idMap[name] = leaf : 0,
6774
- innerId: (leaf, innerId) => leaf.innerId === innerId ? this.innerIdMap[innerId] = leaf : 0,
7202
+ id: (leaf, name) => leaf.id === name ? (this.idMap[name] = leaf, 1) : 0,
7203
+ innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.innerIdMap[innerId] = leaf, 1) : 0,
6775
7204
  className: (leaf, name) => leaf.className === name ? 1 : 0,
6776
7205
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0
6777
7206
  };
@@ -6781,11 +7210,6 @@ class Selector {
6781
7210
  this.pather = new Pather(target, this);
6782
7211
  this.__listenEvents();
6783
7212
  }
6784
- getByPoint(hitPoint, hitRadius, options) {
6785
- if (Platform.name === 'node')
6786
- this.target.emit(LayoutEvent.CHECK_UPDATE);
6787
- return this.pather.getByPoint(hitPoint, hitRadius, options);
6788
- }
6789
7213
  getBy(condition, branch, one, options) {
6790
7214
  switch (typeof condition) {
6791
7215
  case 'number':
@@ -6805,6 +7229,11 @@ class Selector {
6805
7229
  return this.getByMethod(condition, branch, one, options);
6806
7230
  }
6807
7231
  }
7232
+ getByPoint(hitPoint, hitRadius, options) {
7233
+ if (Platform.name === 'node')
7234
+ this.target.emit(LayoutEvent.CHECK_UPDATE);
7235
+ return this.pather.getByPoint(hitPoint, hitRadius, options);
7236
+ }
6808
7237
  getByInnerId(innerId, branch) {
6809
7238
  const cache = this.innerIdMap[innerId];
6810
7239
  if (cache)
@@ -6831,10 +7260,11 @@ class Selector {
6831
7260
  return list || this.findLeaf;
6832
7261
  }
6833
7262
  eachFind(children, method, list, options) {
6834
- let child;
7263
+ let child, result;
6835
7264
  for (let i = 0, len = children.length; i < len; i++) {
6836
7265
  child = children[i];
6837
- if (method(child, options)) {
7266
+ result = method(child, options);
7267
+ if (result === Yes || result === YesAndSkip) {
6838
7268
  if (list) {
6839
7269
  list.push(child);
6840
7270
  }
@@ -6843,7 +7273,7 @@ class Selector {
6843
7273
  return;
6844
7274
  }
6845
7275
  }
6846
- if (child.isBranch)
7276
+ if (child.isBranch && result < NoAndSkip)
6847
7277
  this.eachFind(child.children, method, list, options);
6848
7278
  }
6849
7279
  }
@@ -7208,7 +7638,6 @@ function useCanvas(_canvasType, app) {
7208
7638
  Platform.name = 'miniapp';
7209
7639
  Platform.requestRender = function (render) { Platform.canvas.view.requestAnimationFrame(render); };
7210
7640
  Platform.devicePixelRatio = wx.getSystemInfoSync().pixelRatio;
7211
- Platform.realtimeLayout = true;
7212
7641
 
7213
7642
  function draw(leafer) {
7214
7643
  const { config } = leafer;
@@ -7219,7 +7648,7 @@ function design(leafer) {
7219
7648
  if (leafer.isApp)
7220
7649
  return;
7221
7650
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => { LeafHelper.moveWorld(leafer.zoomLayer, e.moveX, e.moveY); }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
7222
- const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.config.zoom;
7651
+ const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.app.config.zoom;
7223
7652
  let { scale } = e;
7224
7653
  if (scale * Math.abs(scaleX) < min)
7225
7654
  scale = min / scaleX;
@@ -7266,6 +7695,9 @@ const Export$1 = {};
7266
7695
  const emptyPaint = {};
7267
7696
  const debug$1 = Debug.get('UIData');
7268
7697
  class UIData extends LeafData {
7698
+ get __autoWidth() { return !this._width; }
7699
+ get __autoHeight() { return !this._height; }
7700
+ get __autoBounds() { return !this._width && !this._height; }
7269
7701
  setVisible(value) {
7270
7702
  if (this.__leaf.leafer)
7271
7703
  this.__leaf.leafer.watcher.hasVisible = true;
@@ -7442,6 +7874,9 @@ class TextData extends UIData {
7442
7874
  class ImageData extends RectData {
7443
7875
  }
7444
7876
 
7877
+ class CanvasData extends RectData {
7878
+ }
7879
+
7445
7880
  function effectType(defaultValue) {
7446
7881
  return (target, key) => {
7447
7882
  defineLeafAttr(target, key, defaultValue, {
@@ -7652,6 +8087,7 @@ const RectRender = {
7652
8087
 
7653
8088
  var UI_1;
7654
8089
  let UI = UI_1 = class UI extends Leaf {
8090
+ get app() { return this.leafer && this.leafer.app; }
7655
8091
  set scale(value) {
7656
8092
  if (typeof value === 'number') {
7657
8093
  this.scaleX = this.scaleY = value;
@@ -7665,22 +8101,25 @@ let UI = UI_1 = class UI extends Leaf {
7665
8101
  const { scaleX, scaleY } = this;
7666
8102
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
7667
8103
  }
8104
+ constructor(data) {
8105
+ super(data);
8106
+ }
7668
8107
  reset(_data) { }
7669
8108
  set(data) {
7670
8109
  Object.assign(this, data);
7671
8110
  }
7672
- get(options) {
7673
- return this.__.__getInputData(options);
8111
+ get() {
8112
+ return this.__.__getInputData();
7674
8113
  }
7675
- getProxyData() { return undefined; }
7676
- find(condition) {
7677
- return this.leafer ? this.leafer.selector.getBy(condition, this) : [];
8114
+ createProxyData() { return undefined; }
8115
+ find(condition, options) {
8116
+ return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
7678
8117
  }
7679
- findOne(condition) {
7680
- return this.leafer ? this.leafer.selector.getBy(condition, this, true) : null;
8118
+ findOne(condition, options) {
8119
+ return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
7681
8120
  }
7682
8121
  getPath(curve) {
7683
- const path = this.__.path;
8122
+ const { path } = this.__;
7684
8123
  if (!path)
7685
8124
  return [];
7686
8125
  return curve ? PathConvert.toCanvasData(path, true) : path;
@@ -7712,6 +8151,15 @@ let UI = UI_1 = class UI extends Leaf {
7712
8151
  this.__drawPathByData(canvas, this.__.path);
7713
8152
  }
7714
8153
  __drawPathByData(_drawer, _data) { }
8154
+ __drawPathByBox(drawer) {
8155
+ const { x, y, width, height } = this.__layout.boxBounds;
8156
+ if (this.__.cornerRadius) {
8157
+ drawer.roundRect(x, y, width, height, this.__.cornerRadius);
8158
+ }
8159
+ else {
8160
+ drawer.rect(x, y, width, height);
8161
+ }
8162
+ }
7715
8163
  export(filename, options) {
7716
8164
  return Export$1.export(this, filename, options);
7717
8165
  }
@@ -7753,12 +8201,12 @@ __decorate([
7753
8201
  __decorate([
7754
8202
  eraserType(false)
7755
8203
  ], UI.prototype, "isEraser", void 0);
8204
+ __decorate([
8205
+ dataType(false)
8206
+ ], UI.prototype, "locked", void 0);
7756
8207
  __decorate([
7757
8208
  sortType(0)
7758
8209
  ], UI.prototype, "zIndex", void 0);
7759
- __decorate([
7760
- dataType()
7761
- ], UI.prototype, "locked", void 0);
7762
8210
  __decorate([
7763
8211
  positionType(0)
7764
8212
  ], UI.prototype, "x", void 0);
@@ -7787,11 +8235,17 @@ __decorate([
7787
8235
  rotationType(0)
7788
8236
  ], UI.prototype, "skewY", void 0);
7789
8237
  __decorate([
7790
- positionType()
8238
+ autoLayoutType()
7791
8239
  ], UI.prototype, "around", void 0);
7792
8240
  __decorate([
7793
8241
  dataType(false)
7794
8242
  ], UI.prototype, "draggable", void 0);
8243
+ __decorate([
8244
+ dataType(false)
8245
+ ], UI.prototype, "editable", void 0);
8246
+ __decorate([
8247
+ dataType('size')
8248
+ ], UI.prototype, "editSize", void 0);
7795
8249
  __decorate([
7796
8250
  hitType(true)
7797
8251
  ], UI.prototype, "hittable", void 0);
@@ -7844,7 +8298,7 @@ __decorate([
7844
8298
  strokeType(10)
7845
8299
  ], UI.prototype, "miterLimit", void 0);
7846
8300
  __decorate([
7847
- pathType()
8301
+ pathType(0)
7848
8302
  ], UI.prototype, "cornerRadius", void 0);
7849
8303
  __decorate([
7850
8304
  pathType()
@@ -7877,9 +8331,9 @@ UI = UI_1 = __decorate([
7877
8331
  rewriteAble()
7878
8332
  ], UI);
7879
8333
 
8334
+ const matrix = MatrixHelper.get();
7880
8335
  let Group = class Group extends UI {
7881
8336
  get __tag() { return 'Group'; }
7882
- get resizeable() { return false; }
7883
8337
  set mask(child) {
7884
8338
  if (this.__hasMask)
7885
8339
  this.__removeMask();
@@ -7927,6 +8381,14 @@ let Group = class Group extends UI {
7927
8381
  data.children = this.children.map(child => child.toJSON());
7928
8382
  return data;
7929
8383
  }
8384
+ __scaleResize(scaleX, scaleY) {
8385
+ const { children } = this;
8386
+ for (let i = 0; i < children.length; i++) {
8387
+ matrix.a = scaleX;
8388
+ matrix.d = scaleY;
8389
+ children[i].transform(matrix, true);
8390
+ }
8391
+ }
7930
8392
  addAt(child, index) {
7931
8393
  this.add(child, index);
7932
8394
  }
@@ -7954,21 +8416,17 @@ let Rect = class Rect extends UI {
7954
8416
  constructor(data) {
7955
8417
  super(data);
7956
8418
  }
7957
- __drawPathByData(drawer, _data) {
7958
- const { width, height, cornerRadius } = this.__;
7959
- if (cornerRadius) {
7960
- drawer.roundRect(0, 0, width, height, cornerRadius);
7961
- }
7962
- else {
7963
- drawer.rect(0, 0, width, height);
7964
- }
7965
- }
8419
+ __drawPathByData(_drawer, _data) { }
7966
8420
  };
7967
8421
  __decorate([
7968
8422
  dataProcessor(RectData)
7969
8423
  ], Rect.prototype, "__", void 0);
8424
+ __decorate([
8425
+ rewrite(UI.prototype.__drawPathByBox)
8426
+ ], Rect.prototype, "__drawPathByData", null);
7970
8427
  Rect = __decorate([
7971
8428
  useModule(RectRender),
8429
+ rewriteAble(),
7972
8430
  registerUI()
7973
8431
  ], Rect);
7974
8432
 
@@ -7978,12 +8436,20 @@ const bounds$1 = {};
7978
8436
  const { copy: copy$2, add } = BoundsHelper;
7979
8437
  let Box = class Box extends Group {
7980
8438
  get __tag() { return 'Box'; }
7981
- get resizeable() { return true; }
7982
8439
  constructor(data) {
7983
8440
  super(data);
7984
8441
  this.isBranchLeaf = true;
7985
8442
  this.__layout.renderChanged || this.__layout.renderChange();
7986
8443
  }
8444
+ __scaleResize(scaleX, scaleY) {
8445
+ if (this.__.__autoBounds && this.children.length) {
8446
+ super.__scaleResize(scaleX, scaleY);
8447
+ }
8448
+ else {
8449
+ this.width *= scaleX;
8450
+ this.height *= scaleY;
8451
+ }
8452
+ }
7987
8453
  __updateStrokeSpread() { return 0; }
7988
8454
  __updateRectRenderSpread() { return 0; }
7989
8455
  __updateRenderSpread() {
@@ -7993,7 +8459,15 @@ let Box = class Box extends Group {
7993
8459
  width = this.__.__drawAfterFill ? 0 : 1;
7994
8460
  return width;
7995
8461
  }
7996
- __updateBoxBounds() { }
8462
+ __updateRectBoxBounds() { }
8463
+ __updateBoxBounds() {
8464
+ if (this.__.__autoBounds && this.children.length) {
8465
+ super.__updateBoxBounds();
8466
+ }
8467
+ else {
8468
+ this.__updateRectBoxBounds();
8469
+ }
8470
+ }
7997
8471
  __updateStrokeBounds() { }
7998
8472
  __updateRenderBounds() {
7999
8473
  this.__updateRectRenderBounds();
@@ -8045,7 +8519,7 @@ __decorate([
8045
8519
  ], Box.prototype, "__updateRectRenderSpread", null);
8046
8520
  __decorate([
8047
8521
  rewrite(rect.__updateBoxBounds)
8048
- ], Box.prototype, "__updateBoxBounds", null);
8522
+ ], Box.prototype, "__updateRectBoxBounds", null);
8049
8523
  __decorate([
8050
8524
  rewrite(rect.__updateStrokeBounds)
8051
8525
  ], Box.prototype, "__updateStrokeBounds", null);
@@ -8073,6 +8547,7 @@ let Frame = class Frame extends Box {
8073
8547
  get __tag() { return 'Frame'; }
8074
8548
  constructor(data) {
8075
8549
  super(data);
8550
+ this.isFrame = true;
8076
8551
  if (!this.__.fill)
8077
8552
  this.__.fill = '#FFFFFF';
8078
8553
  }
@@ -8113,7 +8588,7 @@ let Ellipse = class Ellipse extends UI {
8113
8588
  ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
8114
8589
  }
8115
8590
  if (Platform.ellipseToCurve)
8116
- this.__.path = PathConvert.toCanvasData(path, true);
8591
+ this.__.path = this.getPath(true);
8117
8592
  }
8118
8593
  else {
8119
8594
  if (startAngle || endAngle) {
@@ -8143,47 +8618,118 @@ Ellipse = __decorate([
8143
8618
  registerUI()
8144
8619
  ], Ellipse);
8145
8620
 
8146
- const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
8147
- const { moveTo: moveTo$2, lineTo: lineTo$2, closePath: closePath$1, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8148
- const { toBounds: toBounds$2 } = PathBounds;
8149
- let Polygon = class Polygon extends UI {
8150
- get __tag() { return 'Polygon'; }
8151
- get resizeable() { return !this.points; }
8621
+ const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8622
+ const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
8623
+ const { toBounds: toBounds$1 } = PathBounds;
8624
+ let Line = class Line extends UI {
8625
+ get __tag() { return 'Line'; }
8626
+ get toPoint() {
8627
+ const { width, rotation } = this.__;
8628
+ const to = { x: 0, y: 0 };
8629
+ if (width)
8630
+ to.x = width;
8631
+ if (rotation)
8632
+ rotate$1(to, rotation);
8633
+ return to;
8634
+ }
8635
+ set toPoint(value) {
8636
+ this.width = getDistance$2(defaultPoint, value);
8637
+ this.rotation = getAngle$2(defaultPoint, value);
8638
+ if (this.height)
8639
+ this.height = 0;
8640
+ }
8152
8641
  constructor(data) {
8153
8642
  super(data);
8154
8643
  }
8155
8644
  __updatePath() {
8156
8645
  const path = this.__.path = [];
8157
8646
  if (this.__.points) {
8158
- drawPoints$1(path, this.__.points, false, true);
8647
+ drawPoints$1(path, this.__.points, false);
8159
8648
  }
8160
8649
  else {
8161
- const { width, height, sides } = this.__;
8162
- const rx = width / 2, ry = height / 2;
8163
- moveTo$2(path, rx, 0);
8164
- for (let i = 1; i < sides; i++) {
8165
- lineTo$2(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
8166
- }
8650
+ moveTo$2(path, 0, 0);
8651
+ lineTo$2(path, this.width, 0);
8167
8652
  }
8168
- closePath$1(path);
8169
8653
  }
8170
8654
  __updateRenderPath() {
8171
8655
  if (this.__.points && this.__.curve) {
8172
- drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, true);
8656
+ drawPoints$1(this.__.__pathForRender = [], this.__.points, this.__.curve, this.__tag !== 'Line');
8173
8657
  }
8174
8658
  else {
8175
8659
  super.__updateRenderPath();
8176
8660
  }
8177
8661
  }
8178
8662
  __updateBoxBounds() {
8179
- if (this.__.points) {
8180
- toBounds$2(this.__.__pathForRender, this.__layout.boxBounds);
8181
- this.__updateNaturalSize();
8663
+ if (this.points) {
8664
+ toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8182
8665
  }
8183
8666
  else {
8184
8667
  super.__updateBoxBounds();
8185
8668
  }
8186
8669
  }
8670
+ __scaleResize(scaleX, scaleY) {
8671
+ if (this.points) {
8672
+ PathScaler.scalePoints(this.__.points, scaleX, scaleY);
8673
+ this.points = this.__.points;
8674
+ }
8675
+ else {
8676
+ if (this.__tag === 'Line') {
8677
+ const point = this.toPoint;
8678
+ point.x *= scaleX;
8679
+ point.y *= scaleY;
8680
+ this.toPoint = point;
8681
+ }
8682
+ else {
8683
+ super.__scaleResize(scaleX, scaleY);
8684
+ }
8685
+ }
8686
+ }
8687
+ };
8688
+ __decorate([
8689
+ dataProcessor(LineData)
8690
+ ], Line.prototype, "__", void 0);
8691
+ __decorate([
8692
+ affectStrokeBoundsType('center')
8693
+ ], Line.prototype, "strokeAlign", void 0);
8694
+ __decorate([
8695
+ boundsType(0)
8696
+ ], Line.prototype, "height", void 0);
8697
+ __decorate([
8698
+ pathType()
8699
+ ], Line.prototype, "points", void 0);
8700
+ __decorate([
8701
+ pathType(0)
8702
+ ], Line.prototype, "curve", void 0);
8703
+ Line = __decorate([
8704
+ registerUI()
8705
+ ], Line);
8706
+
8707
+ const { sin: sin$1, cos: cos$1, PI: PI$1 } = Math;
8708
+ const { moveTo: moveTo$1, lineTo: lineTo$1, closePath: closePath$1, drawPoints } = PathCommandDataHelper;
8709
+ const line = Line.prototype;
8710
+ let Polygon = class Polygon extends UI {
8711
+ get __tag() { return 'Polygon'; }
8712
+ constructor(data) {
8713
+ super(data);
8714
+ }
8715
+ __updatePath() {
8716
+ const path = this.__.path = [];
8717
+ if (this.__.points) {
8718
+ drawPoints(path, this.__.points, false, true);
8719
+ }
8720
+ else {
8721
+ const { width, height, sides } = this.__;
8722
+ const rx = width / 2, ry = height / 2;
8723
+ moveTo$1(path, rx, 0);
8724
+ for (let i = 1; i < sides; i++) {
8725
+ lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
8726
+ }
8727
+ }
8728
+ closePath$1(path);
8729
+ }
8730
+ __updateRenderPath() { }
8731
+ __updateBoxBounds() { }
8732
+ __scaleResize(_scaleX, _scaleY) { }
8187
8733
  };
8188
8734
  __decorate([
8189
8735
  dataProcessor(PolygonData)
@@ -8197,12 +8743,22 @@ __decorate([
8197
8743
  __decorate([
8198
8744
  pathType(0)
8199
8745
  ], Polygon.prototype, "curve", void 0);
8746
+ __decorate([
8747
+ rewrite(line.__updateRenderPath)
8748
+ ], Polygon.prototype, "__updateRenderPath", null);
8749
+ __decorate([
8750
+ rewrite(line.__updateBoxBounds)
8751
+ ], Polygon.prototype, "__updateBoxBounds", null);
8752
+ __decorate([
8753
+ rewrite(line.__scaleResize)
8754
+ ], Polygon.prototype, "__scaleResize", null);
8200
8755
  Polygon = __decorate([
8756
+ rewriteAble(),
8201
8757
  registerUI()
8202
8758
  ], Polygon);
8203
8759
 
8204
8760
  const { sin, cos, PI } = Math;
8205
- const { moveTo: moveTo$1, lineTo: lineTo$1, closePath } = PathCommandDataHelper;
8761
+ const { moveTo, lineTo, closePath } = PathCommandDataHelper;
8206
8762
  let Star = class Star extends UI {
8207
8763
  get __tag() { return 'Star'; }
8208
8764
  constructor(data) {
@@ -8212,9 +8768,9 @@ let Star = class Star extends UI {
8212
8768
  const { width, height, corners, innerRadius } = this.__;
8213
8769
  const rx = width / 2, ry = height / 2;
8214
8770
  const path = this.__.path = [];
8215
- moveTo$1(path, rx, 0);
8771
+ moveTo(path, rx, 0);
8216
8772
  for (let i = 1; i < corners * 2; i++) {
8217
- 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));
8773
+ lineTo(path, rx + (i % 2 === 0 ? rx : rx * innerRadius) * sin((i * PI) / corners), ry - (i % 2 === 0 ? ry : ry * innerRadius) * cos((i * PI) / corners));
8218
8774
  }
8219
8775
  closePath(path);
8220
8776
  }
@@ -8232,77 +8788,6 @@ Star = __decorate([
8232
8788
  registerUI()
8233
8789
  ], Star);
8234
8790
 
8235
- const { moveTo, lineTo, drawPoints } = PathCommandDataHelper;
8236
- const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
8237
- const { toBounds: toBounds$1 } = PathBounds;
8238
- let Line = class Line extends UI {
8239
- get __tag() { return 'Line'; }
8240
- get resizeable() { return !this.points; }
8241
- get toPoint() {
8242
- const { width, rotation } = this.__;
8243
- const to = { x: 0, y: 0 };
8244
- if (width)
8245
- to.x = width;
8246
- if (rotation)
8247
- rotate$1(to, rotation);
8248
- return to;
8249
- }
8250
- set toPoint(value) {
8251
- this.width = getDistance$2(defaultPoint, value);
8252
- this.rotation = getAngle$2(defaultPoint, value);
8253
- if (this.height)
8254
- this.height = 0;
8255
- }
8256
- constructor(data) {
8257
- super(data);
8258
- }
8259
- __updatePath() {
8260
- const path = this.__.path = [];
8261
- if (this.__.points) {
8262
- drawPoints(path, this.__.points, false);
8263
- }
8264
- else {
8265
- moveTo(path, 0, 0);
8266
- lineTo(path, this.width, 0);
8267
- }
8268
- }
8269
- __updateRenderPath() {
8270
- if (this.__.points && this.__.curve) {
8271
- drawPoints(this.__.__pathForRender = [], this.__.points, this.__.curve, false);
8272
- }
8273
- else {
8274
- super.__updateRenderPath();
8275
- }
8276
- }
8277
- __updateBoxBounds() {
8278
- if (this.points) {
8279
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8280
- this.__updateNaturalSize();
8281
- }
8282
- else {
8283
- super.__updateBoxBounds();
8284
- }
8285
- }
8286
- };
8287
- __decorate([
8288
- dataProcessor(LineData)
8289
- ], Line.prototype, "__", void 0);
8290
- __decorate([
8291
- affectStrokeBoundsType('center')
8292
- ], Line.prototype, "strokeAlign", void 0);
8293
- __decorate([
8294
- boundsType(0)
8295
- ], Line.prototype, "height", void 0);
8296
- __decorate([
8297
- pathType()
8298
- ], Line.prototype, "points", void 0);
8299
- __decorate([
8300
- pathType(0)
8301
- ], Line.prototype, "curve", void 0);
8302
- Line = __decorate([
8303
- registerUI()
8304
- ], Line);
8305
-
8306
8791
  let Image = class Image extends Rect {
8307
8792
  get __tag() { return 'Image'; }
8308
8793
  get ready() { return this.image ? this.image.ready : false; }
@@ -8353,7 +8838,7 @@ let Canvas = class Canvas extends Rect {
8353
8838
  this.__.__drawAfterFill = true;
8354
8839
  }
8355
8840
  draw(ui, offset, scale, rotation) {
8356
- ui.__layout.checkUpdate();
8841
+ ui.__layout.update();
8357
8842
  const matrix = new Matrix(ui.__world);
8358
8843
  matrix.invert();
8359
8844
  const m = new Matrix();
@@ -8363,7 +8848,7 @@ let Canvas = class Canvas extends Rect {
8363
8848
  typeof scale === 'number' ? m.scale(scale) : m.scale(scale.x, scale.y);
8364
8849
  if (rotation)
8365
8850
  m.rotate(rotation);
8366
- matrix.preMultiply(m);
8851
+ matrix.multiplyParent(m);
8367
8852
  ui.__render(this.canvas, { matrix });
8368
8853
  this.paint();
8369
8854
  }
@@ -8423,11 +8908,11 @@ Canvas = __decorate([
8423
8908
  registerUI()
8424
8909
  ], Canvas);
8425
8910
 
8426
- const { copyAndSpread, includes, spread, setByList } = BoundsHelper;
8911
+ const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8427
8912
  let Text = class Text extends UI {
8428
8913
  get __tag() { return 'Text'; }
8429
8914
  get textDrawData() {
8430
- this.__layout.checkUpdate();
8915
+ this.__layout.update();
8431
8916
  return this.__.__textDrawData;
8432
8917
  }
8433
8918
  constructor(data) {
@@ -8458,33 +8943,45 @@ let Text = class Text extends UI {
8458
8943
  const data = this.__;
8459
8944
  const layout = this.__layout;
8460
8945
  const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow } = data;
8461
- const width = data.__getInput('width');
8462
- const height = data.__getInput('height');
8946
+ const autoWidth = data.__autoWidth;
8947
+ const autoHeight = data.__autoHeight;
8463
8948
  data.__lineHeight = UnitConvert.number(lineHeight, fontSize);
8464
8949
  data.__letterSpacing = UnitConvert.number(letterSpacing, fontSize);
8465
8950
  data.__baseLine = data.__lineHeight - (data.__lineHeight - fontSize * 0.7) / 2;
8466
8951
  data.__font = `${italic ? 'italic ' : ''}${textCase === 'small-caps' ? 'small-caps ' : ''}${fontWeight !== 'normal' ? fontWeight + ' ' : ''}${fontSize}px ${fontFamily}`;
8467
- data.__clipText = textOverflow !== 'show' && (width || height);
8952
+ data.__clipText = textOverflow !== 'show' && !data.__autoBounds;
8468
8953
  this.__updateTextDrawData();
8469
8954
  const { bounds } = data.__textDrawData;
8470
8955
  const b = layout.boxBounds;
8471
8956
  if (data.__lineHeight < fontSize)
8472
8957
  spread(bounds, fontSize / 2);
8473
- if (width && height) {
8474
- super.__updateBoxBounds();
8958
+ if (autoWidth || autoHeight) {
8959
+ b.x = autoWidth ? bounds.x : 0;
8960
+ b.y = autoHeight ? bounds.y : 0;
8961
+ b.width = autoWidth ? bounds.width : data.width;
8962
+ b.height = autoHeight ? bounds.height : data.height;
8963
+ const { padding } = data;
8964
+ if (padding) {
8965
+ const [top, right, bottom, left] = MathHelper.fourNumber(padding);
8966
+ if (autoWidth) {
8967
+ b.x -= left;
8968
+ b.width += (right + left);
8969
+ }
8970
+ if (autoHeight) {
8971
+ b.y -= top;
8972
+ b.height += (bottom + top);
8973
+ }
8974
+ }
8975
+ this.__updateNaturalSize();
8475
8976
  }
8476
8977
  else {
8477
- b.x = width ? 0 : bounds.x;
8478
- b.y = height ? 0 : bounds.y;
8479
- b.width = width ? width : bounds.width;
8480
- b.height = height ? height : bounds.height;
8481
- this.__updateNaturalSize();
8978
+ super.__updateBoxBounds();
8482
8979
  }
8483
8980
  const contentBounds = includes(b, bounds) ? b : bounds;
8484
8981
  if (contentBounds !== layout.contentBounds) {
8485
8982
  layout.contentBounds = contentBounds;
8486
8983
  layout.renderChanged = true;
8487
- setByList(data.__textBoxBounds = {}, [b, bounds]);
8984
+ setList(data.__textBoxBounds = {}, [b, bounds]);
8488
8985
  }
8489
8986
  else {
8490
8987
  data.__textBoxBounds = contentBounds;
@@ -8512,6 +9009,9 @@ __decorate([
8512
9009
  __decorate([
8513
9010
  boundsType(0)
8514
9011
  ], Text.prototype, "padding", void 0);
9012
+ __decorate([
9013
+ surfaceType('#000000')
9014
+ ], Text.prototype, "fill", void 0);
8515
9015
  __decorate([
8516
9016
  affectStrokeBoundsType('outside')
8517
9017
  ], Text.prototype, "strokeAlign", void 0);
@@ -8570,13 +9070,15 @@ Text = __decorate([
8570
9070
  const { toBounds } = PathBounds;
8571
9071
  let Path = class Path extends UI {
8572
9072
  get __tag() { return 'Path'; }
8573
- get resizeable() { return false; }
8574
9073
  constructor(data) {
8575
9074
  super(data);
8576
9075
  }
9076
+ __scaleResize(scaleX, scaleY) {
9077
+ PathScaler.scale(this.__.path, scaleX, scaleY);
9078
+ this.path = this.__.path;
9079
+ }
8577
9080
  __updateBoxBounds() {
8578
9081
  toBounds(this.__.path, this.__layout.boxBounds);
8579
- this.__updateNaturalSize();
8580
9082
  }
8581
9083
  };
8582
9084
  __decorate([
@@ -8645,6 +9147,7 @@ let Leafer = class Leafer extends Group {
8645
9147
  get __tag() { return 'Leafer'; }
8646
9148
  get isApp() { return false; }
8647
9149
  get app() { return this.parent || this; }
9150
+ get layoutLocked() { return !this.layouter.running; }
8648
9151
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
8649
9152
  constructor(userConfig, data) {
8650
9153
  super(data);
@@ -8737,13 +9240,18 @@ let Leafer = class Leafer extends Group {
8737
9240
  this.emitLeafer(LeaferEvent.STOP);
8738
9241
  }
8739
9242
  }
9243
+ unlockLayout() {
9244
+ this.layouter.start();
9245
+ this.updateLayout();
9246
+ }
9247
+ lockLayout() {
9248
+ this.updateLayout();
9249
+ this.layouter.stop();
9250
+ }
8740
9251
  resize(size) {
8741
9252
  const data = DataHelper.copyAttrs({}, size, canvasSizeAttrs);
8742
9253
  Object.keys(data).forEach(key => this[key] = data[key]);
8743
9254
  }
8744
- forceLayout() {
8745
- this.__layout.checkUpdate(true);
8746
- }
8747
9255
  forceFullRender() {
8748
9256
  this.renderer.addBlock(this.canvas.bounds);
8749
9257
  if (this.viewReady)
@@ -8889,7 +9397,7 @@ let Leafer = class Leafer extends Group {
8889
9397
  }
8890
9398
  }
8891
9399
  __checkUpdateLayout() {
8892
- this.__layout.checkUpdate();
9400
+ this.__layout.update();
8893
9401
  }
8894
9402
  emitLeafer(type) {
8895
9403
  this.emitEvent(new LeaferEvent(type, this));
@@ -8949,6 +9457,22 @@ Leafer = __decorate([
8949
9457
  let App = class App extends Leafer {
8950
9458
  get __tag() { return 'App'; }
8951
9459
  get isApp() { return true; }
9460
+ constructor(userConfig, data) {
9461
+ super(userConfig, data);
9462
+ if (userConfig) {
9463
+ const { ground, tree, sky, editor } = userConfig;
9464
+ if (ground)
9465
+ this.ground = this.addLeafer(ground);
9466
+ if (tree || editor)
9467
+ this.tree = this.addLeafer(tree);
9468
+ if (sky || editor)
9469
+ this.sky = this.addLeafer(sky || { type: 'draw', usePartRender: false });
9470
+ if (editor) {
9471
+ this.editor = Creator.editor(editor);
9472
+ this.sky.add(this.editor);
9473
+ }
9474
+ }
9475
+ }
8952
9476
  __setApp() {
8953
9477
  const { canvas } = this;
8954
9478
  const { realCanvas, view } = this.config;
@@ -8965,12 +9489,20 @@ let App = class App extends Leafer {
8965
9489
  }
8966
9490
  start() {
8967
9491
  super.start();
8968
- this.children.forEach(leafer => { leafer.start(); });
9492
+ this.children.forEach(leafer => leafer.start());
8969
9493
  }
8970
9494
  stop() {
8971
- this.children.forEach(leafer => { leafer.stop(); });
9495
+ this.children.forEach(leafer => leafer.stop());
8972
9496
  super.stop();
8973
9497
  }
9498
+ unlockLayout() {
9499
+ super.unlockLayout();
9500
+ this.children.forEach(leafer => leafer.unlockLayout());
9501
+ }
9502
+ lockLayout() {
9503
+ super.lockLayout();
9504
+ this.children.forEach(leafer => leafer.lockLayout());
9505
+ }
8974
9506
  addLeafer(merge) {
8975
9507
  const leafer = new Leafer(merge);
8976
9508
  this.add(leafer);
@@ -8989,7 +9521,7 @@ let App = class App extends Leafer {
8989
9521
  }
8990
9522
  __onPropertyChange() {
8991
9523
  if (Debug.showHitView)
8992
- this.children.forEach(leafer => { leafer.forceUpdate('surface'); });
9524
+ this.children.forEach(leafer => leafer.forceUpdate('surface'));
8993
9525
  }
8994
9526
  __onCreated() {
8995
9527
  this.created = this.children.every(child => child.created);
@@ -9011,14 +9543,14 @@ let App = class App extends Leafer {
9011
9543
  this.renderer.update();
9012
9544
  }
9013
9545
  __render(canvas, _options) {
9014
- this.children.forEach(leafer => { canvas.copyWorld(leafer.canvas); });
9546
+ this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
9015
9547
  }
9016
9548
  __onResize(event) {
9017
- this.children.forEach(leafer => { leafer.resize(event); });
9549
+ this.children.forEach(leafer => leafer.resize(event));
9018
9550
  super.__onResize(event);
9019
9551
  }
9020
9552
  __checkUpdateLayout() {
9021
- this.children.forEach(leafer => { leafer.__layout.checkUpdate(); });
9553
+ this.children.forEach(leafer => leafer.__layout.update());
9022
9554
  }
9023
9555
  __getChildConfig(userConfig) {
9024
9556
  let config = Object.assign({}, this.config);
@@ -9043,7 +9575,7 @@ App = __decorate([
9043
9575
  registerUI()
9044
9576
  ], App);
9045
9577
 
9046
- const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper$1, rotate } = MatrixHelper;
9578
+ const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
9047
9579
  function fillOrFitMode(data, mode, box, width, height, rotation) {
9048
9580
  const transform = get$4();
9049
9581
  const swap = rotation && rotation !== 180;
@@ -9053,7 +9585,7 @@ function fillOrFitMode(data, mode, box, width, height, rotation) {
9053
9585
  const x = box.x + (box.width - width * scale) / 2;
9054
9586
  const y = box.y + (box.height - height * scale) / 2;
9055
9587
  translate$1(transform, x, y);
9056
- scaleHelper$1(transform, scale);
9588
+ scaleHelper(transform, scale);
9057
9589
  if (rotation)
9058
9590
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
9059
9591
  data.scaleX = data.scaleY = scale;
@@ -9065,7 +9597,7 @@ function clipMode(data, box, offset, scale, rotation) {
9065
9597
  if (offset)
9066
9598
  translate$1(transform, offset.x, offset.y);
9067
9599
  if (scale) {
9068
- typeof scale === 'number' ? scaleHelper$1(transform, scale) : scaleHelper$1(transform, scale.x, scale.y);
9600
+ typeof scale === 'number' ? scaleHelper(transform, scale) : scaleHelper(transform, scale.x, scale.y);
9069
9601
  data.scaleX = transform.a;
9070
9602
  data.scaleY = transform.d;
9071
9603
  }
@@ -9178,6 +9710,10 @@ function hasNaturalSize(ui, attrName, image) {
9178
9710
  d.__naturalWidth = image.width;
9179
9711
  d.__naturalHeight = image.height;
9180
9712
  if (!d.__getInput('width') || !d.__getInput('height')) {
9713
+ if (ui.__proxyData) {
9714
+ ui.setProxyAttr('width', ui.__.width);
9715
+ ui.setProxyAttr('height', ui.__.height);
9716
+ }
9181
9717
  ui.forceUpdate('width');
9182
9718
  return false;
9183
9719
  }
@@ -9189,22 +9725,19 @@ function emit(type, data) {
9189
9725
  data.target.emitEvent(new ImageEvent(type, data));
9190
9726
  }
9191
9727
 
9192
- const { get: get$2, scale: scaleHelper, copy: copy$1 } = MatrixHelper;
9728
+ const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
9193
9729
  function createPattern(ui, paint, pixelRatio) {
9194
9730
  let { scaleX, scaleY } = ui.__world;
9195
9731
  const id = scaleX + '-' + scaleY;
9196
9732
  if (paint.patternId !== id && !ui.destroyed) {
9197
- paint.patternId = id;
9198
9733
  scaleX = Math.abs(scaleX);
9199
9734
  scaleY = Math.abs(scaleY);
9200
9735
  const { image, data } = paint;
9201
- const maxWidth = image.isSVG ? 4096 : Math.min(image.width, 4096);
9202
- const maxHeight = image.isSVG ? 4096 : Math.min(image.height, 4096);
9203
- let scale, matrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
9736
+ let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, mode } = data;
9204
9737
  if (sx) {
9205
- matrix = get$2();
9206
- copy$1(matrix, transform);
9207
- scaleHelper(matrix, 1 / sx, 1 / sy);
9738
+ imageMatrix = get$2();
9739
+ copy$1(imageMatrix, transform);
9740
+ scale(imageMatrix, 1 / sx, 1 / sy);
9208
9741
  scaleX *= sx;
9209
9742
  scaleY *= sy;
9210
9743
  }
@@ -9212,38 +9745,49 @@ function createPattern(ui, paint, pixelRatio) {
9212
9745
  scaleY *= pixelRatio;
9213
9746
  width *= scaleX;
9214
9747
  height *= scaleY;
9215
- if (width > maxWidth || height > maxHeight) {
9216
- scale = Math.max(width / maxWidth, height / maxHeight);
9748
+ const size = width * height;
9749
+ if (paint.data.mode !== 'repeat') {
9750
+ if (size > Platform.image.maxCacheSize)
9751
+ return false;
9752
+ }
9753
+ let maxSize = Platform.image.maxPatternSize;
9754
+ if (!image.isSVG) {
9755
+ const imageSize = image.width * image.height;
9756
+ if (maxSize > imageSize)
9757
+ maxSize = imageSize;
9217
9758
  }
9218
- if (scale) {
9219
- scaleX /= scale;
9220
- scaleY /= scale;
9221
- width /= scale;
9222
- height /= scale;
9759
+ if (size > maxSize)
9760
+ imageScale = Math.sqrt(size / maxSize);
9761
+ if (imageScale) {
9762
+ scaleX /= imageScale;
9763
+ scaleY /= imageScale;
9764
+ width /= imageScale;
9765
+ height /= imageScale;
9223
9766
  }
9224
9767
  if (sx) {
9225
9768
  scaleX /= sx;
9226
9769
  scaleY /= sy;
9227
9770
  }
9228
9771
  if (transform || scaleX !== 1 || scaleY !== 1) {
9229
- if (!matrix) {
9230
- matrix = get$2();
9772
+ if (!imageMatrix) {
9773
+ imageMatrix = get$2();
9231
9774
  if (transform)
9232
- copy$1(matrix, transform);
9775
+ copy$1(imageMatrix, transform);
9233
9776
  }
9234
- scaleHelper(matrix, 1 / scaleX, 1 / scaleY);
9777
+ scale(imageMatrix, 1 / scaleX, 1 / scaleY);
9235
9778
  }
9236
- const style = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), mode === 'repeat' ? 'repeat' : (Platform.origin.noRepeat || 'no-repeat'));
9779
+ const pattern = Platform.canvas.createPattern(image.getCanvas(width < 1 ? 1 : width, height < 1 ? 1 : height, opacity), mode === 'repeat' ? 'repeat' : (Platform.origin.noRepeat || 'no-repeat'));
9237
9780
  try {
9238
9781
  if (paint.transform)
9239
9782
  paint.transform = null;
9240
- if (matrix)
9241
- style.setTransform ? style.setTransform(matrix) : paint.transform = matrix;
9783
+ if (imageMatrix)
9784
+ pattern.setTransform ? pattern.setTransform(imageMatrix) : paint.transform = imageMatrix;
9242
9785
  }
9243
9786
  catch (_a) {
9244
- paint.transform = matrix;
9787
+ paint.transform = imageMatrix;
9245
9788
  }
9246
- paint.style = style;
9789
+ paint.style = pattern;
9790
+ paint.patternId = id;
9247
9791
  return true;
9248
9792
  }
9249
9793
  else {
@@ -9251,18 +9795,24 @@ function createPattern(ui, paint, pixelRatio) {
9251
9795
  }
9252
9796
  }
9253
9797
 
9798
+ const { abs } = Math;
9254
9799
  function checkImage(ui, canvas, paint, allowPaint) {
9255
9800
  const { scaleX, scaleY } = ui.__world;
9256
9801
  if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
9257
9802
  return false;
9258
9803
  }
9259
9804
  else {
9805
+ const { data } = paint;
9260
9806
  if (allowPaint) {
9261
- if (paint.image.isSVG && paint.data.mode !== 'repeat') {
9262
- let { width, height } = paint.data;
9263
- width *= scaleX * canvas.pixelRatio;
9264
- height *= scaleY * canvas.pixelRatio;
9265
- allowPaint = width > 4096 || height > 4096;
9807
+ if (data.mode !== 'repeat') {
9808
+ let { width, height } = data;
9809
+ width *= abs(scaleX) * canvas.pixelRatio;
9810
+ height *= abs(scaleY) * canvas.pixelRatio;
9811
+ if (data.scaleX) {
9812
+ width *= data.scaleX;
9813
+ height *= data.scaleY;
9814
+ }
9815
+ allowPaint = width * height > Platform.image.maxCacheSize;
9266
9816
  }
9267
9817
  else {
9268
9818
  allowPaint = false;
@@ -9271,7 +9821,6 @@ function checkImage(ui, canvas, paint, allowPaint) {
9271
9821
  if (allowPaint) {
9272
9822
  canvas.save();
9273
9823
  canvas.clip();
9274
- const { data } = paint;
9275
9824
  if (paint.blendMode)
9276
9825
  canvas.blendMode = paint.blendMode;
9277
9826
  if (data.opacity)
@@ -9283,7 +9832,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
9283
9832
  return true;
9284
9833
  }
9285
9834
  else {
9286
- if (!paint.style) {
9835
+ if (!paint.style || Export$1.running) {
9287
9836
  createPattern(ui, paint, canvas.pixelRatio);
9288
9837
  }
9289
9838
  else {
@@ -9302,7 +9851,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
9302
9851
  }
9303
9852
 
9304
9853
  function recycleImage(attrName, data) {
9305
- const paints = (attrName === 'fill' ? data._fill : data._stroke);
9854
+ const paints = data['_' + attrName];
9306
9855
  if (paints instanceof Array) {
9307
9856
  let image, recycleMap, input, url;
9308
9857
  for (let i = 0, len = paints.length; i < len; i++) {
@@ -9406,7 +9955,7 @@ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
9406
9955
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
9407
9956
  fillText(ui, out);
9408
9957
  out.blendMode = 'normal';
9409
- if (ui.__hasMirror || renderOptions.matrix) {
9958
+ if (ui.__worldFlipped || renderOptions.matrix) {
9410
9959
  canvas.copyWorldByReset(out);
9411
9960
  }
9412
9961
  else {
@@ -9479,7 +10028,7 @@ function stroke(stroke, ui, canvas, renderOptions) {
9479
10028
  out.stroke();
9480
10029
  options.windingRule ? out.clip(options.windingRule) : out.clip();
9481
10030
  out.clearWorld(ui.__layout.renderBounds);
9482
- if (ui.__hasMirror || renderOptions.matrix) {
10031
+ if (ui.__worldFlipped || renderOptions.matrix) {
9483
10032
  canvas.copyWorldByReset(out);
9484
10033
  }
9485
10034
  else {
@@ -9519,7 +10068,7 @@ function strokes(strokes, ui, canvas, renderOptions) {
9519
10068
  drawStrokesStyle(strokes, false, ui, out);
9520
10069
  options.windingRule ? out.clip(options.windingRule) : out.clip();
9521
10070
  out.clearWorld(renderBounds);
9522
- if (ui.__hasMirror || renderOptions.matrix) {
10071
+ if (ui.__worldFlipped || renderOptions.matrix) {
9523
10072
  canvas.copyWorldByReset(out);
9524
10073
  }
9525
10074
  else {
@@ -9743,7 +10292,7 @@ function shadow(ui, current, shape, renderOptions) {
9743
10292
  }
9744
10293
  worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
9745
10294
  }
9746
- if (ui.__hasMirror || renderOptions.matrix) {
10295
+ if (ui.__worldFlipped || renderOptions.matrix) {
9747
10296
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
9748
10297
  }
9749
10298
  else {
@@ -9807,7 +10356,7 @@ function innerShadow(ui, current, shape, renderOptions) {
9807
10356
  copyBounds = bounds;
9808
10357
  }
9809
10358
  other.fillWorld(copyBounds, item.color, 'source-in');
9810
- if (ui.__hasMirror || renderOptions.matrix) {
10359
+ if (ui.__worldFlipped || renderOptions.matrix) {
9811
10360
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
9812
10361
  }
9813
10362
  else {
@@ -10305,6 +10854,7 @@ const ColorConvert = {
10305
10854
 
10306
10855
  const Export = {
10307
10856
  export(leaf, filename, options) {
10857
+ Export.running = true;
10308
10858
  return addTask((success) => new Promise((resolve) => {
10309
10859
  const { leafer } = leaf;
10310
10860
  if (leafer) {
@@ -10342,6 +10892,7 @@ const Export = {
10342
10892
  }
10343
10893
  success({ data });
10344
10894
  resolve();
10895
+ Export.running = false;
10345
10896
  if (unreal)
10346
10897
  canvas.recycle();
10347
10898
  }));
@@ -10349,6 +10900,7 @@ const Export = {
10349
10900
  else {
10350
10901
  success({ data: false });
10351
10902
  resolve();
10903
+ Export.running = false;
10352
10904
  }
10353
10905
  }));
10354
10906
  }
@@ -10403,4 +10955,4 @@ LeaferCanvas.prototype.updateViewSize = function () {
10403
10955
  }
10404
10956
  };
10405
10957
 
10406
- export { Animate, AnimateEvent, App, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, Branch, BranchHelper, BranchRender, Canvas, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, DragEvent, DropEvent, Effect, Ellipse, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, Group, HitCanvasManager, Image, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PropertyEvent, Rect, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TwoPointBounds, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIEvent, UIHit, UIRender, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, aliasType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, setDefaultValue, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };
10958
+ export { Animate, AnimateEvent, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIHit, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };