@leafer-draw/miniapp 2.2.6 → 2.2.7

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.
@@ -4814,7 +4814,7 @@ const matrix = {}, {round: round} = Math;
4814
4814
  const LeafHelper = {
4815
4815
  updateAllMatrix(leaf, checkAutoLayout, waitAutoLayout) {
4816
4816
  if (checkAutoLayout && leaf.__hasAutoLayout && leaf.__layout.matrixChanged) waitAutoLayout = true;
4817
- updateMatrix$2(leaf, checkAutoLayout, waitAutoLayout);
4817
+ updateMatrix$1(leaf, checkAutoLayout, waitAutoLayout);
4818
4818
  if (leaf.isBranch) {
4819
4819
  const {children: children} = leaf;
4820
4820
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4835,9 +4835,10 @@ const LeafHelper = {
4835
4835
  if (layout.matrixChanged) leaf.__updateLocalMatrix();
4836
4836
  if (!layout.waitAutoLayout) leaf.__updateWorldMatrix();
4837
4837
  },
4838
- updateBounds(leaf) {
4838
+ updateBounds(leaf, noUpdateSize) {
4839
4839
  const layout = leaf.__layout;
4840
4840
  if (layout.boundsChanged) leaf.__updateLocalBounds();
4841
+ if (noUpdateSize) layout.resized = undefined;
4841
4842
  if (!layout.waitAutoLayout) leaf.__updateWorldBounds();
4842
4843
  },
4843
4844
  updateAllWorldOpacity(leaf) {
@@ -4860,7 +4861,7 @@ const LeafHelper = {
4860
4861
  }
4861
4862
  },
4862
4863
  updateAllChange(leaf) {
4863
- updateChange$1(leaf);
4864
+ updateChange(leaf);
4864
4865
  if (leaf.isBranch) {
4865
4866
  const {children: children} = leaf;
4866
4867
  for (let i = 0, len = children.length; i < len; i++) {
@@ -5032,7 +5033,7 @@ const LeafHelper = {
5032
5033
 
5033
5034
  const L = LeafHelper;
5034
5035
 
5035
- const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$2, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange$1} = L;
5036
+ const {updateAllMatrix: updateAllMatrix$3, updateMatrix: updateMatrix$1, updateAllWorldOpacity: updateAllWorldOpacity, updateAllChange: updateAllChange$1, updateChange: updateChange} = L;
5036
5037
 
5037
5038
  function getTempLocal(t, worldPoint) {
5038
5039
  t.updateLayout();
@@ -5078,7 +5079,7 @@ function checkMask(target, index) {
5078
5079
  return findMask < 0 ? null : (findMask && (findMask = -1), true);
5079
5080
  }
5080
5081
 
5081
- const {updateBounds: updateBounds$3} = LeafHelper;
5082
+ const {updateBounds: updateBounds$2} = LeafHelper;
5082
5083
 
5083
5084
  const BranchHelper = {
5084
5085
  sort(a, b) {
@@ -5139,10 +5140,10 @@ const BranchHelper = {
5139
5140
  branch = branchStack[i];
5140
5141
  children = branch.children;
5141
5142
  for (let j = 0, len = children.length; j < len; j++) {
5142
- updateBounds$3(children[j]);
5143
+ updateBounds$2(children[j]);
5143
5144
  }
5144
5145
  if (exclude && exclude === branch) continue;
5145
- updateBounds$3(branch);
5146
+ updateBounds$2(branch);
5146
5147
  }
5147
5148
  },
5148
5149
  move(branch, x, y) {
@@ -5204,7 +5205,7 @@ const WaitHelper = {
5204
5205
  }
5205
5206
  };
5206
5207
 
5207
- const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$2} = LeafHelper;
5208
+ const {getRelativeWorld: getRelativeWorld$1, updateBounds: updateBounds$1} = LeafHelper;
5208
5209
 
5209
5210
  const {toOuterOf: toOuterOf$3, getPoints: getPoints, copy: copy$4} = BoundsHelper;
5210
5211
 
@@ -5312,7 +5313,7 @@ class LeafLayout {
5312
5313
  }
5313
5314
  update() {
5314
5315
  const {leaf: leaf} = this, {leafer: leafer} = leaf;
5315
- if (leaf.isApp) return updateBounds$2(leaf);
5316
+ if (leaf.isApp) return updateBounds$1(leaf);
5316
5317
  if (leafer) {
5317
5318
  if (leafer.ready) leafer.watcher.changed && leafer.layouter.layout(); else leafer.start();
5318
5319
  } else {
@@ -6049,9 +6050,12 @@ const LeafDataProxy = {
6049
6050
  }
6050
6051
  },
6051
6052
  emitPropertyEvent(type, name, oldValue, newValue) {
6052
- const event = new PropertyEvent(type, this, name, oldValue, newValue);
6053
- this.isLeafer || this.hasEvent(type) && this.emitEvent(event);
6054
- this.leafer.emitEvent(event);
6053
+ const {leafer: leafer} = this;
6054
+ if (leafer.config.trackChanges || leafer.zoomLayer === this) {
6055
+ const event = new PropertyEvent(type, this, name, oldValue, newValue);
6056
+ this.isLeafer || this.hasEvent(type) && this.emitEvent(event);
6057
+ leafer.emitEvent(event);
6058
+ } else leafer.watcher.add(this);
6055
6059
  },
6056
6060
  __realSetAttr(name, newValue) {
6057
6061
  const data = this.__;
@@ -6096,9 +6100,9 @@ const LeafMatrix = {
6096
6100
  }
6097
6101
  };
6098
6102
 
6099
- const {updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
6103
+ const {updateMatrix: updateMatrix, updateAllMatrix: updateAllMatrix$2} = LeafHelper;
6100
6104
 
6101
- const {updateBounds: updateBounds$1} = BranchHelper;
6105
+ const {updateBounds: updateBounds} = BranchHelper;
6102
6106
 
6103
6107
  const {toOuterOf: toOuterOf$2, copyAndSpread: copyAndSpread$2, copy: copy$3} = BoundsHelper;
6104
6108
 
@@ -6201,14 +6205,14 @@ const LeafBounds = {
6201
6205
  if (this.__layout.childrenSortChanged) this.__updateSortChildren();
6202
6206
  if (this.__layout.boxChanged) this.__updateFlowLayout();
6203
6207
  updateAllMatrix$2(this);
6204
- updateBounds$1(this, this);
6208
+ updateBounds(this, this);
6205
6209
  if (this.__.__autoSide) this.__updateBoxBounds(true);
6206
6210
  } else {
6207
6211
  updateAllMatrix$2(this);
6208
- updateBounds$1(this, this);
6212
+ updateBounds(this, this);
6209
6213
  }
6210
6214
  } else {
6211
- updateMatrix$1(this);
6215
+ updateMatrix(this);
6212
6216
  }
6213
6217
  },
6214
6218
  __updateNaturalSize() {
@@ -6881,9 +6885,12 @@ let Branch = class Branch extends Leaf {
6881
6885
  if (this.isFrame) child.__bindFrame(null);
6882
6886
  }
6883
6887
  __emitChildEvent(type, child) {
6884
- const event = new ChildEvent(type, child, this);
6885
- if (this.hasEvent(type) && !this.isLeafer) this.emitEvent(event);
6886
- this.leafer.emitEvent(event);
6888
+ const {leafer: leafer} = this;
6889
+ if (leafer.config.trackChanges || leafer.zoomLayer === this) {
6890
+ const event = new ChildEvent(type, child, this);
6891
+ if (this.hasEvent(type) && !this.isLeafer) this.emitEvent(event);
6892
+ leafer.emitEvent(event);
6893
+ } else leafer.watcher.addChild(child, this, type);
6887
6894
  }
6888
6895
  };
6889
6896
 
@@ -7036,7 +7043,7 @@ class LeafLevelList {
7036
7043
  }
7037
7044
  }
7038
7045
 
7039
- const version = "2.2.6";
7046
+ const version = "2.2.7";
7040
7047
 
7041
7048
  class LeaferCanvas extends LeaferCanvasBase {
7042
7049
  get allowBackgroundColor() {
@@ -7329,6 +7336,7 @@ class Watcher {
7329
7336
  }
7330
7337
  constructor(target, userConfig) {
7331
7338
  this.totalTimes = 0;
7339
+ this.changed = 0;
7332
7340
  this.config = {};
7333
7341
  this.__updatedList = new LeafList;
7334
7342
  this.target = target;
@@ -7348,8 +7356,10 @@ class Watcher {
7348
7356
  this.disabled = true;
7349
7357
  }
7350
7358
  update() {
7351
- this.changed = true;
7352
- if (this.running) this.target.emit(RenderEvent.REQUEST);
7359
+ if (this.changed < 100) {
7360
+ this.changed++;
7361
+ if (this.running) this.target.emit(RenderEvent.REQUEST);
7362
+ }
7353
7363
  }
7354
7364
  __onAttrChange(event) {
7355
7365
  this.add(event.target);
@@ -7358,18 +7368,21 @@ class Watcher {
7358
7368
  if (this.config.usePartLayout) this.__updatedList.add(leaf);
7359
7369
  this.update();
7360
7370
  }
7361
- __onChildEvent(event) {
7371
+ addChild(child, parent, eventType) {
7362
7372
  if (this.config.usePartLayout) {
7363
- if (event.type === ChildEvent.ADD) {
7373
+ if (eventType === ChildEvent.ADD) {
7364
7374
  this.hasAdd = true;
7365
- this.__pushChild(event.child);
7375
+ this.__pushChild(child);
7366
7376
  } else {
7367
7377
  this.hasRemove = true;
7368
- this.__updatedList.add(event.parent);
7378
+ this.__updatedList.add(parent);
7369
7379
  }
7370
7380
  }
7371
7381
  this.update();
7372
7382
  }
7383
+ __onChildEvent(event) {
7384
+ this.addChild(event.child, event.parent, event.type);
7385
+ }
7373
7386
  __pushChild(child) {
7374
7387
  this.__updatedList.add(child);
7375
7388
  if (child.isBranch) this.__loopChildren(child);
@@ -7384,7 +7397,8 @@ class Watcher {
7384
7397
  }));
7385
7398
  this.__updatedList = new LeafList;
7386
7399
  this.totalTimes++;
7387
- this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
7400
+ this.hasVisible = this.hasRemove = this.hasAdd = false;
7401
+ this.changed = 0;
7388
7402
  }
7389
7403
  __listenEvents() {
7390
7404
  this.__eventIds = [ this.target.on_([ [ PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ ChildEvent.ADD, ChildEvent.REMOVE ], this.__onChildEvent, this ], [ WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
@@ -7405,47 +7419,57 @@ const {updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, update
7405
7419
 
7406
7420
  const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = BranchHelper;
7407
7421
 
7408
- function updateMatrix(updateList, levelList) {
7409
- let layout;
7410
- updateList.list.forEach(leaf => {
7411
- layout = leaf.__layout;
7412
- if (levelList.without(leaf) && !layout.proxyZoom) {
7413
- if (layout.matrixChanged) {
7414
- updateAllMatrix$1(leaf, true);
7415
- levelList.add(leaf);
7416
- if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
7417
- pushAllParent(leaf, levelList);
7418
- } else if (layout.boundsChanged) {
7419
- levelList.add(leaf);
7420
- if (leaf.isBranch) leaf.__tempNumber = 0;
7421
- pushAllParent(leaf, levelList);
7422
+ const LayouterHelper = {
7423
+ updateMatrix(updateList, levelList) {
7424
+ let index = 0, leaf, layout;
7425
+ const {list: list} = updateList;
7426
+ while (index < list.length) {
7427
+ leaf = list[index];
7428
+ layout = leaf.__layout;
7429
+ if (levelList.without(leaf) && !layout.proxyZoom) {
7430
+ if (layout.matrixChanged) {
7431
+ updateAllMatrix$1(leaf, true);
7432
+ if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
7433
+ push(leaf, levelList);
7434
+ } else if (layout.boundsChanged) {
7435
+ if (leaf.isBranch) leaf.__tempNumber = 0;
7436
+ push(leaf, levelList);
7437
+ }
7422
7438
  }
7439
+ index++;
7423
7440
  }
7424
- });
7425
- }
7426
-
7427
- function updateBounds(boundsList) {
7428
- let list, branch, children;
7429
- boundsList.sort(true);
7430
- boundsList.levels.forEach(level => {
7431
- list = boundsList.levelMap[level];
7432
- for (let i = 0, len = list.length; i < len; i++) {
7433
- branch = list[i];
7434
- if (branch.isBranch && branch.__tempNumber) {
7435
- children = branch.children;
7436
- for (let j = 0, jLen = children.length; j < jLen; j++) {
7437
- if (!children[j].isBranch) {
7438
- updateOneBounds(children[j]);
7441
+ },
7442
+ updateBounds(boundsList) {
7443
+ let index = 0, level, list, branch, children;
7444
+ const {levels: levels, levelMap: levelMap} = boundsList;
7445
+ boundsList.sort(true);
7446
+ while (index < levels.length) {
7447
+ level = levels[index];
7448
+ list = levelMap[level];
7449
+ for (let i = 0, len = list.length; i < len; i++) {
7450
+ branch = list[i];
7451
+ if (branch.isBranch && branch.__tempNumber) {
7452
+ children = branch.children;
7453
+ for (let j = 0, jLen = children.length; j < jLen; j++) {
7454
+ if (!children[j].isBranch) {
7455
+ updateOneBounds(children[j]);
7456
+ }
7439
7457
  }
7440
7458
  }
7459
+ updateOneBounds(branch);
7441
7460
  }
7442
- updateOneBounds(branch);
7461
+ index++;
7443
7462
  }
7444
- });
7445
- }
7463
+ },
7464
+ updateChange(updateList) {
7465
+ updateList.list.forEach(updateOneChange);
7466
+ },
7467
+ push: push
7468
+ };
7446
7469
 
7447
- function updateChange(updateList) {
7448
- updateList.list.forEach(updateOneChange);
7470
+ function push(leaf, levelList) {
7471
+ levelList.add(leaf);
7472
+ pushAllParent(leaf, levelList);
7449
7473
  }
7450
7474
 
7451
7475
  const {worldBounds: worldBounds} = LeafBoundsHelper;
@@ -7552,9 +7576,9 @@ class Layouter {
7552
7576
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
7553
7577
  this.extraBlock = null;
7554
7578
  updateList.sort();
7555
- updateMatrix(updateList, this.__levelList);
7556
- updateBounds(this.__levelList);
7557
- updateChange(updateList);
7579
+ LayouterHelper.updateMatrix(updateList, this.__levelList);
7580
+ LayouterHelper.updateBounds(this.__levelList);
7581
+ LayouterHelper.updateChange(updateList);
7558
7582
  if (this.extraBlock) blocks.push(this.extraBlock);
7559
7583
  blocks.forEach(item => item.setAfter());
7560
7584
  target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
@@ -7584,11 +7608,16 @@ class Layouter {
7584
7608
  if (target.isBranch) BranchHelper.updateBounds(target); else LeafHelper.updateBounds(target);
7585
7609
  updateAllChange(target);
7586
7610
  }
7587
- addExtra(leaf) {
7611
+ addExtra(leaf, updateBounds) {
7588
7612
  if (!this.__updatedList.has(leaf)) {
7589
7613
  const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
7590
7614
  updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
7591
7615
  updatedList.add(leaf);
7616
+ if (updateBounds) {
7617
+ const list = this.__levelList;
7618
+ LayouterHelper.push(leaf, list);
7619
+ list.sort(true);
7620
+ }
7592
7621
  }
7593
7622
  }
7594
7623
  createBlock(data) {
@@ -8835,6 +8864,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8835
8864
  start: true,
8836
8865
  hittable: true,
8837
8866
  smooth: true,
8867
+ trackChanges: true,
8838
8868
  lazySpeard: 100
8839
8869
  };
8840
8870
  this.leafs = 0;
@@ -10236,7 +10266,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
10236
10266
  data.__naturalHeight = image.height / data.pixelRatio;
10237
10267
  if (data.__autoSide) {
10238
10268
  ui.forceUpdate();
10239
- LeafHelper.updateBounds(ui);
10269
+ LeafHelper.updateBounds(ui, true);
10240
10270
  ui.__layout.boundsChanged = true;
10241
10271
  if (ui.__proxyData) {
10242
10272
  ui.setProxyAttr("width", data.width);
@@ -11511,4 +11541,4 @@ try {
11511
11541
  if (wx) useCanvas("miniapp", wx);
11512
11542
  } catch (_a) {}
11513
11543
 
11514
- export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, doSurfaceType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerPointsCurve, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
11544
+ export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, DataHelper, Debug, Direction4, Direction9, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, Image, ImageData, ImageEvent, ImageManager, IncrementId, LayoutEvent, Layouter, LayouterHelper, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferFilm, LeaferImage, LeaferVideo, Line, LineData, MathHelper, Matrix, MatrixHelper, MyImage, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Plugin, Point, PointHelper, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Run, Star, StarData, State, StringNumberMap, TaskItem, TaskProcessor, Text, TextConvert, TextData, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIRender, UnitConvert, UnitConvertHelper, WaitHelper, WatchEvent, Watcher, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, doSurfaceType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerPointsCurve, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };