@leafer/miniapp 1.7.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -436,7 +436,7 @@ const MatrixHelper = {
436
436
  const M$a = MatrixHelper;
437
437
 
438
438
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
439
- const { sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5 } = Math;
439
+ const { sin: sin$5, cos: cos$5, abs: abs$6, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5 } = Math;
440
440
  const PointHelper = {
441
441
  defaultPoint: getPointData(),
442
442
  tempPoint: {},
@@ -531,8 +531,8 @@ const PointHelper = {
531
531
  return getDistanceFrom(t.x, t.y, point.x, point.y);
532
532
  },
533
533
  getDistanceFrom(x1, y1, x2, y2) {
534
- const x = abs$7(x2 - x1);
535
- const y = abs$7(y2 - y1);
534
+ const x = abs$6(x2 - x1);
535
+ const y = abs$6(y2 - y1);
536
536
  return sqrt$4(x * x + y * y);
537
537
  },
538
538
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
@@ -763,7 +763,7 @@ class Matrix {
763
763
  MatrixHelper.reset(this);
764
764
  }
765
765
  }
766
- const tempMatrix = new Matrix();
766
+ const tempMatrix$1 = new Matrix();
767
767
 
768
768
  const TwoPointBoundsHelper = {
769
769
  tempPointBounds: {},
@@ -860,6 +860,12 @@ const AroundHelper = {
860
860
  }
861
861
  if (!onlyBoxSize)
862
862
  to.x += box.x, to.y += box.y;
863
+ },
864
+ getPoint(around, box, to) {
865
+ if (!to)
866
+ to = {};
867
+ AroundHelper.toPoint(around, box, to, true);
868
+ return to;
863
869
  }
864
870
  };
