fix: resolve SSR issues and optimize DICOM viewer performance #2
+8,890
−3,440
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the Cornerstone DICOM viewer app to improve compatibility with server-side rendering (SSR) and enhance modularity. The main changes involve dynamically importing all Cornerstone-related modules at runtime, updating image loading and rendering logic, and improving the polysegmentation workflow with better state management and user experience.
SSR Compatibility and Dynamic Imports
@cornerstonejs/core,@cornerstonejs/tools, and@cornerstonejs/dicom-image-loader) are now imported dynamically within React components to prevent SSR-related issues. This change is applied in bothapp/page.tsxandapp/polyseg/page.tsx. [1] [2] [3] [4] [5]Image Loading and Rendering Logic
app/page.tsx) now provides clear examples for loading local DICOM files and remote DICOM series, and refactors the volume/stack loading logic to be more modular and easier to switch between modes. [1] [2]createImageIdsAndCacheMetaDatainlib/createImageIdsAndCacheMetaData.tsnow dynamically imports the DICOM image loader and returns both image IDs and metadata, improving SSR safety and modularity. [1] [2]Polysegmentation Workflow Improvements
app/polyseg/page.tsx, segmentation tool state is managed using React'suseStateanduseCallback, and the "Convert to 3D" button is disabled until the viewer is ready, improving user experience. The segmentation conversion logic is moved to a dedicated callback. [1] [2] [3]Code Cleanup and Type Safety
Configuration Updates
Let me know if you have questions about any specific part of the refactor!