codecharta-visualization 1.89.0 → 1.90.0
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/app/app.module.ts +16 -2
- package/app/codeCharta/assets/gameObjectsFile.json +75 -0
- package/app/codeCharta/codeCharta.model.ts +1 -10
- package/app/codeCharta/services/idToBuilding/idToBuilding.service.ts +17 -0
- package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.component.spec.ts +14 -23
- package/app/codeCharta/state/effects/nodeContextMenu/highlightButtons/highlightButtons.component.ts +7 -5
- package/app/codeCharta/state/effects/nodeContextMenu/nodeContextMenuCard/nodeContextMenuCard.component.spec.ts +3 -1
- package/app/codeCharta/state/effects/nodeContextMenu/rightClickedCodeMapNode.selector.ts +1 -1
- package/app/codeCharta/state/effects/trackEventUsageData/trackEventUsageData.effect.spec.ts +56 -0
- package/app/codeCharta/state/effects/trackEventUsageData/trackEventUsageData.effect.ts +49 -0
- package/app/codeCharta/state/effects/unfocusNodesOnLoadingMap.effect.ts +2 -1
- package/app/codeCharta/state/injector.service.ts +0 -4
- package/app/codeCharta/state/selectors/accumulatedData/idToNode.selector.spec.ts +15 -0
- package/app/codeCharta/state/selectors/accumulatedData/idToNode.selector.ts +16 -0
- package/app/codeCharta/state/selectors/selectedNode.selector.ts +5 -2
- package/app/codeCharta/state/state.module.ts +0 -4
- package/app/codeCharta/state/store/appSettings/isLoadingMap/isLoadingMap.reducer.ts +1 -5
- package/app/codeCharta/state/store/state.actions.ts +0 -2
- package/app/codeCharta/state/store/state.reducer.ts +0 -2
- package/app/codeCharta/state/store/state.splitter.ts +0 -10
- package/app/codeCharta/state/store.service.ts +0 -16
- package/app/codeCharta/ui/attributeSideBar/attributeSideBar.component.spec.ts +5 -1
- package/app/codeCharta/ui/attributeSideBar/attributeSideBar.component.ts +2 -2
- package/app/codeCharta/ui/attributeSideBar/attributeSideBarHeaderSection/attributeSideBarHeaderSection.component.html +0 -1
- package/app/codeCharta/ui/attributeSideBar/attributeSideBarHeaderSection/attributeSideBarHeaderSection.component.spec.ts +3 -45
- package/app/codeCharta/ui/attributeSideBar/attributeSideBarHeaderSection/attributeSideBarHeaderSection.component.ts +2 -8
- package/app/codeCharta/ui/attributeSideBar/attributeSideBarHeaderSection/nodePath/nodePath.component.html +1 -1
- package/app/codeCharta/ui/attributeSideBar/attributeSideBarHeaderSection/nodePath/nodePath.component.spec.ts +3 -2
- package/app/codeCharta/ui/attributeSideBar/attributeSideBarHeaderSection/nodePath/nodePath.component.ts +2 -2
- package/app/codeCharta/ui/attributeSideBar/attributeSideBarSecondaryMetrics/secondaryMetrics.selector.ts +2 -2
- package/app/codeCharta/ui/attributeSideBar/metricDeltaSelected/metricDeltaSelected.component.spec.ts +26 -23
- package/app/codeCharta/ui/attributeSideBar/metricDeltaSelected/metricDeltaSelected.component.ts +2 -2
- package/app/codeCharta/ui/attributeSideBar/util/showAttributeTypeSelector.selector.spec.ts +2 -2
- package/app/codeCharta/ui/attributeSideBar/util/showAttributeTypeSelector.selector.ts +2 -2
- package/app/codeCharta/ui/codeMap/codeMap.mouseEvent.service.spec.ts +28 -45
- package/app/codeCharta/ui/codeMap/codeMap.mouseEvent.service.ts +7 -11
- package/app/codeCharta/ui/codeMap/codeMap.preRender.service.ts +4 -46
- package/app/codeCharta/ui/codeMap/threeViewer/threeSceneService.spec.ts +26 -19
- package/app/codeCharta/ui/codeMap/threeViewer/threeSceneService.ts +13 -25
- package/app/codeCharta/ui/codeMap/threeViewer/threeViewer.module.ts +3 -0
- package/app/codeCharta/ui/dialog/dialog.globalSettings.component.ts +3 -5
- package/app/codeCharta/ui/dialog/dialog.globalSettings.e2e.ts +1 -1
- package/app/codeCharta/ui/fileChooser/fileChooser.component.spec.ts +1 -0
- package/app/codeCharta/ui/fileChooser/fileChooser.component.ts +6 -1
- package/app/codeCharta/ui/fileChooser/fileChooser.e2e.ts +5 -0
- package/app/codeCharta/ui/filePanel/filePanel.component.html +1 -0
- package/app/codeCharta/ui/filePanel/filePanel.component.spec.ts +7 -0
- package/app/codeCharta/ui/filePanel/filePanel.component.ts +1 -2
- package/app/codeCharta/ui/filePanel/filePanel.module.ts +2 -0
- package/app/codeCharta/ui/filePanel/filePanelFileSelector/filePanelFileSelector.component.html +7 -1
- package/app/codeCharta/ui/filePanel/filePanelFileSelector/filePanelFileSelector.component.scss +6 -0
- package/app/codeCharta/ui/filePanel/filePanelFileSelector/filePanelFileSelector.component.ts +2 -1
- package/app/codeCharta/ui/filePanel/filePanelFileSelector/removeFileButton/removeFileButton.component.html +3 -0
- package/app/codeCharta/ui/filePanel/filePanelFileSelector/removeFileButton/removeFileButton.component.scss +9 -0
- package/app/codeCharta/ui/filePanel/filePanelFileSelector/removeFileButton/removeFileButton.component.ts +11 -0
- package/app/codeCharta/ui/rangeSlider/rangeSlider.component.ts +9 -33
- package/app/codeCharta/util/__snapshots__/usageDataTracker.spec.ts.snap +1 -16
- package/app/codeCharta/util/codeMapHelper.ts +3 -2
- package/app/codeCharta/util/customConfigHelper.ts +4 -16
- package/app/codeCharta/util/dataMocks.ts +0 -8
- package/app/codeCharta/util/envDetector.ts +0 -4
- package/app/codeCharta/util/gameObjectsParser/__snapshots__/gameObjectsImporter.spec.ts.snap +121 -0
- package/app/codeCharta/util/gameObjectsParser/gameObjectsImporter.spec.ts +11 -0
- package/app/codeCharta/util/gameObjectsParser/gameObjectsImporter.ts +170 -0
- package/app/codeCharta/util/gameObjectsParser/gameObjectsMocks.ts +75 -0
- package/app/codeCharta/util/gameObjectsParser/gameObjectsSchema.json +271 -0
- package/app/codeCharta/util/gameObjectsParser/gameObjectsValidator.spec.ts +18 -0
- package/app/codeCharta/util/gameObjectsParser/gameObjectsValidator.ts +7 -0
- package/app/codeCharta/util/nodeDecorator.ts +1 -0
- package/app/codeCharta/util/usageDataTracker.spec.ts +36 -76
- package/app/codeCharta/util/usageDataTracker.ts +20 -31
- package/conf/webpack.config.js +7 -7
- package/dist/webpack/bundle.js +871 -1260
- package/dist/webpack/bundle.js.map +1 -1
- package/package.json +10 -11
- package/app/codeCharta/state/selectors/selectedBuilding.selector.ts +0 -8
- package/app/codeCharta/state/store/lookUp/idToBuilding/idToBuilding.actions.ts +0 -22
- package/app/codeCharta/state/store/lookUp/idToBuilding/idToBuilding.reducer.spec.ts +0 -33
- package/app/codeCharta/state/store/lookUp/idToBuilding/idToBuilding.reducer.ts +0 -14
- package/app/codeCharta/state/store/lookUp/idToBuilding/idToBuilding.selector.ts +0 -3
- package/app/codeCharta/state/store/lookUp/idToBuilding/idToBuilding.service.spec.ts +0 -40
- package/app/codeCharta/state/store/lookUp/idToBuilding/idToBuilding.service.ts +0 -23
- package/app/codeCharta/state/store/lookUp/idToBuilding/idToBuilding.splitter.ts +0 -6
- package/app/codeCharta/state/store/lookUp/idToNode/idToNode.actions.ts +0 -22
- package/app/codeCharta/state/store/lookUp/idToNode/idToNode.reducer.spec.ts +0 -39
- package/app/codeCharta/state/store/lookUp/idToNode/idToNode.reducer.ts +0 -11
- package/app/codeCharta/state/store/lookUp/idToNode/idToNode.selector.ts +0 -4
- package/app/codeCharta/state/store/lookUp/idToNode/idToNode.service.spec.ts +0 -57
- package/app/codeCharta/state/store/lookUp/idToNode/idToNode.service.ts +0 -23
- package/app/codeCharta/state/store/lookUp/idToNode/idToNode.splitter.ts +0 -6
- package/app/codeCharta/state/store/lookUp/lookUp.actions.ts +0 -27
- package/app/codeCharta/state/store/lookUp/lookUp.reducer.ts +0 -10
- package/app/codeCharta/state/store/lookUp/lookUp.selector.ts +0 -3
- package/app/codeCharta/state/store/lookUp/lookUp.splitter.ts +0 -19
- package/app/codeCharta/ui/removeFileButton/removeFileButton.component.html +0 -5
- package/app/codeCharta/ui/removeFileButton/removeFileButton.component.scss +0 -41
- package/app/codeCharta/ui/removeFileButton/removeFileButton.component.ts +0 -18
- package/app/codeCharta/ui/removeFileButton/removeFileButton.module.ts +0 -7
- package/app/codeCharta/util/codeChartaFileStorage.spec.ts +0 -73
- package/app/codeCharta/util/codeChartaStorage.ts +0 -62
- package/app/codeCharta/util/lazyLoader.spec.ts +0 -33
- package/app/codeCharta/util/lazyLoader.ts +0 -50
- package/dist/webpack/vendors-node_modules_open_index_js.bundle.js +0 -1036
- package/dist/webpack/vendors-node_modules_open_index_js.bundle.js.map +0 -1
|
@@ -19,7 +19,6 @@ import { setCameraTarget } from "../state/store/appSettings/cameraTarget/cameraT
|
|
|
19
19
|
import { StoreService } from "../state/store.service"
|
|
20
20
|
import { ThreeCameraService } from "../ui/codeMap/threeViewer/threeCameraService"
|
|
21
21
|
import { ThreeOrbitControlsService } from "../ui/codeMap/threeViewer/threeOrbitControlsService"
|
|
22
|
-
import { CodeChartaStorage } from "./codeChartaStorage"
|
|
23
22
|
|
|
24
23
|
export const CUSTOM_CONFIG_FILE_EXTENSION = ".cc.config.json"
|
|
25
24
|
const CUSTOM_CONFIGS_LOCAL_STORAGE_VERSION = "1.0.1"
|
|
@@ -28,14 +27,6 @@ export const CUSTOM_CONFIGS_LOCAL_STORAGE_ELEMENT = "CodeCharta::customConfigs"
|
|
|
28
27
|
|
|
29
28
|
export class CustomConfigHelper {
|
|
30
29
|
private static customConfigs: Map<string, CustomConfig> = CustomConfigHelper.loadCustomConfigs()
|
|
31
|
-
private static storage: Storage
|
|
32
|
-
|
|
33
|
-
static getStorage() {
|
|
34
|
-
if (CustomConfigHelper.storage === undefined) {
|
|
35
|
-
CustomConfigHelper.storage = new CodeChartaStorage()
|
|
36
|
-
}
|
|
37
|
-
return CustomConfigHelper.storage
|
|
38
|
-
}
|
|
39
30
|
|
|
40
31
|
static getCustomConfigItemGroups(customConfigFileStateConnector: CustomConfigFileStateConnector): Map<string, CustomConfigItemGroup> {
|
|
41
32
|
const customConfigItemGroups: Map<string, CustomConfigItemGroup> = new Map()
|
|
@@ -83,10 +74,7 @@ export class CustomConfigHelper {
|
|
|
83
74
|
customConfigs: [...CustomConfigHelper.customConfigs]
|
|
84
75
|
}
|
|
85
76
|
|
|
86
|
-
|
|
87
|
-
CUSTOM_CONFIGS_LOCAL_STORAGE_ELEMENT,
|
|
88
|
-
JSON.stringify(newLocalStorageElement, stateObjectReplacer)
|
|
89
|
-
)
|
|
77
|
+
localStorage.setItem(CUSTOM_CONFIGS_LOCAL_STORAGE_ELEMENT, JSON.stringify(newLocalStorageElement, stateObjectReplacer))
|
|
90
78
|
}
|
|
91
79
|
|
|
92
80
|
private static loadCustomConfigs() {
|
|
@@ -97,7 +85,7 @@ export class CustomConfigHelper {
|
|
|
97
85
|
// TODO [2022-08-01]: remove replace method for SINGLE mode when deadline is reached
|
|
98
86
|
private static getCcLocalStorage() {
|
|
99
87
|
const ccLocalStorage: LocalStorageCustomConfigs = JSON.parse(
|
|
100
|
-
|
|
88
|
+
localStorage.getItem(CUSTOM_CONFIGS_LOCAL_STORAGE_ELEMENT),
|
|
101
89
|
stateObjectReviver
|
|
102
90
|
)
|
|
103
91
|
if (ccLocalStorage?.version === "1.0.0") {
|
|
@@ -116,8 +104,8 @@ export class CustomConfigHelper {
|
|
|
116
104
|
}
|
|
117
105
|
|
|
118
106
|
ccLocalStorage.version = CUSTOM_CONFIGS_LOCAL_STORAGE_VERSION
|
|
119
|
-
|
|
120
|
-
|
|
107
|
+
localStorage.removeItem(CUSTOM_CONFIGS_LOCAL_STORAGE_ELEMENT)
|
|
108
|
+
localStorage.setItem(CUSTOM_CONFIGS_LOCAL_STORAGE_ELEMENT, JSON.stringify(ccLocalStorage, stateObjectReviver))
|
|
121
109
|
|
|
122
110
|
return ccLocalStorage
|
|
123
111
|
}
|
|
@@ -1813,10 +1813,6 @@ export const STATE: State = {
|
|
|
1813
1813
|
mapSize: 250
|
|
1814
1814
|
},
|
|
1815
1815
|
files: [],
|
|
1816
|
-
lookUp: {
|
|
1817
|
-
idToNode: new Map(),
|
|
1818
|
-
idToBuilding: new Map()
|
|
1819
|
-
},
|
|
1820
1816
|
appStatus: {
|
|
1821
1817
|
hoveredBuildingPath: null,
|
|
1822
1818
|
selectedBuildingId: null,
|
|
@@ -1898,10 +1894,6 @@ export const DEFAULT_STATE: State = {
|
|
|
1898
1894
|
fileSettings: { attributeTypes: { nodes: {}, edges: {} }, blacklist: [], edges: [], markedPackages: [] },
|
|
1899
1895
|
treeMap: { mapSize: 250 },
|
|
1900
1896
|
files: [],
|
|
1901
|
-
lookUp: {
|
|
1902
|
-
idToBuilding: new Map(),
|
|
1903
|
-
idToNode: new Map()
|
|
1904
|
-
},
|
|
1905
1897
|
appStatus: {
|
|
1906
1898
|
hoveredBuildingPath: null,
|
|
1907
1899
|
selectedBuildingId: null,
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`GameObjectsImporter should parse gameObjects json to cc.json 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"checksum": "b318b8b77caec1e2ba86b87c7a7579c0",
|
|
6
|
+
"data": Object {
|
|
7
|
+
"apiVersion": "1.3",
|
|
8
|
+
"attributeTypes": Object {
|
|
9
|
+
"edges": Object {
|
|
10
|
+
"coupling": "relative",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
"edges": Array [
|
|
14
|
+
Object {
|
|
15
|
+
"attributes": Object {
|
|
16
|
+
"coupling": 100,
|
|
17
|
+
},
|
|
18
|
+
"fromNodeName": "/base/root/CHANGELOG/CHANGELOG",
|
|
19
|
+
"toNodeName": "/base/root/visualization/packageLock/packageLock",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
"fileChecksum": "",
|
|
23
|
+
"nodes": Array [
|
|
24
|
+
Object {
|
|
25
|
+
"attributes": Object {},
|
|
26
|
+
"children": Array [
|
|
27
|
+
Object {
|
|
28
|
+
"attributes": Object {},
|
|
29
|
+
"children": Array [
|
|
30
|
+
Object {
|
|
31
|
+
"attributes": Object {},
|
|
32
|
+
"children": Array [
|
|
33
|
+
Object {
|
|
34
|
+
"attributes": Object {},
|
|
35
|
+
"children": Array [
|
|
36
|
+
Object {
|
|
37
|
+
"attributes": Object {
|
|
38
|
+
"height": 1,
|
|
39
|
+
},
|
|
40
|
+
"name": "ui",
|
|
41
|
+
"type": "File",
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
"fixedPosition": Object {
|
|
45
|
+
"height": 3,
|
|
46
|
+
"left": 2,
|
|
47
|
+
"top": 95,
|
|
48
|
+
"width": 5,
|
|
49
|
+
},
|
|
50
|
+
"name": "ui",
|
|
51
|
+
"type": "Folder",
|
|
52
|
+
},
|
|
53
|
+
Object {
|
|
54
|
+
"attributes": Object {},
|
|
55
|
+
"children": Array [
|
|
56
|
+
Object {
|
|
57
|
+
"attributes": Object {
|
|
58
|
+
"height": 4,
|
|
59
|
+
},
|
|
60
|
+
"name": "packageLock",
|
|
61
|
+
"type": "File",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
"fixedPosition": Object {
|
|
65
|
+
"height": 1,
|
|
66
|
+
"left": 95,
|
|
67
|
+
"top": 48,
|
|
68
|
+
"width": 2,
|
|
69
|
+
},
|
|
70
|
+
"name": "packageLock",
|
|
71
|
+
"type": "Folder",
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
"fixedPosition": Object {
|
|
75
|
+
"height": 95,
|
|
76
|
+
"left": 0,
|
|
77
|
+
"top": 2,
|
|
78
|
+
"width": 15,
|
|
79
|
+
},
|
|
80
|
+
"name": "visualization",
|
|
81
|
+
"type": "Folder",
|
|
82
|
+
},
|
|
83
|
+
Object {
|
|
84
|
+
"attributes": Object {},
|
|
85
|
+
"children": Array [
|
|
86
|
+
Object {
|
|
87
|
+
"attributes": Object {
|
|
88
|
+
"height": 1,
|
|
89
|
+
},
|
|
90
|
+
"name": "CHANGELOG",
|
|
91
|
+
"type": "File",
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
"fixedPosition": Object {
|
|
95
|
+
"height": 2,
|
|
96
|
+
"left": 98,
|
|
97
|
+
"top": 48,
|
|
98
|
+
"width": 0,
|
|
99
|
+
},
|
|
100
|
+
"name": "CHANGELOG",
|
|
101
|
+
"type": "Folder",
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
"fixedPosition": Object {
|
|
105
|
+
"height": 30,
|
|
106
|
+
"left": 0,
|
|
107
|
+
"top": 35,
|
|
108
|
+
"width": 100,
|
|
109
|
+
},
|
|
110
|
+
"name": "root",
|
|
111
|
+
"type": "Folder",
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
"name": "base",
|
|
115
|
+
"type": "Folder",
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
"projectName": "ScriptProjectName",
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TEST_GAMEOBJECTS_FILE } from "./gameObjectsMocks"
|
|
2
|
+
import { clone } from "../clone"
|
|
3
|
+
import { parseGameObjectsFile } from "./gameObjectsImporter"
|
|
4
|
+
|
|
5
|
+
describe("GameObjectsImporter", () => {
|
|
6
|
+
it("should parse gameObjects json to cc.json", function () {
|
|
7
|
+
const gameObjectsFile = clone(TEST_GAMEOBJECTS_FILE)
|
|
8
|
+
|
|
9
|
+
expect(parseGameObjectsFile(JSON.stringify(gameObjectsFile))).toMatchSnapshot()
|
|
10
|
+
})
|
|
11
|
+
})
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import md5 from "md5"
|
|
2
|
+
import { AttributeTypes, CodeMapNode, Edge, FixedPosition, NodeType } from "../../codeCharta.model"
|
|
3
|
+
import { ExportWrappedCCFile } from "../../codeCharta.api.model"
|
|
4
|
+
|
|
5
|
+
export interface BaseNode {
|
|
6
|
+
name: string
|
|
7
|
+
position: Position
|
|
8
|
+
scale: Position
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Position {
|
|
12
|
+
x: number
|
|
13
|
+
y: number
|
|
14
|
+
z: number
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const BASE_NAME = "base"
|
|
18
|
+
|
|
19
|
+
export function parseGameObjectsFile(data) {
|
|
20
|
+
const { gameObjectPositions, cycles = [] } = JSON.parse(data)
|
|
21
|
+
|
|
22
|
+
const ccJson: ExportWrappedCCFile = {
|
|
23
|
+
checksum: "",
|
|
24
|
+
data: {
|
|
25
|
+
projectName: "ScriptProjectName",
|
|
26
|
+
fileChecksum: "",
|
|
27
|
+
apiVersion: "1.3",
|
|
28
|
+
nodes: []
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const nodes = [{ name: BASE_NAME, type: NodeType.FOLDER, attributes: {}, children: [] }]
|
|
33
|
+
const rootGameObjectPosition = gameObjectPositions.find(gameObject => gameObject.name.split(".").length === 1)
|
|
34
|
+
|
|
35
|
+
gameObjectPositions.push(createBaseGameObjectPosition(rootGameObjectPosition))
|
|
36
|
+
|
|
37
|
+
for (const gameObjectPosition of gameObjectPositions) {
|
|
38
|
+
const nodeNames = gameObjectPosition.name.split(".")
|
|
39
|
+
if (nodeNames[0] !== BASE_NAME) {
|
|
40
|
+
addNodeRecursively(nodeNames, nodes[0].children, BASE_NAME, gameObjectPosition, gameObjectPositions, rootGameObjectPosition)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ccJson.data.nodes = nodes
|
|
45
|
+
ccJson.data.edges = cycles.map(cycle => createEdge(cycle))
|
|
46
|
+
ccJson.data.attributeTypes = createAttributeTypes()
|
|
47
|
+
ccJson.checksum = md5(JSON.stringify(ccJson.data))
|
|
48
|
+
return ccJson
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function addNodeRecursively(
|
|
52
|
+
nodeNames: string[],
|
|
53
|
+
nodes: CodeMapNode[],
|
|
54
|
+
parentNodeName: string,
|
|
55
|
+
gameObjectPosition,
|
|
56
|
+
gameObjectPositions,
|
|
57
|
+
rootGameObjectPosition
|
|
58
|
+
) {
|
|
59
|
+
if (nodeNames.length === 0) return
|
|
60
|
+
|
|
61
|
+
// get current node name and create cc node structure
|
|
62
|
+
const [nodeName] = nodeNames
|
|
63
|
+
let node: CodeMapNode = {
|
|
64
|
+
name: nodeName,
|
|
65
|
+
type: isFile(nodeNames) ? NodeType.FILE : NodeType.FOLDER,
|
|
66
|
+
attributes: {}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!isFile(nodeNames)) {
|
|
70
|
+
node.children = []
|
|
71
|
+
} else {
|
|
72
|
+
node = wrapFileInAFolder(nodeName, node, gameObjectPosition)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// add or select node if found
|
|
76
|
+
if (!nodeAlreadyExists(nodes, nodeName)) {
|
|
77
|
+
nodes.push(node)
|
|
78
|
+
} else {
|
|
79
|
+
node = nodes.find(singleNode => singleNode.name === nodeName)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const parentGameObject = gameObjectPositions.find(gameObject => gameObject.name === parentNodeName)
|
|
83
|
+
node.fixedPosition = calculateFixedFolderPosition(node, parentGameObject, gameObjectPosition, rootGameObjectPosition.name)
|
|
84
|
+
|
|
85
|
+
const newParentName = parentNodeName === BASE_NAME ? node.name : `${parentNodeName}.${node.name}`
|
|
86
|
+
addNodeRecursively(nodeNames.slice(1), node.children, newParentName, gameObjectPosition, gameObjectPositions, rootGameObjectPosition)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function isFile(names: string[]) {
|
|
90
|
+
return names.length === 1
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function nodeAlreadyExists(nodes: CodeMapNode[], name: string) {
|
|
94
|
+
return nodes.some(singleNode => singleNode.name === name)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function wrapFileInAFolder(nodeName: string, node: CodeMapNode, gameObjectPosition) {
|
|
98
|
+
const childNode = { ...node }
|
|
99
|
+
childNode.attributes = { height: gameObjectPosition.scale.y }
|
|
100
|
+
const parentNode: CodeMapNode = { name: nodeName, type: NodeType.FOLDER, attributes: {}, children: [childNode] }
|
|
101
|
+
return parentNode
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function calculateFixedFolderPosition(node: CodeMapNode, parentGameObject, childGameObject, rootGameObjectPositionName: string) {
|
|
105
|
+
let position: FixedPosition
|
|
106
|
+
|
|
107
|
+
if (node.type === NodeType.FOLDER) {
|
|
108
|
+
// translate the center point from the middle of the gameObject to the corner as needed for fixedPosition
|
|
109
|
+
const cornerXofParent = parentGameObject.position.x - parentGameObject.scale.x / 2
|
|
110
|
+
const cornerZofParent = parentGameObject.position.z - parentGameObject.scale.z / 2
|
|
111
|
+
const cornerXofChild = childGameObject.position.x - childGameObject.scale.x / 2
|
|
112
|
+
const cornerZofChild = childGameObject.position.z - childGameObject.scale.z / 2
|
|
113
|
+
const top = Math.floor(((cornerXofChild - cornerXofParent) / parentGameObject.scale.x) * 100)
|
|
114
|
+
const left = Math.floor(((cornerZofChild - cornerZofParent) / parentGameObject.scale.z) * 100)
|
|
115
|
+
const width = Math.floor((childGameObject.scale.z / parentGameObject.scale.z) * 100)
|
|
116
|
+
const height = Math.floor((childGameObject.scale.x / parentGameObject.scale.x) * 100)
|
|
117
|
+
position = { left, top, width, height }
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (node.name === rootGameObjectPositionName) {
|
|
121
|
+
centerRootPosition(position)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return position
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function centerRootPosition(rootPosition) {
|
|
128
|
+
rootPosition.top = Math.floor(50 - rootPosition.height / 2)
|
|
129
|
+
rootPosition.left = 0
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function addWrappedFolderName(filePath: string) {
|
|
133
|
+
const splitFilePath = filePath.split(".")
|
|
134
|
+
return `/${BASE_NAME}/${filePath.replace(/\./g, "/")}/${splitFilePath.slice(-1)}`
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function createEdge(cycle) {
|
|
138
|
+
return {
|
|
139
|
+
fromNodeName: addWrappedFolderName(cycle.from),
|
|
140
|
+
toNodeName: addWrappedFolderName(cycle.to),
|
|
141
|
+
attributes: {
|
|
142
|
+
coupling: 100
|
|
143
|
+
}
|
|
144
|
+
} as Edge
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function createAttributeTypes() {
|
|
148
|
+
return {
|
|
149
|
+
edges: {
|
|
150
|
+
coupling: "relative"
|
|
151
|
+
}
|
|
152
|
+
} as AttributeTypes
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function createBaseGameObjectPosition(rootGameObjectPosition) {
|
|
156
|
+
const longEdge = Math.max(rootGameObjectPosition.scale.x, rootGameObjectPosition.scale.z)
|
|
157
|
+
return {
|
|
158
|
+
name: BASE_NAME,
|
|
159
|
+
position: {
|
|
160
|
+
x: 0,
|
|
161
|
+
y: 0,
|
|
162
|
+
z: 0
|
|
163
|
+
},
|
|
164
|
+
scale: {
|
|
165
|
+
x: longEdge,
|
|
166
|
+
y: 0,
|
|
167
|
+
z: longEdge
|
|
168
|
+
}
|
|
169
|
+
} as BaseNode
|
|
170
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export const TEST_GAMEOBJECTS_FILE = {
|
|
2
|
+
gameObjectPositions: [
|
|
3
|
+
{
|
|
4
|
+
name: "root.visualization.ui",
|
|
5
|
+
position: {
|
|
6
|
+
x: 159.5,
|
|
7
|
+
y: 3.5,
|
|
8
|
+
z: 8.5
|
|
9
|
+
},
|
|
10
|
+
scale: {
|
|
11
|
+
x: 5,
|
|
12
|
+
y: 1,
|
|
13
|
+
z: 5
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "root.visualization.packageLock",
|
|
18
|
+
position: {
|
|
19
|
+
x: 82,
|
|
20
|
+
y: 5,
|
|
21
|
+
z: 89
|
|
22
|
+
},
|
|
23
|
+
scale: {
|
|
24
|
+
x: 2,
|
|
25
|
+
y: 4,
|
|
26
|
+
z: 2
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "root.visualization",
|
|
31
|
+
position: {
|
|
32
|
+
x: 84,
|
|
33
|
+
y: 2.5,
|
|
34
|
+
z: 48
|
|
35
|
+
},
|
|
36
|
+
scale: {
|
|
37
|
+
x: 160,
|
|
38
|
+
y: 1,
|
|
39
|
+
z: 88
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "root.CHANGELOG",
|
|
44
|
+
position: {
|
|
45
|
+
x: 84,
|
|
46
|
+
y: 2.5,
|
|
47
|
+
z: 552.5
|
|
48
|
+
},
|
|
49
|
+
scale: {
|
|
50
|
+
x: 5,
|
|
51
|
+
y: 1,
|
|
52
|
+
z: 5
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "root",
|
|
57
|
+
position: {
|
|
58
|
+
x: 84,
|
|
59
|
+
y: 0.5,
|
|
60
|
+
z: 279.5
|
|
61
|
+
},
|
|
62
|
+
scale: {
|
|
63
|
+
x: 168,
|
|
64
|
+
y: 1,
|
|
65
|
+
z: 559
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
cycles: [
|
|
70
|
+
{
|
|
71
|
+
from: "root.CHANGELOG",
|
|
72
|
+
to: "root.visualization.packageLock"
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}
|