@leafer-ui/display 2.0.1 → 2.0.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-ui/display",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "@leafer-ui/display",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,14 +22,14 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/core": "2.0.1",
26
- "@leafer-ui/data": "2.0.1",
27
- "@leafer-ui/display-module": "2.0.1",
28
- "@leafer-ui/decorator": "2.0.1",
29
- "@leafer-ui/external": "2.0.1"
25
+ "@leafer/core": "2.0.3",
26
+ "@leafer-ui/data": "2.0.3",
27
+ "@leafer-ui/display-module": "2.0.3",
28
+ "@leafer-ui/decorator": "2.0.3",
29
+ "@leafer-ui/external": "2.0.3"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "2.0.1",
33
- "@leafer-ui/interface": "2.0.1"
32
+ "@leafer/interface": "2.0.3",
33
+ "@leafer-ui/interface": "2.0.3"
34
34
  }
35
35
  }
package/src/Ellipse.ts CHANGED
@@ -29,10 +29,10 @@ export class Ellipse<TInputData = IEllipseInputData> extends UI<TInputData> impl
29
29
 
30
30
  public __updatePath(): void {
31
31
 
32
- const { width, height, innerRadius, startAngle, endAngle } = this.__
32
+ const data = this.__, { width, height, innerRadius, startAngle, endAngle } = data
33
33
  const rx = width / 2, ry = height / 2
34
34
 
35
- const path: number[] = this.__.path = []
35
+ const path: number[] = data.path = []
36
36
  let open: boolean
37
37
 
38
38
  if (innerRadius) {
@@ -63,7 +63,7 @@ export class Ellipse<TInputData = IEllipseInputData> extends UI<TInputData> impl
63
63
  if (!open) closePath(path)
64
64
 
65
65
  // fix node
66
- if (Platform.ellipseToCurve) this.__.path = this.getPath(true)
66
+ if (Platform.ellipseToCurve || data.__useArrow) data.path = this.getPath(true)
67
67
 
68
68
  }
69
69
 
package/src/Group.ts CHANGED
@@ -63,7 +63,10 @@ export class Group<TInputData = IGroupInputData> extends UI<TInputData> implemen
63
63
 
64
64
  override toJSON(options?: IJSONOptions): IUIJSONData {
65
65
  const data = super.toJSON(options)
66
- if (!this.childlessJSON) data.children = this.children.map(child => child.toJSON(options))
66
+ if (!this.childlessJSON) {
67
+ const children: IUIJSONData[] = data.children = []
68
+ this.children.forEach(child => child.skipJSON || children.push(child.toJSON(options)))
69
+ }
67
70
  return data
68
71
  }
69
72
 
package/src/Leafer.ts CHANGED
@@ -72,6 +72,10 @@ export class Leafer extends Group implements ILeafer {
72
72
  // pixelSnap: false // 是否对齐像素,避免图片存在浮点坐标导致模糊
73
73
  }
74
74
 
75
+ // @leafer-in/find will rewrite
76
+ public cacheId?: boolean
77
+ public cacheInnerId?: boolean
78
+
75
79
  public autoLayout?: IAutoBounds
76
80
  public lazyBounds: IBounds
77
81
 
@@ -184,13 +188,13 @@ export class Leafer extends Group implements ILeafer {
184
188
  }
185
189
  }
186
190
 
