Skip to content

Conversation

@tbouffard
Copy link
Member

@tbouffard tbouffard commented May 6, 2025

Replace custom registry implementations with a consistent BaseRegistry pattern across StencilShapeRegistry,
MarkerShapeRegistry (formerly MarkerShape), and ShapeRegistry (formerly in CellRenderer).

This breaking change ensures all style-related registries share the same interface and behavior, simplifying usage patterns
and improving maintainability throughout the codebase.

BREAKING CHANGES:

  • All registries used to manage "styles" elements now derived from the Registry interface for consistency.
    So, they all share the same methods (add, get and clear) and their internal storage is no longer accessible.
  • The MarkerShape registry has been renamed to MarkerShapeRegistry.
  • The Shapes are now registered in ShapeRegistry instead in CellRenderer.

Summary by CodeRabbit

  • New Features

    • Introduced centralized registries for shapes and edge markers, enabling unified registration and management of custom shapes and markers.
    • Added a new interface for edge marker creation supporting advanced customization.
  • Refactor

    • Replaced static registration methods with ShapeRegistry and EdgeMarkerRegistry throughout the codebase.
    • Updated stencil and shape registration methods to use new registry interfaces and consistent method names.
    • Transitioned from internal shape management in CellRenderer to external registries for improved modularity.
  • Documentation

    • Updated documentation and changelog to reflect the new registry APIs, naming conventions, and usage patterns.

Replace custom registry implementations with a consistent BaseRegistry pattern across `StencilShapeRegistry`,
`MarkerShapeRegistry` (formerly MarkerShape), and `ShapeRegistry` (formerly in CellRenderer).

This breaking change ensures all style-related registries share the same interface and behavior, simplifying usage patterns
and improving maintainability throughout the codebase.

BREAKING CHANGES:
- All registries used to manage "styles" elements now derived from the `Registry` interface for consistency.
  So, they all share the same methods (add, get and clear) and their internal storage is no longer accessible.
- The `MarkerShape` registry has been renamed to `MarkerShapeRegistry`.
- The Shapes are now registered in `ShapeRegistry` instead in `CellRenderer`.
@tbouffard tbouffard added the refactor Code refactoring label May 6, 2025
@coderabbitai
Copy link

coderabbitai bot commented May 6, 2025

Walkthrough

This change refactors the style and shape registration system by replacing static or ad hoc registries (such as those in CellRenderer and MarkerShape) with centralized, instance-based registries (ShapeRegistry, EdgeMarkerRegistry, and StencilShapeRegistry) that inherit from a common Registry interface. All related usage, imports, and documentation are updated accordingly.

Changes

File(s) Change Summary
CHANGELOG.md, packages/website/docs/usage/global-configuration.md Updated documentation to explain the new registry system, replacing references to old registries (CellRenderer, MarkerShape, StyleRegistry) with new ones (ShapeRegistry, EdgeMarkerRegistry, EdgeStyleRegistry, PerimeterRegistry) and clarifying their roles.
packages/core/src/types.ts Added the EdgeMarkerRegistryInterface interface, defining the contract for edge marker registries, including a createMarker method.
packages/core/src/index.ts Changed export style for StencilShapeRegistry and EdgeMarkerRegistry, added export for ShapeRegistry, and updated exports to use namespace or named exports instead of default.
packages/core/src/view/geometry/ShapeRegistry.ts Introduced a new singleton ShapeRegistry for managing shape constructors, extending a generic BaseRegistry and providing documentation and usage examples.
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts Refactored from a static class to a singleton instance of BaseRegistry<StencilShape>, replacing custom methods with generic add and get. Updated documentation and usage accordingly.
packages/core/src/view/style/marker/EdgeMarkerRegistry.ts Replaced the static MarkerShape class with an instance-based EdgeMarkerRegistryImpl implementing the new interface, using a BaseRegistry for storage and providing a createMarker method.
packages/core/src/view/cell/CellRenderer.ts Removed internal shape registry and registration methods, delegating all shape registration and retrieval to the external ShapeRegistry. Updated related logic and documentation.
packages/core/src/view/cell/register-shapes.ts Updated shape registration/unregistration to use ShapeRegistry instead of CellRenderer. Adjusted JSDoc comments accordingly.
packages/core/src/view/geometry/edge/ConnectorShape.ts,
.../stencil/StencilShape.ts
Updated imports and usage to reference EdgeMarkerRegistry and StencilShapeRegistry (using new method names and registry patterns) instead of previous static classes or methods.
packages/core/src/view/geometry/stencil/register.ts Updated stencil shape unregistration to use the clear method of StencilShapeRegistry instead of directly resetting an internal property.
packages/core/src/view/style/register.ts Updated edge marker registration/unregistration to use EdgeMarkerRegistry and its methods instead of MarkerShape.
packages/core/__tests__/view/geometry/node/StencilShapeRegistry.test.ts Updated test suite to use the new get method and expect null instead of undefined for missing stencils.
packages/html/stories/Handles.stories.ts,
.../Markers.stories.ts,
.../Shape.stories.js,
.../Stencils.stories.ts,
.../StencilsViewer.stories.ts,
.../Tree.stories.js,
.../Wires.stories.js
Changed all shape and marker registration from CellRenderer and MarkerShape to ShapeRegistry and EdgeMarkerRegistry, updating imports and method calls accordingly. Updated stencil registration to use new registry methods.
packages/js-example-selected-features/src/index.js,
packages/ts-example-selected-features/src/main.ts
Updated custom marker and shape registration to use EdgeMarkerRegistry and ShapeRegistry instead of deprecated or removed registries.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ShapeRegistry
    participant EdgeMarkerRegistry
    participant CellRenderer
    participant StencilShapeRegistry

    User->>ShapeRegistry: add('customShape', CustomShape)
    User->>EdgeMarkerRegistry: add('customMarker', MarkerFactory)
    User->>StencilShapeRegistry: add('customStencil', StencilShape)

    CellRenderer->>ShapeRegistry: get(shapeName)
    CellRenderer->>StencilShapeRegistry: get(stencilName)
    CellRenderer->>EdgeMarkerRegistry: createMarker(...)
