@hatiolab/things-scene 2.7.11 → 2.7.15

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.
@@ -0,0 +1,296 @@
1
+ declare module '@hatiolab/things-scene' {
2
+ type Constructor<T = {}> = new (...args: any[]) => T
3
+
4
+ enum SCENE_MODE {
5
+ MODE_VIEW = 0,
6
+ MODE_EDIT = 1,
7
+ MODE_SHIFT = 2
8
+ }
9
+
10
+ type FITMODE = 'both' | 'ratio' | 'width' | 'height' | 'center' | 'none'
11
+ type DIMENSION = { x: number; y: number }
12
+ type SCALE = DIMENSION
13
+ type TRANSLATE = DIMENSION
14
+ type POSITION = DIMENSION
15
+
16
+ type ControlHandler = {
17
+ ondragstart?(point: POSITION, index: number, component: Component): void
18
+ ondragmove?(point: POSITION, index: number, component: Component): void
19
+ ondragend?(point: POSITION, index: number, component: Component): void
20
+ }
21
+
22
+ interface Control extends DIMENSION {
23
+ handler: ControlHandler
24
+ }
25
+
26
+ function create({
27
+ target,
28
+ model,
29
+ style,
30
+ layers,
31
+ handlers,
32
+ mode,
33
+ refProvider,
34
+ baseUrl,
35
+ fitMode
36
+ }: {
37
+ target?: HTMLElement
38
+ model: Object
39
+ style?: any
40
+ layers?: Array<any>
41
+ handlers?: Array<any>
42
+ mode?: SCENE_MODE
43
+ refProvider?: any
44
+ baseUrl?: string | undefined
45
+ fitMode?: FITMODE
46
+ }): Scene
47
+
48
+ function error(...args: any[]): void
49
+ function warn(...args: any[]): void
50
+ function debug(...args: any[]): void
51
+
52
+ class ScriptLoader {
53
+ static load(scripts: string | Array<string>, styles?: string | Array<string>): Promise<void>
54
+ }
55
+
56
+ class Anchor {
57
+ constructor({ component, anchor, position }: { component: Component; anchor: string; position: POSITION })
58
+
59
+ position: POSITION
60
+ }
61
+
62
+ class Model {
63
+ static compile(model: Model, context: any): Component
64
+
65
+ type: string;
66
+ [key: string]: any
67
+ }
68
+
69
+ class ApplicationContext {
70
+ readonly refProvider: any
71
+ readonly isViewMode: boolean
72
+
73
+ mode: SCENE_MODE
74
+ baseUrl: string
75
+
76
+ dispose(): void
77
+ }
78
+
79
+ function RectPath<TBase extends Constructor>(Base: TBase): TBase
80
+ function ValueHolder<TBase extends Constructor>(
81
+ Base: TBase
82
+ ): {
83
+ new (...args: any[]): {
84
+ value: number
85
+ animValue: number
86
+ animOnValueChange(value: number, animFromBase: boolean, base: number): void
87
+ }
88
+ } & TBase
89
+
90
+ class Component {
91
+ static register(type: string, Clazz: typeof Component): void
92
+
93
+ state: { [key: string]: any }
94
+ bounds: { top: number; left: number; width: number; height: number }
95
+ root: RootContainer
96
+ parent: Container
97
+ app: ApplicationContext /* application context */
98
+ model: Model
99
+ hierarchy: Model
100
+ path: Array<DIMENSION>
101
+ anchors: Array<Anchor>
102
+ data: any
103
+ get controls(): Array<Control> | undefined
104
+ get hasTextProperty(): boolean
105
+
106
+ ready(): void
107
+ dispose(): void
108
+ setState(state: any): void
109
+ get(state: string): any
110
+ reposition(): void
111
+
112
+ drawImage(
113
+ context: CanvasRenderingContext2D,
114
+ image: HTMLImageElement,
115
+ left: number,
116
+ top: number,
117
+ width: number,
118
+ height: number
119
+ ): void
120
+ drawStroke(context: CanvasRenderingContext2D): void
121
+ drawFill(context: CanvasRenderingContext2D): void
122
+ drawText(context: CanvasRenderingContext2D): void
123
+
124
+ ondblclick(e: MouseEvent): void
125
+ }
126
+
127
+ class Container extends Component {
128
+ indexOf(component: Component): number
129
+ insertComponentAt(target: Component, idx: number): void
130
+ findById(id: string): Component
131
+ }
132
+ class RootContainer extends Container {}
133
+
134
+ class Shape extends Component {}
135
+ class Ellipse extends Shape {}
136
+ class HTMLOverlayElement extends Component {
137
+ element: HTMLElement
138
+ }
139
+
140
+ class HTMLOverlayContainer extends Container {
141
+ readonly layout: any
142
+ }
143
+
144
+ class Scene {
145
+ static readonly residents: WeakSet<Scene>
146
+
147
+ /**
148
+ * scene에 컴포넌트를 추가한다.
149
+ * @param models {object} - Component Model Object
150
+ * @param boundsOrOffset {object} - x, y, cx, cy, ...
151
+ * @param onto {string} - onto
152
+ */
153
+ add({ models, boundsOrOffset, onto }: { models: object; boundsOrOffset: object; onto: string }): Component
154
+
155
+ /**
156
+ * scene의 컴포넌트를 복제한다.
157
+ * 현재 선택되어있는 컴포넌트가 복제되므로, 컴포넌트를 복제하기 위해서는
158
+ * 먼저 복제하고자하는 컴포넌트를 선택된 상태로 만든 후에(참조. {@link select} 메쏘드) 이 메쏘드를 호출한다.
159
+ */
160
+ duplicate(): void
161
+
162
+ /**
163
+ * scene의 컴포넌트를 삭제한다.
164
+ * 현재 선택되어있는 컴포넌트가 삭제되므로, 컴포넌트를 삭제하기 위해서는
165
+ * 먼저 삭제하고자하는 컴포넌트를 선택된 상태로 만든 후에(참조. {@link select} 메쏘드) 이 메쏘드를 호출한다.
166
+ */
167
+ remove(): void
168
+
169
+ animate({
170
+ duration /* unit: milli-second, 1000 milli-seconds by default */,
171
+ delay /* default 30 */,
172
+ step /* step function */,
173
+ delta /* delta function */,
174
+ ease /* ease function */,
175
+ options,
176
+ repeat /* default false */
177
+ }: {
178
+ duration: number
179
+ delay: number
180
+ step: Function
181
+ delta: 'linear' | 'quad' | 'circ' | 'back' | 'bounce' | 'elastic' | Function
182
+ ease: 'out' | 'inout'
183
+ options?: object
184
+ repeat: boolean
185
+ }): {
186
+ start: Function /* start function */
187
+ stop: Function /* stop function */
188
+ }
189
+
190
+ /**
191
+ * scene이 그려지고 있는 컨테이너를 전체화면 모드에서 표시되도록 한다.
192
+ */
193
+ fullscreen(): void
194
+
195
+ /**
196
+ * 파라미터로 주어지는 id를 가진 컴포넌트의 data 값을 변경한다.
197
+ * @param id {string} - component id
198
+ * @param value {any} - data value
199
+ */
200
+ variable(id: string, value: any): any
201
+
202
+ target: HTMLElement
203
+ scale: SCALE
204
+ translate: TRANSLATE
205
+
206
+ readonly unit: string /* 'px' */
207
+ readonly PPM: number
208
+ readonly PPI: number
209
+ readonly DPPX: number
210
+
211
+ /**
212
+ * Scene 모델의 단위(unit)을 감안한 기본 Scale 값을 제공한다.
213
+ * 통산 'mm', 'cm' 단위의 Scene은 각 값에 10배를 곱한 수치로 모델링된다.(값을 10으로 나눈값이 실제 단위와 일치한다.)
214
+ * unitScale의 의미는 scene에 unitScale값으로 scale하면, 각 단위값이 화면과 일치한다는 의미이다.
215
+ *
216
+ * 모델링의 수치단위가 픽셀이 아니고, mm, cm, inch 등의 단위인 경우에,
217
+ * 화면에서의 크기가 실물과 유사하게 보이는 수준의 기본 스케일을 제공하는 기능이다.
218
+ * 이 값은 내부적으로는, Ruler에서 눈금을 실제 자의 눈금과 일치시키기 위해서 사용한다.
219
+ */
220
+ readonly unitScale: string
221
+
222
+ /**
223
+ * scene이 그려질 모니터 화면의 크기정보 (inch)
224
+ * 예시) 17, 20, 24, 27, 30, ...
225
+ * @type {number}
226
+ */
227
+ screen: number
228
+
229
+ /**
230
+ * 컨테이너의 크기에 맞게 크기를 조정한다.
231
+ */
232
+ resize(): void
233
+
234
+ dispose(): void
235
+
236
+ /* Selection Based API - Modeling APIs */
237
+
238
+ /**
239
+ * scene 내에서 선택된 컴포넌트의 리스트
240
+ * @type {object-array}
241
+ */
242
+ selected: Array<Component>
243
+
244
+ /**
245
+ * scene이 그리고 있는 컴포넌트 모델정보
246
+ * @type {object}
247
+ */
248
+ model: Component
249
+
250
+ /*
251
+ * root는 모델의 최상위 컨테이너인 모델레이어를 의미한다.
252
+ */
253
+ readonly root: Container
254
+
255
+ /*
256
+ * selector에 해당하는 모든 컴포넌트들을 찾는다.
257
+ * @params selector {string}
258
+ */
259
+ findAll(selector: string): Array<Component>
260
+
261
+ /*
262
+ * selector에 해당하는 첫번째 컴포넌트를 찾는다.
263
+ * @params selector {string}
264
+ */
265
+ findFirst(selector: string): Component
266
+
267
+ /*
268
+ * id를 갖는 컴포넌트를 찾는다.
269
+ * @params id {string}
270
+ */
271
+ findById(id: string): Component
272
+
273
+ /*
274
+ * scene이 그리는 모델 오브젝트를 JSON 텍스트로 리턴한다.
275
+ */
276
+ serialize(): string
277
+
278
+ on(event: string, listener: Function, context: any): void
279
+ once(event: string, listener: Function, context: any): void
280
+ off(event: string, listener: Function, context: any): void
281
+
282
+ toDataURL(): string
283
+
284
+ fit(type: FITMODE): void
285
+
286
+ readonly fitMode: FITMODE
287
+ readonly ids: string[]
288
+
289
+ data: object
290
+
291
+ // @deprecated
292
+ variables: object
293
+
294
+ baseUrl: string
295
+ }
296
+ }