leafer-draw 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
  const debug$4 = Debug.get("LeaferCanvas");
6870
6886
 
@@ -7187,7 +7203,7 @@ class Watcher {
7187
7203
  return this.hasAdd || this.hasRemove || this.hasVisible;
7188
7204
  }
7189
7205
  get updatedList() {
7190
- if (this.hasRemove) {
7206
+ if (this.hasRemove && this.config.usePartLayout) {
7191
7207
  const updatedList = new LeafList;
7192
7208
  this.__updatedList.list.forEach(item => {
7193
7209
  if (item.leafer) updatedList.add(item);
@@ -7222,16 +7238,18 @@ class Watcher {
7222
7238
  if (this.running) this.target.emit(RenderEvent.REQUEST);
7223
7239
  }
7224
7240
  __onAttrChange(event) {
7225
- this.__updatedList.add(event.target);
7241
+ if (this.config.usePartLayout) this.__updatedList.add(event.target);
7226
7242
  this.update();
7227
7243
  }
7228
7244
  __onChildEvent(event) {
7229
- if (event.type === ChildEvent.ADD) {
7230
- this.hasAdd = true;
7231
- this.__pushChild(event.child);
7232
- } else {
7233
- this.hasRemove = true;
7234
- this.__updatedList.add(event.parent);
7245
+ if (this.config.usePartLayout) {
7246
+ if (event.type === ChildEvent.ADD) {
7247
+ this.hasAdd = true;
7248
+ this.__pushChild(event.child);
7249
+ } else {
7250
+ this.hasRemove = true;
7251
+ this.__updatedList.add(event.parent);
7252
+ }
7235
7253
  }
7236
7254
  this.update();
7237
7255
  }
@@ -7348,7 +7366,9 @@ const debug$3 = Debug.get("Layouter");
7348
7366
  class Layouter {
7349
7367
  constructor(target, userConfig) {
7350
7368
  this.totalTimes = 0;
7351
- this.config = {};
7369
+ this.config = {
7370
+ usePartLayout: true
7371
+ };
7352
7372
  this.__levelList = new LeafLevelList;
7353
7373
  this.target = target;
7354
7374
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -7393,7 +7413,7 @@ class Layouter {
7393
7413
  this.totalTimes++;
7394
7414
  this.layouting = true;
7395
7415
  this.target.emit(WatchEvent.REQUEST);
7396
- if (this.totalTimes > 1) {
7416
+ if (this.totalTimes > 1 && this.config.usePartLayout) {
7397
7417
  this.partLayout();
7398
7418
  } else {
7399
7419
  this.fullLayout();
@@ -7510,7 +7530,7 @@ class Renderer {
7510
7530
  }
7511
7531
  update(change = true) {
7512
7532
  if (!this.changed) this.changed = change;
7513
- this.__requestRender();
7533
+ if (!this.requestTime) this.__requestRender();
7514
7534
  }
7515
7535
  requestLayout() {
7516
7536
  this.target.emit(LayoutEvent.REQUEST);
@@ -7617,7 +7637,7 @@ class Renderer {
7617
7637
  Run.end(t);
7618
7638
  }
7619
7639
  __render(bounds, realBounds) {
7620
- const {canvas: canvas} = this, includes = bounds.includes(this.target.__world), options = includes ? {
7640
+ const {canvas: canvas, target: target} = this, includes = bounds.includes(target.__world), options = includes ? {
7621
7641
  includes: includes
7622
7642
  } : {
7623
7643
  bounds: bounds,
@@ -7625,12 +7645,16 @@ class Renderer {
7625
7645
  };
7626
7646
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
7627
7647
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
7628
- Platform.render(this.target, canvas, options);
7648
+ if (this.config.useCellRender) options.cellList = this.getCellList();
7649
+ Platform.render(target, canvas, options);
7629
7650
  this.renderBounds = realBounds = realBounds || bounds;
7630
7651
  this.renderOptions = options;
7631
7652
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
7632
7653
  canvas.updateRender(realBounds);
7633
7654
  }
7655
+ getCellList() {
7656
+ return undefined;
7657
+ }
7634
7658
  addBlock(block) {
7635
7659
  if (!this.updateBlocks) this.updateBlocks = [];
7636
7660
  this.updateBlocks.push(block);
@@ -8091,6 +8115,11 @@ class TextData extends UIData {
8091
8115
  }
8092
8116
  this._boxStyle = value;
8093
8117
  }
8118
+ __getInputData(names, options) {
8119
+ const data = super.__getInputData(names, options);
8120
+ if (data.textEditing) delete data.textEditing;
8121
+ return data;
8122
+ }
8094
8123
  }
8095
8124
 
8096
8125
  class ImageData extends RectData {
@@ -9937,6 +9966,7 @@ function getLeafPaint(attrName, paint, ui) {
9937
9966
  const {boxBounds: boxBounds} = ui.__layout;
9938
9967
  switch (paint.type) {
9939
9968
  case "image":
9969
+ if (!paint.url) return undefined;
9940
9970
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
9941
9971
  break;
9942
9972
 
@@ -10341,7 +10371,7 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
10341
10371
  if (data.repeat) {
10342
10372
  drawImage = false;
10343
10373
  } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
10344
- drawImage = Platform.image.isLarge(image, scaleX, scaleY);
10374
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
10345
10375
  }
10346
10376
  }
10347
10377
  if (drawImage) {
@@ -10400,7 +10430,7 @@ function recycleImage(attrName, data) {
10400
10430
  if (url) {
10401
10431
  if (!recycleMap) recycleMap = {};
10402
10432
  recycleMap[url] = true;
10403
- ImageManager.recycle(image);
10433
+ ImageManager.recyclePaint(paint);
10404
10434
  if (image.loading) {
10405
10435
  if (!input) {
10406
10436
  input = data.__input && data.__input[attrName] || [];