@leafer-ui/miniapp 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$f = Debug.get('RunTime');
1377
+ const debug$e = 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$f.log(name, duration, 'ms');
1395
+ debug$e.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$e = Debug.get('UICreator');
1424
+ const debug$d = 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$e.repeat(tag);
1430
+ debug$d.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$e.error('not register ' + tag);
1435
+ debug$d.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$d = Debug.get('EventCreator');
1451
+ const debug$c = 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$d.repeat(name), nameList[name] = Event;
1459
+ nameList[name] && debug$c.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$c = Debug.get('PathConvert');
2615
+ const debug$b = 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$c.error(`command: ${command} [index:${i}]`, old);
2856
+ debug$b.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$b = Debug.get('PathDrawer');
3081
+ const debug$a = 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$b.error(`command: ${command} [index:${i}]`, data);
3144
+ debug$a.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$a = Debug.get('PathBounds');
3153
+ const { addPointBounds, copy: copy$8, addPoint, setPoint, addBounds, toBounds: toBounds$2 } = TwoPointBoundsHelper;
3154
+ const debug$9 = 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$a.error(`command: ${command} [index:${i}]`, data);
3262
+ debug$9.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$9 = Debug.get('TaskProcessor');
3378
+ const debug$8 = 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$9.error(error);
3393
+ debug$8.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$8 = new Debug('rewrite');
4080
+ const debug$7 = 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$8.error(item.name, '需在Class上装饰@rewriteAble()');
4097
+ debug$7.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$7 = Debug.get('setAttr');
5008
+ const debug$6 = 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$7.warn(this.innerName, name, newValue);
5014
+ debug$6.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$6 = new Debug('Branch');
5714
+ const debug$5 = 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$6.warn('add self or destroyed');
5756
+ return debug$5.warn('add self or destroyed');
5755
5757
  const noIndex = index === undefined;
5756
5758
  if (!child.__) {
5757
5759
  if (child instanceof Array)
@@ -6005,7 +6007,7 @@ class LeafLevelList {
6005
6007
  }
6006
6008
  }
6007
6009
 
6008
- const version = "1.2.2";
6010
+ const version = "1.3.1";
6009
6011
 
6010
6012
  class LeaferCanvas extends LeaferCanvasBase {
6011
6013
  get allowBackgroundColor() { return false; }
@@ -6419,7 +6421,7 @@ class LayoutBlockData {
6419
6421
  }
6420
6422
 
6421
6423
  const { updateAllMatrix, updateAllChange } = LeafHelper;
6422
- const debug$5 = Debug.get('Layouter');
6424
+ const debug$4 = Debug.get('Layouter');
6423
6425
  class Layouter {
6424
6426
  constructor(target, userConfig) {
6425
6427
  this.totalTimes = 0;
@@ -6454,7 +6456,7 @@ class Layouter {
6454
6456
  target.emitEvent(new LayoutEvent(LayoutEvent.END, this.layoutedBlocks, this.times));
6455
6457
  }
6456
6458
  catch (e) {
6457
- debug$5.error(e);
6459
+ debug$4.error(e);
6458
6460
  }
6459
6461
  this.layoutedBlocks = null;
6460
6462
  }
@@ -6468,9 +6470,9 @@ class Layouter {
6468
6470
  }
6469
6471
  layoutOnce() {
6470
6472
  if (this.layouting)
6471
- return debug$5.warn('layouting');
6473
+ return debug$4.warn('layouting');
6472
6474
  if (this.times > 3)
6473
- return debug$5.warn('layout max times');
6475
+ return debug$4.warn('layout max times');
6474
6476
  this.times++;
6475
6477
  this.totalTimes++;
6476
6478
  this.layouting = true;
@@ -6574,7 +6576,7 @@ class Layouter {
6574
6576
  }
6575
6577
  }
6576
6578
 
6577
- const debug$4 = Debug.get('Renderer');
6579
+ const debug$3 = Debug.get('Renderer');
6578
6580
  class Renderer {
6579
6581
  get needFill() { return !!(!this.canvas.allowBackgroundColor && this.config.fill); }
6580
6582
  constructor(target, canvas, userConfig) {
@@ -6612,7 +6614,7 @@ class Renderer {
6612
6614
  const { target } = this;
6613
6615
  this.times = 0;
6614
6616
  this.totalBounds = new Bounds();
6615
- debug$4.log(target.innerName, '--->');
6617
+ debug$3.log(target.innerName, '--->');
6616
6618
  try {
6617
6619
  if (!target.isApp)
6618
6620
  target.app.emit(RenderEvent.CHILD_START, target);
@@ -6623,9 +6625,9 @@ class Renderer {
6623
6625
  }
6624
6626
  catch (e) {
6625
6627
  this.rendering = false;
6626
- debug$4.error(e);
6628
+ debug$3.error(e);
6627
6629
  }
6628
- debug$4.log('-------------|');
6630
+ debug$3.log('-------------|');
6629
6631
  }
6630
6632
  renderAgain() {
6631
6633
  if (this.rendering) {
@@ -6637,9 +6639,9 @@ class Renderer {
6637
6639
  }
6638
6640
  renderOnce(callback) {
6639
6641
  if (this.rendering)
6640
- return debug$4.warn('rendering');
6642
+ return debug$3.warn('rendering');
6641
6643
  if (this.times > 3)
6642
- return debug$4.warn('render max times');
6644
+ return debug$3.warn('render max times');
6643
6645
  this.times++;
6644
6646
  this.totalTimes++;
6645
6647
  this.rendering = true;
@@ -6676,7 +6678,7 @@ class Renderer {
6676
6678
  partRender() {
6677
6679
  const { canvas, updateBlocks: list } = this;
6678
6680
  if (!list)
6679
- return debug$4.warn('PartRender: need update attr');
6681
+ return debug$3.warn('PartRender: need update attr');
6680
6682
  this.mergeBlocks();
6681
6683
  list.forEach(block => { if (canvas.bounds.hit(block) && !block.isEmpty())
6682
6684
  this.clipRender(block); });
@@ -6779,7 +6781,7 @@ class Renderer {
6779
6781
  empty = (!leaf.__world.width || !leaf.__world.height);
6780
6782
  if (empty) {
6781
6783
  if (!leaf.isLeafer)
6782
- debug$4.tip(leaf.innerName, ': empty');
6784
+ debug$3.tip(leaf.innerName, ': empty');
6783
6785
  empty = (!leaf.isBranch || leaf.isBranchLeaf);
6784
6786
  }
6785
6787
  return empty;
@@ -6945,143 +6947,26 @@ class Picker {
6945
6947
  }
6946
6948
  }
6947
6949
 
6948
- const { Yes, NoAndSkip, YesAndSkip } = Answer;
6949
- const idCondition = {}, classNameCondition = {}, tagCondition = {};
6950
6950
  class Selector {
6951
6951
  constructor(target, userConfig) {
6952
6952
  this.config = {};
6953
- this.innerIdMap = {};
6954
- this.idMap = {};
6955
- this.methods = {
6956
- id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
6957
- innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
6958
- className: (leaf, name) => leaf.className === name ? 1 : 0,
6959
- tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
6960
- tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
6961
- };
6962
- this.target = target;
6963
6953
  if (userConfig)
6964
6954
  this.config = DataHelper.default(userConfig, this.config);
6965
- this.picker = new Picker(target, this);
6966
- if (target)
6967
- this.__listenEvents();
6968
- }
6969
- getBy(condition, branch, one, options) {
6970
- switch (typeof condition) {
6971
- case 'number':
6972
- const leaf = this.getByInnerId(condition, branch);
6973
- return one ? leaf : (leaf ? [leaf] : []);
6974
- case 'string':
6975
- switch (condition[0]) {
6976
- case '#':
6977
- idCondition.id = condition.substring(1), condition = idCondition;
6978
- break;
6979
- case '.':
6980
- classNameCondition.className = condition.substring(1), condition = classNameCondition;
6981
- break;
6982
- default:
6983
- tagCondition.tag = condition, condition = tagCondition;
6984
- }
6985
- case 'object':
6986
- if (condition.id !== undefined) {
6987
- const leaf = this.getById(condition.id, branch);
6988
- return one ? leaf : (leaf ? [leaf] : []);
6989
- }
6990
- else if (condition.tag) {
6991
- const { tag } = condition, isArray = tag instanceof Array;
6992
- return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
6993
- }
6994
- else {
6995
- return this.getByMethod(this.methods.className, branch, one, condition.className);
6996
- }
6997
- case 'function':
6998
- return this.getByMethod(condition, branch, one, options);
6999
- }
6955
+ this.picker = new Picker(this.target = target, this);
6956
+ this.finder = Creator.finder && Creator.finder();
7000
6957
  }
7001
6958
  getByPoint(hitPoint, hitRadius, options) {
7002
- if (Platform.name === 'node' && this.target)
7003
- this.target.emit(LayoutEvent.CHECK_UPDATE);
6959
+ if (Platform.backgrounder && this.target)
6960
+ this.target.updateLayout();
7004
6961
  return this.picker.getByPoint(hitPoint, hitRadius, options);
7005
6962
  }
7006
- getByInnerId(innerId, branch) {
7007
- const cache = this.innerIdMap[innerId];
7008
- if (cache)
7009
- return cache;
7010
- this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
7011
- return this.findLeaf;
7012
- }
7013
- getById(id, branch) {
7014
- const cache = this.idMap[id];
7015
- if (cache && LeafHelper.hasParent(cache, branch || this.target))
7016
- return cache;
7017
- this.eachFind(this.toChildren(branch), this.methods.id, null, id);
7018
- return this.findLeaf;
7019
- }
7020
- getByClassName(className, branch) {
7021
- return this.getByMethod(this.methods.className, branch, false, className);
7022
- }
7023
- getByTag(tag, branch) {
7024
- return this.getByMethod(this.methods.tag, branch, false, tag);
7025
- }
7026
- getByMethod(method, branch, one, options) {
7027
- const list = one ? null : [];
7028
- this.eachFind(this.toChildren(branch), method, list, options);
7029
- return list || this.findLeaf;
7030
- }
7031
- eachFind(children, method, list, options) {
7032
- let child, result;
7033
- for (let i = 0, len = children.length; i < len; i++) {
7034
- child = children[i];
7035
- result = method(child, options);
7036
- if (result === Yes || result === YesAndSkip) {
7037
- if (list) {
7038
- list.push(child);
7039
- }
7040
- else {
7041
- this.findLeaf = child;
7042
- return;
7043
- }
7044
- }
7045
- if (child.isBranch && result < NoAndSkip)
7046
- this.eachFind(child.children, method, list, options);
7047
- }
7048
- }
7049
- toChildren(branch) {
7050
- this.findLeaf = null;
7051
- return [branch || this.target];
7052
- }
7053
- __onRemoveChild(event) {
7054
- const { id, innerId } = event.child;
7055
- if (this.idMap[id])
7056
- delete this.idMap[id];
7057
- if (this.innerIdMap[innerId])
7058
- delete this.innerIdMap[innerId];
7059
- }
7060
- __checkIdChange(event) {
7061
- if (event.attrName === 'id') {
7062
- const id = event.oldValue;
7063
- if (this.idMap[id])
7064
- delete this.idMap[id];
7065
- }
7066
- }
7067
- __listenEvents() {
7068
- this.__eventIds = [
7069
- this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
7070
- this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
7071
- ];
7072
- }
7073
- __removeListenEvents() {
7074
- this.target.off_(this.__eventIds);
7075
- this.__eventIds.length = 0;
6963
+ getBy(condition, branch, one, options) {
6964
+ return this.finder ? this.finder.getBy(condition, branch, one, options) : Plugin.need('find');
7076
6965
  }
7077
6966
  destroy() {
7078
- if (this.__eventIds.length) {
7079
- this.__removeListenEvents();
7080
- this.picker.destroy();
7081
- this.findLeaf = null;
7082
- this.innerIdMap = {};
7083
- this.idMap = {};
7084
- }
6967
+ this.picker.destroy();
6968
+ if (this.finder)
6969
+ this.finder.destroy();
7085
6970
  }
7086
6971
  }
7087
6972
 
@@ -7154,7 +7039,7 @@ const Transition = {
7154
7039
 
7155
7040
  const { parse, objectToCanvasData } = PathConvert;
7156
7041
  const emptyPaint = {};
7157
- const debug$3 = Debug.get('UIData');
7042
+ const debug$2 = Debug.get('UIData');
7158
7043
  class UIData extends LeafData {
7159
7044
  get scale() { const { scaleX, scaleY } = this; return scaleX !== scaleY ? { x: scaleX, y: scaleY } : scaleX; }
7160
7045
  get __strokeWidth() {
@@ -7191,7 +7076,7 @@ class UIData extends LeafData {
7191
7076
  if (value < 0) {
7192
7077
  this._width = -value;
7193
7078
  this.__leaf.scaleX *= -1;
7194
- debug$3.warn('width < 0, instead -scaleX ', this);
7079
+ debug$2.warn('width < 0, instead -scaleX ', this);
7195
7080
  }
7196
7081
  else
7197
7082
  this._width = value;
@@ -7200,7 +7085,7 @@ class UIData extends LeafData {
7200
7085
  if (value < 0) {
7201
7086
  this._height = -value;
7202
7087
  this.__leaf.scaleY *= -1;
7203
- debug$3.warn('height < 0, instead -scaleY', this);
7088
+ debug$2.warn('height < 0, instead -scaleY', this);
7204
7089
  }
7205
7090
  else
7206
7091
  this._height = value;
@@ -7577,25 +7462,27 @@ let UI = UI_1 = class UI extends Leaf {
7577
7462
  }
7578
7463
  reset(_data) { }
7579
7464
  set(data, transition) {
7580
- if (transition) {
7581
- if (transition === 'temp') {
7582
- this.lockNormalStyle = true;
7583
- Object.assign(this, data);
7584
- this.lockNormalStyle = false;
7465
+ if (data) {
7466
+ if (transition) {
7467
+ if (transition === 'temp') {
7468
+ this.lockNormalStyle = true;
7469
+ Object.assign(this, data);
7470
+ this.lockNormalStyle = false;
7471
+ }
7472
+ else
7473
+ this.animate(data, transition);
7585
7474
  }
7586
7475
  else
7587
- this.animate(data, transition);
7476
+ Object.assign(this, data);
7588
7477
  }
7589
- else
7590
- Object.assign(this, data);
7591
7478
  }
7592
7479
  get(name) {
7593
7480
  return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
7594
7481
  }
7595
7482
  createProxyData() { return undefined; }
7596
- find(_condition, _options) { return undefined; }
7483
+ find(_condition, _options) { return Plugin.need('find'); }
7597
7484
  findTag(tag) { return this.find({ tag }); }
7598
- findOne(_condition, _options) { return undefined; }
7485
+ findOne(_condition, _options) { return Plugin.need('find'); }
7599
7486
  findId(id) { return this.findOne({ id }); }
7600
7487
  getPath(curve, pathForRender) {
7601
7488
  this.__layout.update();
@@ -7647,9 +7534,9 @@ let UI = UI_1 = class UI extends Leaf {
7647
7534
  animate(_keyframe, _options, _type, _isTemp) {
7648
7535
  return Plugin.need('animate');
7649
7536
  }
7650
- killAnimate(_type) { }
7651
- export(filename, options) {
7652
- return Export.export(this, filename, options);
7537
+ killAnimate(_type, _killStyle) { }
7538
+ export(_filename, _options) {
7539
+ return Plugin.need('export');
7653
7540
  }
7654
7541
  clone(data) {
7655
7542
  const json = this.toJSON();
@@ -7895,16 +7782,18 @@ let Group = class Group extends UI {
7895
7782
  this.children = [];
7896
7783
  }
7897
7784
  set(data, transition) {
7898
- if (data.children) {
7899
- const { children } = data;
7900
- delete data.children;
7901
- this.children ? this.clear() : this.__setBranch();
7902
- super.set(data, transition);
7903
- children.forEach(child => this.add(child));
7904
- data.children = children;
7785
+ if (data) {
7786
+ if (data.children) {
7787
+ const { children } = data;
7788
+ delete data.children;
7789
+ this.children ? this.clear() : this.__setBranch();
7790
+ super.set(data, transition);
7791
+ children.forEach(child => this.add(child));
7792
+ data.children = children;
7793
+ }
7794
+ else
7795
+ super.set(data, transition);
7905
7796
  }
7906
- else
7907
- super.set(data, transition);
7908
7797
  }
7909
7798
  toJSON(options) {
7910
7799
  const data = super.toJSON(options);
@@ -7936,7 +7825,7 @@ Group = __decorate([
7936
7825
  ], Group);
7937
7826
 
7938
7827
  var Leafer_1;
7939
- const debug$2 = Debug.get('Leafer');
7828
+ const debug$1 = Debug.get('Leafer');
7940
7829
  let Leafer = Leafer_1 = class Leafer extends Group {
7941
7830
  get __tag() { return 'Leafer'; }
7942
7831
  get isApp() { return false; }
@@ -8101,7 +7990,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8101
7990
  if (this.canvas) {
8102
7991
  if (canvasSizeAttrs.includes(attrName)) {
8103
7992
  if (!newValue)
8104
- debug$2.warn(attrName + ' is 0');
7993
+ debug$1.warn(attrName + ' is 0');
8105
7994
  this.__changeCanvasSize(attrName, newValue);
8106
7995
  }
8107
7996
  else if (attrName === 'fill') {
@@ -8242,9 +8131,6 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8242
8131
  this.canvas && this.canvas.updateClientBounds();
8243
8132
  }
8244
8133
  receiveEvent(_event) { }
8245
- __checkUpdateLayout() {
8246
- this.__layout.update();
8247
- }
8248
8134
  emitLeafer(type) {
8249
8135
  this.emitEvent(new LeaferEvent(type, this));
8250
8136
  }
@@ -8255,7 +8141,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8255
8141
  this.once(LayoutEvent.END, () => this.__onReady());
8256
8142
  this.once(RenderEvent.START, () => this.__onCreated());
8257
8143
  this.once(RenderEvent.END, () => this.__onViewReady());
8258
- 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));
8144
+ this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
8259
8145
  }
8260
8146
  __removeListenEvents() {
8261
8147
  this.off_(this.__eventIds);
@@ -8286,7 +8172,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8286
8172
  setTimeout(() => { ImageManager.clearRecycled(); }, 100);
8287
8173
  }
8288
8174
  catch (e) {
8289
- debug$2.error(e);
8175
+ debug$1.error(e);
8290
8176
  }
8291
8177
  }
8292
8178
  };
@@ -8320,7 +8206,7 @@ Rect = __decorate([
8320
8206
  ], Rect);
8321
8207
 
8322
8208
  const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
8323
- const rect$1 = Rect.prototype, group$1 = Group.prototype;
8209
+ const rect$1 = Rect.prototype, group = Group.prototype;
8324
8210
  const childrenRenderBounds = {};
8325
8211
  let Box = class Box extends Group {
8326
8212
  get __tag() { return 'Box'; }
@@ -8430,7 +8316,7 @@ __decorate([
8430
8316
  rewrite(rect$1.__render)
8431
8317
  ], Box.prototype, "__renderRect", null);
8432
8318
  __decorate([
8433
- rewrite(group$1.__render)
8319
+ rewrite(group.__render)
8434
8320
  ], Box.prototype, "__renderGroup", null);
8435
8321
  Box = __decorate([
8436
8322
  rewriteAble(),
@@ -8515,7 +8401,7 @@ Ellipse = __decorate([
8515
8401
 
8516
8402
  const { moveTo: moveTo$2, lineTo: lineTo$2, drawPoints: drawPoints$1 } = PathCommandDataHelper;
8517
8403
  const { rotate: rotate$1, getAngle: getAngle$1, getDistance: getDistance$2, defaultPoint } = PointHelper;
8518
- const { toBounds: toBounds$1 } = PathBounds;
8404
+ const { toBounds } = PathBounds;
8519
8405
  let Line = class Line extends UI {
8520
8406
  get __tag() { return 'Line'; }
8521
8407
  get toPoint() {
@@ -8559,7 +8445,7 @@ let Line = class Line extends UI {
8559
8445
  }
8560
8446
  __updateBoxBounds() {
8561
8447
  if (this.points) {
8562
- toBounds$1(this.__.__pathForRender, this.__layout.boxBounds);
8448
+ toBounds(this.__.__pathForRender, this.__layout.boxBounds);
8563
8449
  }
8564
8450
  else
8565
8451
  super.__updateBoxBounds();
@@ -8911,6 +8797,9 @@ __decorate([
8911
8797
  __decorate([
8912
8798
  boundsType(0)
8913
8799
  ], Text.prototype, "paraSpacing", void 0);
8800
+ __decorate([
8801
+ boundsType('x')
8802
+ ], Text.prototype, "writingMode", void 0);
8914
8803
  __decorate([
8915
8804
  boundsType('left')
8916
8805
  ], Text.prototype, "textAlign", void 0);
@@ -9097,8 +8986,8 @@ let App = class App extends Leafer {
9097
8986
  this.children.forEach(leafer => leafer.resize(event));
9098
8987
  super.__onResize(event);
9099
8988
  }
9100
- __checkUpdateLayout() {
9101
- this.children.forEach(leafer => leafer.__layout.update());
8989
+ updateLayout() {
8990
+ this.children.forEach(leafer => leafer.updateLayout());
9102
8991
  }
9103
8992
  __getChildConfig(userConfig) {
9104
8993
  let config = Object.assign({}, this.config);
@@ -9588,7 +9477,7 @@ class Dragger {
9588
9477
  }
9589
9478
  }
9590
9479
 
9591
- const debug$1 = Debug.get('emit');
9480
+ const debug = Debug.get('emit');
9592
9481
  function emit$1(type, data, path, excludePath) {
9593
9482
  if (!path && !data.path)
9594
9483
  return;
@@ -9618,7 +9507,7 @@ function emit$1(type, data, path, excludePath) {
9618
9507
  }
9619
9508
  }
9620
9509
  catch (e) {
9621
- debug$1.error(e);
9510
+ debug.error(e);
9622
9511
  }
9623
9512
  }
9624
9513
  const allowTypes = ['move', 'zoom', 'rotate', 'key'];
@@ -10175,8 +10064,8 @@ leaf.__drawHitPath = function (canvas) { if (canvas)
10175
10064
  this.__drawRenderPath(canvas); };
10176
10065
 
10177
10066
  const matrix = new Matrix();
10178
- const ui$2 = UI.prototype;
10179
- ui$2.__updateHitCanvas = function () {
10067
+ const ui$1 = UI.prototype;
10068
+ ui$1.__updateHitCanvas = function () {
10180
10069
  const data = this.__, { hitCanvasManager } = this.leafer;
10181
10070
  const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
10182
10071
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -10203,7 +10092,7 @@ ui$2.__updateHitCanvas = function () {
10203
10092
  this.__drawHitPath(h);
10204
10093
  h.setStrokeOptions(data);
10205
10094
  };
10206
- ui$2.__hit = function (inner) {
10095
+ ui$1.__hit = function (inner) {
10207
10096
  if (Platform.name === 'miniapp')
10208
10097
  this.__drawHitPath(this.__hitCanvas);
10209
10098
  const data = this.__;
@@ -10243,43 +10132,35 @@ ui$2.__hit = function (inner) {
10243
10132
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
10244
10133
  };
10245
10134
 
10246
- const ui$1 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
10135
+ const ui = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
10247
10136
  rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
10248
10137
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
10249
- ui$1.__updateHitCanvas.call(this);
10138
+ ui.__updateHitCanvas.call(this);
10250
10139
  else if (this.__hitCanvas)
10251
10140
  this.__hitCanvas = null;
10252
10141
  };
10253
10142
  rect.__hitFill = box$1.__hitFill = function (inner) {
10254
- return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10143
+ return this.__hitCanvas ? ui.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10255
10144
  };
10256
10145
 
10257
- const ui = UI.prototype, group = Group.prototype;
10258
10146
  function getSelector(ui) {
10259
10147
  return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10260
10148
  }
10261
- ui.find = function (condition, options) {
10262
- return getSelector(this).getBy(condition, this, false, options);
10263
- };
10264
- ui.findOne = function (condition, options) {
10265
- return getSelector(this).getBy(condition, this, true, options);
10266
- };
10267
- group.pick = function (hitPoint, options) {
10268
- this.__layout.update();
10269
- if (!options)
10270
- options = {};
10149
+ Group.prototype.pick = function (hitPoint, options) {
10150
+ this.leafer || this.updateLayout();
10151
+ options || (options = emptyData);
10271
10152
  return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
10272
10153
  };
10273
10154
 
10274
- const canvas$1 = LeaferCanvasBase.prototype;
10275
- canvas$1.hitFill = function (point, fillRule) {
10155
+ const canvas = LeaferCanvasBase.prototype;
10156
+ canvas.hitFill = function (point, fillRule) {
10276
10157
  return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
10277
10158
  };
10278
- canvas$1.hitStroke = function (point, strokeWidth) {
10159
+ canvas.hitStroke = function (point, strokeWidth) {
10279
10160
  this.strokeWidth = strokeWidth;
10280
10161
  return this.context.isPointInStroke(point.x, point.y);
10281
10162
  };
10282
- canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
10163
+ canvas.hitPixel = function (radiusPoint, offset, scale = 1) {
10283
10164
  let { x, y, radiusX, radiusY } = radiusPoint;
10284
10165
  if (offset)
10285
10166
  x -= offset.x, y -= offset.y;
@@ -11876,197 +11757,12 @@ const ColorConvertModule = {
11876
11757
  string
11877
11758
  };
11878
11759
 
11879
- const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
11880
- function getTrimBounds(canvas) {
11881
- const { width, height } = canvas.view;
11882
- const { data } = canvas.context.getImageData(0, 0, width, height);
11883
- let x, y, pointBounds, index = 0;
11884
- for (let i = 0; i < data.length; i += 4) {
11885
- if (data[i + 3] !== 0) {
11886
- x = index % width;
11887
- y = (index - x) / width;
11888
- pointBounds ? addPoint(pointBounds, x, y) : setPoint(pointBounds = {}, x, y);
11889
- }
11890
- index++;
11891
- }
11892
- const bounds = new Bounds();
11893
- toBounds(pointBounds, bounds);
11894
- return bounds.scale(1 / canvas.pixelRatio).ceil();
11895
- }
11896
-
11897
- const ExportModule = {
11898
- export(leaf, filename, options) {
11899
- this.running = true;
11900
- const fileType = FileHelper.fileType(filename);
11901
- const isDownload = filename.includes('.');
11902
- options = FileHelper.getExportOptions(options);
11903
- return addTask((success) => new Promise((resolve) => {
11904
- const over = (result) => {
11905
- success(result);
11906
- resolve();
11907
- this.running = false;
11908
- };
11909
- const { toURL } = Platform;
11910
- const { download } = Platform.origin;
11911
- if (fileType === 'json') {
11912
- isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
11913
- return over({ data: isDownload ? true : leaf.toJSON(options.json) });
11914
- }
11915
- if (fileType === 'svg') {
11916
- isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
11917
- return over({ data: isDownload ? true : leaf.toSVG() });
11918
- }
11919
- const { leafer } = leaf;
11920
- if (leafer) {
11921
- checkLazy(leaf);
11922
- leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
11923
- let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
11924
- const { worldTransform, isLeafer, isFrame } = leaf;
11925
- const { slice, trim, onCanvas } = options;
11926
- const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
11927
- const contextSettings = options.contextSettings || leafer.config.contextSettings;
11928
- const screenshot = options.screenshot || leaf.isApp;
11929
- const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
11930
- const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
11931
- if (screenshot) {
11932
- renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
11933
- }
11934
- else {
11935
- let relative = options.relative || (isLeafer ? 'inner' : 'local');
11936
- scaleX = worldTransform.scaleX;
11937
- scaleY = worldTransform.scaleY;
11938
- switch (relative) {
11939
- case 'inner':
11940
- matrix.set(worldTransform);
11941
- break;
11942
- case 'local':
11943
- matrix.set(worldTransform).divide(leaf.localTransform);
11944
- scaleX /= leaf.scaleX;
11945
- scaleY /= leaf.scaleY;
11946
- break;
11947
- case 'world':
11948
- scaleX = 1;
11949
- scaleY = 1;
11950
- break;
11951
- case 'page':
11952
- relative = leaf.leafer;
11953
- default:
11954
- matrix.set(worldTransform).divide(leaf.getTransform(relative));
11955
- const l = relative.worldTransform;
11956
- scaleX /= scaleX / l.scaleX;
11957
- scaleY /= scaleY / l.scaleY;
11958
- }
11959
- renderBounds = leaf.getBounds('render', relative);
11960
- }
11961
- const scaleData = { scaleX: 1, scaleY: 1 };
11962
- MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
11963
- let pixelRatio = options.pixelRatio || 1;
11964
- if (leaf.isApp) {
11965
- scaleData.scaleX *= pixelRatio;
11966
- scaleData.scaleY *= pixelRatio;
11967
- pixelRatio = leaf.app.pixelRatio;
11968
- }
11969
- const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
11970
- const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
11971
- let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
11972
- let sliceLeaf;
11973
- if (slice) {
11974
- sliceLeaf = leaf;
11975
- sliceLeaf.__worldOpacity = 0;
11976
- leaf = leafer;
11977
- renderOptions.bounds = canvas.bounds;
11978
- }
11979
- canvas.save();
11980
- if (isFrame && fill !== undefined) {
11981
- const oldFill = leaf.get('fill');
11982
- leaf.fill = '';
11983
- leaf.__render(canvas, renderOptions);
11984
- leaf.fill = oldFill;
11985
- }
11986
- else {
11987
- leaf.__render(canvas, renderOptions);
11988
- }
11989
- canvas.restore();
11990
- if (sliceLeaf)
11991
- sliceLeaf.__updateWorldOpacity();
11992
- if (trim) {
11993
- trimBounds = getTrimBounds(canvas);
11994
- const old = canvas, { width, height } = trimBounds;
11995
- const config = { x: 0, y: 0, width, height, pixelRatio };
11996
- canvas = Creator.canvas(config);
11997
- canvas.copyWorld(old, trimBounds, config);
11998
- }
11999
- if (needFill)
12000
- canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
12001
- if (onCanvas)
12002
- onCanvas(canvas);
12003
- const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
12004
- over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
12005
- }));
12006
- }
12007
- else {
12008
- over({ data: false });
12009
- }
12010
- }));
12011
- }
12012
- };
12013
- let tasker;
12014
- function addTask(task) {
12015
- if (!tasker)
12016
- tasker = new TaskProcessor();
12017
- return new Promise((resolve) => {
12018
- tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
12019
- });
12020
- }
12021
- function checkLazy(leaf) {
12022
- if (leaf.__.__needComputePaint)
12023
- leaf.__.__computePaint();
12024
- if (leaf.isBranch)
12025
- leaf.children.forEach(child => checkLazy(child));
12026
- }
12027
-
12028
- const canvas = LeaferCanvasBase.prototype;
12029
- const debug = Debug.get('@leafer-ui/export');
12030
- canvas.export = function (filename, options) {
12031
- const { quality, blob } = FileHelper.getExportOptions(options);
12032
- if (filename.includes('.'))
12033
- return this.saveAs(filename, quality);
12034
- else if (blob)
12035
- return this.toBlob(filename, quality);
12036
- else
12037
- return this.toDataURL(filename, quality);
12038
- };
12039
- canvas.toBlob = function (type, quality) {
12040
- return new Promise((resolve) => {
12041
- Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
12042
- resolve(blob);
12043
- }).catch((e) => {
12044
- debug.error(e);
12045
- resolve(null);
12046
- });
12047
- });
12048
- };
12049
- canvas.toDataURL = function (type, quality) {
12050
- return Platform.origin.canvasToDataURL(this.view, type, quality);
12051
- };
12052
- canvas.saveAs = function (filename, quality) {
12053
- return new Promise((resolve) => {
12054
- Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
12055
- resolve(true);
12056
- }).catch((e) => {
12057
- debug.error(e);
12058
- resolve(false);
12059
- });
12060
- });
12061
- };
12062
-
12063
11760
  Object.assign(TextConvert, TextConvertModule);
12064
11761
  Object.assign(ColorConvert, ColorConvertModule);
12065
11762
  Object.assign(Paint, PaintModule);
12066
11763
  Object.assign(PaintImage, PaintImageModule);
12067
11764
  Object.assign(PaintGradient, PaintGradientModule);
12068
11765
  Object.assign(Effect, EffectModule);
12069
- Object.assign(Export, ExportModule);
12070
11766
 
12071
11767
  Object.assign(Creator, {
12072
11768
  interaction: (target, canvas, selector, options) => new Interaction(target, canvas, selector, options),
@@ -12106,4 +11802,4 @@ if (platform === 'ios') {
12106
11802
  };
12107
11803
  }
12108
11804
 
12109
- 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, 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 };
11805
+ 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, 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 };