Loading

Possibly related PRs

  • maxGraph/maxGraph#809: Refactors style registries, removing StyleRegistry and introducing dedicated registries such as EdgeStyleRegistry and PerimeterRegistry, directly related to this PR's registry changes.
  • maxGraph/maxGraph#757: Refactors registration/unregistration mechanisms for style-related registries, including shapes and markers, closely connected to this PR's registry management updates.
  • maxGraph/maxGraph#795: Removes the SHAPE enum and updates shape registration conventions, which is related to this PR's centralization of shape registration but with a narrower focus.

📜 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 99a2a61 and c287262.

📒 Files selected for processing (9)
  • packages/core/src/types.ts (4 hunks)
  • packages/core/src/view/cell/CellRenderer.ts (5 hunks)
  • packages/core/src/view/style/builtin-style-elements.ts (1 hunks)
  • packages/core/src/view/style/marker/edge-markers.ts (3 hunks)
  • packages/core/src/view/style/register.ts (3 hunks)
  • packages/html/stories/Shape.stories.js (2 hunks)
  • packages/html/stories/Wires.stories.js (2 hunks)
  • packages/ts-example/src/custom-shapes.ts (1 hunks)
  • packages/website/docs/usage/global-configuration.md (1 hunks)
✅ Files skipped from review due to trivial changes (3)
  • packages/html/stories/Shape.stories.js
  • packages/core/src/view/style/builtin-style-elements.ts
  • packages/core/src/view/style/marker/edge-markers.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • packages/core/src/view/cell/CellRenderer.ts
  • packages/html/stories/Wires.stories.js
  • packages/core/src/view/style/register.ts
  • packages/core/src/types.ts
🧰 Additional context used
🧠 Learnings (1)
packages/website/docs/usage/global-configuration.md (1)
Learnt from: tbouffard
PR: maxGraph/maxGraph#776
File: packages/core/src/view/Graph.ts:77-83
Timestamp: 2025-04-24T12:33:36.243Z
Learning: All register functions in maxGraph (`registerDefaultShapes`, `registerDefaultEdgeStyles`, `registerDefaultPerimeters`, and `registerDefaultEdgeMarkers`) have internal state flags to prevent duplicate registrations, making them inherently idempotent.
🧬 Code Graph Analysis (1)
packages/ts-example/src/custom-shapes.ts (1)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
🪛 LanguageTool
packages/website/docs/usage/global-configuration.md

