@leafer-ui/miniapp 1.0.9 → 1.1.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.
@@ -108,7 +108,7 @@ const MathHelper = {
108
108
  return rotation - oldRotation;
109
109
  },
110
110
  float(num, maxLength) {
111
- const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
111
+ const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
112
112
  num = round(num * a) / a;
113
113
  return num === -0 ? 0 : num;
114
114
  },
@@ -1411,14 +1411,13 @@ const UICreator = {
1411
1411
  list: {},
1412
1412
  register(UI) {
1413
1413
  const { __tag: tag } = UI.prototype;
1414
- if (list$2[tag]) {
1414
+ if (list$2[tag])
1415
1415
  debug$e.repeat(tag);
1416
- }
1417
- else {
1418
- list$2[tag] = UI;
1419
- }
1416
+ list$2[tag] = UI;
1420
1417
  },
1421
1418
  get(tag, data, x, y, width, height) {
1419
+ if (!list$2[tag])
1420
+ debug$e.error('not register ' + tag);
1422
1421
  const ui = new list$2[tag](data);
1423
1422
  if (x !== undefined) {
1424
1423
  ui.x = x;
@@ -1442,7 +1441,7 @@ const EventCreator = {
1442
1441
  Object.keys(Event).forEach(key => {
1443
1442
  name = Event[key];
1444
1443
  if (typeof name === 'string')
1445
- nameList[name] ? debug$d.repeat(name) : nameList[name] = Event;
1444
+ nameList[name] && debug$d.repeat(name), nameList[name] = Event;
1446
1445
  });
1447
1446
  },
1448
1447
  changeName(oldName, newName) {
@@ -1644,7 +1643,7 @@ class LeafData {
1644
1643
  const t = this;
1645
1644
  if (t.blendMode === 'pass-through') {
1646
1645
  const leaf = this.__leaf;
1647
- if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
1646
+ if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
1648
1647
  t.__single = true;
1649
1648
  }
1650
1649
  else if (t.__single) {
@@ -2042,8 +2041,9 @@ class LeaferCanvasBase extends Canvas$1 {
2042
2041
  takeCanvas = this.getSameCanvas();
2043
2042
  takeCanvas.copyWorld(this);
2044
2043
  }
2045
- DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
2046
- this.size.pixelRatio || (this.size.pixelRatio = 1);
2044
+ const s = this.size;
2045
+ DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2046
+ canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2047
2047
  this.bounds = new Bounds(0, 0, this.width, this.height);
2048
2048
  if (this.context && !this.unreal) {
2049
2049
  this.updateViewSize();
@@ -2157,6 +2157,17 @@ class LeaferCanvasBase extends Canvas$1 {
2157
2157
  if (!onlyResetTransform)
2158
2158
  this.useWorldTransform();
2159
2159
  }
2160
+ useGrayscaleAlpha(bounds) {
2161
+ this.setTempBounds(bounds, true, true);
2162
+ let alpha, pixel;
2163
+ const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
2164
+ for (let i = 0, len = data.length; i < len; i += 4) {
2165
+ pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
2166
+ if (alpha = data[i + 3])
2167
+ data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
2168
+ }
2169
+ context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
2170
+ }
2160
2171
  useMask(maskCanvas, fromBounds, toBounds) {
2161
2172
  this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
2162
2173
  }
@@ -2167,7 +2178,7 @@ class LeaferCanvasBase extends Canvas$1 {
2167
2178
  if (blendMode)
2168
2179
  this.blendMode = blendMode;
2169
2180
  this.fillStyle = color;
2170
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2181
+ this.setTempBounds(bounds);
2171
2182
  this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2172
2183
  if (blendMode)
2173
2184
  this.blendMode = 'source-over';
@@ -2176,22 +2187,18 @@ class LeaferCanvasBase extends Canvas$1 {
2176
2187
  if (blendMode)
2177
2188
  this.blendMode = blendMode;
2178
2189
  this.strokeStyle = color;
2179
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2190
+ this.setTempBounds(bounds);
2180
2191
  this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2181
2192
  if (blendMode)
2182
2193
  this.blendMode = 'source-over';
2183
2194
  }
2184
2195
  clearWorld(bounds, ceilPixel) {
2185
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2186
- if (ceilPixel)
2187
- tempBounds$1.ceil();
2196
+ this.setTempBounds(bounds, ceilPixel);
2188
2197
  this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2189
2198
  }
2190
2199
  clipWorld(bounds, ceilPixel) {
2191
2200
  this.beginPath();
2192
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2193
- if (ceilPixel)
2194
- tempBounds$1.ceil();
2201
+ this.setTempBounds(bounds, ceilPixel);
2195
2202
  this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2196
2203
  this.clip();
2197
2204
  }
@@ -2199,6 +2206,14 @@ class LeaferCanvasBase extends Canvas$1 {
2199
2206
  const { pixelRatio } = this;
2200
2207
  this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
2201
2208
  }
2209
+ setTempBounds(bounds, ceil, intersect) {
2210
+ tempBounds$1.set(bounds);
2211
+ if (intersect)
2212
+ tempBounds$1.intersect(this.bounds);
2213
+ tempBounds$1.scale(this.pixelRatio);
2214
+ if (ceil)
2215
+ tempBounds$1.ceil();
2216
+ }
2202
2217
  isSameSize(size) {
2203
2218
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
2204
2219
  }
@@ -4150,20 +4165,17 @@ const LeafHelper = {
4150
4165
  }
4151
4166
  return true;
4152
4167
  },
4153
- moveWorld(t, x, y = 0, isInnerPoint) {
4168
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4154
4169
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4155
4170
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4156
- L.moveLocal(t, local.x, local.y);
4171
+ L.moveLocal(t, local.x, local.y, transition);
4157
4172
  },
4158
- moveLocal(t, x, y = 0) {
4159
- if (typeof x === 'object') {
4160
- t.x += x.x;
4161
- t.y += x.y;
4162
- }
4163
- else {
4164
- t.x += x;
4165
- t.y += y;
4166
- }
4173
+ moveLocal(t, x, y = 0, transition) {
4174
+ if (typeof x === 'object')
4175
+ y = x.y, x = x.x;
4176
+ x += t.x;
4177
+ y += t.y;
4178
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4167
4179
  },
4168
4180
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4169
4181
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -5212,13 +5224,14 @@ const BranchRender = {
5212
5224
  this.__.__checkSingle();
5213
5225
  },
5214
5226
  __render(canvas, options) {
5227
+ this.__nowWorld = this.__getNowWorld(options);
5215
5228
  if (this.__worldOpacity) {
5216
5229
  if (this.__.__single) {
5217
5230
  if (this.__.eraser === 'path')
5218
5231
  return this.__renderEraser(canvas, options);
5219
5232
  const tempCanvas = canvas.getSameCanvas(false, true);
5220
5233
  this.__renderBranch(tempCanvas, options);
5221
- const nowWorld = this.__getNowWorld(options);
5234
+ const nowWorld = this.__nowWorld;
5222
5235
  canvas.opacity = this.__.opacity;
5223
5236
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
5224
5237
  tempCanvas.recycle(nowWorld);
@@ -5542,11 +5555,11 @@ let Leaf = class Leaf {
5542
5555
  transform(matrix, resize) {
5543
5556
  transform(this, matrix, resize);
5544
5557
  }
5545
- move(x, y) {
5546
- moveLocal(this, x, y);
5558
+ move(x, y, transition) {
5559
+ moveLocal(this, x, y, transition);
5547
5560
  }
5548
- moveInner(x, y) {
5549
- moveWorld(this, x, y, true);
5561
+ moveInner(x, y, transition) {
5562
+ moveWorld(this, x, y, true, transition);
5550
5563
  }
5551
5564
  scaleOf(origin, scaleX, scaleY, resize) {
5552
5565
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5560,8 +5573,8 @@ let Leaf = class Leaf {
5560
5573
  transformWorld(worldTransform, resize) {
5561
5574
  transformWorld(this, worldTransform, resize);
5562
5575
  }
5563
- moveWorld(x, y) {
5564
- moveWorld(this, x, y);
5576
+ moveWorld(x, y, transition) {
5577
+ moveWorld(this, x, y, false, transition);
5565
5578
  }
5566
5579
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5567
5580
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5959,7 +5972,7 @@ class LeafLevelList {
5959
5972
  }
5960
5973
  }
5961
5974
 
5962
- const version = "1.0.9";
5975
+ const version = "1.1.0";
5963
5976
 
5964
5977
  class LeaferCanvas extends LeaferCanvasBase {
5965
5978
  get allowBackgroundColor() { return false; }
@@ -6072,7 +6085,7 @@ function useCanvas(_canvasType, app) {
6072
6085
  Platform.origin = {
6073
6086
  createCanvas: (width, height, _format) => {
6074
6087
  const data = { type: '2d', width, height };
6075
- app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
6088
+ return app.createOffscreenCanvas ? app.createOffscreenCanvas(data) : app.createOffScreenCanvas(data);
6076
6089
  },
6077
6090
  canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
6078
6091
  canvasToBolb: (canvas, type, quality) => canvas.toBuffer(type, { quality }),
@@ -6183,7 +6196,7 @@ function useCanvas(_canvasType, app) {
6183
6196
  }
6184
6197
  Platform.name = 'miniapp';
6185
6198
  Platform.requestRender = function (render) {
6186
- const { view } = (Platform.renderCanvas || Platform.canvas);
6199
+ const { view } = Platform.renderCanvas || Platform.canvas;
6187
6200
  view.requestAnimationFrame ? view.requestAnimationFrame(render) : setTimeout(render, 16);
6188
6201
  };
6189
6202
  defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, wx.getSystemInfoSync().pixelRatio); } });
@@ -6568,7 +6581,8 @@ class Renderer {
6568
6581
  this.totalBounds = new Bounds();
6569
6582
  debug$5.log(target.innerName, '--->');
6570
6583
  try {
6571
- target.app.emit(RenderEvent.CHILD_START, target);
6584
+ if (!target.isApp)
6585
+ target.app.emit(RenderEvent.CHILD_START, target);
6572
6586
  this.emitRender(RenderEvent.START);
6573
6587
  this.renderOnce(callback);
6574
6588
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -7122,6 +7136,12 @@ class UIData extends LeafData {
7122
7136
  return strokeWidth;
7123
7137
  }
7124
7138
  get __hasStroke() { return this.stroke && this.strokeWidth; }
7139
+ get __hasMultiPaint() {
7140
+ const t = this;
7141
+ if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
7142
+ return true;
7143
+ return t.fill && this.__hasStroke;
7144
+ }
7125
7145
  get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
7126
7146
  get __autoWidth() { return !this._width; }
7127
7147
  get __autoHeight() { return !this._height; }
@@ -7491,9 +7511,8 @@ const RectRender = {
7491
7511
  canvas.strokeRect(half, half, width, height);
7492
7512
  canvas.restore();
7493
7513
  }
7494
- else {
7514
+ else
7495
7515
  canvas.strokeRect(half, half, width, height);
7496
- }
7497
7516
  break;
7498
7517
  case 'outside':
7499
7518
  canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
@@ -7523,11 +7542,15 @@ let UI = UI_1 = class UI extends Leaf {
7523
7542
  super(data);
7524
7543
  }
7525
7544
  reset(_data) { }
7526
- set(data, isTemp) {
7527
- if (isTemp) {
7528
- this.lockNormalStyle = true;
7529
- Object.assign(this, data);
7530
- this.lockNormalStyle = false;
7545
+ set(data, transition) {
7546
+ if (transition) {
7547
+ if (transition === 'temp') {
7548
+ this.lockNormalStyle = true;
7549
+ Object.assign(this, data);
7550
+ this.lockNormalStyle = false;
7551
+ }
7552
+ else
7553
+ this.animate(data, transition);
7531
7554
  }
7532
7555
  else
7533
7556
  Object.assign(this, data);
@@ -7718,6 +7741,15 @@ __decorate([
7718
7741
  __decorate([
7719
7742
  boundsType(0)
7720
7743
  ], UI.prototype, "padding", void 0);
7744
+ __decorate([
7745
+ boundsType(false)
7746
+ ], UI.prototype, "lockRatio", void 0);
7747
+ __decorate([
7748
+ boundsType()
7749
+ ], UI.prototype, "widthRange", void 0);
7750
+ __decorate([
7751
+ boundsType()
7752
+ ], UI.prototype, "heightRange", void 0);
7721
7753
  __decorate([
7722
7754
  dataType(false)
7723
7755
  ], UI.prototype, "draggable", void 0);
@@ -7828,17 +7860,17 @@ let Group = class Group extends UI {
7828
7860
  if (!this.children)
7829
7861
  this.children = [];
7830
7862
  }
7831
- set(data, isTemp) {
7863
+ set(data, transition) {
7832
7864
  if (data.children) {
7833
7865
  const { children } = data;
7834
7866
  delete data.children;
7835
7867
  this.children ? this.clear() : this.__setBranch();
7836
- super.set(data, isTemp);
7868
+ super.set(data, transition);
7837
7869
  children.forEach(child => this.add(child));
7838
7870
  data.children = children;
7839
7871
  }
7840
7872
  else
7841
- super.set(data, isTemp);
7873
+ super.set(data, transition);
7842
7874
  }
7843
7875
  toJSON(options) {
7844
7876
  const data = super.toJSON(options);
@@ -7951,8 +7983,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7951
7983
  }
7952
7984
  onInit() { }
7953
7985
  initType(_type) { }
7954
- set(data) {
7955
- this.waitInit(() => { super.set(data); });
7986
+ set(data, transition) {
7987
+ this.waitInit(() => { super.set(data, transition); });
7956
7988
  }
7957
7989
  start() {
7958
7990
  clearTimeout(this.__startTimer);
@@ -8009,8 +8041,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8009
8041
  __onResize(event) {
8010
8042
  this.emitEvent(event);
8011
8043
  DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
8012
- if (!event.width || !event.height)
8013
- debug$3.warn('w = 0 or h = 0');
8014
8044
  setTimeout(() => { if (this.canvasManager)
8015
8045
  this.canvasManager.clearRecycled(); }, 0);
8016
8046
  }
@@ -8335,9 +8365,6 @@ __decorate([
8335
8365
  __decorate([
8336
8366
  dataType(false)
8337
8367
  ], Box.prototype, "resizeChildren", void 0);
8338
- __decorate([
8339
- dataType(false)
8340
- ], Box.prototype, "textBox", void 0);
8341
8368
  __decorate([
8342
8369
  affectRenderBoundsType('show')
8343
8370
  ], Box.prototype, "overflow", void 0);
@@ -9092,19 +9119,13 @@ class UIEvent extends Event {
9092
9119
  Object.assign(this, params);
9093
9120
  }
9094
9121
  getBoxPoint(relative) {
9095
- if (!relative)
9096
- relative = this.current;
9097
- return relative.getBoxPoint(this);
9122
+ return (relative || this.current).getBoxPoint(this);
9098
9123
  }
9099
9124
  getInnerPoint(relative) {
9100
- if (!relative)
9101
- relative = this.current;
9102
- return relative.getInnerPoint(this);
9125
+ return (relative || this.current).getInnerPoint(this);
9103
9126
  }
9104
9127
  getLocalPoint(relative) {
9105
- if (!relative)
9106
- relative = this.current;
9107
- return relative.getLocalPoint(this);
9128
+ return (relative || this.current).getLocalPoint(this);
9108
9129
  }
9109
9130
  getPagePoint() {
9110
9131
  return this.current.getPagePoint(this);
@@ -9152,10 +9173,8 @@ let DragEvent = class DragEvent extends PointerEvent {
9152
9173
  this.data = data;
9153
9174
  }
9154
9175
  static getValidMove(leaf, start, total) {
9155
- const { draggable, dragBounds, x, y } = leaf;
9156
- const move = leaf.getLocalPoint(total, null, true);
9157
- move.x += start.x - x;
9158
- move.y += start.y - y;
9176
+ const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
9177
+ PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9159
9178
  if (dragBounds)
9160
9179
  this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
9161
9180
  if (draggable === 'x')
@@ -9165,8 +9184,7 @@ let DragEvent = class DragEvent extends PointerEvent {
9165
9184
  return move;
9166
9185
  }
9167
9186
  static getMoveInDragBounds(childBox, dragBounds, move, change) {
9168
- const x = childBox.x + move.x, y = childBox.y + move.y;
9169
- const right = x + childBox.width, bottom = y + childBox.height;
9187
+ const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
9170
9188
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9171
9189
  if (!change)
9172
9190
  move = Object.assign({}, move);
@@ -9218,9 +9236,7 @@ let DragEvent = class DragEvent extends PointerEvent {
9218
9236
  return this.getLocalMove(relative, true);
9219
9237
  }
9220
9238
  getPageBounds() {
9221
- const total = this.getPageTotal();
9222
- const start = this.getPagePoint();
9223
- const bounds = {};
9239
+ const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
9224
9240
  BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9225
9241
  BoundsHelper.unsign(bounds);
9226
9242
  return bounds;
@@ -9338,7 +9354,8 @@ const debug$2 = Debug.get('LeaferTypeCreator');
9338
9354
  const LeaferTypeCreator = {
9339
9355
  list: {},
9340
9356
  register(name, fn) {
9341
- list[name] ? debug$2.repeat(name) : list[name] = fn;
9357
+ list[name] && debug$2.repeat(name);
9358
+ list[name] = fn;
9342
9359
  },
9343
9360
  run(name, leafer) {
9344
9361
  const fn = list[name];
@@ -10712,6 +10729,8 @@ function stroke(stroke, ui, canvas) {
10712
10729
  case 'center':
10713
10730
  canvas.setStroke(stroke, __strokeWidth, options);
10714
10731
  canvas.stroke();
10732
+ if (options.__useArrow)
10733
+ strokeArrow(ui, canvas);
10715
10734
  break;
10716
10735
  case 'inside':
10717
10736
  canvas.save();
@@ -10749,6 +10768,8 @@ function strokes(strokes, ui, canvas) {
10749
10768
  case 'center':
10750
10769
  canvas.setStroke(undefined, __strokeWidth, options);
10751
10770
  drawStrokesStyle(strokes, false, ui, canvas);
10771
+ if (options.__useArrow)
10772
+ strokeArrow(ui, canvas);
10752
10773
  break;
10753
10774
  case 'inside':
10754
10775
  canvas.save();
@@ -10774,6 +10795,14 @@ function strokes(strokes, ui, canvas) {
10774
10795
  }
10775
10796
  }
10776
10797
  }
10798
+ function strokeArrow(ui, canvas) {
10799
+ if (ui.__.dashPattern) {
10800
+ canvas.beginPath();
10801
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10802
+ canvas.dashPattern = null;
10803
+ canvas.stroke();
10804
+ }
10805
+ }
10777
10806
 
10778
10807
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
10779
10808
  function shape(ui, current, options) {
@@ -11459,16 +11488,16 @@ const EffectModule = {
11459
11488
 
11460
11489
  const { excludeRenderBounds } = LeafBoundsHelper;
11461
11490
  Group.prototype.__renderMask = function (canvas, options) {
11462
- let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
11491
+ let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
11463
11492
  const { children } = this;
11464
11493
  for (let i = 0, len = children.length; i < len; i++) {
11465
- child = children[i];
11466
- if (child.__.mask) {
11494
+ child = children[i], mask = child.__.mask;
11495
+ if (mask) {
11467
11496
  if (currentMask) {
11468
11497
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
11469
11498
  maskCanvas = contentCanvas = null;
11470
11499
  }
11471
- if (child.__.mask === 'path') {
11500
+ if (mask === 'path' || mask === 'clipping-path') {
11472
11501
  if (child.opacity < 1) {
11473
11502
  currentMask = 'opacity-path';
11474
11503
  maskOpacity = child.opacity;
@@ -11482,14 +11511,14 @@ Group.prototype.__renderMask = function (canvas, options) {
11482
11511
  child.__clip(contentCanvas || canvas, options);
11483
11512
  }
11484
11513
  else {
11485
- currentMask = 'alpha';
11514
+ currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
11486
11515
  if (!maskCanvas)
11487
11516
  maskCanvas = getCanvas(canvas);
11488
11517
  if (!contentCanvas)
11489
11518
  contentCanvas = getCanvas(canvas);
11490
11519
  child.__render(maskCanvas, options);
11491
11520
  }
11492
- if (child.__.mask !== 'clipping')
11521
+ if (!(mask === 'clipping' || mask === 'clipping-path'))
11493
11522
  continue;
11494
11523
  }
11495
11524
  if (excludeRenderBounds(child, options))
@@ -11500,6 +11529,8 @@ Group.prototype.__renderMask = function (canvas, options) {
11500
11529
  };
11501
11530
  function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
11502
11531
  switch (maskMode) {
11532
+ case 'grayscale':
11533
+ maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
11503
11534
  case 'alpha':
11504
11535
  usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
11505
11536
  break;
@@ -12204,15 +12235,12 @@ const canvas = LeaferCanvasBase.prototype;
12204
12235
  const debug = Debug.get('@leafer-ui/export');
12205
12236
  canvas.export = function (filename, options) {
12206
12237
  const { quality, blob } = FileHelper.getExportOptions(options);
12207
- if (filename.includes('.')) {
12238
+ if (filename.includes('.'))
12208
12239
  return this.saveAs(filename, quality);
12209
- }
12210
- else if (blob) {
12240
+ else if (blob)
12211
12241
  return this.toBlob(filename, quality);
12212
- }
12213
- else {
12242
+ else
12214
12243
  return this.toDataURL(filename, quality);
12215
- }
12216
12244
  };
12217
12245
  canvas.toBlob = function (type, quality) {
12218
12246
  return new Promise((resolve) => {