Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented Feb 18, 2025

The connectors are now stored in dedicated files to make the code simpler to read.
The remaining utility properties and methods in EdgeStyle were only used by the Orthogonal connector. So, they are now
internal.
This somewhat reduces the size of maxGraph when it is bundled and minified in applications.

BREAKING CHANGES: properties and utility methods previously exposed by EdgeStyle are now only internal.
The getRoutePattern method has been completely removed as it was not being used. Nor was it used in the entire mxGraph
and draw.io codebase.

Summary by CodeRabbit

  • New Features

    • Introduced two improved edge routing connectors to enhance grid-based and orthogonal path calculations.
  • Refactor

    • Streamlined the edge styling logic by renaming and reorganizing connector methods for clearer functionality.
  • Documentation

    • Updated migration guides with new API naming and configuration details for moving from legacy to updated graph libraries.
  • Chores

    • Adjusted build configuration thresholds to refine chunk size warning triggers across demo projects.

The connectors are now stored in dedicated files to make the code simpler to read.
The remaining utility properties and methods in EdgeStyle were only used by the Orthogonal connector. So, they are now
internal.
This somewhat reduces the size of maxGraph when it is bundled and minified in applications.

BREAKING CHANGES: properties and utility methods previously exposed by `EdgeStyle` are now only internal.
The `getRoutePattern` method has been completely removed as it was not being used. Nor was it used in the entire mxGraph
and draw.io codebase.
@tbouffard tbouffard added the refactor Code refactoring label Feb 18, 2025
@coderabbitai
Copy link

coderabbitai bot commented Feb 18, 2025

Walkthrough

The pull request restructures the edge routing functionality by refactoring the EdgeStyle class. The old connector methods and properties have been replaced with new references to dedicated connector functions. New files have been introduced for both Manhattan and orthogonal routing algorithms, and documentation comments have been updated accordingly. Additionally, build configuration values for Vite and migration documentation from mxGraph have been revised.

Changes

File(s) Change Summary
packages/core/src/view/style/EdgeStyle.ts Refactored the EdgeStyle class: replaced OrthConnector with OrthogonalConnectorFunction, removed legacy static properties and the original ManhattanConnector, and added a new reference to ManhattanConnectorFunction.
packages/core/src/view/style/config.ts Updated documentation comments to explicitly reference EdgeStyle connectors (e.g., EdgeStyle.EntityRelation, EdgeStyle.OrthConnector, EdgeStyle.ManhattanConnector).
packages/core/src/view/style/edge/Manhattan.ts
packages/core/src/view/style/edge/Orthogonal.ts
Introduced new connector implementations:
- Manhattan.ts: Implements ManhattanConnector with a modified A* algorithm, grid snapping, and obstacle handling.
- Orthogonal.ts: Implements OrthogonalConnector with jetty size calculations and waypoint generation.
packages/ts-example-without-defaults/vite.config.js
packages/ts-example/vite.config.js
Adjusted Vite build configuration by reducing the chunkSizeWarningLimit property (from 441 to 440 in one file and from 445 to 444 in the other).
packages/website/docs/usage/migrate-from-mxgraph.md Updated migration documentation: revised API names (e.g., renaming classes such as mxGraph to Graph, mxCell to Cell), removed legacy browser support, and provided new guidelines and examples for migrating to the new API structure.

Sequence Diagram(s)

sequenceDiagram
    participant View as Graph View
    participant ES as EdgeStyle
    participant Manhattan as ManhattanConnector
    participant Result as Route Points

    View->>ES: Request edge route (source, target)
    ES->>Manhattan: Invoke ManhattanConnector
    Manhattan->>Manhattan: Execute A* algorithm with grid snapping and obstacle checks
    Manhattan-->>ES: Return computed route points
    ES-->>View: Render edge using computed route
Loading
sequenceDiagram
    participant View as Graph View
    participant ES as EdgeStyle
    participant Orthogonal as OrthogonalConnector
    participant Result as Route Points

    View->>ES: Request edge route (source, target)
    ES->>Orthogonal: Invoke OrthogonalConnector
    Orthogonal->>Orthogonal: Calculate jetty sizes and generate waypoints
    Orthogonal-->>ES: Return computed route points
    ES-->>View: Render edge using computed route
Loading

Possibly related PRs

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.

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. (Beta)
  • @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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (6)
packages/core/src/view/style/edge/Orthogonal.ts (3)

