@leafer/interface 1.0.0-beta.9 → 1.0.0-rc.10

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 (41) hide show
  1. package/package.json +5 -2
  2. package/src/app/IApp.ts +3 -3
  3. package/src/app/ILeafer.ts +41 -17
  4. package/src/canvas/ICanvas.ts +2 -0
  5. package/src/canvas/IHitCanvasManager.ts +0 -1
  6. package/src/canvas/ILeaferCanvas.ts +13 -9
  7. package/src/canvas/ISkiaCanvas.ts +20 -1
  8. package/src/data/IData.ts +5 -7
  9. package/src/data/ILeafData.ts +12 -6
  10. package/src/data/IList.ts +9 -6
  11. package/src/display/IBranch.ts +4 -2
  12. package/src/display/ILeaf.ts +251 -73
  13. package/src/display/IView.ts +1 -4
  14. package/src/display/module/IBranchRender.ts +2 -2
  15. package/src/display/module/ILeafBounds.ts +4 -0
  16. package/src/display/module/ILeafDataProxy.ts +5 -3
  17. package/src/display/module/ILeafHit.ts +3 -1
  18. package/src/display/module/ILeafRender.ts +1 -0
  19. package/src/event/IEvent.ts +3 -23
  20. package/src/event/IEventer.ts +6 -1
  21. package/src/event/IUIEvent.ts +18 -11
  22. package/src/file/IExport.ts +24 -0
  23. package/src/file/IFileType.ts +1 -1
  24. package/src/function/IFunction.ts +9 -0
  25. package/src/image/IImageManager.ts +13 -2
  26. package/src/image/ILeaferImage.ts +32 -1
  27. package/src/index.ts +17 -16
  28. package/src/interaction/ICursor.ts +16 -0
  29. package/src/interaction/IInteraction.ts +35 -7
  30. package/src/layout/ILeafLayout.ts +33 -15
  31. package/src/layouter/ILayouter.ts +3 -0
  32. package/src/math/IMath.ts +70 -36
  33. package/src/path/IPathDrawer.ts +5 -0
  34. package/src/platform/IPlatform.ts +21 -4
  35. package/src/plugin/IPlugin.ts +2 -2
  36. package/src/renderer/IRenderer.ts +3 -2
  37. package/src/selector/ISelector.ts +26 -9
  38. package/src/task/ITaskProcessor.ts +19 -3
  39. package/src/watcher/IWatcher.ts +5 -1
  40. package/types/index.d.ts +1859 -0
  41. package/src/display/module/ILeafMask.ts +0 -12
@@ -4,28 +4,45 @@ import { ILeaf } from '../display/ILeaf'
4
4
  import { IExportFileType, IExportImageType } from '../file/IFileType'
5
5
  import { IBoundsData, ISizeData } from '../math/IMath'
6
6
  import { IObject } from '../data/IData'
7
+ import { ICanvasType } from '../canvas/ISkiaCanvas'
7
8
 
8
9
  export interface IPlatform {
9
10
  name?: 'web' | 'node' | 'miniapp'
10
11
  os?: 'Mac' | 'Windows' | 'Linux'
11
12
  requestRender?(render: IFunction): void
12
13
  canvas?: ILeaferCanvas
14
+ canvasType?: ICanvasType
13
15
  isWorker?: boolean
16
+ isMobile?: boolean
14
17
  devicePixelRatio?: number
15
- intWheelDeltaY?: boolean // firxfox / Windows need
18
+ intWheelDeltaY?: boolean // firefox / Windows need
16
19
  conicGradientSupport?: boolean
17
- conicGradientRotate90?: boolean // fixfox need rotate
20
+ conicGradientRotate90?: boolean // firefox need rotate
18
21
  fullImageShadow?: boolean // safari need
22
+ syncDomFont?: boolean // firefox need
19
23
  layout?(target: ILeaf): void
20
- realtimeLayout?: boolean
21
24
  origin?: {
22
25
  createCanvas(width: number, height: number, format?: 'svg' | 'pdf'): any
23
- canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string
26
+ canvasToDataURL(canvas: any, type?: IExportImageType, quality?: number): string | Promise<string>
24
27
  canvasToBolb(canvas: any, type?: IExportFileType, quality?: number): Promise<any>
25
28
  canvasSaveAs(canvas: any, filename: string, quality?: number): Promise<void>
26
29
  loadImage(url: string): Promise<any>
30
+ noRepeat?: string // fix: 微信小程序 createPattern 直接使用 no-repeat 有bug,导致无法显示
31
+ },
32
+ roundRectPatch?: boolean // fix: skia-canvas roundRect
33
+ ellipseToCurve?: boolean, // fix: skia 绘制圆环和椭圆弧
34
+ event?: {
35
+ stopDefault(origin: IObject): void
36
+ stopNow(origin: IObject): void
37
+ stop(origin: IObject): void
27
38
  },
28
39
  miniapp?: IMiniapp
40
+ image: {
41
+ maxCacheSize: number // 最大等级缓存,一般取当前屏幕大小,默认2k: 2560 * 1600
42
+ maxPatternSize: number // 最大repeat pattern缓存, 默认4k: 4096 * 2160
43
+ suffix: string // 需要带上后缀区分dom中image标签的缓存,否则会导致浏览器缓存跨域问题
44
+ crossOrigin: string | false // 跨域设置
45
+ }
29
46
  }
