@leafer/interface 1.0.0-alpha.21 → 1.0.0-alpha.23

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-alpha.21",
3
+ "version": "1.0.0-alpha.23",
4
4
  "description": "@leafer/interface",
5
5
  "author": "Chao (Leafer) Wan",
6
6
  "license": "MIT",
package/src/app/IApp.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { ILeafer } from './ILeafer'
2
2
 
3
3
  export interface IApp extends ILeafer {
4
+ virtualCanvas: boolean
4
5
  children: ILeafer[]
5
6
  }
@@ -3,7 +3,7 @@ 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 } from '../selector/ISelector'
6
- import { IInteraction, IInteractionConfig } from '../interaction/IInteraction'
6
+ import { IInteraction, IInteractionCanvas, IInteractionConfig } from '../interaction/IInteraction'
7
7
  import { IWatcher } from '../watcher/IWatcher'
8
8
  import { IAutoBounds, IScreenSizeData } from '../math/IMath'
9
9
  import { ICanvasManager } from '../canvas/ICanvasManager'
@@ -13,13 +13,12 @@ import { IObject } from '../data/IData'
13
13
  import { IZoomView } from '../display/IView'
14
14
  import { IApp } from './IApp'
15
15
  import { ILeaferImage, ILeaferImageConfig } from '../image/ILeaferImage'
16
- import { IEvent } from '../event/IEvent'
17
-
18
16
 
17
+ export type ILeaferType = 'draw' | 'design' | 'board' | 'document' | 'user'
19
18
  export interface ILeaferConfig extends IRendererConfig, ILeaferCanvasConfig, IInteractionConfig, ILayouterConfig {
20
- autoStart?: boolean
21
- useZoom?: boolean
22
- useMove?: boolean
19
+ start?: boolean
20
+ type?: ILeaferType
21
+ virtualCanvas?: boolean
23
22
  }
24
23
 
