mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-18 15:56:43 +02:00
Merge branch 'develop' into fix-connection-gaps-in-flowchart-shapes
This commit is contained in:
7
.changeset/slimy-peaches-win.md
Normal file
7
.changeset/slimy-peaches-win.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'@mermaid-js/examples': patch
|
||||
'mermaid': patch
|
||||
'@mermaid-js/parser': patch
|
||||
---
|
||||
|
||||
chore: Move packet diagram out of beta
|
5
.changeset/tangy-ghosts-watch.md
Normal file
5
.changeset/tangy-ghosts-watch.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'mermaid': patch
|
||||
---
|
||||
|
||||
fix: adjust sequence diagram title positioning to prevent overlap with top border in Safari
|
7
.changeset/wild-areas-lick.md
Normal file
7
.changeset/wild-areas-lick.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'mermaid': patch
|
||||
---
|
||||
|
||||
fix(timeline): fix loading `leftMargin` from config
|
||||
|
||||
The `timeline.leftMargin` config value should now correctly control the size of the left margin, instead of being ignored.
|
2
.github/workflows/autofix.yml
vendored
2
.github/workflows/autofix.yml
vendored
@@ -42,4 +42,4 @@ jobs:
|
||||
working-directory: ./packages/mermaid
|
||||
run: pnpm run docs:build
|
||||
|
||||
- uses: autofix-ci/action@551dded8c6cc8a1054039c8bc0b8b48c51dfc6ef # main
|
||||
- uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27 # main
|
||||
|
26
.github/workflows/pr-labeler.yml
vendored
26
.github/workflows/pr-labeler.yml
vendored
@@ -29,3 +29,29 @@ jobs:
|
||||
disable-releaser: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Add "Sponsored by MermaidChart" label
|
||||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
script: |
|
||||
const prNumber = context.payload.pull_request.number;
|
||||
const { data: commits } = await github.rest.pulls.listCommits({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
pull_number: prNumber,
|
||||
});
|
||||
|
||||
const isSponsored = commits.every(
|
||||
(c) => c.commit.author.email?.endsWith('@mermaidchart.com')
|
||||
);
|
||||
|
||||
if (isSponsored) {
|
||||
console.log('PR is sponsored. Adding label.');
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: prNumber,
|
||||
labels: ['Sponsored by MermaidChart'],
|
||||
});
|
||||
}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { imgSnapshotTest } from '../../helpers/util';
|
||||
|
||||
describe('packet structure', () => {
|
||||
it('should render a simple packet diagram', () => {
|
||||
it('should render a simple packet-beta diagram', () => {
|
||||
imgSnapshotTest(
|
||||
`packet-beta
|
||||
title Hello world
|
||||
@@ -10,9 +10,18 @@ describe('packet structure', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should render a simple packet diagram', () => {
|
||||
imgSnapshotTest(
|
||||
`packet
|
||||
title Hello world
|
||||
0-10: "hello"
|
||||
`
|
||||
);
|
||||
});
|
||||
|
||||
it('should render a simple packet diagram without ranges', () => {
|
||||
imgSnapshotTest(
|
||||
`packet-beta
|
||||
`packet
|
||||
0: "h"
|
||||
1: "i"
|
||||
`
|
||||
@@ -21,7 +30,7 @@ describe('packet structure', () => {
|
||||
|
||||
it('should render a complex packet diagram', () => {
|
||||
imgSnapshotTest(
|
||||
`packet-beta
|
||||
`packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
@@ -52,7 +61,7 @@ describe('packet structure', () => {
|
||||
packet:
|
||||
showBits: false
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
|
@@ -4,7 +4,7 @@
|
||||
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
|
||||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/font-awesome.min.css"
|
||||
/>
|
||||
<link
|
||||
href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css"
|
||||
|
@@ -17,7 +17,7 @@
|
||||
|
||||
<div class="diagrams">
|
||||
<pre class="mermaid">
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
@@ -44,7 +44,7 @@
|
||||
packet:
|
||||
showBits: false
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
@@ -70,7 +70,7 @@
|
||||
config:
|
||||
theme: forest
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
title Forest theme
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
@@ -97,7 +97,7 @@
|
||||
config:
|
||||
theme: dark
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
title Dark theme
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
|
@@ -17,7 +17,7 @@ This diagram type is particularly useful for developers, network engineers, educ
|
||||
## Syntax
|
||||
|
||||
```
|
||||
packet-beta
|
||||
packet
|
||||
start: "Block name" %% Single-bit block
|
||||
start-end: "Block name" %% Multi-bit blocks
|
||||
... More Fields ...
|
||||
@@ -28,7 +28,7 @@ start-end: "Block name" %% Multi-bit blocks
|
||||
Using start and end bit counts can be difficult, especially when modifying a design. For this we add a bit count field, which starts from the end of the previous field automagically. Use `+<count>` to set the number of bits, thus:
|
||||
|
||||
```
|
||||
packet-beta
|
||||
packet
|
||||
+1: "Block name" %% Single-bit block
|
||||
+8: "Block name" %% 8-bit block
|
||||
9-15: "Manually set start and end, it's fine to mix and match"
|
||||
@@ -41,7 +41,7 @@ packet-beta
|
||||
---
|
||||
title: "TCP Packet"
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
@@ -65,7 +65,7 @@ packet-beta
|
||||
---
|
||||
title: "TCP Packet"
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
@@ -86,7 +86,7 @@ packet-beta
|
||||
```
|
||||
|
||||
```mermaid-example
|
||||
packet-beta
|
||||
packet
|
||||
title UDP Packet
|
||||
+16: "Source Port"
|
||||
+16: "Destination Port"
|
||||
@@ -96,7 +96,7 @@ title UDP Packet
|
||||
```
|
||||
|
||||
```mermaid
|
||||
packet-beta
|
||||
packet
|
||||
title UDP Packet
|
||||
+16: "Source Port"
|
||||
+16: "Destination Port"
|
||||
@@ -144,7 +144,7 @@ config:
|
||||
packet:
|
||||
startByteColor: red
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
|
12
package.json
12
package.json
@@ -83,12 +83,12 @@
|
||||
"@vitest/spy": "^3.0.6",
|
||||
"@vitest/ui": "^3.0.6",
|
||||
"ajv": "^8.17.1",
|
||||
"chokidar": "3.6.0",
|
||||
"chokidar": "4.0.3",
|
||||
"concurrently": "^9.1.2",
|
||||
"cors": "^2.8.5",
|
||||
"cpy-cli": "^5.0.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"cspell": "^8.6.1",
|
||||
"cspell": "^9.1.3",
|
||||
"cypress": "^14.0.3",
|
||||
"cypress-image-snapshot": "^4.0.1",
|
||||
"cypress-split": "^1.24.14",
|
||||
@@ -109,25 +109,25 @@
|
||||
"globals": "^16.0.0",
|
||||
"globby": "^14.0.2",
|
||||
"husky": "^9.1.7",
|
||||
"jest": "^29.7.0",
|
||||
"jest": "^30.0.4",
|
||||
"jison": "^0.4.18",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jsdom": "^26.0.0",
|
||||
"langium-cli": "3.3.0",
|
||||
"lint-staged": "^15.2.11",
|
||||
"lint-staged": "^16.1.2",
|
||||
"markdown-table": "^3.0.4",
|
||||
"nyc": "^17.1.0",
|
||||
"path-browserify": "^1.0.1",
|
||||
"prettier": "^3.5.2",
|
||||
"prettier-plugin-jsdoc": "^1.3.2",
|
||||
"rimraf": "^6.0.1",
|
||||
"rollup-plugin-visualizer": "^5.14.0",
|
||||
"rollup-plugin-visualizer": "^6.0.3",
|
||||
"start-server-and-test": "^2.0.10",
|
||||
"tslib": "^2.8.1",
|
||||
"tsx": "^4.7.3",
|
||||
"typescript": "~5.7.3",
|
||||
"typescript-eslint": "^8.32.0",
|
||||
"vite": "^6.1.1",
|
||||
"vite": "^7.0.3",
|
||||
"vite-plugin-istanbul": "^7.0.0",
|
||||
"vitest": "^3.0.6"
|
||||
},
|
||||
|
@@ -11,7 +11,7 @@ export default {
|
||||
code: `---
|
||||
title: "TCP Packet"
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
|
@@ -82,7 +82,7 @@
|
||||
"katex": "^0.16.9",
|
||||
"khroma": "^2.1.0",
|
||||
"lodash-es": "^4.17.21",
|
||||
"marked": "^15.0.7",
|
||||
"marked": "^16.0.0",
|
||||
"roughjs": "^4.6.6",
|
||||
"stylis": "^4.3.6",
|
||||
"ts-dedent": "^2.2.0",
|
||||
@@ -105,7 +105,7 @@
|
||||
"@types/stylis": "^4.2.7",
|
||||
"@types/uuid": "^10.0.0",
|
||||
"ajv": "^8.17.1",
|
||||
"chokidar": "3.6.0",
|
||||
"chokidar": "4.0.3",
|
||||
"concurrently": "^9.1.2",
|
||||
"csstree-validator": "^4.0.1",
|
||||
"globby": "^14.0.2",
|
||||
|
@@ -287,7 +287,7 @@ const setBlock = (block: Block) => {
|
||||
blockDatabase.set(block.id, block);
|
||||
};
|
||||
|
||||
const getLogger = () => console;
|
||||
const getLogger = () => log;
|
||||
|
||||
/**
|
||||
* Return all of the style classes
|
||||
|
@@ -7,7 +7,7 @@ import type {
|
||||
const id = 'packet';
|
||||
|
||||
const detector: DiagramDetector = (txt) => {
|
||||
return /^\s*packet-beta/.test(txt);
|
||||
return /^\s*packet(-beta)?/.test(txt);
|
||||
};
|
||||
|
||||
const loader: DiagramLoader = async () => {
|
||||
|
@@ -15,8 +15,14 @@ describe('packet diagrams', () => {
|
||||
expect(getPacket()).toMatchInlineSnapshot('[]');
|
||||
});
|
||||
|
||||
it('should handle a packet definition', async () => {
|
||||
const str = `packet`;
|
||||
await expect(parser.parse(str)).resolves.not.toThrow();
|
||||
expect(getPacket()).toMatchInlineSnapshot('[]');
|
||||
});
|
||||
|
||||
it('should handle diagram with data and title', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
title Packet diagram
|
||||
accTitle: Packet accTitle
|
||||
accDescr: Packet accDescription
|
||||
@@ -41,7 +47,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should handle single bits', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
0-10: "test"
|
||||
11: "single"
|
||||
`;
|
||||
@@ -67,7 +73,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should handle bit counts', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
+8: "byte"
|
||||
+16: "word"
|
||||
`;
|
||||
@@ -93,7 +99,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should handle bit counts with bit or bits', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
+8: "byte"
|
||||
+16: "word"
|
||||
`;
|
||||
@@ -119,7 +125,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should split into multiple rows', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
0-10: "test"
|
||||
11-90: "multiple"
|
||||
`;
|
||||
@@ -161,7 +167,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should split into multiple rows when cut at exact length', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
0-16: "test"
|
||||
17-63: "multiple"
|
||||
`;
|
||||
@@ -195,7 +201,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should throw error if numbers are not continuous', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
0-16: "test"
|
||||
18-20: "error"
|
||||
`;
|
||||
@@ -205,7 +211,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should throw error if numbers are not continuous with bit counts', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
+16: "test"
|
||||
18-20: "error"
|
||||
`;
|
||||
@@ -215,7 +221,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should throw error if numbers are not continuous for single packets', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
0-16: "test"
|
||||
18: "error"
|
||||
`;
|
||||
@@ -225,7 +231,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should throw error if numbers are not continuous for single packets with bit counts', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
+16: "test"
|
||||
18: "error"
|
||||
`;
|
||||
@@ -235,7 +241,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should throw error if numbers are not continuous for single packets - 2', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
0-16: "test"
|
||||
17: "good"
|
||||
19: "error"
|
||||
@@ -246,7 +252,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should throw error if end is less than start', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
0-16: "test"
|
||||
25-20: "error"
|
||||
`;
|
||||
@@ -256,7 +262,7 @@ describe('packet diagrams', () => {
|
||||
});
|
||||
|
||||
it('should throw error if bit count is 0', async () => {
|
||||
const str = `packet-beta
|
||||
const str = `packet
|
||||
+0: "test"
|
||||
`;
|
||||
await expect(parser.parse(str)).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
|
@@ -524,7 +524,7 @@ export const drawBox = function (elem, box, conf) {
|
||||
box.name,
|
||||
g,
|
||||
box.x,
|
||||
box.y + (box.textMaxHeight || 0) / 2,
|
||||
box.y + conf.boxTextMargin + (box.textMaxHeight || 0) / 2,
|
||||
box.width,
|
||||
0,
|
||||
{ class: 'text' },
|
||||
|
@@ -28,8 +28,7 @@ interface TimelineTask {
|
||||
export const draw = function (text: string, id: string, version: string, diagObj: Diagram) {
|
||||
//1. Fetch the configuration
|
||||
const conf = getConfig();
|
||||
// @ts-expect-error - wrong config?
|
||||
const LEFT_MARGIN = conf.leftMargin ?? 50;
|
||||
const LEFT_MARGIN = conf.timeline?.leftMargin ?? 50;
|
||||
|
||||
log.debug('timeline', diagObj.db);
|
||||
|
||||
|
@@ -27,7 +27,7 @@
|
||||
"@iconify-json/carbon": "^1.1.37",
|
||||
"@unocss/reset": "^66.0.0",
|
||||
"@vite-pwa/vitepress": "^1.0.0",
|
||||
"@vitejs/plugin-vue": "^5.0.5",
|
||||
"@vitejs/plugin-vue": "^6.0.0",
|
||||
"fast-glob": "^3.3.3",
|
||||
"https-localhost": "^4.7.1",
|
||||
"pathe": "^2.0.3",
|
||||
|
@@ -11,7 +11,7 @@ This diagram type is particularly useful for developers, network engineers, educ
|
||||
## Syntax
|
||||
|
||||
```
|
||||
packet-beta
|
||||
packet
|
||||
start: "Block name" %% Single-bit block
|
||||
start-end: "Block name" %% Multi-bit blocks
|
||||
... More Fields ...
|
||||
@@ -22,7 +22,7 @@ start-end: "Block name" %% Multi-bit blocks
|
||||
Using start and end bit counts can be difficult, especially when modifying a design. For this we add a bit count field, which starts from the end of the previous field automagically. Use `+<count>` to set the number of bits, thus:
|
||||
|
||||
```
|
||||
packet-beta
|
||||
packet
|
||||
+1: "Block name" %% Single-bit block
|
||||
+8: "Block name" %% 8-bit block
|
||||
9-15: "Manually set start and end, it's fine to mix and match"
|
||||
@@ -35,7 +35,7 @@ packet-beta
|
||||
---
|
||||
title: "TCP Packet"
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
@@ -56,7 +56,7 @@ packet-beta
|
||||
```
|
||||
|
||||
```mermaid-example
|
||||
packet-beta
|
||||
packet
|
||||
title UDP Packet
|
||||
+16: "Source Port"
|
||||
+16: "Destination Port"
|
||||
@@ -104,7 +104,7 @@ config:
|
||||
packet:
|
||||
startByteColor: red
|
||||
---
|
||||
packet-beta
|
||||
packet
|
||||
0-15: "Source Port"
|
||||
16-31: "Destination Port"
|
||||
32-63: "Sequence Number"
|
||||
|
@@ -794,6 +794,7 @@ graph TD;A--x|text including URL space|B;`)
|
||||
{ textDiagramType: 'gantt', expectedType: 'gantt' },
|
||||
{ textDiagramType: 'journey', expectedType: 'journey' },
|
||||
{ textDiagramType: 'pie', expectedType: 'pie' },
|
||||
{ textDiagramType: 'packet', expectedType: 'packet' },
|
||||
{ textDiagramType: 'packet-beta', expectedType: 'packet' },
|
||||
{ textDiagramType: 'xychart-beta', expectedType: 'xychart' },
|
||||
{ textDiagramType: 'requirementDiagram', expectedType: 'requirement' },
|
||||
|
@@ -3,7 +3,7 @@ import "../common/common";
|
||||
|
||||
entry Packet:
|
||||
NEWLINE*
|
||||
"packet-beta"
|
||||
("packet"| "packet-beta")
|
||||
(
|
||||
TitleAndAccessibilities
|
||||
| blocks+=PacketBlock
|
||||
|
@@ -2,6 +2,6 @@ import { AbstractMermaidTokenBuilder } from '../common/index.js';
|
||||
|
||||
export class PacketTokenBuilder extends AbstractMermaidTokenBuilder {
|
||||
public constructor() {
|
||||
super(['packet-beta']);
|
||||
super(['packet']);
|
||||
}
|
||||
}
|
||||
|
@@ -11,6 +11,12 @@ describe('packet', () => {
|
||||
`
|
||||
\tpacket-beta
|
||||
`,
|
||||
`packet`,
|
||||
` packet `,
|
||||
`\tpacket\t`,
|
||||
`
|
||||
\tpacket
|
||||
`,
|
||||
])('should handle regular packet', (context: string) => {
|
||||
const result = parse(context);
|
||||
expectNoErrorsOrAlternatives(result);
|
||||
|
@@ -32,15 +32,10 @@ const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => undefined)
|
||||
* @param result - the result `parse` function.
|
||||
*/
|
||||
export function expectNoErrorsOrAlternatives(result: ParseResult) {
|
||||
if (result.lexerErrors.length > 0) {
|
||||
// console.debug(result.lexerErrors);
|
||||
}
|
||||
if (result.parserErrors.length > 0) {
|
||||
// console.debug(result.parserErrors);
|
||||
}
|
||||
expect(result.lexerErrors).toHaveLength(0);
|
||||
expect(result.parserErrors).toHaveLength(0);
|
||||
|
||||
expect.soft(result.lexerErrors).toHaveLength(0);
|
||||
expect.soft(result.parserErrors).toHaveLength(0);
|
||||
// To see what the error is, in the logs.
|
||||
expect(result.lexerErrors[0]).toBeUndefined();
|
||||
expect(consoleMock).not.toHaveBeenCalled();
|
||||
consoleMock.mockReset();
|
||||
}
|
||||
|
2506
pnpm-lock.yaml
generated
2506
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user