@leafer-ui/worker 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.
package/dist/worker.cjs CHANGED
@@ -347,7 +347,7 @@ class Layouter {
347
347
  }
348
348
  partLayout() {
349
349
  var _a;
350
- if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
350
+ if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
351
351
  return;
352
352
  const t = core.Run.start('PartLayout');
353
353
  const { target, __updatedList: updateList } = this;
@@ -812,9 +812,10 @@ class Selector {
812
812
  this.finder = core.Creator.finder && core.Creator.finder();
813
813
  }
814
814
  getByPoint(hitPoint, hitRadius, options) {
815
- if (core.Platform.backgrounder && this.target)
816
- this.target.updateLayout();
817
- return this.picker.getByPoint(hitPoint, hitRadius, options);
815
+ const { target, picker } = this;
816
+ if (core.Platform.backgrounder)
817
+ target && target.updateLayout();
818
+ return picker.getByPoint(hitPoint, hitRadius, options);
818
819
  }
819
820
  getBy(condition, branch, one, options) {
820
821
  return this.finder ? this.finder.getBy(condition, branch, one, options) : core.Plugin.need('find');
@@ -1193,7 +1194,7 @@ function getPatternData(paint, box, image) {
1193
1194
  box = tempBox.set(box).shrink(paint.padding);
1194
1195
  if (paint.mode === 'strench')
1195
1196
  paint.mode = 'stretch';
1196
- const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
1197
+ const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
1197
1198
  const sameBox = box.width === width && box.height === height;
1198
1199
  const data = { mode };
1199
1200
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1256,6 +1257,8 @@ function getPatternData(paint, box, image) {
1256
1257
  data.height = height;
1257
1258
  if (opacity)
1258
1259
  data.opacity = opacity;
1260
+ if (filters)
1261
+ data.filters = filters;
1259
1262
  if (repeat)
1260
1263
  data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
1261
1264
  return data;
@@ -1358,7 +1361,7 @@ function createPattern(ui, paint, pixelRatio) {
1358
1361
  scaleX = abs$1(scaleX);
1359
1362
  scaleY = abs$1(scaleY);
1360
1363
  const { image, data } = paint;
1361
- let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
1364
+ let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1362
1365
  if (sx) {
1363
1366
  imageMatrix = get$1();
1364
1367
  copy$1(imageMatrix, transform);
@@ -1401,7 +1404,7 @@ function createPattern(ui, paint, pixelRatio) {
1401
1404
  }
1402
1405
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1403
1406
  }
1404
- const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
1407
+ const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, data.opacity, data.filters);
1405
1408
  const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
1406
1409
  paint.style = pattern;
1407
1410
  paint.patternId = id;
@@ -1477,7 +1480,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1477
1480
  canvas.opacity *= data.opacity;
1478
1481
  if (data.transform)
1479
1482
  canvas.transform(data.transform);
1480
- canvas.drawImage(paint.image.view, 0, 0, data.width, data.height);
1483
+ canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
1481
1484
  canvas.restore();
1482
1485
  return true;
1483
1486
  }
@@ -1487,7 +1490,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1487
1490
  }
1488
1491
  else {
1489
1492
  if (!paint.patternTask) {
1490
- paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
1493
+ paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1491
1494
  paint.patternTask = null;
1492
1495
  if (canvas.bounds.hit(ui.__nowWorld))
1493
1496
  createPattern(ui, paint, pixelRatio);
@@ -2077,11 +2080,11 @@ const TextMode = 2;
2077
2080
  function layoutChar(drawData, style, width, _height) {
2078
2081
  const { rows } = drawData;
2079
2082
  const { textAlign, paraIndent, letterSpacing } = style;
2080
- let charX, addWordWidth, indentWidth, mode, wordChar;
2083
+ let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
2081
2084
  rows.forEach(row => {
2082
2085
  if (row.words) {
2083
- indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
2084
- addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
2086
+ indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
2087
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
2085
2088
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
2086
2089
  if (row.isOverflow && !letterSpacing)
2087
2090
  row.textMode = true;
@@ -2093,7 +2096,7 @@ function layoutChar(drawData, style, width, _height) {
2093
2096
  row.x += indentWidth;
2094
2097
  charX = row.x;
2095
2098
  row.data = [];
2096
- row.words.forEach(word => {
2099
+ row.words.forEach((word, index) => {
2097
2100
  if (mode === WordMode) {
2098
2101
  wordChar = { char: '', x: charX };
2099
2102
  charX = toWordChar(word.data, charX, wordChar);
@@ -2103,7 +2106,7 @@ function layoutChar(drawData, style, width, _height) {
2103
2106
  else {
2104
2107
  charX = toChar(word.data, charX, row.data, row.isOverflow);
2105
2108
  }
2106
- if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
2109
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
2107
2110
  charX += addWordWidth;
2108
2111
  row.width += addWordWidth;
2109
2112
  }
@@ -2382,3 +2385,4 @@ Object.keys(core$1).forEach(function (k) {
2382
2385
  get: function () { return core$1[k]; }
2383
2386
  });
2384
2387
  });
2388
+ //# sourceMappingURL=worker.cjs.map