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.
package/dist/web.js CHANGED
@@ -233,6 +233,7 @@ var LeaferUI = function(exports) {
233
233
  }
234
234
  destroy() {
235
235
  this.__input = this.__middle = null;
236
+ if (this.__complexData) this.__complexData.destroy();
236
237
  }
237
238
  }
238
239
  const IncrementId = {
@@ -323,6 +324,7 @@ var LeaferUI = function(exports) {
323
324
  };
324
325
  const {set: set$2, get: get$5, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
325
326
  const {round: round$6, pow: pow$2, max: max$4, floor: floor$3, PI: PI$4} = Math;
327
+ const tempScaleData$1 = {};
326
328
  const MathHelper = {
327
329
  within(value, min, max) {
328
330
  if (isObject(min)) max = min.max, min = min.min;
@@ -366,6 +368,24 @@ var LeaferUI = function(exports) {
366
368
  } else if (scale) MathHelper.assignScale(scaleData, scale);
367
369
  return scaleData;
368
370
  },
371
+ getScaleFixedData(worldScaleData, scaleFixed, unscale, abs, _localScaleData) {
372
+ let {scaleX: scaleX, scaleY: scaleY} = worldScaleData;
373
+ if (abs || scaleFixed) scaleX < 0 && (scaleX = -scaleX), scaleY < 0 && (scaleY = -scaleY);
374
+ if (scaleFixed) {
375
+ if (scaleFixed === true) {
376
+ scaleX = scaleY = unscale ? 1 : 1 / scaleX;
377
+ } else {
378
+ let minScale;
379
+ if (isNumber(scaleFixed)) minScale = scaleFixed; else if (scaleFixed === "zoom-in") minScale = 1;
380
+ if (minScale) {
381
+ if (scaleX > minScale || scaleY > minScale) scaleX = scaleY = unscale ? 1 : 1 / scaleX; else scaleX = scaleY = unscale ? 1 : 1 / minScale;
382
+ }
383
+ }
384
+ }
385
+ tempScaleData$1.scaleX = scaleX;
386
+ tempScaleData$1.scaleY = scaleY;
387
+ return tempScaleData$1;
388
+ },
369
389
  assignScale(scaleData, scale) {
370
390
  if (isNumber(scale)) {
371
391
  scaleData.scaleX = scaleData.scaleY = scale;
@@ -845,8 +865,8 @@ var LeaferUI = function(exports) {
845
865
  if (isObject(originPoints[0])) points = [], originPoints.forEach(p => points.push(p.x, p.y));
846
866
  return points;
847
867
  },
848
- isSame(t, point) {
849
- return float$4(t.x) === float$4(point.x) && float$4(t.y) === float$4(point.y);
868
+ isSame(t, point, quick) {
869
+ 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);
850
870
  },
851
871
  reset(t) {
852
872
  P$5.reset(t);
@@ -918,8 +938,8 @@ var LeaferUI = function(exports) {
918
938
  getAtan2(to) {
919
939
  return PointHelper.getAtan2(this, to);
920
940
  }
921
- isSame(point) {
922
- return PointHelper.isSame(this, point);
941
+ isSame(point, quick) {
942
+ return PointHelper.isSame(this, point, quick);
923
943
  }
924
944
  reset() {
925
945
  PointHelper.reset(this);
@@ -1163,9 +1183,9 @@ var LeaferUI = function(exports) {
1163
1183
  }
1164
1184
  if (!onlyBoxSize) to.x += box.x, to.y += box.y;
1165
1185
  },
1166
- getPoint(around, box, to) {
1186
+ getPoint(around, box, to, onlyBoxSize = true) {
1167
1187
  if (!to) to = {};
1168
- AroundHelper.toPoint(around, box, to, true);
1188
+ AroundHelper.toPoint(around, box, to, onlyBoxSize);
1169
1189
  return to;
1170
1190
  }
1171
1191
  };
@@ -1420,6 +1440,9 @@ var LeaferUI = function(exports) {
1420
1440
  y: y + height
1421
1441
  } ];
1422
1442
  },
1443
+ getPoint(t, around, onlyBoxSize = false, to) {
1444
+ return AroundHelper.getPoint(around, t, to, onlyBoxSize);
1445
+ },
1423
1446
  hitRadiusPoint(t, point, pointMatrix) {
1424
1447
  if (pointMatrix) point = PointHelper.tempToInnerRadiusPointOf(point, pointMatrix);
1425
1448
  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);
@@ -1588,6 +1611,9 @@ var LeaferUI = function(exports) {
1588
1611
  getPoints() {
1589
1612
  return BoundsHelper.getPoints(this);
1590
1613
  }
1614
+ getPoint(around, onlyBoxSize, to) {
1615
+ return BoundsHelper.getPoint(this, around, onlyBoxSize, to);
1616
+ }
1591
1617
  hitPoint(point, pointMatrix) {
1592
1618
  return BoundsHelper.hitPoint(this, point, pointMatrix);
1593
1619
  }
@@ -3861,6 +3887,7 @@ var LeaferUI = function(exports) {
3861
3887
  return image;
3862
3888
  },
3863
3889
  recycle(image) {
3890
+ if (image.parent) image = image.parent;
3864
3891
  image.use--;
3865
3892
  setTimeout(() => {
3866
3893
  if (!image.use) {
@@ -4026,8 +4053,10 @@ var LeaferUI = function(exports) {
4026
4053
  return undefined;
4027
4054
  }
4028
4055
  clearLevels(_checkUse) {}
4056
+ destroyFilter() {}
4029
4057
  destroy() {
4030
4058
  this.clearLevels();
4059
+ this.destroyFilter();
4031
4060
  const {view: view} = this;
4032
4061
  if (view && view.close) view.close();
4033
4062
  this.config = {
@@ -4198,7 +4227,6 @@ var LeaferUI = function(exports) {
4198
4227
  if (this.__setAttr(key, value)) {
4199
4228
  const data = this.__;
4200
4229
  DataHelper.stintSet(data, "__useDim", data.dim || data.bright || data.dimskip);
4201
- this.__layout.surfaceChange();
4202
4230
  }
4203
4231
  }
4204
4232
  }));
@@ -4243,7 +4271,6 @@ var LeaferUI = function(exports) {
4243
4271
  return decorateLeafAttr(defaultValue, key => attr({
4244
4272
  set(value) {
4245
4273
  if (this.__setAttr(key, value)) {
4246
- this.__layout.surfaceChange();
4247
4274
  this.waitParent(() => {
4248
4275
  this.parent.__layout.childrenSortChange();
4249
4276
  });
@@ -4277,7 +4304,6 @@ var LeaferUI = function(exports) {
4277
4304
  set(value) {
4278
4305
  if (this.__setAttr(key, value)) {
4279
4306
  this.__layout.hitCanvasChanged = true;
4280
- if (Debug.showBounds === "hit") this.__layout.surfaceChange();
4281
4307
  if (this.leafer) this.leafer.updateCursor();
4282
4308
  }
4283
4309
  }
@@ -4465,6 +4491,10 @@ var LeaferUI = function(exports) {
4465
4491
  if (layout.stateStyleChanged) leaf.updateState();
4466
4492
  if (layout.opacityChanged) updateAllWorldOpacity(leaf);
4467
4493
  leaf.__updateChange();
4494
+ if (layout.surfaceChanged) {
4495
+ if (leaf.__hasComplex) L$1.updateComplex(leaf);
4496
+ layout.surfaceChanged = false;
4497
+ }
4468
4498
  },
4469
4499
  updateAllChange(leaf) {
4470
4500
  updateChange$1(leaf);
@@ -4489,6 +4519,9 @@ var LeaferUI = function(exports) {
4489
4519
  if (!fromWorld) fromWorld = leaf.__nowWorld;
4490
4520
  if (leaf.__worldFlipped || Platform.fullImageShadow) currentCanvas.copyWorldByReset(fromCanvas, fromWorld, leaf.__nowWorld, blendMode, onlyResetTransform); else currentCanvas.copyWorldToInner(fromCanvas, fromWorld, leaf.__layout.renderBounds, blendMode);
4491
4521
  },
4522
+ renderComplex(_leaf, _canvas, _options) {},
4523
+ updateComplex(_leaf) {},
4524
+ checkComplex(_leaf) {},
4492
4525
  moveWorld(t, x, y = 0, isInnerPoint, transition) {
4493
4526
  const local = isObject(x) ? Object.assign({}, x) : {
4494
4527
  x: x,
@@ -4600,6 +4633,9 @@ var LeaferUI = function(exports) {
4600
4633
  divideParent(matrix$1, relative.scrollWorldTransform);
4601
4634
  return temp ? matrix$1 : Object.assign({}, matrix$1);
4602
4635
  },
4636
+ updateScaleFixedWorld(_t) {},
4637
+ updateOuterBounds(_t) {},
4638
+ cacheId(_t) {},
4603
4639
  drop(t, parent, index, resize) {
4604
4640
  t.setTransform(L$1.getRelativeWorld(t, parent, true), resize);
4605
4641
  parent.add(t, index);
@@ -4646,7 +4682,8 @@ var LeaferUI = function(exports) {
4646
4682
  return target.__.eraser || target.__.visible === 0 ? null : target.__layout.localStrokeBounds;
4647
4683
  },
4648
4684
  localRenderBounds(target) {
4649
- return target.__.eraser || target.__.visible === 0 ? null : target.__layout.localRenderBounds;
4685
+ const {__: __, __layout: __layout} = target;
4686
+ return __.eraser || __.visible === 0 ? null : __layout.localOuterBounds || __layout.localRenderBounds;
4650
4687
  },
4651
4688
  maskLocalBoxBounds(target, index) {
4652
4689
  return checkMask(target, index) && target.__localBoxBounds;
@@ -4655,7 +4692,8 @@ var LeaferUI = function(exports) {
4655
4692
  return checkMask(target, index) && target.__layout.localStrokeBounds;
4656
4693
  },
4657
4694
  maskLocalRenderBounds(target, index) {
4658
- return checkMask(target, index) && target.__layout.localRenderBounds;
4695
+ const {__layout: __layout} = target;
4696
+ return checkMask(target, index) && (__layout.localOuterBounds || __layout.localRenderBounds);
4659
4697
  },
4660
4698
  excludeRenderBounds(child, options) {
4661
4699
  if (options.bounds && !options.bounds.hit(child.__world, options.matrix)) return true;
@@ -5164,7 +5202,6 @@ var LeaferUI = function(exports) {
5164
5202
  }
5165
5203
  opacityChange() {
5166
5204
  this.opacityChanged = true;
5167
- this.surfaceChanged || this.surfaceChange();
5168
5205
  }
5169
5206
  childrenSortChange() {
5170
5207
  if (!this.childrenSortChanged) {
@@ -5252,7 +5289,7 @@ var LeaferUI = function(exports) {
5252
5289
  }
5253
5290
  }
5254
5291
  static emitWorld(leaf) {
5255
- if (leaf.leaferIsReady) leaf.emit(WORLD, this);
5292
+ if (leaf.leaferIsReady) leaf.emit(WORLD, leaf);
5256
5293
  }
5257
5294
  }
5258
5295
  BoundsEvent.RESIZE = "bounds.resize";
@@ -5579,6 +5616,7 @@ var LeaferUI = function(exports) {
5579
5616
  const {parent: parent, __layout: __layout, __world: __world, __scrollWorld: __scrollWorld, __: __} = this;
5580
5617
  multiplyParent$2(this.__local || __layout, parent ? parent.__scrollWorld || parent.__world : defaultWorld, __world, !!__layout.affectScaleOrRotation, __);
5581
5618
  if (__scrollWorld) translateInner(Object.assign(__scrollWorld, __world), __.scrollX, __.scrollY);
5619
+ if (__layout.scaleFixed) LeafHelper.updateScaleFixedWorld(this);
5582
5620
  },
5583
5621
  __updateLocalMatrix() {
5584
5622
  if (this.__local) {
@@ -5607,6 +5645,7 @@ var LeaferUI = function(exports) {
5607
5645
  __updateWorldBounds() {
5608
5646
  const {__layout: __layout, __world: __world} = this;
5609
5647
  toOuterOf$2(__layout.renderBounds, __world, __world);
5648
+ if (this.__hasComplex) LeafHelper.checkComplex(this);
5610
5649
  if (__layout.resized) {
5611
5650
  if (__layout.resized === "inner") this.__onUpdateSize();
5612
5651
  if (this.__hasLocalEvent) BoundsEvent.emitLocal(this);
@@ -5656,6 +5695,7 @@ var LeaferUI = function(exports) {
5656
5695
  layout.renderChanged = undefined;
5657
5696
  if (this.parent) this.parent.__layout.renderChange();
5658
5697
  }
5698
+ if (layout.outerScale) LeafHelper.updateOuterBounds(this);
5659
5699
  layout.resized || (layout.resized = "local");
5660
5700
  layout.boundsChanged = undefined;
5661
5701
  },
@@ -5721,7 +5761,7 @@ var LeaferUI = function(exports) {
5721
5761
  const data = this.__;
5722
5762
  if (data.bright && !options.topRendering) return options.topList.add(this);
5723
5763
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5724
- canvas.opacity = options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5764
+ canvas.opacity = options.ignoreOpacity ? 1 : options.dimOpacity && !data.dimskip ? data.opacity * options.dimOpacity : data.opacity;
5725
5765
  if (this.__.__single) {
5726
5766
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5727
5767
  const tempCanvas = canvas.getSameCanvas(true, true);
@@ -5773,7 +5813,7 @@ var LeaferUI = function(exports) {
5773
5813
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
5774
5814
  const tempCanvas = canvas.getSameCanvas(false, true);
5775
5815
  this.__renderBranch(tempCanvas, options);
5776
- canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
5816
+ canvas.opacity = options.ignoreOpacity ? 1 : options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
5777
5817
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
5778
5818
  tempCanvas.recycle(nowWorld);
5779
5819
  } else {
@@ -5789,7 +5829,7 @@ var LeaferUI = function(exports) {
5789
5829
  const {children: children} = this;
5790
5830
  for (let i = 0, len = children.length; i < len; i++) {
5791
5831
  child = children[i];
5792
- excludeRenderBounds$1(child, options) || (child.__.complex ? child.__renderComplex(canvas, options) : child.__render(canvas, options));
5832
+ excludeRenderBounds$1(child, options) || (child.__hasComplex ? LeafHelper.renderComplex(child, canvas, options) : child.__render(canvas, options));
5793
5833
  }
5794
5834
  }
5795
5835
  },
@@ -5802,12 +5842,12 @@ var LeaferUI = function(exports) {
5802
5842
  }
5803
5843
  }
5804
5844
  };
5805
- const tempScaleData$1 = {};
5806
5845
  const {LEAF: LEAF, create: create} = IncrementId;
5807
5846
  const {stintSet: stintSet$4} = DataHelper;
5808
5847
  const {toInnerPoint: toInnerPoint, toOuterPoint: toOuterPoint, multiplyParent: multiplyParent$1} = MatrixHelper;
5809
5848
  const {toOuterOf: toOuterOf$1} = BoundsHelper;
5810
5849
  const {copy: copy$2, move: move$2} = PointHelper;
5850
+ const {getScaleFixedData: getScaleFixedData} = MathHelper;
5811
5851
  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;
5812
5852
  exports.Leaf = class Leaf {
5813
5853
  get tag() {
@@ -5965,6 +6005,7 @@ var LeaferUI = function(exports) {
5965
6005
  this.__level = this.parent ? this.parent.__level + 1 : 1;
5966
6006
  if (this.animation) this.__runAnimation("in");
5967
6007
  if (this.__bubbleMap) this.__emitLifeEvent(ChildEvent.MOUNTED);
6008
+ if (leafer.cacheId) LeafHelper.cacheId(this);
5968
6009
  } else {
5969
6010
  this.__emitLifeEvent(ChildEvent.UNMOUNTED);
5970
6011
  }
@@ -6094,13 +6135,8 @@ var LeaferUI = function(exports) {
6094
6135
  if (scaleX < 0) scaleX = -scaleX;
6095
6136
  return scaleX > 1 ? scaleX : 1;
6096
6137
  }
6097
- getRenderScaleData(abs, scaleFixed) {
6098
- let {scaleX: scaleX, scaleY: scaleY} = ImageManager.patternLocked ? this.__world : this.__nowWorld;
6099
- if (abs) scaleX < 0 && (scaleX = -scaleX), scaleY < 0 && (scaleY = -scaleY);
6100
- if (scaleFixed === true || scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) scaleX = scaleY = 1;
6101
- tempScaleData$1.scaleX = scaleX;
6102
- tempScaleData$1.scaleY = scaleY;
6103
- return tempScaleData$1;
6138
+ getRenderScaleData(abs, scaleFixed, unscale = true) {
6139
+ return getScaleFixedData(ImageManager.patternLocked ? this.__world : this.__nowWorld || this.__world, scaleFixed, unscale, abs);
6104
6140
  }
6105
6141
  getTransform(relative) {
6106
6142
  return this.__layout.getTransform(relative || "local");
@@ -6139,14 +6175,16 @@ var LeaferUI = function(exports) {
6139
6175
  relative.innerToWorld(world, to, distance);
6140
6176
  world = to ? to : world;
6141
6177
  }
6142
- toInnerPoint(this.scrollWorldTransform, world, to, distance);
6178
+ toInnerPoint(this.worldTransform, world, to, distance);
6143
6179
  }
6144
6180
  innerToWorld(inner, to, distance, relative) {
6145
- toOuterPoint(this.scrollWorldTransform, inner, to, distance);
6181
+ toOuterPoint(this.worldTransform, inner, to, distance);
6146
6182
  if (relative) relative.worldToInner(to ? to : inner, null, distance);
6147
6183
  }
6148
6184
  getBoxPoint(world, relative, distance, change) {
6149
- return this.getBoxPointByInner(this.getInnerPoint(world, relative, distance, change), null, null, true);
6185
+ const inner = this.getInnerPoint(world, relative, distance, change);
6186
+ if (distance) return inner;
6187
+ return this.getBoxPointByInner(inner, null, null, true);
6150
6188
  }
6151
6189
  getBoxPointByInner(inner, _relative, _distance, change) {
6152
6190
  const point = change ? inner : Object.assign({}, inner), {x: x, y: y} = this.boxBounds;
@@ -6262,7 +6300,6 @@ var LeaferUI = function(exports) {
6262
6300
  __drawHitPath(_canvas) {}
6263
6301
  __updateHitCanvas() {}
6264
6302
  __render(_canvas, _options) {}
6265
- __renderComplex(_canvas, _options) {}
6266
6303
  __drawFast(_canvas, _options) {}
6267
6304
  __draw(_canvas, _options, _originCanvas) {}
6268
6305
  __clip(_canvas, _options) {}
@@ -6273,7 +6310,7 @@ var LeaferUI = function(exports) {
6273
6310
  __drawPath(_canvas) {}
6274
6311
  __drawRenderPath(_canvas) {}
6275
6312
  __updatePath() {}
6276
- __updateRenderPath() {}
6313
+ __updateRenderPath(_updateCache) {}
6277
6314
  getMotionPathData() {
6278
6315
  return Plugin.need("path");
6279
6316
  }
@@ -6341,9 +6378,11 @@ var LeaferUI = function(exports) {
6341
6378
  return 0;
6342
6379
  }
6343
6380
  __updateRenderSpread() {
6381
+ let layout;
6344
6382
  const {children: children} = this;
6345
6383
  for (let i = 0, len = children.length; i < len; i++) {
6346
- if (children[i].__layout.renderSpread) return 1;
6384
+ layout = children[i].__layout;
6385
+ if (layout.renderSpread || layout.localOuterBounds) return 1;
6347
6386
  }
6348
6387
  return 0;
6349
6388
  }
@@ -6598,7 +6637,7 @@ var LeaferUI = function(exports) {
6598
6637
  this.levelMap = null;
6599
6638
  }
6600
6639
  }
6601
- const version = "2.0.2";
6640
+ const version = "2.0.4";
6602
6641
  const debug$5 = Debug.get("LeaferCanvas");
6603
6642
  class LeaferCanvas extends LeaferCanvasBase {
6604
6643
  set zIndex(zIndex) {
@@ -7600,7 +7639,7 @@ var LeaferUI = function(exports) {
7600
7639
  this.config = {};
7601
7640
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
7602
7641
  this.picker = new Picker(this.target = target, this);
7603
- this.finder = Creator.finder && Creator.finder();
7642
+ this.finder = Creator.finder && Creator.finder(target, this.config);
7604
7643
  }
7605
7644
  getByPoint(hitPoint, hitRadius, options) {
7606
7645
  const {target: target, picker: picker} = this;
@@ -7638,7 +7677,9 @@ var LeaferUI = function(exports) {
7638
7677
  set(value) {
7639
7678
  this.__setAttr(key, value);
7640
7679
  if (value) this.__.__useEffect = true;
7641
- this.__layout.renderChanged || this.__layout.renderChange();
7680
+ const layout = this.__layout;
7681
+ layout.renderChanged || layout.renderChange();
7682
+ layout.surfaceChange();
7642
7683
  }
7643
7684
  }));
7644
7685
  }
@@ -7831,15 +7872,16 @@ var LeaferUI = function(exports) {
7831
7872
  this.__needComputePaint = undefined;
7832
7873
  }
7833
7874
  __getRealStrokeWidth(childStyle) {
7834
- let {strokeWidth: strokeWidth, strokeWidthFixed: strokeWidthFixed} = this;
7875
+ let {strokeWidth: strokeWidth, strokeScaleFixed: strokeScaleFixed} = this;
7835
7876
  if (childStyle) {
7836
7877
  if (childStyle.strokeWidth) strokeWidth = childStyle.strokeWidth;
7837
- if (!isUndefined(childStyle.strokeWidthFixed)) strokeWidthFixed = childStyle.strokeWidthFixed;
7878
+ if (!isUndefined(childStyle.strokeScaleFixed)) strokeScaleFixed = childStyle.strokeScaleFixed;
7879
+ }
7880
+ if (strokeScaleFixed) {
7881
+ const {scaleX: scaleX} = this.__leaf.getRenderScaleData(true, strokeScaleFixed, false);
7882
+ if (scaleX !== 1) return strokeWidth * scaleX;
7838
7883
  }
7839
- if (strokeWidthFixed) {
7840
- const scale = this.__leaf.getClampRenderScale();
7841
- return scale > 1 ? strokeWidth / scale : strokeWidth;
7842
- } else return strokeWidth;
7884
+ return strokeWidth;
7843
7885
  }
7844
7886
  __setPaint(attrName, value) {
7845
7887
  this.__setInput(attrName, value);
@@ -7911,7 +7953,11 @@ var LeaferUI = function(exports) {
7911
7953
  }
7912
7954
  }
7913
7955
  class PolygonData extends LineData {}
7914
- class StarData extends UIData {}
7956
+ class StarData extends UIData {
7957
+ get __boxStroke() {
7958
+ return !this.__pathInputed;
7959
+ }
7960
+ }
7915
7961
  class PathData extends UIData {
7916
7962
  get __pathInputed() {
7917
7963
  return 2;
@@ -8007,7 +8053,7 @@ var LeaferUI = function(exports) {
8007
8053
  const data = this.__, {strokeAlign: strokeAlign, __maxStrokeWidth: strokeWidth} = data, box = this.__box;
8008
8054
  if ((data.stroke || data.hitStroke === "all") && strokeWidth && strokeAlign !== "inside") {
8009
8055
  boxSpread = spread = strokeAlign === "center" ? strokeWidth / 2 : strokeWidth;
8010
- if (!data.__boxStroke) {
8056
+ if (!data.__boxStroke || data.__useArrow) {
8011
8057
  const miterLimitAddWidth = data.__isLinePath ? 0 : 10 * spread;
8012
8058
  const storkeCapAddWidth = data.strokeCap === "none" ? 0 : strokeWidth;
8013
8059
  spread += Math.max(miterLimitAddWidth, storkeCapAddWidth);
@@ -8158,6 +8204,12 @@ var LeaferUI = function(exports) {
8158
8204
  get isFrame() {
8159
8205
  return false;
8160
8206
  }
8207
+ set strokeWidthFixed(value) {
8208
+ this.strokeScaleFixed = value;
8209
+ }
8210
+ get strokeWidthFixed() {
8211
+ return this.strokeScaleFixed;
8212
+ }
8161
8213
  set scale(value) {
8162
8214
  MathHelper.assignScale(this, value);
8163
8215
  }
@@ -8213,6 +8265,9 @@ var LeaferUI = function(exports) {
8213
8265
  getPathString(curve, pathForRender, floatLength) {
8214
8266
  return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength);
8215
8267
  }
8268
+ asPath(curve, pathForRender) {
8269
+ this.path = this.getPath(curve, pathForRender);
8270
+ }
8216
8271
  load() {
8217
8272
  this.__.__computePaint();
8218
8273
  }
@@ -8222,16 +8277,18 @@ var LeaferUI = function(exports) {
8222
8277
  data.lazy && !this.__inLazyBounds && !Export.running ? data.__needComputePaint = true : data.__computePaint();
8223
8278
  }
8224
8279
  }
8225
- __updateRenderPath() {
8280
+ __updateRenderPath(updateCache) {
8226
8281
  const data = this.__;
8227
8282
  if (data.path) {
8228
8283
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path;
8229
- if (data.__useArrow) PathArrow.addArrows(this);
8284
+ if (data.__useArrow) PathArrow.addArrows(this, updateCache);
8230
8285
  } else data.__pathForRender && (data.__pathForRender = undefined);
8231
8286
  }
8232
8287
  __drawRenderPath(canvas) {
8288
+ const data = this.__;
8233
8289
  canvas.beginPath();
8234
- this.__drawPathByData(canvas, this.__.__pathForRender);
8290
+ if (data.__useArrow) PathArrow.updateArrow(this);
8291
+ this.__drawPathByData(canvas, data.__pathForRender);
8235
8292
  }
8236
8293
  __drawPath(canvas) {
8237
8294
  canvas.beginPath();
@@ -8280,6 +8337,7 @@ var LeaferUI = function(exports) {
8280
8337
  static setEditOuter(_toolName) {}
8281
8338
  static setEditInner(_editorName) {}
8282
8339
  destroy() {
8340
+ this.__.__willDestroy = true;
8283
8341
  this.fill = this.stroke = null;
8284
8342
  if (this.__animate) this.killAnimate();
8285
8343
  super.destroy();
@@ -8340,7 +8398,7 @@ var LeaferUI = function(exports) {
8340
8398
  __decorate([ strokeType(undefined, true) ], exports.UI.prototype, "stroke", void 0);
8341
8399
  __decorate([ strokeType("inside") ], exports.UI.prototype, "strokeAlign", void 0);
8342
8400
  __decorate([ strokeType(1, true) ], exports.UI.prototype, "strokeWidth", void 0);
8343
- __decorate([ strokeType(false) ], exports.UI.prototype, "strokeWidthFixed", void 0);
8401
+ __decorate([ strokeType(false) ], exports.UI.prototype, "strokeScaleFixed", void 0);
8344
8402
  __decorate([ strokeType("none") ], exports.UI.prototype, "strokeCap", void 0);
8345
8403
  __decorate([ strokeType("miter") ], exports.UI.prototype, "strokeJoin", void 0);
8346
8404
  __decorate([ strokeType() ], exports.UI.prototype, "dashPattern", void 0);
@@ -8804,6 +8862,9 @@ var LeaferUI = function(exports) {
8804
8862
  get isBranchLeaf() {
8805
8863
  return true;
8806
8864
  }
8865
+ get __useSelfBox() {
8866
+ return this.pathInputed;
8867
+ }
8807
8868
  constructor(data) {
8808
8869
  super(data);
8809
8870
  this.__layout.renderChanged || this.__layout.renderChange();
@@ -8819,7 +8880,7 @@ var LeaferUI = function(exports) {
8819
8880
  }
8820
8881
  __updateRectBoxBounds() {}
8821
8882
  __updateBoxBounds(_secondLayout) {
8822
- if (this.children.length && !this.pathInputed) {
8883
+ if (this.children.length && !this.__useSelfBox) {
8823
8884
  const data = this.__;
8824
8885
  if (data.__autoSide) {
8825
8886
  if (data.__hasSurface) this.__extraUpdate();
@@ -8914,9 +8975,9 @@ var LeaferUI = function(exports) {
8914
8975
  return "Ellipse";
8915
8976
  }
8916
8977
  __updatePath() {
8917
- const {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = this.__;
8978
+ const data = this.__, {width: width, height: height, innerRadius: innerRadius, startAngle: startAngle, endAngle: endAngle} = data;
8918
8979
  const rx = width / 2, ry = height / 2;
8919
- const path = this.__.path = [];
8980
+ const path = data.path = [];
8920
8981
  let open;
8921
8982
  if (innerRadius) {
8922
8983
  if (startAngle || endAngle) {
@@ -8938,7 +8999,7 @@ var LeaferUI = function(exports) {
8938
8999
  }
8939
9000
  }
8940
9001
  if (!open) closePath$2(path);
8941
- if (Platform.ellipseToCurve) this.__.path = this.getPath(true);
9002
+ if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true);
8942
9003
  }
8943
9004
  };
8944
9005
  __decorate([ dataProcessor(EllipseData) ], exports.Ellipse.prototype, "__", void 0);
@@ -9394,7 +9455,7 @@ var LeaferUI = function(exports) {
9394
9455
  if (this.viewReady) this.renderer.update();
9395
9456
  }
9396
9457
  __render(canvas, options) {
9397
- if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options.bounds));
9458
+ if (canvas.context) this.forEach(leafer => options.matrix ? leafer.__render(canvas, options) : canvas.copyWorld(leafer.canvas, options.bounds, undefined, undefined, true));
9398
9459
  }
9399
9460
  __onResize(event) {
9400
9461
  this.forEach(leafer => leafer.resize(event));
@@ -10348,6 +10409,14 @@ var LeaferUI = function(exports) {
10348
10409
  stopDragAnimate() {
10349
10410
  this.dragger.stopAnimate();
10350
10411
  }
10412
+ replaceDownTarget(target) {
10413
+ const {downData: downData} = this;
10414
+ if (downData && target) {
10415
+ const {path: path} = downData;
10416
+ path.remove(path.list[0]);
10417
+ path.addAt(target, 0);
10418
+ }
10419
+ }
10351
10420
  updateDownData(data, options, merge) {
10352
10421
  const {downData: downData} = this;
10353
10422
  if (!data && downData) data = downData;
@@ -10748,6 +10817,10 @@ var LeaferUI = function(exports) {
10748
10817
  };
10749
10818
  const {pathCanDrag: pathCanDrag} = InteractionHelper;
10750
10819
  class Interaction extends InteractionBase {
10820
+ get windowTarget() {
10821
+ const {view: view} = this;
10822
+ return view && view.ownerDocument || window;
10823
+ }
10751
10824
  get notPointer() {
10752
10825
  const {p: p} = this;
10753
10826
  return p.type !== "pointer" || p.touch || this.useMultiTouch;
@@ -10793,7 +10866,7 @@ var LeaferUI = function(exports) {
10793
10866
  }
10794
10867
  for (let name in windowEvents) {
10795
10868
  windowEvents[name] = windowEvents[name].bind(this);
10796
- window.addEventListener(name, windowEvents[name]);
10869
+ this.windowTarget.addEventListener(name, windowEvents[name]);
10797
10870
  }
10798
10871
  }
10799
10872
  __removeListenEvents() {
@@ -10804,7 +10877,7 @@ var LeaferUI = function(exports) {
10804
10877
  this.viewEvents = {};
10805
10878
  }
10806
10879
  for (let name in windowEvents) {
10807
- window.removeEventListener(name, windowEvents[name]);
10880
+ this.windowTarget.removeEventListener(name, windowEvents[name]);
10808
10881
  this.windowEvents = {};
10809
10882
  }
10810
10883
  }
@@ -10824,7 +10897,8 @@ var LeaferUI = function(exports) {
10824
10897
  if (wheel.preventDefault) e.preventDefault();
10825
10898
  }
10826
10899
  preventWindowPointer(e) {
10827
- return !this.downData && e.target !== this.view;
10900
+ if (this.downData || e.target === this.view) return false;
10901
+ return this.config.shadowDOM && e.composedPath ? !e.composedPath().includes(this.view) : true;
10828
10902
  }
10829
10903
  onKeyDown(e) {
10830
10904
  this.keyDown(KeyEventHelper.convert(e));
@@ -11034,8 +11108,8 @@ var LeaferUI = function(exports) {
11034
11108
  canvas.save();
11035
11109
  if (item.transform) canvas.transform(item.transform);
11036
11110
  if (originPaint.scaleFixed) {
11037
- const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11038
- if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
11111
+ const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true, originPaint.scaleFixed, false);
11112
+ if (scaleX !== 1) canvas.scale(scaleX, scaleY);
11039
11113
  }
11040
11114
  if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
11041
11115
  fillPathOrText(ui, canvas, renderOptions);
@@ -11432,6 +11506,7 @@ var LeaferUI = function(exports) {
11432
11506
  const clip = transform && !transform.onlyScale || data.path || data.cornerRadius;
11433
11507
  if (clip || opacity && opacity < 1 || blendMode) leafPaint.complex = clip ? 2 : true;
11434
11508
  }
11509
+ if (paint.filter) PaintImage.applyFilter(leafPaint, image, paint.filter, ui);
11435
11510
  return true;
11436
11511
  }
11437
11512
  function onLoad(ui, event) {
@@ -11635,7 +11710,7 @@ var LeaferUI = function(exports) {
11635
11710
  let {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions), id = paint.film ? paint.nowIndex : scaleX + "-" + scaleY;
11636
11711
  if (paint.patternId !== id && !ui.destroyed) {
11637
11712
  if (!(Platform.image.isLarge(paint.image, scaleX, scaleY) && !paint.data.repeat)) {
11638
- const {image: image, data: data} = paint, {opacity: opacity, filters: filters} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11713
+ const {image: image, data: data} = paint, {opacity: opacity} = paint.originPaint, {transform: transform, gap: gap} = data, fixScale = PaintImage.getPatternFixScale(paint, scaleX, scaleY);
11639
11714
  let imageMatrix, xGap, yGap, {width: width, height: height} = image;
11640
11715
  if (fixScale) scaleX *= fixScale, scaleY *= fixScale;
11641
11716
  width *= scaleX;
@@ -11651,7 +11726,7 @@ var LeaferUI = function(exports) {
11651
11726
  if (transform) copy$1(imageMatrix, transform);
11652
11727
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
11653
11728
  }
11654
- const imageCanvas = image.getCanvas(width, height, opacity, filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11729
+ const imageCanvas = image.getCanvas(width, height, opacity, undefined, xGap, yGap, ui.leafer && ui.leafer.config.smooth, data.interlace);
11655
11730
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
11656
11731
  paint.style = pattern;
11657
11732
  paint.patternId = id;
@@ -11678,7 +11753,7 @@ var LeaferUI = function(exports) {
11678
11753
  if (drawImage) {
11679
11754
  if (data.repeat) {
11680
11755
  drawImage = false;
11681
- } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11756
+ } else if (!(originPaint.changeful || paint.film || Platform.name === "miniapp" || exporting)) {
11682
11757
  drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
11683
11758
  }
11684
11759
  }
@@ -11737,6 +11812,7 @@ var LeaferUI = function(exports) {
11737
11812
  if (!recycleMap) recycleMap = {};
11738
11813
  recycleMap[url] = true;
11739
11814
  ImageManager.recyclePaint(paint);
11815
+ if (data.__willDestroy && image.parent) PaintImage.recycleFilter(image, data.__leaf);
11740
11816
  if (image.loading) {
11741
11817
  if (!input) {
11742
11818
  input = data.__input && data.__input[attrName] || [];
@@ -12157,7 +12233,7 @@ var LeaferUI = function(exports) {
12157
12233
  }, row = {
12158
12234
  words: []
12159
12235
  };
12160
- if (__letterSpacing) content = [ ...content ];
12236
+ content = [ ...content ];
12161
12237
  for (let i = 0, len = content.length; i < len; i++) {
12162
12238
  char = content[i];
12163
12239
  if (char === "\n") {
@@ -14344,9 +14420,7 @@ var LeaferUI = function(exports) {
14344
14420
  const {Yes: Yes, NoAndSkip: NoAndSkip, YesAndSkip: YesAndSkip} = exports.Answer;
14345
14421
  const idCondition = {}, classNameCondition = {}, tagCondition = {};
14346
14422
  class Finder {
14347
- constructor(target) {
14348
- this.innerIdMap = {};
14349
- this.idMap = {};
14423
+ constructor(target, _config) {
14350
14424
  this.methods = {
14351
14425
  id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf),
14352
14426
  1) : 0,
@@ -14356,6 +14430,13 @@ var LeaferUI = function(exports) {
14356
14430
  tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
14357
14431
  tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
14358
14432
  };
14433
+ this.idMap = {};
14434
+ this.innerIdMap = {};
14435
+ const app = target && target.app;
14436
+ if (app) {
14437
+ app.idMap ? this.idMap = app.idMap : app.idMap = this.idMap;
14438
+ app.innerIdMap ? this.innerIdMap = app.innerIdMap : app.innerIdMap = this.innerIdMap;
14439
+ }
14359
14440
  if (this.target = target) this.__listenEvents();
14360
14441
  }
14361
14442
  getBy(condition, branch, one, options) {
@@ -14476,8 +14557,13 @@ var LeaferUI = function(exports) {
14476
14557
  return getSelector(this).getBy(condition, this, true, options);
14477
14558
  };
14478
14559
  Plugin.add("find");
14479
- Creator.finder = function(target) {
14480
- return new Finder(target);
14560
+ Creator.finder = function(target, config) {
14561
+ return new Finder(target, config);
14562
+ };
14563
+ LeafHelper.cacheId = function(t) {
14564
+ const {leafer: leafer, id: id} = t;
14565
+ if (id) leafer.app.idMap[id] = t;
14566
+ if (leafer.cacheInnerId) leafer.app.innerIdMap[t.innerId] = t;
14481
14567
  };
14482
14568
  exports.AlignHelper = AlignHelper;
14483
14569
  exports.AnimateEasing = AnimateEasing;