@principal-ai/file-city-react 0.3.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/dist/builder/cityDataUtils.d.ts +15 -0
- package/dist/builder/cityDataUtils.d.ts.map +1 -0
- package/dist/builder/cityDataUtils.js +348 -0
- package/dist/components/ArchitectureMapHighlightLayers.d.ts +63 -0
- package/dist/components/ArchitectureMapHighlightLayers.d.ts.map +1 -0
- package/dist/components/ArchitectureMapHighlightLayers.js +1040 -0
- package/dist/components/CityViewWithReactFlow.d.ts +14 -0
- package/dist/components/CityViewWithReactFlow.d.ts.map +1 -0
- package/dist/components/CityViewWithReactFlow.js +266 -0
- package/dist/config/files.json +996 -0
- package/dist/hooks/useCodeCityData.d.ts +21 -0
- package/dist/hooks/useCodeCityData.d.ts.map +1 -0
- package/dist/hooks/useCodeCityData.js +57 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/render/client/drawLayeredBuildings.d.ts +51 -0
- package/dist/render/client/drawLayeredBuildings.d.ts.map +1 -0
- package/dist/render/client/drawLayeredBuildings.js +650 -0
- package/dist/stories/ArchitectureMapGridLayout.stories.d.ts +73 -0
- package/dist/stories/ArchitectureMapGridLayout.stories.d.ts.map +1 -0
- package/dist/stories/ArchitectureMapGridLayout.stories.js +345 -0
- package/dist/stories/ArchitectureMapHighlightLayers.stories.d.ts +78 -0
- package/dist/stories/ArchitectureMapHighlightLayers.stories.d.ts.map +1 -0
- package/dist/stories/ArchitectureMapHighlightLayers.stories.js +270 -0
- package/dist/stories/CityViewWithReactFlow.stories.d.ts +24 -0
- package/dist/stories/CityViewWithReactFlow.stories.d.ts.map +1 -0
- package/dist/stories/CityViewWithReactFlow.stories.js +778 -0
- package/dist/stories/sample-data.d.ts +4 -0
- package/dist/stories/sample-data.d.ts.map +1 -0
- package/dist/stories/sample-data.js +268 -0
- package/dist/types/react-types.d.ts +17 -0
- package/dist/types/react-types.d.ts.map +1 -0
- package/dist/types/react-types.js +4 -0
- package/dist/utils/fileColorHighlightLayers.d.ts +86 -0
- package/dist/utils/fileColorHighlightLayers.d.ts.map +1 -0
- package/dist/utils/fileColorHighlightLayers.js +283 -0
- package/package.json +49 -0
- package/src/builder/cityDataUtils.ts +430 -0
- package/src/components/ArchitectureMapHighlightLayers.tsx +1518 -0
- package/src/components/CityViewWithReactFlow.tsx +365 -0
- package/src/config/files.json +996 -0
- package/src/hooks/useCodeCityData.ts +82 -0
- package/src/index.ts +64 -0
- package/src/render/client/drawLayeredBuildings.ts +946 -0
- package/src/stories/ArchitectureMapGridLayout.stories.tsx +410 -0
- package/src/stories/ArchitectureMapHighlightLayers.stories.tsx +312 -0
- package/src/stories/CityViewWithReactFlow.stories.tsx +787 -0
- package/src/stories/sample-data.ts +301 -0
- package/src/types/react-types.ts +18 -0
- package/src/utils/fileColorHighlightLayers.ts +378 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import 'reactflow/dist/style.css';
|
|
3
|
+
import { FileTree } from '@principal-ai/repository-abstraction';
|
|
4
|
+
import { CodebaseView } from '@principal-ai/alexandria-core-library';
|
|
5
|
+
export interface CityViewWithReactFlowProps {
|
|
6
|
+
fileTree: FileTree;
|
|
7
|
+
gridConfig?: CodebaseView;
|
|
8
|
+
onCellClick?: (cellId: string) => void;
|
|
9
|
+
cellWidth?: number;
|
|
10
|
+
cellHeight?: number;
|
|
11
|
+
cellSpacing?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const CityViewWithReactFlow: React.FC<CityViewWithReactFlowProps>;
|
|
14
|
+
//# sourceMappingURL=CityViewWithReactFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CityViewWithReactFlow.d.ts","sourceRoot":"","sources":["../../src/components/CityViewWithReactFlow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA+B,MAAM,OAAO,CAAC;AAepD,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAIrE,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA+UD,eAAO,MAAM,qBAAqB,sCAA6B,CAAC"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CityViewWithReactFlow = void 0;
|
|
37
|
+
const react_1 = __importStar(require("react"));
|
|
38
|
+
const reactflow_1 = __importStar(require("reactflow"));
|
|
39
|
+
require("reactflow/dist/style.css");
|
|
40
|
+
const industry_theme_1 = require("@principal-ade/industry-theme");
|
|
41
|
+
const file_city_builder_1 = require("@principal-ai/file-city-builder");
|
|
42
|
+
const ArchitectureMapHighlightLayers_1 = require("./ArchitectureMapHighlightLayers");
|
|
43
|
+
const CellNode = ({ data, selected }) => {
|
|
44
|
+
const { label, fileTree, fileCount, directoryCount } = data;
|
|
45
|
+
const { theme } = (0, industry_theme_1.useTheme)();
|
|
46
|
+
// Build city data for this cell's file tree
|
|
47
|
+
const cityBuilder = (0, react_1.useMemo)(() => new file_city_builder_1.CodeCityBuilderWithGrid(), []);
|
|
48
|
+
const cityData = (0, react_1.useMemo)(() => {
|
|
49
|
+
if (!fileTree || !fileTree.root || fileTree.root.children.length === 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
const result = cityBuilder.buildCityFromFileSystem(fileTree);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
// Silently fail for production
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}, [fileTree, cityBuilder]);
|
|
61
|
+
return (react_1.default.createElement("div", { className: "cell-node", style: {
|
|
62
|
+
background: selected
|
|
63
|
+
? `linear-gradient(135deg, ${theme.colors.primary} 0%, ${theme.colors.accent} 100%)`
|
|
64
|
+
: `linear-gradient(135deg, ${theme.colors.backgroundSecondary} 0%, ${theme.colors.background} 100%)`,
|
|
65
|
+
borderRadius: `${theme.radii[2]}px`,
|
|
66
|
+
padding: `${theme.space[3]}px`,
|
|
67
|
+
width: '450px',
|
|
68
|
+
height: '450px',
|
|
69
|
+
border: selected ? `3px solid ${theme.colors.accent}` : `2px solid ${theme.colors.border}`,
|
|
70
|
+
boxShadow: selected
|
|
71
|
+
? `0 10px 25px ${theme.colors.accent}30`
|
|
72
|
+
: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'column',
|
|
75
|
+
transition: 'all 0.3s ease',
|
|
76
|
+
} },
|
|
77
|
+
react_1.default.createElement(reactflow_1.Handle, { type: "target", position: reactflow_1.Position.Top, style: { background: theme.colors.accent } }),
|
|
78
|
+
react_1.default.createElement("div", { style: {
|
|
79
|
+
marginBottom: `${theme.space[2]}px`,
|
|
80
|
+
paddingBottom: `${theme.space[2]}px`,
|
|
81
|
+
borderBottom: `1px solid ${theme.colors.border}`,
|
|
82
|
+
} },
|
|
83
|
+
react_1.default.createElement("h3", { style: {
|
|
84
|
+
margin: `0 0 ${theme.space[1]}px 0`,
|
|
85
|
+
fontSize: `${theme.fontSizes[2]}px`,
|
|
86
|
+
fontWeight: theme.fontWeights.bold,
|
|
87
|
+
fontFamily: theme.fonts.heading,
|
|
88
|
+
color: theme.colors.text,
|
|
89
|
+
} }, label),
|
|
90
|
+
react_1.default.createElement("div", { style: {
|
|
91
|
+
fontSize: `${theme.fontSizes[0]}px`,
|
|
92
|
+
fontFamily: theme.fonts.body,
|
|
93
|
+
color: theme.colors.textSecondary,
|
|
94
|
+
display: 'flex',
|
|
95
|
+
gap: `${theme.space[3]}px`,
|
|
96
|
+
} },
|
|
97
|
+
react_1.default.createElement("span", null,
|
|
98
|
+
fileCount,
|
|
99
|
+
" files"),
|
|
100
|
+
react_1.default.createElement("span", null,
|
|
101
|
+
directoryCount,
|
|
102
|
+
" directories"))),
|
|
103
|
+
react_1.default.createElement("div", { style: {
|
|
104
|
+
position: 'relative',
|
|
105
|
+
background: theme.colors.background,
|
|
106
|
+
borderRadius: `${theme.radii[1]}px`,
|
|
107
|
+
overflow: 'hidden',
|
|
108
|
+
width: '350px',
|
|
109
|
+
height: '350px',
|
|
110
|
+
} }, cityData ? (react_1.default.createElement("div", { style: { width: '100%', height: '100%', position: 'relative', pointerEvents: 'none' } },
|
|
111
|
+
react_1.default.createElement(ArchitectureMapHighlightLayers_1.ArchitectureMapHighlightLayers, { cityData: cityData, highlightLayers: [
|
|
112
|
+
{
|
|
113
|
+
id: 'typescript',
|
|
114
|
+
name: 'TypeScript Files',
|
|
115
|
+
enabled: true,
|
|
116
|
+
color: theme.colors.success,
|
|
117
|
+
opacity: 0.8,
|
|
118
|
+
priority: 1,
|
|
119
|
+
items: cityData.buildings
|
|
120
|
+
.filter(b => b.path.endsWith('.ts') || b.path.endsWith('.tsx'))
|
|
121
|
+
.map(b => ({
|
|
122
|
+
path: b.path,
|
|
123
|
+
type: 'file',
|
|
124
|
+
opacity: 1,
|
|
125
|
+
})),
|
|
126
|
+
},
|
|
127
|
+
], showGrid: false, showDirectoryLabels: false, canvasBackgroundColor: theme.colors.background, defaultBuildingColor: theme.colors.muted, defaultDirectoryColor: theme.colors.backgroundSecondary, className: "w-full h-full",
|
|
128
|
+
// Disable interactions to prevent conflicts with React Flow
|
|
129
|
+
onFileClick: undefined }))) : (react_1.default.createElement("div", { style: {
|
|
130
|
+
display: 'flex',
|
|
131
|
+
alignItems: 'center',
|
|
132
|
+
justifyContent: 'center',
|
|
133
|
+
height: '100%',
|
|
134
|
+
color: theme.colors.textMuted,
|
|
135
|
+
fontSize: `${theme.fontSizes[1]}px`,
|
|
136
|
+
fontFamily: theme.fonts.body,
|
|
137
|
+
} }, "Empty cell"))),
|
|
138
|
+
react_1.default.createElement(reactflow_1.Handle, { type: "source", position: reactflow_1.Position.Bottom, style: { background: theme.colors.accent } })));
|
|
139
|
+
};
|
|
140
|
+
const nodeTypes = {
|
|
141
|
+
cellNode: CellNode,
|
|
142
|
+
};
|
|
143
|
+
const CityViewWithReactFlowInner = ({ fileTree, gridConfig, onCellClick, cellWidth = 450, cellHeight = 350, cellSpacing = 100, }) => {
|
|
144
|
+
const { theme } = (0, industry_theme_1.useTheme)();
|
|
145
|
+
const defaultGridConfig = {
|
|
146
|
+
id: 'default',
|
|
147
|
+
version: '1.0',
|
|
148
|
+
name: 'Default Grid',
|
|
149
|
+
description: 'Default single-cell grid layout',
|
|
150
|
+
overviewPath: 'README.md',
|
|
151
|
+
category: 'default',
|
|
152
|
+
displayOrder: 0,
|
|
153
|
+
referenceGroups: {
|
|
154
|
+
main: {
|
|
155
|
+
files: ['*'],
|
|
156
|
+
coordinates: [0, 0],
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
metadata: {
|
|
160
|
+
ui: {
|
|
161
|
+
enabled: true,
|
|
162
|
+
rows: 1,
|
|
163
|
+
cols: 1,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
const config = gridConfig || defaultGridConfig;
|
|
168
|
+
const { nodes, edges } = (0, react_1.useMemo)(() => {
|
|
169
|
+
const gridManager = new file_city_builder_1.GridLayoutManager();
|
|
170
|
+
const { rows, cols } = gridManager.getGridDimensions(config);
|
|
171
|
+
const gridTrees = gridManager.splitTreeIntoGrid(fileTree, config);
|
|
172
|
+
const generatedNodes = [];
|
|
173
|
+
const generatedEdges = [];
|
|
174
|
+
// Create cell nodes
|
|
175
|
+
gridTrees.forEach((cellTree, cellKey) => {
|
|
176
|
+
const [row, col] = cellKey.split(',').map(Number);
|
|
177
|
+
// Find cell name from config
|
|
178
|
+
let cellName = 'Cell';
|
|
179
|
+
for (const [name, cellConfig] of Object.entries(config.referenceGroups)) {
|
|
180
|
+
if (cellConfig.coordinates[0] === row && cellConfig.coordinates[1] === col) {
|
|
181
|
+
cellName = name;
|
|
182
|
+
break;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const cellNode = {
|
|
186
|
+
id: `cell-${row}-${col}`,
|
|
187
|
+
type: 'cellNode',
|
|
188
|
+
position: {
|
|
189
|
+
x: col * (cellWidth + cellSpacing),
|
|
190
|
+
y: row * (cellHeight + cellSpacing),
|
|
191
|
+
},
|
|
192
|
+
data: {
|
|
193
|
+
label: cellName,
|
|
194
|
+
fileTree: cellTree,
|
|
195
|
+
fileCount: cellTree.stats.totalFiles,
|
|
196
|
+
directoryCount: cellTree.stats.totalDirectories,
|
|
197
|
+
coordinates: [row, col],
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
generatedNodes.push(cellNode);
|
|
201
|
+
});
|
|
202
|
+
// Create subtle grid connections (optional)
|
|
203
|
+
for (let row = 0; row < rows; row++) {
|
|
204
|
+
for (let col = 0; col < cols; col++) {
|
|
205
|
+
// Only add edges if both nodes exist (non-empty cells)
|
|
206
|
+
const currentNode = generatedNodes.find(n => n.id === `cell-${row}-${col}`);
|
|
207
|
+
if (!currentNode)
|
|
208
|
+
continue;
|
|
209
|
+
// Horizontal connections
|
|
210
|
+
if (col < cols - 1) {
|
|
211
|
+
const rightNode = generatedNodes.find(n => n.id === `cell-${row}-${col + 1}`);
|
|
212
|
+
if (rightNode) {
|
|
213
|
+
generatedEdges.push({
|
|
214
|
+
id: `edge-${row}-${col}-to-${row}-${col + 1}`,
|
|
215
|
+
source: `cell-${row}-${col}`,
|
|
216
|
+
target: `cell-${row}-${col + 1}`,
|
|
217
|
+
type: 'straight',
|
|
218
|
+
animated: false,
|
|
219
|
+
style: {
|
|
220
|
+
stroke: `${theme.colors.border}40`,
|
|
221
|
+
strokeWidth: 1,
|
|
222
|
+
strokeDasharray: '5 10',
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
// Vertical connections
|
|
228
|
+
if (row < rows - 1) {
|
|
229
|
+
const bottomNode = generatedNodes.find(n => n.id === `cell-${row + 1}-${col}`);
|
|
230
|
+
if (bottomNode) {
|
|
231
|
+
generatedEdges.push({
|
|
232
|
+
id: `edge-${row}-${col}-to-${row + 1}-${col}`,
|
|
233
|
+
source: `cell-${row}-${col}`,
|
|
234
|
+
target: `cell-${row + 1}-${col}`,
|
|
235
|
+
type: 'straight',
|
|
236
|
+
animated: false,
|
|
237
|
+
style: {
|
|
238
|
+
stroke: `${theme.colors.border}40`,
|
|
239
|
+
strokeWidth: 1,
|
|
240
|
+
strokeDasharray: '5 10',
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return { nodes: generatedNodes, edges: generatedEdges };
|
|
248
|
+
}, [fileTree, config, cellWidth, cellHeight, cellSpacing, theme]);
|
|
249
|
+
const [nodesState, , onNodesChange] = (0, reactflow_1.useNodesState)(nodes);
|
|
250
|
+
const [edgesState, , onEdgesChange] = (0, reactflow_1.useEdgesState)(edges);
|
|
251
|
+
const onNodeClick = (0, react_1.useCallback)((_event, node) => {
|
|
252
|
+
if (node.type === 'cellNode' && onCellClick) {
|
|
253
|
+
onCellClick(node.id);
|
|
254
|
+
}
|
|
255
|
+
}, [onCellClick]);
|
|
256
|
+
return (react_1.default.createElement("div", { style: { width: '100%', height: '100%', background: theme.colors.background } },
|
|
257
|
+
react_1.default.createElement(reactflow_1.ReactFlowProvider, null,
|
|
258
|
+
react_1.default.createElement(reactflow_1.default, { nodes: nodesState, edges: edgesState, onNodesChange: onNodesChange, onEdgesChange: onEdgesChange, onNodeClick: onNodeClick, nodeTypes: nodeTypes, fitView: true, fitViewOptions: { padding: 0.2 }, attributionPosition: "bottom-left", defaultViewport: { x: 0, y: 0, zoom: 0.8 }, minZoom: 0.2, maxZoom: 2 },
|
|
259
|
+
react_1.default.createElement(reactflow_1.Background, { variant: reactflow_1.BackgroundVariant.Dots, gap: 30, size: 1, color: `${theme.colors.border}40` }),
|
|
260
|
+
react_1.default.createElement(reactflow_1.Controls, null),
|
|
261
|
+
react_1.default.createElement(reactflow_1.MiniMap, { nodeColor: () => theme.colors.primary, style: {
|
|
262
|
+
backgroundColor: theme.colors.backgroundSecondary,
|
|
263
|
+
border: `1px solid ${theme.colors.border}`,
|
|
264
|
+
}, maskColor: "rgba(0, 0, 0, 0.6)" })))));
|
|
265
|
+
};
|
|
266
|
+
exports.CityViewWithReactFlow = CityViewWithReactFlowInner;
|