| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
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 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
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 details Configuration used: CodeRabbit UI Reviewing files that changed from the base of the PR and between 99a2a61 and c287262. 📒 Files selected for processing (9)
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/ShapeRegistry.ts (1)🪛 LanguageTool packages/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)
packages/ts-example/src/custom-shapes.ts (2)✨ 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. ❤️ Share 🪧 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 (.coderabbit.yaml)
Documentation and Community
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)packages/core/src/view/style/register.ts (2)📜 Review detailspackages/website/docs/usage/global-configuration.md (1)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/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)55-59: Documentation updated to reflect registry refactoring.
The documentation has been correctly updated to reflect the changes in the registry structure:
- EdgeMarkerRegistry replacing MarkerShape
- 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).
🧰 Tools 🪛 LanguageTool- - `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[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)
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`); + }
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Reviewing files that changed from the base of the PR and between 7c7c899 and 99a2a61.
📒 Files selected for processing (23)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.
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.
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.
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.
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.
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/index.ts (1)packages/html/stories/Tree.stories.js (1)packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)
- EdgeMarkerRegistry (206-206)
- EdgeMarkerRegistry (62-63)
packages/core/src/view/geometry/ShapeRegistry.ts (1)packages/html/stories/StencilsViewer.stories.ts (1)
- ShapeRegistry (49-49)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)packages/html/stories/Shape.stories.js (1)
- StencilShapeRegistry (46-46)
packages/core/src/view/geometry/ShapeRegistry.ts (1)packages/core/src/view/geometry/stencil/register.ts (1)
- ShapeRegistry (49-49)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)packages/core/src/view/geometry/stencil/StencilShape.ts (1)
- StencilShapeRegistry (46-46)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)packages/html/stories/Markers.stories.ts (3)
- StencilShapeRegistry (46-46)
packages/core/src/index.ts (1)packages/html/stories/Handles.stories.ts (1)packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)
- EdgeMarkerRegistry (206-206)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
- EdgeMarkerRegistry (62-63)
- ShapeRegistry (49-49)
packages/core/src/view/geometry/ShapeRegistry.ts (1)packages/core/src/view/style/register.ts (2)
- ShapeRegistry (49-49)
packages/core/src/index.ts (1)packages/html/stories/Wires.stories.js (1)packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)
- EdgeMarkerRegistry (206-206)
- EdgeMarkerRegistry (62-63)
packages/core/src/view/geometry/ShapeRegistry.ts (1)packages/core/src/view/cell/register-shapes.ts (1)
- ShapeRegistry (49-49)
packages/core/src/view/geometry/ShapeRegistry.ts (1)packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (2)
- ShapeRegistry (49-49)
packages/core/src/types.ts (1)packages/html/stories/Stencils.stories.ts (2)packages/core/src/internal/BaseRegistry.ts (1)
- Registry (1496-1508)
- BaseRegistry (24-51)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)packages/core/src/view/cell/CellRenderer.ts (3)packages/core/src/view/geometry/ShapeRegistry.ts (1)
- StencilShapeRegistry (46-46)
- ShapeRegistry (49-49)
packages/core/src/view/geometry/stencil/StencilShapeRegistry.ts (1)packages/core/src/view/style/marker/EdgeMarkerRegistry.ts (3)packages/core/src/types.ts (1)
- StencilShapeRegistry (46-46)
packages/core/src/view/geometry/ShapeRegistry.ts (1)
- ShapeConstructor (1444-1444)
- ShapeRegistry (49-49)
packages/core/src/internal/BaseRegistry.ts (1)packages/js-example-selected-features/src/index.js (2)packages/core/src/types.ts (2)
- BaseRegistry (24-51)
packages/core/src/index.ts (1)
- MarkerFactoryFunction (1317-1328)
- EdgeMarkerRegistryInterface (1575-1595)
- EdgeMarkerRegistry (206-206)
packages/core/src/index.ts (1)🪛 LanguageTool packages/website/docs/usage/global-configuration.mdpackages/core/src/view/style/marker/EdgeMarkerRegistry.ts (1)
- EdgeMarkerRegistry (206-206)
- EdgeMarkerRegistry (62-63)
[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.md55-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)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:
- All style registries now derive from the Registry interface
- The standardized methods available (add, get, and clear)
- The renaming of MarkerShape to EdgeMarkerRegistry
- 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 successfulMethod 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.
Sorry, something went wrong.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
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:
So, they all share the same methods (add, get and clear) and their internal storage is no longer accessible.
Summary by CodeRabbit
New Features
Refactor
Documentation