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

v11 #5069

Merged
merged 242 commits into from
Mar 6, 2024
Merged

v11 #5069

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
242 commits
Select commit Hold shift + click to select a range
da7ff77
chore: Add esbuild (Breaking change)
sidharthv96 Aug 13, 2023
01b2f80
chore: Remove @vitest/coverage-c8
sidharthv96 Aug 13, 2023
9fb9bed
chore: Add live-reload
sidharthv96 Aug 13, 2023
fc99d9b
chore: Add build times to live reload
sidharthv96 Aug 13, 2023
170bbce
chore: Build at start
sidharthv96 Aug 13, 2023
77a1819
chore: Replace Date.now with console.time
sidharthv96 Aug 13, 2023
2ede244
chore: Minor comments
sidharthv96 Aug 13, 2023
8f44de6
chore: IIFE to cSpell
sidharthv96 Aug 13, 2023
b68f45e
chore: Split chunks into folders
sidharthv96 Aug 14, 2023
53669ef
chore: Add defaultOptions to server
sidharthv96 Aug 14, 2023
e26d987
chore: Split chunks into folders
sidharthv96 Aug 14, 2023
9cbebbb
chore: Split chunks into folders
sidharthv96 Aug 14, 2023
5c2a6b5
chore: Add analyzer comment
sidharthv96 Aug 14, 2023
4fd7a88
chore: Fix outfile names
sidharthv96 Aug 14, 2023
13852b7
Fix import
sidharthv96 Aug 14, 2023
9c1a47d
Merge pull request #4729 from mermaid-js/sidv/esbuildV11
sidharthv96 Aug 16, 2023
5d5c627
Merge branch 'develop' into next
sidharthv96 Aug 17, 2023
b26bcf1
chore: Fix minify
sidharthv96 Aug 17, 2023
86c9ee4
Merge pull request #4733 from mermaid-js/sidv/splitChunks
sidharthv96 Aug 17, 2023
bd23705
Merge branch 'develop' into next
sidharthv96 Aug 17, 2023
fe1a062
Fix minify undefined
sidharthv96 Aug 17, 2023
718d52a
chore: Move liveReload code into script.
sidharthv96 Aug 17, 2023
222d8ee
Merge remote-tracking branch 'upstream/develop' into next
Yokozuna59 Aug 19, 2023
6141722
feat: create `parser` package in `packages` directory
Yokozuna59 Aug 20, 2023
1559c2c
feat(parser): create `common` directory for langium parsers
Yokozuna59 Aug 20, 2023
1c24617
feat(parser): create `info` parser with exporting parser internals
Yokozuna59 Aug 20, 2023
963dd75
chore(parser): build `parser` package using `esbuild` and `vite`
Yokozuna59 Aug 20, 2023
82054bf
chore: make `parser` as optional in `ParserDefinition`
Yokozuna59 Aug 20, 2023
cbe9490
feat!: integrate `info` parser into `mermaid` package
Yokozuna59 Aug 20, 2023
fd731c5
Merge branch 'develop' into next
sidharthv96 Aug 20, 2023
6c0ef54
Merge branch 'next' into add-info-langium-parser
Yokozuna59 Aug 20, 2023
9cb62f4
remove duplicate `@types/d3-scale` dev dependency
Yokozuna59 Aug 20, 2023
8678cee
Merge pull request #4749 from Yokozuna59/remove-duplicate-dev-dependency
sidharthv96 Aug 20, 2023
6502496
Merge remote-tracking branch 'upstream/next' into add-info-langium-pa…
Yokozuna59 Aug 20, 2023
4ae361b
reorder `packages/parser` after `packages/mermaid/src/vitepress`
Yokozuna59 Aug 20, 2023
49c5f3b
feat(parser): create `pie` parser and export it
Yokozuna59 Aug 20, 2023
1c8e13b
feat: integrate `pir` parser into `mermaid` package
Yokozuna59 Aug 20, 2023
341db13
chore!: rename `D3Sections` type into `D3Section`
Yokozuna59 Aug 20, 2023
d0c36c0
chore!: change `addSection` header into `D3Section`
Yokozuna59 Aug 20, 2023
1d64549
fix(mermaid): mark `mermaid-parser` dependecy with `^`
Yokozuna59 Aug 20, 2023
83e47a7
fix: use `execFileSync` instead of `execSync` in `generateLangium`
Yokozuna59 Aug 20, 2023
cc6f896
chore: remove `./*` part from `exports` in `parser/package.json`
Yokozuna59 Aug 21, 2023
eb63568
chore: refactore `&&` into `if` in `populateCommonDb`
Yokozuna59 Aug 21, 2023
984a0e6
chore: add a comment illustrate why we build packages sequentially
Yokozuna59 Aug 21, 2023
205360c
fix: fix if statment logic checks if `parser` is not `undefined`
Yokozuna59 Aug 21, 2023
7dd0d12
Merge branch 'develop' into next
sidharthv96 Aug 22, 2023
156fbd1
Merge branch 'develop' into next
sidharthv96 Aug 22, 2023
f946c3d
Merge branch 'develop' into next
sidharthv96 Aug 22, 2023
3943301
Merge remote-tracking branch 'upstream/next' into add-info-langium-pa…
Yokozuna59 Aug 22, 2023
fc96ebe
build: update `langium` and `langium-cli` to `v2.0.1`
Yokozuna59 Aug 22, 2023
8d0ca2c
build: build `.langium` file using `generate` from `langium-cli`
Yokozuna59 Aug 22, 2023
24c8e57
docs(parser): create `packages/parser` README.md file
Yokozuna59 Aug 22, 2023
408910e
Merge branch 'develop' into next
sidharthv96 Aug 23, 2023
866909b
Merge branch 'develop' into next
sidharthv96 Aug 25, 2023
8186a54
chore: export `InfoModule` from `infoModule.ts`
Yokozuna59 Aug 26, 2023
f202770
Merge branch develop into next
Yokozuna59 Aug 26, 2023
91785b8
Merge branch 'next' into add-info-langium-parser
Yokozuna59 Aug 26, 2023
21539df
create `noErrorsOrAlternatives` parser helper function
Yokozuna59 Aug 26, 2023
dd284c0
Merge branch 'add-info-langium-parser' of https://github.com/Yokozuna…
Yokozuna59 Aug 26, 2023
458b90c
chore: run `pnpm lint:fix`
Yokozuna59 Aug 26, 2023
2b6a34e
chore: add `vitest` imports to `test-util.ts`
Yokozuna59 Aug 26, 2023
7ea3c64
chore: increase `test-util.ts` converage by returning `undefined`
Yokozuna59 Aug 26, 2023
9bcfba6
Merge branch 'develop' into next
sidharthv96 Aug 26, 2023
60ed7d3
chore: Increase heap size when building
sidharthv96 Aug 26, 2023
cd19829
Merge branch 'next' into pr/Yokozuna59/4727
sidharthv96 Aug 28, 2023
4d53136
chore: Add comment for `yy`.
sidharthv96 Aug 28, 2023
44b93c0
Merge pull request #4727 from Yokozuna59/add-info-langium-parser
sidharthv96 Aug 28, 2023
258dbf3
Merge branch 'next' into pr/Yokozuna59/4751
sidharthv96 Aug 28, 2023
146364a
chore: Fix imports
sidharthv96 Aug 28, 2023
dff404a
Update docs
sidharthv96 Aug 28, 2023
23fc7c2
Update packages/parser/src/language/pie/pieValueConverter.ts
Yokozuna59 Aug 28, 2023
5469a7e
Update packages/mermaid/src/diagrams/pie/pieParser.ts
Yokozuna59 Aug 28, 2023
795baed
chore: run `pnpm lint:fix`
Yokozuna59 Aug 28, 2023
84f3baf
Merge branch 'develop' into next
Yokozuna59 Sep 2, 2023
77ba7c9
test: rewrite some `config` vals to tighten types
aloisklink Sep 2, 2023
b48136d
refactor!: remove MermaidConfig type enum fallback
aloisklink Sep 2, 2023
fc229cf
Merge pull request #4803 from aloisklink/refactor/mermaid-config-limi…
sidharthv96 Sep 3, 2023
697ac18
Merge branch 'develop' into next
sidharthv96 Sep 3, 2023
0abb4f8
Merge branch develop into next
Yokozuna59 Sep 5, 2023
25f2d22
Merge branch 'develop' into next
sidharthv96 Sep 6, 2023
4342759
Merge branch 'develop' into next
sidharthv96 Sep 6, 2023
4ce2629
Merge branch 'develop' into next
sidharthv96 Sep 6, 2023
24d4384
chore: apply review suggestions
Yokozuna59 Sep 6, 2023
997c23b
Merge branch 'develop' into next
sidharthv96 Sep 8, 2023
7b29a38
chore: Fix type
sidharthv96 Sep 8, 2023
5aee43d
Merge branch 'develop' into next
sidharthv96 Sep 14, 2023
52b33f6
chore: Fix pnpm-lock
sidharthv96 Sep 14, 2023
271b779
refactor: Simplify TokenBuilder and ValueConverter
sidharthv96 Sep 14, 2023
fedbd48
Merge branch 'next' into pr/Yokozuna59/4751
sidharthv96 Sep 14, 2023
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
3c90894
Merge branch 'develop' into next
Yokozuna59 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
91eb824
Merge branch 'develop' into next
Yokozuna59 Sep 20, 2023
8c31db6
Merge branch 'next' into add-pie-langium-parser
Yokozuna59 Sep 20, 2023
3abe7cf
Merge branch 'develop' into next
sidharthv96 Oct 6, 2023
49a197e
chore: Update pnpm-lock
sidharthv96 Oct 6, 2023
0184403
build(deps): remove `langium-cli` from `packages/parser` to use the o…
Yokozuna59 Nov 3, 2023
6a4ad8a
build(deps): update `langium` and `langium-cli` to `v2.1.0`
Yokozuna59 Nov 3, 2023
55d7e9e
pref: remove `CommonLexer` and use `EOF`
Yokozuna59 Nov 3, 2023
7765afa
chore: allow comments to adjust keywords
Yokozuna59 Nov 3, 2023
fe2e46f
build(dev-deps): add `chevrotain` as a `devDependencies`
Yokozuna59 Nov 3, 2023
1cda376
chore(parser): rearrange rules to make imported rules at the beginning
Yokozuna59 Nov 3, 2023
922bb14
test: update all parser test cases
Yokozuna59 Nov 3, 2023
0a62691
remove unnecessary lines
Yokozuna59 Nov 3, 2023
58c7934
export necessary objects and types from `packages/parser`
Yokozuna59 Nov 3, 2023
53ef5c5
create `CommonTokenBuilder`
Yokozuna59 Nov 3, 2023
5ef0527
export all common `ValueConverter` and `TokenBuilder` and update imports
Yokozuna59 Nov 3, 2023
0c57433
Merge branch 'next' into add-pie-langium-parser
Yokozuna59 Nov 3, 2023
cf18803
fix: make `rearrangeRules` update the array itself
Yokozuna59 Nov 4, 2023
c62be1b
export necessary functions and types from `packages/parser`
Yokozuna59 Nov 4, 2023
f01971b
switch to `NEWLINE+` instead of `EOF` until next release of `langium`
Yokozuna59 Nov 4, 2023
cf22e30
rename abstract rules in common parser files
Yokozuna59 Nov 5, 2023
b836034
build(deps): update `langium` to `v2.1.1`
Yokozuna59 Nov 6, 2023
6102285
full switch to EOF
Yokozuna59 Nov 6, 2023
1d88ac4
enhance `title`, `accTitle`, and `accDescr` regexes
Yokozuna59 Nov 6, 2023
6ce543e
Merge branch 'develop' into next
sidharthv96 Nov 14, 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
4c43bae
Merge branch next into add-pie-langium-parser
Yokozuna59 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
510549f
Merge branch 'develop' into next
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
692a747
chore: apply review changes
Yokozuna59 Nov 15, 2023
e86f09a
Apply suggested style from code review
Yokozuna59 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
f0d6789
fix: Netlify build
sidharthv96 Nov 16, 2023
0fec0ef
5043 Move ELK to standalone package
sidharthv96 Nov 18, 2023
38b3a20
5043 Allow registered diagrams to be overridden.
sidharthv96 Nov 19, 2023
1be09df
Merge pull request #5050 from mermaid-js/sidv/splitELK2
sidharthv96 Nov 23, 2023
ac99eb5
Cleanup package.json
sidharthv96 Nov 23, 2023
5b7ba83
Merge branch 'sidv/splitELK' of https://github.com/mermaid-js/mermaid…
sidharthv96 Nov 23, 2023
4ec5783
chore: Optimize build:types
sidharthv96 Nov 23, 2023
30fe363
chore: Update pnpm-lock
sidharthv96 Nov 23, 2023
c294a0a
test: Add flowchart-elk overriding test
sidharthv96 Nov 23, 2023
fe7da97
fix flow elk test
sidharthv96 Nov 23, 2023
a2db4a4
Merge branch 'develop' into next
sidharthv96 Nov 24, 2023
94c3d7f
Merge branch 'next' into sidv/splitELK
sidharthv96 Nov 24, 2023
cbcd2cc
chore: Optimize dev server
sidharthv96 Nov 24, 2023
bcdd1c5
chore: Optimize dev server
sidharthv96 Nov 24, 2023
5eb1160
Turn off patch coverage
sidharthv96 Nov 24, 2023
6d49cd6
Merge pull request #5049 from mermaid-js/sidv/splitELK
sidharthv96 Nov 24, 2023
9ade49b
Version for rc release
sidharthv96 Nov 24, 2023
63890cc
Version for rc release
sidharthv96 Nov 24, 2023
bffbf87
Version for rc release
sidharthv96 Nov 24, 2023
733d6fe
Move mermaid-parser to @mermaid-js/parser
sidharthv96 Nov 26, 2023
fd0f519
Move mermaid-parser to @mermaid-js/parser
sidharthv96 Nov 26, 2023
b5e58f4
refactor: Convert flowDB to TS
sidharthv96 Nov 27, 2023
e7f7b6a
chore: Separate types
sidharthv96 Nov 27, 2023
aff69e5
chore: Fix bindFunctions type
sidharthv96 Nov 27, 2023
d7948a8
fix: Flatten Nodelist
sidharthv96 Nov 27, 2023
3145758
Convert flowDb.spec.js
sidharthv96 Nov 27, 2023
6026628
chore: Remove unused file
sidharthv96 Nov 27, 2023
65a08ef
chore: Cleanup types
sidharthv96 Nov 27, 2023
000b432
Merge branch 'develop' into next
sidharthv96 Dec 6, 2023
c3c7ccd
feat: Add diagramType to RenderResult and ParseResult #5117
sidharthv96 Dec 6, 2023
479188b
refactor: Change return type to retain partial backwards compatibility.
sidharthv96 Dec 6, 2023
6871ad0
test: Update tests
sidharthv96 Dec 6, 2023
60f92dc
Merge branch 'develop' into next
sidharthv96 Dec 7, 2023
867686f
refactor: Address review comments
sidharthv96 Dec 7, 2023
0bda748
Remove default properties before generating the config types
dsogari Dec 7, 2023
8873ffc
chore: Overload parse type to be more specific.
sidharthv96 Dec 8, 2023
aa4bfa0
chore: Fix import.meta.vitest warnings
sidharthv96 Dec 8, 2023
96c90b2
Merge branch 'next' into sidv/diagramType
sidharthv96 Dec 8, 2023
6f3c920
Update packages/mermaid/src/docs/config/usage.md
sidharthv96 Dec 8, 2023
4588039
Update docs
sidharthv96 Dec 8, 2023
b8470a4
chore: Add docs
sidharthv96 Dec 8, 2023
edf3291
Merge branch 'sidv/diagramType' of https://github.com/mermaid-js/merm…
sidharthv96 Dec 8, 2023
b9bc518
chore: Add docs
sidharthv96 Dec 8, 2023
d732a14
Merge branch 'next' into chore/5125-fix-duplicate-config-types
dsogari Dec 8, 2023
dc1b2a6
Merge pull request #5126 from diegosogari/chore/5125-fix-duplicate-co…
sidharthv96 Dec 10, 2023
ff6188b
Merge pull request #5118 from mermaid-js/sidv/diagramType
sidharthv96 Dec 10, 2023
c2ea23f
Merge branch next into add-pie-langium-parser
Yokozuna59 Dec 31, 2023
54a09ea
pref: remove `rearrangeRules` from `AbstractMermaidTokenBuilder`
Yokozuna59 Dec 31, 2023
526d2a6
Merge branch 'mermaid-js:develop' into add-pie-langium-parser
Yokozuna59 Jan 2, 2024
aab7631
Merge branch 'develop' into next
sidharthv96 Jan 16, 2024
58b6cf0
Merge branch 'develop' into next
sidharthv96 Jan 19, 2024
af72825
Merge branch 'next' into sidv/FlowDB_TS
sidharthv96 Jan 19, 2024
c11093f
Update packages/mermaid/src/diagrams/flowchart/flowDb.ts
sidharthv96 Jan 19, 2024
e8f6554
Fix merge error
sidharthv96 Jan 19, 2024
6261fce
Merge pull request #5077 from mermaid-js/sidv/FlowDB_TS
sidharthv96 Jan 19, 2024
832e3f5
Merge branch 'develop' into next
sidharthv96 Jan 19, 2024
c7eaee0
Merge branch next into add-sankey-langium-parser
Yokozuna59 Jan 20, 2024
0dcca35
Update docs
Yokozuna59 Jan 20, 2024
ba46747
Merge branch 'develop' into next
sidharthv96 Jan 23, 2024
5c46b98
Merge branch 'next' into pr/Yokozuna59/4751
sidharthv96 Jan 23, 2024
16968eb
Fix lint
sidharthv96 Jan 23, 2024
31e19a0
Fix applitools
sidharthv96 Jan 23, 2024
ce9a9db
Merge branch 'develop' into next
sidharthv96 Jan 23, 2024
5cc20b5
Merge branch 'next' into feat/948_packetDiagram
sidharthv96 Jan 23, 2024
b7c72cb
Merge pull request #4839 from mermaid-js/feat/948_packetDiagram
sidharthv96 Jan 23, 2024
52fdea0
refactor: Support async parsers
sidharthv96 Jan 24, 2024
ed7dbb1
refactor: Make parser.parse async
sidharthv96 Jan 24, 2024
f715863
Fix types
sidharthv96 Jan 24, 2024
442da6c
chore: Update tests
sidharthv96 Jan 24, 2024
47a6ce4
Update docs
Yokozuna59 Jan 20, 2024
55be75c
Merge branch next into add-pie-langium-parser
Yokozuna59 Jan 25, 2024
969e2c1
Merge pull request #5233 from mermaid-js/AsyncParse
sidharthv96 Jan 27, 2024
a2a9948
Merge branch 'mermaid-js:develop' into add-pie-langium-parser
Yokozuna59 Jan 27, 2024
72a6fad
Merge branch next into add-pie-langium-parser
Yokozuna59 Jan 27, 2024
191ea24
make pie parser async
Yokozuna59 Jan 27, 2024
b30d609
Merge branch 'add-pie-langium-parser' of github.com:Yokozuna59/mermai…
sidharthv96 Feb 11, 2024
e047755
Merge branch 'develop' into next
sidharthv96 Feb 11, 2024
eee0d4b
Update Deps
sidharthv96 Feb 11, 2024
48ff3b2
Merge branch 'next' into pr/Yokozuna59/4751
sidharthv96 Feb 11, 2024
00423ed
Fix config
sidharthv96 Feb 11, 2024
30b180d
Fix docs
sidharthv96 Feb 11, 2024
a344d88
Fix BlockDiagramConfig
sidharthv96 Feb 11, 2024
062176d
Merge branch 'next' into pr/Yokozuna59/4751
sidharthv96 Feb 11, 2024
25cd86f
Fix docs
sidharthv96 Feb 11, 2024
d11bfaa
Merge pull request #4751 from Yokozuna59/add-pie-langium-parser
sidharthv96 Feb 11, 2024
2b2bbe3
build(deps): update `langium` to `v3` and apply the required changes
Yokozuna59 Feb 29, 2024
5807d52
Merge branch 'develop' into next
sidharthv96 Mar 1, 2024
70df6bb
Merge branch 'develop' into next
sidharthv96 Mar 1, 2024
171a201
Merge branch 'next' into pr/Yokozuna59/5345
sidharthv96 Mar 1, 2024
70d2362
Merge pull request #5345 from Yokozuna59/update-langium-to-v3
sidharthv96 Mar 1, 2024
a43cd55
Merge branch 'develop' into next
sidharthv96 Mar 5, 2024
3340608
Merge branch 'develop' into next
sidharthv96 Mar 6, 2024
1659ace
Fix spelling
sidharthv96 Mar 6, 2024
7fec51f
chore: Remove unused imports in block
sidharthv96 Mar 6, 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
30 changes: 30 additions & 0 deletions .build/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Shared common options for both ESBuild and Vite
*/
export const packageOptions = {
parser: {
name: 'mermaid-parser',
packageName: 'parser',
file: 'index.ts',
},
mermaid: {
name: 'mermaid',
packageName: 'mermaid',
file: 'mermaid.ts',
},
'mermaid-example-diagram': {
name: 'mermaid-example-diagram',
packageName: 'mermaid-example-diagram',
file: 'detector.ts',
},
'mermaid-zenuml': {
name: 'mermaid-zenuml',
packageName: 'mermaid-zenuml',
file: 'detector.ts',
},
'mermaid-flowchart-elk': {
name: 'mermaid-flowchart-elk',
packageName: 'mermaid-flowchart-elk',
file: 'detector.ts',
},
} as const;
5 changes: 5 additions & 0 deletions .build/generateLangium.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { generate } from 'langium-cli';

