@hatiolab/things-scene 2.7.16 → 2.7.17

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": "@hatiolab/things-scene",
3
- "version": "2.7.16",
3
+ "version": "2.7.17",
4
4
  "description": "2D graphic library",
5
5
  "main": "src/index.js",
6
6
  "module": "things-scene.mjs",
package/things-scene.d.ts CHANGED
@@ -78,7 +78,10 @@ declare module '@hatiolab/things-scene' {
78
78
  dispose(): void
79
79
  }
80
80
 
81
+ /* mixins */
82
+
81
83
  function RectPath<TBase extends Constructor>(Base: TBase): TBase
84
+
82
85
  function ValueHolder<TBase extends Constructor>(
83
86
  Base: TBase
84
87
  ): {
@@ -88,6 +91,7 @@ declare module '@hatiolab/things-scene' {
88
91
  animOnValueChange(value: number, animFromBase: boolean, base: number): void
89
92
  }
90
93
  } & TBase
94
+
91
95
  function DataSource<TBase extends Constructor>(
92
96
  Base: TBase
93
97
  ): {
@@ -96,12 +100,42 @@ declare module '@hatiolab/things-scene' {
96
100
  }
97
101
  } & TBase
98
102
 
99
- class Component {
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) {
100
133
  static register(type: string, Clazz: typeof Component): void
101
134
 
102
135
  state: Properties
103
136
  bounds: { top: number; left: number; width: number; height: number }
104
137
  root: RootContainer
138
+ rootModel: ModelLayer
105
139
  parent: Container
106
140
  app: ApplicationContext /* application context */
107
141
  model: Model
@@ -109,6 +143,7 @@ declare module '@hatiolab/things-scene' {
109
143
  path: Array<DIMENSION>
110
144
  anchors: Array<Anchor>
111
145
  data: any
146
+
112
147
  get controls(): Array<Control> | undefined
113
148
  get hasTextProperty(): boolean
114
149
 
@@ -121,6 +156,7 @@ declare module '@hatiolab/things-scene' {
121
156
  reposition(): void
122
157
  transcoordP2S(x: number, y: number): POSITION
123
158
  render(context: CanvasRenderingContext2D): void
159
+ executeMappings(force?: boolean): void
124
160
 
125
161
  onchange(after: Properties, before: Properties): void
126
162
 
@@ -139,26 +175,37 @@ declare module '@hatiolab/things-scene' {
139
175
  ondblclick(e: MouseEvent): void
140
176
  }
141
177
 
142
- class Container extends Component {
178
+ class ContainerAbstract extends MoveHandle(RectPath(Component)) {}
179
+ class Container extends MixinHTMLElement(ContainerAbstract) {
143
180
  indexOf(component: Component): number
144
181
  insertComponentAt(target: Component, idx: number): void
145
182
  findById(id: string): Component
146
183
  }
147
184
  class RootContainer extends Container {}
148
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
+
149
198
  class Shape extends Component {}
150
199
  class Ellipse extends Shape {}
151
200
  class Rect extends RectPath(Shape) {}
152
- class HTMLOverlayElement extends Component {
153
- element: HTMLElement
154
-
155
- createElement(): void
156
- }
201
+ class HTMLOverlayElement extends MixinHTMLElement(RectPath(Component)) {}
157
202
 
158
203
  class HTMLOverlayContainer extends Container {
159
204
  readonly layout: any
160
205
  }
161
206
 
207
+ /* Scene API */
208
+
162
209
  class Scene {
163
210
  static readonly residents: WeakSet<Scene>
164
211
 
@@ -293,9 +340,9 @@ declare module '@hatiolab/things-scene' {
293
340
  */
294
341
  serialize(): string
295
342
 
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
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
299
346
 
300
347
  toDataURL(): string
301
348