Skip to content

Commit 44e4699

Browse files
committed
minor #54424 [WebProfilerBundle] Inline flowchart-only Mermaid version (MatTheCat)
This PR was merged into the 7.1 branch. Discussion ---------- [WebProfilerBundle] Inline flowchart-only Mermaid version | Q | A | ------------- | --- | Branch? | 7.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | Fix #54416 | License | MIT From mermaid-js/mermaid#2920 (comment) there is no official way to generate a diagram-specific script, but it is possible by patching the `packages/mermaid/src/diagram-api/diagram-orchestration.ts` file before building. This PR comes with a Makefile whose default recipe does so, and the `mermaid-flowchart-v2.min.js` file it generated from v10.9.0. Bumping the script’s version will require to update the Makefile’s `tag` variable to the corresponding `mermaid-js/mermaid`’s (from https://github.com/mermaid-js/mermaid/tags) and running `make`. The recipe depends on cURL, GNU tar, and pnpm. Commits ------- 32612e7 [WebProfilerBundle] Inline flowchart-only Mermaid version
2 parents 91dc097 + 32612e7 commit 44e4699

File tree

5 files changed

+519
-2
lines changed

5 files changed

+519
-2
lines changed

src/Symfony/Bundle/WebProfilerBundle/.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/phpunit.xml.dist export-ignore
33
/.gitattributes export-ignore
44
/.gitignore export-ignore
5+
/Resources/views/Script/Mermaid/Makefile export-ignore
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor/
22
composer.lock
33
phpunit.xml
4+
/Resources/views/Script/Mermaid/repo-*

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/workflow.html.twig

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@
132132
<p>There are no workflows configured.</p>
133133
</div>
134134
{% else %}
135-
<script type="module">
136-
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
135+
<script>
136+
{{ source('@WebProfiler/Script/Mermaid/mermaid-flowchart-v2.min.js') }}
137137
const isDarkMode = document.querySelector('body').classList.contains('theme-dark');
138138
mermaid.initialize({
139139
flowchart: { useMaxWidth: false },
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
define diagram-orchestration
2+
import { diagram as flowchartV2 } from '../diagrams/flowchart/flowDiagram-v2.js';
3+
import { registerDiagram } from './diagramAPI.js';
4+
5+
let hasLoadedDiagrams = false;
6+
export const addDiagrams = () => {
7+
if (hasLoadedDiagrams) {
8+
return;
9+
}
10+
hasLoadedDiagrams = true;
11+
registerDiagram('flowchart-v2', flowchartV2, () => true);
12+
};
13+
endef
14+
15+
override tag := v10.9.0
16+
17+
.PHONY: mermaid-flowchart-v2.min.js
18+
mermaid-flowchart-v2.min.js: | repo-$(tag)/node_modules
19+
$(file >repo-$(tag)/packages/mermaid/src/diagram-api/diagram-orchestration.ts,$(diagram-orchestration))
20+
pnpm -C repo-$(tag) run build
21+
cp repo-$(tag)/packages/mermaid/dist/mermaid.min.js $@
22+
23+
repo-$(tag)/node_modules: | repo-$(tag)
24+
pnpm -C $(@D) install --ignore-scripts
25+
26+
.SECONDARY: repo-$(tag)
27+
repo-$(tag):
28+
curl -fL https://github.com/mermaid-js/mermaid/archive/refs/tags/$(tag).tar.gz | tar -xz --strip-components=1 --one-top-level=$@
29+
30+
.PHONY: clean
31+
clean:
32+
rm -rf ./repo-*

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Script/Mermaid/mermaid-flowchart-v2.min.js

+483
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)