@leafer/core 1.11.2 → 1.12.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
@@ -4049,16 +4049,27 @@ const ImageManager = {
4049
4049
  recycle(image) {
4050
4050
  image.use--;
4051
4051
  setTimeout(() => {
4052
- if (!image.use) I.recycledList.push(image);
4052
+ if (!image.use) {
4053
+ if (Platform.image.isLarge(image)) {
4054
+ if (image.url) Resource.remove(image.url);
4055
+ } else {
4056
+ image.clearLevels();
4057
+ I.recycledList.push(image);
4058
+ }
4059
+ }
4053
4060
  });
4054
4061
  },
4055
- clearRecycled() {
4062
+ recyclePaint(paint) {
4063
+ I.recycle(paint.image);
4064
+ },
4065
+ clearRecycled(force) {
4056
4066
  const list = I.recycledList;
4057
- if (list.length > I.maxRecycled) {
4058
- list.forEach(image => !image.use && image.url && Resource.remove(image.url));
4067
+ if (list.length > I.maxRecycled || force) {
4068
+ list.forEach(image => (!image.use || force) && image.url && Resource.remove(image.url));
4059
4069
  list.length = 0;
4060
4070
  }
4061
4071
  },
4072
+ clearLevels() {},
4062
4073
  hasAlphaPixel(config) {
4063
4074
  return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
4064
4075
  },
@@ -4073,7 +4084,7 @@ const ImageManager = {
4073
4084
  return false;
4074
4085
  },
4075
4086
  destroy() {
4076
- I.recycledList = [];
4087
+ this.clearRecycled(true);
4077
4088
  }
4078
4089
  };
4079
4090
 
@@ -4176,11 +4187,15 @@ class LeaferImage {
4176
4187
  Platform.image.setPatternTransform(pattern, transform, paint);
4177
4188
  return pattern;
4178
4189
  }
4190
+ clearLevels(_checkUse) {}
4179
4191
  destroy() {
4192
+ this.clearLevels();
4193
+ const {view: view} = this;
4194
+ if (view && view.close) view.close();
4180
4195
  this.config = {
4181
4196
  url: ""
4182
4197
  };
4183
- this.cache = null;
4198
+ this.cache = this.view = null;
4184
4199
  this.waitComplete.length = 0;
4185
4200
  }
4186
4201
  }
@@ -4929,10 +4944,53 @@ const BranchHelper = {
4929
4944
  if (exclude && exclude === branch) continue;
4930
4945
  updateBounds$2(branch);
4931
4946
  }
4947
+ },
4948
+ move(branch, x, y) {
4949
+ let w;
4950
+ const {children: children} = branch;
4951
+ for (let i = 0, len = children.length; i < len; i++) {
4952
+ branch = children[i];
4953
+ w = branch.__world;
4954
+ w.e += x;
4955
+ w.f += y;
4956
+ w.x += x;
4957
+ w.y += y;
4958
+ if (branch.isBranch) move$1(branch, x, y);
4959
+ }
4960
+ },
4961
+ scale(branch, x, y, scaleX, scaleY, a, b) {
4962
+ let w;
4963
+ const {children: children} = branch;
4964
+ const changeScaleX = scaleX - 1;
4965
+ const changeScaleY = scaleY - 1;
4966
+ for (let i = 0, len = children.length; i < len; i++) {
4967
+ branch = children[i];
4968
+ w = branch.__world;
4969
+ w.a *= scaleX;
4970
+ w.d *= scaleY;
4971
+ if (w.b || w.c) {
4972
+ w.b *= scaleX;
4973
+ w.c *= scaleY;
4974
+ }
4975
+ if (w.e === w.x && w.f === w.y) {
4976
+ w.x = w.e += (w.e - a) * changeScaleX + x;
4977
+ w.y = w.f += (w.f - b) * changeScaleY + y;
4978
+ } else {
4979
+ w.e += (w.e - a) * changeScaleX + x;
4980
+ w.f += (w.f - b) * changeScaleY + y;
4981
+ w.x += (w.x - a) * changeScaleX + x;
4982
+ w.y += (w.y - b) * changeScaleY + y;
4983
+ }
4984
+ w.width *= scaleX;
4985
+ w.height *= scaleY;
4986
+ w.scaleX *= scaleX;
4987
+ w.scaleY *= scaleY;
4988
+ if (branch.isBranch) scale(branch, x, y, scaleX, scaleY, a, b);
4989
+ }
4932
4990
  }
4933
4991
  };
4934
4992
 
4935
- const {pushAllChildBranch: pushAllChildBranch, pushAllBranchStack: pushAllBranchStack, updateBoundsByBranchStack: updateBoundsByBranchStack} = BranchHelper;
4993
+ const {pushAllChildBranch: pushAllChildBranch, pushAllBranchStack: pushAllBranchStack, updateBoundsByBranchStack: updateBoundsByBranchStack, move: move$1, scale: scale} = BranchHelper;
4936
4994
 
4937
4995
  const WaitHelper = {
4938
4996
  run(wait) {
@@ -5959,6 +6017,7 @@ const LeafBounds = {
5959
6017
  const LeafRender = {
5960
6018
  __render(canvas, options) {
5961
6019
  if (options.shape) return this.__renderShape(canvas, options);
6020
+ if (options.cellList && !options.cellList.has(this)) return;
5962
6021
  if (this.__worldOpacity) {
5963
6022
  const data = this.__;
5964
6023
  if (data.bright && !options.topRendering) return options.topList.add(this);
@@ -6495,10 +6554,10 @@ exports.Leaf = class Leaf {
6495
6554
  hit(_world, _hitRadius) {
6496
6555
  return true;
6497
6556
  }
6498
- __hitWorld(_point) {
6557
+ __hitWorld(_point, _forceHitFill) {
6499
6558
  return true;
6500
6559
  }
6501
- __hit(_local) {
6560
+ __hit(_local, _forceHitFill) {
6502
6561
  return true;
6503
6562
  }
6504
6563
  __hitFill(_inner) {
@@ -6857,7 +6916,7 @@ class LeafLevelList {
6857
6916
  }
6858
6917
  }
6859
6918
 
6860
- const version = "1.11.2";
6919
+ const version = "1.12.1";
6861
6920
 
6862
6921
  exports.AlignHelper = AlignHelper;
6863
6922
 
package/lib/core.esm.js CHANGED
@@ -4047,16 +4047,27 @@ const ImageManager = {
4047
4047
  recycle(image) {
4048
4048
  image.use--;
4049
4049
  setTimeout(() => {
4050
- if (!image.use) I.recycledList.push(image);
4050
+ if (!image.use) {
4051
+ if (Platform.image.isLarge(image)) {
4052
+ if (image.url) Resource.remove(image.url);
4053
+ } else {
4054
+ image.clearLevels();
4055
+ I.recycledList.push(image);
4056
+ }
4057
+ }
4051
4058
  });
4052
4059
  },
4053
- clearRecycled() {
4060
+ recyclePaint(paint) {
4061
+ I.recycle(paint.image);
4062
+ },
4063
+ clearRecycled(force) {
4054
4064
  const list = I.recycledList;
4055
- if (list.length > I.maxRecycled) {
4056
- list.forEach(image => !image.use && image.url && Resource.remove(image.url));
4065
+ if (list.length > I.maxRecycled || force) {
4066
+ list.forEach(image => (!image.use || force) && image.url && Resource.remove(image.url));
4057
4067
  list.length = 0;
4058
4068
  }
4059
4069
  },
4070
+ clearLevels() {},
4060
4071
  hasAlphaPixel(config) {
4061
4072
  return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
4062
4073
  },
@@ -4071,7 +4082,7 @@ const ImageManager = {
4071
4082
  return false;
4072
4083
  },
4073
4084
  destroy() {
4074
- I.recycledList = [];
4085
+ this.clearRecycled(true);
4075
4086
  }
4076
4087
  };
4077
4088
 
@@ -4174,11 +4185,15 @@ class LeaferImage {
4174
4185
  Platform.image.setPatternTransform(pattern, transform, paint);
4175
4186
  return pattern;
4176
4187
  }
4188
+ clearLevels(_checkUse) {}
4177
4189
  destroy() {
4190
+ this.clearLevels();
4191
+ const {view: view} = this;
4192
+ if (view && view.close) view.close();
4178
4193
  this.config = {
4179
4194
  url: ""
4180
4195
  };
4181
- this.cache = null;
4196
+ this.cache = this.view = null;
4182
4197
  this.waitComplete.length = 0;
4183
4198
  }
4184
4199
  }
@@ -4927,10 +4942,53 @@ const BranchHelper = {
4927
4942
  if (exclude && exclude === branch) continue;
4928
4943
  updateBounds$2(branch);
4929
4944
  }
4945
+ },
4946
+ move(branch, x, y) {
4947
+ let w;
4948
+ const {children: children} = branch;
4949
+ for (let i = 0, len = children.length; i < len; i++) {
4950
+ branch = children[i];
4951
+ w = branch.__world;
4952
+ w.e += x;
4953
+ w.f += y;
4954
+ w.x += x;
4955
+ w.y += y;
4956
+ if (branch.isBranch) move$1(branch, x, y);
4957
+ }
4958
+ },
4959
+ scale(branch, x, y, scaleX, scaleY, a, b) {
4960
+ let w;
4961
+ const {children: children} = branch;
4962
+ const changeScaleX = scaleX - 1;
4963
+ const changeScaleY = scaleY - 1;
4964
+ for (let i = 0, len = children.length; i < len; i++) {
4965
+ branch = children[i];
4966
+ w = branch.__world;
4967
+ w.a *= scaleX;
4968
+ w.d *= scaleY;
4969
+ if (w.b || w.c) {
4970
+ w.b *= scaleX;
4971
+ w.c *= scaleY;
4972
+ }
4973
+ if (w.e === w.x && w.f === w.y) {
4974
+ w.x = w.e += (w.e - a) * changeScaleX + x;
4975
+ w.y = w.f += (w.f - b) * changeScaleY + y;
4976
+ } else {
4977
+ w.e += (w.e - a) * changeScaleX + x;
4978
+ w.f += (w.f - b) * changeScaleY + y;
4979
+ w.x += (w.x - a) * changeScaleX + x;
4980
+ w.y += (w.y - b) * changeScaleY + y;
4981
+ }
4982
+ w.width *= scaleX;
4983
+ w.height *= scaleY;
4984
+ w.scaleX *= scaleX;
4985
+ w.scaleY *= scaleY;
4986
+ if (branch.isBranch) scale(branch, x, y, scaleX, scaleY, a, b);
4987
+ }
4930
4988
  }
4931
4989
  };
4932
4990
 
4933
- const {pushAllChildBranch: pushAllChildBranch, pushAllBranchStack: pushAllBranchStack, updateBoundsByBranchStack: updateBoundsByBranchStack} = BranchHelper;
4991
+ const {pushAllChildBranch: pushAllChildBranch, pushAllBranchStack: pushAllBranchStack, updateBoundsByBranchStack: updateBoundsByBranchStack, move: move$1, scale: scale} = BranchHelper;
4934
4992
 
4935
4993
  const WaitHelper = {
4936
4994
  run(wait) {
@@ -5957,6 +6015,7 @@ const LeafBounds = {
5957
6015
  const LeafRender = {
5958
6016
  __render(canvas, options) {
5959
6017
  if (options.shape) return this.__renderShape(canvas, options);
6018
+ if (options.cellList && !options.cellList.has(this)) return;
5960
6019
  if (this.__worldOpacity) {
5961
6020
  const data = this.__;
5962
6021
  if (data.bright && !options.topRendering) return options.topList.add(this);
@@ -6493,10 +6552,10 @@ let Leaf = class Leaf {
6493
6552
  hit(_world, _hitRadius) {
6494
6553
  return true;
6495
6554
  }
6496
- __hitWorld(_point) {
6555
+ __hitWorld(_point, _forceHitFill) {
6497
6556
  return true;
6498
6557
  }
6499
- __hit(_local) {
6558
+ __hit(_local, _forceHitFill) {
6500
6559
  return true;
6501
6560
  }
6502
6561
  __hitFill(_inner) {
@@ -6855,6 +6914,6 @@ class LeafLevelList {
6855
6914
  }
6856
6915
  }
6857
6916
 
6858
- const version = "1.11.2";
6917
+ const version = "1.12.1";
6859
6918
 
6860
6919
  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, LeaferImage, 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, 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 };