@leafer/worker 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 true; }
@@ -7096,6 +7136,11 @@ function zoomLayerType() {
7096
7136
  });
7097
7137
  };
7098
7138
  }
7139
+ function createAttr(defaultValue) {
7140
+ return (target, key) => {
7141
+ defineKey(target, key, createDescriptor(key, defaultValue));
7142
+ };
7143
+ }
7099
7144
 
7100
7145
  function hasTransparent$3(color) {
7101
7146
  if (!color || color.length === 7 || color.length === 4)
@@ -7153,22 +7198,9 @@ const emptyPaint = {};
7153
7198
  const debug$5 = Debug.get('UIData');
7154
7199
  class UIData extends LeafData {
7155
7200
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
7156
- get __strokeWidth() {
7157
- const { strokeWidth, strokeWidthFixed } = this;
7158
- if (strokeWidthFixed) {
7159
- const ui = this.__leaf;
7160
- let { scaleX } = ui.__nowWorld || ui.__world;
7161
- if (scaleX < 0)
7162
- scaleX = -scaleX;
7163
- return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
7164
- }
7165
- else
7166
- return strokeWidth;
7167
- }
7168
- get __hasMultiPaint() {
7169
- const t = this;
7170
- return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
7171
- }
7201
+ get __strokeWidth() { return this.__getRealStrokeWidth(); }
7202
+ get __maxStrokeWidth() { const t = this; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth; }
7203
+ get __hasMultiPaint() { const t = this; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect; }
7172
7204
  get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7173
7205
  get __hasSurface() { const t = this; return (t.fill || t.stroke); }
7174
7206
  get __autoWidth() { return !this._width; }
@@ -7250,6 +7282,21 @@ class UIData extends LeafData {
7250
7282
  Paint.compute('stroke', this.__leaf);
7251
7283
  this.__needComputePaint = undefined;
7252
7284
  }
7285
+ __getRealStrokeWidth(childStyle) {
7286
+ let { strokeWidth, strokeWidthFixed } = this;
7287
+ if (childStyle) {
7288
+ if (childStyle.strokeWidth)
7289
+ strokeWidth = childStyle.strokeWidth;
7290
+ if (childStyle.strokeWidthFixed !== undefined)
7291
+ strokeWidthFixed = childStyle.strokeWidthFixed;
7292
+ }
7293
+ if (strokeWidthFixed) {
7294
+ const scale = this.__leaf.getClampRenderScale();
7295
+ return scale > 1 ? strokeWidth / scale : strokeWidth;
7296
+ }
7297
+ else
7298
+ return strokeWidth;
7299
+ }
7253
7300
  __setPaint(attrName, value) {
7254
7301
  this.__setInput(attrName, value);
7255
7302
  const layout = this.__leaf.__layout;
@@ -7274,6 +7321,7 @@ class UIData extends LeafData {
7274
7321
  }
7275
7322
  else {
7276
7323
  stintSet$2(this, '__isAlphaPixelStroke', undefined);
7324
+ stintSet$2(this, '__hasMultiStrokeStyle', undefined);
7277
7325
  this._stroke = this.__isStrokes = undefined;
7278
7326
  }
7279
7327
  }
@@ -7295,8 +7343,8 @@ class GroupData extends UIData {
7295
7343
 
7296
7344
  class BoxData extends GroupData {
7297
7345
  get __boxStroke() { return !this.__pathInputed; }
7298
- get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7299
- get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7346
+ get __drawAfterFill() { const t = this; return t.__single || t.__clipAfterFill; }
7347
+ get __clipAfterFill() { const t = this; return t.overflow === 'hide' && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill); }
7300
7348
  }
7301
7349
 
7302
7350
  class LeaferData extends GroupData {
@@ -7416,7 +7464,7 @@ class CanvasData extends RectData {
7416
7464
  const UIBounds = {
7417
7465
  __updateStrokeSpread() {
7418
7466
  let width = 0, boxWidth = 0;
7419
- const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
7467
+ const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
7420
7468
  if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
7421
7469
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
7422
7470
  if (!data.__boxStroke) {
@@ -7436,13 +7484,15 @@ const UIBounds = {
7436
7484
  },
7437
7485
  __updateRenderSpread() {
7438
7486
  let width = 0;
7439
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7487
+ const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
7440
7488
  if (shadow)
7441
7489
  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));
7442
7490
  if (blur)
7443
7491
  width = Math.max(width, blur);
7444
7492
  if (filter)
7445
7493
  width += Filter.getSpread(filter);
7494
+ if (renderSpread)
7495
+ width += renderSpread;
7446
7496
  let shapeWidth = width = Math.ceil(width);
7447
7497
  if (innerShadow)
7448
7498
  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));
@@ -7465,7 +7515,7 @@ const UIRender = {
7465
7515
  }
7466
7516
  if (data.__useEffect) {
7467
7517
  const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7468
- 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')));
7518
+ 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')));
7469
7519
  data.__useEffect = !!(shadow || otherEffect);
7470
7520
  }
7471
7521
  data.__checkSingle();
@@ -7572,17 +7622,17 @@ const RectRender = {
7572
7622
  if (__drawAfterFill)
7573
7623
  this.__drawAfterFill(canvas, options);
7574
7624
  if (stroke) {
7575
- const { strokeAlign, __strokeWidth } = this.__;
7576
- if (!__strokeWidth)
7625
+ const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
7626
+ if (!strokeWidth)
7577
7627
  return;
7578
- canvas.setStroke(stroke, __strokeWidth, this.__);
7579
- const half = __strokeWidth / 2;
7628
+ canvas.setStroke(stroke, strokeWidth, this.__);
7629
+ const half = strokeWidth / 2;
7580
7630
  switch (strokeAlign) {
7581
7631
  case 'center':
7582
7632
  canvas.strokeRect(0, 0, width, height);
7583
7633
  break;
7584
7634
  case 'inside':
7585
- width -= __strokeWidth, height -= __strokeWidth;
7635
+ width -= strokeWidth, height -= strokeWidth;
7586
7636
  if (width < 0 || height < 0) {
7587
7637
  canvas.save();
7588
7638
  this.__clip(canvas, options);
@@ -7593,7 +7643,7 @@ const RectRender = {
7593
7643
  canvas.strokeRect(x + half, y + half, width, height);
7594
7644
  break;
7595
7645
  case 'outside':
7596
- canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
7646
+ canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
7597
7647
  break;
7598
7648
  }
7599
7649
  }
@@ -7606,6 +7656,8 @@ let UI = UI_1 = class UI extends Leaf {
7606
7656
  get isFrame() { return false; }
7607
7657
  set scale(value) { MathHelper.assignScale(this, value); }
7608
7658
  get scale() { return this.__.scale; }
7659
+ get isAutoWidth() { const t = this.__; return t.__autoWidth || t.autoWidth; }
7660
+ get isAutoHeight() { const t = this.__; return t.__autoHeight || t.autoHeight; }
7609
7661
  get pen() {
7610
7662
  const { path } = this.__;
7611
7663
  pen.set(this.path = path || []);
@@ -7820,6 +7872,9 @@ __decorate([
7820
7872
  __decorate([
7821
7873
  naturalBoundsType(1)
7822
7874
  ], UI.prototype, "pixelRatio", void 0);
7875
+ __decorate([
7876
+ affectRenderBoundsType(0)
7877
+ ], UI.prototype, "renderSpread", void 0);
7823
7878
  __decorate([
7824
7879
  pathInputType()
7825
7880
  ], UI.prototype, "path", void 0);
@@ -7976,7 +8031,8 @@ let Group = class Group extends UI {
7976
8031
  }
7977
8032
  toJSON(options) {
7978
8033
  const data = super.toJSON(options);
7979
- data.children = this.children.map(child => child.toJSON(options));
8034
+ if (!this.childlessJSON)
8035
+ data.children = this.children.map(child => child.toJSON(options));
7980
8036
  return data;
7981
8037
  }
7982
8038
  pick(_hitPoint, _options) { return undefined; }
@@ -8423,8 +8479,8 @@ let Box = class Box extends Group {
8423
8479
  __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
8424
8480
  __updateRectBoxBounds() { }
8425
8481
  __updateBoxBounds(_secondLayout) {
8426
- const data = this.__;
8427
8482
  if (this.children.length && !this.pathInputed) {
8483
+ const data = this.__;
8428
8484
  if (data.__autoSide) {
8429
8485
  if (data.__hasSurface)
8430
8486
  this.__extraUpdate();
@@ -8451,20 +8507,26 @@ let Box = class Box extends Group {
8451
8507
  __updateStrokeBounds() { }
8452
8508
  __updateRenderBounds() {
8453
8509
  let isOverflow;
8454
- const { renderBounds } = this.__layout;
8455
8510
  if (this.children.length) {
8511
+ const data = this.__, { renderBounds, boxBounds } = this.__layout;
8456
8512
  super.__updateRenderBounds();
8457
8513
  copy$6(childrenRenderBounds, renderBounds);
8458
8514
  this.__updateRectRenderBounds();
8459
- isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8460
- if (isOverflow && this.__.overflow !== 'hide')
8515
+ if (data.scrollY || data.scrollX) {
8516
+ childrenRenderBounds.x += data.scrollX;
8517
+ childrenRenderBounds.y += data.scrollY;
8518
+ }
8519
+ isOverflow = !includes$1(boxBounds, childrenRenderBounds);
8520
+ if (isOverflow && data.overflow !== 'hide')
8461
8521
  add(renderBounds, childrenRenderBounds);
8462
8522
  }
8463
8523
  else
8464
8524
  this.__updateRectRenderBounds();
8465
8525
  DataHelper.stintSet(this, 'isOverflow', isOverflow);
8526
+ this.__updateScrollBar();
8466
8527
  }
8467
8528
  __updateRectRenderBounds() { }
8529
+ __updateScrollBar() { }
8468
8530
  __updateRectChange() { }
8469
8531
  __updateChange() {
8470
8532
  super.__updateChange();
@@ -8481,10 +8543,12 @@ let Box = class Box extends Group {
8481
8543
  if (this.children.length)
8482
8544
  this.__renderGroup(canvas, options);
8483
8545
  }
8546
+ if (this.scrollBar)
8547
+ this.scrollBar.__render(canvas, options);
8484
8548
  }
8485
8549
  __drawContent(canvas, options) {
8486
8550
  this.__renderGroup(canvas, options);
8487
- if (this.__.__useStroke) {
8551
+ if (this.__.__useStroke || this.__.__useEffect) {
8488
8552
  canvas.setWorld(this.__nowWorld);
8489
8553
  this.__drawRenderPath(canvas);
8490
8554
  }
@@ -10287,18 +10351,20 @@ leaf$1.__hitWorld = function (point) {
10287
10351
  }
10288
10352
  return this.__hit(inner);
10289
10353
  };
10290
- leaf$1.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
10291
- leaf$1.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
10292
- 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); };
10293
- leaf$1.__drawHitPath = function (canvas) { if (canvas)
10294
- this.__drawRenderPath(canvas); };
10354
+ leaf$1.__hitFill = function (inner) { const h = this.__hitCanvas; return h && h.hitFill(inner, this.__.windingRule); };
10355
+ leaf$1.__hitStroke = function (inner, strokeWidth) { const h = this.__hitCanvas; return h && h.hitStroke(inner, strokeWidth); };
10356
+ leaf$1.__hitPixel = function (inner) { const h = this.__hitCanvas; return h && h.hitPixel(inner, this.__layout.renderBounds, h.hitScale); };
10357
+ leaf$1.__drawHitPath = function (canvas) { canvas && this.__drawRenderPath(canvas); };
10295
10358
 
10296
10359
  const matrix$2 = new Matrix();
10297
10360
  const ui$5 = UI.prototype;
10298
10361
  ui$5.__updateHitCanvas = function () {
10299
10362
  if (this.__box)
10300
10363
  this.__box.__updateHitCanvas();
10301
- const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10364
+ const leafer = this.leafer || (this.parent && this.parent.leafer);
10365
+ if (!leafer)
10366
+ return;
10367
+ const data = this.__, { hitCanvasManager } = leafer;
10302
10368
  const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10303
10369
  const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10304
10370
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -10334,7 +10400,7 @@ ui$5.__hit = function (inner) {
10334
10400
  const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10335
10401
  if (needHitFillPath && this.__hitFill(inner))
10336
10402
  return true;
10337
- const { hitStroke, __strokeWidth } = data;
10403
+ const { hitStroke, __maxStrokeWidth: strokeWidth } = data;
10338
10404
  const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10339
10405
  if (!needHitFillPath && !needHitStrokePath)
10340
10406
  return false;
@@ -10343,16 +10409,16 @@ ui$5.__hit = function (inner) {
10343
10409
  if (needHitStrokePath) {
10344
10410
  switch (data.strokeAlign) {
10345
10411
  case 'inside':
10346
- hitWidth += __strokeWidth * 2;
10412
+ hitWidth += strokeWidth * 2;
10347
10413
  if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
10348
10414
  return true;
10349
10415
  hitWidth = radiusWidth;
10350
10416
  break;
10351
10417
  case 'center':
10352
- hitWidth += __strokeWidth;
10418
+ hitWidth += strokeWidth;
10353
10419
  break;
10354
10420
  case 'outside':
10355
- hitWidth += __strokeWidth * 2;
10421
+ hitWidth += strokeWidth * 2;
10356
10422
  if (!needHitFillPath) {
10357
10423
  if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
10358
10424
  return true;
@@ -10452,9 +10518,14 @@ function fills(fills, ui, canvas) {
10452
10518
  }
10453
10519
  }
10454
10520
  canvas.fillStyle = item.style;
10455
- if (item.transform) {
10521
+ if (item.transform || item.scaleFixed) {
10456
10522
  canvas.save();
10457
- canvas.transform(item.transform);
10523
+ if (item.transform)
10524
+ canvas.transform(item.transform);
10525
+ if (item.scaleFixed) {
10526
+ const { scaleX, scaleY } = ui.getRenderScaleData(true);
10527
+ canvas.scale(1 / scaleX, 1 / scaleY);
10528
+ }
10458
10529
  if (item.blendMode)
10459
10530
  canvas.blendMode = item.blendMode;
10460
10531
  fillPathOrText(ui, canvas);
@@ -10490,8 +10561,13 @@ function strokeText(stroke, ui, canvas) {
10490
10561
  }
10491
10562
  function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10492
10563
  const data = ui.__;
10493
- canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10494
- data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10564
+ if (typeof stroke === 'object') {
10565
+ drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
10566
+ }
10567
+ else {
10568
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10569
+ drawTextStroke(ui, canvas);
10570
+ }
10495
10571
  }
10496
10572
  function drawAlign(stroke, align, ui, canvas) {
10497
10573
  const out = canvas.getSameCanvas(true, true);
@@ -10500,15 +10576,9 @@ function drawAlign(stroke, align, ui, canvas) {
10500
10576
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10501
10577
  fillText(ui, out);
10502
10578
  out.blendMode = 'normal';
10503
- copyWorld(canvas, out, ui);
10579
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10504
10580
  out.recycle(ui.__nowWorld);
10505
10581
  }
10506
- function copyWorld(canvas, out, ui) {
10507
- if (ui.__worldFlipped || Platform.fullImageShadow)
10508
- canvas.copyWorldByReset(out, ui.__nowWorld);
10509
- else
10510
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10511
- }
10512
10582
  function drawTextStroke(ui, canvas) {
10513
10583
  let row, data = ui.__.__textDrawData;
10514
10584
  const { rows, decorationY } = data;
@@ -10524,14 +10594,21 @@ function drawTextStroke(ui, canvas) {
10524
10594
  rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
10525
10595
  }
10526
10596
  }
10527
- function drawStrokesStyle(strokes, isText, ui, canvas) {
10597
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
10528
10598
  let item;
10599
+ const data = ui.__, { __hasMultiStrokeStyle } = data;
10600
+ __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
10529
10601
  for (let i = 0, len = strokes.length; i < len; i++) {
10530
10602
  item = strokes[i];
10531
10603
  if (item.image && PaintImage.checkImage(ui, canvas, item, false))
10532
10604
  continue;
10533
10605
  if (item.style) {
10534
- canvas.strokeStyle = item.style;
10606
+ if (__hasMultiStrokeStyle) {
10607
+ const { strokeStyle } = item;
10608
+ strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
10609
+ }
10610
+ else
10611
+ canvas.strokeStyle = item.style;
10535
10612
  if (item.blendMode) {
10536
10613
  canvas.saveBlendMode(item.blendMode);
10537
10614
  isText ? drawTextStroke(ui, canvas) : canvas.stroke();
@@ -10570,8 +10647,13 @@ function strokes(strokes, ui, canvas) {
10570
10647
  }
10571
10648
  function drawCenter(stroke, strokeWidthScale, ui, canvas) {
10572
10649
  const data = ui.__;
10573
- canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
10574
- data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
10650
+ if (typeof stroke === 'object') {
10651
+ drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
10652
+ }
10653
+ else {
10654
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10655
+ canvas.stroke();
10656
+ }
10575
10657
  if (data.__useArrow)
10576
10658
  Paint.strokeArrow(stroke, ui, canvas);
10577
10659
  }
@@ -10593,7 +10675,7 @@ function drawOutside(stroke, ui, canvas) {
10593
10675
  drawCenter(stroke, 2, ui, out);
10594
10676
  out.clipUI(data);
10595
10677
  out.clearWorld(renderBounds);
10596
- copyWorld(canvas, out, ui);
10678
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10597
10679
  out.recycle(ui.__nowWorld);
10598
10680
  }
10599
10681
  }
@@ -10648,8 +10730,16 @@ function compute(attrName, ui) {
10648
10730
  if (!(paints instanceof Array))
10649
10731
  paints = [paints];
10650
10732
  recycleMap = PaintImage.recycleImage(attrName, data);
10733
+ let maxChildStrokeWidth;
10651
10734
  for (let i = 0, len = paints.length, item; i < len; i++) {
10652
- (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
10735
+ if (item = getLeafPaint(attrName, paints[i], ui)) {
10736
+ leafPaints.push(item);
10737
+ if (item.strokeStyle) {
10738
+ maxChildStrokeWidth || (maxChildStrokeWidth = 1);
10739
+ if (item.strokeStyle.strokeWidth)
10740
+ maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
10741
+ }
10742
+ }
10653
10743
  }
10654
10744
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10655
10745
  if (leafPaints.length) {
@@ -10666,6 +10756,7 @@ function compute(attrName, ui) {
10666
10756
  else {
10667
10757
  stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
10668
10758
  stintSet(data, '__isTransparentStroke', isTransparent);
10759
+ stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
10669
10760
  }
10670
10761
  }
10671
10762
  function getLeafPaint(attrName, paint, ui) {
@@ -10697,6 +10788,11 @@ function getLeafPaint(attrName, paint, ui) {
10697
10788
  if (data) {
10698
10789
  if (typeof data.style === 'string' && hasTransparent$1(data.style))
10699
10790
  data.isTransparent = true;
10791
+ if (paint.style) {
10792
+ if (paint.style.strokeWidth === 0)
10793
+ return undefined;
10794
+ data.strokeStyle = paint.style;
10795
+ }
10700
10796
  if (paint.blendMode)
10701
10797
  data.blendMode = paint.blendMode;
10702
10798
  }
@@ -10716,8 +10812,8 @@ const PaintModule = {
10716
10812
  shape
10717
10813
  };
10718
10814
 
10719
- let origin$1 = {};
10720
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
10815
+ let origin$1 = {}, tempMatrix = getMatrixData();
10816
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
10721
10817
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10722
10818
  const transform = get$3();
10723
10819
  translate$1(transform, box.x + x, box.y + y);
@@ -10726,7 +10822,7 @@ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10726
10822
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10727
10823
  data.transform = transform;
10728
10824
  }
10729
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
10825
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
10730
10826
  const transform = get$3();
10731
10827
  if (rotation)
10732
10828
  rotate$2(transform, rotation);
@@ -10735,6 +10831,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
10735
10831
  if (scaleX)
10736
10832
  scaleHelper(transform, scaleX, scaleY);
10737
10833
  translate$1(transform, box.x + x, box.y + y);
10834
+ if (clipSize) {
10835
+ tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
10836
+ multiplyParent(transform, tempMatrix);
10837
+ }
10738
10838
  data.transform = transform;
10739
10839
  }
10740
10840
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -10771,13 +10871,15 @@ const tempBox = new Bounds();
10771
10871
  const tempScaleData = {};
10772
10872
  const tempImage = {};
10773
10873
  function createData(leafPaint, image, paint, box) {
10774
- const { changeful, sync, editing } = paint;
10874
+ const { changeful, sync, editing, scaleFixed } = paint;
10775
10875
  if (changeful)
10776
10876
  leafPaint.changeful = changeful;
10777
10877
  if (sync)
10778
10878
  leafPaint.sync = sync;
10779
10879
  if (editing)
10780
10880
  leafPaint.editing = editing;
10881
+ if (scaleFixed)
10882
+ leafPaint.scaleFixed = scaleFixed;
10781
10883
  leafPaint.data = getPatternData(paint, box, image);
10782
10884
  }
10783
10885
  function getPatternData(paint, box, image) {
@@ -10786,7 +10888,7 @@ function getPatternData(paint, box, image) {
10786
10888
  if (paint.mode === 'strench')
10787
10889
  paint.mode = 'stretch';
10788
10890
  let { width, height } = image;
10789
- const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
10891
+ const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
10790
10892
  const sameBox = box.width === width && box.height === height;
10791
10893
  const data = { mode };
10792
10894
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -10820,8 +10922,8 @@ function getPatternData(paint, box, image) {
10820
10922
  break;
10821
10923
  case 'normal':
10822
10924
  case 'clip':
10823
- if (tempImage.x || tempImage.y || scaleX || rotation || skew)
10824
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
10925
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
10926
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
10825
10927
  break;
10826
10928
  case 'repeat':
10827
10929
  if (!sameBox || scaleX || rotation)
@@ -10958,18 +11060,16 @@ function ignoreRender(ui, value) {
10958
11060
  }
10959
11061
 
10960
11062
  const { get: get$1, scale: scale$2, copy: copy$4 } = MatrixHelper;
10961
- const { ceil: ceil$1, abs: abs$4 } = Math;
11063
+ const { ceil: ceil$1, abs: abs$3 } = Math;
10962
11064
  function createPattern(ui, paint, pixelRatio) {
10963
- let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11065
+ let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
10964
11066
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
10965
11067
  if (paint.patternId !== id && !ui.destroyed) {
10966
- scaleX = abs$4(scaleX);
10967
- scaleY = abs$4(scaleY);
10968
11068
  const { image, data } = paint;
10969
11069
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
10970
11070
  if (sx) {
10971
- sx = abs$4(sx);
10972
- sy = abs$4(sy);
11071
+ sx = abs$3(sx);
11072
+ sy = abs$3(sy);
10973
11073
  imageMatrix = get$1();
10974
11074
  copy$4(imageMatrix, transform);
10975
11075
  scale$2(imageMatrix, 1 / sx, 1 / sy);
@@ -11022,9 +11122,8 @@ function createPattern(ui, paint, pixelRatio) {
11022
11122
  }
11023
11123
  }
11024
11124
 
11025
- const { abs: abs$3 } = Math;
11026
11125
  function checkImage(ui, canvas, paint, allowDraw) {
11027
- const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11126
+ const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
11028
11127
  const { pixelRatio } = canvas, { data } = paint;
11029
11128
  if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
11030
11129
  return false;
@@ -11037,8 +11136,8 @@ function checkImage(ui, canvas, paint, allowDraw) {
11037
11136
  else {
11038
11137
  if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
11039
11138
  let { width, height } = data;
11040
- width *= abs$3(scaleX) * pixelRatio;
11041
- height *= abs$3(scaleY) * pixelRatio;
11139
+ width *= scaleX * pixelRatio;
11140
+ height *= scaleY * pixelRatio;
11042
11141
  if (data.scaleX) {
11043
11142
  width *= data.scaleX;
11044
11143
  height *= data.scaleY;
@@ -11048,6 +11147,10 @@ function checkImage(ui, canvas, paint, allowDraw) {
11048
11147
  }
11049
11148
  }
11050
11149
  if (allowDraw) {
11150
+ if (ui.__.__isFastShadow) {
11151
+ canvas.fillStyle = paint.style || '#000';
11152
+ canvas.fill();
11153
+ }
11051
11154
  drawImage(ui, canvas, paint, data);
11052
11155
  return true;
11053
11156
  }
@@ -11236,10 +11339,7 @@ function shadow$1(ui, current, shape) {
11236
11339
  }
11237
11340
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
11238
11341
  }
11239
- if (ui.__worldFlipped)
11240
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11241
- else
11242
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11342
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11243
11343
  if (end && index < end)
11244
11344
  other.clearWorld(copyBounds, true);
11245
11345
  });
@@ -11298,10 +11398,7 @@ function innerShadow(ui, current, shape) {
11298
11398
  copyBounds = bounds;
11299
11399
  }
11300
11400
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
11301
- if (ui.__worldFlipped)
11302
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11303
- else
11304
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11401
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11305
11402
  if (end && index < end)
11306
11403
  other.clearWorld(copyBounds, true);
11307
11404
  });
@@ -11357,12 +11454,11 @@ Group.prototype.__renderMask = function (canvas, options) {
11357
11454
  contentCanvas = getCanvas(canvas);
11358
11455
  child.__render(maskCanvas, options);
11359
11456
  }
11360
- if (!(mask === 'clipping' || mask === 'clipping-path'))
11361
- continue;
11362
- }
11363
- if (excludeRenderBounds(child, options))
11457
+ if (mask === 'clipping' || mask === 'clipping-path')
11458
+ excludeRenderBounds(child, options) || child.__render(canvas, options);
11364
11459
  continue;
11365
- child.__render(contentCanvas || canvas, options);
11460
+ }
11461
+ excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
11366
11462
  }
11367
11463
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
11368
11464
  };
@@ -11980,6 +12076,8 @@ function targetAttr(fn) {
11980
12076
  if (isSelect) {
11981
12077
  if (value instanceof Array && value.length > 1 && value[0].locked)
11982
12078
  value.splice(0, 1);
12079
+ if (this.single)
12080
+ this.element.syncEventer = null;
11983
12081
  const { beforeSelect } = this.config;
11984
12082
  if (beforeSelect) {
11985
12083
  const check = beforeSelect({ target: value });
@@ -12003,9 +12101,11 @@ function mergeConfigAttr() {
12003
12101
  return (target, key) => {
12004
12102
  defineKey(target, key, {
12005
12103
  get() {
12006
- const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
12104
+ const { config, element, dragPoint, editBox } = this, mergeConfig = Object.assign({}, config);
12007
12105
  if (element && element.editConfig)
12008
12106
  Object.assign(mergeConfig, element.editConfig);
12107
+ if (editBox.config)
12108
+ Object.assign(mergeConfig, editBox.config);
12009
12109
  if (dragPoint) {
12010
12110
  if (dragPoint.editConfig)
12011
12111
  Object.assign(mergeConfig, dragPoint.editConfig);
@@ -12037,14 +12137,17 @@ class Stroker extends UI {
12037
12137
  this.strokeAlign = 'center';
12038
12138
  }
12039
12139
  setTarget(target, style) {
12040
- this.set(style);
12140
+ if (style)
12141
+ this.set(style);
12041
12142
  this.target = target;
12042
12143
  this.update();
12043
12144
  }
12044
- update() {
12145
+ update(style) {
12045
12146
  const { list } = this;
12046
12147
  if (list.length) {
12047
12148
  setListWithFn(bounds$2, list, worldBounds);
12149
+ if (style)
12150
+ this.set(style);
12048
12151
  this.set(bounds$2);
12049
12152
  this.visible = true;
12050
12153
  }
@@ -12187,15 +12290,14 @@ class EditSelect extends Group {
12187
12290
  }
12188
12291
  onSelect() {
12189
12292
  if (this.running) {
12190
- const { mergeConfig, list } = this.editor;
12191
- const { stroke, strokeWidth, selectedStyle } = mergeConfig;
12192
- this.targetStroker.setTarget(list, Object.assign({ stroke, strokeWidth: Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
12293
+ this.targetStroker.setTarget(this.editor.list);
12193
12294
  this.hoverStroker.target = null;
12194
12295
  }
12195
12296
  }
12196
12297
  update() {
12197
12298
  this.hoverStroker.update();
12198
- this.targetStroker.update();
12299
+ const { stroke, strokeWidth, selectedStyle } = this.editor.mergedConfig;
12300
+ this.targetStroker.update(Object.assign({ stroke, strokeWidth: strokeWidth && Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
12199
12301
  }
12200
12302
  onPointerMove(e) {
12201
12303
  const { app, editor } = this;
@@ -12471,15 +12573,17 @@ const EditDataHelper = {
12471
12573
  toPoint(around || align, boxBounds, origin, true);
12472
12574
  if (dragBounds) {
12473
12575
  const allowBounds = dragBounds === 'parent' ? target.parent.boxBounds : dragBounds;
12474
- const localBounds = new Bounds(target.__localBoxBounds);
12475
- localBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
12476
- if (!BoundsHelper.includes(allowBounds, localBounds)) {
12477
- const realBounds = localBounds.getIntersect(allowBounds);
12478
- const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
12479
- if (useScaleX)
12480
- scaleX *= fitScaleX;
12481
- if (useScaleY)
12482
- scaleY *= fitScaleY;
12576
+ const childBounds = new Bounds(target.__localBoxBounds);
12577
+ if (BoundsHelper.includes(new Bounds(allowBounds).spread(0.1), childBounds)) {
12578
+ childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
12579
+ if (!BoundsHelper.includes(allowBounds, childBounds)) {
12580
+ const realBounds = childBounds.getIntersect(allowBounds);
12581
+ const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
12582
+ if (useScaleX)
12583
+ scaleX *= fitScaleX;
12584
+ if (useScaleY)
12585
+ scaleY *= fitScaleY;
12586
+ }
12483
12587
  }
12484
12588
  }
12485
12589
  if (useScaleX && widthRange) {
@@ -12614,9 +12718,9 @@ const EditDataHelper = {
12614
12718
  };
12615
12719
 
12616
12720
  const cacheCursors = {};
12617
- function updateCursor(editBox, e) {
12618
- const { enterPoint: point } = editBox;
12619
- if (!point || !editBox.editor.editing || !editBox.visible)
12721
+ function updatePointCursor(editBox, e) {
12722
+ const { enterPoint: point, dragging, skewing, resizing, flippedX, flippedY } = editBox;
12723
+ if (!point || !editBox.editor.editing || !editBox.canUse)
12620
12724
  return;
12621
12725
  if (point.name === 'circle')
12622
12726
  return;
@@ -12625,13 +12729,15 @@ function updateCursor(editBox, e) {
12625
12729
  point.cursor = 'pointer';
12626
12730
  return;
12627
12731
  }
12628
- let { rotation, flippedX, flippedY } = editBox;
12732
+ let { rotation } = editBox;
12629
12733
  const { pointType } = point, { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } = editBox.mergeConfig;
12630
12734
  let showResize = pointType.includes('resize');
12631
12735
  if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
12632
12736
  showResize = false;
12633
12737
  const showSkew = skewable && !showResize && (point.name === 'resize-line' || pointType === 'skew');
12634
- const cursor = showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor);
12738
+ const cursor = dragging
12739
+ ? (skewing ? skewCursor : (resizing ? resizeCursor : rotateCursor))
12740
+ : (showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor));
12635
12741
  rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
12636
12742
  rotation = Math.round(MathHelper.formatRotation(rotation, true) / 2) * 2;
12637
12743
  const { url, x, y } = cursor;
@@ -12645,7 +12751,8 @@ function updateCursor(editBox, e) {
12645
12751
  }
12646
12752
  function updateMoveCursor(editBox) {
12647
12753
  const { moveCursor, moveable } = editBox.mergeConfig;
12648
- editBox.rect.cursor = moveable ? moveCursor : undefined;
12754
+ if (editBox.canUse)
12755
+ editBox.rect.cursor = moveable ? moveCursor : undefined;
12649
12756
  }
12650
12757
  function toDataURL(svg, rotation) {
12651
12758
  return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
@@ -12661,8 +12768,8 @@ class EditPoint extends Box {
12661
12768
  const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
12662
12769
  class EditBox extends Group {
12663
12770
  get mergeConfig() {
12664
- const { config } = this, { mergeConfig } = this.editor;
12665
- return this.mergedConfig = config ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
12771
+ const { config } = this, { mergeConfig, editBox } = this.editor;
12772
+ return this.mergedConfig = config && (editBox !== this) ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
12666
12773
  }
12667
12774
  get target() { return this._target || this.editor.element; }
12668
12775
  set target(target) { this._target = target; }
@@ -12673,6 +12780,13 @@ class EditBox extends Group {
12673
12780
  get flippedX() { return this.scaleX < 0; }
12674
12781
  get flippedY() { return this.scaleY < 0; }
12675
12782
  get flippedOne() { return this.scaleX * this.scaleY < 0; }
12783
+ get canUse() { return (this.visible && this.view.visible); }
12784
+ get canGesture() {
12785
+ if (!this.canUse)
12786
+ return false;
12787
+ const { moveable, resizeable, rotateable } = this.mergeConfig;
12788
+ return typeof moveable === 'string' || typeof resizeable === 'string' || typeof rotateable === 'string';
12789
+ }
12676
12790
  constructor(editor) {
12677
12791
  super();
12678
12792
  this.view = new Group();
@@ -12719,8 +12833,7 @@ class EditBox extends Group {
12719
12833
  for (let i = 0; i < 8; i++) {
12720
12834
  resizeP = resizePoints[i];
12721
12835
  resizeP.set(this.getPointStyle((i % 2) ? middlePointsStyle[((i - 1) / 2) % middlePointsStyle.length] : pointsStyle[(i / 2) % pointsStyle.length]));
12722
- if (!(i % 2))
12723
- resizeP.rotation = (i / 2) * 90;
12836
+ resizeP.rotation = ((i - (i % 2 ? 1 : 0)) / 2) * 90;
12724
12837
  }
12725
12838
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
12726
12839
  rect.set(Object.assign({ stroke, strokeWidth, editConfig }, (mergeConfig.rect || {})));
@@ -12739,12 +12852,19 @@ class EditBox extends Group {
12739
12852
  this.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
12740
12853
  this.updateBounds({ x: 0, y: 0, width, height });
12741
12854
  }
12855
+ unload() {
12856
+ this.visible = false;
12857
+ if (this.app)
12858
+ this.rect.syncEventer = this.app.interaction.bottomList = null;
12859
+ }
12742
12860
  updateBounds(bounds) {
12743
12861
  const { editMask } = this.editor;
12744
12862
  const { mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
12745
- const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask } = mergeConfig;
12863
+ const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask, spread } = mergeConfig;
12746
12864
  this.visible = !this.target.locked;
12747
12865
  editMask.visible = mask ? true : 0;
12866
+ if (spread)
12867
+ BoundsHelper.spread(bounds, spread);
12748
12868
  if (this.view.worldOpacity) {
12749
12869
  const { width, height } = bounds;
12750
12870
  const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
@@ -12769,7 +12889,6 @@ class EditBox extends Group {
12769
12889
  }
12770
12890
  else {
12771
12891
  resizeL.height = height;
12772
- resizeP.rotation = 90;
12773
12892
  if (hideOnSmall && resizeP.width * 2 > height)
12774
12893
  resizeP.visible = false;
12775
12894
  }
@@ -12824,9 +12943,6 @@ class EditBox extends Group {
12824
12943
  buttons.y = point.y + margin;
12825
12944
  }
12826
12945
  }
12827
- unload() {
12828
- this.visible = false;
12829
- }
12830
12946
  getPointStyle(userStyle) {
12831
12947
  const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.mergedConfig;
12832
12948
  const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0, editConfig };
@@ -12840,20 +12956,26 @@ class EditBox extends Group {
12840
12956
  const { middlePoint } = this.mergedConfig;
12841
12957
  return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
12842
12958
  }
12843
- onSelect(e) {
12844
- if (e.oldList.length === 1) {
12845
- e.oldList[0].syncEventer = null;
12846
- if (this.app)
12847
- this.app.interaction.bottomList = null;
12848
- }
12849
- }
12850
12959
  onDragStart(e) {
12851
12960
  this.dragging = true;
12852
12961
  const point = this.dragPoint = e.current, { pointType } = point;
12853
- const { editor, dragStartData } = this, { target } = this;
12962
+ const { editor, dragStartData } = this, { target } = this, { moveable, resizeable, rotateable, skewable, hideOnMove } = this.mergeConfig;
12854
12963
  if (point.name === 'rect') {
12855
- this.moving = true;
12856
- editor.opacity = this.mergeConfig.hideOnMove ? 0 : 1;
12964
+ moveable && (this.moving = true);
12965
+ editor.opacity = hideOnMove ? 0 : 1;
12966
+ }
12967
+ else {
12968
+ if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !resizeable) {
12969
+ rotateable && (this.rotating = true);
12970
+ if (pointType === 'resize-rotate')
12971
+ resizeable && (this.resizing = true);
12972
+ else if (point.name === 'resize-line')
12973
+ skewable && (this.skewing = true), this.rotating = false;
12974
+ }
12975
+ else if (pointType === 'resize')
12976
+ resizeable && (this.resizing = true);
12977
+ if (pointType === 'skew')
12978
+ skewable && (this.skewing = true);
12857
12979
  }
12858
12980
  dragStartData.x = e.x;
12859
12981
  dragStartData.y = e.y;
@@ -12864,9 +12986,8 @@ class EditBox extends Group {
12864
12986
  ResizeEvent.resizingKeys = editor.leafList.keys;
12865
12987
  }
12866
12988
  onDragEnd(e) {
12867
- this.dragging = false;
12868
12989
  this.dragPoint = null;
12869
- this.moving = false;
12990
+ this.resetDoing();
12870
12991
  const { name, pointType } = e.current;
12871
12992
  if (name === 'rect')
12872
12993
  this.editor.opacity = 1;
@@ -12874,31 +12995,61 @@ class EditBox extends Group {
12874
12995
  ResizeEvent.resizingKeys = null;
12875
12996
  }
12876
12997
  onDrag(e) {
12877
- const { transformTool } = this, point = e.current;
12878
- if (point.name === 'rect') {
12998
+ const { transformTool, moving, resizing, rotating, skewing } = this;
12999
+ if (moving) {
12879
13000
  transformTool.onMove(e);
12880
13001
  updateMoveCursor(this);
12881
13002
  }
12882
- else {
12883
- const { pointType } = this.enterPoint = point;
12884
- if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !this.mergeConfig.resizeable) {
13003
+ else if (resizing || rotating || skewing) {
13004
+ const point = e.current;
13005
+ if (point.pointType)
13006
+ this.enterPoint = point;
13007
+ if (rotating)
12885
13008
  transformTool.onRotate(e);
12886
- if (pointType === 'resize-rotate')
12887
- transformTool.onScale(e);
12888
- }
12889
- else if (pointType === 'resize')
13009
+ if (resizing)
12890
13010
  transformTool.onScale(e);
12891
- if (pointType === 'skew')
13011
+ if (skewing)
12892
13012
  transformTool.onSkew(e);
12893
- updateCursor(this, e);
13013
+ updatePointCursor(this, e);
13014
+ }
13015
+ }
13016
+ resetDoing() {
13017
+ if (this.canUse)
13018
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
13019
+ }
13020
+ onMove(e) {
13021
+ if (this.canGesture && e.moveType !== 'drag') {
13022
+ e.stop();
13023
+ if (typeof this.mergeConfig.moveable === 'string') {
13024
+ this.gesturing = this.moving = true;
13025
+ this.transformTool.onMove(e);
13026
+ }
13027
+ }
13028
+ }
13029
+ onScale(e) {
13030
+ if (this.canGesture) {
13031
+ e.stop();
13032
+ if (typeof this.mergeConfig.resizeable === 'string') {
13033
+ this.gesturing = this.resizing = true;
13034
+ this.transformTool.onScale(e);
13035
+ }
13036
+ }
13037
+ }
13038
+ onRotate(e) {
13039
+ if (this.canGesture) {
13040
+ e.stop();
13041
+ if (typeof this.mergeConfig.rotateable === 'string') {
13042
+ this.gesturing = this.rotating = true;
13043
+ this.transformTool.onRotate(e);
13044
+ }
12894
13045
  }
12895
13046
  }
12896
13047
  onKey(e) {
12897
- updateCursor(this, e);
13048
+ updatePointCursor(this, e);
12898
13049
  }
12899
13050
  onArrow(e) {
12900
- const { editor } = this;
12901
- if (editor.editing && this.mergeConfig.keyEvent) {
13051
+ const { editor, transformTool } = this;
13052
+ if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
12902
13053
  let x = 0, y = 0;
12903
13054
  const distance = e.shiftKey ? 10 : 1;
12904
13055
  switch (e.code) {
@@ -12915,7 +13066,7 @@ class EditBox extends Group {
12915
13066
  x = distance;
12916
13067
  }
12917
13068
  if (x || y)
12918
- editor.move(x, y);
13069
+ transformTool.move(x, y);
12919
13070
  }
12920
13071
  }
12921
13072
  onDoubleTap(e) {
@@ -12958,12 +13109,12 @@ class EditBox extends Group {
12958
13109
  [PointerEvent.LEAVE, () => { this.enterPoint = null; }],
12959
13110
  ];
12960
13111
  if (point.name !== 'circle')
12961
- events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(this, e); }]);
13112
+ events.push([PointerEvent.ENTER, (e) => { this.enterPoint = point, updatePointCursor(this, e); }]);
12962
13113
  this.__eventIds.push(point.on_(events));
12963
13114
  }
12964
13115
  __listenEvents() {
12965
13116
  const { rect, editor, __eventIds: events } = this;
12966
- events.push(editor.on_(EditorEvent.SELECT, this.onSelect, this), rect.on_([
13117
+ events.push(rect.on_([
12967
13118
  [DragEvent.START, this.onDragStart, this],
12968
13119
  [DragEvent.DRAG, this.onDrag, this],
12969
13120
  [DragEvent.END, this.onDragEnd, this],
@@ -12974,7 +13125,13 @@ class EditBox extends Group {
12974
13125
  this.waitLeafer(() => {
12975
13126
  events.push(editor.app.on_([
12976
13127
  [[KeyEvent.HOLD, KeyEvent.UP], this.onKey, this],
12977
- [KeyEvent.DOWN, this.onArrow, this]
13128
+ [KeyEvent.DOWN, this.onArrow, this],
13129
+ [MoveEvent.BEFORE_MOVE, this.onMove, this, true],
13130
+ [ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
13131
+ [RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
13132
+ [MoveEvent.END, this.resetDoing, this],
13133
+ [ZoomEvent.END, this.resetDoing, this],
13134
+ [RotateEvent.END, this.resetDoing, this],
12978
13135
  ]));
12979
13136
  });
12980
13137
  }
@@ -13130,7 +13287,8 @@ function onTarget(editor, oldValue) {
13130
13287
  editor.simulateTarget.remove();
13131
13288
  editor.leafList.reset();
13132
13289
  }
13133
- editor.closeInnerEditor();
13290
+ editor.closeInnerEditor(true);
13291
+ editor.unloadEditTool();
13134
13292
  const data = { editor, value: target, oldValue };
13135
13293
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, data));
13136
13294
  editor.checkOpenedGroups();
@@ -13350,16 +13508,10 @@ EditorSkewEvent.SKEW = 'editor.skew';
13350
13508
 
13351
13509
  class TransformTool {
13352
13510
  onMove(e) {
13353
- const { target, mergeConfig, dragStartData } = this.editBox;
13511
+ const { target, dragStartData } = this.editBox;
13354
13512
  if (e instanceof MoveEvent) {
13355
- if (e.moveType !== 'drag') {
13356
- const { moveable, resizeable } = mergeConfig;
13357
- const move = e.getLocalMove(target);
13358
- if (moveable === 'move')
13359
- e.stop(), this.move(move.x, move.y);
13360
- else if (resizeable === 'zoom')
13361
- e.stop();
13362
- }
13513
+ const move = e.getLocalMove(target);
13514
+ this.move(move.x, move.y);
13363
13515
  }
13364
13516
  else {
13365
13517
  const total = { x: e.totalX, y: e.totalY };
@@ -13374,10 +13526,9 @@ class TransformTool {
13374
13526
  }
13375
13527
  onScale(e) {
13376
13528
  const { target, mergeConfig, single, dragStartData } = this.editBox;
13377
- let { around, lockRatio, resizeable, flipable, editSize } = mergeConfig;
13529
+ let { around, lockRatio, flipable, editSize } = mergeConfig;
13378
13530
  if (e instanceof ZoomEvent) {
13379
- if (resizeable === 'zoom')
13380
- e.stop(), this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
13531
+ this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
13381
13532
  }
13382
13533
  else {
13383
13534
  const { direction } = e.current;
@@ -13395,28 +13546,18 @@ class TransformTool {
13395
13546
  }
13396
13547
  onRotate(e) {
13397
13548
  const { target, mergeConfig, dragStartData } = this.editBox;
13398
- const { skewable, rotateable, around, rotateGap } = mergeConfig;
13399
- const { direction, name } = e.current;
13400
- if (skewable && name === 'resize-line')
13401
- return this.onSkew(e);
13549
+ const { around, rotateAround, rotateGap } = mergeConfig;
13550
+ const { direction } = e.current;
13402
13551
  let origin, rotation;
13403
13552
  if (e instanceof RotateEvent) {
13404
- if (rotateable === 'rotate')
13405
- e.stop(), rotation = e.rotation, origin = target.getBoxPoint(e);
13406
- else
13407
- return;
13408
- if (target.scaleX * target.scaleY < 0)
13409
- rotation = -rotation;
13553
+ rotation = e.rotation;
13554
+ origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
13410
13555
  }
13411
13556
  else {
13412
- const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (target.around || target.origin || around || 'center'));
13413
- rotation = data.rotation;
13557
+ const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (rotateAround || target.around || target.origin || around || 'center'));
13558
+ rotation = dragStartData.rotation + data.rotation - target.rotation;
13414
13559
  origin = data.origin;
13415
13560
  }
13416
- if (target.scaleX * target.scaleY < 0)
13417
- rotation = -rotation;
13418
- if (e instanceof DragEvent)
13419
- rotation = dragStartData.rotation + rotation - target.rotation;
13420
13561
  rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
13421
13562
  if (!rotation)
13422
13563
  return;
@@ -13582,9 +13723,13 @@ let Editor = class Editor extends Group {
13582
13723
  get groupOpening() { return !!this.openedGroupList.length; }
13583
13724
  get multiple() { return this.list.length > 1; }
13584
13725
  get single() { return this.list.length === 1; }
13726
+ get dragPoint() { return this.editBox.dragPoint; }
13585
13727
  get dragging() { return this.editBox.dragging; }
13728
+ get gesturing() { return this.editBox.gesturing; }
13586
13729
  get moving() { return this.editBox.moving; }
13587
- get dragPoint() { return this.editBox.dragPoint; }
13730
+ get resizing() { return this.editBox.resizing; }
13731
+ get rotating() { return this.editBox.rotating; }
13732
+ get skewing() { return this.editBox.skewing; }
13588
13733
  get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
13589
13734
  get buttons() { return this.editBox.buttons; }
13590
13735
  constructor(userConfig, data) {
@@ -13641,19 +13786,22 @@ let Editor = class Editor extends Group {
13641
13786
  this.update();
13642
13787
  }
13643
13788
  updateEditTool() {
13789
+ this.unloadEditTool();
13790
+ if (this.editing) {
13791
+ const name = this.element.editOuter || 'EditTool';
13792
+ const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
13793
+ this.editBox.load();
13794
+ tool.load();
13795
+ this.update();
13796
+ }
13797
+ }
13798
+ unloadEditTool() {
13644
13799
  let tool = this.editTool;
13645
13800
  if (tool) {
13646
13801
  this.editBox.unload();
13647
13802
  tool.unload();
13648
13803
  this.editTool = null;
13649
13804
  }
13650
- if (this.editing) {
13651
- const tag = this.element.editOuter || 'EditTool';
13652
- tool = this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
13653
- this.editBox.load();
13654
- tool.load();
13655
- this.update();
13656
- }
13657
13805
  }
13658
13806
  getEditSize(_ui) {
13659
13807
  return this.mergeConfig.editSize;
@@ -13727,16 +13875,21 @@ let Editor = class Editor extends Group {
13727
13875
  if (group)
13728
13876
  group.emitEvent(event);
13729
13877
  }
13730
- openInnerEditor(target, select) {
13878
+ openInnerEditor(target, nameOrSelect, select) {
13879
+ let name;
13880
+ if (typeof nameOrSelect === 'string')
13881
+ name = nameOrSelect;
13882
+ else if (!select)
13883
+ select = nameOrSelect;
13731
13884
  if (target && select)
13732
13885
  this.target = target;
13733
13886
  if (this.single) {
13734
13887
  const editTarget = target || this.element;
13735
- const tag = editTarget.editInner;
13736
- if (tag && EditToolCreator.list[tag]) {
13888
+ name || (name = editTarget.editInner);
13889
+ if (name && EditToolCreator.list[name]) {
13737
13890
  this.editTool.unload();
13738
13891
  this.innerEditing = true;
13739
- this.innerEditor = this.editToolList[tag] || EditToolCreator.get(tag, this);
13892
+ this.innerEditor = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
13740
13893
  this.innerEditor.editTarget = editTarget;
13741
13894
  this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
13742
13895
  this.innerEditor.load();
@@ -13744,13 +13897,14 @@ let Editor = class Editor extends Group {
13744
13897
  }
13745
13898
  }
13746
13899
  }
13747
- closeInnerEditor() {
13900
+ closeInnerEditor(onlyInnerEditor) {
13748
13901
  if (this.innerEditing) {
13749
13902
  this.innerEditing = false;
13750
13903
  this.emitInnerEvent(InnerEditorEvent.BEFORE_CLOSE);
13751
13904
  this.innerEditor.unload();
13752
13905
  this.emitInnerEvent(InnerEditorEvent.CLOSE);
13753
- this.editTool.load();
13906
+ if (!onlyInnerEditor)
13907
+ this.updateEditTool();
13754
13908
  this.innerEditor = null;
13755
13909
  }
13756
13910
  }
@@ -13793,12 +13947,7 @@ let Editor = class Editor extends Group {
13793
13947
  const { app, leafer, editMask } = this;
13794
13948
  this.targetEventIds = [
13795
13949
  leafer.on_(RenderEvent.START, this.onRenderStart, this),
13796
- app.on_([
13797
- [RenderEvent.CHILD_START, this.onAppRenderStart, this],
13798
- [MoveEvent.BEFORE_MOVE, this.onMove, this, true],
13799
- [ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
13800
- [RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
13801
- ])
13950
+ app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this)
13802
13951
  ];
13803
13952
  if (editMask.visible)
13804
13953
  editMask.forceRender();
@@ -14286,7 +14435,7 @@ Creator.editor = function (options, app) {
14286
14435
  };
14287
14436
  Box.addAttr('textBox', false, dataType);
14288
14437
  UI.addAttr('editConfig', undefined, dataType);
14289
- UI.addAttr('editOuter', (ui) => ui.__.__isLinePath ? 'LineEditTool' : 'EditTool', dataType);
14438
+ UI.addAttr('editOuter', (ui) => { ui.updateLayout(); return ui.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }, dataType);
14290
14439
  UI.addAttr('editInner', 'PathEditor', dataType);
14291
14440
  Group.addAttr('editInner', '', dataType);
14292
14441
  Text.addAttr('editInner', 'TextEditor', dataType);
@@ -15978,9 +16127,8 @@ box.__updateContentBounds = function () {
15978
16127
  }
15979
16128
  };
15980
16129
  box.__updateBoxBounds = function (secondLayout) {
15981
- const data = this.__;
15982
16130
  if (this.children.length && !this.pathInputed) {
15983
- const { flow } = data;
16131
+ const data = this.__, { flow } = data;
15984
16132
  if (data.__autoSide) {
15985
16133
  if (data.__hasSurface)
15986
16134
  this.__extraUpdate();
@@ -16212,6 +16360,11 @@ let Animate = class Animate extends Eventer {
16212
16360
  this.play();
16213
16361
  }, 0);
16214
16362
  }
16363
+ emitType(type) {
16364
+ this.emit(type, this);
16365
+ if (this.parent)
16366
+ this.parent.onChildEvent(type, this);
16367
+ }
16215
16368
  play() {
16216
16369
  if (this.destroyed)
16217
16370
  return;
@@ -16220,20 +16373,20 @@ let Animate = class Animate extends Eventer {
16220
16373
  this.clearTimer(), this.start();
16221
16374
  else if (!this.timer)
16222
16375
  this.requestAnimate();
16223
- this.emit(AnimateEvent.PLAY, this);
16376
+ this.emitType(AnimateEvent.PLAY);
16224
16377
  }
16225
16378
  pause() {
16226
16379
  if (this.destroyed)
16227
16380
  return;
16228
16381
  this.running = false;
16229
16382
  this.clearTimer();
16230
- this.emit(AnimateEvent.PAUSE, this);
16383
+ this.emitType(AnimateEvent.PAUSE);
16231
16384
  }
16232
16385
  stop() {
16233
16386
  if (this.destroyed)
16234
16387
  return;
16235
16388
  this.complete();
16236
- this.emit(AnimateEvent.STOP, this);
16389
+ this.emitType(AnimateEvent.STOP);
16237
16390
  }
16238
16391
  seek(time) {
16239
16392
  if (this.destroyed)
@@ -16247,7 +16400,7 @@ let Animate = class Animate extends Eventer {
16247
16400
  this.time = time;
16248
16401
  this.animate(0, true);
16249
16402
  this.clearTimer(() => this.requestAnimate());
16250
- this.emit(AnimateEvent.SEEK, this);
16403
+ this.emitType(AnimateEvent.SEEK);
16251
16404
  }
16252
16405
  kill(complete = true, killStyle) {
16253
16406
  this.killStyle = killStyle;
@@ -16314,7 +16467,7 @@ let Animate = class Animate extends Eventer {
16314
16467
  if (totalTime)
16315
16468
  this.changeDuration(totalTime);
16316
16469
  }
16317
- this.emit(AnimateEvent.CREATED, this);
16470
+ this.emitType(AnimateEvent.CREATED);
16318
16471
  }
16319
16472
  changeDuration(duration) {
16320
16473
  const { config } = this;
@@ -16434,7 +16587,7 @@ let Animate = class Animate extends Eventer {
16434
16587
  key in killStyle || (style[key] = endingStyle[key]);
16435
16588
  this.setStyle(style);
16436
16589
  this.clearTimer();
16437
- this.emit(AnimateEvent.COMPLETED, this);
16590
+ this.emitType(AnimateEvent.COMPLETED);
16438
16591
  }
16439
16592
  setFrom() {
16440
16593
  this.nowIndex = 0;
@@ -16478,7 +16631,7 @@ let Animate = class Animate extends Eventer {
16478
16631
  Transition.setBetweenStyle(betweenStyle, fromStyle, toStyle, style, t, target, attrsMap);
16479
16632
  this.setStyle(betweenStyle);
16480
16633
  }
16481
- this.emit(AnimateEvent.UPDATE, this);
16634
+ this.emitType(AnimateEvent.UPDATE);
16482
16635
  }
16483
16636
  setStyle(style) {
16484
16637
  const { target } = this;
@@ -16522,7 +16675,7 @@ let Animate = class Animate extends Eventer {
16522
16675
  this.stop();
16523
16676
  else
16524
16677
  this.pause();
16525
- this.target = this.config = this.frames = this.fromStyle = this.toStyle = this.style = this.killStyle = null;
16678
+ this.target = this.parent = this.config = this.frames = this.fromStyle = this.toStyle = this.style = this.killStyle = null;
16526
16679
  this.destroyed = true;
16527
16680
  }
16528
16681
  }
@@ -16588,6 +16741,7 @@ let AnimateList = class AnimateList extends Animate {
16588
16741
  });
16589
16742
  this.list = animation.map(item => {
16590
16743
  const animate = item.target ? item : new Animate(this.target, item, isTemp);
16744
+ animate.parent = this;
16591
16745
  Object.assign(this.fromStyle, animate.fromStyle);
16592
16746
  Object.assign(this.toStyle, animate.toStyle);
16593
16747
  Object.assign(this._endingStyle, animate.endingStyle);
@@ -16596,20 +16750,34 @@ let AnimateList = class AnimateList extends Animate {
16596
16750
  }
16597
16751
  play() {
16598
16752
  this.each(item => item.play());
16753
+ this.emitType(AnimateEvent.PLAY);
16599
16754
  }
16600
16755
  pause() {
16601
16756
  this.each(item => item.pause());
16757
+ this.emitType(AnimateEvent.PAUSE);
16602
16758
  }
16603
16759
  stop() {
16604
16760
  this.each(item => item.stop());
16761
+ this.emitType(AnimateEvent.STOP);
16605
16762
  }
16606
16763
  seek(time) {
16607
16764
  this.each(item => item.seek(time));
16765
+ this.emitType(AnimateEvent.SEEK);
16608
16766
  }
16609
16767
  kill(complete, killStyle) {
16610
16768
  this.each(item => item.kill(complete, killStyle));
16611
16769
  this.destroy();
16612
16770
  }
16771
+ onChildEvent(type, _animate) {
16772
+ switch (type) {
16773
+ case AnimateEvent.COMPLETED:
16774
+ if (this.completed)
16775
+ this.emitType(type);
16776
+ break;
16777
+ case AnimateEvent.UPDATE:
16778
+ this.emitType(type);
16779
+ }
16780
+ }
16613
16781
  each(func) {
16614
16782
  this.list.forEach(func);
16615
16783
  }
@@ -18068,123 +18236,131 @@ function getTrimBounds(canvas) {
18068
18236
  index++;
18069
18237
  }
18070
18238
  const bounds = new Bounds();
18071
- toBounds(pointBounds, bounds);
18072
- return bounds.scale(1 / canvas.pixelRatio).ceil();
18239
+ if (pointBounds) {
18240
+ toBounds(pointBounds, bounds);
18241
+ bounds.scale(1 / canvas.pixelRatio).ceil();
18242
+ }
18243
+ return bounds;
18073
18244
  }
18074
18245
 
18075
18246
  const ExportModule = {
18076
18247
  syncExport(leaf, filename, options) {
18077
- this.running = true;
18248
+ Export.running = true;
18078
18249
  let result;
18079
- const fileType = FileHelper.fileType(filename);
18080
- const isDownload = filename.includes('.');
18081
- options = FileHelper.getExportOptions(options);
18082
- const { toURL } = Platform;
18083
- const { download } = Platform.origin;
18084
- if (fileType === 'json') {
18085
- isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
18086
- result = { data: isDownload ? true : leaf.toJSON(options.json) };
18087
- }
18088
- else if (fileType === 'svg') {
18089
- isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
18090
- result = { data: isDownload ? true : leaf.toSVG() };
18091
- }
18092
- else {
18093
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
18094
- const { worldTransform, isLeafer, leafer, isFrame } = leaf;
18095
- const { slice, clip, trim, screenshot, padding, onCanvas } = options;
18096
- const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
18097
- const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
18098
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
18099
- const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
18100
- if (screenshot) {
18101
- renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
18250
+ try {
18251
+ const fileType = FileHelper.fileType(filename);
18252
+ const isDownload = filename.includes('.');
18253
+ options = FileHelper.getExportOptions(options);
18254
+ const { toURL } = Platform;
18255
+ const { download } = Platform.origin;
18256
+ if (fileType === 'json') {
18257
+ isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
18258
+ result = { data: isDownload ? true : leaf.toJSON(options.json) };
18259
+ }
18260
+ else if (fileType === 'svg') {
18261
+ isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
18262
+ result = { data: isDownload ? true : leaf.toSVG() };
18102
18263
  }
18103
18264
  else {
18104
- let relative = options.relative || (isLeafer ? 'inner' : 'local');
18105
- scaleX = worldTransform.scaleX;
18106
- scaleY = worldTransform.scaleY;
18107
- switch (relative) {
18108
- case 'inner':
18109
- matrix.set(worldTransform);
18110
- break;
18111
- case 'local':
18112
- matrix.set(worldTransform).divide(leaf.localTransform);
18113
- scaleX /= leaf.scaleX;
18114
- scaleY /= leaf.scaleY;
18115
- break;
18116
- case 'world':
18117
- scaleX = 1;
18118
- scaleY = 1;
18119
- break;
18120
- case 'page':
18121
- relative = leafer || leaf;
18122
- default:
18123
- matrix.set(worldTransform).divide(leaf.getTransform(relative));
18124
- const l = relative.worldTransform;
18125
- scaleX /= scaleX / l.scaleX;
18126
- scaleY /= scaleY / l.scaleY;
18265
+ let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
18266
+ const { worldTransform, isLeafer, leafer, isFrame } = leaf;
18267
+ const { slice, clip, trim, screenshot, padding, onCanvas } = options;
18268
+ const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
18269
+ const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
18270
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
18271
+ const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
18272
+ if (screenshot) {
18273
+ renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
18127
18274
  }
18128
- renderBounds = leaf.getBounds('render', relative);
18129
- }
18130
- const scaleData = { scaleX: 1, scaleY: 1 };
18131
- MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
18132
- let pixelRatio = options.pixelRatio || 1;
18133
- let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
18134
- if (clip)
18135
- x += clip.x, y += clip.y, width = clip.width, height = clip.height;
18136
- 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) };
18137
- let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
18138
- let sliceLeaf;
18139
- if (slice) {
18140
- sliceLeaf = leaf;
18141
- sliceLeaf.__worldOpacity = 0;
18142
- leaf = leafer || leaf;
18143
- renderOptions.bounds = canvas.bounds;
18144
- }
18145
- canvas.save();
18146
- if (isFrame && fill !== undefined) {
18147
- const oldFill = leaf.get('fill');
18148
- leaf.fill = '';
18149
- leaf.__render(canvas, renderOptions);
18150
- leaf.fill = oldFill;
18151
- }
18152
- else {
18153
- leaf.__render(canvas, renderOptions);
18154
- }
18155
- canvas.restore();
18156
- if (sliceLeaf)
18157
- sliceLeaf.__updateWorldOpacity();
18158
- if (trim) {
18159
- trimBounds = getTrimBounds(canvas);
18160
- const old = canvas, { width, height } = trimBounds;
18161
- const config = { x: 0, y: 0, width, height, pixelRatio };
18162
- canvas = Creator.canvas(config);
18163
- canvas.copyWorld(old, trimBounds, config);
18275
+ else {
18276
+ let relative = options.relative || (isLeafer ? 'inner' : 'local');
18277
+ scaleX = worldTransform.scaleX;
18278
+ scaleY = worldTransform.scaleY;
18279
+ switch (relative) {
18280
+ case 'inner':
18281
+ matrix.set(worldTransform);
18282
+ break;
18283
+ case 'local':
18284
+ matrix.set(worldTransform).divide(leaf.localTransform);
18285
+ scaleX /= leaf.scaleX;
18286
+ scaleY /= leaf.scaleY;
18287
+ break;
18288
+ case 'world':
18289
+ scaleX = 1;
18290
+ scaleY = 1;
18291
+ break;
18292
+ case 'page':
18293
+ relative = leafer || leaf;
18294
+ default:
18295
+ matrix.set(worldTransform).divide(leaf.getTransform(relative));
18296
+ const l = relative.worldTransform;
18297
+ scaleX /= scaleX / l.scaleX;
18298
+ scaleY /= scaleY / l.scaleY;
18299
+ }
18300
+ renderBounds = leaf.getBounds('render', relative);
18301
+ }
18302
+ const scaleData = { scaleX: 1, scaleY: 1 };
18303
+ MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
18304
+ let pixelRatio = options.pixelRatio || 1;
18305
+ let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
18306
+ if (clip)
18307
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
18308
+ 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) };
18309
+ let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
18310
+ let sliceLeaf;
18311
+ if (slice) {
18312
+ sliceLeaf = leaf;
18313
+ sliceLeaf.__worldOpacity = 0;
18314
+ leaf = leafer || leaf;
18315
+ renderOptions.bounds = canvas.bounds;
18316
+ }
18317
+ canvas.save();
18318
+ if (isFrame && fill !== undefined) {
18319
+ const oldFill = leaf.get('fill');
18320
+ leaf.fill = '';
18321
+ leaf.__render(canvas, renderOptions);
18322
+ leaf.fill = oldFill;
18323
+ }
18324
+ else {
18325
+ leaf.__render(canvas, renderOptions);
18326
+ }
18327
+ canvas.restore();
18328
+ if (sliceLeaf)
18329
+ sliceLeaf.__updateWorldOpacity();
18330
+ if (trim) {
18331
+ trimBounds = getTrimBounds(canvas);
18332
+ const old = canvas, { width, height } = trimBounds;
18333
+ const config = { x: 0, y: 0, width, height, pixelRatio };
18334
+ canvas = Creator.canvas(config);
18335
+ canvas.copyWorld(old, trimBounds, config);
18336
+ }
18337
+ if (padding) {
18338
+ const [top, right, bottom, left] = MathHelper.fourNumber(padding);
18339
+ const old = canvas, { width, height } = old;
18340
+ canvas = Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
18341
+ canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
18342
+ }
18343
+ if (needFill)
18344
+ canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
18345
+ if (onCanvas)
18346
+ onCanvas(canvas);
18347
+ const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
18348
+ result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
18164
18349
  }
18165
- if (padding) {
18166
- const [top, right, bottom, left] = MathHelper.fourNumber(padding);
18167
- const old = canvas, { width, height } = old;
18168
- canvas = Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
18169
- canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
18170
- }
18171
- if (needFill)
18172
- canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
18173
- if (onCanvas)
18174
- onCanvas(canvas);
18175
- const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
18176
- result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
18177
18350
  }
18178
- this.running = false;
18351
+ catch (error) {
18352
+ result = { data: '', error };
18353
+ }
18354
+ Export.running = false;
18179
18355
  return result;
18180
18356
  },
18181
18357
  export(leaf, filename, options) {
18182
- this.running = true;
18358
+ Export.running = true;
18183
18359
  return addTask((success) => new Promise((resolve) => {
18184
18360
  const getResult = () => __awaiter(this, void 0, void 0, function* () {
18185
18361
  if (!Resource.isComplete)
18186
18362
  return Platform.requestRender(getResult);
18187
- const result = ExportModule.syncExport(leaf, filename, options);
18363
+ const result = Export.syncExport(leaf, filename, options);
18188
18364
  if (result.data instanceof Promise)
18189
18365
  result.data = yield result.data;
18190
18366
  success(result);
@@ -18284,4 +18460,4 @@ Object.assign(Filter, {
18284
18460
  }
18285
18461
  });
18286
18462
 
18287
- 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, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, 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, TextEditor, 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 };
18463
+ 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, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, 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, TextEditor, 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 };