@leafer/interface 1.0.0-rc.6 → 1.0.0-rc.8

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.
@@ -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,13 +51,13 @@ 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
@@ -66,11 +70,13 @@ export interface IBounds extends IBoundsData {
66
70
  unsign(): IBounds
67
71
 
68
72
  add(bounds: IBoundsData): IBounds
69
- addList(boundsList: IBounds[]): IBounds
70
- setByList(boundsList: IBounds[], addMode?: boolean): IBounds
71
- addListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle): IBounds
72
- setByListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle, addMode: boolean): IBounds
73
- 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
74
80
 
75
81
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean
76
82
  hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixWithLayoutData): boolean
@@ -92,12 +98,6 @@ export interface ITwoPointBoundsData {
92
98
  maxY: number
93
99
  }
94
100
 
95
- export interface ITwoPointBounds extends ITwoPointBoundsData {
96
- addPoint(x: number, y: number): void
97
- addBounds(x: number, y: number, width: number, height: number): void
98
- add(pointBounds: ITwoPointBoundsData): void
99
- }
100
-
101
101
 
102
102
  export interface IAutoBoundsData {
103
103
  top?: number
@@ -126,17 +126,24 @@ export interface IMatrixData {
126
126
  f: number
127
127
  }
128
128
 
129
- export interface IMatrixDecompositionData {
130
- x: number
131
- y: number
129
+ export interface IScaleData {
132
130
  scaleX: number
133
131
  scaleY: number
132
+ }
133
+
134
+ export interface IScaleRotationData extends IScaleData {
134
135
  rotation: number
136
+ }
137
+
138
+ export interface ISkewData {
135
139
  skewX: number
136
140
  skewY: number
137
141
  }
138
142
 
139
- export type IMatrixDecompositionAttr =
143
+ export interface ILayoutData extends IScaleRotationData, ISkewData, IPointData {
144
+ }
145
+
146
+ export type ILayoutAttr =
140
147
  | 'x'
141
148
  | 'y'
142
149
  | 'scaleX'
@@ -145,9 +152,12 @@ export type IMatrixDecompositionAttr =
145
152
  | 'skewX'
146
153
  | 'skewY'
147
154
 
155
+
156
+ export interface ILayoutBoundsData extends ILayoutData, IBoundsData {
157
+ }
148
158
  export interface IMatrix extends IMatrixData {
149
- set(a: number, b: number, c: number, d: number, e: number, f: number): void
150
- copy(matrix: IMatrixData): IMatrix
159
+ set(a: number | IMatrixData, b: number, c: number, d: number, e: number, f: number): IMatrix
160
+ get(): IMatrixData
151
161
  clone(): IMatrix
152
162
 
153
163
  translate(x: number, y: number): IMatrix
@@ -165,19 +175,24 @@ export interface IMatrix extends IMatrixData {
165
175
  skewOfOuter(origin: IPointData, x: number, y?: number): IMatrix
166
176
  skewOfInner(origin: IPointData, x: number, y?: number): IMatrix
167
177
 
168
- multiply(matrix: IMatrixData): IMatrix
169
- divide(matrix: IMatrixData): IMatrix
170
- 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
171
183
  invert(): IMatrix
172
184
 
173
185
  toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void
174
186
  toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void
175
187
 
176
- decompose(): IMatrixDecompositionData
188
+ setLayout(data: ILayoutData, origin?: IPointData): IMatrix
189
+ getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData
177
190
 
178
191
  reset(): void
179
192
  }
180
193
 
181
194
  export interface IMatrixWithBoundsData extends IMatrixData, IBoundsData { }
182
195
 
183
- export interface IMatrixWithLayoutData extends IMatrixData, IMatrixDecompositionData, IBoundsData { }
196
+ export interface IMatrixWithScaleData extends IMatrixData, IScaleData { }
197
+
198
+ export interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData { }
@@ -21,7 +21,6 @@ export interface IPlatform {
21
21
  fullImageShadow?: boolean // safari need
22
22
  syncDomFont?: boolean // firefox need
23
23
  layout?(target: ILeaf): void
24
- realtimeLayout?: boolean
25
24
  origin?: {
26
25
  createCanvas(width: number, height: number, format?: 'svg' | 'pdf'): any
27
26
  canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string | Promise<string>
@@ -38,7 +37,11 @@ export interface IPlatform {
38
37
  stop(origin: IObject): void
39
38
  },
40
39
  miniapp?: IMiniapp
41
- 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
+ }
42
45
  }
43
46
 
44
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,14 +19,25 @@ 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
+
22
29
  export interface IFindMethod {
23
- (leaf: ILeaf, options?: any): any
30
+ (leaf: ILeaf, options?: any): AnswerType
31
+ }
32
+
33
+ export interface ISelectorProxy {
34
+ list: ILeaf[]
24
35
  }
25
36
 
26
37
  export interface ISelector {
27
38
  target: ILeaf
28
39
 
29
- list: ILeafList
40
+ proxy?: ISelectorProxy
30
41
 
31
42
  config: ISelectorConfig
32
43