@leafer-ui/interface 1.0.0-rc.1 → 1.0.0-rc.11

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/interface",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.11",
4
4
  "description": "@leafer-ui/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -22,6 +22,6 @@
22
22
  "leaferjs"
23
23
  ],
24
24
  "dependencies": {
25
- "@leafer/interface": "1.0.0-rc.1"
25
+ "@leafer/interface": "1.0.0-rc.11"
26
26
  }
27
27
  }
@@ -1,15 +1,17 @@
1
- import { IPaint, IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect, ITextAlign, IVerticalAlign, IOverflow, IUnitData } from './type/IType'
1
+ import { INumber, IBoolean, IString } from '@leafer/interface'
2
+ import { IStrokeAlign, IStrokeCap, IStrokeJoin, IBlurEffect, IFontWeight, ITextCase, ITextDecoration, IShadowEffect, IGrayscaleEffect, ITextAlign, IVerticalAlign, IOverflow, IUnitData, ITextWrap, IStroke, IFill, IArrowType } from './type/IType'
2
3
  import { ILeafStrokePaint, ILeafShadowEffect, ILeafPaint } from './type/IComputedType'
3
- import { IPaintString, IDashPatternString, IShadowString, IColorString, IStrokeWidthString, ICornerRadiusString } from './type/IStringType'
4
+ import { IDashPatternString, IShadowString, IColorString, IStrokeWidthString, ICornerRadiusString } from './type/IStringType'
5
+
4
6
 
5
7
  // corner---
6
8
  export interface ICornerRadiusAttrData {
7
- cornerRadius: number | number[] | ICornerRadiusString
8
- cornerSmoothing: number
9
+ cornerRadius: INumber | INumber[] | ICornerRadiusString
10
+ cornerSmoothing: INumber
9
11
  }
10
12
  export interface ICornerRadiusInputData {
11
- cornerRadius?: number | number[] | ICornerRadiusString
12
- cornerSmoothing?: number
13
+ cornerRadius?: INumber | INumber[] | ICornerRadiusString
14
+ cornerSmoothing?: INumber
13
15
  }
