@leafer/interface 1.0.0-beta.7 → 1.0.0-beta.9

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-beta.7",
3
+ "version": "1.0.0-beta.9",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
@@ -6,5 +6,5 @@ export interface ICanvasManager {
6
6
  recycle(old: ILeaferCanvas): void
7
7
  clearRecycled(): void
8
8
  clear(): void
9
- destory(): void
9
+ destroy(): void
10
10
  }
@@ -6,5 +6,5 @@ import { IHitCanvas } from './ILeaferCanvas'
6
6
  export interface IHitCanvasManager extends ICanvasManager {
7
7
  getPathType(leaf: ILeaf): IHitCanvas
8
8
  getImageType(leaf: ILeaf, size: IScreenSizeData): IHitCanvas
9
- destory(): void
9
+ destroy(): void
10
10
  }
@@ -146,13 +146,14 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
146
146
  hittable?: boolean
147
147
 
148
148
  bounds: IBounds
149
+ clientBounds: IBoundsData
149
150
 
150
151
  config: ILeaferCanvasConfig
151
152
 
152
153
  autoLayout: boolean
153
154
 
154
- view: unknown
155
- parentView: unknown
155
+ view: any
156
+ parentView: any
156
157
 
157
158
  unreal?: boolean
158
159
 
@@ -175,6 +176,7 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
175
176
 
176
177
  resize(size: IScreenSizeData): void
177
178
  updateViewSize(): void
179
+ updateClientBounds(): void
178
180
 
179
181
  // other
180
182
  isSameSize(options: ILeaferCanvasConfig): boolean
@@ -187,7 +189,10 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
187
189
  }
188
190
 
189
191
 
190
- export type IHitCanvas = ILeaferCanvas
192
+ export interface IHitCanvas extends ILeaferCanvas {
193
+
194
+ }
195
+
191
196
 
