@leafer-ui/miniapp 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.
@@ -6835,7 +6835,7 @@ class LeafLevelList {
6835
6835
  }
6836
6836
  }
6837
6837
 
6838
- const version = "1.10.0";
6838
+ const version = "1.10.1";
6839
6839
 
6840
6840
  class LeaferCanvas extends LeaferCanvasBase {
6841
6841
  get allowBackgroundColor() {
@@ -8497,7 +8497,7 @@ let UI = UI_1 = class UI extends Leaf {
8497
8497
  drawer.roundRect(x, y, width, height, isNumber(cornerRadius) ? [ cornerRadius ] : cornerRadius);
8498
8498
  } else drawer.rect(x, y, width, height);
8499
8499
  }
8500
- drawImagePlaceholder(_image, canvas, renderOptions) {
8500
+ drawImagePlaceholder(_paint, canvas, renderOptions) {
8501
8501
  Paint.fill(this.__.placeholderColor, this, canvas, renderOptions);
8502
8502
  }
8503
8503
  animate(keyframe, _options, _type, _isTemp) {
@@ -11362,30 +11362,31 @@ function fill(fill, ui, canvas, renderOptions) {
11362
11362
  }
11363
11363
 
11364
11364
  function fills(fills, ui, canvas, renderOptions) {
11365
- let item;
11365
+ let item, originPaint, countImage;
11366
11366
  for (let i = 0, len = fills.length; i < len; i++) {
11367
- item = fills[i];
11367
+ item = fills[i], originPaint = item.originPaint;
11368
11368
  if (item.image) {
11369
+ countImage ? countImage++ : countImage = 1;
11369
11370
  if (PaintImage.checkImage(item, !ui.__.__font, ui, canvas, renderOptions)) continue;
11370
11371
  if (!item.style) {
11371
- if (!i && item.image.isPlacehold) ui.drawImagePlaceholder(item.image, canvas, renderOptions);
11372
+ if (countImage === 1 && item.image.isPlacehold) ui.drawImagePlaceholder(item, canvas, renderOptions);
11372
11373
  continue;
11373
11374
  }
11374
11375
  }
11375
11376
  canvas.fillStyle = item.style;
11376
- if (item.transform || item.scaleFixed) {
11377
+ if (item.transform || originPaint.scaleFixed) {
11377
11378
  canvas.save();
11378
11379
  if (item.transform) canvas.transform(item.transform);
11379
- if (item.scaleFixed) {
11380
+ if (originPaint.scaleFixed) {
11380
11381
  const {scaleX: scaleX, scaleY: scaleY} = ui.getRenderScaleData(true);
11381
- if (item.scaleFixed === true || item.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
11382
+ if (originPaint.scaleFixed === true || originPaint.scaleFixed === "zoom-in" && scaleX > 1 && scaleY > 1) canvas.scale(1 / scaleX, 1 / scaleY);
11382
11383
  }
11383
- if (item.blendMode) canvas.blendMode = item.blendMode;
11384
+ if (originPaint.blendMode) canvas.blendMode = originPaint.blendMode;
11384
11385
  fillPathOrText(ui, canvas, renderOptions);
11385
11386
  canvas.restore();
11386
11387
  } else {
11387
- if (item.blendMode) {
11388
- canvas.saveBlendMode(item.blendMode);
11388
+ if (originPaint.blendMode) {
11389
+ canvas.saveBlendMode(originPaint.blendMode);
11389
11390
  fillPathOrText(ui, canvas, renderOptions);
11390
11391
  canvas.restoreBlendMode();
11391
11392
  } else fillPathOrText(ui, canvas, renderOptions);
@@ -11538,8 +11539,8 @@ function drawStrokesStyle(strokes, strokeWidthScale, isText, ui, canvas, renderO
11538
11539
  const {strokeStyle: strokeStyle} = item;
11539
11540
  strokeStyle ? canvas.setStroke(item.style, data.__getRealStrokeWidth(strokeStyle) * strokeWidthScale, data, strokeStyle) : canvas.setStroke(item.style, data.__strokeWidth * strokeWidthScale, data);
11540
11541
  } else canvas.strokeStyle = item.style;
11541
- if (item.blendMode) {
11542
- canvas.saveBlendMode(item.blendMode);
11542
+ if (item.originPaint.blendMode) {
11543
+ canvas.saveBlendMode(item.originPaint.blendMode);
11543
11544
  isText ? Paint.drawTextStroke(ui, canvas, renderOptions) : canvas.stroke();
11544
11545
  canvas.restoreBlendMode();
11545
11546
  } else {
@@ -11636,62 +11637,63 @@ function compute(attrName, ui) {
11636
11637
  if (leafPaints.some(item => item.image)) isAlphaPixel = true;
11637
11638
  isTransparent = true;
11638
11639
  }
11639
- }
11640
- if (attrName === "fill") {
11641
- stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
11642
- stintSet(data, "__isTransparentFill", isTransparent);
11640
+ if (attrName === "fill") {
11641
+ stintSet(data, "__isAlphaPixelFill", isAlphaPixel);
11642
+ stintSet(data, "__isTransparentFill", isTransparent);
11643
+ } else {
11644
+ stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
11645
+ stintSet(data, "__isTransparentStroke", isTransparent);
11646
+ stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
11647
+ }
11643
11648
  } else {
11644
- stintSet(data, "__isAlphaPixelStroke", isAlphaPixel);
11645
- stintSet(data, "__isTransparentStroke", isTransparent);
11646
- stintSet(data, "__hasMultiStrokeStyle", maxChildStrokeWidth);
11649
+ data.__removePaint(attrName, false);
11647
11650
  }
11648
11651
  }
11649
11652
 
11650
11653
  function getLeafPaint(attrName, paint, ui) {
11651
11654
  if (!isObject(paint) || paint.visible === false || paint.opacity === 0) return undefined;
11652
- let data;
11655
+ let leafPaint;
11653
11656
  const {boxBounds: boxBounds} = ui.__layout;
11654
11657
  switch (paint.type) {
11655
11658
  case "image":
11656
- data = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11659
+ leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11657
11660
  break;
11658
11661
 
11659
11662
  case "linear":
11660
- data = PaintGradient.linearGradient(paint, boxBounds);
11663
+ leafPaint = PaintGradient.linearGradient(paint, boxBounds);
11661
11664
  break;
11662
11665
 
11663
11666
  case "radial":
11664
- data = PaintGradient.radialGradient(paint, boxBounds);
11667
+ leafPaint = PaintGradient.radialGradient(paint, boxBounds);
11665
11668
  break;
11666
11669
 
11667
11670
  case "angular":
11668
- data = PaintGradient.conicGradient(paint, boxBounds);
11671
+ leafPaint = PaintGradient.conicGradient(paint, boxBounds);
11669
11672
  break;
11670
11673
 
11671
11674
  case "solid":
11672
11675
  const {type: type, color: color, opacity: opacity} = paint;
11673
- data = {
11676
+ leafPaint = {
11674
11677
  type: type,
11675
11678
  style: ColorConvert.string(color, opacity)
11676
11679
  };
11677
11680
  break;
11678
11681
 
11679
11682
  default:
11680
- if (!isUndefined(paint.r)) data = {
11683
+ if (!isUndefined(paint.r)) leafPaint = {
11681
11684
  type: "solid",
11682
11685
  style: ColorConvert.string(paint)
11683
11686
  };
11684
11687
  }
11685
- if (data) {
11686
- if (isString(data.style) && hasTransparent$1(data.style)) data.isTransparent = true;
11688
+ if (leafPaint) {
11689
+ leafPaint.originPaint = paint;
11690
+ if (isString(leafPaint.style) && hasTransparent$1(leafPaint.style)) leafPaint.isTransparent = true;
11687
11691
  if (paint.style) {
11688
11692
  if (paint.style.strokeWidth === 0) return undefined;
11689
- data.strokeStyle = paint.style;
11693
+ leafPaint.strokeStyle = paint.style;
11690
11694
  }
11691
- if (paint.editing) data.editing = paint.editing;
11692
- if (paint.blendMode) data.blendMode = paint.blendMode;
11693
11695
  }
11694
- return data;
11696
+ return leafPaint;
11695
11697
  }
11696
11698
 
11697
11699
  const PaintModule = {
@@ -11824,10 +11826,6 @@ const tempScaleData = {};
11824
11826
  const tempImage = {};
11825
11827
 
11826
11828
  function createData(leafPaint, image, paint, box) {
11827
- const {changeful: changeful, sync: sync, scaleFixed: scaleFixed} = paint;
11828
- if (changeful) leafPaint.changeful = changeful;
11829
- if (sync) leafPaint.sync = sync;
11830
- if (scaleFixed) leafPaint.scaleFixed = scaleFixed;
11831
11829
  leafPaint.data = PaintImage.getPatternData(paint, box, image);
11832
11830
  }
11833
11831
 
@@ -12054,14 +12052,14 @@ function getPatternFixScale(paint, imageScaleX, imageScaleY) {
12054
12052
 
12055
12053
  function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12056
12054
  const {scaleX: scaleX, scaleY: scaleY} = PaintImage.getImageRenderScaleData(paint, ui, canvas, renderOptions);
12057
- const {image: image, data: data} = paint, {exporting: exporting} = renderOptions;
12055
+ const {image: image, data: data, originPaint: originPaint} = paint, {exporting: exporting} = renderOptions;
12058
12056
  if (!data || paint.patternId === scaleX + "-" + scaleY && !exporting) {
12059
12057
  return false;
12060
12058
  } else {
12061
12059
  if (drawImage) {
12062
12060
  if (data.repeat) {
12063
12061
  drawImage = false;
12064
- } else if (!(paint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12062
+ } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12065
12063
  drawImage = Platform.image.isLarge(image, scaleX, scaleY);
12066
12064
  }
12067
12065
  }
@@ -12073,16 +12071,16 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12073
12071
  PaintImage.drawImage(paint, scaleX, scaleY, ui, canvas, renderOptions);
12074
12072
  return true;
12075
12073
  } else {
12076
- if (!paint.style || paint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
12074
+ if (!paint.style || originPaint.sync || exporting) PaintImage.createPattern(paint, ui, canvas, renderOptions); else PaintImage.createPatternTask(paint, ui, canvas, renderOptions);
12077
12075
  return false;
12078
12076
  }
12079
12077
  }
12080
12078
  }
12081
12079
 
12082
12080
  function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions) {
12083
- const {data: data, image: image, blendMode: blendMode} = paint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
12081
+ const {data: data, image: image} = paint, {blendMode: blendMode} = paint.originPaint, {opacity: opacity, transform: transform} = data, view = image.getFull(data.filters), u = ui.__;
12084
12082
  let {width: width, height: height} = image, clipUI;
12085
- if (transform && !transform.onlyScale || (clipUI = u.path || u.cornerRadius) || opacity || blendMode) {
12083
+ if ((clipUI = transform && !transform.onlyScale || u.path || u.cornerRadius) || opacity || blendMode) {
12086
12084
  canvas.save();
12087
12085
  clipUI && canvas.clipUI(ui);
12088
12086
  blendMode && (canvas.blendMode = blendMode);
@@ -12097,7 +12095,7 @@ function drawImage(paint, _imageScaleX, _imageScaleY, ui, canvas, _renderOptions
12097
12095
  }
12098
12096
 
12099
12097
  function getImageRenderScaleData(paint, ui, canvas, _renderOptions) {
12100
- const scaleData = ui.getRenderScaleData(true, paint.scaleFixed), {data: data} = paint;
12098
+ const scaleData = ui.getRenderScaleData(true, paint.originPaint.scaleFixed), {data: data} = paint;
12101
12099
  if (canvas) {
12102
12100
  const {pixelRatio: pixelRatio} = canvas;
12103
12101
  scaleData.scaleX *= pixelRatio;