@leafer-draw/worker 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() {
@@ -7170,6 +7177,7 @@ class Watcher {
7170
7177
  }
7171
7178
  constructor(target, userConfig) {
7172
7179
  this.totalTimes = 0;
7180
+ this.changed = 0;
7173
7181
  this.config = {};
7174
7182
  this.__updatedList = new LeafList;
7175
7183
  this.target = target;
@@ -7189,8 +7197,10 @@ class Watcher {
7189
7197
  this.disabled = true;
7190
7198
  }
7191
7199
  update() {
7192
- this.changed = true;
7193
- if (this.running) this.target.emit(RenderEvent.REQUEST);
7200
+ if (this.changed < 100) {
7201
+ this.changed++;
7202
+ if (this.running) this.target.emit(RenderEvent.REQUEST);
7203
+ }
7194
7204
  }
7195
7205
  __onAttrChange(event) {
7196
7206
  this.add(event.target);
@@ -7199,18 +7209,21 @@ class Watcher {
7199
7209
  if (this.config.usePartLayout) this.__updatedList.add(leaf);
7200
7210
  this.update();
7201
7211
  }
7202
- __onChildEvent(event) {
7212
+ addChild(child, parent, eventType) {
7203
7213
  if (this.config.usePartLayout) {
7204
- if (event.type === ChildEvent.ADD) {
7214
+ if (eventType === ChildEvent.ADD) {
7205
7215
  this.hasAdd = true;
7206
- this.__pushChild(event.child);
7216
+ this.__pushChild(child);
7207
7217
  } else {
7208
7218
  this.hasRemove = true;
7209
- this.__updatedList.add(event.parent);
7219
+ this.__updatedList.add(parent);
7210
7220
  }
7211
7221
  }
7212
7222
  this.update();
7213
7223
  }
7224
+ __onChildEvent(event) {
7225
+ this.addChild(event.child, event.parent, event.type);
7226
+ }
7214
7227
  __pushChild(child) {
7215
7228
  this.__updatedList.add(child);
7216
7229
  if (child.isBranch) this.__loopChildren(child);
@@ -7225,7 +7238,8 @@ class Watcher {
7225
7238
  }));
7226
7239
  this.__updatedList = new LeafList;
7227
7240
  this.totalTimes++;
7228
- this.changed = this.hasVisible = this.hasRemove = this.hasAdd = false;
7241
+ this.hasVisible = this.hasRemove = this.hasAdd = false;
7242
+ this.changed = 0;
7229
7243
  }
7230
7244
  __listenEvents() {
7231
7245
  this.__eventIds = [ this.target.on_([ [ PropertyEvent.CHANGE, this.__onAttrChange, this ], [ [ ChildEvent.ADD, ChildEvent.REMOVE ], this.__onChildEvent, this ], [ WatchEvent.REQUEST, this.__onRquestData, this ] ]) ];
@@ -7246,47 +7260,57 @@ const {updateAllMatrix: updateAllMatrix$1, updateBounds: updateOneBounds, update
7246
7260
 
7247
7261
  const {pushAllChildBranch: pushAllChildBranch, pushAllParent: pushAllParent} = BranchHelper;
7248
7262
 
7249
- function updateMatrix(updateList, levelList) {
7250
- let layout;
7251
- updateList.list.forEach(leaf => {
7252
- layout = leaf.__layout;
7253
- if (levelList.without(leaf) && !layout.proxyZoom) {
7254
- if (layout.matrixChanged) {
7255
- updateAllMatrix$1(leaf, true);
7256
- levelList.add(leaf);
7257
- if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
7258
- pushAllParent(leaf, levelList);
7259
- } else if (layout.boundsChanged) {
7260
- levelList.add(leaf);
7261
- if (leaf.isBranch) leaf.__tempNumber = 0;
7262
- pushAllParent(leaf, levelList);
7263
+ const LayouterHelper = {
7264
+ updateMatrix(updateList, levelList) {
7265
+ let index = 0, leaf, layout;
7266
+ const {list: list} = updateList;
7267
+ while (index < list.length) {
7268
+ leaf = list[index];
7269
+ layout = leaf.__layout;
7270
+ if (levelList.without(leaf) && !layout.proxyZoom) {
7271
+ if (layout.matrixChanged) {
7272
+ updateAllMatrix$1(leaf, true);
7273
+ if (leaf.isBranch) pushAllChildBranch(leaf, levelList);
7274
+ push(leaf, levelList);
7275
+ } else if (layout.boundsChanged) {
7276
+ if (leaf.isBranch) leaf.__tempNumber = 0;
7277
+ push(leaf, levelList);
7278
+ }
7263
7279
  }
7280
+ index++;
7264
7281
  }
7265
- });
7266
- }
7267
-
7268
- function updateBounds(boundsList) {
7269
- let list, branch, children;
7270
- boundsList.sort(true);
7271
- boundsList.levels.forEach(level => {
7272
- list = boundsList.levelMap[level];
7273
- for (let i = 0, len = list.length; i < len; i++) {
7274
- branch = list[i];
7275
- if (branch.isBranch && branch.__tempNumber) {
7276
- children = branch.children;
7277
- for (let j = 0, jLen = children.length; j < jLen; j++) {
7278
- if (!children[j].isBranch) {
7279
- updateOneBounds(children[j]);
7282
+ },
7283
+ updateBounds(boundsList) {
7284
+ let index = 0, level, list, branch, children;
7285
+ const {levels: levels, levelMap: levelMap} = boundsList;
7286
+ boundsList.sort(true);
7287
+ while (index < levels.length) {
7288
+ level = levels[index];
7289
+ list = levelMap[level];
7290
+ for (let i = 0, len = list.length; i < len; i++) {
7291
+ branch = list[i];
7292
+ if (branch.isBranch && branch.__tempNumber) {
7293
+ children = branch.children;
7294
+ for (let j = 0, jLen = children.length; j < jLen; j++) {
7295
+ if (!children[j].isBranch) {
7296
+ updateOneBounds(children[j]);
7297
+ }
7280
7298
  }
7281
7299
  }
7300
+ updateOneBounds(branch);
7282
7301
  }
7283
- updateOneBounds(branch);
7302
+ index++;
7284
7303
  }
7285
- });
7286
- }
7304
+ },
7305
+ updateChange(updateList) {
7306
+ updateList.list.forEach(updateOneChange);
7307
+ },
7308
+ push: push
7309
+ };
7287
7310
 
7288
- function updateChange(updateList) {
7289
- updateList.list.forEach(updateOneChange);
7311
+ function push(leaf, levelList) {
7312
+ levelList.add(leaf);
7313
+ pushAllParent(leaf, levelList);
7290
7314
  }
7291
7315
 
7292
7316
  const {worldBounds: worldBounds} = LeafBoundsHelper;
@@ -7393,9 +7417,9 @@ class Layouter {
7393
7417
  target.emitEvent(new LayoutEvent(BEFORE, blocks, this.times));
7394
7418
  this.extraBlock = null;
7395
7419
  updateList.sort();
7396
- updateMatrix(updateList, this.__levelList);
7397
- updateBounds(this.__levelList);
7398
- updateChange(updateList);
7420
+ LayouterHelper.updateMatrix(updateList, this.__levelList);
7421
+ LayouterHelper.updateBounds(this.__levelList);
7422
+ LayouterHelper.updateChange(updateList);
7399
7423
  if (this.extraBlock) blocks.push(this.extraBlock);
7400
7424
  blocks.forEach(item => item.setAfter());
7401
7425
  target.emitEvent(new LayoutEvent(LAYOUT, blocks, this.times));
@@ -7425,11 +7449,16 @@ class Layouter {
7425
7449
  if (target.isBranch) BranchHelper.updateBounds(target); else LeafHelper.updateBounds(target);
7426
7450
  updateAllChange(target);
7427
7451
  }
7428
- addExtra(leaf) {
7452
+ addExtra(leaf, updateBounds) {
7429
7453
  if (!this.__updatedList.has(leaf)) {
7430
7454
  const {updatedList: updatedList, beforeBounds: beforeBounds} = this.extraBlock || (this.extraBlock = new LayoutBlockData([]));
7431
7455
  updatedList.length ? beforeBounds.add(leaf.__world) : beforeBounds.set(leaf.__world);
7432
7456
  updatedList.add(leaf);
7457
+ if (updateBounds) {
7458
+ const list = this.__levelList;
7459
+ LayouterHelper.push(leaf, list);
7460
+ list.sort(true);
7461
+ }
7433
7462
  }
7434
7463
  }
7435
7464
  createBlock(data) {
@@ -8676,6 +8705,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
8676
8705
  start: true,
8677
8706
  hittable: true,
8678
8707
  smooth: true,
8708
+ trackChanges: true,
8679
8709
  lazySpeard: 100
8680
8710
  };
8681
8711
  this.leafs = 0;
@@ -10077,7 +10107,7 @@ function checkSizeAndCreateData(ui, attrName, paint, image, leafPaint, boxBounds
10077
10107
  data.__naturalHeight = image.height / data.pixelRatio;
10078
10108
  if (data.__autoSide) {
10079
10109
  ui.forceUpdate();
10080
- LeafHelper.updateBounds(ui);
10110
+ LeafHelper.updateBounds(ui, true);
10081
10111
  ui.__layout.boundsChanged = true;
10082
10112
  if (ui.__proxyData) {
10083
10113
  ui.setProxyAttr("width", data.width);
@@ -11350,4 +11380,4 @@ Object.assign(Effect, EffectModule);
11350
11380
 
11351
11381
  useCanvas();
11352
11382
 
11353
- 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 };
11383
+ 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 };