192
197
  export interface IBlobFunction {
193
198
  (blob: IBlob | null): void
@@ -1,6 +1,6 @@
1
1
  import { IExportFileType, IExportImageType } from '../file/IFileType'
2
2
 
3
- export type ICanvasType = 'skia' | 'canvas'
3
+ export type ICanvasType = 'skia' | 'canvas' | 'wx'
4
4
 
5
5
  export interface ISkiaCanvas {
6
6
  toBuffer(format: IExportFileType, config: ISkiaCanvasExportConfig): Promise<any>
@@ -158,6 +158,8 @@ export interface ILeafComputedData {
158
158
  // other
159
159
  __childBranchNumber?: number // 存在子分支的个数
160
160
  __complex?: boolean // 外观是否复杂
161
+ __naturalWidth?: number
162
+ __naturalHeight?: number
161
163
  }
162
164
 
163
165
  export interface ILeaf extends ILeafMask, ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
@@ -2,7 +2,7 @@ import { IEventer } from './IEventer'
2
2
  import { IWatchEventData } from '../watcher/IWatcher'
3
3
  import { ILayoutBlockData } from '../layouter/ILayouter'
4
4
  import { ILeaf } from '../display/ILeaf'
5
- import { IScreenSizeData } from '../math/IMath'
5
+ import { IScreenSizeData, IPointData } from '../math/IMath'
6
6
 
7
7
  export interface IEvent {
8
8
  type?: string
@@ -95,4 +95,17 @@ export interface ITransformEvent extends IEvent, ITransformEventData {
95
95
  readonly scaleY: number
96
96
  readonly rotation: number
97
97
  }
98
- export type TransformMode = 'move' | 'zoom' | 'rotate'
98
+ export type TransformMode = 'move' | 'zoom' | 'rotate'
99
+
100
+
101
+ export interface IMultiTouchData {
102
+ move: IPointData,
103
+ scale: number,
104
+ angle: number,
105
+ center: IPointData
106
+ }
107
+
108
+ export interface IKeepTouchData {
109
+ from: IPointData
110
+ to: IPointData
111
+ }
@@ -2,6 +2,8 @@ import { IObject } from '../data/IData'
2
2
  import { ILeafList } from '../data/IList'
3
3
  import { IEvent } from './IEvent'
4
4
  import { ILeaferImage } from '../image/ILeaferImage'
5
+ import { ILeaf } from '../display/ILeaf'
6
+ import { IPointData } from '../math/IMath'
5
7
 
6
8
  export interface IUIEvent extends IEvent {
7
9
  x: number
@@ -22,6 +24,9 @@ export interface IUIEvent extends IEvent {
22
24
  throughPath?: ILeafList // 穿透path,不受层级影响,从上到下只要碰撞到区域就算,一般点击的时候
23
25
 
24
26
  origin?: IObject
27
+
28
+ getInner?(target?: ILeaf): IPointData
29
+ getLocal?(target?: ILeaf): IPointData
25
30
  }
26
31
 
27
32
 
@@ -42,6 +47,9 @@ export interface IDragEvent extends IPointerEvent {
42
47
  moveY: number
43
48
  totalX: number
44
49
  totalY: number
50
+
51
+ getInnerMove?(target?: ILeaf): IPointData
52
+ getLocalMove?(target?: ILeaf): IPointData
45
53
  }
46
54
 
47
55
  export interface IDropEvent extends IPointerEvent {
@@ -6,5 +6,5 @@ export interface IImageManager {
6
6
  tasker: ITaskProcessor
7
7
  get(config: ILeaferImageConfig): ILeaferImage
8
8
  load(image: ILeaferImage, onSuccess: IFunction, onError: IFunction): void
9
- destory(): void
9
+ destroy(): void
10
10
  }
package/src/index.ts CHANGED
@@ -30,7 +30,7 @@ export { ITaskProcessor, ITaskProcessorConfig } from './task/ITaskProcessor'
30
30
 
31
31
 
32
32
  export { IControl } from './control/IControl'
33
- export { IPlatform } from './platform/IPlatform'
33
+ export { IPlatform, IMiniapp, IMiniappSelect, IMiniappSizeView } from './platform/IPlatform'
34
34
  export { IPlugin } from './plugin/IPlugin'
35
35
 
36
36
 
@@ -44,7 +44,7 @@ export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnE
44
44
  export { IExportFileType, IExportImageType } from './file/IFileType'
45
45
 
46
46
  export { InnerId, IEventer, IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId } from './event/IEventer'
47
- export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IAnimateEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, ITransformEvent, ITransformEventData, TransformMode } from './event/IEvent'
47
+ export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IAnimateEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, ITransformEvent, ITransformEventData, TransformMode, IMultiTouchData, IKeepTouchData } from './event/IEvent'
48
48
  export { IUIEvent, IPointerEvent, PointerType, IDragEvent, IDropEvent, ISwipeEvent, IMoveEvent, IZoomEvent, IRotateEvent, IKeyEvent, IImageEvent } from './event/IUIEvent'
49
49
  export { IInteraction, IInteractionCanvas, IInteractionConfig, IWheelConfig, IPointerConfig } from './interaction/IInteraction'
50
50
 
@@ -6,6 +6,9 @@ import { IPointData } from '../math/IMath'
6
6
  import { ISelector } from '../selector/ISelector'
7
7
  import { IBounds } from '../math/IMath'
8
8
  import { IControl } from '../control/IControl'
9
+ import { IKeepTouchData } from '../event/IEvent'
10
+ import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
11
+ import { IObject } from '../data/IData'
9
12
 
10
13
  export interface IInteraction extends IControl {
11
14
  target: ILeaf
@@ -23,12 +26,16 @@ export interface IInteraction extends IControl {
23
26
  downData: IPointerEvent
24
27
  downTime: number
25
28
 
29
+ receive(event: any): void
30
+
26
31
  pointerDown(data: IPointerEvent): void
27
32
  pointerMove(data: IPointerEvent): void
28
33
  pointerMoveReal(data: IPointerEvent): void
29
34
  pointerUp(data: IPointerEvent): void
30
35
  pointerCancel(): void
31
36
 
37
+ multiTouch(data: IUIEvent, list: IKeepTouchData[]): void
38
+
32
39
  move(data: IMoveEvent): void
33
40
  zoom(data: IZoomEvent): void
34
41
  rotate(data: IRotateEvent): void
@@ -36,9 +43,8 @@ export interface IInteraction extends IControl {
36
43
  emit(type: string, data: IUIEvent, path?: ILeafList, excludePath?: ILeafList): void
37
44
  }
38
45
 
39
- export interface IInteractionCanvas {
40
- bounds: IBounds
41
- view: unknown
46
+ export interface IInteractionCanvas extends ILeaferCanvas {
47
+
42
48
  }
43
49
 
44
50
  export interface IInteractionConfig {
@@ -46,6 +52,7 @@ export interface IInteractionConfig {
46
52
  pointer?: IPointerConfig
47
53
  zoom?: IZoomConfig
48
54
  move?: IMoveConfig
55
+ eventer?: IObject
49
56
  }
50
57
 
51
58
  export interface IZoomConfig {
@@ -2,6 +2,8 @@ import { IFunction } from '../function/IFunction'
2
2
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
3
3
  import { ILeaf } from '../display/ILeaf'
4
4
  import { IExportFileType, IExportImageType } from '../file/IFileType'
5
+ import { IBoundsData, ISizeData } from '../math/IMath'
6
+ import { IObject } from '../data/IData'
5
7
 
6
8
  export interface IPlatform {
7
9
  name?: 'web' | 'node' | 'miniapp'
@@ -22,5 +24,22 @@ export interface IPlatform {
22
24
  canvasToBolb(canvas: any, type?: IExportFileType, quality?: number): Promise<any>
23
25
  canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>
24
26
  loadImage(url: string): Promise<any>
25
- }
27
+ },
28
+ miniapp?: IMiniapp
29
+ }
30
+
31
+
32
+ export interface IMiniappSelect extends IObject { }
33
+
34
+ export interface IMiniappSizeView extends ISizeData {
35
+ view: any
36
+ }
37
+
38
+ export interface IMiniapp {
39
+ select(name: string): IMiniappSelect
40
+ getBounds(select: IMiniappSelect): Promise<IBoundsData>
41
+ getSizeView(select: IMiniappSelect): Promise<IMiniappSizeView>
42
+ onWindowResize(fun: IFunction): void
43
+ offWindowResize(fun: IFunction): void
44
+ saveToAlbum(path: string): Promise<any>
26
45
  }
@@ -1,3 +1,4 @@
1
+ import { ILeafer } from '../app/ILeafer'
1
2
  import { IObject } from '../data/IData'
2
3
 
3
4
  export interface IPlugin extends IObject {
@@ -5,4 +6,5 @@ export interface IPlugin extends IObject {
5
6
  importVersion: string
6
7
  import: string[]
7
8
  run(LeaferUI: IObject, config: IObject): void
9
+ onLeafer?(leafer: ILeafer): void
8
10
  }
@@ -24,5 +24,5 @@ export interface ITaskProcessor {
24
24
  add(taskCallback: IFunction, taskTime?: number): void
25
25
  addParallel(taskCallback: IFunction, taskTime?: number): void
26
26
  addEmpty(callback?: IFunction): void
27
- destory(): void
27
+ destroy(): void
28
28
  }