-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
fix: Remove triple parsing of diagrams #4697
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #4697 +/- ##
============================================
+ Coverage 46.03% 72.82% +26.79%
============================================
Files 53 146 +93
Lines 6736 14658 +7922
Branches 18 562 +544
============================================
+ Hits 3101 10675 +7574
- Misses 3635 3851 +216
- Partials 0 132 +132
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Time taken to render diagrams in
Interesting to see Firefox is twice as fast as Chrome for rendering mermaid! |
Related |
Awesome! I saw some diagrams have |
Yeah, I noticed that, but didn't want to change too much in this PR. That can be removed and tested in an upcoming flowDB cleanup PR (that I'm working on). |
Awesome. What I previously did was only initial cleanup of extra rendering, and you opened a can of warms for sure. Nice excavations. |
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.
Wooo, the performance impact sounds pretty nice!
The only potential issue I see is whether or not this is a BREAKING CHANGE.
In some of the tests, you've removed lines that used to have await mermaidAPI.parse(str1);
. Is this something that might break how Mermaid's public API works?
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.
The only potential issue I see is whether or not this is a BREAKING CHANGE.
In some of the tests, you've removed lines that used to have
await mermaidAPI.parse(str1);
. Is this something that might break how Mermaid's public API works?
I guess it's not a breaking change. When initializing new diagram using new Diagram()
, it runs the parse
function async and update the DB, which is exactly what the mermaidAPI
do when calling mermaidAPI.parse
.
After looking at these changes, doesn't that mean that there's no use of I guess we could add that log call inside the render function with log.debug(`rendering ${id} diagram\n${text}`); So maybe now we could remove unnecessary parameters in |
Co-authored-by: Alois Klink <alois@aloisklink.com> Co-authored-by: Nikolay Rozhkov <nironame@gmail.com> Co-authored-by: Yokozuna59 <u.yokozuna@gmail.com>
Co-authored-by: Alois Klink <alois@aloisklink.com>
I don't think it'll have any external changes visible to the mermaidAPI.parse users.
Yes, we could! The renderer should not need to know anything regarding the original text. It's only concern should be rendering whatever is in the DB. |
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 don't think it'll have any external changes visible to the
mermaidAPI.parse
users.
In that case, I'll officially approve this PR :)
So maybe now we could remove unnecessary parameters in v11, see #4450 (comment).
Yes, we could! The renderer should not need to know anything regarding the original text. It's only concern should be rendering whatever is in the DB.
Should we make a GitHub issue (or maybe a GitHub Discussion is better) for all of the breaking changes we want in a v11 release?
There are some breaking changes I want to make to Mermaid.JS types :)
Side-note, what label should we give this PR for the Release notes? Maybe we should make a new label called |
* develop: (59 commits) fix!(deps): fix zenuml style leakage. update @zenuml/core to ^3.0.6 to fix the style leakage. Update selectSvgElement.ts create `Group` type Add specialChars in textNoTagsToken, alphaNumToken Return Unicode Text to idStringToken definition Add underscore to unit test on special Chars Revert to old docs concerning quotations marks in string Refactor unit tests and remove repetition Correct idStringToken definition to include all individual special tokens Add unit tests for node ids with special Chars Create lychee.toml create `selectSvgElement` change `svgElem` to `SVG` in `configureSvgSize` add `configureSvgSize` in infoRenderer run docs:build remove info sandbox test case Remove replaceAll method in addLink Modify HREF token regex to contain space Add unit tests for stange node names Remove escaped quotes with backslash feature ...
I think we should. We are currently just suggesting stuff in random issues and PRs without collecting and filtering them. It would also help us create a changelog for v11. |
Done: https://github.com/orgs/mermaid-js/discussions/4710 |
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.
Good Job @sidharthv96 !
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [mermaid](https://togithub.com/mermaid-js/mermaid) | [`10.3.0` -> `10.3.1`](https://renovatebot.com/diffs/npm/mermaid/10.3.0/10.3.1) | [![age](https://developer.mend.io/api/mc/badges/age/npm/mermaid/10.3.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/mermaid/10.3.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/mermaid/10.3.0/10.3.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/mermaid/10.3.0/10.3.1?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>mermaid-js/mermaid (mermaid)</summary> ### [`v10.3.1`](https://togithub.com/mermaid-js/mermaid/releases/tag/v10.3.1) [Compare Source](https://togithub.com/mermaid-js/mermaid/compare/v10.3.0...v10.3.1) #### What's Changed #### Bugfixes - fix style in contributors section of intro by [@​keer4n](https://togithub.com/keer4n) in [https://github.com/mermaid-js/mermaid/pull/4670](https://togithub.com/mermaid-js/mermaid/pull/4670) - fix: [#​4676](https://togithub.com/mermaid-js/mermaid/issues/4676) redirect fix by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4693](https://togithub.com/mermaid-js/mermaid/pull/4693) - [#​2139](https://togithub.com/mermaid-js/mermaid/issues/2139) Applying user defined classes properly when calculating shape width by [@​knsv](https://togithub.com/knsv) in [https://github.com/mermaid-js/mermaid/pull/4722](https://togithub.com/mermaid-js/mermaid/pull/4722) - Bug/4645 graph node containing keyword by [@​ibrahimWassouf](https://togithub.com/ibrahimWassouf) in [https://github.com/mermaid-js/mermaid/pull/4657](https://togithub.com/mermaid-js/mermaid/pull/4657) - fix: Remove triple parsing of diagrams by [@​sidharthv96](https://togithub.com/sidharthv96) in [https://github.com/mermaid-js/mermaid/pull/4697](https://togithub.com/mermaid-js/mermaid/pull/4697) - resolve info `HTML` and `Document` assignment by [@​Yokozuna59](https://togithub.com/Yokozuna59) in [https://github.com/mermaid-js/mermaid/pull/4514](https://togithub.com/mermaid-js/mermaid/pull/4514) - fix!(deps): fix zenuml style leakage. by [@​danshuitaihejie](https://togithub.com/danshuitaihejie) in [https://github.com/mermaid-js/mermaid/pull/4705](https://togithub.com/mermaid-js/mermaid/pull/4705) - Use our prettier config on the `packages/mermaid/src/config.type.ts` file by [@​aloisklink](https://togithub.com/aloisklink) in [https://github.com/mermaid-js/mermaid/pull/4715](https://togithub.com/mermaid-js/mermaid/pull/4715) - create `ParserDefinition` type by [@​Yokozuna59](https://togithub.com/Yokozuna59) in [https://github.com/mermaid-js/mermaid/pull/4719](https://togithub.com/mermaid-js/mermaid/pull/4719) - standardized `error` diagram by [@​Yokozuna59](https://togithub.com/Yokozuna59) in [https://github.com/mermaid-js/mermaid/pull/4718](https://togithub.com/mermaid-js/mermaid/pull/4718) #### Documentation - Docs: Directives not needed in new diagrams as yaml formatter does this for all new diagrams by [@​Incognito](https://togithub.com/Incognito) in [https://github.com/mermaid-js/mermaid/pull/4688](https://togithub.com/mermaid-js/mermaid/pull/4688) - Docs: add latest blog post by [@​huynhicode](https://togithub.com/huynhicode) in [https://github.com/mermaid-js/mermaid/pull/4668](https://togithub.com/mermaid-js/mermaid/pull/4668) - Lychee config by [@​mmorel-35](https://togithub.com/mmorel-35) in [https://github.com/mermaid-js/mermaid/pull/4699](https://togithub.com/mermaid-js/mermaid/pull/4699) - Syntax Update CONTRIBUTING.md by [@​soomrozaid](https://togithub.com/soomrozaid) in [https://github.com/mermaid-js/mermaid/pull/4713](https://togithub.com/mermaid-js/mermaid/pull/4713) #### Chores - chore(deps): update all minor dependencies (minor) by [@​renovate](https://togithub.com/renovate) in [https://github.com/mermaid-js/mermaid/pull/4682](https://togithub.com/mermaid-js/mermaid/pull/4682) - build(deps-dev): bump json5 from 2.2.1 to 2.2.3 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/mermaid-js/mermaid/pull/4685](https://togithub.com/mermaid-js/mermaid/pull/4685) - build(deps): bump [@​braintree/sanitize-url](https://togithub.com/braintree/sanitize-url) from 6.0.0 to 6.0.1 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/mermaid-js/mermaid/pull/4686](https://togithub.com/mermaid-js/mermaid/pull/4686) - build(deps-dev): bump vite from 4.3.3 to 4.3.9 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/mermaid-js/mermaid/pull/4687](https://togithub.com/mermaid-js/mermaid/pull/4687) - chore(deps): update all patch dependencies (patch) by [@​renovate](https://togithub.com/renovate) in [https://github.com/mermaid-js/mermaid/pull/4681](https://togithub.com/mermaid-js/mermaid/pull/4681) - chore: ts-ignore comment was misleading, JISON doesn't support types by [@​Incognito](https://togithub.com/Incognito) in [https://github.com/mermaid-js/mermaid/pull/4689](https://togithub.com/mermaid-js/mermaid/pull/4689) - chore(deps): unpin the dompurify dependency by [@​djadmin](https://togithub.com/djadmin) in [https://github.com/mermaid-js/mermaid/pull/4677](https://togithub.com/mermaid-js/mermaid/pull/4677) - build(deps-dev): bump pnpm from 8.3.1 to 8.6.8 by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/mermaid-js/mermaid/pull/4692](https://togithub.com/mermaid-js/mermaid/pull/4692) #### New Contributors - [@​keer4n](https://togithub.com/keer4n) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4670](https://togithub.com/mermaid-js/mermaid/pull/4670) - [@​djadmin](https://togithub.com/djadmin) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4677](https://togithub.com/mermaid-js/mermaid/pull/4677) - [@​danshuitaihejie](https://togithub.com/danshuitaihejie) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4705](https://togithub.com/mermaid-js/mermaid/pull/4705) - [@​soomrozaid](https://togithub.com/soomrozaid) made their first contribution in [https://github.com/mermaid-js/mermaid/pull/4713](https://togithub.com/mermaid-js/mermaid/pull/4713) **Full Changelog**: mermaid-js/mermaid@v10.3.0...v10.3.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/levaintech/contented). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi40MC4zIiwidXBkYXRlZEluVmVyIjoiMzYuNDMuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
📑 Summary
Many diagrams were parsed 2-3 times for each render. Removed that.
📏 Design Decisions
Moved the call to
init()
afterclear()
.📋 Tasks
Make sure you
MERMAID_RELEASE_VERSION
is used for all new features.develop
branch