@leafer/core 1.12.4 → 2.0.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.
package/lib/core.cjs CHANGED
@@ -209,59 +209,6 @@ class LeafData {
209
209
  }
210
210
  }
211
211
 
212
- const {floor: floor$2, max: max$2} = Math;
213
-
214
- const Platform = {
215
- toURL(text, fileType) {
216
- let url = encodeURIComponent(text);
217
- if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
218
- return url;
219
- },
220
- image: {
221
- hitCanvasSize: 100,
222
- maxCacheSize: 2560 * 1600,
223
- maxPatternSize: 4096 * 2160,
224
- crossOrigin: "anonymous",
225
- isLarge(size, scaleX, scaleY, largeSize) {
226
- return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize);
227
- },
228
- isSuperLarge(size, scaleX, scaleY) {
229
- return image.isLarge(size, scaleX, scaleY, image.maxPatternSize);
230
- },
231
- getRealURL(url) {
232
- const {prefix: prefix, suffix: suffix} = Platform.image;
233
- if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
234
- if (prefix && url[0] === "/") url = prefix + url;
235
- return url;
236
- },
237
- resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
238
- const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
239
- const ctx = canvas.getContext("2d");
240
- if (opacity) ctx.globalAlpha = opacity;
241
- ctx.imageSmoothingEnabled = smooth === false ? false : true;
242
- if (image) {
243
- if (clip) {
244
- const scaleX = width / clip.width, scaleY = height / clip.height;
245
- ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
246
- ctx.drawImage(image, 0, 0, image.width, image.height);
247
- } else ctx.drawImage(image, 0, 0, width, height);
248
- }
249
- return canvas;
250
- },
251
- setPatternTransform(pattern, transform, paint) {
252
- try {
253
- if (transform && pattern.setTransform) {
254
- pattern.setTransform(transform);
255
- transform = undefined;
256
- }
257
- } catch (_a) {}
258
- if (paint) DataHelper.stintSet(paint, "transform", transform);
259
- }
260
- }
261
- };
262
-
263
- const {image: image} = Platform;
264
-
265
212
  const IncrementId = {
266
213
  RUNTIME: "runtime",
267
214
  LEAF: "leaf",
@@ -284,7 +231,7 @@ const I$1 = IncrementId;
284
231
 
285
232
  let tempA, tempB, tempTo;
286
233
 
287
- const {max: max$1} = Math, tempFour = [ 0, 0, 0, 0 ];
234
+ const {max: max$2} = Math, tempFour = [ 0, 0, 0, 0 ];
288
235
 
289
236
  const FourNumberHelper = {
290
237
  zero: [ ...tempFour ],
@@ -336,9 +283,9 @@ const FourNumberHelper = {
336
283
  return data;
337
284
  },
338
285
  max(t, other, change) {
339
- if (isNumber(t) && isNumber(other)) return max$1(t, other);
286
+ if (isNumber(t) && isNumber(other)) return max$2(t, other);
340
287
  toTempAB(t, other, change);
341
- return set$1(tempTo, max$1(tempA[0], tempB[0]), max$1(tempA[1], tempB[1]), max$1(tempA[2], tempB[2]), max$1(tempA[3], tempB[3]));
288
+ return set$1(tempTo, max$2(tempA[0], tempB[0]), max$2(tempA[1], tempB[1]), max$2(tempA[2], tempB[2]), max$2(tempA[3], tempB[3]));
342
289
  },
343
290
  add(t, other, change) {
344
291
  if (isNumber(t) && isNumber(other)) return t + other;
@@ -355,7 +302,7 @@ const FourNumberHelper = {
355
302
 
356
303
  const {set: set$1, get: get$1, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
357
304
 
358
- const {round: round$3, pow: pow$1, max: max, floor: floor$1, PI: PI$1} = Math;
305
+ const {round: round$3, pow: pow$1, max: max$1, floor: floor$2, PI: PI$1} = Math;
359
306
 
360
307
  const MathHelper = {
361
308
  within(value, min, max) {
@@ -409,7 +356,7 @@ const MathHelper = {
409
356
  }
410
357
  },
411
358
  getFloorScale(num, min = 1) {
412
- return max(floor$1(num), min) / num;
359
+ return max$1(floor$2(num), min) / num;
413
360
  },
414
361
  randInt: randInt,
415
362
  randColor(opacity) {
@@ -1254,7 +1201,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1254
1201
 
1255
1202
  const {float: float, fourNumber: fourNumber} = MathHelper;
1256
1203
 
1257
- const {floor: floor, ceil: ceil$1} = Math;
1204
+ const {floor: floor$1, ceil: ceil$1} = Math;
1258
1205
 
1259
1206
  let right, bottom, boundsRight, boundsBottom;
1260
1207
 
@@ -1411,8 +1358,8 @@ const BoundsHelper = {
1411
1358
  },
1412
1359
  ceil(t) {
1413
1360
  const {x: x, y: y} = t;
1414
- t.x = floor(t.x);
1415
- t.y = floor(t.y);
1361
+ t.x = floor$1(t.x);
1362
+ t.y = floor$1(t.y);
1416
1363
  t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1417
1364
  t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
1418
1365
  },
@@ -1544,6 +1491,9 @@ const BoundsHelper = {
1544
1491
  isEmpty(t) {
1545
1492
  return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0;
1546
1493
  },
1494
+ hasSize(t) {
1495
+ return t.width && t.height;
1496
+ },
1547
1497
  reset(t) {
1548
1498
  B.set(t);
1549
1499
  }
@@ -1720,6 +1670,12 @@ class AutoBounds {
1720
1670
  }
1721
1671
  }
1722
1672
 
1673
+ const UnitConvertHelper = {
1674
+ number(value, percentRefer) {
1675
+ return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
1676
+ }
1677
+ };
1678
+
1723
1679
  const StringNumberMap = {
1724
1680
  0: 1,
1725
1681
  1: 1,
@@ -1736,6 +1692,69 @@ const StringNumberMap = {
1736
1692
  E: 1
1737
1693
  };
1738
1694
 
1695
+ const {floor: floor, max: max} = Math;
1696
+
1697
+ const Platform = {
1698
+ toURL(text, fileType) {
1699
+ let url = encodeURIComponent(text);
1700
+ if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
1701
+ return url;
1702
+ },
1703
+ image: {
1704
+ hitCanvasSize: 100,
1705
+ maxCacheSize: 2560 * 1600,
1706
+ maxPatternSize: 4096 * 2160,
1707
+ crossOrigin: "anonymous",
1708
+ isLarge(size, scaleX, scaleY, largeSize) {
1709
+ return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize);
1710
+ },
1711
+ isSuperLarge(size, scaleX, scaleY) {
1712
+ return image.isLarge(size, scaleX, scaleY, image.maxPatternSize);
1713
+ },
1714
+ getRealURL(url) {
1715
+ const {prefix: prefix, suffix: suffix} = image;
1716
+ if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
1717
+ if (prefix && url[0] === "/") url = prefix + url;
1718
+ return url;
1719
+ },
1720
+ resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1721
+ const realWidth = max(floor(width + (xGap || 0)), 1), realHeight = max(floor(height + (yGap || 0)), 1);
1722
+ let interlaceX, interlaceY, interlaceOffset;
1723
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
1724
+ const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1725
+ const ctx = canvas.getContext("2d");
1726
+ if (opacity) ctx.globalAlpha = opacity;
1727
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
1728
+ if (image.canUse(view)) {
1729
+ if (clip) {
1730
+ const scaleX = width / clip.width, scaleY = height / clip.height;
1731
+ ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
1732
+ ctx.drawImage(view, 0, 0, view.width, view.height);
1733
+ } else ctx.drawImage(view, 0, 0, width, height);
1734
+ if (interlaceOffset) {
1735
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset - realWidth : realWidth, interlaceX ? realHeight : interlaceOffset - realHeight, realWidth, realHeight);
1736
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset : realWidth, interlaceX ? realHeight : interlaceOffset, realWidth, realHeight);
1737
+ }
1738
+ }
1739
+ return canvas;
1740
+ },
1741
+ canUse(view) {
1742
+ return view && view.width && !view.__closed;
1743
+ },
1744
+ setPatternTransform(pattern, transform, paint) {
1745
+ try {
1746
+ if (transform && pattern.setTransform) {
1747
+ pattern.setTransform(transform);
1748
+ transform = undefined;
1749
+ }
1750
+ } catch (_a) {}
1751
+ if (paint) DataHelper.stintSet(paint, "transform", transform);
1752
+ }
1753
+ }
1754
+ };
1755
+
1756
+ const {image: image} = Platform;
1757
+
1739
1758
  const {randColor: randColor} = MathHelper;
1740
1759
 
1741
1760
  class Debug {
@@ -3778,9 +3797,10 @@ class TaskItem {
3778
3797
  run() {
3779
3798
  return __awaiter(this, void 0, void 0, function*() {
3780
3799
  try {
3781
- if (this.isComplete) return;
3800
+ if (this.isComplete || this.runing) return;
3801
+ this.runing = true;
3782
3802
  if (this.canUse && !this.canUse()) return this.cancel();
3783
- if (this.task && this.parent.running) yield this.task();
3803
+ if (this.task) yield this.task();
3784
3804
  } catch (error) {
3785
3805
  debug$4.error(error);
3786
3806
  }
@@ -3896,7 +3916,7 @@ class TaskProcessor {
3896
3916
  stop() {
3897
3917
  this.isComplete = true;
3898
3918
  this.list.forEach(task => {
3899
- if (!task.isComplete) task.cancel();
3919
+ if (!task.isComplete) task.run();
3900
3920
  });
3901
3921
  this.pause();
3902
3922
  this.empty();
@@ -4186,7 +4206,7 @@ class LeaferImage {
4186
4206
  getFull(_filters) {
4187
4207
  return this.view;
4188
4208
  }
4189
- getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
4209
+ getCanvas(width, height, opacity, filters, xGap, yGap, smooth, interlace) {
4190
4210
  width || (width = this.width);
4191
4211
  height || (height = this.height);
4192
4212
  if (this.cache) {
@@ -4199,7 +4219,7 @@ class LeaferImage {
4199
4219
  }
4200
4220
  if (data) return data;
4201
4221
  }
4202
- const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
4222
+ const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters, interlace);
4203
4223
  this.cache = this.use > 1 ? {
4204
4224
  data: canvas,
4205
4225
  params: arguments
@@ -6091,7 +6111,7 @@ const LeafRender = {
6091
6111
  }
6092
6112
  };
6093
6113
 
6094
- const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
6114
+ const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
6095
6115
 
6096
6116
  const BranchRender = {
6097
6117
  __updateChange() {
@@ -6103,8 +6123,8 @@ const BranchRender = {
6103
6123
  this.__.__checkSingle();
6104
6124
  },
6105
6125
  __render(canvas, options) {
6106
- this.__nowWorld = this.__getNowWorld(options);
6107
- if (this.__worldOpacity) {
6126
+ const nowWorld = this.__nowWorld = this.__getNowWorld(options);
6127
+ if (this.__worldOpacity && hasSize(nowWorld)) {
6108
6128
  const data = this.__;
6109
6129
  if (data.__useDim) {
6110
6130
  if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
@@ -6113,7 +6133,6 @@ const BranchRender = {
6113
6133
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
6114
6134
  const tempCanvas = canvas.getSameCanvas(false, true);
6115
6135
  this.__renderBranch(tempCanvas, options);
6116
- const nowWorld = this.__nowWorld;
6117
6136
  canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
6118
6137
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
6119
6138
  tempCanvas.recycle(nowWorld);
@@ -6953,7 +6972,7 @@ class LeafLevelList {
6953
6972
  }
6954
6973
  }
6955
6974
 
6956
- const version = "1.12.4";
6975
+ const version = "2.0.0";
6957
6976
 
6958
6977
  exports.AlignHelper = AlignHelper;
6959
6978
 
@@ -7097,6 +7116,8 @@ exports.TwoPointBoundsHelper = TwoPointBoundsHelper;
7097
7116
 
7098
7117
  exports.UICreator = UICreator;
7099
7118
 
7119
+ exports.UnitConvertHelper = UnitConvertHelper;
7120
+
7100
7121
  exports.WaitHelper = WaitHelper;
7101
7122
 
7102
7123
  exports.WatchEvent = WatchEvent;
package/lib/core.esm.js CHANGED
@@ -207,59 +207,6 @@ class LeafData {
207
207
  }
208
208
  }
209
209
 
210
- const {floor: floor$2, max: max$2} = Math;
211
-
212
- const Platform = {
213
- toURL(text, fileType) {
214
- let url = encodeURIComponent(text);
215
- if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
216
- return url;
217
- },
218
- image: {
219
- hitCanvasSize: 100,
220
- maxCacheSize: 2560 * 1600,
221
- maxPatternSize: 4096 * 2160,
222
- crossOrigin: "anonymous",
223
- isLarge(size, scaleX, scaleY, largeSize) {
224
- return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize);
225
- },
226
- isSuperLarge(size, scaleX, scaleY) {
227
- return image.isLarge(size, scaleX, scaleY, image.maxPatternSize);
228
- },
229
- getRealURL(url) {
230
- const {prefix: prefix, suffix: suffix} = Platform.image;
231
- if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
232
- if (prefix && url[0] === "/") url = prefix + url;
233
- return url;
234
- },
235
- resize(image, width, height, xGap, yGap, clip, smooth, opacity, _filters) {
236
- const canvas = Platform.origin.createCanvas(max$2(floor$2(width + (xGap || 0)), 1), max$2(floor$2(height + (yGap || 0)), 1));
237
- const ctx = canvas.getContext("2d");
238
- if (opacity) ctx.globalAlpha = opacity;
239
- ctx.imageSmoothingEnabled = smooth === false ? false : true;
240
- if (image) {
241
- if (clip) {
242
- const scaleX = width / clip.width, scaleY = height / clip.height;
243
- ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
244
- ctx.drawImage(image, 0, 0, image.width, image.height);
245
- } else ctx.drawImage(image, 0, 0, width, height);
246
- }
247
- return canvas;
248
- },
249
- setPatternTransform(pattern, transform, paint) {
250
- try {
251
- if (transform && pattern.setTransform) {
252
- pattern.setTransform(transform);
253
- transform = undefined;
254
- }
255
- } catch (_a) {}
256
- if (paint) DataHelper.stintSet(paint, "transform", transform);
257
- }
258
- }
259
- };
260
-
261
- const {image: image} = Platform;
262
-
263
210
  const IncrementId = {
264
211
  RUNTIME: "runtime",
265
212
  LEAF: "leaf",
@@ -282,7 +229,7 @@ const I$1 = IncrementId;
282
229
 
283
230
  let tempA, tempB, tempTo;
284
231
 
285
- const {max: max$1} = Math, tempFour = [ 0, 0, 0, 0 ];
232
+ const {max: max$2} = Math, tempFour = [ 0, 0, 0, 0 ];
286
233
 
287
234
  const FourNumberHelper = {
288
235
  zero: [ ...tempFour ],
@@ -334,9 +281,9 @@ const FourNumberHelper = {
334
281
  return data;
335
282
  },
336
283
  max(t, other, change) {
337
- if (isNumber(t) && isNumber(other)) return max$1(t, other);
284
+ if (isNumber(t) && isNumber(other)) return max$2(t, other);
338
285
  toTempAB(t, other, change);
339
- return set$1(tempTo, max$1(tempA[0], tempB[0]), max$1(tempA[1], tempB[1]), max$1(tempA[2], tempB[2]), max$1(tempA[3], tempB[3]));
286
+ return set$1(tempTo, max$2(tempA[0], tempB[0]), max$2(tempA[1], tempB[1]), max$2(tempA[2], tempB[2]), max$2(tempA[3], tempB[3]));
340
287
  },
341
288
  add(t, other, change) {
342
289
  if (isNumber(t) && isNumber(other)) return t + other;
@@ -353,7 +300,7 @@ const FourNumberHelper = {
353
300
 
354
301
  const {set: set$1, get: get$1, setTemp: setTemp, toTempAB: toTempAB} = FourNumberHelper;
355
302
 
356
- const {round: round$3, pow: pow$1, max: max, floor: floor$1, PI: PI$1} = Math;
303
+ const {round: round$3, pow: pow$1, max: max$1, floor: floor$2, PI: PI$1} = Math;
357
304
 
358
305
  const MathHelper = {
359
306
  within(value, min, max) {
@@ -407,7 +354,7 @@ const MathHelper = {
407
354
  }
408
355
  },
409
356
  getFloorScale(num, min = 1) {
410
- return max(floor$1(num), min) / num;
357
+ return max$1(floor$2(num), min) / num;
411
358
  },
412
359
  randInt: randInt,
413
360
  randColor(opacity) {
@@ -1252,7 +1199,7 @@ const {toOuterPoint: toOuterPoint$2} = MatrixHelper;
1252
1199
 
1253
1200
  const {float: float, fourNumber: fourNumber} = MathHelper;
1254
1201
 
1255
- const {floor: floor, ceil: ceil$1} = Math;
1202
+ const {floor: floor$1, ceil: ceil$1} = Math;
1256
1203
 
1257
1204
  let right, bottom, boundsRight, boundsBottom;
1258
1205
 
@@ -1409,8 +1356,8 @@ const BoundsHelper = {
1409
1356
  },
1410
1357
  ceil(t) {
1411
1358
  const {x: x, y: y} = t;
1412
- t.x = floor(t.x);
1413
- t.y = floor(t.y);
1359
+ t.x = floor$1(t.x);
1360
+ t.y = floor$1(t.y);
1414
1361
  t.width = x > t.x ? ceil$1(t.width + x - t.x) : ceil$1(t.width);
1415
1362
  t.height = y > t.y ? ceil$1(t.height + y - t.y) : ceil$1(t.height);
1416
1363
  },
@@ -1542,6 +1489,9 @@ const BoundsHelper = {
1542
1489
  isEmpty(t) {
1543
1490
  return t.x === 0 && t.y === 0 && t.width === 0 && t.height === 0;
1544
1491
  },
1492
+ hasSize(t) {
1493
+ return t.width && t.height;
1494
+ },
1545
1495
  reset(t) {
1546
1496
  B.set(t);
1547
1497
  }
@@ -1718,6 +1668,12 @@ class AutoBounds {
1718
1668
  }
1719
1669
  }
1720
1670
 
1671
+ const UnitConvertHelper = {
1672
+ number(value, percentRefer) {
1673
+ return isObject(value) ? value.type === "percent" ? value.value * percentRefer : value.value : value;
1674
+ }
1675
+ };
1676
+
1721
1677
  const StringNumberMap = {
1722
1678
  0: 1,
1723
1679
  1: 1,
@@ -1734,6 +1690,69 @@ const StringNumberMap = {
1734
1690
  E: 1
1735
1691
  };
1736
1692
 
1693
+ const {floor: floor, max: max} = Math;
1694
+
1695
+ const Platform = {
1696
+ toURL(text, fileType) {
1697
+ let url = encodeURIComponent(text);
1698
+ if (fileType === "text") url = "data:text/plain;charset=utf-8," + url; else if (fileType === "svg") url = "data:image/svg+xml," + url;
1699
+ return url;
1700
+ },
1701
+ image: {
1702
+ hitCanvasSize: 100,
1703
+ maxCacheSize: 2560 * 1600,
1704
+ maxPatternSize: 4096 * 2160,
1705
+ crossOrigin: "anonymous",
1706
+ isLarge(size, scaleX, scaleY, largeSize) {
1707
+ return size.width * size.height * (scaleX ? scaleX * scaleY : 1) > (largeSize || image.maxCacheSize);
1708
+ },
1709
+ isSuperLarge(size, scaleX, scaleY) {
1710
+ return image.isLarge(size, scaleX, scaleY, image.maxPatternSize);
1711
+ },
1712
+ getRealURL(url) {
1713
+ const {prefix: prefix, suffix: suffix} = image;
1714
+ if (suffix && !url.startsWith("data:") && !url.startsWith("blob:")) url += (url.includes("?") ? "&" : "?") + suffix;
1715
+ if (prefix && url[0] === "/") url = prefix + url;
1716
+ return url;
1717
+ },
1718
+ resize(view, width, height, xGap, yGap, clip, smooth, opacity, _filters, interlace) {
1719
+ const realWidth = max(floor(width + (xGap || 0)), 1), realHeight = max(floor(height + (yGap || 0)), 1);
1720
+ let interlaceX, interlaceY, interlaceOffset;
1721
+ if (interlace && (interlaceOffset = UnitConvertHelper.number(interlace.offset, (interlaceX = interlace.type === "x") ? width : height))) interlaceX || (interlaceY = true);
1722
+ const canvas = Platform.origin.createCanvas(interlaceY ? realWidth * 2 : realWidth, interlaceX ? realHeight * 2 : realHeight);
1723
+ const ctx = canvas.getContext("2d");
1724
+ if (opacity) ctx.globalAlpha = opacity;
1725
+ ctx.imageSmoothingEnabled = smooth === false ? false : true;
1726
+ if (image.canUse(view)) {
1727
+ if (clip) {
1728
+ const scaleX = width / clip.width, scaleY = height / clip.height;
1729
+ ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
1730
+ ctx.drawImage(view, 0, 0, view.width, view.height);
1731
+ } else ctx.drawImage(view, 0, 0, width, height);
1732
+ if (interlaceOffset) {
1733
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset - realWidth : realWidth, interlaceX ? realHeight : interlaceOffset - realHeight, realWidth, realHeight);
1734
+ ctx.drawImage(canvas, 0, 0, realWidth, realHeight, interlaceX ? interlaceOffset : realWidth, interlaceX ? realHeight : interlaceOffset, realWidth, realHeight);
1735
+ }
1736
+ }
1737
+ return canvas;
1738
+ },
1739
+ canUse(view) {
1740
+ return view && view.width && !view.__closed;
1741
+ },
1742
+ setPatternTransform(pattern, transform, paint) {
1743
+ try {
1744
+ if (transform && pattern.setTransform) {
1745
+ pattern.setTransform(transform);
1746
+ transform = undefined;
1747
+ }
1748
+ } catch (_a) {}
1749
+ if (paint) DataHelper.stintSet(paint, "transform", transform);
1750
+ }
1751
+ }
1752
+ };
1753
+
1754
+ const {image: image} = Platform;
1755
+
1737
1756
  const {randColor: randColor} = MathHelper;
1738
1757
 
1739
1758
  class Debug {
@@ -3776,9 +3795,10 @@ class TaskItem {
3776
3795
  run() {
3777
3796
  return __awaiter(this, void 0, void 0, function*() {
3778
3797
  try {
3779
- if (this.isComplete) return;
3798
+ if (this.isComplete || this.runing) return;
3799
+ this.runing = true;
3780
3800
  if (this.canUse && !this.canUse()) return this.cancel();
3781
- if (this.task && this.parent.running) yield this.task();
3801
+ if (this.task) yield this.task();
3782
3802
  } catch (error) {
3783
3803
  debug$4.error(error);
3784
3804
  }
@@ -3894,7 +3914,7 @@ class TaskProcessor {
3894
3914
  stop() {
3895
3915
  this.isComplete = true;
3896
3916
  this.list.forEach(task => {
3897
- if (!task.isComplete) task.cancel();
3917
+ if (!task.isComplete) task.run();
3898
3918
  });
3899
3919
  this.pause();
3900
3920
  this.empty();
@@ -4184,7 +4204,7 @@ class LeaferImage {
4184
4204
  getFull(_filters) {
4185
4205
  return this.view;
4186
4206
  }
4187
- getCanvas(width, height, opacity, filters, xGap, yGap, smooth) {
4207
+ getCanvas(width, height, opacity, filters, xGap, yGap, smooth, interlace) {
4188
4208
  width || (width = this.width);
4189
4209
  height || (height = this.height);
4190
4210
  if (this.cache) {
@@ -4197,7 +4217,7 @@ class LeaferImage {
4197
4217
  }
4198
4218
  if (data) return data;
4199
4219
  }
4200
- const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters);
4220
+ const canvas = Platform.image.resize(this.view, width, height, xGap, yGap, undefined, smooth, opacity, filters, interlace);
4201
4221
  this.cache = this.use > 1 ? {
4202
4222
  data: canvas,
4203
4223
  params: arguments
@@ -6089,7 +6109,7 @@ const LeafRender = {
6089
6109
  }
6090
6110
  };
6091
6111
 
6092
- const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper;
6112
+ const {excludeRenderBounds: excludeRenderBounds} = LeafBoundsHelper, {hasSize: hasSize} = BoundsHelper;
6093
6113
 
6094
6114
  const BranchRender = {
6095
6115
  __updateChange() {
@@ -6101,8 +6121,8 @@ const BranchRender = {
6101
6121
  this.__.__checkSingle();
6102
6122
  },
6103
6123
  __render(canvas, options) {
6104
- this.__nowWorld = this.__getNowWorld(options);
6105
- if (this.__worldOpacity) {
6124
+ const nowWorld = this.__nowWorld = this.__getNowWorld(options);
6125
+ if (this.__worldOpacity && hasSize(nowWorld)) {
6106
6126
  const data = this.__;
6107
6127
  if (data.__useDim) {
6108
6128
  if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
@@ -6111,7 +6131,6 @@ const BranchRender = {
6111
6131
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
6112
6132
  const tempCanvas = canvas.getSameCanvas(false, true);
6113
6133
  this.__renderBranch(tempCanvas, options);
6114
- const nowWorld = this.__nowWorld;
6115
6134
  canvas.opacity = options.dimOpacity ? data.opacity * options.dimOpacity : data.opacity;
6116
6135
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, data.__blendMode, true);
6117
6136
  tempCanvas.recycle(nowWorld);
@@ -6951,6 +6970,6 @@ class LeafLevelList {
6951
6970
  }
6952
6971
  }
6953
6972
 
6954
- const version = "1.12.4";
6973
+ const version = "2.0.0";
6955
6974
 
6956
- 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 };
6975
+ 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, 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 };