leafer-ui 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.
@@ -765,8 +765,8 @@ const TwoPointBoundsHelper = {
765
765
  t.maxY = y > t.maxY ? y : t.maxY;
766
766
  },
767
767
  addBounds(t, x, y, width, height) {
768
- addPoint$4(t, x, y);
769
- addPoint$4(t, x + width, y + height);
768
+ addPoint$3(t, x, y);
769
+ addPoint$3(t, x + width, y + height);
770
770
  },
771
771
  copy(t, pb) {
772
772
  t.minX = pb.minX;
@@ -787,9 +787,9 @@ const TwoPointBoundsHelper = {
787
787
  setBounds.height = t.maxY - t.minY;
788
788
  }
789
789
  };
790
- const { addPoint: addPoint$4 } = TwoPointBoundsHelper;
790
+ const { addPoint: addPoint$3 } = TwoPointBoundsHelper;
791
791
 
792
- const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$3, addPoint: addPoint$3, toBounds: toBounds$4 } = TwoPointBoundsHelper;
792
+ const { tempPointBounds: tempPointBounds$1, setPoint: setPoint$2, addPoint: addPoint$2, toBounds: toBounds$3 } = TwoPointBoundsHelper;
793
793
  const { toOuterPoint: toOuterPoint$2 } = MatrixHelper;
794
794
  const { float, fourNumber } = MathHelper;
795
795
  const { floor, ceil: ceil$2 } = Math;
@@ -905,17 +905,17 @@ const BoundsHelper = {
905
905
  point.x = t.x;
906
906
  point.y = t.y;
907
907
  toOuterPoint$2(matrix, point, toPoint$5);
908
- setPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
908
+ setPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
909
909
  point.x = t.x + t.width;
910
910
  toOuterPoint$2(matrix, point, toPoint$5);
911
- addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
911
+ addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
912
912
  point.y = t.y + t.height;
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.x = t.x;
916
916
  toOuterPoint$2(matrix, point, toPoint$5);
917
- addPoint$3(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
918
- toBounds$4(tempPointBounds$1, to);
917
+ addPoint$2(tempPointBounds$1, toPoint$5.x, toPoint$5.y);
918
+ toBounds$3(tempPointBounds$1, to);
919
919
  }
920
920
  },