[uncategorized] ~55-~55: Loose punctuation mark.
Context: ... configurations. - EdgeMarkerRegistry: edge markers (since 0.20.0, previously ...

(UNLIKELY_OPENING_PUNCTUATION)

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build
  • GitHub Check: build (windows-2022)
  • GitHub Check: build (macos-14)
  • GitHub Check: build (ubuntu-22.04)
🔇 Additional comments (3)
packages/ts-example/src/custom-shapes.ts (2)

18-18: Import statement updated correctly to use ShapeRegistry

The change from importing CellRenderer to ShapeRegistry aligns with the PR's goal of centralizing shape registration in a dedicated registry that implements the standardized Registry interface.


21-22: Shape registration properly migrated to new Registry interface

The registration method has been correctly updated from CellRenderer.registerShape to ShapeRegistry.add, conforming to the standardized Registry interface that provides consistent add, get, and clear methods across all style registries.

packages/website/docs/usage/global-configuration.md (1)

55-59: Documentation accurately reflects registry standardization

The documentation has been properly updated to reflect the architectural changes in the style registry system. The consistent naming pattern with an "-Registry" suffix and clear documentation of previous ownership helps users understand the migration path.

The version information (0.20.0) is consistently provided for all changed registries, which is helpful for users tracking breaking changes.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~55-~55: Loose punctuation mark.
Context: ... configurations. - EdgeMarkerRegistry: edge markers (since 0.20.0, previously ...

(UNLIKELY_OPENING_PUNCTUATION)

✨ 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.

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: 0

🧹 Nitpick comments (4)
packages/core/src/view/style/register.ts (2)

132-138: JSDoc comments need updating to match code changes.

The JSDoc comment still references MarkerShape but the code now uses EdgeMarkerRegistry. This documentation should be updated to maintain consistency with the implementation.

/**
 *
- * Register default builtin {@link MarkerFactoryFunction}s in {@link MarkerShape}.
+ * Register default builtin {@link MarkerFactoryFunction}s in {@link EdgeMarkerRegistry}.
 *
 *
 * @category Configuration
 * @category Style
 * @since 0.18.0
 */

160-165: JSDoc comment needs updating to match code changes.

This JSDoc comment also still references MarkerShape instead of EdgeMarkerRegistry and should be updated.

/**
 * Unregister all {@link MarkerFactoryFunction}s from {@link MarkerShape}.
+ * Unregister all {@link MarkerFactoryFunction}s from {@link EdgeMarkerRegistry}.
 *
 *
 * @category Configuration
 * @category Style
 * @since 0.18.0
 */
packages/website/docs/usage/global-configuration.md (1)

55-59: Documentation updated to reflect registry refactoring.

The documentation has been correctly updated to reflect the changes in the registry structure:

  1. EdgeMarkerRegistry replacing MarkerShape
  2. ShapeRegistry replacing shape management in CellRenderer

This aligns with the implementation changes and provides clear information about the previous structure.

However, the indentation in this unordered list is inconsistent with the rest of the document. The static analysis tools flagged this as an issue (MD007).

-  - `EdgeMarkerRegistry`: edge markers (since 0.20.0, previously managed by `MarkerShape`)
-  - `EdgeStyleRegistry`: edge styles (since 0.20.0, previously managed by `StyleRegistry`)
-  - `PerimeterRegistry`: perimeters (since 0.20.0, previously managed by `StyleRegistry`)
-  - `ShapeRegistry`: shapes (since 0.20.0, previously managed by `CellRenderer`)
-  - `StencilShapeRegistry`: stencil shapes
+- `EdgeMarkerRegistry`: edge markers (since 0.20.0, previously managed by `MarkerShape`)
+- `EdgeStyleRegistry`: edge styles (since 0.20.0, previously managed by `StyleRegistry`)
+- `PerimeterRegistry`: perimeters (since 0.20.0, previously managed by `StyleRegistry`)
+- `ShapeRegistry`: shapes (since 0.20.0, previously managed by `CellRenderer`)
+- `StencilShapeRegistry`: stencil shapes
🧰 Tools
🪛 LanguageTool

[uncategorized] ~55-~55: Loose punctuation mark.
Context: ...onfigurations. - EdgeMarkerRegistry: edge markers (since 0.20.0, previously ...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 markdownlint-cli2 (0.17.2)

55-55: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


56-56: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


57-57: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


58-58: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


59-59: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)

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

46-46: Consider adding more robust error handling

While the current implementation correctly returns null when a marker type is not found, consider adding logging or more detailed error handling for easier debugging in complex applications.

- const markerFunction = this.get(type);
+ const markerFunction = this.get(type);
+ if (!markerFunction && type) {
+   console.warn(`Marker type '${type}' not found in EdgeMarkerRegistry`);
+ }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7c7c899 and 99a2a61.

📒 Files selected for processing (23)
  • CHANGELOG.md (1 hunks)
  • packages/core/__tests__/view/geometry/node/StencilShapeRegistry.test.ts (1 hunks)
  • packages/core/src/index.ts (2 hunks)
  • packages/core/src/types.ts (1 hunks)
  • packages/core/src/view/cell/CellRenderer.ts (4 hunks)
  • packages/core/src/view/cell/register-shapes.ts (2 hunks)
  • packages/core/src/view/geometry/ShapeRegistry.ts (1 hunks)
  • packages/core/src/view/geometry/edge/ConnectorShape.ts (2 hunks)
  • packages/core/src/view/geometry/stencil/StencilShape.ts (2 hunks)
  • packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (3 hunks)
  • packages/core/src/view/geometry/stencil/register.ts (2 hunks)
  • packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (2 hunks)
  • packages/core/src/view/style/register.ts (3 hunks)
  • packages/html/stories/Handles.stories.ts (2 hunks)
  • packages/html/stories/Markers.stories.ts (4 hunks)
  • packages/html/stories/Shape.stories.js (2 hunks)
  • packages/html/stories/Stencils.stories.ts (4 hunks)
  • packages/html/stories/StencilsViewer.stories.ts (1 hunks)
  • packages/html/stories/Tree.stories.js (2 hunks)
  • packages/html/stories/Wires.stories.js (2 hunks)
  • packages/js-example-selected-features/src/index.js (2 hunks)
  • packages/ts-example-selected-features/src/main.ts (3 hunks)
  • packages/website/docs/usage/global-configuration.md (1 hunks)
🧰 Additional context used
🧠 Learnings (6)
packages/core/__tests__/view/geometry/node/StencilShapeRegistry.test.ts (1)
Learnt from: tbouffard
PR: maxGraph/maxGraph#660
File: packages/core/src/view/geometry/node/StencilShapeRegistry.ts:0-0
Timestamp: 2025-02-08T16:39:11.178Z
Learning: The StencilShapeRegistry.getStencil method's implementation using non-null assertion (!) is validated by dedicated tests to handle null/undefined inputs correctly, returning undefined in such cases.
packages/website/docs/usage/global-configuration.md (1)
Learnt from: tbouffard
PR: maxGraph/maxGraph#776
File: packages/core/src/view/Graph.ts:77-83
Timestamp: 2025-04-24T12:33:36.243Z
Learning: All register functions in maxGraph (`registerDefaultShapes`, `registerDefaultEdgeStyles`, `registerDefaultPerimeters`, and `registerDefaultEdgeMarkers`) have internal state flags to prevent duplicate registrations, making them inherently idempotent.
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)
Learnt from: tbouffard
PR: maxGraph/maxGraph#660
File: packages/core/src/view/geometry/node/StencilShapeRegistry.ts:0-0
Timestamp: 2025-02-08T16:39:11.178Z
Learning: The StencilShapeRegistry.getStencil method's implementation using non-null assertion (!) is validated by dedicated tests to handle null/undefined inputs correctly, returning undefined in such cases.
packages/html/stories/Stencils.stories.ts (1)
Learnt from: tbouffard
PR: maxGraph/maxGraph#660
File: packages/core/src/view/geometry/node/StencilShapeRegistry.ts:0-0
Timestamp: 2025-02-08T16:39:11.178Z
Learning: The StencilShapeRegistry.getStencil method's implementation using non-null assertion (!) is validated by dedicated tests to handle null/undefined inputs correctly, returning undefined in such cases.
packages/core/src/view/cell/CellRenderer.ts (1)
Learnt from: tbouffard
PR: maxGraph/maxGraph#660
File: packages/core/src/view/geometry/node/StencilShapeRegistry.ts:0-0
Timestamp: 2025-02-08T16:39:11.178Z
Learning: The StencilShapeRegistry.getStencil method's implementation using non-null assertion (!) is validated by dedicated tests to handle null/undefined inputs correctly, returning undefined in such cases.
packages/js-example-selected-features/src/index.js (1)
Learnt from: tbouffard
PR: maxGraph/maxGraph#776
File: packages/core/src/view/Graph.ts:77-83
Timestamp: 2025-04-24T12:33:36.243Z
Learning: All register functions in maxGraph (`registerDefaultShapes`, `registerDefaultEdgeStyles`, `registerDefaultPerimeters`, and `registerDefaultEdgeMarkers`) have internal state flags to prevent duplicate registrations, making them inherently idempotent.
🧬 Code Graph Analysis (16)
packages/core/src/view/geometry/edge/ConnectorShape.ts (2)
packages/core/src/index.ts (1)
  • EdgeMarkerRegistry (206-206)
packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)
  • EdgeMarkerRegistry (62-63)
