@leafer/interface 1.0.0-rc.1 → 1.0.0-rc.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer/interface",
3
- "version": "1.0.0-rc.1",
3
+ "version": "1.0.0-rc.11",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
package/src/app/IApp.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { ILeafer } from './ILeafer'
1
+ import { ILeaferBase } from './ILeafer'
2
2
 
3
- export interface IApp extends ILeafer {
4
- children: ILeafer[]
3
+ export interface IAppBase extends ILeaferBase {
4
+ children: ILeaferBase[]
5
5
  realCanvas: boolean
6
6
  }
@@ -1,40 +1,39 @@
1
- import { ILeaf } from '../display/ILeaf'
1
+ import { ILeaf, ICursorType } from '../display/ILeaf'
2
2
  import { IRenderer, IRendererConfig } from '../renderer/IRenderer'
3
3
  import { IHitCanvas, ILeaferCanvas, ILeaferCanvasConfig, IHitCanvasConfig } from '../canvas/ILeaferCanvas'
4
4
  import { ILayouter, ILayouterConfig } from '../layouter/ILayouter'
5
5
  import { ISelector, ISelectorConfig } from '../selector/ISelector'
6
6
  import { IInteraction, IInteractionCanvas, IInteractionConfig } from '../interaction/IInteraction'
7
7
  import { IWatcher, IWatcherConfig } from '../watcher/IWatcher'
8
- import { IAutoBounds, IScreenSizeData } from '../math/IMath'
8
+ import { IAutoBounds, IBoundsData, IPointData, IScreenSizeData } from '../math/IMath'
9
9
  import { ICanvasManager } from '../canvas/ICanvasManager'
10
10
  import { IHitCanvasManager } from '../canvas/IHitCanvasManager'
11
11
  import { IEventListenerId } from '../event/IEventer'
12
12
  import { IObject } from '../data/IData'
13
13
  import { IZoomView } from '../display/IView'
14
- import { IApp } from './IApp'
14
+ import { IAppBase } from './IApp'
15
15
  import { ILeaferImage, ILeaferImageConfig } from '../image/ILeaferImage'
16
16
  import { IControl } from '../control/IControl'
17
17
  import { IFunction } from '../function/IFunction'
18
18
 
19
19
 
20
- export type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'user'
20
+ export type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'app' | 'game' | 'player' | 'chart'
21
21
  export interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
22
22
  start?: boolean
23
23
  type?: ILeaferType
24
24
  realCanvas?: boolean
25
25
  }
26
26
 
27
- export interface ILeafer extends IZoomView, IControl {
28
-
29
- readonly isApp: boolean
30
- readonly app: ILeafer
31
- parent?: IApp
32
-
27
+ export interface ILeaferAttrData {
33
28
  running: boolean
34
29
  created: boolean
35
30
  ready: boolean
36
31
  viewReady: boolean
32
+ imageReady: boolean
37
33
  viewCompleted: boolean
34
+ layoutLocked: boolean
35
+
36
+ transforming: boolean
38
37
 
39
38
  pixelRatio: number
40
39
 
@@ -56,13 +55,24 @@ export interface ILeafer extends IZoomView, IControl {
56
55
 
57
56
  config: ILeaferConfig
58
57
 
58
+ readonly cursorPoint: IPointData
59
+ leafs: number
60
+
59
61
  __eventIds: IEventListenerId[]
60
62
  __nextRenderWait: IFunction[]
61
63
 
62
- init(userConfig?: ILeaferConfig, parentApp?: IApp): void
63
- setZoomLayer(zoomLayer: ILeaf, moveLayer?: ILeaf): void
64
+ init(userConfig?: ILeaferConfig, parentApp?: IAppBase): void
65
+
66
+ start(): void
67
+ stop(): void
68
+
69
+ unlockLayout(): void
70
+ lockLayout(): void
71
+
72
+ setZoomLayer(zoomLayer: ILeaf): void
64
73
  forceFullRender(): void
65
- updateCursor(): void
74
+ forceRender(bounds?: IBoundsData): void
75
+ updateCursor(cursor?: ICursorType): void
66
76
  resize(size: IScreenSizeData): void
67
77
 
68
78
  waitReady(item: IFunction): void
@@ -70,14 +80,20 @@ export interface ILeafer extends IZoomView, IControl {
70
80
  waitViewCompleted(item: IFunction): void
71
81
  }
72
82
 
83
+ export interface ILeaferBase extends IZoomView, IControl, ILeaferAttrData {
84
+ readonly isApp: boolean
85
+ readonly app: ILeaferBase
86
+ parent?: IAppBase
87
+ }
88
+
73
89
  export interface ILeaferTypeCreator {
74
90
  list: ILeaferTypeList
75
91
  register(name: string, fn: ILeaferTypeFunction): void
76
- run(name: string, leafer: ILeafer): void
92
+ run(name: string, leafer: ILeaferBase): void
77
93
  }
78
94
 
79
95
  export interface ILeaferTypeFunction {
80
- (leafer: ILeafer): void
96
+ (leafer: ILeaferBase): void
81
97
  }
82
98
 
83
99
  export interface ILeaferTypeList {
@@ -88,6 +104,7 @@ export interface ICreator {
88
104
  image?(options?: ILeaferImageConfig): ILeaferImage
89
105
  canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas
90
106
  hitCanvas?(options?: IHitCanvasConfig, manager?: ICanvasManager): IHitCanvas
107
+ hitCanvasManager?(): IHitCanvasManager
91
108
 
92
109
  watcher?(target: ILeaf, options?: IWatcherConfig): IWatcher
93
110
  layouter?(target: ILeaf, options?: ILayouterConfig): ILayouter
@@ -95,6 +112,8 @@ export interface ICreator {
95
112
  selector?(target: ILeaf, options?: ISelectorConfig): ISelector
96
113
 
97
114
  interaction?(target: ILeaf, canvas: IInteractionCanvas, selector: ISelector, options?: IInteractionConfig): IInteraction
115
+
116
+ editor?(options?: IObject): ILeaf
98
117
  }
99
118
 
100
119
  export interface IUICreator {
@@ -111,6 +111,8 @@ export interface CanvasPattern {
111
111
  setTransform(transform?: DOMMatrix2DInit): void
112
112
  }
113
113
 
114
+ export type ICanvasPattern = CanvasPattern
115
+
114
116
  declare var CanvasPattern: {
115
117
  prototype: CanvasPattern
116
118
  new(): CanvasPattern
@@ -5,7 +5,8 @@ import { IResizeEventListener } from '../event/IEvent'
5
5
  import { IPathDrawer } from '../path/IPathDrawer'
6
6
  import { InnerId } from '../event/IEventer'
7
7
  import { ICanvasManager } from './ICanvasManager'
8
- import { ICursorType } from '../display/ILeaf'
8
+ import { IExportFileType } from '../file/IFileType'
9
+ import { IExportOptions } from '../file/IExport'
9
10
 
10
11
  export interface ILeaferCanvasConfig extends IAutoBoundsData {
11
12
  view?: string | IObject
@@ -116,7 +117,7 @@ interface ICanvasMethod {
116
117
  setWorldBlur(blur: number): void
117
118
 
118
119
  copyWorld(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void
119
- copyWorldByReset(canvas: ILeaferCanvas, from?: IBoundsData, to?: IBoundsData, blendMode?: string): void
120
+ copyWorldByReset(canvas: ILeaferCanvas, from?: IBoundsData, to?: IBoundsData, blendMode?: string, onlyResetTransform?: boolean): void
120
121
  copyWorldToInner(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toInnerBounds: IBoundsData, blendMode?: string): void
121
122
 
122
123
  useMask(maskCanvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData): void
@@ -130,6 +131,7 @@ interface ICanvasMethod {
130
131
  clear(): void
131
132
  }
132
133
 
134
+ export type ILeaferCanvasView = any
133
135
  export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
134
136
 
135
137
  readonly innerId: InnerId
@@ -155,7 +157,7 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
155
157
 
156
158
  autoLayout: boolean
157
159
 
158
- view: any
160
+ view: ILeaferCanvasView
159
161
  parentView: any
160
162
 
161
163
  unreal?: boolean
@@ -168,6 +170,7 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
168
170
 
169
171
  init(): void
170
172
 
173
+ export(filename: IExportFileType | string, options?: IExportOptions | number | boolean): string | Promise<any>
171
174
  toBlob(type?: string, quality?: number): Promise<IBlob>
172
175
  toDataURL(type?: string, quality?: number): string | Promise<string>
173
176
  saveAs(filename: string, quality?: number): Promise<boolean>
@@ -179,13 +182,10 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
179
182
  updateViewSize(): void
180
183
  updateClientBounds(): void
181
184
 
182
- setCursor(cursor: ICursorType | ICursorType[]): void
183
-
184
185
  // other
185
186
  isSameSize(options: ILeaferCanvasConfig): boolean
186
- getSameCanvas(useSameWorldTransform?: boolean): ILeaferCanvas
187
- getBiggerCanvas(addWidth: number, addHeight: number): ILeaferCanvas
188
- recycle(): void
187
+ getSameCanvas(useSameWorldTransform?: boolean, useSameSmooth?: boolean): ILeaferCanvas
188
+ recycle(clearBounds?: IBoundsData): void
189
189
 
190
190
  updateRender(): void
191
191
  unrealCanvas(): void
@@ -1,7 +1,8 @@
1
1
  import { IExportFileType, IExportImageType } from '../file/IFileType'
2
2
 
3
- export type ICanvasType = 'skia' | 'canvas' | 'wx'
3
+ export type ICanvasType = 'skia' | 'napi' | 'canvas' | 'wx'
4
4
 
5
+ // skia
5
6
  export interface ISkiaCanvas {
6
7
  toBuffer(format: IExportFileType, config: ISkiaCanvasExportConfig): Promise<any>
7
8
  toBufferSync(format: IExportFileType, config: ISkiaCanvasExportConfig): any
@@ -17,4 +18,22 @@ export interface ISkiaCanvasExportConfig {
17
18
  density?: number,
18
19
  quality?: number,
19
20
  outline?: boolean
21
+ }
22
+
23
+ // skia-napi
24
+ export interface ISkiaNAPICanvas {
25
+ encodeSync(format: 'webp' | 'jpeg', quality?: number): any
26
+ encodeSync(format: 'png'): any
27
+
28
+ encode(format: 'webp' | 'jpeg' | string, quality?: number): Promise<any>
29
+ encode(format: 'png'): Promise<any>
30
+
31
+ toBuffer(mime: 'image/png'): any
32
+ toBuffer(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): any
33
+
34
+ toDataURL(mime?: 'image/png'): string
35
+ toDataURL(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): string
36
+
37
+ toDataURLAsync(mime?: 'image/png'): Promise<string>
38
+ toDataURLAsync(mime: 'image/jpeg' | 'image/webp' | string, quality?: number): Promise<string>
20
39
  }
package/src/data/IData.ts CHANGED
@@ -1,8 +1,7 @@
1
- export type __Number = number // number | string will convert to number
2
- export type __Boolean = boolean // boolean | string will convert to boolean
3
- export type __String = string // string | other will convert to string
4
- export type __Object = IObject // will convert to object
5
- export type __Value = __Number | __Boolean | __String | __Object //
1
+ export type INumber = number // number | string will convert to number
2
+ export type IBoolean = boolean // boolean | string will convert to boolean
3
+ export type IString = string // string | other will convert to string
4
+ export type IValue = INumber | IBoolean | IString | IObject //
6
5
  export type ITimer = any
7
6
 
8
7
  export type IPathString = string
@@ -1,7 +1,7 @@
1
1
  import { ILeaf, ILeafComputedData } from '../display/ILeaf'
2
2
  import { IObject } from './IData'
3
3
 
4
- export interface IDataProcessor extends IObject {
4
+ export interface IDataProcessor {
5
5
  __leaf: ILeaf
6
6
  __input: IObject
7
7
  __middle: IObject
@@ -10,6 +10,7 @@ export interface IDataProcessor extends IObject {
10
10
  __checkSingle(): void
11
11
 
12
12
  __get(name: string): any
13
+ __getData(): IObject
13
14
 
14
15
  __setInput(name: string, value: any): void
15
16
  __getInput(name: string): any
@@ -22,6 +23,11 @@ export interface IDataProcessor extends IObject {
22
23
  destroy(): void
23
24
  }
24
25
 
26
+ export interface ILeafDataOptions {
27
+ attrs?: 'all' | string[]
28
+ children?: boolean
29
+ }
30
+
25
31
  export interface ILeafData extends IDataProcessor, ILeafComputedData {
26
32
 
27
33
  }
package/src/data/IList.ts CHANGED
@@ -18,13 +18,16 @@ export interface ILeafList {
18
18
  has(leaf: ILeaf): boolean
19
19
  indexAt(index: number): ILeaf
20
20
  indexOf(leaf: ILeaf): number
21
- unshift(leaf: ILeaf): void
22
- pushList(list: ILeaf[]): void
23
- push(leaf: ILeaf): void
24
- sort(reverse?: boolean): void
21
+
22
+ add(leaf: ILeaf): void
23
+ addAt(leaf: ILeaf, index: number): void
24
+ addList(list: ILeaf[]): void
25
25
  remove(leaf: ILeaf): void
26
+
26
27
  forEach(itemCallback: ILeafListItemCallback): void
28
+ sort(reverse?: boolean): void
27
29
  clone(): ILeafList
30
+ update(): void
28
31
  reset(): void
29
32
  destroy(): void
30
33
  }
@@ -37,8 +40,8 @@ export interface ILeafLevelList {
37
40
  has(leaf: ILeaf): boolean
38
41
  without(leaf: ILeaf): boolean
39
42
  sort(reverse?: boolean): void
40
- pushList(list: ILeaf[]): void
41
- push(leaf: ILeaf): void
43
+ addList(list: ILeaf[]): void
44
+ add(leaf: ILeaf): void
42
45
  forEach(itemCallback: ILeafListItemCallback): void
43
46
  reset(): void
44
47
  destroy(): void
@@ -1,10 +1,11 @@
1
+ import { ILeaf } from './ILeaf'
1
2
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
3
  import { IRenderOptions } from '../renderer/IRenderer'
3
- import { ILeaf } from './ILeaf'
4
4
 
5
5
  export interface IBranch extends ILeaf {
6
6
  children: ILeaf[]
7
7
  __renderBranch?(canvas: ILeaferCanvas, options: IRenderOptions): void
8
8
  addMany(...children: ILeaf[]): void
9
9
  removeAll(destroy?: boolean): void
10
+ clear(): void
10
11
  }