@leafer/interface 1.0.0-alpha.1 → 1.0.0-alpha.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.
package/package.json CHANGED
@@ -1,11 +1,13 @@
1
1
  {
2
2
  "name": "@leafer/interface",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.10",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
7
7
  "main": "src/index.ts",
8
- "files": ["src"],
8
+ "files": [
9
+ "src"
10
+ ],
9
11
  "repository": {
10
12
  "type": "git",
11
13
  "url": "https://github.com/leaferjs/leafer.git"
@@ -16,4 +18,4 @@
16
18
  "leafer",
17
19
  "leaferjs"
18
20
  ]
19
- }
21
+ }
@@ -1,5 +1,5 @@
1
1
  import { ILeafer } from './ILeafer'
2
2
 
3
- export interface ISupperLeafer extends ILeafer {
3
+ export interface IApp extends ILeafer {
4
4
  children: ILeafer[]
5
5
  }
@@ -11,7 +11,7 @@ import { IHitCanvasManager } from '../canvas/IHitCanvasManager'
11
11
  import { IImageManager } from '../image/IImageManager'
12
12
  import { IObject } from '../data/IData'
13
13
  import { IZoomView } from '../display/IView'
14
- import { ISupperLeafer } from './ISupperLeafer'
14
+ import { IApp } from './IApp'
15
15
  import { ILeaferImage, ILeaferImageConfig } from '../image/ILeaferImage'
16
16
  import { IEvent } from '../event/IEvent'
17
17
 
@@ -26,8 +26,8 @@ export interface ILeafer extends IZoomView {
26
26
 
27
27
  creator: ICreator
28
28
 
29
- readonly isSupperLeafer: boolean
30
- parent?: ISupperLeafer
29
+ readonly isApp: boolean
30
+ parent?: IApp
31
31
 
32
32
  running: boolean
33
33
 
@@ -1,24 +1,24 @@
1
1
  type GlobalCompositeOperation = 'color' | 'color-burn' | 'color-dodge' | 'copy' | 'darken' | 'destination-atop' | 'destination-in' | 'destination-out' | 'destination-over' | 'difference' | 'exclusion' | 'hard-light' | 'hue' | 'lighten' | 'lighter' | 'luminosity' | 'multiply' | 'overlay' | 'saturation' | 'screen' | 'soft-light' | 'source-atop' | 'source-in' | 'source-out' | 'source-over' | 'xor'
2
2
  type CanvasDirection = 'inherit' | 'ltr' | 'rtl'
3
- export type CanvasFillRule = 'evenodd' | 'nonzero'
4
- type CanvasFontKerning = 'auto' | 'none' | 'normal'
5
- type CanvasFontStretch = 'condensed' | 'expanded' | 'extra-condensed' | 'extra-expanded' | 'normal' | 'semi-condensed' | 'semi-expanded' | 'ultra-condensed' | 'ultra-expanded'
6
- type CanvasFontVariantCaps = 'all-petite-caps' | 'all-small-caps' | 'normal' | 'petite-caps' | 'small-caps' | 'titling-caps' | 'unicase'
3
+ export type IWindingRule = 'evenodd' | 'nonzero'
4
+ // type CanvasFontKerning = 'auto' | 'none' | 'normal'
5
+ // type CanvasFontStretch = 'condensed' | 'expanded' | 'extra-condensed' | 'extra-expanded' | 'normal' | 'semi-condensed' | 'semi-expanded' | 'ultra-condensed' | 'ultra-expanded'
6
+ // type CanvasFontVariantCaps = 'all-petite-caps' | 'all-small-caps' | 'normal' | 'petite-caps' | 'small-caps' | 'titling-caps' | 'unicase'
7
7
  type CanvasLineCap = 'butt' | 'round' | 'square'
8
8
  type CanvasLineJoin = 'bevel' | 'miter' | 'round'
9
9
  type CanvasTextAlign = 'center' | 'end' | 'left' | 'right' | 'start'
10
10
  type CanvasTextBaseline = 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top'
11
- type CanvasTextRendering = 'auto' | 'geometricPrecision' | 'optimizeLegibility' | 'optimizeSpeed'
11
+ //type CanvasTextRendering = 'auto' | 'geometricPrecision' | 'optimizeLegibility' | 'optimizeSpeed'
12
12
 
13
13
  /** This Canvas 2D API interface is used to declare a path that can then be used on a CanvasRenderingContext2D object. The path methods of the CanvasRenderingContext2D interface are also present on this interface, which gives you the convenience of being able to retain and replay your path whenever desired. */
14
- interface Path2D extends CanvasPath {
14
+ export interface IPath2D extends CanvasPath {
15
15
  /** Adds to the path the path given by the argument. */
16
- addPath(path: Path2D, transform?: DOMMatrix2DInit): void
16
+ addPath(path: IPath2D, transform?: DOMMatrix2DInit): void
17
17
  }
18
18
 
19
- export declare var Path2D: {
20
- prototype: Path2D
21
- new(path?: Path2D | string): Path2D
19
+ declare var IPath2D: {
20
+ prototype: IPath2D
21
+ new(path?: IPath2D | string): IPath2D
22
22
  }
23
23
 
24
24
  interface CanvasCompositing {
@@ -35,16 +35,16 @@ interface CanvasDrawImage {
35
35
 
36
36
  interface CanvasDrawPath {
37
37
  beginPath(): void
38
- clip(fillRule?: CanvasFillRule): void
39
- clip(path: Path2D, fillRule?: CanvasFillRule): void
40
- fill(fillRule?: CanvasFillRule): void
41
- fill(path: Path2D, fillRule?: CanvasFillRule): void
42
- isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean
43
- isPointInPath(path: Path2D, x: number, y: number, fillRule?: CanvasFillRule): boolean
38
+ clip(fillRule?: IWindingRule): void
39
+ clip(path: IPath2D, fillRule?: IWindingRule): void
40
+ fill(fillRule?: IWindingRule): void
41
+ fill(path: IPath2D, fillRule?: IWindingRule): void
42
+ isPointInPath(x: number, y: number, fillRule?: IWindingRule): boolean
43
+ isPointInPath(path: IPath2D, x: number, y: number, fillRule?: IWindingRule): boolean
44
44
  isPointInStroke(x: number, y: number): boolean
45
- isPointInStroke(path: Path2D, x: number, y: number): boolean
45
+ isPointInStroke(path: IPath2D, x: number, y: number): boolean
46
46
  stroke(): void
47
- stroke(path: Path2D): void
47
+ stroke(path: IPath2D): void
48
48
  }
49
49
 
50
50
  interface CanvasFillStrokeStyles {
@@ -137,14 +137,14 @@ interface CanvasRenderingContext2DSettings {
137
137
  }
138
138
 
139
139
  /** The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a <canvas> element. It is used for drawing shapes, text, images, and other objects. */
140
- export interface CanvasRenderingContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
140
+ export interface ICanvasContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
141
141
  readonly canvas: HTMLCanvasElement
142
142
  getContextAttributes(): CanvasRenderingContext2DSettings
143
143
  }
144
144
 
145
- declare var CanvasRenderingContext2D: {
146
- prototype: CanvasRenderingContext2D
147
- new(): CanvasRenderingContext2D
145
+ declare var ICanvasContext2D: {
146
+ prototype: ICanvasContext2D
147
+ new(): ICanvasContext2D
148
148
  }
149
149
 
150
150
  interface CanvasShadowStyles {
@@ -161,12 +161,12 @@ interface CanvasState {
161
161
 
162
162
  interface CanvasUserInterface {
163
163
  drawFocusIfNeeded(element: any): void
164
- drawFocusIfNeeded(path: Path2D, element: any): void
164
+ drawFocusIfNeeded(path: IPath2D, element: any): void
165
165
  }
166
166
 
167
167
 
168
168
  /** The dimensions of a piece of text in the canvas, as created by the CanvasRenderingContext2D.measureText() method. */
169
- export interface TextMetrics {
169
+ export interface ITextMetrics {
170
170
  /** Returns the measurement described below. */
171
171
  readonly actualBoundingBoxAscent: number
172
172
  /** Returns the measurement described below. */
@@ -184,13 +184,13 @@ export interface TextMetrics {
184
184
  }
185
185
 
186
186
  declare var TextMetrics: {
187
- prototype: TextMetrics
188
- new(): TextMetrics
187
+ prototype: ITextMetrics
188
+ new(): ITextMetrics
189
189
  }
190
190
 
191
191
  interface CanvasText {
192
192
  fillText(text: string, x: number, y: number, maxWidth?: number): void
193
- measureText(text: string): TextMetrics
193
+ measureText(text: string): ITextMetrics
194
194
  strokeText(text: string, x: number, y: number, maxWidth?: number): void
195
195
  }
196
196
 
@@ -1,15 +1,11 @@
1
1
  import { IObject } from '../data/IData'
2
2
  import { IBounds, IMatrixData, IBoundsData, IAutoBoundsData, IAutoBounds, IScreenSizeData, IMatrixWithBoundsData, IPointData } from '../math/IMath'
3
- import { CanvasRenderingContext2D, CanvasFillRule, Path2D, TextMetrics, CanvasGradient, CanvasPattern } from './ICanvas'
3
+ import { ICanvasContext2D, IWindingRule, IPath2D, ITextMetrics, CanvasGradient, CanvasPattern } from './ICanvas'
4
4
  import { IResizeEventListener } from '../event/IEvent'
5
- import { ICanvasDrawPath } from './ICanvasPathDrawer'
5
+ import { IPathDrawer } from '../path/IPathDrawer'
6
6
  import { InnerId } from '../event/IEventer'
7
7
  import { ICanvasManager } from './ICanvasManager'
8
8
 
9
- export interface ILeaferCanvasContext extends CanvasRenderingContext2D {
10
-
11
- }
12
-
13
9
  export interface ILeaferCanvasConfig extends IAutoBoundsData {
14
10
  view?: string | IObject
15
11
  fill?: string
@@ -67,9 +63,9 @@ interface ICanvasMethod {
67
63
  save(): void
68
64
  restore(): void
69
65
 
70
- fill(path?: Path2D | CanvasFillRule, rule?: CanvasFillRule): void
71
- stroke(path?: Path2D): void
72
- clip(path?: Path2D | CanvasFillRule, rule?: CanvasFillRule): void
66
+ fill(path?: IPath2D | IWindingRule, rule?: IWindingRule): void
67
+ stroke(path?: IPath2D): void
68
+ clip(path?: IPath2D | IWindingRule, rule?: IWindingRule): void
73
69
 
74
70
  fillRect(x: number, y: number, width: number, height: number): void
75
71
  strokeRect(x: number, y: number, width: number, height: number): void
@@ -95,7 +91,7 @@ interface ICanvasMethod {
95
91
  // text
96
92
 
97
93
  fillText(text: string, x: number, y: number, maxWidth?: number): void
98
- measureText(text: string): TextMetrics
94
+ measureText(text: string): ITextMetrics
99
95
  strokeText(text: string, x: number, y: number, maxWidth?: number): void
100
96
 
101
97
  // custom
@@ -121,7 +117,7 @@ interface ICanvasMethod {
121
117
  clear(): void
122
118
  }
123
119
 
124
- export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, ICanvasDrawPath {
120
+ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
125
121
 
126
122
  manager: ICanvasManager
127
123
 
@@ -137,7 +133,7 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, ICanvasDrawPa
137
133
  bounds: IBounds
138
134
 
139
135
  view: unknown
140
- context: ILeaferCanvasContext
136
+ context: ICanvasContext2D
141
137
 
142
138
  recycled?: boolean
143
139
 
@@ -118,7 +118,7 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
118
118
 
119
119
  __worldOpacity: number
120
120
  __renderTime: number // μs 1000微秒 = 1毫秒
121
- __complex: boolean // 外观是否复杂, 将调用__drawComplex()
121
+ __complex: boolean // 外观是否复杂
122
122
 
123
123
  __level: number // 图层级别 root(1) -> hight
124
124
  __tempNumber?: number // 用于临时运算储存状态
@@ -1,5 +1,5 @@
1
1
  import { IEvent, IFunction, IObject } from '@leafer/interface'
2
- import { LeafEventer } from '../display/module/ILeafEventer'
2
+ import { ILeafEventer } from '../display/module/ILeafEventer'
3
3
 
4
4
  export type IEventListener = IFunction
5
5
 
@@ -24,7 +24,7 @@ export interface IEventListenerId {
24
24
 
25
25
  export type InnerId = number
26
26
 
27
- export interface IEventer extends LeafEventer {
27
+ export interface IEventer extends ILeafEventer {
28
28
 
29
29
  readonly innerId: InnerId
30
30
  __captureMap?: IEventListenerMap
@@ -3,6 +3,8 @@ export interface ILeaferImageConfig {
3
3
  thumb?: string
4
4
  }
5
5
 
6
- export interface ILeaferImage {
7
6
 
7
+
8
+ export interface ILeaferImage {
9
+ //load(url: string):Promise<>
8
10
  }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { ISupperLeafer } from './app/ISupperLeafer'
1
+ export { IApp } from './app/IApp'
2
2
  export { ILeafer, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
3
  export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf } from './display/ILeaf'
4
4
  export { IBranch } from './display/IBranch'
@@ -29,9 +29,9 @@ export { IPlatform } from './platform/IPlatform'
29
29
  export { IPlugin } from './plugin/IPlugin'
30
30
 
31
31
 
32
- export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasContext, ILeaferCanvasConfig, IHitCanvasConfig } from './canvas/ILeaferCanvas'
33
- export { ICanvasDrawPath } from './canvas/ICanvasPathDrawer'
34
- export { CanvasFillRule, CanvasRenderingContext2D, TextMetrics, Path2D } from './canvas/ICanvas'
32
+ export { ILeaferCanvas, IHitCanvas, ICanvasAttr, ICanvasStrokeOptions, ILeaferCanvasConfig, IHitCanvasConfig } from './canvas/ILeaferCanvas'
33
+ export { IPathDrawer } from './path/IPathDrawer'
34
+ export { IWindingRule, ICanvasContext2D, ITextMetrics, IPath2D } from './canvas/ICanvas'
35
35
  export { CanvasPathCommand, IPathCommandData, MCommandData, HCommandData, VCommandData, LCommandData, CCommandData, SCommandData, QCommandData, TCommandData, ZCommandData, ACommandData, RectCommandData, RoundRectCommandData, EllipseCommandData, ArcCommandData, ArcToCommandData } from './path/IPathCommand'
36
36
 
37
37
  export { ILeaferImage, ILeaferImageConfig } from './image/ILeaferImage'
@@ -1,20 +1,33 @@
1
1
  import { INumberFunction, IPointDataFunction } from '../function/IFunction'
2
- import { IPointerEvent, IMoveEvent, IZoomEvent, IRotateEvent } from '../event/IUIEvent'
2
+ import { IPointerEvent, IMoveEvent, IZoomEvent, IRotateEvent, IUIEvent } from '../event/IUIEvent'
3
3
  import { ILeaf } from '../display/ILeaf'
4
+ import { ILeafList } from '../data/IList'
4
5
  import { IPointData } from '../math/IMath'
6
+ import { ISelector } from '../selector/ISelector'
7
+ import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
8
+ import { IBounds } from '../math/IMath'
5
9
 
6
10
  export interface IInteraction {
7
11
  target: ILeaf
8
- config: IInteractionConfig
12
+ canvas: ILeaferCanvas
13
+ selector: ISelector
14
+
9
15
  running: boolean
16
+ readonly dragging: boolean
17
+
18
+ config: IInteractionConfig
19
+
20
+ readonly hitRadius: number
21
+ shrinkCanvasBounds: IBounds
10
22
 
11
- pointerMoveIgnore: boolean
23
+ downData: IPointerEvent
12
24
 
13
25
  start(): void
14
26
  stop(): void
15
27
 
16
28
  pointerDown(data: IPointerEvent): void
17
29
  pointerMove(data: IPointerEvent): void
30
+ pointerMoveReal(data: IPointerEvent): void
18
31
  pointerUp(data: IPointerEvent): void
19
32
  pointerCancel(): void
20
33
 
@@ -22,6 +35,8 @@ export interface IInteraction {
22
35
  zoom(data: IZoomEvent): void
23
36
  rotate(data: IRotateEvent): void
24
37
 
38
+ emit(type: string, data: IUIEvent, path?: ILeafList, excludePath?: ILeafList): void
39
+
25
40
  destroy(): void
26
41
  }
27
42
 
@@ -36,7 +51,7 @@ export interface IWheelConfig {
36
51
  zoomSpeed?: number // 取值范围 0 ~ 1, 默认0.5
37
52
  moveSpeed?: number
38
53
  rotateSpeed?: number // 取值范围 0 ~ 1, 默认0.5
39
- delta?: IPointData
54
+ delta?: IPointData // 以chrome为基准, 鼠标滚动一格的距离
40
55
  getScale?: INumberFunction
41
56
  getMove?: IPointDataFunction
42
57
  }
@@ -50,4 +65,5 @@ export interface IPointerConfig {
50
65
  dragDistance?: number
51
66
  swipeDistance?: number
52
67
  autoMoveDistance?: number
68
+ ignoreMove: boolean // 性能优化字段, 控制move事件触发次数
53
69
  }
@@ -33,20 +33,27 @@ export interface ILayouterConfig {
33
33
  export interface ILayouter {
34
34
  target: ILeaf
35
35
  layoutedBlocks: ILayoutBlockData[]
36
+
36
37
  totalTimes: number
37
38
  times: number
38
- config: ILayouterConfig
39
+
39
40
  running: boolean
41
+ changed: boolean
42
+
43
+ config: ILayouterConfig
40
44
 
41
45
  start(): void
42
46
  stop(): void
47
+ update(): void
48
+
49
+ layout(): void
50
+ layoutOnce(): void
51
+ partLayout(): void
52
+ fullLayout(): void
43
53
 
44
54
  createBlock(data: ILeafList | ILeaf[]): ILayoutBlockData
45
55
  getBlocks(list: ILeafList): ILayoutBlockData[]
46
56
  setBlocks(current: ILayoutBlockData[]): void
47
57
 
48
- layout(): void
49
- partLayout(): void
50
- fullLayout(): void
51
58
  destroy(): void
52
59
  }
@@ -1,4 +1,4 @@
1
- export interface ICanvasDrawPath {
1
+ export interface IPathDrawer {
2
2
  beginPath?(): void
3
3
 
4
4
  moveTo(x: number, y: number): void
@@ -12,5 +12,5 @@ export interface ICanvasDrawPath {
12
12
  ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void
13
13
 
14
14
  rect(x: number, y: number, width: number, height: number): void
15
- roundRect?(x: number, y: number, width: number, height: number, radius?: number | number[]): void
15
+ roundRect(x: number, y: number, width: number, height: number, radius?: number | number[]): void
16
16
  }
@@ -2,7 +2,6 @@ import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
2
2
  import { ILeaf } from '../display/ILeaf'
3
3
  import { IBounds, IMatrix } from '../math/IMath'
4
4
  import { IFunction } from '../function/IFunction'
5
- import { ILayoutBlockData } from '../layouter/ILayouter'
6
5
 
7
6
  export interface IRenderOptions {
8
7
  bounds?: IBounds,
@@ -12,26 +11,38 @@ export interface IRenderOptions {
12
11
  }
13
12
 
14
13
  export interface IRendererConfig {
14
+ usePartRender?: boolean
15
15
  maxFPS?: number
16
16
  }
17
17
 
18
18
  export interface IRenderer {
19
- canvas: ILeaferCanvas
20
19
  target: ILeaf
21
- layoutedBlocks: ILayoutBlockData[]
22
- running: boolean
20
+ canvas: ILeaferCanvas
21
+ updateBlocks: IBounds[]
22
+
23
+ FPS: number
23
24
  totalTimes: number
24
25
  times: number
25
- config: IRendererConfig
26
26
 
27
- FPS: number
27
+ running: boolean
28
+ changed: boolean
29
+
30
+ config: IRendererConfig
28
31
 
29
32
  start(): void
30
33
  stop(): void
34
+ update(): void
31
35
 
32
36
  requestLayout(): void
37
+
33
38
  render(callback?: IFunction): void
34
- clipRender(bounds: IBounds): void
39
+ renderOnce(callback?: IFunction): void
40
+ partRender(): void
41
+ clipRender(bounds: IBounds, fullMode?: boolean): void
35
42
  fullRender(bounds?: IBounds): void
43
+
44
+ addBlock(block: IBounds): void
45
+ mergeBlocks(): void
46
+
36
47
  destroy(): void
37
48
  }
@@ -15,8 +15,8 @@ export interface ISelectPathOptions {
15
15
 
16
16
  export interface ISelector {
17
17
  target: ILeaf
18
-
19
18
  defaultPath: ILeafList
19
+
20
20
  getHitPointPath(hitPoint: IPointData, hitRadius: number, options?: ISelectPathOptions): ISelectPathResult
21
21
 
22
22
  find(name: number | string, branch?: ILeaf): ILeaf | ILeaf[]
@@ -12,11 +12,14 @@ export interface IWatcherConfig {
12
12
  export interface IWatcher {
13
13
  target: ILeaf
14
14
  updatedList: ILeafList
15
+
15
16
  totalTimes: number
16
- config: IWatcherConfig
17
+
17
18
  running: boolean
18
19
  changed: boolean
19
20
 
21
+ config: IWatcherConfig
22
+
20
23
  start(): void
21
24
  stop(): void
22
25