@leafer/core 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/lib/core.cjs CHANGED
@@ -2031,13 +2031,11 @@ class LeaferCanvasBase extends Canvas {
2031
2031
  this.worldTransform = {};
2032
2032
  if (!config)
2033
2033
  config = minSize;
2034
- if (!config.pixelRatio)
2035
- config.pixelRatio = Platform.devicePixelRatio;
2036
2034
  this.manager = manager;
2037
2035
  this.innerId = IncrementId.create(IncrementId.CNAVAS);
2038
2036
  const { width, height, pixelRatio } = config;
2039
2037
  this.autoLayout = !width || !height;
2040
- this.size.pixelRatio = pixelRatio;
2038
+ this.size.pixelRatio = pixelRatio | Platform.devicePixelRatio;
2041
2039
  this.config = config;
2042
2040
  this.init();
2043
2041
  }
@@ -2234,7 +2232,7 @@ class LeaferCanvasBase extends Canvas {
2234
2232
  tempBounds.ceil();
2235
2233
  }
2236
2234
  isSameSize(size) {
2237
- return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
2235
+ return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
2238
2236
  }
2239
2237
  getSameCanvas(useSameWorldTransform, useSameSmooth) {
2240
2238
  const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
@@ -4072,13 +4070,10 @@ function defineDataProcessor(target, key, defaultValue) {
4072
4070
  if (defaultValue === undefined) {
4073
4071
  property.get = function () { return this[computedKey]; };
4074
4072
  }
4075
- else if (typeof defaultValue === 'object') {
4076
- const { clone } = DataHelper;
4073
+ else if (typeof defaultValue === 'function') {
4077
4074
  property.get = function () {
4078
4075
  let v = this[computedKey];
4079
- if (v === undefined)
4080
- this[computedKey] = v = clone(defaultValue);
4081
- return v;
4076
+ return v === undefined ? defaultValue(this.__leaf) : v;
4082
4077
  };
4083
4078
  }
4084
4079
  if (key === 'width') {
@@ -5724,10 +5719,10 @@ exports.Leaf = class Leaf {
5724
5719
  static changeAttr(attrName, defaultValue, fn) {
5725
5720
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5726
5721
  }
5727
- static addAttr(attrName, defaultValue, fn) {
5722
+ static addAttr(attrName, defaultValue, fn, helpValue) {
5728
5723
  if (!fn)
5729
5724
  fn = boundsType;
5730
- fn(defaultValue)(this.prototype, attrName);
5725
+ fn(defaultValue, helpValue)(this.prototype, attrName);
5731
5726
  }
5732
5727
  __emitLifeEvent(type) {
5733
5728
  if (this.hasEvent(type))
@@ -6054,7 +6049,7 @@ class LeafLevelList {
6054
6049
  }
6055
6050
  }
6056
6051
 
6057
- const version = "1.4.2";
6052
+ const version = "1.5.1";
6058
6053
 
6059
6054
  exports.AlignHelper = AlignHelper;
6060
6055
  exports.AroundHelper = AroundHelper;