@leafer/core 2.1.4 → 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) {
@@ -5512,6 +5514,7 @@ class LeafLayout {
5512
5514
  this.renderChanged = true;
5513
5515
  this.renderSpread || (this.renderSpread = 1);
5514
5516
  this.boundsChanged = true;
5517
+ this.hitCanvasChanged = true;
5515
5518
  }
5516
5519
  scaleChange() {
5517
5520
  this.scaleChanged = true;
@@ -6452,10 +6455,6 @@ exports.Leaf = class Leaf {
6452
6455
  }
6453
6456
  }
6454
6457
  }
6455
- set(_data, _isTemp) {}
6456
- get(_name) {
6457
- return undefined;
6458
- }
6459
6458
  setAttr(name, value) {
6460
6459
  this[name] = value;
6461
6460
  }
@@ -6472,37 +6471,10 @@ exports.Leaf = class Leaf {
6472
6471
  toString(options) {
6473
6472
  return JSON.stringify(this.toJSON(options));
6474
6473
  }
6475
- toSVG() {
6476
- return undefined;
6477
- }
6478
- __SVG(_data) {}
6479
- toHTML() {
6480
- return undefined;
6481
- }
6482
- __setAttr(_attrName, _newValue) {
6483
- return true;
6484
- }
6485
- __getAttr(_attrName) {
6486
- return undefined;
6487
- }
6488
- setProxyAttr(_attrName, _newValue) {}
6489
- getProxyAttr(_attrName) {
6490
- return undefined;
6491
- }
6492
- find(_condition, _options) {
6493
- return undefined;
6494
- }
6495
- findTag(_tag) {
6496
- return undefined;
6497
- }
6498
- findOne(_condition, _options) {
6499
- return undefined;
6500
- }
6501
- findId(_id) {
6502
- return undefined;
6474
+ scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6475
+ this.scaleX *= scaleX;
6476
+ this.scaleY *= scaleY;
6503
6477
  }
6504
- focus(_value) {}
6505
- updateState() {}
6506
6478
  updateLayout() {
6507
6479
  this.__layout.update();
6508
6480
  }
@@ -6518,27 +6490,6 @@ exports.Leaf = class Leaf {
6518
6490
  __extraUpdate() {
6519
6491
  if (this.leaferIsReady) this.leafer.layouter.addExtra(this);
6520
6492
  }
6521
- __updateWorldMatrix() {}
6522
- __updateLocalMatrix() {}
6523
- __updateWorldBounds() {}
6524
- __updateLocalBounds() {}
6525
- __updateLocalBoxBounds() {}
6526
- __updateLocalStrokeBounds() {}
6527
- __updateLocalRenderBounds() {}
6528
- __updateBoxBounds(_secondLayout, _bounds) {}
6529
- __updateContentBounds() {}
6530
- __updateStrokeBounds(_bounds) {}
6531
- __updateRenderBounds(_bounds) {}
6532
- __updateAutoLayout() {}
6533
- __updateFlowLayout() {}
6534
- __updateNaturalSize() {}
6535
- __updateStrokeSpread() {
6536
- return 0;
6537
- }
6538
- __updateRenderSpread() {
6539
- return 0;
6540
- }
6541
- __onUpdateSize() {}
6542
6493
  __updateEraser(value) {
6543
6494
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
6544
6495
  }
@@ -6552,7 +6503,6 @@ exports.Leaf = class Leaf {
6552
6503
  __updateMask(_value) {
6553
6504
  this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6554
6505
  }
6555
- __renderMask(_canvas, _options) {}
6556
6506
  __getNowWorld(options) {
6557
6507
  if (options.matrix) {
6558
6508
  if (!this.__cameraWorld) this.__cameraWorld = {};
@@ -6708,76 +6658,12 @@ exports.Leaf = class Leaf {
6708
6658
  flip(axis, transition) {
6709
6659
  transform(this, getFlipTransform(this, axis), false, transition);
6710
6660
  }
6711
- scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6712
- this.scaleX *= scaleX;
6713
- this.scaleY *= scaleY;
6714
- }
6715
- __scaleResize(_scaleX, _scaleY) {}
6716
- resizeWidth(_width) {}
6717
- resizeHeight(_height) {}
6718
- hit(_world, _hitRadius) {
6719
- return true;
6720
- }
6721
- __hitWorld(_point, _forceHitFill) {
6722
- return true;
6723
- }
6724
- __hit(_local, _forceHitFill) {
6725
- return true;
6726
- }
6727
- __hitFill(_inner) {
6728
- return true;
6729
- }
6730
- __hitStroke(_inner, _strokeWidth) {
6731
- return true;
6732
- }
6733
- __hitPixel(_inner) {
6734
- return true;
6735
- }
6736
- __drawHitPath(_canvas) {}
6737
- __updateHitCanvas() {}
6738
- __render(_canvas, _options) {}
6739
- __drawFast(_canvas, _options) {}
6740
- __draw(_canvas, _options, _originCanvas) {}
6741
- __clip(_canvas, _options) {}
6742
- __renderShape(_canvas, _options) {}
6743
- __drawShape(_canvas, _options) {}
6744
- __updateWorldOpacity() {}
6745
- __updateChange() {}
6746
- __drawPath(_canvas) {}
6747
- __drawRenderPath(_canvas) {}
6748
- __updatePath() {}
6749
- __updateRenderPath(_updateCache) {}
6750
- getMotionPathData() {
6751
- return Plugin.need("path");
6752
- }
6753
- getMotionPoint(_motionDistance) {
6754
- return Plugin.need("path");
6755
- }
6756
- getMotionTotal() {
6757
- return 0;
6758
- }
6759
- __updateMotionPath() {}
6760
- __runAnimation(_type, _complete) {}
6761
- __updateSortChildren() {}
6762
- add(_child, _index) {}
6763
6661
  remove(_child, destroy) {
6764
6662
  if (this.parent) this.parent.remove(this, destroy);
6765
6663
  }
6766
6664
  dropTo(parent, index, resize) {
6767
6665
  drop(this, parent, index, resize);
6768
6666
  }
6769
- on(_type, _listener, _options) {}
6770
- off(_type, _listener, _options) {}
6771
- on_(_type, _listener, _bind, _options) {
6772
- return undefined;
6773
- }
6774
- off_(_id) {}
6775
- once(_type, _listener, _captureOrBind, _capture) {}
6776
- emit(_type, _event, _capture) {}
6777
- emitEvent(_event, _capture) {}
6778
- hasEvent(_type, _capture) {
6779
- return false;
6780
- }
6781
6667
  static changeAttr(attrName, defaultValue, fn) {
6782
6668
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
6783
6669
  }
@@ -7083,7 +6969,7 @@ class LeafLevelList {
7083
6969
  }
7084
6970
  }
7085
6971
 
7086
- const version = "2.1.4";
6972
+ const version = "2.1.5";
7087
6973
 
7088
6974
  exports.AlignHelper = AlignHelper;
7089
6975
 
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) {
@@ -5510,6 +5512,7 @@ class LeafLayout {
5510
5512
  this.renderChanged = true;
5511
5513
  this.renderSpread || (this.renderSpread = 1);
5512
5514
  this.boundsChanged = true;
5515
+ this.hitCanvasChanged = true;
5513
5516
  }
5514
5517
  scaleChange() {
5515
5518
  this.scaleChanged = true;
@@ -6450,10 +6453,6 @@ let Leaf = class Leaf {
6450
6453
  }
6451
6454
  }
6452
6455
  }
6453
- set(_data, _isTemp) {}
6454
- get(_name) {
6455
- return undefined;
6456
- }
6457
6456
  setAttr(name, value) {
6458
6457
  this[name] = value;
6459
6458
  }
@@ -6470,37 +6469,10 @@ let Leaf = class Leaf {
6470
6469
  toString(options) {
6471
6470
  return JSON.stringify(this.toJSON(options));
6472
6471
  }
6473
- toSVG() {
6474
- return undefined;
6475
- }
6476
- __SVG(_data) {}
6477
- toHTML() {
6478
- return undefined;
6479
- }
6480
- __setAttr(_attrName, _newValue) {
6481
- return true;
6482
- }
6483
- __getAttr(_attrName) {
6484
- return undefined;
6485
- }
6486
- setProxyAttr(_attrName, _newValue) {}
6487
- getProxyAttr(_attrName) {
6488
- return undefined;
6489
- }
6490
- find(_condition, _options) {
6491
- return undefined;
6492
- }
6493
- findTag(_tag) {
6494
- return undefined;
6495
- }
6496
- findOne(_condition, _options) {
6497
- return undefined;
6498
- }
6499
- findId(_id) {
6500
- return undefined;
6472
+ scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6473
+ this.scaleX *= scaleX;
6474
+ this.scaleY *= scaleY;
6501
6475
  }
6502
- focus(_value) {}
6503
- updateState() {}
6504
6476
  updateLayout() {
6505
6477
  this.__layout.update();
6506
6478
  }
@@ -6516,27 +6488,6 @@ let Leaf = class Leaf {
6516
6488
  __extraUpdate() {
6517
6489
  if (this.leaferIsReady) this.leafer.layouter.addExtra(this);
6518
6490
  }
6519
- __updateWorldMatrix() {}
6520
- __updateLocalMatrix() {}
6521
- __updateWorldBounds() {}
6522
- __updateLocalBounds() {}
6523
- __updateLocalBoxBounds() {}
6524
- __updateLocalStrokeBounds() {}
6525
- __updateLocalRenderBounds() {}
6526
- __updateBoxBounds(_secondLayout, _bounds) {}
6527
- __updateContentBounds() {}
6528
- __updateStrokeBounds(_bounds) {}
6529
- __updateRenderBounds(_bounds) {}
6530
- __updateAutoLayout() {}
6531
- __updateFlowLayout() {}
6532
- __updateNaturalSize() {}
6533
- __updateStrokeSpread() {
6534
- return 0;
6535
- }
6536
- __updateRenderSpread() {
6537
- return 0;
6538
- }
6539
- __onUpdateSize() {}
6540
6491
  __updateEraser(value) {
6541
6492
  this.__hasEraser = value ? true : this.children.some(item => item.__.eraser);
6542
6493
  }
@@ -6550,7 +6501,6 @@ let Leaf = class Leaf {
6550
6501
  __updateMask(_value) {
6551
6502
  this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6552
6503
  }
6553
- __renderMask(_canvas, _options) {}
6554
6504
  __getNowWorld(options) {
6555
6505
  if (options.matrix) {
6556
6506
  if (!this.__cameraWorld) this.__cameraWorld = {};
@@ -6706,76 +6656,12 @@ let Leaf = class Leaf {
6706
6656
  flip(axis, transition) {
6707
6657
  transform(this, getFlipTransform(this, axis), false, transition);
6708
6658
  }
6709
- scaleResize(scaleX, scaleY = scaleX, _noResize, _boundsType) {
6710
- this.scaleX *= scaleX;
6711
- this.scaleY *= scaleY;
6712
- }
6713
- __scaleResize(_scaleX, _scaleY) {}
6714
- resizeWidth(_width) {}
6715
- resizeHeight(_height) {}
6716
- hit(_world, _hitRadius) {
6717
- return true;
6718
- }
6719
- __hitWorld(_point, _forceHitFill) {
6720
- return true;
6721
- }
6722
- __hit(_local, _forceHitFill) {
6723
- return true;
6724
- }
6725
- __hitFill(_inner) {
6726
- return true;
6727
- }
6728
- __hitStroke(_inner, _strokeWidth) {
6729
- return true;
6730
- }
6731
- __hitPixel(_inner) {
6732
- return true;
6733
- }
6734
- __drawHitPath(_canvas) {}
6735
- __updateHitCanvas() {}
6736
- __render(_canvas, _options) {}
6737
- __drawFast(_canvas, _options) {}
6738
- __draw(_canvas, _options, _originCanvas) {}
6739
- __clip(_canvas, _options) {}
6740
- __renderShape(_canvas, _options) {}
6741
- __drawShape(_canvas, _options) {}
6742
- __updateWorldOpacity() {}
6743
- __updateChange() {}
6744
- __drawPath(_canvas) {}
6745
- __drawRenderPath(_canvas) {}
6746
- __updatePath() {}
6747
- __updateRenderPath(_updateCache) {}
6748
- getMotionPathData() {
6749
- return Plugin.need("path");
6750
- }
6751
- getMotionPoint(_motionDistance) {
6752
- return Plugin.need("path");
6753
- }
6754
- getMotionTotal() {
6755
- return 0;
6756
- }
6757
- __updateMotionPath() {}
6758
- __runAnimation(_type, _complete) {}
6759
- __updateSortChildren() {}
6760
- add(_child, _index) {}
6761
6659
  remove(_child, destroy) {
6762
6660
  if (this.parent) this.parent.remove(this, destroy);
6763
6661
  }
6764
6662
  dropTo(parent, index, resize) {
6765
6663
  drop(this, parent, index, resize);
6766
6664
  }
6767
- on(_type, _listener, _options) {}
6768
- off(_type, _listener, _options) {}
6769
- on_(_type, _listener, _bind, _options) {
6770
- return undefined;
6771
- }
6772
- off_(_id) {}
6773
- once(_type, _listener, _captureOrBind, _capture) {}
6774
- emit(_type, _event, _capture) {}
6775
- emitEvent(_event, _capture) {}
6776
- hasEvent(_type, _capture) {
6777
- return false;
6778
- }
6779
6665
  static changeAttr(attrName, defaultValue, fn) {
6780
6666
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
6781
6667
  }
@@ -7081,6 +6967,6 @@ class LeafLevelList {
7081
6967
  }
7082
6968
  }
7083
6969
 
7084
- const version = "2.1.4";
6970
+ const version = "2.1.5";
7085
6971
 
7086
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 };