Skip to content

Commit

Permalink
Merge 3b25cd3 into 4bc997c
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Feb 21, 2023
2 parents 4bc997c + 3b25cd3 commit b2e0db7
Show file tree
Hide file tree
Showing 174 changed files with 2,163 additions and 3,123 deletions.
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
15 changes: 4 additions & 11 deletions .vite/server.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
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();

// Create Vite server in middleware mode
const vite = await createViteServer({
configFile: './vite.config.ts',
mode: 'production',
server: { middlewareMode: true },
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

## Async

`parse`, `render` are now async.

## 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/erDiagram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ describe('Entity Relationship Diagram', () => {
erDiagram
CLUSTER {
varchar(99) name
string(255) description
string(255) description
}
`,
{ logLevel: 1 }
Expand Down
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
11 changes: 11 additions & 0 deletions cypress/integration/rendering/flowchart-v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,17 @@ title: Simple flowchart
---
flowchart TD
A --> B
`,
{ titleTopMargin: 0 }
);
});
it('3192: It should be possieble to render flowcharts with invisible edges', () => {
imgSnapshotTest(
`---
title: Simple flowchart with invisible edges
---
flowchart TD
A ~~~ B
`,
{ titleTopMargin: 0 }
);
Expand Down
6 changes: 5 additions & 1 deletion cypress/integration/rendering/sequencediagram.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ context('Sequence diagram', () => {
loop Loopy
Bob->>Alice: Pasten
end `,
{ wrap: true }
{
sequence: {
wrap: true,
},
}
);
});
context('font settings', () => {
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

0 comments on commit b2e0db7

Please sign in to comment.