@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.
package/dist/worker.js CHANGED
@@ -2032,13 +2032,11 @@ var LeaferUI = (function (exports) {
2032
2032
  this.worldTransform = {};
2033
2033
  if (!config)
2034
2034
  config = minSize;
2035
- if (!config.pixelRatio)
2036
- config.pixelRatio = Platform.devicePixelRatio;
2037
2035
  this.manager = manager;
2038
2036
  this.innerId = IncrementId.create(IncrementId.CNAVAS);
2039
2037
  const { width, height, pixelRatio } = config;
2040
2038
  this.autoLayout = !width || !height;
2041
- this.size.pixelRatio = pixelRatio;
2039
+ this.size.pixelRatio = pixelRatio | Platform.devicePixelRatio;
2042
2040
  this.config = config;
2043
2041
  this.init();
2044
2042
  }
@@ -2235,7 +2233,7 @@ var LeaferUI = (function (exports) {
2235
2233
  tempBounds$1.ceil();
2236
2234
  }
2237
2235
  isSameSize(size) {
2238
- return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
2236
+ return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
2239
2237
  }
2240
2238
  getSameCanvas(useSameWorldTransform, useSameSmooth) {
2241
2239
  const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
@@ -4073,13 +4071,10 @@ var LeaferUI = (function (exports) {
4073
4071
  if (defaultValue === undefined) {
4074
4072
  property.get = function () { return this[computedKey]; };
4075
4073
  }
4076
- else if (typeof defaultValue === 'object') {
4077
- const { clone } = DataHelper;
4074
+ else if (typeof defaultValue === 'function') {
4078
4075
  property.get = function () {
4079
4076
  let v = this[computedKey];
4080
- if (v === undefined)
4081
- this[computedKey] = v = clone(defaultValue);
4082
- return v;
4077
+ return v === undefined ? defaultValue(this.__leaf) : v;
4083
4078
  };
4084
4079
  }
4085
4080
  if (key === 'width') {
@@ -5725,10 +5720,10 @@ var LeaferUI = (function (exports) {
5725
5720
  static changeAttr(attrName, defaultValue, fn) {
5726
5721
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5727
5722
  }
5728
- static addAttr(attrName, defaultValue, fn) {
5723
+ static addAttr(attrName, defaultValue, fn, helpValue) {
5729
5724
  if (!fn)
5730
5725
  fn = boundsType;
5731
- fn(defaultValue)(this.prototype, attrName);
5726
+ fn(defaultValue, helpValue)(this.prototype, attrName);
5732
5727
  }
5733
5728
  __emitLifeEvent(type) {
5734
5729
  if (this.hasEvent(type))
@@ -6055,7 +6050,7 @@ var LeaferUI = (function (exports) {
6055
6050
  }
6056
6051
  }
6057
6052
 
6058
- const version = "1.4.2";
6053
+ const version = "1.5.1";
6059
6054
 
6060
6055
  class LeaferCanvas extends LeaferCanvasBase {
6061
6056
  get allowBackgroundColor() { return true; }
@@ -6942,7 +6937,11 @@ var LeaferUI = (function (exports) {
6942
6937
  setStyleName() { return Plugin.need('state'); },
6943
6938
  set() { return Plugin.need('state'); }
6944
6939
  };
6945
- const Transition = {};
6940
+ const Transition = {
6941
+ list: {},
6942
+ register(attrName, fn) { Transition.list[attrName] = fn; },
6943
+ get(attrName) { return Transition.list[attrName]; }
6944
+ };
6946
6945
 
6947
6946
  const { parse, objectToCanvasData } = PathConvert;
6948
6947
  const emptyPaint = {};
@@ -7366,9 +7365,6 @@ var LeaferUI = (function (exports) {
7366
7365
  this.__drawPathByBox(pen);
7367
7366
  return pen;
7368
7367
  }
7369
- get editConfig() { return undefined; }
7370
- get editOuter() { return ''; }
7371
- get editInner() { return ''; }
7372
7368
  constructor(data) {
7373
7369
  super(data);
7374
7370
  }
@@ -7450,8 +7446,11 @@ var LeaferUI = (function (exports) {
7450
7446
  export(_filename, _options) {
7451
7447
  return Plugin.need('export');
7452
7448
  }
7449
+ syncExport(_filename, _options) {
7450
+ return Plugin.need('export');
7451
+ }
7453
7452
  clone(data) {
7454
- const json = this.toJSON();
7453
+ const json = DataHelper.clone(this.toJSON());
7455
7454
  if (data)
7456
7455
  Object.assign(json, data);
7457
7456
  return UI_1.one(json);
@@ -7750,7 +7749,7 @@ var LeaferUI = (function (exports) {
7750
7749
  get layoutLocked() { return !this.layouter.running; }
7751
7750
  get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7752
7751
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7753
- get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
7752
+ get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
7754
7753
  constructor(userConfig, data) {
7755
7754
  super(data);
7756
7755
  this.config = {
@@ -8052,6 +8051,10 @@ var LeaferUI = (function (exports) {
8052
8051
  getPagePointByClient(clientPoint, updateClient) {
8053
8052
  return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
8054
8053
  }
8054
+ getClientPointByWorld(worldPoint) {
8055
+ const { x, y } = this.clientBounds;
8056
+ return { x: x + worldPoint.x, y: y + worldPoint.y };
8057
+ }
8055
8058
  updateClientBounds() {
8056
8059
  this.canvas && this.canvas.updateClientBounds();
8057
8060
  }
@@ -10020,8 +10023,6 @@ var LeaferUI = (function (exports) {
10020
10023
  h.setStrokeOptions(data);
10021
10024
  };
10022
10025
  ui$1.__hit = function (inner) {
10023
- if (Platform.name === 'miniapp')
10024
- this.__drawHitPath(this.__hitCanvas);
10025
10026
  const data = this.__;
10026
10027
  if (data.__isHitPixel && this.__hitPixel(inner))
10027
10028
  return true;
@@ -11376,13 +11377,14 @@ var LeaferUI = (function (exports) {
11376
11377
  }
11377
11378
 
11378
11379
  function layoutText(drawData, style) {
11379
- const { rows, bounds } = drawData;
11380
+ const { rows, bounds } = drawData, countRows = rows.length;
11380
11381
  const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
11381
- let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11382
+ let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
11382
11383
  let starY = __baseLine;
11383
11384
  if (__clipText && realHeight > height) {
11384
11385
  realHeight = Math.max(height, __lineHeight);
11385
- drawData.overflow = rows.length;
11386
+ if (countRows > 1)
11387
+ drawData.overflow = countRows;
11386
11388
  }
11387
11389
  else if (height || autoSizeAlign) {
11388
11390
  switch (verticalAlign) {
@@ -11394,7 +11396,7 @@ var LeaferUI = (function (exports) {
11394
11396
  }
11395
11397
  starY += y;
11396
11398
  let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
11397
- for (let i = 0, len = rows.length; i < len; i++) {
11399
+ for (let i = 0, len = countRows; i < len; i++) {
11398
11400
  row = rows[i];
11399
11401
  row.x = x;
11400
11402
  if (row.width < width || (row.width > width && !__clipText)) {
@@ -11463,7 +11465,7 @@ var LeaferUI = (function (exports) {
11463
11465
  if (i === end && charRight < right) {
11464
11466
  break;
11465
11467
  }
11466
- else if (charRight < right && char.char !== ' ') {
11468
+ else if ((charRight < right && char.char !== ' ') || !i) {
11467
11469
  row.data.splice(i + 1);
11468
11470
  row.width -= char.width;
11469
11471
  break;