@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.esm.js CHANGED
@@ -212,7 +212,7 @@ const IncrementId = {
212
212
  RUNTIME: "runtime",
213
213
  LEAF: "leaf",
214
214
  TASK: "task",
215
- CNAVAS: "canvas",
215
+ CANVAS: "canvas",
216
216
  IMAGE: "image",
217
217
  types: {},
218
218
  create(typeName) {
@@ -866,7 +866,7 @@ const PointHelper = {
866
866
  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);
867
867
  },
868
868
  reset(t) {
869
- P$5.reset(t);
869
+ t.x = t.y = 0;
870
870
  }
871
871
  };
872
872
 
@@ -1075,6 +1075,7 @@ class Matrix {
1075
1075
  }
1076
1076
  reset() {
1077
1077
  MatrixHelper.reset(this);
1078
+ return this;
1078
1079
  }
1079
1080
  }
1080
1081
 
@@ -2337,7 +2338,7 @@ class LeaferCanvasBase extends Canvas {
2337
2338
  this.worldTransform = {};
2338
2339
  if (!config) config = minSize;
2339
2340
  this.manager = manager;
2340
- this.innerId = IncrementId.create(IncrementId.CNAVAS);
2341
+ this.innerId = IncrementId.create(IncrementId.CANVAS);
2341
2342
  const {width: width, height: height, pixelRatio: pixelRatio} = config;
2342
2343
  this.autoLayout = !width || !height;
2343
2344
  this.size.pixelRatio = pixelRatio || Platform.devicePixelRatio;
@@ -2487,6 +2488,7 @@ class LeaferCanvasBase extends Canvas {
2487
2488
  }
2488
2489
  useGrayscaleAlpha(bounds) {
2489
2490
  this.setTempPixelBounds(bounds, true, true);
2491
+ if (!tempPixelBounds.width || !tempPixelBounds.height) return;
2490
2492
  let alpha, pixel;
2491
2493
  const {context: context} = this, imageData = context.getImageData(tempPixelBounds.x, tempPixelBounds.y, tempPixelBounds.width, tempPixelBounds.height), {data: data} = imageData;
2492
2494
  for (let i = 0, len = data.length; i < len; i += 4) {
@@ -3039,7 +3041,8 @@ const PathConvert = {
3039
3041
  current.length = PathCommandLengthMap[char];
3040
3042
  current.index = 0;
3041
3043
  pushData(data, current.name);
3042
- if (char === "m") current.name = PathCommandMap["l"]; else if (char === "M") current.name = PathCommandMap["L"]; else if (!needConvert && convertCommand[char]) needConvert = true;
3044
+ if (char === "m") current.name = PathCommandMap["l"]; else if (char === "M") current.name = PathCommandMap["L"];
3045
+ if (!needConvert && convertCommand[char]) needConvert = true;
3043
3046
  } else {
3044
3047
  if (char === "-" || char === "+") {
3045
3048
  if (lastChar === "e" || lastChar === "E") {
@@ -3115,8 +3118,8 @@ const PathConvert = {
3115
3118
 
3116
3119
  case S:
3117
3120
  smooth = lastCommand === C$3 || lastCommand === S;
3118
- x1 = smooth ? x * 2 - controlX : old[i + 1];
3119
- y1 = smooth ? y * 2 - controlY : old[i + 2];
3121
+ x1 = smooth ? x * 2 - controlX : x;
3122
+ y1 = smooth ? y * 2 - controlY : y;
3120
3123
  controlX = old[i + 1];
3121
3124
  controlY = old[i + 2];
3122
3125
  x = old[i + 3];
@@ -3150,8 +3153,8 @@ const PathConvert = {
3150
3153
 
3151
3154
  case T:
3152
3155
  smooth = lastCommand === Q$3 || lastCommand === T;
3153
- controlX = smooth ? x * 2 - controlX : old[i + 1];
3154
- controlY = smooth ? y * 2 - controlY : old[i + 2];
3156
+ controlX = smooth ? x * 2 - controlX : x;
3157
+ controlY = smooth ? y * 2 - controlY : y;
3155
3158
  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]);
3156
3159
  x = old[i + 1];
3157
3160
  y = old[i + 2];
@@ -4856,10 +4859,10 @@ const LeafHelper = {
4856
4859
  y: y
4857
4860
  }, transition) : (t.x = x, t.y = y);
4858
4861
  },
4859
- zoomOfWorld(t, origin, scaleX, scaleY, resize, transition) {
4860
- L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize, transition);
4862
+ zoomOfWorld(t, origin, scaleX, scaleY, resize, transition, boundsType) {
4863
+ L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize, transition, boundsType);
4861
4864
  },
4862
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize, transition) {
4865
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize, transition, boundsType) {
4863
4866
  const o = t.__localMatrix;
4864
4867
  if (!isNumber(scaleY)) {
4865
4868
  if (scaleY) transition = scaleY;
@@ -4868,7 +4871,7 @@ const LeafHelper = {
4868
4871
  copy$3(matrix, o);
4869
4872
  scaleOfOuter(matrix, origin, scaleX, scaleY);
4870
4873
  if (L.hasHighPosition(t)) {
4871
- L.setTransform(t, matrix, resize, transition);
4874
+ L.setTransform(t, matrix, resize, transition, boundsType);
4872
4875
  } else {
4873
4876
  const x = t.x + matrix.e - o.e, y = t.y + matrix.f - o.f;
4874
4877
  if (transition && !resize) t.animate({
@@ -4876,7 +4879,7 @@ const LeafHelper = {
4876
4879
  y: y,
4877
4880
  scaleX: t.scaleX * scaleX,
4878
4881
  scaleY: t.scaleY * scaleY
4879
- }, transition); else t.x = x, t.y = y, t.scaleResize(scaleX, scaleY, resize !== true);
4882
+ }, transition); else t.x = x, t.y = y, t.scaleResize(scaleX, scaleY, resize !== true, boundsType);
4880
4883
  }
4881
4884
  },
4882
4885
  rotateOfWorld(t, origin, angle, transition) {
@@ -4900,18 +4903,18 @@ const LeafHelper = {
4900
4903
  skewOfOuter(matrix, origin, skewX, skewY);
4901
4904
  L.setTransform(t, matrix, resize, transition);
4902
4905
  },
4903
- transformWorld(t, transform, resize, transition) {
4906
+ transformWorld(t, transform, resize, transition, boundsType) {
4904
4907
  copy$3(matrix, t.worldTransform);
4905
4908
  multiplyParent$2(matrix, transform);
4906
4909
  if (t.parent) divideParent(matrix, t.parent.scrollWorldTransform);
4907
- L.setTransform(t, matrix, resize, transition);
4910
+ L.setTransform(t, matrix, resize, transition, boundsType);
4908
4911
  },
4909
- transform(t, transform, resize, transition) {
4912
+ transform(t, transform, resize, transition, boundsType) {
4910
4913
  copy$3(matrix, t.localTransform);
4911
4914
  multiplyParent$2(matrix, transform);
4912
- L.setTransform(t, matrix, resize, transition);
4915
+ L.setTransform(t, matrix, resize, transition, boundsType);
4913
4916
  },
4914
- setTransform(t, transform, resize, transition) {
4917
+ setTransform(t, transform, resize, transition, boundsType) {
4915
4918
  const data = t.__, originPoint = data.origin && L.getInnerOrigin(t, data.origin);
4916
4919
  const layout = getLayout(transform, originPoint, data.around && L.getInnerOrigin(t, data.around));
4917
4920
  if (L.hasOffset(t)) {
@@ -4927,7 +4930,7 @@ const LeafHelper = {
4927
4930
  PointHelper.move(layout, originPoint.x - changedPoint.x, originPoint.y - changedPoint.y);
4928
4931
  }
4929
4932
  t.set(layout);
4930
- t.scaleResize(scaleX, scaleY, false);
4933
+ t.scaleResize(scaleX, scaleY, false, boundsType);
4931
4934
  } else t.set(layout, transition);
4932
4935
  },
4933
4936
  getFlipTransform(t, axis) {
@@ -5509,6 +5512,7 @@ class LeafLayout {
5509
5512
  this.renderChanged = true;
5510
5513
  this.renderSpread || (this.renderSpread = 1);
5511
5514
  this.boundsChanged = true;
5515
+ this.hitCanvasChanged = true;
5512
5516
  }
5513
5517
  scaleChange() {
5514
5518
  this.scaleChanged = true;
@@ -6449,10 +6453,6 @@ let Leaf = class Leaf {
6449
6453
  }
6450
6454
  }
6451
6455
  }
6452
- set(_data, _isTemp) {}
6453
- get(_name) {
6454
- return undefined;
6455
- }
6456
6456
  setAttr(name, value) {
6457
6457
  this[name] = value;
6458
6458
  }
@@ -6469,37 +6469,10 @@ let Leaf = class Leaf {
6469
6469
  toString(options) {
6470
6470
  return JSON.stringify(this.toJSON(options));
6471
6471
  }
6472
- toSVG() {
6473
- return undefined;
6474
- }
6475
- __SVG(_data) {}
6476
- toHTML() {
6477
- return undefined;
6478
- }
6479
- __setAttr(_attrName, _newValue) {
6480
- return true;
6481
- }
6482
- __getAttr(_attrName) {
6483
- return undefined;
6484
- }
6485
- setProxyAttr(_attrName, _newValue) {}
6486
- getProxyAttr(_attrName) {
6487
- return undefined;
6488
- }
6489
- find(_condition, _options) {
6490
- return undefined;
6491
- }
6492
- findTag(_tag) {
6493
- return undefined;
6494
- }
6495
- findOne(_condition, _options) {
6496
- return undefined;
6497
- }
6498
- findId(_id) {
6499
- return undefined;
6472
+ scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6473
+ this.scaleX *= scaleX;
6474
+ this.scaleY *= scaleY;
6500
6475
  }
6501
- focus(_value) {}
6502
- updateState() {}
6503
6476
  updateLayout() {
6504
6477
  this.__layout.update();
6505
6478
  }
@@ -6515,27 +6488,6 @@ let Leaf = class Leaf {
6515
6488
  __extraUpdate() {
6516
6489
  if (this.leaferIsReady) this.leafer.layouter.addExtra(this);
6517
6490
  }
6518
- __updateWorldMatrix() {}
6519
- __updateLocalMatrix() {}
6520
- __updateWorldBounds() {}
6521
- __updateLocalBounds() {}
6522
- __updateLocalBoxBounds() {}
6523
- __updateLocalStrokeBounds() {}
6524
- __updateLocalRenderBounds() {}
6525
- __updateBoxBounds(_secondLayout, _bounds) {}
6526
- __updateContentBounds() {}
6527
- __updateStrokeBounds(_bounds) {}
6528
- __updateRenderBounds(_bounds) {}
6529
- __updateAutoLayout() {}
6530
- __updateFlowLayout() {}
6531
- __updateNaturalSize() {}
6532
- __updateStrokeSpread() {
6533
- return 0;
6534
- }
6535
- __updateRenderSpread() {
6536
- return 0;
6537
- }
6538
- __onUpdateSize() {}
6539
6491
  __updateEraser(value) {
6540
6492
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
6541
6493
  }
@@ -6549,7 +6501,6 @@ let Leaf = class Leaf {
6549
6501
  __updateMask(_value) {
6550
6502
  this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6551
6503
  }
6552
- __renderMask(_canvas, _options) {}
6553
6504
  __getNowWorld(options) {
6554
6505
  if (options.matrix) {
6555
6506
  if (!this.__cameraWorld) this.__cameraWorld = {};
@@ -6666,11 +6617,11 @@ let Leaf = class Leaf {
6666
6617
  const layer = this.leafer ? this.leafer.zoomLayer : this;
6667
6618
  return layer.getWorldPoint(page, relative, distance, change);
6668
6619
  }
6669
- setTransform(matrix, resize, transition) {
6670
- setTransform(this, matrix, resize, transition);
6620
+ setTransform(matrix, resize, transition, boundsType) {
6621
+ setTransform(this, matrix, resize, transition, boundsType);
6671
6622
  }
6672
- transform(matrix, resize, transition) {
6673
- transform(this, matrix, resize, transition);
6623
+ transform(matrix, resize, transition, boundsType) {
6624
+ transform(this, matrix, resize, transition, boundsType);
6674
6625
  }
6675
6626
  move(x, y, transition) {
6676
6627
  moveLocal(this, x, y, transition);
@@ -6678,8 +6629,8 @@ let Leaf = class Leaf {
6678
6629
  moveInner(x, y, transition) {
6679
6630
  moveWorld(this, x, y, true, transition);
6680
6631
  }
6681
- scaleOf(origin, scaleX, scaleY, resize, transition) {
6682
- zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize, transition);
6632
+ scaleOf(origin, scaleX, scaleY, resize, transition, boundsType) {
6633
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize, transition, boundsType);
6683
6634
  }
6684
6635
  rotateOf(origin, rotation, transition) {
6685
6636
  rotateOfLocal(this, getLocalOrigin(this, origin), rotation, transition);
@@ -6687,14 +6638,14 @@ let Leaf = class Leaf {
6687
6638
  skewOf(origin, skewX, skewY, resize, transition) {
6688
6639
  skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize, transition);
6689
6640
  }
6690
- transformWorld(worldTransform, resize, transition) {
6691
- transformWorld(this, worldTransform, resize, transition);
6641
+ transformWorld(worldTransform, resize, transition, boundsType) {
6642
+ transformWorld(this, worldTransform, resize, transition, boundsType);
6692
6643
  }
6693
6644
  moveWorld(x, y, transition) {
6694
6645
  moveWorld(this, x, y, false, transition);
6695
6646
  }
6696
- scaleOfWorld(worldOrigin, scaleX, scaleY, resize, transition) {
6697
- zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize, transition);
6647
+ scaleOfWorld(worldOrigin, scaleX, scaleY, resize, transition, boundsType) {
6648
+ zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize, transition, boundsType);
6698
6649
  }
6699
6650
  rotateOfWorld(worldOrigin, rotation) {
6700
6651
  rotateOfWorld(this, worldOrigin, rotation);
@@ -6705,76 +6656,12 @@ let Leaf = class Leaf {
6705
6656
  flip(axis, transition) {
6706
6657
  transform(this, getFlipTransform(this, axis), false, transition);
6707
6658
  }
6708
- scaleResize(scaleX, scaleY = scaleX, _noResize) {
6709
- this.scaleX *= scaleX;
6710
- this.scaleY *= scaleY;
6711
- }
6712
- __scaleResize(_scaleX, _scaleY) {}
6713
- resizeWidth(_width) {}
6714
- resizeHeight(_height) {}
6715
- hit(_world, _hitRadius) {
6716
- return true;
6717
- }
6718
- __hitWorld(_point, _forceHitFill) {
6719
- return true;
6720
- }
6721
- __hit(_local, _forceHitFill) {
6722
- return true;
6723
- }
6724
- __hitFill(_inner) {
6725
- return true;
6726
- }
6727
- __hitStroke(_inner, _strokeWidth) {
6728
- return true;
6729
- }
6730
- __hitPixel(_inner) {
6731
- return true;
6732
- }
6733
- __drawHitPath(_canvas) {}
6734
- __updateHitCanvas() {}
6735
- __render(_canvas, _options) {}
6736
- __drawFast(_canvas, _options) {}
6737
- __draw(_canvas, _options, _originCanvas) {}
6738
- __clip(_canvas, _options) {}
6739
- __renderShape(_canvas, _options) {}
6740
- __drawShape(_canvas, _options) {}
6741
- __updateWorldOpacity() {}
6742
- __updateChange() {}
6743
- __drawPath(_canvas) {}
6744
- __drawRenderPath(_canvas) {}
6745
- __updatePath() {}
6746
- __updateRenderPath(_updateCache) {}
6747
- getMotionPathData() {
6748
- return Plugin.need("path");
6749
- }
6750
- getMotionPoint(_motionDistance) {
6751
- return Plugin.need("path");
6752
- }
6753
- getMotionTotal() {
6754
- return 0;
6755
- }
6756
- __updateMotionPath() {}
6757
- __runAnimation(_type, _complete) {}
6758
- __updateSortChildren() {}
6759
- add(_child, _index) {}
6760
6659
  remove(_child, destroy) {
6761
6660
  if (this.parent) this.parent.remove(this, destroy);
6762
6661
  }
6763
6662
  dropTo(parent, index, resize) {
6764
6663
  drop(this, parent, index, resize);
6765
6664
  }
6766
- on(_type, _listener, _options) {}
6767
- off(_type, _listener, _options) {}
6768
- on_(_type, _listener, _bind, _options) {
6769
- return undefined;
6770
- }
6771
- off_(_id) {}
6772
- once(_type, _listener, _captureOrBind, _capture) {}
6773
- emit(_type, _event, _capture) {}
6774
- emitEvent(_event, _capture) {}
6775
- hasEvent(_type, _capture) {
6776
- return false;
6777
- }
6778
6665
  static changeAttr(attrName, defaultValue, fn) {
6779
6666
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
6780
6667
  }
@@ -7080,6 +6967,6 @@ class LeafLevelList {
7080
6967
  }
7081
6968
  }
7082
6969
 
7083
- const version = "2.1.3";
6970
+ const version = "2.1.5";
7084
6971
 
7085
6972
  export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, FourNumberHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, UnitConvertHelper, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };