@leafer/interface 1.0.0-rc.5 → 1.0.0-rc.7

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/src/index.ts CHANGED
@@ -1,12 +1,12 @@
1
- export { IApp } from './app/IApp'
2
- export { ILeafer, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
- export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType, IBlendMode, IResizeType, ICursorType, ICursorTypeMap, IAround } from './display/ILeaf'
1
+ export { IAppBase } from './app/IApp'
2
+ export { ILeaferBase, ILeaferAttrData, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
+ export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType, IBlendMode, IEditSize, ICursorType, ICursorTypeMap, IAround } from './display/ILeaf'
4
4
  export { IBranch } from './display/IBranch'
5
5
  export { IZoomView } from './display/IView'
6
6
 
7
7
 
8
- export { ILeafData, IDataProcessor } from './data/ILeafData'
9
- export { ILeafLayout, ILayoutLocationType, ILayoutBoundsType } from './layout/ILeafLayout'
8
+ export { ILeafData, IDataProcessor, ILeafDataOptions } from './data/ILeafData'
9
+ export { ILeafLayout, ILocationType, IBoundsType } from './layout/ILeafLayout'
10
10
 
11
11
  export { ILeafDataProxy, ILeafDataProxyModule } from './display/module/ILeafDataProxy'
12
12
  export { ILeafMatrix, ILeafMatrixModule } from './display/module/ILeafMatrix'
@@ -20,7 +20,7 @@ export { IBranchRender, IBranchRenderModule } from './display/module/IBranchRend
20
20
  export { IRenderer, IRendererConfig, IRenderOptions } from './renderer/IRenderer'
21
21
  export { IWatcher, IWatchEventData, IWatcherConfig } from './watcher/IWatcher'
22
22
  export { ILayouter, ILayoutChangedData, ILayoutBlockData, ILayouterConfig, IPartLayoutConfig } from './layouter/ILayouter'
23
- export { ISelector, ISelectorConfig, ISelectPathResult, ISelectPathOptions } from './selector/ISelector'
23
+ export { ISelector, ISelectorConfig, ISelectorProxy, IFindMethod, ISelectPathResult, ISelectPathOptions, AnswerType } from './selector/ISelector'
24
24
 
25
25
  export { ICanvasManager } from './canvas/ICanvasManager'
26
26
  export { IHitCanvasManager } from './canvas/IHitCanvasManager'
@@ -35,7 +35,7 @@ export { IPlugin } from './plugin/IPlugin'
35
35
 
36
36
 
37
37
  export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasConfig, IHitCanvasConfig, IBlobFunction, IBlob } from './canvas/ILeaferCanvas'
38
- export { ISkiaCanvas, ISkiaCanvasExportConfig, ICanvasType } from './canvas/ISkiaCanvas'
38
+ export { ISkiaCanvas, ISkiaCanvasExportConfig, ICanvasType, ISkiaNAPICanvas } from './canvas/ISkiaCanvas'
39
39
  export { IPathDrawer, IPathCreator } from './path/IPathDrawer'
40
40
  export { IWindingRule, ICanvasContext2D, ITextMetrics, IPath2D } from './canvas/ICanvas'
41
41
  export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData } from './path/IPathCommand'