58-83: Consider externalizing or documenting complex route patterns.
The hardcoded routePatterns block with multiple nested arrays could be clarified by dedicating a separate file or well-documented data structure. This will improve maintainability and reduce cognitive load for future contributors.


92-107: Remove or justify commented-out constants.
There is a block of commented-out constants (e.g., LEFT_MASK = 32, TOP_MASK = 64) that may cause confusion. If these values are no longer needed, remove them to keep the codebase clean; otherwise, move them to an internal configuration if you plan to use them later.


108-108: Follow through on TODO for magic numbers.
“TODO remove magic numbers” suggests that these references (e.g., 480, 512, 1024) will be replaced with more expressive constants. Consider extracting them into descriptive named constants.

packages/core/src/view/style/edge/Manhattan.ts (1)

210-211: Use optional chaining for clarity.
Adopting optional chaining can simplify the expression and improve readability:

- .filter((s) => s.cell && s.cell.isVertex() && !s.cell.isEdge())
+ .filter((s) => s.cell?.isVertex() && !s.cell?.isEdge())
🧰 Tools
🪛 Biome (1.9.4)

[error] 211-211: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

packages/website/docs/usage/migrate-from-mxgraph.md (2)

374-376: Highlight the Change in VERSION Reference
The moved property note for VERSION—now relocated to constants.VERSION—is succinct. Consider adding a short note advising developers to update any direct references to mxEdgeStyle.VERSION in their code.


401-405: Emphasize the Connector-Only API in EdgeStyle
The updated section for mxEdgeStyle now explains that the new EdgeStyle class only includes properties referencing connectors. Since the PR refactors the Orthogonal and Manhattan connectors into dedicated files, a brief example or a link to the detailed global configuration for these connectors would improve clarity. This will help developers understand how to configure the new Orthogonal and Manhattan connectors in their projects.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 57366eb and b31441f.

📒 Files selected for processing (7)
  • packages/core/src/view/style/EdgeStyle.ts (2 hunks)
  • packages/core/src/view/style/config.ts (3 hunks)
  • packages/core/src/view/style/edge/Manhattan.ts (1 hunks)
  • packages/core/src/view/style/edge/Orthogonal.ts (1 hunks)
  • packages/ts-example-without-defaults/vite.config.js (1 hunks)
  • packages/ts-example/vite.config.js (1 hunks)
  • packages/website/docs/usage/migrate-from-mxgraph.md (2 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/ts-example-without-defaults/vite.config.js
  • packages/ts-example/vite.config.js
  • packages/core/src/view/style/config.ts
🧰 Additional context used
🪛 Biome (1.9.4)
packages/core/src/view/style/edge/Manhattan.ts

[error] 211-211: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (3)
packages/core/src/view/style/EdgeStyle.ts (3)

22-23: Great import structure for new connectors.
Importing the Manhattan and Orthogonal connectors into separate modules clarifies their usage and supports the new refactoring effort.


145-145: Consistent naming for orthogonal connector.
Replacing OrthConnector with OrthogonalConnectorFunction fosters clarity of purpose and aligns with the improved naming scheme of dedicated connector files.


152-152: Manhattan connector reference looks good.
The new reference to ManhattanConnectorFunction continues the refactoring into dedicated modules. Ensure unit tests cover this integration.

Comment on lines +368 to 373
- `isBrowserSupported` (0.16.0): no longer necessary
- `setForceIncludes`: the `mxForceIncludes` property has been removed
- `setLoadResources`: the `mxLoadResources` property has been removed
- `setLoadStylesheets`: the `mxLoadStylesheets` property has been removed
- `setResourceExtension`: the `mxResourceExtension` property has been removed

Copy link

@coderabbitai coderabbitai bot Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Clarify Breaking Changes for Removed Methods
The list of removed methods (e.g. isBrowserSupported, setForceIncludes, setLoadResources, setLoadStylesheets, and setResourceExtension) is clearly documented. It would be helpful to briefly mention any recommended alternatives or to explicitly state that developers should remove any references to these methods in their migration process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already mentioned: removed because no longer necessary or because the related property has been removed as well.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbouffard You're absolutely right - I apologize for the redundant suggestion. The documentation already clearly explains that isBrowserSupported is no longer necessary, and the other methods were removed due to their corresponding properties being removed. Thank you for the clarification!

@tbouffard tbouffard merged commit 82d2a80 into main Feb 18, 2025
7 checks passed
@tbouffard tbouffard deleted the refactor/extract_connectors_to_individual_files branch February 18, 2025 07:07
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