14
16
  export interface ICornerRadiusComputedData {
15
17
  cornerRadius?: number
@@ -18,10 +20,10 @@ export interface ICornerRadiusComputedData {
18
20
 
19
21
  // fill---
20
22
  export interface IFillAttrData {
21
- fill: IPaint | IPaint[] | IPaintString
23
+ fill: IFill
22
24
  }
23
25
  export interface IFillInputData {
24
- fill?: IPaint | IPaint[] | IPaintString
26
+ fill?: IFill
25
27
  }
26
28
  export interface IFillComputedData {
27
29
  fill?: IColorString | ILeafPaint[]
@@ -35,26 +37,34 @@ export interface IBorderComputedData {
35
37
 
36
38
  // stroke---
37
39
  export interface IStrokeAttrData {
38
- stroke: IPaint | IPaint[] | IPaintString
40
+ stroke: IStroke
39
41
 
40
42
  strokeAlign: IStrokeAlign
41
- strokeWidth: number | number[] | IStrokeWidthString
43
+ strokeWidth: INumber | INumber[] | IStrokeWidthString
44
+ strokeWidthFixed: IBoolean
42
45
  strokeCap: IStrokeCap
43
46
  strokeJoin: IStrokeJoin
44
- dashPattern: number[] | IDashPatternString
45
- dashOffset: number
46
- miterLimit: number
47
+ dashPattern: INumber[] | IDashPatternString
48
+ dashOffset: INumber
49
+ miterLimit: INumber
50
+
51
+ startArrow: IArrowType
52
+ endArrow: IArrowType
47
53
  }
48
54
  export interface IStrokeInputData {
49
- stroke?: IPaint | IPaint[] | IPaintString
55
+ stroke?: IStroke
50
56
 
51
57
  strokeAlign?: IStrokeAlign
52
- strokeWidth?: number | number[] | IStrokeWidthString
58
+ strokeWidth?: INumber | INumber[] | IStrokeWidthString
59
+ strokeWidthFixed?: IBoolean
53
60
  strokeCap?: IStrokeCap
54
61
  strokeJoin?: IStrokeJoin
55
- dashPattern?: number[] | IDashPatternString
56
- dashOffset?: number
57
- miterLimit?: number
62
+ dashPattern?: INumber[] | IDashPatternString
63
+ dashOffset?: INumber
64
+ miterLimit?: INumber
65
+
66
+ startArrow?: IArrowType
67
+ endArrow?: IArrowType
58
68
  }
59
69
  export interface IStrokeComputedData {
60
70
  stroke?: IColorString | ILeafStrokePaint[]
@@ -62,6 +72,7 @@ export interface IStrokeComputedData {
62
72
  strokeAlign?: IStrokeAlign
63
73
  strokeWidth?: number
64
74
  strokeWidths?: number[]
75
+ strokeWidthFixed?: boolean
65
76
  strokeCap?: IStrokeCap
66
77
  strokeJoin?: IStrokeJoin
67
78
  dashPattern?: number[]
@@ -71,39 +82,41 @@ export interface IStrokeComputedData {
71
82
 
72
83
  // text---
73
84
  export interface ITextStyleAttrData {
74
- fontFamily: string
75
- fontSize: number
85
+ fontFamily: IString
86
+ fontSize: INumber
76
87
  fontWeight: IFontWeight
77
- italic: boolean
88
+ italic: IBoolean
78
89
  textCase: ITextCase
79
90
  textDecoration: ITextDecoration
80
- letterSpacing: number | IUnitData
81
- lineHeight: number | IUnitData
91
+ letterSpacing: INumber | IUnitData
92
+ lineHeight: INumber | IUnitData
82
93
 
83
- paraIndent: number
84
- paraSpacing: number
94
+ paraIndent: INumber
95
+ paraSpacing: INumber
85
96
 
86
97
  textAlign: ITextAlign
87
98
  verticalAlign: IVerticalAlign
88
99
 
100
+ textWrap: ITextWrap
89
101
  textOverflow: IOverflow | string
90
102
  }
91
103
  export interface ITextStyleInputData {
92
- fontFamily?: string
93
- fontSize?: number
104
+ fontFamily?: IString
105
+ fontSize?: INumber
94
106
  fontWeight?: IFontWeight
95
- italic?: boolean
107
+ italic?: IBoolean
96
108
  textCase?: ITextCase
97
109
  textDecoration?: ITextDecoration
98
- letterSpacing?: number | IUnitData
99
- lineHeight?: number | IUnitData
110
+ letterSpacing?: INumber | IUnitData
111
+ lineHeight?: INumber | IUnitData
100
112
 
101
- paraIndent?: number
102
- paraSpacing?: number
113
+ paraIndent?: INumber
114
+ paraSpacing?: INumber
103
115
 
104
116
  textAlign?: ITextAlign
105
117
  verticalAlign?: IVerticalAlign
106
118
 
119
+ textWrap?: ITextWrap
107
120
  textOverflow?: IOverflow | string
108
121
  }
109
122
  export interface ITextStyleComputedData {
@@ -121,23 +134,25 @@ export interface ITextStyleComputedData {
121
134
 
122
135
  textAlign?: ITextAlign
123
136
  verticalAlign?: IVerticalAlign
124
- textOverflow?: IOverflow
137
+
138
+ textWrap?: ITextWrap
139
+ textOverflow?: IOverflow | string
125
140
  }
126
141
 
127
142
  // effect---
128
143
  export interface IEffectAttrData {
129
144
  shadow: IShadowEffect | IShadowEffect[] | IShadowString
130
145
  innerShadow: IShadowEffect | IShadowEffect[] | IShadowString
131
- blur: number | IBlurEffect
132
- backgroundBlur: number | IBlurEffect
133
- grayscale: number | IGrayscaleEffect
146
+ blur: INumber | IBlurEffect
147
+ backgroundBlur: INumber | IBlurEffect
148
+ grayscale: INumber | IGrayscaleEffect
134
149
  }
135
150
  export interface IEffectInputData {
136
151
  shadow?: IShadowEffect | IShadowEffect[] | IShadowString
137
152
  innerShadow?: IShadowEffect | IShadowEffect[] | IShadowString
138
- blur?: number | IBlurEffect
139
- backgroundBlur?: number | IBlurEffect
140
- grayscale?: number | IGrayscaleEffect
153
+ blur?: INumber | IBlurEffect
154
+ backgroundBlur?: INumber | IBlurEffect
155
+ grayscale?: INumber | IGrayscaleEffect
141
156
  }
142
157
  export interface IEffectComputedData {
143
158
  shadow?: ILeafShadowEffect[]
package/src/IUI.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, __Number, IPathString, ILeaferImage, IBlob, IPathCreator } from '@leafer/interface'
1
+ import { ILeaf, ILeafComputedData, ILeafData, ILeafInputData, ILeaferCanvas, IRenderOptions, IExportOptions, IExportResult, IPathDrawer, IPointData, IPath2D, IPathCommandData, IWindingRule, ILeaferImageConfig, IBoundsData, IObject, IPathString, ILeaferImage, IPathCreator, IAnswer, IPickOptions, IPickResult } from '@leafer/interface'
2
2
 
3
3
  import {
4
4
  IFillAttrData, IFillInputData, IFillComputedData,
@@ -9,8 +9,7 @@ import {
9
9
  ITextStyleAttrData, ITextStyleInputData, ITextStyleComputedData
10
10
  } from './ICommonAttr'
11
11
  import { IOverflow } from './type/IType'
12
- import { IExportOptions } from './module/IExport'
13
-
12
+ import { ILeafer } from './app/ILeafer'
14
13
 
15
14
  // Line
16
15
  export interface ILine extends IUI {
@@ -19,12 +18,26 @@ export interface ILine extends IUI {
19
18
  points: number[]
20
19
  curve: boolean | number
21
20
  }
22
- export interface ILineData extends IUIData { }
23
- export interface ILineInputData extends IUIBaseInputData {
21
+
22
+ interface ILineAttrData {
24
23
  toPoint?: IPointData
25
24
  points?: number[]
26
25
  curve?: boolean | number
27
26
  }
27
+ export interface ILineData extends ILineAttrData, IUIData { }
28
+ export interface ILineInputData extends ILineAttrData, IUIBaseInputData { }
29
+
30
+
31
+ // Arrow
32
+ export interface IArrow extends ILine {
33
+ __: IArrowData
34
+ }
35
+
36
+ interface IArrowAttrData {
37
+
38
+ }
39
+ export interface IArrowData extends IArrowAttrData, ILineData { }
40
+ export interface IArrowInputData extends IArrowAttrData, IUIBaseInputData { }
28
41
 
29
42
 
30
43
  // Rect
@@ -124,6 +137,9 @@ export interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIDat
124
137
  __baseLine?: number
125
138
  __lineHeight?: number
126
139
  __letterSpacing?: number
140
+ __padding?: number[]
141
+ __clipText?: boolean
142
+ __textBoxBounds?: IBoundsData
127
143
  }
128
144
  export interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIBaseInputData {
129
145
 
@@ -138,9 +154,13 @@ export interface ITextRowData {
138
154
  data?: ITextCharData[]
139
155
  words?: ITextWordData[]
140
156
 
157
+ startCharSize?: number
158
+ endCharSize?: number
159
+
141
160
  paraStart?: boolean // paragraph start
142
161
  paraEnd?: boolean // paragraph end
143
162
  isOverflow?: boolean
163
+ textMode?: boolean
144
164
  }
145
165
 
146
166
  export interface ITextWordData {
@@ -179,7 +199,9 @@ export interface IImage extends IRect, ILeaferImageConfig {
179
199
  interface IImageAttrData {
180
200
  url?: string
181
201
  }
182
- export interface IImageData extends IImageAttrData, IRectData { }
202
+ export interface IImageData extends IImageAttrData, IRectData {
203
+ __setImageFill(value: string): void
204
+ }
183
205
  export interface IImageInputData extends IImageAttrData, IUIBaseInputData { }
184
206
 
185
207
  export interface ICanvas extends IRect {
@@ -206,6 +228,12 @@ export interface ILeaferInputData extends IGroupInputData {
206
228
  pixelRatio?: number
207
229
  }
208
230
 
231
+ export interface IAppData extends ILeaferData {
232
+
233
+ }
234
+ export interface IAppInputData extends ILeaferInputData {
235
+
236
+ }
209
237
 
210
238
  // Frame
211
239
  export interface IFrame extends IBox {
@@ -238,13 +266,15 @@ export interface IBoxInputData extends IGroupInputData {
238
266
  export interface IGroup extends IUI {
239
267
  __: IGroupData
240
268
  children: IUI[]
241
- mask?: IUI
269
+ pick(hitPoint: IPointData, options?: IPickOptions): IPickResult
242
270
  add(child: IUI, index?: number): void
243
271
  addAt(child: IUI, index: number): void
244
272
  addAfter(child: IUI, after: IUI): void
245
273
  addBefore(child: IUI, before: IUI): void
274
+ addMany(...children: ILeaf[]): void
246
275
  remove(child?: IUI): void
247
276
  removeAll(): void
277
+ clear(): void
248
278
  }
249
279
  export interface IGroupData extends IUIData { }
250
280
  export interface IGroupInputData extends IUIBaseInputData { }
@@ -252,20 +282,41 @@ export interface IGroupInputData extends IUIBaseInputData { }
252
282
  // UI
253
283
  export interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
254
284
  __: IUIData
285
+
286
+ readonly app: ILeafer
287
+ leafer?: ILeafer
255
288
  parent?: IGroup
289
+ isFrame?: boolean
290
+
291
+ proxyData: IUIInputData
292
+ __proxyData?: IUIInputData
293
+
294
+ children?: IUI[]
295
+
296
+ reset(data?: IUIInputData): void
256
297
 
257
298
  set(data: IUIInputData): void
258
299
  toJSON(): IUIInputData
259
300
 
260
- getPath(curve?: boolean): IPathCommandData
261
- getPathString(curve?: boolean): IPathString
301
+ get(): IUIInputData
302
+ createProxyData(): IUIInputData
303
+
304
+ find(condition: number | string | IFindUIMethod, options?: any): IUI[]
305
+ findOne(condition: number | string | IFindUIMethod, options?: any): IUI
306
+
307
+ getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData
308
+ getPathString(curve?: boolean, pathForRender?: boolean): IPathString
262
309
 
263
310
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void
311
+ __drawPathByBox(drawer: IPathDrawer): void
264
312
  __drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void
265
313
 
266
- export(filename: string, options?: IExportOptions | number): Promise<IBlob | string | boolean>
314
+ export(filename: string, options?: IExportOptions | number | boolean): Promise<IExportResult>
267
315
  clone(): IUI
316
+ }
268
317
 
318
+ export interface IFindUIMethod {
319
+ (leaf: IUI, options?: any): IAnswer
269
320
  }
270
321
 
271
322
  export interface IUIData extends IUIComputedData, ILeafData {
@@ -276,15 +327,25 @@ export interface IUIData extends IUIComputedData, ILeafData {
276
327
  // 非数据属性, 自动计算的缓存数据
277
328
  __isFills?: boolean
278
329
  __isStrokes?: boolean
330
+
331
+ readonly __strokeWidth: number
332
+
333
+ __pixelFill?: boolean // png / svg / webp
334
+ __pixelStroke?: boolean
335
+
336
+ __opacityFill?: boolean // 半透明的
337
+ __opacityStroke?: boolean
338
+
279
339
  __drawAfterFill?: boolean
280
340
  __isOverflow?: boolean
281
341
  __blendLayer?: boolean
282
342
 
283
- __isTranslucentFill?: boolean // 半透明的
284
- __isTranslucentStroke?: boolean
285
-
286
343
  __useEffect?: boolean
287
344
 
345
+ __autoWidth: boolean
346
+ __autoHeight: boolean
347
+ __autoBounds: boolean
348
+
288
349
  // path
289
350
  path?: IPathCommandData
290
351
  windingRule?: IWindingRule
@@ -298,6 +359,9 @@ export interface IUIData extends IUIComputedData, ILeafData {
298
359
  __font?: string
299
360
  __textDrawData?: ITextDrawData
300
361
 
362
+ __needComputePaint: boolean
363
+ __computePaint(): void
364
+
301
365
  }
302
366
  export interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
303
367
  padding?: number | number[]
@@ -308,7 +372,7 @@ export interface IUIComputedData extends IFillComputedData, IBorderComputedData,
308
372
  export interface IUIBaseInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
309
373
  padding?: number | number[]
310
374
  locked?: boolean
311
- children?: IUIBaseInputData[]
375
+ children?: IUIInputData[]
312
376
  }
313
377
 
314
378
 
@@ -331,5 +395,5 @@ export type IUITag =
331
395
 
332
396
 
333
397
  export interface IUIInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IUIBaseInputData, IObject {
334
-
398
+ children?: IUIInputData[]
335
399
  }
@@ -0,0 +1,16 @@
1
+ import { ILeaferConfig } from '@leafer/interface'
2
+
3
+ import { ILeafer } from './ILeafer'
4
+ import { IEditorConfig } from '../editor/IEditor'
5
+
6
+ export interface IApp extends ILeafer {
7
+ children: ILeafer[]
8
+ realCanvas: boolean
9
+ }
10
+
11
+ export interface IAppConfig extends ILeaferConfig {
12
+ ground?: ILeaferConfig
13
+ tree?: ILeaferConfig
14
+ sky?: ILeaferConfig
15
+ editor?: IEditorConfig
16
+ }
@@ -0,0 +1,21 @@
1
+ import { IControl, ILeaferAttrData, ILeaferConfig, ILeaferType } from '@leafer/interface'
2
+ import { IApp } from './IApp'
3
+ import { IGroup } from '../IUI'
4
+ import { IEditorBase } from '../editor/IEditor'
5
+
6
+ export interface ILeafer extends IGroup, ILeaferAttrData, IControl {
7
+ readonly isApp: boolean
8
+ readonly app: ILeafer
9
+ parent?: IApp
10
+ zoomLayer: IGroup
11
+ editor: IEditorBase
12
+
13
+ ground?: ILeafer
14
+ tree?: ILeafer
15
+ sky?: ILeafer
16
+
17
+ userConfig?: ILeaferConfig
18
+
19
+ onInit(): void
20
+ initType(type: ILeaferType): void
21
+ }
@@ -0,0 +1,88 @@
1
+ import { IGroup, IUI, IRectInputData, ISelectorProxy, IEditSize, ICursorType, IAround, IDragEvent, IRotateEvent, IStroke, IFill, ILeaf, IObject, IBoxInputData, IGroupInputData, IImageCursor } from '@leafer-ui/interface'
2
+
3
+ export interface IEditorBase extends IGroup, ISelectorProxy {
4
+ config: IEditorConfig
5
+
6
+ hoverTarget: IUI
7
+ target: IUI | IUI[]
8
+
9
+ readonly list: IUI[]
10
+
11
+ readonly hasTarget: boolean
12
+ readonly multiple: boolean
13
+ readonly single: boolean
14
+
15
+ readonly dragging: boolean
16
+
17
+ element: IUI
18
+ buttons: IGroup
19
+
20
+ selector: IGroup
21
+ editBox: IGroup
22
+ editTool: IObject
23
+
24
+ hasItem(item: IUI): boolean
25
+ shiftItem(item: IUI): void
26
+ addItem(item: IUI): void
27
+ removeItem(item: IUI): void
28
+
29
+ update(): void
30
+ updateEditTool(): void
31
+
32
+ getEditSize(ui: ILeaf): IEditSize
33
+
34
+ onMove(e: IDragEvent): void
35
+ onScale(e: IDragEvent): void
36
+ onRotate(e: IDragEvent | IRotateEvent): void
37
+ onSkew(e: IDragEvent): void
38
+
39
+ group(group?: IGroup | IGroupInputData): IGroup
40
+ ungroup(): IUI[]
41
+
42
+ lock(): void
43
+ unlock(): void
44
+
45
+ toTop(): void
46
+ toBottom(): void
47
+ }
48
+
49
+ export interface IEditorConfig {
50
+ editSize?: 'auto' | IEditSize
51
+
52
+ stroke?: IStroke
53
+ strokeWidth?: number
54
+
55
+ pointFill?: IFill
56
+ pointSize?: number
57
+ pointRadius?: number
58
+
59
+ point?: IBoxInputData | IBoxInputData[]
60
+ middlePoint?: IBoxInputData | IBoxInputData[]
61
+ rotatePoint?: IBoxInputData
62
+
63
+ rect?: IBoxInputData
64
+ area?: IRectInputData
65
+
66
+ buttonsDirection?: 'top' | 'right' | 'bottom' | 'left'
67
+ buttonsFixed?: boolean
68
+ buttonsMargin?: number
69
+
70
+ hideOnMove?: boolean
71
+
72
+ moveCursor?: ICursorType
73
+ resizeCursor?: IImageCursor
74
+ rotateCursor?: IImageCursor
75
+ skewCursor?: IImageCursor
76
+
77
+ around?: IAround
78
+ lockRatio?: boolean
79
+ rotateGap?: number
80
+
81
+ selector?: boolean
82
+ hover?: boolean
83
+ boxSelect?: boolean
84
+
85
+ rotateable?: boolean
86
+ resizeable?: boolean
87
+ skewable?: boolean
88
+ }
package/src/index.ts CHANGED
@@ -1,7 +1,11 @@
1
1
  export * from '@leafer/interface'
2
2
 
3
+ export { IApp, IAppConfig } from './app/IApp'
4
+ export { ILeafer } from './app/ILeafer'
5
+
3
6
  export {
4
7
  ILine, ILineInputData, ILineData,
8
+ IArrow, IArrowInputData, IArrowData,
5
9
  IRect, IRectInputData, IRectData,
6
10
  IEllipse, IEllipseInputData, IEllipseData,
7
11
  IPolygon, IPolygonInputData, IPolygonData,
@@ -15,11 +19,13 @@ export {
15
19
  IBox, IBoxInputData, IBoxData,
16
20
  IGroup, IGroupInputData, IGroupData,
17
21
  ILeaferInputData, ILeaferData,
18
- IUI, IUIBaseInputData, IUIData,
22
+ IAppInputData, IAppData,
23
+ IUI, IUIBaseInputData, IUIData, IFindUIMethod,
19
24
  IUITag, IUIInputData
20
25
  } from './IUI'
21
- export { IUnitData, IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IStrokeAlign, IStrokeJoin, IStrokeCap, IRGB, IRGBA, IColor, IColorStop, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign, IOverflow } from './type/IType'
22
- export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IColorString as IStringColor } from './type/IStringType'
26
+
27
+ export { IUnitData, IVectorPath, IShadowEffect, IBlurEffect, IGrayscaleEffect, IFill, IStroke, IPaintAttr, IStrokeAlign, IStrokeJoin, IStrokeCap, IArrowType, IRGB, IRGBA, IColor, IColorStop, IPaint, IGradientPaint, IImagePaint, IImagePaintMode, IFontWeight, ITextCase, ITextDecoration, ITextAlign, IVerticalAlign, IOverflow, ITextWrap, IRepeat } from './type/IType'
28
+ export { ICornerRadiusString, IStrokeWidthString, IPaintString, IShadowString, IPercent, IDashPatternString, IColorString } from './type/IStringType'
23
29
  export { ILeafFill, ILeafPaint, ILeafPaintPatternData, ILeafPaintColor, ILeafStrokePaint, ILeafShadowEffect } from './type/IComputedType'
24
30
 
25
31
  export { IUIRenderModule, IRectRenderModule, IImageRenderModule, ITextRenderModule, IGroupRenderModule, IFrameRenderModule } from './module/IUIRender'
@@ -27,9 +33,10 @@ export { IUIBoundsModule } from './module/IUIBounds'
27
33
  export { IUIHitModule } from './module/IUIHit'
28
34
  export { ITextConvertModule } from './module/ITextConvert'
29
35
  export { IColorConvertModule } from './module/IColorConvert'
30
- export { IExportModule, IExportOptions, IExportResult, IExportResultFunction } from './module/IExport'
36
+ export { IExportModule } from './module/IExport'
31
37
 
32
-
33
- export { IPaintModule } from './module/IPaint'
38
+ export { IPaintModule, IPaintImageModule, IPaintGradientModule } from './module/IPaint'
34
39
  export { IEffectModule } from './module/IEffect'
35
- export { ICachedShape } from './ICachedShape'
40
+ export { ICachedShape } from './ICachedShape'
41
+
42
+ export { IEditorBase, IEditorConfig } from './editor/IEditor'
@@ -1,5 +1,5 @@
1
1
  import { IColor } from '../type/IType'
2
2
 
3
3
  export interface IColorConvertModule {
4
- string?(color: IColor, opacity?: number): string
4
+ string(color: IColor, opacity?: number): string
5
5
  }
@@ -1,12 +1,12 @@
1
- import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
1
+ import { ILeaferCanvas } from '@leafer/interface'
2
2
 
3
3
  import { IUI } from '../IUI'
4
4
  import { ICachedShape } from '../ICachedShape'
5
5
 
6
6
 
7
7
  export interface IEffectModule {
8
- shadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void
9
- innerShadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void
10
- blur?(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas, options: IRenderOptions): void
11
- backgroundBlur?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void
8
+ shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
9
+ innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
10
+ blur(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas): void
11
+ backgroundBlur(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void
12
12
  }
@@ -1,19 +1,7 @@
1
- import { ILeaf, IExportFileType, IBlob } from '@leafer/interface'
2
-
3
- export interface IExportOptions {
4
- quality?: number
5
- blob?: boolean
6
- }
7
-
8
- export interface IExportResult {
9
- data: IBlob | string | boolean
10
- }
11
-
12
- export interface IExportResultFunction {
13
- (data: IExportResult): void
14
- }
1
+ import { ILeaf, IExportFileType, IExportOptions, IExportResult } from '@leafer/interface'
15
2
 
16
3
 
17
4
  export interface IExportModule {
18
- export?(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
5
+ running?: boolean
6
+ export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
19
7
  }
@@ -1,26 +1,42 @@
1
- import { ILeaferCanvas, IRenderOptions, IBooleanMap } from '@leafer/interface'
1
+ import { ILeaferCanvas, IRenderOptions, IBooleanMap, IBoundsData, ILeaferImage } from '@leafer/interface'
2
2
 
3
- import { ILeafPaint } from '../type/IComputedType'
3
+ import { ILeafPaint, ILeafPaintPatternData } from '../type/IComputedType'
4
4
  import { IUI, IUIData } from '../IUI'
5
5
  import { ICachedShape } from '../ICachedShape'
6
+ import { IGradientPaint, IImagePaint, IImagePaintMode, IPaintAttr } from '../type/IType'
6
7
 
7
8
  export interface IPaintModule {
8
- compute?(ui: IUI, attrName: 'fill' | 'stroke'): void
9
+ compute(attrName: IPaintAttr, ui: IUI): void
9
10
 
10
- fill?(ui: IUI, canvas: ILeaferCanvas, fill: string): void
11
- fills?(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void
11
+ fill(fill: string, ui: IUI, canvas: ILeaferCanvas,): void
12
+ fills(fills: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
12
13
 
13
- fillText?(ui: IUI, canvas: ILeaferCanvas): void
14
+ fillText(ui: IUI, canvas: ILeaferCanvas): void
14
15
 
15
- stroke?(ui: IUI, canvas: ILeaferCanvas, stroke: string): void
16
- strokes?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
16
+ stroke(stroke: string, ui: IUI, canvas: ILeaferCanvas): void
17
+ strokes(strokes: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
17
18
 
18
- strokeText?(ui: IUI, canvas: ILeaferCanvas, stroke: string): void
19
- strokesText?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void
19
+ strokeText(stroke: string | ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
20
+ drawTextStroke(ui: IUI, canvas: ILeaferCanvas): void
21
+
22
+ shape(ui: IUI, current: ILeaferCanvas, renderOptions: IRenderOptions): ICachedShape
23
+ }
20
24
 
21
- drawTextStroke?(ui: IUI, canvas: ILeaferCanvas): void
22
25
 
23
- shape?(ui: IUI, current: ILeaferCanvas, options: IRenderOptions): ICachedShape
26
+ export interface IPaintImageModule {
27
+ image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds: IBoundsData, firstUse: boolean): ILeafPaint
28
+ checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, allowPaint?: boolean): boolean
29
+ createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): boolean
30
+ recycleImage(attrName: IPaintAttr, data: IUIData): IBooleanMap
24
31
 
25
- recycleImage?(data: IUIData, attrName: string): IBooleanMap
32
+ createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: IImagePaint, box: IBoundsData): void
33
+ fillOrFitMode(data: ILeafPaintPatternData, mode: IImagePaintMode, box: IBoundsData, width: number, height: number, rotation: number): void
34
+ clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void
35
+ repeatMode(data: ILeafPaintPatternData, box: IBoundsData, width: number, height: number, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void
26
36
  }
37
+
38
+ export interface IPaintGradientModule {
39
+ linearGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
40
+ radialGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
41
+ conicGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint
42
+ }
@@ -1,5 +1,5 @@
1
1
  import { ITextData, ITextDrawData } from '../IUI'
2
2
 
3
3
  export interface ITextConvertModule {
4
- getDrawData?(content: string, style: ITextData): ITextDrawData
4
+ getDrawData(content: string, style: ITextData): ITextDrawData
5
5
  }
@@ -1,4 +1,4 @@
1
- import { IBlendMode, ILeaferImage, IMatrixData } from '@leafer/interface'
1
+ import { IBlendMode, ILeaferImage, IMatrixData, ITaskItem } from '@leafer/interface'
2
2
 
3
3
  import { IColorString } from './IStringType'
4
4
  import { IStrokeAlign, IStrokeJoin, IStrokeCap, IImagePaintMode } from './IType'
@@ -15,6 +15,7 @@ export interface ILeafPaint {
15
15
  image?: ILeaferImage
16
16
  loadId?: number
17
17
  patternId?: string
18
+ patternTask?: ITaskItem
18
19
  data?: ILeafPaintPatternData
19
20
  }
20
21
 
@@ -26,6 +27,7 @@ export interface ILeafPaintPatternData {
26
27
  opacity?: number
27
28
  transform?: IMatrixData
28
29
  mode?: IImagePaintMode
30
+ repeat?: 'repeat' | 'repeat-x' | 'repeat-y'
29
31
  }
30
32
 
31
33
  export type ILeafFill = ILeafPaint
package/src/type/IType.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType } from '@leafer/interface'
2
- import { IColorString } from './IStringType'
1
+ import { IPointData, IPathCommandData, IWindingRule, IBlendMode, IExportFileType, ISizeData } from '@leafer/interface'
2
+ import { IColorString, IPaintString } from './IStringType'
3
3
 
4
4
  export interface IUnitData {
5
5
  type: 'percent' | 'px'
@@ -8,6 +8,12 @@ export interface IUnitData {
8
8
 
9
9
  export type IPaint = ISolidPaint | IGradientPaint | IImagePaint
10
10
 
11
+ export type IFill = IPaint | IPaint[] | IPaintString
12
+
13
+ export type IStroke = IPaint | IPaint[] | IPaintString
14
+
15
+ export type IPaintAttr = 'fill' | 'stroke'
16
+
11
17
  export interface IPaintBase {
12
18
  type: IPaintType
13
19
  blendMode?: IBlendMode
@@ -66,8 +72,11 @@ export interface IImagePaint extends IPaintBase {
66
72
  filters?: IImageFilters
67
73
 
68
74
  offset?: IPointData
75
+ size?: number | ISizeData
69
76
  scale?: number | IPointData
70
77
  rotation?: number
78
+
79
+ repeat?: IRepeat
71
80
  }
72
81
  export interface IImageFilters {
73
82
  exposure?: number // 曝光
@@ -79,12 +88,16 @@ export interface IImageFilters {
79
88
  shadows?: number // 阴影
80
89
  }
81
90
  export type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
91
+ export type IRepeat = boolean | 'x' | 'y'
82
92
 
83
93
  // 描边
84
94
  export type IStrokeAlign = 'inside' | 'outside' | 'center'
85
95
  export type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-equilateral'
86
96
  export type IStrokeJoin = 'bevel' | 'round' | 'miter'
87
97
 
98
+ // 箭头
99
+ export type IArrowType = 'none' | 'line' | 'triangle' | 'circle'
100
+
88
101
  // 文本
89
102
  export type ITextAlign = 'left' | 'center' | 'right' | 'justify'
90
103
  export type IVerticalAlign = 'top' | 'middle' | 'bottom'
@@ -102,6 +115,7 @@ export type IFontWeightString =
102
115
  | 'extra-bold'
103
116
  | 'black'
104
117
  export type ITextDecoration = 'none' | 'under' | 'delete'
118
+ export type ITextWrap = 'normal' | 'none' | 'break'
105
119
 
106
120
  // 路径
107
121
  export interface IVectorPath {
package/types/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { IPointData, IExportFileType, IWindingRule, IPathCommandData, IBlendMode, IMatrixData, ILeaferImage, IBlob, ILeaf, IPathString, IPathCreator, IBoundsData, ILeaferImageConfig, ILeaferCanvas, IRenderOptions, IPathDrawer, ILeafData, IPath2D, ILeafComputedData, ILeafInputData, IObject, ILeafRender, ILeafBounds, ILeafHit, ICachedLeaf, IBooleanMap } from '@leafer/interface';
1
+ import { IPointData, IExportFileType, ISizeData, IWindingRule, IPathCommandData, IBlendMode, IMatrixData, ILeaferImage, ITaskItem, INumber, IBoolean, IString, IPathString, IPathCreator, IBoundsData, ILeaferImageConfig, ILeaferCanvas, IRenderOptions, IPickOptions, IPickResult, ILeaf, IPathDrawer, IExportOptions, IExportResult, IAnswer, ILeafData, IPath2D, ILeafComputedData, ILeafInputData, IObject, ILeaferAttrData, IControl, ILeaferConfig, ILeaferType, ILeafRender, ILeafBounds, ILeafHit, ICachedLeaf, IBooleanMap } from '@leafer/interface';
2
2
  export * from '@leafer/interface';
3
+ import { IGroup as IGroup$1, ISelectorProxy, IUI as IUI$1, IObject as IObject$1, ILeaf as ILeaf$1, IEditSize, IDragEvent, IRotateEvent, IGroupInputData as IGroupInputData$1, IStroke as IStroke$1, IFill as IFill$1, IBoxInputData as IBoxInputData$1, IRectInputData as IRectInputData$1, ICursorType, IImageCursor, IAround } from '@leafer-ui/interface';
3
4
 
4
5
  type IPercent = string;
5
6
  type IColorString = string;
@@ -17,6 +18,9 @@ interface IUnitData {
17
18
  value: number;
18
19
  }
19
20
  type IPaint = ISolidPaint | IGradientPaint | IImagePaint;
21
+ type IFill = IPaint | IPaint[] | IPaintString;
22
+ type IStroke = IPaint | IPaint[] | IPaintString;
23
+ type IPaintAttr = 'fill' | 'stroke';
20
24
  interface IPaintBase {
21
25
  type: IPaintType;
22
26
  blendMode?: IBlendMode;
@@ -57,8 +61,10 @@ interface IImagePaint extends IPaintBase {
57
61
  format?: IExportFileType;
58
62
  filters?: IImageFilters;
59
63
  offset?: IPointData;
64
+ size?: number | ISizeData;
60
65
  scale?: number | IPointData;
61
66
  rotation?: number;
67
+ repeat?: IRepeat;
62
68
  }
63
69
  interface IImageFilters {
64
70
  exposure?: number;
@@ -70,9 +76,11 @@ interface IImageFilters {
70
76
  shadows?: number;
71
77
  }
72
78
  type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat';
79
+ type IRepeat = boolean | 'x' | 'y';
73
80
  type IStrokeAlign = 'inside' | 'outside' | 'center';
74
81
  type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-equilateral';
75
82
  type IStrokeJoin = 'bevel' | 'round' | 'miter';
83
+ type IArrowType = 'none' | 'line' | 'triangle' | 'circle';
76
84
  type ITextAlign = 'left' | 'center' | 'right' | 'justify';
77
85
  type IVerticalAlign = 'top' | 'middle' | 'bottom';
78
86
  type ITextCase = 'upper' | 'lower' | 'title' | 'none' | 'small-caps';
@@ -80,6 +88,7 @@ type IFontWeight = IFontWeightNumer | IFontWeightString;
80
88
  type IFontWeightNumer = 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
81
89
  type IFontWeightString = 'thin' | 'extra-light' | 'light' | 'normal' | 'medium' | 'semi-bold' | 'bold' | 'extra-bold' | 'black';
82
90
  type ITextDecoration = 'none' | 'under' | 'delete';
91
+ type ITextWrap = 'normal' | 'none' | 'break';
83
92
  interface IVectorPath {
84
93
  rule?: IWindingRule;
85
94
  data: string | IPathCommandData;
@@ -114,6 +123,7 @@ interface ILeafPaint {
114
123
  image?: ILeaferImage;
115
124
  loadId?: number;
116
125
  patternId?: string;
126
+ patternTask?: ITaskItem;
117
127
  data?: ILeafPaintPatternData;
118
128
  }
119
129
  interface ILeafPaintPatternData {
@@ -124,6 +134,7 @@ interface ILeafPaintPatternData {
124
134
  opacity?: number;
125
135
  transform?: IMatrixData;
126
136
  mode?: IImagePaintMode;
137
+ repeat?: 'repeat' | 'repeat-x' | 'repeat-y';
127
138
  }
128
139
  type ILeafFill = ILeafPaint;
129
140
  interface ILeafStrokePaint extends ILeafPaint {
@@ -145,22 +156,22 @@ interface ILeafShadowEffect {
145
156
  }
146
157
 
147
158
  interface ICornerRadiusAttrData {
148
- cornerRadius: number | number[] | ICornerRadiusString;
149
- cornerSmoothing: number;
159
+ cornerRadius: INumber | INumber[] | ICornerRadiusString;
160
+ cornerSmoothing: INumber;
150
161
  }
151
162
  interface ICornerRadiusInputData {
152
- cornerRadius?: number | number[] | ICornerRadiusString;
153
- cornerSmoothing?: number;
163
+ cornerRadius?: INumber | INumber[] | ICornerRadiusString;
164
+ cornerSmoothing?: INumber;
154
165
  }
155
166
  interface ICornerRadiusComputedData {
156
167
  cornerRadius?: number;
157
168
  cornerSmoothing?: number;
158
169
  }
159
170
  interface IFillAttrData {
160
- fill: IPaint | IPaint[] | IPaintString;
171
+ fill: IFill;
161
172
  }
162
173
  interface IFillInputData {
163
- fill?: IPaint | IPaint[] | IPaintString;
174
+ fill?: IFill;
164
175
  }
165
176
  interface IFillComputedData {
166
177
  fill?: IColorString | ILeafPaint[];
@@ -170,30 +181,37 @@ interface IBorderComputedData {
170
181
  borderRadius?: number | number[];
171
182
  }
172
183
  interface IStrokeAttrData {
173
- stroke: IPaint | IPaint[] | IPaintString;
184
+ stroke: IStroke;
174
185
  strokeAlign: IStrokeAlign;
175
- strokeWidth: number | number[] | IStrokeWidthString;
186
+ strokeWidth: INumber | INumber[] | IStrokeWidthString;
187
+ strokeWidthFixed: IBoolean;
176
188
  strokeCap: IStrokeCap;
177
189
  strokeJoin: IStrokeJoin;
178
- dashPattern: number[] | IDashPatternString;
179
- dashOffset: number;
180
- miterLimit: number;
190
+ dashPattern: INumber[] | IDashPatternString;
191
+ dashOffset: INumber;
192
+ miterLimit: INumber;
193
+ startArrow: IArrowType;
194
+ endArrow: IArrowType;
181
195
  }
182
196
  interface IStrokeInputData {
183
- stroke?: IPaint | IPaint[] | IPaintString;
197
+ stroke?: IStroke;
184
198
  strokeAlign?: IStrokeAlign;
185
- strokeWidth?: number | number[] | IStrokeWidthString;
199
+ strokeWidth?: INumber | INumber[] | IStrokeWidthString;
200
+ strokeWidthFixed?: IBoolean;
186
201
  strokeCap?: IStrokeCap;
187
202
  strokeJoin?: IStrokeJoin;
188
- dashPattern?: number[] | IDashPatternString;
189
- dashOffset?: number;
190
- miterLimit?: number;
203
+ dashPattern?: INumber[] | IDashPatternString;
204
+ dashOffset?: INumber;
205
+ miterLimit?: INumber;
206
+ startArrow?: IArrowType;
207
+ endArrow?: IArrowType;
191
208
  }
192
209
  interface IStrokeComputedData {
193
210
  stroke?: IColorString | ILeafStrokePaint[];
194
211
  strokeAlign?: IStrokeAlign;
195
212
  strokeWidth?: number;
196
213
  strokeWidths?: number[];
214
+ strokeWidthFixed?: boolean;
197
215
  strokeCap?: IStrokeCap;
198
216
  strokeJoin?: IStrokeJoin;
199
217
  dashPattern?: number[];
@@ -201,33 +219,35 @@ interface IStrokeComputedData {
201
219
  miterLimit?: number;
202
220
  }
203
221
  interface ITextStyleAttrData {
204
- fontFamily: string;
205
- fontSize: number;
222
+ fontFamily: IString;
223
+ fontSize: INumber;
206
224
  fontWeight: IFontWeight;
207
- italic: boolean;
225
+ italic: IBoolean;
208
226
  textCase: ITextCase;
209
227
  textDecoration: ITextDecoration;
210
- letterSpacing: number | IUnitData;
211
- lineHeight: number | IUnitData;
212
- paraIndent: number;
213
- paraSpacing: number;
228
+ letterSpacing: INumber | IUnitData;
229
+ lineHeight: INumber | IUnitData;
230
+ paraIndent: INumber;
231
+ paraSpacing: INumber;
214
232
  textAlign: ITextAlign;
215
233
  verticalAlign: IVerticalAlign;
234
+ textWrap: ITextWrap;
216
235
  textOverflow: IOverflow | string;
217
236
  }
218
237
  interface ITextStyleInputData {
219
- fontFamily?: string;
220
- fontSize?: number;
238
+ fontFamily?: IString;
239
+ fontSize?: INumber;
221
240
  fontWeight?: IFontWeight;
222
- italic?: boolean;
241
+ italic?: IBoolean;
223
242
  textCase?: ITextCase;
224
243
  textDecoration?: ITextDecoration;
225
- letterSpacing?: number | IUnitData;
226
- lineHeight?: number | IUnitData;
227
- paraIndent?: number;
228
- paraSpacing?: number;
244
+ letterSpacing?: INumber | IUnitData;
245
+ lineHeight?: INumber | IUnitData;
246
+ paraIndent?: INumber;
247
+ paraSpacing?: INumber;
229
248
  textAlign?: ITextAlign;
230
249
  verticalAlign?: IVerticalAlign;
250
+ textWrap?: ITextWrap;
231
251
  textOverflow?: IOverflow | string;
232
252
  }
233
253
  interface ITextStyleComputedData {
@@ -243,21 +263,22 @@ interface ITextStyleComputedData {
243
263
  paraSpacing?: number;
244
264
  textAlign?: ITextAlign;
245
265
  verticalAlign?: IVerticalAlign;
246
- textOverflow?: IOverflow;
266
+ textWrap?: ITextWrap;
267
+ textOverflow?: IOverflow | string;
247
268
  }
248
269
  interface IEffectAttrData {
249
270
  shadow: IShadowEffect | IShadowEffect[] | IShadowString;
250
271
  innerShadow: IShadowEffect | IShadowEffect[] | IShadowString;
251
- blur: number | IBlurEffect;
252
- backgroundBlur: number | IBlurEffect;
253
- grayscale: number | IGrayscaleEffect;
272
+ blur: INumber | IBlurEffect;
273
+ backgroundBlur: INumber | IBlurEffect;
274
+ grayscale: INumber | IGrayscaleEffect;
254
275
  }
255
276
  interface IEffectInputData {
256
277
  shadow?: IShadowEffect | IShadowEffect[] | IShadowString;
257
278
  innerShadow?: IShadowEffect | IShadowEffect[] | IShadowString;
258
- blur?: number | IBlurEffect;
259
- backgroundBlur?: number | IBlurEffect;
260
- grayscale?: number | IGrayscaleEffect;
279
+ blur?: INumber | IBlurEffect;
280
+ backgroundBlur?: INumber | IBlurEffect;
281
+ grayscale?: INumber | IGrayscaleEffect;
261
282
  }
262
283
  interface IEffectComputedData {
263
284
  shadow?: ILeafShadowEffect[];
@@ -267,33 +288,30 @@ interface IEffectComputedData {
267
288
  grayscale?: number;
268
289
  }
269
290
 
270
- interface IExportOptions {
271
- quality?: number;
272
- blob?: boolean;
273
- }
274
- interface IExportResult {
275
- data: IBlob | string | boolean;
276
- }
277
- interface IExportResultFunction {
278
- (data: IExportResult): void;
279
- }
280
- interface IExportModule {
281
- export?(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
282
- }
283
-
284
291
  interface ILine extends IUI {
285
292
  __: ILineData;
286
293
  toPoint: IPointData;
287
294
  points: number[];
288
295
  curve: boolean | number;
289
296
  }
290
- interface ILineData extends IUIData {
291
- }
292
- interface ILineInputData extends IUIBaseInputData {
297
+ interface ILineAttrData {
293
298
  toPoint?: IPointData;
294
299
  points?: number[];
295
300
  curve?: boolean | number;
296
301
  }
302
+ interface ILineData extends ILineAttrData, IUIData {
303
+ }
304
+ interface ILineInputData extends ILineAttrData, IUIBaseInputData {
305
+ }
306
+ interface IArrow extends ILine {
307
+ __: IArrowData;
308
+ }
309
+ interface IArrowAttrData {
310
+ }
311
+ interface IArrowData extends IArrowAttrData, ILineData {
312
+ }
313
+ interface IArrowInputData extends IArrowAttrData, IUIBaseInputData {
314
+ }
297
315
  interface IRect extends IUI {
298
316
  __: IRectData;
299
317
  }
@@ -380,6 +398,9 @@ interface ITextData extends ITextAttrData, ITextStyleComputedData, IUIData {
380
398
  __baseLine?: number;
381
399
  __lineHeight?: number;
382
400
  __letterSpacing?: number;
401
+ __padding?: number[];
402
+ __clipText?: boolean;
403
+ __textBoxBounds?: IBoundsData;
383
404
  }
384
405
  interface ITextInputData extends ITextAttrData, ITextStyleInputData, IUIBaseInputData {
385
406
  }
@@ -391,9 +412,12 @@ interface ITextRowData {
391
412
  text?: string;
392
413
  data?: ITextCharData[];
393
414
  words?: ITextWordData[];
415
+ startCharSize?: number;
416
+ endCharSize?: number;
394
417
  paraStart?: boolean;
395
418
  paraEnd?: boolean;
396
419
  isOverflow?: boolean;
420
+ textMode?: boolean;
397
421
  }
398
422
  interface ITextWordData {
399
423
  x?: number;
@@ -428,6 +452,7 @@ interface IImageAttrData {
428
452
  url?: string;
429
453
  }
430
454
  interface IImageData extends IImageAttrData, IRectData {
455
+ __setImageFill(value: string): void;
431
456
  }
432
457
  interface IImageInputData extends IImageAttrData, IUIBaseInputData {
433
458
  }
@@ -452,6 +477,10 @@ interface ILeaferData extends IGroupData {
452
477
  interface ILeaferInputData extends IGroupInputData {
453
478
  pixelRatio?: number;
454
479
  }
480
+ interface IAppData extends ILeaferData {
481
+ }
482
+ interface IAppInputData extends ILeaferInputData {
483
+ }
455
484
  interface IFrame extends IBox {
456
485
  __: IFrameData;
457
486
  }
@@ -474,13 +503,15 @@ interface IBoxInputData extends IGroupInputData {
474
503
  interface IGroup extends IUI {
475
504
  __: IGroupData;
476
505
  children: IUI[];
477
- mask?: IUI;
506
+ pick(hitPoint: IPointData, options?: IPickOptions): IPickResult;
478
507
  add(child: IUI, index?: number): void;
479
508
  addAt(child: IUI, index: number): void;
480
509
  addAfter(child: IUI, after: IUI): void;
481
510
  addBefore(child: IUI, before: IUI): void;
511
+ addMany(...children: ILeaf[]): void;
482
512
  remove(child?: IUI): void;
483
513
  removeAll(): void;
514
+ clear(): void;
484
515
  }
485
516
  interface IGroupData extends IUIData {
486
517
  }
@@ -488,27 +519,48 @@ interface IGroupInputData extends IUIBaseInputData {
488
519
  }
489
520
  interface IUI extends IFillAttrData, IStrokeAttrData, ICornerRadiusAttrData, IEffectAttrData, ILeaf {
490
521
  __: IUIData;
522
+ readonly app: ILeafer;
523
+ leafer?: ILeafer;
491
524
  parent?: IGroup;
525
+ isFrame?: boolean;
526
+ proxyData: IUIInputData;
527
+ __proxyData?: IUIInputData;
528
+ children?: IUI[];
529
+ reset(data?: IUIInputData): void;
492
530
  set(data: IUIInputData): void;
493
531
  toJSON(): IUIInputData;
494
- getPath(curve?: boolean): IPathCommandData;
495
- getPathString(curve?: boolean): IPathString;
532
+ get(): IUIInputData;
533
+ createProxyData(): IUIInputData;
534
+ find(condition: number | string | IFindUIMethod, options?: any): IUI[];
535
+ findOne(condition: number | string | IFindUIMethod, options?: any): IUI;
536
+ getPath(curve?: boolean, pathForRender?: boolean): IPathCommandData;
537
+ getPathString(curve?: boolean, pathForRender?: boolean): IPathString;
496
538
  __drawPathByData(drawer: IPathDrawer, data: IPathCommandData): void;
539
+ __drawPathByBox(drawer: IPathDrawer): void;
497
540
  __drawAfterFill?(canvas: ILeaferCanvas, options: IRenderOptions): void;
498
- export(filename: string, options?: IExportOptions | number): Promise<IBlob | string | boolean>;
541
+ export(filename: string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
499
542
  clone(): IUI;
500
543
  }
544
+ interface IFindUIMethod {
545
+ (leaf: IUI, options?: any): IAnswer;
546
+ }
501
547
  interface IUIData extends IUIComputedData, ILeafData {
502
548
  padding?: number | number[];
503
549
  locked?: boolean;
504
550
  __isFills?: boolean;
505
551
  __isStrokes?: boolean;
552
+ readonly __strokeWidth: number;
553
+ __pixelFill?: boolean;
554
+ __pixelStroke?: boolean;
555
+ __opacityFill?: boolean;
556
+ __opacityStroke?: boolean;
506
557
  __drawAfterFill?: boolean;
507
558
  __isOverflow?: boolean;
508
559
  __blendLayer?: boolean;
509
- __isTranslucentFill?: boolean;
510
- __isTranslucentStroke?: boolean;
511
560
  __useEffect?: boolean;
561
+ __autoWidth: boolean;
562
+ __autoHeight: boolean;
563
+ __autoBounds: boolean;
512
564
  path?: IPathCommandData;
513
565
  windingRule?: IWindingRule;
514
566
  __pathForRender?: IPathCommandData;
@@ -516,6 +568,8 @@ interface IUIData extends IUIComputedData, ILeafData {
516
568
  __boxStroke?: boolean;
517
569
  __font?: string;
518
570
  __textDrawData?: ITextDrawData;
571
+ __needComputePaint: boolean;
572
+ __computePaint(): void;
519
573
  }
520
574
  interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrokeComputedData, ITextStyleComputedData, ICornerRadiusComputedData, IEffectComputedData, ILeafComputedData {
521
575
  padding?: number | number[];
@@ -524,10 +578,99 @@ interface IUIComputedData extends IFillComputedData, IBorderComputedData, IStrok
524
578
  interface IUIBaseInputData extends IFillInputData, IStrokeInputData, ITextStyleInputData, ICornerRadiusInputData, IEffectInputData, ILeafInputData {
525
579
  padding?: number | number[];
526
580
  locked?: boolean;
527
- children?: IUIBaseInputData[];
581
+ children?: IUIInputData[];
528
582
  }
529
583
  type IUITag = 'App' | 'Leafer' | 'Rect' | 'Ellipse' | 'Polygon' | 'Star' | 'Line' | 'Path' | 'Pen' | 'Text' | 'Image' | 'Canvas' | 'Group' | 'Frame' | 'Box';
530
584
  interface IUIInputData extends IRectInputData, IEllipseInputData, IPolygonInputData, IStarInputData, ILineInputData, IPathInputData, ITextInputData, IImageInputData, IGroupInputData, IFrameInputData, IUIBaseInputData, IObject {
585
+ children?: IUIInputData[];
586
+ }
587
+
588
+ interface IEditorBase extends IGroup$1, ISelectorProxy {
589
+ config: IEditorConfig;
590
+ hoverTarget: IUI$1;
591
+ target: IUI$1 | IUI$1[];
592
+ readonly list: IUI$1[];
593
+ readonly hasTarget: boolean;
594
+ readonly multiple: boolean;
595
+ readonly single: boolean;
596
+ readonly dragging: boolean;
597
+ element: IUI$1;
598
+ buttons: IGroup$1;
599
+ selector: IGroup$1;
600
+ editBox: IGroup$1;
601
+ editTool: IObject$1;
602
+ hasItem(item: IUI$1): boolean;
603
+ shiftItem(item: IUI$1): void;
604
+ addItem(item: IUI$1): void;
605
+ removeItem(item: IUI$1): void;
606
+ update(): void;
607
+ updateEditTool(): void;
608
+ getEditSize(ui: ILeaf$1): IEditSize;
609
+ onMove(e: IDragEvent): void;
610
+ onScale(e: IDragEvent): void;
611
+ onRotate(e: IDragEvent | IRotateEvent): void;
612
+ onSkew(e: IDragEvent): void;
613
+ group(group?: IGroup$1 | IGroupInputData$1): IGroup$1;
614
+ ungroup(): IUI$1[];
615
+ lock(): void;
616
+ unlock(): void;
617
+ toTop(): void;
618
+ toBottom(): void;
619
+ }
620
+ interface IEditorConfig {
621
+ editSize?: 'auto' | IEditSize;
622
+ stroke?: IStroke$1;
623
+ strokeWidth?: number;
624
+ pointFill?: IFill$1;
625
+ pointSize?: number;
626
+ pointRadius?: number;
627
+ point?: IBoxInputData$1 | IBoxInputData$1[];
628
+ middlePoint?: IBoxInputData$1 | IBoxInputData$1[];
629
+ rotatePoint?: IBoxInputData$1;
630
+ rect?: IBoxInputData$1;
631
+ area?: IRectInputData$1;
632
+ buttonsDirection?: 'top' | 'right' | 'bottom' | 'left';
633
+ buttonsFixed?: boolean;
634
+ buttonsMargin?: number;
635
+ hideOnMove?: boolean;
636
+ moveCursor?: ICursorType;
637
+ resizeCursor?: IImageCursor;
638
+ rotateCursor?: IImageCursor;
639
+ skewCursor?: IImageCursor;
640
+ around?: IAround;
641
+ lockRatio?: boolean;
642
+ rotateGap?: number;
643
+ selector?: boolean;
644
+ hover?: boolean;
645
+ boxSelect?: boolean;
646
+ rotateable?: boolean;
647
+ resizeable?: boolean;
648
+ skewable?: boolean;
649
+ }
650
+
651
+ interface ILeafer extends IGroup, ILeaferAttrData, IControl {
652
+ readonly isApp: boolean;
653
+ readonly app: ILeafer;
654
+ parent?: IApp;
655
+ zoomLayer: IGroup;
656
+ editor: IEditorBase;
657
+ ground?: ILeafer;
658
+ tree?: ILeafer;
659
+ sky?: ILeafer;
660
+ userConfig?: ILeaferConfig;
661
+ onInit(): void;
662
+ initType(type: ILeaferType): void;
663
+ }
664
+
665
+ interface IApp extends ILeafer {
666
+ children: ILeafer[];
667
+ realCanvas: boolean;
668
+ }
669
+ interface IAppConfig extends ILeaferConfig {
670
+ ground?: ILeaferConfig;
671
+ tree?: ILeaferConfig;
672
+ sky?: ILeaferConfig;
673
+ editor?: IEditorConfig;
531
674
  }
532
675
 
533
676
  type IUIRenderModule = IUIRender & ThisType<IUI>;
@@ -557,11 +700,16 @@ interface IUIBounds extends ILeafBounds {
557
700
  type IUIHitModule = ILeafHit & ThisType<IUI>;
558
701
 
559
702
  interface ITextConvertModule {
560
- getDrawData?(content: string, style: ITextData): ITextDrawData;
703
+ getDrawData(content: string, style: ITextData): ITextDrawData;
561
704
  }
562
705
 
563
706
  interface IColorConvertModule {
564
- string?(color: IColor, opacity?: number): string;
707
+ string(color: IColor, opacity?: number): string;
708
+ }
709
+
710
+ interface IExportModule {
711
+ running?: boolean;
712
+ export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>;
565
713
  }
566
714
 
567
715
  interface ICachedShape extends ICachedLeaf {
@@ -572,24 +720,37 @@ interface ICachedShape extends ICachedLeaf {
572
720
  }
573
721
 
574
722
  interface IPaintModule {
575
- compute?(ui: IUI, attrName: 'fill' | 'stroke'): void;
576
- fill?(ui: IUI, canvas: ILeaferCanvas, fill: string): void;
577
- fills?(ui: IUI, canvas: ILeaferCanvas, fills: ILeafPaint[]): void;
578
- fillText?(ui: IUI, canvas: ILeaferCanvas): void;
579
- stroke?(ui: IUI, canvas: ILeaferCanvas, stroke: string): void;
580
- strokes?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void;
581
- strokeText?(ui: IUI, canvas: ILeaferCanvas, stroke: string): void;
582
- strokesText?(ui: IUI, canvas: ILeaferCanvas, strokes: ILeafPaint[]): void;
583
- drawTextStroke?(ui: IUI, canvas: ILeaferCanvas): void;
584
- shape?(ui: IUI, current: ILeaferCanvas, options: IRenderOptions): ICachedShape;
585
- recycleImage?(data: IUIData, attrName: string): IBooleanMap;
723
+ compute(attrName: IPaintAttr, ui: IUI): void;
724
+ fill(fill: string, ui: IUI, canvas: ILeaferCanvas): void;
725
+ fills(fills: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void;
726
+ fillText(ui: IUI, canvas: ILeaferCanvas): void;
727
+ stroke(stroke: string, ui: IUI, canvas: ILeaferCanvas): void;
728
+ strokes(strokes: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void;
729
+ strokeText(stroke: string | ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void;
730
+ drawTextStroke(ui: IUI, canvas: ILeaferCanvas): void;
731
+ shape(ui: IUI, current: ILeaferCanvas, renderOptions: IRenderOptions): ICachedShape;
732
+ }
733
+ interface IPaintImageModule {
734
+ image(ui: IUI, attrName: string, paint: IImagePaint, boxBounds: IBoundsData, firstUse: boolean): ILeafPaint;
735
+ checkImage(ui: IUI, canvas: ILeaferCanvas, paint: ILeafPaint, allowPaint?: boolean): boolean;
736
+ createPattern(ui: IUI, paint: ILeafPaint, pixelRatio: number): boolean;
737
+ recycleImage(attrName: IPaintAttr, data: IUIData): IBooleanMap;
738
+ createData(leafPaint: ILeafPaint, image: ILeaferImage, paint: IImagePaint, box: IBoundsData): void;
739
+ fillOrFitMode(data: ILeafPaintPatternData, mode: IImagePaintMode, box: IBoundsData, width: number, height: number, rotation: number): void;
740
+ clipMode(data: ILeafPaintPatternData, box: IBoundsData, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void;
741
+ repeatMode(data: ILeafPaintPatternData, box: IBoundsData, width: number, height: number, x: number, y: number, scaleX: number, scaleY: number, rotation: number): void;
742
+ }
743
+ interface IPaintGradientModule {
744
+ linearGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint;
745
+ radialGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint;
746
+ conicGradient(paint: IGradientPaint, box: IBoundsData): ILeafPaint;
586
747
  }
587
748
 
588
749
  interface IEffectModule {
589
- shadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void;
590
- innerShadow?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void;
591
- blur?(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas, options: IRenderOptions): void;
592
- backgroundBlur?(ui: IUI, current: ILeaferCanvas, shape: ICachedShape, options: IRenderOptions): void;
750
+ shadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void;
751
+ innerShadow(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void;
752
+ blur(ui: IUI, current: ILeaferCanvas, origin: ILeaferCanvas): void;
753
+ backgroundBlur(ui: IUI, current: ILeaferCanvas, shape: ICachedShape): void;
593
754
  }
594
755
 
595
- export type { IBlurEffect, IBox, IBoxData, IBoxInputData, ICachedShape, ICanvas, ICanvasData, ICanvasInputData, IColor, IColorConvertModule, IColorStop, ICornerRadiusString, IDashPatternString, IEffectModule, IEllipse, IEllipseData, IEllipseInputData, IExportModule, IExportOptions, IExportResult, IExportResultFunction, IFontWeight, IFrame, IFrameData, IFrameInputData, IFrameRenderModule, IGradientPaint, IGrayscaleEffect, IGroup, IGroupData, IGroupInputData, IGroupRenderModule, IImage, IImageData, IImageInputData, IImagePaint, IImagePaintMode, IImageRenderModule, ILeafFill, ILeafPaint, ILeafPaintColor, ILeafPaintPatternData, ILeafShadowEffect, ILeafStrokePaint, ILeaferData, ILeaferInputData, ILine, ILineData, ILineInputData, IOverflow, IPaint, IPaintModule, IPaintString, IPath, IPathData, IPathInputData, IPen, IPenData, IPenInputData, IPercent, IPolygon, IPolygonData, IPolygonInputData, IRGB, IRGBA, IRect, IRectData, IRectInputData, IRectRenderModule, IShadowEffect, IShadowString, IStar, IStarData, IStarInputData, IColorString as IStringColor, IStrokeAlign, IStrokeCap, IStrokeJoin, IStrokeWidthString, IText, ITextAlign, ITextCase, ITextCharData, ITextConvertModule, ITextData, ITextDecoration, ITextDrawData, ITextInputData, ITextRenderModule, ITextRowData, ITextWordData, IUI, IUIBaseInputData, IUIBoundsModule, IUIData, IUIHitModule, IUIInputData, IUIRenderModule, IUITag, IUnitData, IVectorPath, IVerticalAlign };
756
+ export type { IApp, IAppConfig, IAppData, IAppInputData, IArrow, IArrowData, IArrowInputData, IArrowType, IBlurEffect, IBox, IBoxData, IBoxInputData, ICachedShape, ICanvas, ICanvasData, ICanvasInputData, IColor, IColorConvertModule, IColorStop, IColorString, ICornerRadiusString, IDashPatternString, IEditorBase, IEditorConfig, IEffectModule, IEllipse, IEllipseData, IEllipseInputData, IExportModule, IFill, IFindUIMethod, IFontWeight, IFrame, IFrameData, IFrameInputData, IFrameRenderModule, IGradientPaint, IGrayscaleEffect, IGroup, IGroupData, IGroupInputData, IGroupRenderModule, IImage, IImageData, IImageInputData, IImagePaint, IImagePaintMode, IImageRenderModule, ILeafFill, ILeafPaint, ILeafPaintColor, ILeafPaintPatternData, ILeafShadowEffect, ILeafStrokePaint, ILeafer, ILeaferData, ILeaferInputData, ILine, ILineData, ILineInputData, IOverflow, IPaint, IPaintAttr, IPaintGradientModule, IPaintImageModule, IPaintModule, IPaintString, IPath, IPathData, IPathInputData, IPen, IPenData, IPenInputData, IPercent, IPolygon, IPolygonData, IPolygonInputData, IRGB, IRGBA, IRect, IRectData, IRectInputData, IRectRenderModule, IRepeat, IShadowEffect, IShadowString, IStar, IStarData, IStarInputData, IStroke, IStrokeAlign, IStrokeCap, IStrokeJoin, IStrokeWidthString, IText, ITextAlign, ITextCase, ITextCharData, ITextConvertModule, ITextData, ITextDecoration, ITextDrawData, ITextInputData, ITextRenderModule, ITextRowData, ITextWordData, ITextWrap, IUI, IUIBaseInputData, IUIBoundsModule, IUIData, IUIHitModule, IUIInputData, IUIRenderModule, IUITag, IUnitData, IVectorPath, IVerticalAlign };