@leafer-ui/miniapp 1.0.0-rc.20 → 1.0.0-rc.22

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.
@@ -117,7 +117,7 @@ function getMatrixData() { return { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }; }
117
117
 
118
118
  const { sin: sin$5, cos: cos$5, acos, sqrt: sqrt$3 } = Math;
119
119
  const { float: float$1 } = MathHelper;
120
- const tempPoint$3 = {};
120
+ const tempPoint$4 = {};
121
121
  function getWorld() {
122
122
  return Object.assign(Object.assign(Object.assign({}, getMatrixData()), getBoundsData()), { scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 });
123
123
  }
@@ -158,8 +158,8 @@ const MatrixHelper = {
158
158
  t.d *= scaleY;
159
159
  },
160
160
  scaleOfOuter(t, origin, scaleX, scaleY) {
161
- M$6.toInnerPoint(t, origin, tempPoint$3);
162
- M$6.scaleOfInner(t, tempPoint$3, scaleX, scaleY);
161
+ M$6.toInnerPoint(t, origin, tempPoint$4);
162
+ M$6.scaleOfInner(t, tempPoint$4, scaleX, scaleY);
163
163
  },
164
164
  scaleOfInner(t, origin, scaleX, scaleY = scaleX) {
165
165
  M$6.translateInner(t, origin.x, origin.y);
@@ -177,8 +177,8 @@ const MatrixHelper = {
177
177
  t.d = c * sinR + d * cosR;
178
178
  },
179
179
  rotateOfOuter(t, origin, rotation) {
180
- M$6.toInnerPoint(t, origin, tempPoint$3);
181
- M$6.rotateOfInner(t, tempPoint$3, rotation);
180
+ M$6.toInnerPoint(t, origin, tempPoint$4);
181
+ M$6.rotateOfInner(t, tempPoint$4, rotation);
182
182
  },
183
183
  rotateOfInner(t, origin, rotation) {
184
184
  M$6.translateInner(t, origin.x, origin.y);
@@ -199,8 +199,8 @@ const MatrixHelper = {
199
199
  }
200
200
  },
201
201
  skewOfOuter(t, origin, skewX, skewY) {
202
- M$6.toInnerPoint(t, origin, tempPoint$3);
203
- M$6.skewOfInner(t, tempPoint$3, skewX, skewY);
202
+ M$6.toInnerPoint(t, origin, tempPoint$4);
203
+ M$6.skewOfInner(t, tempPoint$4, skewX, skewY);
204
204
  },
205
205
  skewOfInner(t, origin, skewX, skewY = 0) {
206
206
  M$6.translateInner(t, origin.x, origin.y);
@@ -594,7 +594,7 @@ class Point {
594
594
  return this;
595
595
  }
596
596
  }
597
- const tempPoint$2 = new Point();
597
+ const tempPoint$3 = new Point();
598
598
 
599
599
  class Matrix {
600
600
  constructor(a, b, c, d, e, f) {
@@ -1206,11 +1206,19 @@ const AroundHelper = {
1206
1206
  directionData,
1207
1207
  tempPoint: {},
1208
1208
  get: get$5,
1209
- toPoint(around, bounds, to, onlySize) {
1209
+ toPoint(around, bounds, to, onlySize, pointBounds) {
1210
1210
  to || (to = {});
1211
1211
  const point = get$5(around);
1212
1212
  to.x = point.x * bounds.width;
1213
1213
  to.y = point.y * bounds.height;
1214
+ if (pointBounds) {
1215
+ to.x -= pointBounds.x;
1216
+ to.y -= pointBounds.y;
1217
+ if (point.x)
1218
+ to.x -= (point.x === 1) ? pointBounds.width : (point.x === 0.5 ? point.x * pointBounds.width : 0);
1219
+ if (point.y)
1220
+ to.y -= (point.y === 1) ? pointBounds.height : (point.y === 0.5 ? point.y * pointBounds.height : 0);
1221
+ }
1214
1222
  if (!onlySize) {
1215
1223
  to.x += bounds.x;
1216
1224
  to.y += bounds.y;
@@ -1265,7 +1273,8 @@ class Debug {
1265
1273
  this.warn(...messages);
1266
1274
  }
1267
1275
  warn(...messages) {
1268
- console.warn(this.name, ...messages);
1276
+ if (D$4.showWarn)
1277
+ console.warn(this.name, ...messages);
1269
1278
  }
1270
1279
  repeat(name, ...messages) {
1271
1280
  if (!this.repeatMap[name]) {
@@ -1284,6 +1293,7 @@ class Debug {
1284
1293
  }
1285
1294
  Debug.filterList = [];
1286
1295
  Debug.excludeList = [];
1296
+ Debug.showWarn = true;
1287
1297
  function getNameList(name) {
1288
1298
  if (!name)
1289
1299
  name = [];
@@ -2206,7 +2216,7 @@ const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI
2206
2216
  const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2207
2217
  const { set: set$2 } = PointHelper;
2208
2218
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2209
- const tempPoint$1 = {};
2219
+ const tempPoint$2 = {};
2210
2220
  const BezierHelper = {
2211
2221
  points(data, points, curve, close) {
2212
2222
  data.push(M$5, points[0], points[1]);
@@ -2396,8 +2406,8 @@ const BezierHelper = {
2396
2406
  addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
2397
2407
  addPoint$2(pointBounds, toX, toY);
2398
2408
  for (let i = 0, len = tList.length; i < len; i++) {
2399
- getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$1);
2400
- addPoint$2(pointBounds, tempPoint$1.x, tempPoint$1.y);
2409
+ getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2410
+ addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
2401
2411
  }
2402
2412
  },
2403
2413
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2467,7 +2477,7 @@ const EllipseHelper = {
2467
2477
  };
2468
2478
 
2469
2479
  const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2470
- const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2480
+ const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2471
2481
  const { ellipticalArc } = EllipseHelper;
2472
2482
  const debug$c = Debug.get('PathConvert');
2473
2483
  const setEndPoint$1 = {};
@@ -2660,7 +2670,7 @@ const PathConvert = {
2660
2670
  case N$3:
2661
2671
  x = old[i + 1];
2662
2672
  y = old[i + 2];
2663
- curveMode ? rect$2(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2673
+ curveMode ? rect$3(data, x, y, old[i + 3], old[i + 4]) : copyData(data, old, i, 5);
2664
2674
  i += 5;
2665
2675
  break;
2666
2676
  case D$3:
@@ -2817,7 +2827,7 @@ const PathCommandDataHelper = {
2817
2827
  };
2818
2828
  const { ellipse: ellipse$3, arc: arc$2 } = PathCommandDataHelper;
2819
2829
 
2820
- const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$1, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2830
+ const { moveTo: moveTo$4, lineTo: lineTo$3, quadraticCurveTo, bezierCurveTo, closePath: closePath$3, beginPath, rect: rect$2, roundRect: roundRect$1, ellipse: ellipse$2, arc: arc$1, arcTo: arcTo$2, drawEllipse, drawArc, drawPoints: drawPoints$2 } = PathCommandDataHelper;
2821
2831
  class PathCreator {
2822
2832
  set path(value) { this.__path = value; }
2823
2833
  get path() { return this.__path; }
@@ -2859,7 +2869,7 @@ class PathCreator {
2859
2869
  return this;
2860
2870
  }
2861
2871
  rect(x, y, width, height) {
2862
- rect$1(this.__path, x, y, width, height);
2872
+ rect$2(this.__path, x, y, width, height);
2863
2873
  return this;
2864
2874
  }
2865
2875
  roundRect(x, y, width, height, cornerRadius) {
@@ -3954,15 +3964,21 @@ const LeafHelper = {
3954
3964
  }
3955
3965
  return true;
3956
3966
  },
3957
- moveWorld(t, x, y) {
3958
- const local = { x, y };
3967
+ moveWorld(t, x, y = 0) {
3968
+ const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
3959
3969
  if (t.parent)
3960
3970
  toInnerPoint$1(t.parent.worldTransform, local, local, true);
3961
3971
  L.moveLocal(t, local.x, local.y);
3962
3972
  },
3963
3973
  moveLocal(t, x, y = 0) {
3964
- t.x += x;
3965
- t.y += y;
3974
+ if (typeof x === 'object') {
3975
+ t.x += x.x;
3976
+ t.y += x.y;
3977
+ }
3978
+ else {
3979
+ t.x += x;
3980
+ t.y += y;
3981
+ }
3966
3982
  },
3967
3983
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
3968
3984
  L.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -4524,12 +4540,15 @@ const LeafEventer = {
4524
4540
  break;
4525
4541
  }
4526
4542
  }
4543
+ this.syncEventer && this.syncEventer.emitEvent(event, capture);
4527
4544
  },
4528
4545
  emitEvent(event, capture) {
4529
4546
  event.current = this;
4530
4547
  this.emit(event.type, event, capture);
4531
4548
  },
4532
4549
  hasEvent(type, capture) {
4550
+ if (this.syncEventer && this.syncEventer.hasEvent(type, capture))
4551
+ return true;
4533
4552
  const { __bubbleMap: b, __captureMap: c } = this;
4534
4553
  const hasB = b && b[type], hasC = c && c[type];
4535
4554
  return !!(capture === undefined ? (hasB || hasC) : (capture ? hasC : hasB));
@@ -4749,7 +4768,7 @@ const LeafDataProxy = {
4749
4768
  };
4750
4769
 
4751
4770
  const { setLayout, multiplyParent: multiplyParent$1, translateInner, defaultWorld } = MatrixHelper;
4752
- const { toPoint, tempPoint } = AroundHelper;
4771
+ const { toPoint, tempPoint: tempPoint$1 } = AroundHelper;
4753
4772
  const LeafMatrix = {
4754
4773
  __updateWorldMatrix() {
4755
4774
  multiplyParent$1(this.__local || this.__layout, this.parent ? this.parent.__world : defaultWorld, this.__world, !!this.__layout.affectScaleOrRotation, this.__);
@@ -4766,8 +4785,8 @@ const LeafMatrix = {
4766
4785
  local.e = data.x;
4767
4786
  local.f = data.y;
4768
4787
  if (data.around) {
4769
- toPoint(data.around, layout.boxBounds, tempPoint);
4770
- translateInner(local, -tempPoint.x, -tempPoint.y);
4788
+ toPoint(data.around, layout.boxBounds, tempPoint$1);
4789
+ translateInner(local, -tempPoint$1.x, -tempPoint$1.y);
4771
4790
  }
4772
4791
  }
4773
4792
  this.__layout.matrixChanged = false;
@@ -6405,32 +6424,38 @@ class Picker {
6405
6424
  const target = options.target || this.target;
6406
6425
  this.exclude = options.exclude || null;
6407
6426
  this.point = { x: hitPoint.x, y: hitPoint.y, radiusX: hitRadius, radiusY: hitRadius };
6408
- this.findList = options.findList || [];
6427
+ this.findList = new LeafList(options.findList);
6409
6428
  if (!options.findList)
6410
- this.eachFind(target.children, target.__onlyHitMask);
6411
- const list = this.findList;
6412
- const leaf = this.getBestMatchLeaf();
6429
+ this.hitBranch(target);
6430
+ const { list } = this.findList;
6431
+ const leaf = this.getBestMatchLeaf(list, options.bottomList, ignoreHittable);
6413
6432
  const path = ignoreHittable ? this.getPath(leaf) : this.getHitablePath(leaf);
6414
6433
  this.clear();
6415
6434
  return through ? { path, target: leaf, throughPath: list.length ? this.getThroughPath(list) : path } : { path, target: leaf };
6416
6435
  }
6417
- getBestMatchLeaf() {
6418
- const { findList: targets } = this;
6419
- if (targets.length > 1) {
6436
+ getBestMatchLeaf(list, bottomList, ignoreHittable) {
6437
+ if (list.length) {
6420
6438
  let find;
6421
- this.findList = [];
6439
+ this.findList = new LeafList();
6422
6440
  const { x, y } = this.point;
6423
6441
  const point = { x, y, radiusX: 0, radiusY: 0 };
6424
- for (let i = 0, len = targets.length; i < len; i++) {
6425
- find = targets[i];
6426
- if (LeafHelper.worldHittable(find)) {
6442
+ for (let i = 0, len = list.length; i < len; i++) {
6443
+ find = list[i];
6444
+ if (ignoreHittable || LeafHelper.worldHittable(find)) {
6427
6445
  this.hitChild(find, point);
6428
6446
  if (this.findList.length)
6429
- return this.findList[0];
6447
+ return this.findList.list[0];
6430
6448
  }
6431
6449
  }
6432
6450
  }
6433
- return targets[0];
6451
+ if (bottomList) {
6452
+ for (let i = 0, len = bottomList.length; i < len; i++) {
6453
+ this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
6454
+ if (this.findList.length)
6455
+ return this.findList.list[0];
6456
+ }
6457
+ }
6458
+ return list[0];
6434
6459
  }
6435
6460
  getPath(leaf) {
6436
6461
  const path = new LeafList();
@@ -6472,6 +6497,9 @@ class Picker {
6472
6497
  }
6473
6498
  return throughPath;
6474
6499
  }
6500
+ hitBranch(branch) {
6501
+ this.eachFind(branch.children, branch.__onlyHitMask);
6502
+ }
6475
6503
  eachFind(children, hitMask) {
6476
6504
  let child, hit;
6477
6505
  const { point } = this, len = children.length;
@@ -6493,11 +6521,11 @@ class Picker {
6493
6521
  }
6494
6522
  }
6495
6523
  }
6496
- hitChild(child, point) {
6524
+ hitChild(child, point, proxy) {
6497
6525
  if (this.exclude && this.exclude.has(child))
6498
6526
  return;
6499
6527
  if (child.__hitWorld(point))
6500
- this.findList.push(child);
6528
+ this.findList.add(proxy || child);
6501
6529
  }
6502
6530
  clear() {
6503
6531
  this.point = null;
@@ -6695,7 +6723,11 @@ function zoomLayerType() {
6695
6723
  defineKey(target, key, {
6696
6724
  set(value) { if (this.isLeafer)
6697
6725
  this[privateKey] = value; },
6698
- get() { return this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer; }
6726
+ get() {
6727
+ return this.isApp
6728
+ ? this.tree.zoomLayer
6729
+ : (this.isLeafer ? (this[privateKey] || this) : this.leafer && this.leafer.zoomLayer);
6730
+ }
6699
6731
  });
6700
6732
  };
6701
6733
  }
@@ -7101,6 +7133,9 @@ let UI = UI_1 = class UI extends Leaf {
7101
7133
  pen.set(this.path = this.__.path || []);
7102
7134
  return pen;
7103
7135
  }
7136
+ get editConfig() { return undefined; }
7137
+ get editOuter() { return 'EditTool'; }
7138
+ get editInner() { return 'PathEditor'; }
7104
7139
  constructor(data) {
7105
7140
  super(data);
7106
7141
  }
@@ -7162,7 +7197,8 @@ let UI = UI_1 = class UI extends Leaf {
7162
7197
  __drawPathByBox(drawer) {
7163
7198
  const { x, y, width, height } = this.__layout.boxBounds;
7164
7199
  if (this.__.cornerRadius) {
7165
- drawer.roundRect(x, y, width, height, this.__.cornerRadius);
7200
+ const { cornerRadius } = this.__;
7201
+ drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
7166
7202
  }
7167
7203
  else {
7168
7204
  drawer.rect(x, y, width, height);
@@ -7183,6 +7219,9 @@ let UI = UI_1 = class UI extends Leaf {
7183
7219
  static registerData(data) {
7184
7220
  dataProcessor(data)(this.prototype);
7185
7221
  }
7222
+ static setEditConfig(_config) { }
7223
+ static setEditOuter(_toolName) { }
7224
+ static setEditInner(_editorName) { }
7186
7225
  destroy() {
7187
7226
  this.fill = this.stroke = null;
7188
7227
  super.destroy();
@@ -7266,15 +7305,15 @@ __decorate([
7266
7305
  __decorate([
7267
7306
  dataType(false)
7268
7307
  ], UI.prototype, "draggable", void 0);
7308
+ __decorate([
7309
+ dataType()
7310
+ ], UI.prototype, "dragBounds", void 0);
7269
7311
  __decorate([
7270
7312
  dataType(false)
7271
7313
  ], UI.prototype, "editable", void 0);
7272
7314
  __decorate([
7273
7315
  dataType('size')
7274
7316
  ], UI.prototype, "editSize", void 0);
7275
- __decorate([
7276
- dataType()
7277
- ], UI.prototype, "editorStyle", void 0);
7278
7317
  __decorate([
7279
7318
  hitType(true)
7280
7319
  ], UI.prototype, "hittable", void 0);
@@ -7466,7 +7505,6 @@ Group = __decorate([
7466
7505
  var Leafer_1;
7467
7506
  const debug$3 = Debug.get('Leafer');
7468
7507
  let Leafer = Leafer_1 = class Leafer extends Group {
7469
- static get version() { return '1.0.0-rc.20'; }
7470
7508
  get __tag() { return 'Leafer'; }
7471
7509
  get isApp() { return false; }
7472
7510
  get app() { return this.parent || this; }
@@ -7519,7 +7557,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7519
7557
  if (this.isApp)
7520
7558
  this.__setApp();
7521
7559
  this.__checkAutoLayout(config);
7522
- this.updateLazyBounds();
7523
7560
  this.view = canvas.view;
7524
7561
  if (parentApp) {
7525
7562
  this.__bindApp(parentApp);
@@ -7763,6 +7800,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7763
7800
  __listenEvents() {
7764
7801
  const runId = Run.start('FirstCreate ' + this.innerName);
7765
7802
  this.once(LeaferEvent.START, () => Run.end(runId));
7803
+ this.once(LayoutEvent.START, () => this.updateLazyBounds());
7766
7804
  this.once(LayoutEvent.END, () => this.__onReady());
7767
7805
  this.once(RenderEvent.START, () => this.__onCreated());
7768
7806
  this.once(RenderEvent.END, () => this.__onViewReady());
@@ -7833,8 +7871,8 @@ Rect = __decorate([
7833
7871
  registerUI()
7834
7872
  ], Rect);
7835
7873
 
7836
- const rect = Rect.prototype;
7837
- const group = Group.prototype;
7874
+ const rect$1 = Rect.prototype;
7875
+ const group$1 = Group.prototype;
7838
7876
  const bounds$1 = {};
7839
7877
  const { copy: copy$3, add } = BoundsHelper;
7840
7878
  let Box = class Box extends Group {
@@ -7913,28 +7951,28 @@ __decorate([
7913
7951
  affectRenderBoundsType('show')
7914
7952
  ], Box.prototype, "overflow", void 0);
7915
7953
  __decorate([
7916
- rewrite(rect.__updateStrokeSpread)
7954
+ rewrite(rect$1.__updateStrokeSpread)
7917
7955
  ], Box.prototype, "__updateStrokeSpread", null);
7918
7956
  __decorate([
7919
- rewrite(rect.__updateRenderSpread)
7957
+ rewrite(rect$1.__updateRenderSpread)
7920
7958
  ], Box.prototype, "__updateRectRenderSpread", null);
7921
7959
  __decorate([
7922
- rewrite(rect.__updateBoxBounds)
7960
+ rewrite(rect$1.__updateBoxBounds)
7923
7961
  ], Box.prototype, "__updateRectBoxBounds", null);
7924
7962
  __decorate([
7925
- rewrite(rect.__updateStrokeBounds)
7963
+ rewrite(rect$1.__updateStrokeBounds)
7926
7964
  ], Box.prototype, "__updateStrokeBounds", null);
7927
7965
  __decorate([
7928
- rewrite(rect.__updateRenderBounds)
7966
+ rewrite(rect$1.__updateRenderBounds)
7929
7967
  ], Box.prototype, "__updateRectRenderBounds", null);
7930
7968
  __decorate([
7931
- rewrite(rect.__updateChange)
7969
+ rewrite(rect$1.__updateChange)
7932
7970
  ], Box.prototype, "__updateRectChange", null);
7933
7971
  __decorate([
7934
- rewrite(rect.__render)
7972
+ rewrite(rect$1.__render)
7935
7973
  ], Box.prototype, "__renderRect", null);
7936
7974
  __decorate([
7937
- rewrite(group.__render)
7975
+ rewrite(group$1.__render)
7938
7976
  ], Box.prototype, "__renderGroup", null);
7939
7977
  Box = __decorate([
7940
7978
  rewriteAble(),
@@ -8281,6 +8319,7 @@ Canvas = __decorate([
8281
8319
  const { copyAndSpread, includes, spread, setList } = BoundsHelper;
8282
8320
  let Text = class Text extends UI {
8283
8321
  get __tag() { return 'Text'; }
8322
+ get editInner() { return 'TextEditor'; }
8284
8323
  get textDrawData() {
8285
8324
  this.__layout.update();
8286
8325
  return this.__.__textDrawData;
@@ -8509,7 +8548,7 @@ function penPathType() {
8509
8548
  };
8510
8549
  }
8511
8550
 
8512
- const version = "1.0.0-rc.20";
8551
+ const version = "1.0.0-rc.21";
8513
8552
 
8514
8553
  let App = class App extends Leafer {
8515
8554
  get __tag() { return 'App'; }
@@ -8603,7 +8642,8 @@ let App = class App extends Leafer {
8603
8642
  this.renderer.update();
8604
8643
  }
8605
8644
  __render(canvas, options) {
8606
- canvas.setWorld(options.matrix || this.__world);
8645
+ if (options.matrix)
8646
+ canvas.setWorld(options.matrix);
8607
8647
  this.children.forEach(leafer => canvas.copyWorld(leafer.canvas));
8608
8648
  }
8609
8649
  __onResize(event) {
@@ -8725,6 +8765,35 @@ let DragEvent = class DragEvent extends PointerEvent {
8725
8765
  static setData(data) {
8726
8766
  this.data = data;
8727
8767
  }
8768
+ static getValidMove(leaf, start, total) {
8769
+ const { draggable, dragBounds, x, y } = leaf;
8770
+ const move = leaf.getLocalPoint(total, null, true);
8771
+ move.x += start.x - x;
8772
+ move.y += start.y - y;
8773
+ if (dragBounds)
8774
+ this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
8775
+ if (draggable === 'x')
8776
+ move.y = 0;
8777
+ if (draggable === 'y')
8778
+ move.x = 0;
8779
+ return move;
8780
+ }
8781
+ static getMoveInDragBounds(box, dragBounds, move, change) {
8782
+ const x = box.x + move.x, y = box.y + move.y;
8783
+ const right = x + box.width, bottom = y + box.height;
8784
+ const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
8785
+ if (!change)
8786
+ move = Object.assign({}, move);
8787
+ if (x < dragBounds.x)
8788
+ move.x += dragBounds.x - x;
8789
+ else if (right > boundsRight)
8790
+ move.x += boundsRight - right;
8791
+ if (y < dragBounds.y)
8792
+ move.y += dragBounds.y - y;
8793
+ else if (bottom > boundsBottom)
8794
+ move.y += boundsBottom - bottom;
8795
+ return move;
8796
+ }
8728
8797
  getPageMove(total) {
8729
8798
  this.assignMove(total);
8730
8799
  return this.current.getPagePoint(move, null, true);
@@ -8834,9 +8903,7 @@ function addInteractionWindow(leafer) {
8834
8903
  if (leafer.isApp)
8835
8904
  return;
8836
8905
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => {
8837
- const { x, y } = leafer.getValidMove(e.moveX, e.moveY);
8838
- if (x || y)
8839
- leafer.zoomLayer.move(x, y);
8906
+ leafer.zoomLayer.move(leafer.getValidMove(e.moveX, e.moveY));
8840
8907
  }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
8841
8908
  const { zoomLayer } = leafer;
8842
8909
  const changeScale = leafer.getValidScale(e.scale);
@@ -9105,9 +9172,14 @@ class Dragger {
9105
9172
  if (this.dragging) {
9106
9173
  this.interaction.emit(DragEvent.START, this.dragData);
9107
9174
  this.getDragableList(this.dragData.path);
9175
+ this.setDragStartPoints(this.realDragableList = this.getList());
9108
9176
  }
9109
9177
  }
9110
9178
  }
9179
+ setDragStartPoints(list) {
9180
+ this.dragStartPoints = {};
9181
+ list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
9182
+ }
9111
9183
  getDragableList(path) {
9112
9184
  let leaf;
9113
9185
  for (let i = 0, len = path.length; i < len; i++) {
@@ -9137,10 +9209,10 @@ class Dragger {
9137
9209
  }
9138
9210
  dragReal() {
9139
9211
  const { running } = this.interaction;
9140
- const list = this.getList();
9212
+ const list = this.realDragableList;
9141
9213
  if (list.length && running) {
9142
- const { moveX, moveY } = this.dragData;
9143
- list.forEach(leaf => leaf.draggable && leaf.moveWorld(moveX, moveY));
9214
+ const { totalX, totalY } = this.dragData;
9215
+ list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
9144
9216
  }
9145
9217
  }
9146
9218
  dragOverOrOut(data) {
@@ -9609,7 +9681,8 @@ class InteractionBase {
9609
9681
  }
9610
9682
  findPath(data, options) {
9611
9683
  const { hitRadius, through } = this.config.pointer;
9612
- const find = this.selector.getByPoint(data, hitRadius, options || { through });
9684
+ const { bottomList } = this;
9685
+ const find = this.selector.getByPoint(data, hitRadius, Object.assign({ bottomList, name: data.type }, (options || { through })));
9613
9686
  if (find.throughPath)
9614
9687
  data.throughPath = find.throughPath;
9615
9688
  data.path = find.path;
@@ -9622,7 +9695,7 @@ class InteractionBase {
9622
9695
  const app = this.target.app;
9623
9696
  if (!app || !app.isApp)
9624
9697
  return false;
9625
- return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree));
9698
+ return app.editor && (!data.path.has(app.editor) && data.path.has(app.tree) && !data.target.syncEventer);
9626
9699
  }
9627
9700
  checkPath(data, useDefaultPath) {
9628
9701
  if (useDefaultPath || this.canMove(data))
@@ -9688,7 +9761,7 @@ class InteractionBase {
9688
9761
  const { path } = data;
9689
9762
  for (let i = 0, len = path.length; i < len; i++) {
9690
9763
  leaf = path.list[i];
9691
- cursor = leaf.cursor;
9764
+ cursor = leaf.syncEventer ? leaf.syncEventer.cursor : leaf.cursor;
9692
9765
  if (cursor)
9693
9766
  break;
9694
9767
  }
@@ -9846,6 +9919,8 @@ const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
9846
9919
  const inner = {};
9847
9920
  const leaf = Leaf.prototype;
9848
9921
  leaf.__hitWorld = function (point) {
9922
+ if (!this.__.hitSelf)
9923
+ return false;
9849
9924
  if (this.__.hitRadius) {
9850
9925
  copy$2(inner, point), point = inner;
9851
9926
  setRadius(point, this.__.hitRadius);
@@ -9873,8 +9948,8 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
9873
9948
  this.__drawRenderPath(canvas); };
9874
9949
 
9875
9950
  const matrix = new Matrix();
9876
- const ui$1 = UI.prototype;
9877
- ui$1.__updateHitCanvas = function () {
9951
+ const ui$2 = UI.prototype;
9952
+ ui$2.__updateHitCanvas = function () {
9878
9953
  const data = this.__, { hitCanvasManager } = this.leafer;
9879
9954
  const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
9880
9955
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -9901,7 +9976,7 @@ ui$1.__updateHitCanvas = function () {
9901
9976
  this.__drawHitPath(h);
9902
9977
  h.setStrokeOptions(data);
9903
9978
  };
9904
- ui$1.__hit = function (inner) {
9979
+ ui$2.__hit = function (inner) {
9905
9980
  if (Platform.name === 'miniapp')
9906
9981
  this.__drawHitPath(this.__hitCanvas);
9907
9982
  const data = this.__;
@@ -9941,22 +10016,24 @@ ui$1.__hit = function (inner) {
9941
10016
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
9942
10017
  };
9943
10018
 
9944
- const ui = new UI();
9945
- Rect.prototype.__updateHitCanvas = function () {
10019
+ const ui$1 = new UI();
10020
+ const rect = Rect.prototype;
10021
+ rect.__updateHitCanvas = function () {
9946
10022
  if (this.stroke || this.cornerRadius)
9947
- ui.__updateHitCanvas.call(this);
10023
+ ui$1.__updateHitCanvas.call(this);
9948
10024
  };
9949
- Rect.prototype.__hitFill = function (inner) {
9950
- return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10025
+ rect.__hitFill = function (inner) {
10026
+ return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
9951
10027
  };
9952
10028
 
9953
- UI.prototype.find = function (condition, options) {
10029
+ const ui = UI.prototype, group = Group.prototype;
10030
+ ui.find = function (condition, options) {
9954
10031
  return this.leafer ? this.leafer.selector.getBy(condition, this, false, options) : [];
9955
10032
  };
9956
- UI.prototype.findOne = function (condition, options) {
10033
+ ui.findOne = function (condition, options) {
9957
10034
  return this.leafer ? this.leafer.selector.getBy(condition, this, true, options) : null;
9958
10035
  };
9959
- Group.prototype.pick = function (hitPoint, options) {
10036
+ group.pick = function (hitPoint, options) {
9960
10037
  this.__layout.update();
9961
10038
  if (!options)
9962
10039
  options = {};
@@ -10373,79 +10450,75 @@ const PaintModule = {
10373
10450
 
10374
10451
  let origin = {};
10375
10452
  const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
10376
- function fillOrFitMode(data, mode, box, width, height, rotation) {
10453
+ function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10377
10454
  const transform = get$4();
10378
- const swap = rotation && rotation !== 180;
10379
- const sw = box.width / (swap ? height : width);
10380
- const sh = box.height / (swap ? width : height);
10381
- const scale = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10382
- const x = box.x + (box.width - width * scale) / 2;
10383
- const y = box.y + (box.height - height * scale) / 2;
10384
- translate$1(transform, x, y);
10385
- scaleHelper(transform, scale);
10455
+ translate$1(transform, box.x + x, box.y + y);
10456
+ scaleHelper(transform, scaleX, scaleY);
10386
10457
  if (rotation)
10387
10458
  rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10388
- data.scaleX = data.scaleY = scale;
10389
10459
  data.transform = transform;
10390
10460
  }
10391
10461
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10392
10462
  const transform = get$4();
10393
- translate$1(transform, box.x, box.y);
10394
- if (x || y)
10395
- translate$1(transform, x, y);
10396
- if (scaleX) {
10463
+ translate$1(transform, box.x + x, box.y + y);
10464
+ if (scaleX)
10397
10465
  scaleHelper(transform, scaleX, scaleY);
10398
- data.scaleX = transform.a;
10399
- data.scaleY = transform.d;
10400
- }
10401
10466
  if (rotation)
10402
10467
  rotate(transform, rotation);
10403
10468
  data.transform = transform;
10404
10469
  }
10405
- function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation) {
10470
+ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around) {
10406
10471
  const transform = get$4();
10407
10472
  if (rotation) {
10408
- rotate(transform, rotation);
10409
- switch (rotation) {
10410
- case 90:
10411
- translate$1(transform, height, 0);
10412
- break;
10413
- case 180:
10414
- translate$1(transform, width, height);
10415
- break;
10416
- case 270:
10417
- translate$1(transform, 0, width);
10418
- break;
10473
+ if (around === 'center') {
10474
+ rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
10475
+ }
10476
+ else {
10477
+ rotate(transform, rotation);
10478
+ switch (rotation) {
10479
+ case 90:
10480
+ translate$1(transform, height, 0);
10481
+ break;
10482
+ case 180:
10483
+ translate$1(transform, width, height);
10484
+ break;
10485
+ case 270:
10486
+ translate$1(transform, 0, width);
10487
+ break;
10488
+ }
10419
10489
  }
10420
10490
  }
10421
- origin.x = box.x;
10422
- origin.y = box.y;
10423
- if (x || y)
10424
- origin.x += x, origin.y += y;
10491
+ origin.x = box.x + x;
10492
+ origin.y = box.y + y;
10425
10493
  translate$1(transform, origin.x, origin.y);
10426
- if (scaleX) {
10494
+ if (scaleX)
10427
10495
  scaleOfOuter$2(transform, origin, scaleX, scaleY);
10428
- data.scaleX = scaleX;
10429
- data.scaleY = scaleY;
10430
- }
10431
10496
  data.transform = transform;
10432
10497
  }
10433
10498
 
10434
10499
  const { get: get$3, translate } = MatrixHelper;
10435
10500
  const tempBox = new Bounds();
10501
+ const tempPoint = {};
10436
10502
  function createData(leafPaint, image, paint, box) {
10437
10503
  let { width, height } = image;
10438
10504
  if (paint.padding)
10439
10505
  box = tempBox.set(box).shrink(paint.padding);
10440
- const { opacity, mode, offset, scale, size, rotation, blendMode, repeat } = paint;
10506
+ const { opacity, mode, around, offset, scale, size, rotation, blendMode, repeat } = paint;
10441
10507
  const sameBox = box.width === width && box.height === height;
10442
10508
  if (blendMode)
10443
10509
  leafPaint.blendMode = blendMode;
10444
10510
  const data = leafPaint.data = { mode };
10445
- let x, y, scaleX, scaleY;
10446
- if (offset)
10447
- x = offset.x, y = offset.y;
10448
- if (size) {
10511
+ const swapSize = around !== 'center' && (rotation || 0) % 180 === 90;
10512
+ const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10513
+ let x = 0, y = 0, scaleX, scaleY;
10514
+ if (!mode || mode === 'cover' || mode === 'fit') {
10515
+ if (!sameBox || rotation) {
10516
+ const sw = box.width / swapWidth, sh = box.height / swapHeight;
10517
+ scaleX = scaleY = mode === 'fit' ? Math.min(sw, sh) : Math.max(sw, sh);
10518
+ x += (box.width - width * scaleX) / 2, y += (box.height - height * scaleY) / 2;
10519
+ }
10520
+ }
10521
+ else if (size) {
10449
10522
  scaleX = (typeof size === 'number' ? size : size.width) / width;
10450
10523
  scaleY = (typeof size === 'number' ? size : size.height) / height;
10451
10524
  }
@@ -10453,26 +10526,36 @@ function createData(leafPaint, image, paint, box) {
10453
10526
  scaleX = typeof scale === 'number' ? scale : scale.x;
10454
10527
  scaleY = typeof scale === 'number' ? scale : scale.y;
10455
10528
  }
10529
+ if (around) {
10530
+ const imageBounds = { x, y, width: swapWidth, height: swapHeight };
10531
+ if (scaleX)
10532
+ imageBounds.width *= scaleX, imageBounds.height *= scaleY;
10533
+ AroundHelper.toPoint(around, box, tempPoint, true, imageBounds);
10534
+ x += tempPoint.x, y += tempPoint.y;
10535
+ }
10536
+ if (offset)
10537
+ x += offset.x, y += offset.y;
10456
10538
  switch (mode) {
10457
10539
  case 'strench':
10458
10540
  if (!sameBox)
10459
10541
  width = box.width, height = box.height;
10460
10542
  break;
10543
+ case 'normal':
10461
10544
  case 'clip':
10462
- if (offset || scaleX || rotation)
10545
+ if (x || y || scaleX || rotation)
10463
10546
  clipMode(data, box, x, y, scaleX, scaleY, rotation);
10464
10547
  break;
10465
10548
  case 'repeat':
10466
10549
  if (!sameBox || scaleX || rotation)
10467
- repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation);
10550
+ repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, around);
10468
10551
  if (!repeat)
10469
10552
  data.repeat = 'repeat';
10470
10553
  break;
10471
10554
  case 'fit':
10472
10555
  case 'cover':
10473
10556
  default:
10474
- if (!sameBox || rotation)
10475
- fillOrFitMode(data, mode, box, width, height, rotation);
10557
+ if (scaleX)
10558
+ fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation);
10476
10559
  }
10477
10560
  if (!data.transform) {
10478
10561
  if (box.x || box.y) {
@@ -10480,6 +10563,10 @@ function createData(leafPaint, image, paint, box) {
10480
10563
  translate(data.transform, box.x, box.y);
10481
10564
  }
10482
10565
  }
10566
+ if (scaleX && mode !== 'strench') {
10567
+ data.scaleX = scaleX;
10568
+ data.scaleY = scaleY;
10569
+ }
10483
10570
  data.width = width;
10484
10571
  data.height = height;
10485
10572
  if (opacity)
@@ -11535,6 +11622,13 @@ const ExportModule = {
11535
11622
  resolve();
11536
11623
  this.running = false;
11537
11624
  };
11625
+ if (filename === 'json') {
11626
+ return over({ data: leaf.toJSON() });
11627
+ }
11628
+ else if (FileHelper.fileType(filename) === 'json') {
11629
+ Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
11630
+ return over({ data: true });
11631
+ }
11538
11632
  const { leafer } = leaf;
11539
11633
  if (leafer) {
11540
11634
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
@@ -11711,4 +11805,4 @@ LeaferCanvas.prototype.updateViewSize = function () {
11711
11805
  }
11712
11806
  };
11713
11807
 
11714
- export { 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, 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, 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$2 as tempPoint, useCanvas, useModule, version, zoomLayerType };
11808
+ export { 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, 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, 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, zoomLayerType };