export async function generateLangium() {
await generate({ file: `./packages/parser/langium-config.json` });
}
File renamed without changes.
124 changes: 124 additions & 0 deletions .build/jsonSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import { load, JSON_SCHEMA } from 'js-yaml';
import assert from 'node:assert';
import Ajv2019, { type JSONSchemaType } from 'ajv/dist/2019.js';
import type { MermaidConfig, BaseDiagramConfig } from '../packages/mermaid/src/config.type.js';

/**
* All of the keys in the mermaid config that have a mermaid diagram config.
*/
const MERMAID_CONFIG_DIAGRAM_KEYS = [
'flowchart',
'sequence',
'gantt',
'journey',
'class',
'state',
'er',
'pie',
'quadrantChart',
'xyChart',
'requirement',
'mindmap',
'timeline',
'gitGraph',
'c4',
'sankey',
'block',
'packet',
] as const;

/**
* Generate default values from the JSON Schema.
*
* AJV does not support nested default values yet (or default values with $ref),
* so we need to manually find them (this may be fixed in ajv v9).
*
* @param mermaidConfigSchema - The Mermaid JSON Schema to use.
* @returns The default mermaid config object.
*/
function generateDefaults(mermaidConfigSchema: JSONSchemaType<MermaidConfig>) {
const ajv = new Ajv2019({
useDefaults: true,
allowUnionTypes: true,
strict: true,
});

ajv.addKeyword({
keyword: 'meta:enum', // used by jsonschema2md
errors: false,
});
ajv.addKeyword({
keyword: 'tsType', // used by json-schema-to-typescript
errors: false,
});

// ajv currently doesn't support nested default values, see https://github.com/ajv-validator/ajv/issues/1718
// (may be fixed in v9) so we need to manually use sub-schemas
const mermaidDefaultConfig = {};

assert.ok(mermaidConfigSchema.$defs);
const baseDiagramConfig = mermaidConfigSchema.$defs.BaseDiagramConfig;

for (const key of MERMAID_CONFIG_DIAGRAM_KEYS) {
const subSchemaRef = mermaidConfigSchema.properties[key].$ref;
const [root, defs, defName] = subSchemaRef.split('/');
assert.strictEqual(root, '#');
assert.strictEqual(defs, '$defs');
const subSchema = {
$schema: mermaidConfigSchema.$schema,
$defs: mermaidConfigSchema.$defs,
...mermaidConfigSchema.$defs[defName],
} as JSONSchemaType<BaseDiagramConfig>;

const validate = ajv.compile(subSchema);

mermaidDefaultConfig[key] = {};

for (const required of subSchema.required ?? []) {
if (subSchema.properties[required] === undefined && baseDiagramConfig.properties[required]) {
mermaidDefaultConfig[key][required] = baseDiagramConfig.properties[required].default;
}
}
if (!validate(mermaidDefaultConfig[key])) {
throw new Error(
`schema for subconfig ${key} does not have valid defaults! Errors were ${JSON.stringify(
validate.errors,
undefined,
2
)}`
);
}
}

const validate = ajv.compile(mermaidConfigSchema);

if (!validate(mermaidDefaultConfig)) {
throw new Error(
`Mermaid config JSON Schema does not have valid defaults! Errors were ${JSON.stringify(
validate.errors,
undefined,
2
)}`
);
}

return mermaidDefaultConfig;
}

export const loadSchema = (src: string, filename: string): JSONSchemaType<MermaidConfig> => {
const jsonSchema = load(src, {
filename,
// only allow JSON types in our YAML doc (will probably be default in YAML 1.3)
// e.g. `true` will be parsed a boolean `true`, `True` will be parsed as string `"True"`.
schema: JSON_SCHEMA,
}) as JSONSchemaType<MermaidConfig>;
return jsonSchema;
};

export const getDefaults = (schema: JSONSchemaType<MermaidConfig>) => {
return `export default ${JSON.stringify(generateDefaults(schema), undefined, 2)};`;
};

export const getSchema = (schema: JSONSchemaType<MermaidConfig>) => {
return `export default ${JSON.stringify(schema, undefined, 2)};`;
};
18 changes: 18 additions & 0 deletions .build/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { packageOptions } from './common.js';
import { execSync } from 'child_process';

const buildType = (packageName: string) => {
console.log(`Building types for ${packageName}`);
try {
const out = execSync(`tsc -p ./packages/${packageName}/tsconfig.json --emitDeclarationOnly`);
out.length > 0 && console.log(out.toString());
} catch (e) {
console.error(e);
e.stdout.length > 0 && console.error(e.stdout.toString());
e.stderr.length > 0 && console.error(e.stderr.toString());
}
};

