@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,82 @@
|
|
|
1
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import { FileTree as FileSystemTree } from '@principal-ai/file-city-builder';
|
|
3
|
+
import { MultiVersionCityBuilder, CityData } from '@principal-ai/file-city-builder';
|
|
4
|
+
|
|
5
|
+
export interface UseCodeCityDataOptions {
|
|
6
|
+
fileSystemTree?: FileSystemTree;
|
|
7
|
+
autoUpdate?: boolean;
|
|
8
|
+
colorMapping?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface UseCodeCityDataReturn {
|
|
12
|
+
cityData: CityData | null;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
error: string | null;
|
|
15
|
+
rebuild: () => void;
|
|
16
|
+
setHighlightedPaths: (paths: Set<string>) => void;
|
|
17
|
+
setSelectedPaths: (paths: Set<string>) => void;
|
|
18
|
+
setFocusDirectory: (directory: string | null) => void;
|
|
19
|
+
highlightedPaths: Set<string>;
|
|
20
|
+
selectedPaths: Set<string>;
|
|
21
|
+
focusDirectory: string | null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function useCodeCityData({
|
|
25
|
+
fileSystemTree,
|
|
26
|
+
autoUpdate = true,
|
|
27
|
+
}: UseCodeCityDataOptions): UseCodeCityDataReturn {
|
|
28
|
+
const [cityData, setCityData] = useState<CityData | null>(null);
|
|
29
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
30
|
+
const [error, setError] = useState<string | null>(null);
|
|
31
|
+
|
|
32
|
+
// UI state
|
|
33
|
+
const [highlightedPaths, setHighlightedPaths] = useState<Set<string>>(new Set());
|
|
34
|
+
const [selectedPaths, setSelectedPaths] = useState<Set<string>>(new Set());
|
|
35
|
+
const [focusDirectory, setFocusDirectory] = useState<string | null>(null);
|
|
36
|
+
|
|
37
|
+
// Rebuild city data
|
|
38
|
+
const rebuild = useMemo(() => {
|
|
39
|
+
return () => {
|
|
40
|
+
if (!fileSystemTree) {
|
|
41
|
+
setCityData(null);
|
|
42
|
+
setError('No file system tree provided');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
setIsLoading(true);
|
|
47
|
+
setError(null);
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
// Create a single-version map for the builder
|
|
51
|
+
const versionMap = new Map([['main', fileSystemTree]]);
|
|
52
|
+
const { unionCity } = MultiVersionCityBuilder.build(versionMap);
|
|
53
|
+
setCityData(unionCity);
|
|
54
|
+
} catch (err) {
|
|
55
|
+
setError(err instanceof Error ? err.message : 'Failed to build city data');
|
|
56
|
+
setCityData(null);
|
|
57
|
+
} finally {
|
|
58
|
+
setIsLoading(false);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}, [fileSystemTree]);
|
|
62
|
+
|
|
63
|
+
// Auto rebuild when dependencies change
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (autoUpdate) {
|
|
66
|
+
rebuild();
|
|
67
|
+
}
|
|
68
|
+
}, [autoUpdate, rebuild]);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
cityData,
|
|
72
|
+
isLoading,
|
|
73
|
+
error,
|
|
74
|
+
rebuild,
|
|
75
|
+
setHighlightedPaths,
|
|
76
|
+
setSelectedPaths,
|
|
77
|
+
setFocusDirectory,
|
|
78
|
+
highlightedPaths,
|
|
79
|
+
selectedPaths,
|
|
80
|
+
focusDirectory,
|
|
81
|
+
};
|
|
82
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Main component export
|
|
2
|
+
export {
|
|
3
|
+
ArchitectureMapHighlightLayers,
|
|
4
|
+
type ArchitectureMapHighlightLayersProps,
|
|
5
|
+
} from './components/ArchitectureMapHighlightLayers';
|
|
6
|
+
|
|
7
|
+
// Layer and rendering types
|
|
8
|
+
export {
|
|
9
|
+
type LayerRenderStrategy,
|
|
10
|
+
type LayerItem,
|
|
11
|
+
type HighlightLayer,
|
|
12
|
+
} from './render/client/drawLayeredBuildings';
|
|
13
|
+
|
|
14
|
+
// React-specific types
|
|
15
|
+
export { type MapInteractionState, type MapDisplayOptions } from './types/react-types';
|
|
16
|
+
|
|
17
|
+
// Utility functions
|
|
18
|
+
export {
|
|
19
|
+
filterCityDataForSelectiveRender,
|
|
20
|
+
filterCityDataForSubdirectory,
|
|
21
|
+
filterCityDataForMultipleDirectories,
|
|
22
|
+
} from './builder/cityDataUtils';
|
|
23
|
+
|
|
24
|
+
// File color highlight layer utilities
|
|
25
|
+
export {
|
|
26
|
+
createFileColorHighlightLayers,
|
|
27
|
+
getDefaultFileColorConfig,
|
|
28
|
+
getFileColorMapping,
|
|
29
|
+
} from './utils/fileColorHighlightLayers';
|
|
30
|
+
|
|
31
|
+
export type {
|
|
32
|
+
ColorLayerConfig,
|
|
33
|
+
FileSuffixConfig,
|
|
34
|
+
FileSuffixColorConfig,
|
|
35
|
+
} from './utils/fileColorHighlightLayers';
|
|
36
|
+
|
|
37
|
+
// Re-export commonly used types from builder
|
|
38
|
+
export type {
|
|
39
|
+
CityData,
|
|
40
|
+
CityBuilding,
|
|
41
|
+
CityDistrict,
|
|
42
|
+
SelectiveRenderOptions,
|
|
43
|
+
Bounds2D,
|
|
44
|
+
Position3D,
|
|
45
|
+
} from '@principal-ai/file-city-builder';
|
|
46
|
+
|
|
47
|
+
// Re-export MultiVersionCityBuilder which was requested
|
|
48
|
+
export { MultiVersionCityBuilder } from '@principal-ai/file-city-builder';
|
|
49
|
+
|
|
50
|
+
// Export the useCodeCityData hook
|
|
51
|
+
export { useCodeCityData } from './hooks/useCodeCityData';
|
|
52
|
+
export type { UseCodeCityDataOptions, UseCodeCityDataReturn } from './hooks/useCodeCityData';
|
|
53
|
+
|
|
54
|
+
// Re-export FileTree type for convenience
|
|
55
|
+
export type { FileTree } from '@principal-ai/file-city-builder';
|
|
56
|
+
|
|
57
|
+
// Export React Flow based city view component
|
|
58
|
+
export {
|
|
59
|
+
CityViewWithReactFlow,
|
|
60
|
+
type CityViewWithReactFlowProps,
|
|
61
|
+
} from './components/CityViewWithReactFlow';
|
|
62
|
+
|
|
63
|
+
// Re-export theme utilities for consumers
|
|
64
|
+
export { ThemeProvider, useTheme } from '@principal-ade/industry-theme';
|