@leafer/core 2.1.3 → 2.1.5

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
@@ -214,7 +214,7 @@ const IncrementId = {
214
214
  RUNTIME: "runtime",
215
215
  LEAF: "leaf",
216
216
  TASK: "task",
217
- CNAVAS: "canvas",
217
+ CANVAS: "canvas",
218
218
  IMAGE: "image",
219
219
  types: {},
220
220
  create(typeName) {
@@ -868,7 +868,7 @@ const PointHelper = {
868
868
  return quick ? t.x === point.x && t.y === point.y : float$1(t.x) === float$1(point.x) && float$1(t.y) === float$1(point.y);
869
869
  },
870
870
  reset(t) {
871
- P$5.reset(t);
871
+ t.x = t.y = 0;
872
872
  }
873
873
  };
874
874
 
@@ -1077,6 +1077,7 @@ class Matrix {
1077
1077
  }
1078
1078
  reset() {
1079
1079
  MatrixHelper.reset(this);
1080
+ return this;
1080
1081
  }
1081
1082
  }
1082
1083
 
@@ -2339,7 +2340,7 @@ class LeaferCanvasBase extends Canvas {
2339
2340
  this.worldTransform = {};
2340
2341
  if (!config) config = minSize;
2341
2342
  this.manager = manager;
2342
- this.innerId = IncrementId.create(IncrementId.CNAVAS);
2343
+ this.innerId = IncrementId.create(IncrementId.CANVAS);
2343
2344
  const {width: width, height: height, pixelRatio: pixelRatio} = config;
2344
2345
  this.autoLayout = !width || !height;
2345
2346
  this.size.pixelRatio = pixelRatio || Platform.devicePixelRatio;
@@ -2489,6 +2490,7 @@ class LeaferCanvasBase extends Canvas {
2489
2490
  }
2490
2491
  useGrayscaleAlpha(bounds) {
2491
2492
  this.setTempPixelBounds(bounds, true, true);
2493
+ if (!tempPixelBounds.width || !tempPixelBounds.height) return;
2492
2494
  let alpha, pixel;
2493
2495
  const {context: context} = this, imageData = context.getImageData(tempPixelBounds.x, tempPixelBounds.y, tempPixelBounds.width, tempPixelBounds.height), {data: data} = imageData;
2494
2496
  for (let i = 0, len = data.length; i < len; i += 4) {
@@ -3041,7 +3043,8 @@ const PathConvert = {
3041
3043
  current.length = PathCommandLengthMap[char];
3042
3044
  current.index = 0;
3043
3045
  pushData(data, current.name);
3044
- if (char === "m") current.name = PathCommandMap["l"]; else if (char === "M") current.name = PathCommandMap["L"]; else if (!needConvert && convertCommand[char]) needConvert = true;
3046
+ if (char === "m") current.name = PathCommandMap["l"]; else if (char === "M") current.name = PathCommandMap["L"];
3047
+ if (!needConvert && convertCommand[char]) needConvert = true;
3045
3048
  } else {
3046
3049
  if (char === "-" || char === "+") {
3047
3050
  if (lastChar === "e" || lastChar === "E") {
@@ -3117,8 +3120,8 @@ const PathConvert = {
3117
3120
 
3118
3121
  case S:
3119
3122
  smooth = lastCommand === C$3 || lastCommand === S;
3120
- x1 = smooth ? x * 2 - controlX : old[i + 1];
3121
- y1 = smooth ? y * 2 - controlY : old[i + 2];
3123
+ x1 = smooth ? x * 2 - controlX : x;
3124
+ y1 = smooth ? y * 2 - controlY : y;
3122
3125
  controlX = old[i + 1];
3123
3126
  controlY = old[i + 2];
3124
3127
  x = old[i + 3];
@@ -3152,8 +3155,8 @@ const PathConvert = {
3152
3155
 
3153
3156
  case T:
3154
3157
  smooth = lastCommand === Q$3 || lastCommand === T;
3155
- controlX = smooth ? x * 2 - controlX : old[i + 1];
3156
- controlY = smooth ? y * 2 - controlY : old[i + 2];
3158
+ controlX = smooth ? x * 2 - controlX : x;
3159
+ controlY = smooth ? y * 2 - controlY : y;
3157
3160
  curveMode ? quadraticCurveTo$1(data, x, y, controlX, controlY, old[i + 1], old[i + 2]) : data.push(Q$3, controlX, controlY, old[i + 1], old[i + 2]);
3158
3161
  x = old[i + 1];
3159
3162
  y = old[i + 2];
@@ -4858,10 +4861,10 @@ const LeafHelper = {
4858
4861
  y: y
4859
4862
  }, transition) : (t.x = x, t.y = y);
4860
4863
  },
4861
- zoomOfWorld(t, origin, scaleX, scaleY, resize, transition) {
4862
- L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize, transition);
4864
+ zoomOfWorld(t, origin, scaleX, scaleY, resize, transition, boundsType) {
4865
+ L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize, transition, boundsType);
4863
4866
  },
4864
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize, transition) {
4867
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize, transition, boundsType) {
4865
4868
  const o = t.__localMatrix;
4866
4869
  if (!isNumber(scaleY)) {
4867
4870
  if (scaleY) transition = scaleY;
@@ -4870,7 +4873,7 @@ const LeafHelper = {
4870
4873
  copy$3(matrix, o);
4871
4874
  scaleOfOuter(matrix, origin, scaleX, scaleY);
4872
4875
  if (L.hasHighPosition(t)) {
4873
- L.setTransform(t, matrix, resize, transition);
4876
+ L.setTransform(t, matrix, resize, transition, boundsType);
4874
4877
  } else {
4875
4878
  const x = t.x + matrix.e - o.e, y = t.y + matrix.f - o.f;
4876
4879
  if (transition && !resize) t.animate({
@@ -4878,7 +4881,7 @@ const LeafHelper = {
4878
4881
  y: y,
4879
4882
  scaleX: t.scaleX * scaleX,
4880
4883
  scaleY: t.scaleY * scaleY
4881
- }, transition); else t.x = x, t.y = y, t.scaleResize(scaleX, scaleY, resize !== true);
4884
+ }, transition); else t.x = x, t.y = y, t.scaleResize(scaleX, scaleY, resize !== true, boundsType);
4882
4885
  }
4883
4886
  },
4884
4887
  rotateOfWorld(t, origin, angle, transition) {
@@ -4902,18 +4905,18 @@ const LeafHelper = {
4902
4905
  skewOfOuter(matrix, origin, skewX, skewY);
4903
4906
  L.setTransform(t, matrix, resize, transition);
4904
4907
  },
4905
- transformWorld(t, transform, resize, transition) {
4908
+ transformWorld(t, transform, resize, transition, boundsType) {
4906
4909
  copy$3(matrix, t.worldTransform);
4907
4910
  multiplyParent$2(matrix, transform);
4908
4911
  if (t.parent) divideParent(matrix, t.parent.scrollWorldTransform);
4909
- L.setTransform(t, matrix, resize, transition);
4912
+ L.setTransform(t, matrix, resize, transition, boundsType);
4910
4913
  },
4911
- transform(t, transform, resize, transition) {
4914
+ transform(t, transform, resize, transition, boundsType) {
4912
4915
  copy$3(matrix, t.localTransform);
4913
4916
  multiplyParent$2(matrix, transform);
4914
- L.setTransform(t, matrix, resize, transition);
4917
+ L.setTransform(t, matrix, resize, transition, boundsType);
4915
4918
  },
4916
- setTransform(t, transform, resize, transition) {
4919
+ setTransform(t, transform, resize, transition, boundsType) {
4917
4920
  const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
4918
4921
  const layout = getLayout(transform, originPoint, data.around && L.getInnerOrigin(t, data.around));
4919
4922
  if (L.hasOffset(t)) {
@@ -4929,7 +4932,7 @@ const LeafHelper = {
4929
4932
  PointHelper.move(layout, originPoint.x - changedPoint.x, originPoint.y - changedPoint.y);
4930
4933
  }
4931
4934
  t.set(layout);
4932
- t.scaleResize(scaleX, scaleY, false);
4935
+ t.scaleResize(scaleX, scaleY, false, boundsType);
4933
4936
  } else t.set(layout, transition);
4934
4937
  },
4935
4938
  getFlipTransform(t, axis) {
@@ -5511,6 +5514,7 @@ class LeafLayout {
5511
5514
  this.renderChanged = true;
5512
5515
  this.renderSpread || (this.renderSpread = 1);
5513
5516
  this.boundsChanged = true;
5517
+ this.hitCanvasChanged = true;
5514
5518
  }
5515
5519
  scaleChange() {
5516
5520
  this.scaleChanged = true;
@@ -6451,10 +6455,6 @@ exports.Leaf = class Leaf {
6451
6455
  }
6452
6456
  }
6453
6457
  }
6454
- set(_data, _isTemp) {}
6455
- get(_name) {
6456
- return undefined;
6457
- }
6458
6458
  setAttr(name, value) {
6459
6459
  this[name] = value;
6460
6460
  }
@@ -6471,37 +6471,10 @@ exports.Leaf = class Leaf {
6471
6471
  toString(options) {
6472
6472
  return JSON.stringify(this.toJSON(options));
6473
6473
  }
6474
- toSVG() {
6475
- return undefined;
6476
- }
6477
- __SVG(_data) {}
6478
- toHTML() {
6479
- return undefined;
6480
- }
6481
- __setAttr(_attrName, _newValue) {
6482
- return true;
6483
- }
6484
- __getAttr(_attrName) {
6485
- return undefined;
6486
- }
6487
- setProxyAttr(_attrName, _newValue) {}
6488
- getProxyAttr(_attrName) {
6489
- return undefined;
6490
- }
6491
- find(_condition, _options) {
6492
- return undefined;
6493
- }
6494
- findTag(_tag) {
6495
- return undefined;
6496
- }
6497
- findOne(_condition, _options) {
6498
- return undefined;
6499
- }
6500
- findId(_id) {
6501
- return undefined;
6474
+ scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6475
+ this.scaleX *= scaleX;
6476
+ this.scaleY *= scaleY;
6502
6477
  }
6503
- focus(_value) {}
6504
- updateState() {}
6505
6478
  updateLayout() {
6506
6479
  this.__layout.update();
6507
6480
  }
@@ -6517,27 +6490,6 @@ exports.Leaf = class Leaf {
6517
6490
  __extraUpdate() {
6518
6491
  if (this.leaferIsReady) this.leafer.layouter.addExtra(this);
6519
6492
  }
6520
- __updateWorldMatrix() {}
6521
- __updateLocalMatrix() {}
6522
- __updateWorldBounds() {}
6523
- __updateLocalBounds() {}
6524
- __updateLocalBoxBounds() {}
6525
- __updateLocalStrokeBounds() {}
6526
- __updateLocalRenderBounds() {}
6527
- __updateBoxBounds(_secondLayout, _bounds) {}
6528
- __updateContentBounds() {}
6529
- __updateStrokeBounds(_bounds) {}
6530
- __updateRenderBounds(_bounds) {}
6531
- __updateAutoLayout() {}
6532
- __updateFlowLayout() {}
6533
- __updateNaturalSize() {}
6534
- __updateStrokeSpread() {
6535
- return 0;
6536
- }
6537
- __updateRenderSpread() {
6538
- return 0;
6539
- }
6540
- __onUpdateSize() {}
6541
6493
  __updateEraser(value) {
6542
6494
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
6543
6495
  }
@@ -6551,7 +6503,6 @@ exports.Leaf = class Leaf {
6551
6503
  __updateMask(_value) {
6552
6504
  this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6553
6505
  }
6554
- __renderMask(_canvas, _options) {}
6555
6506
  __getNowWorld(options) {
6556
6507
  if (options.matrix) {
6557
6508
  if (!this.__cameraWorld) this.__cameraWorld = {};
@@ -6668,11 +6619,11 @@ exports.Leaf = class Leaf {
6668
6619
  const layer = this.leafer ? this.leafer.zoomLayer : this;
6669
6620
  return layer.getWorldPoint(page, relative, distance, change);
6670
6621
  }
6671
- setTransform(matrix, resize, transition) {
6672
- setTransform(this, matrix, resize, transition);
6622
+ setTransform(matrix, resize, transition, boundsType) {
6623
+ setTransform(this, matrix, resize, transition, boundsType);
6673
6624
  }
6674
- transform(matrix, resize, transition) {
6675
- transform(this, matrix, resize, transition);
6625
+ transform(matrix, resize, transition, boundsType) {
6626
+ transform(this, matrix, resize, transition, boundsType);
6676
6627
  }
6677
6628
  move(x, y, transition) {
6678
6629
  moveLocal(this, x, y, transition);
@@ -6680,8 +6631,8 @@ exports.Leaf = class Leaf {
6680
6631
  moveInner(x, y, transition) {
6681
6632
  moveWorld(this, x, y, true, transition);
6682
6633
  }
6683
- scaleOf(origin, scaleX, scaleY, resize, transition) {
6684
- zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize, transition);
6634
+ scaleOf(origin, scaleX, scaleY, resize, transition, boundsType) {
6635
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize, transition, boundsType);
6685
6636
  }
6686
6637
  rotateOf(origin, rotation, transition) {
6687
6638
  rotateOfLocal(this, getLocalOrigin(this, origin), rotation, transition);
@@ -6689,14 +6640,14 @@ exports.Leaf = class Leaf {
6689
6640
  skewOf(origin, skewX, skewY, resize, transition) {
6690
6641
  skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize, transition);
6691
6642
  }
6692
- transformWorld(worldTransform, resize, transition) {
6693
- transformWorld(this, worldTransform, resize, transition);
6643
+ transformWorld(worldTransform, resize, transition, boundsType) {
6644
+ transformWorld(this, worldTransform, resize, transition, boundsType);
6694
6645
  }
6695
6646
  moveWorld(x, y, transition) {
6696
6647
  moveWorld(this, x, y, false, transition);
6697
6648
  }
6698
- scaleOfWorld(worldOrigin, scaleX, scaleY, resize, transition) {
6699
- zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize, transition);
6649
+ scaleOfWorld(worldOrigin, scaleX, scaleY, resize, transition, boundsType) {
6650
+ zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize, transition, boundsType);
6700
6651
  }
6701
6652
  rotateOfWorld(worldOrigin, rotation) {
6702
6653
  rotateOfWorld(this, worldOrigin, rotation);
@@ -6707,76 +6658,12 @@ exports.Leaf = class Leaf {
6707
6658
  flip(axis, transition) {
6708
6659
  transform(this, getFlipTransform(this, axis), false, transition);
6709
6660
  }
6710
- scaleResize(scaleX, scaleY = scaleX, _noResize) {
6711
- this.scaleX *= scaleX;
6712
- this.scaleY *= scaleY;
6713
- }
6714
- __scaleResize(_scaleX, _scaleY) {}
6715
- resizeWidth(_width) {}
6716
- resizeHeight(_height) {}
6717
- hit(_world, _hitRadius) {
6718
- return true;
6719
- }
6720
- __hitWorld(_point, _forceHitFill) {
6721
- return true;
6722
- }
6723
- __hit(_local, _forceHitFill) {
6724
- return true;
6725
- }
6726
- __hitFill(_inner) {
6727
- return true;
6728
- }
6729
- __hitStroke(_inner, _strokeWidth) {
6730
- return true;
6731
- }
6732
- __hitPixel(_inner) {
6733
- return true;
6734
- }
6735
- __drawHitPath(_canvas) {}
6736
- __updateHitCanvas() {}
6737
- __render(_canvas, _options) {}
6738
- __drawFast(_canvas, _options) {}
6739
- __draw(_canvas, _options, _originCanvas) {}
6740
- __clip(_canvas, _options) {}
6741
- __renderShape(_canvas, _options) {}
6742
- __drawShape(_canvas, _options) {}
6743
- __updateWorldOpacity() {}
6744
- __updateChange() {}
6745
- __drawPath(_canvas) {}
6746
- __drawRenderPath(_canvas) {}
6747
- __updatePath() {}
6748
- __updateRenderPath(_updateCache) {}
6749
- getMotionPathData() {
6750
- return Plugin.need("path");
6751
- }
6752
- getMotionPoint(_motionDistance) {
6753
- return Plugin.need("path");
6754
- }
6755
- getMotionTotal() {
6756
- return 0;
6757
- }
6758
- __updateMotionPath() {}
6759
- __runAnimation(_type, _complete) {}
6760
- __updateSortChildren() {}
6761
- add(_child, _index) {}
6762
6661
  remove(_child, destroy) {
6763
6662
  if (this.parent) this.parent.remove(this, destroy);
6764
6663
  }
6765
6664
  dropTo(parent, index, resize) {
6766
6665
  drop(this, parent, index, resize);
6767
6666
  }
6768
- on(_type, _listener, _options) {}
6769
- off(_type, _listener, _options) {}
6770
- on_(_type, _listener, _bind, _options) {
6771
- return undefined;
6772
- }
6773
- off_(_id) {}
6774
- once(_type, _listener, _captureOrBind, _capture) {}
6775
- emit(_type, _event, _capture) {}
6776
- emitEvent(_event, _capture) {}
6777
- hasEvent(_type, _capture) {
6778
- return false;
6779
- }
6780
6667
  static changeAttr(attrName, defaultValue, fn) {
6781
6668
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
6782
6669
  }
@@ -7082,7 +6969,7 @@ class LeafLevelList {
7082
6969
  }
7083
6970
  }
7084
6971
 
7085
- const version = "2.1.3";
6972
+ const version = "2.1.5";
7086
6973
 
7087
6974
  exports.AlignHelper = AlignHelper;
7088
6975