Skip to content

Commit e49c816

Browse files
authored
GLSP-1022: Update to TS5 and inversify 6 (#48)
- Update to typescript 5 - Update to inversify 6. Inversify is now a peerDependency (^6.0.0). A matching version has to be provided by consuming projects. - Adapt codebase to new inversify API - Rework elk-layouit package to remove unnecessary dependency in `sprotty-elk` Part of eclipse-glsp/glsp#1023 (uses locally published glsp packages. needs to be adapted once the offical packages are available) Requires eclipse-glsp/glsp-client#253
1 parent f692ea4 commit e49c816

File tree

18 files changed

+398
-347
lines changed

18 files changed

+398
-347
lines changed

.eslintrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ module.exports = {
99
project: 'tsconfig.eslint.json'
1010
},
1111
rules: {
12-
'no-shadow': 'off',
12+
'@typescript-eslint/no-shadow': 'off',
1313
'no-restricted-imports': [
1414
'warn',
1515
{
1616
name: 'sprotty-protocol',
1717
message:
18-
"The sprotty-protocol default exports are customized and reexported by GLSP. Please import from '@eclipse-glsp/client' instead"
18+
"The sprotty-protocol default exports are customized and reexported by GLSP. Please import from '@eclipse-glsp/protocol' instead"
1919
}
2020
]
2121
}

examples/workflow-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
},
5858
"dependencies": {
5959
"@eclipse-glsp/layout-elk": "1.1.0-next",
60-
"@eclipse-glsp/server": "1.1.0-next"
60+
"@eclipse-glsp/server": "1.1.0-next",
61+
"inversify": "^6.0.1"
6162
},
6263
"devDependencies": {
6364
"source-map-loader": "^4.0.1",

examples/workflow-server/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": "@eclipse-glsp/ts-config/tsconfig.json",
2+
"extends": "@eclipse-glsp/ts-config/",
33
"compilerOptions": {
44
"rootDir": "src",
55
"outDir": "lib",

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"check:headers": "glsp checkHeaders . -t lastCommit",
1313
"check:pr": "yarn all && yarn check:headers",
1414
"clean": "lerna run clean && rimraf coverage .nyc_output",
15-
"download:exampleServer": "ts-node examples/workflow-glsp/scripts/download.ts",
1615
"lint": "lerna run lint",
1716
"lint:ci": "lerna run lint:ci",
1817
"prepare": "lerna run prepare",
@@ -29,8 +28,10 @@
2928
"watch": "lerna run --parallel watch"
3029
},
3130
"devDependencies": {
32-
"@eclipse-glsp/dev": "1.1.0-next.7026c40.129",
33-
"@types/node": "16.x"
31+
"@eclipse-glsp/dev": "next",
32+
"@types/node": "16.x",
33+
"lerna": "^6.6.2",
34+
"typescript": "^5.0.4"
3435
},
3536
"engines": {
3637
"node": ">=16.11.0",

packages/graph/tsconfig.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"extends": "@eclipse-glsp/ts-config/tsconfig.json",
2+
"extends": "@eclipse-glsp/ts-config/mocha",
33
"compilerOptions": {
44
"rootDir": "src",
55
"outDir": "lib",
66
"reactNamespace": "JSX",
77
"baseUrl": "src",
8-
"types": ["node", "mocha", "reflect-metadata"]
98
},
10-
"exclude": ["**/*.spec.ts"],
11-
"include": ["src"]
12-
}
9+
"include": [
10+
"src"
11+
]
12+
}

packages/layout-elk/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@
5151
},
5252
"dependencies": {
5353
"@eclipse-glsp/server": "1.1.0-next",
54-
"elkjs": "^0.7.1",
55-
"sprotty-elk": "0.12.0"
54+
"elkjs": "^0.7.1"
55+
},
56+
"peerDependencies": {
57+
"inversify": "^6.0.0"
5658
},
5759
"publishConfig": {
5860
"access": "public"

packages/layout-elk/src/di.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
import { LayoutEngine, ModelState } from '@eclipse-glsp/server';
1717
import ElkConstructor, { LayoutOptions } from 'elkjs/lib/elk.bundled';
1818
import { ContainerModule } from 'inversify';
19-
import { ElkFactory } from 'sprotty-elk';
2019
import { DefaultElementFilter, ElementFilter } from './element-filter';
21-
import { GlspElkLayoutEngine } from './glsp-elk-layout-engine';
20+
import { ElkFactory, GlspElkLayoutEngine } from './glsp-elk-layout-engine';
2221
import { FallbackLayoutConfigurator, LayoutConfigurator } from './layout-configurator';
2322

2423
type Constructor<T> = new (...args: any[]) => T;

packages/layout-elk/src/glsp-elk-layout-engine.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@ import {
3232
} from '@eclipse-glsp/server';
3333
import { ELK, ElkEdge, ElkExtendedEdge, ElkGraphElement, ElkLabel, ElkNode, ElkPort, ElkPrimitiveEdge, ElkShape } from 'elkjs/lib/elk-api';
3434
import { injectable } from 'inversify';
35-
import { ElkFactory } from 'sprotty-elk';
3635
import { ElementFilter } from './element-filter';
3736
import { LayoutConfigurator } from './layout-configurator';
3837

38+
/**
39+
* Factory for ELK instances. Follow the elkjs package documentation on how to configure ELK
40+
* instances. For example, the bundled version can be used by importing the ELK constructor
41+
* from `"elkjs/lib/elk.bundled"`. For the webworker version, import the constructor from
42+
* `"elkjs/lib/elk-api"` and add the option `workerUrl: "elk/elk-worker.min.js"`.
43+
*/
44+
export type ElkFactory = () => ELK;
45+
export const ElkFactory = Symbol('ElkFactory');
46+
3947
/**
4048
* An implementation of GLSP's {@link LayoutEngine} interface that retrieves the graphical model from the {@link ModelState},
4149
* transforms this model into an ELK graph and then invokes the underlying ELK instance for layout computation.

packages/layout-elk/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (c) 2022 STMicroelectronics and others.
2+
* Copyright (c) 2022-2023 STMicroelectronics and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License v. 2.0 which is available at
@@ -13,8 +13,8 @@
1313
*
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
16+
export { LayoutOptions } from 'elkjs';
1617
export * from './di.config';
1718
export * from './element-filter';
1819
export * from './glsp-elk-layout-engine';
1920
export * from './layout-configurator';
20-
export * from './sprotty-elk';

packages/layout-elk/src/layout-configurator.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
1616
import { GEdge, GGraph, GLabel, GModelElement, GNode, GPort, ModelState } from '@eclipse-glsp/server';
17+
import { LayoutOptions } from 'elkjs';
1718
import { inject, injectable } from 'inversify';
18-
import { LayoutOptions } from './sprotty-elk';
19-
2019
export const LayoutConfigurator = Symbol('LayoutConfigurator');
2120
/**
2221
* Configurator for ELK layout algorithms; provides mappings of layout options for each model element.

0 commit comments

Comments
 (0)