@leafer/interface 1.0.0-rc.2 → 1.0.0-rc.21

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.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/app/IApp.ts +3 -3
  3. package/src/app/ILeafer.ts +44 -20
  4. package/src/canvas/ICanvas.ts +7 -2
  5. package/src/canvas/IHitCanvasManager.ts +3 -3
  6. package/src/canvas/ILeaferCanvas.ts +19 -11
  7. package/src/canvas/ISkiaCanvas.ts +20 -1
  8. package/src/data/IData.ts +6 -5
  9. package/src/data/ILeafData.ts +11 -6
  10. package/src/data/IList.ts +9 -6
  11. package/src/display/IBranch.ts +2 -1
  12. package/src/display/ILeaf.ts +266 -93
  13. package/src/display/IView.ts +2 -6
  14. package/src/display/module/IBranchRender.ts +2 -2
  15. package/src/display/module/ILeafBounds.ts +2 -0
  16. package/src/display/module/ILeafDataProxy.ts +5 -3
  17. package/src/display/module/ILeafHit.ts +4 -1
  18. package/src/display/module/ILeafRender.ts +2 -1
  19. package/src/event/IEvent.ts +3 -23
  20. package/src/event/IEventer.ts +6 -1
  21. package/src/event/IUIEvent.ts +11 -8
  22. package/src/file/IExport.ts +34 -0
  23. package/src/file/IFileType.ts +1 -1
  24. package/src/function/IFunction.ts +9 -0
  25. package/src/image/IImageManager.ts +4 -0
  26. package/src/image/ILeaferImage.ts +13 -0
  27. package/src/index.ts +16 -15
  28. package/src/interaction/ICursor.ts +16 -0
  29. package/src/interaction/IInteraction.ts +33 -4
  30. package/src/layout/ILeafLayout.ts +30 -14
  31. package/src/layouter/ILayouter.ts +3 -0
  32. package/src/math/IMath.ts +72 -35
  33. package/src/path/IPathDrawer.ts +6 -3
  34. package/src/platform/IPlatform.ts +17 -2
  35. package/src/plugin/IPlugin.ts +2 -2
  36. package/src/renderer/IRenderer.ts +4 -2
  37. package/src/selector/ISelector.ts +26 -9
  38. package/types/index.d.ts +619 -325
  39. package/src/display/module/ILeafMask.ts +0 -12
package/types/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { IFunction as IFunction$1, IObject as IObject$1, IEvent as IEvent$1, ILeaferCanvas as ILeaferCanvas$1, IScreenSizeData as IScreenSizeData$1 } from '@leafer/interface';
1
+ import { ILeaferCanvas as ILeaferCanvas$1, IScreenSizeData as IScreenSizeData$1 } from '@leafer/interface';
2
2
 
3
- type __Number = number;
4
- type __Boolean = boolean;
5
- type __String = string;
6
- type __Object = IObject;
7
- type __Value = __Number | __Boolean | __String | __Object;
3
+ type INumber = number;
4
+ type IBoolean = boolean;
5
+ type IString = string;
6
+ type IValue = INumber | IBoolean | IString | IObject;
8
7
  type ITimer = any;
9
8
  type IPathString = string;
9
+ type IFourNumber = number | number[];
10
10
  interface IObject {
11
11
  [name: string]: any;
12
12
  }
@@ -37,13 +37,14 @@ interface ILeafList {
37
37
  has(leaf: ILeaf): boolean;
38
38
  indexAt(index: number): ILeaf;
39
39
  indexOf(leaf: ILeaf): number;
40
- unshift(leaf: ILeaf): void;
41
- pushList(list: ILeaf[]): void;
42
- push(leaf: ILeaf): void;
43
- sort(reverse?: boolean): void;
40
+ add(leaf: ILeaf): void;
41
+ addAt(leaf: ILeaf, index: number): void;
42
+ addList(list: ILeaf[]): void;
44
43
  remove(leaf: ILeaf): void;
45
44
  forEach(itemCallback: ILeafListItemCallback): void;
45
+ sort(reverse?: boolean): void;
46
46
  clone(): ILeafList;
47
+ update(): void;
47
48
  reset(): void;
48
49
  destroy(): void;
49
50
  }