921
921
  toInnerOf(t, matrix, to) {
@@ -1005,8 +1005,8 @@ const BoundsHelper = {
1005
1005
  B.reset(t);
1006
1006
  },
1007
1007
  setPoints(t, points) {
1008
- points.forEach((point, index) => index === 0 ? setPoint$3(tempPointBounds$1, point.x, point.y) : addPoint$3(tempPointBounds$1, point.x, point.y));
1009
- toBounds$4(tempPointBounds$1, t);
1008
+ points.forEach((point, index) => index === 0 ? setPoint$2(tempPointBounds$1, point.x, point.y) : addPoint$2(tempPointBounds$1, point.x, point.y));
1009
+ toBounds$3(tempPointBounds$1, t);
1010
1010
  },
1011
1011
  setPoint(t, point) {
1012
1012
  B.set(t, point.x, point.y);
@@ -1374,7 +1374,7 @@ function getNameList(name) {
1374
1374
  }
1375
1375
  const D$4 = Debug;
1376
1376
 
1377
- const debug$g = Debug.get('RunTime');
1377
+ const debug$f = Debug.get('RunTime');
1378
1378
  const Run = {
1379
1379
  currentId: 0,
1380
1380
  currentName: '',
@@ -1392,7 +1392,7 @@ const Run = {
1392
1392
  const time = R.idMap[id], name = R.nameMap[id];
1393
1393
  const duration = microsecond ? (performance.now() - time) / 1000 : Date.now() - time;
1394
1394
  R.idMap[id] = R.nameMap[id] = R.nameToIdMap[name] = undefined;
1395
- debug$g.log(name, duration, 'ms');
1395
+ debug$f.log(name, duration, 'ms');
1396
1396
  },
1397
1397
  endOfName(name, microsecond) {
1398
1398
  const id = R.nameToIdMap[name];
@@ -1402,34 +1402,37 @@ const Run = {
1402
1402
  };
1403
1403
  const R = Run;
1404
1404
 
1405
+ const check = [];
1405
1406
  const Plugin = {
1406
1407
  list: {},
1407
- add(name) {
1408
+ add(name, ...needPlugins) {
1408
1409
  this.list[name] = true;
1410
+ check.push(...needPlugins);
1409
1411
  },
1410
- check(name, tip) {
1412
+ has(name, tip) {
1411
1413
  const rs = this.list[name];
1412
1414
  if (!rs && tip)
1413
1415
  this.need(name);
1414
1416
  return rs;
1415
1417
  },
1416
1418
  need(name) {
1417
- console.error('need plugin: @leafer-in/' + name);
1419
+ console.error('need plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
1418
1420
  }
1419
1421
  };
1422
+ setTimeout(() => check.forEach(name => Plugin.has(name, true)));
1420
1423
 
1421
- const debug$f = Debug.get('UICreator');
1424
+ const debug$e = Debug.get('UICreator');
1422
1425
  const UICreator = {
1423
1426
  list: {},
1424
1427
  register(UI) {
1425
1428
  const { __tag: tag } = UI.prototype;
1426
1429
  if (list$1[tag])
1427
- debug$f.repeat(tag);
1430
+ debug$e.repeat(tag);
1428
1431
  list$1[tag] = UI;
1429
1432
  },
1430
1433
  get(tag, data, x, y, width, height) {
1431
1434
  if (!list$1[tag])
1432
- debug$f.error('not register ' + tag);
1435
+ debug$e.error('not register ' + tag);
1433
1436
  const ui = new list$1[tag](data);
1434
1437
  if (x !== undefined) {
1435
1438
  ui.x = x;
@@ -1445,7 +1448,7 @@ const UICreator = {
1445
1448
  };
1446
1449
  const { list: list$1 } = UICreator;
1447
1450
 
1448
- const debug$e = Debug.get('EventCreator');
1451
+ const debug$d = Debug.get('EventCreator');
1449
1452
  const EventCreator = {
1450
1453
  nameList: {},
1451
1454
  register(Event) {
@@ -1453,7 +1456,7 @@ const EventCreator = {
1453
1456
  Object.keys(Event).forEach(key => {
1454
1457
  name = Event[key];
1455
1458
  if (typeof name === 'string')
1456
- nameList[name] && debug$e.repeat(name), nameList[name] = Event;
1459
+ nameList[name] && debug$d.repeat(name), nameList[name] = Event;
1457
1460
  });
1458
1461
  },
1459
1462
  changeName(oldName, newName) {
@@ -2342,7 +2345,7 @@ const RectHelper = {
2342
2345
  };
2343
2346
 
2344
2347
  const { sin: sin$3, cos: cos$3, atan2: atan2$1, ceil: ceil$1, abs: abs$3, PI: PI$2, sqrt: sqrt$1, pow } = Math;
2345
- const { setPoint: setPoint$2, addPoint: addPoint$2 } = TwoPointBoundsHelper;
2348
+ const { setPoint: setPoint$1, addPoint: addPoint$1 } = TwoPointBoundsHelper;
2346
2349
  const { set, toNumberPoints } = PointHelper;
2347
2350
  const { M: M$5, L: L$6, C: C$5, Q: Q$4, Z: Z$5 } = PathCommandMap;
2348
2351
  const tempPoint$2 = {};
@@ -2418,8 +2421,8 @@ const BezierHelper = {
2418
2421
  if (data)
2419
2422
  data.push(L$6, x1, y1);
2420
2423
  if (setPointBounds) {
2421
- setPoint$2(setPointBounds, fromX, fromY);
2422
- addPoint$2(setPointBounds, x1, y1);
2424
+ setPoint$1(setPointBounds, fromX, fromY);
2425
+ addPoint$1(setPointBounds, x1, y1);
2423
2426
  }
2424
2427
  if (setStartPoint)
2425
2428
  set(setStartPoint, fromX, fromY);
@@ -2471,7 +2474,7 @@ const BezierHelper = {
2471
2474
  if (data)
2472
2475
  data.push(data.length ? L$6 : M$5, fromX, fromY);
2473
2476
  if (setPointBounds)
2474
- setPoint$2(setPointBounds, fromX, fromY);
2477
+ setPoint$1(setPointBounds, fromX, fromY);
2475
2478
  if (setStartPoint)
2476
2479
  set(setStartPoint, fromX, fromY);
2477
2480
  for (let i = 0; i < parts; i++) {
@@ -2533,11 +2536,11 @@ const BezierHelper = {
2533
2536
  if (0 < t2 && t2 < 1)
2534
2537
  tList.push(t2);
2535
2538
  }
2536
- addMode ? addPoint$2(pointBounds, fromX, fromY) : setPoint$2(pointBounds, fromX, fromY);
2537
- addPoint$2(pointBounds, toX, toY);
2539
+ addMode ? addPoint$1(pointBounds, fromX, fromY) : setPoint$1(pointBounds, fromX, fromY);
2540
+ addPoint$1(pointBounds, toX, toY);
2538
2541
  for (let i = 0, len = tList.length; i < len; i++) {
2539
2542
  getPointAndSet(tList[i], fromX, fromY, x1, y1, x2, y2, toX, toY, tempPoint$2);
2540
- addPoint$2(pointBounds, tempPoint$2.x, tempPoint$2.y);
2543
+ addPoint$1(pointBounds, tempPoint$2.x, tempPoint$2.y);
2541
2544
  }
2542
2545
  },
2543
2546
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, setPoint) {
@@ -2609,7 +2612,7 @@ const EllipseHelper = {
2609
2612
  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;
2610
2613
  const { rect: rect$3, roundRect: roundRect$2, arcTo: arcTo$3, arc: arc$3, ellipse: ellipse$4, quadraticCurveTo: quadraticCurveTo$1 } = BezierHelper;
2611
2614
  const { ellipticalArc } = EllipseHelper;
2612
- const debug$d = Debug.get('PathConvert');
2615
+ const debug$c = Debug.get('PathConvert');
2613
2616
  const setEndPoint$1 = {};
2614
2617
  const PathConvert = {
2615
2618
  current: { dot: 0 },
@@ -2850,7 +2853,7 @@ const PathConvert = {
2850
2853
  i += 6;
2851
2854
  break;
2852
2855
  default:
2853
- debug$d.error(`command: ${command} [index:${i}]`, old);
2856
+ debug$c.error(`command: ${command} [index:${i}]`, old);
2854
2857
  return data;
2855
2858
  }
2856
2859
  lastCommand = command;
@@ -3075,7 +3078,7 @@ class PathCreator {
3075
3078
  }
3076
3079
 
3077
3080
  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;
3078
- const debug$c = Debug.get('PathDrawer');
3081
+ const debug$b = Debug.get('PathDrawer');
3079
3082
  const PathDrawer = {
3080
3083
  drawPathByData(drawer, data) {
3081
3084
  if (!data)
@@ -3138,7 +3141,7 @@ const PathDrawer = {
3138
3141
  i += 6;
3139
3142
  break;
3140
3143
  default:
3141
- debug$c.error(`command: ${command} [index:${i}]`, data);
3144
+ debug$b.error(`command: ${command} [index:${i}]`, data);
3142
3145
  return;
3143
3146
  }
3144
3147
  }
@@ -3147,8 +3150,8 @@ const PathDrawer = {
3147
3150
 
3148
3151
  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;
3149
3152
  const { toTwoPointBounds, toTwoPointBoundsByQuadraticCurve, arcTo: arcTo$1, arc, ellipse: ellipse$1 } = BezierHelper;
3150
- const { addPointBounds, copy: copy$8, addPoint: addPoint$1, setPoint: setPoint$1, addBounds, toBounds: toBounds$3 } = TwoPointBoundsHelper;
3151
- const debug$b = Debug.get('PathBounds');
3153
+ const { addPointBounds, copy: copy$8, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
3154
+ const debug$a = Debug.get('PathBounds');
3152
3155
  let radius, radiusX, radiusY;
3153
3156
  const tempPointBounds = {};
3154
3157
  const setPointBounds = {};
@@ -3156,21 +3159,21 @@ const setEndPoint = {};
3156
3159
  const PathBounds = {
3157
3160
  toBounds(data, setBounds) {
3158
3161
  PathBounds.toTwoPointBounds(data, setPointBounds);
3159
- toBounds$3(setPointBounds, setBounds);
3162
+ toBounds$2(setPointBounds, setBounds);
3160
3163
  },
3161
3164
  toTwoPointBounds(data, setPointBounds) {
3162
3165
  if (!data || !data.length)
3163
- return setPoint$1(setPointBounds, 0, 0);
3166
+ return setPoint(setPointBounds, 0, 0);
3164
3167
  let i = 0, x = 0, y = 0, x1, y1, toX, toY, command;
3165
3168
  const len = data.length;
3166
3169
  while (i < len) {
3167
3170
  command = data[i];
3168
3171
  if (i === 0) {
3169
3172
  if (command === Z$1 || command === C$1 || command === Q) {
3170
- setPoint$1(setPointBounds, x, y);
3173
+ setPoint(setPointBounds, x, y);
3171
3174
  }
3172
3175
  else {
3173
- setPoint$1(setPointBounds, data[i + 1], data[i + 2]);
3176
+ setPoint(setPointBounds, data[i + 1], data[i + 2]);
3174
3177
  }
3175
3178
  }
3176
3179
  switch (command) {
@@ -3178,7 +3181,7 @@ const PathBounds = {
3178
3181
  case L$2:
3179
3182
  x = data[i + 1];
3180
3183
  y = data[i + 2];
3181
- addPoint$1(setPointBounds, x, y);
3184
+ addPoint(setPointBounds, x, y);
3182
3185
  i += 3;
3183
3186
  break;
3184
3187
  case C$1:
@@ -3256,7 +3259,7 @@ const PathBounds = {
3256
3259
  i += 6;
3257
3260
  break;
3258
3261
  default:
3259
- debug$b.error(`command: ${command} [index:${i}]`, data);
3262
+ debug$a.error(`command: ${command} [index:${i}]`, data);
3260
3263
  return;
3261
3264
  }
3262
3265
  }
@@ -3372,7 +3375,7 @@ const FileHelper = {
3372
3375
  const F = FileHelper;
3373
3376
  F.opacityTypes.forEach(type => F.upperCaseTypeMap[type] = type.toUpperCase());
3374
3377
 
3375
- const debug$a = Debug.get('TaskProcessor');
3378
+ const debug$9 = Debug.get('TaskProcessor');
3376
3379
  class TaskItem {
3377
3380
  constructor(task) {
3378
3381
  this.parallel = true;
@@ -3387,7 +3390,7 @@ class TaskItem {
3387
3390
  yield this.task();
3388
3391
  }
3389
3392
  catch (error) {
3390
- debug$a.error(error);
3393
+ debug$9.error(error);
3391
3394
  }
3392
3395
  });
3393
3396
  }
@@ -4074,7 +4077,7 @@ function defineDataProcessor(target, key, defaultValue) {
4074
4077
  defineKey(data, key, property);
4075
4078
  }
4076
4079
 
4077
- const debug$9 = new Debug('rewrite');
4080
+ const debug$8 = new Debug('rewrite');
4078
4081
  const list = [];
4079
4082
  const excludeNames = ['destroy', 'constructor'];
4080
4083
  function rewrite(method) {
@@ -4091,7 +4094,7 @@ function doRewrite(error) {
4091
4094
  if (list.length) {
4092
4095
  list.forEach(item => {
4093
4096
  if (error)
4094
- debug$9.error(item.name, '需在Class上装饰@rewriteAble()');
4097
+ debug$8.error(item.name, '需在Class上装饰@rewriteAble()');
4095
4098
  item.run();
4096
4099
  });
4097
4100
  list.length = 0;
@@ -4808,7 +4811,6 @@ class LayoutEvent extends Event {
4808
4811
  }
4809
4812
  }
4810
4813
  }
4811
- LayoutEvent.CHECK_UPDATE = 'layout.check_update';
4812
4814
  LayoutEvent.REQUEST = 'layout.request';
4813
4815
  LayoutEvent.START = 'layout.start';
4814
4816
  LayoutEvent.BEFORE = 'layout.before';
@@ -5003,13 +5005,13 @@ const { on, on_, off, off_, once, emit: emit$2, emitEvent: emitEvent$1, hasEvent
5003
5005
  const LeafEventer = { on, on_, off, off_, once, emit: emit$2, emitEvent: emitEvent$1, hasEvent, destroyEventer: destroy };
5004
5006
 
5005
5007
  const { isFinite } = Number;
5006
- const debug$8 = Debug.get('setAttr');
5008
+ const debug$7 = Debug.get('setAttr');
5007
5009
  const LeafDataProxy = {
5008
5010
  __setAttr(name, newValue, checkFiniteNumber) {
5009
5011
  if (this.leaferIsCreated) {
5010
5012
  const oldValue = this.__.__getInput(name);
5011
5013
  if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
5012
- debug$8.warn(this.innerName, name, newValue);
5014
+ debug$7.warn(this.innerName, name, newValue);
5013
5015
  newValue = undefined;
5014
5016
  }
5015
5017
  if (typeof newValue === 'object' || oldValue !== newValue) {
@@ -5079,7 +5081,7 @@ const LeafMatrix = {
5079
5081
  const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
5080
5082
  const { updateBounds: updateBounds$1 } = BranchHelper;
5081
5083
  const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
5082
- const { toBounds: toBounds$2 } = PathBounds;
5084
+ const { toBounds: toBounds$1 } = PathBounds;
5083
5085
  const LeafBounds = {
5084
5086
  __updateWorldBounds() {
5085
5087
  toOuterOf$1(this.__layout.renderBounds, this.__world, this.__world);
@@ -5161,7 +5163,7 @@ const LeafBounds = {
5161
5163
  const b = this.__layout.boxBounds;
5162
5164
  const data = this.__;
5163
5165
  if (data.__pathInputed) {
5164
- toBounds$2(data.path, b);
5166
+ toBounds$1(data.path, b);
5165
5167
  }
5166
5168
  else {
5167
5169
  b.x = 0;
@@ -5709,7 +5711,7 @@ Leaf = __decorate([
5709
5711
  const { setListWithFn } = BoundsHelper;
5710
5712
  const { sort } = BranchHelper;
5711
5713
  const { localBoxBounds, localStrokeBounds, localRenderBounds, maskLocalBoxBounds, maskLocalStrokeBounds, maskLocalRenderBounds } = LeafBoundsHelper;
5712
- const debug$7 = new Debug('Branch');
5714
+ const debug$6 = new Debug('Branch');
5713
5715
  let Branch = class Branch extends Leaf {
5714
5716
  __updateStrokeSpread() {
5715
5717
  const { children } = this;
@@ -5751,7 +5753,7 @@ let Branch = class Branch extends Leaf {
5751
5753
  }
5752
5754
  add(child, index) {
5753
5755
  if (child === this || child.destroyed)
5754
- return debug$7.warn('add self or destroyed');
5756
+ return debug$6.warn('add self or destroyed');
5755
5757
  const noIndex = index === undefined;
5756
5758
  if (!child.__) {
5757
5759
  if (child instanceof Array)
@@ -6005,9 +6007,9 @@ class LeafLevelList {
6005
6007
  }
6006
6008
  }
6007
6009
 
6008
- const version = "1.2.2";
6010
+ const version = "1.3.1";
6009
6011
 
6010
- const debug$6 = Debug.get('LeaferCanvas');
6012
+ const debug$5 = Debug.get('LeaferCanvas');
6011
6013
  class LeaferCanvas extends LeaferCanvasBase {
6012
6014
  set zIndex(zIndex) {
6013
6015
  const { style } = this.view;
@@ -6079,7 +6081,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6079
6081
  }
6080
6082
  }
6081
6083
  else {
6082
- debug$6.error(`no id: ${inputView}`);
6084
+ debug$5.error(`no id: ${inputView}`);
6083
6085
  this.__createView();
6084
6086
  }
6085
6087
  }
@@ -6117,7 +6119,7 @@ class LeaferCanvas extends LeaferCanvasBase {
6117
6119
  }
6118
6120
  else {
6119
6121
  this.checkAutoBounds(this.view);
6120
- debug$6.warn('no parent');
6122
+ debug$5.warn('no parent');
6121
6123
  }
6122
6124
  }
6123
6125
  catch (_a) {
@@ -6453,7 +6455,7 @@ class LayoutBlockData {
6453
6455
  }
6454
6456
 
6455
6457
  const { updateAllMatrix, updateAllChange } = LeafHelper;
6456
- const debug$5 = Debug.get('Layouter');
6458
+ const debug$4 = Debug.get('Layouter');
6457
6459
  class Layouter {
6458
6460
  constructor(target, userConfig) {
6459
6461
  this.totalTimes = 0;
@@ -6488,7 +6490,7 @@ class Layouter {
6488
6490
  target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
6489
6491
  }
6490
6492
  catch (e) {
6491
- debug$5.error(e);
6493
+ debug$4.error(e);
6492
6494
  }
6493
6495
  this.layoutedBlocks = null;
6494
6496
  }
@@ -6502,9 +6504,9 @@ class Layouter {
6502
6504
  }
6503
6505
  layoutOnce() {
6504
6506
  if (this.layouting)
6505
- return debug$5.warn('layouting');
6507
+ return debug$4.warn('layouting');
6506
6508
  if (this.times > 3)
6507
- return debug$5.warn('layout max times');
6509
+ return debug$4.warn('layout max times');
6508
6510
  this.times++;
6509
6511
  this.totalTimes++;
6510
6512
  this.layouting = true;
@@ -6608,7 +6610,7 @@ class Layouter {
6608
6610
  }
6609
6611
  }
6610
6612
 
6611
- const debug$4 = Debug.get('Renderer');
6613
+ const debug$3 = Debug.get('Renderer');
6612
6614
  class Renderer {
6613
6615
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
6614
6616
  constructor(target, canvas, userConfig) {
@@ -6646,7 +6648,7 @@ class Renderer {
6646
6648
  const { target } = this;
6647
6649
  this.times = 0;
6648
6650
  this.totalBounds = new Bounds();
6649
- debug$4.log(target.innerName, '--->');
6651
+ debug$3.log(target.innerName, '--->');
6650
6652
  try {
6651
6653
  if (!target.isApp)
6652
6654
  target.app.emit(RenderEvent.CHILD_START, target);
@@ -6657,9 +6659,9 @@ class Renderer {
6657
6659
  }
6658
6660
  catch (e) {
6659
6661
  this.rendering = false;
6660
- debug$4.error(e);
6662
+ debug$3.error(e);
6661
6663
  }
6662
- debug$4.log('-------------|');
6664
+ debug$3.log('-------------|');
6663
6665
  }
6664
6666
  renderAgain() {
6665
6667
  if (this.rendering) {
@@ -6671,9 +6673,9 @@ class Renderer {
6671
6673
  }
6672
6674
  renderOnce(callback) {
6673
6675
  if (this.rendering)
6674
- return debug$4.warn('rendering');
6676
+ return debug$3.warn('rendering');
6675
6677
  if (this.times > 3)
6676
- return debug$4.warn('render max times');
6678
+ return debug$3.warn('render max times');
6677
6679
  this.times++;
6678
6680
  this.totalTimes++;
6679
6681
  this.rendering = true;
@@ -6710,7 +6712,7 @@ class Renderer {
6710
6712
  partRender() {
6711
6713
  const { canvas, updateBlocks: list } = this;
6712
6714
  if (!list)
6713
- return debug$4.warn('PartRender: need update attr');
6715
+ return debug$3.warn('PartRender: need update attr');
6714
6716
  this.mergeBlocks();
6715
6717
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6716
6718
  this.clipRender(block); });
@@ -6813,7 +6815,7 @@ class Renderer {
6813
6815
  empty = (!leaf.__world.width || !leaf.__world.height);
6814
6816
  if (empty) {
6815
6817
  if (!leaf.isLeafer)
6816
- debug$4.tip(leaf.innerName, ': empty');
6818
+ debug$3.tip(leaf.innerName, ': empty');
6817
6819
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6818
6820
  }
6819
6821
  return empty;
@@ -6979,143 +6981,26 @@ class Picker {
6979
6981
  }
6980
6982
  }
6981
6983
 
6982
- const { Yes, NoAndSkip, YesAndSkip } = Answer;
6983
- const idCondition = {}, classNameCondition = {}, tagCondition = {};
6984
6984
  class Selector {
6985
6985
  constructor(target, userConfig) {
6986
6986
  this.config = {};
6987
- this.innerIdMap = {};
6988
- this.idMap = {};
6989
- this.methods = {
6990
- id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
6991
- innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
6992
- className: (leaf, name) => leaf.className === name ? 1 : 0,
6993
- tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6994
- tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
6995
- };
6996
- this.target = target;
6997
6987
  if (userConfig)
6998
6988
  this.config = DataHelper.default(userConfig, this.config);
6999
- this.picker = new Picker(target, this);
7000
- if (target)
7001
- this.__listenEvents();
7002
- }
7003
- getBy(condition, branch, one, options) {
7004
- switch (typeof condition) {
7005
- case 'number':
7006
- const leaf = this.getByInnerId(condition, branch);
7007
- return one ? leaf : (leaf ? [leaf] : []);
7008
- case 'string':
7009
- switch (condition[0]) {
7010
- case '#':
7011
- idCondition.id = condition.substring(1), condition = idCondition;
7012
- break;
7013
- case '.':
7014
- classNameCondition.className = condition.substring(1), condition = classNameCondition;
7015
- break;
7016
- default:
7017
- tagCondition.tag = condition, condition = tagCondition;
7018
- }
7019
- case 'object':
7020
- if (condition.id !== undefined) {
7021
- const leaf = this.getById(condition.id, branch);
7022
- return one ? leaf : (leaf ? [leaf] : []);
7023
- }
7024
- else if (condition.tag) {
7025
- const { tag } = condition, isArray = tag instanceof Array;
7026
- return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
7027
- }
7028
- else {
7029
- return this.getByMethod(this.methods.className, branch, one, condition.className);
7030
- }
7031
- case 'function':
7032
- return this.getByMethod(condition, branch, one, options);
7033
- }
6989
+ this.picker = new Picker(this.target = target, this);
6990
+ this.finder = Creator.finder && Creator.finder();
7034
6991
  }
7035
6992
  getByPoint(hitPoint, hitRadius, options) {
7036
- if (Platform.name === 'node' && this.target)
7037
- this.target.emit(LayoutEvent.CHECK_UPDATE);
6993
+ if (Platform.backgrounder && this.target)
6994
+ this.target.updateLayout();
7038
6995
  return this.picker.getByPoint(hitPoint, hitRadius, options);
7039
6996
  }
7040
- getByInnerId(innerId, branch) {
7041
- const cache = this.innerIdMap[innerId];
7042
- if (cache)
7043
- return cache;
7044
- this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
7045
- return this.findLeaf;
7046
- }
7047
- getById(id, branch) {
7048
- const cache = this.idMap[id];
7049
- if (cache && LeafHelper.hasParent(cache, branch || this.target))
7050
- return cache;
7051
- this.eachFind(this.toChildren(branch), this.methods.id, null, id);
7052
- return this.findLeaf;
7053
- }
7054
- getByClassName(className, branch) {
7055
- return this.getByMethod(this.methods.className, branch, false, className);
7056
- }
7057
- getByTag(tag, branch) {
7058
- return this.getByMethod(this.methods.tag, branch, false, tag);
7059
- }
7060
- getByMethod(method, branch, one, options) {
7061
- const list = one ? null : [];
7062
- this.eachFind(this.toChildren(branch), method, list, options);
7063
- return list || this.findLeaf;
7064
- }
7065
- eachFind(children, method, list, options) {
7066
- let child, result;
7067
- for (let i = 0, len = children.length; i < len; i++) {
7068
- child = children[i];
7069
- result = method(child, options);
7070
- if (result === Yes || result === YesAndSkip) {
7071
- if (list) {
7072
- list.push(child);
7073
- }
7074
- else {
7075
- this.findLeaf = child;
7076
- return;
7077
- }
7078
- }
7079
- if (child.isBranch && result < NoAndSkip)
7080
- this.eachFind(child.children, method, list, options);
7081
- }
7082
- }
7083
- toChildren(branch) {
7084
- this.findLeaf = null;
7085
- return [branch || this.target];
7086
- }
7087
- __onRemoveChild(event) {
7088
- const { id, innerId } = event.child;
7089
- if (this.idMap[id])
7090
- delete this.idMap[id];
7091
- if (this.innerIdMap[innerId])
7092
- delete this.innerIdMap[innerId];
7093
- }
7094
- __checkIdChange(event) {
7095
- if (event.attrName === 'id') {
7096
- const id = event.oldValue;
7097
- if (this.idMap[id])
7098
- delete this.idMap[id];
7099
- }
7100
- }
7101
- __listenEvents() {
7102
- this.__eventIds = [
7103
- this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
7104
- this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
7105
- ];
7106
- }
7107
- __removeListenEvents() {
7108
- this.target.off_(this.__eventIds);
7109
- this.__eventIds.length = 0;
6997
+ getBy(condition, branch, one, options) {
6998
+ return this.finder ? this.finder.getBy(condition, branch, one, options) : Plugin.need('find');
7110
6999
  }
7111
7000
  destroy() {
7112
- if (this.__eventIds.length) {
7113
- this.__removeListenEvents();
7114
- this.picker.destroy();
7115
- this.findLeaf = null;
7116
- this.innerIdMap = {};
7117
- this.idMap = {};
7118
- }
7001
+ this.picker.destroy();
7002
+ if (this.finder)
7003
+ this.finder.destroy();
7119
7004
  }
7120
7005
  }
7121
7006
 
@@ -7188,7 +7073,7 @@ const Transition = {
7188
7073
 
7189
7074
  const { parse, objectToCanvasData } = PathConvert;
7190
7075
  const emptyPaint = {};
7191
- const debug$3 = Debug.get('UIData');
7076
+ const debug$2 = Debug.get('UIData');
7192
7077
  class UIData extends LeafData {
7193
7078
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
7194
7079
  get __strokeWidth() {
@@ -7225,7 +7110,7 @@ class UIData extends LeafData {
7225
7110
  if (value < 0) {
7226
7111
  this._width = -value;
7227
7112
  this.__leaf.scaleX *= -1;
7228
- debug$3.warn('width < 0, instead -scaleX ', this);
7113
+ debug$2.warn('width < 0, instead -scaleX ', this);
7229
7114
  }
7230
7115
  else
7231
7116
  this._width = value;
@@ -7234,7 +7119,7 @@ class UIData extends LeafData {
7234
7119
  if (value < 0) {
7235
7120
  this._height = -value;
7236
7121
  this.__leaf.scaleY *= -1;
7237
- debug$3.warn('height < 0, instead -scaleY', this);
7122
+ debug$2.warn('height < 0, instead -scaleY', this);
7238
7123
  }
7239
7124
  else
7240
7125
  this._height = value;
@@ -7611,25 +7496,27 @@ let UI = UI_1 = class UI extends Leaf {
7611
7496
  }
7612
7497
  reset(_data) { }
7613
7498
  set(data, transition) {
7614
- if (transition) {
7615
- if (transition === 'temp') {
7616
- this.lockNormalStyle = true;
7617
- Object.assign(this, data);
7618
- this.lockNormalStyle = false;
7499
+ if (data) {
7500
+ if (transition) {
7501
+ if (transition === 'temp') {
7502
+ this.lockNormalStyle = true;
7503
+ Object.assign(this, data);
7504
+ this.lockNormalStyle = false;
7505
+ }
7506
+ else
7507
+ this.animate(data, transition);
7619
7508
  }
7620
7509
  else
7621
- this.animate(data, transition);
7510
+ Object.assign(this, data);
7622
7511
  }
7623
- else
7624
- Object.assign(this, data);
7625
7512
  }
7626
7513
  get(name) {
7627
7514
  return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
7628
7515
  }
7629
7516
  createProxyData() { return undefined; }
7630
- find(_condition, _options) { return undefined; }
7517
+ find(_condition, _options) { return Plugin.need('find'); }
7631
7518
  findTag(tag) { return this.find({ tag }); }
7632
- findOne(_condition, _options) { return undefined; }
7519
+ findOne(_condition, _options) { return Plugin.need('find'); }
7633
7520
  findId(id) { return this.findOne({ id }); }
7634
7521
  getPath(curve, pathForRender) {
7635
7522
  this.__layout.update();
@@ -7681,9 +7568,9 @@ let UI = UI_1 = class UI extends Leaf {
7681
7568
  animate(_keyframe, _options, _type, _isTemp) {
7682
7569
  return Plugin.need('animate');
7683
7570
  }
7684
- killAnimate(_type) { }
7685
- export(filename, options) {
7686
- return Export.export(this, filename, options);
7571
+ killAnimate(_type, _killStyle) { }
7572
+ export(_filename, _options) {
7573
+ return Plugin.need('export');
7687
7574
  }
7688
7575
  clone(data) {
7689
7576
  const json = this.toJSON();
@@ -7929,16 +7816,18 @@ let Group = class Group extends UI {
7929
7816
  this.children = [];
7930
7817
  }
7931
7818
  set(data, transition) {
7932
- if (data.children) {
7933
- const { children } = data;
7934
- delete data.children;
7935
- this.children ? this.clear() : this.__setBranch();
7936
- super.set(data, transition);
7937
- children.forEach(child => this.add(child));
7938
- data.children = children;
7819
+ if (data) {
7820
+ if (data.children) {
7821
+ const { children } = data;
7822
+ delete data.children;
7823
+ this.children ? this.clear() : this.__setBranch();
7824
+ super.set(data, transition);
7825
+ children.forEach(child => this.add(child));
7826
+ data.children = children;
7827
+ }
7828
+ else
7829
+ super.set(data, transition);
7939
7830
  }
7940
- else
7941
- super.set(data, transition);
7942
7831
  }
7943
7832
  toJSON(options) {
7944
7833
  const data = super.toJSON(options);
@@ -7970,7 +7859,7 @@ Group = __decorate([
7970
7859
  ], Group);
7971
7860
 
7972
7861
  var Leafer_1;
7973
- const debug$2 = Debug.get('Leafer');
7862
+ const debug$1 = Debug.get('Leafer');
7974
7863
  let Leafer = Leafer_1 = class Leafer extends Group {
7975
7864
  get __tag() { return 'Leafer'; }
7976
7865
  get isApp() { return false; }
@@ -8135,7 +8024,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8135
8024
  if (this.canvas) {
8136
8025
  if (canvasSizeAttrs.includes(attrName)) {
8137
8026
  if (!newValue)
8138
- debug$2.warn(attrName + ' is 0');
8027
+ debug$1.warn(attrName + ' is 0');
8139
8028
  this.__changeCanvasSize(attrName, newValue);
8140
8029
  }
8141
8030
  else if (attrName === 'fill') {
@@ -8276,9 +8165,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8276
8165
  this.canvas && this.canvas.updateClientBounds();
8277
8166
  }
8278
8167
  receiveEvent(_event) { }
8279
- __checkUpdateLayout() {
8280
- this.__layout.update();
8281
- }
8282
8168
  emitLeafer(type) {
8283
8169
  this.emitEvent(new LeaferEvent(type, this));
8284
8170
  }
@@ -8289,7 +8175,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8289
8175
  this.once(LayoutEvent.END, () => this.__onReady());
8290
8176
  this.once(RenderEvent.START, () => this.__onCreated());
8291
8177
  this.once(RenderEvent.END, () => this.__onViewReady());
8292
- 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));
8178
+ this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8293
8179
  }
8294
8180
  __removeListenEvents() {
8295
8181
  this.off_(this.__eventIds);
@@ -8320,7 +8206,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8320
8206
  setTimeout(() => { ImageManager.clearRecycled(); }, 100);
8321
8207
  }
8322
8208
  catch (e) {
8323
- debug$2.error(e);
8209
+ debug$1.error(e);
8324
8210
  }
8325
8211
  }
8326
8212
  };
@@ -8354,7 +8240,7 @@ Rect = __decorate([
8354
8240
  ], Rect);
8355
8241
 
8356
8242
  const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8357
- const rect$1 = Rect.prototype, group$1 = Group.prototype;
8243
+ const rect$1 = Rect.prototype, group = Group.prototype;
8358
8244
  const childrenRenderBounds = {};
8359
8245
  let Box = class Box extends Group {
8360
8246
  get __tag() { return 'Box'; }
@@ -8464,7 +8350,7 @@ __decorate([
8464
8350
  rewrite(rect$1.__render)
8465
8351
  ], Box.prototype, "__renderRect", null);
8466
8352
  __decorate([
8467
- rewrite(group$1.__render)
8353
+ rewrite(group.__render)
8468
8354
  ], Box.prototype, "__renderGroup", null);
8469
8355
  Box = __decorate([
8470
8356
  rewriteAble(),
@@ -8549,7 +8435,7 @@ Ellipse = __decorate([
8549
8435
 
8550
8436
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8551
8437
  const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
8552
- const { toBounds: toBounds$1 } = PathBounds;
8438
+ const { toBounds } = PathBounds;
8553
8439
  let Line = class Line extends UI {
8554
8440
  get __tag() { return 'Line'; }
8555
8441
  get toPoint() {
@@ -8593,7 +8479,7 @@ let Line = class Line extends UI {
8593
8479
  }
8594
8480
  __updateBoxBounds() {
8595
8481
  if (this.points) {
8596
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8482
+ toBounds(this.__.__pathForRender, this.__layout.boxBounds);
8597
8483
  }
8598
8484
  else
8599
8485
  super.__updateBoxBounds();
@@ -8945,6 +8831,9 @@ __decorate([
8945
8831
  __decorate([
8946
8832
  boundsType(0)
8947
8833
  ], Text.prototype, "paraSpacing", void 0);
8834
+ __decorate([
8835
+ boundsType('x')
8836
+ ], Text.prototype, "writingMode", void 0);
8948
8837
  __decorate([
8949
8838
  boundsType('left')
8950
8839
  ], Text.prototype, "textAlign", void 0);
@@ -9131,8 +9020,8 @@ let App = class App extends Leafer {
9131
9020
  this.children.forEach(leafer => leafer.resize(event));
9132
9021
  super.__onResize(event);
9133
9022
  }
9134
- __checkUpdateLayout() {
9135
- this.children.forEach(leafer => leafer.__layout.update());
9023
+ updateLayout() {
9024
+ this.children.forEach(leafer => leafer.updateLayout());
9136
9025
  }
9137
9026
  __getChildConfig(userConfig) {
9138
9027
  let config = Object.assign({}, this.config);
@@ -9622,7 +9511,7 @@ class Dragger {
9622
9511
  }
9623
9512
  }
9624
9513
 
9625
- const debug$1 = Debug.get('emit');
9514
+ const debug = Debug.get('emit');
9626
9515
  function emit$1(type, data, path, excludePath) {
9627
9516
  if (!path && !data.path)
9628
9517
  return;
@@ -9652,7 +9541,7 @@ function emit$1(type, data, path, excludePath) {
9652
9541
  }
9653
9542
  }
9654
9543
  catch (e) {
9655
- debug$1.error(e);
9544
+ debug.error(e);
9656
9545
  }
9657
9546
  }
9658
9547
  const allowTypes = ['move', 'zoom', 'rotate', 'key'];
@@ -10209,8 +10098,8 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
10209
10098
  this.__drawRenderPath(canvas); };
10210
10099
 
10211
10100
  const matrix = new Matrix();
10212
- const ui$2 = UI.prototype;
10213
- ui$2.__updateHitCanvas = function () {
10101
+ const ui$1 = UI.prototype;
10102
+ ui$1.__updateHitCanvas = function () {
10214
10103
  const data = this.__, { hitCanvasManager } = this.leafer;
10215
10104
  const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10216
10105
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -10237,7 +10126,7 @@ ui$2.__updateHitCanvas = function () {
10237
10126
  this.__drawHitPath(h);
10238
10127
  h.setStrokeOptions(data);
10239
10128
  };
10240
- ui$2.__hit = function (inner) {
10129
+ ui$1.__hit = function (inner) {
10241
10130
  if (Platform.name === 'miniapp')
10242
10131
  this.__drawHitPath(this.__hitCanvas);
10243
10132
  const data = this.__;
@@ -10277,43 +10166,35 @@ ui$2.__hit = function (inner) {
10277
10166
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10278
10167
  };
10279
10168
 
10280
- const ui$1 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
10169
+ const ui = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
10281
10170
  rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10282
10171
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10283
- ui$1.__updateHitCanvas.call(this);
10172
+ ui.__updateHitCanvas.call(this);
10284
10173
  else if (this.__hitCanvas)
10285
10174
  this.__hitCanvas = null;
10286
10175
  };
10287
10176
  rect.__hitFill = box$1.__hitFill = function (inner) {
10288
- return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10177
+ return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10289
10178
  };
10290
10179
 
10291
- const ui = UI.prototype, group = Group.prototype;
10292
10180
  function getSelector(ui) {
10293
10181
  return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10294
10182
  }
10295
- ui.find = function (condition, options) {
10296
- return getSelector(this).getBy(condition, this, false, options);
10297
- };
10298
- ui.findOne = function (condition, options) {
10299
- return getSelector(this).getBy(condition, this, true, options);
10300
- };
10301
- group.pick = function (hitPoint, options) {
10302
- this.__layout.update();
10303
- if (!options)
10304
- options = {};
10183
+ Group.prototype.pick = function (hitPoint, options) {
10184
+ this.leafer || this.updateLayout();
10185
+ options || (options = emptyData);
10305
10186
  return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
10306
10187
  };
10307
10188
 
10308
- const canvas$1 = LeaferCanvasBase.prototype;
10309
- canvas$1.hitFill = function (point, fillRule) {
10189
+ const canvas = LeaferCanvasBase.prototype;
10190
+ canvas.hitFill = function (point, fillRule) {
10310
10191
  return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
10311
10192
  };
10312
- canvas$1.hitStroke = function (point, strokeWidth) {
10193
+ canvas.hitStroke = function (point, strokeWidth) {
10313
10194
  this.strokeWidth = strokeWidth;
10314
10195
  return this.context.isPointInStroke(point.x, point.y);
10315
10196
  };
10316
- canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
10197
+ canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
10317
10198
  let { x, y, radiusX, radiusY } = radiusPoint;
10318
10199
  if (offset)
10319
10200
  x -= offset.x, y -= offset.y;
@@ -12109,197 +11990,12 @@ const ColorConvertModule = {
12109
11990
  string
12110
11991
  };
12111
11992
 
12112
- const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
12113
- function getTrimBounds(canvas) {
12114
- const { width, height } = canvas.view;
12115
- const { data } = canvas.context.getImageData(0, 0, width, height);
12116
- let x, y, pointBounds, index = 0;
12117
- for (let i = 0; i < data.length; i += 4) {
12118
- if (data[i + 3] !== 0) {
12119
- x = index % width;
12120
- y = (index - x) / width;
12121
- pointBounds ? addPoint(pointBounds, x, y) : setPoint(pointBounds = {}, x, y);
12122
- }
12123
- index++;
12124
- }
12125
- const bounds = new Bounds();
12126
- toBounds(pointBounds, bounds);
12127
- return bounds.scale(1 / canvas.pixelRatio).ceil();
12128
- }
12129
-
12130
- const ExportModule = {
12131
- export(leaf, filename, options) {
12132
- this.running = true;
12133
- const fileType = FileHelper.fileType(filename);
12134
- const isDownload = filename.includes('.');
12135
- options = FileHelper.getExportOptions(options);
12136
- return addTask((success) => new Promise((resolve) => {
12137
- const over = (result) => {
12138
- success(result);
12139
- resolve();
12140
- this.running = false;
12141
- };
12142
- const { toURL } = Platform;
12143
- const { download } = Platform.origin;
12144
- if (fileType === 'json') {
12145
- isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
12146
- return over({ data: isDownload ? true : leaf.toJSON(options.json) });
12147
- }
12148
- if (fileType === 'svg') {
12149
- isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
12150
- return over({ data: isDownload ? true : leaf.toSVG() });
12151
- }
12152
- const { leafer } = leaf;
12153
- if (leafer) {
12154
- checkLazy(leaf);
12155
- leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
12156
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
12157
- const { worldTransform, isLeafer, isFrame } = leaf;
12158
- const { slice, trim, onCanvas } = options;
12159
- const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
12160
- const contextSettings = options.contextSettings || leafer.config.contextSettings;
12161
- const screenshot = options.screenshot || leaf.isApp;
12162
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
12163
- const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
12164
- if (screenshot) {
12165
- renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
12166
- }
12167
- else {
12168
- let relative = options.relative || (isLeafer ? 'inner' : 'local');
12169
- scaleX = worldTransform.scaleX;
12170
- scaleY = worldTransform.scaleY;
12171
- switch (relative) {
12172
- case 'inner':
12173
- matrix.set(worldTransform);
12174
- break;
12175
- case 'local':
12176
- matrix.set(worldTransform).divide(leaf.localTransform);
12177
- scaleX /= leaf.scaleX;
12178
- scaleY /= leaf.scaleY;
12179
- break;
12180
- case 'world':
12181
- scaleX = 1;
12182
- scaleY = 1;
12183
- break;
12184
- case 'page':
12185
- relative = leaf.leafer;
12186
- default:
12187
- matrix.set(worldTransform).divide(leaf.getTransform(relative));
12188
- const l = relative.worldTransform;
12189
- scaleX /= scaleX / l.scaleX;
12190
- scaleY /= scaleY / l.scaleY;
12191
- }
12192
- renderBounds = leaf.getBounds('render', relative);
12193
- }
12194
- const scaleData = { scaleX: 1, scaleY: 1 };
12195
- MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
12196
- let pixelRatio = options.pixelRatio || 1;
12197
- if (leaf.isApp) {
12198
- scaleData.scaleX *= pixelRatio;
12199
- scaleData.scaleY *= pixelRatio;
12200
- pixelRatio = leaf.app.pixelRatio;
12201
- }
12202
- const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
12203
- const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
12204
- let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
12205
- let sliceLeaf;
12206
- if (slice) {
12207
- sliceLeaf = leaf;
12208
- sliceLeaf.__worldOpacity = 0;
12209
- leaf = leafer;
12210
- renderOptions.bounds = canvas.bounds;
12211
- }
12212
- canvas.save();
12213
- if (isFrame && fill !== undefined) {
12214
- const oldFill = leaf.get('fill');
12215
- leaf.fill = '';
12216
- leaf.__render(canvas, renderOptions);
12217
- leaf.fill = oldFill;
12218
- }
12219
- else {
12220
- leaf.__render(canvas, renderOptions);
12221
- }
12222
- canvas.restore();
12223
- if (sliceLeaf)
12224
- sliceLeaf.__updateWorldOpacity();
12225
- if (trim) {
12226
- trimBounds = getTrimBounds(canvas);
12227
- const old = canvas, { width, height } = trimBounds;
12228
- const config = { x: 0, y: 0, width, height, pixelRatio };
12229
- canvas = Creator.canvas(config);
12230
- canvas.copyWorld(old, trimBounds, config);
12231
- }
12232
- if (needFill)
12233
- canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
12234
- if (onCanvas)
12235
- onCanvas(canvas);
12236
- const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
12237
- over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
12238
- }));
12239
- }
12240
- else {
12241
- over({ data: false });
12242
- }
12243
- }));
12244
- }
12245
- };
12246
- let tasker;
12247
- function addTask(task) {
12248
- if (!tasker)
12249
- tasker = new TaskProcessor();
12250
- return new Promise((resolve) => {
12251
- tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
12252
- });
12253
- }
12254
- function checkLazy(leaf) {
12255
- if (leaf.__.__needComputePaint)
12256
- leaf.__.__computePaint();
12257
- if (leaf.isBranch)
12258
- leaf.children.forEach(child => checkLazy(child));
12259
- }
12260
-
12261
- const canvas = LeaferCanvasBase.prototype;
12262
- const debug = Debug.get('@leafer-ui/export');
12263
- canvas.export = function (filename, options) {
12264
- const { quality, blob } = FileHelper.getExportOptions(options);
12265
- if (filename.includes('.'))
12266
- return this.saveAs(filename, quality);
12267
- else if (blob)
12268
- return this.toBlob(filename, quality);
12269
- else
12270
- return this.toDataURL(filename, quality);
12271
- };
12272
- canvas.toBlob = function (type, quality) {
12273
- return new Promise((resolve) => {
12274
- Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
12275
- resolve(blob);
12276
- }).catch((e) => {
12277
- debug.error(e);
12278
- resolve(null);
12279
- });
12280
- });
12281
- };
12282
- canvas.toDataURL = function (type, quality) {
12283
- return Platform.origin.canvasToDataURL(this.view, type, quality);
12284
- };
12285
- canvas.saveAs = function (filename, quality) {
12286
- return new Promise((resolve) => {
12287
- Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
12288
- resolve(true);
12289
- }).catch((e) => {
12290
- debug.error(e);
12291
- resolve(false);
12292
- });
12293
- });
12294
- };
12295
-
12296
11993
  Object.assign(TextConvert, TextConvertModule);
12297
11994
  Object.assign(ColorConvert, ColorConvertModule);
12298
11995
  Object.assign(Paint, PaintModule);
12299
11996
  Object.assign(PaintImage, PaintImageModule);
12300
11997
  Object.assign(PaintGradient, PaintGradientModule);
12301
11998
  Object.assign(Effect, EffectModule);
12302
- Object.assign(Export, ExportModule);
12303
11999
 
12304
12000
  Object.assign(Creator, {
12305
12001
  interaction: (target, canvas, selector, options) => new Interaction(target, canvas, selector, options),
@@ -12308,4 +12004,4 @@ Object.assign(Creator, {
12308
12004
  });
12309
12005
  useCanvas();
12310
12006
 
12311
- export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
12007
+ export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };