@leafer/interface 1.0.0 → 1.0.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/interface",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -17,10 +17,11 @@ import { IControl } from '../control/IControl'
17
17
  import { IFunction } from '../function/IFunction'
18
18
 
19
19
 
20
- export type ILeaferType = 'draw' | 'editor' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart' | 'custom'
20
+ export type ILeaferType = 'draw' | 'block' | 'editor' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart' | 'custom'
21
21
  export interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
22
22
  start?: boolean
23
23
  type?: ILeaferType
24
+ mobile?: boolean
24
25
  realCanvas?: boolean
25
26
  lazySpeard?: IFourNumber
26
27
  }
@@ -82,6 +83,10 @@ export interface ILeaferAttrData {
82
83
  getValidScale(changeScale: number): number
83
84
 
84
85
  getWorldPointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData
86
+ getPagePointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData
87
+ updateClientBounds(): void
88
+
89
+ receiveEvent(event: any): void
85
90
  }
86
91
 
87
92
  export type IZoomType = 'in' | 'out' | 'fit' | 'fit-width' | 'fit-height' | number | ILeaf | ILeaf[] | IBoundsData
@@ -10,6 +10,7 @@ import { IExportOptions } from '../file/IExport'
10
10
 
11
11
  export interface ILeaferCanvasConfig extends IAutoBoundsData {
12
12
  view?: string | IObject
13
+ canvas?: string | IObject
13
14
  fill?: string
14
15
  pixelRatio?: number
15
16
  smooth?: boolean
@@ -199,7 +200,7 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
199
200
  getSameCanvas(useSameWorldTransform?: boolean, useSameSmooth?: boolean): ILeaferCanvas
200
201
  recycle(clearBounds?: IBoundsData): void
201
202
 
202
- updateRender(): void
203
+ updateRender(bounds: IBoundsData): void
203
204
  unrealCanvas(): void
204
205
  destroy(): void
205
206
  }
@@ -1,6 +1,6 @@
1
1
  import { IExportFileType, IExportImageType } from '../file/IFileType'
2
2
 
3
- export type ICanvasType = 'skia' | 'napi' | 'canvas' | 'wx'
3
+ export type ICanvasType = 'skia' | 'napi' | 'canvas' | 'miniapp'
4
4
 
5
5
  // skia