packages/html/stories/Tree.stories.js (1)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
packages/html/stories/StencilsViewer.stories.ts (1)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)
  • StencilShapeRegistry (46-46)
packages/html/stories/Shape.stories.js (1)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
packages/core/src/view/geometry/stencil/register.ts (1)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)
  • StencilShapeRegistry (46-46)
packages/core/src/view/geometry/stencil/StencilShape.ts (1)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)
  • StencilShapeRegistry (46-46)
packages/html/stories/Markers.stories.ts (3)
packages/core/src/index.ts (1)
  • EdgeMarkerRegistry (206-206)
packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)
  • EdgeMarkerRegistry (62-63)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
packages/html/stories/Handles.stories.ts (1)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
packages/core/src/view/style/register.ts (2)
packages/core/src/index.ts (1)
  • EdgeMarkerRegistry (206-206)
packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)
  • EdgeMarkerRegistry (62-63)
packages/html/stories/Wires.stories.js (1)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
packages/core/src/view/cell/register-shapes.ts (1)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (2)
packages/core/src/types.ts (1)
  • Registry (1496-1508)
packages/core/src/internal/BaseRegistry.ts (1)
  • BaseRegistry (24-51)
packages/html/stories/Stencils.stories.ts (2)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)
  • StencilShapeRegistry (46-46)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