@@ -55,8 +56,8 @@ interface ILeafLevelList {
55
56
  has(leaf: ILeaf): boolean;
56
57
  without(leaf: ILeaf): boolean;
57
58
  sort(reverse?: boolean): void;
58
- pushList(list: ILeaf[]): void;
59
- push(leaf: ILeaf): void;
59
+ addList(list: ILeaf[]): void;
60
+ add(leaf: ILeaf): void;
60
61
  forEach(itemCallback: ILeafListItemCallback): void;
61
62
  reset(): void;
62
63
  destroy(): void;
@@ -94,17 +95,23 @@ interface IPointData {
94
95
  y: number;
95
96
  }
96
97
  interface IPoint extends IPointData {
97
- set(x?: number, y?: number): void;
98
- copy(point: IPointData): IPoint;
98
+ set(x?: number | IPointData, y?: number): IPoint;
99
+ get(): IPointData;
99
100
  clone(): IPoint;
100
- rotate(angle: number, center?: IPointData): IPoint;
101
+ move(x: number, y: number): IPoint;
102
+ scale(scaleX: number, scaleY?: number): IPoint;
103
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IPoint;
104
+ rotate(rotation: number, origin?: IPointData): IPoint;
105
+ rotateOf(origin: IPointData, rotation: number): IPoint;
106
+ getRotation(origin: IPointData, to: IPointData, toOrigin?: IPointData): number;
101
107
  toInnerOf(matrix: IMatrixData, to?: IPointData): IPoint;
102
108
  toOuterOf(matrix: IMatrixData, to?: IPointData): IPoint;
103
- getCenter(to: IPointData): IPointData;
109
+ getCenter(to: IPointData): IPoint;
104
110
  getDistance(to: IPointData): number;
111
+ getDistancePoint(to: IPointData, distance: number, changeTo?: boolean): IPoint;
105
112
  getAngle(to: IPointData): number;
106
113
  getAtan2(to: IPointData): number;
107
- reset(): void;
114
+ reset(): IPoint;
108
115
  }
109
116
  interface IRadiusPointData extends IPointData {
110
117
  radiusX: number;
@@ -125,25 +132,32 @@ interface IOffsetBoundsData extends IBoundsData {
125
132
  offsetX: number;
126
133
  offsetY: number;
127
134
  }
128
- interface IBoundsDataHandle {
135
+ interface IBoundsDataFn {
129
136
  (target: any): IBoundsData;
130
137
  }
131
- interface IBounds extends IBoundsData {
132
- set(x?: number, y?: number, width?: number, height?: number): void;
133
- copy(bounds: IBoundsData): IBounds;
138
+ interface IBounds extends IBoundsData, ITwoPointBoundsData {
139
+ set(x?: number | IBoundsData, y?: number, width?: number, height?: number): IBounds;
140
+ get(): IBoundsData;
134
141
  clone(): IBounds;
142
+ move(x: number, y: number): IBounds;
135
143
  scale(scaleX: number, scaleY?: number): IBounds;
144
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number): IBounds;
136
145
  toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds;
137
- getFitMatrix(put: IBoundsData): IMatrix;
138
- spread(size: number): IBounds;
146
+ toInnerOf(matrix: IMatrixData, to?: IBoundsData): IBounds;
147
+ getFitMatrix(put: IBoundsData, baseScale?: number): IMatrix;
148
+ spread(fourNumber: IFourNumber, spreadY?: number): IBounds;
149
+ shrink(fourNumber: IFourNumber): IBounds;
139
150
  ceil(): IBounds;
140
151
  unsign(): IBounds;
152
+ float(maxLength?: number): IBounds;
141
153
  add(bounds: IBoundsData): IBounds;
142
- addList(boundsList: IBounds[]): IBounds;
143
- setByList(boundsList: IBounds[], addMode?: boolean): IBounds;
144
- addListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle): IBounds;
145
- setByListWithHandle(list: IObject[], boundsDataHandle: IBoundsDataHandle, addMode: boolean): IBounds;
146
- setByPoints(points: IPointData[]): IBounds;
154
+ addList(boundsList: IBoundsData[]): IBounds;
155
+ setList(boundsList: IBoundsData[]): IBounds;
156
+ addListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds;
157
+ setListWithFn(list: IObject[], boundsDataHandle: IBoundsDataFn): IBounds;
158
+ setPoints(points: IPointData[]): IBounds;
159
+ addPoint(point: IPointData): IBounds;
160
+ getPoints(): IPointData[];
147
161
  hitPoint(point: IPointData, pointMatrix?: IMatrixData): boolean;
148
162
  hitRadiusPoint(point: IRadiusPointData, pointMatrix?: IMatrixWithLayoutData): boolean;
149
163
  hit(bounds: IBoundsData, boundsMatrix?: IMatrixData): boolean;
@@ -160,11 +174,6 @@ interface ITwoPointBoundsData {
160
174
  maxX: number;
161
175
  maxY: number;
162
176
  }
163
- interface ITwoPointBounds extends ITwoPointBoundsData {
164
- addPoint(x: number, y: number): void;
165
- addBounds(x: number, y: number, width: number, height: number): void;
166
- add(pointBounds: ITwoPointBoundsData): void;
167
- }
168
177
  interface IAutoBoundsData {
169
178
  top?: number;
170
179
  right?: number;
@@ -186,23 +195,31 @@ interface IMatrixData {
186
195
  e: number;
187
196
  f: number;
188
197
  }
189
- interface IMatrixDecompositionData {
190
- x: number;
191
- y: number;
198
+ interface IScaleData {
192
199
  scaleX: number;
193
200
  scaleY: number;
201
+ }
202
+ interface IScaleRotationData extends IScaleData {
194
203
  rotation: number;
204
+ }
205
+ interface ISkewData {
195
206
  skewX: number;
196
207
  skewY: number;
197
208
  }
198
- type IMatrixDecompositionAttr = 'x' | 'y' | 'scaleX' | 'scaleY' | 'rotation' | 'skewX' | 'skewY';
199
- interface IMatrix extends IMatrixData {
200
- set(a: number, b: number, c: number, d: number, e: number, f: number): void;
201
- copy(matrix: IMatrixData): IMatrix;
209
+ interface ILayoutData extends IScaleRotationData, ISkewData, IPointData {
210
+ }
211
+ type ILayoutAttr = 'x' | 'y' | 'scaleX' | 'scaleY' | 'rotation' | 'skewX' | 'skewY';
212
+ interface ILayoutBoundsData extends ILayoutData, IBoundsData {
213
+ }
214
+ interface IMatrix extends IMatrixWithScaleData {
215
+ set(a: number | IMatrixData, b: number, c: number, d: number, e: number, f: number): IMatrix;
216
+ setWith(dataWithScale: IMatrixWithScaleData): IMatrix;
217
+ get(): IMatrixData;
202
218
  clone(): IMatrix;
203
219
  translate(x: number, y: number): IMatrix;
204
220
  translateInner(x: number, y: number): IMatrix;
205
221
  scale(x: number, y?: number): IMatrix;
222
+ scaleWith(x: number, y?: number): IMatrix;
206
223
  scaleOfOuter(origin: IPointData, x: number, y?: number): IMatrix;
207
224
  scaleOfInner(origin: IPointData, x: number, y?: number): IMatrix;
208
225
  rotate(angle: number): IMatrix;
@@ -211,18 +228,30 @@ interface IMatrix extends IMatrixData {
211
228
  skew(x: number, y?: number): IMatrix;
212
229
  skewOfOuter(origin: IPointData, x: number, y?: number): IMatrix;
213
230
  skewOfInner(origin: IPointData, x: number, y?: number): IMatrix;
214
- multiply(matrix: IMatrixData): IMatrix;
215
- divide(matrix: IMatrixData): IMatrix;
216
- preMultiply(matrix: IMatrixData): IMatrix;
231
+ multiply(child: IMatrixData): IMatrix;
232
+ multiplyParent(parent: IMatrixData): IMatrix;
233
+ divide(child: IMatrixData): IMatrix;
234
+ divideParent(parent: IMatrixData): IMatrix;
217
235
  invert(): IMatrix;
236
+ invertWith(): IMatrix;
218
237
  toOuterPoint(inner: IPointData, to?: IPointData, distance?: boolean): void;
219
238
  toInnerPoint(outer: IPointData, to?: IPointData, distance?: boolean): void;
220
- decompose(): IMatrixDecompositionData;
239
+ setLayout(data: ILayoutData, origin?: IPointData): IMatrix;
240
+ getLayout(origin?: IPointData, firstSkewY?: boolean): ILayoutData;
241
+ withScale(scaleX?: number, scaleY?: number): IMatrixWithScaleData;
221
242
  reset(): void;
222
243
  }
223
244
  interface IMatrixWithBoundsData extends IMatrixData, IBoundsData {
224
245
  }
225
- interface IMatrixWithLayoutData extends IMatrixData, IMatrixDecompositionData, IBoundsData {
246
+ interface IMatrixWithScaleData extends IMatrixData, IScaleData {
247
+ }
248
+ interface IMatrixWithOptionScaleData extends IMatrixData {
249
+ scaleX?: number;
250
+ scaleY?: number;
251
+ }
252
+ interface IMatrixWithBoundsScaleData extends IMatrixData, IBoundsData, IScaleData {
253
+ }
254
+ interface IMatrixWithLayoutData extends IMatrixData, ILayoutBoundsData {
226
255
  }
227
256
 
228
257
  interface ILayoutChangedData {
@@ -250,6 +279,7 @@ interface ILayouterConfig {
250
279
  interface ILayouter extends IControl {
251
280
  target: ILeaf;
252
281
  layoutedBlocks: ILayoutBlockData[];
282
+ extraBlock: ILayoutBlockData;
253
283
  totalTimes: number;
254
284
  times: number;
255
285
  disabled: boolean;
@@ -263,12 +293,14 @@ interface ILayouter extends IControl {
263
293
  layoutOnce(): void;
264
294
  partLayout(): void;
265
295
  fullLayout(): void;
296
+ addExtra(leaf: ILeaf): void;
266
297
  createBlock(data: ILeafList | ILeaf[]): ILayoutBlockData;
267
298
  getBlocks(list: ILeafList): ILayoutBlockData[];
268
299
  addBlocks(current: ILayoutBlockData[]): void;
269
300
  }
270
301
 
271
302
  interface IEvent {
303
+ origin?: IObject;
272
304
  type?: string;
273
305
  target?: IEventTarget;
274
306
  current?: IEventTarget;
@@ -319,25 +351,6 @@ interface ILayoutEvent extends IEvent {
319
351
  interface IWatchEvent extends IEvent {
320
352
  readonly data: IWatchEventData;
321
353
  }
322
- interface ITransformEventData {
323
- x: number;
324
- y: number;
325
- scaleX: number;
326
- scaleY: number;
327
- rotation: number;
328
- readonly zooming: boolean;
329
- readonly moving: boolean;
330
- readonly rotating: boolean;
331
- readonly changing: boolean;
332
- }
333
- interface ITransformEvent extends IEvent, ITransformEventData {
334
- readonly x: number;
335
- readonly y: number;
336
- readonly scaleX: number;
337
- readonly scaleY: number;
338
- readonly rotation: number;
339
- }
340
- type TransformMode = 'move' | 'zoom' | 'rotate';
341
354
  interface IMultiTouchData {
342
355
  move: IPointData;
343
356
  scale: number;
@@ -361,7 +374,23 @@ interface ILeafEventer {
361
374
  hasEvent?(type: string, capture?: boolean): boolean;
362
375
  }
363
376
 
364
- type IEventListener = IFunction$1;
377
+ interface IFunction {
378
+ (...arg: any): any;
379
+ }
380
+ interface INumberFunction {
381
+ (...arg: any): number;
382
+ }
383
+ interface IPointDataFunction {
384
+ (...arg: any): IPointData;
385
+ }
386
+ interface IAttrDecorator {
387
+ (...arg: any): IAttrDecoratorInner;
388
+ }
389
+ interface IAttrDecoratorInner {
390
+ (target: any, key: string): any;
391
+ }
392
+
393
+ type IEventListener = IFunction;
365
394
  interface IEventListenerOptions {
366
395
  capture?: boolean;
367
396
  once?: boolean;
@@ -374,6 +403,7 @@ interface IEventListenerMap {
374
403
  }
375
404
  interface IEventListenerId {
376
405
  type: string | string[];
406
+ current: ILeaf;
377
407
  listener: IEventListener;
378
408
  options?: IEventListenerOptions | boolean;
379
409
  }
@@ -384,11 +414,11 @@ interface IEventer extends ILeafEventer {
384
414
  __bubbleMap?: IEventListenerMap;
385
415
  on(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void;
386
416
  off(type: string | string[], listener: IEventListener, options?: IEventListenerOptions | boolean): void;
387
- on_(type: string | string[], listener: IEventListener, bind?: IObject$1, options?: IEventListenerOptions | boolean): IEventListenerId;
417
+ on_(type: string | string[], listener: IEventListener, bind?: IObject, options?: IEventListenerOptions | boolean): IEventListenerId;
388
418
  off_(id: IEventListenerId | IEventListenerId[]): void;
389
419
  once(type: string | string[], listener: IEventListener): void;
390
- emit(type: string, event?: IEvent$1 | IObject$1, capture?: boolean): void;
391
- emitEvent(event?: IEvent$1, capture?: boolean): void;
420
+ emit(type: string, event?: IEvent | IObject, capture?: boolean): void;
421
+ emitEvent(event?: IEvent, capture?: boolean): void;
392
422
  hasEvent(type: string, capture?: boolean): boolean;
393
423
  destroy(): void;
394
424
  }
@@ -478,21 +508,23 @@ interface CanvasPathDrawingStyles {
478
508
  interface CanvasPattern {
479
509
  setTransform(transform?: DOMMatrix2DInit): void;
480
510
  }
511
+ type ICanvasPattern = CanvasPattern;
481
512
  interface CanvasRect {
482
513
  clearRect(x: number, y: number, w: number, h: number): void;
483
514
  fillRect(x: number, y: number, w: number, h: number): void;
484
515
  strokeRect(x: number, y: number, w: number, h: number): void;
485
516
  }
486
517
  type PredefinedColorSpace = 'display-p3' | 'srgb';
487
- interface CanvasRenderingContext2DSettings {
518
+ interface ICanvasRenderingContext2DSettings {
488
519
  alpha?: boolean;
489
520
  colorSpace?: PredefinedColorSpace;
490
521
  desynchronized?: boolean;
491
522
  willReadFrequently?: boolean;
492
523
  }
524
+ type ICanvasContext2DSettings = ICanvasRenderingContext2DSettings;
493
525
  interface ICanvasContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
494
526
  readonly canvas: HTMLCanvasElement;
495
- getContextAttributes(): CanvasRenderingContext2DSettings;
527
+ getContextAttributes(): ICanvasRenderingContext2DSettings;
496
528
  }
497
529
  interface CanvasShadowStyles {
498
530
  shadowBlur: number;
@@ -712,22 +744,24 @@ interface IPathDrawer {
712
744
  rect(x: number, y: number, width: number, height: number): void;
713
745
  roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): void;
714
746
  }
715
- interface IPathCreator {
747
+ interface IPathCreator extends IPathDrawer {
716
748
  path: IPathCommandData;
749
+ __path: IPathCommandData;
717
750
  beginPath(): IPathCreator;
718
751
  moveTo(x: number, y: number): IPathCreator;
719
752
  lineTo(x: number, y: number): IPathCreator;
720
753
  bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): IPathCreator;
721
754
  quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): IPathCreator;
722
755
  closePath(): IPathCreator;
723
- arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): IPathCreator;
756
+ arc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
724
757
  arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): IPathCreator;
725
- ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): IPathCreator;
758
+ ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
726
759
  rect(x: number, y: number, width: number, height: number): IPathCreator;
727
760
  roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): IPathCreator;
728
761
  drawEllipse(x: number, y: number, radiusX: number, radiusY: number, rotation?: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
729
762
  drawArc(x: number, y: number, radius: number, startAngle?: number, endAngle?: number, anticlockwise?: boolean): IPathCreator;
730
763
  drawPoints(points: number[], curve?: boolean | number, close?: boolean): IPathCreator;
764
+ clearPath(): IPathCreator;
731
765
  }
732
766
 
733
767
  interface ICanvasManager {
@@ -739,6 +773,101 @@ interface ICanvasManager {
739
773
  destroy(): void;
740
774
  }
741
775
 
776
+ type IExportImageType = 'jpg' | 'png' | 'webp';
777
+ type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json';
778
+
779
+ type ILocationType = 'world' | 'page' | 'local' | 'inner';
780
+ type IBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render';
781
+ interface ILeafLayout {
782
+ leaf: ILeaf;
783
+ proxyZoom: boolean;
784
+ boxBounds: IBoundsData;
785
+ strokeBounds: IBoundsData;
786
+ renderBounds: IBoundsData;
787
+ marginBounds: IBoundsData;
788
+ contentBounds: IBoundsData;
789
+ localStrokeBounds?: IBoundsData;
790
+ localRenderBounds?: IBoundsData;
791
+ resized: boolean;
792
+ waitAutoLayout: boolean;
793
+ matrixChanged: boolean;
794
+ scaleChanged: boolean;
795
+ rotationChanged: boolean;
796
+ boundsChanged: boolean;
797
+ boxChanged: boolean;
798
+ strokeChanged: boolean;
799
+ renderChanged: boolean;
800
+ localBoxChanged: boolean;
801
+ surfaceChanged: boolean;
802
+ opacityChanged: boolean;
803
+ hitCanvasChanged: boolean;
804
+ childrenSortChanged?: boolean;
805
+ affectScaleOrRotation: boolean;
806
+ affectRotation: boolean;
807
+ affectChildrenSort?: boolean;
808
+ strokeSpread: number;
809
+ renderSpread: number;
810
+ strokeBoxSpread: number;
811
+ renderShapeSpread: number;
812
+ a: number;
813
+ b: number;
814
+ c: number;
815
+ d: number;
816
+ e: number;
817
+ f: number;
818
+ x: number;
819
+ y: number;
820
+ width: number;
821
+ height: number;
822
+ createLocal(): void;
823
+ update(): void;
824
+ getTransform(relative?: ILocationType | ILeaf): IMatrixData;
825
+ getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
826
+ getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
827
+ getLayoutPoints(type?: IBoundsType, relative?: ILocationType | ILeaf): IPointData[];
828
+ spreadStroke(): void;
829
+ spreadRender(): void;
830
+ spreadStrokeCancel(): void;
831
+ spreadRenderCancel(): void;
832
+ boxChange(): void;
833
+ localBoxChange(): void;
834
+ strokeChange(): void;
835
+ renderChange(): void;
836
+ scaleChange(): void;
837
+ rotationChange(): void;
838
+ matrixChange(): void;
839
+ surfaceChange(): void;
840
+ opacityChange(): void;
841
+ childrenSortChange(): void;
842
+ destroy(): void;
843
+ }
844
+
845
+ interface IExportOptions {
846
+ quality?: number;
847
+ blob?: boolean;
848
+ scale?: number;
849
+ pixelRatio?: number;
850
+ slice?: boolean;
851
+ trim?: boolean;
852
+ fill?: string;
853
+ screenshot?: IBoundsData | boolean;
854
+ relative?: ILocationType | ILeaf;
855
+ onCanvas?: IExportOnCanvasFunction;
856
+ }
857
+ interface IExportResult {
858
+ data: ILeaferCanvas | IBlob | string | boolean;
859
+ width?: number;
860
+ height?: number;
861
+ renderBounds?: IBoundsData;
862
+ trimBounds?: IBoundsData;
863
+ }
864
+ interface IExportResultFunction {
865
+ (data: IExportResult): void;
866
+ }
867
+ interface IExportOnCanvasFunction {
868
+ (data: ILeaferCanvas): void;
869
+ }
870
+
742
871
  interface ILeaferCanvasConfig extends IAutoBoundsData {
743
872
  view?: string | IObject;
744
873
  fill?: string;
@@ -746,6 +875,7 @@ interface ILeaferCanvasConfig extends IAutoBoundsData {
746
875
  smooth?: boolean;
747
876
  hittable?: boolean;
748
877
  webgl?: boolean;
878
+ contextSettings?: ICanvasContext2DSettings;
749
879
  }
750
880
  type IHitCanvasConfig = ILeaferCanvasConfig;
751
881
  interface ICanvasStrokeOptions {
@@ -757,6 +887,10 @@ interface ICanvasStrokeOptions {
757
887
  dashOffset?: number;
758
888
  miterLimit?: number;
759
889
  }
890
+ interface ICanvasCacheOptions extends ICanvasStrokeOptions {
891
+ fillStyle?: string | object;
892
+ strokeStyle?: string | object;
893
+ }
760
894
  interface ICanvasAttr extends ICanvasStrokeOptions, IObject {
761
895
  smooth: boolean;
762
896
  smoothLevel: string;
@@ -811,6 +945,7 @@ interface ICanvasMethod {
811
945
  restoreBlendMode(): void;
812
946
  hitFill(point: IPointData, fillRule?: string): boolean;
813
947
  hitStroke(point: IPointData, strokeWidth?: number): boolean;
948
+ hitPixel(radiusPoint: IRadiusPointData, offset?: IPointData, scale?: number): boolean;
814
949
  setStroke(strokeStyle: string | object, strokeWidth: number, options?: ICanvasStrokeOptions): void;
815
950
  setStrokeOptions(options: ICanvasStrokeOptions): void;
816
951
  setWorld(matrix: IMatrixData, parentMatrix?: IMatrixData): void;
@@ -818,7 +953,7 @@ interface ICanvasMethod {
818
953
  setWorldShadow(x: number, y: number, blur: number, color?: string): void;
819
954
  setWorldBlur(blur: number): void;
820
955
  copyWorld(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void;
821
- copyWorldByReset(canvas: ILeaferCanvas, from?: IBoundsData, to?: IBoundsData, blendMode?: string): void;
956
+ copyWorldByReset(canvas: ILeaferCanvas, from?: IBoundsData, to?: IBoundsData, blendMode?: string, onlyResetTransform?: boolean): void;
822
957
  copyWorldToInner(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toInnerBounds: IBoundsData, blendMode?: string): void;
823
958
  useMask(maskCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void;
824
959
  useEraser(eraserCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void;
@@ -828,6 +963,7 @@ interface ICanvasMethod {
828
963
  clearWorld(bounds: IBoundsData, ceilPixel?: boolean): void;
829
964
  clear(): void;
830
965
  }
966
+ type ILeaferCanvasView = any;
831
967
  interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
832
968
  readonly innerId: InnerId;
833
969
  name: string;
@@ -844,13 +980,14 @@ interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
844
980
  clientBounds: IBoundsData;
845
981
  config: ILeaferCanvasConfig;
846
982
  autoLayout: boolean;
847
- view: any;
983
+ view: ILeaferCanvasView;
848
984
  parentView: any;
849
985
  unreal?: boolean;
850
986
  context: ICanvasContext2D;
851
987
  recycled?: boolean;
852
988
  worldTransform: IMatrixData;
853
989
  init(): void;
990
+ export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): string | Promise<any>;
854
991
  toBlob(type?: string, quality?: number): Promise<IBlob>;
855
992
  toDataURL(type?: string, quality?: number): string | Promise<string>;
856
993
  saveAs(filename: string, quality?: number): Promise<boolean>;
@@ -859,36 +996,26 @@ interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
859
996
  resize(size: IScreenSizeData): void;
860
997
  updateViewSize(): void;
861
998
  updateClientBounds(): void;
862
- setCursor(cursor: ICursorType | ICursorType[]): void;
863
999
  isSameSize(options: ILeaferCanvasConfig): boolean;
864
- getSameCanvas(useSameWorldTransform?: boolean): ILeaferCanvas;
865
- getBiggerCanvas(addWidth: number, addHeight: number): ILeaferCanvas;
866
- recycle(): void;
1000
+ getSameCanvas(useSameWorldTransform?: boolean, useSameSmooth?: boolean): ILeaferCanvas;
1001
+ recycle(clearBounds?: IBoundsData): void;
867
1002
  updateRender(): void;
868
1003
  unrealCanvas(): void;
869
1004
  destroy(): void;
870
1005
  }
871
1006
  interface IHitCanvas extends ILeaferCanvas {
1007
+ hitScale?: number;
872
1008
  }
873
1009
  interface IBlobFunction {
874
1010
  (blob: IBlob | null): void;
875
1011
  }
876
1012
  type IBlob = any;
877
1013
 
878
- interface IFunction {
879
- (...arg: any): any;
880
- }
881
- interface INumberFunction {
882
- (...arg: any): number;
883
- }
884
- interface IPointDataFunction {
885
- (...arg: any): IPointData;
886
- }
887
-
888
1014
  interface IRenderOptions {
1015
+ includes?: boolean;
889
1016
  bounds?: IBounds;
890
1017
  hideBounds?: IBounds;
891
- matrix?: IMatrix;
1018
+ matrix?: IMatrixWithScaleData;
892
1019
  inCamera?: boolean;
893
1020
  }
894
1021
  interface IRendererConfig {
@@ -907,6 +1034,7 @@ interface IRenderer extends IControl {
907
1034
  rendering: boolean;
908
1035
  waitAgain: boolean;
909
1036
  changed: boolean;
1037
+ ignore: boolean;
910
1038
  config: IRendererConfig;
911
1039
  update(): void;
912
1040
  requestLayout(): void;
@@ -924,8 +1052,10 @@ interface IRenderer extends IControl {
924
1052
 
925
1053
  type ILeafDataProxyModule = ILeafDataProxy & ThisType<ILeaf>;
926
1054
  interface ILeafDataProxy {
927
- __setAttr?(name: string, newValue: __Value): void;
928
- __getAttr?(name: string): __Value;
1055
+ __setAttr?(name: string, newValue: IValue): boolean;
1056
+ __getAttr?(name: string): IValue;
1057
+ setProxyAttr?(name: string, newValue: IValue): void;
1058
+ getProxyAttr?(name: string): IValue;
929
1059
  }
930
1060
 
931
1061
  type ILeafMatrixModule = ILeafMatrix & ThisType<ILeaf>;
@@ -937,75 +1067,27 @@ interface ILeafMatrix {
937
1067
  type ILeafBoundsModule = ILeafBounds & ThisType<ILeaf>;
938
1068
  interface ILeafBounds {
939
1069
  __updateWorldBounds?(): void;
1070
+ __updateLocalBounds?(): void;
940
1071
  __updateLocalBoxBounds?(): void;
941
1072
  __updateLocalStrokeBounds?(): void;
942
1073
  __updateLocalRenderBounds?(): void;
943
1074
  __updateBoxBounds?(): void;
944
1075
  __updateStrokeBounds?(): void;
945
1076
  __updateRenderBounds?(): void;
1077
+ __updateAutoLayout?(): void;
946
1078
  __updateNaturalSize?(): void;
947
1079
  __updateStrokeSpread?(): number;
948
1080
  __updateRenderSpread?(): number;
949
1081
  __onUpdateSize?(): void;
950
1082
  }
951
1083
 
952
- type ILayoutLocationType = 'world' | 'local' | 'inner';
953
- type ILayoutBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render';
954
- interface ILeafLayout {
955
- leaf: ILeaf;
956
- useZoomProxy: boolean;
957
- boxBounds: IBoundsData;
958
- strokeBounds: IBoundsData;
959
- renderBounds: IBoundsData;
960
- marginBounds: IBoundsData;
961
- contentBounds: IBoundsData;
962
- localStrokeBounds: IBoundsData;
963
- localRenderBounds: IBoundsData;
964
- matrixChanged: boolean;
965
- positionChanged: boolean;
966
- originChanged?: boolean;
967
- scaleChanged: boolean;
968
- rotationChanged: boolean;
969
- boundsChanged: boolean;
970
- boxChanged: boolean;
971
- strokeChanged: boolean;
972
- renderChanged: boolean;
973
- localBoxChanged: boolean;
974
- surfaceChanged: boolean;
975
- opacityChanged: boolean;
976
- hitCanvasChanged: boolean;
977
- childrenSortChanged?: boolean;
978
- affectScaleOrRotation: boolean;
979
- affectRotation: boolean;
980
- affectChildrenSort?: boolean;
981
- strokeSpread: number;
982
- renderSpread: number;
983
- strokeBoxSpread: number;
984
- renderShapeSpread: number;
985
- checkUpdate(force?: boolean): void;
986
- getTransform(locationType: ILayoutLocationType): IMatrixData;
987
- getBounds(type: ILayoutBoundsType, locationType: ILayoutLocationType): IBoundsData;
988
- spreadStroke(): void;
989
- spreadRender(): void;
990
- spreadStrokeCancel(): void;
991
- spreadRenderCancel(): void;
992
- boxChange(): void;
993
- localBoxChange(): void;
994
- strokeChange(): void;
995
- renderChange(): void;
996
- positionChange(): void;
997
- scaleChange(): void;
998
- rotationChange(): void;
999
- surfaceChange(): void;
1000
- opacityChange(): void;
1001
- childrenSortChange(): void;
1002
- destroy(): void;
1003
- }
1004
-
1005
1084
  type ILeafHitModule = ILeafHit & ThisType<ILeaf>;
1006
1085
  interface ILeafHit {
1007
1086
  __hitWorld?(point: IRadiusPointData): boolean;
1008
- __hit?(local: IRadiusPointData): boolean;
1087
+ __hit?(inner: IRadiusPointData): boolean;
1088
+ __hitFill?(inner: IRadiusPointData): boolean;
1089
+ __hitStroke?(inner: IRadiusPointData, strokeWidth: number): boolean;
1090
+ __hitPixel(inner: IRadiusPointData): boolean;
1009
1091
  __drawHitPath?(canvas: ILeaferCanvas): void;
1010
1092
  __updateHitCanvas?(): void;
1011
1093
  }
@@ -1015,35 +1097,79 @@ interface ILeafRender {
1015
1097
  __render?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1016
1098
  __draw?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1017
1099
  __drawFast?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1018
- __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1100
+ __clip?(_canvas: ILeaferCanvas, _options: IRenderOptions): void;
1101
+ __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions, ignoreFill?: boolean, ignoreStroke?: boolean): void;
1019
1102
  __updateWorldOpacity?(): void;
1020
1103
  __updateChange?(): void;
1021
1104
  }
1022
1105
 
1023
- type ILeafMaskModule = ILeafMask & ThisType<ILeaf>;
1024
- interface ILeafMask {
1025
- __updateEraser?(value?: boolean): void;
1026
- __updateMask?(value?: boolean): void;
1027
- __renderMask?(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas): void;
1028
- __removeMask?(child?: ILeaf): void;
1029
- }
1030
-
1031
- interface IDataProcessor extends IObject {
1106
+ interface IDataProcessor {
1032
1107
  __leaf: ILeaf;
1033
1108
  __input: IObject;
1034
1109
  __middle: IObject;
1035
- __single: boolean;
1036
- __checkSingle(): void;
1037
1110
  __get(name: string): any;
1111
+ __getData(): IObject;
1038
1112
  __setInput(name: string, value: any): void;
1039
1113
  __getInput(name: string): any;
1040
1114
  __removeInput(name: string): void;
1041
- __getInputData(): IObject;
1115
+ __getInputData(names?: string[] | IObject): IObject;
1042
1116
  __setMiddle(name: string, value: any): void;
1043
1117
  __getMiddle(name: string): any;
1044
1118
  destroy(): void;
1045
1119
  }
1120
+ interface ILeafDataOptions {
1121
+ attrs?: 'all' | string[];
1122
+ children?: boolean;
1123
+ }
1046
1124
  interface ILeafData extends IDataProcessor, ILeafComputedData {
1125
+ __single?: boolean;
1126
+ __checkSingle(): void;
1127
+ __removeNaturalSize(): void;
1128
+ }
1129
+
1130
+ interface IBranch extends ILeaf {
1131
+ children: ILeaf[];
1132
+ __renderBranch?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1133
+ addMany(...children: ILeaf[]): void;
1134
+ removeAll(destroy?: boolean): void;
1135
+ clear(): void;
1136
+ }
1137
+
1138
+ interface IPickResult {
1139
+ target: ILeaf;
1140
+ path: ILeafList;
1141
+ throughPath?: ILeafList;
1142
+ }
1143
+ interface IPickOptions {
1144
+ name?: string;
1145
+ hitRadius?: number;
1146
+ through?: boolean;
1147
+ target?: IBranch;
1148
+ findList?: ILeaf[];
1149
+ exclude?: ILeafList;
1150
+ ignoreHittable?: boolean;
1151
+ }
1152
+ interface ISelectorConfig {
1153
+ }
1154
+ type IAnswer = 0 | 1 | 2 | 3;
1155
+ interface IFindMethod {
1156
+ (leaf: ILeaf, options?: any): IAnswer;
1157
+ }
1158
+ interface ISelectorProxy {
1159
+ list: ILeaf[];
1160
+ }
1161
+ interface ISelector {
1162
+ target: ILeaf;
1163
+ proxy?: ISelectorProxy;
1164
+ config: ISelectorConfig;
1165
+ getByPoint(hitPoint: IPointData, hitRadius: number, options?: IPickOptions): IPickResult;
1166
+ getBy(condition: number | string | IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[];
1167
+ getByInnerId(innerId: number, branch?: ILeaf): ILeaf;
1168
+ getById(id: string, branch?: ILeaf): ILeaf;
1169
+ getByClassName(className: string, branch?: ILeaf): ILeaf[];
1170
+ getByTag(tag: string, branch?: ILeaf): ILeaf[];
1171
+ getByMethod(method: IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[];
1172
+ destroy(): void;
1047
1173
  }
1048
1174
 
1049
1175
  interface ICachedLeaf {
@@ -1052,79 +1178,118 @@ interface ICachedLeaf {
1052
1178
  bounds: IBoundsData;
1053
1179
  }
1054
1180
  interface ILeafAttrData {
1055
- id: __String;
1056
- name: __String;
1057
- className: __String;
1181
+ id: IString;
1182
+ name: IString;
1183
+ className: IString;
1058
1184
  blendMode: IBlendMode;
1059
- opacity: __Number;
1060
- visible: __Boolean;
1061
- isMask: __Boolean;
1062
- isEraser: __Boolean;
1063
- zIndex: __Number;
1064
- x: __Number;
1065
- y: __Number;
1066
- width: __Number;
1067
- height: __Number;
1068
- scaleX: __Number;
1069
- scaleY: __Number;
1070
- rotation: __Number;
1071
- skewX: __Number;
1072
- skewY: __Number;
1073
- scale: __Number | IPointData;
1074
- around: 'center' | IPointData;
1075
- draggable: __Boolean;
1076
- hittable: __Boolean;
1185
+ opacity: INumber;
1186
+ visible: IBoolean;
1187
+ selected: IBoolean;
1188
+ disabled: IBoolean;
1189
+ locked: IBoolean;
1190
+ zIndex: INumber;
1191
+ mask: IBoolean;
1192
+ maskType: IMaskType;
1193
+ eraser: IBoolean;
1194
+ x: INumber;
1195
+ y: INumber;
1196
+ width: INumber;
1197
+ height: INumber;
1198
+ scaleX: INumber;
1199
+ scaleY: INumber;
1200
+ rotation: INumber;
1201
+ skewX: INumber;
1202
+ skewY: INumber;
1203
+ scale: INumber | IPointData;
1204
+ around: IAround;
1205
+ lazy: IBoolean;
1206
+ pixelRatio: INumber;
1207
+ draggable: IBoolean;
1208
+ path: IPathCommandData | IPathString;
1209
+ windingRule: IWindingRule;
1210
+ closed: boolean;
1211
+ editable: IBoolean;
1212
+ editSize: IEditSize;
1213
+ editorStyle: IObject;
1214
+ hittable: IBoolean;
1077
1215
  hitFill: IHitType;
1078
1216
  hitStroke: IHitType;
1079
- hitChildren: __Boolean;
1080
- hitSelf: __Boolean;
1081
- hitRadius: __Number;
1217
+ hitBox: IBoolean;
1218
+ hitChildren: IBoolean;
1219
+ hitSelf: IBoolean;
1220
+ hitRadius: INumber;
1082
1221
  cursor: ICursorType | ICursorType[];
1222
+ normalStyle: ILeafInputData;
1223
+ hoverStyle: ILeafInputData;
1224
+ pressStyle: ILeafInputData;
1225
+ focusStyle: ILeafInputData;
1226
+ selectedStyle: ILeafInputData;
1227
+ disabledStyle: ILeafInputData;
1083
1228
  }
1084
1229
  type IHitType = 'path' | 'pixel' | 'all' | 'none';
1085
- 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';
1086
- type IResizeType = 'size' | 'scale';
1230
+ type IMaskType = 'path' | 'pixel' | 'clipping';
1231
+ 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';
1232
+ type IEditSize = 'size' | 'scale';
1087
1233
  interface IImageCursor {
1088
1234
  url: string;
1089
1235
  x?: number;
1090
1236
  y?: number;
1237
+ rotation?: number;
1091
1238
  }
1092
- type IAround = 'center' | IPointData;
1093
- 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';
1094
- interface ICursorTypeMap {
1095
- [name: string]: ICursorType | ICursorType[];
1096
- }
1097
- interface ILeafInputData extends IObject {
1239
+ type IAround = 'topLeft' | 'top' | 'topRight' | 'right' | 'bottomRight' | 'bottom' | 'bottomLeft' | 'left' | 'center' | IPointData;
1240
+ 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';
1241
+ type IStateStyleType = 'hoverStyle' | 'pressStyle' | 'focusStyle' | 'selectedStyle' | 'disabledStyle';
1242
+ interface ILeafInputData {
1098
1243
  tag?: string;
1099
- id?: __String;
1100
- name?: __String;
1101
- className?: __String;
1244
+ id?: IString;
1245
+ name?: IString;
1246
+ className?: IString;
1102
1247
  blendMode?: IBlendMode;
1103
- opacity?: __Number;
1104
- visible?: __Boolean;
1105
- isMask?: __Boolean;
1106
- isEraser?: __Boolean;
1107
- zIndex?: __Number;
1108
- x?: __Number;
1109
- y?: __Number;
1110
- width?: __Number;
1111
- height?: __Number;
1112
- scaleX?: __Number;
1113
- scaleY?: __Number;
1114
- rotation?: __Number;
1115
- skewX?: __Number;
1116
- skewY?: __Number;
1117
- scale?: __Number | IPointData;
1248
+ opacity?: INumber;
1249
+ visible?: IBoolean;
1250
+ selected?: IBoolean;
1251
+ disabled?: IBoolean;
1252
+ locked?: IBoolean;
1253
+ zIndex?: INumber;
1254
+ mask?: IBoolean;
1255
+ maskType?: IMaskType;
1256
+ eraser?: IBoolean;
1257
+ x?: INumber;
1258
+ y?: INumber;
1259
+ width?: INumber;
1260
+ height?: INumber;
1261
+ scaleX?: INumber;
1262
+ scaleY?: INumber;
1263
+ rotation?: INumber;
1264
+ skewX?: INumber;
1265
+ skewY?: INumber;
1266
+ scale?: INumber | IPointData;
1118
1267
  around?: IAround;
1119
- draggable?: __Boolean;
1120
- hittable?: __Boolean;
1268
+ lazy?: IBoolean;
1269
+ pixelRatio?: INumber;
1270
+ draggable?: IBoolean;
1271
+ path?: IPathCommandData | IPathString;
1272
+ windingRule?: IWindingRule;
1273
+ closed?: boolean;
1274
+ editable?: IBoolean;
1275
+ editSize?: IEditSize;
1276
+ editorStyle?: IObject;
1277
+ hittable?: IBoolean;
1121
1278
  hitFill?: IHitType;
1122
1279
  hitStroke?: IHitType;
1123
- hitChildren?: __Boolean;
1124
- hitSelf?: __Boolean;
1125
- hitRadius?: __Number;
1280
+ hitBox?: IBoolean;
1281
+ hitChildren?: IBoolean;
1282
+ hitSelf?: IBoolean;
1283
+ hitRadius?: INumber;
1126
1284
  cursor?: ICursorType | ICursorType[];
1285
+ normalStyle?: ILeafInputData;
1286
+ hoverStyle?: ILeafInputData;
1287
+ pressStyle?: ILeafInputData;
1288
+ focusStyle?: ILeafInputData;
1289
+ selectedStyle?: ILeafInputData;
1290
+ disabledStyle?: ILeafInputData;
1127
1291
  children?: ILeafInputData[];
1292
+ noBounds?: boolean;
1128
1293
  }
1129
1294
  interface ILeafComputedData {
1130
1295
  id?: string;
@@ -1133,9 +1298,13 @@ interface ILeafComputedData {
1133
1298
  blendMode?: IBlendMode;
1134
1299
  opacity?: number;
1135
1300
  visible?: boolean;
1136
- isMask?: boolean;
1137
- isEraser?: boolean;
1301
+ selected?: boolean;
1302
+ disabled?: boolean;
1303
+ locked?: boolean;
1138
1304
  zIndex?: number;
1305
+ mask?: boolean;
1306
+ maskType?: IMaskType;
1307
+ eraser?: boolean;
1139
1308
  x?: number;
1140
1309
  y?: number;
1141
1310
  width?: number;
@@ -1146,85 +1315,133 @@ interface ILeafComputedData {
1146
1315
  skewX?: number;
1147
1316
  skewY?: number;
1148
1317
  around?: IAround;
1318
+ lazy?: boolean;
1319
+ pixelRatio?: number;
1320
+ path?: IPathCommandData;
1321
+ windingRule?: IWindingRule;
1322
+ closed?: boolean;
1149
1323
  draggable?: boolean;
1324
+ editable?: boolean;
1325
+ editSize?: IEditSize;
1326
+ editorStyle?: IObject;
1150
1327
  hittable?: boolean;
1151
1328
  hitFill?: IHitType;
1152
1329
  hitStroke?: IHitType;
1330
+ hitBox?: boolean;
1153
1331
  hitChildren?: boolean;
1154
1332
  hitSelf?: boolean;
1155
1333
  hitRadius?: number;
1156
1334
  cursor?: ICursorType | ICursorType[];
1335
+ normalStyle?: ILeafInputData;
1336
+ hoverStyle?: ILeafInputData;
1337
+ pressStyle?: ILeafInputData;
1338
+ focusStyle?: ILeafInputData;
1339
+ selectedStyle?: ILeafInputData;
1340
+ disabledStyle?: ILeafInputData;
1157
1341
  __childBranchNumber?: number;
1158
1342
  __complex?: boolean;
1159
1343
  __naturalWidth?: number;
1160
1344
  __naturalHeight?: number;
1161
- }
1162
- interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
1345
+ readonly __blendMode: string;
1346
+ __useArrow?: boolean;
1347
+ __useEffect?: boolean;
1348
+ __pathInputed?: number;
1349
+ __pathForRender?: IPathCommandData;
1350
+ __path2DForRender?: IPath2D;
1351
+ }
1352
+ interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
1163
1353
  tag: string;
1164
1354
  readonly __tag: string;
1165
1355
  readonly innerName: string;
1166
1356
  readonly __DataProcessor: IObject;
1167
1357
  readonly __LayoutProcessor: IObject;
1168
- leafer?: ILeafer;
1358
+ readonly app?: ILeaferBase;
1359
+ leafer?: ILeaferBase;
1169
1360
  parent?: ILeaf;
1361
+ zoomLayer?: ILeaf;
1170
1362
  readonly isApp?: boolean;
1171
- isLeafer?: boolean;
1172
- isBranch?: boolean;
1173
- isBranchLeaf?: boolean;
1363
+ readonly isLeafer?: boolean;
1364
+ readonly isBranch?: boolean;
1365
+ readonly isBranchLeaf?: boolean;
1366
+ readonly isOutside?: boolean;
1174
1367
  __: ILeafData;
1368
+ proxyData?: ILeafInputData;
1369
+ __proxyData?: ILeafInputData;
1175
1370
  __layout: ILeafLayout;
1176
- __world: IMatrixWithLayoutData;
1177
- __local: IMatrixWithBoundsData;
1371
+ __world: IMatrixWithBoundsScaleData;
1372
+ __local?: IMatrixWithBoundsData;
1373
+ __nowWorld?: IMatrixWithBoundsScaleData;
1374
+ __cameraWorld?: IMatrixWithBoundsScaleData;
1375
+ readonly __localMatrix: IMatrixData;
1376
+ readonly __localBoxBounds: IBoundsData;
1178
1377
  __worldOpacity: number;
1179
- readonly worldTransform: IMatrixWithLayoutData;
1180
- readonly localTransform: IMatrixWithBoundsData;
1378
+ readonly worldTransform: IMatrixWithScaleData;
1379
+ readonly localTransform: IMatrixData;
1181
1380
  readonly boxBounds: IBoundsData;
1381
+ readonly renderBounds: IBoundsData;
1182
1382
  readonly worldBoxBounds: IBoundsData;
1183
1383
  readonly worldStrokeBounds: IBoundsData;
1184
1384
  readonly worldRenderBounds: IBoundsData;
1185
1385
  readonly worldOpacity: number;
1186
- __renderTime?: number;
1187
1386
  __level: number;
1188
1387
  __tempNumber?: number;
1189
- readonly resizeable: boolean;
1190
- readonly __hasMirror: boolean;
1388
+ readonly __worldFlipped: boolean;
1389
+ __hasAutoLayout?: boolean;
1191
1390
  __hasMask?: boolean;
1192
1391
  __hasEraser?: boolean;
1193
1392
  __hitCanvas?: IHitCanvas;
1194
1393
  readonly __onlyHitMask: boolean;
1195
1394
  readonly __ignoreHitWorld: boolean;
1395
+ readonly pathInputed: boolean;
1196
1396
  __parentWait?: IFunction[];
1197
1397
  __leaferWait?: IFunction[];
1198
1398
  destroyed: boolean;
1199
- waitParent(item: IFunction): void;
1200
- waitLeafer(item: IFunction): void;
1201
- nextRender(item: IFunction): void;
1202
- __bindLeafer(leafer: ILeafer | null): void;
1399
+ reset(data?: ILeafInputData): void;
1400
+ resetCustom(): void;
1401
+ waitParent(item: IFunction, bind?: IObject): void;
1402
+ waitLeafer(item: IFunction, bind?: IObject): void;
1403
+ nextRender(item: IFunction, bind?: IObject, off?: 'off'): void;
1404
+ removeNextRender(item: IFunction): void;
1405
+ __bindLeafer(leafer: ILeaferBase | null): void;
1203
1406
  set(data: IObject): void;
1407
+ get(name?: string | string[] | IObject): ILeafInputData | IValue;
1204
1408
  toJSON(): IObject;
1205
1409
  toString(): string;
1206
- __setAttr(attrName: string, newValue: __Value): void;
1207
- __getAttr(attrName: string): __Value;
1410
+ toSVG?(): string;
1411
+ toHTML?(): string;
1412
+ __setAttr(attrName: string, newValue: IValue, checkFiniteNumber?: boolean): boolean;
1413
+ __getAttr(attrName: string): IValue;
1414
+ setProxyAttr(name: string, newValue: IValue): void;
1415
+ getProxyAttr(name: string): IValue;
1416
+ find(condition: number | string | IFindMethod, options?: any): ILeaf[];
1417
+ findOne(condition: number | string | IFindMethod, options?: any): ILeaf;
1418
+ focus(value?: boolean): void;
1208
1419
  forceUpdate(attrName?: string): void;
1420
+ updateLayout(): void;
1209
1421
  __updateWorldMatrix(): void;
1210
1422
  __updateLocalMatrix(): void;
1211
1423
  __updateWorldBounds(): void;
1424
+ __updateLocalBounds(): void;
1212
1425
  __updateLocalBoxBounds(): void;
1213
1426
  __updateLocalStrokeBounds(): void;
1214
1427
  __updateLocalRenderBounds(): void;
1215
1428
  __updateBoxBounds(): void;
1216
1429
  __updateStrokeBounds(): void;
1217
1430
  __updateRenderBounds(): void;
1431
+ __updateAutoLayout(): void;
1218
1432
  __updateNaturalSize(): void;
1219
1433
  __updateStrokeSpread(): number;
1220
1434
  __updateRenderSpread(): number;
1221
1435
  __onUpdateSize(): void;
1222
1436
  __updateEraser(value?: boolean): void;
1223
1437
  __updateMask(value?: boolean): void;
1224
- __renderMask(canvas: ILeaferCanvas, content: ILeaferCanvas, mask: ILeaferCanvas): void;
1225
- __removeMask(child?: ILeaf): void;
1226
- getWorld(attrName: IMatrixDecompositionAttr): number;
1227
- getBounds(type: ILayoutBoundsType, locationType?: ILayoutLocationType): IBoundsData;
1438
+ __renderMask(canvas: ILeaferCanvas, options: IRenderOptions): void;
1439
+ __getNowWorld(options: IRenderOptions): IMatrixWithBoundsScaleData;
1440
+ getWorld(attrName: ILayoutAttr): number;
1441
+ getTransform(relative?: ILocationType | ILeaf): IMatrixData;
1442
+ getBounds(type?: IBoundsType, relative?: ILocationType | ILeaf): IBoundsData;
1443
+ getLayoutBounds(type?: IBoundsType, relative?: ILocationType | ILeaf, unscale?: boolean): ILayoutBoundsData;
1444
+ getWorldBounds(inner: IBoundsData, relative?: ILeaf, change?: boolean): IBoundsData;
1228
1445
  worldToLocal(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
1229
1446
  localToWorld(local: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
1230
1447
  worldToInner(world: IPointData, to?: IPointData, distance?: boolean, relative?: ILeaf): void;
@@ -1235,18 +1452,33 @@ interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatr
1235
1452
  getLocalPointByInner(inner: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1236
1453
  getWorldPoint(inner: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1237
1454
  getWorldPointByLocal(local: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1455
+ getPagePoint(world: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1456
+ getWorldPointByPage(page: IPointData, relative?: ILeaf, distance?: boolean, change?: boolean): IPointData;
1457
+ setTransform(transform?: IMatrixData, resize?: boolean): void;
1458
+ transform(transform?: IMatrixData, resize?: boolean): void;
1238
1459
  move(x: number, y?: number): void;
1239
- scaleOf(origin: IPointData, x: number, y?: number): void;
1460
+ scaleOf(origin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
1240
1461
  rotateOf(origin: IPointData, rotation: number): void;
1241
- skewOf(origin: IPointData, x: number, y: number): void;
1462
+ skewOf(origin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
1463
+ transformWorld(worldTransform?: IMatrixData, resize?: boolean): void;
1464
+ moveWorld(x: number, y?: number): void;
1465
+ scaleOfWorld(worldOrigin: IPointData, scaleX: number, scaleY?: number, resize?: boolean): void;
1466
+ rotateOfWorld(worldOrigin: IPointData, rotation: number): void;
1467
+ skewOfWorld(worldOrigin: IPointData, skewX: number, skewY?: number, resize?: boolean): void;
1468
+ scaleResize(scaleX: number, scaleY: number, noResize?: boolean): void;
1469
+ __scaleResize(scaleX: number, scaleY: number): void;
1242
1470
  __hitWorld(point: IRadiusPointData): boolean;
1243
1471
  __hit(local: IRadiusPointData): boolean;
1472
+ __hitFill(inner: IRadiusPointData): boolean;
1473
+ __hitStroke(inner: IRadiusPointData, strokeWidth: number): boolean;
1474
+ __hitPixel(inner: IRadiusPointData): boolean;
1244
1475
  __drawHitPath(canvas: ILeaferCanvas): void;
1245
1476
  __updateHitCanvas(): void;
1246
1477
  __render(canvas: ILeaferCanvas, options: IRenderOptions): void;
1247
1478
  __drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void;
1248
1479
  __draw(canvas: ILeaferCanvas, options: IRenderOptions): void;
1249
- __renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void;
1480
+ __clip(canvas: ILeaferCanvas, options: IRenderOptions): void;
1481
+ __renderShape(canvas: ILeaferCanvas, options: IRenderOptions, ignoreFill?: boolean, ignoreStroke?: boolean): void;
1250
1482
  __updateWorldOpacity(): void;
1251
1483
  __updateChange(): void;
1252
1484
  __drawPath(canvas: ILeaferCanvas): void;
@@ -1257,35 +1489,12 @@ interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatr
1257
1489
  __updateSortChildren(): void;
1258
1490
  add(child: ILeaf, index?: number): void;
1259
1491
  remove(child?: ILeaf, destroy?: boolean): void;
1492
+ dropTo(parent: ILeaf, index?: number, resize?: boolean): void;
1260
1493
  }
1261
-
1262
- interface ISelectPathResult {
1263
- leaf: ILeaf;
1264
- path: ILeafList;
1265
- throughPath?: ILeafList;
1494
+ type ILeafAttrDescriptor = IObject & ThisType<ILeaf>;
1495
+ interface ILeafAttrDescriptorFn {
1496
+ (key: string): ILeafAttrDescriptor;
1266
1497
  }
1267
- interface ISelectPathOptions {
1268
- name?: string;
1269
- through?: boolean;
1270
- exclude?: ILeafList;
1271
- ignoreHittable?: boolean;
1272
- }
1273
- interface ISelectorConfig {
1274
- }
1275
- interface ISelector {
1276
- target: ILeaf;
1277
- config: ISelectorConfig;
1278
- getByPoint(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult;
1279
- find(name: number | string, branch?: ILeaf): ILeaf | ILeaf[];
1280
- getByInnerId(name: number, branch?: ILeaf): ILeaf;
1281
- getById(name: string, branch?: ILeaf): ILeaf;
1282
- getByClassName(name: string, branch?: ILeaf): ILeaf[];
1283
- getByTagName(name: string, branch?: ILeaf): ILeaf[];
1284
- destroy(): void;
1285
- }
1286
-
1287
- type IExportImageType = 'jpg' | 'png' | 'webp';
1288
- type IExportFileType = IExportImageType | 'svg' | 'pdf' | 'json';
1289
1498
 
1290
1499
  interface ILeaferImageConfig {
1291
1500
  url: string;
@@ -1298,6 +1507,13 @@ interface ILeaferImageOnLoaded {
1298
1507
  interface ILeaferImageOnError {
1299
1508
  (error?: string | IObject, image?: ILeaferImage): any;
1300
1509
  }
1510
+ interface ILeaferImageCacheCanvas {
1511
+ data: IObject;
1512
+ params: IArguments;
1513
+ }
1514
+ interface ILeaferImagePatternPaint {
1515
+ transform: IMatrixData;
1516
+ }
1301
1517
  interface ILeaferImage {
1302
1518
  readonly innerId: InnerId;
1303
1519
  readonly url: string;
@@ -1305,6 +1521,7 @@ interface ILeaferImage {
1305
1521
  width: number;
1306
1522
  height: number;
1307
1523
  isSVG: boolean;
1524
+ hasOpacityPixel: boolean;
1308
1525
  readonly completed: boolean;
1309
1526
  ready: boolean;
1310
1527
  error: IObject;
@@ -1314,6 +1531,7 @@ interface ILeaferImage {
1314
1531
  load(onSuccess?: ILeaferImageOnLoaded, onError?: ILeaferImageOnError): number;
1315
1532
  unload(index: number, stopEvent?: boolean): void;
1316
1533
  getCanvas(width: number, height: number, opacity?: number, _filters?: IObject): unknown;
1534
+ getPattern(canvas: any, repeat: string | null, transform?: IMatrixData, paint?: IObject): ICanvasPattern;
1317
1535
  destroy(): void;
1318
1536
  }
1319
1537
 
@@ -1331,9 +1549,9 @@ interface IUIEvent extends IEvent {
1331
1549
  buttons?: number;
1332
1550
  path?: ILeafList;
1333
1551
  throughPath?: ILeafList;
1334
- origin?: IObject;
1335
- getInner?(target?: ILeaf): IPointData;
1336
- getLocal?(target?: ILeaf): IPointData;
1552
+ getPage?(): IPointData;
1553
+ getInner?(relative?: ILeaf): IPointData;
1554
+ getLocal?(relative?: ILeaf): IPointData;
1337
1555
  }
1338
1556
  interface IPointerEvent extends IUIEvent {
1339
1557
  width?: number;
@@ -1344,6 +1562,7 @@ interface IPointerEvent extends IUIEvent {
1344
1562
  tiltX?: number;
1345
1563
  tiltY?: number;
1346
1564
  twist?: number;
1565
+ isCancel?: boolean;
1347
1566
  }
1348
1567
  type PointerType = 'mouse' | 'pen' | 'touch';
1349
1568
  interface IDragEvent extends IPointerEvent {
@@ -1351,10 +1570,12 @@ interface IDragEvent extends IPointerEvent {
1351
1570
  moveY: number;
1352
1571
  totalX?: number;
1353
1572
  totalY?: number;
1354
- getInnerMove?(target?: ILeaf): IPointData;
1355
- getLocalMove?(target?: ILeaf): IPointData;
1356
- getInnerTotal?(target?: ILeaf): IPointData;
1357
- getLocalTotal?(target?: ILeaf): IPointData;
1573
+ getPageMove?(total?: boolean): IPointData;
1574
+ getInnerMove?(relative?: ILeaf): IPointData;
1575
+ getLocalMove?(relative?: ILeaf): IPointData;
1576
+ getPageTotal?(): IPointData;
1577
+ getInnerTotal?(relative?: ILeaf): IPointData;
1578
+ getLocalTotal?(relative?: ILeaf): IPointData;
1358
1579
  }
1359
1580
  interface IDropEvent extends IPointerEvent {
1360
1581
  list: ILeafList;
@@ -1387,6 +1608,8 @@ interface IInteraction extends IControl {
1387
1608
  selector: ISelector;
1388
1609
  running: boolean;
1389
1610
  readonly dragging: boolean;
1611
+ readonly isDragEmpty: boolean;
1612
+ readonly isHoldRightKey: boolean;
1390
1613
  readonly moveMode: boolean;
1391
1614
  config: IInteractionConfig;
1392
1615
  cursor: ICursorType | ICursorType[];
@@ -1395,6 +1618,7 @@ interface IInteraction extends IControl {
1395
1618
  downData: IPointerEvent;
1396
1619
  hoverData: IPointerEvent;
1397
1620
  downTime: number;
1621
+ focusData: ILeaf;
1398
1622
  receive(event: any): void;
1399
1623
  pointerDown(data?: IPointerEvent, defaultPath?: boolean): void;
1400
1624
  pointerMove(data?: IPointerEvent): void;
@@ -1407,10 +1631,19 @@ interface IInteraction extends IControl {
1407
1631
  rotate(data: IRotateEvent): void;
1408
1632
  keyDown(data: IKeyEvent): void;
1409
1633
  keyUp(data: IKeyEvent): void;
1410
- findPath(data: IPointerEvent, options?: ISelectPathOptions): ILeafList;
1411
- updateDownData(data?: IPointerEvent): void;
1634
+ findPath(data: IPointerEvent, options?: IPickOptions): ILeafList;
1635
+ isRootPath(data: IPointerEvent): boolean;
1636
+ isTreePath(data: IPointerEvent): boolean;
1637
+ canMove(data: IPointerEvent): boolean;
1638
+ isDrag(leaf: ILeaf): boolean;
1639
+ isPress(leaf: ILeaf): boolean;
1640
+ isHover(leaf: ILeaf): boolean;
1641
+ isFocus(leaf: ILeaf): boolean;
1642
+ cancelHover(): void;
1643
+ updateDownData(data?: IPointerEvent, options?: IPickOptions, merge?: boolean): void;
1412
1644
  updateHoverData(data: IPointerEvent): void;
1413
1645
  updateCursor(hoverData?: IPointerEvent): void;
1646
+ setCursor(cursor: ICursorType | ICursorType[]): void;
1414
1647
  emit(type: string, data: IUIEvent, path?: ILeafList, excludePath?: ILeafList): void;
1415
1648
  }
1416
1649
  interface IInteractionCanvas extends ILeaferCanvas {
@@ -1418,22 +1651,30 @@ interface IInteractionCanvas extends ILeaferCanvas {
1418
1651
  interface IInteractionConfig {
1419
1652
  wheel?: IWheelConfig;
1420
1653
  pointer?: IPointerConfig;
1654
+ cursor?: ICursorConfig;
1421
1655
  zoom?: IZoomConfig;
1422
1656
  move?: IMoveConfig;
1423
1657
  eventer?: IObject;
1424
1658
  }
1425
1659
  interface IZoomConfig {
1660
+ disabled?: boolean;
1426
1661
  min?: number;
1427
1662
  max?: number;
1428
1663
  }
1429
1664
  interface IMoveConfig {
1665
+ disabled?: boolean;
1430
1666
  holdSpaceKey?: boolean;
1667
+ holdMiddleKey?: boolean;
1668
+ holdRightKey?: boolean;
1669
+ scroll?: boolean | 'limit';
1670
+ drag?: boolean;
1671
+ dragAnimate?: boolean;
1431
1672
  dragEmpty?: boolean;
1432
1673
  dragOut?: boolean;
1433
1674
  autoDistance?: number;
1434
1675
  }
1435
1676
  interface IWheelConfig {
1436
- zoomMode?: boolean;
1677
+ zoomMode?: boolean | 'mouse';
1437
1678
  zoomSpeed?: number;
1438
1679
  moveSpeed?: number;
1439
1680
  rotateSpeed?: number;
@@ -1449,48 +1690,43 @@ interface IPointerConfig {
1449
1690
  tapTime?: number;
1450
1691
  longPressTime?: number;
1451
1692
  transformTime?: number;
1693
+ hover?: boolean;
1452
1694
  dragHover?: boolean;
1453
1695
  dragDistance?: number;
1454
1696
  swipeDistance?: number;
1455
1697
  ignoreMove?: boolean;
1456
1698
  preventDefault?: boolean;
1699
+ preventDefaultMenu?: boolean;
1700
+ }
1701
+ interface ICursorConfig {
1702
+ stop?: boolean;
1457
1703
  }
1458
1704
 
1459
1705
  interface IHitCanvasManager extends ICanvasManager {
1706
+ maxTotal: number;
1460
1707
  getPathType(leaf: ILeaf): IHitCanvas;
1461
- getImageType(leaf: ILeaf, size: IScreenSizeData): IHitCanvas;
1462
- }
1463
-
1464
- interface IBranch extends ILeaf {
1465
- children: ILeaf[];
1466
- __renderBranch?(canvas: ILeaferCanvas, options: IRenderOptions): void;
1467
- addMany(...children: ILeaf[]): void;
1468
- removeAll(destroy?: boolean): void;
1708
+ getPixelType(leaf: ILeaf, config: ILeaferCanvasConfig): IHitCanvas;
1469
1709
  }
1470
1710
 
1471
1711
  interface IZoomView extends IBranch {
1472
- zoomLayer?: ILeaf;
1473
- moveLayer?: ILeaf;
1474
- transformData?: ITransformEventData;
1475
- setZoomLayer(zoomLayer: ILeaf, moveLayer?: ILeaf): void;
1476
1712
  }
1477
1713
 
1478
- type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'user';
1714
+ type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'app' | 'website' | 'game' | 'player' | 'chart';
1479
1715
  interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
1480
1716
  start?: boolean;
1481
1717
  type?: ILeaferType;
1482
1718
  realCanvas?: boolean;
1719
+ lazySpeard?: IFourNumber;
1483
1720
  }
1484
- interface ILeafer extends IZoomView, IControl {
1485
- readonly isApp: boolean;
1486
- readonly app: ILeafer;
1487
- parent?: IApp;
1721
+ interface ILeaferAttrData {
1488
1722
  running: boolean;
1489
1723
  created: boolean;
1490
1724
  ready: boolean;
1491
1725
  viewReady: boolean;
1726
+ imageReady: boolean;
1492
1727
  viewCompleted: boolean;
1493
- pixelRatio: number;
1728
+ layoutLocked: boolean;
1729
+ transforming: boolean;
1494
1730
  view: unknown;
1495
1731
  canvas: ILeaferCanvas;
1496
1732
  renderer: IRenderer;
@@ -1501,25 +1737,41 @@ interface ILeafer extends IZoomView, IControl {
1501
1737
  canvasManager: ICanvasManager;
1502
1738
  hitCanvasManager?: IHitCanvasManager;
1503
1739
  autoLayout?: IAutoBounds;
1740
+ lazyBounds: IBounds;
1504
1741
  config: ILeaferConfig;
1742
+ readonly cursorPoint: IPointData;
1743
+ leafs: number;
1505
1744
  __eventIds: IEventListenerId[];
1506
1745
  __nextRenderWait: IFunction[];
1507
- init(userConfig?: ILeaferConfig, parentApp?: IApp): void;
1508
- setZoomLayer(zoomLayer: ILeaf, moveLayer?: ILeaf): void;
1746
+ init(userConfig?: ILeaferConfig, parentApp?: IAppBase): void;
1747
+ start(): void;
1748
+ stop(): void;
1749
+ unlockLayout(): void;
1750
+ lockLayout(): void;
1509
1751
  forceFullRender(): void;
1510
- updateCursor(): void;
1752
+ forceRender(bounds?: IBoundsData): void;
1753
+ updateCursor(cursor?: ICursorType): void;
1511
1754
  resize(size: IScreenSizeData): void;
1512
- waitReady(item: IFunction): void;
1513
- waitViewReady(item: IFunction): void;
1514
- waitViewCompleted(item: IFunction): void;
1755
+ waitReady(item: IFunction, bind?: IObject): void;
1756
+ waitViewReady(item: IFunction, bind?: IObject): void;
1757
+ waitViewCompleted(item: IFunction, bind?: IObject): void;
1758
+ zoom(zoomType: IZoomType, padding?: IFourNumber, fixedScale?: boolean): IBoundsData;
1759
+ getValidMove(moveX: number, moveY: number): IPointData;
1760
+ getValidScale(changeScale: number): number;
1761
+ }
1762
+ type IZoomType = 'in' | 'out' | 'fit' | 'fit-width' | 'fit-height' | number | ILeaf | ILeaf[] | IBoundsData;
1763
+ interface ILeaferBase extends IZoomView, IControl, ILeaferAttrData {
1764
+ readonly isApp: boolean;
1765
+ readonly app: ILeaferBase;
1766
+ parent?: IAppBase;
1515
1767
  }
1516
1768
  interface ILeaferTypeCreator {
1517
1769
  list: ILeaferTypeList;
1518
1770
  register(name: string, fn: ILeaferTypeFunction): void;
1519
- run(name: string, leafer: ILeafer): void;
1771
+ run(name: string, leafer: ILeaferBase): void;
1520
1772
  }
1521
1773
  interface ILeaferTypeFunction {
1522
- (leafer: ILeafer): void;
1774
+ (leafer: ILeaferBase): void;
1523
1775
  }
1524
1776
  interface ILeaferTypeList {
1525
1777
  [key: string]: ILeaferTypeFunction;
@@ -1528,19 +1780,21 @@ interface ICreator {
1528
1780
  image?(options?: ILeaferImageConfig): ILeaferImage;
1529
1781
  canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas;
1530
1782
  hitCanvas?(options?: IHitCanvasConfig, manager?: ICanvasManager): IHitCanvas;
1783
+ hitCanvasManager?(): IHitCanvasManager;
1531
1784
  watcher?(target: ILeaf, options?: IWatcherConfig): IWatcher;
1532
1785
  layouter?(target: ILeaf, options?: ILayouterConfig): ILayouter;
1533
1786
  renderer?(target: ILeaf, canvas: ILeaferCanvas, options?: IRendererConfig): IRenderer;
1534
1787
  selector?(target: ILeaf, options?: ISelectorConfig): ISelector;
1535
1788
  interaction?(target: ILeaf, canvas: IInteractionCanvas, selector: ISelector, options?: IInteractionConfig): IInteraction;
1789
+ editor?(options?: IObject): ILeaf;
1536
1790
  }
1537
1791
  interface IUICreator {
1538
1792
  register(UI: IObject): void;
1539
1793
  get(tag: string, data: IObject): IObject;
1540
1794
  }
1541
1795
 
1542
- interface IApp extends ILeafer {
1543
- children: ILeafer[];
1796
+ interface IAppBase extends ILeaferBase {
1797
+ children: ILeaferBase[];
1544
1798
  realCanvas: boolean;
1545
1799
  }
1546
1800
 
@@ -1597,18 +1851,51 @@ interface IImageManager {
1597
1851
  recycledList: ILeaferImage[];
1598
1852
  tasker: ITaskProcessor;
1599
1853
  patternTasker: ITaskProcessor;
1854
+ patternLocked?: boolean;
1600
1855
  readonly isComplete: boolean;
1601
1856
  get(config: ILeaferImageConfig): ILeaferImage;
1602
1857
  recycle(image: ILeaferImage): void;
1603
1858
  clearRecycled(): void;
1859
+ hasOpacityPixel(config: ILeaferImageConfig): boolean;
1860
+ isFormat(format: IExportFileType, config: ILeaferImageConfig): boolean;
1604
1861
  destroy(): void;
1605
1862
  }
1606
1863
 
1864
+ type ICanvasType = 'skia' | 'napi' | 'canvas' | 'wx';
1865
+ interface ISkiaCanvas {
1866
+ toBuffer(format: IExportFileType, config: ISkiaCanvasExportConfig): Promise<any>;
1867
+ toBufferSync(format: IExportFileType, config: ISkiaCanvasExportConfig): any;
1868
+ toDataURL(format: IExportImageType, config: ISkiaCanvasExportConfig): Promise<string>;
1869
+ toDataURLSync(format: IExportImageType, config: ISkiaCanvasExportConfig): string;
1870
+ saveAs(filename: string, config: ISkiaCanvasExportConfig): Promise<void>;
1871
+ saveAsSync(filename: string, config: ISkiaCanvasExportConfig): void;
1872
+ }
1873
+ interface ISkiaCanvasExportConfig {
1874
+ page?: number;
1875
+ matte?: string;
1876
+ density?: number;
1877
+ quality?: number;
1878
+ outline?: boolean;
1879
+ }
1880
+ interface ISkiaNAPICanvas {
1881
+ encodeSync(format: 'webp' | 'jpeg', quality?: number): any;
1882
+ encodeSync(format: 'png'): any;
1883
+ encode(format: 'webp' | 'jpeg' | string, quality?: number): Promise<any>;
1884
+ encode(format: 'png'): Promise<any>;
1885
+ toBuffer(mime: 'image/png'): any;
1886
+ toBuffer(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): any;
1887
+ toDataURL(mime?: 'image/png'): string;
1888
+ toDataURL(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): string;
1889
+ toDataURLAsync(mime?: 'image/png'): Promise<string>;
1890
+ toDataURLAsync(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): Promise<string>;
1891
+ }
1892
+
1607
1893
  interface IPlatform {
1608
1894
  name?: 'web' | 'node' | 'miniapp';
1609
1895
  os?: 'Mac' | 'Windows' | 'Linux';
1610
1896
  requestRender?(render: IFunction): void;
1611
1897
  canvas?: ILeaferCanvas;
1898
+ canvasType?: ICanvasType;
1612
1899
  isWorker?: boolean;
1613
1900
  isMobile?: boolean;
1614
1901
  devicePixelRatio?: number;
@@ -1618,17 +1905,30 @@ interface IPlatform {
1618
1905
  fullImageShadow?: boolean;
1619
1906
  syncDomFont?: boolean;
1620
1907
  layout?(target: ILeaf): void;
1621
- realtimeLayout?: boolean;
1622
1908
  origin?: {
1623
1909
  createCanvas(width: number, height: number, format?: 'svg' | 'pdf'): any;
1624
1910
  canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string | Promise<string>;
1625
1911
  canvasToBolb(canvas: any, type?: IExportFileType, quality?: number): Promise<any>;
1626
1912
  canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>;
1913
+ download(url: string, filename: string): Promise<void>;
1627
1914
  loadImage(url: string): Promise<any>;
1628
1915
  noRepeat?: string;
1629
1916
  };
1917
+ roundRectPatch?: boolean;
1918
+ ellipseToCurve?: boolean;
1919
+ event?: {
1920
+ stopDefault(origin: IObject): void;
1921
+ stopNow(origin: IObject): void;
1922
+ stop(origin: IObject): void;
1923
+ };
1630
1924
  miniapp?: IMiniapp;
1631
- imageSuffix?: string;
1925
+ image: {
1926
+ hitCanvasSize: number;
1927
+ maxCacheSize: number;
1928
+ maxPatternSize: number;
1929
+ suffix: string;
1930
+ crossOrigin: string | false;
1931
+ };
1632
1932
  }
1633
1933
  interface IMiniappSelect extends IObject {
1634
1934
  }
@@ -1649,24 +1949,18 @@ interface IPlugin extends IObject {
1649
1949
  importVersion: string;
1650
1950
  import: string[];
1651
1951
  run(LeaferUI: IObject, config: IObject): void;
1652
- onLeafer?(leafer: ILeafer): void;
1952
+ onLeafer?(leafer: ILeaferBase): void;
1653
1953
  }
1654
1954
 
1655
- type ICanvasType = 'skia' | 'canvas' | 'wx';
1656
- interface ISkiaCanvas {
1657
- toBuffer(format: IExportFileType, config: ISkiaCanvasExportConfig): Promise<any>;
1658
- toBufferSync(format: IExportFileType, config: ISkiaCanvasExportConfig): any;
1659
- toDataURL(format: IExportImageType, config: ISkiaCanvasExportConfig): Promise<string>;
1660
- toDataURLSync(format: IExportImageType, config: ISkiaCanvasExportConfig): string;
1661
- saveAs(filename: string, config: ISkiaCanvasExportConfig): Promise<void>;
1662
- saveAsSync(filename: string, config: ISkiaCanvasExportConfig): void;
1955
+ interface ICursorTypeMap {
1956
+ [name: string]: ICursorType | ICursorType[];
1663
1957
  }
1664
- interface ISkiaCanvasExportConfig {
1665
- page?: number;
1666
- matte?: string;
1667
- density?: number;
1668
- quality?: number;
1669
- outline?: boolean;
1958
+ interface ICursorRotate {
1959
+ rotation?: number;
1960
+ data?: string;
1961
+ }
1962
+ interface ICursorRotateMap {
1963
+ [name: string]: ICursorRotate;
1670
1964
  }
1671
1965
 
1672
- export type { ACommandData, ArcCommandData, ArcToCommandData, CCommandData, CanvasPathCommand, EllipseCommandData, HCommandData, IAnimateEvent, IApp, IAround, IAutoBounds, IAutoBoundsData, IBlendMode, IBlob, IBlobFunction, IBooleanMap, IBounds, IBoundsData, IBoundsDataHandle, IBranch, IBranchRender, IBranchRenderModule, ICachedLeaf, ICanvasAttr, ICanvasContext2D, ICanvasManager, ICanvasStrokeOptions, ICanvasType, IChildEvent, IControl, ICreator, ICursorType, ICursorTypeMap, IDataProcessor, IDataTypeHandle, IDragEvent, IDropEvent, IEvent, IEventListener, IEventListenerId, IEventListenerItem, IEventListenerMap, IEventListenerOptions, IEventTarget, IEventer, IExportFileType, IExportImageType, IFunction, IHitCanvas, IHitCanvasConfig, IHitCanvasManager, IHitType, IImageEvent, IImageManager, IInteraction, IInteractionCanvas, IInteractionConfig, IKeepTouchData, IKeyEvent, ILayoutBlockData, ILayoutBoundsType, ILayoutChangedData, ILayoutEvent, ILayoutLocationType, ILayouter, ILayouterConfig, ILeaf, ILeafArrayMap, ILeafAttrData, ILeafBounds, ILeafBoundsModule, ILeafComputedData, ILeafData, ILeafDataProxy, ILeafDataProxyModule, ILeafEventer, ILeafEventerModule, ILeafHit, ILeafHitModule, ILeafInputData, ILeafLayout, ILeafLevelList, ILeafList, ILeafListItemCallback, ILeafMap, ILeafMask, ILeafMaskModule, ILeafMatrix, ILeafMatrixModule, ILeafRender, ILeafRenderModule, ILeafer, ILeaferCanvas, ILeaferCanvasConfig, ILeaferConfig, ILeaferEvent, ILeaferImage, ILeaferImageConfig, ILeaferImageOnError, ILeaferImageOnLoaded, ILeaferType, ILeaferTypeCreator, ILeaferTypeFunction, ILeaferTypeList, IMatrix, IMatrixData, IMatrixDecompositionAttr, IMatrixDecompositionData, IMatrixWithBoundsData, IMatrixWithLayoutData, IMiniapp, IMiniappSelect, IMiniappSizeView, IMoveEvent, IMultiTouchData, INumberMap, IObject, IOffsetBoundsData, IPartLayoutConfig, IPath2D, IPathCommandData, IPathCreator, IPathDrawer, IPathString, IPlatform, IPlugin, IPoint, IPointData, IPointerConfig, IPointerEvent, IPropertyEvent, IRadiusPointData, IRenderEvent, IRenderOptions, IRenderer, IRendererConfig, IResizeEvent, IResizeEventListener, IResizeType, IRotateEvent, IScreenSizeData, ISelectPathOptions, ISelectPathResult, ISelector, ISelectorConfig, ISize, ISizeData, ISkiaCanvas, ISkiaCanvasExportConfig, IStringMap, ISwipeEvent, ITaskItem, ITaskOptions, ITaskProcessor, ITaskProcessorConfig, ITextMetrics, ITimer, ITransformEvent, ITransformEventData, ITwoPointBounds, ITwoPointBoundsData, IUICreator, IUIEvent, IUpdateEvent, IWatchEvent, IWatchEventData, IWatcher, IWatcherConfig, IWheelConfig, IWindingRule, IZoomEvent, IZoomView, InnerId, LCommandData, MCommandData, PointerType, QCommandData, RectCommandData, RoundRectCommandData, SCommandData, TCommandData, TransformMode, VCommandData, ZCommandData, __Boolean, __Number, __Object, __String, __Value };
1966
+ export type { ACommandData, ArcCommandData, ArcToCommandData, CCommandData, CanvasPathCommand, EllipseCommandData, HCommandData, IAnimateEvent, IAnswer, IAppBase, IAround, IAttrDecorator, IAutoBounds, IAutoBoundsData, IBlendMode, IBlob, IBlobFunction, IBoolean, IBooleanMap, IBounds, IBoundsData, IBoundsDataFn, IBoundsType, IBranch, IBranchRender, IBranchRenderModule, ICachedLeaf, ICanvasAttr, ICanvasCacheOptions, ICanvasContext2D, ICanvasContext2DSettings, ICanvasManager, ICanvasPattern, ICanvasStrokeOptions, ICanvasType, IChildEvent, IControl, ICreator, ICursorRotate, ICursorRotateMap, ICursorType, ICursorTypeMap, IDataProcessor, IDataTypeHandle, IDragEvent, IDropEvent, IEditSize, IEvent, IEventListener, IEventListenerId, IEventListenerItem, IEventListenerMap, IEventListenerOptions, IEventTarget, IEventer, IExportFileType, IExportImageType, IExportOnCanvasFunction, IExportOptions, IExportResult, IExportResultFunction, IFindMethod, IFourNumber, IFunction, IHitCanvas, IHitCanvasConfig, IHitCanvasManager, IHitType, IImageCursor, IImageEvent, IImageManager, IInteraction, IInteractionCanvas, IInteractionConfig, 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, INumberMap, IObject, IOffsetBoundsData, IPartLayoutConfig, IPath2D, IPathCommandData, IPathCreator, IPathDrawer, IPathString, IPickOptions, IPickResult, IPlatform, IPlugin, IPoint, IPointData, IPointerConfig, IPointerEvent, IPropertyEvent, IRadiusPointData, IRenderEvent, IRenderOptions, IRenderer, IRendererConfig, IResizeEvent, IResizeEventListener, IRotateEvent, IScaleData, IScaleRotationData, IScreenSizeData, ISelector, ISelectorConfig, ISelectorProxy, ISize, ISizeData, ISkewData, ISkiaCanvas, ISkiaCanvasExportConfig, ISkiaNAPICanvas, IStateStyleType, IString, IStringMap, ISwipeEvent, ITaskItem, ITaskOptions, ITaskProcessor, ITaskProcessorConfig, ITextMetrics, ITimer, ITwoPointBoundsData, IUICreator, IUIEvent, IUpdateEvent, IValue, IWatchEvent, IWatchEventData, IWatcher, IWatcherConfig, IWheelConfig, IWindingRule, IZoomEvent, IZoomType, IZoomView, InnerId, LCommandData, MCommandData, PointerType, QCommandData, RectCommandData, RoundRectCommandData, SCommandData, TCommandData, VCommandData, ZCommandData };