@leafer-ui/miniapp 1.0.0 → 1.0.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.
@@ -48,6 +48,8 @@ const I$2 = IncrementId;
48
48
  const { round, pow: pow$1, PI: PI$4 } = Math;
49
49
  const MathHelper = {
50
50
  within(value, min, max) {
51
+ if (typeof min === 'object')
52
+ max = min.max, min = min.min;
51
53
  if (min !== undefined && value < min)
52
54
  value = min;
53
55
  if (max !== undefined && value > max)
@@ -150,10 +152,10 @@ const MatrixHelper = {
150
152
  t.e += x;
151
153
  t.f += y;
152
154
  },
153
- translateInner(t, x, y, isMoveOrigin) {
155
+ translateInner(t, x, y, hasOrigin) {
154
156
  t.e += t.a * x + t.c * y;
155
157
  t.f += t.b * x + t.d * y;
156
- if (isMoveOrigin)
158
+ if (hasOrigin)
157
159
  t.e -= x, t.f -= y;
158
160
  },
159
161
  scale(t, scaleX, scaleY = scaleX) {
@@ -312,7 +314,7 @@ const MatrixHelper = {
312
314
  to.y -= (f * a - e * b) * s;
313
315
  }
314
316
  },
315
- setLayout(t, layout, origin, bcChanged) {
317
+ setLayout(t, layout, origin, around, bcChanged) {
316
318
  const { x, y, scaleX, scaleY } = layout;
317
319
  if (bcChanged === undefined)
318
320
  bcChanged = layout.rotation || layout.skewX || layout.skewY;
@@ -344,10 +346,10 @@ const MatrixHelper = {
344
346
  }
345
347
  t.e = x;
346
348
  t.f = y;
347
- if (origin)
348
- M$6.translateInner(t, -origin.x, -origin.y, true);
349
+ if (origin = origin || around)
350
+ M$6.translateInner(t, -origin.x, -origin.y, !around);
349
351
  },
350
- getLayout(t, origin, firstSkewY) {
352
+ getLayout(t, origin, around, firstSkewY) {
351
353
  const { a, b, c, d, e, f } = t;
352
354
  let x = e, y = f, scaleX, scaleY, rotation, skewX, skewY;
353
355
  if (b || c) {
@@ -376,9 +378,11 @@ const MatrixHelper = {
376
378
  scaleY = d;
377
379
  rotation = skewX = skewY = 0;
378
380
  }
379
- if (origin) {
381
+ if (origin = around || origin) {
380
382
  x += origin.x * a + origin.y * c;
381
383
  y += origin.x * b + origin.y * d;
384
+ if (!around)
385
+ x -= origin.x, y -= origin.y;
382
386
  }
383
387
  return { x, y, scaleX, scaleY, rotation, skewX, skewY };
384
388
  },
@@ -706,12 +710,12 @@ class Matrix {
706
710
  toInnerPoint(outer, to, distance) {
707
711
  MatrixHelper.toInnerPoint(this, outer, to, distance);
708
712
  }
709
- setLayout(data, origin) {
710
- MatrixHelper.setLayout(this, data, origin);
713
+ setLayout(data, origin, around) {
714
+ MatrixHelper.setLayout(this, data, origin, around);
711
715
  return this;
712
716
  }
713
- getLayout(origin, firstSkewY) {
714
- return MatrixHelper.getLayout(this, origin, firstSkewY);
717
+ getLayout(origin, around, firstSkewY) {
718
+ return MatrixHelper.getLayout(this, origin, around, firstSkewY);
715
719
  }
716
720
  withScale(scaleX, scaleY) {
717
721
  return MatrixHelper.withScale(this, scaleX, scaleY);
@@ -1999,7 +2003,7 @@ class LeaferCanvasBase extends Canvas$1 {
1999
2003
  DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
2000
2004
  this.size.pixelRatio || (this.size.pixelRatio = 1);
2001
2005
  this.bounds = new Bounds(0, 0, this.width, this.height);
2002
- if (!this.unreal) {
2006
+ if (this.context && !this.unreal) {
2003
2007
  this.updateViewSize();
2004
2008
  this.smooth = this.config.smooth;
2005
2009
  }
@@ -2172,7 +2176,7 @@ class LeaferCanvasBase extends Canvas$1 {
2172
2176
  this.manager ? this.manager.recycle(this) : this.destroy();
2173
2177
  }
2174
2178
  }
2175
- updateRender() { }
2179
+ updateRender(_bounds) { }
2176
2180
  unrealCanvas() { }
2177
2181
  destroy() {
2178
2182
  this.manager = this.view = this.parentView = null;
@@ -4066,8 +4070,13 @@ const LeafHelper = {
4066
4070
  zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4067
4071
  copy$7(matrix$1, t.__localMatrix);
4068
4072
  scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
4069
- moveByMatrix(t, matrix$1);
4070
- t.scaleResize(scaleX, scaleY, resize !== true);
4073
+ if (t.origin || t.around) {
4074
+ L.setTransform(t, matrix$1, resize);
4075
+ }
4076
+ else {
4077
+ moveByMatrix(t, matrix$1);
4078
+ t.scaleResize(scaleX, scaleY, resize !== true);
4079
+ }
4071
4080
  },
4072
4081
  rotateOfWorld(t, origin, angle) {
4073
4082
  L.rotateOfLocal(t, getTempLocal(t, origin), angle);
@@ -4075,8 +4084,13 @@ const LeafHelper = {
4075
4084
  rotateOfLocal(t, origin, angle) {
4076
4085
  copy$7(matrix$1, t.__localMatrix);
4077
4086
  rotateOfOuter$2(matrix$1, origin, angle);
4078
- moveByMatrix(t, matrix$1);
4079
- t.rotation = MathHelper.formatRotation(t.rotation + angle);
4087
+ if (t.origin || t.around) {
4088
+ L.setTransform(t, matrix$1);
4089
+ }
4090
+ else {
4091
+ moveByMatrix(t, matrix$1);
4092
+ t.rotation = MathHelper.formatRotation(t.rotation + angle);
4093
+ }
4080
4094
  },
4081
4095
  skewOfWorld(t, origin, skewX, skewY, resize) {
4082
4096
  L.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY, resize);
@@ -4099,7 +4113,7 @@ const LeafHelper = {
4099
4113
  L.setTransform(t, matrix$1, resize);
4100
4114
  },
4101
4115
  setTransform(t, transform, resize) {
4102
- const layout = getLayout(transform);
4116
+ const layout = getLayout(transform, t.origin && L.getInnerOrigin(t, t.origin), t.around && L.getInnerOrigin(t, t.around));
4103
4117
  if (resize) {
4104
4118
  const scaleX = layout.scaleX / t.scaleX;
4105
4119
  const scaleY = layout.scaleY / t.scaleY;
@@ -4112,13 +4126,19 @@ const LeafHelper = {
4112
4126
  t.set(layout);
4113
4127
  }
4114
4128
  },
4129
+ getFlipTransform(t, axis) {
4130
+ const m = getMatrixData();
4131
+ const sign = axis === 'x' ? 1 : -1;
4132
+ scaleOfOuter$2(m, L.getLocalOrigin(t, 'center'), -1 * sign, 1 * sign);
4133
+ return m;
4134
+ },
4115
4135
  getLocalOrigin(t, origin) {
4116
4136
  return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
4117
4137
  },
4118
4138
  getInnerOrigin(t, origin) {
4119
- if (typeof origin === 'string')
4120
- AroundHelper.toPoint(origin, t.boxBounds, origin = {});
4121
- return origin;
4139
+ const innerOrigin = {};
4140
+ AroundHelper.toPoint(origin, t.boxBounds, innerOrigin);
4141
+ return innerOrigin;
4122
4142
  },
4123
4143
  getRelativeWorld(t, relative, temp) {
4124
4144
  copy$7(matrix$1, t.worldTransform);
@@ -4545,7 +4565,10 @@ const LeafEventer = {
4545
4565
  on(type, listener, options) {
4546
4566
  let capture, once;
4547
4567
  if (options) {
4548
- if (typeof options === 'boolean') {
4568
+ if (options === 'once') {
4569
+ once = true;
4570
+ }
4571
+ else if (typeof options === 'boolean') {
4549
4572
  capture = options;
4550
4573
  }
4551
4574
  else {
@@ -4576,7 +4599,7 @@ const LeafEventer = {
4576
4599
  if (listener) {
4577
4600
  let capture;
4578
4601
  if (options)
4579
- capture = typeof options === 'boolean' ? options : options.capture;
4602
+ capture = typeof options === 'boolean' ? options : (options === 'once' ? false : options.capture);
4580
4603
  let events, index;
4581
4604
  const map = __getListenerMap(this, capture);
4582
4605
  typeList.forEach(type => {
@@ -4878,7 +4901,7 @@ const LeafMatrix = {
4878
4901
  const layout = this.__layout, local = this.__local, data = this.__;
4879
4902
  if (layout.affectScaleOrRotation) {
4880
4903
  if (layout.scaleChanged || layout.rotationChanged) {
4881
- setLayout(local, data, null, layout.affectRotation);
4904
+ setLayout(local, data, null, null, layout.affectRotation);
4882
4905
  layout.scaleChanged = layout.rotationChanged = false;
4883
4906
  }
4884
4907
  }
@@ -4886,7 +4909,7 @@ const LeafMatrix = {
4886
4909
  local.f = data.y + data.offsetY;
4887
4910
  if (data.around || data.origin) {
4888
4911
  toPoint$3(data.around || data.origin, layout.boxBounds, tempPoint$1);
4889
- translateInner(local, -tempPoint$1.x, -tempPoint$1.y, data.origin);
4912
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y, !data.around);
4890
4913
  }
4891
4914
  }
4892
4915
  this.__layout.matrixChanged = false;
@@ -5115,7 +5138,7 @@ const { LEAF, create } = IncrementId;
5115
5138
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5116
5139
  const { toOuterOf } = BoundsHelper;
5117
5140
  const { copy: copy$4 } = PointHelper;
5118
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5141
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getFlipTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5119
5142
  let Leaf = class Leaf {
5120
5143
  get tag() { return this.__tag; }
5121
5144
  set tag(_value) { }
@@ -5141,6 +5164,8 @@ let Leaf = class Leaf {
5141
5164
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5142
5165
  get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
5143
5166
  get pathInputed() { return this.__.__pathInputed; }
5167
+ set event(map) { let event; for (let key in map)
5168
+ event = map[key], event instanceof Array ? this.on(key, event[0], event[1]) : this.on(key, event); }
5144
5169
  constructor(data) {
5145
5170
  this.innerId = create(LEAF);
5146
5171
  this.reset(data);
@@ -5400,6 +5425,9 @@ let Leaf = class Leaf {
5400
5425
  skewOfWorld(worldOrigin, skewX, skewY, resize) {
5401
5426
  skewOfWorld(this, worldOrigin, skewX, skewY, resize);
5402
5427
  }
5428
+ flip(axis) {
5429
+ transform(this, getFlipTransform(this, axis));
5430
+ }
5403
5431
  scaleResize(scaleX, scaleY = scaleX, _noResize) {
5404
5432
  this.scaleX *= scaleX;
5405
5433
  this.scaleY *= scaleY;
@@ -5757,13 +5785,14 @@ class LeafLevelList {
5757
5785
  }
5758
5786
  }
5759
5787
 
5760
- const version = "1.0.0-rc.30";
5788
+ const version = "1.0.1";
5761
5789
  const inviteCode = {};
5762
5790
 
5763
5791
  class LeaferCanvas extends LeaferCanvasBase {
5764
5792
  get allowBackgroundColor() { return false; }
5765
5793
  init() {
5766
- let { view } = this.config;
5794
+ const { config } = this;
5795
+ let view = config.view || config.canvas;
5767
5796
  if (view) {
5768
5797
  if (typeof view === 'string') {
5769
5798
  if (view[0] !== '#')
@@ -5793,16 +5822,18 @@ class LeaferCanvas extends LeaferCanvasBase {
5793
5822
  else {
5794
5823
  this.view = view.view || view;
5795
5824
  }
5796
- this.__createContext();
5825
+ this.view.getContext ? this.__createContext() : this.unrealCanvas();
5797
5826
  const { width, height, pixelRatio } = this.config;
5798
5827
  const size = { width: width || view.width, height: height || view.height, pixelRatio };
5799
5828
  this.resize(size);
5800
- if (this.context.roundRect) {
5801
- this.roundRect = function (x, y, width, height, radius) {
5802
- this.context.roundRect(x, y, width, height, typeof radius === 'number' ? [radius] : radius);
5803
- };
5829
+ if (this.context) {
5830
+ if (this.context.roundRect) {
5831
+ this.roundRect = function (x, y, width, height, radius) {
5832
+ this.context.roundRect(x, y, width, height, typeof radius === 'number' ? [radius] : radius);
5833
+ };
5834
+ }
5835
+ canvasPatch(this.context.__proto__);
5804
5836
  }
5805
- canvasPatch(this.context.__proto__);
5806
5837
  }
5807
5838
  __createView() {
5808
5839
  this.view = Platform.origin.createCanvas(1, 1);
@@ -5820,10 +5851,12 @@ class LeaferCanvas extends LeaferCanvasBase {
5820
5851
  callback();
5821
5852
  });
5822
5853
  }
5823
- startAutoLayout(_autoBounds, listener) {
5854
+ startAutoLayout(autoBounds, listener) {
5824
5855
  this.resizeListener = listener;
5825
- this.checkSize = this.checkSize.bind(this);
5826
- Platform.miniapp.onWindowResize(this.checkSize);
5856
+ if (autoBounds) {
5857
+ this.checkSize = this.checkSize.bind(this);
5858
+ Platform.miniapp.onWindowResize(this.checkSize);
5859
+ }
5827
5860
  }
5828
5861
  checkSize() {
5829
5862
  if (this.viewSelect) {
@@ -5832,13 +5865,8 @@ class LeaferCanvas extends LeaferCanvasBase {
5832
5865
  const { width, height } = this.clientBounds;
5833
5866
  const { pixelRatio } = this;
5834
5867
  const size = { width, height, pixelRatio };
5835
- if (!this.isSameSize(size)) {
5836
- const oldSize = {};
5837
- DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
5838
- this.resize(size);
5839
- if (this.width !== undefined)
5840
- this.resizeListener(new ResizeEvent(size, oldSize));
5841
- }
5868
+ if (!this.isSameSize(size))
5869
+ this.emitResize(size);
5842
5870
  });
5843
5871
  }, 500);
5844
5872
  }
@@ -5848,6 +5876,16 @@ class LeaferCanvas extends LeaferCanvasBase {
5848
5876
  this.resizeListener = null;
5849
5877
  Platform.miniapp.offWindowResize(this.checkSize);
5850
5878
  }
5879
+ unrealCanvas() {
5880
+ this.unreal = true;
5881
+ }
5882
+ emitResize(size) {
5883
+ const oldSize = {};
5884
+ DataHelper.copyAttrs(oldSize, this, canvasSizeAttrs);
5885
+ this.resize(size);
5886
+ if (this.width !== undefined)
5887
+ this.resizeListener(new ResizeEvent(size, oldSize));
5888
+ }
5851
5889
  }
5852
5890
 
5853
5891
  const { mineType, fileType } = FileHelper;
@@ -5969,7 +6007,7 @@ function useCanvas(_canvasType, app) {
5969
6007
  }
5970
6008
  Platform.name = 'miniapp';
5971
6009
  Platform.requestRender = function (render) { Platform.canvas.view.requestAnimationFrame(render); };
5972
- Platform.devicePixelRatio = wx.getSystemInfoSync().pixelRatio;
6010
+ defineKey(Platform, 'devicePixelRatio', { get() { return Math.max(1, wx.getSystemInfoSync().pixelRatio); } });
5973
6011
 
5974
6012
  class Watcher {
5975
6013
  get childrenChanged() { return this.hasAdd || this.hasRemove || this.hasVisible; }
@@ -6447,14 +6485,14 @@ class Renderer {
6447
6485
  if (Debug.showRepaint)
6448
6486
  this.canvas.strokeWorld(bounds, 'red');
6449
6487
  this.target.__render(this.canvas, options);
6450
- this.renderBounds = realBounds || bounds;
6488
+ this.renderBounds = realBounds = realBounds || bounds;
6451
6489
  this.renderOptions = options;
6452
- this.totalBounds.isEmpty() ? this.totalBounds = this.renderBounds : this.totalBounds.add(this.renderBounds);
6490
+ this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
6453
6491
  if (Debug.showHitView)
6454
6492
  this.renderHitView(options);
6455
6493
  if (Debug.showBoundsView)
6456
6494
  this.renderBoundsView(options);
6457
- this.canvas.updateRender();
6495
+ this.canvas.updateRender(realBounds);
6458
6496
  }
6459
6497
  renderHitView(_options) { }
6460
6498
  renderBoundsView(_options) { }
@@ -7776,7 +7814,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7776
7814
  this.__controllers.push(this.renderer = Creator.renderer(this, canvas, config), this.watcher = Creator.watcher(this, config), this.layouter = Creator.layouter(this, config));
7777
7815
  if (this.isApp)
7778
7816
  this.__setApp();
7779
- this.__checkAutoLayout(config);
7817
+ this.__checkAutoLayout(config, parentApp);
7780
7818
  this.view = canvas.view;
7781
7819
  if (parentApp) {
7782
7820
  this.__bindApp(parentApp);
@@ -7877,9 +7915,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7877
7915
  this.leafer = leafer;
7878
7916
  this.__level = 1;
7879
7917
  }
7880
- __checkAutoLayout(config) {
7881
- if (!config.width || !config.height) {
7882
- this.autoLayout = new AutoBounds(config);
7918
+ __checkAutoLayout(config, parentApp) {
7919
+ if (!parentApp) {
7920
+ if (!config.width || !config.height)
7921
+ this.autoLayout = new AutoBounds(config);
7883
7922
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this));
7884
7923
  }
7885
7924
  }
@@ -8014,7 +8053,9 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8014
8053
  list.push(item);
8015
8054
  }
8016
8055
  }
8017
- zoom(_zoomType, _padding, _fixedScale) { return undefined; }
8056
+ zoom(_zoomType, _padding, _fixedScale) {
8057
+ return debug$3.error('need @leafer-in/view');
8058
+ }
8018
8059
  getValidMove(moveX, moveY) { return { x: moveX, y: moveY }; }
8019
8060
  getValidScale(changeScale) { return changeScale; }
8020
8061
  getWorldPointByClient(clientPoint, updateClient) {
@@ -8541,8 +8582,7 @@ let Canvas = class Canvas extends Rect {
8541
8582
  destroy() {
8542
8583
  if (this.canvas) {
8543
8584
  this.canvas.destroy();
8544
- this.canvas = null;
8545
- this.context = null;
8585
+ this.canvas = this.context = null;
8546
8586
  }
8547
8587
  super.destroy();
8548
8588
  }
@@ -8895,11 +8935,13 @@ let App = class App extends Leafer {
8895
8935
  this.renderer.update();
8896
8936
  }
8897
8937
  __render(canvas, options) {
8898
- if (options.matrix) {
8899
- const { a, b, c, d, e, f } = options.matrix;
8900
- canvas.setTransform(a, b, c, d, e, f);
8938
+ if (canvas.context) {
8939
+ if (options.matrix) {
8940
+ const { a, b, c, d, e, f } = options.matrix;
8941
+ canvas.setTransform(a, b, c, d, e, f);
8942
+ }
8943
+ this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8901
8944
  }
8902
- this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8903
8945
  }
8904
8946
  __onResize(event) {
8905
8947
  this.children.forEach(leafer => leafer.resize(event));
@@ -9266,11 +9308,14 @@ leafer.getValidScale = function (changeScale) {
9266
9308
  };
9267
9309
 
9268
9310
  class Transformer {
9311
+ get transforming() { return !!(this.moveData || this.zoomData || this.rotateData); }
9269
9312
  constructor(interaction) {
9270
9313
  this.interaction = interaction;
9271
9314
  }
9272
9315
  move(data) {
9273
9316
  const { interaction } = this;
9317
+ if (!data.moveType)
9318
+ data.moveType = 'move';
9274
9319
  if (!this.moveData) {
9275
9320
  const { path } = interaction.selector.getByPoint(data, interaction.hitRadius);
9276
9321
  data.path = path;
@@ -9435,8 +9480,10 @@ class Dragger {
9435
9480
  return;
9436
9481
  }
9437
9482
  if (!this.moving && canDrag) {
9438
- if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty)
9483
+ if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey || interaction.isMobileDragEmpty) {
9484
+ this.dragData.moveType = 'drag';
9439
9485
  interaction.emit(MoveEvent.START, this.dragData);
9486
+ }
9440
9487
  }
9441
9488
  if (!this.moving) {
9442
9489
  this.dragStart(data, canDrag);
@@ -9475,6 +9522,7 @@ class Dragger {
9475
9522
  this.dragData.throughPath = throughPath;
9476
9523
  this.dragData.path = path;
9477
9524
  if (this.moving) {
9525
+ this.dragData.moveType = 'drag';
9478
9526
  interaction.emit(MoveEvent.BEFORE_MOVE, this.dragData);
9479
9527
  interaction.emit(MoveEvent.MOVE, this.dragData);
9480
9528
  }
@@ -9541,6 +9589,7 @@ class Dragger {
9541
9589
  endDragData.path = path;
9542
9590
  if (this.moving) {
9543
9591
  this.moving = false;
9592
+ endDragData.moveType = 'drag';
9544
9593
  interaction.emit(MoveEvent.END, endDragData);
9545
9594
  }
9546
9595
  if (this.dragging) {
@@ -9599,7 +9648,7 @@ class Dragger {
9599
9648
  totalY += moveY;
9600
9649
  PointHelper.move(downData, moveX, moveY);
9601
9650
  PointHelper.move(this.dragData, moveX, moveY);
9602
- interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY }));
9651
+ interaction.move(Object.assign(Object.assign({}, data), { moveX, moveY, totalX, totalY, moveType: 'drag' }));
9603
9652
  interaction.pointerMoveReal(data);
9604
9653
  }, 10);
9605
9654
  }
@@ -9719,9 +9768,11 @@ const config = {
9719
9768
  const { pathHasEventType, getMoveEventData, getZoomEventData, getRotateEventData } = InteractionHelper;
9720
9769
  class InteractionBase {
9721
9770
  get dragging() { return this.dragger.dragging; }
9771
+ get transforming() { return this.transformer.transforming; }
9722
9772
  get moveMode() { return this.config.move.drag || this.isHoldSpaceKey || this.isHoldMiddleKey || (this.isHoldRightKey && this.dragger.moving) || this.isDragEmpty; }
9773
+ get canHover() { return this.config.pointer.hover && !this.config.mobile; }
9723
9774
  get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
9724
- get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.config.pointer.hover && this.downData && this.isTreePath(this.downData); }
9775
+ get isMobileDragEmpty() { return this.config.move.dragEmpty && !this.canHover && this.downData && this.isTreePath(this.downData); }
9725
9776
  get isHoldMiddleKey() { return this.config.move.holdMiddleKey && this.downData && PointerButton.middle(this.downData); }
9726
9777
  get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
9727
9778
  get isHoldSpaceKey() { return this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey(); }
@@ -9814,6 +9865,7 @@ class InteractionBase {
9814
9865
  if (!downData)
9815
9866
  return;
9816
9867
  PointerButton.defaultLeft(data);
9868
+ data.multiTouch = downData.multiTouch;
9817
9869
  this.findPath(data);
9818
9870
  const upData = Object.assign(Object.assign({}, data), { path: data.path.clone() });
9819
9871
  data.path.addList(downData.path.list);
@@ -9886,7 +9938,7 @@ class InteractionBase {
9886
9938
  this.updateCursor();
9887
9939
  }
9888
9940
  pointerHover(data) {
9889
- if (this.config.pointer.hover) {
9941
+ if (this.canHover) {
9890
9942
  this.pointerOverOrOut(data);
9891
9943
  this.pointerEnterOrLeave(data);
9892
9944
  }
@@ -10023,7 +10075,7 @@ class InteractionBase {
10023
10075
  this.hoverData = data;
10024
10076
  }
10025
10077
  updateCursor(data) {
10026
- if (!this.config.cursor || !this.config.pointer.hover)
10078
+ if (!this.config.cursor || !this.canHover)
10027
10079
  return;
10028
10080
  if (!data) {
10029
10081
  this.updateHoverData();
@@ -10330,7 +10382,7 @@ const PointerEventHelper = {
10330
10382
  convertTouch(e, local) {
10331
10383
  const touch = PointerEventHelper.getTouch(e);
10332
10384
  const base = InteractionHelper.getBase(e);
10333
- return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', pressure: touch.force || 1 });
10385
+ return Object.assign(Object.assign({}, base), { x: local.x, y: local.y, width: 1, height: 1, pointerType: 'touch', multiTouch: e.touches.length > 1, pressure: touch.force || 1 });
10334
10386
  },
10335
10387
  getTouch(e) {
10336
10388
  return e.touches[0] || e.changedTouches[0];
@@ -10390,7 +10442,7 @@ class Interaction extends InteractionBase {
10390
10442
  this.pointerCancel();
10391
10443
  }
10392
10444
  multiTouchStart(e) {
10393
- this.useMultiTouch = (e.touches.length >= 2);
10445
+ this.useMultiTouch = (e.touches.length > 1);
10394
10446
  this.touches = this.useMultiTouch ? this.getTouches(e.touches) : undefined;
10395
10447
  if (this.useMultiTouch)
10396
10448
  this.pointerCancel();
@@ -11016,7 +11068,7 @@ function createPattern(ui, paint, pixelRatio) {
11016
11068
  const { abs } = Math;
11017
11069
  function checkImage(ui, canvas, paint, allowPaint) {
11018
11070
  const { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
11019
- if (!paint.data || paint.patternId === scaleX + '-' + scaleY) {
11071
+ if (!paint.data || (paint.patternId === scaleX + '-' + scaleY && !Export.running)) {
11020
11072
  return false;
11021
11073
  }
11022
11074
  else {
@@ -11994,7 +12046,10 @@ const ExportModule = {
11994
12046
  const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
11995
12047
  let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
11996
12048
  const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
12049
+ let sliceLeaf;
11997
12050
  if (slice) {
12051
+ sliceLeaf = leaf;
12052
+ sliceLeaf.__worldOpacity = 0;
11998
12053
  leaf = leafer;
11999
12054
  renderOptions.bounds = canvas.bounds;
12000
12055
  }
@@ -12009,6 +12064,8 @@ const ExportModule = {
12009
12064
  leaf.__render(canvas, renderOptions);
12010
12065
  }
12011
12066
  canvas.restore();
12067
+ if (sliceLeaf)
12068
+ sliceLeaf.__updateWorldOpacity();
12012
12069
  if (trim) {
12013
12070
  trimBounds = getTrimBounds(canvas);
12014
12071
  const old = canvas, { width, height } = trimBounds;
@@ -12101,34 +12158,28 @@ try {
12101
12158
  }
12102
12159
  catch (_a) { }
12103
12160
 
12104
- LeaferCanvas.prototype.__createContext = function () {
12105
- if (this.viewSelect) {
12106
- const offscreenView = Platform.origin.createCanvas(1, 1);
12107
- const context = this.view.getContext('2d');
12108
- this.testView = this.view;
12109
- this.testContext = context;
12110
- this.view = offscreenView;
12111
- }
12112
- this.context = this.view.getContext('2d');
12113
- this.__bindContext();
12114
- };
12115
- LeaferCanvas.prototype.updateRender = function () {
12116
- if (this.testView) {
12117
- let pattern = this.context.createPattern(this.view, Platform.origin.noRepeat);
12118
- this.testContext.clearRect(0, 0, this.view.width, this.view.height);
12119
- this.testContext.fillStyle = pattern;
12120
- this.testContext.fillRect(0, 0, this.view.width, this.view.height);
12121
- this.testContext.fillStyle = pattern = null;
12122
- }
12123
- };
12124
- LeaferCanvas.prototype.updateViewSize = function () {
12125
- const { width, height, pixelRatio, view, testView } = this;
12126
- view.width = width * pixelRatio;
12127
- view.height = height * pixelRatio;
12128
- if (testView) {
12129
- testView.width = view.width;
12130
- testView.height = view.height;
12131
- }
12132
- };
12161
+ const systemInfo = wx.getSystemInfoSync();
12162
+ const platform = systemInfo.platform;
12163
+ if (platform === 'ios') {
12164
+ LeaferImage.prototype.getPattern = function (canvas, repeat, transform, paint) {
12165
+ const pattern = Platform.canvas.createPattern(this.view, repeat);
12166
+ const { width, height } = canvas;
12167
+ if (this.width !== width || this.height !== height) {
12168
+ if (!transform)
12169
+ transform = MatrixHelper.get();
12170
+ MatrixHelper.scale(transform, width / this.width, height / this.height);
12171
+ }
12172
+ try {
12173
+ if (transform && pattern.setTransform) {
12174
+ pattern.setTransform(transform);
12175
+ transform = null;
12176
+ }
12177
+ }
12178
+ catch (_a) { }
12179
+ if (paint)
12180
+ paint.transform = transform;
12181
+ return pattern;
12182
+ };
12183
+ }
12133
12184
 
12134
12185
  export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };