Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented May 7, 2025

Previously, elements related to shapes were located at the same place as geometry or cell elements. This was unclear
and didn't explicitly split the concepts.

This is only an internal change which has no impact for applications integration maxGraph.
The elements are still exported to the outside world in the same way as before.

Summary by CodeRabbit

  • Refactor
    • Updated internal structure by moving all shape-related modules from the geometry directory to a new shape directory.
    • Adjusted import and export paths throughout the codebase to reflect the new organization for shape modules.
    • No changes to user-facing features or functionality; these updates are structural and organizational only.

Previously, elements related to shapes were located at the same place as geometry or cell elements. This was unclear
and didn't explicitly split the concepts.

This is only an internal change which has no impact for applications integration maxGraph.
The elements are still exported to the outside world in the same way as before.
@tbouffard tbouffard added the refactor Code refactoring label May 7, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 7, 2025

Walkthrough

The changes systematically update import and export paths for all shape-related modules in the codebase, moving them from the geometry directory to a new shape directory. This includes updating references in both imports and exports, adding new exports for shape registration utilities, and removing outdated ones. No logic, control flow, or public API signatures are altered.

Changes

File(s) Change Summary
packages/core/src/index.ts Updated all shape-related exports from view/geometry to view/shape; added exports for ShapeRegistry and register-shapes; removed outdated exports.
packages/core/src/types.ts, .../event/InternalMouseEvent.ts, .../view/cell/TemporaryCellStates.ts, .../view/mixins/TooltipMixin.ts, .../view/style/marker/EdgeMarkerRegistry.ts, .../view/style/marker/edge-markers.ts, .../view/image/ImageExport.ts Updated import path for Shape type/class from geometry to shape.
packages/core/src/view/Graph.ts Changed import path for registerDefaultShapes from cell/register-shapes to shape/register-shapes.
packages/core/src/view/GraphView.ts, .../cell/CellRenderer.ts, .../cell/CellState.ts, .../cell/VertexHandle.ts, .../handler/ConstraintHandler.ts, .../handler/EdgeHandler.ts, .../handler/VertexHandler.ts, .../other/Guide.ts, .../other/Outline.ts, .../plugins/CellEditorHandler.ts, .../plugins/ConnectionHandler.ts, .../plugins/SelectionHandler.ts, .../mixins/PageBreaksMixin.ts, .../layout/EdgeLabelLayout.ts Updated imports for all shape-related classes (e.g., RectangleShape, ImageShape, TextShape, etc.) from geometry to shape directory.
packages/core/src/view/animate/Effects.ts Removed explicit type casts to Shape, replaced with non-null assertions; removed import of Shape class.
packages/core/src/view/cell/CellHighlight.ts, .../cell/CellState.ts, .../cell/VertexHandle.ts Changed import of Shape to type-only import from new path.
packages/core/src/view/shape/Shape.ts, .../edge/ArrowConnectorShape.ts, .../edge/ArrowShape.ts, .../edge/ConnectorShape.ts, .../edge/LineShape.ts, .../edge/PolylineShape.ts, .../node/ActorShape.ts, .../node/CloudShape.ts, .../node/CylinderShape.ts, .../node/DoubleEllipseShape.ts, .../node/EllipseShape.ts, .../node/HexagonShape.ts, .../node/ImageShape.ts, .../node/LabelShape.ts, .../node/RectangleShape.ts, .../node/RhombusShape.ts, .../node/SwimlaneShape.ts, .../node/TextShape.ts, .../node/TriangleShape.ts, .../stencil/StencilShape.ts Updated internal imports for geometry primitives (Rectangle, Point, etc.) to point to geometry directory.
packages/core/src/view/shape/register-shapes.ts Changed imports for all shapes and ShapeRegistry to use new shape directory structure.

Sequence Diagram(s)

Not applicable: The changes are limited to import/export path updates and do not affect control flow or introduce new features.

Possibly related PRs

  • maxGraph/maxGraph#812: Refactors shape registration to a centralized ShapeRegistry, closely related to this PR’s move of shape exports and registration utilities to a unified location.

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 399d874 and bdff5da.

