@eclipse-glsp/layout-elk 2.8.0-next.5 → 2.8.0-next.7
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 +7 -8
- package/src/di.config.spec.ts +0 -110
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eclipse-glsp/layout-elk",
|
|
3
|
-
"version": "2.8.0-next.
|
|
3
|
+
"version": "2.8.0-next.7",
|
|
4
4
|
"description": "Integration of ELK graph layout algorithms in GLSP Node Server",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eclipse",
|
|
@@ -36,11 +36,13 @@
|
|
|
36
36
|
"types": "lib/index",
|
|
37
37
|
"files": [
|
|
38
38
|
"lib",
|
|
39
|
-
"src"
|
|
39
|
+
"src",
|
|
40
|
+
"!**/*.spec.ts",
|
|
41
|
+
"!**/*.spec.tsx"
|
|
40
42
|
],
|
|
41
43
|
"dependencies": {
|
|
42
44
|
"elkjs": "^0.11.1",
|
|
43
|
-
"@eclipse-glsp/server": "2.8.0-next.
|
|
45
|
+
"@eclipse-glsp/server": "2.8.0-next.7"
|
|
44
46
|
},
|
|
45
47
|
"peerDependencies": {
|
|
46
48
|
"inversify": "^6.1.3",
|
|
@@ -51,11 +53,8 @@
|
|
|
51
53
|
},
|
|
52
54
|
"scripts": {
|
|
53
55
|
"build": "tsc -b",
|
|
54
|
-
"clean": "rimraf lib *.tsbuildinfo coverage
|
|
56
|
+
"clean": "rimraf lib *.tsbuildinfo coverage",
|
|
55
57
|
"generate:index": "glsp generateIndex src -f -s",
|
|
56
|
-
"lint": "eslint ./src"
|
|
57
|
-
"test": "mocha --config ../../.mocharc \"./src/**/*.spec.?(ts|tsx)\"",
|
|
58
|
-
"test:ci": "pnpm test --reporter mocha-ctrf-json-reporter",
|
|
59
|
-
"test:coverage": "nyc pnpm test"
|
|
58
|
+
"lint": "eslint ./src"
|
|
60
59
|
}
|
|
61
60
|
}
|
package/src/di.config.spec.ts
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (c) 2022-2023 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 {
|
|
17
|
-
DefaultModelState,
|
|
18
|
-
DiagramConfiguration,
|
|
19
|
-
EdgeTypeHint,
|
|
20
|
-
GGraph,
|
|
21
|
-
GModelElementConstructor,
|
|
22
|
-
ModelState,
|
|
23
|
-
ServerLayoutKind,
|
|
24
|
-
ShapeTypeHint
|
|
25
|
-
} from '@eclipse-glsp/server';
|
|
26
|
-
import { expect } from 'chai';
|
|
27
|
-
import { Container, ContainerModule, injectable } from 'inversify';
|
|
28
|
-
import * as sinon from 'sinon';
|
|
29
|
-
import { configureELKLayoutModule } from './di.config';
|
|
30
|
-
import { DefaultElementFilter, ElementFilter } from './element-filter';
|
|
31
|
-
import { AbstractLayoutConfigurator, FallbackLayoutConfigurator, LayoutConfigurator } from './layout-configurator';
|
|
32
|
-
|
|
33
|
-
@injectable()
|
|
34
|
-
class CustomLayoutConfigurator extends AbstractLayoutConfigurator {}
|
|
35
|
-
|
|
36
|
-
@injectable()
|
|
37
|
-
class CustomElementFilter extends DefaultElementFilter {}
|
|
38
|
-
|
|
39
|
-
class StubDiagramConfiguration implements DiagramConfiguration {
|
|
40
|
-
typeMapping = new Map<string, GModelElementConstructor>();
|
|
41
|
-
|
|
42
|
-
shapeTypeHints: ShapeTypeHint[] = [];
|
|
43
|
-
|
|
44
|
-
edgeTypeHints: EdgeTypeHint[] = [];
|
|
45
|
-
|
|
46
|
-
layoutKind = ServerLayoutKind.NONE;
|
|
47
|
-
|
|
48
|
-
needsClientLayout = true;
|
|
49
|
-
|
|
50
|
-
animatedUpdate = true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
describe('test configureELKLayoutModule', () => {
|
|
54
|
-
const sandbox = sinon.createSandbox();
|
|
55
|
-
const mockDiagramConfiguration = new StubDiagramConfiguration();
|
|
56
|
-
const typeMappings = new Map<string, GModelElementConstructor>();
|
|
57
|
-
|
|
58
|
-
typeMappings.set('graph', GGraph);
|
|
59
|
-
sandbox.stub(mockDiagramConfiguration, 'typeMapping').value(typeMappings);
|
|
60
|
-
const modelState = new DefaultModelState();
|
|
61
|
-
const baseModule = new ContainerModule(bind => {
|
|
62
|
-
bind(ModelState).toConstantValue(modelState);
|
|
63
|
-
});
|
|
64
|
-
it('configure with minimal options', () => {
|
|
65
|
-
const algorithm = 'layered';
|
|
66
|
-
const elkModule = configureELKLayoutModule({ algorithms: [algorithm] });
|
|
67
|
-
const container = new Container();
|
|
68
|
-
container.load(baseModule, elkModule);
|
|
69
|
-
const filter = container.get<ElementFilter>(ElementFilter);
|
|
70
|
-
expect(filter).to.be.an.instanceOf(DefaultElementFilter);
|
|
71
|
-
const configurator = container.get<LayoutConfigurator>(LayoutConfigurator);
|
|
72
|
-
expect(configurator).to.be.an.instanceOf(FallbackLayoutConfigurator);
|
|
73
|
-
const graphOptions = configurator.apply(new GGraph());
|
|
74
|
-
expect(graphOptions).not.to.be.undefined;
|
|
75
|
-
expect(graphOptions!['elk.algorithm']).to.equal(algorithm);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('configure with additional default layout options', () => {
|
|
79
|
-
const algorithm = 'layered';
|
|
80
|
-
const defaultLayoutOptions = {
|
|
81
|
-
'elk.direction': 'LEFT',
|
|
82
|
-
'elk.edgeRouting': 'POLYLINE'
|
|
83
|
-
};
|
|
84
|
-
const elkModule = configureELKLayoutModule({ algorithms: [algorithm], defaultLayoutOptions });
|
|
85
|
-
const container = new Container();
|
|
86
|
-
container.load(baseModule, elkModule);
|
|
87
|
-
const configurator = container.get<LayoutConfigurator>(LayoutConfigurator);
|
|
88
|
-
const graphOptions = configurator.apply(new GGraph());
|
|
89
|
-
expect(graphOptions).not.to.be.undefined;
|
|
90
|
-
expect(graphOptions).to.include(defaultLayoutOptions);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('configure with custom layout configurator', () => {
|
|
94
|
-
const algorithm = 'layered';
|
|
95
|
-
const elkModule = configureELKLayoutModule({ algorithms: [algorithm], layoutConfigurator: CustomLayoutConfigurator });
|
|
96
|
-
const container = new Container();
|
|
97
|
-
container.load(baseModule, elkModule);
|
|
98
|
-
const configurator = container.get<LayoutConfigurator>(LayoutConfigurator);
|
|
99
|
-
expect(configurator).to.be.an.instanceOf(CustomLayoutConfigurator);
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('configure with custom element filter', () => {
|
|
103
|
-
const algorithm = 'layered';
|
|
104
|
-
const elkModule = configureELKLayoutModule({ algorithms: [algorithm], elementFilter: CustomElementFilter });
|
|
105
|
-
const container = new Container();
|
|
106
|
-
container.load(baseModule, elkModule);
|
|
107
|
-
const filter = container.get<ElementFilter>(ElementFilter);
|
|
108
|
-
expect(filter).to.be.an.instanceOf(CustomElementFilter);
|
|
109
|
-
});
|
|
110
|
-
});
|