@leafer-ui/worker 1.4.2 → 1.5.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.
@@ -2029,13 +2029,11 @@ class LeaferCanvasBase extends Canvas$1 {
2029
2029
  this.worldTransform = {};
2030
2030
  if (!config)
2031
2031
  config = minSize;
2032
- if (!config.pixelRatio)
2033
- config.pixelRatio = Platform.devicePixelRatio;
2034
2032
  this.manager = manager;
2035
2033
  this.innerId = IncrementId.create(IncrementId.CNAVAS);
2036
2034
  const { width, height, pixelRatio } = config;
2037
2035
  this.autoLayout = !width || !height;
2038
- this.size.pixelRatio = pixelRatio;
2036
+ this.size.pixelRatio = pixelRatio | Platform.devicePixelRatio;
2039
2037
  this.config = config;
2040
2038
  this.init();
2041
2039
  }
@@ -2232,7 +2230,7 @@ class LeaferCanvasBase extends Canvas$1 {
2232
2230
  tempBounds$1.ceil();
2233
2231
  }
2234
2232
  isSameSize(size) {
2235
- return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
2233
+ return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
2236
2234
  }
2237
2235
  getSameCanvas(useSameWorldTransform, useSameSmooth) {
2238
2236
  const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
@@ -4070,13 +4068,10 @@ function defineDataProcessor(target, key, defaultValue) {
4070
4068
  if (defaultValue === undefined) {
4071
4069
  property.get = function () { return this[computedKey]; };
4072
4070
  }
4073
- else if (typeof defaultValue === 'object') {
4074
- const { clone } = DataHelper;
4071
+ else if (typeof defaultValue === 'function') {
4075
4072
  property.get = function () {
4076
4073
  let v = this[computedKey];
4077
- if (v === undefined)
4078
- this[computedKey] = v = clone(defaultValue);
4079
- return v;
4074
+ return v === undefined ? defaultValue(this.__leaf) : v;
4080
4075
  };
4081
4076
  }
4082
4077
  if (key === 'width') {
@@ -5722,10 +5717,10 @@ let Leaf = class Leaf {
5722
5717
  static changeAttr(attrName, defaultValue, fn) {
5723
5718
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5724
5719
  }
5725
- static addAttr(attrName, defaultValue, fn) {
5720
+ static addAttr(attrName, defaultValue, fn, helpValue) {
5726
5721
  if (!fn)
5727
5722
  fn = boundsType;
5728
- fn(defaultValue)(this.prototype, attrName);
5723
+ fn(defaultValue, helpValue)(this.prototype, attrName);
5729
5724
  }
5730
5725
  __emitLifeEvent(type) {
5731
5726
  if (this.hasEvent(type))
@@ -6052,7 +6047,7 @@ class LeafLevelList {
6052
6047
  }
6053
6048
  }
6054
6049
 
6055
- const version = "1.4.2";
6050
+ const version = "1.5.1";
6056
6051
 
6057
6052
  class LeaferCanvas extends LeaferCanvasBase {
6058
6053
  get allowBackgroundColor() { return true; }
@@ -6939,7 +6934,11 @@ const State = {
6939
6934
  setStyleName() { return Plugin.need('state'); },
6940
6935
  set() { return Plugin.need('state'); }
6941
6936
  };
6942
- const Transition = {};
6937
+ const Transition = {
6938
+ list: {},
6939
+ register(attrName, fn) { Transition.list[attrName] = fn; },
6940
+ get(attrName) { return Transition.list[attrName]; }
6941
+ };
6943
6942
 
6944
6943
  const { parse, objectToCanvasData } = PathConvert;
6945
6944
  const emptyPaint = {};
@@ -7363,9 +7362,6 @@ let UI = UI_1 = class UI extends Leaf {
7363
7362
  this.__drawPathByBox(pen);
7364
7363
  return pen;
7365
7364
  }
7366
- get editConfig() { return undefined; }
7367
- get editOuter() { return ''; }
7368
- get editInner() { return ''; }
7369
7365
  constructor(data) {
7370
7366
  super(data);
7371
7367
  }
@@ -7447,8 +7443,11 @@ let UI = UI_1 = class UI extends Leaf {
7447
7443
  export(_filename, _options) {
7448
7444
  return Plugin.need('export');
7449
7445
  }
7446
+ syncExport(_filename, _options) {
7447
+ return Plugin.need('export');
7448
+ }
7450
7449
  clone(data) {
7451
- const json = this.toJSON();
7450
+ const json = DataHelper.clone(this.toJSON());
7452
7451
  if (data)
7453
7452
  Object.assign(json, data);
7454
7453
  return UI_1.one(json);
@@ -7747,7 +7746,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7747
7746
  get layoutLocked() { return !this.layouter.running; }
7748
7747
  get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7749
7748
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7750
- get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
7749
+ get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
7751
7750
  constructor(userConfig, data) {
7752
7751
  super(data);
7753
7752
  this.config = {
@@ -8049,6 +8048,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8049
8048
  getPagePointByClient(clientPoint, updateClient) {
8050
8049
  return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
8051
8050
  }
8051
+ getClientPointByWorld(worldPoint) {
8052
+ const { x, y } = this.clientBounds;
8053
+ return { x: x + worldPoint.x, y: y + worldPoint.y };
8054
+ }
8052
8055
  updateClientBounds() {
8053
8056
  this.canvas && this.canvas.updateClientBounds();
8054
8057
  }
@@ -10017,8 +10020,6 @@ ui$1.__updateHitCanvas = function () {
10017
10020
  h.setStrokeOptions(data);
10018
10021
  };
10019
10022
  ui$1.__hit = function (inner) {
10020
- if (Platform.name === 'miniapp')
10021
- this.__drawHitPath(this.__hitCanvas);
10022
10023
  const data = this.__;
10023
10024
  if (data.__isHitPixel && this.__hitPixel(inner))
10024
10025
  return true;
@@ -11373,13 +11374,14 @@ function toChar(data, charX, rowData, isOverflow) {
11373
11374
  }
11374
11375
 
11375
11376
  function layoutText(drawData, style) {
11376
- const { rows, bounds } = drawData;
11377
+ const { rows, bounds } = drawData, countRows = rows.length;
11377
11378
  const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11378
- let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11379
+ let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11379
11380
  let starY = __baseLine;
11380
11381
  if (__clipText && realHeight > height) {
11381
11382
  realHeight = Math.max(height, __lineHeight);
11382
- drawData.overflow = rows.length;
11383
+ if (countRows > 1)
11384
+ drawData.overflow = countRows;
11383
11385
  }
11384
11386
  else if (height || autoSizeAlign) {
11385
11387
  switch (verticalAlign) {
@@ -11391,7 +11393,7 @@ function layoutText(drawData, style) {
11391
11393
  }
11392
11394
  starY += y;
11393
11395
  let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11394
- for (let i = 0, len = rows.length; i < len; i++) {
11396
+ for (let i = 0, len = countRows; i < len; i++) {
11395
11397
  row = rows[i];
11396
11398
  row.x = x;
11397
11399
  if (row.width < width || (row.width > width && !__clipText)) {
@@ -11460,7 +11462,7 @@ function clipText(drawData, style, x, width) {
11460
11462
  if (i === end && charRight < right) {
11461
11463
  break;
11462
11464
  }
11463
- else if (charRight < right && char.char !== ' ') {
11465
+ else if ((charRight < right && char.char !== ' ') || !i) {
11464
11466
  row.data.splice(i + 1);
11465
11467
  row.width -= char.width;
11466
11468
  break;