mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-16 06:49:31 +02:00
Merge branch 'develop' into 6584-piechart-zero-negative-values
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
|
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.
|
26
.github/workflows/pr-labeler.yml
vendored
26
.github/workflows/pr-labeler.yml
vendored
@@ -29,3 +29,29 @@ jobs:
|
|||||||
disable-releaser: true
|
disable-releaser: true
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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';
|
import { imgSnapshotTest } from '../../helpers/util';
|
||||||
|
|
||||||
describe('packet structure', () => {
|
describe('packet structure', () => {
|
||||||
it('should render a simple packet diagram', () => {
|
it('should render a simple packet-beta diagram', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`packet-beta
|
`packet-beta
|
||||||
title Hello world
|
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', () => {
|
it('should render a simple packet diagram without ranges', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`packet-beta
|
`packet
|
||||||
0: "h"
|
0: "h"
|
||||||
1: "i"
|
1: "i"
|
||||||
`
|
`
|
||||||
@@ -21,7 +30,7 @@ describe('packet structure', () => {
|
|||||||
|
|
||||||
it('should render a complex packet diagram', () => {
|
it('should render a complex packet diagram', () => {
|
||||||
imgSnapshotTest(
|
imgSnapshotTest(
|
||||||
`packet-beta
|
`packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
@@ -52,7 +61,7 @@ describe('packet structure', () => {
|
|||||||
packet:
|
packet:
|
||||||
showBits: false
|
showBits: false
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" />
|
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" />
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
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
|
<link
|
||||||
href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css"
|
href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css"
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
<div class="diagrams">
|
<div class="diagrams">
|
||||||
<pre class="mermaid">
|
<pre class="mermaid">
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
packet:
|
packet:
|
||||||
showBits: false
|
showBits: false
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
@@ -70,7 +70,7 @@
|
|||||||
config:
|
config:
|
||||||
theme: forest
|
theme: forest
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
title Forest theme
|
title Forest theme
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
@@ -97,7 +97,7 @@
|
|||||||
config:
|
config:
|
||||||
theme: dark
|
theme: dark
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
title Dark theme
|
title Dark theme
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
|
@@ -17,7 +17,7 @@ This diagram type is particularly useful for developers, network engineers, educ
|
|||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```
|
```
|
||||||
packet-beta
|
packet
|
||||||
start: "Block name" %% Single-bit block
|
start: "Block name" %% Single-bit block
|
||||||
start-end: "Block name" %% Multi-bit blocks
|
start-end: "Block name" %% Multi-bit blocks
|
||||||
... More Fields ...
|
... 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:
|
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
|
+1: "Block name" %% Single-bit block
|
||||||
+8: "Block name" %% 8-bit block
|
+8: "Block name" %% 8-bit block
|
||||||
9-15: "Manually set start and end, it's fine to mix and match"
|
9-15: "Manually set start and end, it's fine to mix and match"
|
||||||
@@ -41,7 +41,7 @@ packet-beta
|
|||||||
---
|
---
|
||||||
title: "TCP Packet"
|
title: "TCP Packet"
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
@@ -65,7 +65,7 @@ packet-beta
|
|||||||
---
|
---
|
||||||
title: "TCP Packet"
|
title: "TCP Packet"
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
@@ -86,7 +86,7 @@ packet-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
packet-beta
|
packet
|
||||||
title UDP Packet
|
title UDP Packet
|
||||||
+16: "Source Port"
|
+16: "Source Port"
|
||||||
+16: "Destination Port"
|
+16: "Destination Port"
|
||||||
@@ -96,7 +96,7 @@ title UDP Packet
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
packet-beta
|
packet
|
||||||
title UDP Packet
|
title UDP Packet
|
||||||
+16: "Source Port"
|
+16: "Source Port"
|
||||||
+16: "Destination Port"
|
+16: "Destination Port"
|
||||||
@@ -144,7 +144,7 @@ config:
|
|||||||
packet:
|
packet:
|
||||||
startByteColor: red
|
startByteColor: red
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
|
12
package.json
12
package.json
@@ -83,12 +83,12 @@
|
|||||||
"@vitest/spy": "^3.0.6",
|
"@vitest/spy": "^3.0.6",
|
||||||
"@vitest/ui": "^3.0.6",
|
"@vitest/ui": "^3.0.6",
|
||||||
"ajv": "^8.17.1",
|
"ajv": "^8.17.1",
|
||||||
"chokidar": "3.6.0",
|
"chokidar": "4.0.3",
|
||||||
"concurrently": "^9.1.2",
|
"concurrently": "^9.1.2",
|
||||||
"cors": "^2.8.5",
|
"cors": "^2.8.5",
|
||||||
"cpy-cli": "^5.0.0",
|
"cpy-cli": "^5.0.0",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"cspell": "^8.6.1",
|
"cspell": "^9.1.3",
|
||||||
"cypress": "^14.0.3",
|
"cypress": "^14.0.3",
|
||||||
"cypress-image-snapshot": "^4.0.1",
|
"cypress-image-snapshot": "^4.0.1",
|
||||||
"cypress-split": "^1.24.14",
|
"cypress-split": "^1.24.14",
|
||||||
@@ -109,25 +109,25 @@
|
|||||||
"globals": "^16.0.0",
|
"globals": "^16.0.0",
|
||||||
"globby": "^14.0.2",
|
"globby": "^14.0.2",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"jest": "^29.7.0",
|
"jest": "^30.0.4",
|
||||||
"jison": "^0.4.18",
|
"jison": "^0.4.18",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"jsdom": "^26.0.0",
|
"jsdom": "^26.0.0",
|
||||||
"langium-cli": "3.3.0",
|
"langium-cli": "3.3.0",
|
||||||
"lint-staged": "^15.2.11",
|
"lint-staged": "^16.1.2",
|
||||||
"markdown-table": "^3.0.4",
|
"markdown-table": "^3.0.4",
|
||||||
"nyc": "^17.1.0",
|
"nyc": "^17.1.0",
|
||||||
"path-browserify": "^1.0.1",
|
"path-browserify": "^1.0.1",
|
||||||
"prettier": "^3.5.2",
|
"prettier": "^3.5.2",
|
||||||
"prettier-plugin-jsdoc": "^1.3.2",
|
"prettier-plugin-jsdoc": "^1.3.2",
|
||||||
"rimraf": "^6.0.1",
|
"rimraf": "^6.0.1",
|
||||||
"rollup-plugin-visualizer": "^5.14.0",
|
"rollup-plugin-visualizer": "^6.0.3",
|
||||||
"start-server-and-test": "^2.0.10",
|
"start-server-and-test": "^2.0.10",
|
||||||
"tslib": "^2.8.1",
|
"tslib": "^2.8.1",
|
||||||
"tsx": "^4.7.3",
|
"tsx": "^4.7.3",
|
||||||
"typescript": "~5.7.3",
|
"typescript": "~5.7.3",
|
||||||
"typescript-eslint": "^8.32.0",
|
"typescript-eslint": "^8.32.0",
|
||||||
"vite": "^6.1.1",
|
"vite": "^7.0.3",
|
||||||
"vite-plugin-istanbul": "^7.0.0",
|
"vite-plugin-istanbul": "^7.0.0",
|
||||||
"vitest": "^3.0.6"
|
"vitest": "^3.0.6"
|
||||||
},
|
},
|
||||||
|
@@ -11,7 +11,7 @@ export default {
|
|||||||
code: `---
|
code: `---
|
||||||
title: "TCP Packet"
|
title: "TCP Packet"
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
|
@@ -82,7 +82,7 @@
|
|||||||
"katex": "^0.16.9",
|
"katex": "^0.16.9",
|
||||||
"khroma": "^2.1.0",
|
"khroma": "^2.1.0",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
"marked": "^15.0.7",
|
"marked": "^16.0.0",
|
||||||
"roughjs": "^4.6.6",
|
"roughjs": "^4.6.6",
|
||||||
"stylis": "^4.3.6",
|
"stylis": "^4.3.6",
|
||||||
"ts-dedent": "^2.2.0",
|
"ts-dedent": "^2.2.0",
|
||||||
@@ -105,7 +105,7 @@
|
|||||||
"@types/stylis": "^4.2.7",
|
"@types/stylis": "^4.2.7",
|
||||||
"@types/uuid": "^10.0.0",
|
"@types/uuid": "^10.0.0",
|
||||||
"ajv": "^8.17.1",
|
"ajv": "^8.17.1",
|
||||||
"chokidar": "3.6.0",
|
"chokidar": "4.0.3",
|
||||||
"concurrently": "^9.1.2",
|
"concurrently": "^9.1.2",
|
||||||
"csstree-validator": "^4.0.1",
|
"csstree-validator": "^4.0.1",
|
||||||
"globby": "^14.0.2",
|
"globby": "^14.0.2",
|
||||||
|
@@ -287,7 +287,7 @@ const setBlock = (block: Block) => {
|
|||||||
blockDatabase.set(block.id, block);
|
blockDatabase.set(block.id, block);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getLogger = () => console;
|
const getLogger = () => log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all of the style classes
|
* Return all of the style classes
|
||||||
|
@@ -7,7 +7,7 @@ import type {
|
|||||||
const id = 'packet';
|
const id = 'packet';
|
||||||
|
|
||||||
const detector: DiagramDetector = (txt) => {
|
const detector: DiagramDetector = (txt) => {
|
||||||
return /^\s*packet-beta/.test(txt);
|
return /^\s*packet(-beta)?/.test(txt);
|
||||||
};
|
};
|
||||||
|
|
||||||
const loader: DiagramLoader = async () => {
|
const loader: DiagramLoader = async () => {
|
||||||
|
@@ -15,8 +15,14 @@ describe('packet diagrams', () => {
|
|||||||
expect(getPacket()).toMatchInlineSnapshot('[]');
|
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 () => {
|
it('should handle diagram with data and title', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
title Packet diagram
|
title Packet diagram
|
||||||
accTitle: Packet accTitle
|
accTitle: Packet accTitle
|
||||||
accDescr: Packet accDescription
|
accDescr: Packet accDescription
|
||||||
@@ -41,7 +47,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle single bits', async () => {
|
it('should handle single bits', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
0-10: "test"
|
0-10: "test"
|
||||||
11: "single"
|
11: "single"
|
||||||
`;
|
`;
|
||||||
@@ -67,7 +73,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle bit counts', async () => {
|
it('should handle bit counts', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
+8: "byte"
|
+8: "byte"
|
||||||
+16: "word"
|
+16: "word"
|
||||||
`;
|
`;
|
||||||
@@ -93,7 +99,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should handle bit counts with bit or bits', async () => {
|
it('should handle bit counts with bit or bits', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
+8: "byte"
|
+8: "byte"
|
||||||
+16: "word"
|
+16: "word"
|
||||||
`;
|
`;
|
||||||
@@ -119,7 +125,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should split into multiple rows', async () => {
|
it('should split into multiple rows', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
0-10: "test"
|
0-10: "test"
|
||||||
11-90: "multiple"
|
11-90: "multiple"
|
||||||
`;
|
`;
|
||||||
@@ -161,7 +167,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should split into multiple rows when cut at exact length', async () => {
|
it('should split into multiple rows when cut at exact length', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
0-16: "test"
|
0-16: "test"
|
||||||
17-63: "multiple"
|
17-63: "multiple"
|
||||||
`;
|
`;
|
||||||
@@ -195,7 +201,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if numbers are not continuous', async () => {
|
it('should throw error if numbers are not continuous', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
0-16: "test"
|
0-16: "test"
|
||||||
18-20: "error"
|
18-20: "error"
|
||||||
`;
|
`;
|
||||||
@@ -205,7 +211,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if numbers are not continuous with bit counts', async () => {
|
it('should throw error if numbers are not continuous with bit counts', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
+16: "test"
|
+16: "test"
|
||||||
18-20: "error"
|
18-20: "error"
|
||||||
`;
|
`;
|
||||||
@@ -215,7 +221,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if numbers are not continuous for single packets', async () => {
|
it('should throw error if numbers are not continuous for single packets', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
0-16: "test"
|
0-16: "test"
|
||||||
18: "error"
|
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 () => {
|
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"
|
+16: "test"
|
||||||
18: "error"
|
18: "error"
|
||||||
`;
|
`;
|
||||||
@@ -235,7 +241,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if numbers are not continuous for single packets - 2', async () => {
|
it('should throw error if numbers are not continuous for single packets - 2', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
0-16: "test"
|
0-16: "test"
|
||||||
17: "good"
|
17: "good"
|
||||||
19: "error"
|
19: "error"
|
||||||
@@ -246,7 +252,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if end is less than start', async () => {
|
it('should throw error if end is less than start', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
0-16: "test"
|
0-16: "test"
|
||||||
25-20: "error"
|
25-20: "error"
|
||||||
`;
|
`;
|
||||||
@@ -256,7 +262,7 @@ describe('packet diagrams', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if bit count is 0', async () => {
|
it('should throw error if bit count is 0', async () => {
|
||||||
const str = `packet-beta
|
const str = `packet
|
||||||
+0: "test"
|
+0: "test"
|
||||||
`;
|
`;
|
||||||
await expect(parser.parse(str)).rejects.toThrowErrorMatchingInlineSnapshot(
|
await expect(parser.parse(str)).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||||
|
@@ -28,8 +28,7 @@ interface TimelineTask {
|
|||||||
export const draw = function (text: string, id: string, version: string, diagObj: Diagram) {
|
export const draw = function (text: string, id: string, version: string, diagObj: Diagram) {
|
||||||
//1. Fetch the configuration
|
//1. Fetch the configuration
|
||||||
const conf = getConfig();
|
const conf = getConfig();
|
||||||
// @ts-expect-error - wrong config?
|
const LEFT_MARGIN = conf.timeline?.leftMargin ?? 50;
|
||||||
const LEFT_MARGIN = conf.leftMargin ?? 50;
|
|
||||||
|
|
||||||
log.debug('timeline', diagObj.db);
|
log.debug('timeline', diagObj.db);
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
"@iconify-json/carbon": "^1.1.37",
|
"@iconify-json/carbon": "^1.1.37",
|
||||||
"@unocss/reset": "^66.0.0",
|
"@unocss/reset": "^66.0.0",
|
||||||
"@vite-pwa/vitepress": "^1.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",
|
"fast-glob": "^3.3.3",
|
||||||
"https-localhost": "^4.7.1",
|
"https-localhost": "^4.7.1",
|
||||||
"pathe": "^2.0.3",
|
"pathe": "^2.0.3",
|
||||||
|
@@ -11,7 +11,7 @@ This diagram type is particularly useful for developers, network engineers, educ
|
|||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```
|
```
|
||||||
packet-beta
|
packet
|
||||||
start: "Block name" %% Single-bit block
|
start: "Block name" %% Single-bit block
|
||||||
start-end: "Block name" %% Multi-bit blocks
|
start-end: "Block name" %% Multi-bit blocks
|
||||||
... More Fields ...
|
... 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:
|
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
|
+1: "Block name" %% Single-bit block
|
||||||
+8: "Block name" %% 8-bit block
|
+8: "Block name" %% 8-bit block
|
||||||
9-15: "Manually set start and end, it's fine to mix and match"
|
9-15: "Manually set start and end, it's fine to mix and match"
|
||||||
@@ -35,7 +35,7 @@ packet-beta
|
|||||||
---
|
---
|
||||||
title: "TCP Packet"
|
title: "TCP Packet"
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
@@ -56,7 +56,7 @@ packet-beta
|
|||||||
```
|
```
|
||||||
|
|
||||||
```mermaid-example
|
```mermaid-example
|
||||||
packet-beta
|
packet
|
||||||
title UDP Packet
|
title UDP Packet
|
||||||
+16: "Source Port"
|
+16: "Source Port"
|
||||||
+16: "Destination Port"
|
+16: "Destination Port"
|
||||||
@@ -104,7 +104,7 @@ config:
|
|||||||
packet:
|
packet:
|
||||||
startByteColor: red
|
startByteColor: red
|
||||||
---
|
---
|
||||||
packet-beta
|
packet
|
||||||
0-15: "Source Port"
|
0-15: "Source Port"
|
||||||
16-31: "Destination Port"
|
16-31: "Destination Port"
|
||||||
32-63: "Sequence Number"
|
32-63: "Sequence Number"
|
||||||
|
@@ -794,6 +794,7 @@ graph TD;A--x|text including URL space|B;`)
|
|||||||
{ textDiagramType: 'gantt', expectedType: 'gantt' },
|
{ textDiagramType: 'gantt', expectedType: 'gantt' },
|
||||||
{ textDiagramType: 'journey', expectedType: 'journey' },
|
{ textDiagramType: 'journey', expectedType: 'journey' },
|
||||||
{ textDiagramType: 'pie', expectedType: 'pie' },
|
{ textDiagramType: 'pie', expectedType: 'pie' },
|
||||||
|
{ textDiagramType: 'packet', expectedType: 'packet' },
|
||||||
{ textDiagramType: 'packet-beta', expectedType: 'packet' },
|
{ textDiagramType: 'packet-beta', expectedType: 'packet' },
|
||||||
{ textDiagramType: 'xychart-beta', expectedType: 'xychart' },
|
{ textDiagramType: 'xychart-beta', expectedType: 'xychart' },
|
||||||
{ textDiagramType: 'requirementDiagram', expectedType: 'requirement' },
|
{ textDiagramType: 'requirementDiagram', expectedType: 'requirement' },
|
||||||
|
@@ -17,7 +17,7 @@ export async function note<T extends SVGGraphicsElement>(
|
|||||||
if (!useHtmlLabels) {
|
if (!useHtmlLabels) {
|
||||||
node.centerLabel = true;
|
node.centerLabel = true;
|
||||||
}
|
}
|
||||||
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
|
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
|
||||||
const totalWidth = Math.max(bbox.width + (node.padding ?? 0) * 2, node?.width ?? 0);
|
const totalWidth = Math.max(bbox.width + (node.padding ?? 0) * 2, node?.width ?? 0);
|
||||||
const totalHeight = Math.max(bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0);
|
const totalHeight = Math.max(bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0);
|
||||||
const x = -totalWidth / 2;
|
const x = -totalWidth / 2;
|
||||||
@@ -50,6 +50,11 @@ export async function note<T extends SVGGraphicsElement>(
|
|||||||
rect.selectAll('path').attr('style', nodeStyles);
|
rect.selectAll('path').attr('style', nodeStyles);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
label.attr(
|
||||||
|
'transform',
|
||||||
|
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${-(bbox.height / 2) - (bbox.y - (bbox.top ?? 0))})`
|
||||||
|
);
|
||||||
|
|
||||||
updateNodeBounds(node, rect);
|
updateNodeBounds(node, rect);
|
||||||
|
|
||||||
node.intersect = function (point) {
|
node.intersect = function (point) {
|
||||||
|
@@ -3,7 +3,7 @@ import "../common/common";
|
|||||||
|
|
||||||
entry Packet:
|
entry Packet:
|
||||||
NEWLINE*
|
NEWLINE*
|
||||||
"packet-beta"
|
("packet"| "packet-beta")
|
||||||
(
|
(
|
||||||
TitleAndAccessibilities
|
TitleAndAccessibilities
|
||||||
| blocks+=PacketBlock
|
| blocks+=PacketBlock
|
||||||
|
@@ -2,6 +2,6 @@ import { AbstractMermaidTokenBuilder } from '../common/index.js';
|
|||||||
|
|
||||||
export class PacketTokenBuilder extends AbstractMermaidTokenBuilder {
|
export class PacketTokenBuilder extends AbstractMermaidTokenBuilder {
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super(['packet-beta']);
|
super(['packet']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -11,6 +11,12 @@ describe('packet', () => {
|
|||||||
`
|
`
|
||||||
\tpacket-beta
|
\tpacket-beta
|
||||||
`,
|
`,
|
||||||
|
`packet`,
|
||||||
|
` packet `,
|
||||||
|
`\tpacket\t`,
|
||||||
|
`
|
||||||
|
\tpacket
|
||||||
|
`,
|
||||||
])('should handle regular packet', (context: string) => {
|
])('should handle regular packet', (context: string) => {
|
||||||
const result = parse(context);
|
const result = parse(context);
|
||||||
expectNoErrorsOrAlternatives(result);
|
expectNoErrorsOrAlternatives(result);
|
||||||
|
@@ -32,15 +32,10 @@ const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => undefined)
|
|||||||
* @param result - the result `parse` function.
|
* @param result - the result `parse` function.
|
||||||
*/
|
*/
|
||||||
export function expectNoErrorsOrAlternatives(result: ParseResult) {
|
export function expectNoErrorsOrAlternatives(result: ParseResult) {
|
||||||
if (result.lexerErrors.length > 0) {
|
expect.soft(result.lexerErrors).toHaveLength(0);
|
||||||
// console.debug(result.lexerErrors);
|
expect.soft(result.parserErrors).toHaveLength(0);
|
||||||
}
|
// To see what the error is, in the logs.
|
||||||
if (result.parserErrors.length > 0) {
|
expect(result.lexerErrors[0]).toBeUndefined();
|
||||||
// console.debug(result.parserErrors);
|
|
||||||
}
|
|
||||||
expect(result.lexerErrors).toHaveLength(0);
|
|
||||||
expect(result.parserErrors).toHaveLength(0);
|
|
||||||
|
|
||||||
expect(consoleMock).not.toHaveBeenCalled();
|
expect(consoleMock).not.toHaveBeenCalled();
|
||||||
consoleMock.mockReset();
|
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