@leafer-draw/worker 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/worker.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$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$3, rotateOfOuter: rotateOfOuter$3, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3972
+ const { copy: copy$6, toInnerPoint: toInnerPoint$1, scaleOfOuter: scaleOfOuter$2, rotateOfOuter: rotateOfOuter$2, skewOfOuter, multiplyParent: multiplyParent$2, divideParent, getLayout } = MatrixHelper;
3957
3973
  const matrix = {};
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$6(matrix, t.__localMatrix);
4042
- scaleOfOuter$3(matrix, origin, scaleX, scaleY);
4058
+ scaleOfOuter$2(matrix, origin, scaleX, scaleY);
4043
4059
  moveByMatrix(t, matrix);
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$6(matrix, t.__localMatrix);
4051
- rotateOfOuter$3(matrix, origin, angle);
4067
+ rotateOfOuter$2(matrix, origin, angle);
4052
4068
  moveByMatrix(t, matrix);
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$6(matrix, 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$3 } = PointHelper;
5079
- const { moveLocal, zoomOfLocal, rotateOfLocal, skewOfLocal, moveWorld, zoomOfWorld, rotateOfWorld, skewOfWorld, transform, transformWorld, setTransform, getRelativeWorld, drop } = LeafHelper;
5107
+ const { copy: copy$3 } = 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
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6986,7 +7026,7 @@ var LeaferUI = (function (exports) {
6986
7026
  stateType(false)
6987
7027
  ], exports.UI.prototype, "disabled", void 0);
6988
7028
  __decorate([
6989
- dataType(false)
7029
+ surfaceType(false)
6990
7030
  ], exports.UI.prototype, "locked", void 0);
6991
7031
  __decorate([
6992
7032
  sortType(0)
@@ -7068,10 +7108,10 @@ var LeaferUI = (function (exports) {
7068
7108
  ], exports.UI.prototype, "gap", void 0);
7069
7109
  __decorate([
7070
7110
  boundsType('top-left')
7071
- ], exports.UI.prototype, "align", void 0);
7111
+ ], exports.UI.prototype, "flowAlign", void 0);
7072
7112
  __decorate([
7073
7113
  boundsType(false)
7074
- ], exports.UI.prototype, "wrap", void 0);
7114
+ ], exports.UI.prototype, "flowWrap", void 0);
7075
7115
  __decorate([
7076
7116
  boundsType('box')
7077
7117
  ], exports.UI.prototype, "itemBox", void 0);