@@ -49,7 +49,7 @@ export { IUIEvent, IPointerEvent, PointerType, IDragEvent, IDropEvent, ISwipeEve
49
49
  export { IInteraction, IInteractionCanvas, IInteractionConfig, IWheelConfig, IPointerConfig } from './interaction/IInteraction'
50
50
 
51
51
 
52
- export { __Number, __Boolean, __String, __Object, __Value, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IDataTypeHandle } from './data/IData'
52
+ export { INumber, IBoolean, IString, IValue, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IDataTypeHandle } from './data/IData'
53
53
  export { ILeafList, ILeafArrayMap, ILeafMap, ILeafLevelList, ILeafListItemCallback } from './data/IList'
54
- export { IPoint, IPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataHandle, IOffsetBoundsData, ITwoPointBounds, ITwoPointBoundsData, IAutoBounds, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithLayoutData, IMatrixDecompositionData, IMatrixDecompositionAttr } from './math/IMath'
55
- export { IFunction } from './function/IFunction'
54
+ export { IPoint, IPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataFn, IOffsetBoundsData, ITwoPointBoundsData, IAutoBounds, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithScaleData, IMatrixWithLayoutData, IScaleRotationData, IScaleData, ISkewData, ILayoutBoundsData, ILayoutData, ILayoutAttr } from './math/IMath'
55
+ export { IFunction, IAttrDecorator } from './function/IFunction'
@@ -17,6 +17,7 @@ export interface IInteraction extends IControl {
17
17
 
18
18
  running: boolean
19
19
  readonly dragging: boolean
20
+ readonly isDragEmpty: boolean
20
21
  readonly moveMode: boolean
21
22
 
22
23
  config: IInteractionConfig
@@ -77,13 +78,14 @@ export interface IZoomConfig {
77
78
 
78
79
  export interface IMoveConfig {
79
80
  holdSpaceKey?: boolean
81
+ drag?: boolean
80
82
  dragEmpty?: boolean
81
83
  dragOut?: boolean
82
84
  autoDistance?: number
83
85
  }
84
86
 
85
87
  export interface IWheelConfig {
86
- zoomMode?: boolean
88
+ zoomMode?: boolean | 'mouse'
87
89
  zoomSpeed?: number // 取值范围 0 ~ 1, 默认0.5
88
90
  moveSpeed?: number
89
91
  rotateSpeed?: number // 取值范围 0 ~ 1, 默认0.5
@@ -1,8 +1,8 @@
1
- import { IBoundsData, IMatrixData } from '../math/IMath'
1
+ import { IBoundsData, IMatrixData, ILayoutBoundsData, IPointData } from '../math/IMath'
2
2
  import { ILeaf } from '../display/ILeaf'
3
3
 
4
- export type ILayoutLocationType = 'world' | 'local' | 'inner'
5
- export type ILayoutBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render'
4
+ export type ILocationType = 'world' | 'local' | 'inner'
5
+ export type IBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render'
6
6
 
7
7
  export interface ILeafLayout {
8
8
 
@@ -23,10 +23,12 @@ export interface ILeafLayout {
23
23
  // local
24
24
 
25
25
  //localBoxBounds: IBoundsData = leaf.__local
26
- localStrokeBounds: IBoundsData
27
- localRenderBounds: IBoundsData
26
+ localStrokeBounds?: IBoundsData
27
+ localRenderBounds?: IBoundsData
28
28
 
29
29
  // state
30
+ resized: boolean
31
+ waitAutoLayout: boolean
30
32
 
31
33
  // matrix changed
32
34
  matrixChanged: boolean // include positionChanged scaleChanged skewChanged
@@ -60,10 +62,20 @@ export interface ILeafLayout {
60
62
  strokeBoxSpread: number
61
63
  renderShapeSpread: number
62
64
 
63
- checkUpdate(force?: boolean): void
65
+ // temp local
66
+ a: number
67
+ b: number
68
+ c: number
69
+ d: number
70
+ e: number
71
+ f: number
64
72
 
65
- getTransform(locationType: ILayoutLocationType): IMatrixData
66
- getBounds(type: ILayoutBoundsType, locationType: ILayoutLocationType): IBoundsData
73
+ update(): void
74
+
75
+ getTransform(relative?: ILocationType | ILeaf): IMatrixData
76
+ getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData
77
+ getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData
78
+ getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[]
67
79
 
68
80
  // 独立 / 引用 boxBounds
69
81
  spreadStroke(): void
@@ -34,6 +34,7 @@ export interface ILayouterConfig {
34
34
  export interface ILayouter extends IControl {
35
35
  target: ILeaf
36
36
  layoutedBlocks: ILayoutBlockData[]
37
+ extraBlock: ILayoutBlockData
37
38
 
38
39
  totalTimes: number
39
40
  times: number
@@ -54,6 +55,8 @@ export interface ILayouter extends IControl {
54
55
  partLayout(): void
55
56
  fullLayout(): void
56
57
 
58
+ addExtra(leaf: ILeaf): void
59
+
57
60
  createBlock(data: ILeafList | ILeaf[]): ILayoutBlockData
58
61
  getBlocks(list: ILeafList): ILayoutBlockData[]
59
62
  addBlocks(current: ILayoutBlockData[]): void
package/src/math/IMath.ts CHANGED
@@ -6,21 +6,25 @@ export interface IPointData {
6
6
  }
7
7
 
8
8
  export interface IPoint extends IPointData {
9
- set(x?: number, y?: number): void
10
- copy(point: IPointData): IPoint
9
+ set(x?: number | IPointData, y?: number): IPoint
10
+ get(): IPointData
11
11
  clone(): IPoint
12
12
 
13
- rotate(angle: number, center?: IPointData): IPoint
13
+ rotate(rotation: number, origin?: IPointData): IPoint
14
+ rotateOf(origin: IPointData, rotation: number): IPoint
15
+ getRotation(origin: IPointData, to: IPointData, toOrigin?: IPointData): number
14
16
 
15
17
  toInnerOf(matrix: IMatrixData, to?: IPointData): IPoint
16
18
  toOuterOf(matrix: IMatrixData, to?: IPointData): IPoint
17
19
 
18
- getCenter(to: IPointData): IPointData
20
+ getCenter(to: IPointData): IPoint
19
21
  getDistance(to: IPointData): number
22
+ getDistancePoint(to: IPointData, distance: number): IPoint
23
+
20
24
  getAngle(to: IPointData): number
21
25
  getAtan2(to: IPointData): number
22
26
 
23
- reset(): void
27
+ reset(): IPoint
24
28
  }
25
29
 
26
30
  export interface IRadiusPointData extends IPointData {
@@ -47,16 +51,17 @@ export interface IOffsetBoundsData extends IBoundsData {
47
51
  offsetY: number
48
52
  }
49
53
 
50
- export interface IBoundsDataHandle {
54
+ export interface IBoundsDataFn {
51
55
  (target: any): IBoundsData
52
56
  }
53
57
 
54
- export interface IBounds extends IBoundsData {
55
- set(x?: number, y?: number, width?: number, height?: number): void
56
- copy(bounds: IBoundsData): IBounds
58
+ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
59
+ set(x?: number | IBoundsData, y?: number, width?: number, height?: number): IBounds
60
+ get(): IBoundsData
57
61
  clone(): IBounds
58
62
 
59
63
  scale(scaleX: number, scaleY?: number): IBounds
64
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IBounds
60
65
  toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds
61
66
  getFitMatrix(put: IBoundsData): IMatrix
62
67
 
@@ -65,11 +70,13 @@ export interface IBounds extends IBoundsData {
65
70
  unsign(): IBounds
66
71
 
67
72
  add(bounds: IBoundsData): IBounds
68
- addList(boundsList: IBounds[]): IBounds
69
- setByList(boundsList: IBounds[], addMode?: boolean): IBounds
70
- addListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle): IBounds
71
- setByListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle, addMode: boolean): IBounds
72
- setByPoints(points: IPointData[]): IBounds
73
+ addList(boundsList: IBoundsData[]): IBounds
74
+ setList(boundsList: IBoundsData[]): IBounds
75
+ addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
76
+ setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds
77
+
78
+ setPoints(points: IPointData[]): IBounds
79
+ getPoints(): IPointData[] // topLeft, topRight, bottomRight, bottomLeft
73
80
 
74
81
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean
75
82
  hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixWithLayoutData): boolean
@@ -91,12 +98,6 @@ export interface ITwoPointBoundsData {
91
98
  maxY: number
92
99
  }
93
100
 
94
- export interface ITwoPointBounds extends ITwoPointBoundsData {
95
- addPoint(x: number, y: number): void
96
- addBounds(x: number, y: number, width: number, height: number): void
97
- add(pointBounds: ITwoPointBoundsData): void
98
- }
99
-
100
101
 
101
102
  export interface IAutoBoundsData {
102
103
  top?: number
@@ -125,17 +126,24 @@ export interface IMatrixData {
125
126
  f: number
126
127
  }
127
128
 
128
- export interface IMatrixDecompositionData {
129
- x: number
130
- y: number
129
+ export interface IScaleData {
131
130
  scaleX: number
132
131
  scaleY: number
132
+ }
133
+
134
+ export interface IScaleRotationData extends IScaleData {
133
135
  rotation: number
136
+ }
137
+
138
+ export interface ISkewData {
134
139
  skewX: number
135
140
  skewY: number
136
141
  }
137
142
 
138
- export type IMatrixDecompositionAttr =
143
+ export interface ILayoutData extends IScaleRotationData, ISkewData, IPointData {
144
+ }
145
+
146
+ export type ILayoutAttr =
139
147
  | 'x'
140
148
  | 'y'
141
149
  | 'scaleX'
@@ -144,9 +152,12 @@ export type IMatrixDecompositionAttr =
144
152
  | 'skewX'
145
153
  | 'skewY'
146
154
 
155
+
156
+ export interface ILayoutBoundsData extends ILayoutData, IBoundsData {
157
+ }
147
158
  export interface IMatrix extends IMatrixData {
148
- set(a: number, b: number, c: number, d: number, e: number, f: number): void
149
- copy(matrix: IMatrixData): IMatrix
159
+ set(a: number | IMatrixData, b: number, c: number, d: number, e: number, f: number): IMatrix
160
+ get(): IMatrixData
150
161
  clone(): IMatrix
151
162
 
152
163
  translate(x: number, y: number): IMatrix
@@ -164,19 +175,24 @@ export interface IMatrix extends IMatrixData {
164
175
  skewOfOuter(origin: IPointData, x: number, y?: number): IMatrix
165
176
  skewOfInner(origin: IPointData, x: number, y?: number): IMatrix
166
177
 
167
- multiply(matrix: IMatrixData): IMatrix
168
- divide(matrix: IMatrixData): IMatrix
169
- preMultiply(matrix: IMatrixData): IMatrix
178
+ multiply(child: IMatrixData): IMatrix
179
+ multiplyParent(parent: IMatrixData): IMatrix
180
+
181
+ divide(child: IMatrixData): IMatrix
182
+ divideParent(parent: IMatrixData): IMatrix
170
183
  invert(): IMatrix
171
184
 
172
185
  toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void
173
186
  toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void
174
187
 
175
- decompose(): IMatrixDecompositionData
188
+ setLayout(data: ILayoutData, origin?: IPointData): IMatrix
189
+ getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData
176
190
 
177
191
  reset(): void
178
192
  }
179
193
 
180
194
  export interface IMatrixWithBoundsData extends IMatrixData, IBoundsData { }
181
195
 
182
- export interface IMatrixWithLayoutData extends IMatrixData, IMatrixDecompositionData, IBoundsData { }
196
+ export interface IMatrixWithScaleData extends IMatrixData, IScaleData { }
197
+
198
+ export interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData { }
@@ -4,12 +4,14 @@ import { ILeaf } from '../display/ILeaf'
4
4
  import { IExportFileType, IExportImageType } from '../file/IFileType'
5
5
  import { IBoundsData, ISizeData } from '../math/IMath'
6
6
  import { IObject } from '../data/IData'
7
+ import { ICanvasType } from '../canvas/ISkiaCanvas'
7
8
 
8
9
  export interface IPlatform {
9
10
  name?: 'web' | 'node' | 'miniapp'
10
11
  os?: 'Mac' | 'Windows' | 'Linux'
11
12
  requestRender?(render: IFunction): void
12
13
  canvas?: ILeaferCanvas
14
+ canvasType?: ICanvasType
13
15
  isWorker?: boolean
14
16
  isMobile?: boolean
15
17
  devicePixelRatio?: number
@@ -19,7 +21,6 @@ export interface IPlatform {
19
21
  fullImageShadow?: boolean // safari need
20
22
  syncDomFont?: boolean // firefox need
21
23
  layout?(target: ILeaf): void
22
- realtimeLayout?: boolean
23
24
  origin?: {
24
25
  createCanvas(width: number, height: number, format?: 'svg' | 'pdf'): any
25
26
  canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string | Promise<string>
@@ -28,13 +29,19 @@ export interface IPlatform {
28
29
  loadImage(url: string): Promise<any>
29
30
  noRepeat?: string // fix: 微信小程序 createPattern 直接使用 no-repeat 有bug,导致无法显示
30
31
  },
32
+ roundRectPatch?: boolean // fix: skia-canvas roundRect
33
+ ellipseToCurve?: boolean, // fix: skia 绘制圆环和椭圆弧
31
34
  event?: {
32
35
  stopDefault(origin: IObject): void
33
36
  stopNow(origin: IObject): void
34
37
  stop(origin: IObject): void
35
38
  },
36
39
  miniapp?: IMiniapp
37
- imageSuffix?: string // 需要带上后缀区分dom中image标签的缓存,否则会导致浏览器缓存跨域问题
40
+ image: {
41
+ maxCacheSize: number // 最大等级缓存,一般取当前屏幕大小,默认2k: 2560 * 1600
42
+ maxPatternSize: number // 最大repeat pattern缓存, 默认4k: 4096 * 2160
43
+ suffix: string // 需要带上后缀区分dom中image标签的缓存,否则会导致浏览器缓存跨域问题
44
+ }
38
45
  }
39
46
 
40
47
 
@@ -1,4 +1,4 @@
1
- import { ILeafer } from '../app/ILeafer'
1
+ import { ILeaferBase } from '../app/ILeafer'
2
2
  import { IObject } from '../data/IData'
3
3
 
4
4
  export interface IPlugin extends IObject {
@@ -6,5 +6,5 @@ export interface IPlugin extends IObject {
6
6
  importVersion: string
7
7
  import: string[]
8
8
  run(LeaferUI: IObject, config: IObject): void
9
- onLeafer?(leafer: ILeafer): void
9
+ onLeafer?(leafer: ILeaferBase): void
10
10
  }
@@ -19,19 +19,35 @@ export interface ISelectorConfig {
19
19
 
20
20
  }
21
21
 
22
+ export enum AnswerType {
23
+ No = 0,
24
+ Yes = 1,
25
+ NoAndSkip = 2,
26
+ YesAndSkip = 3
27
+ }
28
+
29
+ export interface IFindMethod {
30
+ (leaf: ILeaf, options?: any): AnswerType
31
+ }
32
+
33
+ export interface ISelectorProxy {
34
+ list: ILeaf[]
35
+ }
36
+
22
37
  export interface ISelector {
23
38
  target: ILeaf
24
39
 
25
- list: ILeafList
40
+ proxy?: ISelectorProxy
26
41
 
27
42
  config: ISelectorConfig
28
43
 
29
44
  getByPoint(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult
30
45
 
31
- find(name: number | string, branch?: ILeaf): ILeaf | ILeaf[]
32
- getByInnerId(name: number, branch?: ILeaf): ILeaf
33
- getById(name: string, branch?: ILeaf): ILeaf
34
- getByClassName(name: string, branch?: ILeaf): ILeaf[]
35
- getByTagName(name: string, branch?: ILeaf): ILeaf[]
46
+ getBy(condition: number | string | IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[]
47
+ getByInnerId(innerId: number, branch?: ILeaf): ILeaf
48
+ getById(id: string, branch?: ILeaf): ILeaf
49
+ getByClassName(className: string, branch?: ILeaf): ILeaf[]
50
+ getByTag(tag: string, branch?: ILeaf): ILeaf[]
51
+ getByMethod(method: IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[]
36
52
  destroy(): void
37
53
  }