-
Notifications
You must be signed in to change notification settings - Fork 199
refactor!: standardize style registries with Registry interface
#812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor!: standardize style registries with Registry interface
#812
Conversation
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`.
WalkthroughThis change refactors the style and shape registration system by replacing static or ad hoc registries (such as those in Changes
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(...)
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (9)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (4)
🧰 Additional context used🧠 Learnings (1)packages/website/docs/usage/global-configuration.md (1)🧬 Code Graph Analysis (1)packages/ts-example/src/custom-shapes.ts (1)
🪛 LanguageToolpackages/website/docs/usage/global-configuration.md[uncategorized] ~55-~55: Loose punctuation mark. (UNLIKELY_OPENING_PUNCTUATION) ⏰ Context from checks skipped due to timeout of 90000ms (4)
🔇 Additional comments (3)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
MarkerShapebut the code now usesEdgeMarkerRegistry. 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
MarkerShapeinstead ofEdgeMarkerRegistryand 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:
EdgeMarkerRegistryreplacingMarkerShapeShapeRegistryreplacing shape management inCellRendererThis 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 handlingWhile the current implementation correctly returns
nullwhen 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
📒 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
ShapeRegistryfrom@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 previousCellRenderer.registerShapemethod, 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
StencilShapeRegistryinstead 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()toStencilShapeRegistry.get(), using the standardized method name from the commonRegistryinterface 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
MarkerShapeto the newEdgeMarkerRegistry, following the registry renaming and standardization described in the PR objectives.
124-135: Updated marker creation to use the new registry.Changed from
MarkerShape.createMarkertoEdgeMarkerRegistry.createMarkerto 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
ShapeRegistryto the import list from@maxgraph/coreto support the new registry-based shape registration pattern.
607-607: Updated shape registration to use new Registry interface.Changed from
CellRenderer.registerShape('resistor', ResistorShape)toShapeRegistry.add('resistor', ResistorShape), aligning with the standardized Registry pattern where shape registrations are moved fromCellRenderertoShapeRegistry.packages/html/stories/Tree.stories.js (2)
31-31: ShapeRegistry import looks good!The new import statement correctly brings in the
ShapeRegistryfrom the core package, which is consistent with the registry refactoring where shape registration has been centralized.
88-88: Successfully migrated to new Registry APIThe shape registration has been properly updated from
CellRenderer.registerShape('treenode', TreeNodeShape)toShapeRegistry.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 APIThe code has been properly updated to use the new standardized registry interface, changing from
CellRenderer.registerShape('myShape', MyShape)toShapeRegistry.add('myShape', MyShape).packages/html/stories/StencilsViewer.stories.ts (1)
95-96: Successfully migrated to new Registry APIThe StencilShapeRegistry usage has been correctly updated to use the standardized
addmethod instead of the previousaddStencilmethod, aligning with the unified Registry interface pattern.packages/core/src/view/geometry/stencil/register.ts (2)
17-17: Updated import style for StencilShapeRegistryThe 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 APIThe 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
getinstead of the previous specific methodgetStencil, and the expected return value for invalid inputs has been changed fromundefinedtonullto 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
MarkerShapewithEdgeMarkerRegistryas 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.addinstead of the previous implementation-specificMarkerShape.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:
- All style registries now derive from the
Registryinterface- The standardized methods available (
add,get, andclear)- The renaming of
MarkerShapetoEdgeMarkerRegistry- The relocation of shape registrations from
CellRenderertoShapeRegistryThis 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
ShapeRegistryandEdgeMarkerRegistryinstead 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.addinstead 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.registerShapeto the new centralizedShapeRegistry.addmethod.
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
Registryinterface pattern.
153-154: Method call updated to match registry interface pattern.The code now uses the standardized
addmethod from the newRegistryinterface instead of the previousaddMarkermethod, which improves consistency across registries.
167-168: Method call updated to match registry interface pattern.The code now uses the standardized
clearmethod instead of directly manipulating internal storage, which improves encapsulation and consistency with theRegistryinterface.packages/ts-example-selected-features/src/main.ts (4)
24-25: Import updated to use the new registry name.The code now imports
EdgeMarkerRegistryinstead ofMarkerShape, aligning with the refactoring of registry management across the codebase.
36-37: Import updated for shape registry management.The code now imports
ShapeRegistrywhich has replaced the shape registration functionality previously part ofCellRenderer.
46-47: Method call updated to use the new shape registry.The shape registration now uses
ShapeRegistry.add()instead ofCellRenderer.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, replacingMarkerShape.addMarker().packages/html/stories/Stencils.stories.ts (4)
34-35: Import updated for shape registry management.The import of
ShapeRegistryreplaces the previous import ofCellRendererfor 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 ofCellRenderer.registerShape(), following the standardized registry interface pattern.
178-182: Stencil shape registration method updated.The code now uses
StencilShapeRegistry.add()instead ofStencilShapeRegistry.addStencil(), aligning with the standardizedRegistryinterface.
98-99:Details
✅ Verification successful
Method call updated to use standardized registry interface.
The code now uses
StencilShapeRegistry.get()instead ofStencilShapeRegistry.getStencil(), aligning with the standardizedRegistryinterface.Based on the retrieved learning, we should verify that the
getmethod 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
getmethodfile=$(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
getmethodfile=$(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 ofgetStencil(), leveraging theRegistry<StencilShape>interface implemented byBaseRegistry.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 previousCellRenderer.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
MarkerShapeto a named export ofEdgeMarkerRegistry, 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
createMarkermethod 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-shakingUsing
import typefor 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 patternThe JSDoc has been properly updated to match the new API pattern, with the example showing the usage of
StencilShapeRegistry.add()instead of the previousaddStencilmethod. This ensures consistent documentation across all registry implementations.
46-46: Registry implementation follows the standardized patternThe implementation correctly follows the standardized pattern of using a
BaseRegistryinstance that implements theRegistryinterface, providing consistent behavior across all style registries.packages/core/src/view/cell/CellRenderer.ts (3)
34-35: Good import of registry dependenciesThe 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
CellRendererclass.
139-140: Correctly updated StencilShapeRegistry callThe call to retrieve a stencil has been properly updated to use the new
getmethod onStencilShapeRegistryinstead of the previousgetStencilmethod, consistent with the standardized registry interface.
159-162: Method documentation and implementation correctly updatedThe method documentation has been updated to reflect that shapes are now retrieved from
ShapeRegistry, and the implementation correctly usesShapeRegistry.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 BaseRegistryThe imports have been properly updated to include the new
EdgeMarkerRegistryInterfacetype and to import theBaseRegistryclass. This sets up the required dependencies for the refactored registry implementation.
30-51: Well-structured registry implementation with inheritanceThe implementation of
EdgeMarkerRegistryImplcorrectly extendsBaseRegistry<MarkerFactoryFunction>and implements theEdgeMarkerRegistryInterface. ThecreateMarkermethod properly uses the inheritedgetmethod 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 tagsThe 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.
|



Replace custom registry implementations with a consistent BaseRegistry pattern across
StencilShapeRegistry,MarkerShapeRegistry(formerly MarkerShape), andShapeRegistry(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:
Registryinterface for consistency.So, they all share the same methods (add, get and clear) and their internal storage is no longer accessible.
MarkerShaperegistry has been renamed toMarkerShapeRegistry.ShapeRegistryinstead inCellRenderer.Summary by CodeRabbit
New Features
Refactor
ShapeRegistryandEdgeMarkerRegistrythroughout the codebase.CellRendererto external registries for improved modularity.Documentation