30
47
 
31
48
 
@@ -1,4 +1,4 @@
1
- import { ILeafer } from '../app/ILeafer'
1
+ import { ILeaferBase } from '../app/ILeafer'
2
2
  import { IObject } from '../data/IData'
3
3
 
4
4
  export interface IPlugin extends IObject {
@@ -6,5 +6,5 @@ export interface IPlugin extends IObject {
6
6
  importVersion: string
7
7
  import: string[]
8
8
  run(LeaferUI: IObject, config: IObject): void
9
- onLeafer?(leafer: ILeafer): void
9
+ onLeafer?(leafer: ILeaferBase): void
10
10
  }
@@ -1,13 +1,14 @@
1
1
  import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
2
  import { ILeaf } from '../display/ILeaf'
3
- import { IBounds, IMatrix } from '../math/IMath'
3
+ import { IBounds, IMatrixWithScaleData } from '../math/IMath'
4
4
  import { IFunction } from '../function/IFunction'
5
5
  import { IControl } from '../control/IControl'
6
6
 
7
7
  export interface IRenderOptions {
8
+ includes?: boolean,
8
9
  bounds?: IBounds,
9
10
  hideBounds?: IBounds,
10
- matrix?: IMatrix,
11
+ matrix?: IMatrixWithScaleData,
11
12
  inCamera?: boolean
12
13
  }
13
14
 
@@ -1,16 +1,20 @@
1
1
  import { ILeaf } from '../display/ILeaf'
2
2
  import { ILeafList } from '../data/IList'
3
3
  import { IPointData } from '../math/IMath'
4
+ import { IBranch } from '../display/IBranch'
4
5
 
5
- export interface ISelectPathResult {
6
- leaf: ILeaf
6
+ export interface IPickResult {
7
+ target: ILeaf
7
8
  path: ILeafList
8
9
  throughPath?: ILeafList
9
10
  }
10
11
 
11
- export interface ISelectPathOptions {
12
+ export interface IPickOptions {
12
13
  name?: string
14
+ hitRadius?: number
13
15
  through?: boolean
16
+ target?: IBranch
17
+ findList?: ILeaf[]
14
18
  exclude?: ILeafList
15
19
  ignoreHittable?: boolean
16
20
  }
@@ -19,17 +23,30 @@ export interface ISelectorConfig {
19
23
 
20
24
  }
21
25
 
26
+ export type IAnswer = 0 | 1 | 2 | 3
27
+
28
+ export interface IFindMethod {
29
+ (leaf: ILeaf, options?: any): IAnswer
30
+ }
31
+
32
+ export interface ISelectorProxy {
33
+ list: ILeaf[]
34
+ }
35
+
22
36
  export interface ISelector {
23
37
  target: ILeaf
24
38
 
39
+ proxy?: ISelectorProxy
40
+
25
41
  config: ISelectorConfig
26
42
 
27
- getByPoint(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult
43
+ getByPoint(hitPoint: IPointData, hitRadius: number, options?: IPickOptions): IPickResult
28
44
 
29
- find(name: number | string, branch?: ILeaf): ILeaf | ILeaf[]
30
- getByInnerId(name: number, branch?: ILeaf): ILeaf
31
- getById(name: string, branch?: ILeaf): ILeaf
32
- getByClassName(name: string, branch?: ILeaf): ILeaf[]
33
- getByTagName(name: string, branch?: ILeaf): ILeaf[]
45
+ getBy(condition: number | string | IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[]
46
+ getByInnerId(innerId: number, branch?: ILeaf): ILeaf
47
+ getById(id: string, branch?: ILeaf): ILeaf
48
+ getByClassName(className: string, branch?: ILeaf): ILeaf[]
49
+ getByTag(tag: string, branch?: ILeaf): ILeaf[]
50
+ getByMethod(method: IFindMethod, branch?: ILeaf, one?: boolean, options?: any): ILeaf | ILeaf[]
34
51
  destroy(): void
35
52
  }
@@ -21,8 +21,24 @@ export interface ITaskProcessor {
21
21
  resume(): void
22
22
  skip(): void
23
23
  stop(): void
24
- add(taskCallback: IFunction, taskTime?: number): void
25
- addParallel(taskCallback: IFunction, taskTime?: number): void
26
- addEmpty(callback?: IFunction): void
24
+ add(taskCallback: IFunction, options?: ITaskOptions | number): ITaskItem
27
25
  destroy(): void
26
+ }
27
+
28
+ export interface ITaskItem {
29
+ parent: ITaskProcessor
30
+ parallel: boolean
31
+ isComplete: boolean
32
+ isCancel: boolean
33
+ time: number
34
+ run(): Promise<void>
35
+ complete(): void
36
+ cancel(): void
37
+ }
38
+
39
+ export interface ITaskOptions {
40
+ start?: boolean // default true
41
+ time?: number // default 1
42
+ parallel?: boolean // default true
43
+ delay?: number // default 0
28
44
  }
@@ -18,7 +18,11 @@ export interface IWatcher extends IControl {
18
18
  disabled: boolean
19
19
  running: boolean
20
20
  changed: boolean
21
- hasRemoved: boolean
21
+
22
+ hasVisible: boolean
23
+ hasAdd: boolean
24
+ hasRemove: boolean
25
+ readonly childrenChanged: boolean
22
26
 
23
27
  config: IWatcherConfig
24
28