@leafer-ui/miniapp 2.2.0 → 2.2.1

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.
@@ -4531,11 +4531,15 @@ function affectRenderBoundsType(defaultValue) {
4531
4531
  function surfaceType(defaultValue) {
4532
4532
  return decorateLeafAttr(defaultValue, key => attr({
4533
4533
  set(value) {
4534
- this.__setAttr(key, value) && (this.__layout.surfaceChanged || this.__layout.surfaceChange());
4534
+ this.__setAttr(key, value) && doSurfaceType(this);
4535
4535
  }
4536
4536
  }));
4537
4537
  }
4538
4538
 
4539
+ function doSurfaceType(leaf) {
4540
+ leaf.__layout.surfaceChanged || leaf.__layout.surfaceChange();
4541
+ }
4542
+
4539
4543
  function dimType(defaultValue) {
4540
4544
  return decorateLeafAttr(defaultValue, key => attr({
4541
4545
  set(value) {
@@ -4601,12 +4605,12 @@ function sortType(defaultValue) {
4601
4605
  }));
4602
4606
  }
4603
4607
 
4604
- function maskType(defaultValue) {
4608
+ function maskType(defaultValue, updateSelf) {
4605
4609
  return decorateLeafAttr(defaultValue, key => attr({
4606
4610
  set(value) {
4607
4611
  if (this.__setAttr(key, value)) {
4608
4612
  this.__layout.boxChanged || this.__layout.boxChange();
4609
- this.waitParent(() => {
4613
+ updateSelf ? this.__updateMask() : this.waitParent(() => {
4610
4614
  this.parent.__updateMask(value);
4611
4615
  });
4612
4616
  }
@@ -6258,7 +6262,8 @@ const BranchRender = {
6258
6262
  if (this.__worldOpacity && hasSize(nowWorld)) {
6259
6263
  const data = this.__;
6260
6264
  if (data.__useDim) {
6261
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
6265
+ if (data.bright && !options.topRendering) return options.topList.add(this);
6266
+ if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
6262
6267
  }
6263
6268
  if (data.__single && !this.isBranchLeaf) {
6264
6269
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
@@ -6282,6 +6287,7 @@ const BranchRender = {
6282
6287
  child = children[i];
6283
6288
  excludeRenderBounds$1(child, options) || (child.__hasComplex ? LeafHelper.renderComplex(child, canvas, options) : child.__render(canvas, options));
6284
6289
  }
6290
+ if (this.__hasMask === 0) this.__rerenderMask(canvas, options);
6285
6291
  }
6286
6292
  },
6287
6293
  __clip(canvas, options) {
@@ -6498,11 +6504,19 @@ let Leaf = class Leaf {
6498
6504
  updateLayout() {
6499
6505
  this.__layout.update();
6500
6506
  }
6501
- forceUpdate(attrName) {
6502
- if (isUndefined(attrName)) attrName = "width"; else if (attrName === "surface") attrName = "blendMode";
6503
- const value = this.__.__getInput(attrName);
6504
- this.__[attrName] = isUndefined(value) ? null : undefined;
6505
- this[attrName] = value;
6507
+ forceUpdate(typeOrAttrName) {
6508
+ let quick;
6509
+ if (!typeOrAttrName || typeOrAttrName === "bounds") doBoundsType(this), quick = true; else if (typeOrAttrName === "surface") doSurfaceType(this),
6510
+ quick = true; else if (typeOrAttrName === "stroke") doStrokeType(this), quick = true;
6511
+ if (quick) {
6512
+ const {leafer: leafer} = this;
6513
+ return leafer && leafer.watcher && leafer.watcher.__onAttrChange({
6514
+ target: this
6515
+ });
6516
+ }
6517
+ const value = this.__.__getInput(typeOrAttrName);
6518
+ this.__[typeOrAttrName] = isUndefined(value) ? null : undefined;
6519
+ this[typeOrAttrName] = value;
6506
6520
  }
6507
6521
  forceRender(_bounds, _sync) {
6508
6522
  this.forceUpdate("surface");
@@ -6521,7 +6535,8 @@ let Leaf = class Leaf {
6521
6535
  canvas.restore();
6522
6536
  }
6523
6537
  __updateMask(_value) {
6524
- this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6538
+ const hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6539
+ this.__hasMask = this.__.maskskip ? hasMask && 0 : hasMask;
6525
6540
  }
6526
6541
  __getNowWorld(options) {
6527
6542
  if (options.matrix) {
@@ -6990,7 +7005,7 @@ class LeafLevelList {
6990
7005
  }
6991
7006
  }
6992
7007
 
6993
- const version = "2.2.0";
7008
+ const version = "2.2.1";
6994
7009
 
6995
7010
  class LeaferCanvas extends LeaferCanvasBase {
6996
7011
  get allowBackgroundColor() {
@@ -7867,7 +7882,7 @@ class Picker {
7867
7882
  for (let i = 0, len = list.length; i < len; i++) {
7868
7883
  find = list[i];
7869
7884
  if (ignoreHittable || LeafHelper.worldHittable(find)) {
7870
- this.hitChild(find, point);
7885
+ this.hitChild(find, find.hitThrough ? this.point : point);
7871
7886
  if (findList.length) {
7872
7887
  if (find.isBranchLeaf && list.some(item => item !== find && LeafHelper.hasParent(item, find))) {
7873
7888
  findList.reset();
@@ -7880,7 +7895,7 @@ class Picker {
7880
7895
  }
7881
7896
  if (bottomList) {
7882
7897
  for (let i = 0, len = bottomList.length; i < len; i++) {
7883
- this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
7898
+ this.hitChild(bottomList[i].target, this.point, undefined, bottomList[i].proxy);
7884
7899
  if (findList.length) return findList.list[0];
7885
7900
  }
7886
7901
  }
@@ -7938,42 +7953,38 @@ class Picker {
7938
7953
  hitBranch(branch) {
7939
7954
  this.eachFind(branch.children, branch.__onlyHitMask);
7940
7955
  }
7941
- eachFind(children, hitMask) {
7956
+ eachFind(children, onlyHitMask) {
7942
7957
  let child, hit, data;
7943
7958
  const {point: point} = this, len = children.length;
7944
7959
  for (let i = len - 1; i > -1; i--) {
7945
7960
  child = children[i], data = child.__;
7946
- if (!data.visible || hitMask && !data.mask) continue;
7961
+ if (!data.visible || onlyHitMask && !data.mask) continue;
7947
7962
  hit = hitRadiusPoint$1(child.__world, data.hitRadius ? copyRadiusPoint$1(tempPoint$1, point, data.hitRadius) : point);
7948
7963
  if (child.isBranch) {
7949
7964
  if (hit || child.__ignoreHitWorld) {
7950
7965
  if (child.isBranchLeaf && data.__clipAfterFill && !child.__hitWorld(point, true)) continue;
7951
7966
  if (child.topChildren) this.eachFind(child.topChildren, false);
7952
7967
  this.eachFind(child.children, child.__onlyHitMask);
7953
- if (child.isBranchLeaf) this.hitChild(child, point);
7968
+ if (child.isBranchLeaf) this.hitChild(child, point, onlyHitMask);
7954
7969
  }
7955
7970
  } else {
7956
- if (hit) this.hitChild(child, point);
7971
+ if (hit) this.hitChild(child, point, onlyHitMask);
7957
7972
  }
7958
7973
  }
7959
7974
  }
7960
- hitChild(child, point, proxy) {
7975
+ hitChild(child, point, onlyHitMask, proxy) {
7961
7976
  if (this.exclude && this.exclude.has(child)) return;
7962
- if (child.__hitWorld(point)) {
7963
- const {parent: parent} = child;
7964
- if (parent && parent.__hasMask && !child.__.mask) {
7965
- let findMasks = [], item;
7966
- const {children: children} = parent;
7967
- for (let i = 0, len = children.length; i < len; i++) {
7968
- item = children[i];
7969
- if (item.__.mask) findMasks.push(item);
7970
- if (item === child) {
7971
- if (findMasks && !findMasks.every(value => value.__hitWorld(point))) return;
7972
- break;
7973
- }
7974
- }
7977
+ if (child.__hitWorld(point, onlyHitMask && child.mask === "path" ? true : undefined)) {
7978
+ const {parent: parent, mask: mask} = child;
7979
+ if (parent && parent.__hasMask && mask && !(mask === "clipping" || mask === "clipping-path")) {
7980
+ if (!parent.children.some(item => !item.mask && item.__hitWorld(point))) return;
7975
7981
  }
7976
- this.findList.add(proxy || child);
7982
+ const leaf = proxy || child, {hitThrough: hitThrough} = child, {findList: findList} = this;
7983
+ if (hitThrough) {
7984
+ const index = findList.list.findIndex(item => item[hitThrough] === child[hitThrough]);
7985
+ if (index > 0) return findList.addAt(leaf, index);
7986
+ }
7987
+ findList.add(leaf);
7977
7988
  }
7978
7989
  }
7979
7990
  clear() {
@@ -8835,6 +8846,8 @@ __decorate([ dataType(false) ], UI.prototype, "editable", void 0);
8835
8846
 
8836
8847
  __decorate([ hitType(true) ], UI.prototype, "hittable", void 0);
8837
8848
 
8849
+ __decorate([ hitType() ], UI.prototype, "hitThrough", void 0);
8850
+
8838
8851
  __decorate([ hitType("path") ], UI.prototype, "hitFill", void 0);
8839
8852
 
8840
8853
  __decorate([ strokeType("path") ], UI.prototype, "hitStroke", void 0);
@@ -10668,6 +10681,7 @@ class Dragger {
10668
10681
  }
10669
10682
  dragEnd(data) {
10670
10683
  if (!this.dragging && !this.moving) return;
10684
+ setTimeout(() => this.interaction.pointerMove(data));
10671
10685
  if (this.checkDragEndAnimate(data)) return;
10672
10686
  this.dragEndReal(data);
10673
10687
  }
@@ -12040,7 +12054,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
12040
12054
  data.__naturalWidth = image.width / data.pixelRatio;
12041
12055
  data.__naturalHeight = image.height / data.pixelRatio;
12042
12056
  if (data.__autoSide) {
12043
- ui.forceUpdate("width");
12057
+ ui.forceUpdate();
12044
12058
  LeafHelper.updateBounds(ui);
12045
12059
  ui.__layout.boundsChanged = true;
12046
12060
  if (ui.__proxyData) {
@@ -13326,4 +13340,4 @@ try {
13326
13340
  if (wx) useCanvas("miniapp", wx);
13327
13341
  } catch (_a) {}
13328
13342
 
13329
- export { AlignHelper, 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, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, 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, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, 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, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
13343
+ export { AlignHelper, 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, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, 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, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, 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, doSurfaceType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$4 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };