Skip to content

Commit 2ae7567

Browse files
authored
GLSP-865 Update to latest protocol version (#61)
Update to latest protocol version and add gmodel class + builder for `GForeignObjectElement`
1 parent 63971fc commit 2ae7567

File tree

17 files changed

+277
-255
lines changed

17 files changed

+277
-255
lines changed

examples/workflow-server/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"compilerOptions": {
44
"rootDir": "src",
55
"outDir": "lib",
6-
"baseUrl": ".",
76
"esModuleInterop": true,
87
"resolveJsonModule": true
98
},

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"watch": "lerna run --parallel watch"
2929
},
3030
"devDependencies": {
31-
"@eclipse-glsp/dev": "next",
31+
"@eclipse-glsp/dev": "1.1.0-next.3b7f01d.144",
3232
"@types/node": "16.x",
3333
"lerna": "^6.6.2",
3434
"typescript": "^5.0.4"

packages/graph/src/default-types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { GButton } from './gbutton';
1818
import { GCompartment } from './gcompartment';
1919
import { GEdge } from './gedge';
2020
import { GGraph } from './ggraph';
21-
import { GHtmlRoot } from './ghtmlroot';
21+
import { GHtmlRoot } from './ghtml-root';
2222
import { GIssueMarker } from './gissue-marker';
2323
import { GLabel } from './glabel';
2424
import { GModelElementConstructor } from './gmodel-element';
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/********************************************************************************
2+
* Copyright (c) 2023 EclipseSource 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+
17+
import { GShapePreRenderedElementBuilder, GShapedPreRenderedElement } from './gshaped-prerendered-element';
18+
19+
/**
20+
* A `foreignObject` element to be transferred to the DOM within the SVG.
21+
*
22+
* This can be useful to to benefit from e.g. HTML rendering features, such as line wrapping, inside of
23+
* the SVG diagram. Note that `foreignObject` is not supported by all browsers and SVG viewers may not
24+
* support rendering the `foreignObject` content.
25+
*
26+
* If no dimensions are specified in the schema element, this element will obtain the dimension of
27+
* its parent to fill the entire available room. Thus, this element requires specified bounds itself
28+
* or bounds to be available for its parent.
29+
*/
30+
export class GForeignObjectElement extends GShapedPreRenderedElement {
31+
static override builder(): GForeignObjectElementBuilder {
32+
return new GForeignObjectElementBuilder(GForeignObjectElement);
33+
}
34+
namespace: string;
35+
}
36+
37+
export class GForeignObjectElementBuilder<
38+
G extends GForeignObjectElement = GForeignObjectElement
39+
> extends GShapePreRenderedElementBuilder<G> {
40+
namespace(namespace: string): this {
41+
this.proxy.namespace = namespace;
42+
return this;
43+
}
44+
}

packages/graph/src/gmodel-element.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,16 @@ import {
1717
Args,
1818
Bounds,
1919
Dimension,
20-
flatPush,
20+
GModelElementSchema,
21+
GModelRootSchema,
2122
JsonPrimitive,
2223
MaybeArray,
2324
Point,
24-
SModelElementSchema,
25-
SModelRootSchema
25+
flatPush
2626
} from '@eclipse-glsp/protocol';
2727
import * as uuid from 'uuid';
2828

2929
export type GModelElementConstructor<G extends GModelElement = GModelElement> = new () => G;
30-
/**
31-
* Represents a `GModeElement` serialized as plain JSON object.
32-
*/
33-
export type GModelElementSchema = SModelElementSchema;
34-
35-
export namespace GModelElementSchema {
36-
/**
37-
* Typeguard function to check wether the given object is an {@link GModelElementSchema}.
38-
* @param object The object to check.
39-
* @returns A type literal indicating wether the given object is of type {@link GModelElementSchema}.
40-
*/
41-
export const is = SModelElementSchema.is;
42-
}
4330

4431
/**
4532
* Base type for all elements of the graphical model.
@@ -187,9 +174,7 @@ export abstract class GModelElementBuilder<G extends GModelElement> {
187174
}
188175
}
189176

190-
export type GModelRootSchema = SModelRootSchema;
191-
192-
export class GModelRoot extends GModelElement implements SModelRootSchema {
177+
export class GModelRoot extends GModelElement implements GModelRootSchema {
193178
static builder(): GModelRootBuilder {
194179
return new GModelRootBuilder(GModelRoot);
195180
}

packages/graph/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ export * from './gbutton';
2020
export * from './gcompartment';
2121
export * from './gedge';
2222
export * from './gedge-layoutable';
23+
export * from './gforeign-object-element';
2324
export * from './ggraph';
24-
export * from './ghtmlroot';
25+
export * from './ghtml-root';
2526
export * from './gissue-marker';
2627
export * from './glabel';
2728
export * from './glayoutable';

packages/graph/tsconfig.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
"compilerOptions": {
44
"rootDir": "src",
55
"outDir": "lib",
6-
"reactNamespace": "JSX",
7-
"baseUrl": "src",
6+
"reactNamespace": "JSX"
87
},
9-
"include": [
10-
"src"
11-
]
12-
}
8+
"include": ["src"]
9+
}

packages/layout-elk/tsconfig.json

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,8 @@
44
"rootDir": "src",
55
"outDir": "lib",
66
"reactNamespace": "JSX",
7-
"baseUrl": "src",
8-
"types": [
9-
"node",
10-
"mocha",
11-
"reflect-metadata"
12-
]
7+
"types": ["node", "mocha", "reflect-metadata"]
138
},
14-
"exclude": [
15-
"**/*.spec.ts"
16-
],
17-
"include": [
18-
"src"
19-
]
20-
}
9+
"exclude": ["**/*.spec.ts"],
10+
"include": ["src"]
11+
}

packages/server/src/common/command/recording-command.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
1515
********************************************************************************/
1616

17-
import { GModelRootSchema } from '@eclipse-glsp/graph';
18-
import { AnyObject, MaybePromise, SModelRootSchema } from '@eclipse-glsp/protocol';
17+
import { AnyObject, GModelElementSchema, GModelRootSchema, MaybePromise } from '@eclipse-glsp/protocol';
1918
import * as jsonPatch from 'fast-json-patch';
2019
import { GModelSerializer } from '../features/model/gmodel-serializer';
2120
import { ModelState } from '../features/model/model-state';
@@ -102,7 +101,7 @@ export class GModelRecordingCommand extends AbstractRecordingCommand<GModelRootS
102101
return this.serializer.createSchema(this.modelState.root);
103102
}
104103

105-
protected override postChange(newModel: SModelRootSchema): MaybePromise<void> {
104+
protected override postChange(newModel: GModelElementSchema): MaybePromise<void> {
106105
const newRoot = this.serializer.createRoot(newModel);
107106
this.modelState.updateRoot(newRoot);
108107
}

0 commit comments

Comments
 (0)