@operato/scene-integration 9.1.1 → 10.0.0-beta.1

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.
@@ -1,5 +1,241 @@
1
- import { ComponentNature, Shape } from '@hatiolab/things-scene';
2
- declare const ConnectionControl_base: typeof Shape;
1
+ import { Component, ComponentNature, Shape } from '@hatiolab/things-scene';
2
+ declare const ConnectionControl_base: (new (...args: any[]) => {
3
+ contains(x: number, y: number): boolean;
4
+ get path(): {
5
+ x: any;
6
+ y: any;
7
+ }[];
8
+ set path(path: {
9
+ x: any;
10
+ y: any;
11
+ }[]): any;
12
+ get anchors(): {
13
+ name: string;
14
+ position: {
15
+ x: any;
16
+ y: any;
17
+ };
18
+ }[];
19
+ get bounds(): any;
20
+ set bounds(bounds: any): any;
21
+ render(ctx: CanvasRenderingContext2D): void;
22
+ _app: any;
23
+ _model: any;
24
+ _state: any;
25
+ _delta: any;
26
+ _animation: any;
27
+ _animate: any;
28
+ _parent: any;
29
+ _disposed: any;
30
+ _textHidden: any;
31
+ _text_substitutor: any;
32
+ _value_substitutor: any;
33
+ _mappings: any;
34
+ _realObject: import("@hatiolab/things-scene").IRealObject | undefined;
35
+ _cachedState: any;
36
+ updatedAt: any;
37
+ fontSize: any;
38
+ __cache__: any;
39
+ created(): void;
40
+ added(parent: any): void;
41
+ removed(parent: any): void;
42
+ ready(): Promise<void>;
43
+ touch(): void;
44
+ clearCache(...attrs: any[]): void;
45
+ removeSelf(completely: any): void;
46
+ resetAnimation(): void;
47
+ dispose(): void;
48
+ get nature(): import("@hatiolab/things-scene").ComponentNature;
49
+ get disposed(): boolean;
50
+ isLayer(): boolean;
51
+ isGroup(): boolean;
52
+ isContainer(): this is import("@hatiolab/things-scene/dist-types/types/component").Container;
53
+ isLine(): boolean;
54
+ isRoot(): boolean;
55
+ isRootModel(): boolean;
56
+ is3dish(): boolean;
57
+ get is3dMode(): boolean;
58
+ isIn3DSpace(): boolean;
59
+ isTemplate(): boolean;
60
+ isHTMLElement(): boolean;
61
+ isConnectable(): boolean;
62
+ isIdentifiable(): boolean;
63
+ isPositionable(): boolean;
64
+ replaceRefids(replaceMap: any): void;
65
+ get(property: any): any;
66
+ set(props: any, propval?: any): any;
67
+ getState(property: any): any;
68
+ setState(props: any, propval?: any): any;
69
+ get model(): any;
70
+ get state(): any;
71
+ get hierarchy(): any;
72
+ get volatile(): never[];
73
+ _applyProps(target: any, props: any, options: any): any;
74
+ move(offset: {
75
+ x: number;
76
+ y: number;
77
+ }, ...args: boolean[]): void;
78
+ symmetryX(x?: number): void;
79
+ symmetryY(y: number): void;
80
+ adjustResize(bounds: import("@hatiolab/things-scene").BOUNDS, origin_bounds: import("@hatiolab/things-scene").BOUNDS, diagonal: boolean): {
81
+ left: any;
82
+ top: any;
83
+ width: any;
84
+ height: any;
85
+ };
86
+ adjustRotation(rotation: number, step: boolean): number;
87
+ outline(progress: number): any;
88
+ get center(): import("@hatiolab/things-scene").POINT;
89
+ set center(p: import("@hatiolab/things-scene").POINT): any;
90
+ get location(): import("@hatiolab/things-scene").POINT;
91
+ set location(l: import("@hatiolab/things-scene").POINT): any;
92
+ get rotate(): import("@hatiolab/things-scene").POINT;
93
+ set rotate(r: import("@hatiolab/things-scene").POINT): any;
94
+ get dimension(): import("@hatiolab/things-scene").DIMENSION;
95
+ set dimension(d: import("@hatiolab/things-scene").DIMENSION): any;
96
+ get drawPath(): import("@hatiolab/things-scene").POINT[];
97
+ get rotatePoint(): import("@hatiolab/things-scene").POINT;
98
+ get mutable(): boolean;
99
+ get resizable(): boolean;
100
+ get rotatable(): boolean;
101
+ buildRealObject(): import("@hatiolab/things-scene").IRealObject | undefined;
102
+ get realObject(): import("@hatiolab/things-scene").IRealObject | undefined;
103
+ draw(context?: import("@hatiolab/things-scene").SceneRenderContext): void;
104
+ prerender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
105
+ postrender(context: import("@hatiolab/things-scene").SceneRenderContext): void;
106
+ prepare(resolve: (component: Component) => void, reject: (reason: any) => void): void;
107
+ prepareIf(condition: boolean): void;
108
+ drawText(context: import("@hatiolab/things-scene").SceneRenderContext): void;
109
+ drawStroke(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
110
+ drawFill(context: import("@hatiolab/things-scene").SceneRenderContext, override?: Record<string, unknown>): void;
111
+ get strokeStyle(): any;
112
+ set strokeStyle(v: any): any;
113
+ get fillStyle(): any;
114
+ set fillStyle(v: any): any;
115
+ get fontColor(): string;
116
+ set fontColor(v: string): any;
117
+ get rotation(): number;
118
+ set rotation(v: number): any;
119
+ get decorators(): string[];
120
+ get decotag(): string;
121
+ get hidden(): boolean;
122
+ set hidden(v: boolean): any;
123
+ get tag(): string;
124
+ set tag(v: string): any;
125
+ get appendum(): any;
126
+ set appendum(v: any): any;
127
+ defaultTextSubstitutor(): string;
128
+ textLines(context?: import("@hatiolab/things-scene").SceneRenderContext): any[][];
129
+ get font(): string;
130
+ get lineHeight(): number;
131
+ get textSubstitutor(): () => string;
132
+ get text(): string;
133
+ set text(v: string): any;
134
+ get textBounds(): import("@hatiolab/things-scene").BOUNDS;
135
+ get textRotation(): number;
136
+ get textHidden(): boolean;
137
+ set textHidden(v: boolean): any;
138
+ get hasTextProperty(): boolean;
139
+ animate(opts: import("@hatiolab/things-scene").AnimationConfig): any;
140
+ effect(context: import("@hatiolab/things-scene").SceneRenderContext, model: any): void;
141
+ serialize(...others: any[]): string;
142
+ trim(): void;
143
+ closeScene(data: any): void;
144
+ delta(attr?: string | object, value?: any): any;
145
+ invalidate(): void;
146
+ get value(): any;
147
+ set value(v: any): any;
148
+ get data(): any;
149
+ set data(v: any): any;
150
+ set tap(v: any): any;
151
+ get mappings(): any[];
152
+ get retention(): number;
153
+ get animation(): import("@hatiolab/things-scene").AnimationController | undefined;
154
+ get started(): boolean;
155
+ set started(v: boolean): any;
156
+ get controls(): import("@hatiolab/things-scene").Control[] | undefined;
157
+ findFirst(finder: string | ((c: Component) => boolean), ...others: any[]): Component | undefined;
158
+ findAll(s: string | ((c: Component) => boolean), ...others: any[]): any[] | undefined;
159
+ capture(x: number, y: number, except?: (c: Component) => boolean): any;
160
+ findAnchor(name: string): any;
161
+ isDescendible(container: Component): boolean;
162
+ getContext(component?: unknown): any;
163
+ get root(): Component;
164
+ get rootModel(): Component;
165
+ get parent(): Component;
166
+ set parent(v: Component): any;
167
+ get scalable(): boolean;
168
+ get stuck(): boolean;
169
+ get capturable(): boolean;
170
+ get position(): string;
171
+ get origin(): string;
172
+ get offset(): import("@hatiolab/things-scene").POINT;
173
+ get app(): import("@hatiolab/things-scene").ApplicationContext;
174
+ drawEffect(context: import("@hatiolab/things-scene").SceneRenderContext): void;
175
+ prepareFill(resolve: Function, reject: Function): void;
176
+ prepareFillIf(condition: boolean): void;
177
+ onchangeFill(after: Record<string, any>, before: Record<string, any>): void;
178
+ drawImage(context: import("@hatiolab/things-scene").SceneRenderContext, image: HTMLImageElement, left: number, top: number, width: number, height: number): void;
179
+ mutateBounds(logic: ((bounds: import("@hatiolab/things-scene").BOUNDS) => import("@hatiolab/things-scene").BOUNDS | void) | null, context?: any): void;
180
+ mutatePath(beforeLogic: ((path: import("@hatiolab/things-scene").POINT[]) => import("@hatiolab/things-scene").POINT[] | void) | null, afterLogic: ((path: import("@hatiolab/things-scene").POINT[]) => import("@hatiolab/things-scene").POINT[] | void) | null, context?: any): void;
181
+ access(accessor: string): any;
182
+ substitute(template: string, data: any): string | undefined;
183
+ onchangeMappings(after: Record<string, any>, before: Record<string, any>): void;
184
+ onchangeData(after: Record<string, any>, before: Record<string, any>): void;
185
+ buildMappings(): void;
186
+ executeMappings(force?: boolean): void;
187
+ disposeMappings(): void;
188
+ ondropfile(transfered: FileList, files: string[]): void;
189
+ transcoordS2P(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
190
+ transcoordP2S(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
191
+ transcoordS2T(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
192
+ transcoordT2P(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
193
+ transcoordT2S(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
194
+ transcoordS2TR(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
195
+ transcoordS2O(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
196
+ transcoordC2S(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
197
+ transcoordS2C(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
198
+ toParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
199
+ fromParent(x: number, y: number, rp?: import("@hatiolab/things-scene").POINT): import("@hatiolab/things-scene").POINT;
200
+ toScene(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
201
+ fromScene(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
202
+ toLocal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
203
+ toGlobal(x: number, y: number, top?: Component): import("@hatiolab/things-scene").POINT;
204
+ toOther(x: number, y: number, target: Component): import("@hatiolab/things-scene").POINT;
205
+ on(name: string | object, callback: Function, context?: any): any;
206
+ off(name?: string | object, callback?: Function, context?: any): any;
207
+ once(name: string | object, callback: Function, context?: any): any;
208
+ trigger(name: string, ...args: any[]): any;
209
+ delegate_on(delegator: any): any;
210
+ delegate_off(delegator: any): any;
211
+ onchange(after: Record<string, any>, before: Record<string, any>): void;
212
+ calculateBounds?(): void;
213
+ oncreate_element?(element: HTMLElement): void;
214
+ removeComponent(component: Component, ghost?: boolean): void;
215
+ addComponent(component: Component, ghost?: boolean): void;
216
+ insertComponentAt(component: Component, index: number, ghost?: boolean): void;
217
+ getOverlay(component: Component): HTMLElement | undefined;
218
+ findById(id: string): Component | undefined;
219
+ findByRefid(ref: string | number): Component | undefined;
220
+ findAllById(id: string): Component[];
221
+ resize(): void;
222
+ fit(type?: string): void;
223
+ get components(): Component[] | undefined;
224
+ get layout(): any;
225
+ get auxOverlay(): HTMLElement | undefined;
226
+ get isReady(): boolean;
227
+ get unitScale(): number;
228
+ get selected(): Component[];
229
+ set selected(_v: Component[]): any;
230
+ get focused(): Component | null;
231
+ set focused(_v: Component | null): any;
232
+ get hasSameParentForAllSelected(): boolean;
233
+ set hasSameParentForAllSelected(_v: boolean): any;
234
+ get fitMode(): string | undefined;
235
+ set fitMode(_v: string | undefined): any;
236
+ get element(): HTMLElement | null;
237
+ set element(_v: HTMLElement | null): any;
238
+ }) & typeof Shape;
3
239
  export default class ConnectionControl extends ConnectionControl_base {
4
240
  static _image: HTMLImageElement;
5
241
  static get image(): HTMLImageElement;
@@ -57,7 +57,9 @@ const NATURE = {
57
57
  'value-property': 'controlType',
58
58
  help: 'scene/component/connection-control'
59
59
  };
60
- let ConnectionControl = ConnectionControl_1 = class ConnectionControl extends RectPath(Shape) {
60
+ let ConnectionControl = class ConnectionControl extends RectPath(Shape) {
61
+ static { ConnectionControl_1 = this; }
62
+ static _image;
61
63
  static get image() {
62
64
  if (!ConnectionControl_1._image) {
63
65
  ConnectionControl_1._image = new Image();
@@ -1 +1 @@
1
- {"version":3,"file":"connection-control.js","sourceRoot":"","sources":["../src/connection-control.ts"],"names":[],"mappings":";;AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAA8B,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACpG,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,gBAAgB;YACtB,QAAQ,EAAE;gBACR,OAAO,EAAE,KAAK,I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B,iBAAiB;IADrC,cAAc,CAAC,oBAAoB,CAAC;GAChB,iBAAiB,CA+DrC;eA/DoB,iBAAiB","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\nimport { client } from '@operato/graphql'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'connection-name',\n name: 'connectionName',\n property: {\n options: async () => {\n var response = await client.query({\n query: gql`\n query {\n connections {\n items {\n name\n }\n }\n }\n `\n })\n if (response.errors) {\n return ['']\n }\n\n return [''].concat(response.data.connections.items.map((item: any) => item.name))\n }\n }\n },\n {\n type: 'select',\n label: 'control-type',\n name: 'controlType',\n property: {\n options: [\n {\n display: '',\n value: ''\n },\n {\n display: 'connect',\n value: 'connect'\n },\n {\n display: 'disconnect',\n value: 'disconnect'\n }\n ]\n }\n }\n ],\n 'value-property': 'controlType',\n help: 'scene/component/connection-control'\n}\n\n@sceneComponent('connection-control')\nexport default class ConnectionControl extends RectPath(Shape) {\n static _image: HTMLImageElement\n\n static get image() {\n if (!ConnectionControl._image) {\n ConnectionControl._image = new Image()\n ConnectionControl._image.src = new URL('../icons/symbol-connection-control.png', import.meta.url).href\n }\n return ConnectionControl._image\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n context.beginPath()\n this.drawImage(context, ConnectionControl.image, left, top, width, height)\n }\n\n get nature() {\n return NATURE\n }\n\n get controlType() {\n return this.getState('controlType')\n }\n\n set controlType(controlType: string) {\n this.setState('controlType', controlType)\n this.controlConnect()\n }\n\n async controlConnect() {\n let { controlType, connectionName } = this.state\n\n if (!connectionName || !this.app.isViewMode) return\n\n switch (controlType) {\n case 'connect':\n case true:\n case 1:\n controlType = 'connect'\n break\n default:\n controlType = 'disconnect'\n }\n\n var query = ''\n\n query = `mutation{\n ${controlType}Connection(name: \"${connectionName}\") {\n status\n }\n }`\n\n if (client) {\n var response = await client.query({\n query: gql`\n ${query}\n `\n })\n\n this.data = response\n }\n }\n}\n"]}
1
+ {"version":3,"file":"connection-control.js","sourceRoot":"","sources":["../src/connection-control.ts"],"names":[],"mappings":";;AAAA,OAAO,GAAG,MAAM,aAAa,CAAA;AAE7B,OAAO,EAA8B,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACpG,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAEzC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,iBAAiB;YACxB,IAAI,EAAE,gBAAgB;YACtB,QAAQ,EAAE;gBACR,OAAO,EAAE,KAAK,IAAI,EAAE;oBAClB,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;wBAChC,KAAK,EAAE,GAAG,CAAA;;;;;;;;aAQT;qBACF,CAAC,CAAA;oBACF,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;wBACpB,OAAO,CAAC,EAAE,CAAC,CAAA;oBACb,CAAC;oBAED,OAAO,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;gBACnF,CAAC;aACF;SACF;QACD;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,cAAc;YACrB,IAAI,EAAE,aAAa;YACnB,QAAQ,EAAE;gBACR,OAAO,EAAE;oBACP;wBACE,OAAO,EAAE,EAAE;wBACX,KAAK,EAAE,EAAE;qBACV;oBACD;wBACE,OAAO,EAAE,SAAS;wBAClB,KAAK,EAAE,SAAS;qBACjB;oBACD;wBACE,OAAO,EAAE,YAAY;wBACrB,K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AAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU;YAAE,OAAM;QAEnD,QAAQ,WAAW,EAAE,CAAC;YACpB,KAAK,SAAS,CAAC;YACf,KAAK,IAAI,CAAC;YACV,KAAK,CAAC;gBACJ,WAAW,GAAG,SAAS,CAAA;gBACvB,MAAK;YACP;gBACE,WAAW,GAAG,YAAY,CAAA;QAC9B,CAAC;QAED,IAAI,KAAK,GAAG,EAAE,CAAA;QAEd,KAAK,GAAG;QACJ,WAAW,qBAAqB,cAAc;;;MAGhD,CAAA;QAEF,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,QAAQ,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC;gBAChC,KAAK,EAAE,GAAG,CAAA;YACN,KAAK;SACR;aACF,CAAC,CAAA;YAEF,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAA;QACtB,CAAC;IACH,CAAC;CACF,CAAA;AA/DoB,iBAAiB;IADrC,cAAc,CAAC,oBAAoB,CAAC;GAChB,iBAAiB,CA+DrC;eA/DoB,iBAAiB","sourcesContent":["import gql from 'graphql-tag'\n\nimport { Component, ComponentNature, RectPath, Shape, sceneComponent } from '@hatiolab/things-scene'\nimport { client } from '@operato/graphql'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'connection-name',\n name: 'connectionName',\n property: {\n options: async () => {\n var response = await client.query({\n query: gql`\n query {\n connections {\n items {\n name\n }\n }\n }\n `\n })\n if (response.errors) {\n return ['']\n }\n\n return [''].concat(response.data.connections.items.map((item: any) => item.name))\n }\n }\n },\n {\n type: 'select',\n label: 'control-type',\n name: 'controlType',\n property: {\n options: [\n {\n display: '',\n value: ''\n },\n {\n display: 'connect',\n value: 'connect'\n },\n {\n display: 'disconnect',\n value: 'disconnect'\n }\n ]\n }\n }\n ],\n 'value-property': 'controlType',\n help: 'scene/component/connection-control'\n}\n\n@sceneComponent('connection-control')\nexport default class ConnectionControl extends RectPath(Shape) {\n static _image: HTMLImageElement\n\n static get image() {\n if (!ConnectionControl._image) {\n ConnectionControl._image = new Image()\n ConnectionControl._image.src = new URL('../icons/symbol-connection-control.png', import.meta.url).href\n }\n return ConnectionControl._image\n }\n\n render(context: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n context.beginPath()\n this.drawImage(context, ConnectionControl.image, left, top, width, height)\n }\n\n get nature() {\n return NATURE\n }\n\n get controlType() {\n return this.getState('controlType')\n }\n\n set controlType(controlType: string) {\n this.setState('controlType', controlType)\n this.controlConnect()\n }\n\n async controlConnect() {\n let { controlType, connectionName } = this.state\n\n if (!connectionName || !this.app.isViewMode) return\n\n switch (controlType) {\n case 'connect':\n case true:\n case 1:\n controlType = 'connect'\n break\n default:\n controlType = 'disconnect'\n }\n\n var query = ''\n\n query = `mutation{\n ${controlType}Connection(name: \"${connectionName}\") {\n status\n }\n }`\n\n if (client) {\n var response = await client.query({\n query: gql`\n ${query}\n `\n })\n\n this.data = response\n }\n }\n}\n"]}