leafer-ui 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
  const debug$5 = Debug.get("LeaferCanvas");
6861
6886
 
@@ -7178,7 +7203,7 @@ class Watcher {
7178
7203
  return this.hasAdd || this.hasRemove || this.hasVisible;
7179
7204
  }
7180
7205
  get updatedList() {
7181
- if (this.hasRemove) {
7206
+ if (this.hasRemove && this.config.usePartLayout) {
7182
7207
  const updatedList = new LeafList;
7183
7208
  this.__updatedList.list.forEach(item => {
7184
7209
  if (item.leafer) updatedList.add(item);
@@ -7213,16 +7238,18 @@ class Watcher {
7213
7238
  if (this.running) this.target.emit(RenderEvent.REQUEST);
7214
7239
  }
7215
7240
  __onAttrChange(event) {
7216
- this.__updatedList.add(event.target);
7241
+ if (this.config.usePartLayout) this.__updatedList.add(event.target);
7217
7242
  this.update();
7218
7243
  }
7219
7244
  __onChildEvent(event) {
7220
- if (event.type === ChildEvent.ADD) {
7221
- this.hasAdd = true;
7222
- this.__pushChild(event.child);
7223
- } else {
7224
- this.hasRemove = true;
7225
- this.__updatedList.add(event.parent);
7245
+ if (this.config.usePartLayout) {
7246
+ if (event.type === ChildEvent.ADD) {
7247
+ this.hasAdd = true;
7248
+ this.__pushChild(event.child);
7249
+ } else {
7250
+ this.hasRemove = true;
7251
+ this.__updatedList.add(event.parent);
7252
+ }
7226
7253
  }
7227
7254
  this.update();
7228
7255
  }
@@ -7339,7 +7366,9 @@ const debug$4 = Debug.get("Layouter");
7339
7366
  class Layouter {
7340
7367
  constructor(target, userConfig) {
7341
7368
  this.totalTimes = 0;
7342
- this.config = {};
7369
+ this.config = {
7370
+ usePartLayout: true
7371
+ };
7343
7372
  this.__levelList = new LeafLevelList;
7344
7373
  this.target = target;
7345
7374
  if (userConfig) this.config = DataHelper.default(userConfig, this.config);
@@ -7384,7 +7413,7 @@ class Layouter {
7384
7413
  this.totalTimes++;
7385
7414
  this.layouting = true;
7386
7415
  this.target.emit(WatchEvent.REQUEST);
7387
- if (this.totalTimes > 1) {
7416
+ if (this.totalTimes > 1 && this.config.usePartLayout) {
7388
7417
  this.partLayout();
7389
7418
  } else {
7390
7419
  this.fullLayout();
@@ -7501,7 +7530,7 @@ class Renderer {
7501
7530
  }
7502
7531
  update(change = true) {
7503
7532
  if (!this.changed) this.changed = change;
7504
- this.__requestRender();
7533
+ if (!this.requestTime) this.__requestRender();
7505
7534
  }
7506
7535
  requestLayout() {
7507
7536
  this.target.emit(LayoutEvent.REQUEST);
@@ -7608,7 +7637,7 @@ class Renderer {
7608
7637
  Run.end(t);
7609
7638
  }
7610
7639
  __render(bounds, realBounds) {
7611
- const {canvas: canvas} = this, includes = bounds.includes(this.target.__world), options = includes ? {
7640
+ const {canvas: canvas, target: target} = this, includes = bounds.includes(target.__world), options = includes ? {
7612
7641
  includes: includes
7613
7642
  } : {
7614
7643
  bounds: bounds,
@@ -7616,12 +7645,16 @@ class Renderer {
7616
7645
  };
7617
7646
  if (this.needFill) canvas.fillWorld(bounds, this.config.fill);
7618
7647
  if (Debug.showRepaint) Debug.drawRepaint(canvas, bounds);
7619
- Platform.render(this.target, canvas, options);
7648
+ if (this.config.useCellRender) options.cellList = this.getCellList();
7649
+ Platform.render(target, canvas, options);
7620
7650
  this.renderBounds = realBounds = realBounds || bounds;
7621
7651
  this.renderOptions = options;
7622
7652
  this.totalBounds.isEmpty() ? this.totalBounds = realBounds : this.totalBounds.add(realBounds);
7623
7653
  canvas.updateRender(realBounds);
7624
7654
  }
7655
+ getCellList() {
7656
+ return undefined;
7657
+ }
7625
7658
  addBlock(block) {
7626
7659
  if (!this.updateBlocks) this.updateBlocks = [];
7627
7660
  this.updateBlocks.push(block);
@@ -8278,6 +8311,11 @@ class TextData extends UIData {
8278
8311
  }
8279
8312
  this._boxStyle = value;
8280
8313
  }
8314
+ __getInputData(names, options) {
8315
+ const data = super.__getInputData(names, options);
8316
+ if (data.textEditing) delete data.textEditing;
8317
+ return data;
8318
+ }
8281
8319
  }
8282
8320
 
8283
8321
  class ImageData extends RectData {
@@ -11945,6 +11983,7 @@ function getLeafPaint(attrName, paint, ui) {
11945
11983
  const {boxBounds: boxBounds} = ui.__layout;
11946
11984
  switch (paint.type) {
11947
11985
  case "image":
11986
+ if (!paint.url) return undefined;
11948
11987
  leafPaint = PaintImage.image(ui, attrName, paint, boxBounds, !recycleMap || !recycleMap[paint.url]);
11949
11988
  break;
11950
11989
 
@@ -12349,7 +12388,7 @@ function checkImage(paint, drawImage, ui, canvas, renderOptions) {
12349
12388
  if (data.repeat) {
12350
12389
  drawImage = false;
12351
12390
  } else if (!(originPaint.changeful || Platform.name === "miniapp" && ResizeEvent.isResizing(ui) || exporting)) {
12352
- drawImage = Platform.image.isLarge(image, scaleX, scaleY);
12391
+ drawImage = Platform.image.isLarge(image, scaleX, scaleY) || image.width * scaleX > 8096 || image.height * scaleY > 8096;
12353
12392
  }
12354
12393
  }
12355
12394
  if (drawImage) {
@@ -12408,7 +12447,7 @@ function recycleImage(attrName, data) {
12408
12447
  if (url) {
12409
12448
  if (!recycleMap) recycleMap = {};
12410
12449
  recycleMap[url] = true;
12411
- ImageManager.recycle(image);
12450
+ ImageManager.recyclePaint(paint);
12412
12451
  if (image.loading) {
12413
12452
  if (!input) {
12414
12453
  input = data.__input && data.__input[attrName] || [];
@@ -13324,4 +13363,4 @@ Object.assign(Creator, {
13324
13363
 
13325
13364
  useCanvas();
13326
13365
 
13327
- export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathCommandNodeHelper, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, 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, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };
13366
+ export { AlignHelper, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragBoundsHelper, DragEvent$1 as DragEvent, Dragger, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Filter, FourNumberHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, Line, LineData, MathHelper, Matrix, MatrixHelper, MoveEvent, MyDragEvent, MyImage, MyPointerEvent, MyTouchEvent, 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, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent$1 as PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, Resource, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TouchEvent, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, affectRenderBoundsType, affectStrokeBoundsType, 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, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, path, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds$2 as tempBounds, tempMatrix$2 as tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useCanvas, useModule, version, visibleType, zoomLayerType };