@leafer/worker 1.11.1 → 1.12.0

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.
@@ -1,3 +1,12 @@
1
+ var PathNodeHandleType;
2
+
3
+ (function(PathNodeHandleType) {
4
+ PathNodeHandleType[PathNodeHandleType["none"] = 1] = "none";
5
+ PathNodeHandleType[PathNodeHandleType["free"] = 2] = "free";
6
+ PathNodeHandleType[PathNodeHandleType["mirrorAngle"] = 3] = "mirrorAngle";
7
+ PathNodeHandleType[PathNodeHandleType["mirror"] = 4] = "mirror";
8
+ })(PathNodeHandleType || (PathNodeHandleType = {}));
9
+
1
10
  var Answer;
2
11
 
3
12
  (function(Answer) {
@@ -4047,16 +4056,27 @@ const ImageManager = {
4047
4056
  recycle(image) {
4048
4057
  image.use--;
4049
4058
  setTimeout(() => {
4050
- if (!image.use) I$1.recycledList.push(image);
4059
+ if (!image.use) {
4060
+ if (Platform.image.isLarge(image)) {
4061
+ if (image.url) Resource.remove(image.url);
4062
+ } else {
4063
+ image.clearLevels();
4064
+ I$1.recycledList.push(image);
4065
+ }
4066
+ }
4051
4067
  });
4052
4068
  },
4053
- clearRecycled() {
4069
+ recyclePaint(paint) {
4070
+ I$1.recycle(paint.image);
4071
+ },
4072
+ clearRecycled(force) {
4054
4073
  const list = I$1.recycledList;
4055
- if (list.length > I$1.maxRecycled) {
4056
- list.forEach(image => !image.use && image.url && Resource.remove(image.url));
4074
+ if (list.length > I$1.maxRecycled || force) {
4075
+ list.forEach(image => (!image.use || force) && image.url && Resource.remove(image.url));
4057
4076
  list.length = 0;
4058
4077
  }
4059
4078
  },
4079
+ clearLevels() {},
4060
4080
  hasAlphaPixel(config) {
4061
4081
  return FileHelper.alphaPixelTypes.some(item => I$1.isFormat(item, config));
4062
4082
  },
@@ -4071,7 +4091,7 @@ const ImageManager = {
4071
4091
  return false;
4072
4092
  },
4073
4093
  destroy() {
4074
- I$1.recycledList = [];
4094
+ this.clearRecycled(true);
4075
4095
  }
4076
4096
  };
4077
4097
 
@@ -4174,11 +4194,15 @@ class LeaferImage {
4174
4194
  Platform.image.setPatternTransform(pattern, transform, paint);
4175
4195
  return pattern;
4176
4196
  }
4197
+ clearLevels(_checkUse) {}
4177
4198
  destroy() {
4199
+ this.clearLevels();
4200
+ const {view: view} = this;
4201
+ if (view && view.close) view.close();
4178
4202
  this.config = {
4179
4203
  url: ""
4180
4204
  };
4181
- this.cache = null;
4205
+ this.cache = this.view = null;
4182
4206
  this.waitComplete.length = 0;
4183
4207
  }
4184
4208
  }
@@ -5957,6 +5981,7 @@ const LeafBounds = {
5957
5981
  const LeafRender = {
5958
5982
  __render(canvas, options) {
5959
5983
  if (options.shape) return this.__renderShape(canvas, options);
5984
+ if (options.cellList && !options.cellList.has(this)) return;
5960
5985
  if (this.__worldOpacity) {
5961
5986
  const data = this.__;
5962
5987
  if (data.bright && !options.topRendering) return options.topList.add(this);
@@ -6855,7 +6880,7 @@ class LeafLevelList {
6855
6880
  }
6856
6881
  }
6857
6882
 
6858
- const version = "1.11.1";
6883
+ const version = "1.12.0";
6859
6884
 
6860
6885
  class LeaferCanvas extends LeaferCanvasBase {
6861
6886
  get allowBackgroundColor() {
@@ -6972,7 +6997,7 @@ class Watcher {
6972
6997
  return this.hasAdd || this.hasRemove || this.hasVisible;
6973
6998
  }
6974
6999
  get updatedList() {
6975
- if (this.hasRemove) {
7000
+ if (this.hasRemove && this.config.usePartLayout) {
6976
7001
  const updatedList = new LeafList;
6977
7002
  this.__updatedList.list.forEach(item => {
6978
7003
  if (item.leafer) updatedList.add(item);
@@ -7007,16 +7032,18 @@ class Watcher {
7007
7032
  if (this.running) this.target.emit(RenderEvent.REQUEST);
7008
7033
  }
7009
7034
  __onAttrChange(event) {
7010
- this.__updatedList.add(event.target);
7035
+ if (this.config.usePartLayout) this.__updatedList.add(event.target);
7011
7036
  this.update();
7012
7037
  }
7013
7038
  __onChildEvent(event) {
7014
- if (event.type === ChildEvent.ADD) {
7015
- this.hasAdd = true;
7016
- this.__pushChild(event.child);
7017
- } else {
7018
- this.hasRemove = true;
7019
- this.__updatedList.add(event.parent);
7039
+ if (this.config.usePartLayout) {
7040
+ if (event.type === ChildEvent.ADD) {
7041
+ this.hasAdd = true;
7042
+ this.__pushChild(event.child);
7043
+ } else {
7044
+ this.hasRemove = true;
7045
+ this.__updatedList.add(event.parent);
7046
+ }
7020
7047
  }
7021
7048
  this.update();
7022
7049
  }
@@ -7133,7 +7160,9 @@ const debug$7 = Debug.get("Layouter");
7133
7160
  class Layouter {
7134
7161
  constructor(target, userConfig) {
7135
7162
  this.totalTimes = 0;
7136
- this.config = {};
7163
+ this.config = {
7164
+ usePartLayout: true
7165
+ };
7137
7166
  this.__levelList = new LeafLevelList;
7138
7167
  this.target = target;
7139
7168
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -7178,7 +7207,7 @@ class Layouter {
7178
7207
  this.totalTimes++;
7179
7208
  this.layouting = true;
7180
7209
  this.target.emit(WatchEvent.REQUEST);
7181
- if (this.totalTimes > 1) {
7210
+ if (this.totalTimes > 1 && this.config.usePartLayout) {
7182
7211
  this.partLayout();
7183
7212
  } else {
7184
7213
  this.fullLayout();
@@ -7295,7 +7324,7 @@ class Renderer {
7295
7324
  }
7296
7325
  update(change = true) {
7297
7326
  if (!this.changed) this.changed = change;
7298
- this.__requestRender();
7327
+ if (!this.requestTime) this.__requestRender();
7299
7328
  }
7300
7329
  requestLayout() {
7301
7330
  this.target.emit(LayoutEvent.REQUEST);
@@ -7402,7 +7431,7 @@ class Renderer {
7402
7431
  Run.end(t);
7403
7432
  }
7404
7433
  __render(bounds, realBounds) {
7405
- const {canvas: canvas} = this, includes = bounds.includes(this.target.__world), options = includes ? {
7434
+ const {canvas: canvas, target: target} = this, includes = bounds.includes(target.__world), options = includes ? {
7406
7435
  includes: includes
7407
7436
  } : {
7408
7437
  bounds: bounds,
@@ -7410,12 +7439,16 @@ class Renderer {
7410
7439
  };
7411
7440
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
7412
7441
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
7413
- Platform.render(this.target, canvas, options);
7442
+ if (this.config.useCellRender) options.cellList = this.getCellList();
7443
+ Platform.render(target, canvas, options);
7414
7444
  this.renderBounds = realBounds = realBounds || bounds;
7415
7445
  this.renderOptions = options;
7416
7446
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
7417
7447
  canvas.updateRender(realBounds);
7418
7448
  }
7449
+ getCellList() {
7450
+ return undefined;
7451
+ }
7419
7452
  addBlock(block) {
7420
7453
  if (!this.updateBlocks) this.updateBlocks = [];
7421
7454
  this.updateBlocks.push(block);
@@ -8072,6 +8105,11 @@ class TextData extends UIData {
8072
8105
  }
8073
8106
  this._boxStyle = value;
8074
8107
  }
8108
+ __getInputData(names, options) {
8109
+ const data = super.__getInputData(names, options);
8110
+ if (data.textEditing) delete data.textEditing;
8111
+ return data;
8112
+ }
8075
8113
  }
8076
8114
 
8077
8115
  class ImageData extends RectData {
@@ -11411,6 +11449,7 @@ function getLeafPaint(attrName, paint, ui) {
11411
11449
  const {boxBounds: boxBounds} = ui.__layout;
11412
11450
  switch (paint.type) {
11413
11451
  case "image":
11452
+ if (!paint.url) return undefined;
11414
11453
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11415
11454
  break;
11416
11455
 
@@ -11751,7 +11790,7 @@ function layout$3(transform, box, x, y, scaleX, scaleY, rotation, skew) {
11751
11790
  translate(transform, box.x + x, box.y + y);
11752
11791
  }
11753
11792
 
11754
- const {get: get$1, scale: scale$2, copy: copy$4} = MatrixHelper;
11793
+ const {get: get$1, scale: scale$1, copy: copy$4} = MatrixHelper;
11755
11794
 
11756
11795
  const {getFloorScale: getFloorScale} = MathHelper, {abs: abs$6} = Math;
11757
11796
 
@@ -11783,7 +11822,7 @@ function createPattern(paint, ui, canvas, renderOptions) {
11783
11822
  scaleY *= getFloorScale(height + (yGap || 0));
11784
11823
  imageMatrix = get$1();
11785
11824
  if (transform) copy$4(imageMatrix, transform);
11786
- scale$2(imageMatrix, 1 / scaleX, 1 / scaleY);
11825
+ scale$1(imageMatrix, 1 / scaleX, 1 / scaleY);
11787
11826
  }
11788
11827
  const imageCanvas = image.getCanvas(width, height, data.opacity, data.filters, xGap, yGap, ui.leafer && ui.leafer.config.smooth);
11789
11828
  const pattern = image.getPattern(imageCanvas, data.repeat || (Platform.origin.noRepeat || "no-repeat"), imageMatrix, paint);
@@ -11815,7 +11854,7 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
11815
11854
  if (data.repeat) {
11816
11855
  drawImage = false;
11817
11856
  } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
11818
- drawImage = Platform.image.isLarge(image, scaleX, scaleY);
11857
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
11819
11858
  }
11820
11859
  }
11821
11860
  if (drawImage) {
@@ -11874,7 +11913,7 @@ function recycleImage(attrName, data) {
11874
11913
  if (url) {
11875
11914
  if (!recycleMap) recycleMap = {};
11876
11915
  recycleMap[url] = true;
11877
- ImageManager.recycle(image);
11916
+ ImageManager.recyclePaint(paint);
11878
11917
  if (image.loading) {
11879
11918
  if (!input) {
11880
11919
  input = data.__input && data.__input[attrName] || [];
@@ -12892,7 +12931,7 @@ function mergeConfigAttr() {
12892
12931
 
12893
12932
  const {abs: abs$4} = Math;
12894
12933
 
12895
- const {copy: copy$2, scale: scale$1} = MatrixHelper;
12934
+ const {copy: copy$2} = MatrixHelper;
12896
12935
 
12897
12936
  const {setListWithFn: setListWithFn} = BoundsHelper;
12898
12937
 
@@ -12936,19 +12975,10 @@ class Stroker extends UI {
12936
12975
  const aScaleX = abs$4(worldTransform.scaleX), aScaleY = abs$4(worldTransform.scaleY);
12937
12976
  copy$2(matrix$1, worldTransform);
12938
12977
  matrix$1.half = strokeWidth % 2;
12939
- if (aScaleX !== aScaleY) {
12940
- scale$1(matrix$1, 1 / aScaleX, 1 / aScaleY);
12941
- canvas.setWorld(matrix$1, options.matrix);
12942
- canvas.beginPath();
12943
- data.strokeWidth = strokeWidth;
12944
- const {x: x, y: y, width: width, height: height} = leaf.__layout.boxBounds;
12945
- canvas.rect(x * aScaleX, y * aScaleY, width * aScaleX, height * aScaleY);
12946
- } else {
12947
- canvas.setWorld(matrix$1, options.matrix);
12948
- canvas.beginPath();
12949
- if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12950
- data.strokeWidth = strokeWidth / abs$4(worldTransform.scaleX);
12951
- }
12978
+ canvas.setWorld(matrix$1, options.matrix);
12979
+ canvas.beginPath();
12980
+ if (leaf.__.__useArrow) leaf.__drawPath(canvas); else leaf.__.__pathForRender ? leaf.__drawRenderPath(canvas) : leaf.__drawPathByBox(canvas);
12981
+ data.strokeWidth = strokeWidth / Math.max(aScaleX, aScaleY);
12952
12982
  if (stroke) isString(stroke) ? Paint.stroke(stroke, this, canvas, options) : Paint.strokes(stroke, this, canvas, options);
12953
12983
  if (fill) isString(fill) ? Paint.fill(fill, this, canvas, options) : Paint.fills(fill, this, canvas, options);
12954
12984
  }
@@ -19907,4 +19937,4 @@ Plugin.add("bright");
19907
19937
 
19908
19938
  UI.addAttr("bright", false, dimType);
19909
19939
 
19910
- export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
19940
+ export { AlignHelper, Animate, AnimateEasing, AnimateEvent, AnimateList, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, Finder, Flow, FourNumberHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HighBezierHelper, HighCurveHelper, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNodeHandleType, PathNumberCommandLengthMap, PathNumberCommandMap, PathScaler, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, Robot, RobotData, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, TouchEvent, TransformTool, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createAttr, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, dimType, doBoundsType, doStrokeType, effectType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite$1 as isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, motionPathType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleResize, scaleResizeFontSize, scaleResizeGroup, scaleResizePath, scaleResizePoints, scaleType, scrollType, sortType, stateStyleType, stateType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$3 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };