@leafer/worker 1.10.0 → 1.10.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.
package/dist/worker.js CHANGED
@@ -6428,7 +6428,7 @@ var LeaferUI = function(exports) {
6428
6428
  this.levelMap = null;
6429
6429
  }
6430
6430
  }
6431
- const version = "1.10.0";
6431
+ const version = "1.10.1";
6432
6432
  class LeaferCanvas extends LeaferCanvasBase {
6433
6433
  get allowBackgroundColor() {
6434
6434
  return true;
@@ -7857,7 +7857,7 @@ var LeaferUI = function(exports) {
7857
7857
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
7858
7858
  } else drawer.rect(x, y, width, height);
7859
7859
  }
7860
- drawImagePlaceholder(_image, canvas, renderOptions) {
7860
+ drawImagePlaceholder(_paint, canvas, renderOptions) {
7861
7861
  Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
7862
7862
  }
7863
7863
  animate(keyframe, _options, _type, _isTemp) {
@@ -10288,30 +10288,31 @@ var LeaferUI = function(exports) {
10288
10288
  fillPathOrText(ui, canvas, renderOptions);
10289
10289
  }
10290
10290
  function fills(fills, ui, canvas, renderOptions) {
10291
- let item;
10291
+ let item, originPaint, countImage;
10292
10292
  for (let i = 0, len = fills.length; i < len; i++) {
10293
- item = fills[i];
10293
+ item = fills[i], originPaint = item.originPaint;
10294
10294
  if (item.image) {
10295
+ countImage ? countImage++ : countImage = 1;
10295
10296
  if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
10296
10297
  if (!item.style) {
10297
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
10298
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
10298
10299
  continue;
10299
10300
  }
10300
10301
  }
10301
10302
  canvas.fillStyle = item.style;
10302
- if (item.transform || item.scaleFixed) {
10303
+ if (item.transform || originPaint.scaleFixed) {
10303
10304
  canvas.save();
10304
10305
  if (item.transform) canvas.transform(item.transform);
10305
- if (item.scaleFixed) {
10306
+ if (originPaint.scaleFixed) {
10306
10307
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
10307
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
10308
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
10308
10309
  }
10309
- if (item.blendMode) canvas.blendMode = item.blendMode;
10310
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
10310
10311
  fillPathOrText(ui, canvas, renderOptions);
10311
10312
  canvas.restore();
10312
10313
  } else {
10313
- if (item.blendMode) {
10314
- canvas.saveBlendMode(item.blendMode);
10314
+ if (originPaint.blendMode) {
10315
+ canvas.saveBlendMode(originPaint.blendMode);
10315
10316
  fillPathOrText(ui, canvas, renderOptions);
10316
10317
  canvas.restoreBlendMode();
10317
10318
  } else fillPathOrText(ui, canvas, renderOptions);
@@ -10452,8 +10453,8 @@ var LeaferUI = function(exports) {
10452
10453
  const {strokeStyle: strokeStyle} = item;
10453
10454
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
10454
10455
  } else canvas.strokeStyle = item.style;
10455
- if (item.blendMode) {
10456
- canvas.saveBlendMode(item.blendMode);
10456
+ if (item.originPaint.blendMode) {
10457
+ canvas.saveBlendMode(item.originPaint.blendMode);
10457
10458
  isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
10458
10459
  canvas.restoreBlendMode();
10459
10460
  } else {
@@ -10544,61 +10545,62 @@ var LeaferUI = function(exports) {
10544
10545
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
10545
10546
  isTransparent = true;
10546
10547
  }
10547
- }
10548
- if (attrName === "fill") {
10549
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
10550
- stintSet(data, "__isTransparentFill", isTransparent);
10548
+ if (attrName === "fill") {
10549
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
10550
+ stintSet(data, "__isTransparentFill", isTransparent);
10551
+ } else {
10552
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
10553
+ stintSet(data, "__isTransparentStroke", isTransparent);
10554
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
10555
+ }
10551
10556
  } else {
10552
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
10553
- stintSet(data, "__isTransparentStroke", isTransparent);
10554
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
10557
+ data.__removePaint(attrName, false);
10555
10558
  }
10556
10559
  }
10557
10560
  function getLeafPaint(attrName, paint, ui) {
10558
10561
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
10559
- let data;
10562
+ let leafPaint;
10560
10563
  const {boxBounds: boxBounds} = ui.__layout;
10561
10564
  switch (paint.type) {
10562
10565
  case "image":
10563
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10566
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
10564
10567
  break;
10565
10568
 
10566
10569
  case "linear":
10567
- data = PaintGradient.linearGradient(paint, boxBounds);
10570
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
10568
10571
  break;
10569
10572
 
10570
10573
  case "radial":
10571
- data = PaintGradient.radialGradient(paint, boxBounds);
10574
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
10572
10575
  break;
10573
10576
 
10574
10577
  case "angular":
10575
- data = PaintGradient.conicGradient(paint, boxBounds);
10578
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
10576
10579
  break;
10577
10580
 
10578
10581
  case "solid":
10579
10582
  const {type: type, color: color, opacity: opacity} = paint;
10580
- data = {
10583
+ leafPaint = {
10581
10584
  type: type,
10582
10585
  style: ColorConvert.string(color, opacity)
10583
10586
  };
10584
10587
  break;
10585
10588
 
10586
10589
  default:
10587
- if (!isUndefined(paint.r)) data = {
10590
+ if (!isUndefined(paint.r)) leafPaint = {
10588
10591
  type: "solid",
10589
10592
  style: ColorConvert.string(paint)
10590
10593
  };
10591
10594
  }
10592
- if (data) {
10593
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
10595
+ if (leafPaint) {
10596
+ leafPaint.originPaint = paint;
10597
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
10594
10598
  if (paint.style) {
10595
10599
  if (paint.style.strokeWidth === 0) return undefined;
10596
- data.strokeStyle = paint.style;
10600
+ leafPaint.strokeStyle = paint.style;
10597
10601
  }
10598
- if (paint.editing) data.editing = paint.editing;
10599
- if (paint.blendMode) data.blendMode = paint.blendMode;
10600
10602
  }
10601
- return data;
10603
+ return leafPaint;
10602
10604
  }
10603
10605
  const PaintModule = {
10604
10606
  compute: compute,
@@ -10716,10 +10718,6 @@ var LeaferUI = function(exports) {
10716
10718
  const tempScaleData = {};
10717
10719
  const tempImage = {};
10718
10720
  function createData(leafPaint, image, paint, box) {
10719
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
10720
- if (changeful) leafPaint.changeful = changeful;
10721
- if (sync) leafPaint.sync = sync;
10722
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
10723
10721
  leafPaint.data = PaintImage.getPatternData(paint, box, image);
10724
10722
  }
10725
10723
  function getPatternData(paint, box, image) {
@@ -10930,14 +10928,14 @@ var LeaferUI = function(exports) {
10930
10928
  }
10931
10929
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10932
10930
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
10933
- const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
10931
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
10934
10932
  if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
10935
10933
  return false;
10936
10934
  } else {
10937
10935
  if (drawImage) {
10938
10936
  if (data.repeat) {
10939
10937
  drawImage = false;
10940
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10938
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10941
10939
  drawImage = Platform.image.isLarge(image, scaleX, scaleY);
10942
10940
  }
10943
10941
  }
@@ -10949,15 +10947,15 @@ var LeaferUI = function(exports) {
10949
10947
  PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
10950
10948
  return true;
10951
10949
  } else {
10952
- if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10950
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
10953
10951
  return false;
10954
10952
  }
10955
10953
  }
10956
10954
  }
10957
10955
  function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
10958
- const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10956
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
10959
10957
  let {width: width, height: height} = image, clipUI;
10960
- if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
10958
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
10961
10959
  canvas.save();
10962
10960
  clipUI && canvas.clipUI(ui);
10963
10961
  blendMode && (canvas.blendMode = blendMode);
@@ -10971,7 +10969,7 @@ var LeaferUI = function(exports) {
10971
10969
  }
10972
10970
  }
10973
10971
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
10974
- const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
10972
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
10975
10973
  if (canvas) {
10976
10974
  const {pixelRatio: pixelRatio} = canvas;
10977
10975
  scaleData.scaleX *= pixelRatio;