leafer-ui 1.5.3 → 1.6.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/README.md CHANGED
@@ -296,7 +296,7 @@ LeaferJS 致力于实现一套简洁、开放、现代化的 UI 绘图语言标
296
296
  </p>
297
297
  <p><h3 align="center">铜牌赞助</h3></p>
298
298
  <p style="display: flex;flex-wrap: wrap;justify-content: center;gap: 15px;">
299
- 在路上 &nbsp;&nbsp;张余🌈 &nbsp;&nbsp;Jerry &nbsp;&nbsp;李狗嗨。💢 &nbsp;&nbsp;李维亮 &nbsp;&nbsp;朝夕 &nbsp;&nbsp;SaltedFish &nbsp;&nbsp;zhk &nbsp;&nbsp;格子 &nbsp;&nbsp;等等 &nbsp;&nbsp;goosen &nbsp;&nbsp;建伟F4nniu &nbsp;&nbsp;梁福斌 &nbsp;&nbsp;江万江 &nbsp;&nbsp;杨超 &nbsp;&nbsp;ToB Dev &nbsp;&nbsp;前端之虎陈随易 &nbsp;&nbsp;A☀️云☀️A &nbsp;&nbsp;ʚ LMT ɞ &nbsp;&nbsp;爱发电用户_c9c82 &nbsp;&nbsp;轻简历 &nbsp;&nbsp;爱发电用户_0fac0 &nbsp;&nbsp;wangyesheji.cn &nbsp;&nbsp;风间 &nbsp;&nbsp;爱发电用户_Tqsm &nbsp;&nbsp;爱发电用户_6KpE &nbsp;&nbsp;dongdong &nbsp;&nbsp;zwm &nbsp;&nbsp;爱发电用户_3725c &nbsp;&nbsp;Noth1ng &nbsp;&nbsp;纳西妲の√ &nbsp;&nbsp;爱发电用户_Ahb9 &nbsp;&nbsp;爱发电用户_7617d &nbsp;&nbsp;冷漠 &nbsp;&nbsp;爱发电用户_9RXB &nbsp;&nbsp;今日值得读 &nbsp;&nbsp;爱发电用户_49sT &nbsp;&nbsp;爱发电用户_NFCS &nbsp;&nbsp;爱发电用户_43ad8 &nbsp;&nbsp;爱发电用户_30455 &nbsp;&nbsp;xiaozhang &nbsp;&nbsp;砖吐筷筷 &nbsp;&nbsp;爱发电用户_b47b3 &nbsp;&nbsp;longbow1998 &nbsp;&nbsp;爱发电用户_5d755 &nbsp;&nbsp;爱发电用户_b76b8 &nbsp;&nbsp;爱发电用户_e70c2 &nbsp;&nbsp;爱发电用户_039dc &nbsp;&nbsp;花祁 &nbsp;&nbsp;爱发电用户_99f39 &nbsp;&nbsp;坤坤 &nbsp;&nbsp;爱发电用户_X6hp &nbsp;&nbsp;爱发电用户_s5u9 &nbsp;&nbsp;曹吉美爸爸 &nbsp;&nbsp;啸沧海 &nbsp;&nbsp;Ronny &nbsp;&nbsp;Biu &nbsp;&nbsp;王志强 &nbsp;&nbsp;PD.新城คิดถึง &nbsp;&nbsp;糖颂缘冥倾 &nbsp;&nbsp;ALBERT. &nbsp;&nbsp;爱发电用户_UXEV &nbsp;&nbsp;SaltedFish &nbsp;&nbsp;爱发电用户_76f9d &nbsp;&nbsp;Leafer &nbsp;&nbsp;爱发电用户_Pbm7 &nbsp;&nbsp;</p>
299
+ Lauginwing &nbsp;&nbsp;江万江 &nbsp;&nbsp;在路上 &nbsp;&nbsp;张余🌈 &nbsp;&nbsp;Jerry &nbsp;&nbsp;李狗嗨。💢 &nbsp;&nbsp;李维亮 &nbsp;&nbsp;朝夕 &nbsp;&nbsp;SaltedFish &nbsp;&nbsp;zhk &nbsp;&nbsp;格子 &nbsp;&nbsp;等等 &nbsp;&nbsp;goosen &nbsp;&nbsp;建伟F4nniu &nbsp;&nbsp;梁福斌 &nbsp;&nbsp;江万江 &nbsp;&nbsp;杨超 &nbsp;&nbsp;ToB Dev &nbsp;&nbsp;前端之虎陈随易 &nbsp;&nbsp;A☀️云☀️A &nbsp;&nbsp;ʚ LMT ɞ &nbsp;&nbsp;爱发电用户_c9c82 &nbsp;&nbsp;轻简历 &nbsp;&nbsp;爱发电用户_0fac0 &nbsp;&nbsp;wangyesheji.cn &nbsp;&nbsp;风间 &nbsp;&nbsp;爱发电用户_Tqsm &nbsp;&nbsp;爱发电用户_6KpE &nbsp;&nbsp;dongdong &nbsp;&nbsp;zwm &nbsp;&nbsp;爱发电用户_3725c &nbsp;&nbsp;Noth1ng &nbsp;&nbsp;纳西妲の√ &nbsp;&nbsp;爱发电用户_Ahb9 &nbsp;&nbsp;爱发电用户_7617d &nbsp;&nbsp;冷漠 &nbsp;&nbsp;爱发电用户_9RXB &nbsp;&nbsp;今日值得读 &nbsp;&nbsp;爱发电用户_49sT &nbsp;&nbsp;爱发电用户_NFCS &nbsp;&nbsp;爱发电用户_43ad8 &nbsp;&nbsp;爱发电用户_30455 &nbsp;&nbsp;xiaozhang &nbsp;&nbsp;砖吐筷筷 &nbsp;&nbsp;爱发电用户_b47b3 &nbsp;&nbsp;longbow1998 &nbsp;&nbsp;爱发电用户_5d755 &nbsp;&nbsp;爱发电用户_b76b8 &nbsp;&nbsp;爱发电用户_e70c2 &nbsp;&nbsp;爱发电用户_039dc &nbsp;&nbsp;花祁 &nbsp;&nbsp;爱发电用户_99f39 &nbsp;&nbsp;坤坤 &nbsp;&nbsp;爱发电用户_X6hp &nbsp;&nbsp;爱发电用户_s5u9 &nbsp;&nbsp;曹吉美爸爸 &nbsp;&nbsp;啸沧海 &nbsp;&nbsp;Ronny &nbsp;&nbsp;Biu &nbsp;&nbsp;王志强 &nbsp;&nbsp;PD.新城คิดถึง &nbsp;&nbsp;糖颂缘冥倾 &nbsp;&nbsp;ALBERT. &nbsp;&nbsp;爱发电用户_UXEV &nbsp;&nbsp;SaltedFish &nbsp;&nbsp;爱发电用户_76f9d &nbsp;&nbsp;Leafer &nbsp;&nbsp;爱发电用户_Pbm7 &nbsp;&nbsp;</p>
300
300
 
301
301
  ## License
302
302
 
package/dist/web.cjs CHANGED
@@ -423,7 +423,6 @@ function updateChange(updateList) {
423
423
  }
424
424
 
425
425
  const { worldBounds } = core.LeafBoundsHelper;
426
- const bigBounds = { x: 0, y: 0, width: 100000, height: 100000 };
427
426
  class LayoutBlockData {
428
427
  constructor(list) {
429
428
  this.updatedBounds = new core.Bounds();
@@ -437,13 +436,7 @@ class LayoutBlockData {
437
436
  this.beforeBounds.setListWithFn(this.updatedList.list, worldBounds);
438
437
  }
439
438
  setAfter() {
440
- const { list } = this.updatedList;
441
- if (list.some(leaf => leaf.noBounds)) {
442
- this.afterBounds.set(bigBounds);
443
- }
444
- else {
445
- this.afterBounds.setListWithFn(list, worldBounds);
446
- }
439
+ this.afterBounds.setListWithFn(this.updatedList.list, worldBounds);
447
440
  this.updatedBounds.setList([this.beforeBounds, this.afterBounds]);
448
441
  }
449
442
  merge(data) {
@@ -645,6 +638,22 @@ class Renderer {
645
638
  requestLayout() {
646
639
  this.target.emit(core.LayoutEvent.REQUEST);
647
640
  }
641
+ checkRender() {
642
+ if (this.running) {
643
+ const { target } = this;
644
+ if (target.isApp) {
645
+ target.emit(core.RenderEvent.CHILD_START, target);
646
+ target.children.forEach(leafer => {
647
+ leafer.renderer.FPS = this.FPS;
648
+ leafer.renderer.checkRender();
649
+ });
650
+ target.emit(core.RenderEvent.CHILD_END, target);
651
+ }
652
+ if (this.changed && this.canvas.view)
653
+ this.render();
654
+ this.target.emit(core.RenderEvent.NEXT);
655
+ }
656
+ }
648
657
  render(callback) {
649
658
  if (!(this.running && this.canvas.view))
650
659
  return this.update();
@@ -653,8 +662,6 @@ class Renderer {
653
662
  this.totalBounds = new core.Bounds();
654
663
  debug.log(target.innerName, '--->');
655
664
  try {
656
- if (!target.isApp)
657
- target.app.emit(core.RenderEvent.CHILD_START, target);
658
665
  this.emitRender(core.RenderEvent.START);
659
666
  this.renderOnce(callback);
660
667
  this.emitRender(core.RenderEvent.END, this.totalBounds);
@@ -722,20 +729,12 @@ class Renderer {
722
729
  }
723
730
  clipRender(block) {
724
731
  const t = core.Run.start('PartRender');
725
- const { canvas } = this;
726
- const bounds = block.getIntersect(canvas.bounds);
727
- const includes = block.includes(this.target.__world);
728
- const realBounds = new core.Bounds(bounds);
732
+ const { canvas } = this, bounds = block.getIntersect(canvas.bounds), realBounds = new core.Bounds(bounds);
729
733
  canvas.save();
730
- if (includes && !core.Debug.showRepaint) {
731
- canvas.clear();
732
- }
733
- else {
734
- bounds.spread(10 + 1 / this.canvas.pixelRatio).ceil();
735
- canvas.clearWorld(bounds, true);
736
- canvas.clipWorld(bounds, true);
737
- }
738
- this.__render(bounds, includes, realBounds);
734
+ bounds.spread(Renderer.clipSpread).ceil();
735
+ canvas.clearWorld(bounds, true);
736
+ canvas.clipWorld(bounds, true);
737
+ this.__render(bounds, realBounds);
739
738
  canvas.restore();
740
739
  core.Run.end(t);
741
740
  }
@@ -744,28 +743,22 @@ class Renderer {
744
743
  const { canvas } = this;
745
744
  canvas.save();
746
745
  canvas.clear();
747
- this.__render(canvas.bounds, true);
746
+ this.__render(canvas.bounds);
748
747
  canvas.restore();
749
748
  core.Run.end(t);
750
749
  }
751
- __render(bounds, includes, realBounds) {
752
- const options = bounds.includes(this.target.__world) ? { includes } : { bounds, includes };
750
+ __render(bounds, realBounds) {
751
+ const { canvas } = this, includes = bounds.includes(this.target.__world), options = includes ? { includes } : { bounds, includes };
753
752
  if (this.needFill)
754
- this.canvas.fillWorld(bounds, this.config.fill);
753
+ canvas.fillWorld(bounds, this.config.fill);
755
754
  if (core.Debug.showRepaint)
756
- this.canvas.strokeWorld(bounds, 'red');
757
- this.target.__render(this.canvas, options);
755
+ core.Debug.drawRepaint(canvas, bounds);
756
+ this.target.__render(canvas, options);
758
757
  this.renderBounds = realBounds = realBounds || bounds;
759
758
  this.renderOptions = options;
760
759
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
761
- if (core.Debug.showHitView)
762
- this.renderHitView(options);
763
- if (core.Debug.showBoundsView)
764
- this.renderBoundsView(options);
765
- this.canvas.updateRender(realBounds);
766
- }
767
- renderHitView(_options) { }
768
- renderBoundsView(_options) { }
760
+ canvas.updateRender(realBounds);
761
+ }
769
762
  addBlock(block) {
770
763
  if (!this.updateBlocks)
771
764
  this.updateBlocks = [];
@@ -781,17 +774,16 @@ class Renderer {
781
774
  }
782
775
  }
783
776
  __requestRender() {
784
- if (this.requestTime)
777
+ const target = this.target;
778
+ if (this.requestTime || !target)
785
779
  return;
780
+ if (target.parentApp)
781
+ return target.parentApp.requestRender(false);
786
782
  const requestTime = this.requestTime = Date.now();
787
783
  core.Platform.requestRender(() => {
788
784
  this.FPS = Math.min(60, Math.ceil(1000 / (Date.now() - requestTime)));
789
785
  this.requestTime = 0;
790
- if (this.running) {
791
- if (this.changed && this.canvas.view)
792
- this.render();
793
- this.target.emit(core.RenderEvent.NEXT);
794
- }
786
+ this.checkRender();
795
787
  });
796
788
  }
797
789
  __onResize(e) {
@@ -849,6 +841,7 @@ class Renderer {
849
841
  }
850
842
  }
851
843
  }
844
+ Renderer.clipSpread = 10;
852
845
 
853
846
  const { hitRadiusPoint } = core.BoundsHelper;
854
847
  class Picker {
@@ -1677,9 +1670,11 @@ const tempBox = new core.Bounds();
1677
1670
  const tempPoint = {};
1678
1671
  const tempScaleData = {};
1679
1672
  function createData(leafPaint, image, paint, box) {
1680
- const { blendMode, sync } = paint;
1673
+ const { blendMode, changeful, sync } = paint;
1681
1674
  if (blendMode)
1682
1675
  leafPaint.blendMode = blendMode;
1676
+ if (changeful)
1677
+ leafPaint.changeful = changeful;
1683
1678
  if (sync)
1684
1679
  leafPaint.sync = sync;
1685
1680
  leafPaint.data = getPatternData(paint, box, image);
@@ -1944,40 +1939,32 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
1944
1939
  };
1945
1940
 
1946
1941
  const { abs } = Math;
1947
- function checkImage(ui, canvas, paint, allowPaint) {
1942
+ function checkImage(ui, canvas, paint, allowDraw) {
1948
1943
  const { scaleX, scaleY } = core.ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
1949
- const { pixelRatio } = canvas;
1950
- if (!paint.data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
1944
+ const { pixelRatio } = canvas, { data } = paint;
1945
+ if (!data || (paint.patternId === scaleX + '-' + scaleY + '-' + pixelRatio && !draw.Export.running)) {
1951
1946
  return false;
1952
1947
  }
1953
1948
  else {
1954
- const { data } = paint;
1955
- if (allowPaint) {
1956
- if (!data.repeat) {
1957
- let { width, height } = data;
1958
- width *= abs(scaleX) * pixelRatio;
1959
- height *= abs(scaleY) * pixelRatio;
1960
- if (data.scaleX) {
1961
- width *= data.scaleX;
1962
- height *= data.scaleY;
1963
- }
1964
- allowPaint = (width * height > core.Platform.image.maxCacheSize) || draw.Export.running;
1949
+ if (allowDraw) {
1950
+ if (data.repeat) {
1951
+ allowDraw = false;
1965
1952
  }
1966
1953
  else {
1967
- allowPaint = false;
1954
+ if (!(paint.changeful || core.ResizeEvent.isResizing(ui) || draw.Export.running)) {
1955
+ let { width, height } = data;
1956
+ width *= abs(scaleX) * pixelRatio;
1957
+ height *= abs(scaleY) * pixelRatio;
1958
+ if (data.scaleX) {
1959
+ width *= data.scaleX;
1960
+ height *= data.scaleY;
1961
+ }
1962
+ allowDraw = (width * height > core.Platform.image.maxCacheSize);
1963
+ }
1968
1964
  }
1969
1965
  }
1970
- if (allowPaint) {
1971
- canvas.save();
1972
- ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
1973
- if (paint.blendMode)
1974
- canvas.blendMode = paint.blendMode;
1975
- if (data.opacity)
1976
- canvas.opacity *= data.opacity;
1977
- if (data.transform)
1978
- canvas.transform(data.transform);
1979
- canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
1980
- canvas.restore();
1966
+ if (allowDraw) {
1967
+ drawImage(ui, canvas, paint, data);
1981
1968
  return true;
1982
1969
  }
1983
1970
  else {
@@ -1998,13 +1985,26 @@ function checkImage(ui, canvas, paint, allowPaint) {
1998
1985
  }
1999
1986
  }
2000
1987
  }
1988
+ function drawImage(ui, canvas, paint, data) {
1989
+ canvas.save();
1990
+ ui.windingRule ? canvas.clip(ui.windingRule) : canvas.clip();
1991
+ if (paint.blendMode)
1992
+ canvas.blendMode = paint.blendMode;
1993
+ if (data.opacity)
1994
+ canvas.opacity *= data.opacity;
1995
+ if (data.transform)
1996
+ canvas.transform(data.transform);
1997
+ canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
1998
+ canvas.restore();
1999
+ }
2001
2000
 
2002
2001
  function recycleImage(attrName, data) {
2003
2002
  const paints = data['_' + attrName];
2004
2003
  if (paints instanceof Array) {
2005
- let image, recycleMap, input, url;
2004
+ let paint, image, recycleMap, input, url;
2006
2005
  for (let i = 0, len = paints.length; i < len; i++) {
2007
- image = paints[i].image;
2006
+ paint = paints[i];
2007
+ image = paint.image;
2008
2008
  url = image && image.url;
2009
2009
  if (url) {
2010
2010
  if (!recycleMap)
@@ -2019,8 +2019,6 @@ function recycleImage(attrName, data) {
2019
2019
  }
2020
2020
  image.unload(paints[i].loadId, !input.some((item) => item.url === url));
2021
2021
  }
2022
- else
2023
- paints[i].style = null;
2024
2022
  }
2025
2023
  }
2026
2024
  return recycleMap;
@@ -2199,7 +2197,7 @@ const { toOffsetOutBounds } = core.BoundsHelper;
2199
2197
  const offsetOutBounds = {};
2200
2198
  function innerShadow(ui, current, shape) {
2201
2199
  let copyBounds, spreadScale;
2202
- const { __nowWorld: nowWorld, __layout: __layout } = ui;
2200
+ const { __nowWorld: nowWorld, __layout } = ui;
2203
2201
  const { innerShadow } = ui.__;
2204
2202
  const { worldCanvas, bounds, shapeBounds, scaleX, scaleY } = shape;
2205
2203
  const other = current.getSameCanvas();