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

Release/10.0.0 #4108

Merged
merged 41 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
08ac411
chore(deps): update dependency vite to v4
renovate[bot] Feb 9, 2023
004432f
Fix types
sidharthv96 Feb 9, 2023
ac23194
Merge pull request #4071 from mermaid-js/renovate/vite-4.x
sidharthv96 Feb 16, 2023
17238c0
Merge branch 'master' into develop
sidharthv96 Feb 16, 2023
ccaa999
chore(deps): update dependency cypress to v12
renovate[bot] Feb 16, 2023
4ed6ec1
Add highlight tag info in contributing.md
sidharthv96 Feb 16, 2023
fec193e
Merge pull request #4068 from mermaid-js/renovate/cypress-12.x
sidharthv96 Feb 16, 2023
e31924e
fix(api): tree shaking package.json import
AielloChan Feb 18, 2023
3c4a6a1
fix: Vite, D3, Vitest Types
sidharthv96 Feb 18, 2023
0f36bbf
Revert #4034
sidharthv96 Feb 18, 2023
bd98f14
Revert #4034
sidharthv96 Feb 18, 2023
ea8128e
RC version
sidharthv96 Feb 18, 2023
2c062d6
Merge branch 'develop' into release/9.4.2
sidharthv96 Feb 18, 2023
735faa8
Merge branch 'release/9.4.2' into pr/AielloChan/4101
sidharthv96 Feb 18, 2023
31629fe
Merge pull request #4101 from AielloChan/develop
sidharthv96 Feb 18, 2023
631ff8f
chore: Remove cjs from build
sidharthv96 Feb 18, 2023
c1aad59
Merge branch 'release/9.4.2' into release/10.0.0
sidharthv96 Feb 18, 2023
45adc5f
Remove CJS builds from docs
sidharthv96 Feb 18, 2023
d22e8d9
chore: Remove all non async render/parse/init
sidharthv96 Feb 18, 2023
eaa84d2
feat: Break render and parse types
sidharthv96 Feb 19, 2023
d292743
Fix tests
sidharthv96 Feb 19, 2023
735aceb
Fix E2E Tests
sidharthv96 Feb 19, 2023
6aa3ea4
Remove Readme
sidharthv96 Feb 19, 2023
1684faf
Fix lint
sidharthv96 Feb 19, 2023
6e3d96e
fix Server
sidharthv96 Feb 19, 2023
8c64a90
Fix docs
sidharthv96 Feb 19, 2023
8363552
Skip flowchart-elk failing test
sidharthv96 Feb 19, 2023
57fd3e5
chore: Rename lazy loaded diagram definitions
sidharthv96 Feb 19, 2023
4ea7294
fix(#3406, #3394): Remove init & initThrowsErrors
sidharthv96 Feb 19, 2023
83f3ceb
Update docs
sidharthv96 Feb 19, 2023
8469e72
Cleanup
sidharthv96 Feb 19, 2023
1691d48
skip failing elk test
sidharthv96 Feb 19, 2023
db8a14c
10.0.0-rc.2
sidharthv96 Feb 19, 2023
4a721a2
no side effects
sidharthv96 Feb 19, 2023
77207e0
Export more types
sidharthv96 Feb 19, 2023
e22171c
10.0.0-rc.3
sidharthv96 Feb 19, 2023
5de5598
Skip all elk tests as it's flaky
sidharthv96 Feb 19, 2023
4c7306d
Skip elk
sidharthv96 Feb 19, 2023
40b5f86
Cleanup
sidharthv96 Feb 19, 2023
38b2cbc
chore: Update RunOptions docs
sidharthv96 Feb 20, 2023
68cdc75
Minor cleanup
sidharthv96 Feb 20, 2023
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
6 changes: 0 additions & 6 deletions .percy.yml

This file was deleted.

15 changes: 0 additions & 15 deletions .tern-project

This file was deleted.

21 changes: 8 additions & 13 deletions .vite/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ const visualizerOptions = (packageName: string, core = false): PluginOption[] =>
if (packageName !== 'mermaid' || !visualize) {
return [];
}
return ['network', 'treemap', 'sunburst'].map((chartType) =>
visualizer({
filename: `./stats/${chartType}${core ? '.core' : ''}.html`,
template: chartType as TemplateType,
gzipSize: true,
brotliSize: true,
})
return ['network', 'treemap', 'sunburst'].map(
(chartType) =>
visualizer({
filename: `./stats/${chartType}${core ? '.core' : ''}.html`,
template: chartType as TemplateType,
gzipSize: true,
brotliSize: true,
}) as PluginOption
);
};

Expand Down Expand Up @@ -61,12 +62,6 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
sourcemap: true,
entryFileNames: `${name}.esm${minify ? '.min' : ''}.mjs`,
},
{
name,
format: 'umd',
sourcemap: true,
entryFileNames: `${name}${minify ? '.min' : ''}.js`,
},
];

if (core) {
Expand Down
14 changes: 3 additions & 11 deletions .vite/server.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import express, { NextFunction, Request, Response } from 'express';
import express from 'express';
import cors from 'cors';
import { createServer as createViteServer } from 'vite';

const cors = (req: Request, res: Response, next: NextFunction) => {
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
res.header('Access-Control-Allow-Headers', 'Content-Type');

next();
};

async function createServer() {
const app = express();

Expand All @@ -19,9 +12,8 @@ async function createServer() {
appType: 'custom', // don't include Vite's default HTML handling middlewares
});

app.use(cors);
app.use(cors());
app.use(express.static('./packages/mermaid/dist'));
// app.use(express.static('./packages/mermaid-example-diagram/dist'));
app.use(express.static('./packages/mermaid-example-diagram/dist'));
app.use(vite.middlewares);
app.use(express.static('demos'));
Expand Down
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ flowchart LR

```

You can use `note`, `tip`, `warning` and `danger` in triple backticks to add a note, tip, warning or danger box.
Do not use vitepress specific markdown syntax `::: warning` as it will not be processed correctly.

````
```note
Note content
```

```tip
Tip content
```

```warning
Warning content
```

```danger
Danger content
```

````

**_DO NOT CHANGE FILES IN `/docs`_**

### The official documentation site
Expand Down
55 changes: 54 additions & 1 deletion V10-BreakingChanges.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,58 @@
# A collection of updates that change the behaviour
# A collection of updates that change the behavior

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to document that Mermaid is now ESM only.

Ideally we should show some example usage too.

## Async

`parse`, `render` are now async.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth having some examples here, since this is probably one of the most important changes!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'll add documentation soon (with examples and live editor commits for migration)
This file is currently used to keep note of points to elaborate before release.


## Lazy loading and asynchronisity

- Invalid dates are rendered as syntax error instead of returning best guess or the current date

## ParseError is removed

```js
//< v10.0.0
mermaid.parse(text, parseError);

//>= v10.0.0
await mermaid.parse(text).catch(parseError);
// or
try {
await mermaid.parse(text);
} catch (err) {
parseError(err);
}
```

## Init deprecated and InitThrowsErrors removed

The config passed to `init` was not being used eariler.
It will now be used.
The `init` function is deprecated and will be removed in the next major release.
init currently works as a wrapper to `initialize` and `run`.

```js
//< v10.0.0
mermaid.init(config, selector, cb);

//>= v10.0.0
mermaid.initialize(config);
mermaid.run({
querySelector: selector,
postRenderCallback: cb,
suppressErrors: true,
});
```

```js
//< v10.0.0
mermaid.initThrowsErrors(config, selector, cb);

//>= v10.0.0
mermaid.initialize(config);
mermaid.run({
querySelector: selector,
postRenderCallback: cb,
suppressErrors: false,
});
```
2 changes: 1 addition & 1 deletion cypress/integration/rendering/flowchart-elk.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { imgSnapshotTest, renderGraph } from '../../helpers/util';

describe('Flowchart ELK', () => {
describe.skip('Flowchart ELK', () => {
it('1-elk: should render a simple flowchart', () => {
imgSnapshotTest(
`flowchart-elk TD
Expand Down
16 changes: 6 additions & 10 deletions cypress/platform/bundle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,9 @@ mermaid.initialize({
],
},
});
mermaid.render(
'the-id-of-the-svg',
code,
(svg) => {
console.log(svg);
const elem = document.querySelector('#graph-to-be');
elem.innerHTML = svg;
}
// ,document.querySelector('#tmp')
);
void (async () => {
const { svg } = await mermaid.render('the-id-of-the-svg', code);
console.log(svg);
const elem = document.querySelector('#graph-to-be');
elem.innerHTML = svg;
})();
4 changes: 2 additions & 2 deletions cypress/platform/class.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ <h1>info below</h1>
callback Shape "callbackFunction" "This is a tooltip for a callback"

</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
Expand Down
4 changes: 3 additions & 1 deletion cypress/platform/click_security_loose.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
</pre>
</div>

<script src="./mermaid.js"></script>
<script>
function clickByFlow(elemName) {
const div = document.createElement('div');
Expand Down Expand Up @@ -162,6 +161,9 @@

document.getElementsByTagName('body')[0].appendChild(div);
}
</script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ startOnLoad: true, securityLevel: 'loose', logLevel: 1 });
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions cypress/platform/click_security_other.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
Add another diagram to demo page : 48h
</pre>