packages/core/src/view/cell/CellRenderer.ts (3)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)
  • StencilShapeRegistry (46-46)
packages/core/src/types.ts (1)
  • ShapeConstructor (1444-1444)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
  • ShapeRegistry (49-49)
packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (3)
packages/core/src/internal/BaseRegistry.ts (1)
  • BaseRegistry (24-51)
packages/core/src/types.ts (2)
  • MarkerFactoryFunction (1317-1328)
  • EdgeMarkerRegistryInterface (1575-1595)
packages/core/src/index.ts (1)
  • EdgeMarkerRegistry (206-206)
packages/js-example-selected-features/src/index.js (2)
packages/core/src/index.ts (1)
  • EdgeMarkerRegistry (206-206)
packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)
  • EdgeMarkerRegistry (62-63)
🪛 LanguageTool
packages/website/docs/usage/global-configuration.md

[uncategorized] ~55-~55: Loose punctuation mark.
Context: ...onfigurations. - EdgeMarkerRegistry: edge markers (since 0.20.0, previously ...

(UNLIKELY_OPENING_PUNCTUATION)

🪛 markdownlint-cli2 (0.17.2)
packages/website/docs/usage/global-configuration.md

55-55: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


56-56: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


57-57: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)


58-58: Unordered list indentation
Expected: 0; Actual: 2

(MD007, ul-indent)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build (windows-2022)
🔇 Additional comments (54)
packages/html/stories/Shape.stories.js (2)

18-18: Import updated to use new registry pattern.

The import now includes ShapeRegistry from @maxgraph/core, which is part of the standardization of registries according to the PR objectives.


95-95: Updated shape registration to use new Registry interface.

The code now uses ShapeRegistry.add('box', BoxShape) instead of the previous CellRenderer.registerShape method, which aligns with the standardized Registry pattern mentioned in the PR objectives.

packages/core/src/view/geometry/stencil/StencilShape.ts (2)

23-23: Import updated to use named export for StencilShapeRegistry.

The import now uses a named import for StencilShapeRegistry instead of the previous default import, which is consistent with the registry standardization effort.


566-566: Updated method call to use standard Registry interface.

Changed StencilShapeRegistry.getStencil() to StencilShapeRegistry.get(), using the standardized method name from the common Registry interface mentioned in the PR objectives.

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

21-21: Updated import to use new EdgeMarkerRegistry.

The import was changed from the previous MarkerShape to the new EdgeMarkerRegistry, following the registry renaming and standardization described in the PR objectives.


124-135: Updated marker creation to use the new registry.

