@leafer/interface 1.0.0-rc.9 → 1.0.1

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/types/index.d.ts CHANGED
@@ -1,102 +1,33 @@
1
1
  import { ILeaferCanvas as ILeaferCanvas$1, IScreenSizeData as IScreenSizeData$1 } from '@leafer/interface';
2
2
 
3
- type INumber = number;
4
- type IBoolean = boolean;
5
- type IString = string;
6
- type IValue = INumber | IBoolean | IString | IObject;
7
- type ITimer = any;
8
- type IPathString = string;
9
- interface IObject {
10
- [name: string]: any;
11
- }
12
- interface IBooleanMap {
13
- [name: string]: boolean;
14
- }
15
- interface INumberMap {
16
- [name: string]: number;
17
- }
18
- interface IStringMap {
19
- [name: string]: string;
20
- }
21
- interface IDataTypeHandle {
22
- (target: any): void;
23
- }
24
-
25
- interface ILeafMap {
26
- [name: string]: ILeaf;
27
- }
28
- interface ILeafArrayMap {
29
- [name: string]: ILeaf[];
30
- }
31
- type ILeafListItemCallback = (item: ILeaf, index?: number) => void;
32
- interface ILeafList {
33
- list: ILeaf[];
34
- keys: INumberMap;
35
- readonly length: number;
36
- has(leaf: ILeaf): boolean;
37
- indexAt(index: number): ILeaf;
38
- indexOf(leaf: ILeaf): number;
39
- add(leaf: ILeaf): void;
40
- addAt(leaf: ILeaf, index: number): void;
41
- addList(list: ILeaf[]): void;
42
- remove(leaf: ILeaf): void;
43
- forEach(itemCallback: ILeafListItemCallback): void;
44
- sort(reverse?: boolean): void;
45
- clone(): ILeafList;
46
- update(): void;
47
- reset(): void;
48
- destroy(): void;
49
- }
50
- interface ILeafLevelList {
51
- levelMap: ILeafArrayMap;
52
- keys: INumberMap;
53
- levels: number[];
54
- readonly length: number;
55
- has(leaf: ILeaf): boolean;
56
- without(leaf: ILeaf): boolean;
57
- sort(reverse?: boolean): void;
58
- addList(list: ILeaf[]): void;
59
- add(leaf: ILeaf): void;
60
- forEach(itemCallback: ILeafListItemCallback): void;
61
- reset(): void;
62
- destroy(): void;
3
+ interface IPointData {
4
+ x: number;
5
+ y: number;
63
6
  }
64
-
65
- interface IControl {
66
- start(): void;
67
- stop(): void;
68
- destroy(): void;
7
+ interface IUnitPointData {
8
+ type?: 'percent' | 'px';
9
+ x: number;
10
+ y: number;
69
11
  }
70
-
71
- interface IWatchEventData {
72
- updatedList: ILeafList;
12
+ interface IFromToData {
13
+ from: IPointData;
14
+ to: IPointData;
73
15
  }
74
- interface IWatcherConfig {
16
+ interface IScrollPointData {
17
+ scrollX: number;
18
+ scrollY: number;
75
19
  }
76
- interface IWatcher extends IControl {
77
- target: ILeaf;
78
- totalTimes: number;
79
- disabled: boolean;
80
- running: boolean;
81
- changed: boolean;
82
- hasVisible: boolean;
83
- hasAdd: boolean;
84
- hasRemove: boolean;
85
- readonly childrenChanged: boolean;
86
- config: IWatcherConfig;
87
- updatedList: ILeafList;
88
- disable(): void;
89
- update(): void;
90
- }
91
-
92
- interface IPointData {
93
- x: number;
94
- y: number;
20
+ interface IClientPointData {
21
+ clientX: number;
22
+ clientY: number;
95
23
  }
96
24
  interface IPoint extends IPointData {
97
25
  set(x?: number | IPointData, y?: number): IPoint;
98
26
  get(): IPointData;
99
27
  clone(): IPoint;
28
+ move(x: number, y: number): IPoint;
29
+ scale(scaleX: number, scaleY?: number): IPoint;
30
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IPoint;
100
31
  rotate(rotation: number, origin?: IPointData): IPoint;
101
32
  rotateOf(origin: IPointData, rotation: number): IPoint;
102
33
  getRotation(origin: IPointData, to: IPointData, toOrigin?: IPointData): number;
@@ -104,7 +35,7 @@ interface IPoint extends IPointData {
104
35
  toOuterOf(matrix: IMatrixData, to?: IPointData): IPoint;
105
36
  getCenter(to: IPointData): IPoint;
106
37
  getDistance(to: IPointData): number;
107
- getDistancePoint(to: IPointData, distance: number): IPoint;
38
+ getDistancePoint(to: IPointData, distance: number, changeTo?: boolean): IPoint;
108
39
  getAngle(to: IPointData): number;
109
40
  getAtan2(to: IPointData): number;
110
41
  reset(): IPoint;
@@ -135,19 +66,25 @@ interface IBounds extends IBoundsData, ITwoPointBoundsData {
135
66
  set(x?: number | IBoundsData, y?: number, width?: number, height?: number): IBounds;
136
67
  get(): IBoundsData;
137
68
  clone(): IBounds;
69
+ move(x: number, y: number): IBounds;
138
70
  scale(scaleX: number, scaleY?: number): IBounds;
139
71
  scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IBounds;
140
72
  toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds;
141
- getFitMatrix(put: IBoundsData): IMatrix;
142
- spread(spreadX: number, spreadY?: number): IBounds;
73
+ toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds;
74
+ getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix;
75
+ spread(fourNumber: IFourNumber): IBounds;
76
+ shrink(fourNumber: IFourNumber): IBounds;
143
77
  ceil(): IBounds;
144
78
  unsign(): IBounds;
79
+ float(maxLength?: number): IBounds;
145
80
  add(bounds: IBoundsData): IBounds;
146
81
  addList(boundsList: IBoundsData[]): IBounds;
147
82
  setList(boundsList: IBoundsData[]): IBounds;
148
83
  addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds;
149
84
  setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds;
85
+ setPoint(point: IPointData): IBounds;
150
86
  setPoints(points: IPointData[]): IBounds;
87
+ addPoint(point: IPointData): IBounds;
151
88
  getPoints(): IPointData[];
152
89
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean;
153
90
  hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixWithLayoutData): boolean;
@@ -165,11 +102,13 @@ interface ITwoPointBoundsData {
165
102
  maxX: number;
166
103
  maxY: number;
167
104
  }
168
- interface IAutoBoundsData {
105
+ interface IAutoBoxData {
169
106
  top?: number;
170
107
  right?: number;
171
108
  bottom?: number;
172
109
  left?: number;
110
+ }
111
+ interface IAutoBoundsData extends IAutoBoxData {
173
112
  width?: number;
174
113
  height?: number;
175
114
  }
@@ -202,13 +141,15 @@ interface ILayoutData extends IScaleRotationData, ISkewData, IPointData {
202
141
  type ILayoutAttr = 'x' | 'y' | 'scaleX' | 'scaleY' | 'rotation' | 'skewX' | 'skewY';
203
142
  interface ILayoutBoundsData extends ILayoutData, IBoundsData {
204
143
  }
205
- interface IMatrix extends IMatrixData {
144
+ interface IMatrix extends IMatrixWithScaleData {
206
145
  set(a: number | IMatrixData, b: number, c: number, d: number, e: number, f: number): IMatrix;
146
+ setWith(dataWithScale: IMatrixWithScaleData): IMatrix;
207
147
  get(): IMatrixData;
208
148
  clone(): IMatrix;
209
149
  translate(x: number, y: number): IMatrix;
210
150
  translateInner(x: number, y: number): IMatrix;
211
151
  scale(x: number, y?: number): IMatrix;
152
+ scaleWith(x: number, y?: number): IMatrix;
212
153
  scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix;
213
154
  scaleOfInner(origin: IPointData, x: number, y?: number): IMatrix;
214
155
  rotate(angle: number): IMatrix;
@@ -222,19 +163,145 @@ interface IMatrix extends IMatrixData {
222
163
  divide(child: IMatrixData): IMatrix;
223
164
  divideParent(parent: IMatrixData): IMatrix;
224
165
  invert(): IMatrix;
166
+ invertWith(): IMatrix;
225
167
  toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void;
226
168
  toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void;
227
- setLayout(data: ILayoutData, origin?: IPointData): IMatrix;
228
- 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
+ withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData;
229
172
  reset(): void;
230
173
  }
231
174
  interface IMatrixWithBoundsData extends IMatrixData, IBoundsData {
232
175
  }
233
176
  interface IMatrixWithScaleData extends IMatrixData, IScaleData {
234
177
  }
178
+ interface IMatrixWithOptionScaleData extends IMatrixData {
179
+ scaleX?: number;
180
+ scaleY?: number;
181
+ }
182
+ interface IMatrixWithBoundsScaleData extends IMatrixData, IBoundsData, IScaleData {
183
+ }
235
184
  interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData {
236
185
  }
237
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
+
209
+ type INumber = number;
210
+ type IBoolean = boolean;
211
+ type IString = string;
212
+ type IValue = INumber | IBoolean | IString | IObject;
213
+ type ITimer = any;
214
+ type IPathString = string;
215
+ type IFourNumber = number | number[];
216
+ interface IObject {
217
+ [name: string]: any;
218
+ }
219
+ interface IBooleanMap {
220
+ [name: string]: boolean;
221
+ }
222
+ interface INumberMap {
223
+ [name: string]: number;
224
+ }
225
+ interface IStringMap {
226
+ [name: string]: string;
227
+ }
228
+ interface IFunctionMap {
229
+ [name: string]: IFunction;
230
+ }
231
+ interface IPointDataMap {
232
+ [name: string]: IPointData;
233
+ }
234
+ interface IDataTypeHandle {
235
+ (target: any): void;
236
+ }
237
+
238
+ interface ILeafMap {
239
+ [name: string]: ILeaf;
240
+ }
241
+ interface ILeafArrayMap {
242
+ [name: string]: ILeaf[];
243
+ }
244
+ type ILeafListItemCallback = (item: ILeaf, index?: number) => void;
245
+ interface ILeafList {
246
+ list: ILeaf[];
247
+ keys: INumberMap;
248
+ readonly length: number;
249
+ has(leaf: ILeaf): boolean;
250
+ indexAt(index: number): ILeaf;
251
+ indexOf(leaf: ILeaf): number;
252
+ add(leaf: ILeaf): void;
253
+ addAt(leaf: ILeaf, index: number): void;
254
+ addList(list: ILeaf[]): void;
255
+ remove(leaf: ILeaf): void;
256
+ forEach(itemCallback: ILeafListItemCallback): void;
257
+ sort(reverse?: boolean): void;
258
+ clone(): ILeafList;
259
+ update(): void;
260
+ reset(): void;
261
+ destroy(): void;
262
+ }
263
+ interface ILeafLevelList {
264
+ levelMap: ILeafArrayMap;
265
+ keys: INumberMap;
266
+ levels: number[];
267
+ readonly length: number;
268
+ has(leaf: ILeaf): boolean;
269
+ without(leaf: ILeaf): boolean;
270
+ sort(reverse?: boolean): void;
271
+ addList(list: ILeaf[]): void;
272
+ add(leaf: ILeaf): void;
273
+ forEach(itemCallback: ILeafListItemCallback): void;
274
+ reset(): void;
275
+ destroy(): void;
276
+ }
277
+
278
+ interface IControl {
279
+ start(): void;
280
+ stop(): void;
281
+ destroy(): void;
282
+ }
283
+
284
+ interface IWatchEventData {
285
+ updatedList: ILeafList;
286
+ }
287
+ interface IWatcherConfig {
288
+ }
289
+ interface IWatcher extends IControl {
290
+ target: ILeaf;
291
+ totalTimes: number;
292
+ disabled: boolean;
293
+ running: boolean;
294
+ changed: boolean;
295
+ hasVisible: boolean;
296
+ hasAdd: boolean;
297
+ hasRemove: boolean;
298
+ readonly childrenChanged: boolean;
299
+ config: IWatcherConfig;
300
+ updatedList: ILeafList;
301
+ disable(): void;
302
+ update(): void;
303
+ }
304
+
238
305
  interface ILayoutChangedData {
239
306
  matrixList: ILeaf[];
240
307
  boundsList: ILeaf[];
@@ -346,7 +413,7 @@ interface IKeepTouchData {
346
413
  type ILeafEventerModule = ILeafEventer & ThisType<ILeaf>;
347
414
  interface ILeafEventer {
348
415
  on?(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void;
349
- off?(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void;
416
+ off?(type?: string | string[], listener?: IEventListener, options?: IEventListenerOptions | boolean): void;
350
417
  on_?(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId;
351
418
  off_?(id: IEventListenerId | IEventListenerId[]): void;
352
419
  once?(type: string | string[], listener: IEventListener, capture?: boolean): void;
@@ -355,47 +422,35 @@ interface ILeafEventer {
355
422
  hasEvent?(type: string, capture?: boolean): boolean;
356
423
  }
357
424
 
358
- interface IFunction {
359
- (...arg: any): any;
360
- }
361
- interface INumberFunction {
362
- (...arg: any): number;
363
- }
364
- interface IPointDataFunction {
365
- (...arg: any): IPointData;
366
- }
367
- interface IAttrDecorator {
368
- (...arg: any): IAttrDecoratorInner;
369
- }
370
- interface IAttrDecoratorInner {
371
- (target: any, key: string): any;
372
- }
373
-
374
425
  type IEventListener = IFunction;
375
426
  interface IEventListenerOptions {
376
427
  capture?: boolean;
377
428
  once?: boolean;
378
429
  }
430
+ type IEventOption = IEventListenerOptions | boolean | 'once';
379
431
  interface IEventListenerItem extends IEventListenerOptions {
380
432
  listener: IEventListener;
381
433
  }
382
434
  interface IEventListenerMap {
383
435
  [name: string]: IEventListenerItem[];
384
436
  }
437
+ interface IEventMap {
438
+ [name: string]: IEventListener | [IEventListener, IEventOption];
439
+ }
385
440
  interface IEventListenerId {
386
441
  type: string | string[];
387
442
  current: ILeaf;
388
443
  listener: IEventListener;
389
- options?: IEventListenerOptions | boolean;
444
+ options?: IEventOption;
390
445
  }
391
446
  type InnerId = number;
392
447
  interface IEventer extends ILeafEventer {
393
448
  readonly innerId: InnerId;
394
449
  __captureMap?: IEventListenerMap;
395
450
  __bubbleMap?: IEventListenerMap;
396
- on(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void;
397
- off(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void;
398
- 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;
399
454
  off_(id: IEventListenerId | IEventListenerId[]): void;
400
455
  once(type: string | string[], listener: IEventListener): void;
401
456
  emit(type: string, event?: IEvent | IObject, capture?: boolean): void;
@@ -489,21 +544,23 @@ interface CanvasPathDrawingStyles {
489
544
  interface CanvasPattern {
490
545
  setTransform(transform?: DOMMatrix2DInit): void;
491
546
  }
547
+ type ICanvasPattern = CanvasPattern;
492
548
  interface CanvasRect {
493
549
  clearRect(x: number, y: number, w: number, h: number): void;
494
550
  fillRect(x: number, y: number, w: number, h: number): void;
495
551
  strokeRect(x: number, y: number, w: number, h: number): void;
496
552
  }
497
553
  type PredefinedColorSpace = 'display-p3' | 'srgb';
498
- interface CanvasRenderingContext2DSettings {
554
+ interface ICanvasRenderingContext2DSettings {
499
555
  alpha?: boolean;
500
556
  colorSpace?: PredefinedColorSpace;
501
557
  desynchronized?: boolean;
502
558
  willReadFrequently?: boolean;
503
559
  }
560
+ type ICanvasContext2DSettings = ICanvasRenderingContext2DSettings;
504
561
  interface ICanvasContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
505
562
  readonly canvas: HTMLCanvasElement;
506
- getContextAttributes(): CanvasRenderingContext2DSettings;
563
+ getContextAttributes(): ICanvasRenderingContext2DSettings;
507
564
  }
508
565
  interface CanvasShadowStyles {
509
566
  shadowBlur: number;
@@ -723,22 +780,24 @@ interface IPathDrawer {
723
780
  rect(x: number, y: number, width: number, height: number): void;
724
781
  roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): void;
725
782
  }
726
- interface IPathCreator {
783
+ interface IPathCreator extends IPathDrawer {
727
784
  path: IPathCommandData;
785
+ __path: IPathCommandData;
728
786
  beginPath(): IPathCreator;
729
787
  moveTo(x: number, y: number): IPathCreator;
730
788
  lineTo(x: number, y: number): IPathCreator;
731
789
  bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): IPathCreator;
732
790
  quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): IPathCreator;
733
791
  closePath(): IPathCreator;
734
- arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): IPathCreator;
792
+ arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
735
793
  arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): IPathCreator;
736
- ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): IPathCreator;
794
+ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
737
795
  rect(x: number, y: number, width: number, height: number): IPathCreator;
738
796
  roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): IPathCreator;
739
797
  drawEllipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
740
798
  drawArc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
741
799
  drawPoints(points: number[], curve?: boolean | number, close?: boolean): IPathCreator;
800
+ clearPath(): IPathCreator;
742
801
  }
743
802
 
744
803
  interface ICanvasManager {
@@ -750,13 +809,121 @@ interface ICanvasManager {
750
809
  destroy(): void;
751
810
  }
752
811
 
812
+ type IExportImageType = 'jpg' | 'png' | 'webp';
813
+ type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json';
814
+
815
+ type ILocationType = 'world' | 'page' | 'local' | 'inner';
816
+ type IBoundsType = 'content' | 'box' | 'stroke' | 'render';
817
+ interface ILeafLayout {
818
+ leaf: ILeaf;
819
+ proxyZoom: boolean;
820
+ contentBounds: IBoundsData;
821
+ boxBounds: IBoundsData;
822
+ strokeBounds: IBoundsData;
823
+ renderBounds: IBoundsData;
824
+ localContentBounds: IBoundsData;
825
+ localStrokeBounds: IBoundsData;
826
+ localRenderBounds: IBoundsData;
827
+ worldContentBounds: IBoundsData;
828
+ worldBoxBounds: IBoundsData;
829
+ worldStrokeBounds: IBoundsData;
830
+ resized: boolean;
831
+ waitAutoLayout: boolean;
832
+ matrixChanged: boolean;
833
+ scaleChanged: boolean;
834
+ rotationChanged: boolean;
835
+ boundsChanged: boolean;
836
+ boxChanged: boolean;
837
+ strokeChanged: boolean;
838
+ renderChanged: boolean;
839
+ localBoxChanged: boolean;
840
+ surfaceChanged: boolean;
841
+ opacityChanged: boolean;
842
+ hitCanvasChanged: boolean;
843
+ childrenSortChanged?: boolean;
844
+ affectScaleOrRotation: boolean;
845
+ affectRotation: boolean;
846
+ affectChildrenSort?: boolean;
847
+ strokeSpread: number;
848
+ strokeBoxSpread: number;
849
+ renderSpread: number;
850
+ renderShapeSpread: number;
851
+ a: number;
852
+ b: number;
853
+ c: number;
854
+ d: number;
855
+ e: number;
856
+ f: number;
857
+ x: number;
858
+ y: number;
859
+ width: number;
860
+ height: number;
861
+ createLocal(): void;
862
+ update(): void;
863
+ getTransform(relative?: ILocationType | ILeaf): IMatrixData;
864
+ getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
865
+ getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
866
+ getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[];
867
+ shrinkContent(): void;
868
+ spreadStroke(): void;
869
+ spreadRender(): void;
870
+ shrinkContentCancel(): void;
871
+ spreadStrokeCancel(): void;
872
+ spreadRenderCancel(): void;
873
+ boxChange(): void;
874
+ localBoxChange(): void;
875
+ strokeChange(): void;
876
+ renderChange(): void;
877
+ scaleChange(): void;
878
+ rotationChange(): void;
879
+ matrixChange(): void;
880
+ surfaceChange(): void;
881
+ opacityChange(): void;
882
+ childrenSortChange(): void;
883
+ destroy(): void;
884
+ }
885
+
886
+ interface IExportOptions {
887
+ quality?: number;
888
+ blob?: boolean;
889
+ scale?: number;
890
+ smooth?: boolean;
891
+ pixelRatio?: number;
892
+ slice?: boolean;
893
+ trim?: boolean;
894
+ fill?: string;
895
+ screenshot?: IBoundsData | boolean;
896
+ relative?: ILocationType | ILeaf;
897
+ json?: IJSONOptions;
898
+ contextSettings?: ICanvasContext2DSettings;
899
+ onCanvas?: IExportOnCanvasFunction;
900
+ }
901
+ interface IJSONOptions {
902
+ matrix?: boolean;
903
+ }
904
+ interface IExportResult {
905
+ data: ILeaferCanvas | IBlob | string | boolean;
906
+ width?: number;
907
+ height?: number;
908
+ renderBounds?: IBoundsData;
909
+ trimBounds?: IBoundsData;
910
+ }
911
+ interface IExportResultFunction {
912
+ (data: IExportResult): void;
913
+ }
914
+ interface IExportOnCanvasFunction {
915
+ (data: ILeaferCanvas): void;
916
+ }
917
+
753
918
  interface ILeaferCanvasConfig extends IAutoBoundsData {
754
919
  view?: string | IObject;
920
+ canvas?: string | IObject;
755
921
  fill?: string;
756
922
  pixelRatio?: number;
757
923
  smooth?: boolean;
758
924
  hittable?: boolean;
759
925
  webgl?: boolean;
926
+ contextSettings?: ICanvasContext2DSettings;
760
927
  }
761
928
  type IHitCanvasConfig = ILeaferCanvasConfig;
762
929
  interface ICanvasStrokeOptions {
@@ -768,6 +935,10 @@ interface ICanvasStrokeOptions {
768
935
  dashOffset?: number;
769
936
  miterLimit?: number;
770
937
  }
938
+ interface ICanvasCacheOptions extends ICanvasStrokeOptions {
939
+ fillStyle?: string | object;
940
+ strokeStyle?: string | object;
941
+ }
771
942
  interface ICanvasAttr extends ICanvasStrokeOptions, IObject {
772
943
  smooth: boolean;
773
944
  smoothLevel: string;
@@ -822,6 +993,7 @@ interface ICanvasMethod {
822
993
  restoreBlendMode(): void;
823
994
  hitFill(point: IPointData, fillRule?: string): boolean;
824
995
  hitStroke(point: IPointData, strokeWidth?: number): boolean;
996
+ hitPixel(radiusPoint: IRadiusPointData, offset?: IPointData, scale?: number): boolean;
825
997
  setStroke(strokeStyle: string | object, strokeWidth: number, options?: ICanvasStrokeOptions): void;
826
998
  setStrokeOptions(options: ICanvasStrokeOptions): void;
827
999
  setWorld(matrix: IMatrixData, parentMatrix?: IMatrixData): void;
@@ -829,7 +1001,7 @@ interface ICanvasMethod {
829
1001
  setWorldShadow(x: number, y: number, blur: number, color?: string): void;
830
1002
  setWorldBlur(blur: number): void;
831
1003
  copyWorld(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void;
832
- copyWorldByReset(canvas: ILeaferCanvas, from?: IBoundsData, to?: IBoundsData, blendMode?: string): void;
1004
+ copyWorldByReset(canvas: ILeaferCanvas, from?: IBoundsData, to?: IBoundsData, blendMode?: string, onlyResetTransform?: boolean): void;
833
1005
  copyWorldToInner(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toInnerBounds: IBoundsData, blendMode?: string): void;
834
1006
  useMask(maskCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void;
835
1007
  useEraser(eraserCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void;
@@ -839,6 +1011,7 @@ interface ICanvasMethod {
839
1011
  clearWorld(bounds: IBoundsData, ceilPixel?: boolean): void;
840
1012
  clear(): void;
841
1013
  }
1014
+ type ILeaferCanvasView = any;
842
1015
  interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
843
1016
  readonly innerId: InnerId;
844
1017
  name: string;
@@ -851,17 +1024,20 @@ interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
851
1024
  readonly allowBackgroundColor?: boolean;
852
1025
  backgroundColor?: string;
853
1026
  hittable?: boolean;
1027
+ zIndex?: number;
1028
+ childIndex?: number;
854
1029
  bounds: IBounds;
855
1030
  clientBounds: IBoundsData;
856
1031
  config: ILeaferCanvasConfig;
857
1032
  autoLayout: boolean;
858
- view: any;
1033
+ view: ILeaferCanvasView;
859
1034
  parentView: any;
860
1035
  unreal?: boolean;
861
1036
  context: ICanvasContext2D;
862
1037
  recycled?: boolean;
863
1038
  worldTransform: IMatrixData;
864
1039
  init(): void;
1040
+ export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): string | Promise<any>;
865
1041
  toBlob(type?: string, quality?: number): Promise<IBlob>;
866
1042
  toDataURL(type?: string, quality?: number): string | Promise<string>;
867
1043
  saveAs(filename: string, quality?: number): Promise<boolean>;
@@ -870,16 +1046,16 @@ interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
870
1046
  resize(size: IScreenSizeData): void;
871
1047
  updateViewSize(): void;
872
1048
  updateClientBounds(): void;
873
- setCursor(cursor: ICursorType | ICursorType[]): void;
1049
+ getClientBounds(update?: boolean): IBoundsData;
874
1050
  isSameSize(options: ILeaferCanvasConfig): boolean;
875
1051
  getSameCanvas(useSameWorldTransform?: boolean, useSameSmooth?: boolean): ILeaferCanvas;
876
- getBiggerCanvas(addWidth: number, addHeight: number): ILeaferCanvas;
877
- recycle(): void;
878
- updateRender(): void;
1052
+ recycle(clearBounds?: IBoundsData): void;
1053
+ updateRender(bounds: IBoundsData): void;
879
1054
  unrealCanvas(): void;
880
1055
  destroy(): void;
881
1056
  }
882
1057
  interface IHitCanvas extends ILeaferCanvas {
1058
+ hitScale?: number;
883
1059
  }
884
1060
  interface IBlobFunction {
885
1061
  (blob: IBlob | null): void;
@@ -890,7 +1066,7 @@ interface IRenderOptions {
890
1066
  includes?: boolean;
891
1067
  bounds?: IBounds;
892
1068
  hideBounds?: IBounds;
893
- matrix?: IMatrix;
1069
+ matrix?: IMatrixWithScaleData;
894
1070
  inCamera?: boolean;
895
1071
  }
896
1072
  interface IRendererConfig {
@@ -909,6 +1085,7 @@ interface IRenderer extends IControl {
909
1085
  rendering: boolean;
910
1086
  waitAgain: boolean;
911
1087
  changed: boolean;
1088
+ ignore: boolean;
912
1089
  config: IRendererConfig;
913
1090
  update(): void;
914
1091
  requestLayout(): void;
@@ -926,7 +1103,7 @@ interface IRenderer extends IControl {
926
1103
 
927
1104
  type ILeafDataProxyModule = ILeafDataProxy & ThisType<ILeaf>;
928
1105
  interface ILeafDataProxy {
929
- __setAttr?(name: string, newValue: IValue): void;
1106
+ __setAttr?(name: string, newValue: IValue): boolean;
930
1107
  __getAttr?(name: string): IValue;
931
1108
  setProxyAttr?(name: string, newValue: IValue): void;
932
1109
  getProxyAttr?(name: string): IValue;
@@ -949,77 +1126,20 @@ interface ILeafBounds {
949
1126
  __updateStrokeBounds?(): void;
950
1127
  __updateRenderBounds?(): void;
951
1128
  __updateAutoLayout?(): void;
1129
+ __updateFlowLayout?(): void;
952
1130
  __updateNaturalSize?(): void;
953
1131
  __updateStrokeSpread?(): number;
954
1132
  __updateRenderSpread?(): number;
955
1133
  __onUpdateSize?(): void;
956
1134
  }
957
1135
 
958
- type ILocationType = 'world' | 'local' | 'inner';
959
- type IBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render';
960
- interface ILeafLayout {
961
- leaf: ILeaf;
962
- proxyZoom: boolean;
963
- boxBounds: IBoundsData;
964
- strokeBounds: IBoundsData;
965
- renderBounds: IBoundsData;
966
- marginBounds: IBoundsData;
967
- contentBounds: IBoundsData;
968
- localStrokeBounds?: IBoundsData;
969
- localRenderBounds?: IBoundsData;
970
- resized: boolean;
971
- waitAutoLayout: boolean;
972
- matrixChanged: boolean;
973
- scaleChanged: boolean;
974
- rotationChanged: boolean;
975
- boundsChanged: boolean;
976
- boxChanged: boolean;
977
- strokeChanged: boolean;
978
- renderChanged: boolean;
979
- localBoxChanged: boolean;
980
- surfaceChanged: boolean;
981
- opacityChanged: boolean;
982
- hitCanvasChanged: boolean;
983
- childrenSortChanged?: boolean;
984
- affectScaleOrRotation: boolean;
985
- affectRotation: boolean;
986
- affectChildrenSort?: boolean;
987
- strokeSpread: number;
988
- renderSpread: number;
989
- strokeBoxSpread: number;
990
- renderShapeSpread: number;
991
- a: number;
992
- b: number;
993
- c: number;
994
- d: number;
995
- e: number;
996
- f: number;
997
- update(): void;
998
- getTransform(relative?: ILocationType | ILeaf): IMatrixData;
999
- getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
1000
- getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
1001
- getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[];
1002
- spreadStroke(): void;
1003
- spreadRender(): void;
1004
- spreadStrokeCancel(): void;
1005
- spreadRenderCancel(): void;
1006
- boxChange(): void;
1007
- localBoxChange(): void;
1008
- strokeChange(): void;
1009
- renderChange(): void;
1010
- scaleChange(): void;
1011
- rotationChange(): void;
1012
- matrixChange(): void;
1013
- surfaceChange(): void;
1014
- opacityChange(): void;
1015
- childrenSortChange(): void;
1016
- destroy(): void;
1017
- }
1018
-
1019
1136
  type ILeafHitModule = ILeafHit & ThisType<ILeaf>;
1020
1137
  interface ILeafHit {
1021
1138
  __hitWorld?(point: IRadiusPointData): boolean;
1022
- __hit?(local: IRadiusPointData): boolean;
1139
+ __hit?(inner: IRadiusPointData): boolean;
1140
+ __hitFill?(inner: IRadiusPointData): boolean;
1141
+ __hitStroke?(inner: IRadiusPointData, strokeWidth: number): boolean;
1142
+ __hitPixel(inner: IRadiusPointData): boolean;
1023
1143
  __drawHitPath?(canvas: ILeaferCanvas): void;
1024
1144
  __updateHitCanvas?(): void;
1025
1145
  }
@@ -1029,31 +1149,22 @@ interface ILeafRender {
1029
1149
  __render?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1030
1150
  __draw?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1031
1151
  __drawFast?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1032
- __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1152
+ __clip?(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
1153
+ __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions, ignoreFill?: boolean, ignoreStroke?: boolean): void;
1033
1154
  __updateWorldOpacity?(): void;
1034
1155
  __updateChange?(): void;
1035
1156
  }
1036
1157
 
1037
- type ILeafMaskModule = ILeafMask & ThisType<ILeaf>;
1038
- interface ILeafMask {
1039
- __updateEraser?(value?: boolean): void;
1040
- __updateMask?(value?: boolean): void;
1041
- __renderMask?(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas, recycle?: boolean): void;
1042
- __removeMask?(child?: ILeaf): void;
1043
- }
1044
-
1045
1158
  interface IDataProcessor {
1046
1159
  __leaf: ILeaf;
1047
1160
  __input: IObject;
1048
1161
  __middle: IObject;
1049
- __single: boolean;
1050
- __checkSingle(): void;
1051
1162
  __get(name: string): any;
1052
1163
  __getData(): IObject;
1053
1164
  __setInput(name: string, value: any): void;
1054
1165
  __getInput(name: string): any;
1055
1166
  __removeInput(name: string): void;
1056
- __getInputData(): IObject;
1167
+ __getInputData(names?: string[] | IObject, options?: IJSONOptions): IObject;
1057
1168
  __setMiddle(name: string, value: any): void;
1058
1169
  __getMiddle(name: string): any;
1059
1170
  destroy(): void;
@@ -1063,29 +1174,48 @@ interface ILeafDataOptions {
1063
1174
  children?: boolean;
1064
1175
  }
1065
1176
  interface ILeafData extends IDataProcessor, ILeafComputedData {
1177
+ __single?: boolean;
1178
+ __checkSingle(): void;
1179
+ __removeNaturalSize(): void;
1066
1180
  }
1067
1181
 
1068
- interface ISelectPathResult {
1069
- leaf: ILeaf;
1182
+ interface IBranch extends ILeaf {
1183
+ children: ILeaf[];
1184
+ __renderBranch?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1185
+ addMany(...children: ILeaf[]): void;
1186
+ removeAll(destroy?: boolean): void;
1187
+ clear(): void;
1188
+ }
1189
+
1190
+ interface IPickResult {
1191
+ target: ILeaf;
1070
1192
  path: ILeafList;
1071
1193
  throughPath?: ILeafList;
1072
1194
  }
1073
- interface ISelectPathOptions {
1195
+ interface IPickOptions {
1074
1196
  name?: string;
1197
+ hitRadius?: number;
1075
1198
  through?: boolean;
1199
+ target?: IBranch;
1200
+ findList?: ILeaf[];
1201
+ bottomList?: IPickBottom[];
1076
1202
  exclude?: ILeafList;
1077
1203
  ignoreHittable?: boolean;
1078
1204
  }
1205
+ interface IPickBottom {
1206
+ target: ILeaf;
1207
+ proxy?: ILeaf;
1208
+ }
1079
1209
  interface ISelectorConfig {
1080
1210
  }
1081
- declare enum AnswerType {
1082
- No = 0,
1083
- Yes = 1,
1084
- NoAndSkip = 2,
1085
- YesAndSkip = 3
1211
+ type IAnswer = 0 | 1 | 2 | 3;
1212
+ interface IFindCondition {
1213
+ id?: number | string;
1214
+ className?: string;
1215
+ tag?: string | string[];
1086
1216
  }
1087
1217
  interface IFindMethod {
1088
- (leaf: ILeaf, options?: any): AnswerType;
1218
+ (leaf: ILeaf, options?: any): IAnswer;
1089
1219
  }
1090
1220
  interface ISelectorProxy {
1091
1221
  list: ILeaf[];
@@ -1094,7 +1224,7 @@ interface ISelector {
1094
1224
  target: ILeaf;
1095
1225
  proxy?: ISelectorProxy;
1096
1226
  config: ISelectorConfig;
1097
- getByPoint(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult;
1227
+ getByPoint(hitPoint: IPointData, hitRadius: number, options?: IPickOptions): IPickResult;
1098
1228
  getBy(condition: number | string | IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[];
1099
1229
  getByInnerId(innerId: number, branch?: ILeaf): ILeaf;
1100
1230
  getById(id: string, branch?: ILeaf): ILeaf;
@@ -1110,52 +1240,124 @@ interface ICachedLeaf {
1110
1240
  bounds: IBoundsData;
1111
1241
  }
1112
1242
  interface ILeafAttrData {
1113
- id: IString;
1114
- name: IString;
1115
- className: IString;
1116
- blendMode: IBlendMode;
1117
- opacity: INumber;
1118
- visible: IBoolean;
1119
- isMask: IBoolean;
1120
- isEraser: IBoolean;
1121
- locked: IBoolean;
1122
- zIndex: INumber;
1123
- x: INumber;
1124
- y: INumber;
1125
- width: INumber;
1126
- height: INumber;
1127
- scaleX: INumber;
1128
- scaleY: INumber;
1129
- rotation: INumber;
1130
- skewX: INumber;
1131
- skewY: INumber;
1132
- scale: INumber | IPointData;
1133
- around: IAround;
1134
- draggable: IBoolean;
1135
- editable: IBoolean;
1136
- editSize?: IEditSize;
1137
- hittable: IBoolean;
1138
- hitFill: IHitType;
1139
- hitStroke: IHitType;
1140
- hitBox: IBoolean;
1141
- hitChildren: IBoolean;
1142
- hitSelf: IBoolean;
1143
- hitRadius: INumber;
1144
- cursor: ICursorType | ICursorType[];
1243
+ id?: IString;
1244
+ name?: IString;
1245
+ className?: IString;
1246
+ blendMode?: IBlendMode;
1247
+ opacity?: INumber;
1248
+ visible?: IBoolean | 0;
1249
+ selected?: IBoolean;
1250
+ disabled?: IBoolean;
1251
+ locked?: IBoolean;
1252
+ zIndex?: INumber;
1253
+ mask?: IBoolean | IMaskType;
1254
+ eraser?: IBoolean | IEraserType;
1255
+ x?: INumber;
1256
+ y?: INumber;
1257
+ width?: INumber;
1258
+ height?: INumber;
1259
+ scaleX?: INumber;
1260
+ scaleY?: INumber;
1261
+ rotation?: INumber;
1262
+ skewX?: INumber;
1263
+ skewY?: INumber;
1264
+ scale?: INumber | IPointData;
1265
+ offsetX?: INumber;
1266
+ offsetY?: INumber;
1267
+ scrollX?: INumber;
1268
+ scrollY?: INumber;
1269
+ origin?: IAlign | IUnitPointData;
1270
+ around?: IAlign | IUnitPointData;
1271
+ lazy?: IBoolean;
1272
+ pixelRatio?: INumber;
1273
+ path?: IPathCommandData | IPathString;
1274
+ windingRule?: IWindingRule;
1275
+ closed?: IBoolean;
1276
+ flow?: IFlowType;
1277
+ padding?: IFourNumber;
1278
+ gap?: IGap | IPointGap;
1279
+ flowAlign?: IFlowAlign | IFlowAxisAlign;
1280
+ flowWrap?: IFlowWrap;
1281
+ itemBox?: IFlowBoxType;
1282
+ inFlow?: IBoolean;
1283
+ autoWidth?: IAutoSize;
1284
+ autoHeight?: IAutoSize;
1285
+ lockRatio?: IBoolean;
1286
+ autoBox?: IAutoBoxData | IConstraint;
1287
+ widthRange?: IRangeSize;
1288
+ heightRange?: IRangeSize;
1289
+ draggable?: IBoolean | IAxis;
1290
+ dragBounds?: IBoundsData | 'parent';
1291
+ editable?: IBoolean;
1292
+ hittable?: IBoolean;
1293
+ hitFill?: IHitType;
1294
+ hitStroke?: IHitType;
1295
+ hitBox?: IBoolean;
1296
+ hitChildren?: IBoolean;
1297
+ hitSelf?: IBoolean;
1298
+ hitRadius?: INumber;
1299
+ cursor?: ICursorType | ICursorType[];
1300
+ event?: IEventMap;
1301
+ normalStyle?: ILeafInputData;
1302
+ hoverStyle?: ILeafInputData;
1303
+ pressStyle?: ILeafInputData;
1304
+ focusStyle?: ILeafInputData;
1305
+ selectedStyle?: ILeafInputData;
1306
+ disabledStyle?: ILeafInputData;
1307
+ data: IObject;
1308
+ }
1309
+ type IAxis = 'x' | 'y';
1310
+ type IAxisReverse = 'x-reverse' | 'y-reverse';
1311
+ type IFlowType = boolean | IAxis | IAxisReverse;
1312
+ type IFlowBoxType = 'box' | 'stroke';
1313
+ type IGap = INumber | 'auto' | 'fit';
1314
+ interface IPointGap {
1315
+ x?: IGap;
1316
+ y?: IGap;
1317
+ }
1318
+ type IAxisAlign = 'from' | 'center' | 'to';
1319
+ interface IFlowAxisAlign {
1320
+ content?: IFlowAlign;
1321
+ x?: IAxisAlign;
1322
+ y?: IAxisAlign;
1323
+ }
1324
+ type IFlowWrap = boolean | 'reverse';
1325
+ type IAutoSize = IBoolean | INumber | IPercentData;
1326
+ interface IRangeSize {
1327
+ min?: number;
1328
+ max?: number;
1329
+ }
1330
+ interface IUnitData {
1331
+ type: 'percent' | 'px';
1332
+ value: number;
1333
+ }
1334
+ interface IPercentData extends IUnitData {
1335
+ type: 'percent';
1145
1336
  }
1337
+ interface IConstraint {
1338
+ x: IConstraintType;
1339
+ y: IConstraintType;
1340
+ }
1341
+ type IConstraintType = 'from' | 'center' | 'to' | 'from-to' | 'scale';
1146
1342
  type IHitType = 'path' | 'pixel' | 'all' | 'none';
1343
+ type IMaskType = 'path' | 'pixel' | 'clipping';
1344
+ type IEraserType = 'path' | 'pixel';
1147
1345
  type IBlendMode = 'pass-through' | 'normal' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity' | 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'xor';
1148
- type IEditSize = 'size' | 'scale';
1346
+ type IEditSize = 'size' | 'font-size' | 'scale';
1149
1347
  interface IImageCursor {
1150
1348
  url: string;
1151
1349
  x?: number;
1152
1350
  y?: number;
1351
+ rotation?: number;
1153
1352
  }
1154
- type IAround = 'topLeft' | 'top' | 'topRight' | 'right' | 'bottomRight' | 'bottom' | 'bottomLeft' | 'left' | 'center' | IPointData;
1155
- type ICursorType = IImageCursor | '' | 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'grab' | 'grabbing' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'all-scroll' | 'zoom -in' | 'zoom-out';
1156
- interface ICursorTypeMap {
1157
- [name: string]: ICursorType | ICursorType[];
1158
- }
1353
+ type IDirection = 'top-left' | 'top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'left' | 'center';
1354
+ type IDirection4 = 'top' | 'right' | 'bottom' | 'left';
1355
+ type IAlign = IDirection;
1356
+ type IBaseLineAlign = 'baseline-left' | 'baseline-center' | 'baseline-right';
1357
+ type IFlowAlign = IAlign | IBaseLineAlign;
1358
+ type IAround = IAlign | IUnitPointData;
1359
+ type ICursorType = IImageCursor | '' | 'auto' | 'default' | 'none' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'grab' | 'grabbing' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'all-scroll' | 'zoom-in' | 'zoom-out';
1360
+ type IStateStyleType = 'hoverStyle' | 'pressStyle' | 'focusStyle' | 'selectedStyle' | 'disabledStyle';
1159
1361
  interface ILeafInputData {
1160
1362
  tag?: string;
1161
1363
  id?: IString;
@@ -1163,11 +1365,13 @@ interface ILeafInputData {
1163
1365
  className?: IString;
1164
1366
  blendMode?: IBlendMode;
1165
1367
  opacity?: INumber;
1166
- visible?: IBoolean;
1167
- isMask?: IBoolean;
1168
- isEraser?: IBoolean;
1368
+ visible?: IBoolean | 0;
1369
+ selected?: IBoolean;
1370
+ disabled?: IBoolean;
1169
1371
  locked?: IBoolean;
1170
1372
  zIndex?: INumber;
1373
+ mask?: IBoolean | IMaskType;
1374
+ eraser?: IBoolean | IEraserType;
1171
1375
  x?: INumber;
1172
1376
  y?: INumber;
1173
1377
  width?: INumber;
@@ -1178,10 +1382,33 @@ interface ILeafInputData {
1178
1382
  skewX?: INumber;
1179
1383
  skewY?: INumber;
1180
1384
  scale?: INumber | IPointData;
1181
- around?: IAround;
1182
- draggable?: IBoolean;
1385
+ offsetX?: INumber;
1386
+ offsetY?: INumber;
1387
+ scrollX?: INumber;
1388
+ scrollY?: INumber;
1389
+ origin?: IAlign | IUnitPointData;
1390
+ around?: IAlign | IUnitPointData;
1391
+ lazy?: IBoolean;
1392
+ pixelRatio?: INumber;
1393
+ path?: IPathCommandData | IPathString;
1394
+ windingRule?: IWindingRule;
1395
+ closed?: IBoolean;
1396
+ flow?: IFlowType;
1397
+ padding?: IFourNumber;
1398
+ gap?: IGap | IPointGap;
1399
+ flowAlign?: IFlowAlign | IFlowAxisAlign;
1400
+ flowWrap?: IFlowWrap;
1401
+ itemBox?: IFlowBoxType;
1402
+ inFlow?: IBoolean;
1403
+ autoWidth?: IAutoSize;
1404
+ autoHeight?: IAutoSize;
1405
+ lockRatio?: IBoolean;
1406
+ autoBox?: IAutoBoxData | IConstraint;
1407
+ widthRange?: IRangeSize;
1408
+ heightRange?: IRangeSize;
1409
+ draggable?: IBoolean | IAxis;
1410
+ dragBounds?: IBoundsData | 'parent';
1183
1411
  editable?: IBoolean;
1184
- editSize?: IEditSize;
1185
1412
  hittable?: IBoolean;
1186
1413
  hitFill?: IHitType;
1187
1414
  hitStroke?: IHitType;
@@ -1190,6 +1417,14 @@ interface ILeafInputData {
1190
1417
  hitSelf?: IBoolean;
1191
1418
  hitRadius?: INumber;
1192
1419
  cursor?: ICursorType | ICursorType[];
1420
+ event?: IEventMap;
1421
+ normalStyle?: ILeafInputData;
1422
+ hoverStyle?: ILeafInputData;
1423
+ pressStyle?: ILeafInputData;
1424
+ focusStyle?: ILeafInputData;
1425
+ selectedStyle?: ILeafInputData;
1426
+ disabledStyle?: ILeafInputData;
1427
+ data?: IObject;
1193
1428
  children?: ILeafInputData[];
1194
1429
  noBounds?: boolean;
1195
1430
  }
@@ -1199,11 +1434,13 @@ interface ILeafComputedData {
1199
1434
  className?: string;
1200
1435
  blendMode?: IBlendMode;
1201
1436
  opacity?: number;
1202
- visible?: boolean;
1203
- isMask?: boolean;
1204
- isEraser?: boolean;
1437
+ visible?: boolean | 0;
1438
+ selected?: boolean;
1439
+ disabled?: boolean;
1205
1440
  locked?: boolean;
1206
1441
  zIndex?: number;
1442
+ mask?: boolean | IMaskType;
1443
+ eraser?: boolean | IEraserType;
1207
1444
  x?: number;
1208
1445
  y?: number;
1209
1446
  width?: number;
@@ -1213,10 +1450,33 @@ interface ILeafComputedData {
1213
1450
  rotation?: number;
1214
1451
  skewX?: number;
1215
1452
  skewY?: number;
1216
- around?: IAround;
1217
- draggable?: boolean;
1453
+ offsetX?: number;
1454
+ offsetY?: number;
1455
+ scrollX?: number;
1456
+ scrollY?: number;
1457
+ origin?: IAlign | IUnitPointData;
1458
+ around?: IAlign | IUnitPointData;
1459
+ lazy?: boolean;
1460
+ pixelRatio?: number;
1461
+ path?: IPathCommandData;
1462
+ windingRule?: IWindingRule;
1463
+ closed?: boolean;
1464
+ flow?: IFlowType;
1465
+ padding?: IFourNumber;
1466
+ gap?: IGap | IPointGap;
1467
+ flowAlign?: IFlowAlign | IFlowAxisAlign;
1468
+ flowWrap?: IFlowWrap;
1469
+ itemBox?: IFlowBoxType;
1470
+ inFlow?: boolean;
1471
+ autoWidth?: IAutoSize;
1472
+ autoHeight?: IAutoSize;
1473
+ lockRatio?: boolean;
1474
+ autoBox?: IAutoBoxData | IConstraint;
1475
+ widthRange?: IRangeSize;
1476
+ heightRange?: IRangeSize;
1477
+ draggable?: boolean | IAxis;
1478
+ dragBounds?: IBoundsData | 'parent';
1218
1479
  editable?: boolean;
1219
- editSize?: IEditSize;
1220
1480
  hittable?: boolean;
1221
1481
  hitFill?: IHitType;
1222
1482
  hitStroke?: IHitType;
@@ -1225,12 +1485,31 @@ interface ILeafComputedData {
1225
1485
  hitSelf?: boolean;
1226
1486
  hitRadius?: number;
1227
1487
  cursor?: ICursorType | ICursorType[];
1488
+ normalStyle?: ILeafInputData;
1489
+ hoverStyle?: ILeafInputData;
1490
+ pressStyle?: ILeafInputData;
1491
+ focusStyle?: ILeafInputData;
1492
+ selectedStyle?: ILeafInputData;
1493
+ disabledStyle?: ILeafInputData;
1494
+ data?: IObject;
1228
1495
  __childBranchNumber?: number;
1229
1496
  __complex?: boolean;
1230
1497
  __naturalWidth?: number;
1231
1498
  __naturalHeight?: number;
1232
- }
1233
- interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
1499
+ readonly __autoWidth?: boolean;
1500
+ readonly __autoHeight?: boolean;
1501
+ readonly __autoSide?: boolean;
1502
+ readonly __autoSize?: boolean;
1503
+ readonly __useNaturalRatio: boolean;
1504
+ readonly __isLinePath: boolean;
1505
+ readonly __blendMode: string;
1506
+ __useArrow?: boolean;
1507
+ __useEffect?: boolean;
1508
+ __pathInputed?: number;
1509
+ __pathForRender?: IPathCommandData;
1510
+ __path2DForRender?: IPath2D;
1511
+ }
1512
+ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
1234
1513
  tag: string;
1235
1514
  readonly __tag: string;
1236
1515
  readonly innerName: string;
@@ -1239,22 +1518,28 @@ interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatr
1239
1518
  readonly app?: ILeaferBase;
1240
1519
  leafer?: ILeaferBase;
1241
1520
  parent?: ILeaf;
1521
+ zoomLayer?: ILeaf;
1242
1522
  readonly isApp?: boolean;
1243
- isLeafer?: boolean;
1244
- isBranch?: boolean;
1245
- isBranchLeaf?: boolean;
1523
+ readonly isLeafer?: boolean;
1524
+ readonly isBranch?: boolean;
1525
+ readonly isBranchLeaf?: boolean;
1526
+ readonly isOutside?: boolean;
1246
1527
  __: ILeafData;
1247
1528
  proxyData?: ILeafInputData;
1248
1529
  __proxyData?: ILeafInputData;
1530
+ syncEventer?: ILeaf;
1249
1531
  __layout: ILeafLayout;
1250
- __world: IMatrixWithLayoutData;
1532
+ __world: IMatrixWithBoundsScaleData;
1251
1533
  __local?: IMatrixWithBoundsData;
1534
+ __nowWorld?: IMatrixWithBoundsScaleData;
1535
+ __cameraWorld?: IMatrixWithBoundsScaleData;
1252
1536
  readonly __localMatrix: IMatrixData;
1253
- readonly __localBounds: IBoundsData;
1537
+ readonly __localBoxBounds: IBoundsData;
1254
1538
  __worldOpacity: number;
1255
- readonly worldTransform: IMatrixWithLayoutData;
1256
- readonly localTransform: IMatrixWithBoundsData;
1539
+ readonly worldTransform: IMatrixWithScaleData;
1540
+ readonly localTransform: IMatrixData;
1257
1541
  readonly boxBounds: IBoundsData;
1542
+ readonly renderBounds: IBoundsData;
1258
1543
  readonly worldBoxBounds: IBoundsData;
1259
1544
  readonly worldStrokeBounds: IBoundsData;
1260
1545
  readonly worldRenderBounds: IBoundsData;
@@ -1266,29 +1551,46 @@ interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatr
1266
1551
  __hasMask?: boolean;
1267
1552
  __hasEraser?: boolean;
1268
1553
  __hitCanvas?: IHitCanvas;
1554
+ __flowBounds?: IBoundsData;
1555
+ __widthGrow?: number;
1556
+ __heightGrow?: number;
1557
+ __hasGrow?: boolean;
1269
1558
  readonly __onlyHitMask: boolean;
1270
1559
  readonly __ignoreHitWorld: boolean;
1560
+ readonly __inLazyBounds: boolean;
1561
+ readonly pathInputed: boolean;
1271
1562
  __parentWait?: IFunction[];
1272
1563
  __leaferWait?: IFunction[];
1273
1564
  destroyed: boolean;
1274
1565
  reset(data?: ILeafInputData): void;
1275
1566
  resetCustom(): void;
1276
- waitParent(item: IFunction): void;
1277
- waitLeafer(item: IFunction): void;
1278
- nextRender(item: IFunction): void;
1567
+ waitParent(item: IFunction, bind?: IObject): void;
1568
+ waitLeafer(item: IFunction, bind?: IObject): void;
1569
+ nextRender(item: IFunction, bind?: IObject, off?: 'off'): void;
1570
+ removeNextRender(item: IFunction): void;
1279
1571
  __bindLeafer(leafer: ILeaferBase | null): void;
1280
1572
  set(data: IObject): void;
1281
- get(): ILeafInputData;
1282
- toJSON(): IObject;
1283
- toString(): string;
1284
- __setAttr(attrName: string, newValue: IValue): void;
1573
+ get(name?: string | string[] | IObject): ILeafInputData | IValue;
1574
+ setAttr(name: string, value: any): void;
1575
+ getAttr(name: string): any;
1576
+ getComputedAttr(name: string): any;
1577
+ toJSON(options?: IJSONOptions): IObject;
1578
+ toString(options?: IJSONOptions): string;
1579
+ toSVG(): string;
1580
+ __SVG(data: IObject): void;
1581
+ toHTML(): string;
1582
+ __setAttr(attrName: string, newValue: IValue, checkFiniteNumber?: boolean): boolean;
1285
1583
  __getAttr(attrName: string): IValue;
1286
1584
  setProxyAttr(name: string, newValue: IValue): void;
1287
1585
  getProxyAttr(name: string): IValue;
1288
1586
  find(condition: number | string | IFindMethod, options?: any): ILeaf[];
1289
- findOne(condition: number | string | IFindMethod, options?: any): ILeaf;
1290
- forceUpdate(attrName?: string): void;
1587
+ findTag(tag: string | string[]): ILeaf[];
1588
+ findOne(condition: number | string | IFindMethod, options?: any): ILeaf | undefined;
1589
+ findId(id: number | string): ILeaf | undefined;
1590
+ focus(value?: boolean): void;
1291
1591
  updateLayout(): void;
1592
+ forceUpdate(attrName?: string): void;
1593
+ forceRender(_bounds?: IBoundsData): void;
1292
1594
  __updateWorldMatrix(): void;
1293
1595
  __updateLocalMatrix(): void;
1294
1596
  __updateWorldBounds(): void;
@@ -1296,21 +1598,26 @@ interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatr
1296
1598
  __updateLocalBoxBounds(): void;
1297
1599
  __updateLocalStrokeBounds(): void;
1298
1600
  __updateLocalRenderBounds(): void;
1601
+ __updateContentBounds(): void;
1299
1602
  __updateBoxBounds(): void;
1300
1603
  __updateStrokeBounds(): void;
1301
1604
  __updateRenderBounds(): void;
1302
1605
  __updateAutoLayout(): void;
1606
+ __updateFlowLayout(): void;
1303
1607
  __updateNaturalSize(): void;
1304
1608
  __updateStrokeSpread(): number;
1305
1609
  __updateRenderSpread(): number;
1306
1610
  __onUpdateSize(): void;
1307
1611
  __updateEraser(value?: boolean): void;
1308
1612
  __updateMask(value?: boolean): void;
1309
- __renderMask(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas, recycle?: boolean): void;
1310
- __removeMask(child?: ILeaf): void;
1311
- getWorld(attrName: ILayoutAttr): number;
1613
+ __renderMask(canvas: ILeaferCanvas, options: IRenderOptions): void;
1614
+ __renderEraser(canvas: ILeaferCanvas, options: IRenderOptions): void;
1615
+ __getNowWorld(options: IRenderOptions): IMatrixWithBoundsScaleData;
1616
+ getTransform(relative?: ILocationType | ILeaf): IMatrixData;
1312
1617
  getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
1313
1618
  getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
1619
+ getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[];
1620
+ getWorldBounds(inner: IBoundsData, relative?: ILeaf, change?: boolean): IBoundsData;
1314
1621
  worldToLocal(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
1315
1622
  localToWorld(local: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
1316
1623
  worldToInner(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
@@ -1321,22 +1628,36 @@ interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatr
1321
1628
  getLocalPointByInner(inner: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1322
1629
  getWorldPoint(inner: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1323
1630
  getWorldPointByLocal(local: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1631
+ getPagePoint(world: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1632
+ getWorldPointByPage(page: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1324
1633
  setTransform(transform?: IMatrixData, resize?: boolean): void;
1325
1634
  transform(transform?: IMatrixData, resize?: boolean): void;
1326
- move(x: number, y?: number): void;
1327
- scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
1328
- rotateOf(origin: IPointData, rotation: number): void;
1329
- skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
1635
+ move(x: number | IPointData, y?: number): void;
1636
+ scaleOf(origin: IPointData | IAlign, scaleX: number, scaleY?: number, resize?: boolean): void;
1637
+ rotateOf(origin: IPointData | IAlign, rotation: number): void;
1638
+ skewOf(origin: IPointData | IAlign, skewX: number, skewY?: number, resize?: boolean): void;
1639
+ transformWorld(worldTransform?: IMatrixData, resize?: boolean): void;
1640
+ moveWorld(x: number | IPointData, y?: number): void;
1641
+ scaleOfWorld(worldOrigin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
1642
+ rotateOfWorld(worldOrigin: IPointData, rotation: number): void;
1643
+ skewOfWorld(worldOrigin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
1644
+ flip(axis: IAxis): void;
1330
1645
  scaleResize(scaleX: number, scaleY: number, noResize?: boolean): void;
1331
1646
  __scaleResize(scaleX: number, scaleY: number): void;
1647
+ resizeWidth(width: number): void;
1648
+ resizeHeight(height: number): void;
1332
1649
  __hitWorld(point: IRadiusPointData): boolean;
1333
1650
  __hit(local: IRadiusPointData): boolean;
1651
+ __hitFill(inner: IRadiusPointData): boolean;
1652
+ __hitStroke(inner: IRadiusPointData, strokeWidth: number): boolean;
1653
+ __hitPixel(inner: IRadiusPointData): boolean;
1334
1654
  __drawHitPath(canvas: ILeaferCanvas): void;
1335
1655
  __updateHitCanvas(): void;
1336
1656
  __render(canvas: ILeaferCanvas, options: IRenderOptions): void;
1337
1657
  __drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void;
1338
1658
  __draw(canvas: ILeaferCanvas, options: IRenderOptions): void;
1339
- __renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void;
1659
+ __clip(canvas: ILeaferCanvas, options: IRenderOptions): void;
1660
+ __renderShape(canvas: ILeaferCanvas, options: IRenderOptions, ignoreFill?: boolean, ignoreStroke?: boolean): void;
1340
1661
  __updateWorldOpacity(): void;
1341
1662
  __updateChange(): void;
1342
1663
  __drawPath(canvas: ILeaferCanvas): void;
@@ -1349,9 +1670,10 @@ interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatr
1349
1670
  remove(child?: ILeaf, destroy?: boolean): void;
1350
1671
  dropTo(parent: ILeaf, index?: number, resize?: boolean): void;
1351
1672
  }
1352
-
1353
- type IExportImageType = 'jpg' | 'png' | 'webp';
1354
- type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json';
1673
+ type ILeafAttrDescriptor = IObject & ThisType<ILeaf>;
1674
+ interface ILeafAttrDescriptorFn {
1675
+ (key: string): ILeafAttrDescriptor;
1676
+ }
1355
1677
 
1356
1678
  interface ILeaferImageConfig {
1357
1679
  url: string;
@@ -1364,6 +1686,13 @@ interface ILeaferImageOnLoaded {
1364
1686
  interface ILeaferImageOnError {
1365
1687
  (error?: string | IObject, image?: ILeaferImage): any;
1366
1688
  }
1689
+ interface ILeaferImageCacheCanvas {
1690
+ data: IObject;
1691
+ params: IArguments;
1692
+ }
1693
+ interface ILeaferImagePatternPaint {
1694
+ transform: IMatrixData;
1695
+ }
1367
1696
  interface ILeaferImage {
1368
1697
  readonly innerId: InnerId;
1369
1698
  readonly url: string;
@@ -1371,6 +1700,7 @@ interface ILeaferImage {
1371
1700
  width: number;
1372
1701
  height: number;
1373
1702
  isSVG: boolean;
1703
+ hasOpacityPixel: boolean;
1374
1704
  readonly completed: boolean;
1375
1705
  ready: boolean;
1376
1706
  error: IObject;
@@ -1380,6 +1710,7 @@ interface ILeaferImage {
1380
1710
  load(onSuccess?: ILeaferImageOnLoaded, onError?: ILeaferImageOnError): number;
1381
1711
  unload(index: number, stopEvent?: boolean): void;
1382
1712
  getCanvas(width: number, height: number, opacity?: number, _filters?: IObject): unknown;
1713
+ getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: IObject): ICanvasPattern;
1383
1714
  destroy(): void;
1384
1715
  }
1385
1716
 
@@ -1397,6 +1728,7 @@ interface IUIEvent extends IEvent {
1397
1728
  buttons?: number;
1398
1729
  path?: ILeafList;
1399
1730
  throughPath?: ILeafList;
1731
+ getPage?(): IPointData;
1400
1732
  getInner?(relative?: ILeaf): IPointData;
1401
1733
  getLocal?(relative?: ILeaf): IPointData;
1402
1734
  }
@@ -1404,11 +1736,13 @@ interface IPointerEvent extends IUIEvent {
1404
1736
  width?: number;
1405
1737
  height?: number;
1406
1738
  pointerType?: PointerType;
1739
+ multiTouch?: boolean;
1407
1740
  pressure?: number;
1408
1741
  tangentialPressure?: number;
1409
1742
  tiltX?: number;
1410
1743
  tiltY?: number;
1411
1744
  twist?: number;
1745
+ isCancel?: boolean;
1412
1746
  }
1413
1747
  type PointerType = 'mouse' | 'pen' | 'touch';
1414
1748
  interface IDragEvent extends IPointerEvent {
@@ -1416,10 +1750,13 @@ interface IDragEvent extends IPointerEvent {
1416
1750
  moveY: number;
1417
1751
  totalX?: number;
1418
1752
  totalY?: number;
1753
+ getPageMove?(total?: boolean): IPointData;
1419
1754
  getInnerMove?(relative?: ILeaf): IPointData;
1420
1755
  getLocalMove?(relative?: ILeaf): IPointData;
1756
+ getPageTotal?(): IPointData;
1421
1757
  getInnerTotal?(relative?: ILeaf): IPointData;
1422
1758
  getLocalTotal?(relative?: ILeaf): IPointData;
1759
+ getPageBounds?(): IBoundsData;
1423
1760
  }
1424
1761
  interface IDropEvent extends IPointerEvent {
1425
1762
  list: ILeafList;
@@ -1432,6 +1769,7 @@ interface IZoomEvent extends IUIEvent {
1432
1769
  scale: number;
1433
1770
  }
1434
1771
  interface IMoveEvent extends IDragEvent {
1772
+ moveType?: 'drag' | 'move';
1435
1773
  }
1436
1774
  interface ISwipeEvent extends IDragEvent {
1437
1775
  }
@@ -1452,15 +1790,23 @@ interface IInteraction extends IControl {
1452
1790
  selector: ISelector;
1453
1791
  running: boolean;
1454
1792
  readonly dragging: boolean;
1455
- readonly isDragEmpty: boolean;
1793
+ readonly transforming: boolean;
1456
1794
  readonly moveMode: boolean;
1795
+ readonly canHover: boolean;
1796
+ readonly isDragEmpty: boolean;
1797
+ readonly isMobileDragEmpty: boolean;
1798
+ readonly isHoldMiddleKey: boolean;
1799
+ readonly isHoldRightKey: boolean;
1800
+ readonly isHoldSpaceKey: boolean;
1457
1801
  config: IInteractionConfig;
1458
1802
  cursor: ICursorType | ICursorType[];
1459
1803
  readonly hitRadius: number;
1804
+ bottomList?: IPickBottom[];
1460
1805
  shrinkCanvasBounds: IBounds;
1461
1806
  downData: IPointerEvent;
1462
1807
  hoverData: IPointerEvent;
1463
1808
  downTime: number;
1809
+ focusData: ILeaf;
1464
1810
  receive(event: any): void;
1465
1811
  pointerDown(data?: IPointerEvent, defaultPath?: boolean): void;
1466
1812
  pointerMove(data?: IPointerEvent): void;
@@ -1473,11 +1819,20 @@ interface IInteraction extends IControl {
1473
1819
  rotate(data: IRotateEvent): void;
1474
1820
  keyDown(data: IKeyEvent): void;
1475
1821
  keyUp(data: IKeyEvent): void;
1476
- findPath(data: IPointerEvent, options?: ISelectPathOptions): ILeafList;
1822
+ findPath(data: IPointerEvent, options?: IPickOptions): ILeafList;
1823
+ isRootPath(data: IPointerEvent): boolean;
1824
+ isTreePath(data: IPointerEvent): boolean;
1825
+ canMove(data: IPointerEvent): boolean;
1477
1826
  isDrag(leaf: ILeaf): boolean;
1478
- updateDownData(data?: IPointerEvent): void;
1827
+ isPress(leaf: ILeaf): boolean;
1828
+ isHover(leaf: ILeaf): boolean;
1829
+ isFocus(leaf: ILeaf): boolean;
1830
+ cancelHover(): void;
1831
+ updateDownData(data?: IPointerEvent, options?: IPickOptions, merge?: boolean): void;
1479
1832
  updateHoverData(data: IPointerEvent): void;
1480
1833
  updateCursor(hoverData?: IPointerEvent): void;
1834
+ setCursor(cursor: ICursorType | ICursorType[]): void;
1835
+ getLocal(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
1481
1836
  emit(type: string, data: IUIEvent, path?: ILeafList, excludePath?: ILeafList): void;
1482
1837
  }
1483
1838
  interface IInteractionCanvas extends ILeaferCanvas {
@@ -1485,23 +1840,31 @@ interface IInteractionCanvas extends ILeaferCanvas {
1485
1840
  interface IInteractionConfig {
1486
1841
  wheel?: IWheelConfig;
1487
1842
  pointer?: IPointerConfig;
1488
- cursor?: ICursorConfig;
1489
1843
  zoom?: IZoomConfig;
1490
1844
  move?: IMoveConfig;
1491
1845
  eventer?: IObject;
1846
+ cursor?: boolean;
1847
+ keyEvent?: boolean;
1492
1848
  }
1493
1849
  interface IZoomConfig {
1850
+ disabled?: boolean;
1494
1851
  min?: number;
1495
1852
  max?: number;
1496
1853
  }
1497
1854
  interface IMoveConfig {
1855
+ disabled?: boolean;
1498
1856
  holdSpaceKey?: boolean;
1857
+ holdMiddleKey?: boolean;
1858
+ holdRightKey?: boolean;
1859
+ scroll?: boolean | 'limit';
1499
1860
  drag?: boolean;
1861
+ dragAnimate?: boolean;
1500
1862
  dragEmpty?: boolean;
1501
1863
  dragOut?: boolean;
1502
1864
  autoDistance?: number;
1503
1865
  }
1504
1866
  interface IWheelConfig {
1867
+ disabled?: boolean;
1505
1868
  zoomMode?: boolean | 'mouse';
1506
1869
  zoomSpeed?: number;
1507
1870
  moveSpeed?: number;
@@ -1518,38 +1881,32 @@ interface IPointerConfig {
1518
1881
  tapTime?: number;
1519
1882
  longPressTime?: number;
1520
1883
  transformTime?: number;
1884
+ hover?: boolean;
1885
+ touch?: boolean;
1521
1886
  dragHover?: boolean;
1522
1887
  dragDistance?: number;
1523
1888
  swipeDistance?: number;
1524
1889
  ignoreMove?: boolean;
1525
1890
  preventDefault?: boolean;
1526
- }
1527
- interface ICursorConfig {
1528
- stop?: boolean;
1891
+ preventDefaultMenu?: boolean;
1529
1892
  }
1530
1893
 
1531
1894
  interface IHitCanvasManager extends ICanvasManager {
1895
+ maxTotal: number;
1532
1896
  getPathType(leaf: ILeaf): IHitCanvas;
1533
- getImageType(leaf: ILeaf, size: IScreenSizeData): IHitCanvas;
1534
- }
1535
-
1536
- interface IBranch extends ILeaf {
1537
- children: ILeaf[];
1538
- __renderBranch?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1539
- addMany(...children: ILeaf[]): void;
1540
- removeAll(destroy?: boolean): void;
1897
+ getPixelType(leaf: ILeaf, config?: ILeaferCanvasConfig): IHitCanvas;
1541
1898
  }
1542
1899
 
1543
1900
  interface IZoomView extends IBranch {
1544
- zoomLayer?: ILeaf;
1545
- setZoomLayer(zoomLayer: ILeaf): void;
1546
1901
  }
1547
1902
 
1548
- type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'user';
1903
+ type ILeaferType = 'draw' | 'editor' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart' | 'custom';
1549
1904
  interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
1550
1905
  start?: boolean;
1551
1906
  type?: ILeaferType;
1907
+ mobile?: boolean;
1552
1908
  realCanvas?: boolean;
1909
+ lazySpeard?: IFourNumber;
1553
1910
  }
1554
1911
  interface ILeaferAttrData {
1555
1912
  running: boolean;
@@ -1559,7 +1916,7 @@ interface ILeaferAttrData {
1559
1916
  imageReady: boolean;
1560
1917
  viewCompleted: boolean;
1561
1918
  layoutLocked: boolean;
1562
- pixelRatio: number;
1919
+ transforming: boolean;
1563
1920
  view: unknown;
1564
1921
  canvas: ILeaferCanvas;
1565
1922
  renderer: IRenderer;
@@ -1570,8 +1927,10 @@ interface ILeaferAttrData {
1570
1927
  canvasManager: ICanvasManager;
1571
1928
  hitCanvasManager?: IHitCanvasManager;
1572
1929
  autoLayout?: IAutoBounds;
1930
+ lazyBounds: IBounds;
1573
1931
  config: ILeaferConfig;
1574
1932
  readonly cursorPoint: IPointData;
1933
+ readonly clientBounds: IBoundsData;
1575
1934
  leafs: number;
1576
1935
  __eventIds: IEventListenerId[];
1577
1936
  __nextRenderWait: IFunction[];
@@ -1580,14 +1939,17 @@ interface ILeaferAttrData {
1580
1939
  stop(): void;
1581
1940
  unlockLayout(): void;
1582
1941
  lockLayout(): void;
1583
- setZoomLayer(zoomLayer: ILeaf): void;
1584
- forceFullRender(): void;
1585
- updateCursor(): void;
1942
+ updateCursor(cursor?: ICursorType): void;
1586
1943
  resize(size: IScreenSizeData): void;
1587
- waitReady(item: IFunction): void;
1588
- waitViewReady(item: IFunction): void;
1589
- waitViewCompleted(item: IFunction): void;
1590
- }
1944
+ waitReady(item: IFunction, bind?: IObject): void;
1945
+ waitViewReady(item: IFunction, bind?: IObject): void;
1946
+ waitViewCompleted(item: IFunction, bind?: IObject): void;
1947
+ zoom(zoomType: IZoomType, padding?: IFourNumber, fixedScale?: boolean): IBoundsData;
1948
+ getValidMove(moveX: number, moveY: number): IPointData;
1949
+ getValidScale(changeScale: number): number;
1950
+ getWorldPointByClient(clientPoint: IClientPointData, updateClient?: boolean): IPointData;
1951
+ }
1952
+ type IZoomType = 'in' | 'out' | 'fit' | 'fit-width' | 'fit-height' | number | ILeaf | ILeaf[] | IBoundsData;
1591
1953
  interface ILeaferBase extends IZoomView, IControl, ILeaferAttrData {
1592
1954
  readonly isApp: boolean;
1593
1955
  readonly app: ILeaferBase;
@@ -1608,6 +1970,7 @@ interface ICreator {
1608
1970
  image?(options?: ILeaferImageConfig): ILeaferImage;
1609
1971
  canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas;
1610
1972
  hitCanvas?(options?: IHitCanvasConfig, manager?: ICanvasManager): IHitCanvas;
1973
+ hitCanvasManager?(): IHitCanvasManager;
1611
1974
  watcher?(target: ILeaf, options?: IWatcherConfig): IWatcher;
1612
1975
  layouter?(target: ILeaf, options?: ILayouterConfig): ILayouter;
1613
1976
  renderer?(target: ILeaf, canvas: ILeaferCanvas, options?: IRendererConfig): IRenderer;
@@ -1678,11 +2041,12 @@ interface IImageManager {
1678
2041
  recycledList: ILeaferImage[];
1679
2042
  tasker: ITaskProcessor;
1680
2043
  patternTasker: ITaskProcessor;
2044
+ patternLocked?: boolean;
1681
2045
  readonly isComplete: boolean;
1682
2046
  get(config: ILeaferImageConfig): ILeaferImage;
1683
2047
  recycle(image: ILeaferImage): void;
1684
2048
  clearRecycled(): void;
1685
- isPixel(config: ILeaferImageConfig): boolean;
2049
+ hasOpacityPixel(config: ILeaferImageConfig): boolean;
1686
2050
  isFormat(format: IExportFileType, config: ILeaferImageConfig): boolean;
1687
2051
  destroy(): void;
1688
2052
  }
@@ -1719,12 +2083,13 @@ interface ISkiaNAPICanvas {
1719
2083
  interface IPlatform {
1720
2084
  name?: 'web' | 'node' | 'miniapp';
1721
2085
  os?: 'Mac' | 'Windows' | 'Linux';
2086
+ toURL(text: string, fileType?: 'text' | 'svg'): string;
1722
2087
  requestRender?(render: IFunction): void;
1723
2088
  canvas?: ILeaferCanvas;
1724
2089
  canvasType?: ICanvasType;
1725
2090
  isWorker?: boolean;
1726
2091
  isMobile?: boolean;
1727
- devicePixelRatio?: number;
2092
+ readonly devicePixelRatio?: number;
1728
2093
  intWheelDeltaY?: boolean;
1729
2094
  conicGradientSupport?: boolean;
1730
2095
  conicGradientRotate90?: boolean;
@@ -1736,6 +2101,7 @@ interface IPlatform {
1736
2101
  canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string | Promise<string>;
1737
2102
  canvasToBolb(canvas: any, type?: IExportFileType, quality?: number): Promise<any>;
1738
2103
  canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>;
2104
+ download(url: string, filename: string): Promise<void>;
1739
2105
  loadImage(url: string): Promise<any>;
1740
2106
  noRepeat?: string;
1741
2107
  };
@@ -1748,9 +2114,13 @@ interface IPlatform {
1748
2114
  };
1749
2115
  miniapp?: IMiniapp;
1750
2116
  image: {
2117
+ hitCanvasSize: number;
1751
2118
  maxCacheSize: number;
1752
2119
  maxPatternSize: number;
1753
- suffix: string;
2120
+ prefix?: string;
2121
+ suffix?: string;
2122
+ crossOrigin: string | false;
2123
+ getRealURL: IStringFunction;
1754
2124
  };
1755
2125
  }
1756
2126
  interface IMiniappSelect extends IObject {
@@ -1775,4 +2145,15 @@ interface IPlugin extends IObject {
1775
2145
  onLeafer?(leafer: ILeaferBase): void;
1776
2146
  }
1777
2147
 
1778
- export { type ACommandData, AnswerType, type ArcCommandData, type ArcToCommandData, type CCommandData, type CanvasPathCommand, type EllipseCommandData, type HCommandData, type IAnimateEvent, type IAppBase, type IAround, type IAttrDecorator, type IAutoBounds, type IAutoBoundsData, type IBlendMode, type IBlob, type IBlobFunction, type IBoolean, type IBooleanMap, type IBounds, type IBoundsData, type IBoundsDataFn, type IBoundsType, type IBranch, type IBranchRender, type IBranchRenderModule, type ICachedLeaf, type ICanvasAttr, type ICanvasContext2D, type ICanvasManager, type ICanvasStrokeOptions, type ICanvasType, type IChildEvent, type IControl, type ICreator, type ICursorType, type ICursorTypeMap, type IDataProcessor, type IDataTypeHandle, type IDragEvent, type IDropEvent, type IEditSize, type IEvent, type IEventListener, type IEventListenerId, type IEventListenerItem, type IEventListenerMap, type IEventListenerOptions, type IEventTarget, type IEventer, type IExportFileType, type IExportImageType, type IFindMethod, type IFunction, type IHitCanvas, type IHitCanvasConfig, type IHitCanvasManager, type IHitType, type IImageEvent, type IImageManager, type IInteraction, type IInteractionCanvas, type IInteractionConfig, type IKeepTouchData, type IKeyEvent, type ILayoutAttr, type ILayoutBlockData, type ILayoutBoundsData, type ILayoutChangedData, type ILayoutData, type ILayoutEvent, type ILayouter, type ILayouterConfig, type ILeaf, type ILeafArrayMap, type ILeafAttrData, type ILeafBounds, type ILeafBoundsModule, type ILeafComputedData, type ILeafData, type ILeafDataOptions, type ILeafDataProxy, type ILeafDataProxyModule, type ILeafEventer, type ILeafEventerModule, type ILeafHit, type ILeafHitModule, type ILeafInputData, type ILeafLayout, type ILeafLevelList, type ILeafList, type ILeafListItemCallback, type ILeafMap, type ILeafMask, type ILeafMaskModule, type ILeafMatrix, type ILeafMatrixModule, type ILeafRender, type ILeafRenderModule, type ILeaferAttrData, type ILeaferBase, type ILeaferCanvas, type ILeaferCanvasConfig, type ILeaferConfig, type ILeaferEvent, type ILeaferImage, type ILeaferImageConfig, type ILeaferImageOnError, type ILeaferImageOnLoaded, type ILeaferType, type ILeaferTypeCreator, type ILeaferTypeFunction, type ILeaferTypeList, type ILocationType, type IMatrix, type IMatrixData, type IMatrixWithBoundsData, type IMatrixWithLayoutData, type IMatrixWithScaleData, type IMiniapp, type IMiniappSelect, type IMiniappSizeView, type IMoveEvent, type IMultiTouchData, type INumber, type INumberMap, type IObject, type IOffsetBoundsData, type IPartLayoutConfig, type IPath2D, type IPathCommandData, type IPathCreator, type IPathDrawer, type IPathString, type IPlatform, type IPlugin, type IPoint, type IPointData, type IPointerConfig, type IPointerEvent, type IPropertyEvent, type IRadiusPointData, type IRenderEvent, type IRenderOptions, type IRenderer, type IRendererConfig, type IResizeEvent, type IResizeEventListener, type IRotateEvent, type IScaleData, type IScaleRotationData, type IScreenSizeData, type ISelectPathOptions, type ISelectPathResult, type ISelector, type ISelectorConfig, type ISelectorProxy, type ISize, type ISizeData, type ISkewData, type ISkiaCanvas, type ISkiaCanvasExportConfig, type ISkiaNAPICanvas, type IString, type IStringMap, type ISwipeEvent, type ITaskItem, type ITaskOptions, type ITaskProcessor, type ITaskProcessorConfig, type ITextMetrics, type ITimer, type ITwoPointBoundsData, type IUICreator, type IUIEvent, type IUpdateEvent, type IValue, type IWatchEvent, type IWatchEventData, type IWatcher, type IWatcherConfig, type IWheelConfig, type IWindingRule, type IZoomEvent, type IZoomView, type InnerId, type LCommandData, type MCommandData, type PointerType, type QCommandData, type RectCommandData, type RoundRectCommandData, type SCommandData, type TCommandData, type VCommandData, type ZCommandData };
2148
+ interface ICursorTypeMap {
2149
+ [name: string]: ICursorType | ICursorType[];
2150
+ }
2151
+ interface ICursorRotate {
2152
+ rotation?: number;
2153
+ data?: string;
2154
+ }
2155
+ interface ICursorRotateMap {
2156
+ [name: string]: ICursorRotate;
2157
+ }
2158
+
2159
+ 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, 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 };