@eclipse-glsp/layout-elk 0.9.0-next.0193b16.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.
@@ -0,0 +1,303 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GlspElkLayoutEngine = void 0;
13
+ /********************************************************************************
14
+ * Copyright (c) 2018-2022 TypeFox and others.
15
+ * This program and the accompanying materials are made available under the
16
+ * terms of the Eclipse Public License v. 2.0 which is available at
17
+ * http://www.eclipse.org/legal/epl-2.0.
18
+ *
19
+ * This Source Code may also be made available under the following Secondary
20
+ * Licenses when the conditions for such availability set forth in the Eclipse
21
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
22
+ * with the GNU Classpath Exception which is available at
23
+ * https://www.gnu.org/software/classpath/license.html.
24
+ *
25
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
26
+ ********************************************************************************/
27
+ const server_node_1 = require("@eclipse-glsp/server-node");
28
+ const inversify_1 = require("inversify");
29
+ const sprotty_elk_1 = require("sprotty-elk");
30
+ const element_filter_1 = require("./element-filter");
31
+ const layout_configurator_1 = require("./layout-configurator");
32
+ /**
33
+ * An implementation of GLSP's {@link LayoutEngine} interface that retrieves the graphical model from the {@link ModelState},
34
+ * transforms this model into an ELK graph and then invokes the underlying ELK instance for layout computation.
35
+ */
36
+ let GlspElkLayoutEngine = class GlspElkLayoutEngine {
37
+ constructor(elkFactory, filter, configurator, modelState) {
38
+ this.filter = filter;
39
+ this.configurator = configurator;
40
+ this.modelState = modelState;
41
+ this.elk = elkFactory();
42
+ }
43
+ layout() {
44
+ const root = this.modelState.root;
45
+ if (!(root instanceof server_node_1.GGraph)) {
46
+ return root;
47
+ }
48
+ this.elkEdges = [];
49
+ this.idToElkElement = new Map();
50
+ const elkGraph = this.transformToElk(root);
51
+ return this.elk.layout(elkGraph).then(result => {
52
+ this.applyLayout(result);
53
+ return root;
54
+ });
55
+ }
56
+ transformToElk(model) {
57
+ if (model instanceof server_node_1.GGraph) {
58
+ const graph = this.transformGraph(model);
59
+ this.elkEdges.forEach(elkEdge => {
60
+ const parent = this.findCommonAncestor(elkEdge);
61
+ if (parent) {
62
+ parent.edges.push(elkEdge);
63
+ }
64
+ });
65
+ return graph;
66
+ }
67
+ else if (model instanceof server_node_1.GNode) {
68
+ return this.transformNode(model);
69
+ }
70
+ else if (model instanceof server_node_1.GEdge) {
71
+ return this.transformEdge(model);
72
+ }
73
+ else if (model instanceof server_node_1.GLabel) {
74
+ return this.transformPort(model);
75
+ }
76
+ else if (model instanceof server_node_1.GPort) {
77
+ return this.transformPort(model);
78
+ }
79
+ throw new Error('Type not supported: ' + model.type);
80
+ }
81
+ /**
82
+ * Searches for all children of the given element that are an instance of the given {@link GModelElementConstructor}
83
+ * and are included by the {@link ElementFilter}. Also considers children that are nested inside of {@link GCompartment}s.
84
+ * @param element The element whose children should be queried.
85
+ * @param constructor The class instance that should be matched
86
+ * @returns A list of all matching children.
87
+ */
88
+ findChildren(element, constructor) {
89
+ const result = [];
90
+ element.children.forEach(child => {
91
+ if (child instanceof constructor && this.filter.apply(element)) {
92
+ result.push(child);
93
+ }
94
+ else if (child instanceof server_node_1.GCompartment) {
95
+ result.push(...this.findChildren(child, constructor));
96
+ }
97
+ });
98
+ return result;
99
+ }
100
+ findCommonAncestor(elkEdge) {
101
+ const source = this.modelState.index.get(elkEdge.source);
102
+ const target = this.modelState.index.get(elkEdge.target);
103
+ if (!source || !target) {
104
+ return undefined;
105
+ }
106
+ const sourceParent = (0, server_node_1.findParent)(source.parent, parent => parent instanceof server_node_1.GNode || parent instanceof server_node_1.GGraph);
107
+ const targetParent = (0, server_node_1.findParent)(target.parent, parent => parent instanceof server_node_1.GNode || parent instanceof server_node_1.GGraph);
108
+ if (!sourceParent || !targetParent) {
109
+ return undefined;
110
+ }
111
+ if (sourceParent === targetParent) {
112
+ return this.idToElkElement.get(sourceParent.id);
113
+ }
114
+ else if (source === targetParent) {
115
+ return this.idToElkElement.get(source.id);
116
+ }
117
+ else if (target === sourceParent) {
118
+ return this.idToElkElement.get(target.id);
119
+ }
120
+ return undefined;
121
+ }
122
+ transformGraph(graph) {
123
+ const elkGraph = {
124
+ id: graph.id,
125
+ layoutOptions: this.configurator.apply(graph)
126
+ };
127
+ if (graph.children) {
128
+ elkGraph.children = this.findChildren(graph, server_node_1.GNode).map(child => this.transformToElk(child));
129
+ elkGraph.edges = [];
130
+ this.elkEdges.push(...this.findChildren(graph, server_node_1.GEdge).map(child => this.transformToElk(child)));
131
+ }
132
+ this.idToElkElement.set(graph.id, elkGraph);
133
+ return elkGraph;
134
+ }
135
+ transformNode(node) {
136
+ const elkNode = {
137
+ id: node.id,
138
+ layoutOptions: this.configurator.apply(node)
139
+ };
140
+ if (node.children) {
141
+ elkNode.children = this.findChildren(node, server_node_1.GNode).map(child => this.transformToElk(child));
142
+ elkNode.edges = [];
143
+ this.elkEdges.push(...this.findChildren(node, server_node_1.GEdge).map(child => this.transformToElk(child)));
144
+ elkNode.labels = this.findChildren(node, server_node_1.GLabel).map(child => this.transformToElk(child));
145
+ elkNode.ports = this.findChildren(node, server_node_1.GPort).map(child => this.transformToElk(child));
146
+ }
147
+ this.transformShape(elkNode, node);
148
+ this.idToElkElement.set(node.id, elkNode);
149
+ return elkNode;
150
+ }
151
+ transformShape(elkShape, shape) {
152
+ if (shape.position) {
153
+ elkShape.x = shape.position.x;
154
+ elkShape.y = shape.position.y;
155
+ }
156
+ if (shape.size) {
157
+ elkShape.width = shape.size.width;
158
+ elkShape.height = shape.size.height;
159
+ }
160
+ }
161
+ transformEdge(edge) {
162
+ const elkEdge = {
163
+ id: edge.id,
164
+ source: edge.sourceId,
165
+ target: edge.targetId,
166
+ layoutOptions: this.configurator.apply(edge)
167
+ };
168
+ const sourceElement = this.modelState.index.get(edge.sourceId);
169
+ if (sourceElement instanceof server_node_1.GPort) {
170
+ const parentNode = (0, server_node_1.findParentByClass)(sourceElement, server_node_1.GNode);
171
+ if (parentNode) {
172
+ elkEdge.source = parentNode.id;
173
+ elkEdge.sourcePort = sourceElement.id;
174
+ }
175
+ }
176
+ const targetElement = this.modelState.index.get(edge.targetId);
177
+ if (sourceElement instanceof server_node_1.GPort) {
178
+ const parentNode = (0, server_node_1.findParentByClass)(targetElement, server_node_1.GNode);
179
+ if (parentNode) {
180
+ elkEdge.target = parentNode.id;
181
+ elkEdge.targetPort = targetElement.id;
182
+ }
183
+ }
184
+ if (edge.children) {
185
+ elkEdge.labels = this.findChildren(edge, server_node_1.GLabel).map(child => this.transformToElk(child));
186
+ }
187
+ const points = edge.routingPoints;
188
+ if (points && points.length >= 2) {
189
+ elkEdge.sourcePoint = points[0];
190
+ elkEdge.bendPoints = points.slice(1, points.length - 1);
191
+ elkEdge.targetPoint = points[points.length - 1];
192
+ }
193
+ this.idToElkElement.set(edge.id, elkEdge);
194
+ return elkEdge;
195
+ }
196
+ transformLabel(label) {
197
+ const elkLabel = {
198
+ id: label.id,
199
+ text: label.text,
200
+ layoutOptions: this.configurator.apply(label)
201
+ };
202
+ this.transformShape(elkLabel, label);
203
+ this.idToElkElement.set(label.id, elkLabel);
204
+ return elkLabel;
205
+ }
206
+ transformPort(port) {
207
+ const elkPort = {
208
+ id: port.id,
209
+ layoutOptions: this.configurator.apply(port)
210
+ };
211
+ if (port.children) {
212
+ elkPort.labels = this.findChildren(port, server_node_1.GLabel).map(child => this.transformToElk(child));
213
+ }
214
+ this.transformShape(elkPort, port);
215
+ this.idToElkElement.set(port.id, elkPort);
216
+ return elkPort;
217
+ }
218
+ applyLayout(elkNode) {
219
+ const element = this.modelState.index.get(elkNode.id);
220
+ if (element instanceof server_node_1.GNode) {
221
+ this.applyShape(element, elkNode);
222
+ }
223
+ if (elkNode.children) {
224
+ for (const child of elkNode.children) {
225
+ this.applyLayout(child);
226
+ }
227
+ }
228
+ if (elkNode.edges) {
229
+ for (const elkEdge of elkNode.edges) {
230
+ const edge = this.modelState.index.get(elkEdge.id);
231
+ if (edge instanceof server_node_1.GEdge) {
232
+ this.applyEdge(edge, elkEdge);
233
+ }
234
+ }
235
+ }
236
+ if (elkNode.ports) {
237
+ for (const elkPort of elkNode.ports) {
238
+ const port = this.modelState.index.findByClass(elkPort.id, server_node_1.GPort);
239
+ if (port) {
240
+ this.applyShape(port, elkPort);
241
+ }
242
+ }
243
+ }
244
+ }
245
+ applyShape(shape, elkShape) {
246
+ if (elkShape.x !== undefined && elkShape.y !== undefined) {
247
+ shape.position = { x: elkShape.x, y: elkShape.y };
248
+ }
249
+ if (elkShape.width !== undefined && elkShape.height !== undefined) {
250
+ shape.size = { width: elkShape.width, height: elkShape.height };
251
+ }
252
+ if (elkShape.labels) {
253
+ for (const elkLabel of elkShape.labels) {
254
+ const label = this.modelState.index.findByClass(elkLabel.id, server_node_1.GLabel);
255
+ if (label) {
256
+ this.applyShape(label, elkLabel);
257
+ }
258
+ }
259
+ }
260
+ }
261
+ applyEdge(edge, elkEdge) {
262
+ const points = [];
263
+ if (elkEdge.sections && elkEdge.sections.length > 0) {
264
+ const section = elkEdge.sections[0];
265
+ if (section.startPoint) {
266
+ points.push(section.startPoint);
267
+ }
268
+ if (section.bendPoints) {
269
+ points.push(...section.bendPoints);
270
+ }
271
+ if (section.endPoint) {
272
+ points.push(section.endPoint);
273
+ }
274
+ }
275
+ else {
276
+ const section = elkEdge;
277
+ if (section.sourcePoint) {
278
+ points.push(section.sourcePoint);
279
+ }
280
+ if (section.bendPoints) {
281
+ points.push(...section.bendPoints);
282
+ }
283
+ if (section.targetPoint) {
284
+ points.push(section.targetPoint);
285
+ }
286
+ }
287
+ edge.routingPoints = points;
288
+ if (elkEdge.labels) {
289
+ elkEdge.labels.forEach(elkLabel => {
290
+ const label = this.modelState.index.findByClass(elkLabel.id, server_node_1.GLabel);
291
+ if (label) {
292
+ this.applyShape(label, elkLabel);
293
+ }
294
+ });
295
+ }
296
+ }
297
+ };
298
+ GlspElkLayoutEngine = __decorate([
299
+ (0, inversify_1.injectable)(),
300
+ __metadata("design:paramtypes", [Function, Object, Object, Object])
301
+ ], GlspElkLayoutEngine);
302
+ exports.GlspElkLayoutEngine = GlspElkLayoutEngine;
303
+ //# sourceMappingURL=glsp-elk-layout-engine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glsp-elk-layout-engine.js","sourceRoot":"","sources":["../src/glsp-elk-layout-engine.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;kFAakF;AAClF,2DAiBmC;AAEnC,yCAAuC;AACvC,6CAAyC;AACzC,qDAAiD;AACjD,+DAA2D;AAE3D;;;GAGG;AAEH,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAM5B,YACI,UAAsB,EACH,MAAqB,EACrB,YAAgC,EACzC,UAAsB;QAFb,WAAM,GAAN,MAAM,CAAe;QACrB,iBAAY,GAAZ,YAAY,CAAoB;QACzC,eAAU,GAAV,UAAU,CAAY;QAEhC,IAAI,CAAC,GAAG,GAAG,UAAU,EAAE,CAAC;IAC5B,CAAC;IACD,MAAM;QACF,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,CAAC,IAAI,YAAY,oBAAM,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC;SACf;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ACnC;YACD,IAAI,OAAO,CAAC,UAAU,EAAE;gBACpB,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;aACtC;YACD,IAAI,OAAO,CAAC,QAAQ,EAAE;gBAClB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;aACjC;SACJ;aAAM;YACH,MAAM,OAAO,GAAG,OAA2B,CAAC;YAC5C,IAAI,OAAO,CAAC,WAAW,EAAE;gBACrB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;aACpC;YACD,IAAI,OAAO,CAAC,UAAU,EAAE;gBACpB,MAAM,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;aACtC;YACD,IAAI,OAAO,CAAC,WAAW,EAAE;gBACrB,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;aACpC;SACJ;QACD,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;QAE5B,IAAI,OAAO,CAAC,MAAM,EAAE;YAChB,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;gBAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,EAAE,oBAAM,CAAC,CAAC;gBACrE,IAAI,KAAK,EAAE;oBACP,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;iBACpC;YACL,CAAC,CAAC,CAAC;SACN;IACL,CAAC;CACJ,CAAA;AAhSY,mBAAmB;IAD/B,IAAA,sBAAU,GAAE;;GACA,mBAAmB,CAgS/B;AAhSY,kDAAmB"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 STMicroelectronics and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ export * from './di.config';
17
+ export * from './element-filter';
18
+ export * from './glsp-elk-layout-engine';
19
+ export * from './layout-configurator';
20
+ export * from './sprotty-elk';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ /********************************************************************************
14
+ * Copyright (c) 2022 STMicroelectronics and others.
15
+ *
16
+ * This program and the accompanying materials are made available under the
17
+ * terms of the Eclipse Public License v. 2.0 which is available at
18
+ * http://www.eclipse.org/legal/epl-2.0.
19
+ *
20
+ * This Source Code may also be made available under the following Secondary
21
+ * Licenses when the conditions for such availability set forth in the Eclipse
22
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
+ * with the GNU Classpath Exception which is available at
24
+ * https://www.gnu.org/software/classpath/license.html.
25
+ *
26
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
27
+ ********************************************************************************/
28
+ __exportStar(require("./di.config"), exports);
29
+ __exportStar(require("./element-filter"), exports);
30
+ __exportStar(require("./glsp-elk-layout-engine"), exports);
31
+ __exportStar(require("./layout-configurator"), exports);
32
+ __exportStar(require("./sprotty-elk"), exports);
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,8CAA4B;AAC5B,mDAAiC;AACjC,2DAAyC;AACzC,wDAAsC;AACtC,gDAA8B"}
@@ -0,0 +1,57 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 STMicroelectronics and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ import { GEdge, GGraph, GLabel, GModelElement, GNode, GPort, ModelState } from '@eclipse-glsp/server-node';
17
+ import { LayoutOptions } from './sprotty-elk';
18
+ export declare const LayoutConfigurator: unique symbol;
19
+ /**
20
+ * Configurator for ELK layout algorithms; provides mappings of layout options for each model element.
21
+ * For a list of all available layout options checkout the official ELK documentation:
22
+ * {@link https://www.eclipse.org/elk/reference/options.html}
23
+ */
24
+ export interface LayoutConfigurator {
25
+ /**
26
+ * Computes the {@link LayoutOptions} for the given {@link GModelElement}.
27
+ * @param element The element for which the layout options should be computed.
28
+ * @returns The set of layout options for the given element or `undefined`.
29
+ */
30
+ apply(element: GModelElement): LayoutOptions | undefined;
31
+ }
32
+ /**
33
+ * Abstract default implementation of {@link LayoutConfigurator}.
34
+ * A minimal configuration should at least specify the `elk.algorithm` option as
35
+ * return value of {@link DefaultLayoutConfigurator.graphOptions}.
36
+ */
37
+ export declare abstract class AbstractLayoutConfigurator implements LayoutConfigurator {
38
+ protected modelState: ModelState;
39
+ apply(element: GModelElement): LayoutOptions | undefined;
40
+ protected graphOptions(graph: GGraph): LayoutOptions | undefined;
41
+ protected nodeOptions(node: GNode): LayoutOptions | undefined;
42
+ protected edgeOptions(edge: GEdge): LayoutOptions | undefined;
43
+ protected labelOptions(label: GLabel): LayoutOptions | undefined;
44
+ protected portOptions(sport: GPort): LayoutOptions | undefined;
45
+ }
46
+ /**
47
+ * A fallback configurator that is used in the `configureELKLayoutModule` utility method.
48
+ * If no explicit layout configurator binding is provided a new instance of the fallback configurator is
49
+ * bound as replacement. Basic layout options for the root graph element are derived from the
50
+ * configuration parameters that haven been passed to the `configureELKLayoutModule` function.
51
+ */
52
+ export declare class FallbackLayoutConfigurator extends AbstractLayoutConfigurator {
53
+ protected fallbackGraphOptions: LayoutOptions;
54
+ constructor(algorithms: string[], defaultLayoutOptions?: LayoutOptions);
55
+ protected graphOptions(sgraph: GGraph): LayoutOptions | undefined;
56
+ }
57
+ //# sourceMappingURL=layout-configurator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-configurator.d.ts","sourceRoot":"","sources":["../src/layout-configurator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAClF,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE3G,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAC/D;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS,CAAC;CAC5D;AAED;;;;GAIG;AACH,8BACsB,0BAA2B,YAAW,kBAAkB;IAE1E,SAAS,CAAC,UAAU,EAAE,UAAU,CAAC;IAEjC,KAAK,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,GAAG,SAAS;IAexD,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIhE,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,aAAa,GAAG,SAAS;IAI7D,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,GAAG,aAAa,GAAG,SAAS;IAI7D,SAAS,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAIhE,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,GAAG,SAAS;CAGjE;AAED;;;;;GAKG;AACH,qBACa,0BAA2B,SAAQ,0BAA0B;IACtE,SAAS,CAAC,oBAAoB,EAAE,aAAa,CAAC;gBAClC,UAAU,EAAE,MAAM,EAAE,EAAE,oBAAoB,GAAE,aAAkB;cAQvD,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;CAG7E"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.FallbackLayoutConfigurator = exports.AbstractLayoutConfigurator = exports.LayoutConfigurator = void 0;
13
+ /********************************************************************************
14
+ * Copyright (c) 2022 STMicroelectronics and others.
15
+ *
16
+ * This program and the accompanying materials are made available under the
17
+ * terms of the Eclipse Public License v. 2.0 which is available at
18
+ * http://www.eclipse.org/legal/epl-2.0.
19
+ *
20
+ * This Source Code may also be made available under the following Secondary
21
+ * Licenses when the conditions for such availability set forth in the Eclipse
22
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
23
+ * with the GNU Classpath Exception which is available at
24
+ * https://www.gnu.org/software/classpath/license.html.
25
+ *
26
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
27
+ ********************************************************************************/
28
+ const server_node_1 = require("@eclipse-glsp/server-node");
29
+ const inversify_1 = require("inversify");
30
+ exports.LayoutConfigurator = Symbol('LayoutConfigurator');
31
+ /**
32
+ * Abstract default implementation of {@link LayoutConfigurator}.
33
+ * A minimal configuration should at least specify the `elk.algorithm` option as
34
+ * return value of {@link DefaultLayoutConfigurator.graphOptions}.
35
+ */
36
+ let AbstractLayoutConfigurator = class AbstractLayoutConfigurator {
37
+ apply(element) {
38
+ if (element instanceof server_node_1.GGraph) {
39
+ return this.graphOptions(element);
40
+ }
41
+ else if (element instanceof server_node_1.GNode) {
42
+ return this.nodeOptions(element);
43
+ }
44
+ else if (element instanceof server_node_1.GEdge) {
45
+ return this.edgeOptions(element);
46
+ }
47
+ else if (element instanceof server_node_1.GLabel) {
48
+ this.labelOptions(element);
49
+ }
50
+ else if (element instanceof server_node_1.GPort) {
51
+ this.portOptions(element);
52
+ }
53
+ return undefined;
54
+ }
55
+ graphOptions(graph) {
56
+ return undefined;
57
+ }
58
+ nodeOptions(node) {
59
+ return undefined;
60
+ }
61
+ edgeOptions(edge) {
62
+ return undefined;
63
+ }
64
+ labelOptions(label) {
65
+ return undefined;
66
+ }
67
+ portOptions(sport) {
68
+ return undefined;
69
+ }
70
+ };
71
+ __decorate([
72
+ (0, inversify_1.inject)(server_node_1.ModelState),
73
+ __metadata("design:type", Object)
74
+ ], AbstractLayoutConfigurator.prototype, "modelState", void 0);
75
+ AbstractLayoutConfigurator = __decorate([
76
+ (0, inversify_1.injectable)()
77
+ ], AbstractLayoutConfigurator);
78
+ exports.AbstractLayoutConfigurator = AbstractLayoutConfigurator;
79
+ /**
80
+ * A fallback configurator that is used in the `configureELKLayoutModule` utility method.
81
+ * If no explicit layout configurator binding is provided a new instance of the fallback configurator is
82
+ * bound as replacement. Basic layout options for the root graph element are derived from the
83
+ * configuration parameters that haven been passed to the `configureELKLayoutModule` function.
84
+ */
85
+ let FallbackLayoutConfigurator = class FallbackLayoutConfigurator extends AbstractLayoutConfigurator {
86
+ constructor(algorithms, defaultLayoutOptions = {}) {
87
+ super();
88
+ this.fallbackGraphOptions = Object.assign({ 'elk.algorithm': algorithms[0] }, defaultLayoutOptions);
89
+ }
90
+ graphOptions(sgraph) {
91
+ return this.fallbackGraphOptions;
92
+ }
93
+ };
94
+ FallbackLayoutConfigurator = __decorate([
95
+ (0, inversify_1.injectable)(),
96
+ __metadata("design:paramtypes", [Array, Object])
97
+ ], FallbackLayoutConfigurator);
98
+ exports.FallbackLayoutConfigurator = FallbackLayoutConfigurator;
99
+ //# sourceMappingURL=layout-configurator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-configurator.js","sourceRoot":"","sources":["../src/layout-configurator.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,2DA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,EAAE;QACtE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,oBAAoB,mBACrB,eAAe,EAAE,UAAU,CAAC,CAAC,CAAC,IAC3B,oBAAoB,CAC1B,CAAC;IACN,CAAC;IAEkB,YAAY,CAAC,MAAc;QAC1C,OAAO,IAAI,CAAC,oBAAoB,CAAC;IACrC,CAAC;CACJ,CAAA;AAbY,0BAA0B;IADtC,IAAA,sBAAU,GAAE;;GACA,0BAA0B,CAatC;AAbY,gEAA0B"}
@@ -0,0 +1,18 @@
1
+ /********************************************************************************
2
+ * Copyright (c) 2022 STMicroelectronics and others.
3
+ *
4
+ * This program and the accompanying materials are made available under the
5
+ * terms of the Eclipse Public License v. 2.0 which is available at
6
+ * http://www.eclipse.org/legal/epl-2.0.
7
+ *
8
+ * This Source Code may also be made available under the following Secondary
9
+ * Licenses when the conditions for such availability set forth in the Eclipse
10
+ * Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ * with the GNU Classpath Exception which is available at
12
+ * https://www.gnu.org/software/classpath/license.html.
13
+ *
14
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ ********************************************************************************/
16
+ export { LayoutOptions } from 'elkjs';
17
+ export { ElkFactory } from 'sprotty-elk/lib/inversify';
18
+ //# sourceMappingURL=sprotty-elk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sprotty-elk.d.ts","sourceRoot":"","sources":["../src/sprotty-elk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;AAElF,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ElkFactory = void 0;
4
+ var inversify_1 = require("sprotty-elk/lib/inversify");
5
+ Object.defineProperty(exports, "ElkFactory", { enumerable: true, get: function () { return inversify_1.ElkFactory; } });
6
+ //# sourceMappingURL=sprotty-elk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sprotty-elk.js","sourceRoot":"","sources":["../src/sprotty-elk.ts"],"names":[],"mappings":";;;AAiBA,uDAAuD;AAA9C,uGAAA,UAAU,OAAA"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@eclipse-glsp/layout-elk",
3
+ "version": "0.9.0-next.0193b16.17+0193b16",
4
+ "description": "Integration of ELK graph layout algorithms in GLSP Node Server",
5
+ "license": "(EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0)",
6
+ "keywords": [
7
+ "eclipse",
8
+ "graphics",
9
+ "diagram",
10
+ "modeling",
11
+ "visualization",
12
+ "glsp",
13
+ "diagram editor"
14
+ ],
15
+ "author": {
16
+ "name": "Eclipse GLSP"
17
+ },
18
+ "homepage": "https://www.eclipse.org/glsp/",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/eclipse-glsp/glsp-server-node.git"
22
+ },
23
+ "bugs": "https://github.com/eclipse-glsp/glsp/issues",
24
+ "contributors": [
25
+ {
26
+ "name": "STMicroelectronics",
27
+ "url": "https://www.st.com/"
28
+ },
29
+ {
30
+ "name": "Eclipse GLSP Project",
31
+ "email": "glsp-dev@eclipse.org",
32
+ "url": "https://projects.eclipse.org/projects/ecd.glsp"
33
+ }
34
+ ],
35
+ "files": [
36
+ "lib",
37
+ "src",
38
+ "css"
39
+ ],
40
+ "dependencies": {
41
+ "@eclipse-glsp/server-node": "0.9.0-next.0193b16.17+0193b16",
42
+ "elkjs": "^0.7.1",
43
+ "inversify": "^5.1.1",
44
+ "sprotty-elk": "next"
45
+ },
46
+ "scripts": {
47
+ "clean": "rimraf tsconfig.tsbuildinfo lib",
48
+ "build": "yarn run clean && tsc",
49
+ "test": "mocha --config ../../.mocharc.json \"./src/**/*.spec.?(ts|tsx)\"",
50
+ "test:ci": "export JUNIT_REPORT_PATH=./report.xml && yarn test --reporter mocha-jenkins-reporter",
51
+ "lint": "eslint -c ../../.eslintrc.js --ext .ts,.tsx ./src",
52
+ "lint:fix": "eslint --fix -c ../../.eslintrc.js --ext .ts,.tsx ./src",
53
+ "watch": "tsc -w"
54
+ },
55
+ "publishConfig": {
56
+ "access": "public"
57
+ },
58
+ "main": "lib/index",
59
+ "types": "lib/index",
60
+ "gitHead": "0193b161a5f728fd49176859f04b26f8eb788fa5"
61
+ }