@leafer/worker 1.9.10 → 1.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/worker.js CHANGED
@@ -3611,7 +3611,12 @@ var LeaferUI = function(exports) {
3611
3611
  runTask() {
3612
3612
  const task = this.list[this.index];
3613
3613
  if (!task) {
3614
- this.nextTask();
3614
+ this.timer = setTimeout(() => this.nextTask());
3615
+ return;
3616
+ }
3617
+ if (task.isCancel) {
3618
+ this.index++;
3619
+ this.runTask();
3615
3620
  return;
3616
3621
  }
3617
3622
  task.run().then(() => {
@@ -3642,16 +3647,15 @@ var LeaferUI = function(exports) {
3642
3647
  }
3643
3648
  setParallelList() {
3644
3649
  let task;
3650
+ const {config: config, list: list, index: index} = this;
3645
3651
  this.parallelList = [];
3646
3652
  this.parallelSuccessNumber = 0;
3647
- let end = this.index + this.config.parallel;
3648
- if (end > this.list.length) end = this.list.length;
3649
- for (let i = this.index; i < end; i++) {
3650
- task = this.list[i];
3651
- if (task.parallel) {
3652
- this.parallelList.push(task);
3653
- } else {
3654
- break;
3653
+ let end = index + config.parallel;
3654
+ if (end > list.length) end = list.length;
3655
+ if (config.parallel > 1) {
3656
+ for (let i = index; i < end; i++) {
3657
+ task = list[i];
3658
+ if (task.parallel) this.parallelList.push(task); else break;
3655
3659
  }
3656
3660
  }
3657
3661
  }
@@ -6409,7 +6413,7 @@ var LeaferUI = function(exports) {
6409
6413
  this.levelMap = null;
6410
6414
  }
6411
6415
  }
6412
- const version = "1.9.10";
6416
+ const version = "1.9.11";
6413
6417
  class LeaferCanvas extends LeaferCanvasBase {
6414
6418
  get allowBackgroundColor() {
6415
6419
  return true;
@@ -9082,7 +9086,7 @@ var LeaferUI = function(exports) {
9082
9086
  EventCreator.changeName(oldName, newName);
9083
9087
  }
9084
9088
  }
9085
- const {float: float$1, sign: sign$2} = MathHelper, {min: min, max: max$3, abs: abs$7} = Math;
9089
+ 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;
9086
9090
  const tempContent = new Bounds, tempDragBounds = new Bounds;
9087
9091
  const DragBoundsHelper = {
9088
9092
  limitMove(leaf, move) {
@@ -9130,26 +9134,27 @@ var LeaferUI = function(exports) {
9130
9134
  tempContent.set(content).scaleOf(origin, scale.x, scale.y);
9131
9135
  const originLeftScale = (origin.x - content.x) / content.width, originRightScale = 1 - originLeftScale;
9132
9136
  const originTopScale = (origin.y - content.y) / content.height, originBottomScale = 1 - originTopScale;
9133
- let correctScaleX, correctScaleY, aScale, bScale, aSize, bSize;
9137
+ let correctScaleX = 1, correctScaleY = 1, aScale, bScale, aSize, bSize;
9134
9138
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "width")) {
9135
- correctScaleX = scale.x < 0 ? 1 / scale.x : 1;
9136
- if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX, 1);
9139
+ if (scale.x < 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9137
9140
  aSize = float$1(tempContent.minX - tempDragBounds.minX);
9138
9141
  bSize = float$1(tempDragBounds.maxX - tempContent.maxX);
9139
9142
  aScale = originLeftScale && aSize > 0 ? 1 + aSize / (originLeftScale * tempContent.width) : 1;
9140
9143
  bScale = originRightScale && bSize > 0 ? 1 + bSize / (originRightScale * tempContent.width) : 1;
9141
9144
  correctScaleX *= max$3(aScale, bScale);
9142
9145
  } else {
9143
- if (scale.x < 0) tempContent.unsign();
9146
+ if (scale.x < 0) {
9147
+ if (float$1(minX(content) - minX(dragBounds)) <= 0 || float$1(maxX(dragBounds) - maxX(content)) <= 0) tempContent.scaleOf(origin, correctScaleX = 1 / scale.x, 1);
9148
+ tempContent.unsign();
9149
+ }
9144
9150
  aSize = float$1(tempDragBounds.minX - tempContent.minX);
9145
9151
  bSize = float$1(tempContent.maxX - tempDragBounds.maxX);
9146
9152
  aScale = originLeftScale && aSize > 0 ? 1 - aSize / (originLeftScale * tempContent.width) : 1;
9147
9153
  bScale = originRightScale && bSize > 0 ? 1 - bSize / (originRightScale * tempContent.width) : 1;
9148
- correctScaleX = min(aScale, bScale);
9154
+ correctScaleX *= min(aScale, bScale);
9149
9155
  }
9150
9156
  if (D$2.isInnerMode(content, dragBounds, dragBoundsType, "height")) {
9151
- correctScaleY = scale.y < 0 ? 1 / scale.y : 1;
9152
- if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY);
9157
+ if (scale.y < 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9153
9158
  aSize = float$1(tempContent.minY - tempDragBounds.minY);
9154
9159
  bSize = float$1(tempDragBounds.maxY - tempContent.maxY);
9155
9160
  aScale = originTopScale && aSize > 0 ? 1 + aSize / (originTopScale * tempContent.height) : 1;
@@ -9161,12 +9166,15 @@ var LeaferUI = function(exports) {
9161
9166
  correctScaleY = sign$2(correctScaleY) * aScale;
9162
9167
  }
9163
9168
  } else {
9164
- if (scale.y < 0) tempContent.unsign();
9169
+ if (scale.y < 0) {
9170
+ if (float$1(minY(content) - minY(dragBounds)) <= 0 || float$1(maxY(dragBounds) - maxY(content)) <= 0) tempContent.scaleOf(origin, 1, correctScaleY = 1 / scale.y);
9171
+ tempContent.unsign();
9172
+ }
9165
9173
  aSize = float$1(tempDragBounds.minY - tempContent.minY);
9166
9174
  bSize = float$1(tempContent.maxY - tempDragBounds.maxY);
9167
9175
  aScale = originTopScale && aSize > 0 ? 1 - aSize / (originTopScale * tempContent.height) : 1;
9168
9176
  bScale = originBottomScale && bSize > 0 ? 1 - bSize / (originBottomScale * tempContent.height) : 1;
9169
- correctScaleY = min(aScale, bScale);
9177
+ correctScaleY *= min(aScale, bScale);
9170
9178
  }
9171
9179
  scale.x *= isFinite(correctScaleX) ? correctScaleX : 1;
9172
9180
  scale.y *= isFinite(correctScaleY) ? correctScaleY : 1;
@@ -10145,9 +10153,9 @@ var LeaferUI = function(exports) {
10145
10153
  const ui$5 = exports.UI.prototype;
10146
10154
  ui$5.__updateHitCanvas = function() {
10147
10155
  if (this.__box) this.__box.__updateHitCanvas();
10148
- const leafer = this.leafer || this.parent && this.parent.leafer;
10149
- if (!leafer) return;
10150
- const data = this.__, {hitCanvasManager: hitCanvasManager} = leafer;
10156
+ const {hitCanvasManager: hitCanvasManager} = this.leafer || this.parent && this.parent.leafer || {};
10157
+ if (!hitCanvasManager) return;
10158
+ const data = this.__;
10151
10159
  const isHitPixelFill = (data.__isAlphaPixelFill || data.__isCanvas) && data.hitFill === "pixel";
10152
10160
  const isHitPixelStroke = data.__isAlphaPixelStroke && data.hitStroke === "pixel";
10153
10161
  const isHitPixel = isHitPixelFill || isHitPixelStroke;
@@ -11144,11 +11152,11 @@ var LeaferUI = function(exports) {
11144
11152
  }
11145
11153
  function getShadowTransform(ui, canvas, _shape, shadow, outBounds, otherScale, isInnerShaodw) {
11146
11154
  if (shadow.spread) {
11147
- const spreadScale = 1 + shadow.spread * 2 / ui.__layout.strokeBounds.width * otherScale * (isInnerShaodw ? -1 : 1);
11155
+ const spread = shadow.spread * 2 * otherScale * (isInnerShaodw ? -1 : 1), {width: width, height: height} = ui.__layout.strokeBounds;
11148
11156
  tempMatrix.set().scaleOfOuter({
11149
11157
  x: (outBounds.x + outBounds.width / 2) * canvas.pixelRatio,
11150
11158
  y: (outBounds.y + outBounds.height / 2) * canvas.pixelRatio
11151
- }, spreadScale);
11159
+ }, 1 + spread / width, 1 + spread / height);
11152
11160
  return tempMatrix;
11153
11161
  }
11154
11162
  return undefined;
@@ -12577,7 +12585,7 @@ var LeaferUI = function(exports) {
12577
12585
  return this.scaleX * this.scaleY < 0;
12578
12586
  }
12579
12587
  get canUse() {
12580
- return this.app && this.visible && this.view.visible;
12588
+ return this.app && this.editor.editing;
12581
12589
  }
12582
12590
  get canGesture() {
12583
12591
  if (!this.canUse) return false;
@@ -12851,29 +12859,25 @@ var LeaferUI = function(exports) {
12851
12859
  this.dragPoint = null;
12852
12860
  }
12853
12861
  onTransformStart(e) {
12854
- if (this.canUse) {
12855
- if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
12856
- if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
12857
- const {dragStartData: dragStartData, target: target} = this;
12858
- dragStartData.x = e.x;
12859
- dragStartData.y = e.y;
12860
- dragStartData.totalOffset = getPointData();
12861
- dragStartData.point = {
12862
- x: target.x,
12863
- y: target.y
12864
- };
12865
- dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
12866
- dragStartData.rotation = target.rotation;
12867
- }
12862
+ if (this.moving) this.editor.opacity = this.mergedConfig.hideOnMove ? 0 : 1;
12863
+ if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys;
12864
+ const {dragStartData: dragStartData, target: target} = this;
12865
+ dragStartData.x = e.x;
12866
+ dragStartData.y = e.y;
12867
+ dragStartData.totalOffset = getPointData();
12868
+ dragStartData.point = {
12869
+ x: target.x,
12870
+ y: target.y
12871
+ };
12872
+ dragStartData.bounds = Object.assign({}, target.getLayoutBounds("box", "local"));
12873
+ dragStartData.rotation = target.rotation;
12868
12874
  }
12869
12875
  onTransformEnd(e) {
12870
- if (this.canUse) {
12871
- if (this.canDragLimitAnimate && (e instanceof exports.DragEvent || e instanceof exports.MoveEvent)) this.transformTool.onMove(e);
12872
- if (this.resizing) ResizeEvent.resizingKeys = null;
12873
- this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
12874
- this.editor.opacity = 1;
12875
- this.update();
12876
- }
12876
+ if (this.canDragLimitAnimate && (e instanceof exports.DragEvent || e instanceof exports.MoveEvent)) this.transformTool.onMove(e);
12877
+ if (this.resizing) ResizeEvent.resizingKeys = null;
12878
+ this.dragging = this.gesturing = this.moving = this.resizing = this.rotating = this.skewing = false;
12879
+ this.editor.opacity = 1;
12880
+ this.editor.update();
12877
12881
  }
12878
12882
  onMove(e) {
12879
12883
  if (this.canGesture && e.moveType !== "drag") {
@@ -12902,6 +12906,12 @@ var LeaferUI = function(exports) {
12902
12906
  }
12903
12907
  }
12904
12908
  }
12909
+ onGestureStart(e) {
12910
+ if (this.canGesture && e.moveType !== "drag") this.onTransformStart(e);
12911
+ }
12912
+ onGestureEnd(e) {
12913
+ if (this.canGesture && e.moveType !== "drag") this.onTransformEnd(e);
12914
+ }
12905
12915
  isHoldRotateKey(e) {
12906
12916
  const {rotateKey: rotateKey} = this.mergedConfig;
12907
12917
  if (rotateKey) return e.isHoldKeys(rotateKey);
@@ -12971,7 +12981,7 @@ var LeaferUI = function(exports) {
12971
12981
  const {rect: rect, editor: editor, __eventIds: events} = this;
12972
12982
  events.push(rect.on_([ [ exports.PointerEvent.DOUBLE_TAP, this.onDoubleTap, this ], [ exports.PointerEvent.LONG_PRESS, this.onLongPress, this ] ]));
12973
12983
  this.waitLeafer(() => {
12974
- events.push(editor.app.on_([ [ [ exports.KeyEvent.HOLD, exports.KeyEvent.UP ], this.onKey, this ], [ exports.KeyEvent.DOWN, this.onArrow, this ], [ [ exports.MoveEvent.START, exports.MoveEvent.BEFORE_MOVE ], this.onMove, this, true ], [ [ exports.ZoomEvent.START, exports.ZoomEvent.BEFORE_ZOOM ], this.onScale, this, true ], [ [ exports.RotateEvent.START, exports.RotateEvent.BEFORE_ROTATE ], this.onRotate, this, true ], [ [ exports.MoveEvent.END, exports.ZoomEvent.END, exports.RotateEvent.END ], this.onTransformEnd, this ] ]));
12984
+ events.push(editor.app.on_([ [ [ exports.KeyEvent.HOLD, exports.KeyEvent.UP ], this.onKey, this ], [ exports.KeyEvent.DOWN, this.onArrow, this ], [ exports.MoveEvent.BEFORE_MOVE, this.onMove, this, true ], [ exports.ZoomEvent.BEFORE_ZOOM, this.onScale, this, true ], [ exports.RotateEvent.BEFORE_ROTATE, this.onRotate, this, true ], [ [ exports.MoveEvent.START, exports.ZoomEvent.START, exports.RotateEvent.START ], this.onGestureStart, this ], [ [ exports.MoveEvent.END, exports.ZoomEvent.END, exports.RotateEvent.END ], this.onGestureEnd, this ] ]));
12975
12985
  });
12976
12986
  }
12977
12987
  __removeListenEvents() {