@hatiolab/things-scene 2.7.15 → 2.7.19
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 +1 -1
- package/things-scene.d.ts +81 -16
- package/things-scene.mjs +1 -1
package/package.json
CHANGED
package/things-scene.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
declare module '@hatiolab/things-scene' {
|
|
2
2
|
type Constructor<T = {}> = new (...args: any[]) => T
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
type MODE_VIEW = 0
|
|
5
|
+
type MODE_EDIT = 1
|
|
6
|
+
type MODE_SHIFT = 2
|
|
7
|
+
|
|
8
|
+
type SCENE_MODE = MODE_VIEW | MODE_EDIT
|
|
9
9
|
|
|
10
10
|
type FITMODE = 'both' | 'ratio' | 'width' | 'height' | 'center' | 'none'
|
|
11
11
|
type DIMENSION = { x: number; y: number }
|
|
@@ -13,6 +13,8 @@ declare module '@hatiolab/things-scene' {
|
|
|
13
13
|
type TRANSLATE = DIMENSION
|
|
14
14
|
type POSITION = DIMENSION
|
|
15
15
|
|
|
16
|
+
type Properties = { [key: string]: any }
|
|
17
|
+
|
|
16
18
|
type ControlHandler = {
|
|
17
19
|
ondragstart?(point: POSITION, index: number, component: Component): void
|
|
18
20
|
ondragmove?(point: POSITION, index: number, component: Component): void
|
|
@@ -76,7 +78,10 @@ declare module '@hatiolab/things-scene' {
|
|
|
76
78
|
dispose(): void
|
|
77
79
|
}
|
|
78
80
|
|
|
81
|
+
/* mixins */
|
|
82
|
+
|
|
79
83
|
function RectPath<TBase extends Constructor>(Base: TBase): TBase
|
|
84
|
+
|
|
80
85
|
function ValueHolder<TBase extends Constructor>(
|
|
81
86
|
Base: TBase
|
|
82
87
|
): {
|
|
@@ -87,12 +92,50 @@ declare module '@hatiolab/things-scene' {
|
|
|
87
92
|
}
|
|
88
93
|
} & TBase
|
|
89
94
|
|
|
90
|
-
|
|
95
|
+
function DataSource<TBase extends Constructor>(
|
|
96
|
+
Base: TBase
|
|
97
|
+
): {
|
|
98
|
+
new (...args: any[]): {
|
|
99
|
+
isDataSource(): boolean
|
|
100
|
+
}
|
|
101
|
+
} & TBase
|
|
102
|
+
|
|
103
|
+
function MoveHandle<TBase extends Constructor>(Base: TBase): TBase
|
|
104
|
+
|
|
105
|
+
function MixinHTMLElement<TBase extends Constructor>(
|
|
106
|
+
Base: TBase
|
|
107
|
+
): {
|
|
108
|
+
new (...args: any[]): {
|
|
109
|
+
get tagName(): string
|
|
110
|
+
element: HTMLElement
|
|
111
|
+
|
|
112
|
+
createElement(): void
|
|
113
|
+
userInputEventHandler(e: Event): void
|
|
114
|
+
reposition(): void
|
|
115
|
+
disposeElement(): void
|
|
116
|
+
}
|
|
117
|
+
} & TBase
|
|
118
|
+
|
|
119
|
+
function MixinEvent<TBase extends Constructor>(
|
|
120
|
+
Base: TBase
|
|
121
|
+
): {
|
|
122
|
+
new (...args: any[]): {
|
|
123
|
+
on(name: string, callback: Function, context?: any): void
|
|
124
|
+
off(name: string, callback: Function, context?: any): void
|
|
125
|
+
once(name: string, callback: Function, context?: any): void
|
|
126
|
+
trigger(name: string): void
|
|
127
|
+
}
|
|
128
|
+
} & TBase
|
|
129
|
+
|
|
130
|
+
/* components */
|
|
131
|
+
|
|
132
|
+
class Component extends MixinEvent(Object) {
|
|
91
133
|
static register(type: string, Clazz: typeof Component): void
|
|
92
134
|
|
|
93
|
-
state:
|
|
135
|
+
state: Properties
|
|
94
136
|
bounds: { top: number; left: number; width: number; height: number }
|
|
95
137
|
root: RootContainer
|
|
138
|
+
rootModel: ModelLayer
|
|
96
139
|
parent: Container
|
|
97
140
|
app: ApplicationContext /* application context */
|
|
98
141
|
model: Model
|
|
@@ -100,14 +143,22 @@ declare module '@hatiolab/things-scene' {
|
|
|
100
143
|
path: Array<DIMENSION>
|
|
101
144
|
anchors: Array<Anchor>
|
|
102
145
|
data: any
|
|
146
|
+
|
|
103
147
|
get controls(): Array<Control> | undefined
|
|
104
148
|
get hasTextProperty(): boolean
|
|
105
149
|
|
|
106
150
|
ready(): void
|
|
107
151
|
dispose(): void
|
|
108
|
-
|
|
109
|
-
|
|
152
|
+
getState(prop: string): any
|
|
153
|
+
setState(props: Properties | any, value?: any): void
|
|
154
|
+
get(prop: string): any
|
|
155
|
+
set(props: Properties | string, value?: any): void
|
|
110
156
|
reposition(): void
|
|
157
|
+
transcoordP2S(x: number, y: number): POSITION
|
|
158
|
+
render(context: CanvasRenderingContext2D): void
|
|
159
|
+
executeMappings(force?: boolean): void
|
|
160
|
+
|
|
161
|
+
onchange(after: Properties, before: Properties): void
|
|
111
162
|
|
|
112
163
|
drawImage(
|
|
113
164
|
context: CanvasRenderingContext2D,
|
|
@@ -124,23 +175,37 @@ declare module '@hatiolab/things-scene' {
|
|
|
124
175
|
ondblclick(e: MouseEvent): void
|
|
125
176
|
}
|
|
126
177
|
|
|
127
|
-
class
|
|
178
|
+
class ContainerAbstract extends MoveHandle(RectPath(Component)) {}
|
|
179
|
+
class Container extends MixinHTMLElement(ContainerAbstract) {
|
|
128
180
|
indexOf(component: Component): number
|
|
129
181
|
insertComponentAt(target: Component, idx: number): void
|
|
130
182
|
findById(id: string): Component
|
|
131
183
|
}
|
|
132
184
|
class RootContainer extends Container {}
|
|
133
185
|
|
|
186
|
+
class Layer extends ContainerAbstract {
|
|
187
|
+
target: HTMLElement
|
|
188
|
+
canvas: HTMLCanvasElement
|
|
189
|
+
|
|
190
|
+
getContext(): CanvasRenderingContext2D
|
|
191
|
+
invalidate(): void
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
class ModelLayer extends Layer {
|
|
195
|
+
overlay: HTMLDivElement
|
|
196
|
+
}
|
|
197
|
+
|
|
134
198
|
class Shape extends Component {}
|
|
135
199
|
class Ellipse extends Shape {}
|
|
136
|
-
class
|
|
137
|
-
|
|
138
|
-
}
|
|
200
|
+
class Rect extends RectPath(Shape) {}
|
|
201
|
+
class HTMLOverlayElement extends MixinHTMLElement(RectPath(Component)) {}
|
|
139
202
|
|
|
140
203
|
class HTMLOverlayContainer extends Container {
|
|
141
204
|
readonly layout: any
|
|
142
205
|
}
|
|
143
206
|
|
|
207
|
+
/* Scene API */
|
|
208
|
+
|
|
144
209
|
class Scene {
|
|
145
210
|
static readonly residents: WeakSet<Scene>
|
|
146
211
|
|
|
@@ -275,9 +340,9 @@ declare module '@hatiolab/things-scene' {
|
|
|
275
340
|
*/
|
|
276
341
|
serialize(): string
|
|
277
342
|
|
|
278
|
-
on(event: string, listener: Function, context
|
|
279
|
-
once(event: string, listener: Function, context
|
|
280
|
-
off(event: string, listener: Function, context
|
|
343
|
+
on(event: string, listener: Function, context?: any): void
|
|
344
|
+
once(event: string, listener: Function, context?: any): void
|
|
345
|
+
off(event: string, listener: Function, context?: any): void
|
|
281
346
|
|
|
282
347
|
toDataURL(): string
|
|
283
348
|
|