@leafer-draw/worker 1.0.0-rc.28 → 1.0.0

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.
@@ -1555,7 +1555,7 @@ class LeafData {
1555
1555
  if (this.__input && this.__input[name] !== undefined)
1556
1556
  this.__input[name] = undefined;
1557
1557
  }
1558
- __getInputData(names) {
1558
+ __getInputData(names, options) {
1559
1559
  const data = {};
1560
1560
  if (names) {
1561
1561
  if (names instanceof Array) {
@@ -1582,6 +1582,12 @@ class LeafData {
1582
1582
  }
1583
1583
  }
1584
1584
  }
1585
+ if (options) {
1586
+ if (options.matrix) {
1587
+ const { a, b, c, d, e, f } = this.__leaf.__localMatrix;
1588
+ data.matrix = { a, b, c, d, e, f };
1589
+ }
1590
+ }
1585
1591
  return data;
1586
1592
  }
1587
1593
  __setMiddle(name, value) {
@@ -5200,11 +5206,13 @@ let Leaf = class Leaf {
5200
5206
  setAttr(name, value) { this[name] = value; }
5201
5207
  getAttr(name) { return this[name]; }
5202
5208
  getComputedAttr(name) { return this.__[name]; }
5203
- toJSON() {
5204
- return this.__.__getInputData();
5209
+ toJSON(options) {
5210
+ if (options)
5211
+ this.__layout.update();
5212
+ return this.__.__getInputData(null, options);
5205
5213
  }
5206
- toString() {
5207
- return JSON.stringify(this.toJSON());
5214
+ toString(options) {
5215
+ return JSON.stringify(this.toJSON(options));
5208
5216
  }
5209
5217
  toSVG() { return undefined; }
5210
5218
  __SVG(_data) { }
@@ -5277,14 +5285,6 @@ let Leaf = class Leaf {
5277
5285
  return this.__world;
5278
5286
  }
5279
5287
  }
5280
- getWorld(attrName) {
5281
- this.__layout.update();
5282
- if (attrName === 'x')
5283
- return this.__world.e;
5284
- if (attrName === 'y')
5285
- return this.__world.f;
5286
- return this.getLayoutBounds()[attrName];
5287
- }
5288
5288
  getTransform(relative) {
5289
5289
  return this.__layout.getTransform(relative || 'local');
5290
5290
  }
@@ -5405,14 +5405,8 @@ let Leaf = class Leaf {
5405
5405
  this.scaleY *= scaleY;
5406
5406
  }
5407
5407
  __scaleResize(_scaleX, _scaleY) { }
5408
- resizeWidth(width) {
5409
- const scale = width / this.__localBoxBounds.width;
5410
- this.scaleResize(scale, this.__.lockRatio ? scale : 1);
5411
- }
5412
- resizeHeight(height) {
5413
- const scale = height / this.__localBoxBounds.height;
5414
- this.scaleResize(this.__.lockRatio ? scale : 1, scale);
5415
- }
5408
+ resizeWidth(_width) { }
5409
+ resizeHeight(_height) { }
5416
5410
  __hitWorld(_point) { return true; }
5417
5411
  __hit(_local) { return true; }
5418
5412
  __hitFill(_inner) { return true; }
@@ -5763,7 +5757,7 @@ class LeafLevelList {
5763
5757
  }
5764
5758
  }
5765
5759
 
5766
- const version = "1.0.0-rc.27";
5760
+ const version = "1.0.0-rc.30";
5767
5761
  const inviteCode = {};
5768
5762
 
5769
5763
  class LeaferCanvas extends LeaferCanvasBase {
@@ -7303,9 +7297,9 @@ let Group = class Group extends UI {
7303
7297
  super.set(data);
7304
7298
  }
7305
7299
  }
7306
- toJSON() {
7307
- const data = super.toJSON();
7308
- data.children = this.children.map(child => child.toJSON());
7300
+ toJSON(options) {
7301
+ const data = super.toJSON(options);
7302
+ data.children = this.children.map(child => child.toJSON(options));
7309
7303
  return data;
7310
7304
  }
7311
7305
  pick(_hitPoint, _options) { return undefined; }
@@ -7472,6 +7466,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7472
7466
  __onResize(event) {
7473
7467
  this.emitEvent(event);
7474
7468
  DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
7469
+ if (!event.width || !event.height)
7470
+ debug$1.warn('w = 0 or h = 0');
7475
7471
  setTimeout(() => { if (this.canvasManager)
7476
7472
  this.canvasManager.clearRecycled(); }, 0);
7477
7473
  }
@@ -7495,6 +7491,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
7495
7491
  __setAttr(attrName, newValue) {
7496
7492
  if (this.canvas) {
7497
7493
  if (canvasSizeAttrs.includes(attrName)) {
7494
+ if (!newValue)
7495
+ debug$1.warn(attrName + ' is 0');
7498
7496
  this.__changeCanvasSize(attrName, newValue);
7499
7497
  }
7500
7498
  else if (attrName === 'fill') {
@@ -9736,7 +9734,9 @@ function layoutText(drawData, style) {
9736
9734
  bounds.height = realHeight;
9737
9735
  }
9738
9736
 
9739
- function clipText(drawData, style) {
9737
+ function clipText(drawData, style, x, width) {
9738
+ if (!width)
9739
+ return;
9740
9740
  const { rows, overflow } = drawData;
9741
9741
  let { textOverflow } = style;
9742
9742
  rows.splice(overflow);
@@ -9747,7 +9747,7 @@ function clipText(drawData, style) {
9747
9747
  textOverflow = '...';
9748
9748
  let char, charRight;
9749
9749
  const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
9750
- const right = style.x + style.width - ellipsisWidth;
9750
+ const right = x + width - ellipsisWidth;
9751
9751
  const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
9752
9752
  list.forEach(row => {
9753
9753
  if (row.isOverflow && row.data) {
@@ -9823,7 +9823,7 @@ function getDrawData(content, style) {
9823
9823
  layoutText(drawData, style);
9824
9824
  layoutChar(drawData, style, width);
9825
9825
  if (drawData.overflow)
9826
- clipText(drawData, style);
9826
+ clipText(drawData, style, x, width);
9827
9827
  if (textDecoration !== 'none')
9828
9828
  decorationText(drawData, style);
9829
9829
  return drawData;
@@ -9894,6 +9894,8 @@ function getTrimBounds(canvas) {
9894
9894
  const ExportModule = {
9895
9895
  export(leaf, filename, options) {
9896
9896
  this.running = true;
9897
+ const fileType = FileHelper.fileType(filename);
9898
+ options = FileHelper.getExportOptions(options);
9897
9899
  return addTask((success) => new Promise((resolve) => {
9898
9900
  const over = (result) => {
9899
9901
  success(result);
@@ -9902,12 +9904,11 @@ const ExportModule = {
9902
9904
  };
9903
9905
  const { toURL } = Platform;
9904
9906
  const { download } = Platform.origin;
9905
- const fileType = FileHelper.fileType(filename);
9906
9907
  if (filename === 'json') {
9907
- return over({ data: leaf.toJSON() });
9908
+ return over({ data: leaf.toJSON(options.json) });
9908
9909
  }
9909
9910
  else if (fileType === 'json') {
9910
- download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
9911
+ download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
9911
9912
  return over({ data: true });
9912
9913
  }
9913
9914
  if (filename === 'svg') {
@@ -9921,7 +9922,6 @@ const ExportModule = {
9921
9922
  if (leafer) {
9922
9923
  checkLazy(leaf);
9923
9924
  leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
9924
- options = FileHelper.getExportOptions(options);
9925
9925
  let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
9926
9926
  const { worldTransform, isLeafer, isFrame } = leaf;
9927
9927
  const { slice, trim, onCanvas } = options;