865
871
  function get$4(around) {
@@ -1788,10 +1794,13 @@ function contextAttr(realName) {
1788
1794
  return (target, key) => {
1789
1795
  if (!realName)
1790
1796
  realName = key;
1791
- Object.defineProperty(target, key, {
1797
+ const property = {
1792
1798
  get() { return this.context[realName]; },
1793
1799
  set(value) { this.context[realName] = value; }
1794
- });
1800
+ };
1801
+ if (key === 'strokeCap')
1802
+ property.set = function (value) { this.context[realName] = value === 'none' ? 'butt' : value; };
1803
+ Object.defineProperty(target, key, property);
1795
1804
  };
1796
1805
  }
1797
1806
  const contextMethodNameList = [];
@@ -2067,15 +2076,15 @@ __decorate([
2067
2076
  contextMethod()
2068
2077
  ], Canvas$1.prototype, "strokeText", null);
2069
2078
 
2070
- const { copy: copy$c, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$4 } = Math;
2079
+ const { copy: copy$c, multiplyParent: multiplyParent$4 } = MatrixHelper, { round: round$4 } = Math;
2071
2080
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
2072
2081
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
2073
2082
  class LeaferCanvasBase extends Canvas$1 {
2074
2083
  get width() { return this.size.width; }
2075
2084
  get height() { return this.size.height; }
2076
2085
  get pixelRatio() { return this.size.pixelRatio; }
2077
- get pixelWidth() { return this.width * this.pixelRatio; }
2078
- get pixelHeight() { return this.height * this.pixelRatio; }
2086
+ get pixelWidth() { return this.width * this.pixelRatio || 0; }
2087
+ get pixelHeight() { return this.height * this.pixelRatio || 0; }
2079
2088
  get pixelSnap() { return this.config.pixelSnap; }
2080
2089
  set pixelSnap(value) { this.config.pixelSnap = value; }
2081
2090
  get allowBackgroundColor() { return this.view && this.parentView; }
@@ -2140,7 +2149,7 @@ class LeaferCanvasBase extends Canvas$1 {
2140
2149
  setWorld(matrix, parentMatrix) {
2141
2150
  const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
2142
2151
  if (parentMatrix)
2143
- multiplyParent$3(matrix, parentMatrix, w);
2152
+ multiplyParent$4(matrix, parentMatrix, w);
2144
2153
  w.a = matrix.a * pixelRatio;
2145
2154
  w.b = matrix.b * pixelRatio;
2146
2155
  w.c = matrix.c * pixelRatio;
@@ -2162,20 +2171,33 @@ class LeaferCanvasBase extends Canvas$1 {
2162
2171
  if (w)
2163
2172
  this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
2164
2173
  }
2165
- setStroke(color, strokeWidth, options) {
2174
+ setStroke(color, strokeWidth, options, childOptions) {
2166
2175
  if (strokeWidth)
2167
2176
  this.strokeWidth = strokeWidth;
2168
2177
  if (color)
2169
2178
  this.strokeStyle = color;
2170
2179
  if (options)
2171
- this.setStrokeOptions(options);
2172
- }
2173
- setStrokeOptions(options) {
2174
- this.strokeCap = options.strokeCap === 'none' ? 'butt' : options.strokeCap;
2175
- this.strokeJoin = options.strokeJoin;
2176
- this.dashPattern = options.dashPattern;
2177
- this.dashOffset = options.dashOffset;
2178
- this.miterLimit = options.miterLimit;
2180
+ this.setStrokeOptions(options, childOptions);
2181
+ }
2182
+ setStrokeOptions(options, childOptions) {
2183
+ let { strokeCap, strokeJoin, dashPattern, dashOffset, miterLimit } = options;
2184
+ if (childOptions) {
2185
+ if (childOptions.strokeCap)
2186
+ strokeCap = childOptions.strokeCap;
2187
+ if (childOptions.strokeJoin)
2188
+ strokeJoin = childOptions.strokeJoin;
2189
+ if (childOptions.dashPattern !== undefined)
2190
+ dashPattern = childOptions.dashPattern;
2191
+ if (childOptions.dashOffset !== undefined)
2192
+ dashOffset = childOptions.dashOffset;
2193
+ if (childOptions.miterLimit)
2194
+ miterLimit = childOptions.miterLimit;
2195
+ }
2196
+ this.strokeCap = strokeCap;
2197
+ this.strokeJoin = strokeJoin;
2198
+ this.dashPattern = dashPattern;
2199
+ this.dashOffset = dashOffset;
2200
+ this.miterLimit = miterLimit;
2179
2201
  }
2180
2202
  saveBlendMode(blendMode) {
2181
2203
  this.savedBlendMode = this.blendMode;
@@ -2409,7 +2431,7 @@ const RectHelper = {
2409
2431
  }
2410
2432
  };
2411
2433
 
2412
- const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$2, abs: abs$6, PI: PI$3, sqrt: sqrt$3, pow: pow$1 } = Math;
2434
+ const { sin: sin$4, cos: cos$4, atan2: atan2$1, ceil: ceil$2, abs: abs$5, PI: PI$3, sqrt: sqrt$3, pow: pow$1 } = Math;
2413
2435
  const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2414
2436
  const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
2415
2437
  const { M: M$9, L: L$a, C: C$8, Q: Q$7, Z: Z$8 } = PathCommandMap;
@@ -2484,7 +2506,7 @@ const BezierHelper = {
2484
2506
  let totalRadian = endRadian - startRadian;
2485
2507
  if (totalRadian < 0)
2486
2508
  totalRadian += PI2;
2487
- if (totalRadian === PI$3 || (abs$6(BAx + BAy) < 1.e-12) || (abs$6(CBx + CBy) < 1.e-12)) {
2509
+ if (totalRadian === PI$3 || (abs$5(BAx + BAy) < 1.e-12) || (abs$5(CBx + CBy) < 1.e-12)) {
2488
2510
  if (data)
2489
2511
  data.push(L$a, x1, y1);
2490
2512
  if (setPointBounds) {
@@ -2526,7 +2548,7 @@ const BezierHelper = {
2526
2548
  totalRadian -= PI2;
2527
2549
  if (anticlockwise)
2528
2550
  totalRadian -= PI2;
2529
- const parts = ceil$2(abs$6(totalRadian / PI_2));
2551
+ const parts = ceil$2(abs$5(totalRadian / PI_2));
2530
2552
  const partRadian = totalRadian / parts;
2531
2553
  const partRadian4Sin = sin$4(partRadian / 4);
2532
2554
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
@@ -2971,7 +2993,7 @@ const { current, pushData, copyData } = PathConvert;
2971
2993
 
2972
2994
  const { M: M$7, L: L$8, C: C$6, Q: Q$5, Z: Z$6, N: N$4, D: D$4, X: X$4, G: G$4, F: F$5, O: O$5, P: P$4, U: U$4 } = PathCommandMap;
2973
2995
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2974
- const { tan, min, abs: abs$5 } = Math;
2996
+ const { tan, min, abs: abs$4 } = Math;
2975
2997
  const startPoint = {};
2976
2998
  const PathCommandDataHelper = {
2977
2999
  beginPath(data) {
@@ -3034,7 +3056,7 @@ const PathCommandDataHelper = {
3034
3056
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3035
3057
  if (lastX !== undefined) {
3036
3058
  const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3037
- radius = min(radius, min(d / 2, d / 2 * abs$5(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3059
+ radius = min(radius, min(d / 2, d / 2 * abs$4(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3038
3060
  }
3039
3061
  data.push(U$4, x1, y1, x2, y2, radius);
3040
3062
  },
@@ -3910,6 +3932,13 @@ function defineKey(target, key, descriptor, noConfigurable) {
3910
3932
  function getDescriptor(object, name) {
3911
3933
  return Object.getOwnPropertyDescriptor(object, name);
3912
3934
  }
3935
+ function createDescriptor(key, defaultValue) {
3936
+ const privateKey = '_' + key;
3937
+ return {
3938
+ get() { const v = this[privateKey]; return v === undefined ? defaultValue : v; },
3939
+ set(value) { this[privateKey] = value; }
3940
+ };
3941
+ }
3913
3942
  function getNames(object) {
3914
3943
  return Object.getOwnPropertyNames(object);
3915
3944
  }
@@ -4142,15 +4171,7 @@ function defineDataProcessor(target, key, defaultValue) {
4142
4171
  const data = target.__DataProcessor.prototype;
4143
4172
  const computedKey = '_' + key;
4144
4173
  const setMethodName = getSetMethodName(key);
4145
- const property = {
4146
- get() {
4147
- const v = this[computedKey];
4148
- return v === undefined ? defaultValue : v;
4149
- },
4150
- set(value) {
4151
- this[computedKey] = value;
4152
- }
4153
- };
4174
+ const property = createDescriptor(key, defaultValue);
4154
4175
  if (defaultValue === undefined) {
4155
4176
  property.get = function () { return this[computedKey]; };
4156
4177
  }
@@ -4265,7 +4286,7 @@ function registerUIEvent() {
4265
4286
  };
4266
4287
  }
4267
4288
 
4268
- const { copy: copy$a, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
4289
+ const { copy: copy$a, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$3, divideParent, getLayout } = MatrixHelper;
4269
4290
  const matrix$3 = {}, { round: round$3 } = Math;
4270
4291
  const LeafHelper = {
4271
4292
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -4337,6 +4358,14 @@ const LeafHelper = {
4337
4358
  }
4338
4359
  return true;
4339
4360
  },
4361
+ copyCanvasByWorld(leaf, currentCanvas, fromCanvas, fromWorld, blendMode, onlyResetTransform) {
4362
+ if (!fromWorld)
4363
+ fromWorld = leaf.__nowWorld;
4364
+ if (leaf.__worldFlipped || Platform.fullImageShadow)
4365
+ currentCanvas.copyWorldByReset(fromCanvas, fromWorld, leaf.__nowWorld, blendMode, onlyResetTransform);
4366
+ else
4367
+ currentCanvas.copyWorldToInner(fromCanvas, fromWorld, leaf.__layout.renderBounds, blendMode);
4368
+ },
4340
4369
  moveWorld(t, x, y = 0, isInnerPoint, transition) {
4341
4370
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4342
4371
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
@@ -4396,14 +4425,14 @@ const LeafHelper = {
4396
4425
  },
4397
4426
  transformWorld(t, transform, resize, transition) {
4398
4427
  copy$a(matrix$3, t.worldTransform);
4399
- multiplyParent$2(matrix$3, transform);
4428
+ multiplyParent$3(matrix$3, transform);
4400
4429
  if (t.parent)
4401
4430
  divideParent(matrix$3, t.parent.worldTransform);
4402
4431
  L$4.setTransform(t, matrix$3, resize, transition);
4403
4432
  },
4404
4433
  transform(t, transform, resize, transition) {
4405
4434
  copy$a(matrix$3, t.localTransform);
4406
- multiplyParent$2(matrix$3, transform);
4435
+ multiplyParent$3(matrix$3, transform);
4407
4436
  L$4.setTransform(t, matrix$3, resize, transition);
4408
4437
  },
4409
4438
  setTransform(t, transform, resize, transition) {
@@ -5265,17 +5294,18 @@ const LeafDataProxy = {
5265
5294
  }
5266
5295
  };
5267
5296
 
5268
- const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5297
+ const { setLayout, multiplyParent: multiplyParent$2, translateInner, defaultWorld } = MatrixHelper;
5269
5298
  const { toPoint: toPoint$4, tempPoint: tempPoint$1 } = AroundHelper;
5270
5299
  const LeafMatrix = {
5271
5300
  __updateWorldMatrix() {
5272
- multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
5301
+ const { parent, __layout } = this;
5302
+ multiplyParent$2(this.__local || __layout, parent ? parent.__world : defaultWorld, this.__world, !!__layout.affectScaleOrRotation, this.__, parent && (parent.scrollY || parent.scrollX) && parent.__);
5273
5303
  },
5274
5304
  __updateLocalMatrix() {
5275
5305
  if (this.__local) {
5276
5306
  const layout = this.__layout, local = this.__local, data = this.__;
5277
5307
  if (layout.affectScaleOrRotation) {
5278
- if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5308
+ if ((layout.scaleChanged && (layout.resized || (layout.resized = 'scale'))) || layout.rotationChanged) {
5279
5309
  setLayout(local, data, null, null, layout.affectRotation);
5280
5310
  layout.scaleChanged = layout.rotationChanged = undefined;
5281
5311
  }
@@ -5441,10 +5471,7 @@ const LeafRender = {
5441
5471
  return this.__renderEraser(canvas, options);
5442
5472
  const tempCanvas = canvas.getSameCanvas(true, true);
5443
5473
  this.__draw(tempCanvas, options, canvas);
5444
- if (this.__worldFlipped)
5445
- canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
5446
- else
5447
- canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
5474
+ LeafHelper.copyCanvasByWorld(this, canvas, tempCanvas, this.__nowWorld, data.__blendMode, true);
5448
5475
  tempCanvas.recycle(this.__nowWorld);
5449
5476
  }
5450
5477
  else {
@@ -5492,7 +5519,7 @@ const BranchRender = {
5492
5519
  options.dimOpacity = data.dim === true ? 0.2 : data.dim;
5493
5520
  else if (data.dimskip)
5494
5521
  options.dimOpacity && (options.dimOpacity = 0);
5495
- if (data.__single) {
5522
+ if (data.__single && !this.isBranchLeaf) {
5496
5523
  if (data.eraser === 'path')
5497
5524
  return this.__renderEraser(canvas, options);
5498
5525
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -5514,9 +5541,7 @@ const BranchRender = {
5514
5541
  else {
5515
5542
  const { children } = this;
5516
5543
  for (let i = 0, len = children.length; i < len; i++) {
5517
- if (excludeRenderBounds$1(children[i], options))
5518
- continue;
5519
- children[i].__render(canvas, options);
5544
+ excludeRenderBounds$1(children[i], options) || children[i].__render(canvas, options);
5520
5545
  }
5521
5546
  }
5522
5547
  },
@@ -5524,16 +5549,15 @@ const BranchRender = {
5524
5549
  if (this.__worldOpacity) {
5525
5550
  const { children } = this;
5526
5551
  for (let i = 0, len = children.length; i < len; i++) {
5527
- if (excludeRenderBounds$1(children[i], options))
5528
- continue;
5529
- children[i].__clip(canvas, options);
5552
+ excludeRenderBounds$1(children[i], options) || children[i].__clip(canvas, options);
5530
5553
  }
5531
5554
  }
5532
5555
  }
5533
5556
  };
5534
5557
 
5558
+ const tempScaleData$1 = {};
5535
5559
  const { LEAF, create } = IncrementId;
5536
- const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5560
+ const { toInnerPoint, toOuterPoint, multiplyParent: multiplyParent$1 } = MatrixHelper;
5537
5561
  const { toOuterOf } = BoundsHelper;
5538
5562
  const { copy: copy$7, move: move$5 } = PointHelper;
5539
5563
  const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
@@ -5715,7 +5739,7 @@ let Leaf = class Leaf {
5715
5739
  if (!this.__cameraWorld)
5716
5740
  this.__cameraWorld = {};
5717
5741
  const cameraWorld = this.__cameraWorld, world = this.__world;
5718
- multiplyParent(world, options.matrix, cameraWorld, undefined, world);
5742
+ multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
5719
5743
  toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
5720
5744
  cameraWorld.half !== world.half && (cameraWorld.half = world.half);
5721
5745
  return cameraWorld;
@@ -5724,6 +5748,22 @@ let Leaf = class Leaf {
5724
5748
  return this.__world;
5725
5749
  }
5726
5750
  }
5751
+ getClampRenderScale() {
5752
+ let { scaleX } = this.__nowWorld || this.__world;
5753
+ if (scaleX < 0)
5754
+ scaleX = -scaleX;
5755
+ return scaleX > 1 ? scaleX : 1;
5756
+ }
5757
+ getRenderScaleData(abs, scaleFixed) {
5758
+ const { scaleX, scaleY } = ImageManager.patternLocked ? this.__world : this.__nowWorld;
5759
+ if (scaleFixed)
5760
+ tempScaleData$1.scaleX = tempScaleData$1.scaleY = 1;
5761
+ else if (abs)
5762
+ tempScaleData$1.scaleX = scaleX < 0 ? -scaleX : scaleX, tempScaleData$1.scaleY = scaleY < 0 ? -scaleY : scaleY;
5763
+ else
5764
+ tempScaleData$1.scaleX = scaleX, tempScaleData$1.scaleY = scaleY;
5765
+ return tempScaleData$1;
5766
+ }
5727
5767
  getTransform(relative) {
5728
5768
  return this.__layout.getTransform(relative || 'local');
5729
5769
  }
@@ -6248,7 +6288,7 @@ class LeafLevelList {
6248
6288
  }
6249
6289
  }
6250
6290
 
6251
- const version = "1.7.0";
6291
+ const version = "1.8.0";
6252
6292
 
6253
6293
  class LeaferCanvas extends LeaferCanvasBase {
6254
6294
  get allowBackgroundColor() { return false; }
@@ -7235,6 +7275,11 @@ function zoomLayerType() {
7235
7275
  });
7236
7276
  };
7237
7277
  }
7278
+ function createAttr(defaultValue) {
7279
+ return (target, key) => {
7280
+ defineKey(target, key, createDescriptor(key, defaultValue));
7281
+ };
7282
+ }
7238
7283
 
7239
7284
  function hasTransparent$3(color) {
7240
7285
  if (!color || color.length === 7 || color.length === 4)
@@ -7292,22 +7337,9 @@ const emptyPaint = {};
7292
7337
  const debug$5 = Debug.get('UIData');
7293
7338
  class UIData extends LeafData {
7294
7339
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
7295
- get __strokeWidth() {
7296
- const { strokeWidth, strokeWidthFixed } = this;
7297
- if (strokeWidthFixed) {
7298
- const ui = this.__leaf;
7299
- let { scaleX } = ui.__nowWorld || ui.__world;
7300
- if (scaleX < 0)
7301
- scaleX = -scaleX;
7302
- return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
7303
- }
7304
- else
7305
- return strokeWidth;
7306
- }
7307
- get __hasMultiPaint() {
7308
- const t = this;
7309
- return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
7310
- }
7340
+ get __strokeWidth() { return this.__getRealStrokeWidth(); }
7341
+ get __maxStrokeWidth() { const t = this; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth; }
7342
+ get __hasMultiPaint() { const t = this; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect; }
7311
7343
  get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7312
7344
  get __hasSurface() { const t = this; return (t.fill || t.stroke); }
7313
7345
  get __autoWidth() { return !this._width; }
@@ -7389,6 +7421,21 @@ class UIData extends LeafData {
7389
7421
  Paint.compute('stroke', this.__leaf);
7390
7422
  this.__needComputePaint = undefined;
7391
7423
  }
7424
+ __getRealStrokeWidth(childStyle) {
7425
+ let { strokeWidth, strokeWidthFixed } = this;
7426
+ if (childStyle) {
7427
+ if (childStyle.strokeWidth)
7428
+ strokeWidth = childStyle.strokeWidth;
7429
+ if (childStyle.strokeWidthFixed !== undefined)
7430
+ strokeWidthFixed = childStyle.strokeWidthFixed;
7431
+ }
7432
+ if (strokeWidthFixed) {
7433
+ const scale = this.__leaf.getClampRenderScale();
7434
+ return scale > 1 ? strokeWidth / scale : strokeWidth;
7435
+ }
7436
+ else
7437
+ return strokeWidth;
7438
+ }
7392
7439
  __setPaint(attrName, value) {
7393
7440
  this.__setInput(attrName, value);
7394
7441
  const layout = this.__leaf.__layout;
@@ -7413,6 +7460,7 @@ class UIData extends LeafData {
7413
7460
  }
7414
7461
  else {
7415
7462
  stintSet$2(this, '__isAlphaPixelStroke', undefined);
7463
+ stintSet$2(this, '__hasMultiStrokeStyle', undefined);
7416
7464
  this._stroke = this.__isStrokes = undefined;
7417
7465
  }
7418
7466
  }
@@ -7434,8 +7482,8 @@ class GroupData extends UIData {
7434
7482
 
7435
7483
  class BoxData extends GroupData {
7436
7484
  get __boxStroke() { return !this.__pathInputed; }
7437
- get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7438
- get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7485
+ get __drawAfterFill() { const t = this; return t.__single || t.__clipAfterFill; }
7486
+ get __clipAfterFill() { const t = this; return t.overflow === 'hide' && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill); }
7439
7487
  }
7440
7488
 
7441
7489
  class LeaferData extends GroupData {
@@ -7555,7 +7603,7 @@ class CanvasData extends RectData {
7555
7603
  const UIBounds = {
7556
7604
  __updateStrokeSpread() {
7557
7605
  let width = 0, boxWidth = 0;
7558
- const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
7606
+ const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
7559
7607
  if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
7560
7608
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
7561
7609
  if (!data.__boxStroke) {
@@ -7575,13 +7623,15 @@ const UIBounds = {
7575
7623
  },
7576
7624
  __updateRenderSpread() {
7577
7625
  let width = 0;
7578
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7626
+ const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
7579
7627
  if (shadow)
7580
7628
  shadow.forEach(item => width = Math.max(width, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread > 0 ? item.spread : 0) + item.blur * 1.5));
7581
7629
  if (blur)
7582
7630
  width = Math.max(width, blur);
7583
7631
  if (filter)
7584
7632
  width += Filter.getSpread(filter);
7633
+ if (renderSpread)
7634
+ width += renderSpread;
7585
7635
  let shapeWidth = width = Math.ceil(width);
7586
7636
  if (innerShadow)
7587
7637
  innerShadow.forEach(item => shapeWidth = Math.max(shapeWidth, Math.max(Math.abs(item.y), Math.abs(item.x)) + (item.spread < 0 ? -item.spread : 0) + item.blur * 1.5));
@@ -7604,7 +7654,7 @@ const UIRender = {
7604
7654
  }
7605
7655
  if (data.__useEffect) {
7606
7656
  const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7607
- stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && !(shadow[0].box && data.__isTransparentFill) && fill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
7657
+ stintSet$1(data, '__isFastShadow', shadow && !otherEffect && shadow.length < 2 && !shadow[0].spread && fill && !data.__isTransparentFill && !(fill instanceof Array && fill.length > 1) && (this.useFastShadow || !stroke || (stroke && data.strokeAlign === 'inside')));
7608
7658
  data.__useEffect = !!(shadow || otherEffect);
7609
7659
  }
7610
7660
  data.__checkSingle();
@@ -7711,17 +7761,17 @@ const RectRender = {
7711
7761
  if (__drawAfterFill)
7712
7762
  this.__drawAfterFill(canvas, options);
7713
7763
  if (stroke) {
7714
- const { strokeAlign, __strokeWidth } = this.__;
7715
- if (!__strokeWidth)
7764
+ const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
7765
+ if (!strokeWidth)
7716
7766
  return;
7717
- canvas.setStroke(stroke, __strokeWidth, this.__);
7718
- const half = __strokeWidth / 2;
7767
+ canvas.setStroke(stroke, strokeWidth, this.__);
7768
+ const half = strokeWidth / 2;
7719
7769
  switch (strokeAlign) {
7720
7770
  case 'center':
7721
7771
  canvas.strokeRect(0, 0, width, height);
7722
7772
  break;
7723
7773
  case 'inside':
7724
- width -= __strokeWidth, height -= __strokeWidth;
7774
+ width -= strokeWidth, height -= strokeWidth;
7725
7775
  if (width < 0 || height < 0) {
7726
7776
  canvas.save();
7727
7777
  this.__clip(canvas, options);
@@ -7732,7 +7782,7 @@ const RectRender = {
7732
7782
  canvas.strokeRect(x + half, y + half, width, height);
7733
7783
  break;
7734
7784
  case 'outside':
7735
- canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
7785
+ canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
7736
7786
  break;
7737
7787
  }
7738
7788
  }
@@ -7745,6 +7795,8 @@ let UI = UI_1 = class UI extends Leaf {
7745
7795
  get isFrame() { return false; }
7746
7796
  set scale(value) { MathHelper.assignScale(this, value); }
7747
7797
  get scale() { return this.__.scale; }
7798
+ get isAutoWidth() { const t = this.__; return t.__autoWidth || t.autoWidth; }
7799
+ get isAutoHeight() { const t = this.__; return t.__autoHeight || t.autoHeight; }
7748
7800
  get pen() {
7749
7801
  const { path } = this.__;
7750
7802
  pen.set(this.path = path || []);
@@ -7959,6 +8011,9 @@ __decorate([
7959
8011
  __decorate([
7960
8012
  naturalBoundsType(1)
7961
8013
  ], UI.prototype, "pixelRatio", void 0);
8014
+ __decorate([
8015
+ affectRenderBoundsType(0)
8016
+ ], UI.prototype, "renderSpread", void 0);
7962
8017
  __decorate([
7963
8018
  pathInputType()
7964
8019
  ], UI.prototype, "path", void 0);
@@ -8115,7 +8170,8 @@ let Group = class Group extends UI {
8115
8170
  }
8116
8171
  toJSON(options) {
8117
8172
  const data = super.toJSON(options);
8118
- data.children = this.children.map(child => child.toJSON(options));
8173
+ if (!this.childlessJSON)
8174
+ data.children = this.children.map(child => child.toJSON(options));
8119
8175
  return data;
8120
8176
  }
8121
8177
  pick(_hitPoint, _options) { return undefined; }
@@ -8562,8 +8618,8 @@ let Box = class Box extends Group {
8562
8618
  __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
8563
8619
  __updateRectBoxBounds() { }
8564
8620
  __updateBoxBounds(_secondLayout) {
8565
- const data = this.__;
8566
8621
  if (this.children.length && !this.pathInputed) {
8622
+ const data = this.__;
8567
8623
  if (data.__autoSide) {
8568
8624
  if (data.__hasSurface)
8569
8625
  this.__extraUpdate();
@@ -8590,20 +8646,26 @@ let Box = class Box extends Group {
8590
8646
  __updateStrokeBounds() { }
8591
8647
  __updateRenderBounds() {
8592
8648
  let isOverflow;
8593
- const { renderBounds } = this.__layout;
8594
8649
  if (this.children.length) {
8650
+ const data = this.__, { renderBounds, boxBounds } = this.__layout;
8595
8651
  super.__updateRenderBounds();
8596
8652
  copy$6(childrenRenderBounds, renderBounds);
8597
8653
  this.__updateRectRenderBounds();
8598
- isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8599
- if (isOverflow && this.__.overflow !== 'hide')
8654
+ if (data.scrollY || data.scrollX) {
8655
+ childrenRenderBounds.x += data.scrollX;
8656
+ childrenRenderBounds.y += data.scrollY;
8657
+ }
8658
+ isOverflow = !includes$1(boxBounds, childrenRenderBounds);
8659
+ if (isOverflow && data.overflow !== 'hide')
8600
8660
  add(renderBounds, childrenRenderBounds);
8601
8661
  }
8602
8662
  else
8603
8663
  this.__updateRectRenderBounds();
8604
8664
  DataHelper.stintSet(this, 'isOverflow', isOverflow);
8665
+ this.__updateScrollBar();
8605
8666
  }
8606
8667
  __updateRectRenderBounds() { }
8668
+ __updateScrollBar() { }
8607
8669
  __updateRectChange() { }
8608
8670
  __updateChange() {
8609
8671
  super.__updateChange();
@@ -8620,10 +8682,12 @@ let Box = class Box extends Group {
8620
8682
  if (this.children.length)
8621
8683
  this.__renderGroup(canvas, options);
8622
8684
  }
8685
+ if (this.scrollBar)
8686
+ this.scrollBar.__render(canvas, options);
8623
8687
  }
8624
8688
  __drawContent(canvas, options) {
8625
8689
  this.__renderGroup(canvas, options);
8626
- if (this.__.__useStroke) {
8690
+ if (this.__.__useStroke || this.__.__useEffect) {
8627
8691
  canvas.setWorld(this.__nowWorld);
8628
8692
  this.__drawRenderPath(canvas);
8629
8693
  }
@@ -10426,18 +10490,20 @@ leaf$1.__hitWorld = function (point) {
10426
10490
  }
10427
10491
  return this.__hit(inner);
10428
10492
  };
10429
- leaf$1.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
10430
- leaf$1.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
10431
- leaf$1.__hitPixel = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitPixel(inner, this.__layout.renderBounds, this.__hitCanvas.hitScale); };
10432
- leaf$1.__drawHitPath = function (canvas) { if (canvas)
10433
- this.__drawRenderPath(canvas); };
10493
+ leaf$1.__hitFill = function (inner) { const h = this.__hitCanvas; return h && h.hitFill(inner, this.__.windingRule); };
10494
+ leaf$1.__hitStroke = function (inner, strokeWidth) { const h = this.__hitCanvas; return h && h.hitStroke(inner, strokeWidth); };
10495
+ leaf$1.__hitPixel = function (inner) { const h = this.__hitCanvas; return h && h.hitPixel(inner, this.__layout.renderBounds, h.hitScale); };
10496
+ leaf$1.__drawHitPath = function (canvas) { canvas && this.__drawRenderPath(canvas); };
10434
10497
 
10435
10498
  const matrix$2 = new Matrix();
10436
10499
  const ui$5 = UI.prototype;
10437
10500
  ui$5.__updateHitCanvas = function () {
10438
10501
  if (this.__box)
10439
10502
  this.__box.__updateHitCanvas();
10440
- const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10503
+ const leafer = this.leafer || (this.parent && this.parent.leafer);
10504
+ if (!leafer)
10505
+ return;
10506
+ const data = this.__, { hitCanvasManager } = leafer;
10441
10507
  const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10442
10508
  const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10443
10509
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -10473,7 +10539,7 @@ ui$5.__hit = function (inner) {
10473
10539
  const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10474
10540
  if (needHitFillPath && this.__hitFill(inner))
10475
10541
  return true;
10476
- const { hitStroke, __strokeWidth } = data;
10542
+ const { hitStroke, __maxStrokeWidth: strokeWidth } = data;
10477
10543
  const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10478
10544
  if (!needHitFillPath && !needHitStrokePath)
10479
10545
  return false;
@@ -10482,16 +10548,16 @@ ui$5.__hit = function (inner) {
10482
10548
  if (needHitStrokePath) {
10483
10549
  switch (data.strokeAlign) {
10484
10550
  case 'inside':
10485
- hitWidth += __strokeWidth * 2;
10551
+ hitWidth += strokeWidth * 2;
10486
10552
  if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
10487
10553
  return true;
10488
10554
  hitWidth = radiusWidth;
10489
10555
  break;
10490
10556
  case 'center':
10491
- hitWidth += __strokeWidth;
10557
+ hitWidth += strokeWidth;
10492
10558
  break;
10493
10559
  case 'outside':
10494
- hitWidth += __strokeWidth * 2;
10560
+ hitWidth += strokeWidth * 2;
10495
10561
  if (!needHitFillPath) {
10496
10562
  if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
10497
10563
  return true;
@@ -10696,9 +10762,14 @@ function fills(fills, ui, canvas) {
10696
10762
  }
10697
10763
  }
10698
10764
  canvas.fillStyle = item.style;
10699
- if (item.transform) {
10765
+ if (item.transform || item.scaleFixed) {
10700
10766
  canvas.save();
10701
- canvas.transform(item.transform);
10767
+ if (item.transform)
10768
+ canvas.transform(item.transform);
10769
+ if (item.scaleFixed) {
10770
+ const { scaleX, scaleY } = ui.getRenderScaleData(true);
10771
+ canvas.scale(1 / scaleX, 1 / scaleY);
10772
+ }
10702
10773
  if (item.blendMode)
10703
10774
  canvas.blendMode = item.blendMode;
10704
10775
  fillPathOrText(ui, canvas);
@@ -10734,8 +10805,13 @@ function strokeText(stroke, ui, canvas) {
10734
10805
  }
10735
10806
  function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10736
10807
  const data = ui.__;
10737
- canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10738
- data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10808
+ if (typeof stroke === 'object') {
10809
+ drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
10810
+ }
10811
+ else {
10812
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10813
+ drawTextStroke(ui, canvas);
10814
+ }
10739
10815
  }
10740
10816
  function drawAlign(stroke, align, ui, canvas) {
10741
10817
  const out = canvas.getSameCanvas(true, true);
@@ -10744,15 +10820,9 @@ function drawAlign(stroke, align, ui, canvas) {
10744
10820
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10745
10821
  fillText(ui, out);
10746
10822
  out.blendMode = 'normal';
10747
- copyWorld(canvas, out, ui);
10823
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10748
10824
  out.recycle(ui.__nowWorld);
10749
10825
  }
10750
- function copyWorld(canvas, out, ui) {
10751
- if (ui.__worldFlipped || Platform.fullImageShadow)
10752
- canvas.copyWorldByReset(out, ui.__nowWorld);
10753
- else
10754
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10755
- }
10756
10826
  function drawTextStroke(ui, canvas) {
10757
10827
  let row, data = ui.__.__textDrawData;
10758
10828
  const { rows, decorationY } = data;
@@ -10768,14 +10838,21 @@ function drawTextStroke(ui, canvas) {
10768
10838
  rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
10769
10839
  }
10770
10840
  }
10771
- function drawStrokesStyle(strokes, isText, ui, canvas) {
10841
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
10772
10842
  let item;
10843
+ const data = ui.__, { __hasMultiStrokeStyle } = data;
10844
+ __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
10773
10845
  for (let i = 0, len = strokes.length; i < len; i++) {
10774
10846
  item = strokes[i];
10775
10847
  if (item.image && PaintImage.checkImage(ui, canvas, item, false))
10776
10848
  continue;
10777
10849
  if (item.style) {
10778
- canvas.strokeStyle = item.style;
10850
+ if (__hasMultiStrokeStyle) {
10851
+ const { strokeStyle } = item;
10852
+ strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
10853
+ }
10854
+ else
10855
+ canvas.strokeStyle = item.style;
10779
10856
  if (item.blendMode) {
10780
10857
  canvas.saveBlendMode(item.blendMode);
10781
10858
  isText ? drawTextStroke(ui, canvas) : canvas.stroke();
@@ -10814,8 +10891,13 @@ function strokes(strokes, ui, canvas) {
10814
10891
  }
10815
10892
  function drawCenter(stroke, strokeWidthScale, ui, canvas) {
10816
10893
  const data = ui.__;
10817
- canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
10818
- data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
10894
+ if (typeof stroke === 'object') {
10895
+ drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
10896
+ }
10897
+ else {
10898
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10899
+ canvas.stroke();
10900
+ }
10819
10901
  if (data.__useArrow)
10820
10902
  Paint.strokeArrow(stroke, ui, canvas);
10821
10903
  }
@@ -10837,7 +10919,7 @@ function drawOutside(stroke, ui, canvas) {
10837
10919
  drawCenter(stroke, 2, ui, out);
10838
10920
  out.clipUI(data);
10839
10921
  out.clearWorld(renderBounds);
10840
- copyWorld(canvas, out, ui);
10922
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10841
10923
  out.recycle(ui.__nowWorld);
10842
10924
  }
10843
10925
  }
@@ -10892,8 +10974,16 @@ function compute(attrName, ui) {
10892
10974
  if (!(paints instanceof Array))
10893
10975
  paints = [paints];
10894
10976
  recycleMap = PaintImage.recycleImage(attrName, data);
10977
+ let maxChildStrokeWidth;
10895
10978
  for (let i = 0, len = paints.length, item; i < len; i++) {
10896
- (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
10979
+ if (item = getLeafPaint(attrName, paints[i], ui)) {
10980
+ leafPaints.push(item);
10981
+ if (item.strokeStyle) {
10982
+ maxChildStrokeWidth || (maxChildStrokeWidth = 1);
10983
+ if (item.strokeStyle.strokeWidth)
10984
+ maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
10985
+ }
10986
+ }
10897
10987
  }
10898
10988
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10899
10989
  if (leafPaints.length) {
@@ -10910,6 +11000,7 @@ function compute(attrName, ui) {
10910
11000
  else {
10911
11001
  stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
10912
11002
  stintSet(data, '__isTransparentStroke', isTransparent);
11003
+ stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
10913
11004
  }
10914
11005
  }
10915
11006
  function getLeafPaint(attrName, paint, ui) {
@@ -10941,6 +11032,11 @@ function getLeafPaint(attrName, paint, ui) {
10941
11032
  if (data) {
10942
11033
  if (typeof data.style === 'string' && hasTransparent$1(data.style))
10943
11034
  data.isTransparent = true;
11035
+ if (paint.style) {
11036
+ if (paint.style.strokeWidth === 0)
11037
+ return undefined;
11038
+ data.strokeStyle = paint.style;
11039
+ }
10944
11040
  if (paint.blendMode)
10945
11041
  data.blendMode = paint.blendMode;
10946
11042
  }
@@ -10960,8 +11056,8 @@ const PaintModule = {
10960
11056
  shape
10961
11057
  };
10962
11058
 
10963
- let origin$1 = {};
10964
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
11059
+ let origin$1 = {}, tempMatrix = getMatrixData();
11060
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
10965
11061
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10966
11062
  const transform = get$3();
10967
11063
  translate$1(transform, box.x + x, box.y + y);
@@ -10970,7 +11066,7 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10970
11066
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10971
11067
  data.transform = transform;
10972
11068
  }
10973
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
11069
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
10974
11070
  const transform = get$3();
10975
11071
  if (rotation)
10976
11072
  rotate$2(transform, rotation);
@@ -10979,6 +11075,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
10979
11075
  if (scaleX)
10980
11076
  scaleHelper(transform, scaleX, scaleY);
10981
11077
  translate$1(transform, box.x + x, box.y + y);
11078
+ if (clipSize) {
11079
+ tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
11080
+ multiplyParent(transform, tempMatrix);
11081
+ }
10982
11082
  data.transform = transform;
10983
11083
  }
10984
11084
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -11015,13 +11115,15 @@ const tempBox = new Bounds();
11015
11115
  const tempScaleData = {};
11016
11116
  const tempImage = {};
11017
11117
  function createData(leafPaint, image, paint, box) {
11018
- const { changeful, sync, editing } = paint;
11118
+ const { changeful, sync, editing, scaleFixed } = paint;
11019
11119
  if (changeful)
11020
11120
  leafPaint.changeful = changeful;
11021
11121
  if (sync)
11022
11122
  leafPaint.sync = sync;
11023
11123
  if (editing)
11024
11124
  leafPaint.editing = editing;
11125
+ if (scaleFixed)
11126
+ leafPaint.scaleFixed = scaleFixed;
11025
11127
  leafPaint.data = getPatternData(paint, box, image);
11026
11128
  }
11027
11129
  function getPatternData(paint, box, image) {
@@ -11030,7 +11132,7 @@ function getPatternData(paint, box, image) {
11030
11132
  if (paint.mode === 'strench')
11031
11133
  paint.mode = 'stretch';
11032
11134
  let { width, height } = image;
11033
- const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
11135
+ const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
11034
11136
  const sameBox = box.width === width && box.height === height;
11035
11137
  const data = { mode };
11036
11138
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -11064,8 +11166,8 @@ function getPatternData(paint, box, image) {
11064
11166
  break;
11065
11167
  case 'normal':
11066
11168
  case 'clip':
11067
- if (tempImage.x || tempImage.y || scaleX || rotation || skew)
11068
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
11169
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
11170
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
11069
11171
  break;
11070
11172
  case 'repeat':
11071
11173
  if (!sameBox || scaleX || rotation)
@@ -11202,18 +11304,16 @@ function ignoreRender(ui, value) {
11202
11304
  }
11203
11305
 
11204
11306
  const { get: get$1, scale: scale$2, copy: copy$4 } = MatrixHelper;
11205
- const { ceil: ceil$1, abs: abs$4 } = Math;
11307
+ const { ceil: ceil$1, abs: abs$3 } = Math;
11206
11308
  function createPattern(ui, paint, pixelRatio) {
11207
- let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11309
+ let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
11208
11310
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
11209
11311
  if (paint.patternId !== id && !ui.destroyed) {
11210
- scaleX = abs$4(scaleX);
11211
- scaleY = abs$4(scaleY);
11212
11312
  const { image, data } = paint;
11213
11313
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
11214
11314
  if (sx) {
11215
- sx = abs$4(sx);
11216
- sy = abs$4(sy);
11315
+ sx = abs$3(sx);
11316
+ sy = abs$3(sy);
11217
11317
  imageMatrix = get$1();
11218
11318
  copy$4(imageMatrix, transform);
11219
11319
  scale$2(imageMatrix, 1 / sx, 1 / sy);
@@ -11266,9 +11366,8 @@ function createPattern(ui, paint, pixelRatio) {
11266
11366
  }
11267
11367
  }
11268
11368
 
11269
- const { abs: abs$3 } = Math;
11270
11369
  function checkImage(ui, canvas, paint, allowDraw) {
11271
- const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11370
+ const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
11272
11371
  const { pixelRatio } = canvas, { data } = paint;
11273
11372
  if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
11274
11373
  return false;
@@ -11281,8 +11380,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
11281
11380
  else {
11282
11381
  if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
11283
11382
  let { width, height } = data;
11284
- width *= abs$3(scaleX) * pixelRatio;
11285
- height *= abs$3(scaleY) * pixelRatio;
11383
+ width *= scaleX * pixelRatio;
11384
+ height *= scaleY * pixelRatio;
11286
11385
  if (data.scaleX) {
11287
11386
  width *= data.scaleX;
11288
11387
  height *= data.scaleY;
@@ -11292,6 +11391,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
11292
11391
  }
11293
11392
  }
11294
11393
  if (allowDraw) {
11394
+ if (ui.__.__isFastShadow) {
11395
+ canvas.fillStyle = paint.style || '#000';
11396
+ canvas.fill();
11397
+ }
11295
11398
  drawImage(ui, canvas, paint, data);
11296
11399
  return true;
11297
11400
  }
@@ -11480,10 +11583,7 @@ function shadow$1(ui, current, shape) {
11480
11583
  }
11481
11584
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
11482
11585
  }
11483
- if (ui.__worldFlipped)
11484
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11485
- else
11486
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11586
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11487
11587
  if (end && index < end)
11488
11588
  other.clearWorld(copyBounds, true);
11489
11589
  });
@@ -11542,10 +11642,7 @@ function innerShadow(ui, current, shape) {
11542
11642
  copyBounds = bounds;
11543
11643
  }
11544
11644
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
11545
- if (ui.__worldFlipped)
11546
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11547
- else
11548
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11645
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11549
11646
  if (end && index < end)
11550
11647
  other.clearWorld(copyBounds, true);
11551
11648
  });
@@ -11601,12 +11698,11 @@ Group.prototype.__renderMask = function (canvas, options) {
11601
11698
  contentCanvas = getCanvas(canvas);
11602
11699
  child.__render(maskCanvas, options);
11603
11700
  }
11604
- if (!(mask === 'clipping' || mask === 'clipping-path'))
11605
- continue;
11606
- }
11607
- if (excludeRenderBounds(child, options))
11701
+ if (mask === 'clipping' || mask === 'clipping-path')
11702
+ excludeRenderBounds(child, options) || child.__render(canvas, options);
11608
11703
  continue;
11609
- child.__render(contentCanvas || canvas, options);
11704
+ }
11705
+ excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
11610
11706
  }
11611
11707
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
11612
11708
  };
@@ -12231,6 +12327,8 @@ function targetAttr(fn) {
12231
12327
  if (isSelect) {
12232
12328
  if (value instanceof Array && value.length > 1 && value[0].locked)
12233
12329
  value.splice(0, 1);
12330
+ if (this.single)
12331
+ this.element.syncEventer = null;
12234
12332
  const { beforeSelect } = this.config;
12235
12333
  if (beforeSelect) {
12236
12334
  const check = beforeSelect({ target: value });
@@ -12254,9 +12352,11 @@ function mergeConfigAttr() {
12254
12352
  return (target, key) => {
12255
12353
  defineKey(target, key, {
12256
12354
  get() {
12257
- const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
12355
+ const { config, element, dragPoint, editBox } = this, mergeConfig = Object.assign({}, config);
12258
12356
  if (element && element.editConfig)
12259
12357
  Object.assign(mergeConfig, element.editConfig);
12358
+ if (editBox.config)
12359
+ Object.assign(mergeConfig, editBox.config);
12260
12360
  if (dragPoint) {
12261
12361
  if (dragPoint.editConfig)
12262
12362
  Object.assign(mergeConfig, dragPoint.editConfig);
@@ -12288,14 +12388,17 @@ class Stroker extends UI {
12288
12388
  this.strokeAlign = 'center';
12289
12389
  }
12290
12390
  setTarget(target, style) {
12291
- this.set(style);
12391
+ if (style)
12392
+ this.set(style);
12292
12393
  this.target = target;
12293
12394
  this.update();
12294
12395
  }
12295
- update() {
12396
+ update(style) {
12296
12397
  const { list } = this;
12297
12398
  if (list.length) {
12298
12399
  setListWithFn(bounds$2, list, worldBounds);
12400
+ if (style)
12401
+ this.set(style);
12299
12402
  this.set(bounds$2);
12300
12403
  this.visible = true;
12301
12404
  }
@@ -12438,15 +12541,14 @@ class EditSelect extends Group {
12438
12541
  }
12439
12542
  onSelect() {
12440
12543
  if (this.running) {
12441
- const { mergeConfig, list } = this.editor;
12442
- const { stroke, strokeWidth, selectedStyle } = mergeConfig;
12443
- this.targetStroker.setTarget(list, Object.assign({ stroke, strokeWidth: Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
12544
+ this.targetStroker.setTarget(this.editor.list);
12444
12545
  this.hoverStroker.target = null;
12445
12546
  }
12446
12547
  }
12447
12548
  update() {
12448
12549
  this.hoverStroker.update();
12449
- this.targetStroker.update();
12550
+ const { stroke, strokeWidth, selectedStyle } = this.editor.mergedConfig;
12551
+ this.targetStroker.update(Object.assign({ stroke, strokeWidth: strokeWidth && Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
12450
12552
  }
12451
12553
  onPointerMove(e) {
12452
12554
  const { app, editor } = this;
@@ -12722,15 +12824,17 @@ const EditDataHelper = {
12722
12824
  toPoint(around || align, boxBounds, origin, true);
12723
12825
  if (dragBounds) {
12724
12826
  const allowBounds = dragBounds === 'parent' ? target.parent.boxBounds : dragBounds;
12725
- const localBounds = new Bounds(target.__localBoxBounds);
12726
- localBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
12727
- if (!BoundsHelper.includes(allowBounds, localBounds)) {
12728
- const realBounds = localBounds.getIntersect(allowBounds);
12729
- const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
12730
- if (useScaleX)
12731
- scaleX *= fitScaleX;
12732
- if (useScaleY)
12733
- scaleY *= fitScaleY;
12827
+ const childBounds = new Bounds(target.__localBoxBounds);
12828
+ if (BoundsHelper.includes(new Bounds(allowBounds).spread(0.1), childBounds)) {
12829
+ childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
12830
+ if (!BoundsHelper.includes(allowBounds, childBounds)) {
12831
+ const realBounds = childBounds.getIntersect(allowBounds);
12832
+ const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
12833
+ if (useScaleX)
12834
+ scaleX *= fitScaleX;
12835
+ if (useScaleY)
12836
+ scaleY *= fitScaleY;
12837
+ }
12734
12838
  }
12735
12839
  }
12736
12840
  if (useScaleX && widthRange) {
@@ -12865,9 +12969,9 @@ const EditDataHelper = {
12865
12969
  };
12866
12970
 
12867
12971
  const cacheCursors = {};
12868
- function updateCursor(editBox, e) {
12869
- const { enterPoint: point } = editBox;
12870
- if (!point || !editBox.editor.editing || !editBox.visible)
12972
+ function updatePointCursor(editBox, e) {
12973
+ const { enterPoint: point, dragging, skewing, resizing, flippedX, flippedY } = editBox;
12974
+ if (!point || !editBox.editor.editing || !editBox.canUse)
12871
12975
  return;
12872
12976
  if (point.name === 'circle')
12873
12977
  return;
@@ -12876,13 +12980,15 @@ function updateCursor(editBox, e) {
12876
12980
  point.cursor = 'pointer';
12877
12981
  return;
12878
12982
  }
12879
- let { rotation, flippedX, flippedY } = editBox;
12983
+ let { rotation } = editBox;
12880
12984
  const { pointType } = point, { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } = editBox.mergeConfig;
12881
12985
  let showResize = pointType.includes('resize');
12882
12986
  if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
12883
12987
  showResize = false;
12884
12988
  const showSkew = skewable && !showResize && (point.name === 'resize-line' || pointType === 'skew');
12885
- const cursor = showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor);
12989
+ const cursor = dragging
12990
+ ? (skewing ? skewCursor : (resizing ? resizeCursor : rotateCursor))
12991
+ : (showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor));
12886
12992
  rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
12887
12993
  rotation = Math.round(MathHelper.formatRotation(rotation, true) / 2) * 2;
12888
12994
  const { url, x, y } = cursor;
@@ -12896,7 +13002,8 @@ function updateCursor(editBox, e) {
12896
13002
  }
12897
13003
  function updateMoveCursor(editBox) {
12898
13004
  const { moveCursor, moveable } = editBox.mergeConfig;
12899
- editBox.rect.cursor = moveable ? moveCursor : undefined;
13005
+ if (editBox.canUse)
13006
+ editBox.rect.cursor = moveable ? moveCursor : undefined;
12900
13007
  }
12901
13008
  function toDataURL(svg, rotation) {
12902
13009
  return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
@@ -12912,8 +13019,8 @@ class EditPoint extends Box {
12912
13019
  const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
12913
13020
  class EditBox extends Group {
12914
13021
  get mergeConfig() {
12915
- const { config } = this, { mergeConfig } = this.editor;
12916
- return this.mergedConfig = config ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
13022
+ const { config } = this, { mergeConfig, editBox } = this.editor;
13023
+ return this.mergedConfig = config && (editBox !== this) ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
12917
13024
  }
12918
13025
  get target() { return this._target || this.editor.element; }
12919
13026
  set target(target) { this._target = target; }
@@ -12924,6 +13031,13 @@ class EditBox extends Group {
12924
13031
  get flippedX() { return this.scaleX < 0; }
12925
13032
  get flippedY() { return this.scaleY < 0; }
12926
13033
  get flippedOne() { return this.scaleX * this.scaleY < 0; }
13034
+ get canUse() { return (this.visible && this.view.visible); }
13035
+ get canGesture() {
13036
+ if (!this.canUse)
13037
+ return false;
13038
+ const { moveable, resizeable, rotateable } = this.mergeConfig;
13039
+ return typeof moveable === 'string' || typeof resizeable === 'string' || typeof rotateable === 'string';
13040
+ }
12927
13041
  constructor(editor) {
12928
13042
  super();
12929
13043
  this.view = new Group();
@@ -12970,8 +13084,7 @@ class EditBox extends Group {
12970
13084
  for (let i = 0; i < 8; i++) {
12971
13085
  resizeP = resizePoints[i];
12972
13086
  resizeP.set(this.getPointStyle((i % 2) ? middlePointsStyle[((i - 1) / 2) % middlePointsStyle.length] : pointsStyle[(i / 2) % pointsStyle.length]));
12973
- if (!(i % 2))
12974
- resizeP.rotation = (i / 2) * 90;
13087
+ resizeP.rotation = ((i - (i % 2 ? 1 : 0)) / 2) * 90;
12975
13088
  }
12976
13089
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
12977
13090
  rect.set(Object.assign({ stroke, strokeWidth, editConfig }, (mergeConfig.rect || {})));
@@ -12990,12 +13103,19 @@ class EditBox extends Group {
12990
13103
  this.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
12991
13104
  this.updateBounds({ x: 0, y: 0, width, height });
12992
13105
  }
13106
+ unload() {
13107
+ this.visible = false;
13108
+ if (this.app)
13109
+ this.rect.syncEventer = this.app.interaction.bottomList = null;
13110
+ }
12993
13111
  updateBounds(bounds) {
12994
13112
  const { editMask } = this.editor;
12995
13113
  const { mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
12996
- const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask } = mergeConfig;
13114
+ const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask, spread } = mergeConfig;
12997
13115
  this.visible = !this.target.locked;
12998
13116
  editMask.visible = mask ? true : 0;
13117
+ if (spread)
13118
+ BoundsHelper.spread(bounds, spread);
12999
13119
  if (this.view.worldOpacity) {
13000
13120
  const { width, height } = bounds;
13001
13121
  const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
@@ -13020,7 +13140,6 @@ class EditBox extends Group {
13020
13140
  }
13021
13141
  else {
13022
13142
  resizeL.height = height;
13023
- resizeP.rotation = 90;
13024
13143
  if (hideOnSmall && resizeP.width * 2 > height)
13025
13144
  resizeP.visible = false;
13026
13145
  }
@@ -13075,9 +13194,6 @@ class EditBox extends Group {
13075
13194
  buttons.y = point.y + margin;
13076
13195
  }
13077
13196
  }
13078
- unload() {
13079
- this.visible = false;
13080
- }
13081
13197
  getPointStyle(userStyle) {
13082
13198
  const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.mergedConfig;
13083
13199
  const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0, editConfig };
@@ -13091,20 +13207,26 @@ class EditBox extends Group {
13091
13207
  const { middlePoint } = this.mergedConfig;
13092
13208
  return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
13093
13209
  }
13094
- onSelect(e) {
13095
- if (e.oldList.length === 1) {
13096
- e.oldList[0].syncEventer = null;
13097
- if (this.app)
13098
- this.app.interaction.bottomList = null;
13099
- }
13100
- }
13101
13210
  onDragStart(e) {
13102
13211
  this.dragging = true;
13103
13212
  const point = this.dragPoint = e.current, { pointType } = point;
13104
- const { editor, dragStartData } = this, { target } = this;
13213
+ const { editor, dragStartData } = this, { target } = this, { moveable, resizeable, rotateable, skewable, hideOnMove } = this.mergeConfig;
13105
13214
  if (point.name === 'rect') {
13106
- this.moving = true;
13107
- editor.opacity = this.mergeConfig.hideOnMove ? 0 : 1;
13215
+ moveable && (this.moving = true);
13216
+ editor.opacity = hideOnMove ? 0 : 1;
13217
+ }
13218
+ else {
13219
+ if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !resizeable) {
13220
+ rotateable && (this.rotating = true);
13221
+ if (pointType === 'resize-rotate')
13222
+ resizeable && (this.resizing = true);
13223
+ else if (point.name === 'resize-line')
13224
+ skewable && (this.skewing = true), this.rotating = false;
13225
+ }
13226
+ else if (pointType === 'resize')
13227
+ resizeable && (this.resizing = true);
13228
+ if (pointType === 'skew')
13229
+ skewable && (this.skewing = true);
13108
13230
  }
13109
13231
  dragStartData.x = e.x;
13110
13232
  dragStartData.y = e.y;
@@ -13115,9 +13237,8 @@ class EditBox extends Group {
13115
13237
  ResizeEvent.resizingKeys = editor.leafList.keys;
13116
13238
  }
13117
13239
  onDragEnd(e) {
13118
- this.dragging = false;
13119
13240
  this.dragPoint = null;
13120
- this.moving = false;
13241
+ this.resetDoing();
13121
13242
  const { name, pointType } = e.current;
13122
13243
  if (name === 'rect')
13123
13244
  this.editor.opacity = 1;
@@ -13125,31 +13246,61 @@ class EditBox extends Group {
13125
13246
  ResizeEvent.resizingKeys = null;
13126
13247
  }
13127
13248
  onDrag(e) {
13128
- const { transformTool } = this, point = e.current;
13129
- if (point.name === 'rect') {
13249
+ const { transformTool, moving, resizing, rotating, skewing } = this;
13250
+ if (moving) {
13130
13251
  transformTool.onMove(e);
13131
13252
  updateMoveCursor(this);
13132
13253
  }
13133
- else {
13134
- const { pointType } = this.enterPoint = point;
13135
- if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !this.mergeConfig.resizeable) {
13254
+ else if (resizing || rotating || skewing) {
13255
+ const point = e.current;
13256
+ if (point.pointType)
13257
+ this.enterPoint = point;
13258
+ if (rotating)
13136
13259
  transformTool.onRotate(e);
13137
- if (pointType === 'resize-rotate')
13138
- transformTool.onScale(e);
13139
- }
13140
- else if (pointType === 'resize')
13260
+ if (resizing)
13141
13261
  transformTool.onScale(e);
13142
- if (pointType === 'skew')
13262
+ if (skewing)
13143
13263
  transformTool.onSkew(e);
13144
- updateCursor(this, e);
13264
+ updatePointCursor(this, e);
13265
+ }
13266
+ }
13267
+ resetDoing() {
13268
+ if (this.canUse)
13269
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
13270
+ }
13271
+ onMove(e) {
13272
+ if (this.canGesture && e.moveType !== 'drag') {
13273
+ e.stop();
13274
+ if (typeof this.mergeConfig.moveable === 'string') {
13275
+ this.gesturing = this.moving = true;
13276
+ this.transformTool.onMove(e);
13277
+ }
13278
+ }
13279
+ }
13280
+ onScale(e) {
13281
+ if (this.canGesture) {
13282
+ e.stop();
13283
+ if (typeof this.mergeConfig.resizeable === 'string') {
13284
+ this.gesturing = this.resizing = true;
13285
+ this.transformTool.onScale(e);
13286
+ }
13287
+ }
13288
+ }
13289
+ onRotate(e) {
13290
+ if (this.canGesture) {
13291
+ e.stop();
13292
+ if (typeof this.mergeConfig.rotateable === 'string') {
13293
+ this.gesturing = this.rotating = true;
13294
+ this.transformTool.onRotate(e);
13295
+ }
13145
13296
  }
13146
13297
  }
13147
13298
  onKey(e) {
13148
- updateCursor(this, e);
13299
+ updatePointCursor(this, e);
13149
13300
  }
13150
13301
  onArrow(e) {
13151
- const { editor } = this;
13152
- if (editor.editing && this.mergeConfig.keyEvent) {
13302
+ const { editor, transformTool } = this;
13303
+ if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
13153
13304
  let x = 0, y = 0;
13154
13305
  const distance = e.shiftKey ? 10 : 1;
13155
13306
  switch (e.code) {
@@ -13166,7 +13317,7 @@ class EditBox extends Group {
13166
13317
  x = distance;
13167
13318
  }
13168
13319
  if (x || y)
13169
- editor.move(x, y);
13320
+ transformTool.move(x, y);
13170
13321
  }
13171
13322
  }
13172
13323
  onDoubleTap(e) {
@@ -13209,12 +13360,12 @@ class EditBox extends Group {
13209
13360
  [PointerEvent.LEAVE, () => { this.enterPoint = null; }],
13210
13361
  ];
13211
13362
  if (point.name !== 'circle')
13212
- events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(this, e); }]);
13363
+ events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updatePointCursor(this, e); }]);
13213
13364
  this.__eventIds.push(point.on_(events));
13214
13365
  }
13215
13366
  __listenEvents() {
13216
13367
  const { rect, editor, __eventIds: events } = this;
13217
- events.push(editor.on_(EditorEvent.SELECT, this.onSelect, this), rect.on_([
13368
+ events.push(rect.on_([
13218
13369
  [DragEvent.START, this.onDragStart, this],
13219
13370
  [DragEvent.DRAG, this.onDrag, this],
13220
13371
  [DragEvent.END, this.onDragEnd, this],
@@ -13225,7 +13376,13 @@ class EditBox extends Group {
13225
13376
  this.waitLeafer(() => {
13226
13377
  events.push(editor.app.on_([
13227
13378
  [[KeyEvent.HOLD, KeyEvent.UP], this.onKey, this],
13228
- [KeyEvent.DOWN, this.onArrow, this]
13379
+ [KeyEvent.DOWN, this.onArrow, this],
13380
+ [MoveEvent.BEFORE_MOVE, this.onMove, this, true],
13381
+ [ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
13382
+ [RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
13383
+ [MoveEvent.END, this.resetDoing, this],
13384
+ [ZoomEvent.END, this.resetDoing, this],
13385
+ [RotateEvent.END, this.resetDoing, this],
13229
13386
  ]));
13230
13387
  });
13231
13388
  }
@@ -13381,7 +13538,8 @@ function onTarget(editor, oldValue) {
13381
13538
  editor.simulateTarget.remove();
13382
13539
  editor.leafList.reset();
13383
13540
  }
13384
- editor.closeInnerEditor();
13541
+ editor.closeInnerEditor(true);
13542
+ editor.unloadEditTool();
13385
13543
  const data = { editor, value: target, oldValue };
13386
13544
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, data));
13387
13545
  editor.checkOpenedGroups();
@@ -13601,16 +13759,10 @@ EditorSkewEvent.SKEW = 'editor.skew';
13601
13759
 
13602
13760
  class TransformTool {
13603
13761
  onMove(e) {
13604
- const { target, mergeConfig, dragStartData } = this.editBox;
13762
+ const { target, dragStartData } = this.editBox;
13605
13763
  if (e instanceof MoveEvent) {
13606
- if (e.moveType !== 'drag') {
13607
- const { moveable, resizeable } = mergeConfig;
13608
- const move = e.getLocalMove(target);
13609
- if (moveable === 'move')
13610
- e.stop(), this.move(move.x, move.y);
13611
- else if (resizeable === 'zoom')
13612
- e.stop();
13613
- }
13764
+ const move = e.getLocalMove(target);
13765
+ this.move(move.x, move.y);
13614
13766
  }
13615
13767
  else {
13616
13768
  const total = { x: e.totalX, y: e.totalY };
@@ -13625,10 +13777,9 @@ class TransformTool {
13625
13777
  }
13626
13778
  onScale(e) {
13627
13779
  const { target, mergeConfig, single, dragStartData } = this.editBox;
13628
- let { around, lockRatio, resizeable, flipable, editSize } = mergeConfig;
13780
+ let { around, lockRatio, flipable, editSize } = mergeConfig;
13629
13781
  if (e instanceof ZoomEvent) {
13630
- if (resizeable === 'zoom')
13631
- e.stop(), this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
13782
+ this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
13632
13783
  }
13633
13784
  else {
13634
13785
  const { direction } = e.current;
@@ -13646,28 +13797,18 @@ class TransformTool {
13646
13797
  }
13647
13798
  onRotate(e) {
13648
13799
  const { target, mergeConfig, dragStartData } = this.editBox;
13649
- const { skewable, rotateable, around, rotateGap } = mergeConfig;
13650
- const { direction, name } = e.current;
13651
- if (skewable && name === 'resize-line')
13652
- return this.onSkew(e);
13800
+ const { around, rotateAround, rotateGap } = mergeConfig;
13801
+ const { direction } = e.current;
13653
13802
  let origin, rotation;
13654
13803
  if (e instanceof RotateEvent) {
13655
- if (rotateable === 'rotate')
13656
- e.stop(), rotation = e.rotation, origin = target.getBoxPoint(e);
13657
- else
13658
- return;
13659
- if (target.scaleX * target.scaleY < 0)
13660
- rotation = -rotation;
13804
+ rotation = e.rotation;
13805
+ origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
13661
13806
  }
13662
13807
  else {
13663
- const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (target.around || target.origin || around || 'center'));
13664
- rotation = data.rotation;
13808
+ const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (rotateAround || target.around || target.origin || around || 'center'));
13809
+ rotation = dragStartData.rotation + data.rotation - target.rotation;
13665
13810
  origin = data.origin;
13666
13811
  }
13667
- if (target.scaleX * target.scaleY < 0)
13668
- rotation = -rotation;
13669
- if (e instanceof DragEvent)
13670
- rotation = dragStartData.rotation + rotation - target.rotation;
13671
13812
  rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
13672
13813
  if (!rotation)
13673
13814
  return;
@@ -13833,9 +13974,13 @@ let Editor = class Editor extends Group {
13833
13974
  get groupOpening() { return !!this.openedGroupList.length; }
13834
13975
  get multiple() { return this.list.length > 1; }
13835
13976
  get single() { return this.list.length === 1; }
13977
+ get dragPoint() { return this.editBox.dragPoint; }
13836
13978
  get dragging() { return this.editBox.dragging; }
13979
+ get gesturing() { return this.editBox.gesturing; }
13837
13980
  get moving() { return this.editBox.moving; }
13838
- get dragPoint() { return this.editBox.dragPoint; }
13981
+ get resizing() { return this.editBox.resizing; }
13982
+ get rotating() { return this.editBox.rotating; }
13983
+ get skewing() { return this.editBox.skewing; }
13839
13984
  get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
13840
13985
  get buttons() { return this.editBox.buttons; }
13841
13986
  constructor(userConfig, data) {
@@ -13892,19 +14037,22 @@ let Editor = class Editor extends Group {
13892
14037
  this.update();
13893
14038
  }
13894
14039
  updateEditTool() {
14040
+ this.unloadEditTool();
14041
+ if (this.editing) {
14042
+ const name = this.element.editOuter || 'EditTool';
14043
+ const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
14044
+ this.editBox.load();
14045
+ tool.load();
14046
+ this.update();
14047
+ }
14048
+ }
14049
+ unloadEditTool() {
13895
14050
  let tool = this.editTool;
13896
14051
  if (tool) {
13897
14052
  this.editBox.unload();
13898
14053
  tool.unload();
13899
14054
  this.editTool = null;
13900
14055
  }
13901
- if (this.editing) {
13902
- const tag = this.element.editOuter || 'EditTool';
13903
- tool = this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
13904
- this.editBox.load();
13905
- tool.load();
13906
- this.update();
13907
- }
13908
14056
  }
13909
14057
  getEditSize(_ui) {
13910
14058
  return this.mergeConfig.editSize;
@@ -13978,16 +14126,21 @@ let Editor = class Editor extends Group {
13978
14126
  if (group)
13979
14127
  group.emitEvent(event);
13980
14128
  }
13981
- openInnerEditor(target, select) {
14129
+ openInnerEditor(target, nameOrSelect, select) {
14130
+ let name;
14131
+ if (typeof nameOrSelect === 'string')
14132
+ name = nameOrSelect;
14133
+ else if (!select)
14134
+ select = nameOrSelect;
13982
14135
  if (target && select)
13983
14136
  this.target = target;
13984
14137
  if (this.single) {
13985
14138
  const editTarget = target || this.element;
13986
- const tag = editTarget.editInner;
13987
- if (tag && EditToolCreator.list[tag]) {
14139
+ name || (name = editTarget.editInner);
14140
+ if (name && EditToolCreator.list[name]) {
13988
14141
  this.editTool.unload();
13989
14142
  this.innerEditing = true;
13990
- this.innerEditor = this.editToolList[tag] || EditToolCreator.get(tag, this);
14143
+ this.innerEditor = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
13991
14144
  this.innerEditor.editTarget = editTarget;
13992
14145
  this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
13993
14146
  this.innerEditor.load();
@@ -13995,13 +14148,14 @@ let Editor = class Editor extends Group {
13995
14148
  }
13996
14149
  }
13997
14150
  }
13998
- closeInnerEditor() {
14151
+ closeInnerEditor(onlyInnerEditor) {
13999
14152
  if (this.innerEditing) {
14000
14153
  this.innerEditing = false;
14001
14154
  this.emitInnerEvent(InnerEditorEvent.BEFORE_CLOSE);
14002
14155
  this.innerEditor.unload();
14003
14156
  this.emitInnerEvent(InnerEditorEvent.CLOSE);
14004
- this.editTool.load();
14157
+ if (!onlyInnerEditor)
14158
+ this.updateEditTool();
14005
14159
  this.innerEditor = null;
14006
14160
  }
14007
14161
  }
@@ -14044,12 +14198,7 @@ let Editor = class Editor extends Group {
14044
14198
  const { app, leafer, editMask } = this;
14045
14199
  this.targetEventIds = [
14046
14200
  leafer.on_(RenderEvent.START, this.onRenderStart, this),
14047
- app.on_([
14048
- [RenderEvent.CHILD_START, this.onAppRenderStart, this],
14049
- [MoveEvent.BEFORE_MOVE, this.onMove, this, true],
14050
- [ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
14051
- [RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
14052
- ])
14201
+ app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this)
14053
14202
  ];
14054
14203
  if (editMask.visible)
14055
14204
  editMask.forceRender();
@@ -14537,7 +14686,7 @@ Creator.editor = function (options, app) {
14537
14686
  };
14538
14687
  Box.addAttr('textBox', false, dataType);
14539
14688
  UI.addAttr('editConfig', undefined, dataType);
14540
- UI.addAttr('editOuter', (ui) => ui.__.__isLinePath ? 'LineEditTool' : 'EditTool', dataType);
14689
+ UI.addAttr('editOuter', (ui) => { ui.updateLayout(); return ui.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }, dataType);
14541
14690
  UI.addAttr('editInner', 'PathEditor', dataType);
14542
14691
  Group.addAttr('editInner', '', dataType);
14543
14692
  Text.addAttr('editInner', 'TextEditor', dataType);
@@ -15898,9 +16047,8 @@ box.__updateContentBounds = function () {
15898
16047
  }
15899
16048
  };
15900
16049
  box.__updateBoxBounds = function (secondLayout) {
15901
- const data = this.__;
15902
16050
  if (this.children.length && !this.pathInputed) {
15903
- const { flow } = data;
16051
+ const data = this.__, { flow } = data;
15904
16052
  if (data.__autoSide) {
15905
16053
  if (data.__hasSurface)
15906
16054
  this.__extraUpdate();
@@ -16132,6 +16280,11 @@ let Animate = class Animate extends Eventer {
16132
16280
  this.play();
16133
16281
  }, 0);
16134
16282
  }
16283
+ emitType(type) {
16284
+ this.emit(type, this);
16285
+ if (this.parent)
16286
+ this.parent.onChildEvent(type, this);
16287
+ }
16135
16288
  play() {
16136
16289
  if (this.destroyed)
16137
16290
  return;
@@ -16140,20 +16293,20 @@ let Animate = class Animate extends Eventer {
16140
16293
  this.clearTimer(), this.start();
16141
16294
  else if (!this.timer)
16142
16295
  this.requestAnimate();
16143
- this.emit(AnimateEvent.PLAY, this);
16296
+ this.emitType(AnimateEvent.PLAY);
16144
16297
  }
16145
16298
  pause() {
16146
16299
  if (this.destroyed)
16147
16300
  return;
16148
16301
  this.running = false;
16149
16302
  this.clearTimer();
16150
- this.emit(AnimateEvent.PAUSE, this);
16303
+ this.emitType(AnimateEvent.PAUSE);
16151
16304
  }
16152
16305
  stop() {
16153
16306
  if (this.destroyed)
16154
16307
  return;
16155
16308
  this.complete();
16156
- this.emit(AnimateEvent.STOP, this);
16309
+ this.emitType(AnimateEvent.STOP);
16157
16310
  }
16158
16311
  seek(time) {
16159
16312
  if (this.destroyed)
@@ -16167,7 +16320,7 @@ let Animate = class Animate extends Eventer {
16167
16320
  this.time = time;
16168
16321
  this.animate(0, true);
16169
16322
  this.clearTimer(() => this.requestAnimate());
16170
- this.emit(AnimateEvent.SEEK, this);
16323
+ this.emitType(AnimateEvent.SEEK);
16171
16324
  }
16172
16325
  kill(complete = true, killStyle) {
16173
16326
  this.killStyle = killStyle;
@@ -16234,7 +16387,7 @@ let Animate = class Animate extends Eventer {
16234
16387
  if (totalTime)
16235
16388
  this.changeDuration(totalTime);
16236
16389
  }
16237
- this.emit(AnimateEvent.CREATED, this);
16390
+ this.emitType(AnimateEvent.CREATED);
16238
16391
  }
16239
16392
  changeDuration(duration) {
16240
16393
  const { config } = this;
@@ -16354,7 +16507,7 @@ let Animate = class Animate extends Eventer {
16354
16507
  key in killStyle || (style[key] = endingStyle[key]);
16355
16508
  this.setStyle(style);
16356
16509
  this.clearTimer();
16357
- this.emit(AnimateEvent.COMPLETED, this);
16510
+ this.emitType(AnimateEvent.COMPLETED);
16358
16511
  }
16359
16512
  setFrom() {
16360
16513
  this.nowIndex = 0;
@@ -16398,7 +16551,7 @@ let Animate = class Animate extends Eventer {
16398
16551
  Transition.setBetweenStyle(betweenStyle, fromStyle, toStyle, style, t, target, attrsMap);
16399
16552
  this.setStyle(betweenStyle);
16400
16553
  }
16401
- this.emit(AnimateEvent.UPDATE, this);
16554
+ this.emitType(AnimateEvent.UPDATE);
16402
16555
  }
16403
16556
  setStyle(style) {
16404
16557
  const { target } = this;
@@ -16442,7 +16595,7 @@ let Animate = class Animate extends Eventer {
16442
16595
  this.stop();
16443
16596
  else
16444
16597
  this.pause();
16445
- this.target = this.config = this.frames = this.fromStyle = this.toStyle = this.style = this.killStyle = null;
16598
+ this.target = this.parent = this.config = this.frames = this.fromStyle = this.toStyle = this.style = this.killStyle = null;
16446
16599
  this.destroyed = true;
16447
16600
  }
16448
16601
  }
@@ -16508,6 +16661,7 @@ let AnimateList = class AnimateList extends Animate {
16508
16661
  });
16509
16662
  this.list = animation.map(item => {
16510
16663
  const animate = item.target ? item : new Animate(this.target, item, isTemp);
16664
+ animate.parent = this;
16511
16665
  Object.assign(this.fromStyle, animate.fromStyle);
16512
16666
  Object.assign(this.toStyle, animate.toStyle);
16513
16667
  Object.assign(this._endingStyle, animate.endingStyle);
@@ -16516,20 +16670,34 @@ let AnimateList = class AnimateList extends Animate {
16516
16670
  }
16517
16671
  play() {
16518
16672
  this.each(item => item.play());
16673
+ this.emitType(AnimateEvent.PLAY);
16519
16674
  }
16520
16675
  pause() {
16521
16676
  this.each(item => item.pause());
16677
+ this.emitType(AnimateEvent.PAUSE);
16522
16678
  }
16523
16679
  stop() {
16524
16680
  this.each(item => item.stop());
16681
+ this.emitType(AnimateEvent.STOP);
16525
16682
  }
16526
16683
  seek(time) {
16527
16684
  this.each(item => item.seek(time));
16685
+ this.emitType(AnimateEvent.SEEK);
16528
16686
  }
16529
16687
  kill(complete, killStyle) {
16530
16688
  this.each(item => item.kill(complete, killStyle));
16531
16689
  this.destroy();
16532
16690
  }
16691
+ onChildEvent(type, _animate) {
16692
+ switch (type) {
16693
+ case AnimateEvent.COMPLETED:
16694
+ if (this.completed)
16695
+ this.emitType(type);
16696
+ break;
16697
+ case AnimateEvent.UPDATE:
16698
+ this.emitType(type);
16699
+ }
16700
+ }
16533
16701
  each(func) {
16534
16702
  this.list.forEach(func);
16535
16703
  }
@@ -17988,123 +18156,131 @@ function getTrimBounds(canvas) {
17988
18156
  index++;
17989
18157
  }
17990
18158
  const bounds = new Bounds();
17991
- toBounds(pointBounds, bounds);
17992
- return bounds.scale(1 / canvas.pixelRatio).ceil();
18159
+ if (pointBounds) {
18160
+ toBounds(pointBounds, bounds);
18161
+ bounds.scale(1 / canvas.pixelRatio).ceil();
18162
+ }
18163
+ return bounds;
17993
18164
  }
17994
18165
 
17995
18166
  const ExportModule = {
17996
18167
  syncExport(leaf, filename, options) {
17997
- this.running = true;
18168
+ Export.running = true;
17998
18169
  let result;
17999
- const fileType = FileHelper.fileType(filename);
18000
- const isDownload = filename.includes('.');
18001
- options = FileHelper.getExportOptions(options);
18002
- const { toURL } = Platform;
18003
- const { download } = Platform.origin;
18004
- if (fileType === 'json') {
18005
- isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
18006
- result = { data: isDownload ? true : leaf.toJSON(options.json) };
18007
- }
18008
- else if (fileType === 'svg') {
18009
- isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
18010
- result = { data: isDownload ? true : leaf.toSVG() };
18011
- }
18012
- else {
18013
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
18014
- const { worldTransform, isLeafer, leafer, isFrame } = leaf;
18015
- const { slice, clip, trim, screenshot, padding, onCanvas } = options;
18016
- const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
18017
- const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
18018
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
18019
- const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
18020
- if (screenshot) {
18021
- renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
18170
+ try {
18171
+ const fileType = FileHelper.fileType(filename);
18172
+ const isDownload = filename.includes('.');
18173
+ options = FileHelper.getExportOptions(options);
18174
+ const { toURL } = Platform;
18175
+ const { download } = Platform.origin;
18176
+ if (fileType === 'json') {
18177
+ isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
18178
+ result = { data: isDownload ? true : leaf.toJSON(options.json) };
18179
+ }
18180
+ else if (fileType === 'svg') {
18181
+ isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
18182
+ result = { data: isDownload ? true : leaf.toSVG() };
18022
18183
  }
18023
18184
  else {
18024
- let relative = options.relative || (isLeafer ? 'inner' : 'local');
18025
- scaleX = worldTransform.scaleX;
18026
- scaleY = worldTransform.scaleY;
18027
- switch (relative) {
18028
- case 'inner':
18029
- matrix.set(worldTransform);
18030
- break;
18031
- case 'local':
18032
- matrix.set(worldTransform).divide(leaf.localTransform);
18033
- scaleX /= leaf.scaleX;
18034
- scaleY /= leaf.scaleY;
18035
- break;
18036
- case 'world':
18037
- scaleX = 1;
18038
- scaleY = 1;
18039
- break;
18040
- case 'page':
18041
- relative = leafer || leaf;
18042
- default:
18043
- matrix.set(worldTransform).divide(leaf.getTransform(relative));
18044
- const l = relative.worldTransform;
18045
- scaleX /= scaleX / l.scaleX;
18046
- scaleY /= scaleY / l.scaleY;
18185
+ let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
18186
+ const { worldTransform, isLeafer, leafer, isFrame } = leaf;
18187
+ const { slice, clip, trim, screenshot, padding, onCanvas } = options;
18188
+ const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
18189
+ const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
18190
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
18191
+ const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
18192
+ if (screenshot) {
18193
+ renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
18047
18194
  }
18048
- renderBounds = leaf.getBounds('render', relative);
18049
- }
18050
- const scaleData = { scaleX: 1, scaleY: 1 };
18051
- MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
18052
- let pixelRatio = options.pixelRatio || 1;
18053
- let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
18054
- if (clip)
18055
- x += clip.x, y += clip.y, width = clip.width, height = clip.height;
18056
- const renderOptions = { exporting: true, matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
18057
- let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
18058
- let sliceLeaf;
18059
- if (slice) {
18060
- sliceLeaf = leaf;
18061
- sliceLeaf.__worldOpacity = 0;
18062
- leaf = leafer || leaf;
18063
- renderOptions.bounds = canvas.bounds;
18064
- }
18065
- canvas.save();
18066
- if (isFrame && fill !== undefined) {
18067
- const oldFill = leaf.get('fill');
18068
- leaf.fill = '';
18069
- leaf.__render(canvas, renderOptions);
18070
- leaf.fill = oldFill;
18071
- }
18072
- else {
18073
- leaf.__render(canvas, renderOptions);
18074
- }
18075
- canvas.restore();
18076
- if (sliceLeaf)
18077
- sliceLeaf.__updateWorldOpacity();
18078
- if (trim) {
18079
- trimBounds = getTrimBounds(canvas);
18080
- const old = canvas, { width, height } = trimBounds;
18081
- const config = { x: 0, y: 0, width, height, pixelRatio };
18082
- canvas = Creator.canvas(config);
18083
- canvas.copyWorld(old, trimBounds, config);
18195
+ else {
18196
+ let relative = options.relative || (isLeafer ? 'inner' : 'local');
18197
+ scaleX = worldTransform.scaleX;
18198
+ scaleY = worldTransform.scaleY;
18199
+ switch (relative) {
18200
+ case 'inner':
18201
+ matrix.set(worldTransform);
18202
+ break;
18203
+ case 'local':
18204
+ matrix.set(worldTransform).divide(leaf.localTransform);
18205
+ scaleX /= leaf.scaleX;
18206
+ scaleY /= leaf.scaleY;
18207
+ break;
18208
+ case 'world':
18209
+ scaleX = 1;
18210
+ scaleY = 1;
18211
+ break;
18212
+ case 'page':
18213
+ relative = leafer || leaf;
18214
+ default:
18215
+ matrix.set(worldTransform).divide(leaf.getTransform(relative));
18216
+ const l = relative.worldTransform;
18217
+ scaleX /= scaleX / l.scaleX;
18218
+ scaleY /= scaleY / l.scaleY;
18219
+ }
18220
+ renderBounds = leaf.getBounds('render', relative);
18221
+ }
18222
+ const scaleData = { scaleX: 1, scaleY: 1 };
18223
+ MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
18224
+ let pixelRatio = options.pixelRatio || 1;
18225
+ let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
18226
+ if (clip)
18227
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
18228
+ const renderOptions = { exporting: true, matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
18229
+ let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
18230
+ let sliceLeaf;
18231
+ if (slice) {
18232
+ sliceLeaf = leaf;
18233
+ sliceLeaf.__worldOpacity = 0;
18234
+ leaf = leafer || leaf;
18235
+ renderOptions.bounds = canvas.bounds;
18236
+ }
18237
+ canvas.save();
18238
+ if (isFrame && fill !== undefined) {
18239
+ const oldFill = leaf.get('fill');
18240
+ leaf.fill = '';
18241
+ leaf.__render(canvas, renderOptions);
18242
+ leaf.fill = oldFill;
18243
+ }
18244
+ else {
18245
+ leaf.__render(canvas, renderOptions);
18246
+ }
18247
+ canvas.restore();
18248
+ if (sliceLeaf)
18249
+ sliceLeaf.__updateWorldOpacity();
18250
+ if (trim) {
18251
+ trimBounds = getTrimBounds(canvas);
18252
+ const old = canvas, { width, height } = trimBounds;
18253
+ const config = { x: 0, y: 0, width, height, pixelRatio };
18254
+ canvas = Creator.canvas(config);
18255
+ canvas.copyWorld(old, trimBounds, config);
18256
+ }
18257
+ if (padding) {
18258
+ const [top, right, bottom, left] = MathHelper.fourNumber(padding);
18259
+ const old = canvas, { width, height } = old;
18260
+ canvas = Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
18261
+ canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
18262
+ }
18263
+ if (needFill)
18264
+ canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
18265
+ if (onCanvas)
18266
+ onCanvas(canvas);
18267
+ const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
18268
+ result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
18084
18269
  }
18085
- if (padding) {
18086
- const [top, right, bottom, left] = MathHelper.fourNumber(padding);
18087
- const old = canvas, { width, height } = old;
18088
- canvas = Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
18089
- canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
18090
- }
18091
- if (needFill)
18092
- canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
18093
- if (onCanvas)
18094
- onCanvas(canvas);
18095
- const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
18096
- result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
18097
18270
  }
18098
- this.running = false;
18271
+ catch (error) {
18272
+ result = { data: '', error };
18273
+ }
18274
+ Export.running = false;
18099
18275
  return result;
18100
18276
  },
18101
18277
  export(leaf, filename, options) {
18102
- this.running = true;
18278
+ Export.running = true;
18103
18279
  return addTask((success) => new Promise((resolve) => {
18104
18280
  const getResult = () => __awaiter(this, void 0, void 0, function* () {
18105
18281
  if (!Resource.isComplete)
18106
18282
  return Platform.requestRender(getResult);
18107
- const result = ExportModule.syncExport(leaf, filename, options);
18283
+ const result = Export.syncExport(leaf, filename, options);
18108
18284
  if (result.data instanceof Promise)
18109
18285
  result.data = yield result.data;
18110
18286
  success(result);
@@ -18204,4 +18380,4 @@ Object.assign(Filter, {
18204
18380
  }
18205
18381
  });
18206
18382
 
18207
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
18383
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, Frame, FrameData, Group, GroupData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, motionPathType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix$1 as tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };