Skip to content
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

feat: Add packet diagram #4839

Merged
merged 31 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c41594d
feat: Add packet diagram
sidharthv96 Sep 14, 2023
afd7cf5
fix: Types and nomenclature
sidharthv96 Sep 14, 2023
38d9c6d
test: Add unit tests
sidharthv96 Sep 14, 2023
75f1f92
test: Add rendering tests
sidharthv96 Sep 14, 2023
043729f
feat: Support showBits
sidharthv96 Sep 14, 2023
136f1c5
fix: Diagram DB types
sidharthv96 Sep 14, 2023
0ff3ba3
Add mini-live editing to example.html
sidharthv96 Sep 18, 2023
5661509
Add mini-live editing to example.html
sidharthv96 Sep 18, 2023
3e3519e
docs: Add packet to index
sidharthv96 Sep 19, 2023
ce6bfcb
Merge branch 'next' into feat/948_packetDiagram
sidharthv96 Nov 14, 2023
7c79bbd
refactor: Address review comments
sidharthv96 Nov 14, 2023
b88d1df
fix(packet): Grammar whitespace
sidharthv96 Nov 14, 2023
659db9f
chore: Add types and minimums for packet config
sidharthv96 Nov 14, 2023
9925b9b
feat: Add title support to packetDiagram
sidharthv96 Nov 14, 2023
1a8743e
refactor: Separate default options in styles
sidharthv96 Nov 14, 2023
068a74a
chore: Fix magic number
sidharthv96 Nov 14, 2023
fc400ea
fix: Langium formatting
sidharthv96 Nov 14, 2023
b6983e4
Add title to tests
sidharthv96 Nov 14, 2023
113a400
Add DiagramRenderer type
sidharthv96 Nov 14, 2023
f9df193
chore: Fix imports
sidharthv96 Nov 14, 2023
99313fe
fix editor build
sidharthv96 Nov 15, 2023
f15d24b
Merge branch 'next' into feat/948_packetDiagram
sidharthv96 Nov 15, 2023
0d7644c
refactor: Fix types
sidharthv96 Nov 15, 2023
088fc39
Fix SVG width
sidharthv96 Nov 15, 2023
784a853
feat: Add theming to packet
sidharthv96 Nov 15, 2023
480645d
fix: Add language to codeblock
sidharthv96 Nov 15, 2023
a8105f0
fix: Use configureSvgSize
sidharthv96 Nov 16, 2023
bca645f
test: Add packet and xychart into mermaidAPI test
sidharthv96 Nov 16, 2023
96ae4a5
chore: Remove unnecessary(?) mocks.
sidharthv96 Nov 16, 2023
7ef61d5
test: Add packet test for title, accTitle, accDescr
sidharthv96 Nov 16, 2023
5cc20b5
Merge branch 'next' into feat/948_packetDiagram
sidharthv96 Jan 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .build/jsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const MERMAID_CONFIG_DIAGRAM_KEYS = [
'gitGraph',
'c4',
'sankey',
'packet',
] as const;

/**
Expand Down
4 changes: 2 additions & 2 deletions .esbuild/build.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { build } from 'esbuild';
import { mkdir, writeFile } from 'node:fs/promises';
import { MermaidBuildOptions, defaultOptions, getBuildConfig } from './util.js';
import { packageOptions } from '../.build/common.js';
import { generateLangium } from '../.build/generateLangium.js';
import { MermaidBuildOptions, defaultOptions, getBuildConfig } from './util.js';

const shouldVisualize = process.argv.includes('--visualize');

Expand Down Expand Up @@ -56,7 +56,7 @@ const main = async () => {
await generateLangium();
await mkdir('stats').catch(() => {});
const packageNames = Object.keys(packageOptions) as (keyof typeof packageOptions)[];
// it should build `parser` before `mermaid` because it's a dependecy
// it should build `parser` before `mermaid` because it's a dependency
for (const pkg of packageNames) {
await buildPackage(pkg).catch(handler);
}
Expand Down
7 changes: 4 additions & 3 deletions .esbuild/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { generateLangium } from '../.build/generateLangium.js';
const parserCtx = await context(
getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: 'parser' })
);
const mermaidCtx = await context(
getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: 'mermaid' })
);
const mermaidCtx = await context({
...getBuildConfig({ ...defaultOptions, minify: false, core: false, entryName: 'mermaid' }),
sourcemap: 'linked',
});
const mermaidIIFECtx = await context(
getBuildConfig({
...defaultOptions,
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Make sure you

- [ ] :book: have read the [contribution guidelines](https://github.com/mermaid-js/mermaid/blob/develop/CONTRIBUTING.md)
- [ ] :computer: have added necessary unit/e2e tests.
- [ ] :notebook: have added documentation. Make sure [`MERMAID_RELEASE_VERSION`](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/community/development.md#3-update-documentation) is used for all new features.
- [ ] :notebook: have added documentation. Make sure [`MERMAID_RELEASE_VERSION`](https://github.com/mermaid-js/mermaid/blob/develop/packages/mermaid/src/docs/community/code.md#3-update-documentation) is used for all new features.
- [ ] :bookmark: targeted `develop` branch
21 changes: 0 additions & 21 deletions __mocks__/c4Renderer.js

This file was deleted.

16 changes: 0 additions & 16 deletions __mocks__/classRenderer-v2.js

This file was deleted.

13 changes: 0 additions & 13 deletions __mocks__/classRenderer.js

This file was deleted.

1 change: 0 additions & 1 deletion __mocks__/dagre-d3.ts

This file was deleted.

3 changes: 0 additions & 3 deletions __mocks__/entity-decode/browser.ts

This file was deleted.

16 changes: 0 additions & 16 deletions __mocks__/erRenderer.js

This file was deleted.

24 changes: 0 additions & 24 deletions __mocks__/flowRenderer-v2.js

This file was deleted.

16 changes: 0 additions & 16 deletions __mocks__/ganttRenderer.js

This file was deleted.

13 changes: 0 additions & 13 deletions __mocks__/gitGraphRenderer.js

This file was deleted.

15 changes: 0 additions & 15 deletions __mocks__/journeyRenderer.js

This file was deleted.

8 changes: 0 additions & 8 deletions __mocks__/pieRenderer.ts

This file was deleted.

13 changes: 0 additions & 13 deletions __mocks__/requirementRenderer.js

This file was deleted.

13 changes: 0 additions & 13 deletions __mocks__/sankeyRenderer.js

This file was deleted.

23 changes: 0 additions & 23 deletions __mocks__/sequenceRenderer.js

This file was deleted.

22 changes: 0 additions & 22 deletions __mocks__/stateRenderer-v2.js

This file was deleted.

67 changes: 67 additions & 0 deletions cypress/integration/rendering/packet.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { imgSnapshotTest } from '../../helpers/util';

describe('packet structure', () => {
it('should render a simple packet diagram', () => {
imgSnapshotTest(
`packet-beta
title Hello world
0-10: "hello"
`
);
});

it('should render a complex packet diagram', () => {
imgSnapshotTest(
`packet-beta
0-15: "Source Port"
16-31: "Destination Port"
32-63: "Sequence Number"
64-95: "Acknowledgment Number"
96-99: "Data Offset"
100-105: "Reserved"
106: "URG"
107: "ACK"
108: "PSH"
109: "RST"
110: "SYN"
111: "FIN"
112-127: "Window"
128-143: "Checksum"
144-159: "Urgent Pointer"
160-191: "(Options and Padding)"
192-223: "data"
`
);
});

it('should render a complex packet diagram with showBits false', () => {
imgSnapshotTest(
`
---
title: "Packet Diagram"
config:
packet:
showBits: false
---
packet-beta
0-15: "Source Port"
16-31: "Destination Port"
32-63: "Sequence Number"
64-95: "Acknowledgment Number"
96-99: "Data Offset"
100-105: "Reserved"
106: "URG"
107: "ACK"
108: "PSH"
109: "RST"
110: "SYN"
111: "FIN"
112-127: "Window"
128-143: "Checksum"
144-159: "Urgent Pointer"
160-191: "(Options and Padding)"
192-223: "data"
`
);
});
});
Loading
Loading