@leafer-ui/node 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/node.esm.js CHANGED
@@ -1,10 +1,10 @@
1
- import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey, FileHelper, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, Bounds, LeafBoundsHelper, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, Plugin, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4 } from '@leafer/core';
1
+ import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, 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 { writeFileSync } from 'fs';
5
- import { InteractionBase, HitCanvasManager } from '@leafer-ui/core';
5
+ import { HitCanvasManager, InteractionBase } from '@leafer-ui/core';
6
6
  export * from '@leafer-ui/core';
7
- import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, Bounds as Bounds$1, TwoPointBoundsHelper, FileHelper as FileHelper$1, TaskProcessor, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin as Plugin$1, UI } from '@leafer-ui/draw';
7
+ import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, TwoPointBoundsHelper, Bounds as Bounds$1, FileHelper as FileHelper$1, TaskProcessor, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin as Plugin$1, UI } from '@leafer-ui/draw';
8
8
 
9
9
  /******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -85,8 +85,8 @@ function useCanvas(canvasType, power) {
85
85
  Platform.origin = {
86
86
  createCanvas: (width, height, format) => new Canvas(width, height, format),
87
87
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
88
- canvasToBolb: (canvas, type, quality) => __awaiter(this, undefined, undefined, function* () { return canvas.toBuffer(mineType(type), quality); }),
89
- canvasSaveAs: (canvas, filename, quality) => __awaiter(this, undefined, undefined, function* () { return writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
88
+ canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function* () { return canvas.toBuffer(mineType(type), quality); }),
89
+ canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function* () { return writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
90
90
  download(_url, _filename) { return undefined; },
91
91
  loadImage(src) { return loadImage(Platform.image.getRealURL(src)); }
92
92
  };
@@ -361,7 +361,7 @@ class Layouter {
361
361
  }
362
362
  partLayout() {
363
363
  var _a;
364
- if (!((_a = this.__updatedList) === null || _a === undefined ? undefined : _a.length))
364
+ if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
365
365
  return;
366
366
  const t = Run.start('PartLayout');
367
367
  const { target, __updatedList: updateList } = this;
@@ -826,9 +826,10 @@ class Selector {
826
826
  this.finder = Creator.finder && Creator.finder();
827
827
  }
828
828
  getByPoint(hitPoint, hitRadius, options) {
829
- if (Platform.backgrounder && this.target)
830
- this.target.updateLayout();
831
- return this.picker.getByPoint(hitPoint, hitRadius, options);
829
+ const { target, picker } = this;
830
+ if (Platform.backgrounder)
831
+ target && target.updateLayout();
832
+ return picker.getByPoint(hitPoint, hitRadius, options);
832
833
  }
833
834
  getBy(condition, branch, one, options) {
834
835
  return this.finder ? this.finder.getBy(condition, branch, one, options) : Plugin.need('find');
@@ -1207,7 +1208,7 @@ function getPatternData(paint, box, image) {
1207
1208
  box = tempBox.set(box).shrink(paint.padding);
1208
1209
  if (paint.mode === 'strench')
1209
1210
  paint.mode = 'stretch';
1210
- const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
1211
+ const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
1211
1212
  const sameBox = box.width === width && box.height === height;
1212
1213
  const data = { mode };
1213
1214
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
@@ -1270,6 +1271,8 @@ function getPatternData(paint, box, image) {
1270
1271
  data.height = height;
1271
1272
  if (opacity)
1272
1273
  data.opacity = opacity;
1274
+ if (filters)
1275
+ data.filters = filters;
1273
1276
  if (repeat)
1274
1277
  data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
1275
1278
  return data;
@@ -1372,7 +1375,7 @@ function createPattern(ui, paint, pixelRatio) {
1372
1375
  scaleX = abs$1(scaleX);
1373
1376
  scaleY = abs$1(scaleY);
1374
1377
  const { image, data } = paint;
1375
- let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
1378
+ let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
1376
1379
  if (sx) {
1377
1380
  imageMatrix = get$1();
1378
1381
  copy$1(imageMatrix, transform);
@@ -1415,7 +1418,7 @@ function createPattern(ui, paint, pixelRatio) {
1415
1418
  }
1416
1419
  scale(imageMatrix, 1 / scaleX, 1 / scaleY);
1417
1420
  }
1418
- const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
1421
+ const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, data.opacity, data.filters);
1419
1422
  const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
1420
1423
  paint.style = pattern;
1421
1424
  paint.patternId = id;
@@ -1459,7 +1462,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1459
1462
  canvas.opacity *= data.opacity;
1460
1463
  if (data.transform)
1461
1464
  canvas.transform(data.transform);
1462
- canvas.drawImage(paint.image.view, 0, 0, data.width, data.height);
1465
+ canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
1463
1466
  canvas.restore();
1464
1467
  return true;
1465
1468
  }
@@ -1469,7 +1472,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
1469
1472
  }
1470
1473
  else {
1471
1474
  if (!paint.patternTask) {
1472
- paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, undefined, undefined, function* () {
1475
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
1473
1476
  paint.patternTask = null;
1474
1477
  if (canvas.bounds.hit(ui.__nowWorld))
1475
1478
  createPattern(ui, paint, pixelRatio);
@@ -2059,11 +2062,11 @@ const TextMode = 2;
2059
2062
  function layoutChar(drawData, style, width, _height) {
2060
2063
  const { rows } = drawData;
2061
2064
  const { textAlign, paraIndent, letterSpacing } = style;
2062
- let charX, addWordWidth, indentWidth, mode, wordChar;
2065
+ let charX, addWordWidth, indentWidth, mode, wordChar, wordsLength;
2063
2066
  rows.forEach(row => {
2064
2067
  if (row.words) {
2065
- indentWidth = paraIndent && row.paraStart ? paraIndent : 0;
2066
- addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && row.words.length > 1) ? (width - row.width - indentWidth) / (row.words.length - 1) : 0;
2068
+ indentWidth = paraIndent && row.paraStart ? paraIndent : 0, wordsLength = row.words.length;
2069
+ addWordWidth = (width && (textAlign === 'justify' || textAlign === 'both') && wordsLength > 1) ? (width - row.width - indentWidth) / (wordsLength - 1) : 0;
2067
2070
  mode = (letterSpacing || row.isOverflow) ? CharMode : (addWordWidth > 0.01 ? WordMode : TextMode);
2068
2071
  if (row.isOverflow && !letterSpacing)
2069
2072
  row.textMode = true;
@@ -2075,7 +2078,7 @@ function layoutChar(drawData, style, width, _height) {
2075
2078
  row.x += indentWidth;
2076
2079
  charX = row.x;
2077
2080
  row.data = [];
2078
- row.words.forEach(word => {
2081
+ row.words.forEach((word, index) => {
2079
2082
  if (mode === WordMode) {
2080
2083
  wordChar = { char: '', x: charX };
2081
2084
  charX = toWordChar(word.data, charX, wordChar);
@@ -2085,7 +2088,7 @@ function layoutChar(drawData, style, width, _height) {
2085
2088
  else {
2086
2089
  charX = toChar(word.data, charX, row.data, row.isOverflow);
2087
2090
  }
2088
- if (addWordWidth && (!row.paraEnd || textAlign === 'both')) {
2091
+ if (addWordWidth && (!row.paraEnd || textAlign === 'both') && (index !== wordsLength - 1)) {
2089
2092
  charX += addWordWidth;
2090
2093
  row.width += addWordWidth;
2091
2094
  }
@@ -2377,7 +2380,7 @@ const ExportModule = {
2377
2380
  const { leafer } = leaf;
2378
2381
  if (leafer) {
2379
2382
  checkLazy(leaf);
2380
- leafer.waitViewCompleted(() => __awaiter(this, undefined, undefined, function* () {
2383
+ leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
2381
2384
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
2382
2385
  const { worldTransform, isLeafer, isFrame } = leaf;
2383
2386
  const { slice, trim, padding, onCanvas } = options;
@@ -2479,7 +2482,7 @@ function addTask(task) {
2479
2482
  if (!tasker)
2480
2483
  tasker = new TaskProcessor();
2481
2484
  return new Promise((resolve) => {
2482
- tasker.add(() => __awaiter(this, undefined, undefined, function* () { return yield task(resolve); }), { parallel: false });
2485
+ tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
2483
2486
  });
2484
2487
  }
2485
2488
  function checkLazy(leaf) {
@@ -2537,3 +2540,4 @@ Object.assign(Creator, {
2537
2540
  });
2538
2541
 
2539
2542
  export { Layouter, LeaferCanvas, Picker, Renderer, Selector, Watcher, useCanvas };
2543
+ //# sourceMappingURL=node.esm.js.map