leafer-ui 1.0.0-rc.25 → 1.0.0-rc.26

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.
@@ -1,4 +1,12 @@
1
1
  const Platform = {
2
+ toURL(text, fileType) {
3
+ let url = encodeURIComponent(text);
4
+ if (fileType === 'text')
5
+ url = 'data:text/plain;charset=utf-8,' + url;
6
+ else if (fileType === 'svg')
7
+ url = 'data:image/svg+xml,' + url;
8
+ return url;
9
+ },
2
10
  image: {
3
11
  hitCanvasSize: 100,
4
12
  maxCacheSize: 2560 * 1600,
@@ -956,6 +964,9 @@ const BoundsHelper = {
956
964
  points.forEach((point, index) => index === 0 ? setPoint$3(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
957
965
  toBounds$4(tempPointBounds$1, t);
958
966
  },
967
+ setPoint(t, point) {
968
+ B.set(t, point.x, point.y);
969
+ },
959
970
  addPoint(t, point) {
960
971
  add$1(t, point, true);
961
972
  },
@@ -1104,6 +1115,10 @@ class Bounds {
1104
1115
  BoundsHelper.setListWithFn(this, list, boundsDataFn);
1105
1116
  return this;
1106
1117
  }
1118
+ setPoint(point) {
1119
+ BoundsHelper.setPoint(this, point);
1120
+ return this;
1121
+ }
1107
1122
  setPoints(points) {
1108
1123
  BoundsHelper.setPoints(this, points);
1109
1124
  return this;
@@ -1207,10 +1222,10 @@ directionData.forEach(item => item.type = 'percent');
1207
1222
  const AroundHelper = {
1208
1223
  directionData,
1209
1224
  tempPoint: {},
1210
- get: get$5,
1225
+ get: get$4,
1211
1226
  toPoint(around, bounds, to, onlySize, pointBounds) {
1212
1227
  to || (to = {});
1213
- const point = get$5(around);
1228
+ const point = get$4(around);
1214
1229
  to.x = point.x;
1215
1230
  to.y = point.y;
1216
1231
  if (point.type === 'percent') {
@@ -1231,7 +1246,7 @@ const AroundHelper = {
1231
1246
  }
1232
1247
  }
1233
1248
  };
1234
- function get$5(around) {
1249
+ function get$4(around) {
1235
1250
  return typeof around === 'string' ? directionData[Direction9[around]] : around;
1236
1251
  }
1237
1252
 
@@ -3808,6 +3823,7 @@ function hitType(defaultValue) {
3808
3823
  return decorateLeafAttr(defaultValue, (key) => attr({
3809
3824
  set(value) {
3810
3825
  if (this.__setAttr(key, value)) {
3826
+ this.__layout.hitCanvasChanged = true;
3811
3827
  if (Debug.showHitView) {
3812
3828
  this.__layout.surfaceChanged || this.__layout.surfaceChange();
3813
3829
  }
@@ -3950,7 +3966,7 @@ function registerUIEvent() {
3950
3966
  };
3951
3967
  }
3952
3968
 
3953
- const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3969
+ const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3954
3970
  const matrix$1 = {};
3955
3971
  const LeafHelper = {
3956
3972
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -4036,7 +4052,7 @@ const LeafHelper = {
4036
4052
  },
4037
4053
  zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4038
4054
  copy$7(matrix$1, t.__localMatrix);
4039
- scaleOfOuter$3(matrix$1, origin, scaleX, scaleY);
4055
+ scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
4040
4056
  moveByMatrix(t, matrix$1);
4041
4057
  t.scaleResize(scaleX, scaleY, resize !== true);
4042
4058
  },
@@ -4045,7 +4061,7 @@ const LeafHelper = {
4045
4061
  },
4046
4062
  rotateOfLocal(t, origin, angle) {
4047
4063
  copy$7(matrix$1, t.__localMatrix);
4048
- rotateOfOuter$3(matrix$1, origin, angle);
4064
+ rotateOfOuter$2(matrix$1, origin, angle);
4049
4065
  moveByMatrix(t, matrix$1);
4050
4066
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
4051
4067
  },
@@ -4072,11 +4088,24 @@ const LeafHelper = {
4072
4088
  setTransform(t, transform, resize) {
4073
4089
  const layout = getLayout(transform);
4074
4090
  if (resize) {
4075
- t.scaleResize(layout.scaleX / t.scaleX, layout.scaleY / t.scaleY, resize !== true);
4091
+ const scaleX = layout.scaleX / t.scaleX;
4092
+ const scaleY = layout.scaleY / t.scaleY;
4076
4093
  delete layout.scaleX;
4077
4094
  delete layout.scaleY;
4095
+ t.set(layout);
4096
+ t.scaleResize(scaleX, scaleY, resize !== true);
4078
4097
  }
4079
- t.set(layout);
4098
+ else {
4099
+ t.set(layout);
4100
+ }
4101
+ },
4102
+ getLocalOrigin(t, origin) {
4103
+ return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
4104
+ },
4105
+ getInnerOrigin(t, origin) {
4106
+ if (typeof origin === 'string')
4107
+ AroundHelper.toPoint(origin, t.boxBounds, origin = {});
4108
+ return origin;
4080
4109
  },
4081
4110
  getRelativeWorld(t, relative, temp) {
4082
4111
  copy$7(matrix$1, t.worldTransform);
@@ -5072,8 +5101,8 @@ const BranchRender = {
5072
5101
  const { LEAF, create } = IncrementId;
5073
5102
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5074
5103
  const { toOuterOf } = BoundsHelper;
5075
- const { tempToOuterOf, copy: copy$4 } = PointHelper;
5076
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getRelativeWorld, drop } = LeafHelper;
5104
+ const { copy: copy$4 } = PointHelper;
5105
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5077
5106
  let Leaf = class Leaf {
5078
5107
  get tag() { return this.__tag; }
5079
5108
  set tag(_value) { }
@@ -5166,6 +5195,9 @@ let Leaf = class Leaf {
5166
5195
  toString() {
5167
5196
  return JSON.stringify(this.toJSON());
5168
5197
  }
5198
+ toSVG() { return undefined; }
5199
+ __SVG(_data) { }
5200
+ toHTML() { return undefined; }
5169
5201
  __setAttr(_attrName, _newValue) { return true; }
5170
5202
  __getAttr(_attrName) { return undefined; }
5171
5203
  setProxyAttr(_attrName, _newValue) { }
@@ -5331,13 +5363,13 @@ let Leaf = class Leaf {
5331
5363
  moveLocal(this, x, y);
5332
5364
  }
5333
5365
  scaleOf(origin, scaleX, scaleY, resize) {
5334
- zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize);
5366
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
5335
5367
  }
5336
5368
  rotateOf(origin, rotation) {
5337
- rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation);
5369
+ rotateOfLocal(this, getLocalOrigin(this, origin), rotation);
5338
5370
  }
5339
5371
  skewOf(origin, skewX, skewY, resize) {
5340
- skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize);
5372
+ skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize);
5341
5373
  }
5342
5374
  transformWorld(worldTransform, resize) {
5343
5375
  transformWorld(this, worldTransform, resize);
@@ -5359,6 +5391,14 @@ let Leaf = class Leaf {
5359
5391
  this.scaleY *= scaleY;
5360
5392
  }
5361
5393
  __scaleResize(_scaleX, _scaleY) { }
5394
+ resizeWidth(width) {
5395
+ const scale = width / this.__localBoxBounds.width;
5396
+ this.scaleResize(scale, this.__.lockRatio ? scale : 1);
5397
+ }
5398
+ resizeHeight(height) {
5399
+ const scale = height / this.__localBoxBounds.height;
5400
+ this.scaleResize(this.__.lockRatio ? scale : 1, scale);
5401
+ }
5362
5402
  __hitWorld(_point) { return true; }
5363
5403
  __hit(_local) { return true; }
5364
5404
  __hitFill(_inner) { return true; }
@@ -5709,7 +5749,7 @@ class LeafLevelList {
5709
5749
  }
5710
5750
  }
5711
5751
 
5712
- const version = "1.0.0-rc.25";
5752
+ const version = "1.0.0-rc.26";
5713
5753
  const inviteCode = {};
5714
5754
 
5715
5755
  const debug$7 = Debug.get('LeaferCanvas');
@@ -5720,10 +5760,12 @@ class LeaferCanvas extends LeaferCanvasBase {
5720
5760
  const { style } = this.view;
5721
5761
  style.display || (style.display = 'block');
5722
5762
  this.parentView = this.view.parentElement;
5723
- if (this.parentView)
5724
- this.parentView.style.userSelect = 'none';
5763
+ if (this.parentView) {
5764
+ const pStyle = this.parentView.style;
5765
+ pStyle.webkitUserSelect = pStyle.userSelect = 'none';
5766
+ }
5725
5767
  if (Platform.syncDomFont && !this.parentView) {
5726
- this.view.style.display = 'none';
5768
+ style.display = 'none';
5727
5769
  document.body.appendChild(this.view);
5728
5770
  }
5729
5771
  this.__createContext();
@@ -6620,8 +6662,12 @@ class Picker {
6620
6662
  hitChild(child, point, proxy) {
6621
6663
  if (this.exclude && this.exclude.has(child))
6622
6664
  return;
6623
- if (child.__hitWorld(point))
6665
+ if (child.__hitWorld(point)) {
6666
+ const { parent } = child;
6667
+ if (parent && parent.__hasMask && !child.__.mask && !parent.children.some(item => item.__.mask && item.__hitWorld(point)))
6668
+ return;
6624
6669
  this.findList.add(proxy || child);
6670
+ }
6625
6671
  }
6626
6672
  clear() {
6627
6673
  this.point = null;
@@ -7382,7 +7428,7 @@ __decorate([
7382
7428
  stateType(false)
7383
7429
  ], UI.prototype, "disabled", void 0);
7384
7430
  __decorate([
7385
- dataType(false)
7431
+ surfaceType(false)
7386
7432
  ], UI.prototype, "locked", void 0);
7387
7433
  __decorate([
7388
7434
  sortType(0)
@@ -7480,6 +7526,9 @@ __decorate([
7480
7526
  __decorate([
7481
7527
  boundsType()
7482
7528
  ], UI.prototype, "autoHeight", void 0);
7529
+ __decorate([
7530
+ boundsType()
7531
+ ], UI.prototype, "lockRatio", void 0);
7483
7532
  __decorate([
7484
7533
  boundsType()
7485
7534
  ], UI.prototype, "autoBox", void 0);
@@ -8069,9 +8118,9 @@ let Box = class Box extends Group {
8069
8118
  if (!data.__autoSize) {
8070
8119
  const b = this.__layout.boxBounds;
8071
8120
  if (!data.__autoWidth)
8072
- b.x = 0, b.width = data.width;
8121
+ b.height += b.y, b.width = data.width, b.x = b.y = 0;
8073
8122
  if (!data.__autoHeight)
8074
- b.y = 0, b.height = data.height;
8123
+ b.width += b.x, b.height = data.height, b.y = b.x = 0;
8075
8124
  }
8076
8125
  }
8077
8126
  else {
@@ -8141,6 +8190,9 @@ let Box = class Box extends Group {
8141
8190
  __decorate([
8142
8191
  dataProcessor(BoxData)
8143
8192
  ], Box.prototype, "__", void 0);
8193
+ __decorate([
8194
+ dataType(false)
8195
+ ], Box.prototype, "resizeChildren", void 0);
8144
8196
  __decorate([
8145
8197
  affectRenderBoundsType('show')
8146
8198
  ], Box.prototype, "overflow", void 0);
@@ -8250,7 +8302,7 @@ Ellipse = __decorate([
8250
8302
  ], Ellipse);
8251
8303
 
8252
8304
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8253
- const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
8305
+ const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
8254
8306
  const { toBounds: toBounds$1 } = PathBounds;
8255
8307
  let Line = class Line extends UI {
8256
8308
  get __tag() { return 'Line'; }
@@ -8265,7 +8317,7 @@ let Line = class Line extends UI {
8265
8317
  }
8266
8318
  set toPoint(value) {
8267
8319
  this.width = getDistance$2(defaultPoint, value);
8268
- this.rotation = getAngle$2(defaultPoint, value);
8320
+ this.rotation = getAngle$1(defaultPoint, value);
8269
8321
  if (this.height)
8270
8322
  this.height = 0;
8271
8323
  }
@@ -8612,6 +8664,9 @@ __decorate([
8612
8664
  __decorate([
8613
8665
  boundsType(0)
8614
8666
  ], Text.prototype, "height", void 0);
8667
+ __decorate([
8668
+ dataType(false)
8669
+ ], Text.prototype, "resizeFontSize", void 0);
8615
8670
  __decorate([
8616
8671
  surfaceType('#000000')
8617
8672
  ], Text.prototype, "fill", void 0);
@@ -9011,6 +9066,14 @@ let DragEvent = class DragEvent extends PointerEvent {
9011
9066
  getLocalTotal(relative) {
9012
9067
  return this.getLocalMove(relative, true);
9013
9068
  }
9069
+ getPageBounds() {
9070
+ const total = this.getPageTotal();
9071
+ const start = this.getPage();
9072
+ const bounds = {};
9073
+ BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9074
+ BoundsHelper.unsign(bounds);
9075
+ return bounds;
9076
+ }
9014
9077
  assignMove(total) {
9015
9078
  move.x = total ? this.totalX : this.moveX;
9016
9079
  move.y = total ? this.totalY : this.moveY;
@@ -9627,7 +9690,8 @@ const config = {
9627
9690
  swipeDistance: 20,
9628
9691
  preventDefaultMenu: true
9629
9692
  },
9630
- cursor: {}
9693
+ cursor: {},
9694
+ keyEvent: true
9631
9695
  };
9632
9696
 
9633
9697
  const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1 } = InteractionHelper;
@@ -9777,6 +9841,8 @@ class InteractionBase {
9777
9841
  this.transformer.transformEnd();
9778
9842
  }
9779
9843
  keyDown(data) {
9844
+ if (!this.config.keyEvent)
9845
+ return;
9780
9846
  const { code } = data;
9781
9847
  if (!this.downKeyMap[code]) {
9782
9848
  this.downKeyMap[code] = true;
@@ -9790,6 +9856,8 @@ class InteractionBase {
9790
9856
  this.emit(KeyEvent.DOWN, data, this.defaultPath);
9791
9857
  }
9792
9858
  keyUp(data) {
9859
+ if (!this.config.keyEvent)
9860
+ return;
9793
9861
  const { code } = data;
9794
9862
  this.downKeyMap[code] = false;
9795
9863
  Keyboard.setUpCode(code);
@@ -10179,11 +10247,11 @@ ui$2.__hit = function (inner) {
10179
10247
  if (data.__isHitPixel && this.__hitPixel(inner))
10180
10248
  return true;
10181
10249
  const { hitFill } = data;
10182
- const needHitFillPath = ((data.fill && hitFill == 'path') || hitFill === 'all');
10250
+ const needHitFillPath = (data.fill && hitFill && hitFill !== 'none') || hitFill === 'all';
10183
10251
  if (needHitFillPath && this.__hitFill(inner))
10184
10252
  return true;
10185
10253
  const { hitStroke, __strokeWidth } = data;
10186
- const needHitStrokePath = ((data.stroke && hitStroke == 'path') || hitStroke === 'all');
10254
+ const needHitStrokePath = (data.stroke && hitFill && hitStroke !== 'none') || hitStroke === 'all';
10187
10255
  if (!needHitFillPath && !needHitStrokePath)
10188
10256
  return false;
10189
10257
  const radiusWidth = inner.radiusX * 2;
@@ -10215,8 +10283,10 @@ ui$2.__hit = function (inner) {
10215
10283
  const ui$1 = new UI();
10216
10284
  const rect = Rect.prototype;
10217
10285
  rect.__updateHitCanvas = function () {
10218
- if (this.stroke || this.cornerRadius)
10286
+ if (this.stroke || this.cornerRadius || (this.fill && this.hitFill === 'pixel') || this.hitStroke === 'all')
10219
10287
  ui$1.__updateHitCanvas.call(this);
10288
+ else if (this.__hitCanvas)
10289
+ this.__hitCanvas = null;
10220
10290
  };
10221
10291
  rect.__hitFill = function (inner) {
10222
10292
  return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
@@ -10524,11 +10594,15 @@ class Interaction extends InteractionBase {
10524
10594
  scale !== 1 ? this.zoom(getZoomEventData(local, scale, eventBase)) : this.move(getMoveEventData(local, wheel.getMove ? wheel.getMove(e, wheel) : WheelEventHelper.getMove(e, wheel), eventBase));
10525
10595
  }
10526
10596
  onGesturestart(e) {
10597
+ if (this.useMultiTouch)
10598
+ return;
10527
10599
  this.preventDefaultWheel(e);
10528
10600
  this.lastGestureScale = 1;
10529
10601
  this.lastGestureRotation = 0;
10530
10602
  }
10531
10603
  onGesturechange(e) {
10604
+ if (this.useMultiTouch)
10605
+ return;
10532
10606
  this.preventDefaultWheel(e);
10533
10607
  const local = this.getLocal(e);
10534
10608
  const eventBase = InteractionHelper.getBase(e);
@@ -10542,6 +10616,8 @@ class Interaction extends InteractionBase {
10542
10616
  this.lastGestureRotation = e.rotation;
10543
10617
  }
10544
10618
  onGestureend(e) {
10619
+ if (this.useMultiTouch)
10620
+ return;
10545
10621
  this.preventDefaultWheel(e);
10546
10622
  this.transformEnd();
10547
10623
  }
@@ -10861,7 +10937,7 @@ function getLeafPaint(attrName, paint, ui) {
10861
10937
  case 'angular':
10862
10938
  return PaintGradient.conicGradient(paint, boxBounds);
10863
10939
  default:
10864
- return paint.r ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
10940
+ return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
10865
10941
  }
10866
10942
  }
10867
10943
 
@@ -10878,17 +10954,17 @@ const PaintModule = {
10878
10954
  };
10879
10955
 
10880
10956
  let origin = {};
10881
- const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
10957
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
10882
10958
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10883
- const transform = get$4();
10959
+ const transform = get$3();
10884
10960
  translate$1(transform, box.x + x, box.y + y);
10885
10961
  scaleHelper(transform, scaleX, scaleY);
10886
10962
  if (rotation)
10887
- rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10963
+ rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10888
10964
  data.transform = transform;
10889
10965
  }
10890
10966
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10891
- const transform = get$4();
10967
+ const transform = get$3();
10892
10968
  translate$1(transform, box.x + x, box.y + y);
10893
10969
  if (scaleX)
10894
10970
  scaleHelper(transform, scaleX, scaleY);
@@ -10897,10 +10973,10 @@ function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10897
10973
  data.transform = transform;
10898
10974
  }
10899
10975
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
10900
- const transform = get$4();
10976
+ const transform = get$3();
10901
10977
  if (rotation) {
10902
10978
  if (align === 'center') {
10903
- rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
10979
+ rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
10904
10980
  }
10905
10981
  else {
10906
10982
  rotate(transform, rotation);
@@ -10921,22 +10997,26 @@ function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, al
10921
10997
  origin.y = box.y + y;
10922
10998
  translate$1(transform, origin.x, origin.y);
10923
10999
  if (scaleX)
10924
- scaleOfOuter$2(transform, origin, scaleX, scaleY);
11000
+ scaleOfOuter$1(transform, origin, scaleX, scaleY);
10925
11001
  data.transform = transform;
10926
11002
  }
10927
11003
 
10928
- const { get: get$3, translate } = MatrixHelper;
11004
+ const { get: get$2, translate } = MatrixHelper;
10929
11005
  const tempBox = new Bounds();
10930
11006
  const tempPoint = {};
10931
11007
  function createData(leafPaint, image, paint, box) {
11008
+ const { blendMode } = paint;
11009
+ if (blendMode)
11010
+ leafPaint.blendMode = blendMode;
11011
+ leafPaint.data = getPatternData(paint, box, image);
11012
+ }
11013
+ function getPatternData(paint, box, image) {
10932
11014
  let { width, height } = image;
10933
11015
  if (paint.padding)
10934
11016
  box = tempBox.set(box).shrink(paint.padding);
10935
- const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
11017
+ const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
10936
11018
  const sameBox = box.width === width && box.height === height;
10937
- if (blendMode)
10938
- leafPaint.blendMode = blendMode;
10939
- const data = leafPaint.data = { mode };
11019
+ const data = { mode };
10940
11020
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10941
11021
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10942
11022
  let x = 0, y = 0, scaleX, scaleY;
@@ -10988,7 +11068,7 @@ function createData(leafPaint, image, paint, box) {
10988
11068
  }
10989
11069
  if (!data.transform) {
10990
11070
  if (box.x || box.y) {
10991
- data.transform = get$3();
11071
+ data.transform = get$2();
10992
11072
  translate(data.transform, box.x, box.y);
10993
11073
  }
10994
11074
  }
@@ -11002,6 +11082,7 @@ function createData(leafPaint, image, paint, box) {
11002
11082
  data.opacity = opacity;
11003
11083
  if (repeat)
11004
11084
  data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
11085
+ return data;
11005
11086
  }
11006
11087
 
11007
11088
  let cache, box = new Bounds();
@@ -11091,7 +11172,7 @@ function ignoreRender(ui, value) {
11091
11172
  leafer.renderer.ignore = value;
11092
11173
  }
11093
11174
 
11094
- const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
11175
+ const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
11095
11176
  const { ceil, abs: abs$1 } = Math;
11096
11177
  function createPattern(ui, paint, pixelRatio) {
11097
11178
  let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
@@ -11102,7 +11183,7 @@ function createPattern(ui, paint, pixelRatio) {
11102
11183
  const { image, data } = paint;
11103
11184
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
11104
11185
  if (sx) {
11105
- imageMatrix = get$2();
11186
+ imageMatrix = get$1();
11106
11187
  copy$1(imageMatrix, transform);
11107
11188
  scale(imageMatrix, 1 / sx, 1 / sy);
11108
11189
  scaleX *= sx;
@@ -11137,7 +11218,7 @@ function createPattern(ui, paint, pixelRatio) {
11137
11218
  }
11138
11219
  if (transform || scaleX !== 1 || scaleY !== 1) {
11139
11220
  if (!imageMatrix) {
11140
- imageMatrix = get$2();
11221
+ imageMatrix = get$1();
11141
11222
  if (transform)
11142
11223
  copy$1(imageMatrix, transform);
11143
11224
  }
@@ -11238,13 +11319,14 @@ function recycleImage(attrName, data) {
11238
11319
 
11239
11320
  const PaintImageModule = {
11240
11321
  image,
11322
+ checkImage,
11323
+ createPattern,
11324
+ recycleImage,
11241
11325
  createData,
11326
+ getPatternData,
11242
11327
  fillOrFitMode,
11243
11328
  clipMode,
11244
- repeatMode,
11245
- createPattern,
11246
- checkImage,
11247
- recycleImage
11329
+ repeatMode
11248
11330
  };
11249
11331
 
11250
11332
  const { toPoint: toPoint$2 } = AroundHelper;
@@ -11274,8 +11356,8 @@ function applyStops(gradient, stops, opacity) {
11274
11356
  }
11275
11357
  }
11276
11358
 
11277
- const { getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
11278
- const { get: get$1, rotateOfOuter: rotateOfOuter$1, scaleOfOuter: scaleOfOuter$1 } = MatrixHelper;
11359
+ const { getAngle, getDistance: getDistance$1 } = PointHelper;
11360
+ const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
11279
11361
  const { toPoint: toPoint$1 } = AroundHelper;
11280
11362
  const realFrom$1 = {};
11281
11363
  const realTo$1 = {};
@@ -11283,23 +11365,35 @@ function radialGradient(paint, box) {
11283
11365
  let { from, to, type, opacity, blendMode, stretch } = paint;
11284
11366
  toPoint$1(from || 'center', box, realFrom$1);
11285
11367
  toPoint$1(to || 'bottom', box, realTo$1);
11286
- const { width, height } = box;
11287
- let transform;
11288
- if (width !== height || stretch) {
11289
- transform = get$1();
11290
- scaleOfOuter$1(transform, realFrom$1, width / height * (stretch || 1), 1);
11291
- rotateOfOuter$1(transform, realFrom$1, getAngle$1(realFrom$1, realTo$1) + 90);
11292
- }
11293
11368
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
11294
11369
  applyStops(style, paint.stops, opacity);
11295
- const data = { type, style, transform };
11370
+ const data = { type, style };
11371
+ const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
11372
+ if (transform)
11373
+ data.transform = transform;
11296
11374
  if (blendMode)
11297
11375
  data.blendMode = blendMode;
11298
11376
  return data;
11299
11377
  }
11378
+ function getTransform(box, from, to, stretch, rotate90) {
11379
+ let transform;
11380
+ const { width, height } = box;
11381
+ if (width !== height || stretch) {
11382
+ const angle = getAngle(from, to);
11383
+ transform = get();
11384
+ if (rotate90) {
11385
+ scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
11386
+ rotateOfOuter(transform, from, angle + 90);
11387
+ }
11388
+ else {
11389
+ scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
11390
+ rotateOfOuter(transform, from, angle);
11391
+ }
11392
+ }
11393
+ return transform;
11394
+ }
11300
11395
 
11301
- const { getAngle, getDistance } = PointHelper;
11302
- const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
11396
+ const { getDistance } = PointHelper;
11303
11397
  const { toPoint } = AroundHelper;
11304
11398
  const realFrom = {};
11305
11399
  const realTo = {};
@@ -11307,20 +11401,12 @@ function conicGradient(paint, box) {
11307
11401
  let { from, to, type, opacity, blendMode, stretch } = paint;
11308
11402
  toPoint(from || 'center', box, realFrom);
11309
11403
  toPoint(to || 'bottom', box, realTo);
11310
- const { width, height } = box;
11311
- const transform = get();
11312
- const angle = getAngle(realFrom, realTo);
11313
- if (Platform.conicGradientRotate90) {
11314
- scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1);
11315
- rotateOfOuter(transform, realFrom, angle + 90);
11316
- }
11317
- else {
11318
- scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1));
11319
- rotateOfOuter(transform, realFrom, angle);
11320
- }
11321
11404
  const style = Platform.conicGradientSupport ? Platform.canvas.createConicGradient(0, realFrom.x, realFrom.y) : Platform.canvas.createRadialGradient(realFrom.x, realFrom.y, 0, realFrom.x, realFrom.y, getDistance(realFrom, realTo));
11322
11405
  applyStops(style, paint.stops, opacity);
11323
- const data = { type, style, transform };
11406
+ const data = { type, style };
11407
+ const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
11408
+ if (transform)
11409
+ data.transform = transform;
11324
11410
  if (blendMode)
11325
11411
  data.blendMode = blendMode;
11326
11412
  return data;
@@ -11329,7 +11415,8 @@ function conicGradient(paint, box) {
11329
11415
  const PaintGradientModule = {
11330
11416
  linearGradient,
11331
11417
  radialGradient,
11332
- conicGradient
11418
+ conicGradient,
11419
+ getTransform
11333
11420
  };
11334
11421
 
11335
11422
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
@@ -12055,11 +12142,21 @@ const ExportModule = {
12055
12142
  resolve();
12056
12143
  this.running = false;
12057
12144
  };
12145
+ const { toURL } = Platform;
12146
+ const { download } = Platform.origin;
12147
+ const fileType = FileHelper.fileType(filename);
12058
12148
  if (filename === 'json') {
12059
12149
  return over({ data: leaf.toJSON() });
12060
12150
  }
12061
- else if (FileHelper.fileType(filename) === 'json') {
12062
- Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
12151
+ else if (fileType === 'json') {
12152
+ download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
12153
+ return over({ data: true });
12154
+ }
12155
+ if (filename === 'svg') {
12156
+ return over({ data: leaf.toSVG() });
12157
+ }
12158
+ else if (fileType === 'svg') {
12159
+ download(toURL(leaf.toSVG(), 'svg'), filename);
12063
12160
  return over({ data: true });
12064
12161
  }
12065
12162
  const { leafer } = leaf;
@@ -12208,11 +12305,5 @@ Object.assign(Creator, {
12208
12305
  hitCanvasManager: () => new HitCanvasManager()
12209
12306
  });
12210
12307
  useCanvas();
12211
- window.addEventListener('unload', () => {
12212
- const { list } = Leafer;
12213
- list.forEach(leafer => leafer.destroy(true));
12214
- list.destroy();
12215
- ImageManager.destroy();
12216
- });
12217
12308
 
12218
12309
  export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as 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, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };