-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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: Change flowDB to class based architecture. #6161
base: develop
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for mermaid-js ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
commit: |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6161 +/- ##
=======================================
Coverage 4.47% 4.47%
=======================================
Files 385 384 -1
Lines 54180 54176 -4
Branches 598 623 +25
=======================================
Hits 2425 2425
+ Misses 51755 51751 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
|
The latest updates on your projects. Learn more about Argos notifications ↗︎ Awaiting the start of a new Argos build… |
🦋 Changeset detectedLatest commit: 1575a93 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Looks good!
Co-authored-by: Alois Klink <[email protected]>
Co-authored-by: Alois Klink <[email protected]>
…saurabh/refactor/convert-flowDb-to-class
public defaultConfig = () => defaultConfig.flowchart; | ||
public setAccTitle = setAccTitle; | ||
public setAccDescription = setAccDescription; | ||
public setDiagramTitle = setDiagramTitle; | ||
public getAccTitle = getAccTitle; | ||
public getAccDescription = getAccDescription; | ||
public getDiagramTitle = getDiagramTitle; |
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.
Hhhhmmmmmmmmmmmm, this means part of the DB will be tied to a diagram, and some parts will change based on the last rendered diagram.
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.
Yep, it's probably something to fix next.
I'd imagine it would be more difficult, though, since I believe the Langium parsers also modify this shared state.
And since it's part of the DiagramAPI
in
mermaid/packages/mermaid/src/diagram-api/types.ts
Lines 43 to 57 in 037ba2f
/** | |
* DiagramDB with fields that is required for all new diagrams. | |
*/ | |
export type DiagramDBBase<T extends BaseDiagramConfig> = { | |
getConfig: () => Required<T>; | |
} & SetRequired< | |
DiagramDB, | |
| 'clear' | |
| 'getAccTitle' | |
| 'getDiagramTitle' | |
| 'getAccDescription' | |
| 'setAccDescription' | |
| 'setAccTitle' | |
| 'setDiagramTitle' | |
>; |
@saurabhg772244, I know you've already documented in the PR description that you haven't changed these functions. Can you maybe add a link to this comment thread to explain why we haven't changed them in this PR?
this.funs.push(this.setupToolTips); | ||
this.clear(); | ||
this.setGen('gen-2'); |
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.
This is already done inside clear, so why do we need to do it here?
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.
They're copied from the old init
call in:
mermaid/packages/mermaid/src/diagrams/flowchart/flowDiagram.ts
Lines 23 to 24 in bc2cc61
flowDb.clear(); | |
flowDb.setGen('gen-2'); |
But @saurabhg772244 has changed .clear()
to use 'gen-2'
by default, see #6161 (comment)
IMO, my gut feeling is that it's probably better to change as little as possible in this PR, and maybe do the gen-1
/gen-2
cleanup in a separate PR, to keep this PR as small as possible.
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.
We require gen-2
as gen-1
is deprecated and will break sub-graphs. https://mermaidchart.slack.com/archives/C06FGFCQVSR/p1735895537015209
…saurabh/refactor/convert-flowDb-to-class
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.
I think the new class method syntax is better (both from a performance/memory standpoint, since it's shared in the class prototype
, and from a browser/env support standpoint), so thanks for fixing it in f9ac986!
And thanks for adding a changeset!
…saurabh/refactor/convert-flowDb-to-class
📑 Summary
diagramObject.db
is called.📏 Design Decisions
📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.pnpm changeset
and following the prompts. Changesets that add features should beminor
and those that fix bugs should bepatch
. Please prefix changeset messages withfeat:
,fix:
, orchore:
.