@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.
package/dist/worker.js CHANGED
@@ -439,7 +439,7 @@ var LeaferUI = (function (exports) {
439
439
  const M$a = MatrixHelper;
440
440
 
441
441
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
442
- const { sin: sin$5, cos: cos$5, abs: abs$7, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5 } = Math;
442
+ const { sin: sin$5, cos: cos$5, abs: abs$6, sqrt: sqrt$4, atan2: atan2$2, min: min$1, round: round$5 } = Math;
443
443
  const PointHelper = {
444
444
  defaultPoint: getPointData(),
445
445
  tempPoint: {},
@@ -534,8 +534,8 @@ var LeaferUI = (function (exports) {
534
534
  return getDistanceFrom(t.x, t.y, point.x, point.y);
535
535
  },
536
536
  getDistanceFrom(x1, y1, x2, y2) {
537
- const x = abs$7(x2 - x1);
538
- const y = abs$7(y2 - y1);
537
+ const x = abs$6(x2 - x1);
538
+ const y = abs$6(y2 - y1);
539
539
  return sqrt$4(x * x + y * y);
540
540
  },
541
541
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
@@ -766,7 +766,7 @@ var LeaferUI = (function (exports) {
766
766
  MatrixHelper.reset(this);
767
767
  }
768
768
  }
769
- const tempMatrix = new Matrix();
769
+ const tempMatrix$1 = new Matrix();
770
770
 
771
771
  const TwoPointBoundsHelper = {
772
772
  tempPointBounds: {},
@@ -863,6 +863,12 @@ var LeaferUI = (function (exports) {
863
863
  }
864
864
  if (!onlyBoxSize)
865
865
  to.x += box.x, to.y += box.y;
866
+ },
867
+ getPoint(around, box, to) {
868
+ if (!to)
869
+ to = {};
870
+ AroundHelper.toPoint(around, box, to, true);
871
+ return to;
866
872
  }
867
873
  };
868
874
  function get$4(around) {
@@ -1791,10 +1797,13 @@ var LeaferUI = (function (exports) {
1791
1797
  return (target, key) => {
1792
1798
  if (!realName)
1793
1799
  realName = key;
1794
- Object.defineProperty(target, key, {
1800
+ const property = {
1795
1801
  get() { return this.context[realName]; },
1796
1802
  set(value) { this.context[realName] = value; }
1797
- });
1803
+ };
1804
+ if (key === 'strokeCap')
1805
+ property.set = function (value) { this.context[realName] = value === 'none' ? 'butt' : value; };
1806
+ Object.defineProperty(target, key, property);
1798
1807
  };
1799
1808
  }
1800
1809
  const contextMethodNameList = [];
@@ -2070,15 +2079,15 @@ var LeaferUI = (function (exports) {
2070
2079
  contextMethod()
2071
2080
  ], Canvas.prototype, "strokeText", null);
2072
2081
 
2073
- const { copy: copy$c, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$4 } = Math;
2082
+ const { copy: copy$c, multiplyParent: multiplyParent$4 } = MatrixHelper, { round: round$4 } = Math;
2074
2083
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
2075
2084
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
2076
2085
  class LeaferCanvasBase extends Canvas {
2077
2086
  get width() { return this.size.width; }
2078
2087
  get height() { return this.size.height; }
2079
2088
  get pixelRatio() { return this.size.pixelRatio; }
2080
- get pixelWidth() { return this.width * this.pixelRatio; }
2081
- get pixelHeight() { return this.height * this.pixelRatio; }
2089
+ get pixelWidth() { return this.width * this.pixelRatio || 0; }
2090
+ get pixelHeight() { return this.height * this.pixelRatio || 0; }
2082
2091
  get pixelSnap() { return this.config.pixelSnap; }
2083
2092
  set pixelSnap(value) { this.config.pixelSnap = value; }
2084
2093
  get allowBackgroundColor() { return this.view && this.parentView; }
@@ -2143,7 +2152,7 @@ var LeaferUI = (function (exports) {
2143
2152
  setWorld(matrix, parentMatrix) {
2144
2153
  const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
2145
2154
  if (parentMatrix)
2146
- multiplyParent$3(matrix, parentMatrix, w);
2155
+ multiplyParent$4(matrix, parentMatrix, w);
2147
2156
  w.a = matrix.a * pixelRatio;
2148
2157
  w.b = matrix.b * pixelRatio;
2149
2158
  w.c = matrix.c * pixelRatio;
@@ -2165,20 +2174,33 @@ var LeaferUI = (function (exports) {
2165
2174
  if (w)
2166
2175
  this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
2167
2176
  }
2168
- setStroke(color, strokeWidth, options) {
2177
+ setStroke(color, strokeWidth, options, childOptions) {
2169
2178
  if (strokeWidth)
2170
2179
  this.strokeWidth = strokeWidth;
2171
2180
  if (color)
2172
2181
  this.strokeStyle = color;
2173
2182
  if (options)
2174
- this.setStrokeOptions(options);
2175
- }
2176
- setStrokeOptions(options) {
2177
- this.strokeCap = options.strokeCap === 'none' ? 'butt' : options.strokeCap;
2178
- this.strokeJoin = options.strokeJoin;
2179
- this.dashPattern = options.dashPattern;
2180
- this.dashOffset = options.dashOffset;
2181
- this.miterLimit = options.miterLimit;
2183
+ this.setStrokeOptions(options, childOptions);
2184
+ }
2185
+ setStrokeOptions(options, childOptions) {
2186
+ let { strokeCap, strokeJoin, dashPattern, dashOffset, miterLimit } = options;
2187
+ if (childOptions) {
2188
+ if (childOptions.strokeCap)
2189
+ strokeCap = childOptions.strokeCap;
2190
+ if (childOptions.strokeJoin)
2191
+ strokeJoin = childOptions.strokeJoin;
2192
+ if (childOptions.dashPattern !== undefined)
2193
+ dashPattern = childOptions.dashPattern;
2194
+ if (childOptions.dashOffset !== undefined)
2195
+ dashOffset = childOptions.dashOffset;
2196
+ if (childOptions.miterLimit)
2197
+ miterLimit = childOptions.miterLimit;
2198
+ }
2199
+ this.strokeCap = strokeCap;
2200
+ this.strokeJoin = strokeJoin;
2201
+ this.dashPattern = dashPattern;
2202
+ this.dashOffset = dashOffset;
2203
+ this.miterLimit = miterLimit;
2182
2204
  }
2183
2205
  saveBlendMode(blendMode) {
2184
2206
  this.savedBlendMode = this.blendMode;
@@ -2412,7 +2434,7 @@ var LeaferUI = (function (exports) {
2412
2434
  }
2413
2435
  };
2414
2436
 
2415
- 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;
2437
+ 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;
2416
2438
  const { setPoint: setPoint$4, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2417
2439
  const { set, toNumberPoints: toNumberPoints$1 } = PointHelper;
2418
2440
  const { M: M$9, L: L$a, C: C$8, Q: Q$7, Z: Z$8 } = PathCommandMap;
@@ -2487,7 +2509,7 @@ var LeaferUI = (function (exports) {
2487
2509
  let totalRadian = endRadian - startRadian;
2488
2510
  if (totalRadian < 0)
2489
2511
  totalRadian += PI2;
2490
- if (totalRadian === PI$3 || (abs$6(BAx + BAy) < 1.e-12) || (abs$6(CBx + CBy) < 1.e-12)) {
2512
+ if (totalRadian === PI$3 || (abs$5(BAx + BAy) < 1.e-12) || (abs$5(CBx + CBy) < 1.e-12)) {
2491
2513
  if (data)
2492
2514
  data.push(L$a, x1, y1);
2493
2515
  if (setPointBounds) {
@@ -2529,7 +2551,7 @@ var LeaferUI = (function (exports) {
2529
2551
  totalRadian -= PI2;
2530
2552
  if (anticlockwise)
2531
2553
  totalRadian -= PI2;
2532
- const parts = ceil$2(abs$6(totalRadian / PI_2));
2554
+ const parts = ceil$2(abs$5(totalRadian / PI_2));
2533
2555
  const partRadian = totalRadian / parts;
2534
2556
  const partRadian4Sin = sin$4(partRadian / 4);
2535
2557
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$4(partRadian / 2);
@@ -2974,7 +2996,7 @@ var LeaferUI = (function (exports) {
2974
2996
 
2975
2997
  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;
2976
2998
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2977
- const { tan, min, abs: abs$5 } = Math;
2999
+ const { tan, min, abs: abs$4 } = Math;
2978
3000
  const startPoint = {};
2979
3001
  const PathCommandDataHelper = {
2980
3002
  beginPath(data) {
@@ -3037,7 +3059,7 @@ var LeaferUI = (function (exports) {
3037
3059
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3038
3060
  if (lastX !== undefined) {
3039
3061
  const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3040
- radius = min(radius, min(d / 2, d / 2 * abs$5(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3062
+ radius = min(radius, min(d / 2, d / 2 * abs$4(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3041
3063
  }
3042
3064
  data.push(U$4, x1, y1, x2, y2, radius);
3043
3065
  },
@@ -3913,6 +3935,13 @@ var LeaferUI = (function (exports) {
3913
3935
  function getDescriptor(object, name) {
3914
3936
  return Object.getOwnPropertyDescriptor(object, name);
3915
3937
  }
3938
+ function createDescriptor(key, defaultValue) {
3939
+ const privateKey = '_' + key;
3940
+ return {
3941
+ get() { const v = this[privateKey]; return v === undefined ? defaultValue : v; },
3942
+ set(value) { this[privateKey] = value; }
3943
+ };
3944
+ }
3916
3945
  function getNames(object) {
3917
3946
  return Object.getOwnPropertyNames(object);
3918
3947
  }
@@ -4145,15 +4174,7 @@ var LeaferUI = (function (exports) {
4145
4174
  const data = target.__DataProcessor.prototype;
4146
4175
  const computedKey = '_' + key;
4147
4176
  const setMethodName = getSetMethodName(key);
4148
- const property = {
4149
- get() {
4150
- const v = this[computedKey];
4151
- return v === undefined ? defaultValue : v;
4152
- },
4153
- set(value) {
4154
- this[computedKey] = value;
4155
- }
4156
- };
4177
+ const property = createDescriptor(key, defaultValue);
4157
4178
  if (defaultValue === undefined) {
4158
4179
  property.get = function () { return this[computedKey]; };
4159
4180
  }
@@ -4268,7 +4289,7 @@ var LeaferUI = (function (exports) {
4268
4289
  };
4269
4290
  }
4270
4291
 
4271
- const { copy: copy$a, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
4292
+ const { copy: copy$a, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$3, divideParent, getLayout } = MatrixHelper;
4272
4293
  const matrix$3 = {}, { round: round$3 } = Math;
4273
4294
  const LeafHelper = {
4274
4295
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -4340,6 +4361,14 @@ var LeaferUI = (function (exports) {
4340
4361
  }
4341
4362
  return true;
4342
4363
  },
4364
+ copyCanvasByWorld(leaf, currentCanvas, fromCanvas, fromWorld, blendMode, onlyResetTransform) {
4365
+ if (!fromWorld)
4366
+ fromWorld = leaf.__nowWorld;
4367
+ if (leaf.__worldFlipped || Platform.fullImageShadow)
4368
+ currentCanvas.copyWorldByReset(fromCanvas, fromWorld, leaf.__nowWorld, blendMode, onlyResetTransform);
4369
+ else
4370
+ currentCanvas.copyWorldToInner(fromCanvas, fromWorld, leaf.__layout.renderBounds, blendMode);
4371
+ },
4343
4372
  moveWorld(t, x, y = 0, isInnerPoint, transition) {
4344
4373
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4345
4374
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
@@ -4399,14 +4428,14 @@ var LeaferUI = (function (exports) {
4399
4428
  },
4400
4429
  transformWorld(t, transform, resize, transition) {
4401
4430
  copy$a(matrix$3, t.worldTransform);
4402
- multiplyParent$2(matrix$3, transform);
4431
+ multiplyParent$3(matrix$3, transform);
4403
4432
  if (t.parent)
4404
4433
  divideParent(matrix$3, t.parent.worldTransform);
4405
4434
  L$4.setTransform(t, matrix$3, resize, transition);
4406
4435
  },
4407
4436
  transform(t, transform, resize, transition) {
4408
4437
  copy$a(matrix$3, t.localTransform);
4409
- multiplyParent$2(matrix$3, transform);
4438
+ multiplyParent$3(matrix$3, transform);
4410
4439
  L$4.setTransform(t, matrix$3, resize, transition);
4411
4440
  },
4412
4441
  setTransform(t, transform, resize, transition) {
@@ -5268,17 +5297,18 @@ var LeaferUI = (function (exports) {
5268
5297
  }
5269
5298
  };
5270
5299
 
5271
- const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5300
+ const { setLayout, multiplyParent: multiplyParent$2, translateInner, defaultWorld } = MatrixHelper;
5272
5301
  const { toPoint: toPoint$4, tempPoint: tempPoint$1 } = AroundHelper;
5273
5302
  const LeafMatrix = {
5274
5303
  __updateWorldMatrix() {
5275
- multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__, this.parent && this.parent.__);
5304
+ const { parent, __layout } = this;
5305
+ multiplyParent$2(this.__local || __layout, parent ? parent.__world : defaultWorld, this.__world, !!__layout.affectScaleOrRotation, this.__, parent && (parent.scrollY || parent.scrollX) && parent.__);
5276
5306
  },
5277
5307
  __updateLocalMatrix() {
5278
5308
  if (this.__local) {
5279
5309
  const layout = this.__layout, local = this.__local, data = this.__;
5280
5310
  if (layout.affectScaleOrRotation) {
5281
- if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5311
+ if ((layout.scaleChanged && (layout.resized || (layout.resized = 'scale'))) || layout.rotationChanged) {
5282
5312
  setLayout(local, data, null, null, layout.affectRotation);
5283
5313
  layout.scaleChanged = layout.rotationChanged = undefined;
5284
5314
  }
@@ -5444,10 +5474,7 @@ var LeaferUI = (function (exports) {
5444
5474
  return this.__renderEraser(canvas, options);
5445
5475
  const tempCanvas = canvas.getSameCanvas(true, true);
5446
5476
  this.__draw(tempCanvas, options, canvas);
5447
- if (this.__worldFlipped)
5448
- canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
5449
- else
5450
- canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
5477
+ LeafHelper.copyCanvasByWorld(this, canvas, tempCanvas, this.__nowWorld, data.__blendMode, true);
5451
5478
  tempCanvas.recycle(this.__nowWorld);
5452
5479
  }
5453
5480
  else {
@@ -5495,7 +5522,7 @@ var LeaferUI = (function (exports) {
5495
5522
  options.dimOpacity = data.dim === true ? 0.2 : data.dim;
5496
5523
  else if (data.dimskip)
5497
5524
  options.dimOpacity && (options.dimOpacity = 0);
5498
- if (data.__single) {
5525
+ if (data.__single && !this.isBranchLeaf) {
5499
5526
  if (data.eraser === 'path')
5500
5527
  return this.__renderEraser(canvas, options);
5501
5528
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -5517,9 +5544,7 @@ var LeaferUI = (function (exports) {
5517
5544
  else {
5518
5545
  const { children } = this;
5519
5546
  for (let i = 0, len = children.length; i < len; i++) {
5520
- if (excludeRenderBounds$1(children[i], options))
5521
- continue;
5522
- children[i].__render(canvas, options);
5547
+ excludeRenderBounds$1(children[i], options) || children[i].__render(canvas, options);
5523
5548
  }
5524
5549
  }
5525
5550
  },
@@ -5527,16 +5552,15 @@ var LeaferUI = (function (exports) {
5527
5552
  if (this.__worldOpacity) {
5528
5553
  const { children } = this;
5529
5554
  for (let i = 0, len = children.length; i < len; i++) {
5530
- if (excludeRenderBounds$1(children[i], options))
5531
- continue;
5532
- children[i].__clip(canvas, options);
5555
+ excludeRenderBounds$1(children[i], options) || children[i].__clip(canvas, options);
5533
5556
  }
5534
5557
  }
5535
5558
  }
5536
5559
  };
5537
5560
 
5561
+ const tempScaleData$1 = {};
5538
5562
  const { LEAF, create } = IncrementId;
5539
- const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5563
+ const { toInnerPoint, toOuterPoint, multiplyParent: multiplyParent$1 } = MatrixHelper;
5540
5564
  const { toOuterOf } = BoundsHelper;
5541
5565
  const { copy: copy$7, move: move$5 } = PointHelper;
5542
5566
  const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
@@ -5718,7 +5742,7 @@ var LeaferUI = (function (exports) {
5718
5742
  if (!this.__cameraWorld)
5719
5743
  this.__cameraWorld = {};
5720
5744
  const cameraWorld = this.__cameraWorld, world = this.__world;
5721
- multiplyParent(world, options.matrix, cameraWorld, undefined, world);
5745
+ multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
5722
5746
  toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
5723
5747
  cameraWorld.half !== world.half && (cameraWorld.half = world.half);
5724
5748
  return cameraWorld;
@@ -5727,6 +5751,22 @@ var LeaferUI = (function (exports) {
5727
5751
  return this.__world;
5728
5752
  }
5729
5753
  }
5754
+ getClampRenderScale() {
5755
+ let { scaleX } = this.__nowWorld || this.__world;
5756
+ if (scaleX < 0)
5757
+ scaleX = -scaleX;
5758
+ return scaleX > 1 ? scaleX : 1;
5759
+ }
5760
+ getRenderScaleData(abs, scaleFixed) {
5761
+ const { scaleX, scaleY } = ImageManager.patternLocked ? this.__world : this.__nowWorld;
5762
+ if (scaleFixed)
5763
+ tempScaleData$1.scaleX = tempScaleData$1.scaleY = 1;
5764
+ else if (abs)
5765
+ tempScaleData$1.scaleX = scaleX < 0 ? -scaleX : scaleX, tempScaleData$1.scaleY = scaleY < 0 ? -scaleY : scaleY;
5766
+ else
5767
+ tempScaleData$1.scaleX = scaleX, tempScaleData$1.scaleY = scaleY;
5768
+ return tempScaleData$1;
5769
+ }
5730
5770
  getTransform(relative) {
5731
5771
  return this.__layout.getTransform(relative || 'local');
5732
5772
  }
@@ -6251,7 +6291,7 @@ var LeaferUI = (function (exports) {
6251
6291
  }
6252
6292
  }
6253
6293
 
6254
- const version = "1.7.0";
6294
+ const version = "1.8.0";
6255
6295
 
6256
6296
  class LeaferCanvas extends LeaferCanvasBase {
6257
6297
  get allowBackgroundColor() { return true; }
@@ -7099,6 +7139,11 @@ var LeaferUI = (function (exports) {
7099
7139
  });
7100
7140
  };
7101
7141
  }
7142
+ function createAttr(defaultValue) {
7143
+ return (target, key) => {
7144
+ defineKey(target, key, createDescriptor(key, defaultValue));
7145
+ };
7146
+ }
7102
7147
 
7103
7148
  function hasTransparent$3(color) {
7104
7149
  if (!color || color.length === 7 || color.length === 4)
@@ -7156,22 +7201,9 @@ var LeaferUI = (function (exports) {
7156
7201
  const debug$5 = Debug.get('UIData');
7157
7202
  class UIData extends LeafData {
7158
7203
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
7159
- get __strokeWidth() {
7160
- const { strokeWidth, strokeWidthFixed } = this;
7161
- if (strokeWidthFixed) {
7162
- const ui = this.__leaf;
7163
- let { scaleX } = ui.__nowWorld || ui.__world;
7164
- if (scaleX < 0)
7165
- scaleX = -scaleX;
7166
- return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
7167
- }
7168
- else
7169
- return strokeWidth;
7170
- }
7171
- get __hasMultiPaint() {
7172
- const t = this;
7173
- return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect;
7174
- }
7204
+ get __strokeWidth() { return this.__getRealStrokeWidth(); }
7205
+ get __maxStrokeWidth() { const t = this; return t.__hasMultiStrokeStyle ? Math.max(t.__hasMultiStrokeStyle, t.strokeWidth) : t.strokeWidth; }
7206
+ get __hasMultiPaint() { const t = this; return (t.fill && this.__useStroke) || (t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect; }
7175
7207
  get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7176
7208
  get __hasSurface() { const t = this; return (t.fill || t.stroke); }
7177
7209
  get __autoWidth() { return !this._width; }
@@ -7253,6 +7285,21 @@ var LeaferUI = (function (exports) {
7253
7285
  Paint.compute('stroke', this.__leaf);
7254
7286
  this.__needComputePaint = undefined;
7255
7287
  }
7288
+ __getRealStrokeWidth(childStyle) {
7289
+ let { strokeWidth, strokeWidthFixed } = this;
7290
+ if (childStyle) {
7291
+ if (childStyle.strokeWidth)
7292
+ strokeWidth = childStyle.strokeWidth;
7293
+ if (childStyle.strokeWidthFixed !== undefined)
7294
+ strokeWidthFixed = childStyle.strokeWidthFixed;
7295
+ }
7296
+ if (strokeWidthFixed) {
7297
+ const scale = this.__leaf.getClampRenderScale();
7298
+ return scale > 1 ? strokeWidth / scale : strokeWidth;
7299
+ }
7300
+ else
7301
+ return strokeWidth;
7302
+ }
7256
7303
  __setPaint(attrName, value) {
7257
7304
  this.__setInput(attrName, value);
7258
7305
  const layout = this.__leaf.__layout;
@@ -7277,6 +7324,7 @@ var LeaferUI = (function (exports) {
7277
7324
  }
7278
7325
  else {
7279
7326
  stintSet$2(this, '__isAlphaPixelStroke', undefined);
7327
+ stintSet$2(this, '__hasMultiStrokeStyle', undefined);
7280
7328
  this._stroke = this.__isStrokes = undefined;
7281
7329
  }
7282
7330
  }
@@ -7298,8 +7346,8 @@ var LeaferUI = (function (exports) {
7298
7346
 
7299
7347
  class BoxData extends GroupData {
7300
7348
  get __boxStroke() { return !this.__pathInputed; }
7301
- get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7302
- get __clipAfterFill() { return this.__leaf.isOverflow || super.__clipAfterFill; }
7349
+ get __drawAfterFill() { const t = this; return t.__single || t.__clipAfterFill; }
7350
+ get __clipAfterFill() { const t = this; return t.overflow === 'hide' && t.__leaf.children.length && (t.__leaf.isOverflow || super.__clipAfterFill); }
7303
7351
  }
7304
7352
 
7305
7353
  class LeaferData extends GroupData {
@@ -7419,7 +7467,7 @@ var LeaferUI = (function (exports) {
7419
7467
  const UIBounds = {
7420
7468
  __updateStrokeSpread() {
7421
7469
  let width = 0, boxWidth = 0;
7422
- const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
7470
+ const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
7423
7471
  if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
7424
7472
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
7425
7473
  if (!data.__boxStroke) {
@@ -7439,13 +7487,15 @@ var LeaferUI = (function (exports) {
7439
7487
  },
7440
7488
  __updateRenderSpread() {
7441
7489
  let width = 0;
7442
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7490
+ const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
7443
7491
  if (shadow)
7444
7492
  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));
7445
7493
  if (blur)
7446
7494
  width = Math.max(width, blur);
7447
7495
  if (filter)
7448
7496
  width += Filter.getSpread(filter);
7497
+ if (renderSpread)
7498
+ width += renderSpread;
7449
7499
  let shapeWidth = width = Math.ceil(width);
7450
7500
  if (innerShadow)
7451
7501
  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));
@@ -7468,7 +7518,7 @@ var LeaferUI = (function (exports) {
7468
7518
  }
7469
7519
  if (data.__useEffect) {
7470
7520
  const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7471
- 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')));
7521
+ 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')));
7472
7522
  data.__useEffect = !!(shadow || otherEffect);
7473
7523
  }
7474
7524
  data.__checkSingle();
@@ -7575,17 +7625,17 @@ var LeaferUI = (function (exports) {
7575
7625
  if (__drawAfterFill)
7576
7626
  this.__drawAfterFill(canvas, options);
7577
7627
  if (stroke) {
7578
- const { strokeAlign, __strokeWidth } = this.__;
7579
- if (!__strokeWidth)
7628
+ const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
7629
+ if (!strokeWidth)
7580
7630
  return;
7581
- canvas.setStroke(stroke, __strokeWidth, this.__);
7582
- const half = __strokeWidth / 2;
7631
+ canvas.setStroke(stroke, strokeWidth, this.__);
7632
+ const half = strokeWidth / 2;
7583
7633
  switch (strokeAlign) {
7584
7634
  case 'center':
7585
7635
  canvas.strokeRect(0, 0, width, height);
7586
7636
  break;
7587
7637
  case 'inside':
7588
- width -= __strokeWidth, height -= __strokeWidth;
7638
+ width -= strokeWidth, height -= strokeWidth;
7589
7639
  if (width < 0 || height < 0) {
7590
7640
  canvas.save();
7591
7641
  this.__clip(canvas, options);
@@ -7596,7 +7646,7 @@ var LeaferUI = (function (exports) {
7596
7646
  canvas.strokeRect(x + half, y + half, width, height);
7597
7647
  break;
7598
7648
  case 'outside':
7599
- canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
7649
+ canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
7600
7650
  break;
7601
7651
  }
7602
7652
  }
@@ -7609,6 +7659,8 @@ var LeaferUI = (function (exports) {
7609
7659
  get isFrame() { return false; }
7610
7660
  set scale(value) { MathHelper.assignScale(this, value); }
7611
7661
  get scale() { return this.__.scale; }
7662
+ get isAutoWidth() { const t = this.__; return t.__autoWidth || t.autoWidth; }
7663
+ get isAutoHeight() { const t = this.__; return t.__autoHeight || t.autoHeight; }
7612
7664
  get pen() {
7613
7665
  const { path } = this.__;
7614
7666
  pen.set(this.path = path || []);
@@ -7823,6 +7875,9 @@ var LeaferUI = (function (exports) {
7823
7875
  __decorate([
7824
7876
  naturalBoundsType(1)
7825
7877
  ], exports.UI.prototype, "pixelRatio", void 0);
7878
+ __decorate([
7879
+ affectRenderBoundsType(0)
7880
+ ], exports.UI.prototype, "renderSpread", void 0);
7826
7881
  __decorate([
7827
7882
  pathInputType()
7828
7883
  ], exports.UI.prototype, "path", void 0);
@@ -7979,7 +8034,8 @@ var LeaferUI = (function (exports) {
7979
8034
  }
7980
8035
  toJSON(options) {
7981
8036
  const data = super.toJSON(options);
7982
- data.children = this.children.map(child => child.toJSON(options));
8037
+ if (!this.childlessJSON)
8038
+ data.children = this.children.map(child => child.toJSON(options));
7983
8039
  return data;
7984
8040
  }
7985
8041
  pick(_hitPoint, _options) { return undefined; }
@@ -8426,8 +8482,8 @@ var LeaferUI = (function (exports) {
8426
8482
  __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
8427
8483
  __updateRectBoxBounds() { }
8428
8484
  __updateBoxBounds(_secondLayout) {
8429
- const data = this.__;
8430
8485
  if (this.children.length && !this.pathInputed) {
8486
+ const data = this.__;
8431
8487
  if (data.__autoSide) {
8432
8488
  if (data.__hasSurface)
8433
8489
  this.__extraUpdate();
@@ -8454,20 +8510,26 @@ var LeaferUI = (function (exports) {
8454
8510
  __updateStrokeBounds() { }
8455
8511
  __updateRenderBounds() {
8456
8512
  let isOverflow;
8457
- const { renderBounds } = this.__layout;
8458
8513
  if (this.children.length) {
8514
+ const data = this.__, { renderBounds, boxBounds } = this.__layout;
8459
8515
  super.__updateRenderBounds();
8460
8516
  copy$6(childrenRenderBounds, renderBounds);
8461
8517
  this.__updateRectRenderBounds();
8462
- isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8463
- if (isOverflow && this.__.overflow !== 'hide')
8518
+ if (data.scrollY || data.scrollX) {
8519
+ childrenRenderBounds.x += data.scrollX;
8520
+ childrenRenderBounds.y += data.scrollY;
8521
+ }
8522
+ isOverflow = !includes$1(boxBounds, childrenRenderBounds);
8523
+ if (isOverflow && data.overflow !== 'hide')
8464
8524
  add(renderBounds, childrenRenderBounds);
8465
8525
  }
8466
8526
  else
8467
8527
  this.__updateRectRenderBounds();
8468
8528
  DataHelper.stintSet(this, 'isOverflow', isOverflow);
8529
+ this.__updateScrollBar();
8469
8530
  }
8470
8531
  __updateRectRenderBounds() { }
8532
+ __updateScrollBar() { }
8471
8533
  __updateRectChange() { }
8472
8534
  __updateChange() {
8473
8535
  super.__updateChange();
@@ -8484,10 +8546,12 @@ var LeaferUI = (function (exports) {
8484
8546
  if (this.children.length)
8485
8547
  this.__renderGroup(canvas, options);
8486
8548
  }
8549
+ if (this.scrollBar)
8550
+ this.scrollBar.__render(canvas, options);
8487
8551
  }
8488
8552
  __drawContent(canvas, options) {
8489
8553
  this.__renderGroup(canvas, options);
8490
- if (this.__.__useStroke) {
8554
+ if (this.__.__useStroke || this.__.__useEffect) {
8491
8555
  canvas.setWorld(this.__nowWorld);
8492
8556
  this.__drawRenderPath(canvas);
8493
8557
  }
@@ -10290,18 +10354,20 @@ var LeaferUI = (function (exports) {
10290
10354
  }
10291
10355
  return this.__hit(inner);
10292
10356
  };
10293
- leaf$1.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
10294
- leaf$1.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
10295
- 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); };
10296
- leaf$1.__drawHitPath = function (canvas) { if (canvas)
10297
- this.__drawRenderPath(canvas); };
10357
+ leaf$1.__hitFill = function (inner) { const h = this.__hitCanvas; return h && h.hitFill(inner, this.__.windingRule); };
10358
+ leaf$1.__hitStroke = function (inner, strokeWidth) { const h = this.__hitCanvas; return h && h.hitStroke(inner, strokeWidth); };
10359
+ leaf$1.__hitPixel = function (inner) { const h = this.__hitCanvas; return h && h.hitPixel(inner, this.__layout.renderBounds, h.hitScale); };
10360
+ leaf$1.__drawHitPath = function (canvas) { canvas && this.__drawRenderPath(canvas); };
10298
10361
 
10299
10362
  const matrix$2 = new Matrix();
10300
10363
  const ui$5 = exports.UI.prototype;
10301
10364
  ui$5.__updateHitCanvas = function () {
10302
10365
  if (this.__box)
10303
10366
  this.__box.__updateHitCanvas();
10304
- const data = this.__, { hitCanvasManager } = this.leafer || this.parent.leafer;
10367
+ const leafer = this.leafer || (this.parent && this.parent.leafer);
10368
+ if (!leafer)
10369
+ return;
10370
+ const data = this.__, { hitCanvasManager } = leafer;
10305
10371
  const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10306
10372
  const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10307
10373
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -10337,7 +10403,7 @@ var LeaferUI = (function (exports) {
10337
10403
  const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10338
10404
  if (needHitFillPath && this.__hitFill(inner))
10339
10405
  return true;
10340
- const { hitStroke, __strokeWidth } = data;
10406
+ const { hitStroke, __maxStrokeWidth: strokeWidth } = data;
10341
10407
  const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10342
10408
  if (!needHitFillPath && !needHitStrokePath)
10343
10409
  return false;
@@ -10346,16 +10412,16 @@ var LeaferUI = (function (exports) {
10346
10412
  if (needHitStrokePath) {
10347
10413
  switch (data.strokeAlign) {
10348
10414
  case 'inside':
10349
- hitWidth += __strokeWidth * 2;
10415
+ hitWidth += strokeWidth * 2;
10350
10416
  if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
10351
10417
  return true;
10352
10418
  hitWidth = radiusWidth;
10353
10419
  break;
10354
10420
  case 'center':
10355
- hitWidth += __strokeWidth;
10421
+ hitWidth += strokeWidth;
10356
10422
  break;
10357
10423
  case 'outside':
10358
- hitWidth += __strokeWidth * 2;
10424
+ hitWidth += strokeWidth * 2;
10359
10425
  if (!needHitFillPath) {
10360
10426
  if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
10361
10427
  return true;
@@ -10455,9 +10521,14 @@ var LeaferUI = (function (exports) {
10455
10521
  }
10456
10522
  }
10457
10523
  canvas.fillStyle = item.style;
10458
- if (item.transform) {
10524
+ if (item.transform || item.scaleFixed) {
10459
10525
  canvas.save();
10460
- canvas.transform(item.transform);
10526
+ if (item.transform)
10527
+ canvas.transform(item.transform);
10528
+ if (item.scaleFixed) {
10529
+ const { scaleX, scaleY } = ui.getRenderScaleData(true);
10530
+ canvas.scale(1 / scaleX, 1 / scaleY);
10531
+ }
10461
10532
  if (item.blendMode)
10462
10533
  canvas.blendMode = item.blendMode;
10463
10534
  fillPathOrText(ui, canvas);
@@ -10493,8 +10564,13 @@ var LeaferUI = (function (exports) {
10493
10564
  }
10494
10565
  function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10495
10566
  const data = ui.__;
10496
- canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10497
- data.__isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
10567
+ if (typeof stroke === 'object') {
10568
+ drawStrokesStyle(stroke, strokeWidthScale, true, ui, canvas);
10569
+ }
10570
+ else {
10571
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10572
+ drawTextStroke(ui, canvas);
10573
+ }
10498
10574
  }
10499
10575
  function drawAlign(stroke, align, ui, canvas) {
10500
10576
  const out = canvas.getSameCanvas(true, true);
@@ -10503,15 +10579,9 @@ var LeaferUI = (function (exports) {
10503
10579
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10504
10580
  fillText(ui, out);
10505
10581
  out.blendMode = 'normal';
10506
- copyWorld(canvas, out, ui);
10582
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10507
10583
  out.recycle(ui.__nowWorld);
10508
10584
  }
10509
- function copyWorld(canvas, out, ui) {
10510
- if (ui.__worldFlipped || Platform.fullImageShadow)
10511
- canvas.copyWorldByReset(out, ui.__nowWorld);
10512
- else
10513
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10514
- }
10515
10585
  function drawTextStroke(ui, canvas) {
10516
10586
  let row, data = ui.__.__textDrawData;
10517
10587
  const { rows, decorationY } = data;
@@ -10527,14 +10597,21 @@ var LeaferUI = (function (exports) {
10527
10597
  rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
10528
10598
  }
10529
10599
  }
10530
- function drawStrokesStyle(strokes, isText, ui, canvas) {
10600
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
10531
10601
  let item;
10602
+ const data = ui.__, { __hasMultiStrokeStyle } = data;
10603
+ __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
10532
10604
  for (let i = 0, len = strokes.length; i < len; i++) {
10533
10605
  item = strokes[i];
10534
10606
  if (item.image && PaintImage.checkImage(ui, canvas, item, false))
10535
10607
  continue;
10536
10608
  if (item.style) {
10537
- canvas.strokeStyle = item.style;
10609
+ if (__hasMultiStrokeStyle) {
10610
+ const { strokeStyle } = item;
10611
+ strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
10612
+ }
10613
+ else
10614
+ canvas.strokeStyle = item.style;
10538
10615
  if (item.blendMode) {
10539
10616
  canvas.saveBlendMode(item.blendMode);
10540
10617
  isText ? drawTextStroke(ui, canvas) : canvas.stroke();
@@ -10573,8 +10650,13 @@ var LeaferUI = (function (exports) {
10573
10650
  }
10574
10651
  function drawCenter(stroke, strokeWidthScale, ui, canvas) {
10575
10652
  const data = ui.__;
10576
- canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
10577
- data.__isStrokes ? drawStrokesStyle(stroke, false, ui, canvas) : canvas.stroke();
10653
+ if (typeof stroke === 'object') {
10654
+ drawStrokesStyle(stroke, strokeWidthScale, false, ui, canvas);
10655
+ }
10656
+ else {
10657
+ canvas.setStroke(stroke, data.__strokeWidth * strokeWidthScale, data);
10658
+ canvas.stroke();
10659
+ }
10578
10660
  if (data.__useArrow)
10579
10661
  Paint.strokeArrow(stroke, ui, canvas);
10580
10662
  }
@@ -10596,7 +10678,7 @@ var LeaferUI = (function (exports) {
10596
10678
  drawCenter(stroke, 2, ui, out);
10597
10679
  out.clipUI(data);
10598
10680
  out.clearWorld(renderBounds);
10599
- copyWorld(canvas, out, ui);
10681
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10600
10682
  out.recycle(ui.__nowWorld);
10601
10683
  }
10602
10684
  }
@@ -10651,8 +10733,16 @@ var LeaferUI = (function (exports) {
10651
10733
  if (!(paints instanceof Array))
10652
10734
  paints = [paints];
10653
10735
  recycleMap = PaintImage.recycleImage(attrName, data);
10736
+ let maxChildStrokeWidth;
10654
10737
  for (let i = 0, len = paints.length, item; i < len; i++) {
10655
- (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
10738
+ if (item = getLeafPaint(attrName, paints[i], ui)) {
10739
+ leafPaints.push(item);
10740
+ if (item.strokeStyle) {
10741
+ maxChildStrokeWidth || (maxChildStrokeWidth = 1);
10742
+ if (item.strokeStyle.strokeWidth)
10743
+ maxChildStrokeWidth = Math.max(maxChildStrokeWidth, item.strokeStyle.strokeWidth);
10744
+ }
10745
+ }
10656
10746
  }
10657
10747
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10658
10748
  if (leafPaints.length) {
@@ -10669,6 +10759,7 @@ var LeaferUI = (function (exports) {
10669
10759
  else {
10670
10760
  stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
10671
10761
  stintSet(data, '__isTransparentStroke', isTransparent);
10762
+ stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
10672
10763
  }
10673
10764
  }
10674
10765
  function getLeafPaint(attrName, paint, ui) {
@@ -10700,6 +10791,11 @@ var LeaferUI = (function (exports) {
10700
10791
  if (data) {
10701
10792
  if (typeof data.style === 'string' && hasTransparent$1(data.style))
10702
10793
  data.isTransparent = true;
10794
+ if (paint.style) {
10795
+ if (paint.style.strokeWidth === 0)
10796
+ return undefined;
10797
+ data.strokeStyle = paint.style;
10798
+ }
10703
10799
  if (paint.blendMode)
10704
10800
  data.blendMode = paint.blendMode;
10705
10801
  }
@@ -10719,8 +10815,8 @@ var LeaferUI = (function (exports) {
10719
10815
  shape
10720
10816
  };
10721
10817
 
10722
- let origin$1 = {};
10723
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
10818
+ let origin$1 = {}, tempMatrix = getMatrixData();
10819
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate: rotate$2, skew: skewHelper } = MatrixHelper;
10724
10820
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10725
10821
  const transform = get$3();
10726
10822
  translate$1(transform, box.x + x, box.y + y);
@@ -10729,7 +10825,7 @@ var LeaferUI = (function (exports) {
10729
10825
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10730
10826
  data.transform = transform;
10731
10827
  }
10732
- function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew) {
10828
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
10733
10829
  const transform = get$3();
10734
10830
  if (rotation)
10735
10831
  rotate$2(transform, rotation);
@@ -10738,6 +10834,10 @@ var LeaferUI = (function (exports) {
10738
10834
  if (scaleX)
10739
10835
  scaleHelper(transform, scaleX, scaleY);
10740
10836
  translate$1(transform, box.x + x, box.y + y);
10837
+ if (clipSize) {
10838
+ tempMatrix.a = box.width / clipSize.width, tempMatrix.d = box.height / clipSize.height;
10839
+ multiplyParent(transform, tempMatrix);
10840
+ }
10741
10841
  data.transform = transform;
10742
10842
  }
10743
10843
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -10774,13 +10874,15 @@ var LeaferUI = (function (exports) {
10774
10874
  const tempScaleData = {};
10775
10875
  const tempImage = {};
10776
10876
  function createData(leafPaint, image, paint, box) {
10777
- const { changeful, sync, editing } = paint;
10877
+ const { changeful, sync, editing, scaleFixed } = paint;
10778
10878
  if (changeful)
10779
10879
  leafPaint.changeful = changeful;
10780
10880
  if (sync)
10781
10881
  leafPaint.sync = sync;
10782
10882
  if (editing)
10783
10883
  leafPaint.editing = editing;
10884
+ if (scaleFixed)
10885
+ leafPaint.scaleFixed = scaleFixed;
10784
10886
  leafPaint.data = getPatternData(paint, box, image);
10785
10887
  }
10786
10888
  function getPatternData(paint, box, image) {
@@ -10789,7 +10891,7 @@ var LeaferUI = (function (exports) {
10789
10891
  if (paint.mode === 'strench')
10790
10892
  paint.mode = 'stretch';
10791
10893
  let { width, height } = image;
10792
- const { opacity, mode, align, offset, scale, size, rotation, skew, repeat, filters } = paint;
10894
+ const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
10793
10895
  const sameBox = box.width === width && box.height === height;
10794
10896
  const data = { mode };
10795
10897
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -10823,8 +10925,8 @@ var LeaferUI = (function (exports) {
10823
10925
  break;
10824
10926
  case 'normal':
10825
10927
  case 'clip':
10826
- if (tempImage.x || tempImage.y || scaleX || rotation || skew)
10827
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew);
10928
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
10929
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
10828
10930
  break;
10829
10931
  case 'repeat':
10830
10932
  if (!sameBox || scaleX || rotation)
@@ -10961,18 +11063,16 @@ var LeaferUI = (function (exports) {
10961
11063
  }
10962
11064
 
10963
11065
  const { get: get$1, scale: scale$2, copy: copy$4 } = MatrixHelper;
10964
- const { ceil: ceil$1, abs: abs$4 } = Math;
11066
+ const { ceil: ceil$1, abs: abs$3 } = Math;
10965
11067
  function createPattern(ui, paint, pixelRatio) {
10966
- let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11068
+ let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
10967
11069
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
10968
11070
  if (paint.patternId !== id && !ui.destroyed) {
10969
- scaleX = abs$4(scaleX);
10970
- scaleY = abs$4(scaleY);
10971
11071
  const { image, data } = paint;
10972
11072
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
10973
11073
  if (sx) {
10974
- sx = abs$4(sx);
10975
- sy = abs$4(sy);
11074
+ sx = abs$3(sx);
11075
+ sy = abs$3(sy);
10976
11076
  imageMatrix = get$1();
10977
11077
  copy$4(imageMatrix, transform);
10978
11078
  scale$2(imageMatrix, 1 / sx, 1 / sy);
@@ -11025,9 +11125,8 @@ var LeaferUI = (function (exports) {
11025
11125
  }
11026
11126
  }
11027
11127
 
11028
- const { abs: abs$3 } = Math;
11029
11128
  function checkImage(ui, canvas, paint, allowDraw) {
11030
- const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11129
+ const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
11031
11130
  const { pixelRatio } = canvas, { data } = paint;
11032
11131
  if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
11033
11132
  return false;
@@ -11040,8 +11139,8 @@ var LeaferUI = (function (exports) {
11040
11139
  else {
11041
11140
  if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
11042
11141
  let { width, height } = data;
11043
- width *= abs$3(scaleX) * pixelRatio;
11044
- height *= abs$3(scaleY) * pixelRatio;
11142
+ width *= scaleX * pixelRatio;
11143
+ height *= scaleY * pixelRatio;
11045
11144
  if (data.scaleX) {
11046
11145
  width *= data.scaleX;
11047
11146
  height *= data.scaleY;
@@ -11051,6 +11150,10 @@ var LeaferUI = (function (exports) {
11051
11150
  }
11052
11151
  }
11053
11152
  if (allowDraw) {
11153
+ if (ui.__.__isFastShadow) {
11154
+ canvas.fillStyle = paint.style || '#000';
11155
+ canvas.fill();
11156
+ }
11054
11157
  drawImage(ui, canvas, paint, data);
11055
11158
  return true;
11056
11159
  }
@@ -11239,10 +11342,7 @@ var LeaferUI = (function (exports) {
11239
11342
  }
11240
11343
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
11241
11344
  }
11242
- if (ui.__worldFlipped)
11243
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11244
- else
11245
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11345
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11246
11346
  if (end && index < end)
11247
11347
  other.clearWorld(copyBounds, true);
11248
11348
  });
@@ -11301,10 +11401,7 @@ var LeaferUI = (function (exports) {
11301
11401
  copyBounds = bounds;
11302
11402
  }
11303
11403
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
11304
- if (ui.__worldFlipped)
11305
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11306
- else
11307
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11404
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11308
11405
  if (end && index < end)
11309
11406
  other.clearWorld(copyBounds, true);
11310
11407
  });
@@ -11360,12 +11457,11 @@ var LeaferUI = (function (exports) {
11360
11457
  contentCanvas = getCanvas(canvas);
11361
11458
  child.__render(maskCanvas, options);
11362
11459
  }
11363
- if (!(mask === 'clipping' || mask === 'clipping-path'))
11364
- continue;
11365
- }
11366
- if (excludeRenderBounds(child, options))
11460
+ if (mask === 'clipping' || mask === 'clipping-path')
11461
+ excludeRenderBounds(child, options) || child.__render(canvas, options);
11367
11462
  continue;
11368
- child.__render(contentCanvas || canvas, options);
11463
+ }
11464
+ excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
11369
11465
  }
11370
11466
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
11371
11467
  };
@@ -11983,6 +12079,8 @@ var LeaferUI = (function (exports) {
11983
12079
  if (isSelect) {
11984
12080
  if (value instanceof Array && value.length > 1 && value[0].locked)
11985
12081
  value.splice(0, 1);
12082
+ if (this.single)
12083
+ this.element.syncEventer = null;
11986
12084
  const { beforeSelect } = this.config;
11987
12085
  if (beforeSelect) {
11988
12086
  const check = beforeSelect({ target: value });
@@ -12006,9 +12104,11 @@ var LeaferUI = (function (exports) {
12006
12104
  return (target, key) => {
12007
12105
  defineKey(target, key, {
12008
12106
  get() {
12009
- const { config, element, dragPoint } = this, mergeConfig = Object.assign({}, config);
12107
+ const { config, element, dragPoint, editBox } = this, mergeConfig = Object.assign({}, config);
12010
12108
  if (element && element.editConfig)
12011
12109
  Object.assign(mergeConfig, element.editConfig);
12110
+ if (editBox.config)
12111
+ Object.assign(mergeConfig, editBox.config);
12012
12112
  if (dragPoint) {
12013
12113
  if (dragPoint.editConfig)
12014
12114
  Object.assign(mergeConfig, dragPoint.editConfig);
@@ -12040,14 +12140,17 @@ var LeaferUI = (function (exports) {
12040
12140
  this.strokeAlign = 'center';
12041
12141
  }
12042
12142
  setTarget(target, style) {
12043
- this.set(style);
12143
+ if (style)
12144
+ this.set(style);
12044
12145
  this.target = target;
12045
12146
  this.update();
12046
12147
  }
12047
- update() {
12148
+ update(style) {
12048
12149
  const { list } = this;
12049
12150
  if (list.length) {
12050
12151
  setListWithFn(bounds$2, list, worldBounds);
12152
+ if (style)
12153
+ this.set(style);
12051
12154
  this.set(bounds$2);
12052
12155
  this.visible = true;
12053
12156
  }
@@ -12190,15 +12293,14 @@ var LeaferUI = (function (exports) {
12190
12293
  }
12191
12294
  onSelect() {
12192
12295
  if (this.running) {
12193
- const { mergeConfig, list } = this.editor;
12194
- const { stroke, strokeWidth, selectedStyle } = mergeConfig;
12195
- this.targetStroker.setTarget(list, Object.assign({ stroke, strokeWidth: Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
12296
+ this.targetStroker.setTarget(this.editor.list);
12196
12297
  this.hoverStroker.target = null;
12197
12298
  }
12198
12299
  }
12199
12300
  update() {
12200
12301
  this.hoverStroker.update();
12201
- this.targetStroker.update();
12302
+ const { stroke, strokeWidth, selectedStyle } = this.editor.mergedConfig;
12303
+ this.targetStroker.update(Object.assign({ stroke, strokeWidth: strokeWidth && Math.max(1, strokeWidth / 2) }, (selectedStyle || {})));
12202
12304
  }
12203
12305
  onPointerMove(e) {
12204
12306
  const { app, editor } = this;
@@ -12474,15 +12576,17 @@ var LeaferUI = (function (exports) {
12474
12576
  toPoint(around || align, boxBounds, origin, true);
12475
12577
  if (dragBounds) {
12476
12578
  const allowBounds = dragBounds === 'parent' ? target.parent.boxBounds : dragBounds;
12477
- const localBounds = new Bounds(target.__localBoxBounds);
12478
- localBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
12479
- if (!BoundsHelper.includes(allowBounds, localBounds)) {
12480
- const realBounds = localBounds.getIntersect(allowBounds);
12481
- const fitScaleX = realBounds.width / localBounds.width, fitScaleY = realBounds.height / localBounds.height;
12482
- if (useScaleX)
12483
- scaleX *= fitScaleX;
12484
- if (useScaleY)
12485
- scaleY *= fitScaleY;
12579
+ const childBounds = new Bounds(target.__localBoxBounds);
12580
+ if (BoundsHelper.includes(new Bounds(allowBounds).spread(0.1), childBounds)) {
12581
+ childBounds.scaleOf(target.getLocalPointByInner(origin), scaleX, scaleY);
12582
+ if (!BoundsHelper.includes(allowBounds, childBounds)) {
12583
+ const realBounds = childBounds.getIntersect(allowBounds);
12584
+ const fitScaleX = realBounds.width / childBounds.width, fitScaleY = realBounds.height / childBounds.height;
12585
+ if (useScaleX)
12586
+ scaleX *= fitScaleX;
12587
+ if (useScaleY)
12588
+ scaleY *= fitScaleY;
12589
+ }
12486
12590
  }
12487
12591
  }
12488
12592
  if (useScaleX && widthRange) {
@@ -12617,9 +12721,9 @@ var LeaferUI = (function (exports) {
12617
12721
  };
12618
12722
 
12619
12723
  const cacheCursors = {};
12620
- function updateCursor(editBox, e) {
12621
- const { enterPoint: point } = editBox;
12622
- if (!point || !editBox.editor.editing || !editBox.visible)
12724
+ function updatePointCursor(editBox, e) {
12725
+ const { enterPoint: point, dragging, skewing, resizing, flippedX, flippedY } = editBox;
12726
+ if (!point || !editBox.editor.editing || !editBox.canUse)
12623
12727
  return;
12624
12728
  if (point.name === 'circle')
12625
12729
  return;
@@ -12628,13 +12732,15 @@ var LeaferUI = (function (exports) {
12628
12732
  point.cursor = 'pointer';
12629
12733
  return;
12630
12734
  }
12631
- let { rotation, flippedX, flippedY } = editBox;
12735
+ let { rotation } = editBox;
12632
12736
  const { pointType } = point, { resizeCursor, rotateCursor, skewCursor, resizeable, rotateable, skewable } = editBox.mergeConfig;
12633
12737
  let showResize = pointType.includes('resize');
12634
12738
  if (showResize && rotateable && (e.metaKey || e.ctrlKey || !resizeable))
12635
12739
  showResize = false;
12636
12740
  const showSkew = skewable && !showResize && (point.name === 'resize-line' || pointType === 'skew');
12637
- const cursor = showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor);
12741
+ const cursor = dragging
12742
+ ? (skewing ? skewCursor : (resizing ? resizeCursor : rotateCursor))
12743
+ : (showSkew ? skewCursor : (showResize ? resizeCursor : rotateCursor));
12638
12744
  rotation += (EditDataHelper.getFlipDirection(point.direction, flippedX, flippedY) + 1) * 45;
12639
12745
  rotation = Math.round(MathHelper.formatRotation(rotation, true) / 2) * 2;
12640
12746
  const { url, x, y } = cursor;
@@ -12648,7 +12754,8 @@ var LeaferUI = (function (exports) {
12648
12754
  }
12649
12755
  function updateMoveCursor(editBox) {
12650
12756
  const { moveCursor, moveable } = editBox.mergeConfig;
12651
- editBox.rect.cursor = moveable ? moveCursor : undefined;
12757
+ if (editBox.canUse)
12758
+ editBox.rect.cursor = moveable ? moveCursor : undefined;
12652
12759
  }
12653
12760
  function toDataURL(svg, rotation) {
12654
12761
  return '"data:image/svg+xml,' + encodeURIComponent(svg.replace('{{rotation}}', rotation.toString())) + '"';
@@ -12664,8 +12771,8 @@ var LeaferUI = (function (exports) {
12664
12771
  const fourDirection = ['top', 'right', 'bottom', 'left'], editConfig = undefined;
12665
12772
  class EditBox extends exports.Group {
12666
12773
  get mergeConfig() {
12667
- const { config } = this, { mergeConfig } = this.editor;
12668
- return this.mergedConfig = config ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
12774
+ const { config } = this, { mergeConfig, editBox } = this.editor;
12775
+ return this.mergedConfig = config && (editBox !== this) ? Object.assign(Object.assign({}, mergeConfig), config) : mergeConfig;
12669
12776
  }
12670
12777
  get target() { return this._target || this.editor.element; }
12671
12778
  set target(target) { this._target = target; }
@@ -12676,6 +12783,13 @@ var LeaferUI = (function (exports) {
12676
12783
  get flippedX() { return this.scaleX < 0; }
12677
12784
  get flippedY() { return this.scaleY < 0; }
12678
12785
  get flippedOne() { return this.scaleX * this.scaleY < 0; }
12786
+ get canUse() { return (this.visible && this.view.visible); }
12787
+ get canGesture() {
12788
+ if (!this.canUse)
12789
+ return false;
12790
+ const { moveable, resizeable, rotateable } = this.mergeConfig;
12791
+ return typeof moveable === 'string' || typeof resizeable === 'string' || typeof rotateable === 'string';
12792
+ }
12679
12793
  constructor(editor) {
12680
12794
  super();
12681
12795
  this.view = new exports.Group();
@@ -12722,8 +12836,7 @@ var LeaferUI = (function (exports) {
12722
12836
  for (let i = 0; i < 8; i++) {
12723
12837
  resizeP = resizePoints[i];
12724
12838
  resizeP.set(this.getPointStyle((i % 2) ? middlePointsStyle[((i - 1) / 2) % middlePointsStyle.length] : pointsStyle[(i / 2) % pointsStyle.length]));
12725
- if (!(i % 2))
12726
- resizeP.rotation = (i / 2) * 90;
12839
+ resizeP.rotation = ((i - (i % 2 ? 1 : 0)) / 2) * 90;
12727
12840
  }
12728
12841
  circle.set(this.getPointStyle(mergeConfig.circle || mergeConfig.rotatePoint || pointsStyle[0]));
12729
12842
  rect.set(Object.assign({ stroke, strokeWidth, editConfig }, (mergeConfig.rect || {})));
@@ -12742,12 +12855,19 @@ var LeaferUI = (function (exports) {
12742
12855
  this.set({ x, y, scaleX, scaleY, rotation, skewX, skewY });
12743
12856
  this.updateBounds({ x: 0, y: 0, width, height });
12744
12857
  }
12858
+ unload() {
12859
+ this.visible = false;
12860
+ if (this.app)
12861
+ this.rect.syncEventer = this.app.interaction.bottomList = null;
12862
+ }
12745
12863
  updateBounds(bounds) {
12746
12864
  const { editMask } = this.editor;
12747
12865
  const { mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this;
12748
- const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask } = mergeConfig;
12866
+ const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, mask, spread } = mergeConfig;
12749
12867
  this.visible = !this.target.locked;
12750
12868
  editMask.visible = mask ? true : 0;
12869
+ if (spread)
12870
+ BoundsHelper.spread(bounds, spread);
12751
12871
  if (this.view.worldOpacity) {
12752
12872
  const { width, height } = bounds;
12753
12873
  const smallSize = typeof hideOnSmall === 'number' ? hideOnSmall : 10;
@@ -12772,7 +12892,6 @@ var LeaferUI = (function (exports) {
12772
12892
  }
12773
12893
  else {
12774
12894
  resizeL.height = height;
12775
- resizeP.rotation = 90;
12776
12895
  if (hideOnSmall && resizeP.width * 2 > height)
12777
12896
  resizeP.visible = false;
12778
12897
  }
@@ -12827,9 +12946,6 @@ var LeaferUI = (function (exports) {
12827
12946
  buttons.y = point.y + margin;
12828
12947
  }
12829
12948
  }
12830
- unload() {
12831
- this.visible = false;
12832
- }
12833
12949
  getPointStyle(userStyle) {
12834
12950
  const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.mergedConfig;
12835
12951
  const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0, editConfig };
@@ -12843,20 +12959,26 @@ var LeaferUI = (function (exports) {
12843
12959
  const { middlePoint } = this.mergedConfig;
12844
12960
  return middlePoint instanceof Array ? middlePoint : (middlePoint ? [middlePoint] : this.getPointsStyle());
12845
12961
  }
12846
- onSelect(e) {
12847
- if (e.oldList.length === 1) {
12848
- e.oldList[0].syncEventer = null;
12849
- if (this.app)
12850
- this.app.interaction.bottomList = null;
12851
- }
12852
- }
12853
12962
  onDragStart(e) {
12854
12963
  this.dragging = true;
12855
12964
  const point = this.dragPoint = e.current, { pointType } = point;
12856
- const { editor, dragStartData } = this, { target } = this;
12965
+ const { editor, dragStartData } = this, { target } = this, { moveable, resizeable, rotateable, skewable, hideOnMove } = this.mergeConfig;
12857
12966
  if (point.name === 'rect') {
12858
- this.moving = true;
12859
- editor.opacity = this.mergeConfig.hideOnMove ? 0 : 1;
12967
+ moveable && (this.moving = true);
12968
+ editor.opacity = hideOnMove ? 0 : 1;
12969
+ }
12970
+ else {
12971
+ if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !resizeable) {
12972
+ rotateable && (this.rotating = true);
12973
+ if (pointType === 'resize-rotate')
12974
+ resizeable && (this.resizing = true);
12975
+ else if (point.name === 'resize-line')
12976
+ skewable && (this.skewing = true), this.rotating = false;
12977
+ }
12978
+ else if (pointType === 'resize')
12979
+ resizeable && (this.resizing = true);
12980
+ if (pointType === 'skew')
12981
+ skewable && (this.skewing = true);
12860
12982
  }
12861
12983
  dragStartData.x = e.x;
12862
12984
  dragStartData.y = e.y;
@@ -12867,9 +12989,8 @@ var LeaferUI = (function (exports) {
12867
12989
  ResizeEvent.resizingKeys = editor.leafList.keys;
12868
12990
  }
12869
12991
  onDragEnd(e) {
12870
- this.dragging = false;
12871
12992
  this.dragPoint = null;
12872
- this.moving = false;
12993
+ this.resetDoing();
12873
12994
  const { name, pointType } = e.current;
12874
12995
  if (name === 'rect')
12875
12996
  this.editor.opacity = 1;
@@ -12877,31 +12998,61 @@ var LeaferUI = (function (exports) {
12877
12998
  ResizeEvent.resizingKeys = null;
12878
12999
  }
12879
13000
  onDrag(e) {
12880
- const { transformTool } = this, point = e.current;
12881
- if (point.name === 'rect') {
13001
+ const { transformTool, moving, resizing, rotating, skewing } = this;
13002
+ if (moving) {
12882
13003
  transformTool.onMove(e);
12883
13004
  updateMoveCursor(this);
12884
13005
  }
12885
- else {
12886
- const { pointType } = this.enterPoint = point;
12887
- if (pointType.includes('rotate') || e.metaKey || e.ctrlKey || !this.mergeConfig.resizeable) {
13006
+ else if (resizing || rotating || skewing) {
13007
+ const point = e.current;
13008
+ if (point.pointType)
13009
+ this.enterPoint = point;
13010
+ if (rotating)
12888
13011
  transformTool.onRotate(e);
12889
- if (pointType === 'resize-rotate')
12890
- transformTool.onScale(e);
12891
- }
12892
- else if (pointType === 'resize')
13012
+ if (resizing)
12893
13013
  transformTool.onScale(e);
12894
- if (pointType === 'skew')
13014
+ if (skewing)
12895
13015
  transformTool.onSkew(e);
12896
- updateCursor(this, e);
13016
+ updatePointCursor(this, e);
13017
+ }
13018
+ }
13019
+ resetDoing() {
13020
+ if (this.canUse)
13021
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
13022
+ }
13023
+ onMove(e) {
13024
+ if (this.canGesture && e.moveType !== 'drag') {
13025
+ e.stop();
13026
+ if (typeof this.mergeConfig.moveable === 'string') {
13027
+ this.gesturing = this.moving = true;
13028
+ this.transformTool.onMove(e);
13029
+ }
13030
+ }
13031
+ }
13032
+ onScale(e) {
13033
+ if (this.canGesture) {
13034
+ e.stop();
13035
+ if (typeof this.mergeConfig.resizeable === 'string') {
13036
+ this.gesturing = this.resizing = true;
13037
+ this.transformTool.onScale(e);
13038
+ }
13039
+ }
13040
+ }
13041
+ onRotate(e) {
13042
+ if (this.canGesture) {
13043
+ e.stop();
13044
+ if (typeof this.mergeConfig.rotateable === 'string') {
13045
+ this.gesturing = this.rotating = true;
13046
+ this.transformTool.onRotate(e);
13047
+ }
12897
13048
  }
12898
13049
  }
12899
13050
  onKey(e) {
12900
- updateCursor(this, e);
13051
+ updatePointCursor(this, e);
12901
13052
  }
12902
13053
  onArrow(e) {
12903
- const { editor } = this;
12904
- if (editor.editing && this.mergeConfig.keyEvent) {
13054
+ const { editor, transformTool } = this;
13055
+ if (this.canUse && editor.editing && this.mergeConfig.keyEvent) {
12905
13056
  let x = 0, y = 0;
12906
13057
  const distance = e.shiftKey ? 10 : 1;
12907
13058
  switch (e.code) {
@@ -12918,7 +13069,7 @@ var LeaferUI = (function (exports) {
12918
13069
  x = distance;
12919
13070
  }
12920
13071
  if (x || y)
12921
- editor.move(x, y);
13072
+ transformTool.move(x, y);
12922
13073
  }
12923
13074
  }
12924
13075
  onDoubleTap(e) {
@@ -12961,12 +13112,12 @@ var LeaferUI = (function (exports) {
12961
13112
  [exports.PointerEvent.LEAVE, () => { this.enterPoint = null; }],
12962
13113
  ];
12963
13114
  if (point.name !== 'circle')
12964
- events.push([exports.PointerEvent.ENTER, (e) => { this.enterPoint = point, updateCursor(this, e); }]);
13115
+ events.push([exports.PointerEvent.ENTER, (e) => { this.enterPoint = point, updatePointCursor(this, e); }]);
12965
13116
  this.__eventIds.push(point.on_(events));
12966
13117
  }
12967
13118
  __listenEvents() {
12968
13119
  const { rect, editor, __eventIds: events } = this;
12969
- events.push(editor.on_(EditorEvent.SELECT, this.onSelect, this), rect.on_([
13120
+ events.push(rect.on_([
12970
13121
  [exports.DragEvent.START, this.onDragStart, this],
12971
13122
  [exports.DragEvent.DRAG, this.onDrag, this],
12972
13123
  [exports.DragEvent.END, this.onDragEnd, this],
@@ -12977,7 +13128,13 @@ var LeaferUI = (function (exports) {
12977
13128
  this.waitLeafer(() => {
12978
13129
  events.push(editor.app.on_([
12979
13130
  [[exports.KeyEvent.HOLD, exports.KeyEvent.UP], this.onKey, this],
12980
- [exports.KeyEvent.DOWN, this.onArrow, this]
13131
+ [exports.KeyEvent.DOWN, this.onArrow, this],
13132
+ [exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true],
13133
+ [exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
13134
+ [exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
13135
+ [exports.MoveEvent.END, this.resetDoing, this],
13136
+ [exports.ZoomEvent.END, this.resetDoing, this],
13137
+ [exports.RotateEvent.END, this.resetDoing, this],
12981
13138
  ]));
12982
13139
  });
12983
13140
  }
@@ -13133,7 +13290,8 @@ ${filterStyle$1}
13133
13290
  editor.simulateTarget.remove();
13134
13291
  editor.leafList.reset();
13135
13292
  }
13136
- editor.closeInnerEditor();
13293
+ editor.closeInnerEditor(true);
13294
+ editor.unloadEditTool();
13137
13295
  const data = { editor, value: target, oldValue };
13138
13296
  editor.emitEvent(new EditorEvent(EditorEvent.SELECT, data));
13139
13297
  editor.checkOpenedGroups();
@@ -13353,16 +13511,10 @@ ${filterStyle$1}
13353
13511
 
13354
13512
  class TransformTool {
13355
13513
  onMove(e) {
13356
- const { target, mergeConfig, dragStartData } = this.editBox;
13514
+ const { target, dragStartData } = this.editBox;
13357
13515
  if (e instanceof exports.MoveEvent) {
13358
- if (e.moveType !== 'drag') {
13359
- const { moveable, resizeable } = mergeConfig;
13360
- const move = e.getLocalMove(target);
13361
- if (moveable === 'move')
13362
- e.stop(), this.move(move.x, move.y);
13363
- else if (resizeable === 'zoom')
13364
- e.stop();
13365
- }
13516
+ const move = e.getLocalMove(target);
13517
+ this.move(move.x, move.y);
13366
13518
  }
13367
13519
  else {
13368
13520
  const total = { x: e.totalX, y: e.totalY };
@@ -13377,10 +13529,9 @@ ${filterStyle$1}
13377
13529
  }
13378
13530
  onScale(e) {
13379
13531
  const { target, mergeConfig, single, dragStartData } = this.editBox;
13380
- let { around, lockRatio, resizeable, flipable, editSize } = mergeConfig;
13532
+ let { around, lockRatio, flipable, editSize } = mergeConfig;
13381
13533
  if (e instanceof exports.ZoomEvent) {
13382
- if (resizeable === 'zoom')
13383
- e.stop(), this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
13534
+ this.scaleOf(target.getBoxPoint(e), e.scale, e.scale);
13384
13535
  }
13385
13536
  else {
13386
13537
  const { direction } = e.current;
@@ -13398,28 +13549,18 @@ ${filterStyle$1}
13398
13549
  }
13399
13550
  onRotate(e) {
13400
13551
  const { target, mergeConfig, dragStartData } = this.editBox;
13401
- const { skewable, rotateable, around, rotateGap } = mergeConfig;
13402
- const { direction, name } = e.current;
13403
- if (skewable && name === 'resize-line')
13404
- return this.onSkew(e);
13552
+ const { around, rotateAround, rotateGap } = mergeConfig;
13553
+ const { direction } = e.current;
13405
13554
  let origin, rotation;
13406
13555
  if (e instanceof exports.RotateEvent) {
13407
- if (rotateable === 'rotate')
13408
- e.stop(), rotation = e.rotation, origin = target.getBoxPoint(e);
13409
- else
13410
- return;
13411
- if (target.scaleX * target.scaleY < 0)
13412
- rotation = -rotation;
13556
+ rotation = e.rotation;
13557
+ origin = rotateAround ? AroundHelper.getPoint(rotateAround, target.boxBounds) : target.getBoxPoint(e);
13413
13558
  }
13414
13559
  else {
13415
- const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (target.around || target.origin || around || 'center'));
13416
- rotation = data.rotation;
13560
+ const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, e.shiftKey ? null : (rotateAround || target.around || target.origin || around || 'center'));
13561
+ rotation = dragStartData.rotation + data.rotation - target.rotation;
13417
13562
  origin = data.origin;
13418
13563
  }
13419
- if (target.scaleX * target.scaleY < 0)
13420
- rotation = -rotation;
13421
- if (e instanceof exports.DragEvent)
13422
- rotation = dragStartData.rotation + rotation - target.rotation;
13423
13564
  rotation = MathHelper.float(MathHelper.getGapRotation(rotation, rotateGap, target.rotation), 2);
13424
13565
  if (!rotation)
13425
13566
  return;
@@ -13585,9 +13726,13 @@ ${filterStyle$1}
13585
13726
  get groupOpening() { return !!this.openedGroupList.length; }
13586
13727
  get multiple() { return this.list.length > 1; }
13587
13728
  get single() { return this.list.length === 1; }
13729
+ get dragPoint() { return this.editBox.dragPoint; }
13588
13730
  get dragging() { return this.editBox.dragging; }
13731
+ get gesturing() { return this.editBox.gesturing; }
13589
13732
  get moving() { return this.editBox.moving; }
13590
- get dragPoint() { return this.editBox.dragPoint; }
13733
+ get resizing() { return this.editBox.resizing; }
13734
+ get rotating() { return this.editBox.rotating; }
13735
+ get skewing() { return this.editBox.skewing; }
13591
13736
  get element() { return this.multiple ? this.simulateTarget : this.list[0]; }
13592
13737
  get buttons() { return this.editBox.buttons; }
13593
13738
  constructor(userConfig, data) {
@@ -13644,19 +13789,22 @@ ${filterStyle$1}
13644
13789
  this.update();
13645
13790
  }
13646
13791
  updateEditTool() {
13792
+ this.unloadEditTool();
13793
+ if (this.editing) {
13794
+ const name = this.element.editOuter || 'EditTool';
13795
+ const tool = this.editTool = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
13796
+ this.editBox.load();
13797
+ tool.load();
13798
+ this.update();
13799
+ }
13800
+ }
13801
+ unloadEditTool() {
13647
13802
  let tool = this.editTool;
13648
13803
  if (tool) {
13649
13804
  this.editBox.unload();
13650
13805
  tool.unload();
13651
13806
  this.editTool = null;
13652
13807
  }
13653
- if (this.editing) {
13654
- const tag = this.element.editOuter || 'EditTool';
13655
- tool = this.editTool = this.editToolList[tag] = this.editToolList[tag] || EditToolCreator.get(tag, this);
13656
- this.editBox.load();
13657
- tool.load();
13658
- this.update();
13659
- }
13660
13808
  }
13661
13809
  getEditSize(_ui) {
13662
13810
  return this.mergeConfig.editSize;
@@ -13730,16 +13878,21 @@ ${filterStyle$1}
13730
13878
  if (group)
13731
13879
  group.emitEvent(event);
13732
13880
  }
13733
- openInnerEditor(target, select) {
13881
+ openInnerEditor(target, nameOrSelect, select) {
13882
+ let name;
13883
+ if (typeof nameOrSelect === 'string')
13884
+ name = nameOrSelect;
13885
+ else if (!select)
13886
+ select = nameOrSelect;
13734
13887
  if (target && select)
13735
13888
  this.target = target;
13736
13889
  if (this.single) {
13737
13890
  const editTarget = target || this.element;
13738
- const tag = editTarget.editInner;
13739
- if (tag && EditToolCreator.list[tag]) {
13891
+ name || (name = editTarget.editInner);
13892
+ if (name && EditToolCreator.list[name]) {
13740
13893
  this.editTool.unload();
13741
13894
  this.innerEditing = true;
13742
- this.innerEditor = this.editToolList[tag] || EditToolCreator.get(tag, this);
13895
+ this.innerEditor = this.editToolList[name] = this.editToolList[name] || EditToolCreator.get(name, this);
13743
13896
  this.innerEditor.editTarget = editTarget;
13744
13897
  this.emitInnerEvent(InnerEditorEvent.BEFORE_OPEN);
13745
13898
  this.innerEditor.load();
@@ -13747,13 +13900,14 @@ ${filterStyle$1}
13747
13900
  }
13748
13901
  }
13749
13902
  }
13750
- closeInnerEditor() {
13903
+ closeInnerEditor(onlyInnerEditor) {
13751
13904
  if (this.innerEditing) {
13752
13905
  this.innerEditing = false;
13753
13906
  this.emitInnerEvent(InnerEditorEvent.BEFORE_CLOSE);
13754
13907
  this.innerEditor.unload();
13755
13908
  this.emitInnerEvent(InnerEditorEvent.CLOSE);
13756
- this.editTool.load();
13909
+ if (!onlyInnerEditor)
13910
+ this.updateEditTool();
13757
13911
  this.innerEditor = null;
13758
13912
  }
13759
13913
  }
@@ -13796,12 +13950,7 @@ ${filterStyle$1}
13796
13950
  const { app, leafer, editMask } = this;
13797
13951
  this.targetEventIds = [
13798
13952
  leafer.on_(RenderEvent.START, this.onRenderStart, this),
13799
- app.on_([
13800
- [RenderEvent.CHILD_START, this.onAppRenderStart, this],
13801
- [exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true],
13802
- [exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true],
13803
- [exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true],
13804
- ])
13953
+ app.on_(RenderEvent.CHILD_START, this.onAppRenderStart, this)
13805
13954
  ];
13806
13955
  if (editMask.visible)
13807
13956
  editMask.forceRender();
@@ -14289,7 +14438,7 @@ ${filterStyle$1}
14289
14438
  };
14290
14439
  exports.Box.addAttr('textBox', false, dataType);
14291
14440
  exports.UI.addAttr('editConfig', undefined, dataType);
14292
- exports.UI.addAttr('editOuter', (ui) => ui.__.__isLinePath ? 'LineEditTool' : 'EditTool', dataType);
14441
+ exports.UI.addAttr('editOuter', (ui) => { ui.updateLayout(); return ui.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }, dataType);
14293
14442
  exports.UI.addAttr('editInner', 'PathEditor', dataType);
14294
14443
  exports.Group.addAttr('editInner', '', dataType);
14295
14444
  exports.Text.addAttr('editInner', 'TextEditor', dataType);
@@ -15981,9 +16130,8 @@ ${filterStyle$1}
15981
16130
  }
15982
16131
  };
15983
16132
  box.__updateBoxBounds = function (secondLayout) {
15984
- const data = this.__;
15985
16133
  if (this.children.length && !this.pathInputed) {
15986
- const { flow } = data;
16134
+ const data = this.__, { flow } = data;
15987
16135
  if (data.__autoSide) {
15988
16136
  if (data.__hasSurface)
15989
16137
  this.__extraUpdate();
@@ -16215,6 +16363,11 @@ ${filterStyle$1}
16215
16363
  this.play();
16216
16364
  }, 0);
16217
16365
  }
16366
+ emitType(type) {
16367
+ this.emit(type, this);
16368
+ if (this.parent)
16369
+ this.parent.onChildEvent(type, this);
16370
+ }
16218
16371
  play() {
16219
16372
  if (this.destroyed)
16220
16373
  return;
@@ -16223,20 +16376,20 @@ ${filterStyle$1}
16223
16376
  this.clearTimer(), this.start();
16224
16377
  else if (!this.timer)
16225
16378
  this.requestAnimate();
16226
- this.emit(AnimateEvent.PLAY, this);
16379
+ this.emitType(AnimateEvent.PLAY);
16227
16380
  }
16228
16381
  pause() {
16229
16382
  if (this.destroyed)
16230
16383
  return;
16231
16384
  this.running = false;
16232
16385
  this.clearTimer();
16233
- this.emit(AnimateEvent.PAUSE, this);
16386
+ this.emitType(AnimateEvent.PAUSE);
16234
16387
  }
16235
16388
  stop() {
16236
16389
  if (this.destroyed)
16237
16390
  return;
16238
16391
  this.complete();
16239
- this.emit(AnimateEvent.STOP, this);
16392
+ this.emitType(AnimateEvent.STOP);
16240
16393
  }
16241
16394
  seek(time) {
16242
16395
  if (this.destroyed)
@@ -16250,7 +16403,7 @@ ${filterStyle$1}
16250
16403
  this.time = time;
16251
16404
  this.animate(0, true);
16252
16405
  this.clearTimer(() => this.requestAnimate());
16253
- this.emit(AnimateEvent.SEEK, this);
16406
+ this.emitType(AnimateEvent.SEEK);
16254
16407
  }
16255
16408
  kill(complete = true, killStyle) {
16256
16409
  this.killStyle = killStyle;
@@ -16317,7 +16470,7 @@ ${filterStyle$1}
16317
16470
  if (totalTime)
16318
16471
  this.changeDuration(totalTime);
16319
16472
  }
16320
- this.emit(AnimateEvent.CREATED, this);
16473
+ this.emitType(AnimateEvent.CREATED);
16321
16474
  }
16322
16475
  changeDuration(duration) {
16323
16476
  const { config } = this;
@@ -16437,7 +16590,7 @@ ${filterStyle$1}
16437
16590
  key in killStyle || (style[key] = endingStyle[key]);
16438
16591
  this.setStyle(style);
16439
16592
  this.clearTimer();
16440
- this.emit(AnimateEvent.COMPLETED, this);
16593
+ this.emitType(AnimateEvent.COMPLETED);
16441
16594
  }
16442
16595
  setFrom() {
16443
16596
  this.nowIndex = 0;
@@ -16481,7 +16634,7 @@ ${filterStyle$1}
16481
16634
  Transition.setBetweenStyle(betweenStyle, fromStyle, toStyle, style, t, target, attrsMap);
16482
16635
  this.setStyle(betweenStyle);
16483
16636
  }
16484
- this.emit(AnimateEvent.UPDATE, this);
16637
+ this.emitType(AnimateEvent.UPDATE);
16485
16638
  }
16486
16639
  setStyle(style) {
16487
16640
  const { target } = this;
@@ -16525,7 +16678,7 @@ ${filterStyle$1}
16525
16678
  this.stop();
16526
16679
  else
16527
16680
  this.pause();
16528
- this.target = this.config = this.frames = this.fromStyle = this.toStyle = this.style = this.killStyle = null;
16681
+ this.target = this.parent = this.config = this.frames = this.fromStyle = this.toStyle = this.style = this.killStyle = null;
16529
16682
  this.destroyed = true;
16530
16683
  }
16531
16684
  }
@@ -16591,6 +16744,7 @@ ${filterStyle$1}
16591
16744
  });
16592
16745
  this.list = animation.map(item => {
16593
16746
  const animate = item.target ? item : new exports.Animate(this.target, item, isTemp);
16747
+ animate.parent = this;
16594
16748
  Object.assign(this.fromStyle, animate.fromStyle);
16595
16749
  Object.assign(this.toStyle, animate.toStyle);
16596
16750
  Object.assign(this._endingStyle, animate.endingStyle);
@@ -16599,20 +16753,34 @@ ${filterStyle$1}
16599
16753
  }
16600
16754
  play() {
16601
16755
  this.each(item => item.play());
16756
+ this.emitType(AnimateEvent.PLAY);
16602
16757
  }
16603
16758
  pause() {
16604
16759
  this.each(item => item.pause());
16760
+ this.emitType(AnimateEvent.PAUSE);
16605
16761
  }
16606
16762
  stop() {
16607
16763
  this.each(item => item.stop());
16764
+ this.emitType(AnimateEvent.STOP);
16608
16765
  }
16609
16766
  seek(time) {
16610
16767
  this.each(item => item.seek(time));
16768
+ this.emitType(AnimateEvent.SEEK);
16611
16769
  }
16612
16770
  kill(complete, killStyle) {
16613
16771
  this.each(item => item.kill(complete, killStyle));
16614
16772
  this.destroy();
16615
16773
  }
16774
+ onChildEvent(type, _animate) {
16775
+ switch (type) {
16776
+ case AnimateEvent.COMPLETED:
16777
+ if (this.completed)
16778
+ this.emitType(type);
16779
+ break;
16780
+ case AnimateEvent.UPDATE:
16781
+ this.emitType(type);
16782
+ }
16783
+ }
16616
16784
  each(func) {
16617
16785
  this.list.forEach(func);
16618
16786
  }
@@ -18071,123 +18239,131 @@ ${filterStyle$1}
18071
18239
  index++;
18072
18240
  }
18073
18241
  const bounds = new Bounds();
18074
- toBounds(pointBounds, bounds);
18075
- return bounds.scale(1 / canvas.pixelRatio).ceil();
18242
+ if (pointBounds) {
18243
+ toBounds(pointBounds, bounds);
18244
+ bounds.scale(1 / canvas.pixelRatio).ceil();
18245
+ }
18246
+ return bounds;
18076
18247
  }
18077
18248
 
18078
18249
  const ExportModule = {
18079
18250
  syncExport(leaf, filename, options) {
18080
- this.running = true;
18251
+ Export.running = true;
18081
18252
  let result;
18082
- const fileType = FileHelper.fileType(filename);
18083
- const isDownload = filename.includes('.');
18084
- options = FileHelper.getExportOptions(options);
18085
- const { toURL } = Platform;
18086
- const { download } = Platform.origin;
18087
- if (fileType === 'json') {
18088
- isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
18089
- result = { data: isDownload ? true : leaf.toJSON(options.json) };
18090
- }
18091
- else if (fileType === 'svg') {
18092
- isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
18093
- result = { data: isDownload ? true : leaf.toSVG() };
18094
- }
18095
- else {
18096
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
18097
- const { worldTransform, isLeafer, leafer, isFrame } = leaf;
18098
- const { slice, clip, trim, screenshot, padding, onCanvas } = options;
18099
- const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
18100
- const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
18101
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
18102
- const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
18103
- if (screenshot) {
18104
- renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
18253
+ try {
18254
+ const fileType = FileHelper.fileType(filename);
18255
+ const isDownload = filename.includes('.');
18256
+ options = FileHelper.getExportOptions(options);
18257
+ const { toURL } = Platform;
18258
+ const { download } = Platform.origin;
18259
+ if (fileType === 'json') {
18260
+ isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
18261
+ result = { data: isDownload ? true : leaf.toJSON(options.json) };
18262
+ }
18263
+ else if (fileType === 'svg') {
18264
+ isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
18265
+ result = { data: isDownload ? true : leaf.toSVG() };
18105
18266
  }
18106
18267
  else {
18107
- let relative = options.relative || (isLeafer ? 'inner' : 'local');
18108
- scaleX = worldTransform.scaleX;
18109
- scaleY = worldTransform.scaleY;
18110
- switch (relative) {
18111
- case 'inner':
18112
- matrix.set(worldTransform);
18113
- break;
18114
- case 'local':
18115
- matrix.set(worldTransform).divide(leaf.localTransform);
18116
- scaleX /= leaf.scaleX;
18117
- scaleY /= leaf.scaleY;
18118
- break;
18119
- case 'world':
18120
- scaleX = 1;
18121
- scaleY = 1;
18122
- break;
18123
- case 'page':
18124
- relative = leafer || leaf;
18125
- default:
18126
- matrix.set(worldTransform).divide(leaf.getTransform(relative));
18127
- const l = relative.worldTransform;
18128
- scaleX /= scaleX / l.scaleX;
18129
- scaleY /= scaleY / l.scaleY;
18268
+ let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
18269
+ const { worldTransform, isLeafer, leafer, isFrame } = leaf;
18270
+ const { slice, clip, trim, screenshot, padding, onCanvas } = options;
18271
+ const smooth = options.smooth === undefined ? (leafer ? leafer.config.smooth : true) : options.smooth;
18272
+ const contextSettings = options.contextSettings || (leafer ? leafer.config.contextSettings : undefined);
18273
+ const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
18274
+ const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
18275
+ if (screenshot) {
18276
+ renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
18130
18277
  }
18131
- renderBounds = leaf.getBounds('render', relative);
18132
- }
18133
- const scaleData = { scaleX: 1, scaleY: 1 };
18134
- MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
18135
- let pixelRatio = options.pixelRatio || 1;
18136
- let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
18137
- if (clip)
18138
- x += clip.x, y += clip.y, width = clip.width, height = clip.height;
18139
- 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) };
18140
- let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
18141
- let sliceLeaf;
18142
- if (slice) {
18143
- sliceLeaf = leaf;
18144
- sliceLeaf.__worldOpacity = 0;
18145
- leaf = leafer || leaf;
18146
- renderOptions.bounds = canvas.bounds;
18147
- }
18148
- canvas.save();
18149
- if (isFrame && fill !== undefined) {
18150
- const oldFill = leaf.get('fill');
18151
- leaf.fill = '';
18152
- leaf.__render(canvas, renderOptions);
18153
- leaf.fill = oldFill;
18154
- }
18155
- else {
18156
- leaf.__render(canvas, renderOptions);
18157
- }
18158
- canvas.restore();
18159
- if (sliceLeaf)
18160
- sliceLeaf.__updateWorldOpacity();
18161
- if (trim) {
18162
- trimBounds = getTrimBounds(canvas);
18163
- const old = canvas, { width, height } = trimBounds;
18164
- const config = { x: 0, y: 0, width, height, pixelRatio };
18165
- canvas = Creator.canvas(config);
18166
- canvas.copyWorld(old, trimBounds, config);
18278
+ else {
18279
+ let relative = options.relative || (isLeafer ? 'inner' : 'local');
18280
+ scaleX = worldTransform.scaleX;
18281
+ scaleY = worldTransform.scaleY;
18282
+ switch (relative) {
18283
+ case 'inner':
18284
+ matrix.set(worldTransform);
18285
+ break;
18286
+ case 'local':
18287
+ matrix.set(worldTransform).divide(leaf.localTransform);
18288
+ scaleX /= leaf.scaleX;
18289
+ scaleY /= leaf.scaleY;
18290
+ break;
18291
+ case 'world':
18292
+ scaleX = 1;
18293
+ scaleY = 1;
18294
+ break;
18295
+ case 'page':
18296
+ relative = leafer || leaf;
18297
+ default:
18298
+ matrix.set(worldTransform).divide(leaf.getTransform(relative));
18299
+ const l = relative.worldTransform;
18300
+ scaleX /= scaleX / l.scaleX;
18301
+ scaleY /= scaleY / l.scaleY;
18302
+ }
18303
+ renderBounds = leaf.getBounds('render', relative);
18304
+ }
18305
+ const scaleData = { scaleX: 1, scaleY: 1 };
18306
+ MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
18307
+ let pixelRatio = options.pixelRatio || 1;
18308
+ let { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
18309
+ if (clip)
18310
+ x += clip.x, y += clip.y, width = clip.width, height = clip.height;
18311
+ 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) };
18312
+ let canvas = Creator.canvas({ width: Math.floor(width), height: Math.floor(height), pixelRatio, smooth, contextSettings });
18313
+ let sliceLeaf;
18314
+ if (slice) {
18315
+ sliceLeaf = leaf;
18316
+ sliceLeaf.__worldOpacity = 0;
18317
+ leaf = leafer || leaf;
18318
+ renderOptions.bounds = canvas.bounds;
18319
+ }
18320
+ canvas.save();
18321
+ if (isFrame && fill !== undefined) {
18322
+ const oldFill = leaf.get('fill');
18323
+ leaf.fill = '';
18324
+ leaf.__render(canvas, renderOptions);
18325
+ leaf.fill = oldFill;
18326
+ }
18327
+ else {
18328
+ leaf.__render(canvas, renderOptions);
18329
+ }
18330
+ canvas.restore();
18331
+ if (sliceLeaf)
18332
+ sliceLeaf.__updateWorldOpacity();
18333
+ if (trim) {
18334
+ trimBounds = getTrimBounds(canvas);
18335
+ const old = canvas, { width, height } = trimBounds;
18336
+ const config = { x: 0, y: 0, width, height, pixelRatio };
18337
+ canvas = Creator.canvas(config);
18338
+ canvas.copyWorld(old, trimBounds, config);
18339
+ }
18340
+ if (padding) {
18341
+ const [top, right, bottom, left] = MathHelper.fourNumber(padding);
18342
+ const old = canvas, { width, height } = old;
18343
+ canvas = Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
18344
+ canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
18345
+ }
18346
+ if (needFill)
18347
+ canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
18348
+ if (onCanvas)
18349
+ onCanvas(canvas);
18350
+ const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
18351
+ result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
18167
18352
  }
18168
- if (padding) {
18169
- const [top, right, bottom, left] = MathHelper.fourNumber(padding);
18170
- const old = canvas, { width, height } = old;
18171
- canvas = Creator.canvas({ width: width + left + right, height: height + top + bottom, pixelRatio });
18172
- canvas.copyWorld(old, old.bounds, { x: left, y: top, width, height });
18173
- }
18174
- if (needFill)
18175
- canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
18176
- if (onCanvas)
18177
- onCanvas(canvas);
18178
- const data = filename === 'canvas' ? canvas : canvas.export(filename, options);
18179
- result = { data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds };
18180
18353
  }
18181
- this.running = false;
18354
+ catch (error) {
18355
+ result = { data: '', error };
18356
+ }
18357
+ Export.running = false;
18182
18358
  return result;
18183
18359
  },
18184
18360
  export(leaf, filename, options) {
18185
- this.running = true;
18361
+ Export.running = true;
18186
18362
  return addTask((success) => new Promise((resolve) => {
18187
18363
  const getResult = () => __awaiter(this, void 0, void 0, function* () {
18188
18364
  if (!Resource.isComplete)
18189
18365
  return Platform.requestRender(getResult);
18190
- const result = ExportModule.syncExport(leaf, filename, options);
18366
+ const result = Export.syncExport(leaf, filename, options);
18191
18367
  if (result.data instanceof Promise)
18192
18368
  result.data = yield result.data;
18193
18369
  success(result);
@@ -18449,6 +18625,8 @@ ${filterStyle$1}
18449
18625
  exports.boundsType = boundsType;
18450
18626
  exports.canvasPatch = canvasPatch;
18451
18627
  exports.canvasSizeAttrs = canvasSizeAttrs;
18628
+ exports.createAttr = createAttr;
18629
+ exports.createDescriptor = createDescriptor;
18452
18630
  exports.cursorType = cursorType;
18453
18631
  exports.dataProcessor = dataProcessor;
18454
18632
  exports.dataType = dataType;
@@ -18497,7 +18675,7 @@ ${filterStyle$1}
18497
18675
  exports.strokeType = strokeType;
18498
18676
  exports.surfaceType = surfaceType;
18499
18677
  exports.tempBounds = tempBounds$1;
18500
- exports.tempMatrix = tempMatrix;
18678
+ exports.tempMatrix = tempMatrix$1;
18501
18679
  exports.tempPoint = tempPoint$3;
18502
18680
  exports.useCanvas = useCanvas;
18503
18681
  exports.useModule = useModule;