📒 Files selected for processing (46)
  • packages/core/src/index.ts (1 hunks)
  • packages/core/src/types.ts (1 hunks)
  • packages/core/src/view/Graph.ts (1 hunks)
  • packages/core/src/view/GraphView.ts (2 hunks)
  • packages/core/src/view/animate/Effects.ts (3 hunks)
  • packages/core/src/view/cell/CellHighlight.ts (1 hunks)
  • packages/core/src/view/cell/CellRenderer.ts (2 hunks)
  • packages/core/src/view/cell/CellState.ts (1 hunks)
  • packages/core/src/view/cell/TemporaryCellStates.ts (1 hunks)
  • packages/core/src/view/cell/VertexHandle.ts (1 hunks)
  • packages/core/src/view/event/InternalMouseEvent.ts (1 hunks)
  • packages/core/src/view/handler/ConstraintHandler.ts (1 hunks)
  • packages/core/src/view/handler/EdgeHandler.ts (2 hunks)
  • packages/core/src/view/handler/VertexHandler.ts (2 hunks)
  • packages/core/src/view/image/ImageExport.ts (1 hunks)
  • packages/core/src/view/layout/EdgeLabelLayout.ts (1 hunks)
  • packages/core/src/view/mixins/PageBreaksMixin.ts (1 hunks)
  • packages/core/src/view/mixins/TooltipMixin.ts (1 hunks)
  • packages/core/src/view/other/Guide.ts (1 hunks)
  • packages/core/src/view/other/Outline.ts (1 hunks)
  • packages/core/src/view/plugins/CellEditorHandler.ts (1 hunks)
  • packages/core/src/view/plugins/ConnectionHandler.ts (2 hunks)
  • packages/core/src/view/plugins/SelectionHandler.ts (2 hunks)
  • packages/core/src/view/shape/Shape.ts (2 hunks)
  • packages/core/src/view/shape/edge/ArrowConnectorShape.ts (1 hunks)
  • packages/core/src/view/shape/edge/ArrowShape.ts (1 hunks)
  • packages/core/src/view/shape/edge/ConnectorShape.ts (1 hunks)
  • packages/core/src/view/shape/edge/LineShape.ts (1 hunks)
  • packages/core/src/view/shape/edge/PolylineShape.ts (1 hunks)
  • packages/core/src/view/shape/node/ActorShape.ts (1 hunks)
  • packages/core/src/view/shape/node/CloudShape.ts (1 hunks)
  • packages/core/src/view/shape/node/CylinderShape.ts (1 hunks)
  • packages/core/src/view/shape/node/DoubleEllipseShape.ts (1 hunks)
  • packages/core/src/view/shape/node/EllipseShape.ts (1 hunks)
  • packages/core/src/view/shape/node/HexagonShape.ts (1 hunks)
  • packages/core/src/view/shape/node/ImageShape.ts (1 hunks)
  • packages/core/src/view/shape/node/LabelShape.ts (1 hunks)
  • packages/core/src/view/shape/node/RectangleShape.ts (1 hunks)
  • packages/core/src/view/shape/node/RhombusShape.ts (1 hunks)
  • packages/core/src/view/shape/node/SwimlaneShape.ts (1 hunks)
  • packages/core/src/view/shape/node/TextShape.ts (1 hunks)
  • packages/core/src/view/shape/node/TriangleShape.ts (1 hunks)
  • packages/core/src/view/shape/register-shapes.ts (1 hunks)
  • packages/core/src/view/shape/stencil/StencilShape.ts (1 hunks)
  • packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1 hunks)
  • packages/core/src/view/style/marker/edge-markers.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/core/src/view/animate/Effects.ts (1)
packages/core/src/util/styleUtils.ts (1)
  • setOpacity (420-422)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (ubuntu-22.04)
  • GitHub Check: build (windows-2022)
🔇 Additional comments (63)
packages/core/src/view/shape/Shape.ts (2)

19-19: Updated import path for Rectangle
The Rectangle class is now correctly imported from ../geometry/Rectangle, reflecting the relocation of core geometry types to the geometry directory.


28-28: Updated import path for Point
The Point class import has been updated to ../geometry/Point, aligning with the new directory structure for geometry modules.

packages/core/src/view/shape/node/TextShape.ts (2)

33-33: Adjusted import for Point
The Point dependency now correctly references ../../geometry/Point, matching the refactored module layout.


