@leafer-ui/worker 1.6.7 → 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
@@ -46,7 +46,7 @@ var LeaferUI = (function (exports) {
46
46
  };
47
47
  const I$2 = IncrementId;
48
48
 
49
- const { round: round$3, pow: pow$1, PI: PI$4 } = Math;
49
+ const { round: round$3, pow: pow$1, PI: PI$3 } = Math;
50
50
  const MathHelper = {
51
51
  within(value, min, max) {
52
52
  if (typeof min === 'object')
@@ -142,9 +142,9 @@ var LeaferUI = (function (exports) {
142
142
  function randInt(num) {
143
143
  return Math.round(Math.random() * num);
144
144
  }
145
- const OneRadian = PI$4 / 180;
146
- const PI2 = PI$4 * 2;
147
- const PI_2 = PI$4 / 2;
145
+ const OneRadian = PI$3 / 180;
146
+ const PI2 = PI$3 * 2;
147
+ const PI_2 = PI$3 / 2;
148
148
  function getPointData() { return { x: 0, y: 0 }; }
149
149
  function getBoundsData() { return { x: 0, y: 0, width: 0, height: 0 }; }
150
150
  function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
@@ -439,7 +439,7 @@ var LeaferUI = (function (exports) {
439
439
  const M$6 = MatrixHelper;
440
440
 
441
441
  const { toInnerPoint: toInnerPoint$2, toOuterPoint: toOuterPoint$3 } = MatrixHelper;
442
- const { sin: sin$4, cos: cos$4, abs: abs$4, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2, PI: PI$3 } = Math;
442
+ const { sin: sin$4, cos: cos$4, abs: abs$3, sqrt: sqrt$2, atan2: atan2$2, min: min$1, round: round$2 } = 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$4(x2 - x1);
538
- const y = abs$4(y2 - y1);
537
+ const x = abs$3(x2 - x1);
538
+ const y = abs$3(y2 - y1);
539
539
  return sqrt$2(x * x + y * y);
540
540
  },
541
541
  getMinDistanceFrom(x1, y1, x2, y2, x3, y3) {
@@ -552,10 +552,11 @@ var LeaferUI = (function (exports) {
552
552
  getRadianFrom(fromX, fromY, originX, originY, toX, toY, toOriginX, toOriginY) {
553
553
  if (toOriginX === undefined)
554
554
  toOriginX = originX, toOriginY = originY;
555
- let fromAngle = atan2$2(fromY - originY, fromX - originX);
556
- let toAngle = atan2$2(toY - toOriginY, toX - toOriginX);
557
- const radian = toAngle - fromAngle;
558
- return radian < -PI$3 ? radian + PI2 : radian;
555
+ const a = fromX - originX;
556
+ const b = fromY - originY;
557
+ const c = toX - toOriginX;
558
+ const d = toY - toOriginY;
559
+ return Math.atan2(a * d - b * c, a * c + b * d);
559
560
  },
560
561
  getAtan2(t, to) {
561
562
  return atan2$2(to.y - t.y, to.x - t.x);
@@ -765,7 +766,7 @@ var LeaferUI = (function (exports) {
765
766
  MatrixHelper.reset(this);
766
767
  }
767
768
  }
768
- const tempMatrix = new Matrix();
769
+ const tempMatrix$1 = new Matrix();
769
770
 
770
771
  const TwoPointBoundsHelper = {
771
772
  tempPointBounds: {},
@@ -862,6 +863,12 @@ var LeaferUI = (function (exports) {
862
863
  }
863
864
  if (!onlyBoxSize)
864
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;
865
872
  }
866
873
  };
867
874
  function get$4(around) {
@@ -1790,10 +1797,13 @@ var LeaferUI = (function (exports) {
1790
1797
  return (target, key) => {
1791
1798
  if (!realName)
1792
1799
  realName = key;
1793
- Object.defineProperty(target, key, {
1800
+ const property = {
1794
1801
  get() { return this.context[realName]; },
1795
1802
  set(value) { this.context[realName] = value; }
1796
- });
1803
+ };
1804
+ if (key === 'strokeCap')
1805
+ property.set = function (value) { this.context[realName] = value === 'none' ? 'butt' : value; };
1806
+ Object.defineProperty(target, key, property);
1797
1807
  };
1798
1808
  }
1799
1809
  const contextMethodNameList = [];
@@ -2069,15 +2079,15 @@ var LeaferUI = (function (exports) {
2069
2079
  contextMethod()
2070
2080
  ], Canvas.prototype, "strokeText", null);
2071
2081
 
2072
- const { copy: copy$9, multiplyParent: multiplyParent$3 } = MatrixHelper, { round: round$1 } = Math;
2082
+ const { copy: copy$9, multiplyParent: multiplyParent$4 } = MatrixHelper, { round: round$1 } = Math;
2073
2083
  const minSize = { width: 1, height: 1, pixelRatio: 1 };
2074
2084
  const canvasSizeAttrs = ['width', 'height', 'pixelRatio'];
2075
2085
  class LeaferCanvasBase extends Canvas {
2076
2086
  get width() { return this.size.width; }
2077
2087
  get height() { return this.size.height; }
2078
2088
  get pixelRatio() { return this.size.pixelRatio; }
2079
- get pixelWidth() { return this.width * this.pixelRatio; }
2080
- 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; }
2081
2091
  get pixelSnap() { return this.config.pixelSnap; }
2082
2092
  set pixelSnap(value) { this.config.pixelSnap = value; }
2083
2093
  get allowBackgroundColor() { return this.view && this.parentView; }
@@ -2142,7 +2152,7 @@ var LeaferUI = (function (exports) {
2142
2152
  setWorld(matrix, parentMatrix) {
2143
2153
  const { pixelRatio, pixelSnap } = this, w = this.worldTransform;
2144
2154
  if (parentMatrix)
2145
- multiplyParent$3(matrix, parentMatrix, w);
2155
+ multiplyParent$4(matrix, parentMatrix, w);
2146
2156
  w.a = matrix.a * pixelRatio;
2147
2157
  w.b = matrix.b * pixelRatio;
2148
2158
  w.c = matrix.c * pixelRatio;
@@ -2164,20 +2174,33 @@ var LeaferUI = (function (exports) {
2164
2174
  if (w)
2165
2175
  this.setTransform(w.a, w.b, w.c, w.d, w.e, w.f);
2166
2176
  }
2167
- setStroke(color, strokeWidth, options) {
2177
+ setStroke(color, strokeWidth, options, childOptions) {
2168
2178
  if (strokeWidth)
2169
2179
  this.strokeWidth = strokeWidth;
2170
2180
  if (color)
2171
2181
  this.strokeStyle = color;
2172
2182
  if (options)
2173
- this.setStrokeOptions(options);
2174
- }
2175
- setStrokeOptions(options) {
2176
- this.strokeCap = options.strokeCap === 'none' ? 'butt' : options.strokeCap;
2177
- this.strokeJoin = options.strokeJoin;
2178
- this.dashPattern = options.dashPattern;
2179
- this.dashOffset = options.dashOffset;
2180
- 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;
2181
2204
  }
2182
2205
  saveBlendMode(blendMode) {
2183
2206
  this.savedBlendMode = this.blendMode;
@@ -2411,7 +2434,7 @@ var LeaferUI = (function (exports) {
2411
2434
  }
2412
2435
  };
2413
2436
 
2414
- const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2437
+ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$2, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2415
2438
  const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2416
2439
  const { set, toNumberPoints } = PointHelper;
2417
2440
  const { M: M$5, L: L$6, C: C$4, Q: Q$4, Z: Z$5 } = PathCommandMap;
@@ -2486,7 +2509,7 @@ var LeaferUI = (function (exports) {
2486
2509
  let totalRadian = endRadian - startRadian;
2487
2510
  if (totalRadian < 0)
2488
2511
  totalRadian += PI2;
2489
- if (totalRadian === PI$2 || (abs$3(BAx + BAy) < 1.e-12) || (abs$3(CBx + CBy) < 1.e-12)) {
2512
+ if (totalRadian === PI$2 || (abs$2(BAx + BAy) < 1.e-12) || (abs$2(CBx + CBy) < 1.e-12)) {
2490
2513
  if (data)
2491
2514
  data.push(L$6, x1, y1);
2492
2515
  if (setPointBounds) {
@@ -2528,7 +2551,7 @@ var LeaferUI = (function (exports) {
2528
2551
  totalRadian -= PI2;
2529
2552
  if (anticlockwise)
2530
2553
  totalRadian -= PI2;
2531
- const parts = ceil$1(abs$3(totalRadian / PI_2));
2554
+ const parts = ceil$1(abs$2(totalRadian / PI_2));
2532
2555
  const partRadian = totalRadian / parts;
2533
2556
  const partRadian4Sin = sin$3(partRadian / 4);
2534
2557
  const control = 8 / 3 * partRadian4Sin * partRadian4Sin / sin$3(partRadian / 2);
@@ -2973,7 +2996,7 @@ var LeaferUI = (function (exports) {
2973
2996
 
2974
2997
  const { M: M$3, L: L$4, C: C$2, Q: Q$2, Z: Z$3, N: N$2, D: D$2, X: X$2, G: G$2, F: F$3, O: O$2, P: P$2, U: U$2 } = PathCommandMap;
2975
2998
  const { getMinDistanceFrom, getRadianFrom } = PointHelper;
2976
- const { tan, min, abs: abs$2 } = Math;
2999
+ const { tan, min, abs: abs$1 } = Math;
2977
3000
  const startPoint = {};
2978
3001
  const PathCommandDataHelper = {
2979
3002
  beginPath(data) {
@@ -3036,7 +3059,7 @@ var LeaferUI = (function (exports) {
3036
3059
  arcTo(data, x1, y1, x2, y2, radius, lastX, lastY) {
3037
3060
  if (lastX !== undefined) {
3038
3061
  const d = getMinDistanceFrom(lastX, lastY, x1, y1, x2, y2);
3039
- radius = min(radius, min(d / 2, d / 2 * abs$2(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3062
+ radius = min(radius, min(d / 2, d / 2 * abs$1(tan(getRadianFrom(lastX, lastY, x1, y1, x2, y2) / 2))));
3040
3063
  }
3041
3064
  data.push(U$2, x1, y1, x2, y2, radius);
3042
3065
  },
@@ -3342,7 +3365,7 @@ var LeaferUI = (function (exports) {
3342
3365
  const { arcTo } = PathCommandDataHelper;
3343
3366
  const PathCorner = {
3344
3367
  smooth(data, cornerRadius, _cornerSmoothing) {
3345
- let command, commandLen;
3368
+ let command, lastCommand, commandLen;
3346
3369
  let i = 0, x = 0, y = 0, startX = 0, startY = 0, secondX = 0, secondY = 0, lastX = 0, lastY = 0;
3347
3370
  const len = data.length;
3348
3371
  const smooth = [];
@@ -3380,8 +3403,10 @@ var LeaferUI = (function (exports) {
3380
3403
  lastY = y;
3381
3404
  break;
3382
3405
  case Z:
3383
- arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3384
- smooth.push(Z);
3406
+ if (lastCommand !== Z) {
3407
+ arcTo(smooth, startX, startY, secondX, secondY, cornerRadius, lastX, lastY);
3408
+ smooth.push(Z);
3409
+ }
3385
3410
  i += 1;
3386
3411
  break;
3387
3412
  default:
@@ -3390,6 +3415,7 @@ var LeaferUI = (function (exports) {
3390
3415
  smooth.push(data[i + j]);
3391
3416
  i += commandLen;
3392
3417
  }
3418
+ lastCommand = command;
3393
3419
  }
3394
3420
  if (command !== Z) {
3395
3421
  smooth[1] = startX;
@@ -3886,12 +3912,12 @@ var LeaferUI = (function (exports) {
3886
3912
  try {
3887
3913
  if (transform && pattern.setTransform) {
3888
3914
  pattern.setTransform(transform);
3889
- transform = null;
3915
+ transform = undefined;
3890
3916
  }
3891
3917
  }
3892
3918
  catch (_a) { }
3893
3919
  if (paint)
3894
- paint.transform = transform;
3920
+ DataHelper.stintSet(paint, 'transform', transform);
3895
3921
  return pattern;
3896
3922
  }
3897
3923
  destroy() {
@@ -3909,6 +3935,13 @@ var LeaferUI = (function (exports) {
3909
3935
  function getDescriptor(object, name) {
3910
3936
  return Object.getOwnPropertyDescriptor(object, name);
3911
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
+ }
3912
3945
  function getNames(object) {
3913
3946
  return Object.getOwnPropertyNames(object);
3914
3947
  }
@@ -3996,10 +4029,14 @@ var LeaferUI = (function (exports) {
3996
4029
  }));
3997
4030
  }
3998
4031
  const pathType = boundsType;
3999
- function affectStrokeBoundsType(defaultValue) {
4032
+ function affectStrokeBoundsType(defaultValue, useStroke) {
4000
4033
  return decorateLeafAttr(defaultValue, (key) => attr({
4001
4034
  set(value) {
4002
- this.__setAttr(key, value) && doStrokeType(this);
4035
+ if (this.__setAttr(key, value)) {
4036
+ doStrokeType(this);
4037
+ if (useStroke)
4038
+ this.__.__useStroke = true;
4039
+ }
4003
4040
  }
4004
4041
  }));
4005
4042
  }
@@ -4137,15 +4174,7 @@ var LeaferUI = (function (exports) {
4137
4174
  const data = target.__DataProcessor.prototype;
4138
4175
  const computedKey = '_' + key;
4139
4176
  const setMethodName = getSetMethodName(key);
4140
- const property = {
4141
- get() {
4142
- const v = this[computedKey];
4143
- return v === undefined ? defaultValue : v;
4144
- },
4145
- set(value) {
4146
- this[computedKey] = value;
4147
- }
4148
- };
4177
+ const property = createDescriptor(key, defaultValue);
4149
4178
  if (defaultValue === undefined) {
4150
4179
  property.get = function () { return this[computedKey]; };
4151
4180
  }
@@ -4260,7 +4289,7 @@ var LeaferUI = (function (exports) {
4260
4289
  };
4261
4290
  }
4262
4291
 
4263
- const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
4292
+ const { copy: copy$7, toInnerPoint: toInnerPoint$1, toOuterPoint: toOuterPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$3, divideParent, getLayout } = MatrixHelper;
4264
4293
  const matrix$1 = {}, { round } = Math;
4265
4294
  const LeafHelper = {
4266
4295
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -4332,6 +4361,14 @@ var LeaferUI = (function (exports) {
4332
4361
  }
4333
4362
  return true;
4334
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
+ },
4335
4372
  moveWorld(t, x, y = 0, isInnerPoint, transition) {
4336
4373
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4337
4374
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
@@ -4391,14 +4428,14 @@ var LeaferUI = (function (exports) {
4391
4428
  },
4392
4429
  transformWorld(t, transform, resize, transition) {
4393
4430
  copy$7(matrix$1, t.worldTransform);
4394
- multiplyParent$2(matrix$1, transform);
4431
+ multiplyParent$3(matrix$1, transform);
4395
4432
  if (t.parent)
4396
4433
  divideParent(matrix$1, t.parent.worldTransform);
4397
4434
  L.setTransform(t, matrix$1, resize, transition);
4398
4435
  },
4399
4436
  transform(t, transform, resize, transition) {
4400
4437
  copy$7(matrix$1, t.localTransform);
4401
- multiplyParent$2(matrix$1, transform);
4438
+ multiplyParent$3(matrix$1, transform);
4402
4439
  L.setTransform(t, matrix$1, resize, transition);
4403
4440
  },
4404
4441
  setTransform(t, transform, resize, transition) {
@@ -5260,17 +5297,18 @@ var LeaferUI = (function (exports) {
5260
5297
  }
5261
5298
  };
5262
5299
 
5263
- const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
5300
+ const { setLayout, multiplyParent: multiplyParent$2, translateInner, defaultWorld } = MatrixHelper;
5264
5301
  const { toPoint: toPoint$3, tempPoint } = AroundHelper;
5265
5302
  const LeafMatrix = {
5266
5303
  __updateWorldMatrix() {
5267
- 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.__);
5268
5306
  },
5269
5307
  __updateLocalMatrix() {
5270
5308
  if (this.__local) {
5271
5309
  const layout = this.__layout, local = this.__local, data = this.__;
5272
5310
  if (layout.affectScaleOrRotation) {
5273
- if ((layout.scaleChanged && (layout.resized = 'scale')) || layout.rotationChanged) {
5311
+ if ((layout.scaleChanged && (layout.resized || (layout.resized = 'scale'))) || layout.rotationChanged) {
5274
5312
  setLayout(local, data, null, null, layout.affectRotation);
5275
5313
  layout.scaleChanged = layout.rotationChanged = undefined;
5276
5314
  }
@@ -5425,6 +5463,8 @@ var LeaferUI = (function (exports) {
5425
5463
 
5426
5464
  const LeafRender = {
5427
5465
  __render(canvas, options) {
5466
+ if (options.shape)
5467
+ return this.__renderShape(canvas, options);
5428
5468
  if (this.__worldOpacity) {
5429
5469
  const data = this.__;
5430
5470
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
@@ -5434,12 +5474,7 @@ var LeaferUI = (function (exports) {
5434
5474
  return this.__renderEraser(canvas, options);
5435
5475
  const tempCanvas = canvas.getSameCanvas(true, true);
5436
5476
  this.__draw(tempCanvas, options, canvas);
5437
- if (this.__worldFlipped) {
5438
- canvas.copyWorldByReset(tempCanvas, this.__nowWorld, null, data.__blendMode, true);
5439
- }
5440
- else {
5441
- canvas.copyWorldToInner(tempCanvas, this.__nowWorld, this.__layout.renderBounds, data.__blendMode);
5442
- }
5477
+ LeafHelper.copyCanvasByWorld(this, canvas, tempCanvas, this.__nowWorld, data.__blendMode, true);
5443
5478
  tempCanvas.recycle(this.__nowWorld);
5444
5479
  }
5445
5480
  else {
@@ -5449,6 +5484,12 @@ var LeaferUI = (function (exports) {
5449
5484
  Debug.drawBounds(this, canvas, options);
5450
5485
  }
5451
5486
  },
5487
+ __renderShape(canvas, options) {
5488
+ if (this.__worldOpacity) {
5489
+ canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5490
+ this.__drawShape(canvas, options);
5491
+ }
5492
+ },
5452
5493
  __clip(canvas, options) {
5453
5494
  if (this.__worldOpacity) {
5454
5495
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
@@ -5481,7 +5522,7 @@ var LeaferUI = (function (exports) {
5481
5522
  options.dimOpacity = data.dim === true ? 0.2 : data.dim;
5482
5523
  else if (data.dimskip)
5483
5524
  options.dimOpacity && (options.dimOpacity = 0);
5484
- if (data.__single) {
5525
+ if (data.__single && !this.isBranchLeaf) {
5485
5526
  if (data.eraser === 'path')
5486
5527
  return this.__renderEraser(canvas, options);
5487
5528
  const tempCanvas = canvas.getSameCanvas(false, true);
@@ -5503,9 +5544,7 @@ var LeaferUI = (function (exports) {
5503
5544
  else {
5504
5545
  const { children } = this;
5505
5546
  for (let i = 0, len = children.length; i < len; i++) {
5506
- if (excludeRenderBounds$1(children[i], options))
5507
- continue;
5508
- children[i].__render(canvas, options);
5547
+ excludeRenderBounds$1(children[i], options) || children[i].__render(canvas, options);
5509
5548
  }
5510
5549
  }
5511
5550
  },
@@ -5513,16 +5552,15 @@ var LeaferUI = (function (exports) {
5513
5552
  if (this.__worldOpacity) {
5514
5553
  const { children } = this;
5515
5554
  for (let i = 0, len = children.length; i < len; i++) {
5516
- if (excludeRenderBounds$1(children[i], options))
5517
- continue;
5518
- children[i].__clip(canvas, options);
5555
+ excludeRenderBounds$1(children[i], options) || children[i].__clip(canvas, options);
5519
5556
  }
5520
5557
  }
5521
5558
  }
5522
5559
  };
5523
5560
 
5561
+ const tempScaleData$1 = {};
5524
5562
  const { LEAF, create } = IncrementId;
5525
- const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5563
+ const { toInnerPoint, toOuterPoint, multiplyParent: multiplyParent$1 } = MatrixHelper;
5526
5564
  const { toOuterOf } = BoundsHelper;
5527
5565
  const { copy: copy$4, move } = PointHelper;
5528
5566
  const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
@@ -5704,7 +5742,7 @@ var LeaferUI = (function (exports) {
5704
5742
  if (!this.__cameraWorld)
5705
5743
  this.__cameraWorld = {};
5706
5744
  const cameraWorld = this.__cameraWorld, world = this.__world;
5707
- multiplyParent(world, options.matrix, cameraWorld, undefined, world);
5745
+ multiplyParent$1(world, options.matrix, cameraWorld, undefined, world);
5708
5746
  toOuterOf(this.__layout.renderBounds, cameraWorld, cameraWorld);
5709
5747
  cameraWorld.half !== world.half && (cameraWorld.half = world.half);
5710
5748
  return cameraWorld;
@@ -5713,6 +5751,22 @@ var LeaferUI = (function (exports) {
5713
5751
  return this.__world;
5714
5752
  }
5715
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
+ }
5716
5770
  getTransform(relative) {
5717
5771
  return this.__layout.getTransform(relative || 'local');
5718
5772
  }
@@ -5868,7 +5922,8 @@ var LeaferUI = (function (exports) {
5868
5922
  __drawFast(_canvas, _options) { }
5869
5923
  __draw(_canvas, _options, _originCanvas) { }
5870
5924
  __clip(_canvas, _options) { }
5871
- __renderShape(_canvas, _options, _ignoreFill, _ignoreStroke) { }
5925
+ __renderShape(_canvas, _options) { }
5926
+ __drawShape(_canvas, _options) { }
5872
5927
  __updateWorldOpacity() { }
5873
5928
  __updateChange() { }
5874
5929
  __drawPath(_canvas) { }
@@ -6236,7 +6291,7 @@ var LeaferUI = (function (exports) {
6236
6291
  }
6237
6292
  }
6238
6293
 
6239
- const version = "1.6.7";
6294
+ const version = "1.8.0";
6240
6295
 
6241
6296
  class LeaferCanvas extends LeaferCanvasBase {
6242
6297
  get allowBackgroundColor() { return true; }
@@ -7084,6 +7139,11 @@ var LeaferUI = (function (exports) {
7084
7139
  });
7085
7140
  };
7086
7141
  }
7142
+ function createAttr(defaultValue) {
7143
+ return (target, key) => {
7144
+ defineKey(target, key, createDescriptor(key, defaultValue));
7145
+ };
7146
+ }
7087
7147
 
7088
7148
  function hasTransparent$3(color) {
7089
7149
  if (!color || color.length === 7 || color.length === 4)
@@ -7141,26 +7201,9 @@ var LeaferUI = (function (exports) {
7141
7201
  const debug$2 = Debug.get('UIData');
7142
7202
  class UIData extends LeafData {
7143
7203
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
7144
- get __strokeWidth() {
7145
- const { strokeWidth, strokeWidthFixed } = this;
7146
- if (strokeWidthFixed) {
7147
- const ui = this.__leaf;
7148
- let { scaleX } = ui.__nowWorld || ui.__world;
7149
- if (scaleX < 0)
7150
- scaleX = -scaleX;
7151
- return scaleX > 1 ? strokeWidth / scaleX : strokeWidth;
7152
- }
7153
- else
7154
- return strokeWidth;
7155
- }
7156
- get __hasStroke() { return this.stroke && this.strokeWidth; }
7157
- get __hasHalf() { const t = this; return (t.stroke && t.strokeAlign === 'center' && t.strokeWidth % 2) || undefined; }
7158
- get __hasMultiPaint() {
7159
- const t = this;
7160
- if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
7161
- return true;
7162
- return t.fill && this.__hasStroke;
7163
- }
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; }
7164
7207
  get __clipAfterFill() { const t = this; return (t.cornerRadius || t.innerShadow || t.__pathInputed); }
7165
7208
  get __hasSurface() { const t = this; return (t.fill || t.stroke); }
7166
7209
  get __autoWidth() { return !this._width; }
@@ -7242,6 +7285,21 @@ var LeaferUI = (function (exports) {
7242
7285
  Paint.compute('stroke', this.__leaf);
7243
7286
  this.__needComputePaint = undefined;
7244
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
+ }
7245
7303
  __setPaint(attrName, value) {
7246
7304
  this.__setInput(attrName, value);
7247
7305
  const layout = this.__leaf.__layout;
@@ -7266,6 +7324,7 @@ var LeaferUI = (function (exports) {
7266
7324
  }
7267
7325
  else {
7268
7326
  stintSet$2(this, '__isAlphaPixelStroke', undefined);
7327
+ stintSet$2(this, '__hasMultiStrokeStyle', undefined);
7269
7328
  this._stroke = this.__isStrokes = undefined;
7270
7329
  }
7271
7330
  }
@@ -7287,8 +7346,8 @@ var LeaferUI = (function (exports) {
7287
7346
 
7288
7347
  class BoxData extends GroupData {
7289
7348
  get __boxStroke() { return !this.__pathInputed; }
7290
- get __drawAfterFill() { const t = this; return (t.overflow === 'hide' && (t.__clipAfterFill || t.innerShadow) && t.__leaf.children.length); }
7291
- 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); }
7292
7351
  }
7293
7352
 
7294
7353
  class LeaferData extends GroupData {
@@ -7408,7 +7467,7 @@ var LeaferUI = (function (exports) {
7408
7467
  const UIBounds = {
7409
7468
  __updateStrokeSpread() {
7410
7469
  let width = 0, boxWidth = 0;
7411
- const data = this.__, { strokeAlign, strokeWidth } = data, box = this.__box;
7470
+ const data = this.__, { strokeAlign, __maxStrokeWidth: strokeWidth } = data, box = this.__box;
7412
7471
  if ((data.stroke || data.hitStroke === 'all') && strokeWidth && strokeAlign !== 'inside') {
7413
7472
  boxWidth = width = strokeAlign === 'center' ? strokeWidth / 2 : strokeWidth;
7414
7473
  if (!data.__boxStroke) {
@@ -7428,13 +7487,15 @@ var LeaferUI = (function (exports) {
7428
7487
  },
7429
7488
  __updateRenderSpread() {
7430
7489
  let width = 0;
7431
- const { shadow, innerShadow, blur, backgroundBlur, filter } = this.__;
7490
+ const { shadow, innerShadow, blur, backgroundBlur, filter, renderSpread } = this.__;
7432
7491
  if (shadow)
7433
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));
7434
7493
  if (blur)
7435
7494
  width = Math.max(width, blur);
7436
7495
  if (filter)
7437
7496
  width += Filter.getSpread(filter);
7497
+ if (renderSpread)
7498
+ width += renderSpread;
7438
7499
  let shapeWidth = width = Math.ceil(width);
7439
7500
  if (innerShadow)
7440
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));
@@ -7450,15 +7511,18 @@ var LeaferUI = (function (exports) {
7450
7511
  const UIRender = {
7451
7512
  __updateChange() {
7452
7513
  const data = this.__;
7514
+ if (data.__useStroke) {
7515
+ const useStroke = data.__useStroke = !!(data.stroke && data.strokeWidth);
7516
+ stintSet$1(this.__world, 'half', useStroke && data.strokeAlign === 'center' && data.strokeWidth % 2);
7517
+ stintSet$1(data, '__fillAfterStroke', useStroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7518
+ }
7453
7519
  if (data.__useEffect) {
7454
7520
  const { shadow, fill, stroke } = data, otherEffect = data.innerShadow || data.blur || data.backgroundBlur || data.filter;
7455
- 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')));
7456
7522
  data.__useEffect = !!(shadow || otherEffect);
7457
7523
  }
7458
- stintSet$1(this.__world, 'half', data.__hasHalf);
7459
- stintSet$1(data, '__fillAfterStroke', data.stroke && data.strokeAlign === 'outside' && data.fill && !data.__isTransparentFill);
7460
7524
  data.__checkSingle();
7461
- stintSet$1(data, '__complex', data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect);
7525
+ stintSet$1(data, '__complex', (data.__isFills || data.__isStrokes || data.cornerRadius || data.__useEffect));
7462
7526
  },
7463
7527
  __drawFast(canvas, options) {
7464
7528
  drawFast(this, canvas, options);
@@ -7516,18 +7580,15 @@ var LeaferUI = (function (exports) {
7516
7580
  this.__drawFast(canvas, options);
7517
7581
  }
7518
7582
  },
7519
- __renderShape(canvas, options, ignoreFill, ignoreStroke) {
7520
- if (this.__worldOpacity) {
7521
- canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
7522
- const { fill, stroke } = this.__;
7523
- this.__drawRenderPath(canvas);
7524
- if (fill && !ignoreFill)
7525
- this.__.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7526
- if (this.__.__isCanvas)
7527
- this.__drawAfterFill(canvas, options);
7528
- if (stroke && !ignoreStroke)
7529
- this.__.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7530
- }
7583
+ __drawShape(canvas, options) {
7584
+ this.__drawRenderPath(canvas);
7585
+ const data = this.__, { fill, stroke } = data;
7586
+ if (fill && !options.ignoreFill)
7587
+ data.__isAlphaPixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7588
+ if (data.__isCanvas)
7589
+ this.__drawAfterFill(canvas, options);
7590
+ if (stroke && !options.ignoreStroke)
7591
+ data.__isAlphaPixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
7531
7592
  },
7532
7593
  __drawAfterFill(canvas, options) {
7533
7594
  if (this.__.__clipAfterFill) {
@@ -7564,17 +7625,17 @@ var LeaferUI = (function (exports) {
7564
7625
  if (__drawAfterFill)
7565
7626
  this.__drawAfterFill(canvas, options);
7566
7627
  if (stroke) {
7567
- const { strokeAlign, __strokeWidth } = this.__;
7568
- if (!__strokeWidth)
7628
+ const { strokeAlign, __strokeWidth: strokeWidth } = this.__;
7629
+ if (!strokeWidth)
7569
7630
  return;
7570
- canvas.setStroke(stroke, __strokeWidth, this.__);
7571
- const half = __strokeWidth / 2;
7631
+ canvas.setStroke(stroke, strokeWidth, this.__);
7632
+ const half = strokeWidth / 2;
7572
7633
  switch (strokeAlign) {
7573
7634
  case 'center':
7574
7635
  canvas.strokeRect(0, 0, width, height);
7575
7636
  break;
7576
7637
  case 'inside':
7577
- width -= __strokeWidth, height -= __strokeWidth;
7638
+ width -= strokeWidth, height -= strokeWidth;
7578
7639
  if (width < 0 || height < 0) {
7579
7640
  canvas.save();
7580
7641
  this.__clip(canvas, options);
@@ -7585,7 +7646,7 @@ var LeaferUI = (function (exports) {
7585
7646
  canvas.strokeRect(x + half, y + half, width, height);
7586
7647
  break;
7587
7648
  case 'outside':
7588
- canvas.strokeRect(x - half, y - half, width + __strokeWidth, height + __strokeWidth);
7649
+ canvas.strokeRect(x - half, y - half, width + strokeWidth, height + strokeWidth);
7589
7650
  break;
7590
7651
  }
7591
7652
  }
@@ -7598,6 +7659,8 @@ var LeaferUI = (function (exports) {
7598
7659
  get isFrame() { return false; }
7599
7660
  set scale(value) { MathHelper.assignScale(this, value); }
7600
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; }
7601
7664
  get pen() {
7602
7665
  const { path } = this.__;
7603
7666
  pen.set(this.path = path || []);
@@ -7652,12 +7715,14 @@ var LeaferUI = (function (exports) {
7652
7715
  }
7653
7716
  }
7654
7717
  __updateRenderPath() {
7655
- if (this.__.path) {
7656
- const data = this.__;
7718
+ const data = this.__;
7719
+ if (data.path) {
7657
7720
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
7658
7721
  if (data.__useArrow)
7659
7722
  PathArrow.addArrows(this, !data.cornerRadius);
7660
7723
  }
7724
+ else
7725
+ data.__pathForRender && (data.__pathForRender = undefined);
7661
7726
  }
7662
7727
  __drawRenderPath(canvas) {
7663
7728
  canvas.beginPath();
@@ -7810,6 +7875,9 @@ var LeaferUI = (function (exports) {
7810
7875
  __decorate([
7811
7876
  naturalBoundsType(1)
7812
7877
  ], exports.UI.prototype, "pixelRatio", void 0);
7878
+ __decorate([
7879
+ affectRenderBoundsType(0)
7880
+ ], exports.UI.prototype, "renderSpread", void 0);
7813
7881
  __decorate([
7814
7882
  pathInputType()
7815
7883
  ], exports.UI.prototype, "path", void 0);
@@ -7868,13 +7936,13 @@ var LeaferUI = (function (exports) {
7868
7936
  surfaceType()
7869
7937
  ], exports.UI.prototype, "fill", void 0);
7870
7938
  __decorate([
7871
- strokeType()
7939
+ strokeType(undefined, true)
7872
7940
  ], exports.UI.prototype, "stroke", void 0);
7873
7941
  __decorate([
7874
7942
  strokeType('inside')
7875
7943
  ], exports.UI.prototype, "strokeAlign", void 0);
7876
7944
  __decorate([
7877
- strokeType(1)
7945
+ strokeType(1, true)
7878
7946
  ], exports.UI.prototype, "strokeWidth", void 0);
7879
7947
  __decorate([
7880
7948
  strokeType(false)
@@ -7966,7 +8034,8 @@ var LeaferUI = (function (exports) {
7966
8034
  }
7967
8035
  toJSON(options) {
7968
8036
  const data = super.toJSON(options);
7969
- data.children = this.children.map(child => child.toJSON(options));
8037
+ if (!this.childlessJSON)
8038
+ data.children = this.children.map(child => child.toJSON(options));
7970
8039
  return data;
7971
8040
  }
7972
8041
  pick(_hitPoint, _options) { return undefined; }
@@ -8301,7 +8370,7 @@ var LeaferUI = (function (exports) {
8301
8370
  list.push(item);
8302
8371
  this.requestRender();
8303
8372
  }
8304
- zoom(_zoomType, _padding, _fixedScale, _transition) {
8373
+ zoom(_zoomType, _optionsOrPadding, _scroll, _transition) {
8305
8374
  return Plugin.need('view');
8306
8375
  }
8307
8376
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
@@ -8346,7 +8415,7 @@ var LeaferUI = (function (exports) {
8346
8415
  Leafer_1.list.remove(this);
8347
8416
  try {
8348
8417
  this.stop();
8349
- this.emitEvent(new LeaferEvent(LeaferEvent.END, this));
8418
+ this.emitLeafer(LeaferEvent.END);
8350
8419
  this.__removeListenEvents();
8351
8420
  this.__controllers.forEach(item => !(this.parent && item === this.interaction) && item.destroy());
8352
8421
  this.__controllers.length = 0;
@@ -8413,8 +8482,8 @@ var LeaferUI = (function (exports) {
8413
8482
  __updateRenderSpread() { return this.__updateRectRenderSpread() || -1; }
8414
8483
  __updateRectBoxBounds() { }
8415
8484
  __updateBoxBounds(_secondLayout) {
8416
- const data = this.__;
8417
8485
  if (this.children.length && !this.pathInputed) {
8486
+ const data = this.__;
8418
8487
  if (data.__autoSide) {
8419
8488
  if (data.__hasSurface)
8420
8489
  this.__extraUpdate();
@@ -8441,20 +8510,26 @@ var LeaferUI = (function (exports) {
8441
8510
  __updateStrokeBounds() { }
8442
8511
  __updateRenderBounds() {
8443
8512
  let isOverflow;
8444
- const { renderBounds } = this.__layout;
8445
8513
  if (this.children.length) {
8514
+ const data = this.__, { renderBounds, boxBounds } = this.__layout;
8446
8515
  super.__updateRenderBounds();
8447
8516
  copy$3(childrenRenderBounds, renderBounds);
8448
8517
  this.__updateRectRenderBounds();
8449
- isOverflow = !includes$1(renderBounds, childrenRenderBounds);
8450
- 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')
8451
8524
  add(renderBounds, childrenRenderBounds);
8452
8525
  }
8453
8526
  else
8454
8527
  this.__updateRectRenderBounds();
8455
8528
  DataHelper.stintSet(this, 'isOverflow', isOverflow);
8529
+ this.__updateScrollBar();
8456
8530
  }
8457
8531
  __updateRectRenderBounds() { }
8532
+ __updateScrollBar() { }
8458
8533
  __updateRectChange() { }
8459
8534
  __updateChange() {
8460
8535
  super.__updateChange();
@@ -8471,10 +8546,12 @@ var LeaferUI = (function (exports) {
8471
8546
  if (this.children.length)
8472
8547
  this.__renderGroup(canvas, options);
8473
8548
  }
8549
+ if (this.scrollBar)
8550
+ this.scrollBar.__render(canvas, options);
8474
8551
  }
8475
8552
  __drawContent(canvas, options) {
8476
8553
  this.__renderGroup(canvas, options);
8477
- if (this.__.__hasStroke) {
8554
+ if (this.__.__useStroke || this.__.__useEffect) {
8478
8555
  canvas.setWorld(this.__nowWorld);
8479
8556
  this.__drawRenderPath(canvas);
8480
8557
  }
@@ -8694,8 +8771,8 @@ var LeaferUI = (function (exports) {
8694
8771
  for (let i = 1; i < sides; i++) {
8695
8772
  lineTo$1(path, rx + rx * sin$1((i * 2 * PI$1) / sides), ry - ry * cos$1((i * 2 * PI$1) / sides));
8696
8773
  }
8774
+ closePath$1(path);
8697
8775
  }
8698
- closePath$1(path);
8699
8776
  }
8700
8777
  __updateRenderPath() { }
8701
8778
  __updateBoxBounds() { }
@@ -8933,6 +9010,11 @@ var LeaferUI = (function (exports) {
8933
9010
  return;
8934
9011
  super.__draw(canvas, options, originCanvas);
8935
9012
  }
9013
+ __drawShape(canvas, options) {
9014
+ if (options.shape)
9015
+ this.__box && this.__box.__drawShape(canvas, options);
9016
+ super.__drawShape(canvas, options);
9017
+ }
8936
9018
  destroy() {
8937
9019
  if (this.boxStyle)
8938
9020
  this.boxStyle = null;
@@ -9754,6 +9836,7 @@ var LeaferUI = (function (exports) {
9754
9836
  delta: { x: 80 / 4, y: 8.0 },
9755
9837
  },
9756
9838
  pointer: {
9839
+ type: 'pointer',
9757
9840
  snap: true,
9758
9841
  hitRadius: 5,
9759
9842
  tapTime: 120,
@@ -10271,18 +10354,20 @@ var LeaferUI = (function (exports) {
10271
10354
  }
10272
10355
  return this.__hit(inner);
10273
10356
  };
10274
- leaf.__hitFill = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitFill(inner, this.__.windingRule); };
10275
- leaf.__hitStroke = function (inner, strokeWidth) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitStroke(inner, strokeWidth); };
10276
- leaf.__hitPixel = function (inner) { var _a; return (_a = this.__hitCanvas) === null || _a === void 0 ? void 0 : _a.hitPixel(inner, this.__layout.renderBounds, this.__hitCanvas.hitScale); };
10277
- leaf.__drawHitPath = function (canvas) { if (canvas)
10278
- this.__drawRenderPath(canvas); };
10357
+ leaf.__hitFill = function (inner) { const h = this.__hitCanvas; return h && h.hitFill(inner, this.__.windingRule); };
10358
+ leaf.__hitStroke = function (inner, strokeWidth) { const h = this.__hitCanvas; return h && h.hitStroke(inner, strokeWidth); };
10359
+ leaf.__hitPixel = function (inner) { const h = this.__hitCanvas; return h && h.hitPixel(inner, this.__layout.renderBounds, h.hitScale); };
10360
+ leaf.__drawHitPath = function (canvas) { canvas && this.__drawRenderPath(canvas); };
10279
10361
 
10280
10362
  const matrix = new Matrix();
10281
10363
  const ui$1 = exports.UI.prototype;
10282
10364
  ui$1.__updateHitCanvas = function () {
10283
10365
  if (this.__box)
10284
10366
  this.__box.__updateHitCanvas();
10285
- 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;
10286
10371
  const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10287
10372
  const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === 'pixel';
10288
10373
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -10297,7 +10382,7 @@ var LeaferUI = (function (exports) {
10297
10382
  h.resize({ width, height, pixelRatio: 1 });
10298
10383
  h.clear();
10299
10384
  ImageManager.patternLocked = true;
10300
- this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y) }, !isHitPixelFill, !isHitPixelStroke);
10385
+ this.__renderShape(h, { matrix: matrix.setWith(this.__world).scaleWith(1 / scale).invertWith().translate(-x, -y), ignoreFill: !isHitPixelFill, ignoreStroke: !isHitPixelStroke });
10301
10386
  ImageManager.patternLocked = false;
10302
10387
  h.resetTransform();
10303
10388
  data.__isHitPixel = true;
@@ -10318,7 +10403,7 @@ var LeaferUI = (function (exports) {
10318
10403
  const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__isAlphaPixelFill || data.__isCanvas)))) || hitFill === 'all';
10319
10404
  if (needHitFillPath && this.__hitFill(inner))
10320
10405
  return true;
10321
- const { hitStroke, __strokeWidth } = data;
10406
+ const { hitStroke, __maxStrokeWidth: strokeWidth } = data;
10322
10407
  const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__isAlphaPixelStroke))) || hitStroke === 'all';
10323
10408
  if (!needHitFillPath && !needHitStrokePath)
10324
10409
  return false;
@@ -10327,16 +10412,16 @@ var LeaferUI = (function (exports) {
10327
10412
  if (needHitStrokePath) {
10328
10413
  switch (data.strokeAlign) {
10329
10414
  case 'inside':
10330
- hitWidth += __strokeWidth * 2;
10415
+ hitWidth += strokeWidth * 2;
10331
10416
  if (!needHitFillPath && this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
10332
10417
  return true;
10333
10418
  hitWidth = radiusWidth;
10334
10419
  break;
10335
10420
  case 'center':
10336
- hitWidth += __strokeWidth;
10421
+ hitWidth += strokeWidth;
10337
10422
  break;
10338
10423
  case 'outside':
10339
- hitWidth += __strokeWidth * 2;
10424
+ hitWidth += strokeWidth * 2;
10340
10425
  if (!needHitFillPath) {
10341
10426
  if (!this.__hitFill(inner) && this.__hitStroke(inner, hitWidth))
10342
10427
  return true;
@@ -10436,9 +10521,14 @@ var LeaferUI = (function (exports) {
10436
10521
  }
10437
10522
  }
10438
10523
  canvas.fillStyle = item.style;
10439
- if (item.transform) {
10524
+ if (item.transform || item.scaleFixed) {
10440
10525
  canvas.save();
10441
- 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
+ }
10442
10532
  if (item.blendMode)
10443
10533
  canvas.blendMode = item.blendMode;
10444
10534
  fillPathOrText(ui, canvas);
@@ -10474,8 +10564,13 @@ var LeaferUI = (function (exports) {
10474
10564
  }
10475
10565
  function drawCenter$1(stroke, strokeWidthScale, ui, canvas) {
10476
10566
  const data = ui.__;
10477
- canvas.setStroke(!data.__isStrokes && stroke, data.strokeWidth * strokeWidthScale, data);
10478
- 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
+ }
10479
10574
  }
10480
10575
  function drawAlign(stroke, align, ui, canvas) {
10481
10576
  const out = canvas.getSameCanvas(true, true);
@@ -10484,15 +10579,9 @@ var LeaferUI = (function (exports) {
10484
10579
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10485
10580
  fillText(ui, out);
10486
10581
  out.blendMode = 'normal';
10487
- copyWorld(canvas, out, ui);
10582
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10488
10583
  out.recycle(ui.__nowWorld);
10489
10584
  }
10490
- function copyWorld(canvas, out, ui) {
10491
- if (ui.__worldFlipped || Platform.fullImageShadow)
10492
- canvas.copyWorldByReset(out, ui.__nowWorld);
10493
- else
10494
- canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10495
- }
10496
10585
  function drawTextStroke(ui, canvas) {
10497
10586
  let row, data = ui.__.__textDrawData;
10498
10587
  const { rows, decorationY } = data;
@@ -10508,14 +10597,21 @@ var LeaferUI = (function (exports) {
10508
10597
  rows.forEach(row => decorationY.forEach(value => canvas.strokeRect(row.x, row.y + value, row.width, decorationHeight)));
10509
10598
  }
10510
10599
  }
10511
- function drawStrokesStyle(strokes, isText, ui, canvas) {
10600
+ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas) {
10512
10601
  let item;
10602
+ const data = ui.__, { __hasMultiStrokeStyle } = data;
10603
+ __hasMultiStrokeStyle || canvas.setStroke(undefined, data.__strokeWidth * strokeWidthScale, data);
10513
10604
  for (let i = 0, len = strokes.length; i < len; i++) {
10514
10605
  item = strokes[i];
10515
10606
  if (item.image && PaintImage.checkImage(ui, canvas, item, false))
10516
10607
  continue;
10517
10608
  if (item.style) {
10518
- 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;
10519
10615
  if (item.blendMode) {
10520
10616
  canvas.saveBlendMode(item.blendMode);
10521
10617
  isText ? drawTextStroke(ui, canvas) : canvas.stroke();
@@ -10554,8 +10650,13 @@ var LeaferUI = (function (exports) {
10554
10650
  }
10555
10651
  function drawCenter(stroke, strokeWidthScale, ui, canvas) {
10556
10652
  const data = ui.__;
10557
- canvas.setStroke(!data.__isStrokes && stroke, data.__strokeWidth * strokeWidthScale, data);
10558
- 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
+ }
10559
10660
  if (data.__useArrow)
10560
10661
  Paint.strokeArrow(stroke, ui, canvas);
10561
10662
  }
@@ -10577,7 +10678,7 @@ var LeaferUI = (function (exports) {
10577
10678
  drawCenter(stroke, 2, ui, out);
10578
10679
  out.clipUI(data);
10579
10680
  out.clearWorld(renderBounds);
10580
- copyWorld(canvas, out, ui);
10681
+ LeafHelper.copyCanvasByWorld(ui, canvas, out);
10581
10682
  out.recycle(ui.__nowWorld);
10582
10683
  }
10583
10684
  }
@@ -10632,8 +10733,16 @@ var LeaferUI = (function (exports) {
10632
10733
  if (!(paints instanceof Array))
10633
10734
  paints = [paints];
10634
10735
  recycleMap = PaintImage.recycleImage(attrName, data);
10736
+ let maxChildStrokeWidth;
10635
10737
  for (let i = 0, len = paints.length, item; i < len; i++) {
10636
- (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
+ }
10637
10746
  }
10638
10747
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10639
10748
  if (leafPaints.length) {
@@ -10650,6 +10759,7 @@ var LeaferUI = (function (exports) {
10650
10759
  else {
10651
10760
  stintSet(data, '__isAlphaPixelStroke', isAlphaPixel);
10652
10761
  stintSet(data, '__isTransparentStroke', isTransparent);
10762
+ stintSet(data, '__hasMultiStrokeStyle', maxChildStrokeWidth);
10653
10763
  }
10654
10764
  }
10655
10765
  function getLeafPaint(attrName, paint, ui) {
@@ -10681,6 +10791,11 @@ var LeaferUI = (function (exports) {
10681
10791
  if (data) {
10682
10792
  if (typeof data.style === 'string' && hasTransparent$1(data.style))
10683
10793
  data.isTransparent = true;
10794
+ if (paint.style) {
10795
+ if (paint.style.strokeWidth === 0)
10796
+ return undefined;
10797
+ data.strokeStyle = paint.style;
10798
+ }
10684
10799
  if (paint.blendMode)
10685
10800
  data.blendMode = paint.blendMode;
10686
10801
  }
@@ -10700,8 +10815,8 @@ var LeaferUI = (function (exports) {
10700
10815
  shape
10701
10816
  };
10702
10817
 
10703
- let origin = {};
10704
- const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
10818
+ let origin = {}, tempMatrix = getMatrixData();
10819
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, multiplyParent, scale: scaleHelper, rotate, skew: skewHelper } = MatrixHelper;
10705
10820
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10706
10821
  const transform = get$3();
10707
10822
  translate$1(transform, box.x + x, box.y + y);
@@ -10710,13 +10825,19 @@ var LeaferUI = (function (exports) {
10710
10825
  rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10711
10826
  data.transform = transform;
10712
10827
  }
10713
- function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10828
+ function clipMode(data, box, x, y, scaleX, scaleY, rotation, skew, clipSize) {
10714
10829
  const transform = get$3();
10715
- translate$1(transform, box.x + x, box.y + y);
10716
- if (scaleX)
10717
- scaleHelper(transform, scaleX, scaleY);
10718
10830
  if (rotation)
10719
10831
  rotate(transform, rotation);
10832
+ if (skew)
10833
+ skewHelper(transform, skew.x, skew.y);
10834
+ if (scaleX)
10835
+ scaleHelper(transform, scaleX, scaleY);
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
+ }
10720
10841
  data.transform = transform;
10721
10842
  }
10722
10843
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
@@ -10753,11 +10874,15 @@ var LeaferUI = (function (exports) {
10753
10874
  const tempScaleData = {};
10754
10875
  const tempImage = {};
10755
10876
  function createData(leafPaint, image, paint, box) {
10756
- const { changeful, sync } = paint;
10877
+ const { changeful, sync, editing, scaleFixed } = paint;
10757
10878
  if (changeful)
10758
10879
  leafPaint.changeful = changeful;
10759
10880
  if (sync)
10760
10881
  leafPaint.sync = sync;
10882
+ if (editing)
10883
+ leafPaint.editing = editing;
10884
+ if (scaleFixed)
10885
+ leafPaint.scaleFixed = scaleFixed;
10761
10886
  leafPaint.data = getPatternData(paint, box, image);
10762
10887
  }
10763
10888
  function getPatternData(paint, box, image) {
@@ -10766,7 +10891,7 @@ var LeaferUI = (function (exports) {
10766
10891
  if (paint.mode === 'strench')
10767
10892
  paint.mode = 'stretch';
10768
10893
  let { width, height } = image;
10769
- const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
10894
+ const { opacity, mode, align, offset, scale, size, rotation, skew, clipSize, repeat, filters } = paint;
10770
10895
  const sameBox = box.width === width && box.height === height;
10771
10896
  const data = { mode };
10772
10897
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -10800,8 +10925,8 @@ var LeaferUI = (function (exports) {
10800
10925
  break;
10801
10926
  case 'normal':
10802
10927
  case 'clip':
10803
- if (tempImage.x || tempImage.y || scaleX || rotation)
10804
- clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation);
10928
+ if (tempImage.x || tempImage.y || scaleX || clipSize || rotation || skew)
10929
+ clipMode(data, box, tempImage.x, tempImage.y, scaleX, scaleY, rotation, skew, paint.clipSize);
10805
10930
  break;
10806
10931
  case 'repeat':
10807
10932
  if (!sameBox || scaleX || rotation)
@@ -10878,11 +11003,11 @@ var LeaferUI = (function (exports) {
10878
11003
  }
10879
11004
  onLoadSuccess(ui, event);
10880
11005
  }
10881
- leafPaint.loadId = null;
11006
+ leafPaint.loadId = undefined;
10882
11007
  }, (error) => {
10883
11008
  ignoreRender(ui, false);
10884
11009
  onLoadError(ui, event, error);
10885
- leafPaint.loadId = null;
11010
+ leafPaint.loadId = undefined;
10886
11011
  });
10887
11012
  if (ui.placeholderColor) {
10888
11013
  if (!ui.placeholderDelay)
@@ -10938,16 +11063,16 @@ var LeaferUI = (function (exports) {
10938
11063
  }
10939
11064
 
10940
11065
  const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
10941
- const { ceil, abs: abs$1 } = Math;
11066
+ const { ceil, abs } = Math;
10942
11067
  function createPattern(ui, paint, pixelRatio) {
10943
- let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11068
+ let { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
10944
11069
  const id = scaleX + '-' + scaleY + '-' + pixelRatio;
10945
11070
  if (paint.patternId !== id && !ui.destroyed) {
10946
- scaleX = abs$1(scaleX);
10947
- scaleY = abs$1(scaleY);
10948
11071
  const { image, data } = paint;
10949
11072
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
10950
11073
  if (sx) {
11074
+ sx = abs(sx);
11075
+ sy = abs(sy);
10951
11076
  imageMatrix = get$1();
10952
11077
  copy$1(imageMatrix, transform);
10953
11078
  scale(imageMatrix, 1 / sx, 1 / sy);
@@ -11000,9 +11125,8 @@ var LeaferUI = (function (exports) {
11000
11125
  }
11001
11126
  }
11002
11127
 
11003
- const { abs } = Math;
11004
11128
  function checkImage(ui, canvas, paint, allowDraw) {
11005
- const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11129
+ const { scaleX, scaleY } = ui.getRenderScaleData(true, paint.scaleFixed);
11006
11130
  const { pixelRatio } = canvas, { data } = paint;
11007
11131
  if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !Export.running)) {
11008
11132
  return false;
@@ -11015,8 +11139,8 @@ var LeaferUI = (function (exports) {
11015
11139
  else {
11016
11140
  if (!(paint.changeful || ResizeEvent.isResizing(ui) || Export.running)) {
11017
11141
  let { width, height } = data;
11018
- width *= abs(scaleX) * pixelRatio;
11019
- height *= abs(scaleY) * pixelRatio;
11142
+ width *= scaleX * pixelRatio;
11143
+ height *= scaleY * pixelRatio;
11020
11144
  if (data.scaleX) {
11021
11145
  width *= data.scaleX;
11022
11146
  height *= data.scaleY;
@@ -11026,6 +11150,10 @@ var LeaferUI = (function (exports) {
11026
11150
  }
11027
11151
  }
11028
11152
  if (allowDraw) {
11153
+ if (ui.__.__isFastShadow) {
11154
+ canvas.fillStyle = paint.style || '#000';
11155
+ canvas.fill();
11156
+ }
11029
11157
  drawImage(ui, canvas, paint, data);
11030
11158
  return true;
11031
11159
  }
@@ -11214,10 +11342,7 @@ var LeaferUI = (function (exports) {
11214
11342
  }
11215
11343
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
11216
11344
  }
11217
- if (ui.__worldFlipped)
11218
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11219
- else
11220
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11345
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11221
11346
  if (end && index < end)
11222
11347
  other.clearWorld(copyBounds, true);
11223
11348
  });
@@ -11276,10 +11401,7 @@ var LeaferUI = (function (exports) {
11276
11401
  copyBounds = bounds;
11277
11402
  }
11278
11403
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
11279
- if (ui.__worldFlipped)
11280
- current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11281
- else
11282
- current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11404
+ LeafHelper.copyCanvasByWorld(ui, current, other, copyBounds, item.blendMode);
11283
11405
  if (end && index < end)
11284
11406
  other.clearWorld(copyBounds, true);
11285
11407
  });
@@ -11335,12 +11457,11 @@ var LeaferUI = (function (exports) {
11335
11457
  contentCanvas = getCanvas(canvas);
11336
11458
  child.__render(maskCanvas, options);
11337
11459
  }
11338
- if (!(mask === 'clipping' || mask === 'clipping-path'))
11339
- continue;
11340
- }
11341
- if (excludeRenderBounds(child, options))
11460
+ if (mask === 'clipping' || mask === 'clipping-path')
11461
+ excludeRenderBounds(child, options) || child.__render(canvas, options);
11342
11462
  continue;
11343
- child.__render(contentCanvas || canvas, options);
11463
+ }
11464
+ excludeRenderBounds(child, options) || child.__render(contentCanvas || canvas, options);
11344
11465
  }
11345
11466
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
11346
11467
  };
@@ -12052,6 +12173,8 @@ var LeaferUI = (function (exports) {
12052
12173
  exports.boundsType = boundsType;
12053
12174
  exports.canvasPatch = canvasPatch;
12054
12175
  exports.canvasSizeAttrs = canvasSizeAttrs;
12176
+ exports.createAttr = createAttr;
12177
+ exports.createDescriptor = createDescriptor;
12055
12178
  exports.cursorType = cursorType;
12056
12179
  exports.dataProcessor = dataProcessor;
12057
12180
  exports.dataType = dataType;
@@ -12090,7 +12213,7 @@ var LeaferUI = (function (exports) {
12090
12213
  exports.strokeType = strokeType;
12091
12214
  exports.surfaceType = surfaceType;
12092
12215
  exports.tempBounds = tempBounds$1;
12093
- exports.tempMatrix = tempMatrix;
12216
+ exports.tempMatrix = tempMatrix$1;
12094
12217
  exports.tempPoint = tempPoint$2;
12095
12218
  exports.useCanvas = useCanvas;
12096
12219
  exports.useModule = useModule;