leafer-game 2.0.2 → 2.0.4

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.
@@ -252,6 +252,7 @@ class LeafData {
252
252
  }
253
253
  destroy() {
254
254
  this.__input = this.__middle = null;
255
+ if (this.__complexData) this.__complexData.destroy();
255
256
  }
256
257
  }
257
258
 
@@ -350,6 +351,8 @@ const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumbe
350
351
 
351
352
  const {round: round$6, pow: pow$2, max: max$4, floor: floor$3, PI: PI$4} = Math;
352
353
 
354
+ const tempScaleData$1 = {};
355
+
353
356
  const MathHelper = {
354
357
  within(value, min, max) {
355
358
  if (isObject(min)) max = min.max, min = min.min;
@@ -393,6 +396,24 @@ const MathHelper = {
393
396
  } else if (scale) MathHelper.assignScale(scaleData, scale);
394
397
  return scaleData;
395
398
  },
399
+ getScaleFixedData(worldScaleData, scaleFixed, unscale, abs, _localScaleData) {
400
+ let {scaleX: scaleX, scaleY: scaleY} = worldScaleData;
401
+ if (abs || scaleFixed) scaleX < 0 && (scaleX = -scaleX), scaleY < 0 && (scaleY = -scaleY);
402
+ if (scaleFixed) {
403
+ if (scaleFixed === true) {
404
+ scaleX = scaleY = unscale ? 1 : 1 / scaleX;
405
+ } else {
406
+ let minScale;
407
+ if (isNumber(scaleFixed)) minScale = scaleFixed; else if (scaleFixed === "zoom-in") minScale = 1;
408
+ if (minScale) {
409
+ if (scaleX > minScale || scaleY > minScale) scaleX = scaleY = unscale ? 1 : 1 / scaleX; else scaleX = scaleY = unscale ? 1 : 1 / minScale;
410
+ }
411
+ }
412
+ }
413
+ tempScaleData$1.scaleX = scaleX;
414
+ tempScaleData$1.scaleY = scaleY;
415
+ return tempScaleData$1;
416
+ },
396
417
  assignScale(scaleData, scale) {
397
418
  if (isNumber(scale)) {
398
419
  scaleData.scaleX = scaleData.scaleY = scale;
@@ -889,8 +910,8 @@ const PointHelper = {
889
910
  if (isObject(originPoints[0])) points = [], originPoints.forEach(p => points.push(p.x, p.y));
890
911
  return points;
891
912
  },
892
- isSame(t, point) {
893
- return float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
913
+ isSame(t, point, quick) {
914
+ return quick ? t.x === point.x && t.y === point.y : float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
894
915
  },
895
916
  reset(t) {
896
917
  P$5.reset(t);
@@ -965,8 +986,8 @@ class Point {
965
986
  getAtan2(to) {
966
987
  return PointHelper.getAtan2(this, to);
967
988
  }
968
- isSame(point) {
969
- return PointHelper.isSame(this, point);
989
+ isSame(point, quick) {
990
+ return PointHelper.isSame(this, point, quick);
970
991
  }
971
992
  reset() {
972
993
  PointHelper.reset(this);
@@ -1222,9 +1243,9 @@ const AroundHelper = {
1222
1243
  }
1223
1244
  if (!onlyBoxSize) to.x += box.x, to.y += box.y;
1224
1245
  },
1225
- getPoint(around, box, to) {
1246
+ getPoint(around, box, to, onlyBoxSize = true) {
1226
1247
  if (!to) to = {};
1227
- AroundHelper.toPoint(around, box, to, true);
1248
+ AroundHelper.toPoint(around, box, to, onlyBoxSize);
1228
1249
  return to;
1229
1250
  }
1230
1251
  };
@@ -1491,6 +1512,9 @@ const BoundsHelper = {
1491
1512
  y: y + height
1492
1513
  } ];
1493
1514
  },
1515
+ getPoint(t, around, onlyBoxSize = false, to) {
1516
+ return AroundHelper.getPoint(around, t, to, onlyBoxSize);
1517
+ },
1494
1518
  hitRadiusPoint(t, point, pointMatrix) {
1495
1519
  if (pointMatrix) point = PointHelper.tempToInnerRadiusPointOf(point, pointMatrix);
1496
1520
  return point.x >= t.x - point.radiusX && point.x <= t.x + t.width + point.radiusX && (point.y >= t.y - point.radiusY && point.y <= t.y + t.height + point.radiusY);
@@ -1662,6 +1686,9 @@ class Bounds {
1662
1686
  getPoints() {
1663
1687
  return BoundsHelper.getPoints(this);
1664
1688
  }
1689
+ getPoint(around, onlyBoxSize, to) {
1690
+ return BoundsHelper.getPoint(this, around, onlyBoxSize, to);
1691
+ }
1665
1692
  hitPoint(point, pointMatrix) {
1666
1693
  return BoundsHelper.hitPoint(this, point, pointMatrix);
1667
1694
  }
@@ -4102,6 +4129,7 @@ const ImageManager = {
4102
4129
  return image;
4103
4130
  },
4104
4131
  recycle(image) {
4132
+ if (image.parent) image = image.parent;
4105
4133
  image.use--;
4106
4134
  setTimeout(() => {
4107
4135
  if (!image.use) {
@@ -4270,8 +4298,10 @@ class LeaferImage {
4270
4298
  return undefined;
4271
4299
  }
4272
4300
  clearLevels(_checkUse) {}
4301
+ destroyFilter() {}
4273
4302
  destroy() {
4274
4303
  this.clearLevels();
4304
+ this.destroyFilter();
4275
4305
  const {view: view} = this;
4276
4306
  if (view && view.close) view.close();
4277
4307
  this.config = {
@@ -4468,7 +4498,6 @@ function dimType(defaultValue) {
4468
4498
  if (this.__setAttr(key, value)) {
4469
4499
  const data = this.__;
4470
4500
  DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4471
- this.__layout.surfaceChange();
4472
4501
  }
4473
4502
  }
4474
4503
  }));
@@ -4518,7 +4547,6 @@ function sortType(defaultValue) {
4518
4547
  return decorateLeafAttr(defaultValue, key => attr({
4519
4548
  set(value) {
4520
4549
  if (this.__setAttr(key, value)) {
4521
- this.__layout.surfaceChange();
4522
4550
  this.waitParent(() => {
4523
4551
  this.parent.__layout.childrenSortChange();
4524
4552
  });
@@ -4555,7 +4583,6 @@ function hitType(defaultValue) {
4555
4583
  set(value) {
4556
4584
  if (this.__setAttr(key, value)) {
4557
4585
  this.__layout.hitCanvasChanged = true;
4558
- if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4559
4586
  if (this.leafer) this.leafer.updateCursor();
4560
4587
  }
4561
4588
  }
@@ -4761,6 +4788,10 @@ const LeafHelper = {
4761
4788
  if (layout.stateStyleChanged) leaf.updateState();
4762
4789
  if (layout.opacityChanged) updateAllWorldOpacity(leaf);
4763
4790
  leaf.__updateChange();
4791
+ if (layout.surfaceChanged) {
4792
+ if (leaf.__hasComplex) L$1.updateComplex(leaf);
4793
+ layout.surfaceChanged = false;
4794
+ }
4764
4795
  },
4765
4796
  updateAllChange(leaf) {
4766
4797
  updateChange$1(leaf);
@@ -4785,6 +4816,9 @@ const LeafHelper = {
4785
4816
  if (!fromWorld) fromWorld = leaf.__nowWorld;
4786
4817
  if (leaf.__worldFlipped || Platform.fullImageShadow) currentCanvas.copyWorldByReset(fromCanvas, fromWorld, leaf.__nowWorld, blendMode, onlyResetTransform); else currentCanvas.copyWorldToInner(fromCanvas, fromWorld, leaf.__layout.renderBounds, blendMode);
4787
4818
  },
4819
+ renderComplex(_leaf, _canvas, _options) {},
4820
+ updateComplex(_leaf) {},
4821
+ checkComplex(_leaf) {},
4788
4822
  moveWorld(t, x, y = 0, isInnerPoint, transition) {
4789
4823
  const local = isObject(x) ? Object.assign({}, x) : {
4790
4824
  x: x,
@@ -4896,6 +4930,9 @@ const LeafHelper = {
4896
4930
  divideParent(matrix$1, relative.scrollWorldTransform);
4897
4931
  return temp ? matrix$1 : Object.assign({}, matrix$1);
4898
4932
  },
4933
+ updateScaleFixedWorld(_t) {},
4934
+ updateOuterBounds(_t) {},
4935
+ cacheId(_t) {},
4899
4936
  drop(t, parent, index, resize) {
4900
4937
  t.setTransform(L$1.getRelativeWorld(t, parent, true), resize);
4901
4938
  parent.add(t, index);
@@ -4946,7 +4983,8 @@ const LeafBoundsHelper = {
4946
4983
  return target.__.eraser || target.__.visible === 0 ? null : target.__layout.localStrokeBounds;
4947
4984
  },
4948
4985
  localRenderBounds(target) {
4949
- return target.__.eraser || target.__.visible === 0 ? null : target.__layout.localRenderBounds;
4986
+ const {__: __, __layout: __layout} = target;
4987
+ return __.eraser || __.visible === 0 ? null : __layout.localOuterBounds || __layout.localRenderBounds;
4950
4988
  },
4951
4989
  maskLocalBoxBounds(target, index) {
4952
4990
  return checkMask(target, index) && target.__localBoxBounds;
@@ -4955,7 +4993,8 @@ const LeafBoundsHelper = {
4955
4993
  return checkMask(target, index) && target.__layout.localStrokeBounds;
4956
4994
  },
4957
4995
  maskLocalRenderBounds(target, index) {
4958
- return checkMask(target, index) && target.__layout.localRenderBounds;
4996
+ const {__layout: __layout} = target;
4997
+ return checkMask(target, index) && (__layout.localOuterBounds || __layout.localRenderBounds);
4959
4998
  },
4960
4999
  excludeRenderBounds(child, options) {
4961
5000
  if (options.bounds && !options.bounds.hit(child.__world, options.matrix)) return true;
@@ -5475,7 +5514,6 @@ class LeafLayout {
5475
5514
  }
5476
5515
  opacityChange() {
5477
5516
  this.opacityChanged = true;
5478
- this.surfaceChanged || this.surfaceChange();
5479
5517
  }
5480
5518
  childrenSortChange() {
5481
5519
  if (!this.childrenSortChanged) {
@@ -5582,7 +5620,7 @@ class BoundsEvent extends Event {
5582
5620
  }
5583
5621
  }
5584
5622
  static emitWorld(leaf) {
5585
- if (leaf.leaferIsReady) leaf.emit(WORLD, this);
5623
+ if (leaf.leaferIsReady) leaf.emit(WORLD, leaf);
5586
5624
  }
5587
5625
  }
5588
5626
 
@@ -5968,6 +6006,7 @@ const LeafMatrix = {
5968
6006
  const {parent: parent, __layout: __layout, __world: __world, __scrollWorld: __scrollWorld, __: __} = this;
5969
6007
  multiplyParent$2(this.__local || __layout, parent ? parent.__scrollWorld || parent.__world : defaultWorld, __world, !!__layout.affectScaleOrRotation, __);
5970
6008
  if (__scrollWorld) translateInner(Object.assign(__scrollWorld, __world), __.scrollX, __.scrollY);
6009
+ if (__layout.scaleFixed) LeafHelper.updateScaleFixedWorld(this);
5971
6010
  },
5972
6011
  __updateLocalMatrix() {
5973
6012
  if (this.__local) {
@@ -6001,6 +6040,7 @@ const LeafBounds = {
6001
6040
  __updateWorldBounds() {
6002
6041
  const {__layout: __layout, __world: __world} = this;
6003
6042
  toOuterOf$2(__layout.renderBounds, __world, __world);
6043
+ if (this.__hasComplex) LeafHelper.checkComplex(this);
6004
6044
  if (__layout.resized) {
6005
6045
  if (__layout.resized === "inner") this.__onUpdateSize();
6006
6046
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
@@ -6050,6 +6090,7 @@ const LeafBounds = {
6050
6090
  layout.renderChanged = undefined;
6051
6091
  if (this.parent) this.parent.__layout.renderChange();
6052
6092
  }
6093
+ if (layout.outerScale) LeafHelper.updateOuterBounds(this);
6053
6094
  layout.resized || (layout.resized = "local");
6054
6095
  layout.boundsChanged = undefined;
6055
6096
  },
@@ -6116,7 +6157,7 @@ const LeafRender = {
6116
6157
  const data = this.__;
6117
6158
  if (data.bright && !options.topRendering) return options.topList.add(this);
6118
6159
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
6119
- canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
6160
+ canvas.opacity = options.ignoreOpacity ? 1 : options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
6120
6161
  if (this.__.__single) {
6121
6162
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
6122
6163
  const tempCanvas = canvas.getSameCanvas(true, true);
@@ -6170,7 +6211,7 @@ const BranchRender = {
6170
6211
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
6171
6212
  const tempCanvas = canvas.getSameCanvas(false, true);
6172
6213
  this.__renderBranch(tempCanvas, options);
6173
- canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
6214
+ canvas.opacity = options.ignoreOpacity ? 1 : options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
6174
6215
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
6175
6216
  tempCanvas.recycle(nowWorld);
6176
6217
  } else {
@@ -6186,7 +6227,7 @@ const BranchRender = {
6186
6227
  const {children: children} = this;
6187
6228
  for (let i = 0, len = children.length; i < len; i++) {
6188
6229
  child = children[i];
6189
- excludeRenderBounds$1(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
6230
+ excludeRenderBounds$1(child, options) || (child.__hasComplex ? LeafHelper.renderComplex(child, canvas, options) : child.__render(canvas, options));
6190
6231
  }
6191
6232
  }
6192
6233
  },
@@ -6200,8 +6241,6 @@ const BranchRender = {
6200
6241
  }
6201
6242
  };
6202
6243
 
6203
- const tempScaleData$1 = {};
6204
-
6205
6244
  const {LEAF: LEAF, create: create} = IncrementId;
6206
6245
 
6207
6246
  const {stintSet: stintSet$4} = DataHelper;
@@ -6212,6 +6251,8 @@ const {toOuterOf: toOuterOf$1} = BoundsHelper;
6212
6251
 
6213
6252
  const {copy: copy$2, move: move$2} = PointHelper;
6214
6253
 
6254
+ const {getScaleFixedData: getScaleFixedData} = MathHelper;
6255
+
6215
6256
  const {moveLocal: moveLocal, zoomOfLocal: zoomOfLocal, rotateOfLocal: rotateOfLocal, skewOfLocal: skewOfLocal, moveWorld: moveWorld, zoomOfWorld: zoomOfWorld, rotateOfWorld: rotateOfWorld, skewOfWorld: skewOfWorld, transform: transform, transformWorld: transformWorld, setTransform: setTransform, getFlipTransform: getFlipTransform, getLocalOrigin: getLocalOrigin, getRelativeWorld: getRelativeWorld, drop: drop} = LeafHelper;
6216
6257
 
6217
6258
  let Leaf = class Leaf {
@@ -6370,6 +6411,7 @@ let Leaf = class Leaf {
6370
6411
  this.__level = this.parent ? this.parent.__level + 1 : 1;
6371
6412
  if (this.animation) this.__runAnimation("in");
6372
6413
  if (this.__bubbleMap) this.__emitLifeEvent(ChildEvent.MOUNTED);
6414
+ if (leafer.cacheId) LeafHelper.cacheId(this);
6373
6415
  } else {
6374
6416
  this.__emitLifeEvent(ChildEvent.UNMOUNTED);
6375
6417
  }
@@ -6499,13 +6541,8 @@ let Leaf = class Leaf {
6499
6541
  if (scaleX < 0) scaleX = -scaleX;
6500
6542
  return scaleX > 1 ? scaleX : 1;
6501
6543
  }
6502
- getRenderScaleData(abs, scaleFixed) {
6503
- let {scaleX: scaleX, scaleY: scaleY} = ImageManager.patternLocked ? this.__world : this.__nowWorld;
6504
- if (abs) scaleX < 0 && (scaleX = -scaleX), scaleY < 0 && (scaleY = -scaleY);
6505
- if (scaleFixed === true || scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) scaleX = scaleY = 1;
6506
- tempScaleData$1.scaleX = scaleX;
6507
- tempScaleData$1.scaleY = scaleY;
6508
- return tempScaleData$1;
6544
+ getRenderScaleData(abs, scaleFixed, unscale = true) {
6545
+ return getScaleFixedData(ImageManager.patternLocked ? this.__world : this.__nowWorld || this.__world, scaleFixed, unscale, abs);
6509
6546
  }
6510
6547
  getTransform(relative) {
6511
6548
  return this.__layout.getTransform(relative || "local");
@@ -6544,14 +6581,16 @@ let Leaf = class Leaf {
6544
6581
  relative.innerToWorld(world, to, distance);
6545
6582
  world = to ? to : world;
6546
6583
  }
6547
- toInnerPoint(this.scrollWorldTransform, world, to, distance);
6584
+ toInnerPoint(this.worldTransform, world, to, distance);
6548
6585
  }
6549
6586
  innerToWorld(inner, to, distance, relative) {
6550
- toOuterPoint(this.scrollWorldTransform, inner, to, distance);
6587
+ toOuterPoint(this.worldTransform, inner, to, distance);
6551
6588
  if (relative) relative.worldToInner(to ? to : inner, null, distance);
6552
6589
  }
6553
6590
  getBoxPoint(world, relative, distance, change) {
6554
- return this.getBoxPointByInner(this.getInnerPoint(world, relative, distance, change), null, null, true);
6591
+ const inner = this.getInnerPoint(world, relative, distance, change);
6592
+ if (distance) return inner;
6593
+ return this.getBoxPointByInner(inner, null, null, true);
6555
6594
  }
6556
6595
  getBoxPointByInner(inner, _relative, _distance, change) {
6557
6596
  const point = change ? inner : Object.assign({}, inner), {x: x, y: y} = this.boxBounds;
@@ -6667,7 +6706,6 @@ let Leaf = class Leaf {
6667
6706
  __drawHitPath(_canvas) {}
6668
6707
  __updateHitCanvas() {}
6669
6708
  __render(_canvas, _options) {}
6670
- __renderComplex(_canvas, _options) {}
6671
6709
  __drawFast(_canvas, _options) {}
6672
6710
  __draw(_canvas, _options, _originCanvas) {}
6673
6711
  __clip(_canvas, _options) {}
@@ -6678,7 +6716,7 @@ let Leaf = class Leaf {
6678
6716
  __drawPath(_canvas) {}
6679
6717
  __drawRenderPath(_canvas) {}
6680
6718
  __updatePath() {}
6681
- __updateRenderPath() {}
6719
+ __updateRenderPath(_updateCache) {}
6682
6720
  getMotionPathData() {
6683
6721
  return Plugin.need("path");
6684
6722
  }
@@ -6752,9 +6790,11 @@ let Branch = class Branch extends Leaf {
6752
6790
  return 0;
6753
6791
  }
6754
6792
  __updateRenderSpread() {
6793
+ let layout;
6755
6794
  const {children: children} = this;
6756
6795
  for (let i = 0, len = children.length; i < len; i++) {
6757
- if (children[i].__layout.renderSpread) return 1;
6796
+ layout = children[i].__layout;
6797
+ if (layout.renderSpread || layout.localOuterBounds) return 1;
6758
6798
  }
6759
6799
  return 0;
6760
6800
  }
@@ -7013,7 +7053,7 @@ class LeafLevelList {
7013
7053
  }
7014
7054
  }
7015
7055
 
7016
- const version = "2.0.2";
7056
+ const version = "2.0.4";
7017
7057
 
7018
7058
  const debug$5 = Debug.get("LeaferCanvas");
7019
7059
 
@@ -8047,7 +8087,7 @@ class Selector {
8047
8087
  this.config = {};
8048
8088
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
8049
8089
  this.picker = new Picker(this.target = target, this);
8050
- this.finder = Creator.finder && Creator.finder();
8090
+ this.finder = Creator.finder && Creator.finder(target, this.config);
8051
8091
  }
8052
8092
  getByPoint(hitPoint, hitRadius, options) {
8053
8093
  const {target: target, picker: picker} = this;
@@ -8089,7 +8129,9 @@ function effectType(defaultValue) {
8089
8129
  set(value) {
8090
8130
  this.__setAttr(key, value);
8091
8131
  if (value) this.__.__useEffect = true;
8092
- this.__layout.renderChanged || this.__layout.renderChange();
8132
+ const layout = this.__layout;
8133
+ layout.renderChanged || layout.renderChange();
8134
+ layout.surfaceChange();
8093
8135
  }
8094
8136
  }));
8095
8137
  }
@@ -8303,15 +8345,16 @@ class UIData extends LeafData {
8303
8345
  this.__needComputePaint = undefined;
8304
8346
  }
8305
8347
  __getRealStrokeWidth(childStyle) {
8306
- let {strokeWidth: strokeWidth, strokeWidthFixed: strokeWidthFixed} = this;
8348
+ let {strokeWidth: strokeWidth, strokeScaleFixed: strokeScaleFixed} = this;
8307
8349
  if (childStyle) {
8308
8350
  if (childStyle.strokeWidth) strokeWidth = childStyle.strokeWidth;
8309
- if (!isUndefined(childStyle.strokeWidthFixed)) strokeWidthFixed = childStyle.strokeWidthFixed;
8351
+ if (!isUndefined(childStyle.strokeScaleFixed)) strokeScaleFixed = childStyle.strokeScaleFixed;
8310
8352
  }
8311
- if (strokeWidthFixed) {
8312
- const scale = this.__leaf.getClampRenderScale();
8313
- return scale > 1 ? strokeWidth / scale : strokeWidth;
8314
- } else return strokeWidth;
8353
+ if (strokeScaleFixed) {
8354
+ const {scaleX: scaleX} = this.__leaf.getRenderScaleData(true, strokeScaleFixed, false);
8355
+ if (scaleX !== 1) return strokeWidth * scaleX;
8356
+ }
8357
+ return strokeWidth;
8315
8358
  }
8316
8359
  __setPaint(attrName, value) {
8317
8360
  this.__setInput(attrName, value);
@@ -8393,7 +8436,11 @@ class EllipseData extends UIData {
8393
8436
 
8394
8437
  class PolygonData extends LineData {}
8395
8438
 
8396
- class StarData extends UIData {}
8439
+ class StarData extends UIData {
8440
+ get __boxStroke() {
8441
+ return !this.__pathInputed;
8442
+ }
8443
+ }
8397
8444
 
8398
8445
  class PathData extends UIData {
8399
8446
  get __pathInputed() {
@@ -8497,7 +8544,7 @@ const UIBounds = {
8497
8544
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
8498
8545
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
8499
8546
  boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
8500
- if (!data.__boxStroke) {
8547
+ if (!data.__boxStroke || data.__useArrow) {
8501
8548
  const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
8502
8549
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
8503
8550
  spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
@@ -8654,6 +8701,12 @@ let UI = UI_1 = class UI extends Leaf {
8654
8701
  get isFrame() {
8655
8702
  return false;
8656
8703
  }
8704
+ set strokeWidthFixed(value) {
8705
+ this.strokeScaleFixed = value;
8706
+ }
8707
+ get strokeWidthFixed() {
8708
+ return this.strokeScaleFixed;
8709
+ }
8657
8710
  set scale(value) {
8658
8711
  MathHelper.assignScale(this, value);
8659
8712
  }
@@ -8709,6 +8762,9 @@ let UI = UI_1 = class UI extends Leaf {
8709
8762
  getPathString(curve, pathForRender, floatLength) {
8710
8763
  return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
8711
8764
  }
8765
+ asPath(curve, pathForRender) {
8766
+ this.path = this.getPath(curve, pathForRender);
8767
+ }
8712
8768
  load() {
8713
8769
  this.__.__computePaint();
8714
8770
  }
@@ -8718,16 +8774,18 @@ let UI = UI_1 = class UI extends Leaf {
8718
8774
  data.lazy && !this.__inLazyBounds && !Export.running ? data.__needComputePaint = true : data.__computePaint();
8719
8775
  }
8720
8776
  }
8721
- __updateRenderPath() {
8777
+ __updateRenderPath(updateCache) {
8722
8778
  const data = this.__;
8723
8779
  if (data.path) {
8724
8780
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8725
- if (data.__useArrow) PathArrow.addArrows(this);
8781
+ if (data.__useArrow) PathArrow.addArrows(this, updateCache);
8726
8782
  } else data.__pathForRender && (data.__pathForRender = undefined);
8727
8783
  }
8728
8784
  __drawRenderPath(canvas) {
8785
+ const data = this.__;
8729
8786
  canvas.beginPath();
8730
- this.__drawPathByData(canvas, this.__.__pathForRender);
8787
+ if (data.__useArrow) PathArrow.updateArrow(this);
8788
+ this.__drawPathByData(canvas, data.__pathForRender);
8731
8789
  }
8732
8790
  __drawPath(canvas) {
8733
8791
  canvas.beginPath();
@@ -8776,6 +8834,7 @@ let UI = UI_1 = class UI extends Leaf {
8776
8834
  static setEditOuter(_toolName) {}
8777
8835
  static setEditInner(_editorName) {}
8778
8836
  destroy() {
8837
+ this.__.__willDestroy = true;
8779
8838
  this.fill = this.stroke = null;
8780
8839
  if (this.__animate) this.killAnimate();
8781
8840
  super.destroy();
@@ -8892,7 +8951,7 @@ __decorate([ strokeType("inside") ], UI.prototype, "strokeAlign", void 0);
8892
8951
 
8893
8952
  __decorate([ strokeType(1, true) ], UI.prototype, "strokeWidth", void 0);
8894
8953
 
8895
- __decorate([ strokeType(false) ], UI.prototype, "strokeWidthFixed", void 0);
8954
+ __decorate([ strokeType(false) ], UI.prototype, "strokeScaleFixed", void 0);
8896
8955
 
8897
8956
  __decorate([ strokeType("none") ], UI.prototype, "strokeCap", void 0);
8898
8957
 
@@ -9393,6 +9452,9 @@ let Box = class Box extends Group {
9393
9452
  get isBranchLeaf() {
9394
9453
  return true;
9395
9454
  }
9455
+ get __useSelfBox() {
9456
+ return this.pathInputed;
9457
+ }
9396
9458
  constructor(data) {
9397
9459
  super(data);
9398
9460
  this.__layout.renderChanged || this.__layout.renderChange();
@@ -9408,7 +9470,7 @@ let Box = class Box extends Group {
9408
9470
  }
9409
9471
  __updateRectBoxBounds() {}
9410
9472
  __updateBoxBounds(_secondLayout) {
9411
- if (this.children.length && !this.pathInputed) {
9473
+ if (this.children.length && !this.__useSelfBox) {
9412
9474
  const data = this.__;
9413
9475
  if (data.__autoSide) {
9414
9476
  if (data.__hasSurface) this.__extraUpdate();
@@ -9524,9 +9586,9 @@ let Ellipse = class Ellipse extends UI {
9524
9586
  return "Ellipse";
9525
9587
  }
9526
9588
  __updatePath() {
9527
- const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
9589
+ const data = this.__, {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = data;
9528
9590
  const rx = width / 2, ry = height / 2;
9529
- const path = this.__.path = [];
9591
+ const path = data.path = [];
9530
9592
  let open;
9531
9593
  if (innerRadius) {
9532
9594
  if (startAngle || endAngle) {
@@ -9548,7 +9610,7 @@ let Ellipse = class Ellipse extends UI {
9548
9610
  }
9549
9611
  }
9550
9612
  if (!open) closePath$2(path);
9551
- if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
9613
+ if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true);
9552
9614
  }
9553
9615
  };
9554
9616
 
@@ -10088,7 +10150,7 @@ let App = class App extends Leafer {
10088
10150
  if (this.viewReady) this.renderer.update();
10089
10151
  }
10090
10152
  __render(canvas, options) {
10091
- if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options.bounds));
10153
+ if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options.bounds, undefined, undefined, true));
10092
10154
  }
10093
10155
  __onResize(event) {
10094
10156
  this.forEach(leafer => leafer.resize(event));
@@ -11140,6 +11202,14 @@ class InteractionBase {
11140
11202
  stopDragAnimate() {
11141
11203
  this.dragger.stopAnimate();
11142
11204
  }
11205
+ replaceDownTarget(target) {
11206
+ const {downData: downData} = this;
11207
+ if (downData && target) {
11208
+ const {path: path} = downData;
11209
+ path.remove(path.list[0]);
11210
+ path.addAt(target, 0);
11211
+ }
11212
+ }
11143
11213
  updateDownData(data, options, merge) {
11144
11214
  const {downData: downData} = this;
11145
11215
  if (!data && downData) data = downData;
@@ -11571,6 +11641,10 @@ const KeyEventHelper = {
11571
11641
  const {pathCanDrag: pathCanDrag} = InteractionHelper;
11572
11642
 
11573
11643
  class Interaction extends InteractionBase {
11644
+ get windowTarget() {
11645
+ const {view: view} = this;
11646
+ return view && view.ownerDocument || window;
11647
+ }
11574
11648
  get notPointer() {
11575
11649
  const {p: p} = this;
11576
11650
  return p.type !== "pointer" || p.touch || this.useMultiTouch;
@@ -11616,7 +11690,7 @@ class Interaction extends InteractionBase {
11616
11690
  }
11617
11691
  for (let name in windowEvents) {
11618
11692
  windowEvents[name] = windowEvents[name].bind(this);
11619
- window.addEventListener(name, windowEvents[name]);
11693
+ this.windowTarget.addEventListener(name, windowEvents[name]);
11620
11694
  }
11621
11695
  }
11622
11696
  __removeListenEvents() {
@@ -11627,7 +11701,7 @@ class Interaction extends InteractionBase {
11627
11701
  this.viewEvents = {};
11628
11702
  }
11629
11703
  for (let name in windowEvents) {
11630
- window.removeEventListener(name, windowEvents[name]);
11704
+ this.windowTarget.removeEventListener(name, windowEvents[name]);
11631
11705
  this.windowEvents = {};
11632
11706
  }
11633
11707
  }
@@ -11647,7 +11721,8 @@ class Interaction extends InteractionBase {
11647
11721
  if (wheel.preventDefault) e.preventDefault();
11648
11722
  }
11649
11723
  preventWindowPointer(e) {
11650
- return !this.downData && e.target !== this.view;
11724
+ if (this.downData || e.target === this.view) return false;
11725
+ return this.config.shadowDOM && e.composedPath ? !e.composedPath().includes(this.view) : true;
11651
11726
  }
11652
11727
  onKeyDown(e) {
11653
11728
  this.keyDown(KeyEventHelper.convert(e));
@@ -11859,8 +11934,8 @@ function fills(fills, ui, canvas, renderOptions) {
11859
11934
  canvas.save();
11860
11935
  if (item.transform) canvas.transform(item.transform);
11861
11936
  if (originPaint.scaleFixed) {
11862
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11863
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
11937
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
11938
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
11864
11939
  }
11865
11940
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
11866
11941
  fillPathOrText(ui, canvas, renderOptions);
@@ -12281,6 +12356,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
12281
12356
  const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
12282
12357
  if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
12283
12358
  }
12359
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
12284
12360
  return true;
12285
12361
  }
12286
12362
 
@@ -12508,7 +12584,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
12508
12584
  let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
12509
12585
  if (paint.patternId !== id && !ui.destroyed) {
12510
12586
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
12511
- const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
12587
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
12512
12588
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
12513
12589
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
12514
12590
  width *= scaleX;
@@ -12524,7 +12600,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
12524
12600
  if (transform) copy$1(imageMatrix, transform);
12525
12601
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
12526
12602
  }
12527
- const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12603
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
12528
12604
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
12529
12605
  paint.style = pattern;
12530
12606
  paint.patternId = id;
@@ -12553,7 +12629,7 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12553
12629
  if (drawImage) {
12554
12630
  if (data.repeat) {
12555
12631
  drawImage = false;
12556
- } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12632
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" || exporting)) {
12557
12633
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
12558
12634
  }
12559
12635
  }
@@ -12615,6 +12691,7 @@ function recycleImage(attrName, data) {
12615
12691
  if (!recycleMap) recycleMap = {};
12616
12692
  recycleMap[url] = true;
12617
12693
  ImageManager.recyclePaint(paint);
12694
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf);
12618
12695
  if (image.loading) {
12619
12696
  if (!input) {
12620
12697
  input = data.__input && data.__input[attrName] || [];
@@ -13105,7 +13182,7 @@ function createRows(drawData, content, style) {
13105
13182
  }, row = {
13106
13183
  words: []
13107
13184
  };
13108
- if (__letterSpacing) content = [ ...content ];
13185
+ content = [ ...content ];
13109
13186
  for (let i = 0, len = content.length; i < len; i++) {
13110
13187
  char = content[i];
13111
13188
  if (char === "\n") {
@@ -15503,9 +15580,7 @@ const {Yes: Yes, NoAndSkip: NoAndSkip, YesAndSkip: YesAndSkip} = Answer;
15503
15580
  const idCondition = {}, classNameCondition = {}, tagCondition = {};
15504
15581
 
15505
15582
  class Finder {
15506
- constructor(target) {
15507
- this.innerIdMap = {};
15508
- this.idMap = {};
15583
+ constructor(target, _config) {
15509
15584
  this.methods = {
15510
15585
  id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf),
15511
15586
  1) : 0,
@@ -15515,6 +15590,13 @@ class Finder {
15515
15590
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
15516
15591
  tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
15517
15592
  };
15593
+ this.idMap = {};
15594
+ this.innerIdMap = {};
15595
+ const app = target && target.app;
15596
+ if (app) {
15597
+ app.idMap ? this.idMap = app.idMap : app.idMap = this.idMap;
15598
+ app.innerIdMap ? this.innerIdMap = app.innerIdMap : app.innerIdMap = this.innerIdMap;
15599
+ }
15518
15600
  if (this.target = target) this.__listenEvents();
15519
15601
  }
15520
15602
  getBy(condition, branch, one, options) {
@@ -15641,8 +15723,14 @@ ui.findOne = function(condition, options) {
15641
15723
 
15642
15724
  Plugin.add("find");
15643
15725
 
15644
- Creator.finder = function(target) {
15645
- return new Finder(target);
15726
+ Creator.finder = function(target, config) {
15727
+ return new Finder(target, config);
15728
+ };
15729
+
15730
+ LeafHelper.cacheId = function(t) {
15731
+ const {leafer: leafer, id: id} = t;
15732
+ if (id) leafer.app.idMap[id] = t;
15733
+ if (leafer.cacheInnerId) leafer.app.innerIdMap[t.innerId] = t;
15646
15734
  };
15647
15735
 
15648
15736
  export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, FourNumberHelper, Frame, FrameData, Group, GroupData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };