@leafer/interface 1.0.0-bate → 1.0.0-beta.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 +1 -1
- package/src/app/ILeafer.ts +10 -5
- package/src/canvas/ICanvas.ts +4 -0
- package/src/canvas/ICanvasManager.ts +1 -1
- package/src/canvas/IHitCanvasManager.ts +1 -1
- package/src/canvas/ILeaferCanvas.ts +23 -7
- package/src/canvas/ISkiaCanvas.ts +20 -0
- package/src/data/IData.ts +3 -0
- package/src/data/ILeafData.ts +5 -0
- package/src/display/IBranch.ts +4 -4
- package/src/display/ILeaf.ts +12 -1
- package/src/display/module/IBranchRender.ts +10 -0
- package/src/display/module/ILeafMask.ts +1 -0
- package/src/event/IEvent.ts +28 -11
- package/src/event/IUIEvent.ts +26 -20
- package/src/file/IFileType.ts +2 -0
- package/src/image/IImageManager.ts +12 -1
- package/src/image/ILeaferImage.ts +17 -1
- package/src/index.ts +10 -5
- package/src/interaction/IInteraction.ts +11 -4
- package/src/layout/ILeafLayout.ts +8 -4
- package/src/math/IMath.ts +6 -6
- package/src/platform/IPlatform.ts +33 -2
- package/src/plugin/IPlugin.ts +7 -8
- package/src/task/ITaskProcessor.ts +28 -0
- package/src/watcher/IWatcher.ts +3 -1
package/package.json
CHANGED
package/src/app/ILeafer.ts
CHANGED
|
@@ -8,13 +8,13 @@ import { IWatcher, IWatcherConfig } from '../watcher/IWatcher'
|
|
|
8
8
|
import { IAutoBounds, 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
14
|
import { IApp } from './IApp'
|
|
16
15
|
import { ILeaferImage, ILeaferImageConfig } from '../image/ILeaferImage'
|
|
17
16
|
import { IControl } from '../control/IControl'
|
|
17
|
+
import { IFunction } from '../function/IFunction'
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
export type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'user'
|
|
@@ -32,6 +32,7 @@ export interface ILeafer extends IZoomView, IControl {
|
|
|
32
32
|
running: boolean
|
|
33
33
|
ready: boolean
|
|
34
34
|
viewReady: boolean
|
|
35
|
+
readonly viewLoaded: boolean
|
|
35
36
|
|
|
36
37
|
pixelRatio: number
|
|
37
38
|
|
|
@@ -48,7 +49,6 @@ export interface ILeafer extends IZoomView, IControl {
|
|
|
48
49
|
|
|
49
50
|
canvasManager: ICanvasManager
|
|
50
51
|
hitCanvasManager?: IHitCanvasManager
|
|
51
|
-
imageManager: IImageManager
|
|
52
52
|
|
|
53
53
|
autoLayout?: IAutoBounds
|
|
54
54
|
|
|
@@ -57,10 +57,16 @@ export interface ILeafer extends IZoomView, IControl {
|
|
|
57
57
|
__eventIds: IEventListenerId[]
|
|
58
58
|
|
|
59
59
|
init(userConfig?: ILeaferConfig, parentApp?: IApp): void
|
|
60
|
-
|
|
60
|
+
setZoomLayer(zoomLayer: ILeaf, moveLayer?: ILeaf): void
|
|
61
61
|
forceFullRender(): void
|
|
62
|
-
|
|
63
62
|
resize(size: IScreenSizeData): void
|
|
63
|
+
waitViewLoaded(fun: IFunction): void
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ILeaferTypeCreator {
|
|
67
|
+
list: ILeaferTypeList
|
|
68
|
+
register(name: string, fn: ILeaferTypeFunction): void
|
|
69
|
+
run(name: string, leafer: ILeafer): void
|
|
64
70
|
}
|
|
65
71
|
|
|
66
72
|
export interface ILeaferTypeFunction {
|
|
@@ -71,7 +77,6 @@ export interface ILeaferTypeList {
|
|
|
71
77
|
[key: string]: ILeaferTypeFunction
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
|
|
75
80
|
export interface ICreator {
|
|
76
81
|
image?(options?: ILeaferImageConfig): ILeaferImage
|
|
77
82
|
canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas
|
package/src/canvas/ICanvas.ts
CHANGED
|
@@ -67,6 +67,10 @@ declare var CanvasGradient: {
|
|
|
67
67
|
new(): CanvasGradient
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
interface ImageDataSettings {
|
|
71
|
+
colorSpace?: PredefinedColorSpace
|
|
72
|
+
}
|
|
73
|
+
|
|
70
74
|
interface CanvasImageData {
|
|
71
75
|
createImageData(sw: number, sh: number, settings?: ImageDataSettings): ImageData
|
|
72
76
|
createImageData(imagedata: ImageData): ImageData
|
|
@@ -74,7 +74,7 @@ interface ICanvasMethod {
|
|
|
74
74
|
strokeRect(x: number, y: number, width: number, height: number): void
|
|
75
75
|
clearRect(x: number, y: number, width: number, height: number): void
|
|
76
76
|
|
|
77
|
-
transform(a: number, b
|
|
77
|
+
transform(a: number | IMatrixData, b?: number, c?: number, d?: number, e?: number, f?: number): void
|
|
78
78
|
translate(x: number, y: number): void
|
|
79
79
|
scale(x: number, y: number): void
|
|
80
80
|
rotate(angle: number): void
|
|
@@ -117,6 +117,7 @@ interface ICanvasMethod {
|
|
|
117
117
|
copyWorld(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void
|
|
118
118
|
copyWorldToInner(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toInnerBounds: IBoundsData, blendMode?: string): void
|
|
119
119
|
useMask(maskCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void
|
|
120
|
+
useEraser(eraserCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void
|
|
120
121
|
|
|
121
122
|
fillWorld(bounds: IBoundsData, color: string | object, blendMode?: string): void
|
|
122
123
|
strokeWorld(bounds: IBoundsData, color: string | object, blendMode?: string): void
|
|
@@ -139,16 +140,20 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
|
139
140
|
pixelRatio: number
|
|
140
141
|
readonly pixelWidth: number
|
|
141
142
|
readonly pixelHeight: number
|
|
143
|
+
|
|
142
144
|
readonly allowBackgroundColor?: boolean
|
|
145
|
+
backgroundColor?: string
|
|
146
|
+
hittable?: boolean
|
|
143
147
|
|
|
144
148
|
bounds: IBounds
|
|
149
|
+
clientBounds: IBoundsData
|
|
145
150
|
|
|
146
151
|
config: ILeaferCanvasConfig
|
|
147
152
|
|
|
148
153
|
autoLayout: boolean
|
|
149
154
|
|
|
150
|
-
view:
|
|
151
|
-
parentView:
|
|
155
|
+
view: any
|
|
156
|
+
parentView: any
|
|
152
157
|
|
|
153
158
|
unreal?: boolean
|
|
154
159
|
|
|
@@ -162,14 +167,16 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
|
162
167
|
|
|
163
168
|
init(): void
|
|
164
169
|
|
|
165
|
-
|
|
166
|
-
|
|
170
|
+
toBlob(type?: string, quality?: number): Promise<IBlob>
|
|
171
|
+
toDataURL(type?: string, quality?: number): string
|
|
172
|
+
saveAs(filename: string, quality?: number): Promise<boolean>
|
|
167
173
|
|
|
168
174
|
startAutoLayout(autoBounds: IAutoBounds, listener: IResizeEventListener): void
|
|
169
175
|
stopAutoLayout(): void
|
|
170
176
|
|
|
171
177
|
resize(size: IScreenSizeData): void
|
|
172
|
-
|
|
178
|
+
updateViewSize(): void
|
|
179
|
+
updateClientBounds(): void
|
|
173
180
|
|
|
174
181
|
// other
|
|
175
182
|
isSameSize(options: ILeaferCanvasConfig): boolean
|
|
@@ -182,4 +189,13 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
|
|
|
182
189
|
}
|
|
183
190
|
|
|
184
191
|
|
|
185
|
-
export
|
|
192
|
+
export interface IHitCanvas extends ILeaferCanvas {
|
|
193
|
+
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
export interface IBlobFunction {
|
|
198
|
+
(blob: IBlob | null): void
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export type IBlob = any
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IExportFileType, IExportImageType } from '../file/IFileType'
|
|
2
|
+
|
|
3
|
+
export type ICanvasType = 'skia' | 'canvas' | 'wx'
|
|
4
|
+
|
|
5
|
+
export interface ISkiaCanvas {
|
|
6
|
+
toBuffer(format: IExportFileType, config: ISkiaCanvasExportConfig): Promise<any>
|
|
7
|
+
toBufferSync(format: IExportFileType, config: ISkiaCanvasExportConfig): any
|
|
8
|
+
toDataURL(format: IExportImageType, config: ISkiaCanvasExportConfig): Promise<string>
|
|
9
|
+
toDataURLSync(format: IExportImageType, config: ISkiaCanvasExportConfig): string
|
|
10
|
+
saveAs(filename: string, config: ISkiaCanvasExportConfig): Promise<void>
|
|
11
|
+
saveAsSync(filename: string, config: ISkiaCanvasExportConfig): void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ISkiaCanvasExportConfig {
|
|
15
|
+
page?: number,
|
|
16
|
+
matte?: string,
|
|
17
|
+
density?: number,
|
|
18
|
+
quality?: number,
|
|
19
|
+
outline?: boolean
|
|
20
|
+
}
|
package/src/data/IData.ts
CHANGED
|
@@ -4,6 +4,9 @@ export type __String = string // string | other will convert to string
|
|
|
4
4
|
export type __Object = IObject // will convert to object
|
|
5
5
|
export type __Value = __Number | __Boolean | __String | __Object //
|
|
6
6
|
export type ITimer = any
|
|
7
|
+
|
|
8
|
+
export type IPathString = string
|
|
9
|
+
|
|
7
10
|
export interface IObject {
|
|
8
11
|
[name: string]: any
|
|
9
12
|
}
|
package/src/data/ILeafData.ts
CHANGED
|
@@ -5,6 +5,10 @@ export interface IDataProcessor extends IObject {
|
|
|
5
5
|
__leaf: ILeaf
|
|
6
6
|
__input: IObject
|
|
7
7
|
__middle: IObject
|
|
8
|
+
|
|
9
|
+
__single: boolean
|
|
10
|
+
__checkSingle(): void
|
|
11
|
+
|
|
8
12
|
__get(name: string): unknown
|
|
9
13
|
|
|
10
14
|
__setInput(name: string, value: unknown): void
|
|
@@ -14,6 +18,7 @@ export interface IDataProcessor extends IObject {
|
|
|
14
18
|
|
|
15
19
|
__setMiddle(name: string, value: unknown): void
|
|
16
20
|
__getMiddle(name: string): unknown
|
|
21
|
+
|
|
17
22
|
destroy(): void
|
|
18
23
|
}
|
|
19
24
|
|
package/src/display/IBranch.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
|
|
2
|
+
import { IRenderOptions } from '../renderer/IRenderer'
|
|
1
3
|
import { ILeaf } from './ILeaf'
|
|
2
4
|
|
|
3
5
|
export interface IBranch extends ILeaf {
|
|
4
6
|
children: ILeaf[]
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// add(child: ILeaf, index?: number): void
|
|
8
|
-
// remove(child?: ILeaf): void
|
|
7
|
+
__renderBranch?(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
8
|
+
removeAll(destroy?: boolean): void
|
|
9
9
|
}
|
package/src/display/ILeaf.ts
CHANGED
|
@@ -35,6 +35,7 @@ export interface ILeafAttrData {
|
|
|
35
35
|
opacity: __Number
|
|
36
36
|
visible: __Boolean
|
|
37
37
|
isMask: __Boolean
|
|
38
|
+
isEraser?: __Boolean
|
|
38
39
|
zIndex: __Number
|
|
39
40
|
|
|
40
41
|
// layout data
|
|
@@ -100,6 +101,7 @@ export interface ILeafInputData {
|
|
|
100
101
|
opacity?: __Number
|
|
101
102
|
visible?: __Boolean
|
|
102
103
|
isMask?: __Boolean
|
|
104
|
+
isEraser?: __Boolean
|
|
103
105
|
zIndex?: __Number
|
|
104
106
|
|
|
105
107
|
// layout data
|
|
@@ -131,6 +133,7 @@ export interface ILeafComputedData {
|
|
|
131
133
|
opacity?: number
|
|
132
134
|
visible?: boolean
|
|
133
135
|
isMask?: boolean
|
|
136
|
+
isEraser?: boolean
|
|
134
137
|
zIndex?: number
|
|
135
138
|
|
|
136
139
|
// layout data
|
|
@@ -155,6 +158,8 @@ export interface ILeafComputedData {
|
|
|
155
158
|
// other
|
|
156
159
|
__childBranchNumber?: number // 存在子分支的个数
|
|
157
160
|
__complex?: boolean // 外观是否复杂
|
|
161
|
+
__naturalWidth?: number
|
|
162
|
+
__naturalHeight?: number
|
|
158
163
|
}
|
|
159
164
|
|
|
160
165
|
export interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
|
|
@@ -195,6 +200,7 @@ export interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, IL
|
|
|
195
200
|
__tempNumber?: number // 用于临时运算储存状态
|
|
196
201
|
|
|
197
202
|
__hasMask?: boolean
|
|
203
|
+
__hasEraser?: boolean
|
|
198
204
|
__hitCanvas?: IHitCanvas
|
|
199
205
|
|
|
200
206
|
readonly __onlyHitMask: boolean
|
|
@@ -238,6 +244,7 @@ export interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, IL
|
|
|
238
244
|
__onUpdateSize(): void
|
|
239
245
|
|
|
240
246
|
// IBranchMask ->
|
|
247
|
+
__updateEraser(value?: boolean): void
|
|
241
248
|
__updateMask(value?: boolean): void
|
|
242
249
|
__renderMask(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas): void
|
|
243
250
|
__removeMask(child?: ILeaf): void
|
|
@@ -251,6 +258,10 @@ export interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, IL
|
|
|
251
258
|
worldToInner(world: IPointData, to?: IPointData, isMovePoint?: boolean): void
|
|
252
259
|
innerToWorld(inner: IPointData, to?: IPointData, isMovePoint?: boolean): void
|
|
253
260
|
|
|
261
|
+
move(x: number, y?: number): void
|
|
262
|
+
scaleOf(origin: IPointData, x: number, y?: number): void
|
|
263
|
+
rotateOf(origin: IPointData, rotation: number): void
|
|
264
|
+
|
|
254
265
|
// ILeafHit ->
|
|
255
266
|
__hitWorld(point: IRadiusPointData): boolean
|
|
256
267
|
__hit(local: IRadiusPointData): boolean
|
|
@@ -278,5 +289,5 @@ export interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, IL
|
|
|
278
289
|
|
|
279
290
|
__updateSortChildren(): void
|
|
280
291
|
add(child: ILeaf, index?: number): void
|
|
281
|
-
remove(child?: ILeaf): void
|
|
292
|
+
remove(child?: ILeaf, destroy?: boolean): void
|
|
282
293
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ILeaferCanvas } from '../../canvas/ILeaferCanvas'
|
|
2
|
+
import { IRenderOptions } from '../../renderer/IRenderer'
|
|
3
|
+
import { IBranch } from '../IBranch'
|
|
4
|
+
import { ILeafRender } from './ILeafRender'
|
|
5
|
+
|
|
6
|
+
export type IBranchRenderModule = IBranchRender & ThisType<IBranch>
|
|
7
|
+
|
|
8
|
+
export interface IBranchRender extends ILeafRender {
|
|
9
|
+
__renderBranch?(canvas: ILeaferCanvas, options: IRenderOptions): void
|
|
10
|
+
}
|
|
@@ -4,6 +4,7 @@ import { ILeaferCanvas } from '../../canvas/ILeaferCanvas'
|
|
|
4
4
|
export type ILeafMaskModule = ILeafMask & ThisType<ILeaf>
|
|
5
5
|
|
|
6
6
|
export interface ILeafMask {
|
|
7
|
+
__updateEraser?(value?: boolean): void
|
|
7
8
|
__updateMask?(value?: boolean): void
|
|
8
9
|
__renderMask?(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas): void
|
|
9
10
|
__removeMask?(child?: ILeaf): void
|
package/src/event/IEvent.ts
CHANGED
|
@@ -2,22 +2,22 @@ import { IEventer } from './IEventer'
|
|
|
2
2
|
import { IWatchEventData } from '../watcher/IWatcher'
|
|
3
3
|
import { ILayoutBlockData } from '../layouter/ILayouter'
|
|
4
4
|
import { ILeaf } from '../display/ILeaf'
|
|
5
|
-
import { IScreenSizeData } from '../math/IMath'
|
|
5
|
+
import { IScreenSizeData, IPointData } from '../math/IMath'
|
|
6
6
|
|
|
7
7
|
export interface IEvent {
|
|
8
|
-
type
|
|
9
|
-
target
|
|
10
|
-
current
|
|
8
|
+
type?: string
|
|
9
|
+
target?: IEventTarget
|
|
10
|
+
current?: IEventTarget
|
|
11
11
|
|
|
12
12
|
bubbles?: boolean
|
|
13
13
|
phase?: number
|
|
14
14
|
|
|
15
|
-
isStopDefault
|
|
16
|
-
isStop
|
|
17
|
-
isStopNow
|
|
18
|
-
stopDefault(): void
|
|
19
|
-
stopNow(): void
|
|
20
|
-
stop(): void
|
|
15
|
+
isStopDefault?: boolean
|
|
16
|
+
isStop?: boolean
|
|
17
|
+
isStopNow?: boolean
|
|
18
|
+
stopDefault?(): void
|
|
19
|
+
stopNow?(): void
|
|
20
|
+
stop?(): void
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface IEventTarget extends IEventer {
|
|
@@ -32,6 +32,10 @@ export interface IRenderEvent {
|
|
|
32
32
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
export interface IAnimateEvent {
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
35
39
|
export interface IChildEvent extends IEvent {
|
|
36
40
|
parent?: ILeaf
|
|
37
41
|
child?: ILeaf
|
|
@@ -91,4 +95,17 @@ export interface ITransformEvent extends IEvent, ITransformEventData {
|
|
|
91
95
|
readonly scaleY: number
|
|
92
96
|
readonly rotation: number
|
|
93
97
|
}
|
|
94
|
-
export type TransformMode = 'move' | 'zoom' | 'rotate'
|
|
98
|
+
export type TransformMode = 'move' | 'zoom' | 'rotate'
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
export interface IMultiTouchData {
|
|
102
|
+
move: IPointData,
|
|
103
|
+
scale: number,
|
|
104
|
+
angle: number,
|
|
105
|
+
center: IPointData
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface IKeepTouchData {
|
|
109
|
+
from: IPointData
|
|
110
|
+
to: IPointData
|
|
111
|
+
}
|
package/src/event/IUIEvent.ts
CHANGED
|
@@ -2,38 +2,39 @@ import { IObject } from '../data/IData'
|
|
|
2
2
|
import { ILeafList } from '../data/IList'
|
|
3
3
|
import { IEvent } from './IEvent'
|
|
4
4
|
import { ILeaferImage } from '../image/ILeaferImage'
|
|
5
|
+
import { ILeaf } from '../display/ILeaf'
|
|
6
|
+
import { IPointData } from '../math/IMath'
|
|
5
7
|
|
|
6
8
|
export interface IUIEvent extends IEvent {
|
|
7
9
|
x: number
|
|
8
10
|
y: number
|
|
9
11
|
|
|
10
|
-
altKey
|
|
11
|
-
ctrlKey
|
|
12
|
-
shiftKey
|
|
13
|
-
metaKey
|
|
14
|
-
readonly spaceKey
|
|
12
|
+
altKey?: boolean
|
|
13
|
+
ctrlKey?: boolean
|
|
14
|
+
shiftKey?: boolean
|
|
15
|
+
metaKey?: boolean
|
|
16
|
+
readonly spaceKey?: boolean
|
|
15
17
|
|
|
16
|
-
readonly left
|
|
17
|
-
readonly right
|
|
18
|
-
readonly middle
|
|
19
|
-
buttons
|
|
18
|
+
readonly left?: boolean
|
|
19
|
+
readonly right?: boolean
|
|
20
|
+
readonly middle?: boolean
|
|
21
|
+
buttons?: number
|
|
20
22
|
|
|
21
|
-
path
|
|
23
|
+
path?: ILeafList
|
|
22
24
|
throughPath?: ILeafList // 穿透path,不受层级影响,从上到下只要碰撞到区域就算,一般点击的时候
|
|
23
25
|
|
|
24
|
-
origin
|
|
26
|
+
origin?: IObject
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
stop(): void
|
|
28
|
+
getInner?(target?: ILeaf): IPointData
|
|
29
|
+
getLocal?(target?: ILeaf): IPointData
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
export interface IPointerEvent extends IUIEvent {
|
|
33
|
-
width
|
|
34
|
-
height
|
|
35
|
-
pointerType
|
|
36
|
-
pressure
|
|
34
|
+
width?: number
|
|
35
|
+
height?: number
|
|
36
|
+
pointerType?: PointerType
|
|
37
|
+
pressure?: number
|
|
37
38
|
tangentialPressure?: number
|
|
38
39
|
tiltX?: number
|
|
39
40
|
tiltY?: number
|
|
@@ -46,6 +47,9 @@ export interface IDragEvent extends IPointerEvent {
|
|
|
46
47
|
moveY: number
|
|
47
48
|
totalX: number
|
|
48
49
|
totalY: number
|
|
50
|
+
|
|
51
|
+
getInnerMove?(target?: ILeaf): IPointData
|
|
52
|
+
getLocalMove?(target?: ILeaf): IPointData
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
export interface IDropEvent extends IPointerEvent {
|
|
@@ -74,6 +78,8 @@ export interface IKeyEvent extends IUIEvent {
|
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
export interface IImageEvent extends IEvent {
|
|
77
|
-
image
|
|
78
|
-
|
|
81
|
+
image?: ILeaferImage
|
|
82
|
+
attrName?: string
|
|
83
|
+
attrValue?: IObject
|
|
84
|
+
error?: string | IObject
|
|
79
85
|
}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { ILeaferImage, ILeaferImageConfig } from './ILeaferImage'
|
|
2
|
+
import { ITaskProcessor } from '../task/ITaskProcessor'
|
|
2
3
|
|
|
4
|
+
interface ILeaferImageMap {
|
|
5
|
+
[name: string]: ILeaferImage
|
|
6
|
+
}
|
|
3
7
|
|
|
4
8
|
export interface IImageManager {
|
|
9
|
+
map: ILeaferImageMap
|
|
10
|
+
recycledList: ILeaferImage[]
|
|
11
|
+
tasker: ITaskProcessor
|
|
12
|
+
patternTasker: ITaskProcessor
|
|
13
|
+
readonly isComplete: boolean
|
|
5
14
|
get(config: ILeaferImageConfig): ILeaferImage
|
|
6
|
-
|
|
15
|
+
recycle(image: ILeaferImage): void
|
|
16
|
+
clearRecycled(): void
|
|
17
|
+
destroy(): void
|
|
7
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IObject } from '../data/IData'
|
|
2
|
+
import { InnerId } from '../event/IEventer'
|
|
2
3
|
|
|
3
4
|
export interface ILeaferImageConfig {
|
|
4
5
|
url: string
|
|
@@ -14,12 +15,27 @@ export interface ILeaferImageOnError {
|
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
export interface ILeaferImage {
|
|
18
|
+
readonly innerId: InnerId
|
|
19
|
+
readonly url: string
|
|
20
|
+
|
|
17
21
|
view: unknown
|
|
18
22
|
width: number
|
|
19
23
|
height: number
|
|
24
|
+
|
|
25
|
+
isSVG: boolean
|
|
26
|
+
|
|
27
|
+
readonly completed: boolean
|
|
20
28
|
ready: boolean
|
|
21
|
-
|
|
29
|
+
error: IObject
|
|
30
|
+
loading: boolean
|
|
31
|
+
|
|
32
|
+
use: number
|
|
33
|
+
config: ILeaferImageConfig
|
|
34
|
+
|
|
35
|
+
load(onSuccess?: ILeaferImageOnLoaded, onError?: ILeaferImageOnError): number
|
|
36
|
+
unload(index: number): void
|
|
22
37
|
getCanvas(width: number, height: number, opacity?: number, _filters?: IObject): unknown
|
|
38
|
+
destroy(): void
|
|
23
39
|
}
|
|
24
40
|
|
|
25
41
|
export type IImageStatus = 'wait' | 'thumb-loading' | 'thumb-success' | 'thumb-error' | 'loading' | 'success' | 'error'
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { IApp } from './app/IApp'
|
|
2
|
-
export { ILeafer, ILeaferType, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
|
|
2
|
+
export { ILeafer, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
|
|
3
3
|
export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType, IBlendMode } from './display/ILeaf'
|
|
4
4
|
export { IBranch } from './display/IBranch'
|
|
5
5
|
export { IZoomView } from './display/IView'
|
|
@@ -15,6 +15,7 @@ export { ILeafHit, ILeafHitModule } from './display/module/ILeafHit'
|
|
|
15
15
|
export { ILeafRender, ILeafRenderModule } from './display/module/ILeafRender'
|
|
16
16
|
export { ILeafEventer, ILeafEventerModule } from './display/module/ILeafEventer'
|
|
17
17
|
export { ILeafMask, ILeafMaskModule } from './display/module/ILeafMask'
|
|
18
|
+
export { IBranchRender, IBranchRenderModule } from './display/module/IBranchRender'
|
|
18
19
|
|
|
19
20
|
export { IRenderer, IRendererConfig, IRenderOptions } from './renderer/IRenderer'
|
|
20
21
|
export { IWatcher, IWatchEventData, IWatcherConfig } from './watcher/IWatcher'
|
|
@@ -25,26 +26,30 @@ export { ICanvasManager } from './canvas/ICanvasManager'
|
|
|
25
26
|
export { IHitCanvasManager } from './canvas/IHitCanvasManager'
|
|
26
27
|
export { IImageManager } from './image/IImageManager'
|
|
27
28
|
|
|
29
|
+
export { ITaskProcessor, ITaskProcessorConfig } from './task/ITaskProcessor'
|
|
30
|
+
|
|
28
31
|
|
|
29
32
|
export { IControl } from './control/IControl'
|
|
30
|
-
export { IPlatform } from './platform/IPlatform'
|
|
33
|
+
export { IPlatform, IMiniapp, IMiniappSelect, IMiniappSizeView } from './platform/IPlatform'
|
|
31
34
|
export { IPlugin } from './plugin/IPlugin'
|
|
32
35
|
|
|
33
36
|
|
|
34
|
-
export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasConfig, IHitCanvasConfig } from './canvas/ILeaferCanvas'
|
|
37
|
+
export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasConfig, IHitCanvasConfig, IBlobFunction, IBlob } from './canvas/ILeaferCanvas'
|
|
38
|
+
export { ISkiaCanvas, ISkiaCanvasExportConfig, ICanvasType } from './canvas/ISkiaCanvas'
|
|
35
39
|
export { IPathDrawer, IPathCreator } from './path/IPathDrawer'
|
|
36
40
|
export { IWindingRule, ICanvasContext2D, ITextMetrics, IPath2D } from './canvas/ICanvas'
|
|
37
41
|
export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData } from './path/IPathCommand'
|
|
38
42
|
|
|
39
43
|
export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnError } from './image/ILeaferImage'
|
|
44
|
+
export { IExportFileType, IExportImageType } from './file/IFileType'
|
|
40
45
|
|
|
41
46
|
export { InnerId, IEventer, IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId } from './event/IEventer'
|
|
42
|
-
export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, ITransformEvent, ITransformEventData, TransformMode } from './event/IEvent'
|
|
47
|
+
export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IAnimateEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, ITransformEvent, ITransformEventData, TransformMode, IMultiTouchData, IKeepTouchData } from './event/IEvent'
|
|
43
48
|
export { IUIEvent, IPointerEvent, PointerType, IDragEvent, IDropEvent, ISwipeEvent, IMoveEvent, IZoomEvent, IRotateEvent, IKeyEvent, IImageEvent } from './event/IUIEvent'
|
|
44
49
|
export { IInteraction, IInteractionCanvas, IInteractionConfig, IWheelConfig, IPointerConfig } from './interaction/IInteraction'
|
|
45
50
|
|
|
46
51
|
|
|
47
|
-
export { __Number, __Boolean, __String, __Object, __Value, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IDataTypeHandle } from './data/IData'
|
|
52
|
+
export { __Number, __Boolean, __String, __Object, __Value, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IDataTypeHandle } from './data/IData'
|
|
48
53
|
export { ILeafList, ILeafArrayMap, ILeafMap, ILeafLevelList, ILeafListItemCallback } from './data/IList'
|
|
49
54
|
export { IPoint, IPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataHandle, IOffsetBoundsData, ITwoPointBounds, ITwoPointBoundsData, IAutoBounds, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixDecompositionData, IMatrixDecompositionAttr } from './math/IMath'
|
|
50
55
|
export { IFunction } from './function/IFunction'
|
|
@@ -6,6 +6,9 @@ import { IPointData } from '../math/IMath'
|
|
|
6
6
|
import { ISelector } from '../selector/ISelector'
|
|
7
7
|
import { IBounds } from '../math/IMath'
|
|
8
8
|
import { IControl } from '../control/IControl'
|
|
9
|
+
import { IKeepTouchData } from '../event/IEvent'
|
|
10
|
+
import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
|
|
11
|
+
import { IObject } from '../data/IData'
|
|
9
12
|
|
|
10
13
|
export interface IInteraction extends IControl {
|
|
11
14
|
target: ILeaf
|
|
@@ -23,12 +26,16 @@ export interface IInteraction extends IControl {
|
|
|
23
26
|
downData: IPointerEvent
|
|
24
27
|
downTime: number
|
|
25
28
|
|
|
26
|
-
|
|
29
|
+
receive(event: any): void
|
|
30
|
+
|
|
31
|
+
pointerDown(data: IPointerEvent, defaultPath?: boolean): void
|
|
27
32
|
pointerMove(data: IPointerEvent): void
|
|
28
33
|
pointerMoveReal(data: IPointerEvent): void
|
|
29
34
|
pointerUp(data: IPointerEvent): void
|
|
30
35
|
pointerCancel(): void
|
|
31
36
|
|
|
37
|
+
multiTouch(data: IUIEvent, list: IKeepTouchData[]): void
|
|
38
|
+
|
|
32
39
|
move(data: IMoveEvent): void
|
|
33
40
|
zoom(data: IZoomEvent): void
|
|
34
41
|
rotate(data: IRotateEvent): void
|
|
@@ -36,9 +43,8 @@ export interface IInteraction extends IControl {
|
|
|
36
43
|
emit(type: string, data: IUIEvent, path?: ILeafList, excludePath?: ILeafList): void
|
|
37
44
|
}
|
|
38
45
|
|
|
39
|
-
export interface IInteractionCanvas {
|
|
40
|
-
|
|
41
|
-
view: unknown
|
|
46
|
+
export interface IInteractionCanvas extends ILeaferCanvas {
|
|
47
|
+
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
export interface IInteractionConfig {
|
|
@@ -46,6 +52,7 @@ export interface IInteractionConfig {
|
|
|
46
52
|
pointer?: IPointerConfig
|
|
47
53
|
zoom?: IZoomConfig
|
|
48
54
|
move?: IMoveConfig
|
|
55
|
+
eventer?: IObject
|
|
49
56
|
}
|
|
50
57
|
|
|
51
58
|
export interface IZoomConfig {
|
|
@@ -10,7 +10,7 @@ export interface ILeafLayout {
|
|
|
10
10
|
|
|
11
11
|
useZoomProxy: boolean
|
|
12
12
|
|
|
13
|
-
//
|
|
13
|
+
// inner
|
|
14
14
|
|
|
15
15
|
boxBounds: IBoundsData // | content + padding |
|
|
16
16
|
strokeBounds: IBoundsData // | boxBounds + border |
|
|
@@ -31,6 +31,7 @@ export interface ILeafLayout {
|
|
|
31
31
|
// matrix changed
|
|
32
32
|
matrixChanged: boolean // include positionChanged scaleChanged skewChanged
|
|
33
33
|
positionChanged: boolean // x, y
|
|
34
|
+
originChanged?: boolean // originX originY
|
|
34
35
|
scaleChanged: boolean // scaleX scaleY
|
|
35
36
|
rotationChanged: boolean // rotaiton, skewX scaleY 数据更新
|
|
36
37
|
|
|
@@ -54,13 +55,14 @@ export interface ILeafLayout {
|
|
|
54
55
|
// keep state
|
|
55
56
|
affectScaleOrRotation: boolean
|
|
56
57
|
affectRotation: boolean
|
|
58
|
+
affectChildrenSort?: boolean
|
|
57
59
|
|
|
58
60
|
strokeSpread: number
|
|
59
61
|
renderSpread: number
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
strokeBoxSpread: number
|
|
63
|
+
renderShapeSpread: number
|
|
62
64
|
|
|
63
|
-
checkUpdate(): void
|
|
65
|
+
checkUpdate(force?: boolean): void
|
|
64
66
|
|
|
65
67
|
getTransform(locationType: ILayoutLocationType): IMatrixData
|
|
66
68
|
decomposeTransform(locationType: ILayoutLocationType): IMatrixDecompositionData
|
|
@@ -87,5 +89,7 @@ export interface ILeafLayout {
|
|
|
87
89
|
surfaceChange(): void
|
|
88
90
|
opacityChange(): void
|
|
89
91
|
|
|
92
|
+
childrenSortChange(): void
|
|
93
|
+
|
|
90
94
|
destroy(): void
|
|
91
95
|
}
|
package/src/math/IMath.ts
CHANGED
|
@@ -152,16 +152,16 @@ export interface IMatrix extends IMatrixData {
|
|
|
152
152
|
translateInner(x: number, y: number): IMatrix
|
|
153
153
|
|
|
154
154
|
scale(x: number, y?: number): IMatrix
|
|
155
|
-
|
|
156
|
-
scaleOfInner(
|
|
155
|
+
scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix
|
|
156
|
+
scaleOfInner(origin: IPointData, x: number, y?: number): IMatrix
|
|
157
157
|
|
|
158
158
|
rotate(angle: number): IMatrix
|
|
159
|
-
|
|
160
|
-
rotateOfInner(
|
|
159
|
+
rotateOfOuter(origin: IPointData, angle: number): IMatrix
|
|
160
|
+
rotateOfInner(origin: IPointData, angle: number): IMatrix
|
|
161
161
|
|
|
162
162
|
skew(x: number, y?: number): IMatrix
|
|
163
|
-
|
|
164
|
-
skewOfInner(
|
|
163
|
+
skewOfOuter(origin: IPointData, x: number, y?: number): IMatrix
|
|
164
|
+
skewOfInner(origin: IPointData, x: number, y?: number): IMatrix
|
|
165
165
|
|
|
166
166
|
multiply(matrix: IMatrixData): IMatrix
|
|
167
167
|
divide(matrix: IMatrixData): IMatrix
|
|
@@ -1,15 +1,46 @@
|
|
|
1
1
|
import { IFunction } from '../function/IFunction'
|
|
2
2
|
import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
|
|
3
3
|
import { ILeaf } from '../display/ILeaf'
|
|
4
|
+
import { IExportFileType, IExportImageType } from '../file/IFileType'
|
|
5
|
+
import { IBoundsData, ISizeData } from '../math/IMath'
|
|
6
|
+
import { IObject } from '../data/IData'
|
|
4
7
|
|
|
5
8
|
export interface IPlatform {
|
|
9
|
+
name?: 'web' | 'node' | 'miniapp'
|
|
10
|
+
os?: 'Mac' | 'Windows' | 'Linux'
|
|
6
11
|
requestRender?(render: IFunction): void
|
|
7
12
|
canvas?: ILeaferCanvas
|
|
8
13
|
isWorker?: boolean
|
|
9
14
|
devicePixelRatio?: number
|
|
10
|
-
intWheelDeltaY?: boolean // firxfox need
|
|
15
|
+
intWheelDeltaY?: boolean // firxfox / Windows need
|
|
11
16
|
conicGradientSupport?: boolean
|
|
12
17
|
conicGradientRotate90?: boolean // fixfox need rotate
|
|
13
18
|
fullImageShadow?: boolean // safari need
|
|
14
|
-
layout(target: ILeaf): void
|
|
19
|
+
layout?(target: ILeaf): void
|
|
20
|
+
realtimeLayout?: boolean
|
|
21
|
+
origin?: {
|
|
22
|
+
createCanvas(width: number, height: number, format?: 'svg' | 'pdf'): any
|
|
23
|
+
canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string
|
|
24
|
+
canvasToBolb(canvas: any, type?: IExportFileType, quality?: number): Promise<any>
|
|
25
|
+
canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>
|
|
26
|
+
loadImage(url: string): Promise<any>
|
|
27
|
+
noRepeat?: string // fix: 微信小程序 createPattern 直接使用 no-repeat 有bug,导致无法显示
|
|
28
|
+
},
|
|
29
|
+
miniapp?: IMiniapp
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
export interface IMiniappSelect extends IObject { }
|
|
34
|
+
|
|
35
|
+
export interface IMiniappSizeView extends ISizeData {
|
|
36
|
+
view: any
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface IMiniapp {
|
|
40
|
+
select(name: string): IMiniappSelect
|
|
41
|
+
getBounds(select: IMiniappSelect): Promise<IBoundsData>
|
|
42
|
+
getSizeView(select: IMiniappSelect): Promise<IMiniappSizeView>
|
|
43
|
+
onWindowResize(fun: IFunction): void
|
|
44
|
+
offWindowResize(fun: IFunction): void
|
|
45
|
+
saveToAlbum(path: string): Promise<any>
|
|
15
46
|
}
|
package/src/plugin/IPlugin.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { ILeafer } from '../app/ILeafer'
|
|
1
2
|
import { IObject } from '../data/IData'
|
|
2
3
|
|
|
3
|
-
export interface IPlugin {
|
|
4
|
-
name
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
dependencies: string[]
|
|
10
|
-
run(params: IObject): void
|
|
4
|
+
export interface IPlugin extends IObject {
|
|
5
|
+
name?: string
|
|
6
|
+
importVersion: string
|
|
7
|
+
import: string[]
|
|
8
|
+
run(LeaferUI: IObject, config: IObject): void
|
|
9
|
+
onLeafer?(leafer: ILeafer): void
|
|
11
10
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { IFunction } from '../function/IFunction'
|
|
2
|
+
|
|
3
|
+
export interface ITaskProcessorConfig {
|
|
4
|
+
onComplete?: IFunction
|
|
5
|
+
onTask?: IFunction
|
|
6
|
+
onError?: IFunction
|
|
7
|
+
parallel?: number
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface ITaskProcessor {
|
|
11
|
+
config: ITaskProcessorConfig
|
|
12
|
+
running: boolean
|
|
13
|
+
isComplete: boolean
|
|
14
|
+
percent: number
|
|
15
|
+
total: number
|
|
16
|
+
index: number
|
|
17
|
+
finishedIndex: number
|
|
18
|
+
remain: number
|
|
19
|
+
start(): void
|
|
20
|
+
pause(): void
|
|
21
|
+
resume(): void
|
|
22
|
+
skip(): void
|
|
23
|
+
stop(): void
|
|
24
|
+
add(taskCallback: IFunction, taskTime?: number, start?: boolean): void
|
|
25
|
+
addParallel(taskCallback: IFunction, taskTime?: number, start?: boolean,): void
|
|
26
|
+
addEmpty(callback?: IFunction): void
|
|
27
|
+
destroy(): void
|
|
28
|
+
}
|
package/src/watcher/IWatcher.ts
CHANGED
|
@@ -12,16 +12,18 @@ export interface IWatcherConfig {
|
|
|
12
12
|
|
|
13
13
|
export interface IWatcher extends IControl {
|
|
14
14
|
target: ILeaf
|
|
15
|
-
updatedList: ILeafList
|
|
16
15
|
|
|
17
16
|
totalTimes: number
|
|
18
17
|
|
|
19
18
|
disabled: boolean
|
|
20
19
|
running: boolean
|
|
21
20
|
changed: boolean
|
|
21
|
+
hasRemoved: boolean
|
|
22
22
|
|
|
23
23
|
config: IWatcherConfig
|
|
24
24
|
|
|
25
|
+
updatedList: ILeafList
|
|
26
|
+
|
|
25
27
|
disable(): void
|
|
26
28
|
|
|
27
29
|
update(): void
|