36-36: Adjusted import for Rectangle
The Rectangle import has been updated to ../../geometry/Rectangle to reflect the dedicated geometry directory.

packages/core/src/view/shape/edge/ConnectorShape.ts (2)

22-22: Updated import for Point
The Point class is now imported from ../../geometry/Point, consistent with the geometry directory consolidation.


24-24: Updated import for Rectangle
The Rectangle import path changed to ../../geometry/Rectangle, aligning with the new project structure.

packages/core/src/view/shape/node/HexagonShape.ts (1)

20-20: Updated import for Point
The Point class import now points to ../../geometry/Point, in line with the dedicated geometry folder.

packages/core/src/view/shape/node/CylinderShape.ts (1)

21-21: Updated import for Rectangle
The Rectangle dependency is now correctly imported from ../../geometry/Rectangle to match the refactored directory layout.

packages/core/src/view/shape/node/ActorShape.ts (1)

19-19: Correct import path for Rectangle.

The update to import type Rectangle from '../../geometry/Rectangle' correctly points to the centralized geometry module, matching the new directory structure without impacting functionality.

packages/core/src/view/shape/node/RhombusShape.ts (2)

20-20: Correct import path for Point.

The change to import Point from '../../geometry/Point' aligns with the refactor, resolving to the shared geometry directory.


22-22: Correct import path for Rectangle.

The update to import Rectangle from '../../geometry/Rectangle' is accurate and consistent with the new structure.

packages/core/src/view/image/ImageExport.ts (1)

21-21: Correct import path for Shape.

Switching to import Shape from '../shape/Shape' accurately references the moved Shape class in the shape directory.

packages/core/src/view/cell/TemporaryCellStates.ts (1)

24-24: Correct import path for Shape.

The import type Shape from '../shape/Shape' change aligns with the internal restructure and preserves the intended type usage.

packages/core/src/view/event/InternalMouseEvent.ts (1)

28-28: Correct import path for Shape.

Updating to import Shape from '../shape/Shape' properly reflects the relocation of the Shape module.

packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)

27-27: Import path updated to the new shape directory.

This change realigns the Shape import to view/shape/Shape following the directory refactor. The relative path appears correct, and no logic is affected.

packages/core/src/view/style/marker/edge-markers.ts (1)

21-21: Updated Shape import to reflect the new shape directory.

The import now correctly points to view/shape/Shape, matching the project-wide restructure. No functional impact detected.

packages/core/src/view/mixins/TooltipMixin.ts (1)

18-18: Adjusted Shape import in TooltipMixin.

Referencing Shape from ../shape/Shape aligns with the new directory layout. The path is correct and no other changes are needed.

packages/core/src/view/handler/ConstraintHandler.ts (1)

30-31: Redirected ImageShape and RectangleShape imports to shape/node.

The imports now point to view/shape/node/ImageShape and view/shape/node/RectangleShape, consistent with the refactor. Usage within the file remains valid.

packages/core/src/view/shape/edge/ArrowConnectorShape.ts (1)

23-24: Updated Point and Rectangle imports to the geometry directory.

These imports now correctly reference view/geometry/Point and view/geometry/Rectangle following the new organization. There are no side effects on functionality.

packages/core/src/view/shape/edge/ArrowShape.ts (2)

21-21: Import path updated for Rectangle
The path for Rectangle now correctly points to the geometry module under view/geometry.


23-23: Import path updated for Point
The path for Point now correctly points to the geometry module under view/geometry.

packages/core/src/view/shape/node/RectangleShape.ts (1)

22-22: Import path updated for Rectangle
The Rectangle import now targets the shared geometry type under view/geometry.

packages/core/src/view/cell/CellState.ts (2)

23-24: Updated import paths for Shape and TextShape
The Shape and TextShape imports have been moved to the new view/shape directory.


28-28: Updated import path for RectangleShape
The RectangleShape import now correctly references view/shape/node/RectangleShape.

packages/core/src/view/shape/node/EllipseShape.ts (1)

20-21: Updated import paths for AbstractCanvas2D and Rectangle
The imports for AbstractCanvas2D and Rectangle now point to the shared view/canvas and view/geometry modules respectively.

packages/core/src/view/layout/EdgeLabelLayout.ts (1)