for (const { packageName } of Object.values(packageOptions)) {
buildType(packageName);
}
3 changes: 3 additions & 0 deletions .cspell/code-terms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ GENERICTYPE
getBoundarys
grammr
graphtype
iife
interp
introdcued
INVTRAPEND
Expand All @@ -74,11 +75,13 @@ loglevel
LOGMSG
lookaheads
mdast
metafile
minlen
Mstartx
MULT
NODIR
NSTR
outdir
Qcontrolx
reinit
rels
Expand Down
1 change: 1 addition & 0 deletions .cspell/libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jsfiddle
jsonschema
katex
khroma
langium
mathml
matplotlib
mdbook
Expand Down
65 changes: 65 additions & 0 deletions .esbuild/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { build } from 'esbuild';
import { mkdir, writeFile } from 'node:fs/promises';
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');

const buildPackage = async (entryName: keyof typeof packageOptions) => {
const commonOptions = { ...defaultOptions, entryName } as const;
const buildConfigs = [
// package.mjs
{ ...commonOptions },
// package.min.mjs
{
...commonOptions,
minify: true,
metafile: shouldVisualize,
},
// package.core.mjs
{ ...commonOptions, core: true },
];

if (entryName === 'mermaid') {
const iifeOptions: MermaidBuildOptions = { ...commonOptions, format: 'iife' };
buildConfigs.push(
// mermaid.js
{ ...iifeOptions },
// mermaid.min.js
{ ...iifeOptions, minify: true, metafile: shouldVisualize }
);
}

const results = await Promise.all(buildConfigs.map((option) => build(getBuildConfig(option))));

if (shouldVisualize) {
for (const { metafile } of results) {
if (!metafile) {
continue;
}
const fileName = Object.keys(metafile.outputs)
.filter((file) => !file.includes('chunks') && file.endsWith('js'))[0]
.replace('dist/', '');
// Upload metafile into https://esbuild.github.io/analyze/
await writeFile(`stats/${fileName}.meta.json`, JSON.stringify(metafile));
}
}
};

