@leafer-game/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} = MathHelper, {min: min, max: max$2, abs: abs$3} = Math;
9089
+ const {min: min, max: max$2, abs: abs$3} = Math, {float: float$1, sign: sign} = 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.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$2(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.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(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;