@@ -7084,6 +7124,9 @@ var LeaferUI = (function (exports) {
7084
7124
  __decorate([
7085
7125
  boundsType()
7086
7126
  ], exports.UI.prototype, "autoHeight", void 0);
7127
+ __decorate([
7128
+ boundsType()
7129
+ ], exports.UI.prototype, "lockRatio", void 0);
7087
7130
  __decorate([
7088
7131
  boundsType()
7089
7132
  ], exports.UI.prototype, "autoBox", void 0);
@@ -7673,9 +7716,9 @@ var LeaferUI = (function (exports) {
7673
7716
  if (!data.__autoSize) {
7674
7717
  const b = this.__layout.boxBounds;
7675
7718
  if (!data.__autoWidth)
7676
- b.x = 0, b.width = data.width;
7719
+ b.height += b.y, b.width = data.width, b.x = b.y = 0;
7677
7720
  if (!data.__autoHeight)
7678
- b.y = 0, b.height = data.height;
7721
+ b.width += b.x, b.height = data.height, b.y = b.x = 0;
7679
7722
  }
7680
7723
  }
7681
7724
  else {
@@ -7745,6 +7788,9 @@ var LeaferUI = (function (exports) {
7745
7788
  __decorate([
7746
7789
  dataProcessor(BoxData)
7747
7790
  ], exports.Box.prototype, "__", void 0);
7791
+ __decorate([
7792
+ dataType(false)
7793
+ ], exports.Box.prototype, "resizeChildren", void 0);
7748
7794
  __decorate([
7749
7795
  affectRenderBoundsType('show')
7750
7796
  ], exports.Box.prototype, "overflow", void 0);
@@ -7854,7 +7900,7 @@ var LeaferUI = (function (exports) {
7854
7900
  ], exports.Ellipse);
7855
7901
 
7856
7902
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
7857
- const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
7903
+ const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
7858
7904
  const { toBounds: toBounds$1 } = PathBounds;
7859
7905
  exports.Line = class Line extends exports.UI {
7860
7906
  get __tag() { return 'Line'; }
@@ -7869,7 +7915,7 @@ var LeaferUI = (function (exports) {
7869
7915
  }
7870
7916
  set toPoint(value) {
7871
7917
  this.width = getDistance$2(defaultPoint, value);
7872
- this.rotation = getAngle$2(defaultPoint, value);
7918
+ this.rotation = getAngle$1(defaultPoint, value);
7873
7919
  if (this.height)
7874
7920
  this.height = 0;
7875
7921
  }
@@ -8216,6 +8262,9 @@ var LeaferUI = (function (exports) {
8216
8262
  __decorate([
8217
8263
  boundsType(0)
8218
8264
  ], exports.Text.prototype, "height", void 0);
8265
+ __decorate([
8266
+ dataType(false)
8267
+ ], exports.Text.prototype, "resizeFontSize", void 0);
8219
8268
  __decorate([
8220
8269
  surfaceType('#000000')
8221
8270
  ], exports.Text.prototype, "fill", void 0);
@@ -8628,7 +8677,7 @@ var LeaferUI = (function (exports) {
8628
8677
  case 'angular':
8629
8678
  return PaintGradient.conicGradient(paint, boxBounds);
8630
8679
  default:
8631
- return paint.r ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
8680
+ return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
8632
8681
  }
8633
8682
  }
8634
8683
 
@@ -8645,17 +8694,17 @@ var LeaferUI = (function (exports) {
8645
8694
  };
8646
8695
 
8647
8696
  let origin = {};
8648
- const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
8697
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
8649
8698
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
8650
- const transform = get$4();
8699
+ const transform = get$3();
8651
8700
  translate$1(transform, box.x + x, box.y + y);
8652
8701
  scaleHelper(transform, scaleX, scaleY);
8653
8702
  if (rotation)
8654
- rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
8703
+ rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
8655
8704
  data.transform = transform;
8656
8705
  }
8657
8706
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
8658
- const transform = get$4();
8707
+ const transform = get$3();
8659
8708
  translate$1(transform, box.x + x, box.y + y);
8660
8709
  if (scaleX)
8661
8710
  scaleHelper(transform, scaleX, scaleY);
@@ -8664,10 +8713,10 @@ var LeaferUI = (function (exports) {
8664
8713
  data.transform = transform;
8665
8714
  }
8666
8715
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
8667
- const transform = get$4();
8716
+ const transform = get$3();
8668
8717
  if (rotation) {
8669
8718
  if (align === 'center') {
8670
- rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
8719
+ rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
8671
8720
  }
8672
8721
  else {
8673
8722
  rotate(transform, rotation);
@@ -8688,22 +8737,26 @@ var LeaferUI = (function (exports) {
8688
8737
  origin.y = box.y + y;
8689
8738
  translate$1(transform, origin.x, origin.y);
8690
8739
  if (scaleX)
8691
- scaleOfOuter$2(transform, origin, scaleX, scaleY);
8740
+ scaleOfOuter$1(transform, origin, scaleX, scaleY);
8692
8741
  data.transform = transform;
8693
8742
  }
8694
8743
 
8695
- const { get: get$3, translate } = MatrixHelper;
8744
+ const { get: get$2, translate } = MatrixHelper;
8696
8745
  const tempBox = new Bounds();
8697
8746
  const tempPoint = {};
8698
8747
  function createData(leafPaint, image, paint, box) {
8748
+ const { blendMode } = paint;
8749
+ if (blendMode)
8750
+ leafPaint.blendMode = blendMode;
8751
+ leafPaint.data = getPatternData(paint, box, image);
8752
+ }
8753
+ function getPatternData(paint, box, image) {
8699
8754
  let { width, height } = image;
8700
8755
  if (paint.padding)
8701
8756
  box = tempBox.set(box).shrink(paint.padding);
8702
- const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
8757
+ const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
8703
8758
  const sameBox = box.width === width && box.height === height;
8704
- if (blendMode)
8705
- leafPaint.blendMode = blendMode;
8706
- const data = leafPaint.data = { mode };
8759
+ const data = { mode };
8707
8760
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
8708
8761
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
8709
8762
  let x = 0, y = 0, scaleX, scaleY;
@@ -8755,7 +8808,7 @@ var LeaferUI = (function (exports) {
8755
8808
  }
8756
8809
  if (!data.transform) {
8757
8810
  if (box.x || box.y) {
8758
- data.transform = get$3();
8811
+ data.transform = get$2();
8759
8812
  translate(data.transform, box.x, box.y);
8760
8813
  }
8761
8814
  }
@@ -8769,6 +8822,7 @@ var LeaferUI = (function (exports) {
8769
8822
  data.opacity = opacity;
8770
8823
  if (repeat)
8771
8824
  data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
8825
+ return data;
8772
8826
  }
8773
8827
 
8774
8828
  let cache, box = new Bounds();
@@ -8858,7 +8912,7 @@ var LeaferUI = (function (exports) {
8858
8912
  leafer.renderer.ignore = value;
8859
8913
  }
8860
8914
 
8861
- const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
8915
+ const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
8862
8916
  const { ceil, abs: abs$1 } = Math;
8863
8917
  function createPattern(ui, paint, pixelRatio) {
8864
8918
  let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
@@ -8869,7 +8923,7 @@ var LeaferUI = (function (exports) {
8869
8923
  const { image, data } = paint;
8870
8924
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
8871
8925
  if (sx) {
8872
- imageMatrix = get$2();
8926
+ imageMatrix = get$1();
8873
8927
  copy$1(imageMatrix, transform);
8874
8928
  scale(imageMatrix, 1 / sx, 1 / sy);
8875
8929
  scaleX *= sx;
@@ -8904,7 +8958,7 @@ var LeaferUI = (function (exports) {
8904
8958
  }
8905
8959
  if (transform || scaleX !== 1 || scaleY !== 1) {
8906
8960
  if (!imageMatrix) {
8907
- imageMatrix = get$2();
8961
+ imageMatrix = get$1();
8908
8962
  if (transform)
8909
8963
  copy$1(imageMatrix, transform);
8910
8964
  }
@@ -9005,13 +9059,14 @@ var LeaferUI = (function (exports) {
9005
9059
 
9006
9060
  const PaintImageModule = {
9007
9061
  image,
9062
+ checkImage,
9063
+ createPattern,
9064
+ recycleImage,
9008
9065
  createData,
9066
+ getPatternData,
9009
9067
  fillOrFitMode,
9010
9068
  clipMode,
9011
- repeatMode,
9012
- createPattern,
9013
- checkImage,
9014
- recycleImage
9069
+ repeatMode
9015
9070
  };
9016
9071
 
9017
9072
  const { toPoint: toPoint$2 } = AroundHelper;
@@ -9041,8 +9096,8 @@ var LeaferUI = (function (exports) {
9041
9096
  }
9042
9097
  }
9043
9098
 
9044
- const { getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
9045
- const { get: get$1, rotateOfOuter: rotateOfOuter$1, scaleOfOuter: scaleOfOuter$1 } = MatrixHelper;
9099
+ const { getAngle, getDistance: getDistance$1 } = PointHelper;
9100
+ const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
9046
9101
  const { toPoint: toPoint$1 } = AroundHelper;
9047
9102
  const realFrom$1 = {};
9048
9103
  const realTo$1 = {};
@@ -9050,23 +9105,35 @@ var LeaferUI = (function (exports) {
9050
9105
  let { from, to, type, opacity, blendMode, stretch } = paint;
9051
9106
  toPoint$1(from || 'center', box, realFrom$1);
9052
9107
  toPoint$1(to || 'bottom', box, realTo$1);
9053
- const { width, height } = box;
9054
- let transform;
9055
- if (width !== height || stretch) {
9056
- transform = get$1();
9057
- scaleOfOuter$1(transform, realFrom$1, width / height * (stretch || 1), 1);
9058
- rotateOfOuter$1(transform, realFrom$1, getAngle$1(realFrom$1, realTo$1) + 90);
9059
- }
9060
9108
  const style = Platform.canvas.createRadialGradient(realFrom$1.x, realFrom$1.y, 0, realFrom$1.x, realFrom$1.y, getDistance$1(realFrom$1, realTo$1));
9061
9109
  applyStops(style, paint.stops, opacity);
9062
- const data = { type, style, transform };
9110
+ const data = { type, style };
9111
+ const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
9112
+ if (transform)
9113
+ data.transform = transform;
9063
9114
  if (blendMode)
9064
9115
  data.blendMode = blendMode;
9065
9116
  return data;
9066
9117
  }
9118
+ function getTransform(box, from, to, stretch, rotate90) {
9119
+ let transform;
9120
+ const { width, height } = box;
9121
+ if (width !== height || stretch) {
9122
+ const angle = getAngle(from, to);
9123
+ transform = get();
9124
+ if (rotate90) {
9125
+ scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
9126
+ rotateOfOuter(transform, from, angle + 90);
9127
+ }
9128
+ else {
9129
+ scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
9130
+ rotateOfOuter(transform, from, angle);
9131
+ }
9132
+ }
9133
+ return transform;
9134
+ }
9067
9135
 
9068
- const { getAngle, getDistance } = PointHelper;
9069
- const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
9136
+ const { getDistance } = PointHelper;
9070
9137
  const { toPoint } = AroundHelper;
9071
9138
  const realFrom = {};
9072
9139
  const realTo = {};
@@ -9074,20 +9141,12 @@ var LeaferUI = (function (exports) {
9074
9141
  let { from, to, type, opacity, blendMode, stretch } = paint;
9075
9142
  toPoint(from || 'center', box, realFrom);
9076
9143
  toPoint(to || 'bottom', box, realTo);
9077
- const { width, height } = box;
9078
- const transform = get();
9079
- const angle = getAngle(realFrom, realTo);
9080
- if (Platform.conicGradientRotate90) {
9081
- scaleOfOuter(transform, realFrom, width / height * (stretch || 1), 1);
9082
- rotateOfOuter(transform, realFrom, angle + 90);
9083
- }
9084
- else {
9085
- scaleOfOuter(transform, realFrom, 1, width / height * (stretch || 1));
9086
- rotateOfOuter(transform, realFrom, angle);
9087
- }
9088
9144
  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));
9089
9145
  applyStops(style, paint.stops, opacity);
9090
- const data = { type, style, transform };
9146
+ const data = { type, style };
9147
+ const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
9148
+ if (transform)
9149
+ data.transform = transform;
9091
9150
  if (blendMode)
9092
9151
  data.blendMode = blendMode;
9093
9152
  return data;
@@ -9096,7 +9155,8 @@ var LeaferUI = (function (exports) {
9096
9155
  const PaintGradientModule = {
9097
9156
  linearGradient,
9098
9157
  radialGradient,
9099
- conicGradient
9158
+ conicGradient,
9159
+ getTransform
9100
9160
  };
9101
9161
 
9102
9162
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
@@ -9822,11 +9882,21 @@ var LeaferUI = (function (exports) {
9822
9882
  resolve();
9823
9883
  this.running = false;
9824
9884
  };
9885
+ const { toURL } = Platform;
9886
+ const { download } = Platform.origin;
9887
+ const fileType = FileHelper.fileType(filename);
9825
9888
  if (filename === 'json') {
9826
9889
  return over({ data: leaf.toJSON() });
9827
9890
  }
9828
- else if (FileHelper.fileType(filename) === 'json') {
9829
- Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
9891
+ else if (fileType === 'json') {
9892
+ download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
9893
+ return over({ data: true });
9894
+ }
9895
+ if (filename === 'svg') {
9896
+ return over({ data: leaf.toSVG() });
9897
+ }
9898
+ else if (fileType === 'svg') {
9899
+ download(toURL(leaf.toSVG(), 'svg'), filename);
9830
9900
  return over({ data: true });
9831
9901
  }
9832
9902
  const { leafer } = leaf;