@leafer/worker 1.6.3 → 1.6.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/worker.js CHANGED
@@ -2272,16 +2272,19 @@ var LeaferUI = (function (exports) {
2272
2272
  if (blendMode)
2273
2273
  this.blendMode = 'source-over';
2274
2274
  }
2275
- clearWorld(bounds, ceilPixel) {
2276
- this.setTempBounds(bounds, ceilPixel);
2277
- this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2278
- }
2279
2275
  clipWorld(bounds, ceilPixel) {
2280
2276
  this.beginPath();
2281
2277
  this.setTempBounds(bounds, ceilPixel);
2282
2278
  this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2283
2279
  this.clip();
2284
2280
  }
2281
+ clipUI(ruleData) {
2282
+ ruleData.windingRule ? this.clip(ruleData.windingRule) : this.clip();
2283
+ }
2284
+ clearWorld(bounds, ceilPixel) {
2285
+ this.setTempBounds(bounds, ceilPixel);
2286
+ this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2287
+ }
2285
2288
  clear() {
2286
2289
  const { pixelRatio } = this;
2287
2290
  this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
@@ -5450,7 +5453,7 @@ var LeaferUI = (function (exports) {
5450
5453
  if (this.__worldOpacity) {
5451
5454
  canvas.setWorld(this.__nowWorld = this.__getNowWorld(options));
5452
5455
  this.__drawRenderPath(canvas);
5453
- this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
5456
+ canvas.clipUI(this);
5454
5457
  }
5455
5458
  },
5456
5459
  __updateWorldOpacity() {
@@ -6233,7 +6236,7 @@ var LeaferUI = (function (exports) {
6233
6236
  }
6234
6237
  }
6235
6238
 
6236
- const version = "1.6.3";
6239
+ const version = "1.6.4";
6237
6240
 
6238
6241
  class LeaferCanvas extends LeaferCanvasBase {
6239
6242
  get allowBackgroundColor() { return true; }
@@ -7529,7 +7532,7 @@ var LeaferUI = (function (exports) {
7529
7532
  __drawAfterFill(canvas, options) {
7530
7533
  if (this.__.__clipAfterFill) {
7531
7534
  canvas.save();
7532
- this.windingRule ? canvas.clip(this.windingRule) : canvas.clip();
7535
+ canvas.clipUI();
7533
7536
  this.__drawContent(canvas, options);
7534
7537
  canvas.restore();
7535
7538
  }
@@ -9014,6 +9017,9 @@ var LeaferUI = (function (exports) {
9014
9017
  __decorate([
9015
9018
  boundsType('show')
9016
9019
  ], exports.Text.prototype, "textOverflow", void 0);
9020
+ __decorate([
9021
+ surfaceType(false)
9022
+ ], exports.Text.prototype, "textEditing", void 0);
9017
9023
  exports.Text = __decorate([
9018
9024
  registerUI()
9019
9025
  ], exports.Text);
@@ -10478,11 +10484,14 @@ var LeaferUI = (function (exports) {
10478
10484
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
10479
10485
  fillText(ui, out);
10480
10486
  out.blendMode = 'normal';
10487
+ copyWorld(canvas, out, ui);
10488
+ out.recycle(ui.__nowWorld);
10489
+ }
10490
+ function copyWorld(canvas, out, ui) {
10481
10491
  if (ui.__worldFlipped || Platform.fullImageShadow)
10482
10492
  canvas.copyWorldByReset(out, ui.__nowWorld);
10483
10493
  else
10484
10494
  canvas.copyWorldToInner(out, ui.__nowWorld, ui.__layout.renderBounds);
10485
- out.recycle(ui.__nowWorld);
10486
10495
  }
10487
10496
  function drawTextStroke(ui, canvas) {
10488
10497
  let row, data = ui.__.__textDrawData;
@@ -10551,9 +10560,8 @@ var LeaferUI = (function (exports) {
10551
10560
  Paint.strokeArrow(stroke, ui, canvas);
10552
10561
  }
10553
10562
  function drawInside(stroke, ui, canvas) {
10554
- const data = ui.__;
10555
10563
  canvas.save();
10556
- data.windingRule ? canvas.clip(data.windingRule) : canvas.clip();
10564
+ canvas.clipUI(ui);
10557
10565
  drawCenter(stroke, 2, ui, canvas);
10558
10566
  canvas.restore();
10559
10567
  }
@@ -10567,12 +10575,9 @@ var LeaferUI = (function (exports) {
10567
10575
  const out = canvas.getSameCanvas(true, true);
10568
10576
  ui.__drawRenderPath(out);
10569
10577
  drawCenter(stroke, 2, ui, out);
10570
- data.windingRule ? out.clip(data.windingRule) : out.clip();
10578
+ out.clipUI(data);
10571
10579
  out.clearWorld(renderBounds);
10572
- if (ui.__worldFlipped || Platform.fullImageShadow)
10573
- canvas.copyWorldByReset(out, ui.__nowWorld);
10574
- else
10575
- canvas.copyWorldToInner(out, ui.__nowWorld, renderBounds);
10580
+ copyWorld(canvas, out, ui);
10576
10581
  out.recycle(ui.__nowWorld);
10577
10582
  }
10578
10583
  }
@@ -10628,9 +10633,7 @@ var LeaferUI = (function (exports) {
10628
10633
  paints = [paints];
10629
10634
  recycleMap = PaintImage.recycleImage(attrName, data);
10630
10635
  for (let i = 0, len = paints.length, item; i < len; i++) {
10631
- item = getLeafPaint(attrName, paints[i], ui);
10632
- if (item)
10633
- leafPaints.push(item);
10636
+ (item = getLeafPaint(attrName, paints[i], ui)) && leafPaints.push(item);
10634
10637
  }
10635
10638
  data['_' + attrName] = leafPaints.length ? leafPaints : undefined;
10636
10639
  if (leafPaints.length) {
@@ -10668,8 +10671,8 @@ var LeaferUI = (function (exports) {
10668
10671
  data = PaintGradient.conicGradient(paint, boxBounds);
10669
10672
  break;
10670
10673
  case 'solid':
10671
- const { type, blendMode, color, opacity } = paint;
10672
- data = { type, blendMode, style: ColorConvert.string(color, opacity) };
10674
+ const { type, color, opacity } = paint;
10675
+ data = { type, style: ColorConvert.string(color, opacity) };
10673
10676
  break;
10674
10677
  default:
10675
10678
  if (paint.r !== undefined)
@@ -11046,7 +11049,7 @@ var LeaferUI = (function (exports) {
11046
11049
  }
11047
11050
  function drawImage(ui, canvas, paint, data) {
11048
11051
  canvas.save();
11049
- ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
11052
+ canvas.clipUI(ui);
11050
11053
  if (paint.blendMode)
11051
11054
  canvas.blendMode = paint.blendMode;
11052
11055
  if (data.opacity)
@@ -11211,12 +11214,10 @@ var LeaferUI = (function (exports) {
11211
11214
  }
11212
11215
  worldCanvas ? other.copyWorld(worldCanvas, nowWorld, nowWorld, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
11213
11216
  }
11214
- if (ui.__worldFlipped) {
11217
+ if (ui.__worldFlipped)
11215
11218
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11216
- }
11217
- else {
11219
+ else
11218
11220
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11219
- }
11220
11221
  if (end && index < end)
11221
11222
  other.clearWorld(copyBounds, true);
11222
11223
  });
@@ -11275,12 +11276,10 @@ var LeaferUI = (function (exports) {
11275
11276
  copyBounds = bounds;
11276
11277
  }
11277
11278
  other.fillWorld(copyBounds, ColorConvert.string(item.color), 'source-in');
11278
- if (ui.__worldFlipped) {
11279
+ if (ui.__worldFlipped)
11279
11280
  current.copyWorldByReset(other, copyBounds, nowWorld, item.blendMode);
11280
- }
11281
- else {
11281
+ else
11282
11282
  current.copyWorldToInner(other, copyBounds, __layout.renderBounds, item.blendMode);
11283
- }
11284
11283
  if (end && index < end)
11285
11284
  other.clearWorld(copyBounds, true);
11286
11285
  });
@@ -14433,7 +14432,6 @@ ${filterStyle$1}
14433
14432
  ], exports.TextEditor);
14434
14433
 
14435
14434
  Plugin.add('text-editor', 'editor');
14436
- exports.Text.addAttr('textEditing', false, surfaceType);
14437
14435
 
14438
14436
  function addViewport(leafer, mergeConfig, custom) {
14439
14437
  addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);