<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function clickByFlow(elemName) {
const div = document.createElement('div');
div.className = 'created-by-click';
Expand Down
4 changes: 2 additions & 2 deletions cypress/platform/click_security_sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@
</pre>
</div>

<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function clickByFlow(elemName) {
const div = document.createElement('div');
div.className = 'created-by-click';
Expand Down
4 changes: 2 additions & 2 deletions cypress/platform/click_security_strict.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
Add another diagram to demo page : 48h
</pre>

<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function clickByFlow(elemName) {
const div = document.createElement('div');
div.className = 'created-by-click';
Expand Down
4 changes: 2 additions & 2 deletions cypress/platform/css1.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
end
A --> B
</pre>
<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
function showFullFirstSquad(elemName) {
console.log('show ' + elemName);
}
Expand Down
4 changes: 2 additions & 2 deletions cypress/platform/current2.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ <h1>info below</h1>
Note over Bob,Alice: Looks back
</pre>

<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.parseError = function (err, hash) {
// console.error('Mermaid error: ', err);
};
Expand Down
38 changes: 1 addition & 37 deletions cypress/platform/e2e.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
<html>
<head>
<meta charset="utf-8" />
<!-- <meta charset="iso-8859-15"/> -->
<script src="./viewer.js" type="module"></script>
<!-- <link href="https://fonts.googleapis.com/css?family=Mansalva&display=swap" rel="stylesheet" /> -->
<link
href="https://fonts.googleapis.com/css?family=Noto+Sans+SC&display=swap"
rel="stylesheet"
/>
<style>
body {
/* font-family: 'Mansalva', cursive;*/
/* font-family: 'Mansalva', cursive; */
/* font-family: 'arial'; */
/* font-family: "trebuchet ms", verdana, arial; */
}
/* div {
font-family: 'arial';
} */
/* .mermaid-main-font {
font-family: "trebuchet ms", verdana, arial;
font-family: var(--mermaid-font-family);
} */
/* :root {
--mermaid-font-family: '"trebuchet ms", verdana, arial';
--mermaid-font-family: "Comic Sans MS", "Comic Sans", cursive;
--mermaid-font-family: '"Lucida Console", Monaco, monospace';
} */
svg {
border: 2px solid darkred;
}
Expand All @@ -36,21 +16,5 @@
}
</style>
</head>
<body>
<!-- <script src="./mermaid.js"></script> -->
<script>
// Notice startOnLoad=false
// This prevents default handling in mermaid from render before the e2e logic is applied
// mermaid.initialize({
// startOnLoad: false,
// useMaxWidth: true,
// // "themeCSS": ":root { --mermaid-font-family: \"trebuchet ms\", verdana, arial;}",
// // fontFamily: '\"trebuchet ms\", verdana, arial;'
// // fontFamily: '"Comic Sans MS", "Comic Sans", cursive'
// // fontFamily: '"Mansalva", cursive',
// // fontFamily: '"Noto Sans SC", sans-serif'
// fontFamily: '"Noto Sans SC", sans-serif'
// });
</script>
</body>
<body></body>
</html>
2 changes: 1 addition & 1 deletion cypress/platform/external-diagrams-example-diagram.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h1>Should correctly load a third-party diagram using registerDiagram</h1>

await mermaid.registerExternalDiagrams([exampleDiagram]);
await mermaid.initialize({ logLevel: 0 });
await mermaid.initThrowsErrorsAsync();
await mermaid.run();
if (window.Cypress) {
window.rendered = true;
}
Expand Down
4 changes: 2 additions & 2 deletions cypress/platform/flow.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
click a_a "http://www.aftonbladet.se" "apa"
</pre>

<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'forest',
// themeCSS: '.node rect { fill: red; }',
Expand Down
14 changes: 7 additions & 7 deletions cypress/platform/ghsa1.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ <h1>Background should be yellow!!!</h1>
</div>
<svg id="diagram"></svg>

<script src="./mermaid.js"></script>
<script>
<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({ startOnLoad: false, logLevel: 0 });

const graph = `
%%{ init: { "themeVariables" : { "textColor": "green;} #target { background-color: crimson }", "mainBkg": "#fff000" } } }%%
graph TD
A[Goose]
`;
%%{ init: { "themeVariables" : { "textColor": "green;} #target { background-color: crimson }", "mainBkg": "#fff000" } } }%%
graph TD
A[Goose]
`;

const diagram = document.getElementById('diagram');
const svg = mermaid.render('diagram-svg', graph);
const { svg } = await mermaid.render('diagram-svg', graph);
diagram.innerHTML = svg;
if (window.Cypress) {
window.rendered = true;
Expand Down
Loading