Skip to content

Commit 03b4318

Browse files
Add multi cc in one file
1 parent b2a3fe4 commit 03b4318

6 files changed

Lines changed: 67 additions & 38 deletions

File tree

‎example-project/index.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ const App = {
1010
}
1111
};
1212

13+
//cc:#render#3;promise resolve
1314
App.init();

‎src/public/dist/bundle.js‎

Lines changed: 38 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/public/dist/bundle.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/public/js/components/treeDiagram/component/Node/CodeCrumb.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export const CodeCrumbName = props => {
4848

4949
{(flow && (
5050
<React.Fragment>
51+
<rect
52+
x={textPoint.x - 7.5}
53+
y={textPoint.y - 10}
54+
width={3}
55+
height={3}
56+
className={'CodeCrumbName-flow-step'}
57+
/>
5158
<rect
5259
x={textPoint.x - 13}
5360
y={textPoint.y - 7}

‎src/public/js/components/treeDiagram/component/Tree/CodeCrumbsTree.js‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,22 @@ export const CodeCrumbedFlowEdges = props => {
1919

2020
const currentFlow = codeCrumbedFlowsMap[selectedCrumbedFlowKey] || {};
2121

22-
const sortedFlowSteps = Object.entries(currentFlow)
23-
.map(([filePath, step]) => ({ filePath, step, flow: selectedCrumbedFlowKey }))
24-
.sort((a, b) => a.step - b.step);
22+
let sortedFlowSteps = [];
23+
Object.keys(currentFlow).forEach(filePath => {
24+
const steps = fileNodesMap[filePath].children
25+
.filter(({ data }) => data.params.flow === selectedCrumbedFlowKey)
26+
.map(({ data, x, y }) => ({
27+
filePath,
28+
step: data.params.flowStep,
29+
flow: selectedCrumbedFlowKey,
30+
x,
31+
y
32+
}));
33+
34+
sortedFlowSteps = sortedFlowSteps.concat(steps);
35+
});
36+
37+
sortedFlowSteps.sort((a, b) => a.step - b.step);
2538

2639
return (
2740
<React.Fragment>
@@ -33,10 +46,7 @@ export const CodeCrumbedFlowEdges = props => {
3346
const fromFile = fileNodesMap[fromItem.filePath];
3447
const toFile = fileNodesMap[toItem.filePath];
3548

36-
const fromCc = fromFile.children.find(({ data }) => data.params.flow === fromItem.flow);
37-
const toCc = toFile.children.find(({ data }) => data.params.flow === toItem.flow);
38-
39-
const edgePoints = [fromCc, toCc].map(crumb => {
49+
const edgePoints = [fromItem, toItem].map(crumb => {
4050
const [cX, cY] = [crumb.y, crumb.x];
4151
return shiftToCenterPoint(cX, cY);
4252
});

‎src/server/project-source-watcher.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ const grabProjectSourceState = ({ filesList, projectDir, entryPoint }) => {
7575
item.flows = codecrumbsList
7676
.filter(cc => cc.params.flow)
7777
.map(cc => cc.params)
78-
.reduce((acc, { flow, flowStep }) => {
79-
acc[flow] = flowStep;
78+
.reduce((acc, { flow }) => {
79+
acc[flow] = true;
8080
return acc;
8181
}, {});
8282
} else {
@@ -183,7 +183,7 @@ const addFileFlowsToCodeCrumbedFlows = (codeCrumbedFlows, file) => {
183183
if (!codeCrumbedFlows[key]) {
184184
codeCrumbedFlows[key] = {};
185185
}
186-
codeCrumbedFlows[key][file.path] = file.flows[key];
186+
codeCrumbedFlows[key][file.path] = key;
187187
});
188188
};
189189

0 commit comments

Comments
 (0)