@leafer-ui/display 1.9.4 → 1.9.5

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": "1.9.4",
3
+ "version": "1.9.5",
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": "1.9.4",
26
- "@leafer-ui/data": "1.9.4",
27
- "@leafer-ui/display-module": "1.9.4",
28
- "@leafer-ui/decorator": "1.9.4",
29
- "@leafer-ui/external": "1.9.4"
25
+ "@leafer/core": "1.9.5",
26
+ "@leafer-ui/data": "1.9.5",
27
+ "@leafer-ui/display-module": "1.9.5",
28
+ "@leafer-ui/decorator": "1.9.5",
29
+ "@leafer-ui/external": "1.9.5"
30
30
  },
31
31
  "devDependencies": {
32
- "@leafer/interface": "1.9.4",
33
- "@leafer-ui/interface": "1.9.4"
32
+ "@leafer/interface": "1.9.5",
33
+ "@leafer-ui/interface": "1.9.5"
34
34
  }
35
35
  }
package/src/Box.ts CHANGED
@@ -13,7 +13,7 @@ const rect = Rect.prototype, group = Group.prototype
13
13
 
14
14
  @rewriteAble()
15
15
  @registerUI()
16
- export class Box extends Group implements IBox {
16
+ export class Box<TInputData = IBoxInputData> extends Group<TInputData> implements IBox {
17
17
 
18
18
  public get __tag() { return 'Box' }
19
19
 
@@ -46,7 +46,7 @@ export class Box extends Group implements IBox {
46
46
  public scroller?: IScroller
47
47
  public hasScroller?: boolean
48
48
 
49
- constructor(data?: IBoxInputData) {
49
+ constructor(data?: TInputData) {
50
50
  super(data)
51
51
  this.__layout.renderChanged || this.__layout.renderChange()
52
52
  }
package/src/Canvas.ts CHANGED
@@ -9,7 +9,7 @@ import { Rect } from './Rect'
9
9
 
10
10
 
11
11
  @registerUI()
12
- export class Canvas extends Rect implements ICanvas {
12
+ export class Canvas<TInputData = ICanvasInputData> extends Rect<TInputData> implements ICanvas {
13
13
 
14
14
  public get __tag() { return 'Canvas' }
15
15
 
@@ -42,10 +42,10 @@ export class Canvas extends Rect implements ICanvas {
42
42
 
43
43
  public url?: string // 用于临时加载canvas的base64数据,完成后会置空
44
44
 
45
- constructor(data?: ICanvasInputData) {
45
+ constructor(data?: TInputData) {
46
46
  super(data)
47
47
  this.canvas = Creator.canvas(this.__ as ILeaferCanvasConfig)
48
- if (data && data.url) this.drawImage(data.url)
48
+ if (data && (data as ICanvasInputData).url) this.drawImage((data as ICanvasInputData).url)
49
49
  }
50
50
 
51
51
  public drawImage(url: string): void {
package/src/Ellipse.ts CHANGED
@@ -10,7 +10,7 @@ import { UI } from './UI'
10
10
  const { moveTo, closePath, ellipse } = PathCommandDataHelper
11
11
 
12
12
  @registerUI()
13
- export class Ellipse extends UI implements IEllipse {
13
+ export class Ellipse<TInputData = IEllipseInputData> extends UI<TInputData> implements IEllipse {
14
14
 
15
15
  public get __tag() { return 'Ellipse' }
16
16
 
@@ -26,9 +26,6 @@ export class Ellipse extends UI implements IEllipse {
26
26
  @pathType(0)
27
27
  public endAngle?: INumber
28
28
 
29
- constructor(data?: IEllipseInputData) {
30
- super(data)
31
- }
32
29
 
33
30
  public __updatePath(): void {
34
31
 
package/src/Frame.ts CHANGED
@@ -7,7 +7,7 @@ import { Box } from './Box'
7
7
 
8
8
 
9
9
  @registerUI()
10
- export class Frame extends Box implements IFrame {
10
+ export class Frame<TInputData = IFrameInputData> extends Box<TInputData> implements IFrame {
11
11
 
12
12
  public get __tag() { return 'Frame' }
13
13
 
@@ -22,7 +22,4 @@ export class Frame extends Box implements IFrame {
22
22
  @affectRenderBoundsType('hide')
23
23
  declare public overflow?: IOverflow
24
24
 
25
- constructor(data?: IFrameInputData) {
26
- super(data)
27
- }
28
25
  }
package/src/Group.ts CHANGED
@@ -9,7 +9,7 @@ import { UI } from './UI'
9
9
 
10
10
  @useModule(Branch)
11
11
  @registerUI()
12
- export class Group extends UI implements IGroup { // tip: rewrited Box
12
+ export class Group<TInputData = IGroupInputData> extends UI<TInputData> implements IGroup { // tip: rewrited Box
13
13
 
14
14
  public get __tag() { return 'Group' }
15
15
 
@@ -31,9 +31,6 @@ export class Group extends UI implements IGroup { // tip: rewrited Box
31
31
 
32
32
  public childlessJSON?: boolean
33
33
 
34
- constructor(data?: IGroupInputData) {
35
- super(data)
36
- }
37
34
 
38
35
  public reset(data?: IGroupInputData): void {
39
36
  this.__setBranch()
package/src/Image.ts CHANGED
@@ -8,7 +8,7 @@ import { Rect } from './Rect'
8
8
 
9
9
 
10
10
  @registerUI()
11
- export class Image extends Rect implements IImage {
11
+ export class Image<TInputData = IImageInputData> extends Rect<TInputData> implements IImage {
12
12
 
13
13
  public get __tag() { return 'Image' }
14
14
 
@@ -22,10 +22,6 @@ export class Image extends Rect implements IImage {
22
22
 
23
23
  public get image(): ILeaferImage { const { fill } = this.__; return isArray(fill) && fill[0].image }
24
24
 
25
- constructor(data?: IImageInputData) {
26
- super(data)
27
- }
28
-
29
25
  }
30
26
 
31
27
  export const MyImage = Image
package/src/Leafer.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData, ILeaferType, ICursorType, IBoundsData, INumber, IZoomType, IZoomOptions, IFourNumber, IBounds, IClientPointData, ITransition } from '@leafer/interface'
1
+ import { ILeaferCanvas, IRenderer, ILayouter, ISelector, IWatcher, IInteraction, ILeaferConfig, ICanvasManager, IHitCanvasManager, IAutoBounds, IScreenSizeData, IResizeEvent, IEventListenerId, ITimer, IValue, IObject, IControl, IPointData, ILeaferType, ICursorType, IBoundsData, INumber, IZoomType, IZoomOptions, IFourNumber, IBounds, IClientPointData, ITransition, ICanvasSizeAttr } from '@leafer/interface'
2
2
  import { AutoBounds, LayoutEvent, ResizeEvent, LeaferEvent, CanvasManager, ImageManager, Resource, DataHelper, Creator, Run, Debug, RenderEvent, registerUI, boundsType, canvasSizeAttrs, dataProcessor, WaitHelper, WatchEvent, Bounds, LeafList, Plugin, getBoundsData } from '@leafer/core'
3
3
 
4
4
  import { ILeaferInputData, ILeaferData, IFunction, IUIInputData, ILeafer, IApp, IEditorBase } from '@leafer-ui/interface'
@@ -65,6 +65,7 @@ export class Leafer extends Group implements ILeafer {
65
65
  hittable: true,
66
66
  smooth: true,
67
67
  lazySpeard: 100,
68
+ // maxFPS: 120, // 最大的运行帧率
68
69
  // pixelSnap: false // 是否对齐像素,避免图片存在浮点坐标导致模糊
69
70
  }
70
71
 
@@ -123,7 +124,7 @@ export class Leafer extends Group implements ILeafer {
123
124
  )
124
125
 
125
126
  if (this.isApp) this.__setApp()
126
- this.__checkAutoLayout(config, parentApp)
127
+ this.__checkAutoLayout()
127
128
  this.view = canvas.view
128
129
 
129
130
  // interaction / manager
@@ -247,7 +248,8 @@ export class Leafer extends Group implements ILeafer {
247
248
  this.__level = 1
248
249
  }
249
250
 
250
- protected __checkAutoLayout(config: ILeaferConfig, parentApp?: IApp): void {
251
+ protected __checkAutoLayout(): void {
252
+ const { config, parentApp } = this
251
253
  if (!parentApp) {
252
254
  if (!config.width || !config.height) this.autoLayout = new AutoBounds(config)
253
255
  this.canvas.startAutoLayout(this.autoLayout, this.__onResize.bind(this))
@@ -258,7 +260,7 @@ export class Leafer extends Group implements ILeafer {
258
260
  if (this.canvas) {
259
261
  if (canvasSizeAttrs.includes(attrName)) {
260
262
  // if (!newValue) debug.warn(attrName + ' is 0')
261
- this.__changeCanvasSize(attrName, newValue as number)
263
+ this.__changeCanvasSize(attrName as ICanvasSizeAttr, newValue as number)
262
264
  } else if (attrName === 'fill') {
263
265
  this.__changeFill(newValue as string)
264
266
  } else if (attrName === 'hittable') {
@@ -276,10 +278,11 @@ export class Leafer extends Group implements ILeafer {
276
278
  return super.__getAttr(attrName)
277
279
  }
278
280
 
279
- protected __changeCanvasSize(attrName: string, newValue: number): void {
280
- const data = DataHelper.copyAttrs({}, this.canvas, canvasSizeAttrs)
281
- data[attrName] = (this.config as IObject)[attrName] = newValue
282
- if (newValue) this.canvas.stopAutoLayout()
281
+ protected __changeCanvasSize(attrName: ICanvasSizeAttr, newValue: number): void {
282
+ const { config, canvas } = this
283
+ const data = DataHelper.copyAttrs({}, canvas, canvasSizeAttrs)
284
+ data[attrName] = config[attrName] = newValue
285
+ config.width && config.height ? canvas.stopAutoLayout() : this.__checkAutoLayout()
283
286
  this.__doResize(data as IScreenSizeData)
284
287
  }
285
288
 
@@ -455,10 +458,10 @@ export class Leafer extends Group implements ILeafer {
455
458
  if (!this.parent) {
456
459
  if (this.selector) this.selector.destroy()
457
460
  if (this.hitCanvasManager) this.hitCanvasManager.destroy()
458
- this.canvasManager.destroy()
461
+ if (this.canvasManager) this.canvasManager.destroy()
459
462
  }
460
463
 
461
- this.canvas.destroy()
464
+ if (this.canvas) this.canvas.destroy()
462
465
 
463
466
  this.config.view = this.view = this.parentApp = null
464
467
  if (this.userConfig) this.userConfig.view = null
package/src/Line.ts CHANGED
@@ -1,20 +1,18 @@
1
1
  import { IPointData, INumber } from '@leafer/interface'
2
- import { PathBounds, PathCommandDataHelper, PointHelper, boundsType, pathType, affectStrokeBoundsType, dataProcessor, registerUI, getPointData } from '@leafer/core'
2
+ import { PathCommandDataHelper, PointHelper, boundsType, pathType, affectStrokeBoundsType, dataProcessor, registerUI, getPointData } from '@leafer/core'
3
3
 
4
4
  import { ILine, ILineData, ILineInputData, IStrokeAlign } from '@leafer-ui/interface'
5
5
  import { LineData } from '@leafer-ui/data'
6
6
 
7
7
  import { UI } from './UI'
8
- import { PathArrow } from '@leafer-ui/external'
9
8
 
10
9
 
11
10
  const { moveTo, lineTo, drawPoints } = PathCommandDataHelper
12
11
  const { rotate, getAngle, getDistance, defaultPoint } = PointHelper
13
- const { toBounds } = PathBounds
14
12
 
15
13
 
16
14
  @registerUI()
17
- export class Line extends UI implements ILine { // tip: rewrited Polygon
15
+ export class Line<TInputData = ILineInputData> extends UI<TInputData> implements ILine { // tip: rewrited Polygon
18
16
 
19
17
  public get __tag() { return 'Line' }
20
18
 
@@ -53,10 +51,6 @@ export class Line extends UI implements ILine { // tip: rewrited Polygon
53
51
  }
54
52
 
55
53
 
56
- constructor(data?: ILineInputData) {
57
- super(data)
58
- }
59
-
60
54
  public __updatePath(): void {
61
55
 
62
56
  const data = this.__
@@ -64,7 +58,7 @@ export class Line extends UI implements ILine { // tip: rewrited Polygon
64
58
 
65
59
  if (data.points) {
66
60
 
67
- drawPoints(path, data.points, false, data.closed)
61
+ drawPoints(path, data.points, data.curve, data.closed)
68
62
 
69
63
  } else {
70
64
 
@@ -74,18 +68,4 @@ export class Line extends UI implements ILine { // tip: rewrited Polygon
74
68
 
75
69
  }
76
70
 
77
- public __updateRenderPath(): void {
78
- const data = this.__
79
- if (!this.pathInputed && data.points && data.curve) {
80
- drawPoints(data.__pathForRender = [], data.points, data.curve, data.closed)
81
- if (data.__useArrow) PathArrow.addArrows(this, false)
82
- } else super.__updateRenderPath()
83
- }
84
-
85
- public __updateBoxBounds(): void {
86
- if (this.points) {
87
- toBounds(this.__.__pathForRender, this.__layout.boxBounds)
88
- } else super.__updateBoxBounds()
89
- }
90
-
91
71
  }
package/src/Path.ts CHANGED
@@ -7,7 +7,7 @@ import { UI } from './UI'
7
7
 
8
8
 
9
9
  @registerUI()
10
- export class Path extends UI implements IPath {
10
+ export class Path<TInputData = IPathInputData> extends UI<TInputData> implements IPath {
11
11
 
12
12
  public get __tag() { return 'Path' }
13
13
 
@@ -17,8 +17,4 @@ export class Path extends UI implements IPath {
17
17
  @affectStrokeBoundsType('center')
18
18
  declare public strokeAlign?: IStrokeAlign
19
19
 
20
- constructor(data?: IPathInputData) {
21
- super(data)
22
- }
23
-
24
20
  }
package/src/Pen.ts CHANGED
@@ -8,7 +8,7 @@ import { Path } from './Path'
8
8
 
9
9
  @useModule(PathCreator, ['set', 'path', 'paint'])
10
10
  @registerUI()
11
- export class Pen extends Group implements IPen {
11
+ export class Pen<TInputData = IPenInputData> extends Group<TInputData> implements IPen {
12
12
 
13
13
  public get __tag() { return 'Pen' }
14
14
 
@@ -23,9 +23,6 @@ export class Pen extends Group implements IPen {
23
23
 
24
24
  public __path: IPathCommandData
25
25
 
26
- constructor(data?: IPenInputData) {
27
- super(data)
28
- }
29
26
 
30
27
  public setStyle(data: IPathInputData): Pen {
31
28
  const path = this.pathElement = new Path(data)
package/src/Polygon.ts CHANGED
@@ -14,7 +14,7 @@ const line = Line.prototype
14
14
 
15
15
  @rewriteAble()
16
16
  @registerUI()
17
- export class Polygon extends UI implements IPolygon {
17
+ export class Polygon<TInputData = IPolygonInputData> extends UI<TInputData> implements IPolygon {
18
18
 
19
19
  public get __tag() { return 'Polygon' }
20
20
 
@@ -30,21 +30,19 @@ export class Polygon extends UI implements IPolygon {
30
30
  @pathType(0)
31
31
  public curve?: boolean | number
32
32
 
33
- constructor(data?: IPolygonInputData) {
34
- super(data)
35
- }
36
33
 
37
34
  public __updatePath(): void {
38
35
 
39
- const path: number[] = this.__.path = []
36
+ const data = this.__
37
+ const path: number[] = data.path = []
40
38
 
41
- if (this.__.points) {
39
+ if (data.points) {
42
40
 
43
- drawPoints(path, this.__.points, false, true)
41
+ drawPoints(path, data.points, data.curve, true)
44
42
 
45
43
  } else {
46
44
 
47
- const { width, height, sides } = this.__
45
+ const { width, height, sides } = data
48
46
  const rx = width / 2, ry = height / 2
49
47
 
50
48
  moveTo(path, rx, 0)
package/src/Rect.ts CHANGED
@@ -10,15 +10,11 @@ import { UI } from './UI'
10
10
  @useModule(RectRender)
11
11
  @rewriteAble()
12
12
  @registerUI()
13
- export class Rect extends UI implements IRect { // tip: rewrited Box
13
+ export class Rect<TInputData = IRectInputData> extends UI<TInputData> implements IRect { // tip: rewrited Box
14
14
 
15
15
  public get __tag() { return 'Rect' }
16
16
 
17
17
  @dataProcessor(RectData)
18
18
  declare public __: IRectData
19
19
 
20
- constructor(data?: IRectInputData) {
21
- super(data)
22
- }
23
-
24
20
  }
package/src/Star.ts CHANGED
@@ -12,7 +12,7 @@ const { moveTo, lineTo, closePath } = PathCommandDataHelper
12
12
 
13
13
 
14
14
  @registerUI()
15
- export class Star extends UI implements IStar {
15
+ export class Star<TInputData = IStarInputData> extends UI<TInputData> implements IStar {
16
16
 
17
17
  public get __tag() { return 'Star' }
18
18
 
@@ -25,9 +25,6 @@ export class Star extends UI implements IStar {
25
25
  @pathType(0.382)
26
26
  public innerRadius?: INumber
27
27
 
28
- constructor(data?: IStarInputData) {
29
- super(data)
30
- }
31
28
 
32
29
  public __updatePath() {
33
30
 
package/src/Text.ts CHANGED
@@ -12,7 +12,7 @@ import { UI } from './UI'
12
12
  const { copyAndSpread, includes, spread, setList } = BoundsHelper
13
13
 
14
14
  @registerUI()
15
- export class Text extends UI implements IText {
15
+ export class Text<TConstructorData = ITextInputData> extends UI<TConstructorData> implements IText {
16
16
 
17
17
  public get __tag() { return 'Text' }
18
18
 
@@ -103,10 +103,6 @@ export class Text extends UI implements IText {
103
103
  public get textDrawData(): ITextDrawData { this.updateLayout(); return this.__.__textDrawData }
104
104
 
105
105
 
106
- constructor(data?: ITextInputData) {
107
- super(data)
108
- }
109
-
110
106
  public __updateTextDrawData(): void {
111
107
  const data = this.__
112
108
  const { lineHeight, letterSpacing, fontFamily, fontSize, fontWeight, italic, textCase, textOverflow, padding } = data
package/src/UI.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ILeaferCanvas, IPathDrawer, IPathCommandData, IHitType, INumber, IBoolean, IString, IPathString, IExportFileType, IPointData, ICursorType, IMaskType, IEraserType, IValue, 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, ILeaferImage, IScaleFixed, IDragBoundsType } from '@leafer/interface'
2
2
  import { Leaf, PathDrawer, surfaceType, 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, IArrowType, IFindUIMethod, ILeafer, IEditorConfig, IEditorConfigFunction, IEditToolFunction, IKeyframe, IAnimation, IAnimate, IStates, IStateName, IAnimateType, IStateStyle, IColorString, IAnimateList } 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 } from '@leafer-ui/interface'
5
5
  import { effectType, zoomLayerType } from '@leafer-ui/decorator'
6
6
 
7
7
  import { UIData } from '@leafer-ui/data'
@@ -13,7 +13,7 @@ import { Export, Paint, PathArrow } from '@leafer-ui/external'
13
13
  @useModule(UIBounds)
14
14
  @useModule(UIRender)
15
15
  @rewriteAble()
16
- export class UI extends Leaf implements IUI { // tip: rewrited Box
16
+ export class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements IUI { // tip: rewrited Box
17
17
 
18
18
  @dataProcessor(UIData)
19
19
  declare public __: IUIData
@@ -272,9 +272,9 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
272
272
 
273
273
  // @leafer-in/arrow rewrite
274
274
 
275
- public startArrow?: IArrowType
275
+ public startArrow?: IArrowStyle
276
276
 
277
- public endArrow?: IArrowType
277
+ public endArrow?: IArrowStyle
278
278
 
279
279
  // corner
280
280
 
@@ -399,27 +399,16 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
399
399
  }
400
400
 
401
401
 
402
- constructor(data?: IUIInputData) {
403
- super(data)
404
- }
405
-
406
-
407
402
  // data
408
403
 
409
404
  @rewrite(Leaf.prototype.reset)
410
405
  public reset(_data?: IUIInputData): void { }
411
406
 
412
407
 
413
- public set(data: IUIInputData, transition?: ITransition | 'temp'): void {
414
- if (data) {
415
- if (transition) {
416
- if (transition === 'temp') {
417
- this.lockNormalStyle = true
418
- Object.assign(this, data)
419
- this.lockNormalStyle = false
420
- } else this.animate(data, transition)
421
- } else Object.assign(this, data)
422
- }
408
+ // @leafer-in/animate will rewrite
409
+
410
+ public set(data: IUIInputData, _transition?: ITransition | 'temp'): void {
411
+ if (data) Object.assign(this, data)
423
412
  }
424
413
 
425
414
  public get(name?: string | string[] | IUIInputData): IUIInputData | IValue {
@@ -469,7 +458,7 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
469
458
  const data = this.__
470
459
  if (data.path) {
471
460
  data.__pathForRender = data.cornerRadius ? PathCorner.smooth(data.path, data.cornerRadius, data.cornerSmoothing) : data.path
472
- if (data.__useArrow) PathArrow.addArrows(this, !data.cornerRadius)
461
+ if (data.__useArrow) PathArrow.addArrows(this)
473
462
  } else data.__pathForRender && (data.__pathForRender = undefined)
474
463
  }
475
464
 
@@ -501,7 +490,8 @@ export class UI extends Leaf implements IUI { // tip: rewrited Box
501
490
 
502
491
  // @leafer-in/animate rewrite
503
492
 
504
- public animate(_keyframe?: IUIInputData | IKeyframe[] | IAnimation | IAnimation[], _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate {
493
+ public animate(keyframe?: IUIInputData | IKeyframe[] | IAnimation | IAnimation[], _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate {
494
+ this.set(keyframe as IUIInputData)
505
495
  return Plugin.need('animate')
506
496
  }
507
497
 
package/types/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathCommandObject, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IDragBoundsType, IHitType, ICursorType, IScaleFixed, IFilter, ITransition, IUnitData, IObject, IPointData, IPathCreator, IValue, IFindCondition, ILeaferCanvas, IPathDrawer, ILeaferImage, IExportFileType, IJSONOptions, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, IZoomType, IZoomOptions, IClientPointData, IRenderOptions, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
1
+ import { IString, INumber, IBoolean, IMaskType, IEraserType, IAlign, IUnitPointData, IPathCommandData, IPathCommandObject, IPathString, IWindingRule, IFlowType, IFourNumber, IGap, IPointGap, IFlowAlign, IFlowAxisAlign, IFlowWrap, IFlowBoxType, IAutoSize, IAutoBoxData, IConstraint, IRangeSize, IAxis, IBoundsData, IDragBoundsType, IHitType, ICursorType, IScaleFixed, IFilter, ITransition, IUnitData, IObject, IPointData, IPathCreator, IValue, IFindCondition, ILeaferCanvas, IPathDrawer, ILeaferImage, IExportFileType, IJSONOptions, IPickOptions, IPickResult, IRenderer, IWatcher, ILayouter, ISelector, IInteraction, ICanvasManager, IHitCanvasManager, ILeaferConfig, IAutoBounds, IBounds, IEventListenerId, ITimer, IControl, ILeaferType, IScreenSizeData, IResizeEvent, ICanvasSizeAttr, IZoomType, IZoomOptions, IClientPointData, IRenderOptions, ICanvasContext2DSettings, ICanvasContext2D } from '@leafer/interface';
2
2
  import { Leaf, LeafList } from '@leafer/core';
3
- import { IUI, IUIData, IUIInputData, ILeafer, IGroup, IBlendMode, IFill, IStroke, IStrokeAlign, IStrokeWidthString, IStrokeCap, IStrokeJoin, IDashPatternString, IArrowType, ICornerRadiusString, IShadowEffect, IShadowString, IBlurEffect, IGrayscaleEffect, IAnimation, IStates, IStateName, IStateStyle, IColorString, IEditorConfig, IAnimate, IAnimateList, IFindUIMethod, IKeyframe, IAnimateType, IExportOptions, IExportResult, IEditorConfigFunction, IEditToolFunction, IGroupData, IGroupInputData, IUIJSONData, IFindCondition as IFindCondition$1, ILeaferData, IApp, IEditorBase, IFunction, ILeaferInputData, IBox, IBoxData, IOverflow, IScrollConfig, IScroller, IBoxInputData, IFrame, IFrameData, IFrameInputData, IRect, IRectData, IRectInputData, IEllipse, IEllipseData, IEllipseInputData, IPolygon, IPolygonData, IPolygonInputData, IStar, IStarData, IStarInputData, ILine, ILineData, ILineInputData, IImage, IImageData, IImageInputData, ICanvas, ICanvasData, ICanvasInputData, IText, ITextData, IBackgroundBoxStyle, IHitType as IHitType$1, IFontWeight, ITextCase, ITextDecoration, IWritingMode, ITextAlign, IVerticalAlign, ITextWrap, ITextOverflow, ITextDrawData, ITextInputData, IPath, IPathData, IPathInputData, IPen, IPenData, IPathCommandData as IPathCommandData$1, IPenInputData, IPointData as IPointData$1 } from '@leafer-ui/interface';
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, 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
- declare class UI extends Leaf implements IUI {
5
+ declare class UI<TInputData = IUIInputData> extends Leaf<TInputData> implements IUI {
6
6
  __: IUIData;
7
7
  proxyData?: IUIInputData;
8
8
  __proxyData?: IUIInputData;
@@ -80,8 +80,8 @@ declare class UI extends Leaf implements IUI {
80
80
  dashPattern?: INumber[] | IDashPatternString;
81
81
  dashOffset?: INumber;
82
82
  miterLimit?: INumber;
83
- startArrow?: IArrowType;
84
- endArrow?: IArrowType;
83
+ startArrow?: IArrowStyle;
84
+ endArrow?: IArrowStyle;
85
85
  cornerRadius?: IFourNumber | ICornerRadiusString;
86
86
  cornerSmoothing?: INumber;
87
87
  shadow?: IShadowEffect | IShadowEffect[] | IShadowString;
@@ -124,9 +124,8 @@ declare class UI extends Leaf implements IUI {
124
124
  __box?: IUI;
125
125
  __animate?: IAnimate | IAnimateList;
126
126
  get pen(): IPathCreator;
127
- constructor(data?: IUIInputData);
128
127
  reset(_data?: IUIInputData): void;
129
- set(data: IUIInputData, transition?: ITransition | 'temp'): void;
128
+ set(data: IUIInputData, _transition?: ITransition | 'temp'): void;
130
129
  get(name?: string | string[] | IUIInputData): IUIInputData | IValue;
131
130
  createProxyData(): IUIInputData;
132
131
  find(_condition: number | string | IFindCondition | IFindUIMethod, _options?: any): IUI[];
@@ -143,7 +142,7 @@ declare class UI extends Leaf implements IUI {
143
142
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void;
144
143
  __drawPathByBox(drawer: IPathDrawer): void;
145
144
  drawImagePlaceholder(canvas: ILeaferCanvas, _image?: ILeaferImage): void;
146
- animate(_keyframe?: IUIInputData | IKeyframe[] | IAnimation | IAnimation[], _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate;
145
+ animate(keyframe?: IUIInputData | IKeyframe[] | IAnimation | IAnimation[], _options?: ITransition, _type?: IAnimateType, _isTemp?: boolean): IAnimate;
147
146
  killAnimate(_type?: IAnimateType, _nextStyle?: IUIInputData): void;
148
147
  export(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): Promise<IExportResult>;
149
148
  syncExport(_filename: IExportFileType | string, _options?: IExportOptions | number | boolean): IExportResult;
@@ -157,7 +156,7 @@ declare class UI extends Leaf implements IUI {
157
156
  destroy(): void;
158
157
  }
159
158
 
160
- declare class Group extends UI implements IGroup {
159
+ declare class Group<TInputData = IGroupInputData> extends UI<TInputData> implements IGroup {
161
160
  get __tag(): string;
162
161
  get isBranch(): boolean;
163
162
  __: IGroupData;
@@ -166,7 +165,6 @@ declare class Group extends UI implements IGroup {
166
165
  children: IUI[];
167
166
  topChildren?: IUI[];
168
167
  childlessJSON?: boolean;
169
- constructor(data?: IGroupInputData);
170
168
  reset(data?: IGroupInputData): void;
171
169
  __setBranch(): void;
172
170
  set(data: IUIInputData, transition?: ITransition | 'temp'): void;
@@ -245,10 +243,10 @@ declare class Leafer extends Group implements ILeafer {
245
243
  protected __setApp(): void;
246
244
  protected __bindApp(app: IApp): void;
247
245
  __setLeafer(leafer: ILeafer): void;
248
- protected __checkAutoLayout(config: ILeaferConfig, parentApp?: IApp): void;
246
+ protected __checkAutoLayout(): void;
249
247
  __setAttr(attrName: string, newValue: IValue): boolean;
250
248
  __getAttr(attrName: string): IValue;
251
- protected __changeCanvasSize(attrName: string, newValue: number): void;
249
+ protected __changeCanvasSize(attrName: ICanvasSizeAttr, newValue: number): void;
252
250
  protected __changeFill(newValue: string): void;
253
251
  protected __onCreated(): void;
254
252
  protected __onReady(): void;
@@ -276,7 +274,7 @@ declare class Leafer extends Group implements ILeafer {
276
274
  destroy(sync?: boolean): void;
277
275
  }
278
276
 
279
- declare class Box extends Group implements IBox {
277
+ declare class Box<TInputData = IBoxInputData> extends Group<TInputData> implements IBox {
280
278
  get __tag(): string;
281
279
  get isBranchLeaf(): boolean;
282
280
  __: IBoxData;
@@ -289,7 +287,7 @@ declare class Box extends Group implements IBox {
289
287
  scrollConfig?: IScrollConfig;
290
288
  scroller?: IScroller;
291
289
  hasScroller?: boolean;
292
- constructor(data?: IBoxInputData);
290
+ constructor(data?: TInputData);
293
291
  __updateStrokeSpread(): number;
294
292
  __updateRectRenderSpread(): number;
295
293
  __updateRenderSpread(): number;
@@ -307,53 +305,48 @@ declare class Box extends Group implements IBox {
307
305
  __drawContent(canvas: ILeaferCanvas, options: IRenderOptions): void;
308
306
  }
309
307
 
310
- declare class Frame extends Box implements IFrame {
308
+ declare class Frame<TInputData = IFrameInputData> extends Box<TInputData> implements IFrame {
311
309
  get __tag(): string;
312
310
  get isFrame(): boolean;
313
311
  __: IFrameData;
314
312
  fill?: IFill;
315
313
  overflow?: IOverflow;
316
- constructor(data?: IFrameInputData);
317
314
  }
318
315
 
319
- declare class Rect extends UI implements IRect {
316
+ declare class Rect<TInputData = IRectInputData> extends UI<TInputData> implements IRect {
320
317
  get __tag(): string;
321
318
  __: IRectData;
322
- constructor(data?: IRectInputData);
323
319
  }
324
320
 
325
- declare class Ellipse extends UI implements IEllipse {
321
+ declare class Ellipse<TInputData = IEllipseInputData> extends UI<TInputData> implements IEllipse {
326
322
  get __tag(): string;
327
323
  __: IEllipseData;
328
324
  innerRadius?: INumber;
329
325
  startAngle?: INumber;
330
326
  endAngle?: INumber;
331
- constructor(data?: IEllipseInputData);
332
327
  __updatePath(): void;
333
328
  }
334
329
 
335
- declare class Polygon extends UI implements IPolygon {
330
+ declare class Polygon<TInputData = IPolygonInputData> extends UI<TInputData> implements IPolygon {
336
331
  get __tag(): string;
337
332
  __: IPolygonData;
338
333
  sides?: INumber;
339
334
  points?: number[] | IPointData[];
340
335
  curve?: boolean | number;
341
- constructor(data?: IPolygonInputData);
342
336
  __updatePath(): void;
343
337
  __updateRenderPath(): void;
344
338
  __updateBoxBounds(): void;
345
339
  }
346
340
 
347
- declare class Star extends UI implements IStar {
341
+ declare class Star<TInputData = IStarInputData> extends UI<TInputData> implements IStar {
348
342
  get __tag(): string;
349
343
  __: IStarData;
350
344
  corners?: INumber;
351
345
  innerRadius?: INumber;
352
- constructor(data?: IStarInputData);
353
346
  __updatePath(): void;
354
347
  }
355
348
 
356
- declare class Line extends UI implements ILine {
349
+ declare class Line<TInputData = ILineInputData> extends UI<TInputData> implements ILine {
357
350
  get __tag(): string;
358
351
  __: ILineData;
359
352
  strokeAlign?: IStrokeAlign;
@@ -363,23 +356,19 @@ declare class Line extends UI implements ILine {
363
356
  closed?: boolean;
364
357
  get toPoint(): IPointData;
365
358
  set toPoint(value: IPointData);
366
- constructor(data?: ILineInputData);
367
359
  __updatePath(): void;
368
- __updateRenderPath(): void;
369
- __updateBoxBounds(): void;
370
360
  }
371
361
 
372
- declare class Image extends Rect implements IImage {
362
+ declare class Image<TInputData = IImageInputData> extends Rect<TInputData> implements IImage {
373
363
  get __tag(): string;
374
364
  __: IImageData;
375
365
  url: IString;
376
366
  get ready(): boolean;
377
367
  get image(): ILeaferImage;
378
- constructor(data?: IImageInputData);
379
368
  }
380
369
  declare const MyImage: typeof Image;
381
370
 
382
- declare class Canvas extends Rect implements ICanvas {
371
+ declare class Canvas<TInputData = ICanvasInputData> extends Rect<TInputData> implements ICanvas {
383
372
  get __tag(): string;
384
373
  __: ICanvasData;
385
374
  width?: INumber;
@@ -392,7 +381,7 @@ declare class Canvas extends Rect implements ICanvas {
392
381
  get context(): ICanvasContext2D;
393
382
  get ready(): boolean;
394
383
  url?: string;
395
- constructor(data?: ICanvasInputData);
384
+ constructor(data?: TInputData);
396
385
  drawImage(url: string): void;
397
386
  draw(ui: IUI, offset?: IPointData, scale?: number | IPointData, rotation?: number): void;
398
387
  paint(): void;
@@ -401,7 +390,7 @@ declare class Canvas extends Rect implements ICanvas {
401
390
  destroy(): void;
402
391
  }
403
392
 
404
- declare class Text extends UI implements IText {
393
+ declare class Text<TConstructorData = ITextInputData> extends UI<TConstructorData> implements IText {
405
394
  get __tag(): string;
406
395
  __: ITextData;
407
396
  width?: INumber;
@@ -432,7 +421,6 @@ declare class Text extends UI implements IText {
432
421
  textEditing: boolean;
433
422
  isOverflow: boolean;
434
423
  get textDrawData(): ITextDrawData;
435
- constructor(data?: ITextInputData);
436
424
  __updateTextDrawData(): void;
437
425
  __updateBoxBounds(): void;
438
426
  __onUpdateSize(): void;
@@ -444,21 +432,19 @@ declare class Text extends UI implements IText {
444
432
  destroy(): void;
445
433
  }
446
434
 
447
- declare class Path extends UI implements IPath {
435
+ declare class Path<TInputData = IPathInputData> extends UI<TInputData> implements IPath {
448
436
  get __tag(): string;
449
437
  __: IPathData;
450
438
  strokeAlign?: IStrokeAlign;
451
- constructor(data?: IPathInputData);
452
439
  }
453
440
 
454
- declare class Pen extends Group implements IPen {
441
+ declare class Pen<TInputData = IPenInputData> extends Group<TInputData> implements IPen {
455
442
  get __tag(): string;
456
443
  __: IPenData;
457
444
  pathElement: IPath;
458
445
  pathStyle: IPathInputData;
459
446
  path: IPathCommandData$1;
460
447
  __path: IPathCommandData$1;
461
- constructor(data?: IPenInputData);
462
448
  setStyle(data: IPathInputData): Pen;
463
449
  beginPath(): Pen;
464
450
  moveTo(_x: number, _y: number): Pen;