187
- public unlockLayout(): void {
191
+ public unlockLayout(updateLayout: boolean = true): void {
188
192
  this.layouter.start()
189
- this.updateLayout()
193
+ if (updateLayout) this.updateLayout()
190
194
  }
191
195
 
192
- public lockLayout(): void {
193
- this.updateLayout()
196
+ public lockLayout(updateLayout: boolean = true): void {
197
+ if (updateLayout) this.updateLayout()
194
198
  this.layouter.stop()
195
199
  }
196
200
 
package/src/UI.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ILeaferCanvas, IRenderOptions, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IWindingRule, IPathCreator, IFourNumber, IBoundsData, IFlowType, IGap, IFlowWrap, IAxis, IConstraint, IAutoBoxData, IFlowBoxType, IPointGap, IFlowAlign, IFlowAxisAlign, IFindCondition, IAutoSize, IRangeSize, IAlign, IUnitPointData, IObject, IScaleData, IUnitData, IPathCommandObject, ITransition, IFilter, IScaleFixed, IDragBoundsType, IPathCommandNode } from '@leafer/interface'
2
2
  import { Leaf, PathDrawer, surfaceType, dimType, dataType, positionType, scrollType, boundsType, pathType, scaleType, rotationType, opacityType, visibleType, sortType, maskType, dataProcessor, registerUI, useModule, rewrite, rewriteAble, UICreator, PathCorner, hitType, strokeType, PathConvert, eraserType, cursorType, autoLayoutType, pen, naturalBoundsType, pathInputType, MathHelper, Plugin, DataHelper, affectRenderBoundsType, isString, isNumber } from '@leafer/core'
3
3
 
4
- import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowStyle, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction, IKeyframe, IAnimation, IAnimate, IStates, IStateName, IAnimateType, IStateStyle, IColorString, IAnimateList, ILeafPaint } from '@leafer-ui/interface'
4
+ import { IUI, IShadowEffect, IBlurEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IBlendMode, IDashPatternString, IShadowString, IGrayscaleEffect, IUIData, IGroup, IStrokeWidthString, ICornerRadiusString, IUIInputData, IExportOptions, IExportResult, IFill, IStroke, IArrowStyle, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction, IKeyframe, IAnimation, IAnimate, IStates, IStateName, IAnimateType, IStateStyle, IColorString, IAnimateList, ILeafPaint, ILinker } from '@leafer-ui/interface'
5
5
  import { effectType, zoomLayerType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
@@ -33,6 +33,10 @@ export class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements I
33
33
 
34
34
  declare public children?: IUI[]
35
35
 
36
+ // linker
37
+ public startLinker?: ILinker[]
38
+ public endLinker?: ILinker[]
39
+
36
40
  // ---
37
41
 
38
42
  // id
@@ -259,7 +263,11 @@ export class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements I
259
263
  public strokeWidth?: IFourNumber | IStrokeWidthString
260
264
 
261
265
  @strokeType(false)
262
- public strokeWidthFixed?: IScaleFixed
266
+ public strokeScaleFixed?: IScaleFixed
267
+
268
+ // 未来将移除,请用 strokeScaleFixed 代替
269
+ public set strokeWidthFixed(value: IScaleFixed) { this.strokeScaleFixed = value }
270
+ public get strokeWidthFixed(): IScaleFixed { return this.strokeScaleFixed }
263
271
 
264
272
  @strokeType('none')
265
273
  public strokeCap?: IStrokeCap
@@ -312,6 +320,11 @@ export class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements I
312
320
  public filter?: IFilter | IFilter[]
313
321
 
314
322
 
323
+ // need rewrite
324
+
325
+ public complex?: boolean
326
+
327
+
315
328
  // @leafer-in/animate rewrite
316
329
 
317
330
  public animation?: IAnimation | IAnimation[]
@@ -449,6 +462,9 @@ export class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements I
449
462
  return PathConvert.stringify(this.getPath(curve, pathForRender), floatLength)
450
463
  }
451
464
 
465
+ public asPath(curve?: boolean, pathForRender?: boolean): void {
466
+ this.path = this.getPath(curve, pathForRender)
467
+ }
452
468
 
453
469
  public load(): void {
454
470
  this.__.__computePaint() // 手动加载图片
@@ -461,17 +477,19 @@ export class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements I
461
477
  }
462
478
  }
463
479
 