const handler = (e) => {
console.error(e);
process.exit(1);
};

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 dependency
for (const pkg of packageNames) {
await buildPackage(pkg).catch(handler);
}
};

void main();
15 changes: 15 additions & 0 deletions .esbuild/jisonPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { readFile } from 'node:fs/promises';
import { transformJison } from '../.build/jisonTransformer.js';
import { Plugin } from 'esbuild';

export const jisonPlugin: Plugin = {
name: 'jison',
setup(build) {
build.onLoad({ filter: /\.jison$/ }, async (args) => {
// Load the file from the file system
const source = await readFile(args.path, 'utf8');
const contents = transformJison(source);
return { contents, warnings: [] };
});
},
};
35 changes: 35 additions & 0 deletions .esbuild/jsonSchemaPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { JSONSchemaType } from 'ajv/dist/2019.js';
import type { MermaidConfig } from '../packages/mermaid/src/config.type.js';
import { readFile } from 'node:fs/promises';
import { getDefaults, getSchema, loadSchema } from '../.build/jsonSchema.js';

/**
* ESBuild plugin that handles JSON Schemas saved as a `.schema.yaml` file.
*
* Use `my-example.schema.yaml?only-defaults=true` to only load the default values.
*/

export const jsonSchemaPlugin = {
name: 'json-schema-plugin',
setup(build) {
let schema: JSONSchemaType<MermaidConfig> | undefined = undefined;
let content = '';

build.onLoad({ filter: /config\.schema\.yaml$/ }, async (args) => {
// Load the file from the file system
const source = await readFile(args.path, 'utf8');
const resolvedSchema: JSONSchemaType<MermaidConfig> =
content === source && schema ? schema : loadSchema(source, args.path);
if (content !== source) {
content = source;
schema = resolvedSchema;
}
const contents = args.suffix.includes('only-defaults')
? getDefaults(resolvedSchema)
: getSchema(resolvedSchema);
return { contents, warnings: [] };
});
},
};

export default jsonSchemaPlugin;
Loading
Loading