Changed from MarkerShape.createMarker to EdgeMarkerRegistry.createMarker to reflect the registry renaming. This is part of the standardization effort to make all style-related registries follow the same pattern.

packages/html/stories/Wires.stories.js (2)

85-85: Added import for ShapeRegistry.

Added ShapeRegistry to the import list from @maxgraph/core to support the new registry-based shape registration pattern.


607-607: Updated shape registration to use new Registry interface.

Changed from CellRenderer.registerShape('resistor', ResistorShape) to ShapeRegistry.add('resistor', ResistorShape), aligning with the standardized Registry pattern where shape registrations are moved from CellRenderer to ShapeRegistry.

packages/html/stories/Tree.stories.js (2)

31-31: ShapeRegistry import looks good!

The new import statement correctly brings in the ShapeRegistry from the core package, which is consistent with the registry refactoring where shape registration has been centralized.


88-88: Successfully migrated to new Registry API

The shape registration has been properly updated from CellRenderer.registerShape('treenode', TreeNodeShape) to ShapeRegistry.add('treenode', TreeNodeShape), aligning with the standardized Registry interface pattern introduced in this refactor.

packages/html/stories/Handles.stories.ts (2)

34-34: ShapeRegistry import looks good!

The ShapeRegistry import has been correctly added, replacing the previous CellRenderer import for shape registration purposes.


109-109: Successfully migrated to new Registry API

The code has been properly updated to use the new standardized registry interface, changing from CellRenderer.registerShape('myShape', MyShape) to ShapeRegistry.add('myShape', MyShape).

packages/html/stories/StencilsViewer.stories.ts (1)

95-96: Successfully migrated to new Registry API

The StencilShapeRegistry usage has been correctly updated to use the standardized add method instead of the previous addStencil method, aligning with the unified Registry interface pattern.

packages/core/src/view/geometry/stencil/register.ts (2)

17-17: Updated import style for StencilShapeRegistry

The import has been correctly changed from a default import to a named import, reflecting the refactoring of StencilShapeRegistry from a static class to an instance of BaseRegistry.


27-27: Successfully migrated to new Registry API

The implementation has been properly updated to use the standardized clear() method instead of directly manipulating internal properties, improving encapsulation and adhering to the Registry interface pattern.

packages/core/__tests__/view/geometry/node/StencilShapeRegistry.test.ts (1)

20-23: Test updated correctly to reflect the new Registry interface.

The test has been properly updated to use the new standardized registry method get instead of the previous specific method getStencil, and the expected return value for invalid inputs has been changed from undefined to null to align with the new registry behavior.

packages/js-example-selected-features/src/index.js (2)

25-26: Import updated to use the new registry name.

The import statement has been correctly updated to replace MarkerShape with EdgeMarkerRegistry as part of the registry standardization.


43-43: API call updated to use the new standardized registry method.

The method call has been properly updated to use EdgeMarkerRegistry.add instead of the previous implementation-specific MarkerShape.addMarker, aligning with the new registry interface standard.

CHANGELOG.md (1)

33-36: Breaking changes documented clearly in the changelog.

The changelog has been appropriately updated to document the breaking changes related to the registry standardization. The documentation clearly explains:

  1. All style registries now derive from the Registry interface
  2. The standardized methods available (add, get, and clear)
  3. The renaming of MarkerShape to EdgeMarkerRegistry
  4. The relocation of shape registrations from CellRenderer to ShapeRegistry

This provides users with clear guidance on how to adapt their code to the breaking changes.

packages/html/stories/Markers.stories.ts (4)

25-27: Imports updated to use the new registry classes.

The imports have been correctly updated to use ShapeRegistry and EdgeMarkerRegistry instead of their previous implementations.


50-74: Marker registration updated to use the new registry API.

The custom marker registration has been properly updated to use EdgeMarkerRegistry.add instead of the previous implementation-specific method, while preserving the same functionality.


99-99: Shape registration updated to use ShapeRegistry.

The MessageShape registration has been correctly migrated from using CellRenderer.registerShape to the new centralized ShapeRegistry.add method.


144-144: Link shape registration updated to use ShapeRegistry.

The LinkShape registration has been correctly migrated to use the new centralized registry, maintaining functionality while adopting the standardized API.

packages/core/src/view/style/register.ts (3)

19-19: Good refactoring for registry consistency.

This import replacement aligns with the broader effort to standardize style registries with a unified Registry interface pattern.