25-25: Updated import path for TextShape
The TextShape import has been updated to the new view/shape/node directory.

packages/core/src/view/handler/EdgeHandler.ts (2)

38-40: Import paths updated to reflect shapes move to dedicated directory

The import paths for shape-related classes have been updated to reflect their new location in the shape directory structure instead of geometry.


56-56: Shape import path updated correctly

The import path for the base Shape class has been updated to use the new dedicated shapes directory structure.

packages/core/src/view/mixins/PageBreaksMixin.ts (1)

19-19: Updated import path for PolylineShape

The import path has been correctly updated to reflect the new directory structure where shape-related modules are now in the dedicated shape directory.

packages/core/src/view/Graph.ts (1)

26-26: Updated path to shape registration module

The import path for registerDefaultShapes has been updated to point to the new location in the shape directory instead of cell. This is consistent with the larger refactoring to move all shape-related code to a dedicated directory.

packages/core/src/types.ts (1)

27-27: Updated Shape type import path

The import path for the Shape type has been correctly updated to reference the new location in the shape directory structure.

packages/core/src/view/other/Outline.ts (2)

29-29: Import path updated for RectangleShape
The import for RectangleShape has been updated from the old geometry path to the new shape/node directory. This aligns with the PR objective of moving all shape-related modules into the dedicated shape folder, and no behavioral changes are introduced.


32-32: Import path updated for ImageShape
The import for ImageShape has been similarly redirected to the shape/node directory. This keeps the module resolution consistent with the new structure.

packages/core/src/view/shape/node/ImageShape.ts (1)

20-20: Import path corrected for Rectangle type
The Rectangle type is now imported from ../../geometry/Rectangle, reflecting that geometric primitives remain in the geometry folder while shape implementations live under shape. This change matches the overall directory reorganization.

packages/core/src/view/plugins/CellEditorHandler.ts (2)

33-33: Import path updated for TextShape
The TextShape import has been moved from geometry/node to shape/node, consistent with the new directory layout for all node-based shapes.


37-37: Import path updated for Shape base class
The import for the Shape base class now points to ../shape/Shape, aligning with the relocation of shape definitions.

packages/core/src/view/other/Guide.ts (2)

21-21: Import path updated for PolylineShape
The PolylineShape import has been redirected from the old geometry/edge path to the new shape/edge directory, in line with the refactoring.


23-23: Import path updated for Shape base class
The Shape import now correctly references ../shape/Shape, reflecting that common shape interfaces have moved out of geometry.

packages/core/src/view/shape/edge/PolylineShape.ts (1)

21-21: Import path corrected for Point primitive
The Point class is now imported from ../../geometry/Point, ensuring that geometric primitives continue to reside in the geometry folder while edge shapes live under shape/edge.

packages/core/src/view/shape/edge/LineShape.ts (1)

21-21: Import path correction: Updated the Rectangle import to ../../geometry/Rectangle to align with the refactored directory structure. The relative path is correct and consistent with other shape modules.

packages/core/src/view/shape/node/SwimlaneShape.ts (1)

19-19: Import path correction: Updated the Rectangle import to ../../geometry/Rectangle to reflect the new separation between shape definitions and geometric primitives. Path resolution is accurate.

packages/core/src/view/shape/node/TriangleShape.ts (1)

19-19: Import path correction: Changed the Point import to ../../geometry/Point as part of the shape-to-geometry directory move. The path is correct relative to this file.

packages/core/src/view/shape/node/CloudShape.ts (1)

21-21: Import path correction: Updated the Rectangle import to ../../geometry/Rectangle in line with the new module layout. The import path is correct and in sync with other node shape files.

packages/core/src/view/plugins/SelectionHandler.ts (2)

23-23: Import path update for RectangleShape: Updated import to ../shape/node/RectangleShape to match the relocated shape modules. The path is correct relative to the plugins directory.


42-42: Import path update for Shape: Updated import to ../shape/Shape following the directory restructure. This maintains consistency across plugin imports.

packages/core/src/view/shape/stencil/StencilShape.ts (1)

20-20: Import path corrections for geometry primitives
The Rectangle and Point modules are now imported from '../../geometry', which aligns with the updated directory layout. No functional impact.

Also applies to: 25-25

packages/core/src/view/GraphView.ts (1)