25
24
  export interface ILeafer extends IZoomView {
@@ -30,9 +29,13 @@ export interface ILeafer extends IZoomView {
30
29
  parent?: IApp
31
30
 
32
31
  running: boolean
32
+ ready: boolean
33
+
34
+ startTimer: number
33
35
 
34
36
  autoLayout?: IAutoBounds
35
37
 
38
+ view: unknown
36
39
  canvas: ILeaferCanvas
37
40
  renderer: IRenderer
38
41
 
@@ -55,9 +58,6 @@ export interface ILeafer extends IZoomView {
55
58
  }
56
59
 
57
60
  export interface ICreator {
58
- ui?(tag: string, data?: IObject): ILeaf
59
- event?(type: string, event: IEvent): IEvent
60
-
61
61
  image?(options?: ILeaferImageConfig): ILeaferImage
62
62
  canvas?(options?: ILeaferCanvasConfig, manager?: ICanvasManager): ILeaferCanvas
63
63
  hitCanvas?(options?: IHitCanvasConfig, manager?: ICanvasManager): IHitCanvas
@@ -67,7 +67,7 @@ export interface ICreator {
67
67
  renderer?(target: ILeaf, canvas: ILeaferCanvas, options: IRendererConfig): IRenderer
68
68
  selector?(target: ILeaf): ISelector
69
69
 
70
- interaction?(target: ILeaf, canvas: ILeaferCanvas, selector: ISelector, options?: IInteractionConfig): IInteraction
70
+ interaction?(target: ILeaf, canvas: IInteractionCanvas, selector: ISelector, options?: IInteractionConfig): IInteraction
71
71
  }
72
72
 
73
73
  export interface IUICreator {
@@ -10,9 +10,7 @@ type CanvasTextAlign = 'center' | 'end' | 'left' | 'right' | 'start'
10
10
  type CanvasTextBaseline = 'alphabetic' | 'bottom' | 'hanging' | 'ideographic' | 'middle' | 'top'
11
11
  //type CanvasTextRendering = 'auto' | 'geometricPrecision' | 'optimizeLegibility' | 'optimizeSpeed'
12
12
 
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
13
  export interface IPath2D extends CanvasPath {
15
- /** Adds to the path the path given by the argument. */
16
14
  addPath(path: IPath2D, transform?: DOMMatrix2DInit): void
17
15
  }
18
16
 
@@ -60,13 +58,7 @@ interface CanvasFilters {
60
58
  filter: string
61
59
  }
62
60
 
63
- /** An opaque object describing a gradient. It is returned by the methods CanvasRenderingContext2D.createLinearGradient() or CanvasRenderingContext2D.createRadialGradient(). */
64
61
  export interface CanvasGradient {
65
- /**
66
- * Adds a color stop with the given color to the gradient at the given offset. 0.0 is the offset at one end of the gradient, 1.0 is the offset at the other end.
67
- *
68
- * Throws an 'IndexSizeError' DOMException if the offset is out of range. Throws a 'SyntaxError' DOMException if the color cannot be parsed.
69
- */
70
62
  addColorStop(offset: number, color: string): void
71
63
  }
72
64
 
@@ -111,9 +103,7 @@ interface CanvasPathDrawingStyles {
111
103
  setLineDash(segments: number[]): void
112
104
  }
113
105
 
114
- /** An opaque object describing a pattern, based on an image, a canvas, or a video, created by the CanvasRenderingContext2D.createPattern() method. */
115
106
  export interface CanvasPattern {
116
- /** Sets the transformation matrix that will be used when rendering the pattern during a fill or stroke painting operation. */
117
107
  setTransform(transform?: DOMMatrix2DInit): void
118
108
  }
119
109
 
@@ -135,8 +125,6 @@ interface CanvasRenderingContext2DSettings {
135
125
  desynchronized?: boolean
136
126
  willReadFrequently?: boolean
137
127
  }
138
-
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
128
  export interface ICanvasContext2D extends CanvasCompositing, CanvasDrawImage, CanvasDrawPath, CanvasFillStrokeStyles, CanvasFilters, CanvasImageData, CanvasImageSmoothing, CanvasPath, CanvasPathDrawingStyles, CanvasRect, CanvasShadowStyles, CanvasState, CanvasText, CanvasTextDrawingStyles, CanvasTransform, CanvasUserInterface {
141
129
  readonly canvas: HTMLCanvasElement
142
130
  getContextAttributes(): CanvasRenderingContext2DSettings
@@ -165,7 +153,6 @@ interface CanvasUserInterface {
165
153
  }
166
154
 
167
155
 
168
- /** The dimensions of a piece of text in the canvas, as created by the CanvasRenderingContext2D.measureText() method. */
169
156
  export interface ITextMetrics {
170
157
  /** Returns the measurement described below. */
171
158
  readonly actualBoundingBoxAscent: number
@@ -277,7 +264,6 @@ interface DOMMatrixReadOnly {
277
264
  rotateFromVector(x?: number, y?: number): DOMMatrix
278
265
  scale(scaleX?: number, scaleY?: number, scaleZ?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix
279
266
  scale3d(scale?: number, originX?: number, originY?: number, originZ?: number): DOMMatrix
280
- /** @deprecated */
281
267
  scaleNonUniform(scaleX?: number, scaleY?: number): DOMMatrix
282
268
  skewX(sx?: number): DOMMatrix
283
269
  skewY(sy?: number): DOMMatrix
@@ -73,6 +73,7 @@ interface ICanvasMethod {
73
73
  strokeRect(x: number, y: number, width: number, height: number): void
74
74
  clearRect(x: number, y: number, width: number, height: number): void
75
75
 
76
+ transform(a: number, b: number, c: number, d: number, e: number, f: number): void
76
77
  translate(x: number, y: number): void
77
78
  scale(x: number, y: number): void
78
79
  rotate(angle: number): void
@@ -98,7 +99,10 @@ interface ICanvasMethod {
98
99
 
99
100
  // custom
100
101
 
101
- hitPath(point: IPointData, fillRule?: string): boolean
102
+ saveBlendMode(blendMode?: string): void
103
+ restoreBlendMode(): void
104
+
105
+ hitFill(point: IPointData, fillRule?: string): boolean
102
106
  hitStroke(point: IPointData): boolean
103
107
 
104
108
  setStroke(strokeStyle: string | object, strokeWidth: number, options?: ICanvasStrokeOptions): void
@@ -109,7 +113,7 @@ interface ICanvasMethod {
109
113
  setWorldBlur(blur: number): void
110
114
 
111
115
  copyWorld(canvas: ILeaferCanvas, fromBounds?: IBoundsData, toBounds?: IBoundsData, blendMode?: string): void
112
- copyWorldToLocal(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toLocalBounds: IBoundsData, blendMode?: string): void
116
+ copyWorldToInner(canvas: ILeaferCanvas, fromWorld: IMatrixWithBoundsData, toInnerBounds: IBoundsData, blendMode?: string): void
113
117
  fillWorld(bounds: IBoundsData, color: string | object, blendMode?: string): void
114
118
  strokeWorld(bounds: IBoundsData, color: string | object, blendMode?: string): void
115
119
  clipWorld(bounds: IBoundsData, ceilPixel?: boolean): void
@@ -134,11 +138,15 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
134
138
  bounds: IBounds
135
139
 
136
140
  view: unknown
141
+ parentView: unknown
137
142
  offscreen: boolean
143
+
138
144
  context: ICanvasContext2D
139
145
 
140
146
  recycled?: boolean
141
147
 
148
+ debug(): void
149
+
142
150
  startAutoLayout(autoBounds: IAutoBounds, listener: IResizeEventListener): void
143
151
  stopAutoLayout(): void
144
152
 
@@ -152,6 +160,7 @@ export interface ILeaferCanvas extends ICanvasAttr, ICanvasMethod, IPathDrawer {
152
160
  useSameTransform(canvas: ILeaferCanvas): void
153
161
  recycle(): void
154
162
 
163
+ unloadView(): void
155
164
  destroy(): void
156
165
  }
157
166
 
@@ -5,8 +5,10 @@ export interface IDataProcessor extends IObject {
5
5
  __leaf: ILeaf
6
6
  __input: IObject
7
7
  __middle: IObject
8
+ __get(name: string): unknown
8
9
  __setInput(name: string, value: unknown): void
9
10
  __getInput(name: string): unknown
11
+ __getInputData(): IObject
10
12
  __setMiddle(name: string, value: unknown): void
11
13
  __getMiddle(name: string): unknown
12
14
  destroy(): void
@@ -3,7 +3,7 @@ import { ILeaf } from './ILeaf'
3
3
  export interface IBranch extends ILeaf {
4
4
  children: ILeaf[]
5
5
 
6
- __updateSortChildren(): void
7
- add(child: ILeaf, index?: number): void
8
- remove(child?: ILeaf): void
6
+ // __updateSortChildren(): void
7
+ // add(child: ILeaf, index?: number): void
8
+ // remove(child?: ILeaf): void
9
9
  }
@@ -5,13 +5,13 @@ import { ILeaferCanvas, IHitCanvas } from '../canvas/ILeaferCanvas'
5
5
  import { IRenderOptions } from '../renderer/IRenderer'
6
6
 
7
7
  import { IObject, __Number, __Boolean, __Value, __String } from '../data/IData'
8
- import { IMatrixWithBoundsData, IMatrix, IBoundsData, IRadiusPointData } from '../math/IMath'
8
+ import { IMatrixWithBoundsData, IMatrix, IPointData, IBoundsData, IMatrixData, IRadiusPointData, IMatrixDecompositionAttr } from '../math/IMath'
9
9
  import { IFunction } from '../function/IFunction'
10
10
 
11
11
  import { ILeafDataProxy } from './module/ILeafDataProxy'
12
12
  import { ILeafMatrix } from './module/ILeafMatrix'
13
13
  import { ILeafBounds } from './module/ILeafBounds'
14
- import { ILeafLayout } from '../layout/ILeafLayout'
14
+ import { ILeafLayout, ILayoutBoundsType, ILayoutLocationType } from '../layout/ILeafLayout'
15
15
  import { ILeafHit } from './module/ILeafHit'
16
16
  import { ILeafRender } from './module/ILeafRender'
17
17
  import { ILeafData } from '../data/ILeafData'
@@ -30,8 +30,10 @@ export interface ILeafAttrData {
30
30
  name: __String
31
31
  className: __String
32
32
 
33
+ blendMode: IBlendMode
33
34
  opacity: __Number
34
35
  visible: __Boolean
36
+ isMask: __Boolean
35
37
  zIndex: __Number
36
38
 
37
39
  // layout data
@@ -52,7 +54,32 @@ export interface ILeafAttrData {
52
54
  hitChildren: __Boolean
53
55
  }
54
56
 
55
- export type IHitType = 'visible' | 'fill-visible' | 'stroke-visible' | 'all' | 'fill' | 'stroke'
57
+ export type IHitType =
58
+ | 'visible'
59
+ | 'fill-visible'
60
+ | 'stroke-visible'
61
+ | 'all'
62
+ | 'fill'
63
+ | 'stroke'
64
+
65
+ export type IBlendMode =
66
+ | 'pass-through'
67
+ | 'normal'
68
+ | 'multiply'
69
+ | 'screen'
70
+ | 'overlay'
71
+ | 'darken'
72
+ | 'lighten'
73
+ | 'color-dodge'
74
+ | 'color-burn'
75
+ | 'hard-light'
76
+ | 'soft-light'
77
+ | 'difference'
78
+ | 'exclusion'
79
+ | 'hue'
80
+ | 'saturation'
81
+ | 'color'
82
+ | 'luminosity'
56
83
 
57
84
  export interface ILeafInputData {
58
85
  // layer data
@@ -60,8 +87,10 @@ export interface ILeafInputData {
60
87
  name?: __String
61
88
  className?: __String
62
89
 
90
+ blendMode?: IBlendMode
63
91
  opacity?: __Number
64
92
  visible?: __Boolean
93
+ isMask?: __Boolean
65
94
  zIndex?: __Number
66
95
 
67
96
  // layout data
@@ -87,8 +116,10 @@ export interface ILeafComputedData {
87
116
  name?: string
88
117
  className?: string
89
118
 
119
+ blendMode?: IBlendMode
90
120
  opacity?: number
91
121
  visible?: boolean
122
+ isMask?: boolean
92
123
  zIndex?: number
93
124
 
94
125
  // layout data
@@ -114,30 +145,41 @@ export interface ILeafComputedData {
114
145
  }
115
146
 
116
147
  export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix, ILeafDataProxy, ILeafInputData, IEventer {
117
- readonly tag: string
148
+ tag: string
149
+ readonly __tag: string
150
+
118
151
  readonly __DataProcessor: IObject // IDataProcessor
119
152
  readonly __LayoutProcessor: IObject // ILeafLayout
120
153
 
121
154
  leafer?: ILeafer
122
- root?: ILeaf
123
155
  parent?: ILeaf
124
156
 
125
- __isRoot?: boolean
157
+ isLeafer?: boolean
126
158
  __isBranch?: boolean
127
159
  __isBranchLeaf?: boolean
128
160
 
129
161
  __: ILeafData
130
162
  __layout: ILeafLayout
131
163
 
132
- __relative: IMatrixWithBoundsData
164
+ __local: IMatrixWithBoundsData
133
165
  __world: IMatrixWithBoundsData
134
-
135
166
  __worldOpacity: number
136
- __renderTime: number // μs 1000微秒 = 1毫秒
167
+
168
+ readonly worldTransform: IMatrixData
169
+ readonly localTransform: IMatrixData
170
+
171
+ readonly worldBoxBounds: IBoundsData
172
+ readonly worldStrokeBounds: IBoundsData
173
+ readonly worldRenderBounds: IBoundsData
174
+
175
+ readonly worldOpacity: number
176
+
177
+ __renderTime?: number // μs 1000微秒 = 1毫秒
137
178
 
138
179
  __level: number // 图层级别 root(1) -> hight
139
180
  __tempNumber?: number // 用于临时运算储存状态
140
181
 
182
+ __hasMask?: boolean
141
183
  __hitCanvas?: IHitCanvas
142
184
 
143
185
  __parentWait?: IFunction[]
@@ -145,39 +187,51 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
145
187
  __addParentWait(item: IFunction): void
146
188
  __runParentWait(): void
147
189
 
148
- __setAsLeafer(): void
149
- __setAsRoot(): void
190
+ __bindLeafer(leafer: ILeafer): void
150
191
 
151
- __bindRoot(root: ILeaf): void
192
+ set(data: IObject): void
193
+ get(attrNames?: string[]): IObject
152
194
 
153
195
  // ILeafData ->
154
- __set(attrName: string, newValue: __Value): void
155
- __get(attrName: string): __Value
156
- __updateAttr(attrName: string): void
196
+ __setAttr(attrName: string, newValue: __Value): void
197
+ __getAttr(attrName: string): __Value
198
+ __updateAttr(attrName?: string, value?: __Value): void
199
+
200
+ forceUpdate(): void
157
201
 
158
202
  // ILeafMatrix ->
159
203
  __updateWorldMatrix(): void
160
- __updateRelativeMatrix(): void
204
+ __updateLocalMatrix(): void
161
205
 
162
206
  // ILeafBounds ->
163
207
  __updateWorldBounds(): void
164
208
 
165
- __updateRelativeBoxBounds(): void
166
- __updateRelativeEventBounds(): void
167
- __updateRelativeRenderBounds(): void
209
+ __updateLocalBoxBounds(): void
210
+ __updateLocalStrokeBounds(): void
211
+ __updateLocalRenderBounds(): void
168
212
 
169
213
  __updateBoxBounds(): void
170
- __updateEventBounds(): void
214
+ __updateStrokeBounds(): void
171
215
  __updateRenderBounds(): void
172
216
 
173
- __updateEventBoundsSpreadWidth(): number
217
+ __updateStrokeBoundsSpreadWidth(): number
174
218
  __updateRenderBoundsSpreadWidth(): number
175
219
 
176
220
  __onUpdateSize(): void
177
221
 
222
+ // convert
223
+ getWorld(attrName: IMatrixDecompositionAttr): number
224
+ getBounds(type: ILayoutBoundsType, locationType?: ILayoutLocationType): IBoundsData
225
+
226
+ worldToLocal(world: IPointData, to?: IPointData, isMovePoint?: boolean): void
227
+ localToWorld(local: IPointData, to?: IPointData, isMovePoint?: boolean): void
228
+ worldToInner(world: IPointData, to?: IPointData, isMovePoint?: boolean): void
229
+ innerToWorld(inner: IPointData, to?: IPointData, isMovePoint?: boolean): void
230
+
178
231
  // ILeafHit ->
179
232
  __hitWorld(point: IRadiusPointData): boolean
180
233
  __hit(local: IRadiusPointData): boolean
234
+ __drawHitPath(canvas: ILeaferCanvas): void
181
235
  __updateHitCanvas(): void
182
236
 
183
237
  // ILeafRender ->
@@ -185,6 +239,8 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
185
239
  __drawFast(canvas: ILeaferCanvas, options: IRenderOptions): void
186
240
  __draw(canvas: ILeaferCanvas, options: IRenderOptions): void
187
241
 
242
+ __renderShape(canvas: ILeaferCanvas, options: IRenderOptions): void
243
+
188
244
  __updateWorldOpacity(): void
189
245
  __updateRenderTime(): void
190
246
  __updateChange(): void
@@ -201,6 +257,4 @@ export interface ILeaf extends ILeafRender, ILeafHit, ILeafBounds, ILeafMatrix,
201
257
  __updateSortChildren(): void
202
258
  add(child: ILeaf, index?: number): void
203
259
  remove(child?: ILeaf): void
204
- }
205
-
206
-
260
+ }
@@ -5,15 +5,15 @@ export type ILeafBoundsModule = ILeafBounds & ThisType<ILeaf>
5
5
  export interface ILeafBounds {
6
6
  __updateWorldBounds?(): void
7
7
 
8
- __updateRelativeBoxBounds?(): void
9
- __updateRelativeEventBounds?(): void
10
- __updateRelativeRenderBounds?(): void
8
+ __updateLocalBoxBounds?(): void
9
+ __updateLocalStrokeBounds?(): void
10
+ __updateLocalRenderBounds?(): void
11
11
 
12
12
  __updateBoxBounds?(): void
13
- __updateEventBounds?(): void
13
+ __updateStrokeBounds?(): void
14
14
  __updateRenderBounds?(): void
15
15
 
16
- __updateEventBoundsSpreadWidth?(): number
16
+ __updateStrokeBoundsSpreadWidth?(): number
17
17
  __updateRenderBoundsSpreadWidth?(): number
18
18
 
19
19
  __onUpdateSize?(): void
@@ -4,8 +4,8 @@ import { __Value } from '../../data/IData'
4
4
  export type ILeafDataProxyModule = ILeafDataProxy & ThisType<ILeaf>
5
5
 
6
6
  export interface ILeafDataProxy {
7
- __set?(attrName: string, newValue: __Value): void
8
- __get?(attrName: string): __Value
9
- __updateAttr?(attrName: string): void
7
+ __setAttr?(name: string, newValue: __Value): void
8
+ __getAttr?(name: string): __Value
9
+ __updateAttr?(name?: string, value?: __Value): void
10
10
  }
11
11
 
@@ -1,10 +1,12 @@
1
1
  import { IRadiusPointData } from '../../math/IMath'
2
2
  import { ILeaf } from '../ILeaf'
3
+ import { ILeaferCanvas } from '../../canvas/ILeaferCanvas'
3
4
 
4
5
  export type ILeafHitModule = ILeafHit & ThisType<ILeaf>
5
6
 
6
7
  export interface ILeafHit {
7
8
  __hitWorld?(point: IRadiusPointData): boolean
8
9
  __hit?(local: IRadiusPointData): boolean
10
+ __drawHitPath?(canvas: ILeaferCanvas): void
9
11
  __updateHitCanvas?(): void
10
12
  }
@@ -4,5 +4,5 @@ export type ILeafMatrixModule = ILeafMatrix & ThisType<ILeaf>
4
4
 
5
5
  export interface ILeafMatrix {
6
6
  __updateWorldMatrix?(): void
7
- __updateRelativeMatrix?(): void
7
+ __updateLocalMatrix?(): void
8
8
  }
@@ -9,6 +9,8 @@ export interface ILeafRender {
9
9
  __draw?(canvas: ILeaferCanvas, options: IRenderOptions): void
10
10
  __drawFast?(canvas: ILeaferCanvas, options: IRenderOptions): void
11
11
 
12
+ __renderShape?(canvas: ILeaferCanvas, options: IRenderOptions): void
13
+
12
14
  __drawBefore?(canvas: ILeaferCanvas, options: IRenderOptions): void
13
15
  __drawAfter?(canvas: ILeaferCanvas, options: IRenderOptions): void
14
16
 
@@ -24,6 +24,10 @@ export interface IEventTarget extends IEventer {
24
24
 
25
25
  }
26
26
 
27
+ export interface ILeaferEvent {
28
+
29
+ }
30
+
27
31
  export interface IRenderEvent {
28
32
 
29
33
  }
@@ -52,7 +56,7 @@ export interface IUpdateEvent extends IEvent {
52
56
 
53
57
  }
54
58
 
55
- export interface IAttrEvent extends IEvent {
59
+ export interface IPropertyEvent extends IEvent {
56
60
  readonly attrName: string
57
61
  readonly oldValue: unknown
58
62
  readonly newValue: unknown
@@ -1,5 +1,7 @@
1
+ import { IObject } from '../data/IData'
1
2
  import { ILeafList } from '../data/IList'
2
3
  import { IEvent } from './IEvent'
4
+ import { ILeaferImage } from '../image/ILeaferImage'
3
5
 
4
6
  export interface IUIEvent extends IEvent {
5
7
  x: number
@@ -19,6 +21,8 @@ export interface IUIEvent extends IEvent {
19
21
  path: ILeafList
20
22
  throughPath?: ILeafList // 穿透path,不受层级影响,从上到下只要碰撞到区域就算,一般点击的时候
21
23
 
24
+ origin: IObject
25
+
22
26
  stopDefault(): void
23
27
  stopNow(): void
24
28
  stop(): void
@@ -46,6 +50,7 @@ export interface IDragEvent extends IPointerEvent {
46
50
 
47
51
  export interface IDropEvent extends IPointerEvent {
48
52
  list: ILeafList
53
+ data?: IObject
49
54
  }
50
55
 
51
56
  export interface IRotateEvent extends IUIEvent {
@@ -66,4 +71,9 @@ export interface ISwipeEvent extends IDragEvent {
66
71
 
67
72
  export interface IKeyEvent extends IUIEvent {
68
73
 
74
+ }
75
+
76
+ export interface IImageEvent extends IEvent {
77
+ image: ILeaferImage
78
+ error: string | IObject
69
79
  }
@@ -1,3 +1,9 @@
1
+ import { ILeaferImage, ILeaferImageConfig, ILeaferImageOnError, ILeaferImageOnLoaded } from './ILeaferImage'
2
+
3
+
1
4
  export interface IImageManager {
5
+ get(config: ILeaferImageConfig): ILeaferImage
6
+ onLoad(config: ILeaferImageConfig, onLoaded: ILeaferImageOnLoaded): void
7
+ onError(config: ILeaferImageConfig, onError: ILeaferImageOnError): void
2
8
  destory(): void
3
9
  }
@@ -1,12 +1,25 @@
1
+ import { IObject } from '../data/IData'
2
+
1
3
  export interface ILeaferImageConfig {
2
4
  url: string
3
5
  thumb?: string
4
6
  }
5
7
 
8
+ export interface ILeaferImageOnLoaded {
9
+ (image?: ILeaferImage): any
10
+ }
6
11
 
12
+ export interface ILeaferImageOnError {
13
+ (error?: string | IObject, image?: ILeaferImage): any
14
+ }
7
15
 
8
16
  export interface ILeaferImage {
9
- //load(url: string):Promise<>
17
+ view: unknown
18
+ width: number
19
+ height: number
20
+ ready: boolean
21
+ load(onSuccess?: ILeaferImageOnLoaded, onError?: ILeaferImageOnError): void
22
+ getCanvas(width: number, height: number, opacity?: number, _filters?: IObject): unknown
10
23
  }
11
24
 
12
25
  export type IImageStatus = 'wait' | 'thumb-loading' | 'thumb-success' | 'thumb-error' | 'loading' | 'success' | 'error'
package/src/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { IApp } from './app/IApp'
2
- export { ILeafer, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
- export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType } from './display/ILeaf'
2
+ export { ILeafer, ILeaferType, ILeaferConfig, ICreator, IUICreator } from './app/ILeafer'
3
+ export { ILeaf, ILeafAttrData, ILeafComputedData, ILeafInputData, ICachedLeaf, IHitType, IBlendMode } from './display/ILeaf'
4
4
  export { IBranch } from './display/IBranch'
5
5
  export { IZoomView } from './display/IView'
6
6
 
@@ -34,15 +34,15 @@ export { IPathDrawer } from './path/IPathDrawer'
34
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
- export { ILeaferImage, ILeaferImageConfig } from './image/ILeaferImage'
37
+ export { ILeaferImage, ILeaferImageConfig, ILeaferImageOnLoaded, ILeaferImageOnError } from './image/ILeaferImage'
38
38
 
39
39
  export { InnerId, IEventer, IEventListener, IEventListenerOptions, IEventListenerMap, IEventListenerItem, IEventListenerId } from './event/IEventer'
40
- export { IEventTarget, IEvent, IAttrEvent, ILayoutEvent, IRenderEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, ITransformEvent, ITransformEventData, TransformMode } from './event/IEvent'
41
- export { IUIEvent, IPointerEvent, PointerType, IDragEvent, IDropEvent, ISwipeEvent, IMoveEvent, IZoomEvent, IRotateEvent, IKeyEvent } from './event/IUIEvent'
42
- export { IInteraction, IInteractionConfig, IWheelConfig, IPointerConfig } from './interaction/IInteraction'
40
+ export { IEventTarget, IEvent, ILeaferEvent, IPropertyEvent, ILayoutEvent, IRenderEvent, IChildEvent, IResizeEvent, IResizeEventListener, IUpdateEvent, IWatchEvent, ITransformEvent, ITransformEventData, TransformMode } from './event/IEvent'
41
+ export { IUIEvent, IPointerEvent, PointerType, IDragEvent, IDropEvent, ISwipeEvent, IMoveEvent, IZoomEvent, IRotateEvent, IKeyEvent, IImageEvent } from './event/IUIEvent'
42
+ export { IInteraction, IInteractionCanvas, IInteractionConfig, IWheelConfig, IPointerConfig } from './interaction/IInteraction'
43
43
 
44
44
 
45
45
  export { __Number, __Boolean, __String, __Object, __Value, IObject, INumberMap, IStringMap, IBooleanMap, IDataTypeHandle } from './data/IData'
46
46
  export { ILeafList, ILeafArrayMap, ILeafMap, ILeafLevelList, ILeafListItemCallback } from './data/IList'
47
- export { IPoint, IPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataHandle, IOffsetBoundsData, ITwoPointBounds, ITwoPointBoundsData, IAutoBounds, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData } from './math/IMath'
47
+ export { IPoint, IPointData, IRadiusPointData, ISize, ISizeData, IScreenSizeData, IBounds, IBoundsData, IBoundsDataHandle, IOffsetBoundsData, ITwoPointBounds, ITwoPointBoundsData, IAutoBounds, IAutoBoundsData, IMatrix, IMatrixData, IMatrixWithBoundsData, IMatrixDecompositionData, IMatrixDecompositionAttr } from './math/IMath'
48
48
  export { IFunction } from './function/IFunction'
@@ -4,12 +4,11 @@ import { ILeaf } from '../display/ILeaf'
4
4
  import { ILeafList } from '../data/IList'
5
5
  import { IPointData } from '../math/IMath'
6
6
  import { ISelector } from '../selector/ISelector'
7
- import { ILeaferCanvas } from '../canvas/ILeaferCanvas'
8
7
  import { IBounds } from '../math/IMath'
9
8
 
10
9
  export interface IInteraction {
11
10
  target: ILeaf
12
- canvas: ILeaferCanvas
11
+ canvas: IInteractionCanvas
13
12
  selector: ISelector
14
13
 
15
14
  running: boolean
@@ -40,6 +39,11 @@ export interface IInteraction {
40
39
  destroy(): void
41
40
  }
42
41
 
42
+ export interface IInteractionCanvas {
43
+ bounds: IBounds
44
+ view: unknown
45
+ }
46
+
43
47
  export interface IInteractionConfig {
44
48
  wheel?: IWheelConfig
45
49
  pointer?: IPointerConfig
@@ -54,16 +58,20 @@ export interface IWheelConfig {
54
58
  delta?: IPointData // 以chrome为基准, 鼠标滚动一格的距离
55
59
  getScale?: INumberFunction
56
60
  getMove?: IPointDataFunction
61
+ preventDefault?: boolean
57
62
  }
58
63
 
59
64
  export interface IPointerConfig {
60
65
  hitRadius?: number
61
66
  through?: boolean
62
- clickTime?: number
67
+ tapMulti?: boolean
68
+ tapTime?: number
63
69
  longPressTime?: number
64
70
  transformTime?: number
71
+ dragHover?: boolean
65
72
  dragDistance?: number
66
73
  swipeDistance?: number
67
74
  autoMoveDistance?: number
68
- ignoreMove: boolean // 性能优化字段, 控制move事件触发次数
75
+ ignoreMove?: boolean // 性能优化字段, 控制move事件触发次数
76
+ preventDefault?: boolean
69
77
  }
@@ -1,8 +1,8 @@
1
- import { IBoundsData, IMatrixData } from '../math/IMath'
1
+ import { IBoundsData, IMatrixData, IMatrixDecompositionData } from '../math/IMath'
2
2
  import { ILeaf } from '../display/ILeaf'
3
3
 
4
- export type ILayoutLocationType = 'world' | 'relative' | 'local'
5
- export type ILayoutBoundsType = 'content' | 'box' | 'event' | 'margin' | 'render'
4
+ export type ILayoutLocationType = 'world' | 'local' | 'inner'
5
+ export type ILayoutBoundsType = 'content' | 'box' | 'stroke' | 'margin' | 'render'
6
6
 
7
7
  export interface ILeafLayout {
8
8
 
@@ -13,23 +13,23 @@ export interface ILeafLayout {
13
13
  // local
14
14
 
15
15
  boxBounds: IBoundsData // | content + padding |
16
- eventBounds: IBoundsData // | boxBounds + border |
17
- renderBounds: IBoundsData // | eventBounds + shadow |
16
+ strokeBounds: IBoundsData // | boxBounds + border |
17
+ renderBounds: IBoundsData // | strokeBounds + shadow |
18
18
 
19
19
  // auto layout
20
- marginBounds: IBoundsData // | eventBounds + margin |
20
+ marginBounds: IBoundsData // | strokeBounds + margin |
21
21
  contentBounds: IBoundsData // | content |
22
22
 
23
- // relative
23
+ // local
24
24
 
25
- //relativeBoxBounds: IBoundsData = leaf.__local
26
- relativeEventBounds: IBoundsData
27
- relativeRenderBounds: IBoundsData
25
+ //localBoxBounds: IBoundsData = leaf.__local
26
+ localStrokeBounds: IBoundsData
27
+ localRenderBounds: IBoundsData
28
28
 
29
29
  // state
30
30
 
31
31
  // matrix changed
32
- matrixChanged: boolean
32
+ matrixChanged: boolean // include positionChanged scaleChanged skewChanged
33
33
  positionChanged: boolean // x, y
34
34
  scaleChanged: boolean // scaleX scaleY
35
35
  rotationChanged: boolean // rotaiton, skewX scaleY 数据更新
@@ -38,7 +38,7 @@ export interface ILeafLayout {
38
38
  boundsChanged: boolean
39
39
 
40
40
  boxBoundsChanged: boolean
41
- eventBoundsChanged: boolean
41
+ strokeBoundsChanged: boolean
42
42
  renderBoundsChanged: boolean
43
43
 
44
44
  localBoxBoundsChanged: boolean // position
@@ -54,24 +54,25 @@ export interface ILeafLayout {
54
54
  // keep state
55
55
  affectScaleOrRotation: boolean
56
56
  affectRotation: boolean
57
- eventBoundsSpreadWidth: number
57
+ strokeBoundsSpreadWidth: number
58
58
  renderBoundsSpreadWidth: number
59
59
  renderShapeBoundsSpreadWidth: number
60
60
 
61
61
  update(): void
62
62
 
63
- getTransform(type: ILayoutLocationType): IMatrixData
64
- getBounds(type: ILayoutLocationType, boundsType: ILayoutBoundsType): IBoundsData
63
+ getTransform(locationType: ILayoutLocationType): IMatrixData
64
+ getMatrixDecompositionData(locationType: ILayoutLocationType): IMatrixDecompositionData
65
+ getBounds(type: ILayoutBoundsType, locationType: ILayoutLocationType): IBoundsData
65
66
 
66
67
  // 独立 / 引用 boxBounds
67
- eventBoundsSpread(): void
68
+ strokeBoundsSpread(): void
68
69
  renderBoundsSpread(): void
69
- eventBoundsSpreadCancel(): void
70
+ strokeBoundsSpreadCancel(): void
70
71
  renderBoundsSpreadCancel(): void
71
72
 
72
73
  // bounds
73
74
  boxBoundsChange(): void
74
- eventBoundsChange(): void
75
+ strokeBoundsChange(): void
75
76
  renderBoundsChange(): void
76
77
 
77
78
  // matrix
package/src/math/IMath.ts CHANGED
@@ -12,13 +12,15 @@ export interface IPoint extends IPointData {
12
12
 
13
13
  rotate(angle: number, center?: IPointData): IPoint
14
14
 
15
- toLocal(matrix: IMatrixData, to?: IPointData): IPoint
16
- toWorld(matrix: IMatrixData, to?: IPointData): IPoint
15
+ toInnerOf(matrix: IMatrixData, to?: IPointData): IPoint
16
+ toOuterOf(matrix: IMatrixData, to?: IPointData): IPoint
17
17
 
18
18
  getCenter(to: IPointData): IPointData
19
19
  getDistance(to: IPointData): number
20
20
  getAngle(to: IPointData): number
21
21
  getAtan2(to: IPointData): number
22
+
23
+ reset(): void
22
24
  }
23
25
 
24
26
  export interface IRadiusPointData extends IPointData {
@@ -55,7 +57,7 @@ export interface IBounds extends IBoundsData {
55
57
  clone(): IBounds
56
58
 
57
59
  scale(scale: number): IBounds
58
- toWorld(matrix: IMatrixData, to?: IBoundsData): IBounds
60
+ toOuterOf(matrix: IMatrixData, to?: IBoundsData): IBounds
59
61
  getFitMatrix(put: IBoundsData): IMatrix
60
62
 
61
63
  spread(size: number): IBounds
@@ -78,7 +80,7 @@ export interface IBounds extends IBoundsData {
78
80
 
79
81
  isSame(bounds: IBoundsData): boolean
80
82
  isEmpty(): boolean
81
- empty(): void
83
+ reset(): void
82
84
  }
83
85
 
84
86
  export interface ITwoPointBoundsData {
@@ -120,21 +122,56 @@ export interface IMatrixData {
120
122
  e: number
121
123
  f: number
122
124
  }
125
+
126
+ export interface IMatrixDecompositionData {
127
+ x: number
128
+ y: number
129
+ scaleX: number
130
+ scaleY: number
131
+ rotation: number
132
+ skewX: number
133
+ skewY: number
134
+ }
135
+
136
+ export type IMatrixDecompositionAttr =
137
+ | 'x'
138
+ | 'y'
139
+ | 'scaleX'
140
+ | 'scaleY'
141
+ | 'rotation'
142
+ | 'skewX'
143
+ | 'skewY'
144
+
123
145
  export interface IMatrix extends IMatrixData {
124
146
  set(a: number, b: number, c: number, d: number, e: number, f: number): void
125
147
  copy(matrix: IMatrixData): IMatrix
126
148
  clone(): IMatrix
127
149
 
128
150
  translate(x: number, y: number): IMatrix
151
+ translateInner(x: number, y: number): IMatrix
152
+
129
153
  scale(x: number, y?: number): IMatrix
154
+ scaleOf(center: IPointData, x: number, y?: number): IMatrix
155
+ scaleOfInner(center: IPointData, x: number, y?: number): IMatrix
156
+
130
157
  rotate(angle: number): IMatrix
158
+ rotateOf(center: IPointData, angle: number): IMatrix
159
+ rotateOfInner(center: IPointData, angle: number): IMatrix
131
160
 
132
- times(matrix: IMatrixData): IMatrix
161
+ skew(x: number, y?: number): IMatrix
162
+ skewOf(center: IPointData, x: number, y?: number): IMatrix
163
+ skewOfInner(center: IPointData, x: number, y?: number): IMatrix
164
+
165
+ multiply(matrix: IMatrixData): IMatrix
133
166
  divide(matrix: IMatrixData): IMatrix
134
167
  invert(): IMatrix
135
168
 
136
- toWorldPoint(local: IPointData, to?: IPointData): void
137
- toLocalPoint(world: IPointData, to?: IPointData): void
169
+ toOuterPoint(inner: IPointData, to?: IPointData): void
170
+ toInnerPoint(outer: IPointData, to?: IPointData): void
171
+
172
+ decompose(): IMatrixDecompositionData
173
+
174
+ reset(): void
138
175
  }
139
176
 
140
177
 
@@ -5,4 +5,5 @@ export interface IPlatform {
5
5
  requestRender?(render: IFunction): void
6
6
  canvas?: ILeaferCanvas
7
7
  isWorker?: boolean
8
+ conicGradientRotate90?: boolean // fixfox need rotate
8
9
  }
@@ -38,8 +38,8 @@ export interface IRenderer {
38
38
  render(callback?: IFunction): void
39
39
  renderOnce(callback?: IFunction): void
40
40
  partRender(): void
41
- clipRender(bounds: IBounds, fullMode?: boolean): void
42
- fullRender(bounds?: IBounds): void
41
+ clipRender(bounds: IBounds): void
42
+ fullRender(): void
43
43
 
44
44
  addBlock(block: IBounds): void
45
45
  mergeBlocks(): void