153-154: Method call updated to match registry interface pattern.

The code now uses the standardized add method from the new Registry interface instead of the previous addMarker method, which improves consistency across registries.


167-168: Method call updated to match registry interface pattern.

The code now uses the standardized clear method instead of directly manipulating internal storage, which improves encapsulation and consistency with the Registry interface.

packages/ts-example-selected-features/src/main.ts (4)

24-25: Import updated to use the new registry name.

The code now imports EdgeMarkerRegistry instead of MarkerShape, aligning with the refactoring of registry management across the codebase.


36-37: Import updated for shape registry management.

The code now imports ShapeRegistry which has replaced the shape registration functionality previously part of CellRenderer.


46-47: Method call updated to use the new shape registry.

The shape registration now uses ShapeRegistry.add() instead of CellRenderer.registerShape(), aligning with the new standardized registry interface.


57-58: Edge marker registration method updated.

The edge marker registration now uses EdgeMarkerRegistry.add() following the standardized registry interface pattern, replacing MarkerShape.addMarker().

packages/html/stories/Stencils.stories.ts (4)

34-35: Import updated for shape registry management.

The import of ShapeRegistry replaces the previous import of CellRenderer for shape registration, following the refactoring that moved shape registration to a dedicated registry.


169-170: Shape registration method updated.

The shape registration now uses ShapeRegistry.add() instead of CellRenderer.registerShape(), following the standardized registry interface pattern.


178-182: Stencil shape registration method updated.

The code now uses StencilShapeRegistry.add() instead of StencilShapeRegistry.addStencil(), aligning with the standardized Registry interface.


98-99:

Details

✅ Verification successful

Method call updated to use standardized registry interface.

The code now uses StencilShapeRegistry.get() instead of StencilShapeRegistry.getStencil(), aligning with the standardized Registry interface.

Based on the retrieved learning, we should verify that the get method properly handles null/undefined inputs:


🏁 Script executed:

#!/bin/bash
# Check how StencilShapeRegistry.get handles null/undefined inputs
ast-grep --pattern $'StencilShapeRegistry.get($_) {
  $$$
}' 

Length of output: 61


#!/bin/bash

Locate the StencilShapeRegistry definition and inspect its get method

file=$(rg -l "class StencilShapeRegistry" -g "*.ts")
echo "Found file: $file"
rg -n "static get" -C 5 "$file"


🏁 Script executed:

#!/bin/bash
# Locate the file defining StencilShapeRegistry
file=$(rg --files-with-matches "class StencilShapeRegistry" -g "*.ts")
echo "Found registry file: $file"

# Display the implementation of the static get method
rg -n "static get" -C5 "$file"

Length of output: 195


🏁 Script executed:

#!/bin/bash
# Locate the StencilShapeRegistry file and display its static get implementation
file=$(find . -type f -name "StencilShapeRegistry.ts")
echo "Registry file: $file"
rg -n "static get" -C5 "$file"

Length of output: 382


#!/bin/bash

Locate the StencilShapeRegistry file

file=$(find . -type f -name "StencilShapeRegistry.ts")
echo "Registry file: $file"

Show any existing static getStencil method

rg -n "static getStencil" -C2 "$file"

Show any existing static get method

rg -n "static get(" -C2 "$file"


🏁 Script executed:

#!/bin/bash
# Display the start of StencilShapeRegistry.ts to locate static methods
file=$(find . -type f -name "StencilShapeRegistry.ts")
echo "Registry file: $file"
sed -n '1,200p' "$file"

Length of output: 1939


#!/bin/bash

Locate and inspect BaseRegistry implementation for the get method

file=$(find . -type f -name "BaseRegistry.ts")
echo "BaseRegistry file: $file"
rg -n "class BaseRegistry" -C3 "$file"
rg -n "get(" -C5 "$file"


🏁 Script executed:

#!/bin/bash
# Locate and display BaseRegistry implementation to verify get() behavior
file=$(find . -type f -name "BaseRegistry.ts")
echo "BaseRegistry file: $file"
sed -n '1,200p' "$file"

Length of output: 1997


Method call updated to use standardized registry interface

The code correctly uses StencilShapeRegistry.get(...) instead of getStencil(), leveraging the Registry<StencilShape> interface implemented by BaseRegistry.

packages/core/src/view/cell/register-shapes.ts (4)

17-17: Good update to import ShapeRegistry.

