@leafer/miniapp 1.9.10 → 1.9.12

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.
@@ -3840,7 +3840,12 @@ class TaskProcessor {
3840
3840
  runTask() {
3841
3841
  const task = this.list[this.index];
3842
3842
  if (!task) {
3843
- this.nextTask();
3843
+ this.timer = setTimeout(() => this.nextTask());
3844
+ return;
3845
+ }
3846
+ if (task.isCancel) {
3847
+ this.index++;
3848
+ this.runTask();
3844
3849
  return;
3845
3850
  }
3846
3851
  task.run().then(() => {
@@ -3871,16 +3876,15 @@ class TaskProcessor {
3871
3876
  }
3872
3877
  setParallelList() {
3873
3878
  let task;
3879
+ const {config: config, list: list, index: index} = this;
3874
3880
  this.parallelList = [];
3875
3881
  this.parallelSuccessNumber = 0;
3876
- let end = this.index + this.config.parallel;
3877
- if (end > this.list.length) end = this.list.length;
3878
- for (let i = this.index; i < end; i++) {
3879
- task = this.list[i];
3880
- if (task.parallel) {
3881
- this.parallelList.push(task);
3882
- } else {
3883
- break;
3882
+ let end = index + config.parallel;
3883
+ if (end > list.length) end = list.length;
3884
+ if (config.parallel > 1) {
3885
+ for (let i = index; i < end; i++) {
3886
+ task = list[i];
3887
+ if (task.parallel) this.parallelList.push(task); else break;
3884
3888
  }
3885
3889
  }
3886
3890
  }
@@ -6815,7 +6819,7 @@ class LeafLevelList {
6815
6819
  }
6816
6820
  }
6817
6821
 
6818
- const version = "1.9.10";
6822
+ const version = "1.9.12";
6819
6823
 
6820
6824
  class LeaferCanvas extends LeaferCanvasBase {
6821
6825
  get allowBackgroundColor() {
@@ -9925,7 +9929,7 @@ class UIEvent extends Event {
9925
9929
  }
9926
9930
  }
9927
9931
 
9928
- const {float: float$1, sign: sign$2} = MathHelper, {min: min, max: max$3, abs: abs$7} = Math;
9932
+ const {min: min, max: max$3, abs: abs$7} = Math, {float: float$1, sign: sign$2} = MathHelper, {minX: minX, maxX: maxX, minY: minY, maxY: maxY} = BoundsHelper;
9929
9933
 
9930
9934
  const tempContent = new Bounds, tempDragBounds = new Bounds;
9931
9935
 
@@ -9975,26 +9979,27 @@ const DragBoundsHelper = {
9975
9979
  tempContent.set(content).scaleOf(origin, scale.x, scale.y);
9976
9980
  const originLeftScale = (origin.x - content.x) / content.width, originRightScale = 1 - originLeftScale;
9977
9981
  const originTopScale = (origin.y - content.y) / content.height, originBottomScale = 1 - originTopScale;
9978
- let correctScaleX, correctScaleY, aScale, bScale, aSize, bSize;
9982
+ let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
9979
9983
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9980
- correctScaleX = scale.x < 0 ? 1 / scale.x : 1;
9981
- if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX, 1);
9984
+ if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9982
9985
  aSize = float$1(tempContent.minX - tempDragBounds.minX);
9983
9986
  bSize = float$1(tempDragBounds.maxX - tempContent.maxX);
9984
9987
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
9985
9988
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
9986
9989
  correctScaleX *= max$3(aScale, bScale);
9987
9990
  } else {
9988
- if (scale.x < 0) tempContent.unsign();
9991
+ if (scale.x < 0) {
9992
+ if (float$1(minX(content) - minX(dragBounds)) <= 0 || float$1(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9993
+ tempContent.unsign();
9994
+ }
9989
9995
  aSize = float$1(tempDragBounds.minX - tempContent.minX);
9990
9996
  bSize = float$1(tempContent.maxX - tempDragBounds.maxX);
9991
9997
  aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
9992
9998
  bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
9993
- correctScaleX = min(aScale, bScale);
9999
+ correctScaleX *= min(aScale, bScale);
9994
10000
  }
9995
10001
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
9996
- correctScaleY = scale.y < 0 ? 1 / scale.y : 1;
9997
- if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY);
10002
+ if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9998
10003
  aSize = float$1(tempContent.minY - tempDragBounds.minY);
9999
10004
  bSize = float$1(tempDragBounds.maxY - tempContent.maxY);
10000
10005
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
@@ -10006,12 +10011,15 @@ const DragBoundsHelper = {
10006
10011
  correctScaleY = sign$2(correctScaleY) * aScale;
10007
10012
  }
10008
10013
  } else {
10009
- if (scale.y < 0) tempContent.unsign();
10014
+ if (scale.y < 0) {
10015
+ if (float$1(minY(content) - minY(dragBounds)) <= 0 || float$1(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
10016
+ tempContent.unsign();
10017
+ }
10010
10018
  aSize = float$1(tempDragBounds.minY - tempContent.minY);
10011
10019
  bSize = float$1(tempContent.maxY - tempDragBounds.maxY);
10012
10020
  aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
10013
10021
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
10014
- correctScaleY = min(aScale, bScale);
10022
+ correctScaleY *= min(aScale, bScale);
10015
10023
  }
10016
10024
  scale.x *= isFinite(correctScaleX) ? correctScaleX : 1;
10017
10025
  scale.y *= isFinite(correctScaleY) ? correctScaleY : 1;
@@ -11091,9 +11099,9 @@ const ui$5 = UI.prototype;
11091
11099
 
11092
11100
  ui$5.__updateHitCanvas = function() {
11093
11101
  if (this.__box) this.__box.__updateHitCanvas();
11094
- const leafer = this.leafer || this.parent && this.parent.leafer;
11095
- if (!leafer) return;
11096
- const data = this.__, {hitCanvasManager: hitCanvasManager} = leafer;
11102
+ const {hitCanvasManager: hitCanvasManager} = this.leafer || this.parent && this.parent.leafer || {};
11103
+ if (!hitCanvasManager) return;
11104
+ const data = this.__;
11097
11105
  const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === "pixel";
11098
11106
  const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === "pixel";
11099
11107
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -12289,11 +12297,11 @@ function getShadowRenderSpread(_ui, shadow) {
12289
12297
 
12290
12298
  function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
12291
12299
  if (shadow.spread) {
12292
- const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
12300
+ const spread = shadow.spread * 2 * otherScale * (isInnerShaodw ? -1 : 1), {width: width, height: height} = ui.__layout.strokeBounds;
12293
12301
  tempMatrix.set().scaleOfOuter({
12294
12302
  x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
12295
12303
  y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
12296
- }, spreadScale);
12304
+ }, 1 + spread / width, 1 + spread / height);
12297
12305
  return tempMatrix;
12298
12306
  }
12299
12307
  return undefined;
@@ -13836,7 +13844,7 @@ class EditBox extends Group {
13836
13844
  return this.scaleX * this.scaleY < 0;
13837
13845
  }
13838
13846
  get canUse() {
13839
- return this.app && this.visible && this.view.visible;
13847
+ return this.app && this.editor.editing;
13840
13848
  }
13841
13849
  get canGesture() {
13842
13850
  if (!this.canUse) return false;
@@ -14110,29 +14118,25 @@ class EditBox extends Group {
14110
14118
  this.dragPoint = null;
14111
14119
  }
14112
14120
  onTransformStart(e) {
14113
- if (this.canUse) {
14114
- if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
14115
- if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
14116
- const {dragStartData: dragStartData, target: target} = this;
14117
- dragStartData.x = e.x;
14118
- dragStartData.y = e.y;
14119
- dragStartData.totalOffset = getPointData();
14120
- dragStartData.point = {
14121
- x: target.x,
14122
- y: target.y
14123
- };
14124
- dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
14125
- dragStartData.rotation = target.rotation;
14126
- }
14121
+ if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
14122
+ if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
14123
+ const {dragStartData: dragStartData, target: target} = this;
14124
+ dragStartData.x = e.x;
14125
+ dragStartData.y = e.y;
14126
+ dragStartData.totalOffset = getPointData();
14127
+ dragStartData.point = {
14128
+ x: target.x,
14129
+ y: target.y
14130
+ };
14131
+ dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
14132
+ dragStartData.rotation = target.rotation;
14127
14133
  }
14128
14134
  onTransformEnd(e) {
14129
- if (this.canUse) {
14130
- if (this.canDragLimitAnimate && (e instanceof DragEvent || e instanceof MoveEvent)) this.transformTool.onMove(e);
14131
- if (this.resizing) ResizeEvent.resizingKeys = null;
14132
- this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
14133
- this.editor.opacity = 1;
14134
- this.update();
14135
- }
14135
+ if (this.canDragLimitAnimate && (e instanceof DragEvent || e instanceof MoveEvent)) this.transformTool.onMove(e);
14136
+ if (this.resizing) ResizeEvent.resizingKeys = null;
14137
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
14138
+ this.editor.opacity = 1;
14139
+ this.editor.update();
14136
14140
  }
14137
14141
  onMove(e) {
14138
14142
  if (this.canGesture && e.moveType !== "drag") {
@@ -14161,6 +14165,12 @@ class EditBox extends Group {
14161
14165
  }
14162
14166
  }
14163
14167
  }
14168
+ onGestureStart(e) {
14169
+ if (this.canGesture && e.moveType !== "drag") this.onTransformStart(e);
14170
+ }
14171
+ onGestureEnd(e) {
14172
+ if (this.canGesture && e.moveType !== "drag") this.onTransformEnd(e);
14173
+ }
14164
14174
  isHoldRotateKey(e) {
14165
14175
  const {rotateKey: rotateKey} = this.mergedConfig;
14166
14176
  if (rotateKey) return e.isHoldKeys(rotateKey);
@@ -14230,7 +14240,7 @@ class EditBox extends Group {
14230
14240
  const {rect: rect, editor: editor, __eventIds: events} = this;
14231
14241
  events.push(rect.on_([ [ PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
14232
14242
  this.waitLeafer(() => {
14233
- events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ [ MoveEvent.START, MoveEvent.BEFORE_MOVE ], this.onMove, this, true ], [ [ ZoomEvent.START, ZoomEvent.BEFORE_ZOOM ], this.onScale, this, true ], [ [ RotateEvent.START, RotateEvent.BEFORE_ROTATE ], this.onRotate, this, true ], [ [ MoveEvent.END, ZoomEvent.END, RotateEvent.END ], this.onTransformEnd, this ] ]));
14243
+ events.push(editor.app.on_([ [ [ KeyEvent.HOLD, KeyEvent.UP ], this.onKey, this ], [ KeyEvent.DOWN, this.onArrow, this ], [ MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ [ MoveEvent.START, ZoomEvent.START, RotateEvent.START ], this.onGestureStart, this ], [ [ MoveEvent.END, ZoomEvent.END, RotateEvent.END ], this.onGestureEnd, this ] ]));
14234
14244
  });
14235
14245
  }
14236
14246
  __removeListenEvents() {
@@ -15086,7 +15096,7 @@ let Editor = class Editor extends Group {
15086
15096
  const event = new EditorGroupEvent(type, {
15087
15097
  editTarget: group
15088
15098
  });
15089
- if (!group || !group.syncEventer) this.emitEvent(event);
15099
+ this.emitEvent(event);
15090
15100
  if (group) group.emitEvent(event);
15091
15101
  }
15092
15102
  openInnerEditor(target, nameOrSelect, select) {
@@ -15131,7 +15141,7 @@ let Editor = class Editor extends Group {
15131
15141
  editTarget: editTarget,
15132
15142
  innerEditor: innerEditor
15133
15143
  });
15134
- if (!editTarget.syncEventer) this.emitEvent(event);
15144
+ this.emitEvent(event);
15135
15145
  editTarget.emitEvent(event);
15136
15146
  }
15137
15147
  lock() {