mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-15 06:19:24 +02:00
Merge branch 'develop' into fix-connection-gaps-in-flowchart-shapes
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user