464
- public __updateRenderPath(): void {
480
+ public __updateRenderPath(updateCache?: boolean): void {
465
481
  const data = this.__
466
482
  if (data.path) {
467
483
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path
468
- if (data.__useArrow) PathArrow.addArrows(this)
484
+ if (data.__useArrow) PathArrow.addArrows(this, updateCache)
469
485
  } else data.__pathForRender && (data.__pathForRender = undefined)
470
486
  }
471
487
 
472
488
  public __drawRenderPath(canvas: ILeaferCanvas): void {
489
+ const data = this.__
473
490
  canvas.beginPath()
474
- this.__drawPathByData(canvas, this.__.__pathForRender)
491
+ if (data.__useArrow) PathArrow.updateArrow(this)
492
+ this.__drawPathByData(canvas, data.__pathForRender)
475
493
  }
476
494
 
477
495
  public __drawPath(canvas: ILeaferCanvas): void {
@@ -547,9 +565,10 @@ export class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements I
547
565
 
548
566
 
549
567
  public destroy(): void {
568
+ this.__.__willDestroy = true
550
569
  this.fill = this.stroke = null
551
570
  if (this.__animate) this.killAnimate()
552
571
  super.destroy()
553
572
  }
554
573
 
555
- }
574
+ }
package/types/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { IString, INumber, IBoolean, IMaskType, IEraserType, IScaleFixed, IAlign, IUnitPointData, IFourNumber, IPathCommandData, IPathCommandNode, IPathCommandObject, IPathString, IWindingRule, IFlowType, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IDragBoundsType, IHitType, ICursorType, IFilter, ITransition, IUnitData, IObject, IPointData, IPathCreator, IFindCondition, ILeaferCanvas, IPathDrawer, IRenderOptions, IExportFileType, IJSONOptions, IPickOptions, IPickResult, ILeaferMode, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IValue, ICanvasSizeAttr, IZoomType, IZoomOptions, IClientPointData, ILeaferImage, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
2
2
  import { Leaf, LeafList } from '@leafer/core';
3
- import { IUIInputData, IUI, IUIData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowStyle, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IAnimation, IStates, IStateName, IStateStyle, IColorString, IEditorConfig, IAnimate, IAnimateList, IFindUIMethod, ILeafPaint, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupInputData, IGroupData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBoxInputData, IBox, IBoxData, IOverflow, IScrollConfig, IScroller, IFrameInputData, IFrame, IFrameData, IRectInputData, IRect, IRectData, IEllipseInputData, IEllipse, IEllipseData, IPolygonInputData, IPolygon, IPolygonData, IStarInputData, IStar, IStarData, ILineInputData, ILine, ILineData, IImageInputData, IImage, IImageData, ICanvasInputData, ICanvas, ICanvasData, ITextInputData, IText, ITextData, IBackgroundBoxStyle, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IWritingMode, ITextAlign, IVerticalAlign, ITextWrap, ITextOverflow, ITextDrawData, IPathInputData, IPath, IPathData, IPenInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPointData as IPointData$1 } from '@leafer-ui/interface';
3
+ import { IUIInputData, IUI, IUIData, ILeafer, IGroup, ILinker, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowStyle, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IAnimation, IStates, IStateName, IStateStyle, IColorString, IEditorConfig, IAnimate, IAnimateList, IFindUIMethod, ILeafPaint, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupInputData, IGroupData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBoxInputData, IBox, IBoxData, IOverflow, IScrollConfig, IScroller, IFrameInputData, IFrame, IFrameData, IRectInputData, IRect, IRectData, IEllipseInputData, IEllipse, IEllipseData, IPolygonInputData, IPolygon, IPolygonData, IStarInputData, IStar, IStarData, ILineInputData, ILine, ILineData, IImageInputData, IImage, IImageData, ICanvasInputData, ICanvas, ICanvasData, ITextInputData, IText, ITextData, IBackgroundBoxStyle, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IWritingMode, ITextAlign, IVerticalAlign, ITextWrap, ITextOverflow, ITextDrawData, IPathInputData, IPath, IPathData, IPenInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPointData as IPointData$1 } from '@leafer-ui/interface';
4
4
 
5
5
  declare class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements IUI {
6
6
  __: IUIData;
@@ -12,6 +12,8 @@ declare class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements
12
12
  zoomLayer: IGroup;
13
13
  get isFrame(): boolean;
14
14
  children?: IUI[];
15
+ startLinker?: ILinker[];
16
+ endLinker?: ILinker[];
15
17
  id?: IString;
16
18
  name?: IString;
17
19
  className?: IString;
@@ -76,7 +78,9 @@ declare class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements
76
78
  stroke?: IStroke;
77
79
  strokeAlign?: IStrokeAlign;
78
80
  strokeWidth?: IFourNumber | IStrokeWidthString;
79
- strokeWidthFixed?: IScaleFixed;
81
+ strokeScaleFixed?: IScaleFixed;
82
+ set strokeWidthFixed(value: IScaleFixed);
83
+ get strokeWidthFixed(): IScaleFixed;
80
84
  strokeCap?: IStrokeCap;
81
85
  strokeJoin?: IStrokeJoin;
82
86
  dashPattern?: INumber[] | IDashPatternString;
@@ -92,6 +96,7 @@ declare class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements
92
96
  backgroundBlur?: INumber | IBlurEffect;
93
97
  grayscale?: INumber | IGrayscaleEffect;
94
98
  filter?: IFilter | IFilter[];
99
+ complex?: boolean;
95
100
  animation?: IAnimation | IAnimation[];
96
101
  animationOut?: IAnimation | IAnimation[];
97
102
  transition?: ITransition;
@@ -136,9 +141,10 @@ declare class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements
136
141
  findId(id: number | string): IUI | undefined;
137
142
  getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData;
138
143
  getPathString(curve?: boolean, pathForRender?: boolean, floatLength?: number): IPathString;
144
+ asPath(curve?: boolean, pathForRender?: boolean): void;
139
145
  load(): void;
140
146
  __onUpdateSize(): void;
141
- __updateRenderPath(): void;
147
+ __updateRenderPath(updateCache?: boolean): void;
142
148
  __drawRenderPath(canvas: ILeaferCanvas): void;
143
149
  __drawPath(canvas: ILeaferCanvas): void;
144
150
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData, ignoreCornerRadius?: boolean): void;
@@ -213,6 +219,8 @@ declare class Leafer extends Group implements ILeafer {
213
219
  editor: IEditorBase;
214
220
  userConfig: ILeaferConfig;
215
221
  config: ILeaferConfig;
222
+ cacheId?: boolean;
223
+ cacheInnerId?: boolean;
216
224
  autoLayout?: IAutoBounds;
217
225
  lazyBounds: IBounds;
218
226
  get FPS(): number;
@@ -234,8 +242,8 @@ declare class Leafer extends Group implements ILeafer {
234
242
  set(data: IUIInputData, transition?: ITransition | 'temp'): void;
235
243
  start(): void;
236
244
  stop(): void;
237
- unlockLayout(): void;
238
- lockLayout(): void;
245
+ unlockLayout(updateLayout?: boolean): void;
246
+ lockLayout(updateLayout?: boolean): void;
239
247
  resize(size: IScreenSizeData): void;
240
248
  forceRender(bounds?: IBoundsData, sync?: boolean): void;
241
249
  requestRender(change?: boolean): void;