24-24: Import path updates for shape components
The imports for RectangleShape, ImageShape, and Shape now correctly reference the ./shape directory structure. These changes reflect the refactor without altering any logic.

Also applies to: 33-33, 38-38

packages/core/src/view/cell/VertexHandle.ts (1)

21-21: Import path updates for handle rendering shapes
ImageShape and RectangleShape are now imported from ../shape/node, and Shape is imported as a type-only from ../shape/Shape. This aligns with the new module organization and has no runtime effect.

Also applies to: 23-23, 25-25

packages/core/src/view/cell/CellHighlight.ts (1)

28-28: Type-only import for Shape from new directory
Switched to a type-only import of Shape from ../shape/Shape, matching the reorganized codebase. No behavior changes introduced.

packages/core/src/view/shape/node/LabelShape.ts (1)

19-19: Import Rectangle from geometry directory
The Rectangle class is now consistently imported from ../../geometry/Rectangle, reflecting the separation between geometry primitives and shape implementations.

packages/core/src/view/shape/register-shapes.ts (1)

17-34: Align imports with new shape directory
All imports for ShapeRegistry and individual shape classes have been correctly updated to the view/shape directory structure. These changes maintain the original functionality and are consistent across the file.

packages/core/src/view/shape/node/DoubleEllipseShape.ts (1)

19-21: Update import paths to reflect refactoring
The imports for Rectangle and AbstractCanvas2D have been adjusted to their new locations under geometry and canvas. The module resolutions are correct and no logic changes are required.

packages/core/src/view/cell/CellRenderer.ts (1)

19-22: Update shape-related imports to new directory
The import paths for RectangleShape, ConnectorShape, ImageShape, TextShape, ShapeRegistry, StencilShapeRegistry, and Shape have been consistently updated to point into view/shape. This aligns with the directory reorganization without altering behavior.

Also applies to: 34-35, 42-42

packages/core/src/view/handler/VertexHandler.ts (1)

22-24: Adjust handler imports to new shape modules
The imports for RectangleShape, ImageShape, EllipseShape, and Shape now correctly reference the restructured view/shape directory. These path updates are accurate and require no further action.

Also applies to: 34-34

packages/core/src/view/animate/Effects.ts (1)

85-85: Simplify type assertions using non-null assertions
Replaced explicit casts with shape! non-null assertions when calling setOpacity, improving readability. This change preserves the original behavior; just ensure shape is indeed non-null at runtime.

Also applies to: 146-146, 159-159

packages/core/src/view/plugins/ConnectionHandler.ts (3)

39-39: Correct import path for ImageShape
The import of ImageShape has been updated from the old geometry directory to the new shape/node directory, aligning with the refactor.


42-42: Correct import path for PolylineShape
The PolylineShape import now references the shape/edge directory instead of geometry/edge, which matches the new module layout.


57-57: Correct import path for Shape
Importing the base Shape class from shape/Shape is consistent with the directory reorganization.

packages/core/src/index.ts (5)

98-104: Updated node shape exports to new directory
All node shape modules (ActorShape, LabelShape, Shape, SwimlaneShape, TextShape, TriangleShape) have been re-exported from view/shape/node, reflecting the new structure.


105-110: Updated edge shape exports to new directory
Edge shapes (ArrowShape, ArrowConnectorShape, ConnectorShape, LineShape, PolylineShape) now export from view/shape/edge, consistent with the refactor.


111-118: Additional node shape exports updated
Further node shapes (CloudShape, CylinderShape, DoubleEllipseShape, EllipseShape, HexagonShape, ImageShape, RectangleShape, RhombusShape) correctly re-export from view/shape/node.


119-121: Added ShapeRegistry and registration utilities from shape directory
Exports for ShapeRegistry and register-shapes have been moved to view/shape, replacing the old geometry-based exports.


122-128: Updated stencil shape exports to new shape/stencil directory
All stencil-related exports (unregisterAllStencilShapes, StencilShape, StencilShapeConfig, StencilShapeRegistry) now reference view/shape/stencil, which aligns with the reorganization.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 7, 2025

@tbouffard tbouffard merged commit 8f8a55c into main May 7, 2025
7 checks passed
@tbouffard tbouffard deleted the refactor/move_shapes_code branch May 7, 2025 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant