leafer-ui 1.0.0-rc.24 → 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.
package/dist/web.js CHANGED
@@ -2,6 +2,14 @@ var LeaferUI = (function (exports) {
2
2
  'use strict';
3
3
 
4
4
  const Platform = {
5
+ toURL(text, fileType) {
6
+ let url = encodeURIComponent(text);
7
+ if (fileType === 'text')
8
+ url = 'data:text/plain;charset=utf-8,' + url;
9
+ else if (fileType === 'svg')
10
+ url = 'data:image/svg+xml,' + url;
11
+ return url;
12
+ },
5
13
  image: {
6
14
  hitCanvasSize: 100,
7
15
  maxCacheSize: 2560 * 1600,
@@ -959,6 +967,9 @@ var LeaferUI = (function (exports) {
959
967
  points.forEach((point, index) => index === 0 ? setPoint$3(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
960
968
  toBounds$4(tempPointBounds$1, t);
961
969
  },
970
+ setPoint(t, point) {
971
+ B.set(t, point.x, point.y);
972
+ },
962
973
  addPoint(t, point) {
963
974
  add$1(t, point, true);
964
975
  },
@@ -1107,6 +1118,10 @@ var LeaferUI = (function (exports) {
1107
1118
  BoundsHelper.setListWithFn(this, list, boundsDataFn);
1108
1119
  return this;
1109
1120
  }
1121
+ setPoint(point) {
1122
+ BoundsHelper.setPoint(this, point);
1123
+ return this;
1124
+ }
1110
1125
  setPoints(points) {
1111
1126
  BoundsHelper.setPoints(this, points);
1112
1127
  return this;
@@ -1210,10 +1225,10 @@ var LeaferUI = (function (exports) {
1210
1225
  const AroundHelper = {
1211
1226
  directionData,
1212
1227
  tempPoint: {},
1213
- get: get$5,
1228
+ get: get$4,
1214
1229
  toPoint(around, bounds, to, onlySize, pointBounds) {
1215
1230
  to || (to = {});
1216
- const point = get$5(around);
1231
+ const point = get$4(around);
1217
1232
  to.x = point.x;
1218
1233
  to.y = point.y;
1219
1234
  if (point.type === 'percent') {
@@ -1234,7 +1249,7 @@ var LeaferUI = (function (exports) {
1234
1249
  }
1235
1250
  }
1236
1251
  };
1237
- function get$5(around) {
1252
+ function get$4(around) {
1238
1253
  return typeof around === 'string' ? directionData[exports.Direction9[around]] : around;
1239
1254
  }
1240
1255
 
@@ -3811,6 +3826,7 @@ var LeaferUI = (function (exports) {
3811
3826
  return decorateLeafAttr(defaultValue, (key) => attr({
3812
3827
  set(value) {
3813
3828
  if (this.__setAttr(key, value)) {
3829
+ this.__layout.hitCanvasChanged = true;
3814
3830
  if (Debug.showHitView) {
3815
3831
  this.__layout.surfaceChanged || this.__layout.surfaceChange();
3816
3832
  }
@@ -3953,7 +3969,7 @@ var LeaferUI = (function (exports) {
3953
3969
  };
3954
3970
  }
3955
3971
 
3956
- const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3972
+ const { copy: copy$7, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3957
3973
  const matrix$1 = {};
3958
3974
  const LeafHelper = {
3959
3975
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
@@ -4039,7 +4055,7 @@ var LeaferUI = (function (exports) {
4039
4055
  },
4040
4056
  zoomOfLocal(t, origin, scaleX, scaleY = scaleX, resize) {
4041
4057
  copy$7(matrix$1, t.__localMatrix);
4042
- scaleOfOuter$3(matrix$1, origin, scaleX, scaleY);
4058
+ scaleOfOuter$2(matrix$1, origin, scaleX, scaleY);
4043
4059
  moveByMatrix(t, matrix$1);
4044
4060
  t.scaleResize(scaleX, scaleY, resize !== true);
4045
4061
  },
@@ -4048,7 +4064,7 @@ var LeaferUI = (function (exports) {
4048
4064
  },
4049
4065
  rotateOfLocal(t, origin, angle) {
4050
4066
  copy$7(matrix$1, t.__localMatrix);
4051
- rotateOfOuter$3(matrix$1, origin, angle);
4067
+ rotateOfOuter$2(matrix$1, origin, angle);
4052
4068
  moveByMatrix(t, matrix$1);
4053
4069
  t.rotation = MathHelper.formatRotation(t.rotation + angle);
4054
4070
  },
@@ -4075,11 +4091,24 @@ var LeaferUI = (function (exports) {
4075
4091
  setTransform(t, transform, resize) {
4076
4092
  const layout = getLayout(transform);
4077
4093
  if (resize) {
4078
- t.scaleResize(layout.scaleX / t.scaleX, layout.scaleY / t.scaleY, resize !== true);
4094
+ const scaleX = layout.scaleX / t.scaleX;
4095
+ const scaleY = layout.scaleY / t.scaleY;
4079
4096
  delete layout.scaleX;
4080
4097
  delete layout.scaleY;
4098
+ t.set(layout);
4099
+ t.scaleResize(scaleX, scaleY, resize !== true);
4081
4100
  }
4082
- t.set(layout);
4101
+ else {
4102
+ t.set(layout);
4103
+ }
4104
+ },
4105
+ getLocalOrigin(t, origin) {
4106
+ return PointHelper.tempToOuterOf(L.getInnerOrigin(t, origin), t.localTransform);
4107
+ },
4108
+ getInnerOrigin(t, origin) {
4109
+ if (typeof origin === 'string')
4110
+ AroundHelper.toPoint(origin, t.boxBounds, origin = {});
4111
+ return origin;
4083
4112
  },
4084
4113
  getRelativeWorld(t, relative, temp) {
4085
4114
  copy$7(matrix$1, t.worldTransform);
@@ -5075,8 +5104,8 @@ var LeaferUI = (function (exports) {
5075
5104
  const { LEAF, create } = IncrementId;
5076
5105
  const { toInnerPoint, toOuterPoint, multiplyParent } = MatrixHelper;
5077
5106
  const { toOuterOf } = BoundsHelper;
5078
- const { tempToOuterOf, copy: copy$4 } = PointHelper;
5079
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getRelativeWorld, drop } = LeafHelper;
5107
+ const { copy: copy$4 } = PointHelper;
5108
+ const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getLocalOrigin, getRelativeWorld, drop } = LeafHelper;
5080
5109
  exports.Leaf = class Leaf {
5081
5110
  get tag() { return this.__tag; }
5082
5111
  set tag(_value) { }
@@ -5169,6 +5198,9 @@ var LeaferUI = (function (exports) {
5169
5198
  toString() {
5170
5199
  return JSON.stringify(this.toJSON());
5171
5200
  }
5201
+ toSVG() { return undefined; }
5202
+ __SVG(_data) { }
5203
+ toHTML() { return undefined; }
5172
5204
  __setAttr(_attrName, _newValue) { return true; }
5173
5205
  __getAttr(_attrName) { return undefined; }
5174
5206
  setProxyAttr(_attrName, _newValue) { }
@@ -5334,13 +5366,13 @@ var LeaferUI = (function (exports) {
5334
5366
  moveLocal(this, x, y);
5335
5367
  }
5336
5368
  scaleOf(origin, scaleX, scaleY, resize) {
5337
- zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize);
5369
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
5338
5370
  }
5339
5371
  rotateOf(origin, rotation) {
5340
- rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation);
5372
+ rotateOfLocal(this, getLocalOrigin(this, origin), rotation);
5341
5373
  }
5342
5374
  skewOf(origin, skewX, skewY, resize) {
5343
- skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize);
5375
+ skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize);
5344
5376
  }
5345
5377
  transformWorld(worldTransform, resize) {
5346
5378
  transformWorld(this, worldTransform, resize);
@@ -5362,6 +5394,14 @@ var LeaferUI = (function (exports) {
5362
5394
  this.scaleY *= scaleY;
5363
5395
  }
5364
5396
  __scaleResize(_scaleX, _scaleY) { }
5397
+ resizeWidth(width) {
5398
+ const scale = width / this.__localBoxBounds.width;
5399
+ this.scaleResize(scale, this.__.lockRatio ? scale : 1);
5400
+ }
5401
+ resizeHeight(height) {
5402
+ const scale = height / this.__localBoxBounds.height;
5403
+ this.scaleResize(this.__.lockRatio ? scale : 1, scale);
5404
+ }
5365
5405
  __hitWorld(_point) { return true; }
5366
5406
  __hit(_local) { return true; }
5367
5407
  __hitFill(_inner) { return true; }
@@ -5712,7 +5752,7 @@ var LeaferUI = (function (exports) {
5712
5752
  }
5713
5753
  }
5714
5754
 
5715
- const version = "1.0.0-rc.24";
5755
+ const version = "1.0.0-rc.26";
5716
5756
  const inviteCode = {};
5717
5757
 
5718
5758
  const debug$7 = Debug.get('LeaferCanvas');
@@ -5723,10 +5763,12 @@ var LeaferUI = (function (exports) {
5723
5763
  const { style } = this.view;
5724
5764
  style.display || (style.display = 'block');
5725
5765
  this.parentView = this.view.parentElement;
5726
- if (this.parentView)
5727
- this.parentView.style.userSelect = 'none';
5766
+ if (this.parentView) {
5767
+ const pStyle = this.parentView.style;
5768
+ pStyle.webkitUserSelect = pStyle.userSelect = 'none';
5769
+ }
5728
5770
  if (Platform.syncDomFont && !this.parentView) {
5729
- this.view.style.display = 'none';
5771
+ style.display = 'none';
5730
5772
  document.body.appendChild(this.view);
5731
5773
  }
5732
5774
  this.__createContext();
@@ -6623,8 +6665,12 @@ var LeaferUI = (function (exports) {
6623
6665
  hitChild(child, point, proxy) {
6624
6666
  if (this.exclude && this.exclude.has(child))
6625
6667
  return;
6626
- if (child.__hitWorld(point))
6668
+ if (child.__hitWorld(point)) {
6669
+ const { parent } = child;
6670
+ if (parent && parent.__hasMask && !child.__.mask && !parent.children.some(item => item.__.mask && item.__hitWorld(point)))
6671
+ return;
6627
6672
  this.findList.add(proxy || child);
6673
+ }
6628
6674
  }
6629
6675
  clear() {
6630
6676
  this.point = null;
@@ -7385,7 +7431,7 @@ var LeaferUI = (function (exports) {
7385
7431
  stateType(false)
7386
7432
  ], exports.UI.prototype, "disabled", void 0);
7387
7433
  __decorate([
7388
- dataType(false)
7434
+ surfaceType(false)
7389
7435
  ], exports.UI.prototype, "locked", void 0);
7390
7436
  __decorate([
7391
7437
  sortType(0)
@@ -7467,10 +7513,10 @@ var LeaferUI = (function (exports) {
7467
7513
  ], exports.UI.prototype, "gap", void 0);
7468
7514
  __decorate([
7469
7515
  boundsType('top-left')
7470
- ], exports.UI.prototype, "align", void 0);
7516
+ ], exports.UI.prototype, "flowAlign", void 0);
7471
7517
  __decorate([
7472
7518
  boundsType(false)
7473
- ], exports.UI.prototype, "wrap", void 0);
7519
+ ], exports.UI.prototype, "flowWrap", void 0);
7474
7520
  __decorate([
7475
7521
  boundsType('box')
7476
7522
  ], exports.UI.prototype, "itemBox", void 0);
@@ -7483,6 +7529,9 @@ var LeaferUI = (function (exports) {
7483
7529
  __decorate([
7484
7530
  boundsType()
7485
7531
  ], exports.UI.prototype, "autoHeight", void 0);
7532
+ __decorate([
7533
+ boundsType()
7534
+ ], exports.UI.prototype, "lockRatio", void 0);
7486
7535
  __decorate([
7487
7536
  boundsType()
7488
7537
  ], exports.UI.prototype, "autoBox", void 0);
@@ -8072,9 +8121,9 @@ var LeaferUI = (function (exports) {
8072
8121
  if (!data.__autoSize) {
8073
8122
  const b = this.__layout.boxBounds;
8074
8123
  if (!data.__autoWidth)
8075
- b.x = 0, b.width = data.width;
8124
+ b.height += b.y, b.width = data.width, b.x = b.y = 0;
8076
8125
  if (!data.__autoHeight)
8077
- b.y = 0, b.height = data.height;
8126
+ b.width += b.x, b.height = data.height, b.y = b.x = 0;
8078
8127
  }
8079
8128
  }
8080
8129
  else {
@@ -8144,6 +8193,9 @@ var LeaferUI = (function (exports) {
8144
8193
  __decorate([
8145
8194
  dataProcessor(BoxData)
8146
8195
  ], exports.Box.prototype, "__", void 0);
8196
+ __decorate([
8197
+ dataType(false)
8198
+ ], exports.Box.prototype, "resizeChildren", void 0);
8147
8199
  __decorate([
8148
8200
  affectRenderBoundsType('show')
8149
8201
  ], exports.Box.prototype, "overflow", void 0);
@@ -8253,7 +8305,7 @@ var LeaferUI = (function (exports) {
8253
8305
  ], exports.Ellipse);
8254
8306
 
8255
8307
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8256
- const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
8308
+ const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
8257
8309
  const { toBounds: toBounds$1 } = PathBounds;
8258
8310
  exports.Line = class Line extends exports.UI {
8259
8311
  get __tag() { return 'Line'; }
@@ -8268,7 +8320,7 @@ var LeaferUI = (function (exports) {
8268
8320
  }
8269
8321
  set toPoint(value) {
8270
8322
  this.width = getDistance$2(defaultPoint, value);
8271
- this.rotation = getAngle$2(defaultPoint, value);
8323
+ this.rotation = getAngle$1(defaultPoint, value);
8272
8324
  if (this.height)
8273
8325
  this.height = 0;
8274
8326
  }
@@ -8615,6 +8667,9 @@ var LeaferUI = (function (exports) {
8615
8667
  __decorate([
8616
8668
  boundsType(0)
8617
8669
  ], exports.Text.prototype, "height", void 0);
8670
+ __decorate([
8671
+ dataType(false)
8672
+ ], exports.Text.prototype, "resizeFontSize", void 0);
8618
8673
  __decorate([
8619
8674
  surfaceType('#000000')
8620
8675
  ], exports.Text.prototype, "fill", void 0);
@@ -9014,6 +9069,14 @@ var LeaferUI = (function (exports) {
9014
9069
  getLocalTotal(relative) {
9015
9070
  return this.getLocalMove(relative, true);
9016
9071
  }
9072
+ getPageBounds() {
9073
+ const total = this.getPageTotal();
9074
+ const start = this.getPage();
9075
+ const bounds = {};
9076
+ BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9077
+ BoundsHelper.unsign(bounds);
9078
+ return bounds;
9079
+ }
9017
9080
  assignMove(total) {
9018
9081
  move.x = total ? this.totalX : this.moveX;
9019
9082
  move.y = total ? this.totalY : this.moveY;
@@ -9630,7 +9693,8 @@ var LeaferUI = (function (exports) {
9630
9693
  swipeDistance: 20,
9631
9694
  preventDefaultMenu: true
9632
9695
  },
9633
- cursor: {}
9696
+ cursor: {},
9697
+ keyEvent: true
9634
9698
  };
9635
9699
 
9636
9700
  const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1 } = InteractionHelper;
@@ -9780,6 +9844,8 @@ var LeaferUI = (function (exports) {
9780
9844
  this.transformer.transformEnd();
9781
9845
  }
9782
9846
  keyDown(data) {
9847
+ if (!this.config.keyEvent)
9848
+ return;
9783
9849
  const { code } = data;
9784
9850
  if (!this.downKeyMap[code]) {
9785
9851
  this.downKeyMap[code] = true;
@@ -9793,6 +9859,8 @@ var LeaferUI = (function (exports) {
9793
9859
  this.emit(exports.KeyEvent.DOWN, data, this.defaultPath);
9794
9860
  }
9795
9861
  keyUp(data) {
9862
+ if (!this.config.keyEvent)
9863
+ return;
9796
9864
  const { code } = data;
9797
9865
  this.downKeyMap[code] = false;
9798
9866
  Keyboard.setUpCode(code);
@@ -10182,11 +10250,11 @@ var LeaferUI = (function (exports) {
10182
10250
  if (data.__isHitPixel && this.__hitPixel(inner))
10183
10251
  return true;
10184
10252
  const { hitFill } = data;
10185
- const needHitFillPath = ((data.fill && hitFill == 'path') || hitFill === 'all');
10253
+ const needHitFillPath = (data.fill && hitFill && hitFill !== 'none') || hitFill === 'all';
10186
10254
  if (needHitFillPath && this.__hitFill(inner))
10187
10255
  return true;
10188
10256
  const { hitStroke, __strokeWidth } = data;
10189
- const needHitStrokePath = ((data.stroke && hitStroke == 'path') || hitStroke === 'all');
10257
+ const needHitStrokePath = (data.stroke && hitFill && hitStroke !== 'none') || hitStroke === 'all';
10190
10258
  if (!needHitFillPath && !needHitStrokePath)
10191
10259
  return false;
10192
10260
  const radiusWidth = inner.radiusX * 2;
@@ -10218,8 +10286,10 @@ var LeaferUI = (function (exports) {
10218
10286
  const ui$1 = new exports.UI();
10219
10287
  const rect = exports.Rect.prototype;
10220
10288
  rect.__updateHitCanvas = function () {
10221
- if (this.stroke || this.cornerRadius)
10289
+ if (this.stroke || this.cornerRadius || (this.fill && this.hitFill === 'pixel') || this.hitStroke === 'all')
10222
10290
  ui$1.__updateHitCanvas.call(this);
10291
+ else if (this.__hitCanvas)
10292
+ this.__hitCanvas = null;
10223
10293
  };
10224
10294
  rect.__hitFill = function (inner) {
10225
10295
  return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
@@ -10527,11 +10597,15 @@ var LeaferUI = (function (exports) {
10527
10597
  scale !== 1 ? this.zoom(getZoomEventData(local, scale, eventBase)) : this.move(getMoveEventData(local, wheel.getMove ? wheel.getMove(e, wheel) : WheelEventHelper.getMove(e, wheel), eventBase));
10528
10598
  }
10529
10599
  onGesturestart(e) {
10600
+ if (this.useMultiTouch)
10601
+ return;
10530
10602
  this.preventDefaultWheel(e);
10531
10603
  this.lastGestureScale = 1;
10532
10604
  this.lastGestureRotation = 0;
10533
10605
  }
10534
10606
  onGesturechange(e) {
10607
+ if (this.useMultiTouch)
10608
+ return;
10535
10609
  this.preventDefaultWheel(e);
10536
10610
  const local = this.getLocal(e);
10537
10611
  const eventBase = InteractionHelper.getBase(e);
@@ -10545,6 +10619,8 @@ var LeaferUI = (function (exports) {
10545
10619
  this.lastGestureRotation = e.rotation;
10546
10620
  }
10547
10621
  onGestureend(e) {
10622
+ if (this.useMultiTouch)
10623
+ return;
10548
10624
  this.preventDefaultWheel(e);
10549
10625
  this.transformEnd();
10550
10626
  }
@@ -10864,7 +10940,7 @@ var LeaferUI = (function (exports) {
10864
10940
  case 'angular':
10865
10941
  return PaintGradient.conicGradient(paint, boxBounds);
10866
10942
  default:
10867
- return paint.r ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
10943
+ return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
10868
10944
  }
10869
10945
  }
10870
10946
 
@@ -10881,17 +10957,17 @@ var LeaferUI = (function (exports) {
10881
10957
  };
10882
10958
 
10883
10959
  let origin = {};
10884
- const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
10960
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
10885
10961
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
10886
- const transform = get$4();
10962
+ const transform = get$3();
10887
10963
  translate$1(transform, box.x + x, box.y + y);
10888
10964
  scaleHelper(transform, scaleX, scaleY);
10889
10965
  if (rotation)
10890
- rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10966
+ rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
10891
10967
  data.transform = transform;
10892
10968
  }
10893
10969
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
10894
- const transform = get$4();
10970
+ const transform = get$3();
10895
10971
  translate$1(transform, box.x + x, box.y + y);
10896
10972
  if (scaleX)
10897
10973
  scaleHelper(transform, scaleX, scaleY);
@@ -10900,10 +10976,10 @@ var LeaferUI = (function (exports) {
10900
10976
  data.transform = transform;
10901
10977
  }
10902
10978
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
10903
- const transform = get$4();
10979
+ const transform = get$3();
10904
10980
  if (rotation) {
10905
10981
  if (align === 'center') {
10906
- rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
10982
+ rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
10907
10983
  }
10908
10984
  else {
10909
10985
  rotate(transform, rotation);
@@ -10924,22 +11000,26 @@ var LeaferUI = (function (exports) {
10924
11000
  origin.y = box.y + y;
10925
11001
  translate$1(transform, origin.x, origin.y);
10926
11002
  if (scaleX)
10927
- scaleOfOuter$2(transform, origin, scaleX, scaleY);
11003
+ scaleOfOuter$1(transform, origin, scaleX, scaleY);
10928
11004
  data.transform = transform;
10929
11005
  }
10930
11006
 
10931
- const { get: get$3, translate } = MatrixHelper;
11007
+ const { get: get$2, translate } = MatrixHelper;
10932
11008
  const tempBox = new Bounds();
10933
11009
  const tempPoint = {};
10934
11010
  function createData(leafPaint, image, paint, box) {
11011
+ const { blendMode } = paint;
11012
+ if (blendMode)
11013
+ leafPaint.blendMode = blendMode;
11014
+ leafPaint.data = getPatternData(paint, box, image);
11015
+ }
11016
+ function getPatternData(paint, box, image) {
10935
11017
  let { width, height } = image;
10936
11018
  if (paint.padding)
10937
11019
  box = tempBox.set(box).shrink(paint.padding);
10938
- const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
11020
+ const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
10939
11021
  const sameBox = box.width === width && box.height === height;
10940
- if (blendMode)
10941
- leafPaint.blendMode = blendMode;
10942
- const data = leafPaint.data = { mode };
11022
+ const data = { mode };
10943
11023
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
10944
11024
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
10945
11025
  let x = 0, y = 0, scaleX, scaleY;
@@ -10991,7 +11071,7 @@ var LeaferUI = (function (exports) {
10991
11071
  }
10992
11072
  if (!data.transform) {
10993
11073
  if (box.x || box.y) {
10994
- data.transform = get$3();
11074
+ data.transform = get$2();
10995
11075
  translate(data.transform, box.x, box.y);
10996
11076
  }
10997
11077
  }
@@ -11005,6 +11085,7 @@ var LeaferUI = (function (exports) {
11005
11085
  data.opacity = opacity;
11006
11086
  if (repeat)
11007
11087
  data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
11088
+ return data;
11008
11089
  }
11009
11090
 
11010
11091
  let cache, box = new Bounds();
@@ -11094,7 +11175,7 @@ var LeaferUI = (function (exports) {
11094
11175
  leafer.renderer.ignore = value;
11095
11176
  }
11096
11177
 
11097
- const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
11178
+ const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
11098
11179
  const { ceil, abs: abs$1 } = Math;
11099
11180
  function createPattern(ui, paint, pixelRatio) {
11100
11181
  let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
@@ -11105,7 +11186,7 @@ var LeaferUI = (function (exports) {
11105
11186
  const { image, data } = paint;
11106
11187
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
11107
11188
  if (sx) {
11108
- imageMatrix = get$2();
11189
+ imageMatrix = get$1();
11109
11190
  copy$1(imageMatrix, transform);
11110
11191
  scale(imageMatrix, 1 / sx, 1 / sy);
11111
11192
  scaleX *= sx;
@@ -11140,7 +11221,7 @@ var LeaferUI = (function (exports) {
11140
11221
  }
11141
11222
  if (transform || scaleX !== 1 || scaleY !== 1) {
11142
11223
  if (!imageMatrix) {
11143
- imageMatrix = get$2();
11224
+ imageMatrix = get$1();
11144
11225
  if (transform)
11145
11226
  copy$1(imageMatrix, transform);
11146
11227
  }
@@ -11241,13 +11322,14 @@ var LeaferUI = (function (exports) {
11241
11322
 
11242
11323
  const PaintImageModule = {
11243
11324
  image,
11325
+ checkImage,
11326
+ createPattern,
11327
+ recycleImage,
11244
11328
  createData,
11329
+ getPatternData,
11245
11330
  fillOrFitMode,
11246
11331
  clipMode,
11247
- repeatMode,
11248
- createPattern,
11249
- checkImage,
11250
- recycleImage
11332
+ repeatMode
11251
11333
  };
11252
11334
 
11253
11335
  const { toPoint: toPoint$2 } = AroundHelper;
@@ -11277,8 +11359,8 @@ var LeaferUI = (function (exports) {
11277
11359
  }
11278
11360
  }
11279
11361
 
11280
- const { getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
11281
- const { get: get$1, rotateOfOuter: rotateOfOuter$1, scaleOfOuter: scaleOfOuter$1 } = MatrixHelper;
11362
+ const { getAngle, getDistance: getDistance$1 } = PointHelper;
11363
+ const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
11282
11364
  const { toPoint: toPoint$1 } = AroundHelper;
11283
11365
  const realFrom$1 = {};
11284
11366
  const realTo$1 = {};
@@ -11286,23 +11368,35 @@ var LeaferUI = (function (exports) {
11286
11368
  let { from, to, type, opacity, blendMode, stretch } = paint;
11287
11369
  toPoint$1(from || 'center', box, realFrom$1);
11288
11370
  toPoint$1(to || 'bottom', box, realTo$1);
11289
- const { width, height } = box;
11290
- let transform;
11291
- if (width !== height || stretch) {
11292
- transform = get$1();
11293
- scaleOfOuter$1(transform, realFrom$1, width / height * (stretch || 1), 1);
11294
- rotateOfOuter$1(transform, realFrom$1, getAngle$1(realFrom$1, realTo$1) + 90);
11295
- }
11296
11371
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
11297
11372
  applyStops(style, paint.stops, opacity);
11298
- const data = { type, style, transform };
11373
+ const data = { type, style };
11374
+ const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
11375
+ if (transform)
11376
+ data.transform = transform;
11299
11377
  if (blendMode)
11300
11378
  data.blendMode = blendMode;
11301
11379
  return data;
11302
11380
  }
11381
+ function getTransform(box, from, to, stretch, rotate90) {
11382
+ let transform;
11383
+ const { width, height } = box;
11384
+ if (width !== height || stretch) {
11385
+ const angle = getAngle(from, to);
11386
+ transform = get();
11387
+ if (rotate90) {
11388
+ scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
11389
+ rotateOfOuter(transform, from, angle + 90);
11390
+ }
11391
+ else {
11392
+ scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
11393
+ rotateOfOuter(transform, from, angle);
11394
+ }
11395
+ }
11396
+ return transform;
11397
+ }
11303
11398
 
11304
- const { getAngle, getDistance } = PointHelper;
11305
- const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
11399
+ const { getDistance } = PointHelper;
11306
11400
  const { toPoint } = AroundHelper;
11307
11401
  const realFrom = {};
11308
11402
  const realTo = {};
@@ -11310,20 +11404,12 @@ var LeaferUI = (function (exports) {
11310
11404
  let { from, to, type, opacity, blendMode, stretch } = paint;
11311
11405
  toPoint(from || 'center', box, realFrom);
11312
11406
  toPoint(to || 'bottom', box, realTo);
11313
- const { width, height } = box;
11314
- const transform = get();
11315
- const angle = getAngle(realFrom, realTo);
11316
- if (Platform.conicGradientRotate90) {
11317
- scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1);
11318
- rotateOfOuter(transform, realFrom, angle + 90);
11319
- }
11320
- else {
11321
- scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1));
11322
- rotateOfOuter(transform, realFrom, angle);
11323
- }
11324
11407
  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));
11325
11408
  applyStops(style, paint.stops, opacity);
11326
- const data = { type, style, transform };
11409
+ const data = { type, style };
11410
+ const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
11411
+ if (transform)
11412
+ data.transform = transform;
11327
11413
  if (blendMode)
11328
11414
  data.blendMode = blendMode;
11329
11415
  return data;
@@ -11332,7 +11418,8 @@ var LeaferUI = (function (exports) {
11332
11418
  const PaintGradientModule = {
11333
11419
  linearGradient,
11334
11420
  radialGradient,
11335
- conicGradient
11421
+ conicGradient,
11422
+ getTransform
11336
11423
  };
11337
11424
 
11338
11425
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
@@ -12058,11 +12145,21 @@ var LeaferUI = (function (exports) {
12058
12145
  resolve();
12059
12146
  this.running = false;
12060
12147
  };
12148
+ const { toURL } = Platform;
12149
+ const { download } = Platform.origin;
12150
+ const fileType = FileHelper.fileType(filename);
12061
12151
  if (filename === 'json') {
12062
12152
  return over({ data: leaf.toJSON() });
12063
12153
  }
12064
- else if (FileHelper.fileType(filename) === 'json') {
12065
- Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
12154
+ else if (fileType === 'json') {
12155
+ download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
12156
+ return over({ data: true });
12157
+ }
12158
+ if (filename === 'svg') {
12159
+ return over({ data: leaf.toSVG() });
12160
+ }
12161
+ else if (fileType === 'svg') {
12162
+ download(toURL(leaf.toSVG(), 'svg'), filename);
12066
12163
  return over({ data: true });
12067
12164
  }
12068
12165
  const { leafer } = leaf;
@@ -12211,12 +12308,6 @@ var LeaferUI = (function (exports) {
12211
12308
  hitCanvasManager: () => new HitCanvasManager()
12212
12309
  });
12213
12310
  useCanvas();
12214
- window.addEventListener('unload', () => {
12215
- const { list } = exports.Leafer;
12216
- list.forEach(leafer => leafer.destroy(true));
12217
- list.destroy();
12218
- ImageManager.destroy();
12219
- });
12220
12311
 
12221
12312
  exports.AlignHelper = AlignHelper;
12222
12313
  exports.AnimateEvent = AnimateEvent;