leafer-ui 1.0.0-rc.3 → 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.
@@ -654,7 +654,7 @@ const BoundsHelper = {
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;
@@ -4591,7 +4577,8 @@ class InteractionBase {
4591
4577
  dragDistance: 2,
4592
4578
  swipeDistance: 20,
4593
4579
  ignoreMove: false
4594
- }
4580
+ },
4581
+ cursor: {}
4595
4582
  };
4596
4583
  this.tapCount = 0;
4597
4584
  this.downKeyMap = {};
@@ -4691,6 +4678,10 @@ class InteractionBase {
4691
4678
  this.zoom(getZoomEventData$1(center, scale, data));
4692
4679
  this.move(getMoveEventData$1(center, move, data));
4693
4680
  }
4681
+ menu(data) {
4682
+ this.findPath(data);
4683
+ this.emit(PointerEvent.MENU, data);
4684
+ }
4694
4685
  move(data) {
4695
4686
  this.transformer.move(data);
4696
4687
  }
@@ -4800,6 +4791,9 @@ class InteractionBase {
4800
4791
  data.path = find.path;
4801
4792
  return find.path;
4802
4793
  }
4794
+ isDrag(leaf) {
4795
+ return this.dragger.getList().has(leaf);
4796
+ }
4803
4797
  updateDownData(data) {
4804
4798
  if (!data)
4805
4799
  data = this.downData;
@@ -4813,10 +4807,12 @@ class InteractionBase {
4813
4807
  data = this.hoverData;
4814
4808
  if (!data)
4815
4809
  return;
4816
- this.findPath(data, { exclude: this.dragger.getDragList(), name: PointerEvent.MOVE });
4810
+ this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE });
4817
4811
  this.hoverData = data;
4818
4812
  }
4819
4813
  updateCursor(data) {
4814
+ if (this.config.cursor.stop)
4815
+ return;
4820
4816
  if (!data) {
4821
4817
  this.updateHoverData();
4822
4818
  data = this.hoverData;
@@ -4829,17 +4825,16 @@ class InteractionBase {
4829
4825
  }
4830
4826
  else if (!data || this.dragger.dragging)
4831
4827
  return;
4832
- const path = data.path;
4833
4828
  let leaf;
4829
+ let cursor;
4830
+ const { path } = data;
4834
4831
  for (let i = 0, len = path.length; i < len; i++) {
4835
4832
  leaf = path.list[i];
4836
- if (leaf.cursor) {
4837
- const { cursor } = leaf;
4838
- this.setCursor(cursor === 'grab' ? (this.downData ? 'grabbing' : cursor) : cursor);
4839
- return;
4840
- }
4833
+ cursor = leaf.cursor;
4834
+ if (cursor)
4835
+ break;
4841
4836
  }
4842
- this.setCursor('default');
4837
+ this.setCursor(cursor);
4843
4838
  }
4844
4839
  setCursor(cursor) {
4845
4840
  this.cursor = cursor;
@@ -4932,7 +4927,7 @@ class LeafLayout {
4932
4927
  this.renderBounds = this.strokeBounds = this.boxBounds = { x: 0, y: 0, width: 0, height: 0 };
4933
4928
  this.localRenderBounds = this.localStrokeBounds = leaf.__local;
4934
4929
  this.boxChange();
4935
- this.positionChange();
4930
+ this.matrixChange();
4936
4931
  }
4937
4932
  checkUpdate(force) {
4938
4933
  const { leafer } = this.leaf;
@@ -5059,11 +5054,6 @@ class LeafLayout {
5059
5054
  this.renderSpread || (this.renderSpread = 1);
5060
5055
  this.boundsChanged = true;
5061
5056
  }
5062
- positionChange() {
5063
- this.positionChanged = true;
5064
- this.matrixChanged = true;
5065
- this.localBoxChanged || this.localBoxChange();
5066
- }
5067
5057
  scaleChange() {
5068
5058
  this.scaleChanged = true;
5069
5059
  this._scaleOrRotationChange();
@@ -5075,6 +5065,9 @@ class LeafLayout {
5075
5065
  }
5076
5066
  _scaleOrRotationChange() {
5077
5067
  this.affectScaleOrRotation = true;
5068
+ this.matrixChange();
5069
+ }
5070
+ matrixChange() {
5078
5071
  this.matrixChanged = true;
5079
5072
  this.localBoxChanged || this.localBoxChange();
5080
5073
  }
@@ -5217,10 +5210,11 @@ function __getListenerMap(eventer, capture, create) {
5217
5210
  const LeafDataProxy = {
5218
5211
  __setAttr(name, newValue) {
5219
5212
  if (this.leafer && this.leafer.created) {
5220
- if (typeof newValue === 'object' || this.__.__getInput(name) !== newValue) {
5213
+ const oldValue = this.__.__getInput(name);
5214
+ if (typeof newValue === 'object' || oldValue !== newValue) {
5221
5215
  this.__[name] = newValue;
5222
5216
  const { CHANGE } = PropertyEvent;
5223
- const event = new PropertyEvent(CHANGE, this, name, this.__.__get(name), newValue);
5217
+ const event = new PropertyEvent(CHANGE, this, name, oldValue, newValue);
5224
5218
  if (this.hasEvent(CHANGE) && !this.isLeafer)
5225
5219
  this.emitEvent(event);
5226
5220
  this.leafer.emitEvent(event);
@@ -5311,17 +5305,17 @@ const LeafMatrix = {
5311
5305
  }
5312
5306
  }
5313
5307
  }
5314
- if (layout.positionChanged) {
5315
- r.e = this.__.x;
5316
- r.f = this.__.y;
5317
- const { width, height, around } = this.__;
5318
- 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) {
5319
5314
  const origin = (around === 'center') ? defaultCenter : around;
5320
5315
  const offsetX = width * origin.x, offsetY = height * origin.y;
5321
5316
  r.e -= offsetX * r.a + offsetY * r.c;
5322
5317
  r.f -= offsetX * r.b + offsetY * r.d;
5323
5318
  }
5324
- layout.positionChanged = false;
5325
5319
  }
5326
5320
  this.__layout.matrixChanged = false;
5327
5321
  }
@@ -5416,7 +5410,7 @@ const LeafBounds = {
5416
5410
  data.__naturalWidth = layout.boxBounds.width;
5417
5411
  data.__naturalHeight = layout.boxBounds.height;
5418
5412
  if (this.around) {
5419
- layout.positionChanged = layout.matrixChanged = true;
5413
+ layout.matrixChanged = true;
5420
5414
  this.__updateWorldMatrix();
5421
5415
  }
5422
5416
  },
@@ -5457,7 +5451,7 @@ const LeafRender = {
5457
5451
  const tempCanvas = canvas.getSameCanvas(true);
5458
5452
  this.__draw(tempCanvas, options);
5459
5453
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5460
- if (options.matrix || this.__hasMirror) {
5454
+ if (this.__hasMirror || options.matrix) {
5461
5455
  canvas.copyWorldByReset(tempCanvas, null, null, blendMode);
5462
5456
  }
5463
5457
  else {
@@ -5526,7 +5520,12 @@ const BranchRender = {
5526
5520
  this.__renderBranch(tempCanvas, options);
5527
5521
  canvas.opacity = this.__worldOpacity;
5528
5522
  const blendMode = this.__.isEraser ? 'destination-out' : this.__.blendMode;
5529
- options.matrix ? canvas.copyWorld(tempCanvas, null, null, blendMode) : canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
5523
+ if (this.__hasMirror || options.matrix) {
5524
+ canvas.copyWorld(tempCanvas, null, null, blendMode);
5525
+ }
5526
+ else {
5527
+ canvas.copyWorld(tempCanvas, this.__world, this.__world, blendMode);
5528
+ }
5530
5529
  tempCanvas.recycle();
5531
5530
  }
5532
5531
  else {
@@ -5599,11 +5598,16 @@ let Leaf = class Leaf {
5599
5598
  get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
5600
5599
  constructor(data) {
5601
5600
  this.innerId = create(LEAF);
5601
+ this.reset(data);
5602
+ }
5603
+ reset(data) {
5602
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 };
5603
5605
  this.__local = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0, x: 0, y: 0, width: 0, height: 0 };
5604
5606
  this.__worldOpacity = 1;
5605
5607
  this.__ = new this.__DataProcessor(this);
5606
5608
  this.__layout = new this.__LayoutProcessor(this);
5609
+ if (this.__level)
5610
+ this.resetCustom();
5607
5611
  if (data) {
5608
5612
  if (data.children) {
5609
5613
  this.set(data);
@@ -5613,6 +5617,10 @@ let Leaf = class Leaf {
5613
5617
  }
5614
5618
  }
5615
5619
  }
5620
+ resetCustom() {
5621
+ this.__hasMask = this.__hasEraser = null;
5622
+ this.forceUpdate();
5623
+ }
5616
5624
  waitParent(item) {
5617
5625
  this.parent ? item() : (this.__parentWait ? this.__parentWait.push(item) : this.__parentWait = [item]);
5618
5626
  }
@@ -5627,8 +5635,11 @@ let Leaf = class Leaf {
5627
5635
  if (leafer !== null)
5628
5636
  leafer = this;
5629
5637
  }
5638
+ if (this.leafer && !leafer)
5639
+ this.leafer.leafs--;
5630
5640
  this.leafer = leafer;
5631
5641
  if (leafer) {
5642
+ leafer.leafs++;
5632
5643
  this.__level = this.parent ? this.parent.__level + 1 : 1;
5633
5644
  if (this.__leaferWait)
5634
5645
  WaitHelper.run(this.__leaferWait);
@@ -5651,7 +5662,7 @@ let Leaf = class Leaf {
5651
5662
  __getAttr(_attrName) { return undefined; }
5652
5663
  forceUpdate(attrName) {
5653
5664
  if (attrName === undefined)
5654
- attrName = 'scaleX';
5665
+ attrName = 'width';
5655
5666
  else if (attrName === 'surface')
5656
5667
  attrName = 'blendMode';
5657
5668
  const value = this.__.__getInput(attrName);
@@ -5858,7 +5869,7 @@ let Branch = class Branch extends Leaf {
5858
5869
  index === undefined ? this.children.push(child) : this.children.splice(index, 0, child);
5859
5870
  if (child.isBranch)
5860
5871
  this.__.__childBranchNumber = (this.__.__childBranchNumber || 0) + 1;
5861
- child.__layout.boundsChanged || child.__layout.positionChange();
5872
+ child.__layout.boundsChanged || child.__layout.matrixChange();
5862
5873
  if (child.__parentWait)
5863
5874
  WaitHelper.run(child.__parentWait);
5864
5875
  if (this.leafer) {
@@ -6077,7 +6088,7 @@ function updateMatrix(updateList, levelList) {
6077
6088
  let layout;
6078
6089
  updateList.list.forEach(leaf => {
6079
6090
  layout = leaf.__layout;
6080
- if (levelList.without(leaf) && !layout.useZoomProxy) {
6091
+ if (levelList.without(leaf) && !layout.proxyZoom) {
6081
6092
  if (layout.matrixChanged) {
6082
6093
  updateAllWorldMatrix$1(leaf);
6083
6094
  levelList.push(leaf);
@@ -6396,8 +6407,7 @@ class Renderer {
6396
6407
  const { canvas, updateBlocks: list } = this;
6397
6408
  if (!list)
6398
6409
  return debug$4.warn('PartRender: need update attr');
6399
- if (list.some(block => block.includes(this.target.__world)))
6400
- this.mergeBlocks();
6410
+ this.mergeBlocks();
6401
6411
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6402
6412
  this.clipRender(block); });
6403
6413
  }
@@ -6416,7 +6426,7 @@ class Renderer {
6416
6426
  canvas.clearWorld(bounds, true);
6417
6427
  canvas.clipWorld(bounds, true);
6418
6428
  }
6419
- this.__render(bounds, realBounds);
6429
+ this.__render(bounds, includes, realBounds);
6420
6430
  canvas.restore();
6421
6431
  Run.end(t);
6422
6432
  }
@@ -6425,12 +6435,12 @@ class Renderer {
6425
6435
  const { canvas } = this;
6426
6436
  canvas.save();
6427
6437
  canvas.clear();
6428
- this.__render(canvas.bounds);
6438
+ this.__render(canvas.bounds, true);
6429
6439
  canvas.restore();
6430
6440
  Run.end(t);
6431
6441
  }
6432
- __render(bounds, realBounds) {
6433
- 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 };
6434
6444
  if (this.needFill)
6435
6445
  this.canvas.fillWorld(bounds, this.config.fill);
6436
6446
  if (Debug.showRepaint)
@@ -7034,6 +7044,7 @@ class Interaction extends InteractionBase {
7034
7044
  'pointerdown': this.onPointerDown,
7035
7045
  'mousedown': this.onMouseDown,
7036
7046
  'touchstart': this.onTouchStart,
7047
+ 'contextmenu': this.onContextMenu,
7037
7048
  'wheel': this.onWheel,
7038
7049
  'gesturestart': this.onGesturestart,
7039
7050
  'gesturechange': this.onGesturechange,
@@ -7106,6 +7117,9 @@ class Interaction extends InteractionBase {
7106
7117
  onKeyUp(e) {
7107
7118
  this.keyUp(KeyEventHelper.convert(e));
7108
7119
  }
7120
+ onContextMenu(e) {
7121
+ this.menu(PointerEventHelper.convert(e, this.getLocal(e)));
7122
+ }
7109
7123
  onScroll() {
7110
7124
  this.canvas.updateClientBounds();
7111
7125
  }
@@ -7310,6 +7324,11 @@ function useCanvas(_canvasType, _power) {
7310
7324
  });
7311
7325
  }
7312
7326
  };
7327
+ Platform.event = {
7328
+ stopDefault(origin) { origin.preventDefault(); },
7329
+ stopNow(origin) { origin.stopImmediatePropagation(); },
7330
+ stop(origin) { origin.stopPropagation(); }
7331
+ };
7313
7332
  Platform.canvas = Creator.canvas();
7314
7333
  Platform.conicGradientSupport = !!Platform.canvas.context.createConicGradient;
7315
7334
  }
@@ -7346,7 +7365,7 @@ function draw(leafer) {
7346
7365
  function design(leafer) {
7347
7366
  if (leafer.isApp)
7348
7367
  return;
7349
- 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) => {
7350
7369
  const { scaleX } = leafer.zoomLayer.__, { min, max } = leafer.config.zoom;
7351
7370
  let { scale } = e;
7352
7371
  if (scale * Math.abs(scaleX) < min)
@@ -7425,8 +7444,10 @@ class UIData extends LeafData {
7425
7444
  if (typeof value === 'string' || !value) {
7426
7445
  if (this.__isFills) {
7427
7446
  this.__removeInput('fill');
7428
- Paint.recycleImage(this, 'fill');
7447
+ Paint.recycleImage('fill', this);
7429
7448
  this.__isFills = false;
7449
+ if (this.__pixelFill)
7450
+ this.__pixelFill = false;
7430
7451
  }
7431
7452
  this._fill = value;
7432
7453
  }
@@ -7441,8 +7462,10 @@ class UIData extends LeafData {
7441
7462
  if (typeof value === 'string' || !value) {
7442
7463
  if (this.__isStrokes) {
7443
7464
  this.__removeInput('stroke');
7444
- Paint.recycleImage(this, 'stroke');
7465
+ Paint.recycleImage('stroke', this);
7445
7466
  this.__isStrokes = false;
7467
+ if (this.__pixelStroke)
7468
+ this.__pixelStroke = false;
7446
7469
  }
7447
7470
  this._stroke = value;
7448
7471
  }
@@ -7693,11 +7716,11 @@ const UIRender = {
7693
7716
  const { fill, stroke, __drawAfterFill } = this.__;
7694
7717
  this.__drawRenderPath(canvas);
7695
7718
  if (fill)
7696
- Paint.fill(this, canvas, fill);
7719
+ Paint.fill(fill, this, canvas);
7697
7720
  if (__drawAfterFill)
7698
7721
  this.__drawAfterFill(canvas, options);
7699
7722
  if (stroke)
7700
- Paint.stroke(this, canvas, stroke);
7723
+ Paint.stroke(stroke, this, canvas, options);
7701
7724
  },
7702
7725
  __draw(canvas, options) {
7703
7726
  if (this.__.__complex) {
@@ -7709,40 +7732,40 @@ const UIRender = {
7709
7732
  if (shadow)
7710
7733
  Effect.shadow(this, canvas, shape, options);
7711
7734
  if (fill)
7712
- this.__.__isFills ? Paint.fills(this, canvas, fill) : Paint.fill(this, canvas, fill);
7735
+ this.__.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7713
7736
  if (__drawAfterFill)
7714
7737
  this.__drawAfterFill(canvas, options);
7715
7738
  if (innerShadow)
7716
7739
  Effect.innerShadow(this, canvas, shape, options);
7717
7740
  if (stroke)
7718
- this.__.__isStrokes ? Paint.strokes(this, canvas, stroke) : Paint.stroke(this, canvas, stroke);
7741
+ this.__.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
7719
7742
  if (shape.worldCanvas)
7720
7743
  shape.worldCanvas.recycle();
7721
7744
  shape.canvas.recycle();
7722
7745
  }
7723
7746
  else {
7724
7747
  if (fill)
7725
- this.__.__isFills ? Paint.fills(this, canvas, fill) : Paint.fill(this, canvas, fill);
7748
+ this.__.__isFills ? Paint.fills(fill, this, canvas) : Paint.fill(fill, this, canvas);
7726
7749
  if (__drawAfterFill)
7727
7750
  this.__drawAfterFill(canvas, options);
7728
7751
  if (stroke)
7729
- this.__.__isStrokes ? Paint.strokes(this, canvas, stroke) : Paint.stroke(this, canvas, stroke);
7752
+ this.__.__isStrokes ? Paint.strokes(stroke, this, canvas, options) : Paint.stroke(stroke, this, canvas, options);
7730
7753
  }
7731
7754
  }
7732
7755
  else {
7733
7756
  this.__drawFast(canvas, options);
7734
7757
  }
7735
7758
  },
7736
- __renderShape(canvas, options) {
7759
+ __renderShape(canvas, renderOptions) {
7737
7760
  if (!this.__worldOpacity)
7738
7761
  return;
7739
- canvas.setWorld(this.__world, options.matrix);
7762
+ canvas.setWorld(this.__world, renderOptions.matrix);
7740
7763
  const { fill, stroke } = this.__;
7741
7764
  this.__drawRenderPath(canvas);
7742
7765
  if (fill)
7743
- Paint.fill(this, canvas, '#000000');
7766
+ this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
7744
7767
  if (stroke)
7745
- Paint.stroke(this, canvas, '#000000');
7768
+ this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas, renderOptions) : Paint.stroke('#000000', this, canvas, renderOptions);
7746
7769
  }
7747
7770
  };
7748
7771
 
@@ -7789,9 +7812,7 @@ let UI = UI_1 = class UI extends Leaf {
7789
7812
  const { scaleX, scaleY } = this;
7790
7813
  return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX;
7791
7814
  }
7792
- constructor(data) {
7793
- super(data);
7794
- }
7815
+ reset(_data) { }
7795
7816
  set(data) {
7796
7817
  Object.assign(this, data);
7797
7818
  }
@@ -7811,9 +7832,9 @@ let UI = UI_1 = class UI extends Leaf {
7811
7832
  if (this.__.__input) {
7812
7833
  const { fill, stroke } = this.__.__input;
7813
7834
  if (fill)
7814
- Paint.compute(this, 'fill');
7835
+ Paint.compute('fill', this);
7815
7836
  if (stroke)
7816
- Paint.compute(this, 'stroke');
7837
+ Paint.compute('stroke', this);
7817
7838
  }
7818
7839
  }
7819
7840
  __updateRenderPath() {
@@ -7930,7 +7951,7 @@ __decorate([
7930
7951
  hitType()
7931
7952
  ], UI.prototype, "hitRadius", void 0);
7932
7953
  __decorate([
7933
- cursorType('default')
7954
+ cursorType('')
7934
7955
  ], UI.prototype, "cursor", void 0);
7935
7956
  __decorate([
7936
7957
  surfaceType()
@@ -7980,6 +8001,9 @@ __decorate([
7980
8001
  __decorate([
7981
8002
  effectType()
7982
8003
  ], UI.prototype, "grayscale", void 0);
8004
+ __decorate([
8005
+ rewrite(Leaf.prototype.reset)
8006
+ ], UI.prototype, "reset", null);
7983
8007
  __decorate([
7984
8008
  rewrite(PathDrawer.drawPathByData)
7985
8009
  ], UI.prototype, "__drawPathByData", null);
@@ -8017,8 +8041,12 @@ let Group = class Group extends UI {
8017
8041
  if (data.children) {
8018
8042
  const { children } = data;
8019
8043
  delete data.children;
8020
- if (!this.children)
8044
+ if (!this.children) {
8021
8045
  this.__setBranch();
8046
+ }
8047
+ else {
8048
+ this.removeAll(true);
8049
+ }
8022
8050
  super.set(data);
8023
8051
  let child;
8024
8052
  children.forEach(childData => {
@@ -8219,8 +8247,10 @@ let Ellipse = class Ellipse extends UI {
8219
8247
  ellipse(path, rx, ry, rx * innerRadius, ry * innerRadius);
8220
8248
  moveTo$3(path, width, ry);
8221
8249
  }
8222
- ellipse(path, rx, ry, rx, ry, 0, 0, 360, true);
8250
+ ellipse(path, rx, ry, rx, ry, 0, 360, 0, true);
8223
8251
  }
8252
+ if (Platform.name === 'node')
8253
+ this.__.path = PathConvert.toCanvasData(path, true);
8224
8254
  }
8225
8255
  else {
8226
8256
  if (startAngle || endAngle) {
@@ -8741,10 +8771,10 @@ let Leafer = class Leafer extends Group {
8741
8771
  get __tag() { return 'Leafer'; }
8742
8772
  get isApp() { return false; }
8743
8773
  get app() { return this.parent || this; }
8774
+ get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
8744
8775
  constructor(userConfig, data) {
8745
8776
  super(data);
8746
8777
  this.zoomLayer = this;
8747
- this.moveLayer = this;
8748
8778
  this.config = {
8749
8779
  type: 'design',
8750
8780
  start: true,
@@ -8760,6 +8790,7 @@ let Leafer = class Leafer extends Group {
8760
8790
  autoDistance: 2
8761
8791
  }
8762
8792
  };
8793
+ this.leafs = 0;
8763
8794
  this.__eventIds = [];
8764
8795
  this.__controllers = [];
8765
8796
  this.__readyWait = [];
@@ -8873,9 +8904,8 @@ let Leafer = class Leafer extends Group {
8873
8904
  this.isLeafer = !!leafer;
8874
8905
  this.__level = 1;
8875
8906
  }
8876
- setZoomLayer(zoomLayer, moveLayer) {
8907
+ setZoomLayer(zoomLayer) {
8877
8908
  this.zoomLayer = zoomLayer;
8878
- this.moveLayer = moveLayer || zoomLayer;
8879
8909
  }
8880
8910
  __checkAutoLayout(config) {
8881
8911
  if (!config.width || !config.height) {
@@ -9383,17 +9413,20 @@ function checkImage(ui, canvas, paint, allowPaint) {
9383
9413
  createPattern(ui, paint, canvas.pixelRatio);
9384
9414
  }
9385
9415
  else {
9386
- ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
9387
- if (canvas.bounds.hit(ui.__world) && createPattern(ui, paint, canvas.pixelRatio))
9388
- ui.forceUpdate('surface');
9389
- }), 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
+ }
9390
9423
  }
9391
9424
  return false;
9392
9425
  }
9393
9426
  }
9394
9427
  }
9395
9428
 
9396
- function recycleImage(data, attrName) {
9429
+ function recycleImage(attrName, data) {
9397
9430
  const paints = (attrName === 'fill' ? data._fill : data._stroke);
9398
9431
  if (paints instanceof Array) {
9399
9432
  let image, recycleMap, input, url;
@@ -9438,11 +9471,11 @@ function fillText(ui, canvas) {
9438
9471
  }
9439
9472
  }
9440
9473
 
9441
- function fill(ui, canvas, fill) {
9474
+ function fill(fill, ui, canvas) {
9442
9475
  canvas.fillStyle = fill;
9443
9476
  ui.__.__font ? fillText(ui, canvas) : (ui.__.windingRule ? canvas.fill(ui.__.windingRule) : canvas.fill());
9444
9477
  }
9445
- function fills(ui, canvas, fills) {
9478
+ function fills(fills, ui, canvas) {
9446
9479
  let item;
9447
9480
  const { windingRule, __font } = ui.__;
9448
9481
  for (let i = 0, len = fills.length; i < len; i++) {
@@ -9473,32 +9506,37 @@ function fills(ui, canvas, fills) {
9473
9506
  }
9474
9507
  }
9475
9508
 
9476
- function strokeText(ui, canvas, stroke) {
9509
+ function strokeText(stroke, ui, canvas, renderOptions) {
9477
9510
  const { strokeAlign } = ui.__;
9478
9511
  const isStrokes = typeof stroke !== 'string';
9479
9512
  switch (strokeAlign) {
9480
9513
  case 'center':
9481
9514
  canvas.setStroke(isStrokes ? undefined : stroke, ui.__.strokeWidth, ui.__);
9482
- isStrokes ? drawStrokesStyle(ui, stroke, canvas, true) : drawTextStroke(ui, canvas);
9515
+ isStrokes ? drawStrokesStyle(stroke, true, ui, canvas) : drawTextStroke(ui, canvas);
9483
9516
  break;
9484
9517
  case 'inside':
9485
- drawAlignStroke(ui, canvas, stroke, 'inside', isStrokes);
9518
+ drawAlignStroke('inside', stroke, isStrokes, ui, canvas, renderOptions);
9486
9519
  break;
9487
9520
  case 'outside':
9488
- drawAlignStroke(ui, canvas, stroke, 'outside', isStrokes);
9521
+ drawAlignStroke('outside', stroke, isStrokes, ui, canvas, renderOptions);
9489
9522
  break;
9490
9523
  }
9491
9524
  }
9492
- function drawAlignStroke(ui, canvas, stroke, align, isStrokes) {
9525
+ function drawAlignStroke(align, stroke, isStrokes, ui, canvas, renderOptions) {
9493
9526
  const { strokeWidth, __font } = ui.__;
9494
9527
  const out = canvas.getSameCanvas(true);
9495
9528
  out.setStroke(isStrokes ? undefined : stroke, strokeWidth * 2, ui.__);
9496
9529
  out.font = __font;
9497
- isStrokes ? drawStrokesStyle(ui, stroke, out, true) : drawTextStroke(ui, out);
9530
+ isStrokes ? drawStrokesStyle(stroke, true, ui, out) : drawTextStroke(ui, out);
9498
9531
  out.blendMode = align === 'outside' ? 'destination-out' : 'destination-in';
9499
9532
  fillText(ui, out);
9500
9533
  out.blendMode = 'normal';
9501
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
9534
+ if (ui.__hasMirror || renderOptions.matrix) {
9535
+ canvas.copyWorldByReset(out);
9536
+ }
9537
+ else {
9538
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
9539
+ }
9502
9540
  out.recycle();
9503
9541
  }
9504
9542
  function drawTextStroke(ui, canvas) {
@@ -9518,7 +9556,7 @@ function drawTextStroke(ui, canvas) {
9518
9556
  canvas.strokeRect(row.x, row.y + decorationY, row.width, decorationHeight);
9519
9557
  }
9520
9558
  }
9521
- function drawStrokesStyle(ui, strokes, canvas, isText) {
9559
+ function drawStrokesStyle(strokes, isText, ui, canvas) {
9522
9560
  let item;
9523
9561
  for (let i = 0, len = strokes.length; i < len; i++) {
9524
9562
  item = strokes[i];
@@ -9538,13 +9576,13 @@ function drawStrokesStyle(ui, strokes, canvas, isText) {
9538
9576
  }
9539
9577
  }
9540
9578
 
9541
- function stroke(ui, canvas, stroke) {
9579
+ function stroke(stroke, ui, canvas, renderOptions) {
9542
9580
  const options = ui.__;
9543
9581
  const { strokeWidth, strokeAlign, __font } = options;
9544
9582
  if (!strokeWidth)
9545
9583
  return;
9546
9584
  if (__font) {
9547
- strokeText(ui, canvas, stroke);
9585
+ strokeText(stroke, ui, canvas, renderOptions);
9548
9586
  }
9549
9587
  else {
9550
9588
  switch (strokeAlign) {
@@ -9566,31 +9604,36 @@ function stroke(ui, canvas, stroke) {
9566
9604
  out.stroke();
9567
9605
  options.windingRule ? out.clip(options.windingRule) : out.clip();
9568
9606
  out.clearWorld(ui.__layout.renderBounds);
9569
- canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
9607
+ if (ui.__hasMirror || renderOptions.matrix) {
9608
+ canvas.copyWorldByReset(out);
9609
+ }
9610
+ else {
9611
+ canvas.copyWorldToInner(out, ui.__world, ui.__layout.renderBounds);
9612
+ }
9570
9613
  out.recycle();
9571
9614
  break;
9572
9615
  }
9573
9616
  }
9574
9617
  }
9575
- function strokes(ui, canvas, strokes) {
9618
+ function strokes(strokes, ui, canvas, renderOptions) {
9576
9619
  const options = ui.__;
9577
9620
  const { strokeWidth, strokeAlign, __font } = options;
9578
9621
  if (!strokeWidth)
9579
9622
  return;
9580
9623
  if (__font) {
9581
- strokeText(ui, canvas, strokes);
9624
+ strokeText(strokes, ui, canvas, renderOptions);
9582
9625
  }
9583
9626
  else {
9584
9627
  switch (strokeAlign) {
9585
9628
  case 'center':
9586
9629
  canvas.setStroke(undefined, strokeWidth, options);
9587
- drawStrokesStyle(ui, strokes, canvas);
9630
+ drawStrokesStyle(strokes, false, ui, canvas);
9588
9631
  break;
9589
9632
  case 'inside':
9590
9633
  canvas.save();
9591
9634
  canvas.setStroke(undefined, strokeWidth * 2, options);
9592
9635
  options.windingRule ? canvas.clip(options.windingRule) : canvas.clip();
9593
- drawStrokesStyle(ui, strokes, canvas);
9636
+ drawStrokesStyle(strokes, false, ui, canvas);
9594
9637
  canvas.restore();
9595
9638
  break;
9596
9639
  case 'outside':
@@ -9598,10 +9641,15 @@ function strokes(ui, canvas, strokes) {
9598
9641
  const out = canvas.getSameCanvas(true);
9599
9642
  ui.__drawRenderPath(out);
9600
9643
  out.setStroke(undefined, strokeWidth * 2, ui.__);
9601
- drawStrokesStyle(ui, strokes, out);
9644
+ drawStrokesStyle(strokes, false, ui, out);
9602
9645
  options.windingRule ? out.clip(options.windingRule) : out.clip();
9603
9646
  out.clearWorld(renderBounds);
9604
- canvas.copyWorldToInner(out, ui.__world, renderBounds);
9647
+ if (ui.__hasMirror || renderOptions.matrix) {
9648
+ canvas.copyWorldByReset(out);
9649
+ }
9650
+ else {
9651
+ canvas.copyWorldToInner(out, ui.__world, renderBounds);
9652
+ }
9605
9653
  out.recycle();
9606
9654
  break;
9607
9655
  }
@@ -9733,21 +9781,34 @@ function conicGradient(paint, box) {
9733
9781
  }
9734
9782
 
9735
9783
  let recycleMap;
9736
- function compute(ui, attrName) {
9784
+ function compute(attrName, ui) {
9737
9785
  const value = [];
9786
+ const data = ui.__;
9738
9787
  let item;
9739
- let paints = ui.__.__input[attrName];
9788
+ let paints = data.__input[attrName];
9740
9789
  if (!(paints instanceof Array))
9741
9790
  paints = [paints];
9742
- recycleMap = recycleImage(ui.__, attrName);
9791
+ recycleMap = recycleImage(attrName, data);
9743
9792
  for (let i = 0, len = paints.length; i < len; i++) {
9744
- item = getLeafPaint(ui, paints[i], attrName);
9793
+ item = getLeafPaint(attrName, paints[i], ui);
9745
9794
  if (item)
9746
9795
  value.push(item);
9747
9796
  }
9748
- 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
+ }
9749
9810
  }
9750
- function getLeafPaint(ui, paint, attrName) {
9811
+ function getLeafPaint(attrName, paint, ui) {
9751
9812
  if (typeof paint !== 'object' || paint.visible === false || paint.opacity === 0)
9752
9813
  return undefined;
9753
9814
  const { boxBounds } = ui.__layout;
@@ -9785,7 +9846,7 @@ var UIPaint = /*#__PURE__*/Object.freeze({
9785
9846
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
9786
9847
  const tempBounds = {};
9787
9848
  const offsetOutBounds$1 = {};
9788
- function shadow(ui, current, shape, _options) {
9849
+ function shadow(ui, current, shape, renderOptions) {
9789
9850
  let copyBounds, spreadScale;
9790
9851
  const { __world, __layout } = ui;
9791
9852
  const { shadow } = ui.__;
@@ -9807,7 +9868,7 @@ function shadow(ui, current, shape, _options) {
9807
9868
  }
9808
9869
  worldCanvas ? other.copyWorld(worldCanvas, __world, __world, 'destination-out') : other.copyWorld(shape.canvas, shapeBounds, bounds, 'destination-out');
9809
9870
  }
9810
- if (ui.__hasMirror) {
9871
+ if (ui.__hasMirror || renderOptions.matrix) {
9811
9872
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
9812
9873
  }
9813
9874
  else {
@@ -9847,7 +9908,7 @@ function drawWorldShadow(canvas, outBounds, spreadScale, shape) {
9847
9908
 
9848
9909
  const { toOffsetOutBounds } = BoundsHelper;
9849
9910
  const offsetOutBounds = {};
9850
- function innerShadow(ui, current, shape, _options) {
9911
+ function innerShadow(ui, current, shape, renderOptions) {
9851
9912
  let copyBounds, spreadScale;
9852
9913
  const { __world, __layout: __layout } = ui;
9853
9914
  const { innerShadow } = ui.__;
@@ -9871,7 +9932,7 @@ function innerShadow(ui, current, shape, _options) {
9871
9932
  copyBounds = bounds;
9872
9933
  }
9873
9934
  other.fillWorld(copyBounds, item.color, 'source-in');
9874
- if (ui.__hasMirror) {
9935
+ if (ui.__hasMirror || renderOptions.matrix) {
9875
9936
  current.copyWorldByReset(other, copyBounds, __world, item.blendMode);
9876
9937
  }
9877
9938
  else {
@@ -10401,4 +10462,4 @@ Object.assign(Export$1, Export);
10401
10462
 
10402
10463
  useCanvas();
10403
10464
 
10404
- 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 };