leafer-ui 1.0.0-rc.4 → 1.0.0-rc.5

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.
@@ -647,14 +647,14 @@ const BoundsHelper = {
647
647
  },
648
648
  getFitMatrix(t, put) {
649
649
  const scale = Math.min(1, Math.min(t.width / put.width, t.height / put.height));
650
- return new Matrix(scale, 0, 0, scale, -Math.ceil(put.x * scale), -Math.ceil(put.y * scale));
650
+ return new Matrix(scale, 0, 0, scale, -put.x * scale, -put.y * scale);
651
651
  },
652
652
  getSpread(t, spreadX, spreadY) {
653
653
  const n = {};
654
654
  B.copyAndSpread(n, t, spreadX, spreadY);
655
655
  return n;
656
656
  },
657
- spread(t, spreadX, spreadY) {
657
+ spread(t, spreadX, spreadY = spreadX) {
658
658
  B.copyAndSpread(t, t, spreadX, spreadY);
659
659
  },
660
660
  ceil(t) {
@@ -795,8 +795,8 @@ class Bounds {
795
795
  getFitMatrix(put) {
796
796
  return BoundsHelper.getFitMatrix(this, put);
797
797
  }
798
- spread(size) {
799
- BoundsHelper.spread(this, size);
798
+ spread(spreadX, spreadY) {
799
+ BoundsHelper.spread(this, spreadX, spreadY);
800
800
  return this;
801
801
  }
802
802
  ceil() {
@@ -1378,6 +1378,8 @@ class LeafData {
1378
1378
  }
1379
1379
 
1380
1380
  const FileHelper = {
1381
+ opacityTypes: ['png', 'webp', 'svg'],
1382
+ upperCaseTypeMap: {},
1381
1383
  mineType(type) {
1382
1384
  if (!type || type.startsWith('image'))
1383
1385
  return type;
@@ -1390,6 +1392,7 @@ const FileHelper = {
1390
1392
  return l[l.length - 1];
1391
1393
  }
1392
1394
  };
1395
+ FileHelper.opacityTypes.forEach(type => FileHelper.upperCaseTypeMap[type] = type.toUpperCase());
1393
1396
 
1394
1397
  /******************************************************************************
1395
1398
  Copyright (c) Microsoft Corporation.
@@ -2330,7 +2333,7 @@ const EllipseHelper = {
2330
2333
  const centerX = fromX + halfX + rotationCos * cx - rotationSin * cy;
2331
2334
  const centerY = fromY + halfY + rotationSin * cx + rotationCos * cy;
2332
2335
  const anticlockwise = totalRadian < 0 ? 1 : 0;
2333
- if (curveMode) {
2336
+ if (curveMode || Platform.name === 'node') {
2334
2337
  ellipse$5(data, centerX, centerY, radiusX, radiusY, rotation, startRadian / OneRadian, endRadian / OneRadian, anticlockwise);
2335
2338
  }
2336
2339
  else {
@@ -3257,6 +3260,23 @@ const ImageManager = {
3257
3260
  list.length = 0;
3258
3261
  }
3259
3262
  },
3263
+ isPixel(config) {
3264
+ return FileHelper.opacityTypes.some(item => I$1.isFormat(item, config));
3265
+ },
3266
+ isFormat(format, config) {
3267
+ if (config.format === format)
3268
+ return true;
3269
+ const { url } = config;
3270
+ if (url.startsWith('data:')) {
3271
+ if (url.startsWith('data:' + FileHelper.mineType(format)))
3272
+ return true;
3273
+ }
3274
+ else {
3275
+ if (url.includes('.' + format) || url.includes('.' + FileHelper.upperCaseTypeMap[format]))
3276
+ return true;
3277
+ }
3278
+ return false;
3279
+ },
3260
3280
  destroy() {
3261
3281
  I$1.map = {};
3262
3282
  }
@@ -3272,17 +3292,7 @@ class LeaferImage {
3272
3292
  this.waitComplete = [];
3273
3293
  this.innerId = create$1(IMAGE);
3274
3294
  this.config = config || { url: '' };
3275
- const { url } = config;
3276
- if (url.startsWith('data:')) {
3277
- if (url.startsWith('data:image/svg'))
3278
- this.isSVG = true;
3279
- }
3280
- else {
3281
- if (url.includes('.svg'))
3282
- this.isSVG = true;
3283
- }
3284
- if (this.config.format === 'svg')
3285
- this.isSVG = true;
3295
+ this.isSVG = ImageManager.isFormat('svg', config);
3286
3296
  }
3287
3297
  load(onSuccess, onError) {
3288
3298
  if (!this.loading) {
@@ -3355,13 +3365,19 @@ class Event {
3355
3365
  }
3356
3366
  stopDefault() {
3357
3367
  this.isStopDefault = true;
3368
+ if (this.origin)
3369
+ Platform.event.stopDefault(this.origin);
3358
3370
  }
3359
3371
  stopNow() {
3360
3372
  this.isStopNow = true;
3361
3373
  this.isStop = true;
3374
+ if (this.origin)
3375
+ Platform.event.stopNow(this.origin);
3362
3376
  }
3363
3377
  stop() {
3364
3378
  this.isStop = true;
3379
+ if (this.origin)
3380
+ Platform.event.stop(this.origin);
3365
3381
  }
3366
3382
  }
3367
3383
 
@@ -3423,20 +3439,6 @@ class ResizeEvent extends Event {
3423
3439
  }
3424
3440
  ResizeEvent.RESIZE = 'resize';
3425
3441
 
3426
- class TransformEvent extends Event {
3427
- constructor(type, params) {
3428
- super(type);
3429
- if (params)
3430
- Object.assign(this, params);
3431
- }
3432
- }
3433
- TransformEvent.START = 'transform.start';
3434
- TransformEvent.CHANGE = 'transform.change';
3435
- TransformEvent.END = 'transform.end';
3436
- TransformEvent.BEFORE_START = 'transform.before_start';
3437
- TransformEvent.BEFORE_CHANGE = 'transform.before_change';
3438
- TransformEvent.BEFORE_END = 'transform.before_end';
3439
-
3440
3442
  class WatchEvent extends Event {
3441
3443
  constructor(type, data) {
3442
3444
  super(type);
@@ -3537,15 +3539,15 @@ class UIEvent extends Event {
3537
3539
  this.bubbles = true;
3538
3540
  Object.assign(this, params);
3539
3541
  }
3540
- getInner(target) {
3541
- if (!target)
3542
- target = this.current;
3543
- return target.getInnerPoint(this);
3542
+ getInner(relative) {
3543
+ if (!relative)
3544
+ relative = this.current;
3545
+ return relative.getInnerPoint(this);
3544
3546
  }
3545
- getLocal(target) {
3546
- if (!target)
3547
- target = this.current;
3548
- return target.getLocalPoint(this);
3547
+ getLocal(relative) {
3548
+ if (!relative)
3549
+ relative = this.current;
3550
+ return relative.getLocalPoint(this);
3549
3551
  }
3550
3552
  static changeName(oldName, newName) {
3551
3553
  EventCreator.changeName(oldName, newName);
@@ -3592,7 +3594,7 @@ function positionType(defaultValue) {
3592
3594
  defineLeafAttr(target, key, defaultValue, {
3593
3595
  set(value) {
3594
3596
  this.__setAttr(key, value);
3595
- this.__layout.positionChanged || this.__layout.positionChange();
3597
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3596
3598
  }
3597
3599
  });
3598
3600
  };
@@ -3624,7 +3626,7 @@ function boundsType(defaultValue) {
3624
3626
  this.__setAttr(key, value);
3625
3627
  this.__layout.boxChanged || this.__layout.boxChange();
3626
3628
  if (this.__.around)
3627
- this.__layout.positionChanged || this.__layout.positionChange();
3629
+ this.__layout.matrixChanged || this.__layout.matrixChange();
3628
3630
  }
3629
3631
  });
3630
3632
  };
@@ -3860,29 +3862,36 @@ PointerEvent.CLICK = 'click';
3860
3862
  PointerEvent.DOUBLE_CLICK = 'double_click';
3861
3863
  PointerEvent.LONG_PRESS = 'long_press';
3862
3864
  PointerEvent.LONG_TAP = 'long_tap';
3865
+ PointerEvent.MENU = 'pointer.menu';
3863
3866
  PointerEvent = __decorate([
3864
3867
  registerUIEvent()
3865
3868
  ], PointerEvent);
3866
3869
 
3867
3870
  const move = {};
3868
3871
  let DragEvent = class DragEvent extends PointerEvent {
3869
- getInnerMove(target, total) {
3870
- if (!target)
3871
- target = this.current;
3872
+ static setList(data) {
3873
+ this.list = data instanceof LeafList ? data : new LeafList(data);
3874
+ }
3875
+ static setData(data) {
3876
+ this.data = data;
3877
+ }
3878
+ getInnerMove(relative, total) {
3879
+ if (!relative)
3880
+ relative = this.current;
3872
3881
  this.assignMove(total);
3873
- return target.getInnerPoint(move, null, true);
3882
+ return relative.getInnerPoint(move, null, true);
3874
3883
  }
3875
- getLocalMove(target, total) {
3876
- if (!target)
3877
- target = this.current;
3884
+ getLocalMove(relative, total) {
3885
+ if (!relative)
3886
+ relative = this.current;
3878
3887
  this.assignMove(total);
3879
- return target.getLocalPoint(move, null, true);
3888
+ return relative.getLocalPoint(move, null, true);
3880
3889
  }
3881
- getInnerTotal(target) {
3882
- return this.getInnerMove(target, true);
3890
+ getInnerTotal(relative) {
3891
+ return this.getInnerMove(relative, true);
3883
3892
  }
3884
- getLocalTotal(target) {
3885
- return this.getLocalMove(target, true);
3893
+ getLocalTotal(relative) {
3894
+ return this.getLocalMove(relative, true);
3886
3895
  }
3887
3896
  assignMove(total) {
3888
3897
  move.x = total ? this.totalX : this.moveX;
@@ -3901,17 +3910,16 @@ DragEvent = __decorate([
3901
3910
  registerUIEvent()
3902
3911
  ], DragEvent);
3903
3912
 
3904
- var DropEvent_1;
3905
- let DropEvent = DropEvent_1 = class DropEvent extends PointerEvent {
3913
+ let DropEvent = class DropEvent extends PointerEvent {
3906
3914
  static setList(data) {
3907
- DropEvent_1.dragList = data instanceof LeafList ? data : new LeafList(data);
3915
+ DragEvent.setList(data);
3908
3916
  }
3909
3917
  static setData(data) {
3910
- this.dragData = data;
3918
+ DragEvent.setData(data);
3911
3919
  }
3912
3920
  };
3913
3921
  DropEvent.DROP = 'drop';
3914
- DropEvent = DropEvent_1 = __decorate([
3922
+ DropEvent = __decorate([
3915
3923
  registerUIEvent()
3916
3924
  ], DropEvent);
3917
3925
 
@@ -4018,7 +4026,6 @@ class Transformer {
4018
4026
  this.moveEnd();
4019
4027
  this.zoomEnd();
4020
4028
  this.rotateEnd();
4021
- this.transformMode = null;
4022
4029
  }
4023
4030
  moveEnd() {
4024
4031
  if (this.moveData) {
@@ -4043,7 +4050,7 @@ class Transformer {
4043
4050
  }
4044
4051
  }
4045
4052
 
4046
- const { copy: copy$5, translate: translate$2, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter } = MatrixHelper;
4053
+ const { copy: copy$5, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter } = MatrixHelper;
4047
4054
  const matrix = {};
4048
4055
  const LeafHelper = {
4049
4056
  updateAllWorldMatrix(leaf) {
@@ -4086,63 +4093,41 @@ const LeafHelper = {
4086
4093
  return true;
4087
4094
  },
4088
4095
  moveWorld(t, x, y) {
4089
- t.__layout.checkUpdate();
4090
4096
  const local = { x, y };
4091
4097
  if (t.parent)
4092
- toInnerPoint$1(t.parent.__world, local, local, true);
4098
+ toInnerPoint$1(t.parent.worldTransform, local, local, true);
4093
4099
  L.moveLocal(t, local.x, local.y);
4094
4100
  },
4095
4101
  moveLocal(t, x, y = 0) {
4096
4102
  t.x += x;
4097
4103
  t.y += y;
4098
4104
  },
4099
- zoomOfWorld(t, origin, scaleX, scaleY, moveLayer) {
4100
- t.__layout.checkUpdate();
4101
- const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
4102
- this.zoomOfLocal(t, local, scaleX, scaleY, moveLayer);
4105
+ zoomOfWorld(t, origin, scaleX, scaleY) {
4106
+ this.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY);
4103
4107
  },
4104
- zoomOfLocal(t, origin, scaleX, scaleY = scaleX, moveLayer) {
4108
+ zoomOfLocal(t, origin, scaleX, scaleY = scaleX) {
4105
4109
  copy$5(matrix, t.__local);
4106
- if (moveLayer)
4107
- translate$2(matrix, moveLayer.x, moveLayer.y);
4108
4110
  scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4109
- if (!moveLayer)
4110
- moveLayer = t;
4111
- moveLayer.x += matrix.e - t.__local.e;
4112
- moveLayer.y += matrix.f - t.__local.f;
4111
+ moveByMatrix(t, matrix);
4113
4112
  t.scaleX *= scaleX;
4114
4113
  t.scaleY *= scaleY;
4115
4114
  },
4116
- rotateOfWorld(t, origin, angle, moveLayer) {
4117
- t.__layout.checkUpdate();
4118
- const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
4119
- this.rotateOfLocal(t, local, angle, moveLayer);
4115
+ rotateOfWorld(t, origin, angle) {
4116
+ this.rotateOfLocal(t, getTempLocal(t, origin), angle);
4120
4117
  },
4121
- rotateOfLocal(t, origin, angle, moveLayer) {
4118
+ rotateOfLocal(t, origin, angle) {
4122
4119
  copy$5(matrix, t.__local);
4123
- if (moveLayer)
4124
- translate$2(matrix, moveLayer.x, moveLayer.y);
4125
4120
  rotateOfOuter$3(matrix, origin, angle);
4126
- if (!moveLayer)
4127
- moveLayer = t;
4128
- moveLayer.x += matrix.e - t.__local.e;
4129
- moveLayer.y += matrix.f - t.__local.f;
4121
+ moveByMatrix(t, matrix);
4130
4122
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
4131
4123
  },
4132
- skewOfWorld(t, origin, skewX, skewY, moveLayer) {
4133
- t.__layout.checkUpdate();
4134
- const local = t.parent ? PointHelper.tempToInnerOf(origin, t.parent.__world) : origin;
4135
- this.skewOfLocal(t, local, skewX, skewY, moveLayer);
4124
+ skewOfWorld(t, origin, skewX, skewY) {
4125
+ this.skewOfLocal(t, getTempLocal(t, origin), skewX, skewY);
4136
4126
  },
4137
- skewOfLocal(t, origin, skewX, skewY, moveLayer) {
4127
+ skewOfLocal(t, origin, skewX, skewY) {
4138
4128
  copy$5(matrix, t.__local);
4139
- if (moveLayer)
4140
- translate$2(matrix, moveLayer.x, moveLayer.y);
4141
4129
  skewOfOuter(matrix, origin, skewX, skewY);
4142
- if (!moveLayer)
4143
- moveLayer = t;
4144
- moveLayer.x = matrix.e - t.__local.e;
4145
- moveLayer.y = matrix.f - t.__local.f;
4130
+ moveByMatrix(t, matrix);
4146
4131
  t.skewX = MathHelper.formatSkew(t.skewX + skewX);
4147
4132
  t.skewY = MathHelper.formatSkew(t.skewY + skewY);
4148
4133
  },
@@ -4156,6 +4141,14 @@ const LeafHelper = {
4156
4141
  };
4157
4142
  const L = LeafHelper;
4158
4143
  const { updateAllWorldMatrix: updateAllWorldMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity$1, updateAllChange: updateAllChange$1 } = L;
4144
+ function moveByMatrix(t, matrix) {
4145
+ t.x += matrix.e - t.__local.e;
4146
+ t.y += matrix.f - t.__local.f;
4147
+ }
4148
+ function getTempLocal(t, world) {
4149
+ t.__layout.checkUpdate();
4150
+ return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
4151
+ }
4159
4152
 
4160
4153
  const LeafBoundsHelper = {
4161
4154
  worldBounds(target) {
@@ -4317,7 +4310,8 @@ const InteractionHelper = {
4317
4310
  };
4318
4311
  const I = InteractionHelper;
4319
4312
 
4320
- const { getDragEventData, getDropEventData, getSwipeEventData, filterPathByEventType } = InteractionHelper;
4313
+ const emptyList = new LeafList();
4314
+ const { getDragEventData, getDropEventData, getSwipeEventData } = InteractionHelper;
4321
4315
  class Dragger {
4322
4316
  constructor(interaction) {
4323
4317
  this.interaction = interaction;
@@ -4325,8 +4319,8 @@ class Dragger {
4325
4319
  setDragData(data) {
4326
4320
  this.dragData = getDragEventData(data, data, data);
4327
4321
  }
4328
- getDragList() {
4329
- return this.dragging ? DropEvent.dragList || this.dragList : null;
4322
+ getList() {
4323
+ return this.dragging ? (DragEvent.list || this.interaction.selector.list || this.dragableList || emptyList) : emptyList;
4330
4324
  }
4331
4325
  checkDrag(data, canDrag) {
4332
4326
  const { interaction } = this;
@@ -4355,7 +4349,7 @@ class Dragger {
4355
4349
  interaction.emit(MoveEvent.MOVE, this.dragData);
4356
4350
  }
4357
4351
  else if (this.dragging) {
4358
- this.dragDragableList();
4352
+ this.realDrag();
4359
4353
  interaction.emit(DragEvent.BEFORE_DRAG, this.dragData);
4360
4354
  interaction.emit(DragEvent.DRAG, this.dragData);
4361
4355
  }
@@ -4366,9 +4360,6 @@ class Dragger {
4366
4360
  if (this.dragging) {
4367
4361
  this.interaction.emit(DragEvent.START, this.dragData);
4368
4362
  this.getDragableList(this.dragData.path);
4369
- this.dragList = filterPathByEventType(this.dragData.path, DragEvent.DRAG);
4370
- if (!this.dragList.length && this.dragableList)
4371
- this.dragList.pushList(this.dragableList);
4372
4363
  }
4373
4364
  }
4374
4365
  }
@@ -4377,16 +4368,17 @@ class Dragger {
4377
4368
  for (let i = 0, len = path.length; i < len; i++) {
4378
4369
  leaf = path.list[i];
4379
4370
  if (leaf.__.draggable && leaf.__.hitSelf) {
4380
- this.dragableList = [leaf];
4371
+ this.dragableList = new LeafList(leaf);
4381
4372
  break;
4382
4373
  }
4383
4374
  }
4384
4375
  }
4385
- dragDragableList() {
4376
+ realDrag() {
4386
4377
  const { running } = this.interaction;
4387
- if (this.dragableList && running) {
4378
+ const list = this.getList();
4379
+ if (list.length && running) {
4388
4380
  const { moveX, moveY } = this.dragData;
4389
- this.dragableList.forEach(leaf => {
4381
+ list.forEach(leaf => {
4390
4382
  LeafHelper.moveWorld(leaf, moveX, moveY);
4391
4383
  });
4392
4384
  }
@@ -4443,20 +4435,14 @@ class Dragger {
4443
4435
  }
4444
4436
  }
4445
4437
  drop(data) {
4446
- const dropData = getDropEventData(data, this.getDragList(), DropEvent.dragData);
4438
+ const dropData = getDropEventData(data, this.getList(), DragEvent.data);
4447
4439
  dropData.path = this.dragEnterPath;
4448
4440
  this.interaction.emit(DropEvent.DROP, dropData);
4449
4441
  this.interaction.emit(DragEvent.LEAVE, data, this.dragEnterPath);
4450
4442
  }
4451
4443
  dragReset() {
4452
- DropEvent.dragList = null;
4453
- this.dragList = null;
4454
- this.dragableList = null;
4455
- this.dragData = null;
4456
- this.dragOverPath = null;
4457
- this.dragEnterPath = null;
4458
- this.dragging = null;
4459
- this.moving = null;
4444
+ DragEvent.list = DragEvent.data = this.dragableList = this.dragData = this.dragOverPath = this.dragEnterPath = null;
4445
+ this.dragging = this.moving = false;
4460
4446
  }
4461
4447
  checkDragOut(data) {
4462
4448
  const { interaction } = this;
@@ -4692,6 +4678,10 @@ class InteractionBase {
4692
4678
  this.zoom(getZoomEventData$1(center, scale, data));
4693
4679
  this.move(getMoveEventData$1(center, move, data));
4694
4680
  }
4681
+ menu(data) {
4682
+ this.findPath(data);
4683
+ this.emit(PointerEvent.MENU, data);
4684
+ }
4695
4685
  move(data) {
4696
4686
  this.transformer.move(data);
4697
4687
  }
@@ -4801,6 +4791,9 @@ class InteractionBase {
4801
4791
  data.path = find.path;
4802
4792
  return find.path;
4803
4793
  }
4794
+ isDrag(leaf) {
4795
+ return this.dragger.getList().has(leaf);
4796
+ }
4804
4797
  updateDownData(data) {
4805
4798
  if (!data)
4806
4799
  data = this.downData;
@@ -4814,7 +4807,7 @@ class InteractionBase {
4814
4807
  data = this.hoverData;
4815
4808
  if (!data)
4816
4809
  return;
4817
- this.findPath(data, { exclude: this.dragger.getDragList(), name: PointerEvent.MOVE });
4810
+ this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE });
4818
4811
  this.hoverData = data;
4819
4812
  }
4820
4813
  updateCursor(data) {
@@ -4934,7 +4927,7 @@ class LeafLayout {
4934
4927
  this.renderBounds = this.strokeBounds = this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
4935
4928
  this.localRenderBounds = this.localStrokeBounds = leaf.__local;
4936
4929
  this.boxChange();
4937
- this.positionChange();
4930
+ this.matrixChange();
4938
4931
  }
4939
4932
  checkUpdate(force) {
4940
4933
  const { leafer } = this.leaf;
@@ -5061,11 +5054,6 @@ class LeafLayout {
5061
5054
  this.renderSpread || (this.renderSpread = 1);
5062
5055
  this.boundsChanged = true;
5063
5056
  }
5064
- positionChange() {
5065
- this.positionChanged = true;
5066
- this.matrixChanged = true;
5067
- this.localBoxChanged || this.localBoxChange();
5068
- }
5069
5057
  scaleChange() {
5070
5058
  this.scaleChanged = true;
5071
5059
  this._scaleOrRotationChange();
@@ -5077,6 +5065,9 @@ class LeafLayout {
5077
5065
  }
5078
5066
  _scaleOrRotationChange() {
5079
5067
  this.affectScaleOrRotation = true;
5068
+ this.matrixChange();
5069
+ }
5070
+ matrixChange() {
5080
5071
  this.matrixChanged = true;
5081
5072
  this.localBoxChanged || this.localBoxChange();
5082
5073
  }
@@ -5219,10 +5210,11 @@ function __getListenerMap(eventer, capture, create) {
5219
5210
  const LeafDataProxy = {
5220
5211
  __setAttr(name, newValue) {
5221
5212
  if (this.leafer && this.leafer.created) {
5222
- if (typeof newValue === 'object' || this.__.__getInput(name) !== newValue) {
5213
+ const oldValue = this.__.__getInput(name);
5214
+ if (typeof newValue === 'object' || oldValue !== newValue) {
5223
5215
  this.__[name] = newValue;
5224
5216
  const { CHANGE } = PropertyEvent;
5225
- const event = new PropertyEvent(CHANGE, this, name, this.__.__get(name), newValue);
5217
+ const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
5226
5218
  if (this.hasEvent(CHANGE) && !this.isLeafer)
5227
5219
  this.emitEvent(event);
5228
5220
  this.leafer.emitEvent(event);
@@ -5313,17 +5305,17 @@ const LeafMatrix = {
5313
5305
  }
5314
5306
  }
5315
5307
  }
5316
- if (layout.positionChanged) {
5317
- r.e = this.__.x;
5318
- r.f = this.__.y;
5319
- const { width, height, around } = this.__;
5320
- if (around && width && height) {
5308
+ const { x, y, around } = this.__;
5309
+ r.e = x;
5310
+ r.f = y;
5311
+ if (around) {
5312
+ const { width, height } = this.__;
5313
+ if (width && height) {
5321
5314
  const origin = (around === 'center') ? defaultCenter : around;
5322
5315
  const offsetX = width * origin.x, offsetY = height * origin.y;
5323
5316
  r.e -= offsetX * r.a + offsetY * r.c;
5324
5317
  r.f -= offsetX * r.b + offsetY * r.d;
5325
5318
  }
5326
- layout.positionChanged = false;
5327
5319
  }
5328
5320
  this.__layout.matrixChanged = false;
5329
5321
  }
@@ -5418,7 +5410,7 @@ const LeafBounds = {
5418
5410
  data.__naturalWidth = layout.boxBounds.width;
5419
5411
  data.__naturalHeight = layout.boxBounds.height;
5420
5412
  if (this.around) {
5421
- layout.positionChanged = layout.matrixChanged = true;
5413
+ layout.matrixChanged = true;
5422
5414
  this.__updateWorldMatrix();
5423
5415
  }
5424
5416
  },
@@ -5606,11 +5598,16 @@ let Leaf = class Leaf {
5606
5598
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5607
5599
  constructor(data) {
5608
5600
  this.innerId = create(LEAF);
5601
+ this.reset(data);
5602
+ }
5603
+ reset(data) {
5609
5604
  this.__world = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0, scaleX: 1, scaleY: 1, rotation: 0, skewX: 0, skewY: 0 };
5610
5605
  this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
5611
5606
  this.__worldOpacity = 1;
5612
5607
  this.__ = new this.__DataProcessor(this);
5613
5608
  this.__layout = new this.__LayoutProcessor(this);
5609
+ if (this.__level)
5610
+ this.resetCustom();
5614
5611
  if (data) {
5615
5612
  if (data.children) {
5616
5613
  this.set(data);
@@ -5620,6 +5617,10 @@ let Leaf = class Leaf {
5620
5617
  }
5621
5618
  }
5622
5619
  }
5620
+ resetCustom() {
5621
+ this.__hasMask = this.__hasEraser = null;
5622
+ this.forceUpdate();
5623
+ }
5623
5624
  waitParent(item) {
5624
5625
  this.parent ? item() : (this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item]);
5625
5626
  }
@@ -5634,8 +5635,11 @@ let Leaf = class Leaf {
5634
5635
  if (leafer !== null)
5635
5636
  leafer = this;
5636
5637
  }
5638
+ if (this.leafer && !leafer)
5639
+ this.leafer.leafs--;
5637
5640
  this.leafer = leafer;
5638
5641
  if (leafer) {
5642
+ leafer.leafs++;
5639
5643
  this.__level = this.parent ? this.parent.__level + 1 : 1;
5640
5644
  if (this.__leaferWait)
5641
5645
  WaitHelper.run(this.__leaferWait);
@@ -5658,7 +5662,7 @@ let Leaf = class Leaf {
5658
5662
  __getAttr(_attrName) { return undefined; }
5659
5663
  forceUpdate(attrName) {
5660
5664
  if (attrName === undefined)
5661
- attrName = 'scaleX';
5665
+ attrName = 'width';
5662
5666
  else if (attrName === 'surface')
5663
5667
  attrName = 'blendMode';
5664
5668
  const value = this.__.__getInput(attrName);
@@ -5865,7 +5869,7 @@ let Branch = class Branch extends Leaf {
5865
5869
  index === undefined ? this.children.push(child) : this.children.splice(index, 0, child);
5866
5870
  if (child.isBranch)
5867
5871
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5868
- child.__layout.boundsChanged || child.__layout.positionChange();
5872
+ child.__layout.boundsChanged || child.__layout.matrixChange();
5869
5873
  if (child.__parentWait)
5870
5874
  WaitHelper.run(child.__parentWait);
5871
5875
  if (this.leafer) {
@@ -6084,7 +6088,7 @@ function updateMatrix(updateList, levelList) {
6084
6088
  let layout;
6085
6089
  updateList.list.forEach(leaf => {
6086
6090
  layout = leaf.__layout;
6087
- if (levelList.without(leaf) && !layout.useZoomProxy) {
6091
+ if (levelList.without(leaf) && !layout.proxyZoom) {
6088
6092
  if (layout.matrixChanged) {
6089
6093
  updateAllWorldMatrix$1(leaf);
6090
6094
  levelList.push(leaf);
@@ -6403,8 +6407,7 @@ class Renderer {
6403
6407
  const { canvas, updateBlocks: list } = this;
6404
6408
  if (!list)
6405
6409
  return debug$4.warn('PartRender: need update attr');
6406
- if (list.some(block => block.includes(this.target.__world)))
6407
- this.mergeBlocks();
6410
+ this.mergeBlocks();
6408
6411
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6409
6412
  this.clipRender(block); });
6410
6413
  }
@@ -6423,7 +6426,7 @@ class Renderer {
6423
6426
  canvas.clearWorld(bounds, true);
6424
6427
  canvas.clipWorld(bounds, true);
6425
6428
  }
6426
- this.__render(bounds, realBounds);
6429
+ this.__render(bounds, includes, realBounds);
6427
6430
  canvas.restore();
6428
6431
  Run.end(t);
6429
6432
  }
@@ -6432,12 +6435,12 @@ class Renderer {
6432
6435
  const { canvas } = this;
6433
6436
  canvas.save();
6434
6437
  canvas.clear();
6435
- this.__render(canvas.bounds);
6438
+ this.__render(canvas.bounds, true);
6436
6439
  canvas.restore();
6437
6440
  Run.end(t);
6438
6441
  }
6439
- __render(bounds, realBounds) {
6440
- const options = (bounds === null || bounds === void 0 ? void 0 : bounds.includes(this.target.__world)) ? {} : { bounds };
6442
+ __render(bounds, includes, realBounds) {
6443
+ const options = bounds.includes(this.target.__world) ? { includes } : { bounds, includes };
6441
6444
  if (this.needFill)
6442
6445
  this.canvas.fillWorld(bounds, this.config.fill);
6443
6446
  if (Debug.showRepaint)
@@ -7041,6 +7044,7 @@ class Interaction extends InteractionBase {
7041
7044
  'pointerdown': this.onPointerDown,
7042
7045
  'mousedown': this.onMouseDown,
7043
7046
  'touchstart': this.onTouchStart,
7047
+ 'contextmenu': this.onContextMenu,
7044
7048
  'wheel': this.onWheel,
7045
7049
  'gesturestart': this.onGesturestart,
7046
7050
  'gesturechange': this.onGesturechange,
@@ -7113,6 +7117,9 @@ class Interaction extends InteractionBase {
7113
7117
  onKeyUp(e) {
7114
7118
  this.keyUp(KeyEventHelper.convert(e));
7115
7119
  }
7120
+ onContextMenu(e) {
7121
+ this.menu(PointerEventHelper.convert(e, this.getLocal(e)));
7122
+ }
7116
7123
  onScroll() {
7117
7124
  this.canvas.updateClientBounds();
7118
7125
  }
@@ -7317,6 +7324,11 @@ function useCanvas(_canvasType, _power) {
7317
7324
  });
7318
7325
  }
7319
7326
  };
7327
+ Platform.event = {
7328
+ stopDefault(origin) { origin.preventDefault(); },
7329
+ stopNow(origin) { origin.stopImmediatePropagation(); },
7330
+ stop(origin) { origin.stopPropagation(); }
7331
+ };
7320
7332
  Platform.canvas = Creator.canvas();
7321
7333
  Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient;
7322
7334
  }
@@ -7353,7 +7365,7 @@ function draw(leafer) {
7353
7365
  function design(leafer) {
7354
7366
  if (leafer.isApp)
7355
7367
  return;
7356
- leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => { LeafHelper.moveWorld(leafer.moveLayer, e.moveX, e.moveY); }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
7368
+ leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, (e) => { LeafHelper.moveWorld(leafer.zoomLayer, e.moveX, e.moveY); }), leafer.on_(ZoomEvent.BEFORE_ZOOM, (e) => {
7357
7369
  const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.config.zoom;
7358
7370
  let { scale } = e;
7359
7371
  if (scale * Math.abs(scaleX) < min)
@@ -7434,6 +7446,8 @@ class UIData extends LeafData {
7434
7446
  this.__removeInput('fill');
7435
7447
  Paint.recycleImage('fill', this);
7436
7448
  this.__isFills = false;
7449
+ if (this.__pixelFill)
7450
+ this.__pixelFill = false;
7437
7451
  }
7438
7452
  this._fill = value;
7439
7453
  }
@@ -7450,6 +7464,8 @@ class UIData extends LeafData {
7450
7464
  this.__removeInput('stroke');
7451
7465
  Paint.recycleImage('stroke', this);
7452
7466
  this.__isStrokes = false;
7467
+ if (this.__pixelStroke)
7468
+ this.__pixelStroke = false;
7453
7469
  }
7454
7470
  this._stroke = value;
7455
7471
  }
@@ -7747,9 +7763,9 @@ const UIRender = {
7747
7763
  const { fill, stroke } = this.__;
7748
7764
  this.__drawRenderPath(canvas);
7749
7765
  if (fill)
7750
- Paint.fill('#000000', this, canvas);
7766
+ this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7751
7767
  if (stroke)
7752
- Paint.stroke('#000000', this, canvas, renderOptions);
7768
+ this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas, renderOptions) : Paint.stroke('#000000', this, canvas, renderOptions);
7753
7769
  }
7754
7770
  };
7755
7771
 
@@ -7796,9 +7812,7 @@ let UI = UI_1 = class UI extends Leaf {
7796
7812
  const { scaleX, scaleY } = this;
7797
7813
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
7798
7814
  }
7799
- constructor(data) {
7800
- super(data);
7801
- }
7815
+ reset(_data) { }
7802
7816
  set(data) {
7803
7817
  Object.assign(this, data);
7804
7818
  }
@@ -7987,6 +8001,9 @@ __decorate([
7987
8001
  __decorate([
7988
8002
  effectType()
7989
8003
  ], UI.prototype, "grayscale", void 0);
8004
+ __decorate([
8005
+ rewrite(Leaf.prototype.reset)
8006
+ ], UI.prototype, "reset", null);
7990
8007
  __decorate([
7991
8008
  rewrite(PathDrawer.drawPathByData)
7992
8009
  ], UI.prototype, "__drawPathByData", null);
@@ -8024,8 +8041,12 @@ let Group = class Group extends UI {
8024
8041
  if (data.children) {
8025
8042
  const { children } = data;
8026
8043
  delete data.children;
8027
- if (!this.children)
8044
+ if (!this.children) {
8028
8045
  this.__setBranch();
8046
+ }
8047
+ else {
8048
+ this.removeAll(true);
8049
+ }
8029
8050
  super.set(data);
8030
8051
  let child;
8031
8052
  children.forEach(childData => {
@@ -8226,8 +8247,10 @@ let Ellipse = class Ellipse extends UI {
8226
8247
  ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
8227
8248
  moveTo$3(path, width, ry);
8228
8249
  }
8229
- ellipse(path, rx, ry, rx, ry, 0, 0, 360, true);
8250
+ ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
8230
8251
  }
8252
+ if (Platform.name === 'node')
8253
+ this.__.path = PathConvert.toCanvasData(path, true);
8231
8254
  }
8232
8255
  else {
8233
8256
  if (startAngle || endAngle) {
@@ -8748,10 +8771,10 @@ let Leafer = class Leafer extends Group {
8748
8771
  get __tag() { return 'Leafer'; }
8749
8772
  get isApp() { return false; }
8750
8773
  get app() { return this.parent || this; }
8774
+ get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
8751
8775
  constructor(userConfig, data) {
8752
8776
  super(data);
8753
8777
  this.zoomLayer = this;
8754
- this.moveLayer = this;
8755
8778
  this.config = {
8756
8779
  type: 'design',
8757
8780
  start: true,
@@ -8767,6 +8790,7 @@ let Leafer = class Leafer extends Group {
8767
8790
  autoDistance: 2
8768
8791
  }
8769
8792
  };
8793
+ this.leafs = 0;
8770
8794
  this.__eventIds = [];
8771
8795
  this.__controllers = [];
8772
8796
  this.__readyWait = [];
@@ -8880,9 +8904,8 @@ let Leafer = class Leafer extends Group {
8880
8904
  this.isLeafer = !!leafer;
8881
8905
  this.__level = 1;
8882
8906
  }
8883
- setZoomLayer(zoomLayer, moveLayer) {
8907
+ setZoomLayer(zoomLayer) {
8884
8908
  this.zoomLayer = zoomLayer;
8885
- this.moveLayer = moveLayer || zoomLayer;
8886
8909
  }
8887
8910
  __checkAutoLayout(config) {
8888
8911
  if (!config.width || !config.height) {
@@ -9390,10 +9413,13 @@ function checkImage(ui, canvas, paint, allowPaint) {
9390
9413
  createPattern(ui, paint, canvas.pixelRatio);
9391
9414
  }
9392
9415
  else {
9393
- ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
9394
- if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
9395
- ui.forceUpdate('surface');
9396
- }), 300);
9416
+ if (!paint.patternTask) {
9417
+ paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
9418
+ paint.patternTask = null;
9419
+ if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
9420
+ ui.forceUpdate('surface');
9421
+ }), 300);
9422
+ }
9397
9423
  }
9398
9424
  return false;
9399
9425
  }
@@ -9757,17 +9783,30 @@ function conicGradient(paint, box) {
9757
9783
  let recycleMap;
9758
9784
  function compute(attrName, ui) {
9759
9785
  const value = [];
9786
+ const data = ui.__;
9760
9787
  let item;
9761
- let paints = ui.__.__input[attrName];
9788
+ let paints = data.__input[attrName];
9762
9789
  if (!(paints instanceof Array))
9763
9790
  paints = [paints];
9764
- recycleMap = recycleImage(attrName, ui.__);
9791
+ recycleMap = recycleImage(attrName, data);
9765
9792
  for (let i = 0, len = paints.length; i < len; i++) {
9766
9793
  item = getLeafPaint(attrName, paints[i], ui);
9767
9794
  if (item)
9768
9795
  value.push(item);
9769
9796
  }
9770
- ui.__['_' + attrName] = value.length ? value : undefined;
9797
+ data['_' + attrName] = value.length ? value : undefined;
9798
+ let isPixel;
9799
+ if (paints.length === 1) {
9800
+ const paint = paints[0];
9801
+ if (paint.type === 'image')
9802
+ isPixel = ImageManager.isPixel(paint);
9803
+ }
9804
+ if (attrName === 'fill') {
9805
+ data.__pixelFill = isPixel;
9806
+ }
9807
+ else {
9808
+ data.__pixelStroke = isPixel;
9809
+ }
9771
9810
  }
9772
9811
  function getLeafPaint(attrName, paint, ui) {
9773
9812
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
@@ -10423,4 +10462,4 @@ Object.assign(Export$1, Export);
10423
10462
 
10424
10463
  useCanvas();
10425
10464
 
10426
- export { Animate, AnimateEvent, App, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, Branch, BranchHelper, BranchRender, Canvas, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, DragEvent, DropEvent, Effect, Ellipse, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, Group, HitCanvasManager, Image$1 as Image, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PropertyEvent, Rect, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TransformEvent, TwoPointBounds, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIEvent, UIHit, UIRender, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, aliasType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, setDefaultValue, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };
10465
+ export { Animate, AnimateEvent, App, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, Branch, BranchHelper, BranchRender, Canvas, CanvasManager, ChildEvent, ColorConvert$1 as ColorConvert, Creator, Cursor, DataHelper, Debug, DragEvent, DropEvent, Effect, Ellipse, EllipseHelper, Event, EventCreator, Export$1 as Export, FileHelper, Frame, Group, HitCanvasManager, Image$1 as Image, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafHit, LeafLayout, LeafLevelList, LeafList, LeafMask, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, Path, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, Platform, PluginManager, Point, PointHelper, PointerButton, PointerEvent, Polygon, PropertyEvent, Rect, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert$1 as TextConvert, TwoPointBounds, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIEvent, UIHit, UIRender, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, aliasType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, defineDataProcessor, defineKey, defineLeafAttr, effectType, eraserType, getDescriptor, hitType, layoutProcessor, maskType, opacityType, pathType, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, setDefaultValue, sortType, strokeType, surfaceType, useCanvas, useModule, usePlugin };