leafer-draw 1.2.2 → 1.3.1

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
@@ -768,8 +768,8 @@ var LeaferUI = (function (exports) {
768
768
  t.maxY = y > t.maxY ? y : t.maxY;
769
769
  },
770
770
  addBounds(t, x, y, width, height) {
771
- addPoint$4(t, x, y);
772
- addPoint$4(t, x + width, y + height);
771
+ addPoint$3(t, x, y);
772
+ addPoint$3(t, x + width, y + height);
773
773
  },
774
774
  copy(t, pb) {
775
775
  t.minX = pb.minX;
@@ -790,9 +790,9 @@ var LeaferUI = (function (exports) {
790
790
  setBounds.height = t.maxY - t.minY;
791
791
  }
792
792
  };
793
- const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
793
+ const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
794
794
 
795
- const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
795
+ const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
796
796
  const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
797
797
  const { float, fourNumber } = MathHelper;
798
798
  const { floor, ceil: ceil$2 } = Math;
@@ -908,17 +908,17 @@ var LeaferUI = (function (exports) {
908
908
  point.x = t.x;
909
909
  point.y = t.y;
910
910
  toOuterPoint$2(matrix, point, toPoint$5);
911
- setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
911
+ setPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
912
912
  point.x = t.x + t.width;
913
913
  toOuterPoint$2(matrix, point, toPoint$5);
914
- addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
914
+ addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
915
915
  point.y = t.y + t.height;
916
916
  toOuterPoint$2(matrix, point, toPoint$5);
917
- addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
917
+ addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
918
918
  point.x = t.x;
919
919
  toOuterPoint$2(matrix, point, toPoint$5);
920
- addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
921
- toBounds$4(tempPointBounds$1, to);
920
+ addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
921
+ toBounds$3(tempPointBounds$1, to);
922
922
  }
923
923
  },
924
924
  toInnerOf(t, matrix, to) {
@@ -1008,8 +1008,8 @@ var LeaferUI = (function (exports) {
1008
1008
  B.reset(t);
1009
1009
  },
1010
1010
  setPoints(t, points) {
1011
- points.forEach((point, index) => index === 0 ? setPoint$3(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
1012
- toBounds$4(tempPointBounds$1, t);
1011
+ points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
1012
+ toBounds$3(tempPointBounds$1, t);
1013
1013
  },
1014
1014
  setPoint(t, point) {
1015
1015
  B.set(t, point.x, point.y);
@@ -1377,7 +1377,7 @@ var LeaferUI = (function (exports) {
1377
1377
  }
1378
1378
  const D$4 = Debug;
1379
1379
 
1380
- const debug$f = Debug.get('RunTime');
1380
+ const debug$e = Debug.get('RunTime');
1381
1381
  const Run = {
1382
1382
  currentId: 0,
1383
1383
  currentName: '',
@@ -1395,7 +1395,7 @@ var LeaferUI = (function (exports) {
1395
1395
  const time = R.idMap[id], name = R.nameMap[id];
1396
1396
  const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
1397
1397
  R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
1398
- debug$f.log(name, duration, 'ms');
1398
+ debug$e.log(name, duration, 'ms');
1399
1399
  },
1400
1400
  endOfName(name, microsecond) {
1401
1401
  const id = R.nameToIdMap[name];
@@ -1405,34 +1405,37 @@ var LeaferUI = (function (exports) {
1405
1405
  };
1406
1406
  const R = Run;
1407
1407
 
1408
+ const check = [];
1408
1409
  const Plugin = {
1409
1410
  list: {},
1410
- add(name) {
1411
+ add(name, ...needPlugins) {
1411
1412
  this.list[name] = true;
1413
+ check.push(...needPlugins);
1412
1414
  },
1413
- check(name, tip) {
1415
+ has(name, tip) {
1414
1416
  const rs = this.list[name];
1415
1417
  if (!rs && tip)
1416
1418
  this.need(name);
1417
1419
  return rs;
1418
1420
  },
1419
1421
  need(name) {
1420
- console.error('need plugin: @leafer-in/' + name);
1422
+ console.error('need plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1421
1423
  }
1422
1424
  };
1425
+ setTimeout(() => check.forEach(name => Plugin.has(name, true)));
1423
1426
 
1424
- const debug$e = Debug.get('UICreator');
1427
+ const debug$d = Debug.get('UICreator');
1425
1428
  const UICreator = {
1426
1429
  list: {},
1427
1430
  register(UI) {
1428
1431
  const { __tag: tag } = UI.prototype;
1429
1432
  if (list$1[tag])
1430
- debug$e.repeat(tag);
1433
+ debug$d.repeat(tag);
1431
1434
  list$1[tag] = UI;
1432
1435
  },
1433
1436
  get(tag, data, x, y, width, height) {
1434
1437
  if (!list$1[tag])
1435
- debug$e.error('not register ' + tag);
1438
+ debug$d.error('not register ' + tag);
1436
1439
  const ui = new list$1[tag](data);
1437
1440
  if (x !== undefined) {
1438
1441
  ui.x = x;
@@ -1448,7 +1451,7 @@ var LeaferUI = (function (exports) {
1448
1451
  };
1449
1452
  const { list: list$1 } = UICreator;
1450
1453
 
1451
- const debug$d = Debug.get('EventCreator');
1454
+ const debug$c = Debug.get('EventCreator');
1452
1455
  const EventCreator = {
1453
1456
  nameList: {},
1454
1457
  register(Event) {
@@ -1456,7 +1459,7 @@ var LeaferUI = (function (exports) {
1456
1459
  Object.keys(Event).forEach(key => {
1457
1460
  name = Event[key];
1458
1461
  if (typeof name === 'string')
1459
- nameList[name] && debug$d.repeat(name), nameList[name] = Event;
1462
+ nameList[name] && debug$c.repeat(name), nameList[name] = Event;
1460
1463
  });
1461
1464
  },
1462
1465
  changeName(oldName, newName) {
@@ -2345,7 +2348,7 @@ var LeaferUI = (function (exports) {
2345
2348
  };
2346
2349
 
2347
2350
  const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2348
- const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2351
+ const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2349
2352
  const { set, toNumberPoints } = PointHelper;
2350
2353
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2351
2354
  const tempPoint$2 = {};
@@ -2421,8 +2424,8 @@ var LeaferUI = (function (exports) {
2421
2424
  if (data)
2422
2425
  data.push(L$6, x1, y1);
2423
2426
  if (setPointBounds) {
2424
- setPoint$2(setPointBounds, fromX, fromY);
2425
- addPoint$2(setPointBounds, x1, y1);
2427
+ setPoint$1(setPointBounds, fromX, fromY);
2428
+ addPoint$1(setPointBounds, x1, y1);
2426
2429
  }
2427
2430
  if (setStartPoint)
2428
2431
  set(setStartPoint, fromX, fromY);
@@ -2474,7 +2477,7 @@ var LeaferUI = (function (exports) {
2474
2477
  if (data)
2475
2478
  data.push(data.length ? L$6 : M$5, fromX, fromY);
2476
2479
  if (setPointBounds)
2477
- setPoint$2(setPointBounds, fromX, fromY);
2480
+ setPoint$1(setPointBounds, fromX, fromY);
2478
2481
  if (setStartPoint)
2479
2482
  set(setStartPoint, fromX, fromY);
2480
2483
  for (let i = 0; i < parts; i++) {
@@ -2536,11 +2539,11 @@ var LeaferUI = (function (exports) {
2536
2539
  if (0 < t2 && t2 < 1)
2537
2540
  tList.push(t2);
2538
2541
  }
2539
- addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
2540
- addPoint$2(pointBounds, toX, toY);
2542
+ addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
2543
+ addPoint$1(pointBounds, toX, toY);
2541
2544
  for (let i = 0, len = tList.length; i < len; i++) {
2542
2545
  getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2543
- addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
2546
+ addPoint$1(pointBounds, tempPoint$2.x, tempPoint$2.y);
2544
2547
  }
2545
2548
  },
2546
2549
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2612,7 +2615,7 @@ var LeaferUI = (function (exports) {
2612
2615
  const { M: M$4, m, L: L$5, l, H, h, V, v, C: C$4, c, S, s, Q: Q$3, q, T, t, A, a, Z: Z$4, z, N: N$3, D: D$3, X: X$3, G: G$3, F: F$4, O: O$3, P: P$3, U: U$3 } = PathCommandMap;
2613
2616
  const { rect: rect$2, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2614
2617
  const { ellipticalArc } = EllipseHelper;
2615
- const debug$c = Debug.get('PathConvert');
2618
+ const debug$b = Debug.get('PathConvert');
2616
2619
  const setEndPoint$1 = {};
2617
2620
  const PathConvert = {
2618
2621
  current: { dot: 0 },
@@ -2853,7 +2856,7 @@ var LeaferUI = (function (exports) {
2853
2856
  i += 6;
2854
2857
  break;
2855
2858
  default:
2856
- debug$c.error(`command: ${command} [index:${i}]`, old);
2859
+ debug$b.error(`command: ${command} [index:${i}]`, old);
2857
2860
  return data;
2858
2861
  }
2859
2862
  lastCommand = command;
@@ -3078,7 +3081,7 @@ var LeaferUI = (function (exports) {
3078
3081
  }
3079
3082
 
3080
3083
  const { M: M$2, L: L$3, C: C$2, Q: Q$1, Z: Z$2, N: N$1, D: D$1, X: X$1, G: G$1, F: F$2, O: O$1, P: P$1, U: U$1 } = PathCommandMap;
3081
- const debug$b = Debug.get('PathDrawer');
3084
+ const debug$a = Debug.get('PathDrawer');
3082
3085
  const PathDrawer = {
3083
3086
  drawPathByData(drawer, data) {
3084
3087
  if (!data)
@@ -3141,7 +3144,7 @@ var LeaferUI = (function (exports) {
3141
3144
  i += 6;
3142
3145
  break;
3143
3146
  default:
3144
- debug$b.error(`command: ${command} [index:${i}]`, data);
3147
+ debug$a.error(`command: ${command} [index:${i}]`, data);
3145
3148
  return;
3146
3149
  }
3147
3150
  }
@@ -3150,8 +3153,8 @@ var LeaferUI = (function (exports) {
3150
3153
 
3151
3154
  const { M: M$1, L: L$2, C: C$1, Q, Z: Z$1, N, D, X, G, F: F$1, O, P, U } = PathCommandMap;
3152
3155
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3153
- const { addPointBounds, copy: copy$7, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3154
- const debug$a = Debug.get('PathBounds');
3156
+ const { addPointBounds, copy: copy$7, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
3157
+ const debug$9 = Debug.get('PathBounds');
3155
3158
  let radius, radiusX, radiusY;
3156
3159
  const tempPointBounds = {};
3157
3160
  const setPointBounds = {};
@@ -3159,21 +3162,21 @@ var LeaferUI = (function (exports) {
3159
3162
  const PathBounds = {
3160
3163
  toBounds(data, setBounds) {
3161
3164
  PathBounds.toTwoPointBounds(data, setPointBounds);
3162
- toBounds$3(setPointBounds, setBounds);
3165
+ toBounds$2(setPointBounds, setBounds);
3163
3166
  },
3164
3167
  toTwoPointBounds(data, setPointBounds) {
3165
3168
  if (!data || !data.length)
3166
- return setPoint$1(setPointBounds, 0, 0);
3169
+ return setPoint(setPointBounds, 0, 0);
3167
3170
  let i = 0, x = 0, y = 0, x1, y1, toX, toY, command;
3168
3171
  const len = data.length;
3169
3172
  while (i < len) {
3170
3173
  command = data[i];
3171
3174
  if (i === 0) {
3172
3175
  if (command === Z$1 || command === C$1 || command === Q) {
3173
- setPoint$1(setPointBounds, x, y);
3176
+ setPoint(setPointBounds, x, y);
3174
3177
  }
3175
3178
  else {
3176
- setPoint$1(setPointBounds, data[i + 1], data[i + 2]);
3179
+ setPoint(setPointBounds, data[i + 1], data[i + 2]);
3177
3180
  }
3178
3181
  }
3179
3182
  switch (command) {
@@ -3181,7 +3184,7 @@ var LeaferUI = (function (exports) {
3181
3184
  case L$2:
3182
3185
  x = data[i + 1];
3183
3186
  y = data[i + 2];
3184
- addPoint$1(setPointBounds, x, y);
3187
+ addPoint(setPointBounds, x, y);
3185
3188
  i += 3;
3186
3189
  break;
3187
3190
  case C$1:
@@ -3259,7 +3262,7 @@ var LeaferUI = (function (exports) {
3259
3262
  i += 6;
3260
3263
  break;
3261
3264
  default:
3262
- debug$a.error(`command: ${command} [index:${i}]`, data);
3265
+ debug$9.error(`command: ${command} [index:${i}]`, data);
3263
3266
  return;
3264
3267
  }
3265
3268
  }
@@ -3375,7 +3378,7 @@ var LeaferUI = (function (exports) {
3375
3378
  const F = FileHelper;
3376
3379
  F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3377
3380
 
3378
- const debug$9 = Debug.get('TaskProcessor');
3381
+ const debug$8 = Debug.get('TaskProcessor');
3379
3382
  class TaskItem {
3380
3383
  constructor(task) {
3381
3384
  this.parallel = true;
@@ -3390,7 +3393,7 @@ var LeaferUI = (function (exports) {
3390
3393
  yield this.task();
3391
3394
  }
3392
3395
  catch (error) {
3393
- debug$9.error(error);
3396
+ debug$8.error(error);
3394
3397
  }
3395
3398
  });
3396
3399
  }
@@ -4077,7 +4080,7 @@ var LeaferUI = (function (exports) {
4077
4080
  defineKey(data, key, property);
4078
4081
  }
4079
4082
 
4080
- const debug$8 = new Debug('rewrite');
4083
+ const debug$7 = new Debug('rewrite');
4081
4084
  const list = [];
4082
4085
  const excludeNames = ['destroy', 'constructor'];
4083
4086
  function rewrite(method) {
@@ -4094,7 +4097,7 @@ var LeaferUI = (function (exports) {
4094
4097
  if (list.length) {
4095
4098
  list.forEach(item => {
4096
4099
  if (error)
4097
- debug$8.error(item.name, '需在Class上装饰@rewriteAble()');
4100
+ debug$7.error(item.name, '需在Class上装饰@rewriteAble()');
4098
4101
  item.run();
4099
4102
  });
4100
4103
  list.length = 0;
@@ -4811,7 +4814,6 @@ var LeaferUI = (function (exports) {
4811
4814
  }
4812
4815
  }
4813
4816
  }
4814
- LayoutEvent.CHECK_UPDATE = 'layout.check_update';
4815
4817
  LayoutEvent.REQUEST = 'layout.request';
4816
4818
  LayoutEvent.START = 'layout.start';
4817
4819
  LayoutEvent.BEFORE = 'layout.before';
@@ -5006,13 +5008,13 @@ var LeaferUI = (function (exports) {
5006
5008
  const LeafEventer = { on, on_, off, off_, once, emit: emit$1, emitEvent, hasEvent, destroyEventer: destroy };
5007
5009
 
5008
5010
  const { isFinite } = Number;
5009
- const debug$7 = Debug.get('setAttr');
5011
+ const debug$6 = Debug.get('setAttr');
5010
5012
  const LeafDataProxy = {
5011
5013
  __setAttr(name, newValue, checkFiniteNumber) {
5012
5014
  if (this.leaferIsCreated) {
5013
5015
  const oldValue = this.__.__getInput(name);
5014
5016
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
5015
- debug$7.warn(this.innerName, name, newValue);
5017
+ debug$6.warn(this.innerName, name, newValue);
5016
5018
  newValue = undefined;
5017
5019
  }
5018
5020
  if (typeof newValue === 'object' || oldValue !== newValue) {
@@ -5082,7 +5084,7 @@ var LeaferUI = (function (exports) {
5082
5084
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5083
5085
  const { updateBounds: updateBounds$1 } = BranchHelper;
5084
5086
  const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$4 } = BoundsHelper;
5085
- const { toBounds: toBounds$2 } = PathBounds;
5087
+ const { toBounds: toBounds$1 } = PathBounds;
5086
5088
  const LeafBounds = {
5087
5089
  __updateWorldBounds() {
5088
5090
  toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
@@ -5164,7 +5166,7 @@ var LeaferUI = (function (exports) {
5164
5166
  const b = this.__layout.boxBounds;
5165
5167
  const data = this.__;
5166
5168
  if (data.__pathInputed) {
5167
- toBounds$2(data.path, b);
5169
+ toBounds$1(data.path, b);
5168
5170
  }
5169
5171
  else {
5170
5172
  b.x = 0;
@@ -5712,7 +5714,7 @@ var LeaferUI = (function (exports) {
5712
5714
  const { setListWithFn } = BoundsHelper;
5713
5715
  const { sort } = BranchHelper;
5714
5716
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5715
- const debug$6 = new Debug('Branch');
5717
+ const debug$5 = new Debug('Branch');
5716
5718
  exports.Branch = class Branch extends exports.Leaf {
5717
5719
  __updateStrokeSpread() {
5718
5720
  const { children } = this;
@@ -5754,7 +5756,7 @@ var LeaferUI = (function (exports) {
5754
5756
  }
5755
5757
  add(child, index) {
5756
5758
  if (child === this || child.destroyed)
5757
- return debug$6.warn('add self or destroyed');
5759
+ return debug$5.warn('add self or destroyed');
5758
5760
  const noIndex = index === undefined;
5759
5761
  if (!child.__) {
5760
5762
  if (child instanceof Array)
@@ -6008,9 +6010,9 @@ var LeaferUI = (function (exports) {
6008
6010
  }
6009
6011
  }
6010
6012
 
6011
- const version = "1.2.2";
6013
+ const version = "1.3.1";
6012
6014
 
6013
- const debug$5 = Debug.get('LeaferCanvas');
6015
+ const debug$4 = Debug.get('LeaferCanvas');
6014
6016
  class LeaferCanvas extends LeaferCanvasBase {
6015
6017
  set zIndex(zIndex) {
6016
6018
  const { style } = this.view;
@@ -6082,7 +6084,7 @@ var LeaferUI = (function (exports) {
6082
6084
  }
6083
6085
  }
6084
6086
  else {
6085
- debug$5.error(`no id: ${inputView}`);
6087
+ debug$4.error(`no id: ${inputView}`);
6086
6088
  this.__createView();
6087
6089
  }
6088
6090
  }
@@ -6120,7 +6122,7 @@ var LeaferUI = (function (exports) {
6120
6122
  }
6121
6123
  else {
6122
6124
  this.checkAutoBounds(this.view);
6123
- debug$5.warn('no parent');
6125
+ debug$4.warn('no parent');
6124
6126
  }
6125
6127
  }
6126
6128
  catch (_a) {
@@ -6456,7 +6458,7 @@ var LeaferUI = (function (exports) {
6456
6458
  }
6457
6459
 
6458
6460
  const { updateAllMatrix, updateAllChange } = LeafHelper;
6459
- const debug$4 = Debug.get('Layouter');
6461
+ const debug$3 = Debug.get('Layouter');
6460
6462
  class Layouter {
6461
6463
  constructor(target, userConfig) {
6462
6464
  this.totalTimes = 0;
@@ -6491,7 +6493,7 @@ var LeaferUI = (function (exports) {
6491
6493
  target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
6492
6494
  }
6493
6495
  catch (e) {
6494
- debug$4.error(e);
6496
+ debug$3.error(e);
6495
6497
  }
6496
6498
  this.layoutedBlocks = null;
6497
6499
  }
@@ -6505,9 +6507,9 @@ var LeaferUI = (function (exports) {
6505
6507
  }
6506
6508
  layoutOnce() {
6507
6509
  if (this.layouting)
6508
- return debug$4.warn('layouting');
6510
+ return debug$3.warn('layouting');
6509
6511
  if (this.times > 3)
6510
- return debug$4.warn('layout max times');
6512
+ return debug$3.warn('layout max times');
6511
6513
  this.times++;
6512
6514
  this.totalTimes++;
6513
6515
  this.layouting = true;
@@ -6611,7 +6613,7 @@ var LeaferUI = (function (exports) {
6611
6613
  }
6612
6614
  }
6613
6615
 
6614
- const debug$3 = Debug.get('Renderer');
6616
+ const debug$2 = Debug.get('Renderer');
6615
6617
  class Renderer {
6616
6618
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
6617
6619
  constructor(target, canvas, userConfig) {
@@ -6649,7 +6651,7 @@ var LeaferUI = (function (exports) {
6649
6651
  const { target } = this;
6650
6652
  this.times = 0;
6651
6653
  this.totalBounds = new Bounds();
6652
- debug$3.log(target.innerName, '--->');
6654
+ debug$2.log(target.innerName, '--->');
6653
6655
  try {
6654
6656
  if (!target.isApp)
6655
6657
  target.app.emit(RenderEvent.CHILD_START, target);
@@ -6660,9 +6662,9 @@ var LeaferUI = (function (exports) {
6660
6662
  }
6661
6663
  catch (e) {
6662
6664
  this.rendering = false;
6663
- debug$3.error(e);
6665
+ debug$2.error(e);
6664
6666
  }
6665
- debug$3.log('-------------|');
6667
+ debug$2.log('-------------|');
6666
6668
  }
6667
6669
  renderAgain() {
6668
6670
  if (this.rendering) {
@@ -6674,9 +6676,9 @@ var LeaferUI = (function (exports) {
6674
6676
  }
6675
6677
  renderOnce(callback) {
6676
6678
  if (this.rendering)
6677
- return debug$3.warn('rendering');
6679
+ return debug$2.warn('rendering');
6678
6680
  if (this.times > 3)
6679
- return debug$3.warn('render max times');
6681
+ return debug$2.warn('render max times');
6680
6682
  this.times++;
6681
6683
  this.totalTimes++;
6682
6684
  this.rendering = true;
@@ -6713,7 +6715,7 @@ var LeaferUI = (function (exports) {
6713
6715
  partRender() {
6714
6716
  const { canvas, updateBlocks: list } = this;
6715
6717
  if (!list)
6716
- return debug$3.warn('PartRender: need update attr');
6718
+ return debug$2.warn('PartRender: need update attr');
6717
6719
  this.mergeBlocks();
6718
6720
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6719
6721
  this.clipRender(block); });
@@ -6816,7 +6818,7 @@ var LeaferUI = (function (exports) {
6816
6818
  empty = (!leaf.__world.width || !leaf.__world.height);
6817
6819
  if (empty) {
6818
6820
  if (!leaf.isLeafer)
6819
- debug$3.tip(leaf.innerName, ': empty');
6821
+ debug$2.tip(leaf.innerName, ': empty');
6820
6822
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6821
6823
  }
6822
6824
  return empty;
@@ -6918,7 +6920,7 @@ var LeaferUI = (function (exports) {
6918
6920
 
6919
6921
  const { parse, objectToCanvasData } = PathConvert;
6920
6922
  const emptyPaint = {};
6921
- const debug$2 = Debug.get('UIData');
6923
+ const debug$1 = Debug.get('UIData');
6922
6924
  class UIData extends LeafData {
6923
6925
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
6924
6926
  get __strokeWidth() {
@@ -6955,7 +6957,7 @@ var LeaferUI = (function (exports) {
6955
6957
  if (value < 0) {
6956
6958
  this._width = -value;
6957
6959
  this.__leaf.scaleX *= -1;
6958
- debug$2.warn('width < 0, instead -scaleX ', this);
6960
+ debug$1.warn('width < 0, instead -scaleX ', this);
6959
6961
  }
6960
6962
  else
6961
6963
  this._width = value;
@@ -6964,7 +6966,7 @@ var LeaferUI = (function (exports) {
6964
6966
  if (value < 0) {
6965
6967
  this._height = -value;
6966
6968
  this.__leaf.scaleY *= -1;
6967
- debug$2.warn('height < 0, instead -scaleY', this);
6969
+ debug$1.warn('height < 0, instead -scaleY', this);
6968
6970
  }
6969
6971
  else
6970
6972
  this._height = value;
@@ -7341,25 +7343,27 @@ var LeaferUI = (function (exports) {
7341
7343
  }
7342
7344
  reset(_data) { }
7343
7345
  set(data, transition) {
7344
- if (transition) {
7345
- if (transition === 'temp') {
7346
- this.lockNormalStyle = true;
7347
- Object.assign(this, data);
7348
- this.lockNormalStyle = false;
7346
+ if (data) {
7347
+ if (transition) {
7348
+ if (transition === 'temp') {
7349
+ this.lockNormalStyle = true;
7350
+ Object.assign(this, data);
7351
+ this.lockNormalStyle = false;
7352
+ }
7353
+ else
7354
+ this.animate(data, transition);
7349
7355
  }
7350
7356
  else
7351
- this.animate(data, transition);
7357
+ Object.assign(this, data);
7352
7358
  }
7353
- else
7354
- Object.assign(this, data);
7355
7359
  }
7356
7360
  get(name) {
7357
7361
  return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
7358
7362
  }
7359
7363
  createProxyData() { return undefined; }
7360
- find(_condition, _options) { return undefined; }
7364
+ find(_condition, _options) { return Plugin.need('find'); }
7361
7365
  findTag(tag) { return this.find({ tag }); }
7362
- findOne(_condition, _options) { return undefined; }
7366
+ findOne(_condition, _options) { return Plugin.need('find'); }
7363
7367
  findId(id) { return this.findOne({ id }); }
7364
7368
  getPath(curve, pathForRender) {
7365
7369
  this.__layout.update();
@@ -7411,9 +7415,9 @@ var LeaferUI = (function (exports) {
7411
7415
  animate(_keyframe, _options, _type, _isTemp) {
7412
7416
  return Plugin.need('animate');
7413
7417
  }
7414
- killAnimate(_type) { }
7415
- export(filename, options) {
7416
- return Export.export(this, filename, options);
7418
+ killAnimate(_type, _killStyle) { }
7419
+ export(_filename, _options) {
7420
+ return Plugin.need('export');
7417
7421
  }
7418
7422
  clone(data) {
7419
7423
  const json = this.toJSON();
@@ -7659,16 +7663,18 @@ var LeaferUI = (function (exports) {
7659
7663
  this.children = [];
7660
7664
  }
7661
7665
  set(data, transition) {
7662
- if (data.children) {
7663
- const { children } = data;
7664
- delete data.children;
7665
- this.children ? this.clear() : this.__setBranch();
7666
- super.set(data, transition);
7667
- children.forEach(child => this.add(child));
7668
- data.children = children;
7666
+ if (data) {
7667
+ if (data.children) {
7668
+ const { children } = data;
7669
+ delete data.children;
7670
+ this.children ? this.clear() : this.__setBranch();
7671
+ super.set(data, transition);
7672
+ children.forEach(child => this.add(child));
7673
+ data.children = children;
7674
+ }
7675
+ else
7676
+ super.set(data, transition);
7669
7677
  }
7670
- else
7671
- super.set(data, transition);
7672
7678
  }
7673
7679
  toJSON(options) {
7674
7680
  const data = super.toJSON(options);
@@ -7700,7 +7706,7 @@ var LeaferUI = (function (exports) {
7700
7706
  ], exports.Group);
7701
7707
 
7702
7708
  var Leafer_1;
7703
- const debug$1 = Debug.get('Leafer');
7709
+ const debug = Debug.get('Leafer');
7704
7710
  exports.Leafer = Leafer_1 = class Leafer extends exports.Group {
7705
7711
  get __tag() { return 'Leafer'; }
7706
7712
  get isApp() { return false; }
@@ -7865,7 +7871,7 @@ var LeaferUI = (function (exports) {
7865
7871
  if (this.canvas) {
7866
7872
  if (canvasSizeAttrs.includes(attrName)) {
7867
7873
  if (!newValue)
7868
- debug$1.warn(attrName + ' is 0');
7874
+ debug.warn(attrName + ' is 0');
7869
7875
  this.__changeCanvasSize(attrName, newValue);
7870
7876
  }
7871
7877
  else if (attrName === 'fill') {
@@ -8006,9 +8012,6 @@ var LeaferUI = (function (exports) {
8006
8012
  this.canvas && this.canvas.updateClientBounds();
8007
8013
  }
8008
8014
  receiveEvent(_event) { }
8009
- __checkUpdateLayout() {
8010
- this.__layout.update();
8011
- }
8012
8015
  emitLeafer(type) {
8013
8016
  this.emitEvent(new LeaferEvent(type, this));
8014
8017
  }
@@ -8019,7 +8022,7 @@ var LeaferUI = (function (exports) {
8019
8022
  this.once(LayoutEvent.END, () => this.__onReady());
8020
8023
  this.once(RenderEvent.START, () => this.__onCreated());
8021
8024
  this.once(RenderEvent.END, () => this.__onViewReady());
8022
- this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this), this.on_(LayoutEvent.CHECK_UPDATE, this.__checkUpdateLayout, this));
8025
+ this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8023
8026
  }
8024
8027
  __removeListenEvents() {
8025
8028
  this.off_(this.__eventIds);
@@ -8050,7 +8053,7 @@ var LeaferUI = (function (exports) {
8050
8053
  setTimeout(() => { ImageManager.clearRecycled(); }, 100);
8051
8054
  }
8052
8055
  catch (e) {
8053
- debug$1.error(e);
8056
+ debug.error(e);
8054
8057
  }
8055
8058
  }
8056
8059
  };
@@ -8279,7 +8282,7 @@ var LeaferUI = (function (exports) {
8279
8282
 
8280
8283
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8281
8284
  const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
8282
- const { toBounds: toBounds$1 } = PathBounds;
8285
+ const { toBounds } = PathBounds;
8283
8286
  exports.Line = class Line extends exports.UI {
8284
8287
  get __tag() { return 'Line'; }
8285
8288
  get toPoint() {
@@ -8323,7 +8326,7 @@ var LeaferUI = (function (exports) {
8323
8326
  }
8324
8327
  __updateBoxBounds() {
8325
8328
  if (this.points) {
8326
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8329
+ toBounds(this.__.__pathForRender, this.__layout.boxBounds);
8327
8330
  }
8328
8331
  else
8329
8332
  super.__updateBoxBounds();
@@ -8675,6 +8678,9 @@ var LeaferUI = (function (exports) {
8675
8678
  __decorate([
8676
8679
  boundsType(0)
8677
8680
  ], exports.Text.prototype, "paraSpacing", void 0);
8681
+ __decorate([
8682
+ boundsType('x')
8683
+ ], exports.Text.prototype, "writingMode", void 0);
8678
8684
  __decorate([
8679
8685
  boundsType('left')
8680
8686
  ], exports.Text.prototype, "textAlign", void 0);
@@ -10239,197 +10245,12 @@ var LeaferUI = (function (exports) {
10239
10245
  string
10240
10246
  };
10241
10247
 
10242
- const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
10243
- function getTrimBounds(canvas) {
10244
- const { width, height } = canvas.view;
10245
- const { data } = canvas.context.getImageData(0, 0, width, height);
10246
- let x, y, pointBounds, index = 0;
10247
- for (let i = 0; i < data.length; i += 4) {
10248
- if (data[i + 3] !== 0) {
10249
- x = index % width;
10250
- y = (index - x) / width;
10251
- pointBounds ? addPoint(pointBounds, x, y) : setPoint(pointBounds = {}, x, y);
10252
- }
10253
- index++;
10254
- }
10255
- const bounds = new Bounds();
10256
- toBounds(pointBounds, bounds);
10257
- return bounds.scale(1 / canvas.pixelRatio).ceil();
10258
- }
10259
-
10260
- const ExportModule = {
10261
- export(leaf, filename, options) {
10262
- this.running = true;
10263
- const fileType = FileHelper.fileType(filename);
10264
- const isDownload = filename.includes('.');
10265
- options = FileHelper.getExportOptions(options);
10266
- return addTask((success) => new Promise((resolve) => {
10267
- const over = (result) => {
10268
- success(result);
10269
- resolve();
10270
- this.running = false;
10271
- };
10272
- const { toURL } = Platform;
10273
- const { download } = Platform.origin;
10274
- if (fileType === 'json') {
10275
- isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
10276
- return over({ data: isDownload ? true : leaf.toJSON(options.json) });
10277
- }
10278
- if (fileType === 'svg') {
10279
- isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
10280
- return over({ data: isDownload ? true : leaf.toSVG() });
10281
- }
10282
- const { leafer } = leaf;
10283
- if (leafer) {
10284
- checkLazy(leaf);
10285
- leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
10286
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
10287
- const { worldTransform, isLeafer, isFrame } = leaf;
10288
- const { slice, trim, onCanvas } = options;
10289
- const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
10290
- const contextSettings = options.contextSettings || leafer.config.contextSettings;
10291
- const screenshot = options.screenshot || leaf.isApp;
10292
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
10293
- const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
10294
- if (screenshot) {
10295
- renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
10296
- }
10297
- else {
10298
- let relative = options.relative || (isLeafer ? 'inner' : 'local');
10299
- scaleX = worldTransform.scaleX;
10300
- scaleY = worldTransform.scaleY;
10301
- switch (relative) {
10302
- case 'inner':
10303
- matrix.set(worldTransform);
10304
- break;
10305
- case 'local':
10306
- matrix.set(worldTransform).divide(leaf.localTransform);
10307
- scaleX /= leaf.scaleX;
10308
- scaleY /= leaf.scaleY;
10309
- break;
10310
- case 'world':
10311
- scaleX = 1;
10312
- scaleY = 1;
10313
- break;
10314
- case 'page':
10315
- relative = leaf.leafer;
10316
- default:
10317
- matrix.set(worldTransform).divide(leaf.getTransform(relative));
10318
- const l = relative.worldTransform;
10319
- scaleX /= scaleX / l.scaleX;
10320
- scaleY /= scaleY / l.scaleY;
10321
- }
10322
- renderBounds = leaf.getBounds('render', relative);
10323
- }
10324
- const scaleData = { scaleX: 1, scaleY: 1 };
10325
- MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
10326
- let pixelRatio = options.pixelRatio || 1;
10327
- if (leaf.isApp) {
10328
- scaleData.scaleX *= pixelRatio;
10329
- scaleData.scaleY *= pixelRatio;
10330
- pixelRatio = leaf.app.pixelRatio;
10331
- }
10332
- const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
10333
- const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
10334
- let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
10335
- let sliceLeaf;
10336
- if (slice) {
10337
- sliceLeaf = leaf;
10338
- sliceLeaf.__worldOpacity = 0;
10339
- leaf = leafer;
10340
- renderOptions.bounds = canvas.bounds;
10341
- }
10342
- canvas.save();
10343
- if (isFrame && fill !== undefined) {
10344
- const oldFill = leaf.get('fill');
10345
- leaf.fill = '';
10346
- leaf.__render(canvas, renderOptions);
10347
- leaf.fill = oldFill;
10348
- }
10349
- else {
10350
- leaf.__render(canvas, renderOptions);
10351
- }
10352
- canvas.restore();
10353
- if (sliceLeaf)
10354
- sliceLeaf.__updateWorldOpacity();
10355
- if (trim) {
10356
- trimBounds = getTrimBounds(canvas);
10357
- const old = canvas, { width, height } = trimBounds;
10358
- const config = { x: 0, y: 0, width, height, pixelRatio };
10359
- canvas = Creator.canvas(config);
10360
- canvas.copyWorld(old, trimBounds, config);
10361
- }
10362
- if (needFill)
10363
- canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
10364
- if (onCanvas)
10365
- onCanvas(canvas);
10366
- const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
10367
- over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
10368
- }));
10369
- }
10370
- else {
10371
- over({ data: false });
10372
- }
10373
- }));
10374
- }
10375
- };
10376
- let tasker;
10377
- function addTask(task) {
10378
- if (!tasker)
10379
- tasker = new TaskProcessor();
10380
- return new Promise((resolve) => {
10381
- tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
10382
- });
10383
- }
10384
- function checkLazy(leaf) {
10385
- if (leaf.__.__needComputePaint)
10386
- leaf.__.__computePaint();
10387
- if (leaf.isBranch)
10388
- leaf.children.forEach(child => checkLazy(child));
10389
- }
10390
-
10391
- const canvas = LeaferCanvasBase.prototype;
10392
- const debug = Debug.get('@leafer-ui/export');
10393
- canvas.export = function (filename, options) {
10394
- const { quality, blob } = FileHelper.getExportOptions(options);
10395
- if (filename.includes('.'))
10396
- return this.saveAs(filename, quality);
10397
- else if (blob)
10398
- return this.toBlob(filename, quality);
10399
- else
10400
- return this.toDataURL(filename, quality);
10401
- };
10402
- canvas.toBlob = function (type, quality) {
10403
- return new Promise((resolve) => {
10404
- Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
10405
- resolve(blob);
10406
- }).catch((e) => {
10407
- debug.error(e);
10408
- resolve(null);
10409
- });
10410
- });
10411
- };
10412
- canvas.toDataURL = function (type, quality) {
10413
- return Platform.origin.canvasToDataURL(this.view, type, quality);
10414
- };
10415
- canvas.saveAs = function (filename, quality) {
10416
- return new Promise((resolve) => {
10417
- Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
10418
- resolve(true);
10419
- }).catch((e) => {
10420
- debug.error(e);
10421
- resolve(false);
10422
- });
10423
- });
10424
- };
10425
-
10426
10248
  Object.assign(TextConvert, TextConvertModule);
10427
10249
  Object.assign(ColorConvert, ColorConvertModule);
10428
10250
  Object.assign(Paint, PaintModule);
10429
10251
  Object.assign(PaintImage, PaintImageModule);
10430
10252
  Object.assign(PaintGradient, PaintGradientModule);
10431
10253
  Object.assign(Effect, EffectModule);
10432
- Object.assign(Export, ExportModule);
10433
10254
 
10434
10255
  useCanvas();
10435
10256