@leafer-ui/interface 1.0.0-beta.9 → 1.0.0-rc.10
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 +6 -3
- package/src/ICommonAttr.ts +54 -39
- package/src/IUI.ts +112 -49
- package/src/app/IApp.ts +16 -0
- package/src/app/ILeafer.ts +21 -0
- package/src/editor/IEditor.ts +88 -0
- package/src/index.ts +16 -7
- package/src/module/IColorConvert.ts +5 -0
- package/src/module/IEffect.ts +5 -5
- package/src/module/IExport.ts +2 -14
- package/src/module/IPaint.ts +31 -14
- package/src/module/ITextConvert.ts +5 -0
- package/src/type/IComputedType.ts +20 -4
- package/src/type/IType.ts +17 -2
- package/types/index.d.ts +756 -0
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,19 +19,24 @@ export {
|
|
|
15
19
|
IBox, IBoxInputData, IBoxData,
|
|
16
20
|
IGroup, IGroupInputData, IGroupData,
|
|
17
21
|
ILeaferInputData, ILeaferData,
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
IAppInputData, IAppData,
|
|
23
|
+
IUI, IUIBaseInputData, IUIData, IFindUIMethod,
|
|
24
|
+
IUITag, IUIInputData
|
|
20
25
|
} from './IUI'
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
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'
|
|
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'
|
|
26
32
|
export { IUIBoundsModule } from './module/IUIBounds'
|
|
27
33
|
export { IUIHitModule } from './module/IUIHit'
|
|
28
|
-
export {
|
|
34
|
+
export { ITextConvertModule } from './module/ITextConvert'
|
|
35
|
+
export { IColorConvertModule } from './module/IColorConvert'
|
|
36
|
+
export { IExportModule } from './module/IExport'
|
|
29
37
|
|
|
30
|
-
export { IPaintModule } from './module/IPaint'
|
|
38
|
+
export { IPaintModule, IPaintImageModule, IPaintGradientModule } from './module/IPaint'
|
|
31
39
|
export { IEffectModule } from './module/IEffect'
|
|
32
40
|
export { ICachedShape } from './ICachedShape'
|
|
33
41
|
|
|
42
|
+
export { IEditorBase, IEditorConfig } from './editor/IEditor'
|
package/src/module/IEffect.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ILeaferCanvas
|
|
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
|
|
9
|
-
innerShadow
|
|
10
|
-
blur
|
|
11
|
-
backgroundBlur
|
|
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
|
}
|
package/src/module/IExport.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import { ILeaf, IExportFileType,
|
|
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 {
|
|
5
|
+
running?: boolean
|
|
18
6
|
export(leaf: ILeaf, filename: IExportFileType | string, options?: IExportOptions | number | boolean): Promise<IExportResult>
|
|
19
7
|
}
|
package/src/module/IPaint.ts
CHANGED
|
@@ -1,25 +1,42 @@
|
|
|
1
|
-
import { ILeaferCanvas, IRenderOptions } from '@leafer/interface'
|
|
1
|
+
import { ILeaferCanvas, IRenderOptions, IBooleanMap, IBoundsData, ILeaferImage } from '@leafer/interface'
|
|
2
2
|
|
|
3
|
-
import { ILeafPaint } from '../type/IComputedType'
|
|
4
|
-
import { IUI } from '../IUI'
|
|
3
|
+
import { ILeafPaint, ILeafPaintPatternData } from '../type/IComputedType'
|
|
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
|
-
|
|
9
|
-
computeStroke?(ui: IUI): void
|
|
9
|
+
compute(attrName: IPaintAttr, ui: IUI): void
|
|
10
10
|
|
|
11
|
-
fill
|
|
12
|
-
fills
|
|
11
|
+
fill(fill: string, ui: IUI, canvas: ILeaferCanvas,): void
|
|
12
|
+
fills(fills: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
fillText(ui: IUI, canvas: ILeaferCanvas): void
|
|
15
15
|
|
|
16
|
-
stroke
|
|
17
|
-
strokes
|
|
16
|
+
stroke(stroke: string, ui: IUI, canvas: ILeaferCanvas): void
|
|
17
|
+
strokes(strokes: ILeafPaint[], ui: IUI, canvas: ILeaferCanvas): void
|
|
18
18
|
|
|
19
|
-
strokeText
|
|
20
|
-
|
|
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
|
+
}
|
|
21
24
|
|
|
22
|
-
drawTextStroke?(ui: IUI, canvas: ILeaferCanvas): void
|
|
23
25
|
|
|
24
|
-
|
|
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
|
|
31
|
+
|
|
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
|
|
25
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,17 +1,33 @@
|
|
|
1
|
-
import { IBlendMode, IMatrixData } from '@leafer/interface'
|
|
1
|
+
import { IBlendMode, ILeaferImage, IMatrixData, ITaskItem } from '@leafer/interface'
|
|
2
2
|
|
|
3
3
|
import { IColorString } from './IStringType'
|
|
4
|
-
import { IStrokeAlign, IStrokeJoin, IStrokeCap } from './IType'
|
|
4
|
+
import { IStrokeAlign, IStrokeJoin, IStrokeCap, IImagePaintMode } from './IType'
|
|
5
5
|
import { IPaintType } from './IType'
|
|
6
6
|
|
|
7
7
|
export type ILeafPaintColor = IColorString | CanvasGradient | CanvasPattern
|
|
8
8
|
|
|
9
9
|
export interface ILeafPaint {
|
|
10
|
-
type
|
|
11
|
-
style
|
|
10
|
+
type?: IPaintType
|
|
11
|
+
style?: ILeafPaintColor
|
|
12
12
|
transform?: IMatrixData
|
|
13
13
|
blendMode?: IBlendMode
|
|
14
14
|
opacity?: number
|
|
15
|
+
image?: ILeaferImage
|
|
16
|
+
loadId?: number
|
|
17
|
+
patternId?: string
|
|
18
|
+
patternTask?: ITaskItem
|
|
19
|
+
data?: ILeafPaintPatternData
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface ILeafPaintPatternData {
|
|
23
|
+
width?: number
|
|
24
|
+
height?: number
|
|
25
|
+
scaleX?: number
|
|
26
|
+
scaleY?: number
|
|
27
|
+
opacity?: number
|
|
28
|
+
transform?: IMatrixData
|
|
29
|
+
mode?: IImagePaintMode
|
|
30
|
+
repeat?: 'repeat' | 'repeat-x' | 'repeat-y'
|
|
15
31
|
}
|
|
16
32
|
|
|
17
33
|
export type ILeafFill = ILeafPaint
|
package/src/type/IType.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IPointData, IPathCommandData, IWindingRule, IBlendMode } 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
|
|
@@ -61,12 +67,16 @@ export interface IImagePaint extends IPaintBase {
|
|
|
61
67
|
type: "image"
|
|
62
68
|
url: string
|
|
63
69
|
mode?: IImagePaintMode
|
|
70
|
+
format?: IExportFileType
|
|
64
71
|
|
|
65
72
|
filters?: IImageFilters
|
|
66
73
|
|
|
67
74
|
offset?: IPointData
|
|
75
|
+
size?: number | ISizeData
|
|
68
76
|
scale?: number | IPointData
|
|
69
77
|
rotation?: number
|
|
78
|
+
|
|
79
|
+
repeat?: IRepeat
|
|
70
80
|
}
|
|
71
81
|
export interface IImageFilters {
|
|
72
82
|
exposure?: number // 曝光
|
|
@@ -78,12 +88,16 @@ export interface IImageFilters {
|
|
|
78
88
|
shadows?: number // 阴影
|
|
79
89
|
}
|
|
80
90
|
export type IImagePaintMode = 'cover' | 'fit' | 'strench' | 'clip' | 'repeat'
|
|
91
|
+
export type IRepeat = boolean | 'x' | 'y'
|
|
81
92
|
|
|
82
93
|
// 描边
|
|
83
94
|
export type IStrokeAlign = 'inside' | 'outside' | 'center'
|
|
84
95
|
export type IStrokeCap = 'none' | 'round' | 'square' | 'arrow-lines' | 'arrow-equilateral'
|
|
85
96
|
export type IStrokeJoin = 'bevel' | 'round' | 'miter'
|
|
86
97
|
|
|
98
|
+
// 箭头
|
|
99
|
+
export type IArrowType = 'none' | 'line' | 'triangle' | 'circle'
|
|
100
|
+
|
|
87
101
|
// 文本
|
|
88
102
|
export type ITextAlign = 'left' | 'center' | 'right' | 'justify'
|
|
89
103
|
export type IVerticalAlign = 'top' | 'middle' | 'bottom'
|
|
@@ -101,6 +115,7 @@ export type IFontWeightString =
|
|
|
101
115
|
| 'extra-bold'
|
|
102
116
|
| 'black'
|
|
103
117
|
export type ITextDecoration = 'none' | 'under' | 'delete'
|
|
118
|
+
export type ITextWrap = 'normal' | 'none' | 'break'
|
|
104
119
|
|
|
105
120
|
// 路径
|
|
106
121
|
export interface IVectorPath {
|