@leafer/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 +5 -2
- package/src/app/IApp.ts +3 -3
- package/src/app/ILeafer.ts +41 -17
- package/src/canvas/ICanvas.ts +2 -0
- package/src/canvas/IHitCanvasManager.ts +0 -1
- package/src/canvas/ILeaferCanvas.ts +13 -9
- package/src/canvas/ISkiaCanvas.ts +20 -1
- package/src/data/IData.ts +5 -7
- package/src/data/ILeafData.ts +12 -6
- package/src/data/IList.ts +9 -6
- package/src/display/IBranch.ts +4 -2
- package/src/display/ILeaf.ts +251 -73
- package/src/display/IView.ts +1 -4
- package/src/display/module/IBranchRender.ts +2 -2
- package/src/display/module/ILeafBounds.ts +4 -0
- package/src/display/module/ILeafDataProxy.ts +5 -3
- package/src/display/module/ILeafHit.ts +3 -1
- package/src/display/module/ILeafRender.ts +1 -0
- package/src/event/IEvent.ts +3 -23
- package/src/event/IEventer.ts +6 -1
- package/src/event/IUIEvent.ts +18 -11
- package/src/file/IExport.ts +24 -0
- package/src/file/IFileType.ts +1 -1
- package/src/function/IFunction.ts +9 -0
- package/src/image/IImageManager.ts +13 -2
- package/src/image/ILeaferImage.ts +32 -1
- package/src/index.ts +17 -16
- package/src/interaction/ICursor.ts +16 -0
- package/src/interaction/IInteraction.ts +35 -7
- package/src/layout/ILeafLayout.ts +33 -15
- package/src/layouter/ILayouter.ts +3 -0
- package/src/math/IMath.ts +70 -36
- package/src/path/IPathDrawer.ts +5 -0
- package/src/platform/IPlatform.ts +21 -4
- package/src/plugin/IPlugin.ts +2 -2
- package/src/renderer/IRenderer.ts +3 -2
- package/src/selector/ISelector.ts +26 -9
- package/src/task/ITaskProcessor.ts +19 -3
- package/src/watcher/IWatcher.ts +5 -1
- package/types/index.d.ts +1859 -0
- package/src/display/module/ILeafMask.ts +0 -12
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer/interface",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.10",
|
|
4
4
|
"description": "@leafer/interface",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
|
+
"types": "types/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"types",
|
|
12
|
+
"dist"
|
|
10
13
|
],
|
|
11
14
|
"repository": {
|
|
12
15
|
"type": "git",
|
package/src/app/IApp.ts
CHANGED
package/src/app/ILeafer.ts
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { ILeaf } from '../display/ILeaf'
|
|
1
|
+
import { ILeaf, ICursorType } from '../display/ILeaf'
|
|
2
2
|
import { IRenderer, IRendererConfig } from '../renderer/IRenderer'
|
|
3
3
|
import { IHitCanvas, ILeaferCanvas, ILeaferCanvasConfig, IHitCanvasConfig } from '../canvas/ILeaferCanvas'
|
|
4
4
|
import { ILayouter, ILayouterConfig } from '../layouter/ILayouter'
|
|
5
5
|
import { ISelector, ISelectorConfig } from '../selector/ISelector'
|
|
6
6
|
import { IInteraction, IInteractionCanvas, IInteractionConfig } from '../interaction/IInteraction'
|
|
7
7
|
import { IWatcher, IWatcherConfig } from '../watcher/IWatcher'
|
|
8
|
-
import { IAutoBounds, IScreenSizeData } from '../math/IMath'
|
|
8
|
+
import { IAutoBounds, IBoundsData, IPointData, IScreenSizeData } from '../math/IMath'
|
|
9
9
|
import { ICanvasManager } from '../canvas/ICanvasManager'
|
|
10
10
|
import { IHitCanvasManager } from '../canvas/IHitCanvasManager'
|
|
11
|
-
import { IImageManager } from '../image/IImageManager'
|
|
12
11
|
import { IEventListenerId } from '../event/IEventer'
|
|
13
12
|
import { IObject } from '../data/IData'
|
|
14
13
|
import { IZoomView } from '../display/IView'
|
|
15
|
-
import {
|
|
14
|
+
import { IAppBase } from './IApp'
|
|
16
15
|
import { ILeaferImage, ILeaferImageConfig } from '../image/ILeaferImage'
|
|
17
16
|
import { IControl } from '../control/IControl'
|
|
18
17
|
import { IFunction } from '../function/IFunction'
|
|
19
18
|
|
|
20
19
|
|
|
21
|
-
export type ILeaferType = 'draw' | 'design' | 'board' | 'document' | '
|
|
20
|
+
export type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'app' | 'game' | 'player' | 'chart'
|
|
22
21
|
export interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
|
|
23
22
|
start?: boolean
|
|
24
23
|
type?: ILeaferType
|
|
25
24
|
realCanvas?: boolean
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
export interface
|
|
29
|
-
|
|
30
|
-
readonly isApp: boolean
|
|
31
|
-
parent?: IApp
|
|
32
|
-
|
|
27
|
+
export interface ILeaferAttrData {
|
|
33
28
|
running: boolean
|
|
29
|
+
created: boolean
|
|
34
30
|
ready: boolean
|
|
35
31
|
viewReady: boolean
|
|
36
|
-
|
|
32
|
+
imageReady: boolean
|
|
33
|
+
viewCompleted: boolean
|
|
34
|
+
layoutLocked: boolean
|
|
35
|
+
|
|
36
|
+
transforming: boolean
|
|
37
37
|
|
|
38
38
|
pixelRatio: number
|
|
39
39
|
|
|
@@ -50,29 +50,50 @@ export interface ILeafer extends IZoomView, IControl {
|
|
|
50
50
|
|
|
51
51
|
canvasManager: ICanvasManager
|
|
52
52
|
hitCanvasManager?: IHitCanvasManager
|
|
53
|
-
imageManager: IImageManager
|
|
54
53
|
|
|
55
54
|
autoLayout?: IAutoBounds
|
|
56
55
|
|
|
57
56
|
config: ILeaferConfig
|
|
58
57
|
|
|
58
|
+
readonly cursorPoint: IPointData
|
|
59
|
+
leafs: number
|
|
60
|
+
|
|
59
61
|
__eventIds: IEventListenerId[]
|
|
62
|
+
__nextRenderWait: IFunction[]
|
|
63
|
+
|
|
64
|
+
init(userConfig?: ILeaferConfig, parentApp?: IAppBase): void
|
|
65
|
+
|
|
66
|
+
start(): void
|
|
67
|
+
stop(): void
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
unlockLayout(): void
|
|
70
|
+
lockLayout(): void
|
|
71
|
+
|
|
72
|
+
setZoomLayer(zoomLayer: ILeaf): void
|
|
63
73
|
forceFullRender(): void
|
|
74
|
+
forceRender(bounds?: IBoundsData): void
|
|
75
|
+
updateCursor(cursor?: ICursorType): void
|
|
64
76
|
resize(size: IScreenSizeData): void
|
|
65
|
-
|
|
77
|
+
|
|
78
|
+
waitReady(item: IFunction): void
|
|
79
|
+
waitViewReady(item: IFunction): void
|
|
80
|
+
waitViewCompleted(item: IFunction): void
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface ILeaferBase extends IZoomView, IControl, ILeaferAttrData {
|
|
84
|
+
readonly isApp: boolean
|
|
85
|
+
readonly app: ILeaferBase
|
|
86
|
+
parent?: IAppBase
|
|
66
87
|
}
|
|
67
88
|
|
|
68
89
|
export interface ILeaferTypeCreator {
|
|
69
90
|
list: ILeaferTypeList
|
|
70
91
|
register(name: string, fn: ILeaferTypeFunction): void
|
|
71
|
-
run(name: string, leafer:
|
|
92
|
+
run(name: string, leafer: ILeaferBase): void
|
|
72
93
|
}
|
|
73
94
|
|
|
74
95
|
export interface ILeaferTypeFunction {
|
|
75
|
-
(leafer:
|
|
96
|
+
(leafer: ILeaferBase): void
|
|
76
97
|
}
|
|
77
98
|
|
|
78
99
|
export interface ILeaferTypeList {
|
|
@@ -83,6 +104,7 @@ export interface ICreator {
|
|
|
83
104
|
image?(options?: ILeaferImageConfig): ILeaferImage
|
|
84
105
|
canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas
|
|
85
106
|
hitCanvas?(options?: IHitCanvasConfig, manager?: ICanvasManager): IHitCanvas
|
|
107
|
+
hitCanvasManager?(): IHitCanvasManager
|
|
86
108
|
|
|
87
109
|
watcher?(target: ILeaf, options?: IWatcherConfig): IWatcher
|
|
88
110
|
layouter?(target: ILeaf, options?: ILayouterConfig): ILayouter
|
|
@@ -90,6 +112,8 @@ export interface ICreator {
|
|
|
90
112
|
selector?(target: ILeaf, options?: ISelectorConfig): ISelector
|
|
91
113
|
|
|
92
114
|
interaction?(target: ILeaf, canvas: IInteractionCanvas, selector: ISelector, options?: IInteractionConfig): IInteraction
|
|
115
|
+
|
|
116
|
+
editor?(options?: IObject): ILeaf
|
|
93
117
|
}
|
|
94
118
|
|
|
95
119
|
export interface IUICreator {
|
package/src/canvas/ICanvas.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { IResizeEventListener } from '../event/IEvent'
|
|
|
5
5
|
import { IPathDrawer } from '../path/IPathDrawer'
|
|
6
6
|
import { InnerId } from '../event/IEventer'
|
|
7
7
|
import { ICanvasManager } from './ICanvasManager'
|
|
8
|
+
import { IExportFileType } from '../file/IFileType'
|
|
9
|
+
import { IExportOptions } from '../file/IExport'
|
|
8
10
|
|
|
9
11
|
export interface ILeaferCanvasConfig extends IAutoBoundsData {
|
|
10
12
|
view?: string | IObject
|
|
@@ -12,7 +14,6 @@ export interface ILeaferCanvasConfig extends IAutoBoundsData {
|
|
|
12
14
|
pixelRatio?: number
|
|
13
15
|
smooth?: boolean
|
|
14
16
|
hittable?: boolean
|
|
15
|
-
offscreen?: boolean
|
|
16
17
|
webgl?: boolean
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -74,7 +75,7 @@ interface ICanvasMethod {
|
|
|
74
75
|
strokeRect(x: number, y: number, width: number, height: number): void
|
|
75
76
|
clearRect(x: number, y: number, width: number, height: number): void
|
|
76
77
|
|
|
77
|
-
transform(a: number, b
|
|
78
|
+
transform(a: number | IMatrixData, b?: number, c?: number, d?: number, e?: number, f?: number): void
|
|
78
79
|
translate(x: number, y: number): void
|
|
79
80
|
scale(x: number, y: number): void
|
|
80
81
|
rotate(angle: number): void
|
|
@@ -110,12 +111,15 @@ interface ICanvasMethod {
|
|
|
110
111
|
setStrokeOptions(options: ICanvasStrokeOptions): void
|
|
111
112
|
|
|
112
113
|
setWorld(matrix: IMatrixData, parentMatrix?: IMatrixData): void
|
|
114
|
+
useWorldTransform(worldTransform?: IMatrixData): void
|
|
113
115
|
|
|
114
116
|
setWorldShadow(x: number, y: number, blur: number, color?: string): void
|
|
115
117
|
setWorldBlur(blur: number): void
|
|
116
118
|
|
|
117
119
|
copyWorld(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void
|
|
120
|
+
copyWorldByReset(canvas: ILeaferCanvas, from?: IBoundsData, to?: IBoundsData, blendMode?: string, onlyResetTransform?: boolean): void
|
|
118
121
|
copyWorldToInner(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toInnerBounds: IBoundsData, blendMode?: string): void
|
|
122
|
+
|
|
119
123
|
useMask(maskCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void
|
|
120
124
|
useEraser(eraserCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void
|
|
121
125
|
|
|
@@ -127,6 +131,7 @@ interface ICanvasMethod {
|
|
|
127
131
|
clear(): void
|
|
128
132
|
}
|
|
129
133
|
|
|
134
|
+
export type ILeaferCanvasView = any
|
|
130
135
|
export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
131
136
|
|
|
132
137
|
readonly innerId: InnerId
|
|
@@ -152,13 +157,11 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
|
152
157
|
|
|
153
158
|
autoLayout: boolean
|
|
154
159
|
|
|
155
|
-
view:
|
|
160
|
+
view: ILeaferCanvasView
|
|
156
161
|
parentView: any
|
|
157
162
|
|
|
158
163
|
unreal?: boolean
|
|
159
164
|
|
|
160
|
-
offscreen: boolean
|
|
161
|
-
|
|
162
165
|
context: ICanvasContext2D
|
|
163
166
|
|
|
164
167
|
recycled?: boolean
|
|
@@ -167,8 +170,9 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
|
167
170
|
|
|
168
171
|
init(): void
|
|
169
172
|
|
|
173
|
+
export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): string | Promise<any>
|
|
170
174
|
toBlob(type?: string, quality?: number): Promise<IBlob>
|
|
171
|
-
toDataURL(type?: string, quality?: number): string
|
|
175
|
+
toDataURL(type?: string, quality?: number): string | Promise<string>
|
|
172
176
|
saveAs(filename: string, quality?: number): Promise<boolean>
|
|
173
177
|
|
|
174
178
|
startAutoLayout(autoBounds: IAutoBounds, listener: IResizeEventListener): void
|
|
@@ -180,10 +184,10 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
|
180
184
|
|
|
181
185
|
// other
|
|
182
186
|
isSameSize(options: ILeaferCanvasConfig): boolean
|
|
183
|
-
getSameCanvas(useSameWorldTransform?: boolean): ILeaferCanvas
|
|
184
|
-
|
|
185
|
-
recycle(): void
|
|
187
|
+
getSameCanvas(useSameWorldTransform?: boolean, useSameSmooth?: boolean): ILeaferCanvas
|
|
188
|
+
recycle(clearBounds?: IBoundsData): void
|
|
186
189
|
|
|
190
|
+
updateRender(): void
|
|
187
191
|
unrealCanvas(): void
|
|
188
192
|
destroy(): void
|
|
189
193
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { IExportFileType, IExportImageType } from '../file/IFileType'
|
|
2
2
|
|
|
3
|
-
export type ICanvasType = 'skia' | 'canvas' | 'wx'
|
|
3
|
+
export type ICanvasType = 'skia' | 'napi' | 'canvas' | 'wx'
|
|
4
4
|
|
|
5
|
+
// skia
|
|
5
6
|
export interface ISkiaCanvas {
|
|
6
7
|
toBuffer(format: IExportFileType, config: ISkiaCanvasExportConfig): Promise<any>
|
|
7
8
|
toBufferSync(format: IExportFileType, config: ISkiaCanvasExportConfig): any
|
|
@@ -17,4 +18,22 @@ export interface ISkiaCanvasExportConfig {
|
|
|
17
18
|
density?: number,
|
|
18
19
|
quality?: number,
|
|
19
20
|
outline?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// skia-napi
|
|
24
|
+
export interface ISkiaNAPICanvas {
|
|
25
|
+
encodeSync(format: 'webp' | 'jpeg', quality?: number): any
|
|
26
|
+
encodeSync(format: 'png'): any
|
|
27
|
+
|
|
28
|
+
encode(format: 'webp' | 'jpeg' | string, quality?: number): Promise<any>
|
|
29
|
+
encode(format: 'png'): Promise<any>
|
|
30
|
+
|
|
31
|
+
toBuffer(mime: 'image/png'): any
|
|
32
|
+
toBuffer(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): any
|
|
33
|
+
|
|
34
|
+
toDataURL(mime?: 'image/png'): string
|
|
35
|
+
toDataURL(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): string
|
|
36
|
+
|
|
37
|
+
toDataURLAsync(mime?: 'image/png'): Promise<string>
|
|
38
|
+
toDataURLAsync(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): Promise<string>
|
|
20
39
|
}
|
package/src/data/IData.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
export type
|
|
2
|
-
export type
|
|
3
|
-
export type
|
|
4
|
-
export type
|
|
5
|
-
export type __Value = __Number | __Boolean | __String | __Object //
|
|
1
|
+
export type INumber = number // number | string will convert to number
|
|
2
|
+
export type IBoolean = boolean // boolean | string will convert to boolean
|
|
3
|
+
export type IString = string // string | other will convert to string
|
|
4
|
+
export type IValue = INumber | IBoolean | IString | IObject //
|
|
6
5
|
export type ITimer = any
|
|
7
6
|
|
|
8
7
|
export type IPathString = string
|
|
@@ -25,5 +24,4 @@ export interface IStringMap {
|
|
|
25
24
|
|
|
26
25
|
export interface IDataTypeHandle {
|
|
27
26
|
(target: any): void
|
|
28
|
-
}
|
|
29
|
-
|
|
27
|
+
}
|
package/src/data/ILeafData.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ILeaf, ILeafComputedData } from '../display/ILeaf'
|
|
2
2
|
import { IObject } from './IData'
|
|
3
3
|
|
|
4
|
-
export interface IDataProcessor
|
|
4
|
+
export interface IDataProcessor {
|
|
5
5
|
__leaf: ILeaf
|
|
6
6
|
__input: IObject
|
|
7
7
|
__middle: IObject
|
|
@@ -9,19 +9,25 @@ export interface IDataProcessor extends IObject {
|
|
|
9
9
|
__single: boolean
|
|
10
10
|
__checkSingle(): void
|
|
11
11
|
|
|
12
|
-
__get(name: string):
|
|
12
|
+
__get(name: string): any
|
|
13
|
+
__getData(): IObject
|
|
13
14
|
|
|
14
|
-
__setInput(name: string, value:
|
|
15
|
-
__getInput(name: string):
|
|
15
|
+
__setInput(name: string, value: any): void
|
|
16
|
+
__getInput(name: string): any
|
|
16
17
|
__removeInput(name: string): void
|
|
17
18
|
__getInputData(): IObject
|
|
18
19
|
|
|
19
|
-
__setMiddle(name: string, value:
|
|
20
|
-
__getMiddle(name: string):
|
|
20
|
+
__setMiddle(name: string, value: any): void
|
|
21
|
+
__getMiddle(name: string): any
|
|
21
22
|
|
|
22
23
|
destroy(): void
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
export interface ILeafDataOptions {
|
|
27
|
+
attrs?: 'all' | string[]
|
|
28
|
+
children?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
25
31
|
export interface ILeafData extends IDataProcessor, ILeafComputedData {
|
|
26
32
|
|
|
27
33
|
}
|
package/src/data/IList.ts
CHANGED
|
@@ -18,13 +18,16 @@ export interface ILeafList {
|
|
|
18
18
|
has(leaf: ILeaf): boolean
|
|
19
19
|
indexAt(index: number): ILeaf
|
|
20
20
|
indexOf(leaf: ILeaf): number
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
|
|
22
|
+
add(leaf: ILeaf): void
|
|
23
|
+
addAt(leaf: ILeaf, index: number): void
|
|
24
|
+
addList(list: ILeaf[]): void
|
|
25
25
|
remove(leaf: ILeaf): void
|
|
26
|
+
|
|
26
27
|
forEach(itemCallback: ILeafListItemCallback): void
|
|
28
|
+
sort(reverse?: boolean): void
|
|
27
29
|
clone(): ILeafList
|
|
30
|
+
update(): void
|
|
28
31
|
reset(): void
|
|
29
32
|
destroy(): void
|
|
30
33
|
}
|
|
@@ -37,8 +40,8 @@ export interface ILeafLevelList {
|
|
|
37
40
|
has(leaf: ILeaf): boolean
|
|
38
41
|
without(leaf: ILeaf): boolean
|
|
39
42
|
sort(reverse?: boolean): void
|
|
40
|
-
|
|
41
|
-
|
|
43
|
+
addList(list: ILeaf[]): void
|
|
44
|
+
add(leaf: ILeaf): void
|
|
42
45
|
forEach(itemCallback: ILeafListItemCallback): void
|
|
43
46
|
reset(): void
|
|
44
47
|
destroy(): void
|
package/src/display/IBranch.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ILeaf } from './ILeaf'
|
|
1
2
|
import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
|
|
2
3
|
import { IRenderOptions } from '../renderer/IRenderer'
|
|
3
|
-
import { ILeaf } from './ILeaf'
|
|
4
4
|
|
|
5
5
|
export interface IBranch extends ILeaf {
|
|
6
6
|
children: ILeaf[]
|
|
7
7
|
__renderBranch?(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
8
|
-
|
|
8
|
+
addMany(...children: ILeaf[]): void
|
|
9
|
+
removeAll(destroy?: boolean): void
|
|
10
|
+
clear(): void
|
|
9
11
|
}
|