@leafer-draw/worker 1.0.0-rc.25 → 1.0.0-rc.27

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) { }
@@ -5163,12 +5192,18 @@ var LeaferUI = (function (exports) {
5163
5192
  }
5164
5193
  set(_data) { }
5165
5194
  get(_name) { return undefined; }
5195
+ setAttr(name, value) { this[name] = value; }
5196
+ getAttr(name) { return this[name]; }
5197
+ getComputedAttr(name) { return this.__[name]; }
5166
5198
  toJSON() {
5167
5199
  return this.__.__getInputData();
5168
5200
  }
5169
5201
  toString() {
5170
5202
  return JSON.stringify(this.toJSON());
5171
5203
  }
5204
+ toSVG() { return undefined; }
5205
+ __SVG(_data) { }
5206
+ toHTML() { return undefined; }
5172
5207
  __setAttr(_attrName, _newValue) { return true; }
5173
5208
  __getAttr(_attrName) { return undefined; }
5174
5209
  setProxyAttr(_attrName, _newValue) { }
@@ -5334,13 +5369,13 @@ var LeaferUI = (function (exports) {
5334
5369
  moveLocal(this, x, y);
5335
5370
  }
5336
5371
  scaleOf(origin, scaleX, scaleY, resize) {
5337
- zoomOfLocal(this, tempToOuterOf(origin, this.localTransform), scaleX, scaleY, resize);
5372
+ zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
5338
5373
  }
5339
5374
  rotateOf(origin, rotation) {
5340
- rotateOfLocal(this, tempToOuterOf(origin, this.localTransform), rotation);
5375
+ rotateOfLocal(this, getLocalOrigin(this, origin), rotation);
5341
5376
  }
5342
5377
  skewOf(origin, skewX, skewY, resize) {
5343
- skewOfLocal(this, tempToOuterOf(origin, this.localTransform), skewX, skewY, resize);
5378
+ skewOfLocal(this, getLocalOrigin(this, origin), skewX, skewY, resize);
5344
5379
  }
5345
5380
  transformWorld(worldTransform, resize) {
5346
5381
  transformWorld(this, worldTransform, resize);
@@ -5362,6 +5397,14 @@ var LeaferUI = (function (exports) {
5362
5397
  this.scaleY *= scaleY;
5363
5398
  }
5364
5399
  __scaleResize(_scaleX, _scaleY) { }
5400
+ resizeWidth(width) {
5401
+ const scale = width / this.__localBoxBounds.width;
5402
+ this.scaleResize(scale, this.__.lockRatio ? scale : 1);
5403
+ }
5404
+ resizeHeight(height) {
5405
+ const scale = height / this.__localBoxBounds.height;
5406
+ this.scaleResize(this.__.lockRatio ? scale : 1, scale);
5407
+ }
5365
5408
  __hitWorld(_point) { return true; }
5366
5409
  __hit(_local) { return true; }
5367
5410
  __hitFill(_inner) { return true; }
@@ -5712,7 +5755,7 @@ var LeaferUI = (function (exports) {
5712
5755
  }
5713
5756
  }
5714
5757
 
5715
- const version = "1.0.0-rc.25";
5758
+ const version = "1.0.0-rc.27";
5716
5759
  const inviteCode = {};
5717
5760
 
5718
5761
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6782,6 +6825,8 @@ var LeaferUI = (function (exports) {
6782
6825
  this.__drawRenderPath(canvas);
6783
6826
  if (fill && !ignoreFill)
6784
6827
  this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
6828
+ if (this.__.__isCanvas)
6829
+ this.__drawAfterFill(canvas, options);
6785
6830
  if (stroke && !ignoreStroke)
6786
6831
  this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
6787
6832
  }
@@ -6986,7 +7031,7 @@ var LeaferUI = (function (exports) {
6986
7031
  stateType(false)
6987
7032
  ], exports.UI.prototype, "disabled", void 0);
6988
7033
  __decorate([
6989
- dataType(false)
7034
+ surfaceType(false)
6990
7035
  ], exports.UI.prototype, "locked", void 0);
6991
7036
  __decorate([
6992
7037
  sortType(0)
@@ -7084,6 +7129,9 @@ var LeaferUI = (function (exports) {
7084
7129
  __decorate([
7085
7130
  boundsType()
7086
7131
  ], exports.UI.prototype, "autoHeight", void 0);
7132
+ __decorate([
7133
+ boundsType()
7134
+ ], exports.UI.prototype, "lockRatio", void 0);
7087
7135
  __decorate([
7088
7136
  boundsType()
7089
7137
  ], exports.UI.prototype, "autoBox", void 0);
@@ -7201,6 +7249,9 @@ var LeaferUI = (function (exports) {
7201
7249
  __decorate([
7202
7250
  dataType()
7203
7251
  ], exports.UI.prototype, "disabledStyle", void 0);
7252
+ __decorate([
7253
+ dataType({})
7254
+ ], exports.UI.prototype, "data", void 0);
7204
7255
  __decorate([
7205
7256
  rewrite(exports.Leaf.prototype.reset)
7206
7257
  ], exports.UI.prototype, "reset", null);
@@ -7673,9 +7724,9 @@ var LeaferUI = (function (exports) {
7673
7724
  if (!data.__autoSize) {
7674
7725
  const b = this.__layout.boxBounds;
7675
7726
  if (!data.__autoWidth)
7676
- b.x = 0, b.width = data.width;
7727
+ b.height += b.y, b.width = data.width, b.x = b.y = 0;
7677
7728
  if (!data.__autoHeight)
7678
- b.y = 0, b.height = data.height;
7729
+ b.width += b.x, b.height = data.height, b.y = b.x = 0;
7679
7730
  }
7680
7731
  }
7681
7732
  else {
@@ -7745,6 +7796,9 @@ var LeaferUI = (function (exports) {
7745
7796
  __decorate([
7746
7797
  dataProcessor(BoxData)
7747
7798
  ], exports.Box.prototype, "__", void 0);
7799
+ __decorate([
7800
+ dataType(false)
7801
+ ], exports.Box.prototype, "resizeChildren", void 0);
7748
7802
  __decorate([
7749
7803
  affectRenderBoundsType('show')
7750
7804
  ], exports.Box.prototype, "overflow", void 0);
@@ -7854,7 +7908,7 @@ var LeaferUI = (function (exports) {
7854
7908
  ], exports.Ellipse);
7855
7909
 
7856
7910
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
7857
- const { rotate: rotate$1, getAngle: getAngle$2, getDistance: getDistance$2, defaultPoint } = PointHelper;
7911
+ const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
7858
7912
  const { toBounds: toBounds$1 } = PathBounds;
7859
7913
  exports.Line = class Line extends exports.UI {
7860
7914
  get __tag() { return 'Line'; }
@@ -7869,7 +7923,7 @@ var LeaferUI = (function (exports) {
7869
7923
  }
7870
7924
  set toPoint(value) {
7871
7925
  this.width = getDistance$2(defaultPoint, value);
7872
- this.rotation = getAngle$2(defaultPoint, value);
7926
+ this.rotation = getAngle$1(defaultPoint, value);
7873
7927
  if (this.height)
7874
7928
  this.height = 0;
7875
7929
  }
@@ -8040,7 +8094,7 @@ var LeaferUI = (function (exports) {
8040
8094
  super(data);
8041
8095
  this.canvas = Creator.canvas(this.__);
8042
8096
  this.context = this.canvas.context;
8043
- this.__.__drawAfterFill = true;
8097
+ this.__.__isCanvas = this.__.__drawAfterFill = true;
8044
8098
  }
8045
8099
  draw(ui, offset, scale, rotation) {
8046
8100
  ui.__layout.update();
@@ -8108,9 +8162,6 @@ var LeaferUI = (function (exports) {
8108
8162
  __decorate([
8109
8163
  resizeType()
8110
8164
  ], exports.Canvas.prototype, "contextSettings", void 0);
8111
- __decorate([
8112
- hitType('all')
8113
- ], exports.Canvas.prototype, "hitFill", void 0);
8114
8165
  exports.Canvas = __decorate([
8115
8166
  registerUI()
8116
8167
  ], exports.Canvas);
@@ -8216,6 +8267,9 @@ var LeaferUI = (function (exports) {
8216
8267
  __decorate([
8217
8268
  boundsType(0)
8218
8269
  ], exports.Text.prototype, "height", void 0);
8270
+ __decorate([
8271
+ dataType(false)
8272
+ ], exports.Text.prototype, "resizeFontSize", void 0);
8219
8273
  __decorate([
8220
8274
  surfaceType('#000000')
8221
8275
  ], exports.Text.prototype, "fill", void 0);
@@ -8628,7 +8682,7 @@ var LeaferUI = (function (exports) {
8628
8682
  case 'angular':
8629
8683
  return PaintGradient.conicGradient(paint, boxBounds);
8630
8684
  default:
8631
- return paint.r ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
8685
+ return paint.r !== undefined ? { type: 'solid', style: ColorConvert.string(paint) } : undefined;
8632
8686
  }
8633
8687
  }
8634
8688
 
@@ -8645,17 +8699,17 @@ var LeaferUI = (function (exports) {
8645
8699
  };
8646
8700
 
8647
8701
  let origin = {};
8648
- const { get: get$4, rotateOfOuter: rotateOfOuter$2, translate: translate$1, scaleOfOuter: scaleOfOuter$2, scale: scaleHelper, rotate } = MatrixHelper;
8702
+ const { get: get$3, rotateOfOuter: rotateOfOuter$1, translate: translate$1, scaleOfOuter: scaleOfOuter$1, scale: scaleHelper, rotate } = MatrixHelper;
8649
8703
  function fillOrFitMode(data, box, x, y, scaleX, scaleY, rotation) {
8650
- const transform = get$4();
8704
+ const transform = get$3();
8651
8705
  translate$1(transform, box.x + x, box.y + y);
8652
8706
  scaleHelper(transform, scaleX, scaleY);
8653
8707
  if (rotation)
8654
- rotateOfOuter$2(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
8708
+ rotateOfOuter$1(transform, { x: box.x + box.width / 2, y: box.y + box.height / 2 }, rotation);
8655
8709
  data.transform = transform;
8656
8710
  }
8657
8711
  function clipMode(data, box, x, y, scaleX, scaleY, rotation) {
8658
- const transform = get$4();
8712
+ const transform = get$3();
8659
8713
  translate$1(transform, box.x + x, box.y + y);
8660
8714
  if (scaleX)
8661
8715
  scaleHelper(transform, scaleX, scaleY);
@@ -8664,10 +8718,10 @@ var LeaferUI = (function (exports) {
8664
8718
  data.transform = transform;
8665
8719
  }
8666
8720
  function repeatMode(data, box, width, height, x, y, scaleX, scaleY, rotation, align) {
8667
- const transform = get$4();
8721
+ const transform = get$3();
8668
8722
  if (rotation) {
8669
8723
  if (align === 'center') {
8670
- rotateOfOuter$2(transform, { x: width / 2, y: height / 2 }, rotation);
8724
+ rotateOfOuter$1(transform, { x: width / 2, y: height / 2 }, rotation);
8671
8725
  }
8672
8726
  else {
8673
8727
  rotate(transform, rotation);
@@ -8688,22 +8742,26 @@ var LeaferUI = (function (exports) {
8688
8742
  origin.y = box.y + y;
8689
8743
  translate$1(transform, origin.x, origin.y);
8690
8744
  if (scaleX)
8691
- scaleOfOuter$2(transform, origin, scaleX, scaleY);
8745
+ scaleOfOuter$1(transform, origin, scaleX, scaleY);
8692
8746
  data.transform = transform;
8693
8747
  }
8694
8748
 
8695
- const { get: get$3, translate } = MatrixHelper;
8749
+ const { get: get$2, translate } = MatrixHelper;
8696
8750
  const tempBox = new Bounds();
8697
8751
  const tempPoint = {};
8698
8752
  function createData(leafPaint, image, paint, box) {
8753
+ const { blendMode } = paint;
8754
+ if (blendMode)
8755
+ leafPaint.blendMode = blendMode;
8756
+ leafPaint.data = getPatternData(paint, box, image);
8757
+ }
8758
+ function getPatternData(paint, box, image) {
8699
8759
  let { width, height } = image;
8700
8760
  if (paint.padding)
8701
8761
  box = tempBox.set(box).shrink(paint.padding);
8702
- const { opacity, mode, align, offset, scale, size, rotation, blendMode, repeat } = paint;
8762
+ const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
8703
8763
  const sameBox = box.width === width && box.height === height;
8704
- if (blendMode)
8705
- leafPaint.blendMode = blendMode;
8706
- const data = leafPaint.data = { mode };
8764
+ const data = { mode };
8707
8765
  const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
8708
8766
  const swapWidth = swapSize ? height : width, swapHeight = swapSize ? width : height;
8709
8767
  let x = 0, y = 0, scaleX, scaleY;
@@ -8755,7 +8813,7 @@ var LeaferUI = (function (exports) {
8755
8813
  }
8756
8814
  if (!data.transform) {
8757
8815
  if (box.x || box.y) {
8758
- data.transform = get$3();
8816
+ data.transform = get$2();
8759
8817
  translate(data.transform, box.x, box.y);
8760
8818
  }
8761
8819
  }
@@ -8769,6 +8827,7 @@ var LeaferUI = (function (exports) {
8769
8827
  data.opacity = opacity;
8770
8828
  if (repeat)
8771
8829
  data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
8830
+ return data;
8772
8831
  }
8773
8832
 
8774
8833
  let cache, box = new Bounds();
@@ -8858,7 +8917,7 @@ var LeaferUI = (function (exports) {
8858
8917
  leafer.renderer.ignore = value;
8859
8918
  }
8860
8919
 
8861
- const { get: get$2, scale, copy: copy$1 } = MatrixHelper;
8920
+ const { get: get$1, scale, copy: copy$1 } = MatrixHelper;
8862
8921
  const { ceil, abs: abs$1 } = Math;
8863
8922
  function createPattern(ui, paint, pixelRatio) {
8864
8923
  let { scaleX, scaleY } = ImageManager.patternLocked ? ui.__world : ui.__nowWorld;
@@ -8869,7 +8928,7 @@ var LeaferUI = (function (exports) {
8869
8928
  const { image, data } = paint;
8870
8929
  let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, opacity, transform, repeat } = data;
8871
8930
  if (sx) {
8872
- imageMatrix = get$2();
8931
+ imageMatrix = get$1();
8873
8932
  copy$1(imageMatrix, transform);
8874
8933
  scale(imageMatrix, 1 / sx, 1 / sy);
8875
8934
  scaleX *= sx;
@@ -8904,7 +8963,7 @@ var LeaferUI = (function (exports) {
8904
8963
  }
8905
8964
  if (transform || scaleX !== 1 || scaleY !== 1) {
8906
8965
  if (!imageMatrix) {
8907
- imageMatrix = get$2();
8966
+ imageMatrix = get$1();
8908
8967
  if (transform)
8909
8968
  copy$1(imageMatrix, transform);
8910
8969
  }
@@ -9005,13 +9064,14 @@ var LeaferUI = (function (exports) {
9005
9064
 
9006
9065
  const PaintImageModule = {
9007
9066
  image,
9067
+ checkImage,
9068
+ createPattern,
9069
+ recycleImage,
9008
9070
  createData,
9071
+ getPatternData,
9009
9072
  fillOrFitMode,
9010
9073
  clipMode,
9011
- repeatMode,
9012
- createPattern,
9013
- checkImage,
9014
- recycleImage
9074
+ repeatMode
9015
9075
  };
9016
9076
 
9017
9077
  const { toPoint: toPoint$2 } = AroundHelper;
@@ -9041,8 +9101,8 @@ var LeaferUI = (function (exports) {
9041
9101
  }
9042
9102
  }
9043
9103
 
9044
- const { getAngle: getAngle$1, getDistance: getDistance$1 } = PointHelper;
9045
- const { get: get$1, rotateOfOuter: rotateOfOuter$1, scaleOfOuter: scaleOfOuter$1 } = MatrixHelper;
9104
+ const { getAngle, getDistance: getDistance$1 } = PointHelper;
9105
+ const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
9046
9106
  const { toPoint: toPoint$1 } = AroundHelper;
9047
9107
  const realFrom$1 = {};
9048
9108
  const realTo$1 = {};
@@ -9050,23 +9110,35 @@ var LeaferUI = (function (exports) {
9050
9110
  let { from, to, type, opacity, blendMode, stretch } = paint;
9051
9111
  toPoint$1(from || 'center', box, realFrom$1);
9052
9112
  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
9113
  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
9114
  applyStops(style, paint.stops, opacity);
9062
- const data = { type, style, transform };
9115
+ const data = { type, style };
9116
+ const transform = getTransform(box, realFrom$1, realTo$1, stretch, true);
9117
+ if (transform)
9118
+ data.transform = transform;
9063
9119
  if (blendMode)
9064
9120
  data.blendMode = blendMode;
9065
9121
  return data;
9066
9122
  }
9123
+ function getTransform(box, from, to, stretch, rotate90) {
9124
+ let transform;
9125
+ const { width, height } = box;
9126
+ if (width !== height || stretch) {
9127
+ const angle = getAngle(from, to);
9128
+ transform = get();
9129
+ if (rotate90) {
9130
+ scaleOfOuter(transform, from, width / height * (stretch || 1), 1);
9131
+ rotateOfOuter(transform, from, angle + 90);
9132
+ }
9133
+ else {
9134
+ scaleOfOuter(transform, from, 1, width / height * (stretch || 1));
9135
+ rotateOfOuter(transform, from, angle);
9136
+ }
9137
+ }
9138
+ return transform;
9139
+ }
9067
9140
 
9068
- const { getAngle, getDistance } = PointHelper;
9069
- const { get, rotateOfOuter, scaleOfOuter } = MatrixHelper;
9141
+ const { getDistance } = PointHelper;
9070
9142
  const { toPoint } = AroundHelper;
9071
9143
  const realFrom = {};
9072
9144
  const realTo = {};
@@ -9074,20 +9146,12 @@ var LeaferUI = (function (exports) {
9074
9146
  let { from, to, type, opacity, blendMode, stretch } = paint;
9075
9147
  toPoint(from || 'center', box, realFrom);
9076
9148
  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
9149
  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
9150
  applyStops(style, paint.stops, opacity);
9090
- const data = { type, style, transform };
9151
+ const data = { type, style };
9152
+ const transform = getTransform(box, realFrom, realTo, stretch || 1, Platform.conicGradientRotate90);
9153
+ if (transform)
9154
+ data.transform = transform;
9091
9155
  if (blendMode)
9092
9156
  data.blendMode = blendMode;
9093
9157
  return data;
@@ -9096,7 +9160,8 @@ var LeaferUI = (function (exports) {
9096
9160
  const PaintGradientModule = {
9097
9161
  linearGradient,
9098
9162
  radialGradient,
9099
- conicGradient
9163
+ conicGradient,
9164
+ getTransform
9100
9165
  };
9101
9166
 
9102
9167
  const { copy, toOffsetOutBounds: toOffsetOutBounds$1 } = BoundsHelper;
@@ -9822,11 +9887,21 @@ var LeaferUI = (function (exports) {
9822
9887
  resolve();
9823
9888
  this.running = false;
9824
9889
  };
9890
+ const { toURL } = Platform;
9891
+ const { download } = Platform.origin;
9892
+ const fileType = FileHelper.fileType(filename);
9825
9893
  if (filename === 'json') {
9826
9894
  return over({ data: leaf.toJSON() });
9827
9895
  }
9828
- else if (FileHelper.fileType(filename) === 'json') {
9829
- Platform.origin.download('data:text/plain;charset=utf-8,' + encodeURIComponent(JSON.stringify(leaf.toJSON())), filename);
9896
+ else if (fileType === 'json') {
9897
+ download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
9898
+ return over({ data: true });
9899
+ }
9900
+ if (filename === 'svg') {
9901
+ return over({ data: leaf.toSVG() });
9902
+ }
9903
+ else if (fileType === 'svg') {
9904
+ download(toURL(leaf.toSVG(), 'svg'), filename);
9830
9905
  return over({ data: true });
9831
9906
  }
9832
9907
  const { leafer } = leaf;