@nu-art/ts-dependency-viewer-frontend 0.400.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/_ats/ATS_DependencyGraph/ATS_DependencyGraph.d.ts +9 -0
- package/_ats/ATS_DependencyGraph/ATS_DependencyGraph.js +18 -0
- package/_ats/ATS_DependencyGraph/ATS_DependencyGraph.scss +0 -0
- package/_ats/index.d.ts +1 -0
- package/_ats/index.js +1 -0
- package/dependency-viewer/Component_DependencyViewer.d.ts +16 -0
- package/dependency-viewer/Component_DependencyViewer.js +87 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +69 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppToolsScreen, ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
type State = {};
|
|
3
|
+
export declare class ATS_DependencyViewer extends ComponentSync<{}, State> {
|
|
4
|
+
static defaultProps: {};
|
|
5
|
+
static screen: AppToolsScreen;
|
|
6
|
+
protected deriveStateFromProps(nextProps: {}, state: State): State;
|
|
7
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ATS_Frontend, ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
3
|
+
import { Component_DependencyViewer } from '../../dependency-viewer/Component_DependencyViewer.js';
|
|
4
|
+
export class ATS_DependencyViewer extends ComponentSync {
|
|
5
|
+
static defaultProps = {};
|
|
6
|
+
static screen = {
|
|
7
|
+
name: 'Dependency Graph',
|
|
8
|
+
key: 'dependency-graph',
|
|
9
|
+
renderer: this,
|
|
10
|
+
group: ATS_Frontend
|
|
11
|
+
};
|
|
12
|
+
deriveStateFromProps(nextProps, state) {
|
|
13
|
+
return state;
|
|
14
|
+
}
|
|
15
|
+
render() {
|
|
16
|
+
return _jsx(Component_DependencyViewer, {});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
File without changes
|
package/_ats/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ATS_DependencyGraph/ATS_DependencyGraph.js';
|
package/_ats/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ATS_DependencyGraph/ATS_DependencyGraph.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentSync, ModuleFE_BaseApi } from '@nu-art/thunderstorm-frontend/index';
|
|
2
|
+
type State = {
|
|
3
|
+
protoModules: ModuleFE_BaseApi<any>[];
|
|
4
|
+
};
|
|
5
|
+
export declare class Component_DependencyViewer extends ComponentSync<{}, State> {
|
|
6
|
+
private readonly graphContainerRef;
|
|
7
|
+
componentDidMount(): void;
|
|
8
|
+
protected deriveStateFromProps(nextProps: {}, state: State): State;
|
|
9
|
+
private getMidNode;
|
|
10
|
+
private getModuleNode;
|
|
11
|
+
private getDependencyNode;
|
|
12
|
+
private getGraphString;
|
|
13
|
+
private renderGraph;
|
|
14
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { ComponentSync } from '@nu-art/thunderstorm-frontend/index';
|
|
4
|
+
import { _keys, filterDuplicates, RuntimeModules } from '@nu-art/ts-common';
|
|
5
|
+
import { graphviz } from 'd3-graphviz';
|
|
6
|
+
import { Digraph, Edge, Node, Subgraph, toDot } from 'ts-graphviz';
|
|
7
|
+
export class Component_DependencyViewer extends ComponentSync {
|
|
8
|
+
graphContainerRef = React.createRef();
|
|
9
|
+
componentDidMount() {
|
|
10
|
+
if (!this.graphContainerRef.current) {
|
|
11
|
+
this.logWarning('Finished mounting but no ref to container');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this.renderGraph();
|
|
15
|
+
this.forceUpdate();
|
|
16
|
+
}
|
|
17
|
+
deriveStateFromProps(nextProps, state) {
|
|
18
|
+
state = super.deriveStateFromProps(nextProps, state);
|
|
19
|
+
state.protoModules = RuntimeModules().filter((module) => !!module.dbDef?.dbKey);
|
|
20
|
+
return state;
|
|
21
|
+
}
|
|
22
|
+
getMidNode = (startNode, endNode, property) => {
|
|
23
|
+
const id = `${startNode.id} => ${endNode.id} \n\nDependency property: ${property}`;
|
|
24
|
+
return new Node(id, {
|
|
25
|
+
id: id,
|
|
26
|
+
shape: 'circle',
|
|
27
|
+
width: 0.2,
|
|
28
|
+
label: '',
|
|
29
|
+
style: 'filled',
|
|
30
|
+
fillcolor: '#ffffff',
|
|
31
|
+
tooltip: id
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
getModuleNode = (module) => {
|
|
35
|
+
const id = module.dbDef.dbKey;
|
|
36
|
+
return new Node(id, {
|
|
37
|
+
id: id,
|
|
38
|
+
shape: 'rect',
|
|
39
|
+
style: 'filled',
|
|
40
|
+
label: module.dbDef.entityName,
|
|
41
|
+
fillcolor: '#ffffff',
|
|
42
|
+
fontsize: 13,
|
|
43
|
+
fontcolor: '#333333',
|
|
44
|
+
width: 3
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
getDependencyNode = (startNode, endNode, midNode) => {
|
|
48
|
+
const id = `${startNode.id} => ${endNode.id}`;
|
|
49
|
+
return [new Edge([startNode, midNode], { id: id, arrowhead: 'none' }), new Edge([midNode, endNode], { id: id })];
|
|
50
|
+
};
|
|
51
|
+
getGraphString = () => {
|
|
52
|
+
const graph = new Digraph('', { bgcolor: 'transparent' });
|
|
53
|
+
const subgraph = new Subgraph('Container');
|
|
54
|
+
graph.addSubgraph(subgraph);
|
|
55
|
+
const moduleNodes = {};
|
|
56
|
+
this.state.protoModules.forEach(module => {
|
|
57
|
+
const moduleNode = this.getModuleNode(module);
|
|
58
|
+
moduleNodes[module.dbDef.dbKey] = moduleNode;
|
|
59
|
+
subgraph.addNode(moduleNode);
|
|
60
|
+
});
|
|
61
|
+
this.state.protoModules.forEach(module => {
|
|
62
|
+
const startNode = moduleNodes[module.dbDef.dbKey];
|
|
63
|
+
if (module.dbDef.dependencies)
|
|
64
|
+
filterDuplicates(_keys(module.dbDef.dependencies), item => module.dbDef.dependencies[item].dbKey).map(key => {
|
|
65
|
+
const endNode = moduleNodes[module.dbDef.dependencies[key].dbKey];
|
|
66
|
+
const midNode = this.getMidNode(startNode, endNode, key);
|
|
67
|
+
const edge = this.getDependencyNode(startNode, endNode, midNode);
|
|
68
|
+
subgraph.addNode(midNode);
|
|
69
|
+
subgraph.addEdge(edge[0]);
|
|
70
|
+
subgraph.addEdge(edge[1]);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return toDot(graph);
|
|
74
|
+
};
|
|
75
|
+
renderGraph = () => {
|
|
76
|
+
const graphString = this.getGraphString();
|
|
77
|
+
const rect = this.graphContainerRef.current.getBoundingClientRect();
|
|
78
|
+
graphviz(this.graphContainerRef.current, {
|
|
79
|
+
useWorker: false,
|
|
80
|
+
width: rect.width,
|
|
81
|
+
height: rect.height
|
|
82
|
+
}).renderDot(graphString);
|
|
83
|
+
};
|
|
84
|
+
render() {
|
|
85
|
+
return _jsx("div", { className: 'match_parent', ref: this.graphContainerRef });
|
|
86
|
+
}
|
|
87
|
+
}
|
package/index.d.ts
ADDED
package/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nu-art/ts-dependency-viewer-frontend",
|
|
3
|
+
"version": "0.400.7",
|
|
4
|
+
"description": "ts-dependency-viewer - Express & Typescript based backend framework Frontend",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"TacB0sS",
|
|
7
|
+
"infra",
|
|
8
|
+
"nu-art",
|
|
9
|
+
"thunderstorm",
|
|
10
|
+
"typescript",
|
|
11
|
+
"ts-dependency-viewer"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/nu-art-js/thunderstorm",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/nu-art-js/thunderstorm/issues"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"directory": "dist",
|
|
19
|
+
"linkDirectory": true
|
|
20
|
+
},
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+ssh://git@github.com:nu-art-js/thunderstorm.git"
|
|
24
|
+
},
|
|
25
|
+
"license": "Apache-2.0",
|
|
26
|
+
"author": "TacB0sS",
|
|
27
|
+
"files": [
|
|
28
|
+
"**/*"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@nu-art/ts-dependency-viewer-shared": "0.400.7",
|
|
35
|
+
"@nu-art/thunderstorm-frontend": "0.400.7",
|
|
36
|
+
"@nu-art/thunderstorm-shared": "0.400.7",
|
|
37
|
+
"@nu-art/ts-common": "0.400.7",
|
|
38
|
+
"compression": "^1.7.4",
|
|
39
|
+
"d3": "7.8.2",
|
|
40
|
+
"d3-graphviz": "5.0.2",
|
|
41
|
+
"d3-selection": "3.0.0",
|
|
42
|
+
"firebase": "^11.9.0",
|
|
43
|
+
"firebase-admin": "13.4.0",
|
|
44
|
+
"firebase-functions": "6.3.2",
|
|
45
|
+
"react": "^18.0.0",
|
|
46
|
+
"ts-graphviz": "1.5.3"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/react": "^18.0.0",
|
|
50
|
+
"@types/chai": "^4.3.4",
|
|
51
|
+
"@types/mocha": "^10.0.1",
|
|
52
|
+
"@types/d3": "^7.4.0",
|
|
53
|
+
"@types/d3-graphviz": "^2.6.7"
|
|
54
|
+
},
|
|
55
|
+
"unitConfig": {
|
|
56
|
+
"type": "typescript-lib"
|
|
57
|
+
},
|
|
58
|
+
"type": "module",
|
|
59
|
+
"exports": {
|
|
60
|
+
".": {
|
|
61
|
+
"types": "./index.d.ts",
|
|
62
|
+
"import": "./index.js"
|
|
63
|
+
},
|
|
64
|
+
"./*": {
|
|
65
|
+
"types": "./*.d.ts",
|
|
66
|
+
"import": "./*.js"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|