@finos/legend-vscode-extension-dependencies 2.0.12 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Copyright (c) 2020-present, Goldman Sachs
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { getDiagram, DiagramRenderer, } from '@finos/legend-extension-dsl-diagram';
18
+ import { createRef, useEffect, useState } from 'react';
19
+ import '../../style/index.scss';
20
+ import { postMessage } from '../utils/VsCodeUtils.js';
21
+ import { GET_PROJECT_ENTITIES, GET_PROJECT_ENTITIES_RESPONSE, } from '../utils/Const.js';
22
+ import { getPureGraph } from '../graph-manager/index.js';
23
+ export const DiagramRendererComponent = ({ diagramId, presets }) => {
24
+ const ref = createRef();
25
+ const [diagram, setDiagram] = useState(null);
26
+ const [entities, setEntities] = useState([]);
27
+ const [error, setError] = useState();
28
+ useEffect(() => {
29
+ postMessage({
30
+ command: GET_PROJECT_ENTITIES,
31
+ });
32
+ }, [diagramId]);
33
+ window.addEventListener('message', (event) => {
34
+ const message = event.data;
35
+ if (message.command === GET_PROJECT_ENTITIES_RESPONSE) {
36
+ const es = message.result;
37
+ setEntities(es);
38
+ }
39
+ });
40
+ useEffect(() => {
41
+ if (entities.length && diagramId) {
42
+ getPureGraph(entities, presets)
43
+ .then((pureModel) => {
44
+ setDiagram(getDiagram(diagramId, pureModel));
45
+ setError(null);
46
+ })
47
+ .catch((e) => {
48
+ setError(e.message);
49
+ setDiagram(null);
50
+ });
51
+ }
52
+ }, [entities, diagramId, presets]);
53
+ useEffect(() => {
54
+ if (diagram) {
55
+ const diagramRenderer = new DiagramRenderer(ref.current, diagram);
56
+ diagramRenderer.render({ initial: true });
57
+ }
58
+ }, [ref, diagram]);
59
+ return (_jsx("div", { className: "diagram__renderer", ref: ref, children: error ? (_jsxs("div", { className: "diagram__renderer__error", children: [_jsx("span", { children: "Something went wrong. Diagram cannot be created." }), _jsx("span", { className: "diagram__renderer__error__details", title: `${error}`, children: "Error Details." })] })) : null }));
60
+ };
61
+ //# sourceMappingURL=DiagramRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiagramRenderer.js","sourceRoot":"","sources":["../../src/components/DiagramRenderer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,UAAU,EACV,eAAe,GAChB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,wBAAwB,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,MAAM,CAAC,MAAM,wBAAwB,GAGhC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,EAAE;IAC9B,MAAM,GAAG,GAAG,SAAS,EAAkB,CAAC;IACxC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAiB,IAAI,CAAC,CAAC;IAC7D,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAW,EAAE,CAAC,CAAC;IACvD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAAiB,CAAC;IAEpD,SAAS,CAAC,GAAG,EAAE;QACb,WAAW,CAAC;YACV,OAAO,EAAE,oBAAoB;SAC9B,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,MAAM,CAAC,gBAAgB,CACrB,SAAS,EACT,CAAC,KAA0D,EAAE,EAAE;QAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC;QAC3B,IAAI,OAAO,CAAC,OAAO,KAAK,6BAA6B,EAAE,CAAC;YACtD,MAAM,EAAE,GAAa,OAAO,CAAC,MAAM,CAAC;YACpC,WAAW,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CACF,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;YACjC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;iBAC5B,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;gBAClB,UAAU,CAAC,UAAU,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;gBAC7C,QAAQ,CAAC,IAAI,CAAC,CAAC;YACjB,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;gBACX,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBACpB,UAAU,CAAC,IAAI,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACP,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,OAAO,EAAE,CAAC;YACZ,MAAM,eAAe,GAAG,IAAI,eAAe,CACzC,GAAG,CAAC,OAAyB,EAC7B,OAAO,CACR,CAAC;YACF,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,cAAK,SAAS,EAAC,mBAAmB,EAAC,GAAG,EAAE,GAAG,YACxC,KAAK,CAAC,CAAC,CAAC,CACP,eAAK,SAAS,EAAC,0BAA0B,aACvC,8EAA6D,EAC7D,eACE,SAAS,EAAC,mCAAmC,EAC7C,KAAK,EAAE,GAAG,KAAK,EAAE,+BAGZ,IACH,CACP,CAAC,CAAC,CAAC,IAAI,GACJ,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { Entity } from '@finos/legend-storage';
17
+ import { type AbstractPreset } from '@finos/legend-shared';
17
18
  import { type PureModel } from '@finos/legend-graph';
18
- export declare const getPureGraph: (entities: Entity[]) => Promise<PureModel>;
19
+ export declare const getPureGraph: (entities: Entity[], presets: AbstractPreset[]) => Promise<PureModel>;
19
20
  //# sourceMappingURL=VSCODE_Extension_GraphManagerHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"VSCODE_Extension_GraphManagerHelper.d.ts","sourceRoot":"","sources":["../../../src/graph-manager/helpers/VSCODE_Extension_GraphManagerHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAEpD,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,YAAY,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,SAAS,CA4BnE,CAAC"}
1
+ {"version":3,"file":"VSCODE_Extension_GraphManagerHelper.d.ts","sourceRoot":"","sources":["../../../src/graph-manager/helpers/VSCODE_Extension_GraphManagerHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,cAAc,EAAc,MAAM,sBAAsB,CAAC;AACvE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,qBAAqB,CAAC;AAI7B,eAAO,MAAM,YAAY,EAAE,CACzB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,cAAc,EAAE,KACtB,OAAO,CAAC,SAAS,CA8BrB,CAAC"}
@@ -17,12 +17,13 @@ import { LogService } from '@finos/legend-shared';
17
17
  import { Core_GraphManagerPreset, GraphManagerState, } from '@finos/legend-graph';
18
18
  import { LegendStudioPluginManager } from '@finos/legend-application-studio';
19
19
  import { DSL_Diagram_GraphManagerPreset } from '@finos/legend-extension-dsl-diagram/graph';
20
- export const getPureGraph = async (entities) => {
20
+ export const getPureGraph = async (entities, presets) => {
21
21
  const pluginManager = LegendStudioPluginManager.create();
22
22
  pluginManager
23
23
  .usePresets([
24
24
  new Core_GraphManagerPreset(),
25
25
  new DSL_Diagram_GraphManagerPreset(),
26
+ ...presets,
26
27
  ])
27
28
  .install();
28
29
  const graphManagerState = new GraphManagerState(pluginManager, new LogService());
@@ -1 +1 @@
1
- {"version":3,"file":"VSCODE_Extension_GraphManagerHelper.js","sourceRoot":"","sources":["../../../src/graph-manager/helpers/VSCODE_Extension_GraphManagerHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAEL,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAE3F,MAAM,CAAC,MAAM,YAAY,GAA+C,KAAK,EAC3E,QAAkB,EAClB,EAAE;IACF,MAAM,aAAa,GAAG,yBAAyB,CAAC,MAAM,EAAE,CAAC;IACzD,aAAa;SACV,UAAU,CAAC;QACV,IAAI,uBAAuB,EAAE;QAC7B,IAAI,8BAA8B,EAAE;KACrC,CAAC;SACD,OAAO,EAAE,CAAC;IACb,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAC7C,aAAa,EACb,IAAI,UAAU,EAAE,CACjB,CAAC;IAEF,MAAM,iBAAiB,CAAC,YAAY,CAAC,UAAU,CAAC;QAC9C,GAAG,EAAE,MAAM;QACX,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,EAAE;KACjB,CAAC,CAAC;IACH,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC7C,MAAM,iBAAiB,CAAC,YAAY,CAAC,UAAU,CAC7C,iBAAiB,CAAC,KAAK,EACvB,QAAQ,EACR,iBAAiB,CAAC,eAAe,EACjC,EAAE,CACH,CAAC;IACF,OAAO,iBAAiB,CAAC,KAAK,CAAC;AACjC,CAAC,CAAC"}
1
+ {"version":3,"file":"VSCODE_Extension_GraphManagerHelper.js","sourceRoot":"","sources":["../../../src/graph-manager/helpers/VSCODE_Extension_GraphManagerHelper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAuB,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAEL,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC7E,OAAO,EAAE,8BAA8B,EAAE,MAAM,2CAA2C,CAAC;AAE3F,MAAM,CAAC,MAAM,YAAY,GAGC,KAAK,EAC7B,QAAkB,EAClB,OAAyB,EACzB,EAAE;IACF,MAAM,aAAa,GAAG,yBAAyB,CAAC,MAAM,EAAE,CAAC;IACzD,aAAa;SACV,UAAU,CAAC;QACV,IAAI,uBAAuB,EAAE;QAC7B,IAAI,8BAA8B,EAAE;QACpC,GAAG,OAAO;KACX,CAAC;SACD,OAAO,EAAE,CAAC;IACb,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAC7C,aAAa,EACb,IAAI,UAAU,EAAE,CACjB,CAAC;IAEF,MAAM,iBAAiB,CAAC,YAAY,CAAC,UAAU,CAAC;QAC9C,GAAG,EAAE,MAAM;QACX,OAAO,EAAE,CAAC;QACV,YAAY,EAAE,EAAE;KACjB,CAAC,CAAC;IACH,MAAM,iBAAiB,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;IAC7C,MAAM,iBAAiB,CAAC,YAAY,CAAC,UAAU,CAC7C,iBAAiB,CAAC,KAAK,EACvB,QAAQ,EACR,iBAAiB,CAAC,eAAe,EACjC,EAAE,CACH,CAAC;IACF,OAAO,iBAAiB,CAAC,KAAK,CAAC;AACjC,CAAC,CAAC"}
package/lib/index.d.ts CHANGED
@@ -13,6 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export * from '@finos/legend-extension-dsl-diagram';
16
+ export * from './components/DiagramRenderer.js';
17
17
  export * from './graph-manager/index.js';
18
18
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC"}
package/lib/index.js CHANGED
@@ -13,6 +13,6 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export * from '@finos/legend-extension-dsl-diagram';
16
+ export * from './components/DiagramRenderer.js';
17
17
  export * from './graph-manager/index.js';
18
18
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,qCAAqC,CAAC;AACpD,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const GET_PROJECT_ENTITIES = "getProjectEntities";
17
+ export declare const GET_PROJECT_ENTITIES_RESPONSE = "getProjectEntitiesResponse";
18
+ //# sourceMappingURL=Const.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Const.d.ts","sourceRoot":"","sources":["../../src/utils/Const.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AACzD,eAAO,MAAM,6BAA6B,+BAA+B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ // Event Types
17
+ export const GET_PROJECT_ENTITIES = 'getProjectEntities';
18
+ export const GET_PROJECT_ENTITIES_RESPONSE = 'getProjectEntitiesResponse';
19
+ //# sourceMappingURL=Const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Const.js","sourceRoot":"","sources":["../../src/utils/Const.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,cAAc;AACd,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC;AACzD,MAAM,CAAC,MAAM,6BAA6B,GAAG,4BAA4B,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export declare const postMessage: (message: unknown) => void;
17
+ //# sourceMappingURL=VsCodeUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VsCodeUtils.d.ts","sourceRoot":"","sources":["../../src/utils/VsCodeUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,eAAO,MAAM,WAAW,YAAa,OAAO,KAAG,IAE9C,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export const postMessage = (message) => {
17
+ vscode.postMessage(message);
18
+ };
19
+ //# sourceMappingURL=VsCodeUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VsCodeUtils.js","sourceRoot":"","sources":["../../src/utils/VsCodeUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,OAAgB,EAAQ,EAAE;IACpD,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finos/legend-vscode-extension-dependencies",
3
- "version": "2.0.12",
3
+ "version": "2.1.0",
4
4
  "homepage": "https://github.com/finos/legend-studio/tree/master/packages/legend-vscode-extension-dependencies",
5
5
  "bugs": {
6
6
  "url": "https://github.com/finos/legend-studio/issues"
@@ -17,6 +17,9 @@
17
17
  ".": {
18
18
  "import": "./lib/index.js",
19
19
  "require": "./lib/bundles/bundle.cjs.js"
20
+ },
21
+ "./style/index.css": {
22
+ "default": "./lib/bundles/style/bundle.css"
20
23
  }
21
24
  },
22
25
  "module": "lib/index.js",
@@ -37,11 +40,12 @@
37
40
  "test:watch": "jest --watch"
38
41
  },
39
42
  "dependencies": {
40
- "@finos/legend-application-studio": "28.18.8",
41
- "@finos/legend-extension-dsl-diagram": "8.0.200",
42
- "@finos/legend-graph": "31.10.16",
43
+ "@finos/legend-application-studio": "28.18.9",
44
+ "@finos/legend-extension-dsl-diagram": "8.0.201",
45
+ "@finos/legend-graph": "31.10.17",
43
46
  "@finos/legend-shared": "10.0.49",
44
- "@finos/legend-storage": "3.0.99"
47
+ "@finos/legend-storage": "3.0.99",
48
+ "react": "18.3.1"
45
49
  },
46
50
  "devDependencies": {
47
51
  "@babel/core": "7.24.9",
@@ -51,13 +55,16 @@
51
55
  "@rollup/plugin-json": "6.1.0",
52
56
  "@rollup/plugin-node-resolve": "15.2.3",
53
57
  "@rollup/plugin-terser": "0.4.4",
58
+ "@types/vscode": "1.91.0",
54
59
  "cross-env": "7.0.3",
55
60
  "eslint": "8.57.0",
56
61
  "npm-run-all": "4.1.5",
62
+ "postcss-url": "10.1.3",
57
63
  "rimraf": "6.0.1",
58
64
  "rollup": "4.19.0",
59
65
  "rollup-plugin-flow": "1.1.1",
60
66
  "rollup-plugin-import-css": "3.5.0",
67
+ "rollup-plugin-postcss": "4.0.2",
61
68
  "typescript": "5.5.4"
62
69
  },
63
70
  "publishConfig": {
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ import {
18
+ type Diagram,
19
+ getDiagram,
20
+ DiagramRenderer,
21
+ } from '@finos/legend-extension-dsl-diagram';
22
+ import type { Entity } from '@finos/legend-storage';
23
+ import { createRef, useEffect, useState } from 'react';
24
+ import '../../style/index.scss';
25
+ import { postMessage } from '../utils/VsCodeUtils.js';
26
+ import {
27
+ GET_PROJECT_ENTITIES,
28
+ GET_PROJECT_ENTITIES_RESPONSE,
29
+ } from '../utils/Const.js';
30
+ import { getPureGraph } from '../graph-manager/index.js';
31
+ import type { AbstractPreset } from '@finos/legend-shared';
32
+
33
+ export const DiagramRendererComponent: React.FC<{
34
+ diagramId: string;
35
+ presets: AbstractPreset[];
36
+ }> = ({ diagramId, presets }) => {
37
+ const ref = createRef<HTMLDivElement>();
38
+ const [diagram, setDiagram] = useState<Diagram | null>(null);
39
+ const [entities, setEntities] = useState<Entity[]>([]);
40
+ const [error, setError] = useState<string | null>();
41
+
42
+ useEffect(() => {
43
+ postMessage({
44
+ command: GET_PROJECT_ENTITIES,
45
+ });
46
+ }, [diagramId]);
47
+
48
+ window.addEventListener(
49
+ 'message',
50
+ (event: MessageEvent<{ result: Entity[]; command: string }>) => {
51
+ const message = event.data;
52
+ if (message.command === GET_PROJECT_ENTITIES_RESPONSE) {
53
+ const es: Entity[] = message.result;
54
+ setEntities(es);
55
+ }
56
+ },
57
+ );
58
+
59
+ useEffect(() => {
60
+ if (entities.length && diagramId) {
61
+ getPureGraph(entities, presets)
62
+ .then((pureModel) => {
63
+ setDiagram(getDiagram(diagramId, pureModel));
64
+ setError(null);
65
+ })
66
+ .catch((e) => {
67
+ setError(e.message);
68
+ setDiagram(null);
69
+ });
70
+ }
71
+ }, [entities, diagramId, presets]);
72
+
73
+ useEffect(() => {
74
+ if (diagram) {
75
+ const diagramRenderer = new DiagramRenderer(
76
+ ref.current as HTMLDivElement,
77
+ diagram,
78
+ );
79
+ diagramRenderer.render({ initial: true });
80
+ }
81
+ }, [ref, diagram]);
82
+
83
+ return (
84
+ <div className="diagram__renderer" ref={ref}>
85
+ {error ? (
86
+ <div className="diagram__renderer__error">
87
+ <span>Something went wrong. Diagram cannot be created.</span>
88
+ <span
89
+ className="diagram__renderer__error__details"
90
+ title={`${error}`}
91
+ >
92
+ Error Details.
93
+ </span>
94
+ </div>
95
+ ) : null}
96
+ </div>
97
+ );
98
+ };
@@ -15,7 +15,7 @@
15
15
  */
16
16
 
17
17
  import type { Entity } from '@finos/legend-storage';
18
- import { LogService } from '@finos/legend-shared';
18
+ import { type AbstractPreset, LogService } from '@finos/legend-shared';
19
19
  import {
20
20
  type PureModel,
21
21
  Core_GraphManagerPreset,
@@ -24,14 +24,19 @@ import {
24
24
  import { LegendStudioPluginManager } from '@finos/legend-application-studio';
25
25
  import { DSL_Diagram_GraphManagerPreset } from '@finos/legend-extension-dsl-diagram/graph';
26
26
 
27
- export const getPureGraph: (entities: Entity[]) => Promise<PureModel> = async (
27
+ export const getPureGraph: (
28
28
  entities: Entity[],
29
+ presets: AbstractPreset[],
30
+ ) => Promise<PureModel> = async (
31
+ entities: Entity[],
32
+ presets: AbstractPreset[],
29
33
  ) => {
30
34
  const pluginManager = LegendStudioPluginManager.create();
31
35
  pluginManager
32
36
  .usePresets([
33
37
  new Core_GraphManagerPreset(),
34
38
  new DSL_Diagram_GraphManagerPreset(),
39
+ ...presets,
35
40
  ])
36
41
  .install();
37
42
  const graphManagerState = new GraphManagerState(
package/src/index.ts CHANGED
@@ -14,5 +14,5 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- export * from '@finos/legend-extension-dsl-diagram';
17
+ export * from './components/DiagramRenderer.js';
18
18
  export * from './graph-manager/index.js';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ // Event Types
18
+ export const GET_PROJECT_ENTITIES = 'getProjectEntities';
19
+ export const GET_PROJECT_ENTITIES_RESPONSE = 'getProjectEntitiesResponse';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) 2020-present, Goldman Sachs
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ interface Vscode {
18
+ postMessage(message: unknown): void;
19
+ }
20
+
21
+ declare const vscode: Vscode;
22
+
23
+ export const postMessage = (message: unknown): void => {
24
+ vscode.postMessage(message);
25
+ };
package/tsconfig.json CHANGED
@@ -50,7 +50,10 @@
50
50
  "files": [
51
51
  "./src/index.ts",
52
52
  "./src/graph-manager/index.ts",
53
- "./src/graph-manager/helpers/VSCODE_Extension_GraphManagerHelper.ts"
53
+ "./src/graph-manager/helpers/VSCODE_Extension_GraphManagerHelper.ts",
54
+ "./src/utils/Const.ts",
55
+ "./src/utils/VsCodeUtils.ts",
56
+ "./src/components/DiagramRenderer.tsx"
54
57
  ],
55
58
  "include": [
56
59
  "src/**/*.ts",