The import now correctly references the new centralized ShapeRegistry, aligning with the registry refactoring.


66-66: Shape registration correctly uses the new ShapeRegistry API.

The code now properly uses ShapeRegistry.add() instead of the previous CellRenderer.registerShape(), maintaining the same functionality while adhering to the new registry pattern.


73-75: Updated JSDoc to reference ShapeRegistry properly.

The documentation has been correctly updated to reflect the new ownership of shapes by ShapeRegistry instead of CellRenderer.


81-81: Correctly implemented registry clearing.

Now using ShapeRegistry.clear() method instead of directly manipulating internal data structures, which improves encapsulation and follows the Registry interface contract.

packages/core/src/view/geometry/ShapeRegistry.ts (3)

19-21: Good implementation of imports for the registry pattern.

The imports correctly include the Registry type and BaseRegistry implementation, establishing the foundation for a consistent registry pattern.


22-48: Well-documented registry with comprehensive explanations.

The documentation clearly describes the purpose of the ShapeRegistry and lists all the built-in shapes, which is extremely helpful for developers using this API.


49-49: Good implementation of the registry singleton pattern.

Creating ShapeRegistry as an instance of BaseRegistry follows the standardized pattern for registries, ensuring consistent behavior across all style registries.

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

125-125: Good update to export pattern for StencilShapeRegistry.

Changed from default export to namespace export, which is consistent with the new registry pattern being applied across the codebase.


200-200: Properly exported the new ShapeRegistry.

This export is necessary to make the ShapeRegistry available for use throughout the codebase and in external projects.


206-206: Correctly renamed and exported EdgeMarkerRegistry.

The export has been updated from a default export of MarkerShape to a named export of EdgeMarkerRegistry, aligning with the standardized naming convention.

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

1568-1595: Well-defined EdgeMarkerRegistryInterface with appropriate documentation.

The new interface properly extends the base Registry interface and adds the specialized createMarker method needed for edge markers. The documentation clearly explains the purpose and behavior of this interface.

packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (3)

19-21: Good use of type imports for better tree-shaking

Using import type for the imports that are only needed for type checking is a good practice as it helps with tree-shaking and prevents unnecessary code from being included in the bundle.


23-46: Documentation correctly updated to reflect new API pattern

The JSDoc has been properly updated to match the new API pattern, with the example showing the usage of StencilShapeRegistry.add() instead of the previous addStencil method. This ensures consistent documentation across all registry implementations.


46-46: Registry implementation follows the standardized pattern

The implementation correctly follows the standardized pattern of using a BaseRegistry instance that implements the Registry interface, providing consistent behavior across all style registries.

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

34-35: Good import of registry dependencies

The imports have been correctly updated to use the new registry implementations. The imports indicate a clear separation of concerns, with shape registry responsibilities moved out of the CellRenderer class.


139-140: Correctly updated StencilShapeRegistry call

The call to retrieve a stencil has been properly updated to use the new get method on StencilShapeRegistry instead of the previous getStencil method, consistent with the standardized registry interface.


159-162: Method documentation and implementation correctly updated

The method documentation has been updated to reflect that shapes are now retrieved from ShapeRegistry, and the implementation correctly uses ShapeRegistry.get() rather than accessing an internal map. This follows the new pattern of delegating shape management to dedicated registries.

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

19-28: Good type imports and added dependency on BaseRegistry

The imports have been properly updated to include the new EdgeMarkerRegistryInterface type and to import the BaseRegistry class. This sets up the required dependencies for the refactored registry implementation.


30-51: Well-structured registry implementation with inheritance

The implementation of EdgeMarkerRegistryImpl correctly extends BaseRegistry<MarkerFactoryFunction> and implements the EdgeMarkerRegistryInterface. The createMarker method properly uses the inherited get method to retrieve the marker factory function and then invokes it if found. This design follows good OOP principles by leveraging inheritance for common behavior.


53-63: Comprehensive JSDoc with clear category tags

The JSDoc for the registry export is well-structured, clearly explaining the purpose of the registry and including appropriate category tags and version information. This follows good documentation practices and helps maintain consistency across the API.

@sonarqubecloud
Copy link

sonarqubecloud bot commented May 6, 2025

@tbouffard tbouffard merged commit a97dc4b into main May 6, 2025
7 checks passed
@tbouffard tbouffard deleted the refactor/all_style_registries_use_BaseRegistry branch May 6, 2025 19:39
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