@leafer-ui/miniapp 1.3.3 → 1.4.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.
@@ -1,4 +1,4 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, Creator, LeaferImage, defineKey, FileHelper, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Plugin, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4 } from '@leafer/core';
1
+ import { LeaferCanvasBase, Platform, canvasPatch, DataHelper, canvasSizeAttrs, ResizeEvent, FileHelper, Creator, LeaferImage, defineKey, LeafList, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, BoundsHelper, Plugin, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4 } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
  export { LeaferImage } from '@leafer/core';
4
4
  import { InteractionHelper, InteractionBase, HitCanvasManager } from '@leafer-ui/core';
@@ -487,7 +487,7 @@ class Layouter {
487
487
  }
488
488
  partLayout() {
489
489
  var _a;
490
- if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
490
+ if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
491
491
  return;
492
492
  const t = Run.start('PartLayout');
493
493
  const { target, __updatedList: updateList } = this;
@@ -952,9 +952,10 @@ class Selector {
952
952
  this.finder = Creator.finder && Creator.finder();
953
953
  }
954
954
  getByPoint(hitPoint, hitRadius, options) {
955
- if (Platform.backgrounder && this.target)
956
- this.target.updateLayout();
957
- return this.picker.getByPoint(hitPoint, hitRadius, options);
955
+ const { target, picker } = this;
956
+ if (Platform.backgrounder)
957
+ target && target.updateLayout();
958
+ return picker.getByPoint(hitPoint, hitRadius, options);
958
959
  }
959
960
  getBy(condition, branch, one, options) {
960
961
  return this.finder ? this.finder.getBy(condition, branch, one, options) : Plugin.need('find');
@@ -1438,7 +1439,7 @@ function getPatternData(paint, box, image) {
1438
1439
  box = tempBox.set(box).shrink(paint.padding);
1439
1440
  if (paint.mode === 'strench')
1440
1441
  paint.mode = 'stretch';
1441
- const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
1442
+ const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
1442
1443
  const sameBox = box.width === width && box.height === height;
1443
1444
  const data = { mode };
1444
1445
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1501,6 +1502,8 @@ function getPatternData(paint, box, image) {
1501
1502
  data.height = height;
1502
1503
  if (opacity)
1503
1504
  data.opacity = opacity;
1505
+ if (filters)
1506
+ data.filters = filters;
1504
1507
  if (repeat)
1505
1508
  data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
1506
1509
  return data;
@@ -1603,7 +1606,7 @@ function createPattern(ui, paint, pixelRatio) {
1603
1606
  scaleX = abs$1(scaleX);
1604
1607
  scaleY = abs$1(scaleY);
1605
1608
  const { image, data } = paint;
1606
- let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
1609
+ let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1607
1610
  if (sx) {
1608
1611
  imageMatrix = get$1();
1609
1612
  copy$1(imageMatrix, transform);
@@ -1646,7 +1649,7 @@ function createPattern(ui, paint, pixelRatio) {
1646
1649
  }
1647
1650
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1648
1651
  }
1649
- const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
1652
+ const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, data.opacity, data.filters);
1650
1653
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
1651
1654
  paint.style = pattern;
1652
1655
  paint.patternId = id;
@@ -1722,7 +1725,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1722
1725
  canvas.opacity *= data.opacity;
1723
1726
  if (data.transform)
1724
1727
  canvas.transform(data.transform);
1725
- canvas.drawImage(paint.image.view, 0, 0, data.width, data.height);
1728
+ canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
1726
1729
  canvas.restore();
1727
1730
  return true;
1728
1731
  }
@@ -1732,7 +1735,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1732
1735
  }
1733
1736
  else {
1734
1737
  if (!paint.patternTask) {
1735
- paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
1738
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1736
1739
  paint.patternTask = null;
1737
1740
  if (canvas.bounds.hit(ui.__nowWorld))
1738
1741
  createPattern(ui, paint, pixelRatio);
@@ -2322,11 +2325,11 @@ const TextMode = 2;
2322
2325
  function layoutChar(drawData, style, width, _height) {
2323
2326
  const { rows } = drawData;
2324
2327
  const { textAlign, paraIndent, letterSpacing } = style;
2325
- let charX, addWordWidth, indentWidth, mode, wordChar;
2328
+ let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
2326
2329
  rows.forEach(row => {
2327
2330
  if (row.words) {
2328
- indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
2329
- addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
2331
+ indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
2332
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
2330
2333
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
2331
2334
  if (row.isOverflow && !letterSpacing)
2332
2335
  row.textMode = true;
@@ -2338,7 +2341,7 @@ function layoutChar(drawData, style, width, _height) {
2338
2341
  row.x += indentWidth;
2339
2342
  charX = row.x;
2340
2343
  row.data = [];
2341
- row.words.forEach(word => {
2344
+ row.words.forEach((word, index) => {
2342
2345
  if (mode === WordMode) {
2343
2346
  wordChar = { char: '', x: charX };
2344
2347
  charX = toWordChar(word.data, charX, wordChar);
@@ -2348,7 +2351,7 @@ function layoutChar(drawData, style, width, _height) {
2348
2351
  else {
2349
2352
  charX = toChar(word.data, charX, row.data, row.isOverflow);
2350
2353
  }
2351
- if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
2354
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
2352
2355
  charX += addWordWidth;
2353
2356
  row.width += addWordWidth;
2354
2357
  }
@@ -2636,3 +2639,4 @@ if (platform === 'ios') {
2636
2639
  }
2637
2640
 
2638
2641
  export { Interaction, Layouter, LeaferCanvas, Picker, Renderer, Selector, Watcher, useCanvas };
2642
+ //# sourceMappingURL=miniapp.esm.js.map