Increased mem for lint, fixed spell checking, run lint

This commit is contained in:
Nikolay Rozhkov 2023-06-18 01:32:45 +03:00
parent 40f7105ae4
commit 1782f69c8f
8 changed files with 64 additions and 50 deletions

View File

@ -102,6 +102,7 @@
"rehype",
"roledescription",
"sandboxed",
"sankey",
"setupgraphviewbox",
"shiki",
"sidharth",

View File

@ -5,6 +5,10 @@ services:
stdin_open: true
tty: true
working_dir: /mermaid
# mem_reservation: "10M"
mem_limit: '8G'
environment:
- NODE_OPTIONS=--max_old_space_size=8192
volumes:
- ./:/mermaid
- root_cache:/root/.cache
@ -13,4 +17,4 @@ services:
- 9000:9000
volumes:
root_cache:
root_local:
root_local:

View File

@ -81,6 +81,6 @@ export const addDiagrams = () => {
state,
journey,
quadrantChart,
sankey,
sankey
);
};

View File

@ -29,6 +29,7 @@ Interviewed,Accepted Offer,1,orange
```
GoJS uses similar approach:
```json
{
"nodeDataArray": [
@ -47,30 +48,34 @@ GoJS uses similar approach:
## What do we need
Mainly we need:
* collection of nodes
* collection of links
- collection of nodes
- collection of links
We also need graph and node attributes like this:
* link sort
* node sort
* coloring strategy for links (source, target, transition)
* graph alignment (left, right, width)
* node color
* node title
* node width
* node padding
* graph margin
- link sort
- node sort
- coloring strategy for links (source, target, transition)
- graph alignment (left, right, width)
- node color
- node title
- node width
- node padding
- graph margin
## Desired syntax
Graph is a list of flows (or links).
Flow is a sequence `node -> value -> node -> value...`
```
a -> 30 -> b
a -> 40 -> b
```
2 separate streams between 2 nodes they can be grouped as well:
```
a -> {
30
@ -79,6 +84,7 @@ a -> {
```
All outflows from the node can be grouped:
```
a -> {
30 -> b
@ -87,6 +93,7 @@ a -> {
```
All inflows to the node can be grouped too:
```
{
a -> 30
@ -95,6 +102,7 @@ All inflows to the node can be grouped too:
```
Chaining example:
```
a -> {
30
@ -102,12 +110,13 @@ a -> {
} -> b -> {
20 -> d -> 11
50 -> e -> 11
} -> f -> 30
} -> f -> 30
```
**Probably ambiguous!**
Does the sample below mean that total outflow from "a" is 60?
```
a -> 30 -> {
b
@ -116,6 +125,7 @@ a -> 30 -> {
```
Or does this one mean that total outflow must be 140 (70 to "b" and "c" respectively)?
```
a -> {
30
@ -129,6 +139,7 @@ a -> {
**Overcomplicated**
Nested:
```
{
{

View File

@ -13,8 +13,8 @@ describe('Sankey diagram', function () {
});
it('recognizes its type', () => {
const str=`sankey`;
const str = `sankey`;
parser.parse(str);
});
@ -23,10 +23,10 @@ describe('Sankey diagram', function () {
sankey
a -> 30 -> b -> 20 -> c
`;
parser.parse(str);
});
it('recognizes multiple flows', () => {
const str = `
sankey
@ -34,10 +34,10 @@ describe('Sankey diagram', function () {
c -> 30 -> d -> 12 -> e
c -> 40 -> e -> 12 -> q
`;
parser.parse(str);
});
describe('while attributes parsing', () => {
it('parses different quotless variations', () => {
const str = `
@ -50,7 +50,7 @@ describe('Sankey diagram', function () {
node[attr1 = 23413 attr2=1234]
node[x1dfqowie attr1 = 23413 attr2]
`;
parser.parse(str);
});
@ -60,9 +60,9 @@ describe('Sankey diagram', function () {
node[attr="hello, how are you?"]
node[attr="hello\\"afaasd"]
`;
parser.parse(str);
});
});
});
});
});

View File

@ -19,22 +19,20 @@ import {
// export const cleanupComments = (text: string): string => {
// return text.trimStart().replace(/^\s*%%(?!{)[^\n]+\n?/gm, '');
// };
let links:Array<Link> = [];
let nodes: {[id: string]: Node} = {};
let links: Array<Link> = [];
let nodes: { [id: string]: Node } = {};
const clear = function () {
links = [];
nodes = {}
nodes = {};
commonClear();
};
type Nullable<T> = T | null;
class Link {
sourceNode: Nullable<Node>
targetNode: Nullable<Node>
sourceNode: Nullable<Node>;
targetNode: Nullable<Node>;
constructor() {
this.sourceNode = null;
this.targetNode = null;
@ -43,10 +41,10 @@ class Link {
/**
* Adds a stream between two elements on the diagram
*
*
* @param sourceNodeID - The id Node where the link starts
* @param targetNodeID - The id Node where the link ends
*/
*/
interface IAddLink {
sourceNodeID?: string;
@ -54,17 +52,20 @@ interface IAddLink {
// amount?: number;
}
const addLink = ({sourceNodeID, targetNodeID}: IAddLink = {}): Link => {
const addLink = ({ sourceNodeID, targetNodeID }: IAddLink = {}): Link => {
const link: Link = new Link();
if(typeof(sourceNodeID) !== 'undefined') link.sourceNode = addNode(sourceNodeID);
if(typeof(targetNodeID) !== 'undefined') link.targetNode = addNode(targetNodeID);
if (sourceNodeID !== undefined) {
link.sourceNode = addNode(sourceNodeID);
}
if (targetNodeID !== undefined) {
link.targetNode = addNode(targetNodeID);
}
links.push(link);
return link;
}
};
class Node {
id: string;
@ -77,18 +78,17 @@ class Node {
/**
* Finds or creates a new Node by ID
*
*
* @param id - The id Node
*/
const addNode = (id: string): Node => {
id = common.sanitizeText(id, configApi.getConfig());
let node: Node;
if (nodes[id] === undefined) {
nodes[id] = new Node(id);
}
node = nodes[id];
const node = nodes[id];
return node;
}
};
export default {
// sankey interface
@ -102,5 +102,5 @@ export default {
// setAccDescription,
getDiagramTitle,
setDiagramTitle,
clear
clear,
};

View File

@ -11,4 +11,3 @@ export const diagram: DiagramDefinition = {
renderer,
styles,
};

View File

@ -9,16 +9,15 @@ import { Diagram } from '../../Diagram.js';
* @param diagObj - A standard diagram containing the db and the text and type etc of the diagram
*/
export const draw = function (text: string, id: string, _version: string, diagObj: Diagram) {
debugger;
// debugger;
// diagObj.db.clear();
diagObj.parser.parse(text);
// const elem = doc.getElementById(id);
debugger;
// debugger;
return 'TEST';
}
};
export default {
draw,