@hatiolab/things-scene 2.7.16 → 2.7.20

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