6
6
  export interface ISkiaCanvas {
package/src/data/IData.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { IPointData } from '../math/IMath'
2
+ import { IFunction } from '../function/IFunction'
2
3
 
3
4
  export type INumber = number // number | string will convert to number
4
5
  export type IBoolean = boolean // boolean | string will convert to boolean
@@ -26,6 +27,11 @@ export interface IStringMap {
26
27
  [name: string]: string
27
28
  }
28
29
 
30
+ export interface IFunctionMap {
31
+ [name: string]: IFunction
32
+ }
33
+
34
+
29
35
  export interface IPointDataMap {
30
36
  [name: string]: IPointData
31
37
  }
@@ -1,5 +1,5 @@
1
1
  import { ILeaferBase } from '../app/ILeafer'
2
- import { IEventer } from '../event/IEventer'
2
+ import { IEventer, IEventMap } from '../event/IEventer'
3
3
 
4
4
  import { ILeaferCanvas, IHitCanvas } from '../canvas/ILeaferCanvas'
5
5
  import { IRenderOptions } from '../renderer/IRenderer'
@@ -106,6 +106,8 @@ export interface ILeafAttrData {
106
106
 
107
107
  cursor?: ICursorType | ICursorType[]
108
108
 
109
+ event?: IEventMap
110
+
109
111
  normalStyle?: ILeafInputData // restore hover / press / focus / selected / disabled style
110
112
  hoverStyle?: ILeafInputData
111
113
  pressStyle?: ILeafInputData
@@ -117,6 +119,7 @@ export interface ILeafAttrData {
117
119
  data: IObject
118
120
  }
119
121
 
122
+ export type ISide = 'width' | 'height'
120
123
 
121
124
  export type IAxis = 'x' | 'y'
122
125
 
@@ -221,6 +224,12 @@ export type IDirection =
221
224
  | 'left'
222
225
  | 'center'
223
226
 
227
+ export type IDirection4 =
228
+ | 'top'
229
+ | 'right'
230
+ | 'bottom'
231
+ | 'left'
232
+
224
233
  export type IAlign = IDirection
225
234
 
226
235
  export type IBaseLineAlign =
@@ -364,6 +373,8 @@ export interface ILeafInputData {
364
373
 
365
374
  cursor?: ICursorType | ICursorType[]
366
375
 
376
+ event?: IEventMap
377
+
367
378
  normalStyle?: ILeafInputData
368
379
  hoverStyle?: ILeafInputData
369
380
  pressStyle?: ILeafInputData
@@ -475,8 +486,8 @@ export interface ILeafComputedData {
475
486
 
476
487
  readonly __autoWidth?: boolean
477
488
  readonly __autoHeight?: boolean
478
- readonly __autoSide?: boolean
479
- readonly __autoSize?: boolean
489
+ readonly __autoSide?: boolean // 自动宽或自动高
490
+ readonly __autoSize?: boolean // 自动宽高
480
491
 
481
492
  readonly __useNaturalRatio: boolean // 宽高存在一个值时,另一个自动值是否采用natural尺寸比例
482
493
  readonly __isLinePath: boolean
@@ -619,7 +630,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
619
630
  __updateLocalRenderBounds(): void
620
631
 
621
632
  __updateContentBounds(): void
622
- __updateBoxBounds(): void
633
+ __updateBoxBounds(secondLayout?: boolean): void
623
634
  __updateStrokeBounds(): void
624
635
  __updateRenderBounds(): void
625
636
 
@@ -667,8 +678,9 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
667
678
  // transform
668
679
  setTransform(transform?: IMatrixData, resize?: boolean): void
669
680
  transform(transform?: IMatrixData, resize?: boolean): void
670
-
671
681
  move(x: number | IPointData, y?: number): void
682
+
683
+ moveInner(x: number | IPointData, y?: number): void
672
684
  scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void
673
685
  rotateOf(origin: IPointData | IAlign, rotation: number): void
674
686
  skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void
@@ -679,6 +691,8 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
679
691
  rotateOfWorld(worldOrigin: IPointData, rotation: number): void
680
692
  skewOfWorld(worldOrigin: IPointData, skewX: number, skewY?: number, resize?: boolean): void
681
693
 
694
+ flip(axis: IAxis): void
695
+
682
696
  scaleResize(scaleX: number, scaleY: number, noResize?: boolean): void
683
697
  __scaleResize(scaleX: number, scaleY: number): void
684
698
 
@@ -10,7 +10,7 @@ export interface ILeafBounds {
10
10
  __updateLocalStrokeBounds?(): void
11
11
  __updateLocalRenderBounds?(): void
12
12
 
13
- __updateBoxBounds?(): void
13
+ __updateBoxBounds?(secondLayout?: boolean): void
14
14
  __updateStrokeBounds?(): void
15
15
  __updateRenderBounds?(): void
16
16
 
@@ -12,6 +12,8 @@ export interface IEventListenerOptions {
12
12
  once?: boolean
13
13
  }
14
14
 
15
+ export type IEventOption = IEventListenerOptions | boolean | 'once'
16
+
15
17
  export interface IEventListenerItem extends IEventListenerOptions {
16
18
  listener: IEventListener
17
19
  }
@@ -20,11 +22,15 @@ export interface IEventListenerMap {
20
22
  [name: string]: IEventListenerItem[]
21
23
  }
22
24
 
25
+ export interface IEventMap {
26
+ [name: string]: IEventListener | [IEventListener, IEventOption]
27
+ }
28
+
23
29
  export interface IEventListenerId {
24
30
  type: string | string[]
25
31
  current: ILeaf
26
32
  listener: IEventListener
27
- options?: IEventListenerOptions | boolean
33
+ options?: IEventOption
28
34
  }
29
35
 
30
36
  export type InnerId = number
@@ -35,9 +41,9 @@ export interface IEventer extends ILeafEventer {
35
41
  __captureMap?: IEventListenerMap
36
42
  __bubbleMap?: IEventListenerMap
37
43
 
38
- on(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void
39
- off(type?: string | string[], listener?: IEventListener, options?: IEventListenerOptions | boolean): void
40
- on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId
44
+ on(type: string | string[], listener: IEventListener, options?: IEventOption): void
45
+ off(type?: string | string[], listener?: IEventListener, options?: IEventOption): void
46
+ on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventOption): IEventListenerId
41
47
  off_(id: IEventListenerId | IEventListenerId[]): void
42
48
  once(type: string | string[], listener: IEventListener): void
43
49
  emit(type: string, event?: IEvent | IObject, capture?: boolean): void
@@ -33,6 +33,7 @@ export interface IPointerEvent extends IUIEvent {
33
33
  width?: number
34
34
  height?: number
35
35
  pointerType?: PointerType
36
+ multiTouch?: boolean
36
37
  pressure?: number
37
38
  tangentialPressure?: number
38
39
  tiltX?: number
@@ -73,7 +74,7 @@ export interface IZoomEvent extends IUIEvent {
73
74
  }
74
75
 
75
76
  export interface IMoveEvent extends IDragEvent {
76
-
77
+ moveType?: 'drag' | 'move'
77
78
  }
78
79
 
79
80
  export interface ISwipeEvent extends IDragEvent {
@@ -2,12 +2,13 @@ import { IBlob, ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
2
  import { ICanvasContext2DSettings } from '../canvas/ICanvas'
3
3
  import { ILeaf } from '../display/ILeaf'
4
4
  import { ILocationType } from '../layout/ILeafLayout'
5
- import { IBoundsData } from '../math/IMath'
5
+ import { IBoundsData, IPointData, ISizeData } from '../math/IMath'
6
6
 
7
7
  export interface IExportOptions {
8
8
  quality?: number
9
9
  blob?: boolean
10
- scale?: number
10
+ scale?: number | IPointData
11
+ size?: number | ISizeData
11
12
  smooth?: boolean
12
13
  pixelRatio?: number
13
14
  slice?: boolean
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { IAppBase } from './app/IApp'
2
2
  export { ILeaferBase, ILeaferAttrData, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILeaferConfig, ICreator, IUICreator, IZoomType } from './app/ILeafer'
3
- export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IFlowType, IFlowBoxType, IAlign, IAxisAlign, IFlowAlign, IFlowAxisAlign, IAxis, IGap, IPointGap, IAxisReverse, IBaseLineAlign, IFlowWrap, IAutoSize, IRangeSize, IPercentData, IUnitData, IConstraint, IConstraintType, IHitType, IMaskType, IEraserType, IBlendMode, IEditSize, IImageCursor, ICursorType, IStateStyleType, IDirection, IAround, ILeafAttrDescriptor, ILeafAttrDescriptorFn } from './display/ILeaf'
3
+ export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IFlowType, IFlowBoxType, IAlign, IAxisAlign, IFlowAlign, IFlowAxisAlign, ISide, IAxis, IGap, IPointGap, IAxisReverse, IBaseLineAlign, IFlowWrap, IAutoSize, IRangeSize, IPercentData, IUnitData, IConstraint, IConstraintType, IHitType, IMaskType, IEraserType, IBlendMode, IEditSize, IImageCursor, ICursorType, IStateStyleType, IDirection, IDirection4, IAround, ILeafAttrDescriptor, ILeafAttrDescriptorFn } from './display/ILeaf'
4
4
  export { IBranch } from './display/IBranch'
5
5
  export { IZoomView } from './display/IView'
6
6
 
@@ -43,14 +43,14 @@ export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnE
43
43
  export { IExportFileType, IExportImageType } from './file/IFileType'
44
44
  export { IExportOptions, IJSONOptions, IExportResult, IExportResultFunction, IExportOnCanvasFunction } from './file/IExport'
45
45
 
46
- export { InnerId, IEventer, IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId } from './event/IEventer'
46
+ export { InnerId, IEventer, IEventMap, IEventListener, IEventOption, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId } from './event/IEventer'
47
47
  export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IAnimateEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, IMultiTouchData, IKeepTouchData } from './event/IEvent'
48
48
  export { IUIEvent, IPointerEvent, PointerType, IDragEvent, IDropEvent, ISwipeEvent, IMoveEvent, IZoomEvent, IRotateEvent, IKeyEvent, IImageEvent } from './event/IUIEvent'
49
49
  export { ICursorTypeMap, ICursorRotate, ICursorRotateMap } from './interaction/ICursor'
50
- export { IInteraction, IInteractionCanvas, IInteractionConfig, IWheelConfig, IPointerConfig } from './interaction/IInteraction'
50
+ export { IInteraction, IInteractionCanvas, IInteractionConfig, IWheelConfig, ITouchConfig, IPointerConfig } from './interaction/IInteraction'
51
51
 
52
52
 
53
- export { INumber, IBoolean, IString, IValue, IFourNumber, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IPointDataMap, IDataTypeHandle } from './data/IData'
53
+ export { INumber, IBoolean, IString, IValue, IFourNumber, IPathString, ITimer, IObject, INumberMap, IStringMap, IBooleanMap, IFunctionMap, IPointDataMap, IDataTypeHandle } from './data/IData'
54
54
  export { ILeafList, ILeafArrayMap, ILeafMap, ILeafLevelList, ILeafListItemCallback } from './data/IList'
55
55
  export { IPoint, IPointData, IFromToData, IUnitPointData, IScrollPointData, IClientPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataFn, IOffsetBoundsData, ITwoPointBoundsData, IAutoBounds, IAutoBoxData, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithScaleData, IMatrixWithOptionScaleData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IScaleRotationData, IScaleData, ISkewData, ILayoutBoundsData, ILayoutData, ILayoutAttr } from './math/IMath'
56
56
  export { IFunction, IStringFunction, INumberFunction, IObjectFunction, IPointDataFunction, IAttrDecorator } from './function/IFunction'
@@ -16,10 +16,18 @@ export interface IInteraction extends IControl {
16
16
  selector: ISelector
17
17
 
18
18
  running: boolean
19
+
19
20
  readonly dragging: boolean
21
+ readonly transforming: boolean
22
+
23
+ readonly moveMode: boolean
24
+ readonly canHover: boolean
25
+
20
26
  readonly isDragEmpty: boolean
27
+ readonly isMobileDragEmpty: boolean
28
+ readonly isHoldMiddleKey: boolean
21
29
  readonly isHoldRightKey: boolean
22
- readonly moveMode: boolean
30
+ readonly isHoldSpaceKey: boolean
23
31
 
24
32
  config: IInteractionConfig
25
33
 
@@ -82,6 +90,7 @@ export interface IInteractionCanvas extends ILeaferCanvas {
82
90
  export interface IInteractionConfig {
83
91
  wheel?: IWheelConfig
84
92
  pointer?: IPointerConfig
93
+ touch?: ITouchConfig
85
94
  zoom?: IZoomConfig
86
95
  move?: IMoveConfig
87
96
  eventer?: IObject
@@ -101,7 +110,7 @@ export interface IMoveConfig {
101
110
  holdMiddleKey?: boolean
102
111
  holdRightKey?: boolean
103
112
  scroll?: boolean | 'limit'
104
- drag?: boolean
113
+ drag?: boolean | 'auto'
105
114
  dragAnimate?: boolean
106
115
  dragEmpty?: boolean
107
116
  dragOut?: boolean
@@ -127,7 +136,11 @@ export interface IPointerConfig {
127
136
  tapTime?: number
128
137
  longPressTime?: number
129
138
  transformTime?: number
139
+
140
+ // mobile
130
141
  hover?: boolean
142
+ touch?: boolean // 使用touch事件代替pointer事件
143
+
131
144
  dragHover?: boolean
132
145
  dragDistance?: number
133
146
  swipeDistance?: number
@@ -136,6 +149,11 @@ export interface IPointerConfig {
136
149
  preventDefaultMenu?: boolean
137
150
  }
138
151
 
152
+ export interface ITouchConfig {
153
+ preventDefault?: boolean | 'auto'
154
+ }
155
+
156
+
139
157
  export interface ICursorConfig {
140
158
  stop?: boolean
141
159
  }
package/src/math/IMath.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { IFourNumber, IObject } from '../data/IData'
2
+ import { ISide } from '../display/ILeaf'
2
3
 
3
4
  export interface IPointData {
4
5
  x: number
@@ -91,8 +92,8 @@ export interface IBounds extends IBoundsData, ITwoPointBoundsData {
91
92
  toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds
92
93
  getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix
93
94
 
94
- spread(fourNumber: IFourNumber): IBounds
95
- shrink(fourNumber: IFourNumber): IBounds
95
+ spread(fourNumber: IFourNumber, side?: ISide): IBounds
96
+ shrink(fourNumber: IFourNumber, side?: ISide): IBounds
96
97
  ceil(): IBounds
97
98
  unsign(): IBounds
98
99
  float(maxLength?: number): IBounds
@@ -221,8 +222,8 @@ export interface IMatrix extends IMatrixWithScaleData {
221
222
  toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void
222
223
  toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void
223
224
 
224
- setLayout(data: ILayoutData, origin?: IPointData): IMatrix
225
- getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData
225
+ setLayout(data: ILayoutData, origin?: IPointData, around?: IPointData,): IMatrix
226
+ getLayout(origin?: IPointData, around?: IPointData, firstSkewY?: boolean): ILayoutData
226
227
 
227
228
  withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData
228
229
 
@@ -12,10 +12,11 @@ export interface IPlatform {
12
12
  toURL(text: string, fileType?: 'text' | 'svg'): string
13
13
  requestRender?(render: IFunction): void
14
14
  canvas?: ILeaferCanvas
15
+ renderCanvas?: ILeaferCanvas
15
16
  canvasType?: ICanvasType
16
17
  isWorker?: boolean
17
18
  isMobile?: boolean
18
- devicePixelRatio?: number
19
+ readonly devicePixelRatio?: number
19
20
  intWheelDeltaY?: boolean // firefox / Windows need
20
21
  conicGradientSupport?: boolean
21
22
  conicGradientRotate90?: boolean // firefox need rotate
package/types/index.d.ts CHANGED
@@ -72,8 +72,8 @@ interface IBounds extends IBoundsData, ITwoPointBoundsData {
72
72
  toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds;
73
73
  toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds;
74
74
  getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix;
75
- spread(fourNumber: IFourNumber): IBounds;
76
- shrink(fourNumber: IFourNumber): IBounds;
75
+ spread(fourNumber: IFourNumber, side?: ISide): IBounds;
76
+ shrink(fourNumber: IFourNumber, side?: ISide): IBounds;
77
77
  ceil(): IBounds;
78
78
  unsign(): IBounds;
79
79
  float(maxLength?: number): IBounds;
@@ -166,8 +166,8 @@ interface IMatrix extends IMatrixWithScaleData {
166
166
  invertWith(): IMatrix;
167
167
  toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void;
168
168
  toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void;
169
- setLayout(data: ILayoutData, origin?: IPointData): IMatrix;
170
- getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData;
169
+ setLayout(data: ILayoutData, origin?: IPointData, around?: IPointData): IMatrix;
170
+ getLayout(origin?: IPointData, around?: IPointData, firstSkewY?: boolean): ILayoutData;
171
171
  withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData;
172
172
  reset(): void;
173
173
  }
@@ -184,6 +184,28 @@ interface IMatrixWithBoundsScaleData extends IMatrixData, IBoundsData, IScaleDat
184
184
  interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData {
185
185
  }
186
186
 
187
+ interface IFunction {
188
+ (...arg: any): any;
189
+ }
190
+ interface INumberFunction {
191
+ (...arg: any): number;
192
+ }
193
+ interface IStringFunction {
194
+ (...arg: any): string;
195
+ }
196
+ interface IObjectFunction {
197
+ (...arg: any): IObject;
198
+ }
199
+ interface IPointDataFunction {
200
+ (...arg: any): IPointData;
201
+ }
202
+ interface IAttrDecorator {
203
+ (...arg: any): IAttrDecoratorInner;
204
+ }
205
+ interface IAttrDecoratorInner {
206
+ (target: any, key: string): any;
207
+ }
208
+
187
209
  type INumber = number;
188
210
  type IBoolean = boolean;
189
211
  type IString = string;
@@ -203,6 +225,9 @@ interface INumberMap {
203
225
  interface IStringMap {
204
226
  [name: string]: string;
205
227
  }
228
+ interface IFunctionMap {
229
+ [name: string]: IFunction;
230
+ }
206
231
  interface IPointDataMap {
207
232
  [name: string]: IPointData;
208
233
  }
@@ -397,53 +422,35 @@ interface ILeafEventer {
397
422
  hasEvent?(type: string, capture?: boolean): boolean;
398
423
  }
399
424
 
400
- interface IFunction {
401
- (...arg: any): any;
402
- }
403
- interface INumberFunction {
404
- (...arg: any): number;
405
- }
406
- interface IStringFunction {
407
- (...arg: any): string;
408
- }
409
- interface IObjectFunction {
410
- (...arg: any): IObject;
411
- }
412
- interface IPointDataFunction {
413
- (...arg: any): IPointData;
414
- }
415
- interface IAttrDecorator {
416
- (...arg: any): IAttrDecoratorInner;
417
- }
418
- interface IAttrDecoratorInner {
419
- (target: any, key: string): any;
420
- }
421
-
422
425
  type IEventListener = IFunction;
423
426
  interface IEventListenerOptions {
424
427
  capture?: boolean;
425
428
  once?: boolean;
426
429
  }
430
+ type IEventOption = IEventListenerOptions | boolean | 'once';
427
431
  interface IEventListenerItem extends IEventListenerOptions {
428
432
  listener: IEventListener;
429
433
  }
430
434
  interface IEventListenerMap {
431
435
  [name: string]: IEventListenerItem[];
432
436
  }
437
+ interface IEventMap {
438
+ [name: string]: IEventListener | [IEventListener, IEventOption];
439
+ }
433
440
  interface IEventListenerId {
434
441
  type: string | string[];
435
442
  current: ILeaf;
436
443
  listener: IEventListener;
437
- options?: IEventListenerOptions | boolean;
444
+ options?: IEventOption;
438
445
  }
439
446
  type InnerId = number;
440
447
  interface IEventer extends ILeafEventer {
441
448
  readonly innerId: InnerId;
442
449
  __captureMap?: IEventListenerMap;
443
450
  __bubbleMap?: IEventListenerMap;
444
- on(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void;
445
- off(type?: string | string[], listener?: IEventListener, options?: IEventListenerOptions | boolean): void;
446
- on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId;
451
+ on(type: string | string[], listener: IEventListener, options?: IEventOption): void;
452
+ off(type?: string | string[], listener?: IEventListener, options?: IEventOption): void;
453
+ on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventOption): IEventListenerId;
447
454
  off_(id: IEventListenerId | IEventListenerId[]): void;
448
455
  once(type: string | string[], listener: IEventListener): void;
449
456
  emit(type: string, event?: IEvent | IObject, capture?: boolean): void;
@@ -879,7 +886,8 @@ interface ILeafLayout {
879
886
  interface IExportOptions {
880
887
  quality?: number;
881
888
  blob?: boolean;
882
- scale?: number;
889
+ scale?: number | IPointData;
890
+ size?: number | ISizeData;
883
891
  smooth?: boolean;
884
892
  pixelRatio?: number;
885
893
  slice?: boolean;
@@ -910,6 +918,7 @@ interface IExportOnCanvasFunction {
910
918
 
911
919
  interface ILeaferCanvasConfig extends IAutoBoundsData {
912
920
  view?: string | IObject;
921
+ canvas?: string | IObject;
913
922
  fill?: string;
914
923
  pixelRatio?: number;
915
924
  smooth?: boolean;
@@ -1042,7 +1051,7 @@ interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
1042
1051
  isSameSize(options: ILeaferCanvasConfig): boolean;
1043
1052
  getSameCanvas(useSameWorldTransform?: boolean, useSameSmooth?: boolean): ILeaferCanvas;
1044
1053
  recycle(clearBounds?: IBoundsData): void;
1045
- updateRender(): void;
1054
+ updateRender(bounds: IBoundsData): void;
1046
1055
  unrealCanvas(): void;
1047
1056
  destroy(): void;
1048
1057
  }
@@ -1114,7 +1123,7 @@ interface ILeafBounds {
1114
1123
  __updateLocalBoxBounds?(): void;
1115
1124
  __updateLocalStrokeBounds?(): void;
1116
1125
  __updateLocalRenderBounds?(): void;
1117
- __updateBoxBounds?(): void;
1126
+ __updateBoxBounds?(secondLayout?: boolean): void;
1118
1127
  __updateStrokeBounds?(): void;
1119
1128
  __updateRenderBounds?(): void;
1120
1129
  __updateAutoLayout?(): void;
@@ -1289,6 +1298,7 @@ interface ILeafAttrData {
1289
1298
  hitSelf?: IBoolean;
1290
1299
  hitRadius?: INumber;
1291
1300
  cursor?: ICursorType | ICursorType[];
1301
+ event?: IEventMap;
1292
1302
  normalStyle?: ILeafInputData;
1293
1303
  hoverStyle?: ILeafInputData;
1294
1304
  pressStyle?: ILeafInputData;
@@ -1297,6 +1307,7 @@ interface ILeafAttrData {
1297
1307
  disabledStyle?: ILeafInputData;
1298
1308
  data: IObject;
1299
1309
  }
1310
+ type ISide = 'width' | 'height';
1300
1311
  type IAxis = 'x' | 'y';
1301
1312
  type IAxisReverse = 'x-reverse' | 'y-reverse';
1302
1313
  type IFlowType = boolean | IAxis | IAxisReverse;
@@ -1342,6 +1353,7 @@ interface IImageCursor {
1342
1353
  rotation?: number;
1343
1354
  }
1344
1355
  type IDirection = 'top-left' | 'top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'left' | 'center';
1356
+ type IDirection4 = 'top' | 'right' | 'bottom' | 'left';
1345
1357
  type IAlign = IDirection;
1346
1358
  type IBaseLineAlign = 'baseline-left' | 'baseline-center' | 'baseline-right';
1347
1359
  type IFlowAlign = IAlign | IBaseLineAlign;
@@ -1407,6 +1419,7 @@ interface ILeafInputData {
1407
1419
  hitSelf?: IBoolean;
1408
1420
  hitRadius?: INumber;
1409
1421
  cursor?: ICursorType | ICursorType[];
1422
+ event?: IEventMap;
1410
1423
  normalStyle?: ILeafInputData;
1411
1424
  hoverStyle?: ILeafInputData;
1412
1425
  pressStyle?: ILeafInputData;
@@ -1588,7 +1601,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1588
1601
  __updateLocalStrokeBounds(): void;
1589
1602
  __updateLocalRenderBounds(): void;
1590
1603
  __updateContentBounds(): void;
1591
- __updateBoxBounds(): void;
1604
+ __updateBoxBounds(secondLayout?: boolean): void;
1592
1605
  __updateStrokeBounds(): void;
1593
1606
  __updateRenderBounds(): void;
1594
1607
  __updateAutoLayout(): void;
@@ -1622,6 +1635,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1622
1635
  setTransform(transform?: IMatrixData, resize?: boolean): void;
1623
1636
  transform(transform?: IMatrixData, resize?: boolean): void;
1624
1637
  move(x: number | IPointData, y?: number): void;
1638
+ moveInner(x: number | IPointData, y?: number): void;
1625
1639
  scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void;
1626
1640
  rotateOf(origin: IPointData | IAlign, rotation: number): void;
1627
1641
  skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void;
@@ -1630,6 +1644,7 @@ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDa
1630
1644
  scaleOfWorld(worldOrigin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
1631
1645
  rotateOfWorld(worldOrigin: IPointData, rotation: number): void;
1632
1646
  skewOfWorld(worldOrigin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
1647
+ flip(axis: IAxis): void;
1633
1648
  scaleResize(scaleX: number, scaleY: number, noResize?: boolean): void;
1634
1649
  __scaleResize(scaleX: number, scaleY: number): void;
1635
1650
  resizeWidth(width: number): void;
@@ -1724,6 +1739,7 @@ interface IPointerEvent extends IUIEvent {
1724
1739
  width?: number;
1725
1740
  height?: number;
1726
1741
  pointerType?: PointerType;
1742
+ multiTouch?: boolean;
1727
1743
  pressure?: number;
1728
1744
  tangentialPressure?: number;
1729
1745
  tiltX?: number;
@@ -1756,6 +1772,7 @@ interface IZoomEvent extends IUIEvent {
1756
1772
  scale: number;
1757
1773
  }
1758
1774
  interface IMoveEvent extends IDragEvent {
1775
+ moveType?: 'drag' | 'move';
1759
1776
  }
1760
1777
  interface ISwipeEvent extends IDragEvent {
1761
1778
  }
@@ -1776,9 +1793,14 @@ interface IInteraction extends IControl {
1776
1793
  selector: ISelector;
1777
1794
  running: boolean;
1778
1795
  readonly dragging: boolean;
1796
+ readonly transforming: boolean;
1797
+ readonly moveMode: boolean;
1798
+ readonly canHover: boolean;
1779
1799
  readonly isDragEmpty: boolean;
1800
+ readonly isMobileDragEmpty: boolean;
1801
+ readonly isHoldMiddleKey: boolean;
1780
1802
  readonly isHoldRightKey: boolean;
1781
- readonly moveMode: boolean;
1803
+ readonly isHoldSpaceKey: boolean;
1782
1804
  config: IInteractionConfig;
1783
1805
  cursor: ICursorType | ICursorType[];
1784
1806
  readonly hitRadius: number;
@@ -1821,6 +1843,7 @@ interface IInteractionCanvas extends ILeaferCanvas {
1821
1843
  interface IInteractionConfig {
1822
1844
  wheel?: IWheelConfig;
1823
1845
  pointer?: IPointerConfig;
1846
+ touch?: ITouchConfig;
1824
1847
  zoom?: IZoomConfig;
1825
1848
  move?: IMoveConfig;
1826
1849
  eventer?: IObject;
@@ -1838,7 +1861,7 @@ interface IMoveConfig {
1838
1861
  holdMiddleKey?: boolean;
1839
1862
  holdRightKey?: boolean;
1840
1863
  scroll?: boolean | 'limit';
1841
- drag?: boolean;
1864
+ drag?: boolean | 'auto';
1842
1865
  dragAnimate?: boolean;
1843
1866
  dragEmpty?: boolean;
1844
1867
  dragOut?: boolean;
@@ -1863,6 +1886,7 @@ interface IPointerConfig {
1863
1886
  longPressTime?: number;
1864
1887
  transformTime?: number;
1865
1888
  hover?: boolean;
1889
+ touch?: boolean;
1866
1890
  dragHover?: boolean;
1867
1891
  dragDistance?: number;
1868
1892
  swipeDistance?: number;
@@ -1870,6 +1894,9 @@ interface IPointerConfig {
1870
1894
  preventDefault?: boolean;
1871
1895
  preventDefaultMenu?: boolean;
1872
1896
  }
1897
+ interface ITouchConfig {
1898
+ preventDefault?: boolean | 'auto';
1899
+ }
1873
1900
 
1874
1901
  interface IHitCanvasManager extends ICanvasManager {
1875
1902
  maxTotal: number;
@@ -1880,10 +1907,11 @@ interface IHitCanvasManager extends ICanvasManager {
1880
1907
  interface IZoomView extends IBranch {
1881
1908
  }
1882
1909
 
1883
- type ILeaferType = 'draw' | 'editor' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart' | 'custom';
1910
+ type ILeaferType = 'draw' | 'block' | 'editor' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart' | 'custom';
1884
1911
  interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
1885
1912
  start?: boolean;
1886
1913
  type?: ILeaferType;
1914
+ mobile?: boolean;
1887
1915
  realCanvas?: boolean;
1888
1916
  lazySpeard?: IFourNumber;
1889
1917
  }
@@ -1927,6 +1955,9 @@ interface ILeaferAttrData {
1927
1955
  getValidMove(moveX: number, moveY: number): IPointData;
1928
1956
  getValidScale(changeScale: number): number;
1929
1957
  getWorldPointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
1958
+ getPagePointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
1959
+ updateClientBounds(): void;
1960
+ receiveEvent(event: any): void;
1930
1961
  }
1931
1962
  type IZoomType = 'in' | 'out' | 'fit' | 'fit-width' | 'fit-height' | number | ILeaf | ILeaf[] | IBoundsData;
1932
1963
  interface ILeaferBase extends IZoomView, IControl, ILeaferAttrData {
@@ -2030,7 +2061,7 @@ interface IImageManager {
2030
2061
  destroy(): void;
2031
2062
  }
2032
2063
 
2033
- type ICanvasType = 'skia' | 'napi' | 'canvas' | 'wx';
2064
+ type ICanvasType = 'skia' | 'napi' | 'canvas' | 'miniapp';
2034
2065
  interface ISkiaCanvas {
2035
2066
  toBuffer(format: IExportFileType, config: ISkiaCanvasExportConfig): Promise<any>;
2036
2067
  toBufferSync(format: IExportFileType, config: ISkiaCanvasExportConfig): any;
@@ -2065,10 +2096,11 @@ interface IPlatform {
2065
2096
  toURL(text: string, fileType?: 'text' | 'svg'): string;
2066
2097
  requestRender?(render: IFunction): void;
2067
2098
  canvas?: ILeaferCanvas;
2099
+ renderCanvas?: ILeaferCanvas;
2068
2100
  canvasType?: ICanvasType;
2069
2101
  isWorker?: boolean;
2070
2102
  isMobile?: boolean;
2071
- devicePixelRatio?: number;
2103
+ readonly devicePixelRatio?: number;
2072
2104
  intWheelDeltaY?: boolean;
2073
2105
  conicGradientSupport?: boolean;
2074
2106
  conicGradientRotate90?: boolean;
@@ -2135,4 +2167,4 @@ interface ICursorRotateMap {
2135
2167
  [name: string]: ICursorRotate;
2136
2168
  }
2137
2169
 
2138
- export type { ACommandData, ArcCommandData, ArcToCommandData, CCommandData, CanvasPathCommand, EllipseCommandData, HCommandData, IAlign, IAnimateEvent, IAnswer, IAppBase, IAround, IAttrDecorator, IAutoBounds, IAutoBoundsData, IAutoBoxData, IAutoSize, IAxis, IAxisAlign, IAxisReverse, IBaseLineAlign, IBlendMode, IBlob, IBlobFunction, IBoolean, IBooleanMap, IBounds, IBoundsData, IBoundsDataFn, IBoundsType, IBranch, IBranchRender, IBranchRenderModule, ICachedLeaf, ICanvasAttr, ICanvasCacheOptions, ICanvasContext2D, ICanvasContext2DSettings, ICanvasManager, ICanvasPattern, ICanvasStrokeOptions, ICanvasType, IChildEvent, IClientPointData, IConstraint, IConstraintType, IControl, ICreator, ICursorRotate, ICursorRotateMap, ICursorType, ICursorTypeMap, IDataProcessor, IDataTypeHandle, IDirection, IDragEvent, IDropEvent, IEditSize, IEraserType, IEvent, IEventListener, IEventListenerId, IEventListenerItem, IEventListenerMap, IEventListenerOptions, IEventTarget, IEventer, IExportFileType, IExportImageType, IExportOnCanvasFunction, IExportOptions, IExportResult, IExportResultFunction, IFindCondition, IFindMethod, IFlowAlign, IFlowAxisAlign, IFlowBoxType, IFlowType, IFlowWrap, IFourNumber, IFromToData, IFunction, IGap, IHitCanvas, IHitCanvasConfig, IHitCanvasManager, IHitType, IImageCursor, IImageEvent, IImageManager, IInteraction, IInteractionCanvas, IInteractionConfig, IJSONOptions, IKeepTouchData, IKeyEvent, ILayoutAttr, ILayoutBlockData, ILayoutBoundsData, ILayoutChangedData, ILayoutData, ILayoutEvent, ILayouter, ILayouterConfig, ILeaf, ILeafArrayMap, ILeafAttrData, ILeafAttrDescriptor, ILeafAttrDescriptorFn, ILeafBounds, ILeafBoundsModule, ILeafComputedData, ILeafData, ILeafDataOptions, ILeafDataProxy, ILeafDataProxyModule, ILeafEventer, ILeafEventerModule, ILeafHit, ILeafHitModule, ILeafInputData, ILeafLayout, ILeafLevelList, ILeafList, ILeafListItemCallback, ILeafMap, ILeafMatrix, ILeafMatrixModule, ILeafRender, ILeafRenderModule, ILeaferAttrData, ILeaferBase, ILeaferCanvas, ILeaferCanvasConfig, ILeaferCanvasView, ILeaferConfig, ILeaferEvent, ILeaferImage, ILeaferImageCacheCanvas, ILeaferImageConfig, ILeaferImageOnError, ILeaferImageOnLoaded, ILeaferImagePatternPaint, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILocationType, IMaskType, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IMatrixWithOptionScaleData, IMatrixWithScaleData, IMiniapp, IMiniappSelect, IMiniappSizeView, IMoveEvent, IMultiTouchData, INumber, INumberFunction, INumberMap, IObject, IObjectFunction, IOffsetBoundsData, IPartLayoutConfig, IPath2D, IPathCommandData, IPathCreator, IPathDrawer, IPathString, IPercentData, IPickBottom, IPickOptions, IPickResult, IPlatform, IPlugin, IPoint, IPointData, IPointDataFunction, IPointDataMap, IPointGap, IPointerConfig, IPointerEvent, IPropertyEvent, IRadiusPointData, IRangeSize, IRenderEvent, IRenderOptions, IRenderer, IRendererConfig, IResizeEvent, IResizeEventListener, IRotateEvent, IScaleData, IScaleRotationData, IScreenSizeData, IScrollPointData, ISelector, ISelectorConfig, ISelectorProxy, ISize, ISizeData, ISkewData, ISkiaCanvas, ISkiaCanvasExportConfig, ISkiaNAPICanvas, IStateStyleType, IString, IStringFunction, IStringMap, ISwipeEvent, ITaskItem, ITaskOptions, ITaskProcessor, ITaskProcessorConfig, ITextMetrics, ITimer, ITwoPointBoundsData, IUICreator, IUIEvent, IUnitData, IUnitPointData, IUpdateEvent, IValue, IWatchEvent, IWatchEventData, IWatcher, IWatcherConfig, IWheelConfig, IWindingRule, IZoomEvent, IZoomType, IZoomView, InnerId, LCommandData, MCommandData, PointerType, QCommandData, RectCommandData, RoundRectCommandData, SCommandData, TCommandData, VCommandData, ZCommandData };
2170
+ export type { ACommandData, ArcCommandData, ArcToCommandData, CCommandData, CanvasPathCommand, EllipseCommandData, HCommandData, IAlign, IAnimateEvent, IAnswer, IAppBase, IAround, IAttrDecorator, IAutoBounds, IAutoBoundsData, IAutoBoxData, IAutoSize, IAxis, IAxisAlign, IAxisReverse, IBaseLineAlign, IBlendMode, IBlob, IBlobFunction, IBoolean, IBooleanMap, IBounds, IBoundsData, IBoundsDataFn, IBoundsType, IBranch, IBranchRender, IBranchRenderModule, ICachedLeaf, ICanvasAttr, ICanvasCacheOptions, ICanvasContext2D, ICanvasContext2DSettings, ICanvasManager, ICanvasPattern, ICanvasStrokeOptions, ICanvasType, IChildEvent, IClientPointData, IConstraint, IConstraintType, IControl, ICreator, ICursorRotate, ICursorRotateMap, ICursorType, ICursorTypeMap, IDataProcessor, IDataTypeHandle, IDirection, IDirection4, IDragEvent, IDropEvent, IEditSize, IEraserType, IEvent, IEventListener, IEventListenerId, IEventListenerItem, IEventListenerMap, IEventListenerOptions, IEventMap, IEventOption, IEventTarget, IEventer, IExportFileType, IExportImageType, IExportOnCanvasFunction, IExportOptions, IExportResult, IExportResultFunction, IFindCondition, IFindMethod, IFlowAlign, IFlowAxisAlign, IFlowBoxType, IFlowType, IFlowWrap, IFourNumber, IFromToData, IFunction, IFunctionMap, IGap, IHitCanvas, IHitCanvasConfig, IHitCanvasManager, IHitType, IImageCursor, IImageEvent, IImageManager, IInteraction, IInteractionCanvas, IInteractionConfig, IJSONOptions, IKeepTouchData, IKeyEvent, ILayoutAttr, ILayoutBlockData, ILayoutBoundsData, ILayoutChangedData, ILayoutData, ILayoutEvent, ILayouter, ILayouterConfig, ILeaf, ILeafArrayMap, ILeafAttrData, ILeafAttrDescriptor, ILeafAttrDescriptorFn, ILeafBounds, ILeafBoundsModule, ILeafComputedData, ILeafData, ILeafDataOptions, ILeafDataProxy, ILeafDataProxyModule, ILeafEventer, ILeafEventerModule, ILeafHit, ILeafHitModule, ILeafInputData, ILeafLayout, ILeafLevelList, ILeafList, ILeafListItemCallback, ILeafMap, ILeafMatrix, ILeafMatrixModule, ILeafRender, ILeafRenderModule, ILeaferAttrData, ILeaferBase, ILeaferCanvas, ILeaferCanvasConfig, ILeaferCanvasView, ILeaferConfig, ILeaferEvent, ILeaferImage, ILeaferImageCacheCanvas, ILeaferImageConfig, ILeaferImageOnError, ILeaferImageOnLoaded, ILeaferImagePatternPaint, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, ILocationType, IMaskType, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixWithBoundsScaleData, IMatrixWithLayoutData, IMatrixWithOptionScaleData, IMatrixWithScaleData, IMiniapp, IMiniappSelect, IMiniappSizeView, IMoveEvent, IMultiTouchData, INumber, INumberFunction, INumberMap, IObject, IObjectFunction, IOffsetBoundsData, IPartLayoutConfig, IPath2D, IPathCommandData, IPathCreator, IPathDrawer, IPathString, IPercentData, IPickBottom, IPickOptions, IPickResult, IPlatform, IPlugin, IPoint, IPointData, IPointDataFunction, IPointDataMap, IPointGap, IPointerConfig, IPointerEvent, IPropertyEvent, IRadiusPointData, IRangeSize, IRenderEvent, IRenderOptions, IRenderer, IRendererConfig, IResizeEvent, IResizeEventListener, IRotateEvent, IScaleData, IScaleRotationData, IScreenSizeData, IScrollPointData, ISelector, ISelectorConfig, ISelectorProxy, ISide, ISize, ISizeData, ISkewData, ISkiaCanvas, ISkiaCanvasExportConfig, ISkiaNAPICanvas, IStateStyleType, IString, IStringFunction, IStringMap, ISwipeEvent, ITaskItem, ITaskOptions, ITaskProcessor, ITaskProcessorConfig, ITextMetrics, ITimer, ITouchConfig, ITwoPointBoundsData, IUICreator, IUIEvent, IUnitData, IUnitPointData, IUpdateEvent, IValue, IWatchEvent, IWatchEventData, IWatcher, IWatcherConfig, IWheelConfig, IWindingRule, IZoomEvent, IZoomType, IZoomView, InnerId, LCommandData, MCommandData, PointerType, QCommandData, RectCommandData, RoundRectCommandData, SCommandData, TCommandData, VCommandData, ZCommandData };