mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
Cleanup, updating the module name and description for flowchart in package.json
This commit is contained in:
parent
3f7f04e02f
commit
e28a766e7d
@ -54,7 +54,14 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div>Security check</div>
|
<pre id="diagram" class="mermaid">
|
||||||
|
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
|
||||||
|
graph TB
|
||||||
|
a --> b
|
||||||
|
a --> c
|
||||||
|
b --> d
|
||||||
|
c --> d
|
||||||
|
</pre>
|
||||||
<pre id="diagram" class="mermaid">
|
<pre id="diagram" class="mermaid">
|
||||||
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
|
%%{init: {"flowchart": {"defaultRenderer": "elk"}} }%%
|
||||||
flowchart TB
|
flowchart TB
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "@mermaid-js/mermaid-flowchart-v3",
|
"name": "@mermaid-js/mermaid-flowchart-v3",
|
||||||
"version": "9.4.0",
|
"version": "9.4.0",
|
||||||
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
|
"description": "An extension for the Mermaid diagramming library that utilizes elkjs for layout, enabling the creation of visually appealing and easy-to-understand flowcharts.",
|
||||||
"module": "dist/mermaid-mindmap.core.mjs",
|
"module": "dist/mermaid-flowchart-v3.core.mjs",
|
||||||
"types": "dist/detector.d.ts",
|
"types": "dist/detector.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
@ -15,8 +15,9 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"diagram",
|
"diagram",
|
||||||
"markdown",
|
"markdown",
|
||||||
"mindmap",
|
"flowchart",
|
||||||
"mermaid"
|
"mermaid",
|
||||||
|
"elkjs"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "pnpm -w run build"
|
"prepublishOnly": "pnpm -w run build"
|
||||||
@ -39,12 +40,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@braintree/sanitize-url": "^6.0.0",
|
"@braintree/sanitize-url": "^6.0.0",
|
||||||
"cytoscape": "^3.23.0",
|
|
||||||
"cytoscape-cose-bilkent": "^4.1.0",
|
|
||||||
"cytoscape-fcose": "^2.1.0",
|
|
||||||
"graphlib": "^2.1.0",
|
"graphlib": "^2.1.0",
|
||||||
"dagre-d3-es": "7.0.4",
|
"dagre-d3-es": "7.0.4",
|
||||||
"cytoscape-dagre": "^2.1.0",
|
|
||||||
"elkjs": "^0.8.2",
|
"elkjs": "^0.8.2",
|
||||||
"d3": "^7.0.0",
|
"d3": "^7.0.0",
|
||||||
"khroma": "^2.0.0",
|
"khroma": "^2.0.0",
|
||||||
|
@ -1,43 +1,3 @@
|
|||||||
export const findCommonAncestorCoPilot = (id1, id2, treeData) => {
|
|
||||||
const { parentById, childrenById } = treeData;
|
|
||||||
const parents1 = [];
|
|
||||||
const parents2 = [];
|
|
||||||
let cnt = 0;
|
|
||||||
let currentId = id1;
|
|
||||||
while (currentId) {
|
|
||||||
parents1.push(currentId);
|
|
||||||
currentId = parentById[currentId];
|
|
||||||
cnt++;
|
|
||||||
if (cnt > 200) {
|
|
||||||
throw new Error('Infinite loop detected!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentId = id2;
|
|
||||||
while (currentId) {
|
|
||||||
parents2.push(currentId);
|
|
||||||
currentId = parentById[currentId];
|
|
||||||
cnt++;
|
|
||||||
if (cnt > 200) {
|
|
||||||
throw new Error('Infinite loop detected!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let commonAncestor = 'root';
|
|
||||||
while (parents1.length && parents2.length) {
|
|
||||||
cnt++;
|
|
||||||
if (cnt > 200) {
|
|
||||||
throw new Error('Infinite loop detected!');
|
|
||||||
}
|
|
||||||
const p1 = parents1.pop();
|
|
||||||
const p2 = parents2.pop();
|
|
||||||
if (p1 === p2) {
|
|
||||||
commonAncestor = p1;
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return commonAncestor;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const findCommonAncestor = (id1, id2, treeData) => {
|
export const findCommonAncestor = (id1, id2, treeData) => {
|
||||||
const { parentById } = treeData;
|
const { parentById } = treeData;
|
||||||
const visited = new Set();
|
const visited = new Set();
|
||||||
@ -58,62 +18,3 @@ export const findCommonAncestor = (id1, id2, treeData) => {
|
|||||||
}
|
}
|
||||||
return 'root';
|
return 'root';
|
||||||
};
|
};
|
||||||
|
|
||||||
export const findCommonAncestorKnut = (id1, id2, treeData) => {
|
|
||||||
const { parentById, childrenById } = treeData;
|
|
||||||
const parents1 = [];
|
|
||||||
const parents2 = [];
|
|
||||||
let cnt = 0;
|
|
||||||
let currentId = id1;
|
|
||||||
while (currentId) {
|
|
||||||
parents1.push(currentId);
|
|
||||||
currentId = parentById[currentId];
|
|
||||||
cnt++;
|
|
||||||
if (cnt > 200) {
|
|
||||||
throw new Error('Infinite loop detected!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentId = id2;
|
|
||||||
while (currentId) {
|
|
||||||
parents2.push(currentId);
|
|
||||||
currentId = parentById[currentId];
|
|
||||||
if (currentId === 'root') {
|
|
||||||
return 'root';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parents1.includes(currentId)) {
|
|
||||||
return currentId;
|
|
||||||
}
|
|
||||||
|
|
||||||
cnt++;
|
|
||||||
if (cnt > 200) {
|
|
||||||
throw new Error('Infinite loop detected!');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 'root';
|
|
||||||
};
|
|
||||||
|
|
||||||
export const findCommonAncestorRecursive = (id1, id2, treeData) => {
|
|
||||||
const { parentById, childrenById } = treeData;
|
|
||||||
|
|
||||||
// Base case: return the current node if it is the common ancestor
|
|
||||||
if (id1 === id2) {
|
|
||||||
return id1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Recursive case: search for the common ancestor in the parent nodes
|
|
||||||
const parent1 = parentById[id1];
|
|
||||||
const parent2 = parentById[id2];
|
|
||||||
if (parent1 && parent2) {
|
|
||||||
return findCommonAncestor(parent1, parent2, treeData);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edge case: one of the nodes is the root of the tree
|
|
||||||
if (parent1) {
|
|
||||||
return parent1;
|
|
||||||
}
|
|
||||||
if (parent2) {
|
|
||||||
return parent2;
|
|
||||||
}
|
|
||||||
return 'root';
|
|
||||||
};
|
|
||||||
|
@ -2,21 +2,6 @@ import { findCommonAncestor } from './render-utils';
|
|||||||
describe('when rendering a flowchart using elk ', function () {
|
describe('when rendering a flowchart using elk ', function () {
|
||||||
let lookupDb;
|
let lookupDb;
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
/**
|
|
||||||
* root:
|
|
||||||
* B1
|
|
||||||
* outer
|
|
||||||
* B6
|
|
||||||
* Ugge
|
|
||||||
* B2
|
|
||||||
* B3
|
|
||||||
* inner
|
|
||||||
* B4
|
|
||||||
* B5
|
|
||||||
* inner2
|
|
||||||
* C4
|
|
||||||
* C5
|
|
||||||
*/
|
|
||||||
lookupDb = JSON.parse(
|
lookupDb = JSON.parse(
|
||||||
'{"parentById":{"B4":"inner","B5":"inner","C4":"inner2","C5":"inner2","B2":"Ugge","B3":"Ugge","inner":"Ugge","inner2":"Ugge","B6":"outer"},"childrenById":{"inner":["B4","B5"],"inner2":["C4","C5"],"Ugge":["B2","B3","inner","inner2"],"outer":["B6"]}}'
|
'{"parentById":{"B4":"inner","B5":"inner","C4":"inner2","C5":"inner2","B2":"Ugge","B3":"Ugge","inner":"Ugge","inner2":"Ugge","B6":"outer"},"childrenById":{"inner":["B4","B5"],"inner2":["C4","C5"],"Ugge":["B2","B3","inner","inner2"],"outer":["B6"]}}'
|
||||||
);
|
);
|
||||||
|
28
pnpm-lock.yaml
generated
28
pnpm-lock.yaml
generated
@ -311,18 +311,6 @@ importers:
|
|||||||
'@braintree/sanitize-url':
|
'@braintree/sanitize-url':
|
||||||
specifier: ^6.0.0
|
specifier: ^6.0.0
|
||||||
version: 6.0.0
|
version: 6.0.0
|
||||||
cytoscape:
|
|
||||||
specifier: ^3.23.0
|
|
||||||
version: 3.23.0
|
|
||||||
cytoscape-cose-bilkent:
|
|
||||||
specifier: ^4.1.0
|
|
||||||
version: 4.1.0_cytoscape@3.23.0
|
|
||||||
cytoscape-dagre:
|
|
||||||
specifier: ^2.1.0
|
|
||||||
version: 2.5.0_cytoscape@3.23.0
|
|
||||||
cytoscape-fcose:
|
|
||||||
specifier: ^2.1.0
|
|
||||||
version: 2.1.0_cytoscape@3.23.0
|
|
||||||
d3:
|
d3:
|
||||||
specifier: ^7.0.0
|
specifier: ^7.0.0
|
||||||
version: 7.6.1
|
version: 7.6.1
|
||||||
@ -4946,15 +4934,6 @@ packages:
|
|||||||
cytoscape: 3.23.0
|
cytoscape: 3.23.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/cytoscape-dagre/2.5.0_cytoscape@3.23.0:
|
|
||||||
resolution: {integrity: sha512-VG2Knemmshop4kh5fpLO27rYcyUaaDkRw+6PiX4bstpB+QFt0p2oauMrsjVbUamGWQ6YNavh7x2em2uZlzV44g==}
|
|
||||||
peerDependencies:
|
|
||||||
cytoscape: ^3.2.22
|
|
||||||
dependencies:
|
|
||||||
cytoscape: 3.23.0
|
|
||||||
dagre: 0.8.5
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/cytoscape-fcose/2.1.0_cytoscape@3.23.0:
|
/cytoscape-fcose/2.1.0_cytoscape@3.23.0:
|
||||||
resolution: {integrity: sha512-Q3apPl66jf8/2sMsrCjNP247nbDkyIPjA9g5iPMMWNLZgP3/mn9aryF7EFY/oRPEpv7bKJ4jYmCoU5r5/qAc1Q==}
|
resolution: {integrity: sha512-Q3apPl66jf8/2sMsrCjNP247nbDkyIPjA9g5iPMMWNLZgP3/mn9aryF7EFY/oRPEpv7bKJ4jYmCoU5r5/qAc1Q==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@ -5270,13 +5249,6 @@ packages:
|
|||||||
lodash-es: 4.17.21
|
lodash-es: 4.17.21
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/dagre/0.8.5:
|
|
||||||
resolution: {integrity: sha512-/aTqmnRta7x7MCCpExk7HQL2O4owCT2h8NT//9I1OQ9vt29Pa0BzSAkR5lwFUcQ7491yVi/3CXU9jQ5o0Mn2Sw==}
|
|
||||||
dependencies:
|
|
||||||
graphlib: 2.1.8
|
|
||||||
lodash: 4.17.21
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/dargs/7.0.0:
|
/dargs/7.0.0:
|
||||||
resolution: {integrity: sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==}
|
resolution: {integrity: sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user