@leafer-draw/worker 1.11.2 → 1.12.0

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.
@@ -4056,16 +4056,27 @@ const ImageManager = {
4056
4056
  recycle(image) {
4057
4057
  image.use--;
4058
4058
  setTimeout(() => {
4059
- if (!image.use) I.recycledList.push(image);
4059
+ if (!image.use) {
4060
+ if (Platform.image.isLarge(image)) {
4061
+ if (image.url) Resource.remove(image.url);
4062
+ } else {
4063
+ image.clearLevels();
4064
+ I.recycledList.push(image);
4065
+ }
4066
+ }
4060
4067
  });
4061
4068
  },
4062
- clearRecycled() {
4069
+ recyclePaint(paint) {
4070
+ I.recycle(paint.image);
4071
+ },
4072
+ clearRecycled(force) {
4063
4073
  const list = I.recycledList;
4064
- if (list.length > I.maxRecycled) {
4065
- list.forEach(image => !image.use && image.url && Resource.remove(image.url));
4074
+ if (list.length > I.maxRecycled || force) {
4075
+ list.forEach(image => (!image.use || force) && image.url && Resource.remove(image.url));
4066
4076
  list.length = 0;
4067
4077
  }
4068
4078
  },
4079
+ clearLevels() {},
4069
4080
  hasAlphaPixel(config) {
4070
4081
  return FileHelper.alphaPixelTypes.some(item => I.isFormat(item, config));
4071
4082
  },
@@ -4080,7 +4091,7 @@ const ImageManager = {
4080
4091
  return false;
4081
4092
  },
4082
4093
  destroy() {
4083
- I.recycledList = [];
4094
+ this.clearRecycled(true);
4084
4095
  }
4085
4096
  };
4086
4097
 
@@ -4183,11 +4194,15 @@ class LeaferImage {
4183
4194
  Platform.image.setPatternTransform(pattern, transform, paint);
4184
4195
  return pattern;
4185
4196
  }
4197
+ clearLevels(_checkUse) {}
4186
4198
  destroy() {
4199
+ this.clearLevels();
4200
+ const {view: view} = this;
4201
+ if (view && view.close) view.close();
4187
4202
  this.config = {
4188
4203
  url: ""
4189
4204
  };
4190
- this.cache = null;
4205
+ this.cache = this.view = null;
4191
4206
  this.waitComplete.length = 0;
4192
4207
  }
4193
4208
  }
@@ -5966,6 +5981,7 @@ const LeafBounds = {
5966
5981
  const LeafRender = {
5967
5982
  __render(canvas, options) {
5968
5983
  if (options.shape) return this.__renderShape(canvas, options);
5984
+ if (options.cellList && !options.cellList.has(this)) return;
5969
5985
  if (this.__worldOpacity) {
5970
5986
  const data = this.__;
5971
5987
  if (data.bright && !options.topRendering) return options.topList.add(this);
@@ -6864,7 +6880,7 @@ class LeafLevelList {
6864
6880
  }
6865
6881
  }
6866
6882
 
6867
- const version = "1.11.2";
6883
+ const version = "1.12.0";
6868
6884
 
6869
6885
  class LeaferCanvas extends LeaferCanvasBase {
6870
6886
  get allowBackgroundColor() {
@@ -6981,7 +6997,7 @@ class Watcher {
6981
6997
  return this.hasAdd || this.hasRemove || this.hasVisible;
6982
6998
  }
6983
6999
  get updatedList() {
6984
- if (this.hasRemove) {
7000
+ if (this.hasRemove && this.config.usePartLayout) {
6985
7001
  const updatedList = new LeafList;
6986
7002
  this.__updatedList.list.forEach(item => {
6987
7003
  if (item.leafer) updatedList.add(item);
@@ -7016,16 +7032,18 @@ class Watcher {
7016
7032
  if (this.running) this.target.emit(RenderEvent.REQUEST);
7017
7033
  }
7018
7034
  __onAttrChange(event) {
7019
- this.__updatedList.add(event.target);
7035
+ if (this.config.usePartLayout) this.__updatedList.add(event.target);
7020
7036
  this.update();
7021
7037
  }
7022
7038
  __onChildEvent(event) {
7023
- if (event.type === ChildEvent.ADD) {
7024
- this.hasAdd = true;
7025
- this.__pushChild(event.child);
7026
- } else {
7027
- this.hasRemove = true;
7028
- this.__updatedList.add(event.parent);
7039
+ if (this.config.usePartLayout) {
7040
+ if (event.type === ChildEvent.ADD) {
7041
+ this.hasAdd = true;
7042
+ this.__pushChild(event.child);
7043
+ } else {
7044
+ this.hasRemove = true;
7045
+ this.__updatedList.add(event.parent);
7046
+ }
7029
7047
  }
7030
7048
  this.update();
7031
7049
  }
@@ -7142,7 +7160,9 @@ const debug$3 = Debug.get("Layouter");
7142
7160
  class Layouter {
7143
7161
  constructor(target, userConfig) {
7144
7162
  this.totalTimes = 0;
7145
- this.config = {};
7163
+ this.config = {
7164
+ usePartLayout: true
7165
+ };
7146
7166
  this.__levelList = new LeafLevelList;
7147
7167
  this.target = target;
7148
7168
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -7187,7 +7207,7 @@ class Layouter {
7187
7207
  this.totalTimes++;
7188
7208
  this.layouting = true;
7189
7209
  this.target.emit(WatchEvent.REQUEST);
7190
- if (this.totalTimes > 1) {
7210
+ if (this.totalTimes > 1 && this.config.usePartLayout) {
7191
7211
  this.partLayout();
7192
7212
  } else {
7193
7213
  this.fullLayout();
@@ -7304,7 +7324,7 @@ class Renderer {
7304
7324
  }
7305
7325
  update(change = true) {
7306
7326
  if (!this.changed) this.changed = change;
7307
- this.__requestRender();
7327
+ if (!this.requestTime) this.__requestRender();
7308
7328
  }
7309
7329
  requestLayout() {
7310
7330
  this.target.emit(LayoutEvent.REQUEST);
@@ -7411,7 +7431,7 @@ class Renderer {
7411
7431
  Run.end(t);
7412
7432
  }
7413
7433
  __render(bounds, realBounds) {
7414
- const {canvas: canvas} = this, includes = bounds.includes(this.target.__world), options = includes ? {
7434
+ const {canvas: canvas, target: target} = this, includes = bounds.includes(target.__world), options = includes ? {
7415
7435
  includes: includes
7416
7436
  } : {
7417
7437
  bounds: bounds,
@@ -7419,12 +7439,16 @@ class Renderer {
7419
7439
  };
7420
7440
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
7421
7441
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
7422
- Platform.render(this.target, canvas, options);
7442
+ if (this.config.useCellRender) options.cellList = this.getCellList();
7443
+ Platform.render(target, canvas, options);
7423
7444
  this.renderBounds = realBounds = realBounds || bounds;
7424
7445
  this.renderOptions = options;
7425
7446
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
7426
7447
  canvas.updateRender(realBounds);
7427
7448
  }
7449
+ getCellList() {
7450
+ return undefined;
7451
+ }
7428
7452
  addBlock(block) {
7429
7453
  if (!this.updateBlocks) this.updateBlocks = [];
7430
7454
  this.updateBlocks.push(block);
@@ -7885,6 +7909,11 @@ class TextData extends UIData {
7885
7909
  }
7886
7910
  this._boxStyle = value;
7887
7911
  }
7912
+ __getInputData(names, options) {
7913
+ const data = super.__getInputData(names, options);
7914
+ if (data.textEditing) delete data.textEditing;
7915
+ return data;
7916
+ }
7888
7917
  }
7889
7918
 
7890
7919
  class ImageData extends RectData {
@@ -9731,6 +9760,7 @@ function getLeafPaint(attrName, paint, ui) {
9731
9760
  const {boxBounds: boxBounds} = ui.__layout;
9732
9761
  switch (paint.type) {
9733
9762
  case "image":
9763
+ if (!paint.url) return undefined;
9734
9764
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9735
9765
  break;
9736
9766
 
@@ -10135,7 +10165,7 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10135
10165
  if (data.repeat) {
10136
10166
  drawImage = false;
10137
10167
  } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10138
- drawImage = Platform.image.isLarge(image, scaleX, scaleY);
10168
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
10139
10169
  }
10140
10170
  }
10141
10171
  if (drawImage) {
@@ -10194,7 +10224,7 @@ function recycleImage(attrName, data) {
10194
10224
  if (url) {
10195
10225
  if (!recycleMap) recycleMap = {};
10196
10226
  recycleMap[url] = true;
10197
- ImageManager.recycle(image);
10227
+ ImageManager.recyclePaint(paint);
10198
10228
  if (image.loading) {
10199
10229
  if (!input) {
10200
10230
  input = data.__input && data.__input[attrName] || [];