-
Notifications
You must be signed in to change notification settings - Fork 199
refactor!: remove ARROW, EDGESTYLE, PERIMETER enums #796
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
Conversation
This slightly decreases the size of applications. In maxGraph examples, the decrease is about 0.5 kB. BREAKING CHANGES: some enums have been removed. Use the string counterparts from related types: - `ArrowValue` instead of `constants.ARROW` - `EdgeStyleValue` instead of `constants.EDGESTYLE` - `PerimeterValue` instead of `constants.PERIMETER`
## Walkthrough
This update removes the exported enums `ARROW`, `EDGESTYLE`, and `PERIMETER` from the codebase, replacing their usage with string-based types and literals. Documentation and code comments are updated throughout to clarify the use of string values for arrows, edge styles, and perimeters. Type aliases now include comments specifying their intended usage. Example code and documentation in various files are revised to use string literals instead of enum references. No functional or behavioral changes are introduced; all updates are related to type definitions, documentation, and usage examples.
## Changes
| File(s) | Change Summary |
|-------------------------------------------------------------------------------------------|----------------|
| `packages/core/src/util/Constants.ts` | Removed exported enums: `ARROW`, `EDGESTYLE`, and `PERIMETER`. |
| `CHANGELOG.md` | Expanded breaking changes section to list all removed enums and specify migration to string-based types. |
| `packages/core/src/types.ts` | Added documentation comments to `ArrowValue`, `PerimeterValue`, and `EdgeStyleValue` type aliases. |
| `packages/core/src/view/style/Stylesheet.ts` | Updated example in documentation to use string literal `'rectanglePerimeter'` instead of enum reference. |
| `packages/html/stories/SwimLanes.stories.ts` | Replaced enum-based edge style and arrow values with string literals in style assignments. |
| `packages/core/src/view/style/edge/Elbow.ts`<br>`.../EntityRelation.ts`<br>`.../Loop.ts`<br>`.../Manhattan.ts`<br>`.../Orthogonal.ts`<br>`.../Segment.ts`<br>`.../SideToSide.ts`<br>`.../TopToBottom.ts` | Enhanced or added documentation comments clarifying registration names for edge styles in `StyleRegistry`. Minor type assertion change in `Elbow.ts`. |
| `packages/core/src/view/style/perimeter/EllipsePerimeter.ts`<br>`.../HexagonPerimeter.ts`<br>`.../RectanglePerimeter.ts`<br>`.../RhombusPerimeter.ts`<br>`.../TrianglePerimeter.ts` | Added documentation comments specifying registration names for perimeter functions in `StyleRegistry`. |
| `packages/ts-example-selected-features/vite.config.js`<br>`.../ts-example-without-defaults/vite.config.js`<br>`.../ts-example/vite.config.js` | Decreased `chunkSizeWarningLimit` values by 1 in Vite build configurations. |
## Sequence Diagram(s)
```mermaid
sequenceDiagram
participant User
participant Graph
participant StyleRegistry
User->>Graph: Set edgeStyle/endArrow/startArrow/perimeter with string literal
Graph->>StyleRegistry: Lookup style/perimeter by string name
StyleRegistry-->>Graph: Return registered function
Graph->>User: Apply style/perimeter to cellPossibly related PRs
|
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: 1
🔭 Outside diff range comments (1)
packages/html/stories/SwimLanes.stories.ts (1)
23-23:⚠️ Potential issueRemove unused
constantsimport.The
constantsimport is no longer referenced after replacing enum usages with string literals, resulting in a TS6133 error. Please removeconstantsfrom the import list.🧰 Tools
🪛 GitHub Actions: Generate website
[error] 23-23: TypeScript error TS6133: 'constants' is declared but its value is never read.
🧹 Nitpick comments (2)
CHANGELOG.md (1)
14-17: Refine breaking change bullet phrasing.The repeated “instead of” in each bullet can be streamlined. For example:
- Use
ArrowValue,EdgeStyleValue,PerimeterValueandShapeValuein place of the removed enums.🧰 Tools
🪛 LanguageTool
[grammar] ~14-~14: This phrase is duplicated. You should probably use “instead of” only once.
Context: ...ts from related types: -ArrowValueinstead ofconstants.ARROW-EdgeStyleValueinstead ofconstants.EDGESTYLE- `PerimeterVal...(PHRASE_REPETITION)
[grammar] ~16-~16: This phrase is duplicated. You should probably use “instead of” only once.
Context: ...nstants.EDGESTYLE-PerimeterValueinstead ofconstants.PERIMETER-ShapeValueinstead ofconstants.SHAPE` ## 0.19.0 Release ...(PHRASE_REPETITION)
packages/core/src/view/style/edge/EntityRelation.ts (1)
36-36: Fix typo in JSDoc ("ant" → "and").Correct the typo in “The first ant the last point...” to “The first and the last point...”.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (21)
CHANGELOG.md(1 hunks)packages/core/src/types.ts(3 hunks)packages/core/src/util/Constants.ts(0 hunks)packages/core/src/view/style/Stylesheet.ts(1 hunks)packages/core/src/view/style/edge/Elbow.ts(2 hunks)packages/core/src/view/style/edge/EntityRelation.ts(1 hunks)packages/core/src/view/style/edge/Loop.ts(1 hunks)packages/core/src/view/style/edge/Manhattan.ts(1 hunks)packages/core/src/view/style/edge/Orthogonal.ts(1 hunks)packages/core/src/view/style/edge/Segment.ts(1 hunks)packages/core/src/view/style/edge/SideToSide.ts(1 hunks)packages/core/src/view/style/edge/TopToBottom.ts(1 hunks)packages/core/src/view/style/perimeter/EllipsePerimeter.ts(1 hunks)packages/core/src/view/style/perimeter/HexagonPerimeter.ts(1 hunks)packages/core/src/view/style/perimeter/RectanglePerimeter.ts(1 hunks)packages/core/src/view/style/perimeter/RhombusPerimeter.ts(1 hunks)packages/core/src/view/style/perimeter/TrianglePerimeter.ts(1 hunks)packages/html/stories/SwimLanes.stories.ts(1 hunks)packages/ts-example-selected-features/vite.config.js(1 hunks)packages/ts-example-without-defaults/vite.config.js(1 hunks)packages/ts-example/vite.config.js(1 hunks)
💤 Files with no reviewable changes (1)
- packages/core/src/util/Constants.ts
🧰 Additional context used
🪛 GitHub Actions: Generate website
packages/html/stories/SwimLanes.stories.ts
[error] 23-23: TypeScript error TS6133: 'constants' is declared but its value is never read.
🪛 LanguageTool
CHANGELOG.md
[grammar] ~14-~14: This phrase is duplicated. You should probably use “instead of” only once.
Context: ...ts from related types: - ArrowValue instead of constants.ARROW - EdgeStyleValue instead of constants.EDGESTYLE - `PerimeterVal...
(PHRASE_REPETITION)
[grammar] ~16-~16: This phrase is duplicated. You should probably use “instead of” only once.
Context: ...nstants.EDGESTYLE -PerimeterValueinstead ofconstants.PERIMETER -ShapeValueinstead ofconstants.SHAPE` ## 0.19.0 Release ...
(PHRASE_REPETITION)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build (ubuntu-22.04)
- GitHub Check: build (windows-2022)
🔇 Additional comments (22)
packages/ts-example-without-defaults/vite.config.js (1)
30-30: Consistent chunk size threshold update
ThechunkSizeWarningLimitvalue has been decremented by 1 (330 → 329) to match the adjustments in other example configs. This change is aligned and requires no further modifications.packages/ts-example-selected-features/vite.config.js (1)
30-30: Aligned chunk size warning limit
LoweredchunkSizeWarningLimitfrom 381 to 380 to maintain consistency across example packages. No additional changes needed.packages/core/src/view/style/edge/TopToBottom.ts (1)
27-29: Documentation enhancement looks good
The added JSDoc clarifies that this style is registered undertopToBottomEdgeStyle. Formatting matches other edge style docs in this directory.packages/ts-example/vite.config.js (1)
30-30: Chunk size warning threshold updated consistently
AdjustedchunkSizeWarningLimitfrom 439 to 438 in line with the other Vite configs. This is a non-breaking, cosmetic change.packages/core/src/view/style/edge/Loop.ts (1)
28-30: Added registration note is clear and consistent
The new JSDoc line specifyingloopEdgeStyleregistration aligns with similar updates across edge style files. No functional changes required.packages/core/src/view/style/edge/Manhattan.ts (1)
31-32: Approve JSDoc enhancement for registration clarity.The added JSDoc comment clearly specifies that the
ManhattanConnectoredge style is registered under the string keymanhattanEdgeStylein theStyleRegistry. This aligns with the removal of the enum and improves documentation consistency.packages/core/src/view/style/edge/SideToSide.ts (1)
27-28: Approve JSDoc registration comment.The new comment correctly documents that the
SideToSideedge style is registered undersideToSideEdgeStylein theStyleRegistry, matching the pattern used elsewhere in the codebase.packages/core/src/view/style/Stylesheet.ts (1)
136-136: Approve example update for perimeter string literal.The example now uses the string literal
'rectanglePerimeter'instead of the removedPERIMETER.RECTANGLEenum value, accurately reflecting the new recommended usage in style definitions.packages/core/src/view/style/perimeter/RhombusPerimeter.ts (1)
26-27: Approve JSDoc addition for perimeter registration.The added JSDoc comment correctly registers the
RhombusPerimeterfunction under the keyrhombusPerimeterin theStyleRegistry, ensuring consistency with other perimeter functions after enum removal.packages/core/src/view/style/perimeter/RectanglePerimeter.ts (1)
27-28: Approve JSDoc registration documentation.The new comment accurately indicates that the
RectanglePerimeterfunction is registered underrectanglePerimeterin theStyleRegistry, aligning with the updated documentation and type guidance.packages/core/src/view/style/perimeter/EllipsePerimeter.ts (1)
25-26: Approve documentation enhancement for perimeter registration.The added JSDoc lines clearly specify the registration key
ellipsePerimeterin the StyleRegistry and follow the existing pattern for other perimeter functions. Well formatted and consistent.packages/core/src/view/style/perimeter/TrianglePerimeter.ts (1)
27-28: Approve documentation enhancement for perimeter registration.The new JSDoc correctly documents the registration name
trianglePerimeterand matches the style of other perimeter functions. No issues detected.packages/core/src/view/style/edge/Segment.ts (1)
30-31: Approve documentation enhancement for edge style registration.The added JSDoc entry clearly indicates the registration name
segmentEdgeStylein the StyleRegistry for this connector. It aligns with similar updates across other edge style modules.packages/core/src/view/style/perimeter/HexagonPerimeter.ts (1)
27-28: Approve documentation enhancement for perimeter registration.The JSDoc now properly records the registration key
hexagonPerimeterand is consistent with the updates in other perimeter modules.packages/html/stories/SwimLanes.stories.ts (2)
144-145: Replace enum usage with string literals for default edge style.The
edgeStyleandendArrowproperties now use string values ('elbowEdgeStyle'and'block') that align withEdgeStyleValueandArrowValue. This update correctly reflects the removed enums.
152-153: Replace enum usage with string literals for 'crossover' style.The cloned edge style now uses
'open'forendArrowand'oval'forstartArrow, matching theArrowValuedefinitions and removing enum dependencies.packages/core/src/types.ts (3)
933-935: Clarify usage ofArrowValue.Adding “Can be used as a value for {@link CellStateStyle.startArrow} and {@link CellStateStyle.endArrow}” improves discoverability and guides migration from the
ARROWenum.
1233-1235: Clarify usage ofPerimeterValue.The inserted JSDoc note explicitly ties
PerimeterValuetoCellStateStyle.perimeter, aiding users moving away from thePERIMETERenum.
1267-1269: Clarify usage ofEdgeStyleValue.Documenting that
EdgeStyleValuecan be assigned toCellStateStyle.edgeStylecompletes the migration guidance for the removedEDGESTYLEenum.packages/core/src/view/style/edge/Elbow.ts (2)
30-31: Document registered style name.The added JSDoc line about
elbowEdgeStyleregistration aligns with other edge style docs and improves clarity inStyleRegistry.
53-53: Use non-null assertion instead of type assertion.Switching from a cast (
<Point>) to a non-null assertion (!) is more idiomatic. Please verify thattransformControlPointcannot returnnullin this context to avoid runtime errors.packages/core/src/view/style/edge/EntityRelation.ts (1)
28-38: Enhance JSDoc with style registration details.The expanded comments clearly explain the entity relation algorithm and note that it’s registered under
entityRelationEdgeStyle, matching the pattern used for other edge styles.
|



This slightly decreases the size of applications. In maxGraph examples, the decrease is about 0.5 kB.
BREAKING CHANGES: some enums have been removed. Use the string counterparts from related types:
constants.ARROW-->ArrowValueconstants.EDGESTYLE-->EdgeStyleValueconstants.PERIMETER-->PerimeterValueNotes
Covers #378
Impact on the size of the examples
Summary by CodeRabbit
Summary by CodeRabbit