From 07de0907238db20abb50d905a71331d8394480cd Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 16 Apr 2024 13:14:59 -0700 Subject: [PATCH 01/50] fix: move from objects to Maps --- docs/config/setup/modules/mermaidAPI.md | 2 +- .../src/flowRenderer-elk.js | 6 +- packages/mermaid/src/diagram-api/types.ts | 2 +- .../mermaid/src/diagrams/block/blockDB.ts | 63 +-- .../src/diagrams/block/parser/block.spec.ts | 2 +- .../mermaid/src/diagrams/class/classDb.ts | 71 +-- .../src/diagrams/class/classDiagram.spec.ts | 37 +- .../src/diagrams/class/classRenderer-v2.ts | 15 +- .../src/diagrams/class/classRenderer.js | 4 +- .../mermaid/src/diagrams/class/classTypes.ts | 4 +- packages/mermaid/src/diagrams/er/erDb.js | 14 +- .../mermaid/src/diagrams/er/erRenderer.js | 6 +- .../src/diagrams/er/parser/erDiagram.spec.js | 200 ++++---- .../src/diagrams/flowchart/flowDb.spec.ts | 12 +- .../mermaid/src/diagrams/flowchart/flowDb.ts | 87 ++-- .../src/diagrams/flowchart/flowRenderer-v2.js | 12 +- .../src/diagrams/flowchart/flowRenderer.js | 6 +- .../flowchart/parser/flow-arrows.spec.js | 56 +-- .../flowchart/parser/flow-comments.spec.js | 36 +- .../flowchart/parser/flow-edges.spec.js | 94 ++-- .../flowchart/parser/flow-huge.spec.js | 2 +- .../flowchart/parser/flow-md-string.spec.js | 12 +- .../flowchart/parser/flow-singlenode.spec.js | 80 ++-- .../flowchart/parser/flow-style.spec.js | 138 +++--- .../flowchart/parser/flow-text.spec.js | 98 ++-- .../parser/flow-vertice-chaining.spec.js | 60 +-- .../diagrams/flowchart/parser/flow.spec.js | 32 +- .../mermaid/src/diagrams/gantt/ganttDb.js | 6 +- .../src/diagrams/gantt/ganttRenderer.js | 4 +- .../mermaid/src/diagrams/git/gitGraphAst.js | 90 ++-- .../src/diagrams/git/gitGraphParser.spec.js | 78 +-- .../src/diagrams/git/gitGraphParserV2.spec.js | 449 +++++++++--------- .../src/diagrams/git/gitGraphRenderer.js | 18 +- packages/mermaid/src/diagrams/pie/pie.spec.ts | 34 +- packages/mermaid/src/diagrams/pie/pieDb.ts | 8 +- .../mermaid/src/diagrams/pie/pieRenderer.ts | 6 +- packages/mermaid/src/diagrams/pie/pieTypes.ts | 2 +- .../parser/requirementDiagram.spec.js | 42 +- .../src/diagrams/requirement/requirementDb.js | 25 +- .../requirement/requirementRenderer.js | 8 +- .../mermaid/src/diagrams/sankey/sankeyDB.ts | 12 +- .../src/diagrams/sequence/sequenceDb.ts | 32 +- .../diagrams/sequence/sequenceDiagram.spec.js | 212 ++++----- .../src/diagrams/sequence/sequenceRenderer.ts | 95 ++-- .../mermaid/src/diagrams/sequence/svgDraw.js | 2 +- .../state/parser/state-parser.spec.js | 42 +- .../diagrams/state/parser/state-style.spec.js | 72 +-- .../mermaid/src/diagrams/state/stateDb.js | 40 +- .../src/diagrams/state/stateDb.spec.js | 26 +- .../diagrams/state/stateDiagram-v2.spec.js | 2 +- .../src/diagrams/state/stateRenderer-v2.js | 2 +- packages/mermaid/src/mermaidAPI.spec.ts | 15 +- packages/mermaid/src/mermaidAPI.ts | 10 +- 53 files changed, 1245 insertions(+), 1238 deletions(-) diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md index 1a68b05bd0..6531da18f9 100644 --- a/docs/config/setup/modules/mermaidAPI.md +++ b/docs/config/setup/modules/mermaidAPI.md @@ -194,7 +194,7 @@ the string with all the user styles | :---------- | :-------------------------------------------------------- | | `config` | `MermaidConfig` | | `graphType` | `string` | -| `classDefs` | `undefined` \| `Record`<`string`, `DiagramStyleClassDef`> | +| `classDefs` | `undefined` \| `Map`<`string`, `DiagramStyleClassDef`> | | `svgId` | `string` | #### Returns diff --git a/packages/mermaid-flowchart-elk/src/flowRenderer-elk.js b/packages/mermaid-flowchart-elk/src/flowRenderer-elk.js index ea6b9af750..c7bf41ce23 100644 --- a/packages/mermaid-flowchart-elk/src/flowRenderer-elk.js +++ b/packages/mermaid-flowchart-elk/src/flowRenderer-elk.js @@ -41,12 +41,12 @@ let nodeDb = {}; export const addVertices = async function (vert, svgId, root, doc, diagObj, parentLookupDb, graph) { const svg = root.select(`[id="${svgId}"]`); const nodes = svg.insert('g').attr('class', 'nodes'); - const keys = Object.keys(vert); + const keys = [...vert.keys()]; // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition await Promise.all( keys.map(async function (id) { - const vertex = vert[id]; + const vertex = vert.get(id); /** * Variable for storing the classes for the vertex @@ -595,7 +595,7 @@ const addMarkersToEdge = function (svgPath, edgeData, diagramType, arrowMarkerAb * * @param text * @param diagObj - * @returns {Record} ClassDef styles + * @returns {Map} ClassDef styles */ export const getClasses = function (text, diagObj) { log.info('Extracting classes'); diff --git a/packages/mermaid/src/diagram-api/types.ts b/packages/mermaid/src/diagram-api/types.ts index 6ab82bd0dc..4556c1d6eb 100644 --- a/packages/mermaid/src/diagram-api/types.ts +++ b/packages/mermaid/src/diagram-api/types.ts @@ -70,7 +70,7 @@ export interface DiagramRenderer { getClasses?: ( text: string, diagram: Pick - ) => Record; + ) => Map; } export interface DiagramDefinition { diff --git a/packages/mermaid/src/diagrams/block/blockDB.ts b/packages/mermaid/src/diagrams/block/blockDB.ts index e4c863c1dd..c53e0598a1 100644 --- a/packages/mermaid/src/diagrams/block/blockDB.ts +++ b/packages/mermaid/src/diagrams/block/blockDB.ts @@ -6,16 +6,16 @@ import { clear as commonClear } from '../common/commonDb.js'; import type { Block, ClassDef } from './blockTypes.js'; // Initialize the node database for simple lookups -let blockDatabase: Record = {}; +let blockDatabase: Map = new Map(); let edgeList: Block[] = []; -let edgeCount: Record = {}; +let edgeCount: Map = new Map(); const COLOR_KEYWORD = 'color'; const FILL_KEYWORD = 'fill'; const BG_FILL = 'bgFill'; const STYLECLASS_SEP = ','; -let classes = {} as Record; +let classes: Map = new Map(); /** * Called when the parser comes across a (style) class definition @@ -26,10 +26,10 @@ let classes = {} as Record; */ export const addStyleClass = function (id: string, styleAttributes = '') { // create a new style class object with this id - if (classes[id] === undefined) { - classes[id] = { id: id, styles: [], textStyles: [] }; // This is a classDef + if (!classes.has(id)) { + classes.set(id, { id: id, styles: [], textStyles: [] }); // This is a classDef } - const foundClass = classes[id]; + const foundClass = classes.get(id)!; if (styleAttributes !== undefined && styleAttributes !== null) { styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { // remove any trailing ; @@ -54,7 +54,7 @@ export const addStyleClass = function (id: string, styleAttributes = '') { * @param styles - the string with 1 or more style attributes (each separated by a comma) */ export const addStyle2Node = function (id: string, styles = '') { - const foundBlock = blockDatabase[id]; + const foundBlock = blockDatabase.get(id)!; if (styles !== undefined && styles !== null) { foundBlock.styles = styles.split(STYLECLASS_SEP); } @@ -70,16 +70,16 @@ export const addStyle2Node = function (id: string, styles = '') { */ export const setCssClass = function (itemIds: string, cssClassName: string) { itemIds.split(',').forEach(function (id: string) { - let foundBlock = blockDatabase[id]; + let foundBlock = blockDatabase.get(id); if (foundBlock === undefined) { const trimmedId = id.trim(); - blockDatabase[trimmedId] = { id: trimmedId, type: 'na', children: [] } as Block; - foundBlock = blockDatabase[trimmedId]; + blockDatabase.set(trimmedId, { id: trimmedId, type: 'na', children: [] } as Block); + foundBlock = blockDatabase.get(trimmedId); } - if (!foundBlock.classes) { - foundBlock.classes = []; + if (!foundBlock!.classes) { + foundBlock!.classes = []; } - foundBlock.classes.push(cssClassName); + foundBlock!.classes.push(cssClassName); }); }; @@ -104,12 +104,12 @@ const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): if (block.type === 'column-setting') { parent.columns = block.columns || -1; } else if (block.type === 'edge') { - if (edgeCount[block.id]) { - edgeCount[block.id]++; + if (edgeCount.has(block.id)) { + edgeCount.set(block.id, edgeCount.get(block.id)! + 1); } else { - edgeCount[block.id] = 1; + edgeCount.set(block.id, 1); } - block.id = edgeCount[block.id] + '-' + block.id; + block.id = edgeCount.get(block.id)! + '-' + block.id; edgeList.push(block); } else { if (!block.label) { @@ -120,16 +120,17 @@ const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): block.label = block.id; } } - const newBlock = !blockDatabase[block.id]; - if (newBlock) { - blockDatabase[block.id] = block; + const isCreatingBlock = !blockDatabase.has(block.id); + + if (isCreatingBlock) { + blockDatabase.set(block.id, block); } else { // Add newer relevant data to aggregated node if (block.type !== 'na') { - blockDatabase[block.id].type = block.type; + blockDatabase.get(block.id)!.type = block.type; } if (block.label !== block.id) { - blockDatabase[block.id].label = block.label; + blockDatabase.get(block.id)!.label = block.label; } } @@ -142,10 +143,10 @@ const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): for (let j = 0; j < w; j++) { const newBlock = clone(block); newBlock.id = newBlock.id + '-' + j; - blockDatabase[newBlock.id] = newBlock; + blockDatabase.set(newBlock.id, newBlock); children.push(newBlock); } - } else if (newBlock) { + } else if (isCreatingBlock) { children.push(block); } } @@ -160,12 +161,12 @@ const clear = (): void => { log.debug('Clear called'); commonClear(); rootBlock = { id: 'root', type: 'composite', children: [], columns: -1 } as Block; - blockDatabase = { root: rootBlock }; + blockDatabase = new Map([['root', rootBlock]]); blocks = [] as Block[]; - classes = {} as Record; + classes = new Map(); edgeList = []; - edgeCount = {}; + edgeCount = new Map(); }; export function typeStr2Type(typeStr: string) { @@ -241,7 +242,7 @@ const setHierarchy = (block: Block[]): void => { }; const getColumns = (blockId: string): number => { - const block = blockDatabase[blockId]; + const block = blockDatabase.get(blockId); if (!block) { return -1; } @@ -259,7 +260,7 @@ const getColumns = (blockId: string): number => { * @returns */ const getBlocksFlat = () => { - return [...Object.values(blockDatabase)]; + return [...blockDatabase.values()]; }; /** * Returns the the hierarchy of blocks @@ -273,11 +274,11 @@ const getEdges = () => { return edgeList; }; const getBlock = (id: string) => { - return blockDatabase[id]; + return blockDatabase.get(id); }; const setBlock = (block: Block) => { - blockDatabase[block.id] = block; + blockDatabase.set(block.id, block); }; const getLogger = () => console; diff --git a/packages/mermaid/src/diagrams/block/parser/block.spec.ts b/packages/mermaid/src/diagrams/block/parser/block.spec.ts index 65338375aa..8618f4d027 100644 --- a/packages/mermaid/src/diagrams/block/parser/block.spec.ts +++ b/packages/mermaid/src/diagrams/block/parser/block.spec.ts @@ -388,7 +388,7 @@ describe('Block diagram', function () { const mc = blocks[0]; expect(mc.classes).toContain('black'); const classes = db.getClasses(); - const black = classes.black; + const black = classes.get('black')!; expect(black.id).toBe('black'); expect(black.styles[0]).toEqual('color:#ffffff'); }); diff --git a/packages/mermaid/src/diagrams/class/classDb.ts b/packages/mermaid/src/diagrams/class/classDb.ts index 0e18d1e0fa..b3d6f04682 100644 --- a/packages/mermaid/src/diagrams/class/classDb.ts +++ b/packages/mermaid/src/diagrams/class/classDb.ts @@ -26,10 +26,10 @@ import type { const MERMAID_DOM_ID_PREFIX = 'classId-'; let relations: ClassRelation[] = []; -let classes: ClassMap = {}; +let classes: Map = new Map(); let notes: ClassNote[] = []; let classCounter = 0; -let namespaces: NamespaceMap = {}; +let namespaces: Map = new Map(); let namespaceCounter = 0; let functions: any[] = []; @@ -57,7 +57,7 @@ export const setClassLabel = function (_id: string, label: string) { } const { className } = splitClassNameAndType(id); - classes[className].label = label; + classes.get(className)!.label = label; }; /** @@ -70,13 +70,13 @@ export const addClass = function (_id: string) { const id = common.sanitizeText(_id, getConfig()); const { className, type } = splitClassNameAndType(id); // Only add class if not exists - if (Object.hasOwn(classes, className)) { + if (classes.has(className)) { return; } // alert('Adding class: ' + className); const name = common.sanitizeText(className, getConfig()); // alert('Adding class after: ' + name); - classes[name] = { + classes.set(name, { id: name, type: type, label: name, @@ -86,7 +86,7 @@ export const addClass = function (_id: string) { annotations: [], styles: [], domId: MERMAID_DOM_ID_PREFIX + name + '-' + classCounter, - } as ClassNode; + } as ClassNode); classCounter++; }; @@ -99,25 +99,25 @@ export const addClass = function (_id: string) { */ export const lookUpDomId = function (_id: string): string { const id = common.sanitizeText(_id, getConfig()); - if (id in classes) { - return classes[id].domId; + if (classes.has(id)) { + return classes.get(id)!.domId; } throw new Error('Class not found: ' + id); }; export const clear = function () { relations = []; - classes = {}; + classes = new Map(); notes = []; functions = []; functions.push(setupToolTips); - namespaces = {}; + namespaces = new Map(); namespaceCounter = 0; commonClear(); }; export const getClass = function (id: string): ClassNode { - return classes[id]; + return classes.get(id)!; }; export const getClasses = function (): ClassMap { @@ -157,7 +157,7 @@ export const addRelation = function (relation: ClassRelation) { */ export const addAnnotation = function (className: string, annotation: string) { const validatedClassName = splitClassNameAndType(className).className; - classes[validatedClassName].annotations.push(annotation); + classes.get(validatedClassName)!.annotations.push(annotation); }; /** @@ -173,7 +173,7 @@ export const addMember = function (className: string, member: string) { addClass(className); const validatedClassName = splitClassNameAndType(className).className; - const theClass = classes[validatedClassName]; + const theClass = classes.get(validatedClassName)!; if (typeof member === 'string') { // Member can contain white spaces, we trim them out @@ -226,8 +226,8 @@ export const setCssClass = function (ids: string, className: string) { if (_id[0].match(/\d/)) { id = MERMAID_DOM_ID_PREFIX + id; } - if (classes[id] !== undefined) { - classes[id].cssClasses.push(className); + if (classes.has(id)) { + classes.get(id)!.cssClasses.push(className); } }); }; @@ -241,17 +241,17 @@ export const setCssClass = function (ids: string, className: string) { const setTooltip = function (ids: string, tooltip?: string) { ids.split(',').forEach(function (id) { if (tooltip !== undefined) { - classes[id].tooltip = sanitizeText(tooltip); + classes.get(id)!.tooltip = sanitizeText(tooltip); } }); }; export const getTooltip = function (id: string, namespace?: string) { - if (namespace) { - return namespaces[namespace].classes[id].tooltip; + if (namespace && namespaces.has(namespace)) { + return namespaces.get(namespace)!.classes.get(id)!.tooltip; } - return classes[id].tooltip; + return classes.get(id)!.tooltip; }; /** @@ -268,14 +268,15 @@ export const setLink = function (ids: string, linkStr: string, target: string) { if (_id[0].match(/\d/)) { id = MERMAID_DOM_ID_PREFIX + id; } - if (classes[id] !== undefined) { - classes[id].link = utils.formatUrl(linkStr, config); + if (classes.has(id)) { + const theClass = classes.get(id)!; + theClass.link = utils.formatUrl(linkStr, config); if (config.securityLevel === 'sandbox') { - classes[id].linkTarget = '_top'; + theClass.linkTarget = '_top'; } else if (typeof target === 'string') { - classes[id].linkTarget = sanitizeText(target); + theClass.linkTarget = sanitizeText(target); } else { - classes[id].linkTarget = '_blank'; + theClass.linkTarget = '_blank'; } } }); @@ -292,7 +293,7 @@ export const setLink = function (ids: string, linkStr: string, target: string) { export const setClickEvent = function (ids: string, functionName: string, functionArgs: string) { ids.split(',').forEach(function (id) { setClickFunc(id, functionName, functionArgs); - classes[id].haveCallback = true; + classes.get(id)!.haveCallback = true; }); setCssClass(ids, 'clickable'); }; @@ -308,7 +309,7 @@ const setClickFunc = function (_domId: string, functionName: string, functionArg } const id = domId; - if (classes[id] !== undefined) { + if (classes.has(id)) { const elemId = lookUpDomId(id); let argList: string[] = []; if (typeof functionArgs === 'string') { @@ -417,22 +418,22 @@ const setDirection = (dir: string) => { * @public */ export const addNamespace = function (id: string) { - if (namespaces[id] !== undefined) { + if (namespaces.has(id)) { return; } - namespaces[id] = { + namespaces.set(id, { id: id, - classes: {}, + classes: new Map(), children: {}, domId: MERMAID_DOM_ID_PREFIX + id + '-' + namespaceCounter, - } as NamespaceNode; + } as NamespaceNode); namespaceCounter++; }; const getNamespace = function (name: string): NamespaceNode { - return namespaces[name]; + return namespaces.get(name)!; }; const getNamespaces = function (): NamespaceMap { @@ -447,18 +448,18 @@ const getNamespaces = function (): NamespaceMap { * @public */ export const addClassesToNamespace = function (id: string, classNames: string[]) { - if (namespaces[id] === undefined) { + if (!namespaces.has(id)) { return; } for (const name of classNames) { const { className } = splitClassNameAndType(name); - classes[className].parent = id; - namespaces[id].classes[className] = classes[className]; + classes.get(className)!.parent = id; + namespaces.get(id)!.classes.set(className, classes.get(className)!); } }; export const setCssStyle = function (id: string, styles: string[]) { - const thisClass = classes[id]; + const thisClass = classes.get(id); if (!styles || !thisClass) { return; } diff --git a/packages/mermaid/src/diagrams/class/classDiagram.spec.ts b/packages/mermaid/src/diagrams/class/classDiagram.spec.ts index e3dbb17f14..8412c6fbf2 100644 --- a/packages/mermaid/src/diagrams/class/classDiagram.spec.ts +++ b/packages/mermaid/src/diagrams/class/classDiagram.spec.ts @@ -2,6 +2,7 @@ import { parser } from './parser/classDiagram.jison'; import classDb from './classDb.js'; import { vi, describe, it, expect } from 'vitest'; +import type { ClassMap, NamespaceNode } from './classTypes.js'; const spyOn = vi.spyOn; const staticCssStyle = 'text-decoration:underline;'; @@ -392,8 +393,8 @@ class C13["With Città foreign language"] Student "1" --o "1" IdCard : carries Student "1" --o "1" Bike : rides`); - expect(Object.keys(classDb.getClasses()).length).toBe(3); - expect(classDb.getClasses().Student).toMatchInlineSnapshot(` + expect(classDb.getClasses().size).toBe(3); + expect(classDb.getClasses().get('Student')).toMatchInlineSnapshot(` { "annotations": [], "cssClasses": [], @@ -1539,12 +1540,12 @@ class Class2 }`; parser.parse(str); - const testNamespace = parser.yy.getNamespace('Namespace1'); - const testClasses = parser.yy.getClasses(); - expect(Object.keys(testNamespace.classes).length).toBe(2); + const testNamespace: NamespaceNode = parser.yy.getNamespace('Namespace1'); + const testClasses: ClassMap = parser.yy.getClasses(); + expect(testNamespace.classes.size).toBe(2); expect(Object.keys(testNamespace.children).length).toBe(0); - expect(testNamespace.classes['Class1'].id).toBe('Class1'); - expect(Object.keys(testClasses).length).toBe(2); + expect(testNamespace.classes.get('Class1')?.id).toBe('Class1'); + expect(testClasses.size).toBe(2); }); it('should add relations between classes of different namespaces', function () { @@ -1573,25 +1574,25 @@ class Class2 const testNamespaceB = parser.yy.getNamespace('B'); const testClasses = parser.yy.getClasses(); const testRelations = parser.yy.getRelations(); - expect(Object.keys(testNamespaceA.classes).length).toBe(2); - expect(testNamespaceA.classes['A1'].members[0].getDisplayDetails().displayText).toBe( + expect(testNamespaceA.classes.size).toBe(2); + expect(testNamespaceA.classes.get('A1').members[0].getDisplayDetails().displayText).toBe( '+foo : string' ); - expect(testNamespaceA.classes['A2'].members[0].getDisplayDetails().displayText).toBe( + expect(testNamespaceA.classes.get('A2').members[0].getDisplayDetails().displayText).toBe( '+bar : int' ); - expect(Object.keys(testNamespaceB.classes).length).toBe(2); - expect(testNamespaceB.classes['B1'].members[0].getDisplayDetails().displayText).toBe( + expect(testNamespaceB.classes.size).toBe(2); + expect(testNamespaceB.classes.get('B1').members[0].getDisplayDetails().displayText).toBe( '+foo : bool' ); - expect(testNamespaceB.classes['B2'].members[0].getDisplayDetails().displayText).toBe( + expect(testNamespaceB.classes.get('B2').members[0].getDisplayDetails().displayText).toBe( '+bar : float' ); - expect(Object.keys(testClasses).length).toBe(4); - expect(testClasses['A1'].parent).toBe('A'); - expect(testClasses['A2'].parent).toBe('A'); - expect(testClasses['B1'].parent).toBe('B'); - expect(testClasses['B2'].parent).toBe('B'); + expect(testClasses.size).toBe(4); + expect(testClasses.get('A1').parent).toBe('A'); + expect(testClasses.get('A2').parent).toBe('A'); + expect(testClasses.get('B1').parent).toBe('B'); + expect(testClasses.get('B2').parent).toBe('B'); expect(testRelations[0].id1).toBe('A1'); expect(testRelations[0].id2).toBe('B1'); expect(testRelations[1].id1).toBe('A2'); diff --git a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts index a01b1427b5..cf80a8a708 100644 --- a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts +++ b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts @@ -44,13 +44,13 @@ export const addNamespaces = function ( _id: string, diagObj: any ) { - const keys = Object.keys(namespaces); + const keys = [...namespaces.keys()]; log.info('keys:', keys); log.info(namespaces); // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition keys.forEach(function (id) { - const vertex = namespaces[id]; + const vertex = namespaces.get(id)!; // parent node must be one of [rect, roundedWithTitle, noteGroup, divider] const shape = 'rect'; @@ -89,15 +89,15 @@ export const addClasses = function ( diagObj: any, parent?: string ) { - const keys = Object.keys(classes); + const keys = [...classes.keys()]; log.info('keys:', keys); log.info(classes); // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition keys - .filter((id) => classes[id].parent == parent) + .filter((id) => classes.get(id)!.parent == parent) .forEach(function (id) { - const vertex = classes[id]; + const vertex = classes.get(id)!; /** * Variable for storing the classes for the vertex @@ -346,7 +346,7 @@ export const draw = async function (text: string, id: string, _version: string, } const root = securityLevel === 'sandbox' - ? select(sandboxElement.nodes()[0].contentDocument.body) + ? select(sandboxElement!.nodes()[0]!.contentDocument.body) : select('body'); const svg = root.select(`[id="${id}"]`); @@ -366,7 +366,8 @@ export const draw = async function (text: string, id: string, _version: string, // Add label rects for non html labels if (!conf?.htmlLabels) { - const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document; + const doc = + securityLevel === 'sandbox' ? sandboxElement!.nodes()[0]!.contentDocument : document; const labels = doc.querySelectorAll('[id="' + id + '"] .edgeLabel .label'); for (const label of labels) { // Get dimensions of label diff --git a/packages/mermaid/src/diagrams/class/classRenderer.js b/packages/mermaid/src/diagrams/class/classRenderer.js index be098b0274..381b93341f 100644 --- a/packages/mermaid/src/diagrams/class/classRenderer.js +++ b/packages/mermaid/src/diagrams/class/classRenderer.js @@ -175,10 +175,10 @@ export const draw = function (text, id, _version, diagObj) { }); const classes = diagObj.db.getClasses(); - const keys = Object.keys(classes); + const keys = [...classes.keys()]; for (const key of keys) { - const classDef = classes[key]; + const classDef = classes.get(key); const node = svgDraw.drawClass(diagram, classDef, conf, diagObj); idCache[node.id] = node; diff --git a/packages/mermaid/src/diagrams/class/classTypes.ts b/packages/mermaid/src/diagrams/class/classTypes.ts index c2f1587027..5c5812ee10 100644 --- a/packages/mermaid/src/diagrams/class/classTypes.ts +++ b/packages/mermaid/src/diagrams/class/classTypes.ts @@ -161,5 +161,5 @@ export interface NamespaceNode { children: NamespaceMap; } -export type ClassMap = Record; -export type NamespaceMap = Record; +export type ClassMap = Map; +export type NamespaceMap = Map; diff --git a/packages/mermaid/src/diagrams/er/erDb.js b/packages/mermaid/src/diagrams/er/erDb.js index a58b9bbc1a..745ef938ad 100644 --- a/packages/mermaid/src/diagrams/er/erDb.js +++ b/packages/mermaid/src/diagrams/er/erDb.js @@ -11,7 +11,7 @@ import { getDiagramTitle, } from '../common/commonDb.js'; -let entities = {}; +let entities = new Map(); let relationships = []; const Cardinality = { @@ -28,15 +28,15 @@ const Identification = { }; const addEntity = function (name, alias = undefined) { - if (entities[name] === undefined) { - entities[name] = { attributes: [], alias: alias }; + if (!entities.has(name)) { + entities.set(name, { attributes: [], alias: alias }); log.info('Added new entity :', name); - } else if (entities[name] && !entities[name].alias && alias) { - entities[name].alias = alias; + } else if (entities.has(name) && !entities.get(name).alias && alias) { + entities.get(name).alias = alias; log.info(`Add alias '${alias}' to entity '${name}'`); } - return entities[name]; + return entities.get(name); }; const getEntities = () => entities; @@ -75,7 +75,7 @@ const addRelationship = function (entA, rolA, entB, rSpec) { const getRelationships = () => relationships; const clear = function () { - entities = {}; + entities = new Map(); relationships = []; commonClear(); }; diff --git a/packages/mermaid/src/diagrams/er/erRenderer.js b/packages/mermaid/src/diagrams/er/erRenderer.js index e8b25d50bb..7f0a0e914a 100644 --- a/packages/mermaid/src/diagrams/er/erRenderer.js +++ b/packages/mermaid/src/diagrams/er/erRenderer.js @@ -301,7 +301,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => { * @returns {object} The first entity that was inserted */ const drawEntities = function (svgNode, entities, graph) { - const keys = Object.keys(entities); + const keys = [...entities.keys()]; let firstOne; keys.forEach(function (entityName) { @@ -326,12 +326,12 @@ const drawEntities = function (svgNode, entities, graph) { .style('text-anchor', 'middle') .style('font-family', getConfig().fontFamily) .style('font-size', conf.fontSize + 'px') - .text(entities[entityName].alias ?? entityName); + .text(entities.get(entityName).alias ?? entityName); const { width: entityWidth, height: entityHeight } = drawAttributes( groupNode, textNode, - entities[entityName].attributes + entities.get(entityName).attributes ); // Draw the rectangle - insert it before the text so that the text is not obscured diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js index ba29ff04b9..f63fd40e23 100644 --- a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js +++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js @@ -17,7 +17,7 @@ describe('when parsing ER diagram it...', function () { const line2 = 'MAINLAND'; erDiagram.parser.parse(`erDiagram\n${line1}\n${line2}`); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(erDb.getRelationships().length).toBe(0); }); @@ -27,7 +27,7 @@ describe('when parsing ER diagram it...', function () { expect(() => { erDiagram.parser.parse(`erDiagram\n ${name}\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(false); + expect(entities.has(name)).toBe(false); }).toThrow(); }); describe('has non A-Za-z0-9_- chars', function () { @@ -47,7 +47,7 @@ describe('when parsing ER diagram it...', function () { expect(() => { erDiagram.parser.parse(`erDiagram\n ${name}\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(false); + expect(entities.has(name)).toBe(false); }).toThrow(); }); @@ -55,21 +55,21 @@ describe('when parsing ER diagram it...', function () { const name = singleOccurrence; erDiagram.parser.parse(`erDiagram\n "${name}"\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(true); + expect(entities.has(name)).toBe(true); }); it(`"${repeatedOccurrence}" repeated occurrence`, function () { const name = repeatedOccurrence; erDiagram.parser.parse(`erDiagram\n "${name}"\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(true); + expect(entities.has(name)).toBe(true); }); it(`"${singleOccurrence}" ends with`, function () { const name = endsWith; erDiagram.parser.parse(`erDiagram\n "${name}"\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(true); + expect(entities.has(name)).toBe(true); }); it(`"${cannontStartWith}" cannot start with the character`, function () { @@ -77,7 +77,7 @@ describe('when parsing ER diagram it...', function () { expect(() => { erDiagram.parser.parse(`erDiagram\n "${name}"\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(false); + expect(entities.has(name)).toBe(false); }).toThrow(); }); }); @@ -88,7 +88,7 @@ describe('when parsing ER diagram it...', function () { const name = 'a' + allCombined; erDiagram.parser.parse(`erDiagram\n "${name}"\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(true); + expect(entities.has(name)).toBe(true); }); }); @@ -96,14 +96,14 @@ describe('when parsing ER diagram it...', function () { expect(() => { erDiagram.parser.parse(`erDiagram\n "Blo%rf"\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(false); + expect(entities.has(name)).toBe(false); }).toThrow(); }); it('cannot contain \\ because it could start and escape code', function () { expect(() => { erDiagram.parser.parse(`erDiagram\n "Blo\\rf"\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(name)).toBe(false); + expect(entities.has(name)).toBe(false); }).toThrow(); }); @@ -114,7 +114,7 @@ describe('when parsing ER diagram it...', function () { expect(() => { erDiagram.parser.parse(`erDiagram\n "${badName}"\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(badName)).toBe(false); + expect(entities.has(badName)).toBe(false); }).toThrow(); }); }); @@ -124,14 +124,14 @@ describe('when parsing ER diagram it...', function () { const beyondEnglishName = 'DUCK-àáâäæãåā'; erDiagram.parser.parse(`erDiagram\n${beyondEnglishName}\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(beyondEnglishName)).toBe(true); + expect(entities.has(beyondEnglishName)).toBe(true); }); it('can contain - _ without needing ""', function () { const hyphensUnderscore = 'DUCK-BILLED_PLATYPUS'; erDiagram.parser.parse(`erDiagram\n${hyphensUnderscore}\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(hyphensUnderscore)).toBe(true); + expect(entities.has(hyphensUnderscore)).toBe(true); }); it('can have an alias', function () { @@ -139,8 +139,8 @@ describe('when parsing ER diagram it...', function () { const alias = 'bar'; erDiagram.parser.parse(`erDiagram\n${entity}["${alias}"]\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(entity)).toBe(true); - expect(entities[entity].alias).toBe(alias); + expect(entities.has(entity)).toBe(true); + expect(entities.get(entity).alias).toBe(alias); }); it('can have an alias even if the relationship is defined before class', function () { @@ -151,10 +151,10 @@ describe('when parsing ER diagram it...', function () { `erDiagram\n${firstEntity} ||--o| ${secondEntity} : rel\nclass ${firstEntity}["${alias}"]\n` ); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(firstEntity)).toBe(true); - expect(entities.hasOwnProperty(secondEntity)).toBe(true); - expect(entities[firstEntity].alias).toBe(alias); - expect(entities[secondEntity].alias).toBeUndefined(); + expect(entities.has(firstEntity)).toBe(true); + expect(entities.has(secondEntity)).toBe(true); + expect(entities.get(firstEntity).alias).toBe(alias); + expect(entities.get(secondEntity).alias).toBeUndefined(); }); it('can have an alias even if the relationship is defined after class', function () { @@ -165,17 +165,17 @@ describe('when parsing ER diagram it...', function () { `erDiagram\nclass ${firstEntity}["${alias}"]\n${firstEntity} ||--o| ${secondEntity} : rel\n` ); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(firstEntity)).toBe(true); - expect(entities.hasOwnProperty(secondEntity)).toBe(true); - expect(entities[firstEntity].alias).toBe(alias); - expect(entities[secondEntity].alias).toBeUndefined(); + expect(entities.has(firstEntity)).toBe(true); + expect(entities.has(secondEntity)).toBe(true); + expect(entities.get(firstEntity).alias).toBe(alias); + expect(entities.get(secondEntity).alias).toBeUndefined(); }); it('can start with an underscore', function () { const entity = '_foo'; erDiagram.parser.parse(`erDiagram\n${entity}\n`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty(entity)).toBe(true); + expect(entities.has(entity)).toBe(true); }); }); @@ -191,11 +191,11 @@ describe('when parsing ER diagram it...', function () { ); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(3); - expect(entities[entity].attributes[0].attributeName).toBe('myBookTitle'); - expect(entities[entity].attributes[1].attributeName).toBe('MYBOOKSUBTITLE_1'); - expect(entities[entity].attributes[2].attributeName).toBe('author-ref[name](1)'); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(3); + expect(entities.get(entity).attributes[0].attributeName).toBe('myBookTitle'); + expect(entities.get(entity).attributes[1].attributeName).toBe('MYBOOKSUBTITLE_1'); + expect(entities.get(entity).attributes[2].attributeName).toBe('author-ref[name](1)'); }); it('should allow asterisk at the start of attribute name', function () { @@ -204,8 +204,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity}{\n${attribute}}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(1); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(1); }); it('should allow asterisks at the start of attribute declared with type and name', () => { @@ -214,8 +214,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute}}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(1); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(1); }); it('should not allow leading numbers, dashes or brackets', function () { @@ -236,8 +236,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute}\n}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(1); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(1); }); it('should allow an entity with a single attribute to be defined with a key', function () { @@ -246,8 +246,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute}\n}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(1); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(1); }); it('should allow an entity with a single attribute to be defined with a comment', function () { @@ -256,9 +256,9 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute}\n}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(1); - expect(entities[entity].attributes[0].attributeComment).toBe('comment'); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(1); + expect(entities.get(entity).attributes[0].attributeComment).toBe('comment'); }); it('should allow an entity with a single attribute to be defined with a key and a comment', function () { @@ -267,8 +267,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute}\n}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(1); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(1); }); it('should allow an entity with attribute starting with fk, pk or uk and a comment', function () { @@ -282,7 +282,7 @@ describe('when parsing ER diagram it...', function () { `erDiagram\n${entity} {\n${attribute1} \n\n${attribute2}\n${attribute3}\n${attribute4}\n}` ); const entities = erDb.getEntities(); - expect(entities[entity].attributes.length).toBe(4); + expect(entities.get(entity).attributes.length).toBe(4); }); it('should allow an entity with attributes that have many constraints and comments', function () { @@ -297,14 +297,14 @@ describe('when parsing ER diagram it...', function () { `erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n${attribute3}\n${attribute4}\n${attribute5}\n}` ); const entities = erDb.getEntities(); - expect(entities[entity].attributes[0].attributeKeyTypeList).toEqual(['PK', 'FK']); - expect(entities[entity].attributes[0].attributeComment).toBe('comment1'); - expect(entities[entity].attributes[1].attributeKeyTypeList).toEqual(['PK', 'UK', 'FK']); - expect(entities[entity].attributes[2].attributeKeyTypeList).toEqual(['PK', 'UK']); - expect(entities[entity].attributes[2].attributeComment).toBe('comment3'); - expect(entities[entity].attributes[3].attributeKeyTypeList).toBeUndefined(); - expect(entities[entity].attributes[4].attributeKeyTypeList).toBeUndefined(); - expect(entities[entity].attributes[4].attributeComment).toBe('comment5'); + expect(entities.get(entity).attributes[0].attributeKeyTypeList).toEqual(['PK', 'FK']); + expect(entities.get(entity).attributes[0].attributeComment).toBe('comment1'); + expect(entities.get(entity).attributes[1].attributeKeyTypeList).toEqual(['PK', 'UK', 'FK']); + expect(entities.get(entity).attributes[2].attributeKeyTypeList).toEqual(['PK', 'UK']); + expect(entities.get(entity).attributes[2].attributeComment).toBe('comment3'); + expect(entities.get(entity).attributes[3].attributeKeyTypeList).toBeUndefined(); + expect(entities.get(entity).attributes[4].attributeKeyTypeList).toBeUndefined(); + expect(entities.get(entity).attributes[4].attributeComment).toBe('comment5'); }); it('should allow an entity with attribute that has a generic type', function () { @@ -317,8 +317,8 @@ describe('when parsing ER diagram it...', function () { `erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n${attribute3}\n}` ); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(3); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(3); }); it('should allow an entity with attribute that is an array', function () { @@ -328,8 +328,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(2); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(2); }); it('should allow an entity with attribute that is a limited length string', function () { @@ -339,10 +339,10 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(2); - expect(entities[entity].attributes[0].attributeType).toBe('character(10)'); - expect(entities[entity].attributes[1].attributeType).toBe('varchar(5)'); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(2); + expect(entities.get(entity).attributes[0].attributeType).toBe('character(10)'); + expect(entities.get(entity).attributes[1].attributeType).toBe('varchar(5)'); }); it('should allow an entity with multiple attributes to be defined', function () { @@ -355,7 +355,7 @@ describe('when parsing ER diagram it...', function () { `erDiagram\n${entity} {\n${attribute1}\n${attribute2}\n${attribute3}\n}` ); const entities = erDb.getEntities(); - expect(entities[entity].attributes.length).toBe(3); + expect(entities.get(entity).attributes.length).toBe(3); }); it('should allow attribute definitions to be split into multiple blocks', function () { @@ -368,7 +368,7 @@ describe('when parsing ER diagram it...', function () { `erDiagram\n${entity} {\n${attribute1}\n}\n${entity} {\n${attribute2}\n${attribute3}\n}` ); const entities = erDb.getEntities(); - expect(entities[entity].attributes.length).toBe(3); + expect(entities.get(entity).attributes.length).toBe(3); }); it('should allow an empty attribute block', function () { @@ -376,8 +376,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {}`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty('BOOK')).toBe(true); - expect(entities[entity].attributes.length).toBe(0); + expect(entities.has('BOOK')).toBe(true); + expect(entities.get(entity).attributes.length).toBe(0); }); it('should allow an attribute block to start immediately after the entity name', function () { @@ -385,8 +385,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity}{}`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty('BOOK')).toBe(true); - expect(entities[entity].attributes.length).toBe(0); + expect(entities.has('BOOK')).toBe(true); + expect(entities.get(entity).attributes.length).toBe(0); }); it('should allow an attribute block to be separated from the entity name by spaces', function () { @@ -394,8 +394,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {}`); const entities = erDb.getEntities(); - expect(entities.hasOwnProperty('BOOK')).toBe(true); - expect(entities[entity].attributes.length).toBe(0); + expect(entities.has('BOOK')).toBe(true); + expect(entities.get(entity).attributes.length).toBe(0); }); it('should allow whitespace before and after attribute definitions', function () { @@ -404,8 +404,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity} {\n \n\n ${attribute}\n\n \n}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(1); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(1); }); it('should allow no whitespace before and after attribute definitions', function () { @@ -414,8 +414,8 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${entity}{${attribute}}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(1); - expect(entities[entity].attributes.length).toBe(1); + expect(entities.size).toBe(1); + expect(entities.get(entity).attributes.length).toBe(1); }); it('should associate two entities correctly', function () { @@ -423,8 +423,8 @@ describe('when parsing ER diagram it...', function () { const entities = erDb.getEntities(); const relationships = erDb.getRelationships(); - expect(entities.hasOwnProperty('CAR')).toBe(true); - expect(entities.hasOwnProperty('DRIVER')).toBe(true); + expect(entities.has('CAR')).toBe(true); + expect(entities.has('DRIVER')).toBe(true); expect(relationships.length).toBe(1); expect(relationships[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); expect(relationships[0].relSpec.cardB).toBe(erDb.Cardinality.ONLY_ONE); @@ -437,7 +437,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse(`erDiagram\n${line1}\n${line2}`); const entities = erDb.getEntities(); - expect(Object.keys(entities).length).toBe(3); + expect(entities.size).toBe(3); }); it('should create the role specified', function () { @@ -451,7 +451,7 @@ describe('when parsing ER diagram it...', function () { it('should allow recursive relationships', function () { erDiagram.parser.parse('erDiagram\nNODE ||--o{ NODE : "leads to"'); - expect(Object.keys(erDb.getEntities()).length).toBe(1); + expect(erDb.getEntities().size).toBe(1); }); describe('accessible title and description', () => { @@ -491,7 +491,7 @@ describe('when parsing ER diagram it...', function () { const entities = erDb.getEntities(); const rels = erDb.getRelationships(); - expect(Object.keys(entities).length).toBe(2); + expect(entities.size).toBe(2); expect(rels.length).toBe(2); }); @@ -507,7 +507,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA ||--|{ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONE_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONLY_ONE); @@ -517,7 +517,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA ||..o{ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONLY_ONE); @@ -527,7 +527,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA |o..o{ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_ONE); @@ -537,7 +537,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA |o--|{ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONE_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_ONE); @@ -547,7 +547,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA }|--|| B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONLY_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONE_OR_MORE); @@ -557,7 +557,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA }o--|| B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONLY_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_MORE); @@ -567,7 +567,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA }o..o| B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_MORE); @@ -577,7 +577,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA }|..o| B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONE_OR_MORE); @@ -587,7 +587,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA |o..|| B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONLY_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_ONE); @@ -597,7 +597,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA ||..|| B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONLY_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONLY_ONE); @@ -607,7 +607,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA ||--o| B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONLY_ONE); @@ -617,7 +617,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA |o..o| B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_ONE); @@ -627,7 +627,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA }o--o{ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_MORE); @@ -637,7 +637,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA }|..|{ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONE_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONE_OR_MORE); @@ -647,7 +647,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA }o--|{ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONE_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_MORE); @@ -657,7 +657,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA }|..o{ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONE_OR_MORE); @@ -667,7 +667,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA one or zero to many B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_ONE); @@ -677,7 +677,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA one or many optionally to zero or one B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONE_OR_MORE); @@ -687,7 +687,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA zero or more to zero or many B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_MORE); @@ -697,7 +697,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA many(0) to many(1) B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONE_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_MORE); @@ -707,7 +707,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA many optionally to one B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONLY_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_MORE); @@ -717,7 +717,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA only one optionally to 1+ B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONE_OR_MORE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ONLY_ONE); @@ -727,7 +727,7 @@ describe('when parsing ER diagram it...', function () { erDiagram.parser.parse('erDiagram\nA 0+ optionally to 1 B : has'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ONLY_ONE); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.ZERO_OR_MORE); @@ -786,7 +786,7 @@ describe('when parsing ER diagram it...', function () { it('should represent parent-child relationship correctly', function () { erDiagram.parser.parse('erDiagram\nPROJECT u--o{ TEAM_MEMBER : "parent"'); const rels = erDb.getRelationships(); - expect(Object.keys(erDb.getEntities()).length).toBe(2); + expect(erDb.getEntities().size).toBe(2); expect(rels.length).toBe(1); expect(rels[0].relSpec.cardB).toBe(erDb.Cardinality.MD_PARENT); expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts index 68c03bdeb0..464faa1824 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts @@ -51,17 +51,17 @@ describe('flow db addClass', () => { flowDb.addClass('a,b', ['stroke-width: 8px']); const classes = flowDb.getClasses(); - expect(classes.hasOwnProperty('a')).toBe(true); - expect(classes.hasOwnProperty('b')).toBe(true); - expect(classes['a']['styles']).toEqual(['stroke-width: 8px']); - expect(classes['b']['styles']).toEqual(['stroke-width: 8px']); + expect(classes.has('a')).toBe(true); + expect(classes.has('b')).toBe(true); + expect(classes.get('a')?.['styles']).toEqual(['stroke-width: 8px']); + expect(classes.get('b')?.['styles']).toEqual(['stroke-width: 8px']); }); it('should detect single class', () => { flowDb.addClass('a', ['stroke-width: 8px']); const classes = flowDb.getClasses(); - expect(classes.hasOwnProperty('a')).toBe(true); - expect(classes['a']['styles']).toEqual(['stroke-width: 8px']); + expect(classes.has('a')).toBe(true); + expect(classes.get('a')?.['styles']).toEqual(['stroke-width: 8px']); }); }); diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.ts index e84d7fd0c3..d90cead4d0 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.ts @@ -17,12 +17,12 @@ import type { FlowVertex, FlowClass, FlowSubGraph, FlowText, FlowEdge, FlowLink const MERMAID_DOM_ID_PREFIX = 'flowchart-'; let vertexCounter = 0; let config = getConfig(); -let vertices: Record = {}; +let vertices: Map = new Map(); let edges: FlowEdge[] & { defaultInterpolate?: string; defaultStyle?: string[] } = []; -let classes: Record = {}; +let classes: Map = new Map(); let subGraphs: FlowSubGraph[] = []; -let subGraphLookup: Record = {}; -let tooltips: Record = {}; +let subGraphLookup: Map = new Map(); +let tooltips: Map = new Map(); let subCount = 0; let firstGraphFlag = true; let direction: string; @@ -40,10 +40,10 @@ const sanitizeText = (txt: string) => common.sanitizeText(txt, config); * @param id - id of the node */ export const lookUpDomId = function (id: string) { - const vertexKeys = Object.keys(vertices); + const vertexKeys = vertices.keys(); for (const vertexKey of vertexKeys) { - if (vertices[vertexKey].id === id) { - return vertices[vertexKey].domId; + if (vertices.get(vertexKey)!.id === id) { + return vertices.get(vertexKey)!.domId; } } return id; @@ -67,50 +67,52 @@ export const addVertex = function ( } let txt; - if (vertices[id] === undefined) { - vertices[id] = { + if (!vertices.has(id)) { + vertices.set(id, { id, labelType: 'text', domId: MERMAID_DOM_ID_PREFIX + id + '-' + vertexCounter, styles: [], classes: [], - }; + }); } vertexCounter++; + const vertex = vertices.get(id)!; + if (textObj !== undefined) { config = getConfig(); txt = sanitizeText(textObj.text.trim()); - vertices[id].labelType = textObj.type; + vertex.labelType = textObj.type; // strip quotes if string starts and ends with a quote if (txt[0] === '"' && txt[txt.length - 1] === '"') { txt = txt.substring(1, txt.length - 1); } - vertices[id].text = txt; + vertex.text = txt; } else { - if (vertices[id].text === undefined) { - vertices[id].text = id; + if (vertex.text === undefined) { + vertex.text = id; } } if (type !== undefined) { - vertices[id].type = type; + vertex.type = type; } if (style !== undefined && style !== null) { style.forEach(function (s) { - vertices[id].styles.push(s); + vertex.styles.push(s); }); } if (classes !== undefined && classes !== null) { classes.forEach(function (s) { - vertices[id].classes.push(s); + vertex.classes.push(s); }); } if (dir !== undefined) { - vertices[id].dir = dir; + vertex.dir = dir; } - if (vertices[id].props === undefined) { - vertices[id].props = props; + if (vertex.props === undefined) { + vertex.props = props; } else if (props !== undefined) { - Object.assign(vertices[id].props, props); + Object.assign(vertex.props, props); } }; @@ -208,17 +210,17 @@ export const updateLink = function (positions: ('default' | number)[], style: st export const addClass = function (ids: string, style: string[]) { ids.split(',').forEach(function (id) { - if (classes[id] === undefined) { - classes[id] = { id, styles: [], textStyles: [] }; + if (!classes.has(id)) { + classes.set(id, { id, styles: [], textStyles: [] }); } if (style !== undefined && style !== null) { style.forEach(function (s) { if (s.match('color')) { const newStyle = s.replace('fill', 'bgFill').replace('color', 'fill'); - classes[id].textStyles.push(newStyle); + classes.get(id)!.textStyles.push(newStyle); } - classes[id].styles.push(s); + classes.get(id)!.styles.push(s); }); } }); @@ -255,11 +257,11 @@ export const setDirection = function (dir: string) { */ export const setClass = function (ids: string, className: string) { for (const id of ids.split(',')) { - if (vertices[id]) { - vertices[id].classes.push(className); + if (vertices.has(id)) { + vertices.get(id)!.classes.push(className); } - if (subGraphLookup[id]) { - subGraphLookup[id].classes.push(className); + if (subGraphLookup.has(id)) { + subGraphLookup.get(id)!.classes.push(className); } } }; @@ -270,7 +272,7 @@ const setTooltip = function (ids: string, tooltip: string) { } tooltip = sanitizeText(tooltip); for (const id of ids.split(',')) { - tooltips[version === 'gen-1' ? lookUpDomId(id) : id] = tooltip; + tooltips.set(version === 'gen-1' ? lookUpDomId(id) : id, tooltip); } }; @@ -303,8 +305,8 @@ const setClickFun = function (id: string, functionName: string, functionArgs: st argList.push(id); } - if (vertices[id] !== undefined) { - vertices[id].haveCallback = true; + if (vertices.has(id)) { + vertices.get(id)!.haveCallback = true; funs.push(function () { const elem = document.querySelector(`[id="${domId}"]`); if (elem !== null) { @@ -329,17 +331,18 @@ const setClickFun = function (id: string, functionName: string, functionArgs: st */ export const setLink = function (ids: string, linkStr: string, target: string) { ids.split(',').forEach(function (id) { - if (vertices[id] !== undefined) { - vertices[id].link = utils.formatUrl(linkStr, config); - vertices[id].linkTarget = target; + const vertex = vertices.get(id)!; + if (vertex !== undefined) { + vertex.link = utils.formatUrl(linkStr, config); + vertex.linkTarget = target; } }); setClass(ids, 'clickable'); }; export const getTooltip = function (id: string) { - if (tooltips.hasOwnProperty(id)) { - return tooltips[id]; + if (tooltips.has(id)) { + return tooltips.get(id)!; } return undefined; }; @@ -435,14 +438,14 @@ funs.push(setupToolTips); * */ export const clear = function (ver = 'gen-1') { - vertices = {}; - classes = {}; + vertices = new Map(); + classes = new Map(); edges = []; funs = [setupToolTips]; subGraphs = []; - subGraphLookup = {}; + subGraphLookup = new Map(); subCount = 0; - tooltips = {}; + tooltips = new Map(); firstGraphFlag = true; version = ver; config = getConfig(); @@ -516,7 +519,7 @@ export const addSubGraph = function ( // Remove the members in the new subgraph if they already belong to another subgraph subGraph.nodes = makeUniq(subGraph, subGraphs).nodes; subGraphs.push(subGraph); - subGraphLookup[id] = subGraph; + subGraphLookup.set(id, subGraph); return id; }; diff --git a/packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js b/packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js index f27d8e3532..061d370383 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js +++ b/packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js @@ -29,11 +29,11 @@ export const setConf = function (cnf) { */ export const addVertices = async function (vert, g, svgId, root, doc, diagObj) { const svg = root.select(`[id="${svgId}"]`); - const keys = Object.keys(vert); + const keys = vert.keys(); // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition for (const id of keys) { - const vertex = vert[id]; + const vertex = vert.get(id); /** * Variable for storing the classes for the vertex @@ -336,7 +336,7 @@ export const addEdges = async function (edges, g, diagObj) { * * @param text * @param diagObj - * @returns {Record} ClassDef styles + * @returns {Map} ClassDef styles */ export const getClasses = function (text, diagObj) { return diagObj.db.getClasses(); @@ -463,9 +463,9 @@ export const draw = async function (text, id, _version, diagObj) { } // If node has a link, wrap it in an anchor SVG object. - const keys = Object.keys(vert); - keys.forEach(function (key) { - const vertex = vert[key]; + const keys = [...vert.keys()]; + keys.forEach((key) => { + const vertex = vert.get(key); if (vertex.link) { const node = select('#' + id + ' [id="' + key + '"]'); diff --git a/packages/mermaid/src/diagrams/flowchart/flowRenderer.js b/packages/mermaid/src/diagrams/flowchart/flowRenderer.js index b2e6bcc9cb..d45b95616d 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowRenderer.js +++ b/packages/mermaid/src/diagrams/flowchart/flowRenderer.js @@ -265,7 +265,7 @@ export const addEdges = async function (edges, g, diagObj) { * * @param text * @param diagObj - * @returns {Record} ClassDef styles + * @returns {Map} ClassDef styles */ export const getClasses = function (text, diagObj) { log.info('Extracting classes'); @@ -452,9 +452,9 @@ export const draw = async function (text, id, _version, diagObj) { setupGraphViewbox(g, svg, conf.diagramPadding, conf.useMaxWidth); // If node has a link, wrap it in an anchor SVG object. - const keys = Object.keys(vert); + const keys = [...vert.keys()]; keys.forEach(function (key) { - const vertex = vert[key]; + const vertex = vert.get(key); if (vertex.link) { const node = root.select('#' + id + ' [id="' + diagObj.db.lookUpDomId(key) + '"]'); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-arrows.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-arrows.spec.js index 699aa333d0..e89398ab40 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-arrows.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-arrows.spec.js @@ -18,8 +18,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -38,8 +38,8 @@ describe('[Arrows] when parsing', () => { expect(direction).toBe('LR'); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -58,8 +58,8 @@ describe('[Arrows] when parsing', () => { expect(direction).toBe('RL'); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -78,8 +78,8 @@ describe('[Arrows] when parsing', () => { expect(direction).toBe('BT'); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -99,8 +99,8 @@ describe('[Arrows] when parsing', () => { expect(direction).toBe('TB'); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -116,8 +116,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -133,8 +133,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -150,8 +150,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(2); expect(edges[1].start).toBe('B'); expect(edges[1].end).toBe('C'); @@ -169,8 +169,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -186,8 +186,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -203,8 +203,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -220,8 +220,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -237,8 +237,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -254,8 +254,8 @@ describe('[Arrows] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-comments.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-comments.spec.js index 4b0b0c830b..9c2a740af5 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-comments.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-comments.spec.js @@ -19,8 +19,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -34,8 +34,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -49,8 +49,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -64,8 +64,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -79,8 +79,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -94,8 +94,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -109,8 +109,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -124,8 +124,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -143,8 +143,8 @@ describe('[Comments] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-edges.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-edges.spec.js index 21f3a43555..4ae289bad6 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-edges.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-edges.spec.js @@ -48,8 +48,6 @@ describe('[Edges] when parsing', () => { it('should handle open ended edges', function () { const res = flow.parser.parse('graph TD;A---B;'); - - const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); expect(edges[0].type).toBe('arrow_open'); @@ -57,8 +55,6 @@ describe('[Edges] when parsing', () => { it('should handle cross ended edges', function () { const res = flow.parser.parse('graph TD;A--xB;'); - - const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); expect(edges[0].type).toBe('arrow_cross'); @@ -66,8 +62,6 @@ describe('[Edges] when parsing', () => { it('should handle open ended edges', function () { const res = flow.parser.parse('graph TD;A--oB;'); - - const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); expect(edges[0].type).toBe('arrow_circle'); @@ -81,8 +75,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -99,8 +93,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -119,8 +113,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -139,8 +133,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(2); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -164,8 +158,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -183,8 +177,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -202,8 +196,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -221,8 +215,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -240,8 +234,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -259,8 +253,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -278,8 +272,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -297,8 +291,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -316,8 +310,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -335,8 +329,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -354,8 +348,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -373,8 +367,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -392,8 +386,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -411,8 +405,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -430,8 +424,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -449,8 +443,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -468,8 +462,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -487,8 +481,8 @@ describe('[Edges] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(1); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-huge.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-huge.spec.js index e400484ed4..8931c6ee1f 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-huge.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-huge.spec.js @@ -23,7 +23,7 @@ describe('[Text] when parsing', () => { expect(edges[0].type).toBe('arrow_point'); expect(edges.length).toBe(47917); - expect(Object.keys(vert).length).toBe(2); + expect(vert.size).toBe(2); }); }); }); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-md-string.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-md-string.spec.js index 13cb262e3a..55e749a22d 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-md-string.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-md-string.spec.js @@ -19,12 +19,12 @@ A["\`The cat in **the** hat\`"]-- "\`The *bat* in the chat\`" -->B["The dog in t const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['A'].text).toBe('The cat in **the** hat'); - expect(vert['A'].labelType).toBe('markdown'); - expect(vert['B'].id).toBe('B'); - expect(vert['B'].text).toBe('The dog in the hog'); - expect(vert['B'].labelType).toBe('string'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('A').text).toBe('The cat in **the** hat'); + expect(vert.get('A').labelType).toBe('markdown'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('B').text).toBe('The dog in the hog'); + expect(vert.get('B').labelType).toBe('string'); expect(edges.length).toBe(2); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-singlenode.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-singlenode.spec.js index 59336d8d48..f6ed123d7e 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-singlenode.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-singlenode.spec.js @@ -43,7 +43,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['A'].styles.length).toBe(0); + expect(vert.get('A').styles.length).toBe(0); }); it('should handle a single node with white space after it (SN1)', function () { // Silly but syntactically correct @@ -53,7 +53,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['A'].styles.length).toBe(0); + expect(vert.get('A').styles.length).toBe(0); }); it('should handle a single square node', function () { @@ -64,8 +64,8 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].styles.length).toBe(0); - expect(vert['a'].type).toBe('square'); + expect(vert.get('a').styles.length).toBe(0); + expect(vert.get('a').type).toBe('square'); }); it('should handle a single round square node', function () { @@ -76,8 +76,8 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].styles.length).toBe(0); - expect(vert['a'].type).toBe('square'); + expect(vert.get('a').styles.length).toBe(0); + expect(vert.get('a').type).toBe('square'); }); it('should handle a single circle node', function () { @@ -88,7 +88,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('circle'); + expect(vert.get('a').type).toBe('circle'); }); it('should handle a single round node', function () { @@ -99,7 +99,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('round'); + expect(vert.get('a').type).toBe('round'); }); it('should handle a single odd node', function () { @@ -110,7 +110,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('odd'); + expect(vert.get('a').type).toBe('odd'); }); it('should handle a single diamond node', function () { @@ -121,7 +121,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('diamond'); + expect(vert.get('a').type).toBe('diamond'); }); it('should handle a single diamond node with whitespace after it', function () { @@ -132,7 +132,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('diamond'); + expect(vert.get('a').type).toBe('diamond'); }); it('should handle a single diamond node with html in it (SN3)', function () { @@ -143,8 +143,8 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('diamond'); - expect(vert['a'].text).toBe('A
end'); + expect(vert.get('a').type).toBe('diamond'); + expect(vert.get('a').text).toBe('A
end'); }); it('should handle a single hexagon node', function () { @@ -155,7 +155,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('hexagon'); + expect(vert.get('a').type).toBe('hexagon'); }); it('should handle a single hexagon node with html in it', function () { @@ -166,8 +166,8 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('hexagon'); - expect(vert['a'].text).toBe('A
end'); + expect(vert.get('a').type).toBe('hexagon'); + expect(vert.get('a').text).toBe('A
end'); }); it('should handle a single round node with html in it', function () { @@ -178,8 +178,8 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('round'); - expect(vert['a'].text).toBe('A
end'); + expect(vert.get('a').type).toBe('round'); + expect(vert.get('a').text).toBe('A
end'); }); it('should handle a single double circle node', function () { @@ -190,7 +190,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('doublecircle'); + expect(vert.get('a').type).toBe('doublecircle'); }); it('should handle a single double circle node with whitespace after it', function () { @@ -201,7 +201,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('doublecircle'); + expect(vert.get('a').type).toBe('doublecircle'); }); it('should handle a single double circle node with html in it (SN3)', function () { @@ -212,8 +212,8 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['a'].type).toBe('doublecircle'); - expect(vert['a'].text).toBe('A
end'); + expect(vert.get('a').type).toBe('doublecircle'); + expect(vert.get('a').text).toBe('A
end'); }); it('should handle a single node with alphanumerics starting on a char', function () { @@ -224,7 +224,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['id1'].styles.length).toBe(0); + expect(vert.get('id1').styles.length).toBe(0); }); it('should handle a single node with a single digit', function () { @@ -235,7 +235,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['1'].text).toBe('1'); + expect(vert.get('1').text).toBe('1'); }); it('should handle a single node with a single digit in a subgraph', function () { @@ -247,7 +247,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['1'].text).toBe('1'); + expect(vert.get('1').text).toBe('1'); }); it('should handle a single node with alphanumerics starting on a num', function () { @@ -258,7 +258,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['1id'].styles.length).toBe(0); + expect(vert.get('1id').styles.length).toBe(0); }); it('should handle a single node with alphanumerics containing a minus sign', function () { @@ -269,7 +269,7 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['i-d'].styles.length).toBe(0); + expect(vert.get('i-d').styles.length).toBe(0); }); it('should handle a single node with alphanumerics containing a underscore sign', function () { @@ -280,33 +280,33 @@ describe('[Singlenodes] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges.length).toBe(0); - expect(vert['i_d'].styles.length).toBe(0); + expect(vert.get('i_d').styles.length).toBe(0); }); it.each(keywords)('should handle keywords between dashes "-"', function (keyword) { const res = flow.parser.parse(`graph TD;a-${keyword}-node;`); const vert = flow.parser.yy.getVertices(); - expect(vert[`a-${keyword}-node`].text).toBe(`a-${keyword}-node`); + expect(vert.get(`a-${keyword}-node`).text).toBe(`a-${keyword}-node`); }); it.each(keywords)('should handle keywords between periods "."', function (keyword) { const res = flow.parser.parse(`graph TD;a.${keyword}.node;`); const vert = flow.parser.yy.getVertices(); - expect(vert[`a.${keyword}.node`].text).toBe(`a.${keyword}.node`); + expect(vert.get(`a.${keyword}.node`).text).toBe(`a.${keyword}.node`); }); it.each(keywords)('should handle keywords between underscores "_"', function (keyword) { const res = flow.parser.parse(`graph TD;a_${keyword}_node;`); const vert = flow.parser.yy.getVertices(); - expect(vert[`a_${keyword}_node`].text).toBe(`a_${keyword}_node`); + expect(vert.get(`a_${keyword}_node`).text).toBe(`a_${keyword}_node`); }); it.each(keywords)('should handle nodes ending in %s', function (keyword) { const res = flow.parser.parse(`graph TD;node_${keyword};node.${keyword};node-${keyword};`); const vert = flow.parser.yy.getVertices(); - expect(vert[`node_${keyword}`].text).toBe(`node_${keyword}`); - expect(vert[`node.${keyword}`].text).toBe(`node.${keyword}`); - expect(vert[`node-${keyword}`].text).toBe(`node-${keyword}`); + expect(vert.get(`node_${keyword}`).text).toBe(`node_${keyword}`); + expect(vert.get(`node.${keyword}`).text).toBe(`node.${keyword}`); + expect(vert.get(`node-${keyword}`).text).toBe(`node-${keyword}`); }); const errorKeywords = [ @@ -337,9 +337,9 @@ describe('[Singlenodes] when parsing', () => { it.each(workingKeywords)('should parse node beginning with %s', function (keyword) { flow.parser.parse(`graph TD; ${keyword}.node;${keyword}-node;${keyword}/node;`); const vert = flow.parser.yy.getVertices(); - expect(vert[`${keyword}.node`].text).toBe(`${keyword}.node`); - expect(vert[`${keyword}-node`].text).toBe(`${keyword}-node`); - expect(vert[`${keyword}/node`].text).toBe(`${keyword}/node`); + expect(vert.get(`${keyword}.node`).text).toBe(`${keyword}.node`); + expect(vert.get(`${keyword}-node`).text).toBe(`${keyword}-node`); + expect(vert.get(`${keyword}/node`).text).toBe(`${keyword}/node`); }); it.each(specialChars)( @@ -347,7 +347,7 @@ describe('[Singlenodes] when parsing', () => { function (specialChar) { flow.parser.parse(`graph TD; ${specialChar} --> A`); const vert = flow.parser.yy.getVertices(); - expect(vert[`${specialChar}`].text).toBe(`${specialChar}`); + expect(vert.get(`${specialChar}`).text).toBe(`${specialChar}`); } ); @@ -356,7 +356,7 @@ describe('[Singlenodes] when parsing', () => { function (specialChar) { flow.parser.parse(`graph TD; ${specialChar}node --> A`); const vert = flow.parser.yy.getVertices(); - expect(vert[`${specialChar}node`].text).toBe(`${specialChar}node`); + expect(vert.get(`${specialChar}node`).text).toBe(`${specialChar}node`); } ); @@ -365,7 +365,7 @@ describe('[Singlenodes] when parsing', () => { function (specialChar) { flow.parser.parse(`graph TD; node${specialChar} --> A`); const vert = flow.parser.yy.getVertices(); - expect(vert[`node${specialChar}`].text).toBe(`node${specialChar}`); + expect(vert.get(`node${specialChar}`).text).toBe(`node${specialChar}`); } ); }); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-style.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-style.spec.js index 5b0f740bd9..22fd48a334 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-style.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-style.spec.js @@ -20,10 +20,8 @@ describe('[Style] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - const style = vert['Q'].styles[0]; - - expect(vert['Q'].styles.length).toBe(1); - expect(vert['Q'].styles[0]).toBe('background:#fff'); + expect(vert.get('Q').styles.length).toBe(1); + expect(vert.get('Q').styles[0]).toBe('background:#fff'); }); it('should handle multiple styles for a vortex', function () { @@ -32,9 +30,9 @@ describe('[Style] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['R'].styles.length).toBe(2); - expect(vert['R'].styles[0]).toBe('background:#fff'); - expect(vert['R'].styles[1]).toBe('border:1px solid red'); + expect(vert.get('R').styles.length).toBe(2); + expect(vert.get('R').styles[0]).toBe('background:#fff'); + expect(vert.get('R').styles[1]).toBe('border:1px solid red'); }); it('should handle multiple styles in a graph', function () { @@ -45,11 +43,11 @@ describe('[Style] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['S'].styles.length).toBe(1); - expect(vert['T'].styles.length).toBe(2); - expect(vert['S'].styles[0]).toBe('background:#aaa'); - expect(vert['T'].styles[0]).toBe('background:#bbb'); - expect(vert['T'].styles[1]).toBe('border:1px solid red'); + expect(vert.get('S').styles.length).toBe(1); + expect(vert.get('T').styles.length).toBe(2); + expect(vert.get('S').styles[0]).toBe('background:#aaa'); + expect(vert.get('T').styles[0]).toBe('background:#bbb'); + expect(vert.get('T').styles[1]).toBe('border:1px solid red'); }); it('should handle styles and graph definitions in a graph', function () { @@ -60,11 +58,11 @@ describe('[Style] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['S'].styles.length).toBe(1); - expect(vert['T'].styles.length).toBe(2); - expect(vert['S'].styles[0]).toBe('background:#aaa'); - expect(vert['T'].styles[0]).toBe('background:#bbb'); - expect(vert['T'].styles[1]).toBe('border:1px solid red'); + expect(vert.get('S').styles.length).toBe(1); + expect(vert.get('T').styles.length).toBe(2); + expect(vert.get('S').styles[0]).toBe('background:#aaa'); + expect(vert.get('T').styles[0]).toBe('background:#bbb'); + expect(vert.get('T').styles[1]).toBe('border:1px solid red'); }); it('should handle styles and graph definitions in a graph', function () { @@ -73,9 +71,9 @@ describe('[Style] when parsing', () => { const vert = flow.parser.yy.getVertices(); - expect(vert['T'].styles.length).toBe(2); - expect(vert['T'].styles[0]).toBe('background:#bbb'); - expect(vert['T'].styles[1]).toBe('border:1px solid red'); + expect(vert.get('T').styles.length).toBe(2); + expect(vert.get('T').styles[0]).toBe('background:#bbb'); + expect(vert.get('T').styles[1]).toBe('border:1px solid red'); }); it('should keep node label text (if already defined) when a style is applied', function () { @@ -85,10 +83,10 @@ describe('[Style] when parsing', () => { const vert = flow.parser.yy.getVertices(); - expect(vert['A'].text).toBe(''); - expect(vert['B'].text).toBe('Test'); - expect(vert['C'].text).toBe('C'); - expect(vert['D'].text).toBe('D'); + expect(vert.get('A').text).toBe(''); + expect(vert.get('B').text).toBe('Test'); + expect(vert.get('C').text).toBe('C'); + expect(vert.get('D').text).toBe('D'); }); it('should be possible to declare a class', function () { @@ -99,9 +97,9 @@ describe('[Style] when parsing', () => { const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); }); it('should be possible to declare multiple classes', function () { @@ -111,13 +109,13 @@ describe('[Style] when parsing', () => { const classes = flow.parser.yy.getClasses(); - expect(classes['firstClass'].styles.length).toBe(2); - expect(classes['firstClass'].styles[0]).toBe('background:#bbb'); - expect(classes['firstClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('firstClass').styles.length).toBe(2); + expect(classes.get('firstClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('firstClass').styles[1]).toBe('border:1px solid red'); - expect(classes['secondClass'].styles.length).toBe(2); - expect(classes['secondClass'].styles[0]).toBe('background:#bbb'); - expect(classes['secondClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('secondClass').styles.length).toBe(2); + expect(classes.get('secondClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('secondClass').styles[1]).toBe('border:1px solid red'); }); it('should be possible to declare a class with a dot in the style', function () { @@ -128,9 +126,9 @@ describe('[Style] when parsing', () => { const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1.5px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1.5px solid red'); }); it('should be possible to declare a class with a space in the style', function () { const res = flow.parser.parse( @@ -140,9 +138,9 @@ describe('[Style] when parsing', () => { const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(classes['exClass'].styles[0]).toBe('background: #bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1.5px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(classes.get('exClass').styles[0]).toBe('background: #bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1.5px solid red'); }); it('should be possible to apply a class to a vertex', function () { let statement = ''; @@ -156,9 +154,9 @@ describe('[Style] when parsing', () => { const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); }); it('should be possible to apply a class to a vertex with an id containing _', function () { let statement = ''; @@ -172,9 +170,9 @@ describe('[Style] when parsing', () => { const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); }); it('should be possible to apply a class to a vertex directly', function () { let statement = ''; @@ -187,10 +185,10 @@ describe('[Style] when parsing', () => { const vertices = flow.parser.yy.getVertices(); const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(vertices['b'].classes[0]).toBe('exClass'); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(vertices.get('b').classes[0]).toBe('exClass'); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); }); it('should be possible to apply a class to a vertex directly : usecase A[text].class ', function () { @@ -204,10 +202,10 @@ describe('[Style] when parsing', () => { const vertices = flow.parser.yy.getVertices(); const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(vertices['b'].classes[0]).toBe('exClass'); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(vertices.get('b').classes[0]).toBe('exClass'); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); }); it('should be possible to apply a class to a vertex directly : usecase A[text].class-->B[test2] ', function () { @@ -221,10 +219,10 @@ describe('[Style] when parsing', () => { const vertices = flow.parser.yy.getVertices(); const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(vertices['A'].classes[0]).toBe('exClass'); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(vertices.get('A').classes[0]).toBe('exClass'); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); }); it('should be possible to apply a class to a vertex directly 2', function () { @@ -238,10 +236,10 @@ describe('[Style] when parsing', () => { const vertices = flow.parser.yy.getVertices(); const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(vertices['b'].classes[0]).toBe('exClass'); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(vertices.get('b').classes[0]).toBe('exClass'); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); }); it('should be possible to apply a class to a comma separated list of vertices', function () { let statement = ''; @@ -256,11 +254,11 @@ describe('[Style] when parsing', () => { const classes = flow.parser.yy.getClasses(); const vertices = flow.parser.yy.getVertices(); - expect(classes['exClass'].styles.length).toBe(2); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); - expect(vertices['a'].classes[0]).toBe('exClass'); - expect(vertices['b'].classes[0]).toBe('exClass'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); + expect(vertices.get('a').classes[0]).toBe('exClass'); + expect(vertices.get('b').classes[0]).toBe('exClass'); }); it('should handle style definitions with more then 1 digit in a row', function () { @@ -364,9 +362,9 @@ describe('[Style] when parsing', () => { const vert = flow.parser.yy.getVertices(); - expect(vert['A'].classes.length).toBe(0); - expect(vert['B'].classes[0]).toBe('C1'); - expect(vert['D'].classes[0]).toBe('C1'); - expect(vert['E'].classes[0]).toBe('C2'); + expect(vert.get('A').classes.length).toBe(0); + expect(vert.get('B').classes[0]).toBe('C1'); + expect(vert.get('D').classes[0]).toBe('C1'); + expect(vert.get('E').classes[0]).toBe('C2'); }); }); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-text.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-text.spec.js index 61eccbbc8e..3754766f44 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-text.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-text.spec.js @@ -113,7 +113,7 @@ describe('[Text] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges[0].type).toBe('arrow_cross'); - expect(vert['v'].text).toBe('my text'); + expect(vert.get('v').text).toBe('my text'); }); it('should handle v in node ids v at end', function () { // v at end @@ -123,7 +123,7 @@ describe('[Text] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges[0].type).toBe('arrow_cross'); - expect(vert['csv'].text).toBe('my text'); + expect(vert.get('csv').text).toBe('my text'); }); it('should handle v in node ids v in middle', function () { // v in middle @@ -133,7 +133,7 @@ describe('[Text] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges[0].type).toBe('arrow_cross'); - expect(vert['ava'].text).toBe('my text'); + expect(vert.get('ava').text).toBe('my text'); }); it('should handle v in node ids, v at start', function () { // v at start @@ -143,7 +143,7 @@ describe('[Text] when parsing', () => { const edges = flow.parser.yy.getEdges(); expect(edges[0].type).toBe('arrow_cross'); - expect(vert['va'].text).toBe('my text'); + expect(vert.get('va').text).toBe('my text'); }); it('should handle keywords', function () { const res = flow.parser.parse('graph TD;A--x|text including graph space|B;'); @@ -157,7 +157,7 @@ describe('[Text] when parsing', () => { const res = flow.parser.parse('graph TD;V-->a[v]'); const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['a'].text).toBe('v'); + expect(vert.get('a').text).toBe('v'); }); it('should handle quoted text', function () { const res = flow.parser.parse('graph TD;V-- "test string()" -->a[v]'); @@ -302,8 +302,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['C'].type).toBe('round'); - expect(vert['C'].text).toBe('Chimpansen hoppar'); + expect(vert.get('C').type).toBe('round'); + expect(vert.get('C').text).toBe('Chimpansen hoppar'); }); const keywords = [ @@ -353,8 +353,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['B'].type).toBe(`${shape.name}`); - expect(vert['B'].text).toBe(`This node has a ${keyword} as text`); + expect(vert.get('B').type).toBe(`${shape.name}`); + expect(vert.get('B').text).toBe(`This node has a ${keyword} as text`); }); }); @@ -365,24 +365,24 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['B'].type).toBe('rect'); - expect(vert['B'].text).toBe(`This node has a ${keyword} as text`); + expect(vert.get('B').type).toBe('rect'); + expect(vert.get('B').text).toBe(`This node has a ${keyword} as text`); }); it('should handle edge case for odd vertex with node id ending with minus', function () { const res = flow.parser.parse('graph TD;A_node-->odd->Vertex Text];'); const vert = flow.parser.yy.getVertices(); - expect(vert['odd-'].type).toBe('odd'); - expect(vert['odd-'].text).toBe('Vertex Text'); + expect(vert.get('odd-').type).toBe('odd'); + expect(vert.get('odd-').text).toBe('Vertex Text'); }); it('should allow forward slashes in lean_right vertices', function () { const rest = flow.parser.parse(`graph TD;A_node-->B[/This node has a / as text/];`); const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['B'].type).toBe('lean_right'); - expect(vert['B'].text).toBe(`This node has a / as text`); + expect(vert.get('B').type).toBe('lean_right'); + expect(vert.get('B').text).toBe(`This node has a / as text`); }); it('should allow back slashes in lean_left vertices', function () { @@ -390,8 +390,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['B'].type).toBe('lean_left'); - expect(vert['B'].text).toBe(`This node has a \\ as text`); + expect(vert.get('B').type).toBe('lean_left'); + expect(vert.get('B').text).toBe(`This node has a \\ as text`); }); it('should handle åäö and minus', function () { @@ -400,8 +400,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['C'].type).toBe('diamond'); - expect(vert['C'].text).toBe('Chimpansen hoppar åäö-ÅÄÖ'); + expect(vert.get('C').type).toBe('diamond'); + expect(vert.get('C').text).toBe('Chimpansen hoppar åäö-ÅÄÖ'); }); it('should handle with åäö, minus and space and br', function () { @@ -410,8 +410,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['C'].type).toBe('round'); - expect(vert['C'].text).toBe('Chimpansen hoppar åäö
- ÅÄÖ'); + expect(vert.get('C').type).toBe('round'); + expect(vert.get('C').text).toBe('Chimpansen hoppar åäö
- ÅÄÖ'); }); // it.skip('should handle åäö, minus and space and br',function(){ // const res = flow.parser.parse('graph TD; A[Object(foo,bar)]-->B(Thing);'); @@ -419,22 +419,22 @@ describe('[Text] when parsing', () => { // const vert = flow.parser.yy.getVertices(); // const edges = flow.parser.yy.getEdges(); // - // expect(vert['C'].type).toBe('round'); - // expect(vert['C'].text).toBe(' A[Object(foo,bar)]-->B(Thing);'); + // expect(vert.get('C').type).toBe('round'); + // expect(vert.get('C').text).toBe(' A[Object(foo,bar)]-->B(Thing);'); // }); it('should handle unicode chars', function () { const res = flow.parser.parse('graph TD;A-->C(Начало);'); const vert = flow.parser.yy.getVertices(); - expect(vert['C'].text).toBe('Начало'); + expect(vert.get('C').text).toBe('Начало'); }); it('should handle backslask', function () { const res = flow.parser.parse('graph TD;A-->C(c:\\windows);'); const vert = flow.parser.yy.getVertices(); - expect(vert['C'].text).toBe('c:\\windows'); + expect(vert.get('C').text).toBe('c:\\windows'); }); it('should handle CAPS', function () { const res = flow.parser.parse('graph TD;A-->C(some CAPS);'); @@ -442,8 +442,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['C'].type).toBe('round'); - expect(vert['C'].text).toBe('some CAPS'); + expect(vert.get('C').type).toBe('round'); + expect(vert.get('C').text).toBe('some CAPS'); }); it('should handle directions', function () { const res = flow.parser.parse('graph TD;A-->C(some URL);'); @@ -451,8 +451,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['C'].type).toBe('round'); - expect(vert['C'].text).toBe('some URL'); + expect(vert.get('C').type).toBe('round'); + expect(vert.get('C').text).toBe('some URL'); }); }); @@ -464,9 +464,9 @@ describe('[Text] when parsing', () => { expect(edges[0].type).toBe('arrow_circle'); expect(edges[1].type).toBe('arrow_point'); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); - expect(vert['C'].id).toBe('C'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('C').id).toBe('C'); expect(edges.length).toBe(2); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -482,8 +482,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].type).toBe('square'); - expect(vert['A'].text).toBe('chimpansen hoppar'); + expect(vert.get('A').type).toBe('square'); + expect(vert.get('A').text).toBe('chimpansen hoppar'); }); it('should handle text in vertices with space with spaces between vertices and link', function () { @@ -492,8 +492,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].type).toBe('square'); - expect(vert['A'].text).toBe('chimpansen hoppar'); + expect(vert.get('A').type).toBe('square'); + expect(vert.get('A').text).toBe('chimpansen hoppar'); }); it('should handle text including _ in vertices', function () { const res = flow.parser.parse('graph TD;A[chimpansen_hoppar] --> C;'); @@ -501,8 +501,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].type).toBe('square'); - expect(vert['A'].text).toBe('chimpansen_hoppar'); + expect(vert.get('A').type).toBe('square'); + expect(vert.get('A').text).toBe('chimpansen_hoppar'); }); it('should handle quoted text in vertices ', function () { @@ -511,8 +511,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].type).toBe('square'); - expect(vert['A'].text).toBe('chimpansen hoppar ()[]'); + expect(vert.get('A').type).toBe('square'); + expect(vert.get('A').text).toBe('chimpansen hoppar ()[]'); }); it('should handle text in circle vertices with space', function () { @@ -521,8 +521,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].type).toBe('circle'); - expect(vert['A'].text).toBe('chimpansen hoppar'); + expect(vert.get('A').type).toBe('circle'); + expect(vert.get('A').text).toBe('chimpansen hoppar'); }); it('should handle text in ellipse vertices', function () { @@ -531,8 +531,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].type).toBe('ellipse'); - expect(vert['A'].text).toBe('this is an ellipse'); + expect(vert.get('A').type).toBe('ellipse'); + expect(vert.get('A').text).toBe('this is an ellipse'); }); it('should not freeze when ellipse text has a `(`', function () { @@ -545,8 +545,8 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].type).toBe('round'); - expect(vert['A'].text).toBe('chimpansen hoppar'); + expect(vert.get('A').type).toBe('round'); + expect(vert.get('A').text).toBe('chimpansen hoppar'); }); it('should handle text in with ?', function () { @@ -555,7 +555,7 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].text).toBe('?'); + expect(vert.get('A').text).toBe('?'); expect(edges[0].text).toBe('?'); }); it('should handle text in with éèêàçô', function () { @@ -564,7 +564,7 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].text).toBe('éèêàçô'); + expect(vert.get('A').text).toBe('éèêàçô'); expect(edges[0].text).toBe('éèêàçô'); }); @@ -574,7 +574,7 @@ describe('[Text] when parsing', () => { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].text).toBe(',.?!+-*'); + expect(vert.get('A').text).toBe(',.?!+-*'); expect(edges[0].text).toBe(',.?!+-*'); }); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow-vertice-chaining.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow-vertice-chaining.spec.js index 3f1078030d..7166f2c15b 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow-vertice-chaining.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow-vertice-chaining.spec.js @@ -22,9 +22,9 @@ describe('when parsing flowcharts', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); - expect(vert['C'].id).toBe('C'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('C').id).toBe('C'); expect(edges.length).toBe(2); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -44,9 +44,9 @@ describe('when parsing flowcharts', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); - expect(vert['C'].id).toBe('C'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('C').id).toBe('C'); expect(edges.length).toBe(2); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('C'); @@ -66,9 +66,9 @@ describe('when parsing flowcharts', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); - expect(vert['C'].id).toBe('C'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('C').id).toBe('C'); expect(edges.length).toBe(2); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -88,10 +88,10 @@ describe('when parsing flowcharts', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); - expect(vert['C'].id).toBe('C'); - expect(vert['D'].id).toBe('D'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('C').id).toBe('C'); + expect(vert.get('D').id).toBe('D'); expect(edges.length).toBe(4); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('C'); @@ -119,10 +119,10 @@ describe('when parsing flowcharts', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); - expect(vert['C'].id).toBe('C'); - expect(vert['D'].id).toBe('D'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('C').id).toBe('C'); + expect(vert.get('D').id).toBe('D'); expect(edges.length).toBe(4); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('C'); @@ -150,11 +150,11 @@ describe('when parsing flowcharts', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); - expect(vert['B2'].id).toBe('B2'); - expect(vert['C'].id).toBe('C'); - expect(vert['D2'].id).toBe('D2'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('B2').id).toBe('B2'); + expect(vert.get('C').id).toBe('C'); + expect(vert.get('D2').id).toBe('D2'); expect(edges.length).toBe(6); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -193,14 +193,14 @@ describe('when parsing flowcharts', function () { const classes = flow.parser.yy.getClasses(); - expect(classes['exClass'].styles.length).toBe(2); - expect(classes['exClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exClass'].styles[1]).toBe('border:1px solid red'); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); - expect(vert['B'].classes[0]).toBe('exClass'); - expect(vert['C'].id).toBe('C'); - expect(vert['D'].id).toBe('D'); + expect(classes.get('exClass').styles.length).toBe(2); + expect(classes.get('exClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exClass').styles[1]).toBe('border:1px solid red'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); + expect(vert.get('B').classes[0]).toBe('exClass'); + expect(vert.get('C').id).toBe('C'); + expect(vert.get('D').id).toBe('D'); expect(edges.length).toBe(4); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js index 8d0aec789e..ff2c9d506c 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js @@ -19,8 +19,8 @@ describe('parsing a flow chart', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); expect(edges.length).toBe(2); expect(edges[0].start).toBe('A'); expect(edges[0].end).toBe('B'); @@ -34,8 +34,8 @@ describe('parsing a flow chart', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['endpoint'].id).toBe('endpoint'); - expect(vert['sender'].id).toBe('sender'); + expect(vert.get('endpoint').id).toBe('endpoint'); + expect(vert.get('sender').id).toBe('sender'); expect(edges[0].start).toBe('endpoint'); expect(edges[0].end).toBe('sender'); }); @@ -46,8 +46,8 @@ describe('parsing a flow chart', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['blend'].id).toBe('blend'); - expect(vert['monograph'].id).toBe('monograph'); + expect(vert.get('blend').id).toBe('blend'); + expect(vert.get('monograph').id).toBe('monograph'); expect(edges[0].start).toBe('blend'); expect(edges[0].end).toBe('monograph'); }); @@ -58,8 +58,8 @@ describe('parsing a flow chart', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['default'].id).toBe('default'); - expect(vert['monograph'].id).toBe('monograph'); + expect(vert.get('default').id).toBe('default'); + expect(vert.get('monograph').id).toBe('monograph'); expect(edges[0].start).toBe('default'); expect(edges[0].end).toBe('monograph'); }); @@ -71,12 +71,12 @@ describe('parsing a flow chart', function () { const vert = flow.parser.yy.getVertices(); const edges = flow.parser.yy.getEdges(); - expect(vert['A'].id).toBe('A'); - expect(vert['B'].id).toBe('B'); + expect(vert.get('A').id).toBe('A'); + expect(vert.get('B').id).toBe('B'); if (result) { - expect(vert['A'].text).toBe(result); + expect(vert.get('A').text).toBe(result); } else { - expect(vert['A'].text).toBe(char); + expect(vert.get('A').text).toBe(char); } flow.parser.yy.clear(); }; @@ -135,7 +135,7 @@ describe('parsing a flow chart', function () { const res = flow.parser.parse(statement); const vertices = flow.parser.yy.getVertices(); const classes = flow.parser.yy.getClasses(); - expect(vertices['node1TB'].id).toBe('node1TB'); + expect(vertices.get('node1TB').id).toBe('node1TB'); }); it('should be possible to use direction in node ids', function () { @@ -145,7 +145,7 @@ describe('parsing a flow chart', function () { const res = flow.parser.parse(statement); const vertices = flow.parser.yy.getVertices(); const classes = flow.parser.yy.getClasses(); - expect(vertices['A'].id).toBe('A'); + expect(vertices.get('A').id).toBe('A'); }); it('should be possible to use numbers as labels', function () { @@ -154,8 +154,8 @@ describe('parsing a flow chart', function () { statement = statement + 'graph TB;subgraph "number as labels";1;end;'; const res = flow.parser.parse(statement); const vertices = flow.parser.yy.getVertices(); - const classes = flow.parser.yy.getClasses(); - expect(vertices['1'].id).toBe('1'); + + expect(vertices.get('1').id).toBe('1'); }); it('should add accTitle and accDescr to flow chart', function () { diff --git a/packages/mermaid/src/diagrams/gantt/ganttDb.js b/packages/mermaid/src/diagrams/gantt/ganttDb.js index 27d622eeb5..160f297131 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttDb.js +++ b/packages/mermaid/src/diagrams/gantt/ganttDb.js @@ -28,7 +28,7 @@ let tickInterval = undefined; let todayMarker = ''; let includes = []; let excludes = []; -let links = {}; +let links = new Map(); let sections = []; let tasks = []; let currentSection = ''; @@ -62,7 +62,7 @@ export const clear = function () { inclusiveEndDates = false; topAxis = false; lastOrder = 0; - links = {}; + links = new Map(); commonClear(); weekday = 'sunday'; weekend = 'saturday'; @@ -639,7 +639,7 @@ export const setLink = function (ids, _linkStr) { pushFun(id, () => { window.open(linkStr, '_self'); }); - links[id] = linkStr; + links.set(id, linkStr); } }); setClass(ids, 'clickable'); diff --git a/packages/mermaid/src/diagrams/gantt/ganttRenderer.js b/packages/mermaid/src/diagrams/gantt/ganttRenderer.js index 5559ac20d9..a10eb100f4 100644 --- a/packages/mermaid/src/diagrams/gantt/ganttRenderer.js +++ b/packages/mermaid/src/diagrams/gantt/ganttRenderer.js @@ -475,14 +475,14 @@ export const draw = function (text, id, version, diagObj) { rectangles .filter(function (d) { - return links[d.id] !== undefined; + return links.has(d.id); }) .each(function (o) { var taskRect = doc.querySelector('#' + o.id); var taskText = doc.querySelector('#' + o.id + '-text'); const oldParent = taskRect.parentNode; var Link = doc.createElement('a'); - Link.setAttribute('xlink:href', links[o.id]); + Link.setAttribute('xlink:href', links.get(o.id)); Link.setAttribute('target', '_top'); oldParent.appendChild(Link); Link.appendChild(taskRect); diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.js b/packages/mermaid/src/diagrams/git/gitGraphAst.js index 0997f65b1b..269ffa2bf3 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.js +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.js @@ -14,12 +14,12 @@ import { let mainBranchName = getConfig().gitGraph.mainBranchName; let mainBranchOrder = getConfig().gitGraph.mainBranchOrder; -let commits = {}; +let commits = new Map(); let head = null; -let branchesConfig = {}; -branchesConfig[mainBranchName] = { name: mainBranchName, order: mainBranchOrder }; -let branches = {}; -branches[mainBranchName] = head; +let branchesConfig = new Map(); +branchesConfig.set(mainBranchName, { name: mainBranchName, order: mainBranchOrder }); +let branches = new Map(); +branches.set(mainBranchName, head); let curBranch = mainBranchName; let direction = 'LR'; let seq = 0; @@ -46,11 +46,11 @@ function getId() { // if (Array.isArray(otherCommit.parent)) { // log.debug('In merge commit:', otherCommit.parent); // return ( -// isFastForwardable(currentCommit, commits[otherCommit.parent[0]]) || -// isFastForwardable(currentCommit, commits[otherCommit.parent[1]]) +// isFastForwardable(currentCommit, commits.get(otherCommit.parent[0])) || +// isFastForwardable(currentCommit, commits.get(otherCommit.parent[1])) // ); // } else { -// otherCommit = commits[otherCommit.parent]; +// otherCommit = commits.get(otherCommit.parent); // } // } // log.debug(currentCommit.id, otherCommit.id); @@ -118,16 +118,16 @@ export const commit = function (msg, id, type, tag) { branch: curBranch, }; head = commit; - commits[commit.id] = commit; - branches[curBranch] = commit.id; + commits.set(commit.id, commit); + branches.set(curBranch, commit.id); log.debug('in pushCommit ' + commit.id); }; export const branch = function (name, order) { name = common.sanitizeText(name, getConfig()); - if (branches[name] === undefined) { - branches[name] = head != null ? head.id : null; - branchesConfig[name] = { name, order: order ? parseInt(order, 10) : null }; + if (!branches.has(name)) { + branches.set(name, head != null ? head.id : null); + branchesConfig.set(name, { name, order: order ? parseInt(order, 10) : null }); checkout(name); log.debug('in createBranch'); } else { @@ -151,8 +151,8 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag otherBranch = common.sanitizeText(otherBranch, getConfig()); custom_id = common.sanitizeText(custom_id, getConfig()); - const currentCommit = commits[branches[curBranch]]; - const otherCommit = commits[branches[otherBranch]]; + const currentCommit = commits.get(branches.get(curBranch)); + const otherCommit = commits.get(branches.get(otherBranch)); if (curBranch === otherBranch) { let error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself'); error.hash = { @@ -175,7 +175,7 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag expected: ['commit'], }; throw error; - } else if (branches[otherBranch] === undefined) { + } else if (!branches.has(otherBranch)) { let error = new Error( 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ') does not exist' ); @@ -209,7 +209,7 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag expected: ['branch abc'], }; throw error; - } else if (custom_id && commits[custom_id] !== undefined) { + } else if (custom_id && commits.has(custom_id)) { let error = new Error( 'Incorrect usage of "merge". Commit with id:' + custom_id + @@ -232,15 +232,15 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag // return; // } // if (isFastForwardable(currentCommit, otherCommit)) { - // branches[curBranch] = branches[otherBranch]; - // head = commits[branches[curBranch]]; + // branches.set(curBranch, branches.get(otherBranch)); + // head = commits.get(branches.get(curBranch)); // } else { // create merge commit const commit = { id: custom_id ? custom_id : seq + '-' + getId(), message: 'merged branch ' + otherBranch + ' into ' + curBranch, seq: seq++, - parents: [head == null ? null : head.id, branches[otherBranch]], + parents: [head == null ? null : head.id, branches.get(otherBranch)], branch: curBranch, type: commitType.MERGE, customType: override_type, @@ -248,8 +248,8 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag tag: custom_tag ? custom_tag : '', }; head = commit; - commits[commit.id] = commit; - branches[curBranch] = commit.id; + commits.set(commit.id, commit); + branches.set(curBranch, commit.id); // } log.debug(branches); log.debug('in mergeBranch'); @@ -262,7 +262,7 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) { tag = common.sanitizeText(tag, getConfig()); parentCommitId = common.sanitizeText(parentCommitId, getConfig()); - if (!sourceId || commits[sourceId] === undefined) { + if (!sourceId || !commits.has(sourceId)) { let error = new Error( 'Incorrect usage of "cherryPick". Source commit id should exist and provided' ); @@ -275,7 +275,7 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) { }; throw error; } - let sourceCommit = commits[sourceId]; + let sourceCommit = commits.get(sourceId); let sourceCommitBranch = sourceCommit.branch; if ( parentCommitId && @@ -292,7 +292,7 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) { ); throw error; } - if (!targetId || commits[targetId] === undefined) { + if (!targetId || !commits.has(targetId)) { // cherry-pick source commit to current branch if (sourceCommitBranch === curBranch) { @@ -308,7 +308,7 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) { }; throw error; } - const currentCommit = commits[branches[curBranch]]; + const currentCommit = commits.get(branches.get(curBranch)); if (currentCommit === undefined || !currentCommit) { let error = new Error( 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ')has no commits' @@ -336,15 +336,15 @@ export const cherryPick = function (sourceId, targetId, tag, parentCommitId) { }`, }; head = commit; - commits[commit.id] = commit; - branches[curBranch] = commit.id; + commits.set(commit.id, commit); + branches.set(curBranch, commit.id); log.debug(branches); log.debug('in cherryPick'); } }; export const checkout = function (branch) { branch = common.sanitizeText(branch, getConfig()); - if (branches[branch] === undefined) { + if (!branches.has(branch)) { let error = new Error( 'Trying to checkout branch which is not yet created. (Help try using "branch ' + branch + '")' ); @@ -360,8 +360,8 @@ export const checkout = function (branch) { //log.debug('in createBranch'); } else { curBranch = branch; - const id = branches[curBranch]; - head = commits[id]; + const id = branches.get(curBranch); + head = commits.get(id); } }; @@ -369,10 +369,10 @@ export const checkout = function (branch) { // log.debug('in reset', commitRef); // const ref = commitRef.split(':')[0]; // let parentCount = parseInt(commitRef.split(':')[1]); -// let commit = ref === 'HEAD' ? head : commits[branches[ref]]; +// let commit = ref === 'HEAD' ? head : commits.get(branches.get(ref)); // log.debug(commit, parentCount); // while (parentCount > 0) { -// commit = commits[commit.parent]; +// commit = commits.get(commit.parent); // parentCount--; // if (!commit) { // const err = 'Critical error - unique parent commit not found during reset'; @@ -416,19 +416,19 @@ function prettyPrintCommitHistory(commitArr) { }); const label = [line, commit.id, commit.seq]; for (let branch in branches) { - if (branches[branch] === commit.id) { + if (branches.get(branch) === commit.id) { label.push(branch); } } log.debug(label.join(' ')); if (commit.parents && commit.parents.length == 2) { - const newCommit = commits[commit.parents[0]]; + const newCommit = commits.get(commit.parents[0]); upsert(commitArr, commit, newCommit); - commitArr.push(commits[commit.parents[1]]); + commitArr.push(commits.get(commit.parents[1])); } else if (commit.parents.length == 0) { return; } else { - const nextCommit = commits[commit.parents]; + const nextCommit = commits.get(commit.parents); upsert(commitArr, commit, nextCommit); } commitArr = uniqBy(commitArr, (c) => c.id); @@ -442,21 +442,21 @@ export const prettyPrint = function () { }; export const clear = function () { - commits = {}; + commits = new Map(); head = null; let mainBranch = getConfig().gitGraph.mainBranchName; let mainBranchOrder = getConfig().gitGraph.mainBranchOrder; - branches = {}; - branches[mainBranch] = null; - branchesConfig = {}; - branchesConfig[mainBranch] = { name: mainBranch, order: mainBranchOrder }; + branches = new Map(); + branches.set(mainBranch, null); + branchesConfig = new Map(); + branchesConfig.set(mainBranch, { name: mainBranch, order: mainBranchOrder }); curBranch = mainBranch; seq = 0; commonClear(); }; export const getBranchesAsObjArray = function () { - const branchesArray = Object.values(branchesConfig) + const branchesArray = [...branchesConfig.values()] .map((branchConfig, i) => { if (branchConfig.order !== null) { return branchConfig; @@ -479,8 +479,8 @@ export const getCommits = function () { return commits; }; export const getCommitsArray = function () { - const commitArr = Object.keys(commits).map(function (key) { - return commits[key]; + const commitArr = [...commits.keys()].map(function (key) { + return commits.get(key); }); commitArr.forEach(function (o) { log.debug(o.id); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js index f6d4e121ae..3398dd55f5 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js @@ -12,10 +12,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); }); it('should handle a gitGraph definition with empty options', function () { @@ -25,10 +25,10 @@ describe('when parsing a gitGraph', function () { const commits = parser.yy.getCommits(); expect(parser.yy.getOptions()).toEqual({}); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); }); it('should handle a gitGraph definition with valid options', function () { @@ -37,10 +37,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); expect(parser.yy.getOptions()['key']).toBe('value'); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); }); it('should not fail on a gitGraph with malformed json', function () { @@ -48,10 +48,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); }); it('should handle set direction top to bottom', function () { @@ -60,10 +60,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('TB'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); }); it('should handle set direction bottom to top', function () { @@ -72,10 +72,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('BT'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); }); it('should checkout a branch', function () { @@ -84,7 +84,7 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(0); + expect(commits.size).toBe(0); expect(parser.yy.getCurrentBranch()).toBe('new'); }); @@ -94,7 +94,7 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(0); + expect(commits.size).toBe(0); expect(parser.yy.getCurrentBranch()).toBe('new'); }); @@ -104,11 +104,11 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(2); + expect(commits.size).toBe(2); expect(parser.yy.getCurrentBranch()).toBe('new'); - const branchCommit = parser.yy.getBranches()['new']; + const branchCommit = parser.yy.getBranches().get('new'); expect(branchCommit).not.toBeNull(); - expect(commits[branchCommit].parent).not.toBeNull(); + expect(commits.get(branchCommit).parent).not.toBeNull(); }); it('should handle commit with args', function () { const str = 'gitGraph:\n' + 'commit "a commit"\n'; @@ -116,9 +116,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe('a commit'); + expect(commits.size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe('a commit'); expect(parser.yy.getCurrentBranch()).toBe('main'); }); @@ -136,10 +136,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(3); + expect(commits.size).toBe(3); expect(parser.yy.getCurrentBranch()).toBe('newbranch'); - expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['main']); - expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']); + expect(parser.yy.getBranches().get('newbranch')).toEqual(parser.yy.getBranches().get('main')); + expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches().get('newbranch')); }); it.skip('reset can take an argument', function () { @@ -155,9 +155,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(3); + expect(commits.size).toBe(3); expect(parser.yy.getCurrentBranch()).toBe('newbranch'); - const main = commits[parser.yy.getBranches()['main']]; + const main = commits.get(parser.yy.getBranches().get('main')); expect(parser.yy.getHead().id).toEqual(main.parent); }); @@ -175,10 +175,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(4); + expect(commits.size).toBe(4); expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['main']); - expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']); + expect(parser.yy.getBranches().get('newbranch')).toEqual(parser.yy.getBranches().get('main')); + expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches().get('newbranch')); }); it('should handle cases when merge is a noop', function () { @@ -194,10 +194,12 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(4); + expect(commits.size).toBe(4); expect(parser.yy.getCurrentBranch()).toBe('newbranch'); - expect(parser.yy.getBranches()['newbranch']).not.toEqual(parser.yy.getBranches()['main']); - expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['newbranch']); + expect(parser.yy.getBranches().get('newbranch')).not.toEqual( + parser.yy.getBranches().get('main') + ); + expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches().get('newbranch')); }); it('should handle merge with 2 parents', function () { @@ -215,10 +217,12 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(5); + expect(commits.size).toBe(5); expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getBranches()['newbranch']).not.toEqual(parser.yy.getBranches()['main']); - expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['main']); + expect(parser.yy.getBranches().get('newbranch')).not.toEqual( + parser.yy.getBranches().get('main') + ); + expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches().get('main')); }); it.skip('should handle ff merge when history walk has two parents (merge commit)', function () { @@ -239,10 +243,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(7); + expect(commits.size).toBe(7); expect(parser.yy.getCurrentBranch()).toBe('newbranch'); - expect(parser.yy.getBranches()['newbranch']).toEqual(parser.yy.getBranches()['main']); - expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches()['main']); + expect(parser.yy.getBranches().get('newbranch')).toEqual(parser.yy.getBranches().get('main')); + expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches().get('main')); parser.yy.prettyPrint(); }); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js index ac85712b2b..b0e40f73ef 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js +++ b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js @@ -13,15 +13,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); //console.info(commits); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe(''); - expect(commits[key].type).toBe(0); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe(''); + expect(commits.get(key).type).toBe(0); }); it('should handle a gitGraph commit with custom commit id only', function () { @@ -30,15 +30,15 @@ describe('when parsing a gitGraph', function () { `; parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).toBe('1111'); - expect(commits[key].tag).toBe(''); - expect(commits[key].type).toBe(0); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).toBe('1111'); + expect(commits.get(key).tag).toBe(''); + expect(commits.get(key).type).toBe(0); }); it('should handle a gitGraph commit with custom commit tag only', function () { @@ -48,15 +48,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe('test'); - expect(commits[key].type).toBe(0); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe('test'); + expect(commits.get(key).type).toBe(0); }); it('should handle a gitGraph commit with custom commit type HIGHLIGHT only', function () { @@ -66,15 +66,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe(''); - expect(commits[key].type).toBe(2); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe(''); + expect(commits.get(key).type).toBe(2); }); it('should handle a gitGraph commit with custom commit type REVERSE only', function () { @@ -84,15 +84,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe(''); - expect(commits[key].type).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe(''); + expect(commits.get(key).type).toBe(1); }); it('should handle a gitGraph commit with custom commit type NORMAL only', function () { @@ -102,15 +102,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe(''); - expect(commits[key].type).toBe(0); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe(''); + expect(commits.get(key).type).toBe(0); }); it('should handle a gitGraph commit with custom commit msg only', function () { @@ -120,15 +120,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe('test commit'); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe(''); - expect(commits[key].type).toBe(0); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe('test commit'); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe(''); + expect(commits.get(key).type).toBe(0); }); it('should handle a gitGraph commit with custom commit "msg:" key only', function () { @@ -138,15 +138,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe('test commit'); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe(''); - expect(commits[key].type).toBe(0); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe('test commit'); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe(''); + expect(commits.get(key).type).toBe(0); }); it('should handle a gitGraph commit with custom commit id, tag only', function () { @@ -156,15 +156,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).toBe('1111'); - expect(commits[key].tag).toBe('test tag'); - expect(commits[key].type).toBe(0); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).toBe('1111'); + expect(commits.get(key).tag).toBe('test tag'); + expect(commits.get(key).type).toBe(0); }); it('should handle a gitGraph commit with custom commit type, tag only', function () { @@ -174,15 +174,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe('test tag'); - expect(commits[key].type).toBe(2); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe('test tag'); + expect(commits.get(key).type).toBe(2); }); it('should handle a gitGraph commit with custom commit tag and type only', function () { @@ -192,15 +192,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).not.toBeNull(); - expect(commits[key].tag).toBe('test tag'); - expect(commits[key].type).toBe(2); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).not.toBeNull(); + expect(commits.get(key).tag).toBe('test tag'); + expect(commits.get(key).type).toBe(2); }); it('should handle a gitGraph commit with custom commit id, type and tag only', function () { @@ -210,15 +210,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe(''); - expect(commits[key].id).toBe('1111'); - expect(commits[key].tag).toBe('test tag'); - expect(commits[key].type).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe(''); + expect(commits.get(key).id).toBe('1111'); + expect(commits.get(key).tag).toBe('test tag'); + expect(commits.get(key).type).toBe(1); }); it('should handle a gitGraph commit with custom commit id, type, tag and msg', function () { @@ -228,15 +228,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe('test msg'); - expect(commits[key].id).toBe('1111'); - expect(commits[key].tag).toBe('test tag'); - expect(commits[key].type).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe('test msg'); + expect(commits.get(key).id).toBe('1111'); + expect(commits.get(key).tag).toBe('test tag'); + expect(commits.get(key).type).toBe(1); }); it('should handle a gitGraph commit with custom type,tag, msg, commit id,', function () { @@ -247,15 +247,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe('test msg'); - expect(commits[key].id).toBe('1111'); - expect(commits[key].tag).toBe('test tag'); - expect(commits[key].type).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe('test msg'); + expect(commits.get(key).id).toBe('1111'); + expect(commits.get(key).tag).toBe('test tag'); + expect(commits.get(key).type).toBe(1); }); it('should handle a gitGraph commit with custom tag, msg, commit id, type,', function () { @@ -265,15 +265,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe('test msg'); - expect(commits[key].id).toBe('1111'); - expect(commits[key].tag).toBe('test tag'); - expect(commits[key].type).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe('test msg'); + expect(commits.get(key).id).toBe('1111'); + expect(commits.get(key).tag).toBe('test tag'); + expect(commits.get(key).type).toBe(1); }); it('should handle a gitGraph commit with custom msg, commit id, type,tag', function () { @@ -283,15 +283,15 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); - const key = Object.keys(commits)[0]; - expect(commits[key].message).toBe('test msg'); - expect(commits[key].id).toBe('1111'); - expect(commits[key].tag).toBe('test tag'); - expect(commits[key].type).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key).message).toBe('test msg'); + expect(commits.get(key).id).toBe('1111'); + expect(commits.get(key).tag).toBe('test tag'); + expect(commits.get(key).type).toBe(1); }); it('should handle 3 straight commits', function () { @@ -303,10 +303,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(3); + expect(commits.size).toBe(3); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(1); + expect(parser.yy.getBranches().size).toBe(1); }); it('should handle new branch creation', function () { @@ -317,10 +317,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('testBranch'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); + expect(parser.yy.getBranches().size).toBe(2); }); it('should allow quoted branch names', function () { @@ -335,16 +335,16 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(3); + expect(commits.size).toBe(3); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); - const commit1 = Object.keys(commits)[0]; - const commit2 = Object.keys(commits)[1]; - const commit3 = Object.keys(commits)[2]; - expect(commits[commit1].branch).toBe('main'); - expect(commits[commit2].branch).toBe('branch'); - expect(commits[commit3].branch).toBe('main'); + expect(parser.yy.getBranches().size).toBe(2); + const commit1 = commits.keys().next().value; + const commit2 = [...commits.keys()][1]; + const commit3 = [...commits.keys()][2]; + expect(commits.get(commit1).branch).toBe('main'); + expect(commits.get(commit2).branch).toBe('branch'); + expect(commits.get(commit3).branch).toBe('main'); expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'branch' }]); }); @@ -356,10 +356,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('azAZ_-./test'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); + expect(parser.yy.getBranches().size).toBe(2); }); it('should allow branch names starting with numbers', function () { @@ -371,10 +371,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('1.0.1'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); + expect(parser.yy.getBranches().size).toBe(2); }); it('should allow branch names starting with unusual prefixes', function () { @@ -392,11 +392,11 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('A'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(7); - expect(Object.keys(parser.yy.getBranches())).toEqual( + expect(parser.yy.getBranches().size).toBe(7); + expect([...parser.yy.getBranches().keys()]).toEqual( expect.arrayContaining([ 'branch01', 'checkout02', @@ -417,10 +417,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('testBranch'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); + expect(parser.yy.getBranches().size).toBe(2); }); it('should handle new branch checkout with order', function () { const str = `gitGraph: @@ -432,9 +432,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('test3'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(4); + expect(parser.yy.getBranches().size).toBe(4); expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ { name: 'main' }, { name: 'test3' }, @@ -452,9 +452,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('test3'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(4); + expect(parser.yy.getBranches().size).toBe(4); expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ { name: 'main' }, { name: 'test2' }, @@ -473,16 +473,16 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(2); + expect(commits.size).toBe(2); expect(parser.yy.getCurrentBranch()).toBe('testBranch'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); - const commit1 = Object.keys(commits)[0]; - const commit2 = Object.keys(commits)[1]; - expect(commits[commit1].branch).toBe('main'); - expect(commits[commit1].parents).toStrictEqual([]); - expect(commits[commit2].branch).toBe('testBranch'); - expect(commits[commit2].parents).toStrictEqual([commit1]); + expect(parser.yy.getBranches().size).toBe(2); + const commit1 = commits.keys().next().value; + const commit2 = [...commits.keys()][1]; + expect(commits.get(commit1).branch).toBe('main'); + expect(commits.get(commit1).parents).toStrictEqual([]); + expect(commits.get(commit2).branch).toBe('testBranch'); + expect(commits.get(commit2).parents).toStrictEqual([commit1]); }); it('should handle new branch checkout & commit and merge', function () { @@ -498,22 +498,25 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(4); + expect(commits.size).toBe(4); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); - const commit1 = Object.keys(commits)[0]; - const commit2 = Object.keys(commits)[1]; - const commit3 = Object.keys(commits)[2]; - const commit4 = Object.keys(commits)[3]; - expect(commits[commit1].branch).toBe('main'); - expect(commits[commit1].parents).toStrictEqual([]); - expect(commits[commit2].branch).toBe('testBranch'); - expect(commits[commit2].parents).toStrictEqual([commits[commit1].id]); - expect(commits[commit3].branch).toBe('testBranch'); - expect(commits[commit3].parents).toStrictEqual([commits[commit2].id]); - expect(commits[commit4].branch).toBe('main'); - expect(commits[commit4].parents).toStrictEqual([commits[commit1].id, commits[commit3].id]); + expect(parser.yy.getBranches().size).toBe(2); + const commit1 = commits.keys().next().value; + const commit2 = [...commits.keys()][1]; + const commit3 = [...commits.keys()][2]; + const commit4 = [...commits.keys()][3]; + expect(commits.get(commit1).branch).toBe('main'); + expect(commits.get(commit1).parents).toStrictEqual([]); + expect(commits.get(commit2).branch).toBe('testBranch'); + expect(commits.get(commit2).parents).toStrictEqual([commits.get(commit1).id]); + expect(commits.get(commit3).branch).toBe('testBranch'); + expect(commits.get(commit3).parents).toStrictEqual([commits.get(commit2).id]); + expect(commits.get(commit4).branch).toBe('main'); + expect(commits.get(commit4).parents).toStrictEqual([ + commits.get(commit1).id, + commits.get(commit3).id, + ]); expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ { name: 'main' }, { name: 'testBranch' }, @@ -529,10 +532,10 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(1); + expect(commits.size).toBe(1); expect(parser.yy.getCurrentBranch()).toBe('testBranch'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); + expect(parser.yy.getBranches().size).toBe(2); }); it('should handle new branch switch & commit', function () { @@ -545,16 +548,16 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(2); + expect(commits.size).toBe(2); expect(parser.yy.getCurrentBranch()).toBe('testBranch'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); - const commit1 = Object.keys(commits)[0]; - const commit2 = Object.keys(commits)[1]; - expect(commits[commit1].branch).toBe('main'); - expect(commits[commit1].parents).toStrictEqual([]); - expect(commits[commit2].branch).toBe('testBranch'); - expect(commits[commit2].parents).toStrictEqual([commit1]); + expect(parser.yy.getBranches().size).toBe(2); + const commit1 = commits.keys().next().value; + const commit2 = [...commits.keys()][1]; + expect(commits.get(commit1).branch).toBe('main'); + expect(commits.get(commit1).parents).toStrictEqual([]); + expect(commits.get(commit2).branch).toBe('testBranch'); + expect(commits.get(commit2).parents).toStrictEqual([commit1]); }); it('should handle new branch switch & commit and merge', function () { @@ -570,22 +573,25 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(4); + expect(commits.size).toBe(4); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); - const commit1 = Object.keys(commits)[0]; - const commit2 = Object.keys(commits)[1]; - const commit3 = Object.keys(commits)[2]; - const commit4 = Object.keys(commits)[3]; - expect(commits[commit1].branch).toBe('main'); - expect(commits[commit1].parents).toStrictEqual([]); - expect(commits[commit2].branch).toBe('testBranch'); - expect(commits[commit2].parents).toStrictEqual([commits[commit1].id]); - expect(commits[commit3].branch).toBe('testBranch'); - expect(commits[commit3].parents).toStrictEqual([commits[commit2].id]); - expect(commits[commit4].branch).toBe('main'); - expect(commits[commit4].parents).toStrictEqual([commits[commit1].id, commits[commit3].id]); + expect(parser.yy.getBranches().size).toBe(2); + const commit1 = commits.keys().next().value; + const commit2 = [...commits.keys()][1]; + const commit3 = [...commits.keys()][2]; + const commit4 = [...commits.keys()][3]; + expect(commits.get(commit1).branch).toBe('main'); + expect(commits.get(commit1).parents).toStrictEqual([]); + expect(commits.get(commit2).branch).toBe('testBranch'); + expect(commits.get(commit2).parents).toStrictEqual([commits.get(commit1).id]); + expect(commits.get(commit3).branch).toBe('testBranch'); + expect(commits.get(commit3).parents).toStrictEqual([commits.get(commit2).id]); + expect(commits.get(commit4).branch).toBe('main'); + expect(commits.get(commit4).parents).toStrictEqual([ + commits.get(commit1).id, + commits.get(commit3).id, + ]); expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ { name: 'main' }, { name: 'testBranch' }, @@ -604,23 +610,26 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(3); + expect(commits.size).toBe(3); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); - expect(Object.keys(parser.yy.getBranches()).length).toBe(2); - const commit1 = Object.keys(commits)[0]; - const commit2 = Object.keys(commits)[1]; - const commit3 = Object.keys(commits)[2]; + expect(parser.yy.getBranches().size).toBe(2); + const commit1 = commits.keys().next().value; + const commit2 = [...commits.keys()][1]; + const commit3 = [...commits.keys()][2]; - expect(commits[commit1].branch).toBe('main'); - expect(commits[commit1].parents).toStrictEqual([]); + expect(commits.get(commit1).branch).toBe('main'); + expect(commits.get(commit1).parents).toStrictEqual([]); - expect(commits[commit2].branch).toBe('testBranch'); - expect(commits[commit2].parents).toStrictEqual([commits[commit1].id]); + expect(commits.get(commit2).branch).toBe('testBranch'); + expect(commits.get(commit2).parents).toStrictEqual([commits.get(commit1).id]); - expect(commits[commit3].branch).toBe('main'); - expect(commits[commit3].parents).toStrictEqual([commits[commit1].id, commits[commit2].id]); - expect(commits[commit3].tag).toBe('merge-tag'); + expect(commits.get(commit3).branch).toBe('main'); + expect(commits.get(commit3).parents).toStrictEqual([ + commits.get(commit1).id, + commits.get(commit2).id, + ]); + expect(commits.get(commit3).tag).toBe('merge-tag'); expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ { name: 'main' }, { name: 'testBranch' }, @@ -652,7 +661,7 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - expect(Object.keys(commits).length).toBe(7); + expect(commits.size).toBe(7); expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); @@ -665,7 +674,7 @@ describe('when parsing a gitGraph', function () { testBranch2Merge, testBranch3Commit, testBranch3Merge, - ] = Object.values(commits); + ] = [...commits.values()]; expect(mainCommit.branch).toBe('main'); expect(mainCommit.parents).toStrictEqual([]); @@ -708,9 +717,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - const cherryPickCommitID = Object.keys(commits)[2]; - expect(commits[cherryPickCommitID].tag).toBe('cherry-pick:A'); - expect(commits[cherryPickCommitID].branch).toBe('main'); + const cherryPickCommitID = [...commits.keys()][2]; + expect(commits.get(cherryPickCommitID).tag).toBe('cherry-pick:A'); + expect(commits.get(cherryPickCommitID).branch).toBe('main'); }); it('should support cherry-picking commits with custom tag', function () { @@ -724,9 +733,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - const cherryPickCommitID = Object.keys(commits)[2]; - expect(commits[cherryPickCommitID].tag).toBe('MyTag'); - expect(commits[cherryPickCommitID].branch).toBe('main'); + const cherryPickCommitID = [...commits.keys()][2]; + expect(commits.get(cherryPickCommitID).tag).toBe('MyTag'); + expect(commits.get(cherryPickCommitID).branch).toBe('main'); }); it('should support cherry-picking commits with no tag', function () { @@ -740,9 +749,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - const cherryPickCommitID = Object.keys(commits)[2]; - expect(commits[cherryPickCommitID].tag).toBe(''); - expect(commits[cherryPickCommitID].branch).toBe('main'); + const cherryPickCommitID = [...commits.keys()][2]; + expect(commits.get(cherryPickCommitID).tag).toBe(''); + expect(commits.get(cherryPickCommitID).branch).toBe('main'); }); it('should support cherry-picking of merge commits', function () { @@ -761,9 +770,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - const cherryPickCommitID = Object.keys(commits)[4]; - expect(commits[cherryPickCommitID].tag).toBe('cherry-pick:M|parent:B'); - expect(commits[cherryPickCommitID].branch).toBe('release'); + const cherryPickCommitID = [...commits.keys()][4]; + expect(commits.get(cherryPickCommitID).tag).toBe('cherry-pick:M|parent:B'); + expect(commits.get(cherryPickCommitID).branch).toBe('release'); }); it('should support cherry-picking of merge commits with tag', function () { @@ -782,9 +791,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - const cherryPickCommitID = Object.keys(commits)[4]; - expect(commits[cherryPickCommitID].tag).toBe('v1.0'); - expect(commits[cherryPickCommitID].branch).toBe('release'); + const cherryPickCommitID = [...commits.keys()][4]; + expect(commits.get(cherryPickCommitID).tag).toBe('v1.0'); + expect(commits.get(cherryPickCommitID).branch).toBe('release'); }); it('should support cherry-picking of merge commits with additional commit', function () { @@ -805,9 +814,9 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - const cherryPickCommitID = Object.keys(commits)[5]; - expect(commits[cherryPickCommitID].tag).toBe('v2.1:ZERO'); - expect(commits[cherryPickCommitID].branch).toBe('release'); + const cherryPickCommitID = [...commits.keys()][5]; + expect(commits.get(cherryPickCommitID).tag).toBe('v2.1:ZERO'); + expect(commits.get(cherryPickCommitID).branch).toBe('release'); }); it('should support cherry-picking of merge commits with empty tag', function () { @@ -829,11 +838,11 @@ describe('when parsing a gitGraph', function () { parser.parse(str); const commits = parser.yy.getCommits(); - const cherryPickCommitID = Object.keys(commits)[5]; - const cherryPickCommitID2 = Object.keys(commits)[7]; - expect(commits[cherryPickCommitID].tag).toBe(''); - expect(commits[cherryPickCommitID2].tag).toBe(''); - expect(commits[cherryPickCommitID].branch).toBe('release'); + const cherryPickCommitID = [...commits.keys()][5]; + const cherryPickCommitID2 = [...commits.keys()][7]; + expect(commits.get(cherryPickCommitID).tag).toBe(''); + expect(commits.get(cherryPickCommitID2).tag).toBe(''); + expect(commits.get(cherryPickCommitID).branch).toBe('release'); }); it('should fail cherry-picking of merge commits if the parent of merge commits is not specified', function () { diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.js b/packages/mermaid/src/diagrams/git/gitGraphRenderer.js index 7ccc60cd03..2576b26628 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.js +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.js @@ -129,7 +129,7 @@ const setParallelBTPos = (sortedKeys, commits, defaultPos, commitStep, layoutOff let maxPosition = defaultPos; let roots = []; sortedKeys.forEach((key) => { - const commit = commits[key]; + const commit = commits.get(key); if (commit.parents.length) { const closestParent = findClosestParent(commit.parents); curPos = commitPos[closestParent].y + commitStep; @@ -151,7 +151,7 @@ const setParallelBTPos = (sortedKeys, commits, defaultPos, commitStep, layoutOff commitPos[commit.id] = { x: x, y: y }; }); sortedKeys.forEach((key) => { - const commit = commits[key]; + const commit = commits.get(key); if (commit.parents.length) { const closestParent = findClosestParentBT(commit.parents); curPos = commitPos[closestParent].y - commitStep; @@ -183,18 +183,18 @@ const drawCommits = (svg, commits, modifyGraph) => { if (dir === 'TB' || dir === 'BT') { pos = defaultPos; } - const keys = Object.keys(commits); + const keys = [...commits.keys()]; const isParallelCommits = gitGraphConfig.parallelCommits; const layoutOffset = 10; const commitStep = 40; let sortedKeys = dir !== 'BT' || (dir === 'BT' && isParallelCommits) ? keys.sort((a, b) => { - return commits[a].seq - commits[b].seq; + return commits.get(a).seq - commits.get(b).seq; }) : keys .sort((a, b) => { - return commits[a].seq - commits[b].seq; + return commits.get(a).seq - commits.get(b).seq; }) .reverse(); @@ -203,7 +203,7 @@ const drawCommits = (svg, commits, modifyGraph) => { sortedKeys = sortedKeys.reverse(); } sortedKeys.forEach((key) => { - const commit = commits[key]; + const commit = commits.get(key); if (isParallelCommits) { if (commit.parents.length) { const closestParent = @@ -712,11 +712,11 @@ const drawArrow = (svg, commitA, commitB, allCommits) => { const drawArrows = (svg, commits) => { const gArrows = svg.append('g').attr('class', 'commit-arrows'); - Object.keys(commits).forEach((key) => { - const commit = commits[key]; + [...commits.keys()].forEach((key) => { + const commit = commits.get(key); if (commit.parents && commit.parents.length > 0) { commit.parents.forEach((parent) => { - drawArrow(gArrows, commits[parent], commit, commits); + drawArrow(gArrows, commits.get(parent), commit, commits); }); } }); diff --git a/packages/mermaid/src/diagrams/pie/pie.spec.ts b/packages/mermaid/src/diagrams/pie/pie.spec.ts index f68e80efdb..32d49374bf 100644 --- a/packages/mermaid/src/diagrams/pie/pie.spec.ts +++ b/packages/mermaid/src/diagrams/pie/pie.spec.ts @@ -16,7 +16,7 @@ describe('pie', () => { `); const sections = db.getSections(); - expect(sections['ash']).toBe(100); + expect(sections.get('ash')).toBe(100); }); it('should handle simple pie', async () => { @@ -26,8 +26,8 @@ describe('pie', () => { `); const sections = db.getSections(); - expect(sections['ash']).toBe(60); - expect(sections['bat']).toBe(40); + expect(sections.get('ash')).toBe(60); + expect(sections.get('bat')).toBe(40); }); it('should handle simple pie with showData', async () => { @@ -39,8 +39,8 @@ describe('pie', () => { expect(db.getShowData()).toBeTruthy(); const sections = db.getSections(); - expect(sections['ash']).toBe(60); - expect(sections['bat']).toBe(40); + expect(sections.get('ash')).toBe(60); + expect(sections.get('bat')).toBe(40); }); it('should handle simple pie with comments', async () => { @@ -51,8 +51,8 @@ describe('pie', () => { `); const sections = db.getSections(); - expect(sections['ash']).toBe(60); - expect(sections['bat']).toBe(40); + expect(sections.get('ash')).toBe(60); + expect(sections.get('bat')).toBe(40); }); it('should handle simple pie with a title', async () => { @@ -64,8 +64,8 @@ describe('pie', () => { expect(db.getDiagramTitle()).toBe('a 60/40 pie'); const sections = db.getSections(); - expect(sections['ash']).toBe(60); - expect(sections['bat']).toBe(40); + expect(sections.get('ash')).toBe(60); + expect(sections.get('bat')).toBe(40); }); it('should handle simple pie with an acc title (accTitle)', async () => { @@ -80,8 +80,8 @@ describe('pie', () => { expect(db.getAccTitle()).toBe('a neat acc title'); const sections = db.getSections(); - expect(sections['ash']).toBe(60); - expect(sections['bat']).toBe(40); + expect(sections.get('ash')).toBe(60); + expect(sections.get('bat')).toBe(40); }); it('should handle simple pie with an acc description (accDescr)', async () => { @@ -96,8 +96,8 @@ describe('pie', () => { expect(db.getAccDescription()).toBe('a neat description'); const sections = db.getSections(); - expect(sections['ash']).toBe(60); - expect(sections['bat']).toBe(40); + expect(sections.get('ash')).toBe(60); + expect(sections.get('bat')).toBe(40); }); it('should handle simple pie with a multiline acc description (accDescr)', async () => { @@ -115,8 +115,8 @@ describe('pie', () => { expect(db.getAccDescription()).toBe('a neat description\non multiple lines'); const sections = db.getSections(); - expect(sections['ash']).toBe(60); - expect(sections['bat']).toBe(40); + expect(sections.get('ash')).toBe(60); + expect(sections.get('bat')).toBe(40); }); it('should handle simple pie with positive decimal', async () => { @@ -126,8 +126,8 @@ describe('pie', () => { `); const sections = db.getSections(); - expect(sections['ash']).toBe(60.67); - expect(sections['bat']).toBe(40); + expect(sections.get('ash')).toBe(60.67); + expect(sections.get('bat')).toBe(40); }); it('should handle simple pie with negative decimal', () => { diff --git a/packages/mermaid/src/diagrams/pie/pieDb.ts b/packages/mermaid/src/diagrams/pie/pieDb.ts index 1501aad1f4..64831495cd 100644 --- a/packages/mermaid/src/diagrams/pie/pieDb.ts +++ b/packages/mermaid/src/diagrams/pie/pieDb.ts @@ -16,7 +16,7 @@ import DEFAULT_CONFIG from '../../defaultConfig.js'; export const DEFAULT_PIE_CONFIG: Required = DEFAULT_CONFIG.pie; export const DEFAULT_PIE_DB: RequiredDeep = { - sections: {}, + sections: new Map(), showData: false, config: DEFAULT_PIE_CONFIG, } as const; @@ -28,14 +28,14 @@ const config: Required = structuredClone(DEFAULT_PIE_CONFIG); const getConfig = (): Required => structuredClone(config); const clear = (): void => { - sections = structuredClone(DEFAULT_PIE_DB.sections); + sections = new Map(); showData = DEFAULT_PIE_DB.showData; commonClear(); }; const addSection = ({ label, value }: D3Section): void => { - if (sections[label] === undefined) { - sections[label] = value; + if (!sections.has(label)) { + sections.set(label, value); log.debug(`added new section: ${label}, with value: ${value}`); } }; diff --git a/packages/mermaid/src/diagrams/pie/pieRenderer.ts b/packages/mermaid/src/diagrams/pie/pieRenderer.ts index fb386863b0..0f7b7da9aa 100644 --- a/packages/mermaid/src/diagrams/pie/pieRenderer.ts +++ b/packages/mermaid/src/diagrams/pie/pieRenderer.ts @@ -11,7 +11,7 @@ import { selectSvgElement } from '../../rendering-util/selectSvgElement.js'; const createPieArcs = (sections: Sections): d3.PieArcDatum[] => { // Compute the position of each group on the pie: - const pieData: D3Section[] = Object.entries(sections) + const pieData: D3Section[] = [...sections.entries()] .map((element: [string, number]): D3Section => { return { label: element[0], @@ -105,8 +105,8 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => { .attr('class', 'pieCircle'); let sum = 0; - Object.keys(sections).forEach((key: string): void => { - sum += sections[key]; + [...sections.keys()].forEach((key: string): void => { + sum += sections.get(key)!; }); // Now add the percentage. // Use the centroid method to get the best coordinates. diff --git a/packages/mermaid/src/diagrams/pie/pieTypes.ts b/packages/mermaid/src/diagrams/pie/pieTypes.ts index 8b8a367e42..be7bbf68eb 100644 --- a/packages/mermaid/src/diagrams/pie/pieTypes.ts +++ b/packages/mermaid/src/diagrams/pie/pieTypes.ts @@ -34,7 +34,7 @@ export interface PieStyleOptions { pieOpacity: string; } -export type Sections = Record; +export type Sections = Map; export interface D3Section { label: string; diff --git a/packages/mermaid/src/diagrams/requirement/parser/requirementDiagram.spec.js b/packages/mermaid/src/diagrams/requirement/parser/requirementDiagram.spec.js index 1b4c5da318..7e4e26cdec 100644 --- a/packages/mermaid/src/diagrams/requirement/parser/requirementDiagram.spec.js +++ b/packages/mermaid/src/diagrams/requirement/parser/requirementDiagram.spec.js @@ -33,14 +33,14 @@ describe('when parsing requirement diagram it...', function () { reqDiagram.parser.parse(doc); - expect(Object.keys(requirementDb.getRequirements()).length).toBe(1); + expect(requirementDb.getRequirements().size).toBe(1); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.id).toBe(expectedId); expect(foundReq.text).toBe(expectedText); - expect(Object.keys(requirementDb.getElements()).length).toBe(0); + expect(requirementDb.getElements().size).toBe(0); expect(Object.keys(requirementDb.getRelationships()).length).toBe(0); }); @@ -61,10 +61,10 @@ describe('when parsing requirement diagram it...', function () { reqDiagram.parser.parse(doc); - expect(Object.keys(requirementDb.getRequirements()).length).toBe(0); - expect(Object.keys(requirementDb.getElements()).length).toBe(1); + expect(requirementDb.getRequirements().size).toBe(0); + expect(requirementDb.getElements().size).toBe(1); - let foundElement = requirementDb.getElements()[expectedName]; + let foundElement = requirementDb.getElements().get(expectedName); expect(foundElement).toBeDefined(); expect(foundElement.type).toBe(expectedType); expect(foundElement.docRef).toBe(expectedDocRef); @@ -121,8 +121,8 @@ line 2`; reqDiagram.parser.parse(doc); - expect(Object.keys(requirementDb.getRequirements()).length).toBe(0); - expect(Object.keys(requirementDb.getElements()).length).toBe(0); + expect(requirementDb.getRequirements().size).toBe(0); + expect(requirementDb.getElements().size).toBe(0); expect(Object.keys(requirementDb.getRelationships()).length).toBe(1); let foundRelationship = requirementDb.getRelationships()[0]; @@ -152,7 +152,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.type).toBe(expectedType); }); @@ -179,7 +179,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.type).toBe(expectedType); }); @@ -206,7 +206,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.type).toBe(expectedType); }); @@ -233,7 +233,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.type).toBe(expectedType); }); @@ -260,7 +260,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.type).toBe(expectedType); }); @@ -287,7 +287,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.type).toBe(expectedType); }); @@ -314,7 +314,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.risk).toBe(expectedRisk); }); @@ -341,7 +341,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.risk).toBe(expectedRisk); }); @@ -368,7 +368,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.risk).toBe(expectedRisk); }); @@ -395,7 +395,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.verifyMethod).toBe(expectedVerifyMethod); }); @@ -422,7 +422,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.verifyMethod).toBe(expectedVerifyMethod); }); @@ -449,7 +449,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.verifyMethod).toBe(expectedVerifyMethod); }); @@ -476,7 +476,7 @@ line 2`; reqDiagram.parser.parse(doc); - let foundReq = requirementDb.getRequirements()[expectedName]; + let foundReq = requirementDb.getRequirements().get(expectedName); expect(foundReq).toBeDefined(); expect(foundReq.verifyMethod).toBe(expectedVerifyMethod); }); diff --git a/packages/mermaid/src/diagrams/requirement/requirementDb.js b/packages/mermaid/src/diagrams/requirement/requirementDb.js index 9357e2a660..068e0fdab0 100644 --- a/packages/mermaid/src/diagrams/requirement/requirementDb.js +++ b/packages/mermaid/src/diagrams/requirement/requirementDb.js @@ -11,9 +11,9 @@ import { let relations = []; let latestRequirement = {}; -let requirements = {}; +let requirements = new Map(); let latestElement = {}; -let elements = {}; +let elements = new Map(); const RequirementType = { REQUIREMENT: 'Requirement', @@ -48,8 +48,8 @@ const Relationships = { }; const addRequirement = (name, type) => { - if (requirements[name] === undefined) { - requirements[name] = { + if (!requirements.has(name)) { + requirements.set(name, { name, type, @@ -57,11 +57,11 @@ const addRequirement = (name, type) => { text: latestRequirement.text, risk: latestRequirement.risk, verifyMethod: latestRequirement.verifyMethod, - }; + }); } latestRequirement = {}; - return requirements[name]; + return requirements.get(name); }; const getRequirements = () => requirements; @@ -91,18 +91,17 @@ const setNewReqVerifyMethod = (verifyMethod) => { }; const addElement = (name) => { - if (elements[name] === undefined) { - elements[name] = { + if (!elements.has(name)) { + elements.set(name, { name, - type: latestElement.type, docRef: latestElement.docRef, - }; + }); log.info('Added new requirement: ', name); } latestElement = {}; - return elements[name]; + return elements.get(name); }; const getElements = () => elements; @@ -132,9 +131,9 @@ const getRelationships = () => relations; const clear = () => { relations = []; latestRequirement = {}; - requirements = {}; + requirements = new Map(); latestElement = {}; - elements = {}; + elements = new Map(); commonClear(); }; diff --git a/packages/mermaid/src/diagrams/requirement/requirementRenderer.js b/packages/mermaid/src/diagrams/requirement/requirementRenderer.js index b06b1d7b5b..274ae98c72 100644 --- a/packages/mermaid/src/diagrams/requirement/requirementRenderer.js +++ b/packages/mermaid/src/diagrams/requirement/requirementRenderer.js @@ -192,8 +192,8 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) { }; export const drawReqs = (reqs, graph, svgNode) => { - Object.keys(reqs).forEach((reqName) => { - let req = reqs[reqName]; + [...reqs.keys()].forEach((reqName) => { + let req = reqs.get(reqName); reqName = elementString(reqName); log.info('Added new requirement: ', reqName); @@ -237,8 +237,8 @@ export const drawReqs = (reqs, graph, svgNode) => { }; export const drawElements = (els, graph, svgNode) => { - Object.keys(els).forEach((elName) => { - let el = els[elName]; + [...els.keys()].forEach((elName) => { + let el = els.get(elName); const id = elementString(elName); const groupNode = svgNode.append('g').attr('id', id); diff --git a/packages/mermaid/src/diagrams/sankey/sankeyDB.ts b/packages/mermaid/src/diagrams/sankey/sankeyDB.ts index 4826dc6d98..d8fa19a68f 100644 --- a/packages/mermaid/src/diagrams/sankey/sankeyDB.ts +++ b/packages/mermaid/src/diagrams/sankey/sankeyDB.ts @@ -15,12 +15,12 @@ let links: SankeyLink[] = []; // Array of nodes guarantees their order let nodes: SankeyNode[] = []; // We also have to track nodes uniqueness (by ID) -let nodesMap: Record = {}; +let nodesMap: Map = new Map(); const clear = (): void => { links = []; nodes = []; - nodesMap = {}; + nodesMap = new Map(); commonClear(); }; @@ -48,11 +48,11 @@ class SankeyNode { const findOrCreateNode = (ID: string): SankeyNode => { ID = common.sanitizeText(ID, getConfig()); - if (!nodesMap[ID]) { - nodesMap[ID] = new SankeyNode(ID); - nodes.push(nodesMap[ID]); + if (!nodesMap.has(ID)) { + nodesMap.set(ID, new SankeyNode(ID)); + nodes.push(nodesMap.get(ID)!); } - return nodesMap[ID]; + return nodesMap.get(ID)!; }; const getNodes = () => nodes; diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDb.ts b/packages/mermaid/src/diagrams/sequence/sequenceDb.ts index 03d3210aa9..2f15fdd49e 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDb.ts +++ b/packages/mermaid/src/diagrams/sequence/sequenceDb.ts @@ -15,9 +15,9 @@ import type { Actor, AddMessageParams, Box, Message, Note } from './types.js'; interface SequenceState { prevActor?: string; - actors: Record; - createdActors: Record; - destroyedActors: Record; + actors: Map; + createdActors: Map; + destroyedActors: Map; boxes: Box[]; messages: Message[]; notes: Note[]; @@ -30,9 +30,9 @@ interface SequenceState { const state = new ImperativeState(() => ({ prevActor: undefined, - actors: {}, - createdActors: {}, - destroyedActors: {}, + actors: new Map(), + createdActors: new Map(), + destroyedActors: new Map(), boxes: [], messages: [], notes: [], @@ -60,7 +60,7 @@ export const addActor = function ( type: string ) { let assignedBox = state.records.currentBox; - const old = state.records.actors[id]; + const old = state.records.actors.get(id); if (old) { // If already set and trying to set to a new one throw error if (state.records.currentBox && old.box && state.records.currentBox !== old.box) { @@ -87,7 +87,7 @@ export const addActor = function ( description = { text: name, wrap: null, type }; } - state.records.actors[id] = { + state.records.actors.set(id, { box: assignedBox, name: name, description: description.text, @@ -98,9 +98,9 @@ export const addActor = function ( actorCnt: null, rectData: null, type: type ?? 'participant', - }; - if (state.records.prevActor && state.records.actors[state.records.prevActor]) { - state.records.actors[state.records.prevActor].nextActor = id; + }); + if (state.records.prevActor && state.records.actors.has(state.records.prevActor)) { + state.records.actors.get(state.records.prevActor)!.nextActor = id; } if (state.records.currentBox) { @@ -210,10 +210,10 @@ export const getDestroyedActors = function () { return state.records.destroyedActors; }; export const getActor = function (id: string) { - return state.records.actors[id]; + return state.records.actors.get(id)!; }; export const getActorKeys = function () { - return Object.keys(state.records.actors); + return [...state.records.actors.keys()]; }; export const enableSequenceNumbers = function () { state.records.sequenceNumbersEnabled = true; @@ -502,18 +502,18 @@ export const apply = function (param: any | AddMessageParams | AddMessageParams[ addActor(param.actor, param.actor, param.description, param.draw); break; case 'createParticipant': - if (state.records.actors[param.actor]) { + if (state.records.actors.has(param.actor)) { throw new Error( "It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior" ); } state.records.lastCreated = param.actor; addActor(param.actor, param.actor, param.description, param.draw); - state.records.createdActors[param.actor] = state.records.messages.length; + state.records.createdActors.set(param.actor, state.records.messages.length); break; case 'destroyParticipant': state.records.lastDestroyed = param.actor; - state.records.destroyedActors[param.actor] = state.records.messages.length; + state.records.destroyedActors.set(param.actor, state.records.messages.length); break; case 'activeStart': addSignal(param.actor, undefined, undefined, param.signalType); diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js index 1724391e53..8098aa2ed7 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js +++ b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js @@ -192,8 +192,8 @@ Bob-->Alice: I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -235,8 +235,8 @@ Bob-->Alice: I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; expect(diagram.db.getAccDescription()).toBe(''); const messages = diagram.db.getMessages(); @@ -258,8 +258,8 @@ Bob-->Alice: I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; expect(diagram.db.getAccDescription()).toBe(''); const messages = diagram.db.getMessages(); @@ -311,8 +311,8 @@ Bob-->Alice: I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -328,8 +328,8 @@ Bob-->Alice-in-Wonderland:I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors['Alice-in-Wonderland'].description).toBe('Alice-in-Wonderland'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice-in-Wonderland').description).toBe('Alice-in-Wonderland'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -348,9 +348,9 @@ Bob-->Alice-in-Wonderland:I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(Object.keys(actors)).toEqual(['Alice-in-Wonderland', 'Bob']); - expect(actors['Alice-in-Wonderland'].description).toBe('Alice-in-Wonderland'); - expect(actors.Bob.description).toBe('Bob'); + expect([...actors.keys()].sort()).toEqual(['Alice-in-Wonderland', 'Bob']); + expect(actors.get('Alice-in-Wonderland').description).toBe('Alice-in-Wonderland'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -371,9 +371,9 @@ B-->A: I am good thanks!`; const actors = diagram.db.getActors(); - expect(Object.keys(actors)).toEqual(['A', 'B']); - expect(actors.A.description).toBe('Alice'); - expect(actors.B.description).toBe('Bob'); + expect([...actors.keys()].sort()).toEqual(['A', 'B']); + expect(actors.get('A').description).toBe('Alice'); + expect(actors.get('B').description).toBe('Bob'); const messages = diagram.db.getMessages(); expect(messages.length).toBe(2); @@ -396,12 +396,12 @@ sequenceDiagram await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(Object.keys(actors)).toEqual(['Alice', 'Bob', 'John', 'Mandy', 'Joan']); - expect(actors.Alice.description).toBe('Alice2'); - expect(actors.Alice.type).toBe('actor'); - expect(actors.Bob.description).toBe('Bob'); - expect(actors.John.type).toBe('participant'); - expect(actors.Joan.type).toBe('participant'); + expect([...actors.keys()]).toEqual(['Alice', 'Bob', 'John', 'Mandy', 'Joan']); + expect(actors.get('Alice').description).toBe('Alice2'); + expect(actors.get('Alice').type).toBe('actor'); + expect(actors.get('Bob').description).toBe('Bob'); + expect(actors.get('John').type).toBe('participant'); + expect(actors.get('Joan').type).toBe('participant'); const messages = diagram.db.getMessages(); expect(messages.length).toBe(5); @@ -419,9 +419,9 @@ B-->A: I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(Object.keys(actors)).toEqual(['A', 'B']); - expect(actors.A.description).toBe('Alice'); - expect(actors.B.description).toBe('Bob'); + expect([...actors.keys()]).toEqual(['A', 'B']); + expect(actors.get('A').description).toBe('Alice'); + expect(actors.get('B').description).toBe('Bob'); const messages = diagram.db.getMessages(); expect(messages.length).toBe(2); @@ -435,8 +435,8 @@ Alice-xBob:Hello Bob, how are you?`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -450,8 +450,8 @@ Alice--xBob:Hello Bob, how are you?`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -465,8 +465,8 @@ Alice-)Bob:Hello Bob, how are you?`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -480,8 +480,8 @@ Alice--)Bob:Hello Bob, how are you?`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -495,8 +495,8 @@ Alice->>Bob:Hello Bob, how are you?`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -508,8 +508,8 @@ Alice->>Bob:Hello Bob, how are you?`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -526,8 +526,8 @@ deactivate Bob`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -547,8 +547,8 @@ deactivate Bob`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -571,8 +571,8 @@ deactivate Bob`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -624,8 +624,8 @@ deactivate Bob`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -645,8 +645,8 @@ deactivate Bob`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -660,8 +660,8 @@ sequenceDiagram;Alice->Bob: Hello Bob, how are you?;Note right of Bob: Bob think await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -680,8 +680,8 @@ Bob-->Alice: I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -700,8 +700,8 @@ Bob-->Alice: I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -725,8 +725,8 @@ Bob-->John: Jolly good!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -754,10 +754,10 @@ note right of 1: multiline
text await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors['1'].description).toBe('multiline
text'); - expect(actors['2'].description).toBe('multiline
text'); - expect(actors['3'].description).toBe('multiline
text'); - expect(actors['4'].description).toBe('multiline
text'); + expect(actors.get('1').description).toBe('multiline
text'); + expect(actors.get('2').description).toBe('multiline
text'); + expect(actors.get('3').description).toBe('multiline
text'); + expect(actors.get('4').description).toBe('multiline
text'); const messages = diagram.db.getMessages(); expect(messages[0].message).toBe('multiline
text'); @@ -893,8 +893,8 @@ end`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -915,8 +915,8 @@ end`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); expect(messages[1].type).toEqual(diagram.db.LINETYPE.RECT_START); @@ -940,8 +940,8 @@ end`; `; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); expect(messages[1].type).toEqual(diagram.db.LINETYPE.RECT_START); @@ -967,8 +967,8 @@ end`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -993,8 +993,8 @@ end`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - actors.Bob.description = 'Bob'; + expect(actors.get('Alice').description).toBe('Alice'); + actors.get('Bob').description = 'Bob'; const messages = diagram.db.getMessages(); @@ -1039,8 +1039,8 @@ sequenceDiagram await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Service.description).toBe('Service'); - expect(actors.DB.description).toBe('DB'); + expect(actors.get('Service').description).toBe('Service'); + expect(actors.get('DB').description).toBe('DB'); const messages = diagram.db.getMessages(); @@ -1063,8 +1063,8 @@ sequenceDiagram await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Service.description).toBe('Service'); - expect(actors.DB.description).toBe('DB'); + expect(actors.get('Service').description).toBe('Service'); + expect(actors.get('DB').description).toBe('DB'); const messages = diagram.db.getMessages(); @@ -1090,8 +1090,8 @@ sequenceDiagram await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Consumer.description).toBe('Consumer'); - expect(actors.API.description).toBe('API'); + expect(actors.get('Consumer').description).toBe('Consumer'); + expect(actors.get('API').description).toBe('API'); const messages = diagram.db.getMessages(); @@ -1120,8 +1120,8 @@ end`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -1142,8 +1142,8 @@ end`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.Alice.description).toBe('Alice'); - expect(actors.Bob.description).toBe('Bob'); + expect(actors.get('Alice').description).toBe('Alice'); + expect(actors.get('Bob').description).toBe('Bob'); const messages = diagram.db.getMessages(); @@ -1309,15 +1309,15 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.a.links['Repo']).toBe('https://repo.contoso.com/'); - expect(actors.b.links['Repo']).toBe(undefined); - expect(actors.a.links['Dashboard']).toBe('https://dashboard.contoso.com/'); - expect(actors.b.links['Dashboard']).toBe('https://dashboard.contoso.com/'); - expect(actors.a.links['On-Call']).toBe('https://oncall.contoso.com/?svc=alice'); - expect(actors.c.links['Dashboard']).toBe(undefined); - expect(actors.a.links['Endpoint']).toBe('https://alice.contoso.com'); - expect(actors.a.links['Swagger']).toBe('https://swagger.contoso.com'); - expect(actors.a.links['Tests']).toBe('https://tests.contoso.com/?svc=alice@contoso.com'); + expect(actors.get('a').links['Repo']).toBe('https://repo.contoso.com/'); + expect(actors.get('b').links['Repo']).toBe(undefined); + expect(actors.get('a').links['Dashboard']).toBe('https://dashboard.contoso.com/'); + expect(actors.get('b').links['Dashboard']).toBe('https://dashboard.contoso.com/'); + expect(actors.get('a').links['On-Call']).toBe('https://oncall.contoso.com/?svc=alice'); + expect(actors.get('c').links['Dashboard']).toBe(undefined); + expect(actors.get('a').links['Endpoint']).toBe('https://alice.contoso.com'); + expect(actors.get('a').links['Swagger']).toBe('https://swagger.contoso.com'); + expect(actors.get('a').links['Tests']).toBe('https://tests.contoso.com/?svc=alice@contoso.com'); }); it('should handle properties EXPERIMENTAL: USE WITH CAUTION', async () => { @@ -1333,11 +1333,11 @@ properties b: {"class": "external-service-actor", "icon": "@computer"} await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(actors.a.properties['class']).toBe('internal-service-actor'); - expect(actors.b.properties['class']).toBe('external-service-actor'); - expect(actors.a.properties['icon']).toBe('@clock'); - expect(actors.b.properties['icon']).toBe('@computer'); - expect(actors.c.properties['class']).toBe(undefined); + expect(actors.get('a').properties['class']).toBe('internal-service-actor'); + expect(actors.get('b').properties['class']).toBe('external-service-actor'); + expect(actors.get('a').properties['icon']).toBe('@clock'); + expect(actors.get('b').properties['icon']).toBe('@computer'); + expect(actors.get('c').properties['class']).toBe(undefined); }); it('should handle box', async () => { @@ -1423,14 +1423,14 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com await mermaidAPI.parse(str); const actors = diagram.db.getActors(); const createdActors = diagram.db.getCreatedActors(); - expect(actors['c'].name).toEqual('c'); - expect(actors['c'].description).toEqual('c'); - expect(actors['c'].type).toEqual('participant'); - expect(createdActors['c']).toEqual(1); - expect(actors['d'].name).toEqual('d'); - expect(actors['d'].description).toEqual('Donald'); - expect(actors['d'].type).toEqual('actor'); - expect(createdActors['d']).toEqual(3); + expect(actors.get('c').name).toEqual('c'); + expect(actors.get('c').description).toEqual('c'); + expect(actors.get('c').type).toEqual('participant'); + expect(createdActors.get('c')).toEqual(1); + expect(actors.get('d').name).toEqual('d'); + expect(actors.get('d').description).toEqual('Donald'); + expect(actors.get('d').type).toEqual('actor'); + expect(createdActors.get('d')).toEqual(3); }); it('should handle simple actor destruction', async () => { const str = ` @@ -1445,8 +1445,8 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com `; await mermaidAPI.parse(str); const destroyedActors = diagram.db.getDestroyedActors(); - expect(destroyedActors['a']).toEqual(1); - expect(destroyedActors['c']).toEqual(3); + expect(destroyedActors.get('a')).toEqual(1); + expect(destroyedActors.get('c')).toEqual(3); }); it('should handle the creation and destruction of the same actor', async () => { const str = ` @@ -1461,8 +1461,8 @@ link a: Tests @ https://tests.contoso.com/?svc=alice@contoso.com await mermaidAPI.parse(str); const createdActors = diagram.db.getCreatedActors(); const destroyedActors = diagram.db.getDestroyedActors(); - expect(createdActors['c']).toEqual(1); - expect(destroyedActors['c']).toEqual(3); + expect(createdActors.get('c')).toEqual(1); + expect(destroyedActors.get('c')).toEqual(3); }); }); describe('when checking the bounds in a sequenceDiagram', function () { @@ -1668,7 +1668,7 @@ participant Alice await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect(Object.keys(actors)).toEqual(['Alice']); + expect([...actors.keys()]).toEqual(['Alice']); }); it('should handle one actor and a centered note', async () => { const str = ` diff --git a/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts b/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts index 98fdcddc40..5404ed2197 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts +++ b/packages/mermaid/src/diagrams/sequence/sequenceRenderer.ts @@ -144,7 +144,7 @@ export const bounds = { this.updateBounds(_startx, _starty, _stopx, _stopy); }, newActivation: function (message, diagram, actors) { - const actorRect = actors[message.from.actor]; + const actorRect = actors.get(message.from.actor); const stackedSize = actorActivations(message.from.actor).length || 0; const x = actorRect.x + actorRect.width / 2 + ((stackedSize - 1) * conf.activationWidth) / 2; this.activations.push({ @@ -488,7 +488,7 @@ const drawMessage = async function (diagram, msgModel, lineStartY: number, diagO const addActorRenderingData = async function ( diagram, actors, - createdActors, + createdActors: Map, actorKeys, verticalPos, messages, @@ -500,7 +500,7 @@ const addActorRenderingData = async function ( let maxHeight = 0; for (const actorKey of actorKeys) { - const actor = actors[actorKey]; + const actor = actors.get(actorKey); const box = actor.box; // end of box @@ -528,7 +528,7 @@ const addActorRenderingData = async function ( maxHeight = common.getMax(maxHeight, actor.height); // if the actor is created by a message, widen margin - if (createdActors[actor.name]) { + if (createdActors.get(actor.name)) { prevMargin += actor.width / 2; } @@ -558,7 +558,7 @@ const addActorRenderingData = async function ( export const drawActors = async function (diagram, actors, actorKeys, isFooter) { if (!isFooter) { for (const actorKey of actorKeys) { - const actor = actors[actorKey]; + const actor = actors.get(actorKey); // Draw the box with the attached line await svgDraw.drawActor(diagram, actor, conf, false); } @@ -566,7 +566,7 @@ export const drawActors = async function (diagram, actors, actorKeys, isFooter) let maxHeight = 0; bounds.bumpVerticalPos(conf.boxMargin * 2); for (const actorKey of actorKeys) { - const actor = actors[actorKey]; + const actor = actors.get(actorKey); if (!actor.stopy) { actor.stopy = bounds.getVerticalPos(); } @@ -581,7 +581,7 @@ export const drawActorsPopup = function (diagram, actors, actorKeys, doc) { let maxHeight = 0; let maxWidth = 0; for (const actorKey of actorKeys) { - const actor = actors[actorKey]; + const actor = actors.get(actorKey); const minMenuWidth = getRequiredPopupWidth(actor); const menuDimensions = svgDraw.drawPopup( diagram, @@ -624,7 +624,7 @@ const actorActivations = function (actor) { const activationBounds = function (actor, actors) { // handle multiple stacked activations for same actor - const actorObj = actors[actor]; + const actorObj = actors.get(actor); const activations = actorActivations(actor); const left = activations.reduce( @@ -682,7 +682,7 @@ function adjustCreatedDestroyedData( destroyedActors ) { function receiverAdjustment(actor, adjustment) { - if (actor.x < actors[msg.from].x) { + if (actor.x < actors.get(msg.from).x) { bounds.insert( msgModel.stopx - adjustment, msgModel.starty, @@ -702,7 +702,7 @@ function adjustCreatedDestroyedData( } function senderAdjustment(actor, adjustment) { - if (actor.x < actors[msg.to].x) { + if (actor.x < actors.get(msg.to).x) { bounds.insert( msgModel.startx - adjustment, msgModel.starty, @@ -722,16 +722,16 @@ function adjustCreatedDestroyedData( } // if it is a create message - if (createdActors[msg.to] == index) { - const actor = actors[msg.to]; + if (createdActors.get(msg.to) == index) { + const actor = actors.get(msg.to); const adjustment = actor.type == 'actor' ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3; receiverAdjustment(actor, adjustment); actor.starty = lineStartY - actor.height / 2; bounds.bumpVerticalPos(actor.height / 2); } // if it is a destroy sender message - else if (destroyedActors[msg.from] == index) { - const actor = actors[msg.from]; + else if (destroyedActors.get(msg.from) == index) { + const actor = actors.get(msg.from); if (conf.mirrorActors) { const adjustment = actor.type == 'actor' ? ACTOR_TYPE_WIDTH / 2 : actor.width / 2; senderAdjustment(actor, adjustment); @@ -740,8 +740,8 @@ function adjustCreatedDestroyedData( bounds.bumpVerticalPos(actor.height / 2); } // if it is a destroy receiver message - else if (destroyedActors[msg.to] == index) { - const actor = actors[msg.to]; + else if (destroyedActors.get(msg.to) == index) { + const actor = actors.get(msg.to); if (conf.mirrorActors) { const adjustment = actor.type == 'actor' ? ACTOR_TYPE_WIDTH / 2 + 3 : actor.width / 2 + 3; receiverAdjustment(actor, adjustment); @@ -1132,15 +1132,15 @@ export const draw = async function (_text: string, id: string, _version: string, * @returns The max message width of each actor. */ async function getMaxMessageWidthPerActor( - actors: { [id: string]: any }, + actors: Map, messages: any[], diagObj: Diagram ): Promise<{ [id: string]: number }> { const maxMessageWidthPerActor = {}; for (const msg of messages) { - if (actors[msg.to] && actors[msg.from]) { - const actor = actors[msg.to]; + if (actors.get(msg.to) && actors.get(msg.from)) { + const actor = actors.get(msg.to); // If this is the first actor, and the message is left of it, no need to calculate the margin if (msg.placement === diagObj.db.PLACEMENT.LEFTOF && !actor.prevActor) { @@ -1258,13 +1258,13 @@ const getRequiredPopupWidth = function (actor) { * @param boxes - The boxes around the actors if any */ async function calculateActorMargins( - actors: { [id: string]: any }, + actors: Map, actorToMessageWidth: Awaited>, boxes ) { let maxHeight = 0; - for (const prop of Object.keys(actors)) { - const actor = actors[prop]; + for (const prop of actors.keys()) { + const actor = actors.get(prop); if (actor.wrap) { actor.description = utils.wrapLabel( actor.description, @@ -1285,13 +1285,13 @@ async function calculateActorMargins( } for (const actorKey in actorToMessageWidth) { - const actor = actors[actorKey]; + const actor = actors.get(actorKey); if (!actor) { continue; } - const nextActor = actors[actor.nextActor]; + const nextActor = actors.get(actor.nextActor); // No need to space out an actor that doesn't have a next link if (!nextActor) { @@ -1311,7 +1311,7 @@ async function calculateActorMargins( boxes.forEach((box) => { const textFont = messageFont(conf); let totalWidth = box.actorKeys.reduce((total, aKey) => { - return (total += actors[aKey].width + (actors[aKey].margin || 0)); + return (total += actors.get(aKey).width + (actors.get(aKey).margin || 0)); }, 0); totalWidth -= 2 * conf.boxTextMargin; @@ -1334,8 +1334,10 @@ async function calculateActorMargins( } const buildNoteModel = async function (msg, actors, diagObj) { - const startx = actors[msg.from].x; - const stopx = actors[msg.to].x; + const fromActor = actors.get(msg.from); + const toActor = actors.get(msg.to); + const startx = fromActor.x; + const stopx = toActor.x; const shouldWrap = msg.wrap && msg.message; let textDimensions: { width: number; height: number; lineHeight?: number } = hasKatex(msg.message) @@ -1349,7 +1351,7 @@ const buildNoteModel = async function (msg, actors, diagObj) { ? conf.width : common.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin), height: 0, - startx: actors[msg.from].x, + startx: fromActor.x, stopx: 0, starty: 0, stopy: 0, @@ -1359,45 +1361,36 @@ const buildNoteModel = async function (msg, actors, diagObj) { noteModel.width = shouldWrap ? common.getMax(conf.width, textDimensions.width) : common.getMax( - actors[msg.from].width / 2 + actors[msg.to].width / 2, + fromActor.width / 2 + toActor.width / 2, textDimensions.width + 2 * conf.noteMargin ); - noteModel.startx = startx + (actors[msg.from].width + conf.actorMargin) / 2; + noteModel.startx = startx + (fromActor.width + conf.actorMargin) / 2; } else if (msg.placement === diagObj.db.PLACEMENT.LEFTOF) { noteModel.width = shouldWrap ? common.getMax(conf.width, textDimensions.width + 2 * conf.noteMargin) : common.getMax( - actors[msg.from].width / 2 + actors[msg.to].width / 2, + fromActor.width / 2 + toActor.width / 2, textDimensions.width + 2 * conf.noteMargin ); - noteModel.startx = startx - noteModel.width + (actors[msg.from].width - conf.actorMargin) / 2; + noteModel.startx = startx - noteModel.width + (fromActor.width - conf.actorMargin) / 2; } else if (msg.to === msg.from) { textDimensions = utils.calculateTextDimensions( shouldWrap - ? utils.wrapLabel( - msg.message, - common.getMax(conf.width, actors[msg.from].width), - noteFont(conf) - ) + ? utils.wrapLabel(msg.message, common.getMax(conf.width, fromActor.width), noteFont(conf)) : msg.message, noteFont(conf) ); noteModel.width = shouldWrap - ? common.getMax(conf.width, actors[msg.from].width) - : common.getMax( - actors[msg.from].width, - conf.width, - textDimensions.width + 2 * conf.noteMargin - ); - noteModel.startx = startx + (actors[msg.from].width - noteModel.width) / 2; + ? common.getMax(conf.width, fromActor.width) + : common.getMax(fromActor.width, conf.width, textDimensions.width + 2 * conf.noteMargin); + noteModel.startx = startx + (fromActor.width - noteModel.width) / 2; } else { noteModel.width = - Math.abs(startx + actors[msg.from].width / 2 - (stopx + actors[msg.to].width / 2)) + - conf.actorMargin; + Math.abs(startx + fromActor.width / 2 - (stopx + toActor.width / 2)) + conf.actorMargin; noteModel.startx = startx < stopx - ? startx + actors[msg.from].width / 2 - conf.actorMargin / 2 - : stopx + actors[msg.to].width / 2 - conf.actorMargin / 2; + ? startx + fromActor.width / 2 - conf.actorMargin / 2 + : stopx + toActor.width / 2 - conf.actorMargin / 2; } if (shouldWrap) { noteModel.message = utils.wrapLabel( @@ -1545,7 +1538,7 @@ const calculateLoopBounds = async function (messages, actors, _maxWidthPerActor, break; case diagObj.db.LINETYPE.ACTIVE_START: { - const actorRect = actors[msg.from ? msg.from.actor : msg.to.actor]; + const actorRect = actors.get(msg.from ? msg.from.actor : msg.to.actor); const stackedSize = actorActivations(msg.from ? msg.from.actor : msg.to.actor).length; const x = actorRect.x + actorRect.width / 2 + ((stackedSize - 1) * conf.activationWidth) / 2; @@ -1585,8 +1578,8 @@ const calculateLoopBounds = async function (messages, actors, _maxWidthPerActor, stack.forEach((stk) => { current = stk; if (msgModel.startx === msgModel.stopx) { - const from = actors[msg.from]; - const to = actors[msg.to]; + const from = actors.get(msg.from); + const to = actors.get(msg.to); current.from = common.getMin( from.x - msgModel.width / 2, from.x - from.width / 2, diff --git a/packages/mermaid/src/diagrams/sequence/svgDraw.js b/packages/mermaid/src/diagrams/sequence/svgDraw.js index 84351ea5ad..568074b537 100644 --- a/packages/mermaid/src/diagrams/sequence/svgDraw.js +++ b/packages/mermaid/src/diagrams/sequence/svgDraw.js @@ -307,7 +307,7 @@ export const fixLifeLineHeights = (diagram, actors, actorKeys, conf) => { return; } actorKeys.forEach((actorKey) => { - const actor = actors[actorKey]; + const actor = actors.get(actorKey); const actorDOM = diagram.select('#actor' + actor.actorCnt); if (!conf.mirrorActors && actor.stopy) { actorDOM.attr('y2', actor.stopy + actor.height / 2); diff --git a/packages/mermaid/src/diagrams/state/parser/state-parser.spec.js b/packages/mermaid/src/diagrams/state/parser/state-parser.spec.js index e56931ade7..c4461e6301 100644 --- a/packages/mermaid/src/diagrams/state/parser/state-parser.spec.js +++ b/packages/mermaid/src/diagrams/state/parser/state-parser.spec.js @@ -21,8 +21,8 @@ describe('state parser can parse...', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const states = stateDiagram.parser.yy.getStates(); - expect(states['namedState1']).not.toBeUndefined(); - expect(states['namedState1'].descriptions.join(' ')).toEqual('Small State 1'); + expect(states.get('namedState1')).not.toBeUndefined(); + expect(states.get('namedState1').descriptions.join(' ')).toEqual('Small State 1'); }); }); @@ -34,8 +34,8 @@ describe('state parser can parse...', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const states = stateDiagram.parser.yy.getStates(); - expect(states['namedState1']).not.toBeUndefined(); - expect(states['namedState1'].descriptions.join(' ')).toEqual('Small State 1'); + expect(states.get('namedState1')).not.toBeUndefined(); + expect(states.get('namedState1').descriptions.join(' ')).toEqual('Small State 1'); }); it('no spaces before and after the colon', () => { @@ -45,8 +45,8 @@ describe('state parser can parse...', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const states = stateDiagram.parser.yy.getStates(); - expect(states['namedState1']).not.toBeUndefined(); - expect(states['namedState1'].descriptions.join(' ')).toEqual('Small State 1'); + expect(states.get('namedState1')).not.toBeUndefined(); + expect(states.get('namedState1').descriptions.join(' ')).toEqual('Small State 1'); }); }); }); @@ -62,8 +62,8 @@ describe('state parser can parse...', () => { stateDiagram.parser.parse(diagramText); stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const states = stateDiagram.parser.yy.getStates(); - expect(states['assemble']).not.toBeUndefined(); - expect(states['assemblies']).not.toBeUndefined(); + expect(states.get('assemble')).not.toBeUndefined(); + expect(states.get('assemblies')).not.toBeUndefined(); }); it('state "as" as as', function () { @@ -73,8 +73,8 @@ describe('state parser can parse...', () => { stateDiagram.parser.parse(diagramText); stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const states = stateDiagram.parser.yy.getStates(); - expect(states['as']).not.toBeUndefined(); - expect(states['as'].descriptions.join(' ')).toEqual('as'); + expect(states.get('as')).not.toBeUndefined(); + expect(states.get('as').descriptions.join(' ')).toEqual('as'); }); }); @@ -99,12 +99,12 @@ describe('state parser can parse...', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const states = stateDiagram.parser.yy.getStates(); - expect(states['namedState1']).not.toBeUndefined(); - expect(states['bigState1']).not.toBeUndefined(); - expect(states['bigState1'].doc[0].id).toEqual('bigState1InternalState'); - expect(states['namedState2']).not.toBeUndefined(); - expect(states['bigState2']).not.toBeUndefined(); - expect(states['bigState2'].doc[0].id).toEqual('bigState2InternalState'); + expect(states.get('namedState1')).not.toBeUndefined(); + expect(states.get('bigState1')).not.toBeUndefined(); + expect(states.get('bigState1').doc[0].id).toEqual('bigState1InternalState'); + expect(states.get('namedState2')).not.toBeUndefined(); + expect(states.get('bigState2')).not.toBeUndefined(); + expect(states.get('bigState2').doc[0].id).toEqual('bigState2InternalState'); const relationships = stateDiagram.parser.yy.getRelations(); expect(relationships[0].id1).toEqual('namedState1'); expect(relationships[0].id2).toEqual('bigState1'); @@ -123,11 +123,11 @@ describe('state parser can parse...', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const states = stateDiagram.parser.yy.getStates(); - expect(states['bigState1']).not.toBeUndefined(); - expect(states['bigState1'].doc[0].id).toEqual('inner1'); - expect(states['bigState1'].doc[0].description).toEqual('inner state 1'); - expect(states['bigState1'].doc[1].id).toEqual('inner2'); - expect(states['bigState1'].doc[1].description).toEqual('inner state 2'); + expect(states.get('bigState1')).not.toBeUndefined(); + expect(states.get('bigState1').doc[0].id).toEqual('inner1'); + expect(states.get('bigState1').doc[0].description).toEqual('inner state 1'); + expect(states.get('bigState1').doc[1].id).toEqual('inner2'); + expect(states.get('bigState1').doc[1].description).toEqual('inner state 2'); }); }); }); diff --git a/packages/mermaid/src/diagrams/state/parser/state-style.spec.js b/packages/mermaid/src/diagrams/state/parser/state-style.spec.js index 9ce41df503..4a9c510a46 100644 --- a/packages/mermaid/src/diagrams/state/parser/state-style.spec.js +++ b/packages/mermaid/src/diagrams/state/parser/state-style.spec.js @@ -19,8 +19,8 @@ describe('ClassDefs and classes when parsing a State diagram', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const styleClasses = stateDb.getClasses(); - expect(styleClasses['exampleClass'].styles.length).toEqual(1); - expect(styleClasses['exampleClass'].styles[0]).toEqual('background:#bbb'); + expect(styleClasses.get('exampleClass').styles.length).toEqual(1); + expect(styleClasses.get('exampleClass').styles[0]).toEqual('background:#bbb'); }); it('can define multiple attributes separated by commas', function () { @@ -30,10 +30,10 @@ describe('ClassDefs and classes when parsing a State diagram', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const styleClasses = stateDb.getClasses(); - expect(styleClasses['exampleClass'].styles.length).toEqual(3); - expect(styleClasses['exampleClass'].styles[0]).toEqual('background:#bbb'); - expect(styleClasses['exampleClass'].styles[1]).toEqual('font-weight:bold'); - expect(styleClasses['exampleClass'].styles[2]).toEqual('font-style:italic'); + expect(styleClasses.get('exampleClass').styles.length).toEqual(3); + expect(styleClasses.get('exampleClass').styles[0]).toEqual('background:#bbb'); + expect(styleClasses.get('exampleClass').styles[1]).toEqual('font-weight:bold'); + expect(styleClasses.get('exampleClass').styles[2]).toEqual('font-style:italic'); }); // need to look at what the lexer is doing @@ -44,9 +44,9 @@ describe('ClassDefs and classes when parsing a State diagram', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const classes = stateDiagram.parser.yy.getClasses(); - expect(classes['exampleStyleClass'].styles.length).toBe(2); - expect(classes['exampleStyleClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exampleStyleClass'].styles[1]).toBe('border:1.5px solid red'); + expect(classes.get('exampleStyleClass').styles.length).toBe(2); + expect(classes.get('exampleStyleClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exampleStyleClass').styles[1]).toBe('border:1.5px solid red'); }); it('an attribute can have a space in the style', function () { @@ -56,9 +56,9 @@ describe('ClassDefs and classes when parsing a State diagram', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const classes = stateDiagram.parser.yy.getClasses(); - expect(classes['exampleStyleClass'].styles.length).toBe(2); - expect(classes['exampleStyleClass'].styles[0]).toBe('background: #bbb'); - expect(classes['exampleStyleClass'].styles[1]).toBe('border:1.5px solid red'); + expect(classes.get('exampleStyleClass').styles.length).toBe(2); + expect(classes.get('exampleStyleClass').styles[0]).toBe('background: #bbb'); + expect(classes.get('exampleStyleClass').styles[1]).toBe('border:1.5px solid red'); }); }); @@ -74,9 +74,9 @@ describe('ClassDefs and classes when parsing a State diagram', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const classes = stateDb.getClasses(); - expect(classes['exampleStyleClass'].styles.length).toEqual(2); - expect(classes['exampleStyleClass'].styles[0]).toEqual('background:#bbb'); - expect(classes['exampleStyleClass'].styles[1]).toEqual('border:1px solid red'); + expect(classes.get('exampleStyleClass').styles.length).toEqual(2); + expect(classes.get('exampleStyleClass').styles[0]).toEqual('background:#bbb'); + expect(classes.get('exampleStyleClass').styles[1]).toEqual('border:1px solid red'); const state_a = stateDb.getState('a'); expect(state_a.classes.length).toEqual(1); @@ -95,9 +95,9 @@ describe('ClassDefs and classes when parsing a State diagram', () => { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const classes = stateDiagram.parser.yy.getClasses(); - expect(classes['exampleStyleClass'].styles.length).toBe(2); - expect(classes['exampleStyleClass'].styles[0]).toBe('background:#bbb'); - expect(classes['exampleStyleClass'].styles[1]).toBe('border:1px solid red'); + expect(classes.get('exampleStyleClass').styles.length).toBe(2); + expect(classes.get('exampleStyleClass').styles[0]).toBe('background:#bbb'); + expect(classes.get('exampleStyleClass').styles[1]).toBe('border:1px solid red'); const state_a_a = stateDiagram.parser.yy.getState('a_a'); expect(state_a_a.classes.length).toEqual(1); @@ -117,11 +117,11 @@ describe('ClassDefs and classes when parsing a State diagram', () => { const states = stateDiagram.parser.yy.getStates(); const classes = stateDiagram.parser.yy.getClasses(); - expect(classes['exampleStyleClass'].styles.length).toEqual(2); - expect(classes['exampleStyleClass'].styles[0]).toEqual('background:#bbb'); - expect(classes['exampleStyleClass'].styles[1]).toEqual('border:1px solid red'); + expect(classes.get('exampleStyleClass').styles.length).toEqual(2); + expect(classes.get('exampleStyleClass').styles[0]).toEqual('background:#bbb'); + expect(classes.get('exampleStyleClass').styles[1]).toEqual('border:1px solid red'); - expect(states['b'].classes[0]).toEqual('exampleStyleClass'); + expect(states.get('b').classes[0]).toEqual('exampleStyleClass'); }); it('can be applied to a [*] state', () => { @@ -136,11 +136,11 @@ describe('ClassDefs and classes when parsing a State diagram', () => { const states = stateDiagram.parser.yy.getStates(); const classes = stateDiagram.parser.yy.getClasses(); - expect(classes['exampleStyleClass'].styles.length).toEqual(2); - expect(classes['exampleStyleClass'].styles[0]).toEqual('background:#bbb'); - expect(classes['exampleStyleClass'].styles[1]).toEqual('border:1px solid red'); + expect(classes.get('exampleStyleClass').styles.length).toEqual(2); + expect(classes.get('exampleStyleClass').styles[0]).toEqual('background:#bbb'); + expect(classes.get('exampleStyleClass').styles[1]).toEqual('border:1px solid red'); - expect(states['root_start'].classes[0]).toEqual('exampleStyleClass'); + expect(states.get('root_start').classes[0]).toEqual('exampleStyleClass'); }); it('can be applied to a comma separated list of states', function () { @@ -155,11 +155,11 @@ describe('ClassDefs and classes when parsing a State diagram', () => { let classes = stateDiagram.parser.yy.getClasses(); let states = stateDiagram.parser.yy.getStates(); - expect(classes['exampleStyleClass'].styles.length).toEqual(2); - expect(classes['exampleStyleClass'].styles[0]).toEqual('background:#bbb'); - expect(classes['exampleStyleClass'].styles[1]).toEqual('border:1px solid red'); - expect(states['a'].classes[0]).toEqual('exampleStyleClass'); - expect(states['b'].classes[0]).toEqual('exampleStyleClass'); + expect(classes.get('exampleStyleClass').styles.length).toEqual(2); + expect(classes.get('exampleStyleClass').styles[0]).toEqual('background:#bbb'); + expect(classes.get('exampleStyleClass').styles[1]).toEqual('border:1px solid red'); + expect(states.get('a').classes[0]).toEqual('exampleStyleClass'); + expect(states.get('b').classes[0]).toEqual('exampleStyleClass'); }); it('a comma separated list of states may or may not have spaces after commas', function () { @@ -174,13 +174,13 @@ describe('ClassDefs and classes when parsing a State diagram', () => { const classes = stateDiagram.parser.yy.getClasses(); const states = stateDiagram.parser.yy.getStates(); - expect(classes['exampleStyleClass'].styles.length).toEqual(2); - expect(classes['exampleStyleClass'].styles[0]).toEqual('background:#bbb'); - expect(classes['exampleStyleClass'].styles[1]).toEqual('border:1px solid red'); + expect(classes.get('exampleStyleClass').styles.length).toEqual(2); + expect(classes.get('exampleStyleClass').styles[0]).toEqual('background:#bbb'); + expect(classes.get('exampleStyleClass').styles[1]).toEqual('border:1px solid red'); const statesList = ['a', 'b', 'c', 'd', 'e']; statesList.forEach((stateId) => { - expect(states[stateId].classes[0]).toEqual('exampleStyleClass'); + expect(states.get(stateId).classes[0]).toEqual('exampleStyleClass'); }); }); }); @@ -202,7 +202,7 @@ describe('ClassDefs and classes when parsing a State diagram', () => { const states = stateDiagram.parser.yy.getStates(); - expect(states['Moving'].doc.length).toEqual(1); + expect(states.get('Moving').doc.length).toEqual(1); }); }); }); diff --git a/packages/mermaid/src/diagrams/state/stateDb.js b/packages/mermaid/src/diagrams/state/stateDb.js index 0ff32cbb33..5fd800a8b5 100644 --- a/packages/mermaid/src/diagrams/state/stateDb.js +++ b/packages/mermaid/src/diagrams/state/stateDb.js @@ -37,10 +37,10 @@ const STYLECLASS_SEP = ','; * In the future, this can be replaced with a class common to all diagrams. * ClassDef information = { id: id, styles: [], textStyles: [] } * - * @returns {{}} + * @returns {Map} */ function newClassesList() { - return {}; + return new Map(); } let direction = DEFAULT_DIAGRAM_DIRECTION; @@ -49,8 +49,9 @@ let classes = newClassesList(); // style classes defined by a classDef const newDoc = () => { return { + /** @type {{ id1: string, id2: string, relationTitle: string }[]} */ relations: [], - states: {}, + states: new Map(), documents: {}, }; }; @@ -217,9 +218,9 @@ export const addState = function ( ) { const trimmedId = id?.trim(); // add the state if needed - if (currentDocument.states[trimmedId] === undefined) { + if (!currentDocument.states.has(trimmedId)) { log.info('Adding state ', trimmedId, descr); - currentDocument.states[trimmedId] = { + currentDocument.states.set(trimmedId, { id: trimmedId, descriptions: [], type, @@ -228,16 +229,18 @@ export const addState = function ( classes: [], styles: [], textStyles: [], - }; + }); } else { - if (!currentDocument.states[trimmedId].doc) { - currentDocument.states[trimmedId].doc = doc; + if (!currentDocument.states.get(trimmedId).doc) { + currentDocument.states.get(trimmedId).doc = doc; } - if (!currentDocument.states[trimmedId].type) { - currentDocument.states[trimmedId].type = type; + if (!currentDocument.states.get(trimmedId).type) { + currentDocument.states.get(trimmedId).type = type; } } + const doc2 = currentDocument.states.get(trimmedId); + if (descr) { log.info('Setting state description', trimmedId, descr); if (typeof descr === 'string') { @@ -250,11 +253,8 @@ export const addState = function ( } if (note) { - currentDocument.states[trimmedId].note = note; - currentDocument.states[trimmedId].note.text = common.sanitizeText( - currentDocument.states[trimmedId].note.text, - getConfig() - ); + doc2.note = note; + doc2.note.text = common.sanitizeText(doc2.note.text, getConfig()); } if (classes) { @@ -291,7 +291,7 @@ export const clear = function (saveCommon) { }; export const getState = function (id) { - return currentDocument.states[id]; + return currentDocument.states.get(id); }; export const getStates = function () { @@ -429,7 +429,7 @@ export const addRelation = function (item1, item2, title) { }; export const addDescription = function (id, descr) { - const theState = currentDocument.states[id]; + const theState = currentDocument.states.get(id); const _descr = descr.startsWith(':') ? descr.replace(':', '').trim() : descr; theState.descriptions.push(common.sanitizeText(_descr, getConfig())); }; @@ -456,10 +456,10 @@ const getDividerId = () => { */ export const addStyleClass = function (id, styleAttributes = '') { // create a new style class object with this id - if (classes[id] === undefined) { - classes[id] = { id: id, styles: [], textStyles: [] }; // This is a classDef + if (!classes.has(id)) { + classes.set(id, { id: id, styles: [], textStyles: [] }); // This is a classDef } - const foundClass = classes[id]; + const foundClass = classes.get(id); if (styleAttributes !== undefined && styleAttributes !== null) { styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { // remove any trailing ; diff --git a/packages/mermaid/src/diagrams/state/stateDb.spec.js b/packages/mermaid/src/diagrams/state/stateDb.spec.js index 0264c34cc5..ff05812005 100644 --- a/packages/mermaid/src/diagrams/state/stateDb.spec.js +++ b/packages/mermaid/src/diagrams/state/stateDb.spec.js @@ -12,10 +12,10 @@ describe('State Diagram stateDb', () => { stateDb.addStyleClass(newStyleClassId, newStyleClassAttribs); const styleClasses = stateDb.getClasses(); - expect(styleClasses[newStyleClassId].id).toEqual(newStyleClassId); - expect(styleClasses[newStyleClassId].styles.length).toEqual(2); - expect(styleClasses[newStyleClassId].styles[0]).toEqual('font-weight:bold'); - expect(styleClasses[newStyleClassId].styles[1]).toEqual('border:blue'); + expect(styleClasses.get(newStyleClassId).id).toEqual(newStyleClassId); + expect(styleClasses.get(newStyleClassId).styles.length).toEqual(2); + expect(styleClasses.get(newStyleClassId).styles[0]).toEqual('font-weight:bold'); + expect(styleClasses.get(newStyleClassId).styles[1]).toEqual('border:blue'); }); }); @@ -34,15 +34,15 @@ describe('State Diagram stateDb', () => { stateDb.addDescription(testStateId, restOfTheDescription); let states = stateDb.getStates(); - expect(states[testStateId].descriptions[0]).toEqual(restOfTheDescription); + expect(states.get(testStateId).descriptions[0]).toEqual(restOfTheDescription); stateDb.addDescription(testStateId, oneLeadingColon); states = stateDb.getStates(); - expect(states[testStateId].descriptions[1]).toEqual(restOfTheDescription); + expect(states.get(testStateId).descriptions[1]).toEqual(restOfTheDescription); stateDb.addDescription(testStateId, twoLeadingColons); states = stateDb.getStates(); - expect(states[testStateId].descriptions[2]).toEqual(`:${restOfTheDescription}`); + expect(states.get(testStateId).descriptions[2]).toEqual(`:${restOfTheDescription}`); }); it('adds each description to the array of descriptions', () => { @@ -51,10 +51,10 @@ describe('State Diagram stateDb', () => { stateDb.addDescription(testStateId, 'description 2'); let states = stateDb.getStates(); - expect(states[testStateId].descriptions.length).toEqual(3); - expect(states[testStateId].descriptions[0]).toEqual('description 0'); - expect(states[testStateId].descriptions[1]).toEqual('description 1'); - expect(states[testStateId].descriptions[2]).toEqual('description 2'); + expect(states.get(testStateId).descriptions.length).toEqual(3); + expect(states.get(testStateId).descriptions[0]).toEqual('description 0'); + expect(states.get(testStateId).descriptions[1]).toEqual('description 1'); + expect(states.get(testStateId).descriptions[2]).toEqual('description 2'); }); it('sanitizes on the description', () => { @@ -63,13 +63,13 @@ describe('State Diagram stateDb', () => { 'desc outside the script ' ); let states = stateDb.getStates(); - expect(states[testStateId].descriptions[0]).toEqual('desc outside the script '); + expect(states.get(testStateId).descriptions[0]).toEqual('desc outside the script '); }); it('adds the description to the state with the given id', () => { stateDb.addDescription(testStateId, 'the description'); let states = stateDb.getStates(); - expect(states[testStateId].descriptions[0]).toEqual('the description'); + expect(states.get(testStateId).descriptions[0]).toEqual('the description'); }); }); }); diff --git a/packages/mermaid/src/diagrams/state/stateDiagram-v2.spec.js b/packages/mermaid/src/diagrams/state/stateDiagram-v2.spec.js index c387ff7b3d..53063f41a1 100644 --- a/packages/mermaid/src/diagrams/state/stateDiagram-v2.spec.js +++ b/packages/mermaid/src/diagrams/state/stateDiagram-v2.spec.js @@ -405,7 +405,7 @@ describe('state diagram V2, ', function () { stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); const states = stateDb.getStates(); - expect(states['Active'].doc[0].id).toEqual('Idle'); + expect(states.get('Active').doc[0].id).toEqual('Idle'); const rels = stateDb.getRelations(); const rel_Inactive_Idle = rels.find((rel) => rel.id1 === 'Inactive' && rel.id2 === 'Idle'); diff --git a/packages/mermaid/src/diagrams/state/stateRenderer-v2.js b/packages/mermaid/src/diagrams/state/stateRenderer-v2.js index 482e37caee..4d702bf3c1 100644 --- a/packages/mermaid/src/diagrams/state/stateRenderer-v2.js +++ b/packages/mermaid/src/diagrams/state/stateRenderer-v2.js @@ -81,7 +81,7 @@ export const setConf = function (cnf) { * * @param {string} text - the diagram text to be parsed * @param diagramObj - * @returns {Record} ClassDef styles (a Map with keys = strings, values = ) + * @returns {Map} ClassDef styles (a Map with keys = strings, values = ) */ export const getClasses = function (text, diagramObj) { diagramObj.db.extract(diagramObj.db.getRootDocV2()); diff --git a/packages/mermaid/src/mermaidAPI.spec.ts b/packages/mermaid/src/mermaidAPI.spec.ts index 40efd776b6..aa5c7a7fb2 100644 --- a/packages/mermaid/src/mermaidAPI.spec.ts +++ b/packages/mermaid/src/mermaidAPI.spec.ts @@ -295,7 +295,7 @@ describe('mermaidAPI', () => { expect(styles).toMatch(/^\ndefault(.*)/); }); it('gets the fontFamily from the config', () => { - const styles = createCssStyles(mocked_config_with_htmlLabels, {}); + const styles = createCssStyles(mocked_config_with_htmlLabels, new Map()); expect(styles).toMatch(/(.*)\n:root { --mermaid-font-family: serif(.*)/); }); it('gets the alt fontFamily from the config', () => { @@ -375,7 +375,7 @@ describe('mermaidAPI', () => { // @todo TODO Can't figure out how to spy on the cssImportantStyles method. // That would be a much better approach than manually checking the result - const styles = createCssStyles(mocked_config, classDefs); + const styles = createCssStyles(mocked_config, new Map(Object.entries(classDefs))); htmlElements.forEach((htmlElement) => { expect_styles_matchesHtmlElements(styles, htmlElement); }); @@ -413,7 +413,10 @@ describe('mermaidAPI', () => { it('creates CSS styles for every style and textStyle in every classDef', () => { // TODO Can't figure out how to spy on the cssImportantStyles method. That would be a much better approach than manually checking the result. - const styles = createCssStyles(mocked_config_no_htmlLabels, classDefs); + const styles = createCssStyles( + mocked_config_no_htmlLabels, + new Map(Object.entries(classDefs)) + ); htmlElements.forEach((htmlElement) => { expect_styles_matchesHtmlElements(styles, htmlElement); }); @@ -437,7 +440,7 @@ describe('mermaidAPI', () => { it('gets the css styles created', () => { // @todo TODO if a single function in the module can be mocked, do it for createCssStyles and mock the results. - createUserStyles(mockConfig, 'flowchart-v2', { classDef1 }, 'someId'); + createUserStyles(mockConfig, 'flowchart-v2', new Map([['classDef1', classDef1]]), 'someId'); const expectedStyles = '\ndefault' + '\n.classDef1 > * { style1-1 !important; }' + @@ -448,12 +451,12 @@ describe('mermaidAPI', () => { }); it('calls getStyles to get css for all graph, user css styles, and config theme variables', () => { - createUserStyles(mockConfig, 'someDiagram', {}, 'someId'); + createUserStyles(mockConfig, 'someDiagram', new Map(), 'someId'); expect(getStyles).toHaveBeenCalled(); }); it('returns the result of compiling, stringifying, and serializing the css code with stylis', () => { - const result = createUserStyles(mockConfig, 'someDiagram', {}, 'someId'); + const result = createUserStyles(mockConfig, 'someDiagram', new Map(), 'someId'); expect(compile).toHaveBeenCalled(); expect(serialize).toHaveBeenCalled(); expect(result).toEqual('stylis serialized css'); diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts index fc5eb77dc8..b13dd27b55 100644 --- a/packages/mermaid/src/mermaidAPI.ts +++ b/packages/mermaid/src/mermaidAPI.ts @@ -152,7 +152,7 @@ export const cssImportantStyles = ( */ export const createCssStyles = ( config: MermaidConfig, - classDefs: Record | null | undefined = {} + classDefs: Map | null | undefined = new Map() ): string => { let cssStyles = ''; @@ -171,7 +171,7 @@ export const createCssStyles = ( } // classDefs defined in the diagram text - if (!isEmpty(classDefs)) { + if (!isEmpty(classDefs) && classDefs instanceof Map) { const htmlLabels = config.htmlLabels || config.flowchart?.htmlLabels; // TODO why specifically check the Flowchart diagram config? const cssHtmlElements = ['> *', 'span']; // TODO make a constant @@ -180,8 +180,8 @@ export const createCssStyles = ( const cssElements = htmlLabels ? cssHtmlElements : cssShapeElements; // create the CSS styles needed for each styleClass definition and css element - for (const classId in classDefs) { - const styleClassDef = classDefs[classId]; + for (const classId of classDefs!.keys()) { + const styleClassDef = classDefs.get(classId)!; // create the css styles for each cssElement and the styles (only if there are styles) if (!isEmpty(styleClassDef.styles)) { cssElements.forEach((cssElement) => { @@ -200,7 +200,7 @@ export const createCssStyles = ( export const createUserStyles = ( config: MermaidConfig, graphType: string, - classDefs: Record | undefined, + classDefs: Map | undefined, svgId: string ): string => { const userCSSstyles = createCssStyles(config, classDefs); From 002aa29f19055b92d728fdbae07790ae99540114 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 16 Apr 2024 13:49:01 -0700 Subject: [PATCH 02/50] test: unsafe props to make sure they work with changes --- .../src/diagrams/block/parser/block.spec.ts | 19 ++++++++ .../src/diagrams/class/parser/class.spec.js | 28 ++++++++++++ .../src/diagrams/er/parser/erDiagram.spec.js | 18 ++++++++ .../diagrams/flowchart/parser/flow.spec.js | 43 +++++++++++++++++++ .../src/diagrams/gantt/parser/gantt.spec.js | 9 ++++ 5 files changed, 117 insertions(+) create mode 100644 packages/mermaid/src/diagrams/class/parser/class.spec.js diff --git a/packages/mermaid/src/diagrams/block/parser/block.spec.ts b/packages/mermaid/src/diagrams/block/parser/block.spec.ts index 8618f4d027..29ddad3469 100644 --- a/packages/mermaid/src/diagrams/block/parser/block.spec.ts +++ b/packages/mermaid/src/diagrams/block/parser/block.spec.ts @@ -406,4 +406,23 @@ columns 1 expect(B.styles).toContain('fill:#f9F'); }); }); + + describe('prototype properties', function () { + function validateProperty(prop: string) { + expect(() => block.parse(`block-beta\n${prop}`)).not.toThrow(); + expect(() => block.parse(`block-beta\nA; classDef ${prop} color:#ffffff,fill:#000000; class A ${prop}`)).not.toThrow(); + } + + it('should work with a prototype property', function () { + validateProperty('prototype'); + }); + + it('should work with a __proto__ property', function () { + validateProperty('__proto__'); + }); + + it('should work with a constructor property', function () { + validateProperty('constructor'); + }); + }); }); diff --git a/packages/mermaid/src/diagrams/class/parser/class.spec.js b/packages/mermaid/src/diagrams/class/parser/class.spec.js new file mode 100644 index 0000000000..1758877568 --- /dev/null +++ b/packages/mermaid/src/diagrams/class/parser/class.spec.js @@ -0,0 +1,28 @@ +import { parser } from './classDiagram.jison'; +import classDb from '../classDb.js'; + +describe('class diagram', function () { + beforeEach(function () { + parser.yy = classDb; + parser.yy.clear(); + }); + + describe('prototype properties', function () { + function validateProperty(prop) { + expect(() => parser.parse(`classDiagram\nclass ${prop}`)).not.toThrow(); + expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow(); + } + + it('should work with a prototype property', function () { + validateProperty('prototype'); + }); + + it('should work with a __proto__ property', function () { + validateProperty('__proto__'); + }); + + it('should work with a constructor property', function () { + validateProperty('constructor'); + }); + }); +}); diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js index f63fd40e23..62c43e6f28 100644 --- a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js +++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js @@ -792,4 +792,22 @@ describe('when parsing ER diagram it...', function () { expect(rels[0].relSpec.cardA).toBe(erDb.Cardinality.ZERO_OR_MORE); }); }); + + describe('prototype properties', function () { + function validateProperty(prop) { + expect(() => erDiagram.parser.parse(`erDiagram\n${prop} ||--|{ ORDER : place`)).not.toThrow(); + } + + it('should work with a prototype property', function () { + validateProperty('prototype'); + }); + + it('should work with a __proto__ property', function () { + validateProperty('__proto__'); + }); + + it('should work with a constructor property', function () { + validateProperty('constructor'); + }); + }) }); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js index ff2c9d506c..368ec0595d 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js @@ -194,4 +194,47 @@ describe('parsing a flow chart', function () { with a second line` ); }); + + for (const unsafeProp of ['__proto__', 'constructor', 'prototype']) { + it(`should work with node id ${unsafeProp}`, function () { + const flowChart = `graph LR + ${unsafeProp} --> A;`; + + expect(() => { + flow.parser.parse(flowChart); + }).not.toThrow(); + }); + + it(`should work with tooltip id ${unsafeProp}`, function () { + const flowChart = `graph LR + click ${unsafeProp} callback "${unsafeProp}";`; + + expect(() => { + flow.parser.parse(flowChart); + }).not.toThrow(); + }); + + it(`should work with class id ${unsafeProp}`, function () { + const flowChart = `graph LR + ${unsafeProp} --> A; + classDef ${unsafeProp} color:#ffffff,fill:#000000; + class ${unsafeProp} ${unsafeProp};`; + + expect(() => { + flow.parser.parse(flowChart); + }).not.toThrow(); + }); + + it(`should work with subgraph id ${unsafeProp}`, function () { + const flowChart = `graph LR + ${unsafeProp} --> A; + subgraph ${unsafeProp} + C --> D; + end;`; + + expect(() => { + flow.parser.parse(flowChart); + }).not.toThrow(); + }); + } }); diff --git a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js index 6665765a4b..cff6a1e2ad 100644 --- a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js +++ b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js @@ -256,4 +256,13 @@ row2`; expect(ganttDb.getWeekday()).toBe(day); } ); + + it.each(['__proto__', 'constructor', 'prototype'])('should allow for a link to %s id', (prop) => { + expect(() => parser.parse(`gantt + dateFormat YYYY-MM-DD + section Section + A task :${prop}, 2024-10-01, 3d + click ${prop} href "https://mermaid.js.org/" + `)).not.toThrow(); + }); }); From c993a817d1d6a6f57f772df791d683be4edf2d48 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 16 Apr 2024 14:46:50 -0700 Subject: [PATCH 03/50] test: block, er, gantt, git, pie --- docs/config/setup/modules/mermaidAPI.md | 10 ++++----- .../src/diagrams/block/parser/block.spec.ts | 4 +++- .../src/diagrams/er/parser/erDiagram.spec.js | 2 +- .../src/diagrams/gantt/parser/gantt.spec.js | 6 +++-- .../src/diagrams/git/gitGraphParserV2.spec.js | 22 +++++++++++++++++++ packages/mermaid/src/diagrams/pie/pie.spec.ts | 8 +++++++ 6 files changed, 43 insertions(+), 9 deletions(-) diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md index 6531da18f9..9598a404cc 100644 --- a/docs/config/setup/modules/mermaidAPI.md +++ b/docs/config/setup/modules/mermaidAPI.md @@ -190,12 +190,12 @@ the string with all the user styles #### Parameters -| Name | Type | -| :---------- | :-------------------------------------------------------- | -| `config` | `MermaidConfig` | -| `graphType` | `string` | +| Name | Type | +| :---------- | :----------------------------------------------------- | +| `config` | `MermaidConfig` | +| `graphType` | `string` | | `classDefs` | `undefined` \| `Map`<`string`, `DiagramStyleClassDef`> | -| `svgId` | `string` | +| `svgId` | `string` | #### Returns diff --git a/packages/mermaid/src/diagrams/block/parser/block.spec.ts b/packages/mermaid/src/diagrams/block/parser/block.spec.ts index 29ddad3469..c4fbe54837 100644 --- a/packages/mermaid/src/diagrams/block/parser/block.spec.ts +++ b/packages/mermaid/src/diagrams/block/parser/block.spec.ts @@ -410,7 +410,9 @@ columns 1 describe('prototype properties', function () { function validateProperty(prop: string) { expect(() => block.parse(`block-beta\n${prop}`)).not.toThrow(); - expect(() => block.parse(`block-beta\nA; classDef ${prop} color:#ffffff,fill:#000000; class A ${prop}`)).not.toThrow(); + expect(() => + block.parse(`block-beta\nA; classDef ${prop} color:#ffffff,fill:#000000; class A ${prop}`) + ).not.toThrow(); } it('should work with a prototype property', function () { diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js index 62c43e6f28..bb747dcc67 100644 --- a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js +++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js @@ -809,5 +809,5 @@ describe('when parsing ER diagram it...', function () { it('should work with a constructor property', function () { validateProperty('constructor'); }); - }) + }); }); diff --git a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js index cff6a1e2ad..52c1d93cdb 100644 --- a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js +++ b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js @@ -258,11 +258,13 @@ row2`; ); it.each(['__proto__', 'constructor', 'prototype'])('should allow for a link to %s id', (prop) => { - expect(() => parser.parse(`gantt + expect(() => + parser.parse(`gantt dateFormat YYYY-MM-DD section Section A task :${prop}, 2024-10-01, 3d click ${prop} href "https://mermaid.js.org/" - `)).not.toThrow(); + `) + ).not.toThrow(); }); }); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js index b0e40f73ef..be042b75ee 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js +++ b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js @@ -1095,4 +1095,26 @@ describe('when parsing a gitGraph', function () { expect(parser.yy.getAccDescription()).toBe('This is a description\nusing multiple lines'); }); }); + + describe('unsafe properties', () => { + for (const prop of ['__proto__', 'constructor', 'prototype']) { + it(`should work with custom commit id or branch name ${prop}`, () => { + const str = `gitGraph + commit id:"${prop}" + branch ${prop} + checkout ${prop} + commit + checkout main + merge ${prop} + `; + parser.parse(str); + const commits = parser.yy.getCommits(); + expect(commits.size).toBe(3); + expect(commits.keys().next().value).toBe(prop); + expect(parser.yy.getCurrentBranch()).toBe('main'); + expect(parser.yy.getBranches().size).toBe(2); + expect(parser.yy.getBranchesAsObjArray()[1].name).toBe(prop); + }); + } + }); }); diff --git a/packages/mermaid/src/diagrams/pie/pie.spec.ts b/packages/mermaid/src/diagrams/pie/pie.spec.ts index 32d49374bf..c93e99c559 100644 --- a/packages/mermaid/src/diagrams/pie/pie.spec.ts +++ b/packages/mermaid/src/diagrams/pie/pie.spec.ts @@ -138,6 +138,14 @@ describe('pie', () => { `); }).rejects.toThrowError(); }); + + it('should handle unsafe properties', async () => { + await expect(parser.parse(`pie title Unsafe props test + "__proto__" : 386 + "constructor" : 85 + "prototype" : 15`)).resolves.toBeUndefined(); + expect([...db.getSections().keys()]).toEqual(['__proto__', 'constructor', 'prototype']); + }); }); describe('config', () => { From 6105185d05ef581afb2ac4bb42484e4860ae4068 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 16 Apr 2024 17:14:49 -0700 Subject: [PATCH 04/50] test: requirement, sankey --- .../src/diagrams/block/parser/block.spec.ts | 4 ---- .../src/diagrams/class/parser/class.spec.js | 4 ---- .../diagrams/flowchart/parser/flow.spec.js | 2 +- .../src/diagrams/gantt/parser/gantt.spec.js | 2 +- .../src/diagrams/git/gitGraphParserV2.spec.js | 2 +- .../parser/requirementDiagram.spec.js | 21 +++++++++++++++++++ .../src/diagrams/sankey/parser/sankey.spec.ts | 7 +++++++ 7 files changed, 31 insertions(+), 11 deletions(-) diff --git a/packages/mermaid/src/diagrams/block/parser/block.spec.ts b/packages/mermaid/src/diagrams/block/parser/block.spec.ts index c4fbe54837..295dabf89c 100644 --- a/packages/mermaid/src/diagrams/block/parser/block.spec.ts +++ b/packages/mermaid/src/diagrams/block/parser/block.spec.ts @@ -415,10 +415,6 @@ columns 1 ).not.toThrow(); } - it('should work with a prototype property', function () { - validateProperty('prototype'); - }); - it('should work with a __proto__ property', function () { validateProperty('__proto__'); }); diff --git a/packages/mermaid/src/diagrams/class/parser/class.spec.js b/packages/mermaid/src/diagrams/class/parser/class.spec.js index 1758877568..d5f1de276c 100644 --- a/packages/mermaid/src/diagrams/class/parser/class.spec.js +++ b/packages/mermaid/src/diagrams/class/parser/class.spec.js @@ -13,10 +13,6 @@ describe('class diagram', function () { expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow(); } - it('should work with a prototype property', function () { - validateProperty('prototype'); - }); - it('should work with a __proto__ property', function () { validateProperty('__proto__'); }); diff --git a/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js b/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js index 368ec0595d..0828852e1b 100644 --- a/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js +++ b/packages/mermaid/src/diagrams/flowchart/parser/flow.spec.js @@ -195,7 +195,7 @@ with a second line` ); }); - for (const unsafeProp of ['__proto__', 'constructor', 'prototype']) { + for (const unsafeProp of ['__proto__', 'constructor']) { it(`should work with node id ${unsafeProp}`, function () { const flowChart = `graph LR ${unsafeProp} --> A;`; diff --git a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js index 52c1d93cdb..281e9b6bd3 100644 --- a/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js +++ b/packages/mermaid/src/diagrams/gantt/parser/gantt.spec.js @@ -257,7 +257,7 @@ row2`; } ); - it.each(['__proto__', 'constructor', 'prototype'])('should allow for a link to %s id', (prop) => { + it.each(['__proto__', 'constructor'])('should allow for a link to %s id', (prop) => { expect(() => parser.parse(`gantt dateFormat YYYY-MM-DD diff --git a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js index be042b75ee..28174e823b 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js +++ b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js @@ -1097,7 +1097,7 @@ describe('when parsing a gitGraph', function () { }); describe('unsafe properties', () => { - for (const prop of ['__proto__', 'constructor', 'prototype']) { + for (const prop of ['__proto__', 'constructor']) { it(`should work with custom commit id or branch name ${prop}`, () => { const str = `gitGraph commit id:"${prop}" diff --git a/packages/mermaid/src/diagrams/requirement/parser/requirementDiagram.spec.js b/packages/mermaid/src/diagrams/requirement/parser/requirementDiagram.spec.js index 7e4e26cdec..dce62c6ed4 100644 --- a/packages/mermaid/src/diagrams/requirement/parser/requirementDiagram.spec.js +++ b/packages/mermaid/src/diagrams/requirement/parser/requirementDiagram.spec.js @@ -578,4 +578,25 @@ line 2`; let foundRelationship = requirementDb.getRelationships()[0]; expect(foundRelationship.type).toBe(expectedType); }); + + for (const property of ['__proto__', 'constructor']) { + it(`will accept ${property} as requirement id`, function () { + reqDiagram.parser.parse(`requirementDiagram + requirement ${property} { + id: 1 + text: the test text. + risk: high + verifymethod: test + }`); + expect(reqDiagram.parser.yy.getRequirements().size).toBe(1); + }); + + it(`will accept ${property} as element id`, function () { + reqDiagram.parser.parse(`requirementDiagram + element ${property} { + type: simulation + }`); + expect(reqDiagram.parser.yy.getElements().size).toBe(1); + }); + } }); diff --git a/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts b/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts index 4517ca01fc..a45b3d0eb9 100644 --- a/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts +++ b/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts @@ -20,5 +20,12 @@ describe('Sankey diagram', function () { sankey.parser.parse(graphDefinition); }); + + it('allows __proto__ as id', function () { + sankey.parser.parse(prepareTextForParsing(`sankey-beta + __proto__,A,0.597 + A,__proto__,0.403 + `)); + }); }); }); From 087a5748c87b7e12e047a74d571ad4f370990eb7 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 16 Apr 2024 17:52:26 -0700 Subject: [PATCH 05/50] test: seq, state --- .../src/diagrams/sequence/sequenceDiagram.spec.js | 6 ++++++ .../src/diagrams/state/parser/state-parser.spec.js | 12 ++++++++++++ .../src/diagrams/state/parser/state-style.spec.js | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js index 8098aa2ed7..53eb544925 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js +++ b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js @@ -2033,4 +2033,10 @@ participant Alice`; ); }); }); + + it.each(['__proto__', 'constructor'])('should allow %s as an actor name', function (prop) { + mermaidAPI.parse(` +sequenceDiagram +${prop}-->>A: Hello, how are you?`); + }); }); diff --git a/packages/mermaid/src/diagrams/state/parser/state-parser.spec.js b/packages/mermaid/src/diagrams/state/parser/state-parser.spec.js index c4461e6301..9fa8acab8a 100644 --- a/packages/mermaid/src/diagrams/state/parser/state-parser.spec.js +++ b/packages/mermaid/src/diagrams/state/parser/state-parser.spec.js @@ -130,4 +130,16 @@ describe('state parser can parse...', () => { expect(states.get('bigState1').doc[1].description).toEqual('inner state 2'); }); }); + + describe('unsafe properties as state names', () => { + it.each(['__proto__', 'constructor'])('should allow %s as a state name', function (prop) { + stateDiagram.parser.parse(` +stateDiagram-v2 +[*] --> ${prop} +${prop} --> [*]`); + stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); + const states = stateDiagram.parser.yy.getStates(); + expect(states.get(prop)).not.toBeUndefined(); + }); + }); }); diff --git a/packages/mermaid/src/diagrams/state/parser/state-style.spec.js b/packages/mermaid/src/diagrams/state/parser/state-style.spec.js index 4a9c510a46..1be9148b8d 100644 --- a/packages/mermaid/src/diagrams/state/parser/state-style.spec.js +++ b/packages/mermaid/src/diagrams/state/parser/state-style.spec.js @@ -60,6 +60,16 @@ describe('ClassDefs and classes when parsing a State diagram', () => { expect(classes.get('exampleStyleClass').styles[0]).toBe('background: #bbb'); expect(classes.get('exampleStyleClass').styles[1]).toBe('border:1.5px solid red'); }); + + it('can have __proto__ or constructor as a class name', function () { + stateDiagram.parser.parse( + 'stateDiagram-v2\n classDef __proto__ background:#bbb,border:1.5px solid red;\n classDef constructor background:#bbb,border:1.5px solid red;' + ); + stateDiagram.parser.yy.extract(stateDiagram.parser.yy.getRootDocV2()); + const classes = stateDiagram.parser.yy.getClasses(); + expect(classes.get('__proto__').styles.length).toBe(2); + expect(classes.get('constructor').styles.length).toBe(2); + }); }); describe('applying to states in the diagram', () => { From 9b411fa8d4f5558a1734c337a96aaed4c4f77343 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 16 Apr 2024 20:47:47 -0700 Subject: [PATCH 06/50] test: sankey, pie, seq diagram --- packages/mermaid/src/diagrams/pie/pie.spec.ts | 6 ++++-- packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts | 6 ++++-- .../mermaid/src/diagrams/sequence/sequenceDiagram.spec.js | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/mermaid/src/diagrams/pie/pie.spec.ts b/packages/mermaid/src/diagrams/pie/pie.spec.ts index c93e99c559..b7bbf65bfa 100644 --- a/packages/mermaid/src/diagrams/pie/pie.spec.ts +++ b/packages/mermaid/src/diagrams/pie/pie.spec.ts @@ -140,10 +140,12 @@ describe('pie', () => { }); it('should handle unsafe properties', async () => { - await expect(parser.parse(`pie title Unsafe props test + await expect( + parser.parse(`pie title Unsafe props test "__proto__" : 386 "constructor" : 85 - "prototype" : 15`)).resolves.toBeUndefined(); + "prototype" : 15`) + ).resolves.toBeUndefined(); expect([...db.getSections().keys()]).toEqual(['__proto__', 'constructor', 'prototype']); }); }); diff --git a/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts b/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts index a45b3d0eb9..169aee8731 100644 --- a/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts +++ b/packages/mermaid/src/diagrams/sankey/parser/sankey.spec.ts @@ -22,10 +22,12 @@ describe('Sankey diagram', function () { }); it('allows __proto__ as id', function () { - sankey.parser.parse(prepareTextForParsing(`sankey-beta + sankey.parser.parse( + prepareTextForParsing(`sankey-beta __proto__,A,0.597 A,__proto__,0.403 - `)); + `) + ); }); }); }); diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js index 53eb544925..5743627f97 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js +++ b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js @@ -2035,8 +2035,10 @@ participant Alice`; }); it.each(['__proto__', 'constructor'])('should allow %s as an actor name', function (prop) { - mermaidAPI.parse(` + expect( + mermaidAPI.parse(` sequenceDiagram -${prop}-->>A: Hello, how are you?`); +${prop}-->>A: Hello, how are you?`) + ).resolves.toBeDefined(); }); }); From 357da0ca281f519fe41cfb7587addba00be7eb33 Mon Sep 17 00:00:00 2001 From: Yash-Singh1 Date: Wed, 17 Apr 2024 03:50:39 +0000 Subject: [PATCH 07/50] Update docs --- docs/config/setup/modules/mermaidAPI.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md index 9598a404cc..d9b8f16eba 100644 --- a/docs/config/setup/modules/mermaidAPI.md +++ b/docs/config/setup/modules/mermaidAPI.md @@ -167,10 +167,10 @@ Create the user styles #### Parameters -| Name | Type | Description | -| :---------- | :------------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------------------ | -| `config` | `MermaidConfig` | configuration that has style and theme settings to use | -| `classDefs` | `undefined` \| `null` \| `Record`<`string`, `DiagramStyleClassDef`> | the classDefs in the diagram text. Might be null if none were defined. Usually is the result of a call to getClasses(...) | +| Name | Type | Description | +| :---------- | :--------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------ | +| `config` | `MermaidConfig` | configuration that has style and theme settings to use | +| `classDefs` | `undefined` \| `null` \| `Map`<`string`, `DiagramStyleClassDef`> | the classDefs in the diagram text. Might be null if none were defined. Usually is the result of a call to getClasses(...) | #### Returns From 3b0687e5571c2091ce582200d2fd7e15222d3efc Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Mon, 22 Apr 2024 17:12:12 -0500 Subject: [PATCH 08/50] feat(mathml): added additional config option for forcing legacy rendering --- packages/mermaid/src/config.type.ts | 7 +++++++ packages/mermaid/src/diagrams/common/common.ts | 5 +++-- packages/mermaid/src/schemas/config.schema.yaml | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/config.type.ts b/packages/mermaid/src/config.type.ts index 79f4243151..775d49fb58 100644 --- a/packages/mermaid/src/config.type.ts +++ b/packages/mermaid/src/config.type.ts @@ -120,6 +120,13 @@ export interface MermaidConfig { * */ legacyMathML?: boolean; + /** + * This option forces Mermaid to rely on KaTeX's own stylesheet for rendering MathML. Due to differences between OS + * fonts and browser's MathML implementation, this option is recommended if consistent rendering is important. + * If set to true, ignores legacyMathML. + * + */ + forceLegacyMathML?: boolean; /** * This option controls if the generated ids of nodes in the SVG are * generated randomly or based on a seed. diff --git a/packages/mermaid/src/diagrams/common/common.ts b/packages/mermaid/src/diagrams/common/common.ts index 017b2b0911..364dc25ea8 100644 --- a/packages/mermaid/src/diagrams/common/common.ts +++ b/packages/mermaid/src/diagrams/common/common.ts @@ -337,11 +337,12 @@ export const renderKatex = async (text: string, config: MermaidConfig): Promise< return text; } - if (!isMathMLSupported() && !config.legacyMathML) { + if (!(isMathMLSupported() || config.legacyMathML || config.forceLegacyMathML)) { return text.replace(katexRegex, 'MathML is unsupported in this environment.'); } const { default: katex } = await import('katex'); + const outputMode = (config.forceLegacyMathML) || (!isMathMLSupported() && config.legacyMathML) ? 'htmlAndMathml' : 'mathml'; return text .split(lineBreakRegex) .map((line) => @@ -357,7 +358,7 @@ export const renderKatex = async (text: string, config: MermaidConfig): Promise< .renderToString(c, { throwOnError: true, displayMode: true, - output: isMathMLSupported() ? 'mathml' : 'htmlAndMathml', + output: outputMode }) .replace(/\n/g, ' ') .replace(//g, '') diff --git a/packages/mermaid/src/schemas/config.schema.yaml b/packages/mermaid/src/schemas/config.schema.yaml index d1bb8ad1bf..68da484e04 100644 --- a/packages/mermaid/src/schemas/config.schema.yaml +++ b/packages/mermaid/src/schemas/config.schema.yaml @@ -180,6 +180,13 @@ properties: fall back to legacy rendering for KaTeX. type: boolean default: false + forceLegacyMathML: + description: | + This option forces Mermaid to rely on KaTeX's own stylesheet for rendering MathML. Due to differences between OS + fonts and browser's MathML implementation, this option is recommended if consistent rendering is important. + If set to true, ignores legacyMathML. + type: boolean + default: false deterministicIds: description: | This option controls if the generated ids of nodes in the SVG are From 13aa3265e3cd7fefe20eac18dcc26563f55d796a Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Mon, 22 Apr 2024 17:14:36 -0500 Subject: [PATCH 09/50] docs(mathml): updated docs to include forceLegacyMathML --- .../src/docs/config/img/mathMLDifferences.png | Bin 0 -> 15108 bytes packages/mermaid/src/docs/config/math.md | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 packages/mermaid/src/docs/config/img/mathMLDifferences.png diff --git a/packages/mermaid/src/docs/config/img/mathMLDifferences.png b/packages/mermaid/src/docs/config/img/mathMLDifferences.png new file mode 100644 index 0000000000000000000000000000000000000000..6b7a86400f44b00fd16acad5e3a66a1a9ff26d52 GIT binary patch literal 15108 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 XLkqWVSLh6AYX!+jD2P{y8U_6qGL%eZ literal 0 HcmV?d00001 diff --git a/packages/mermaid/src/docs/config/math.md b/packages/mermaid/src/docs/config/math.md index 22b398e087..6b203c52d9 100644 --- a/packages/mermaid/src/docs/config/math.md +++ b/packages/mermaid/src/docs/config/math.md @@ -60,3 +60,13 @@ Example with legacy mode enabled (the latest version of KaTeX's stylesheet can b ``` + +## Handling Rendering Differences + +Due to differences between default fonts across operating systems and browser's MathML implementations, inconsistent results can be seen across platforms. If having consistent results are important, or the most optimal rendered results are desired, `forceLegacyMathML` can be enabled in the config. + +This option will always use KaTeX's stylesheet instead of only when MathML is not supported (as with `legacyMathML`). Note that only `forceLegacyMathML` needs to be set. + +If including KaTeX's stylesheet is not a concern, enabling this option is recommended to avoid scenarios where no MathML implementation within a browser provides the desired output (as seen below). + +![Image showing differences between Browsers](img/mathMLDifferences.png) From 7f33ae0f40700654216a787771b95a454978a1bb Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Mon, 22 Apr 2024 17:15:10 -0500 Subject: [PATCH 10/50] fix(mathml): fixed flowchart equations being cut off --- packages/mermaid/src/diagrams/common/common.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/mermaid/src/diagrams/common/common.ts b/packages/mermaid/src/diagrams/common/common.ts index 364dc25ea8..c6537e3904 100644 --- a/packages/mermaid/src/diagrams/common/common.ts +++ b/packages/mermaid/src/diagrams/common/common.ts @@ -347,9 +347,7 @@ export const renderKatex = async (text: string, config: MermaidConfig): Promise< .split(lineBreakRegex) .map((line) => hasKatex(line) - ? `
- ${line} -
` + ? `
${line}
` : `
${line}
` ) .join('') From 128c69aa76c58d088f03cb5dd4dd4fcdc1883846 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Wed, 17 Apr 2024 10:25:54 -0700 Subject: [PATCH 11/50] fix: use maps for quadrant diagrams --- .../quadrant-chart/parser/quadrant.jison.spec.ts | 11 +++++++++++ .../src/diagrams/quadrant-chart/quadrantBuilder.ts | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts index 6ec2ddafb6..e59cc0fe20 100644 --- a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts +++ b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts @@ -2,6 +2,7 @@ import { parser } from './quadrant.jison'; import type { Mock } from 'vitest'; import { vi } from 'vitest'; +import { addClass } from '../../flowchart/flowDb.js'; const parserFnConstructor = (str: string) => { return () => { @@ -20,6 +21,7 @@ const mockDB: Record> = { setYAxisBottomText: vi.fn(), setDiagramTitle: vi.fn(), addPoint: vi.fn(), + addClass: vi.fn(), }; function clearMocks() { @@ -423,4 +425,13 @@ describe('Testing quadrantChart jison file', () => { ['stroke-width: 10px'] ); }); + + it('should be able to handle constructor as a className', () => { + const str = `quadrantChart + classDef constructor fill:#ff0000 + Microsoft:::constructor: [0.75, 0.75] + `; + expect(parserFnConstructor(str)).not.toThrow(); + expect(mockDB.addClass).toHaveBeenCalledWith('constructor', ['fill:#ff0000']); + }); }); diff --git a/packages/mermaid/src/diagrams/quadrant-chart/quadrantBuilder.ts b/packages/mermaid/src/diagrams/quadrant-chart/quadrantBuilder.ts index 173b4c0780..f1507a1b90 100644 --- a/packages/mermaid/src/diagrams/quadrant-chart/quadrantBuilder.ts +++ b/packages/mermaid/src/diagrams/quadrant-chart/quadrantBuilder.ts @@ -127,7 +127,7 @@ export class QuadrantBuilder { private config: QuadrantBuilderConfig; private themeConfig: QuadrantBuilderThemeConfig; private data: QuadrantBuilderData; - private classes: Record = {}; + private classes: Map = new Map(); constructor() { this.config = this.getDefaultConfig(); @@ -202,7 +202,7 @@ export class QuadrantBuilder { this.config = this.getDefaultConfig(); this.themeConfig = this.getDefaultThemeConfig(); this.data = this.getDefaultData(); - this.classes = {}; + this.classes = new Map(); log.info('clear called'); } @@ -215,7 +215,7 @@ export class QuadrantBuilder { } addClass(className: string, styles: StylesObject) { - this.classes[className] = styles; + this.classes.set(className, styles); } setConfig(config: Partial) { @@ -486,7 +486,7 @@ export class QuadrantBuilder { .range([quadrantHeight + quadrantTop, quadrantTop]); const points: QuadrantPointType[] = this.data.points.map((point) => { - const classStyles = this.classes[point.className as keyof typeof this.classes]; + const classStyles = this.classes.get(point.className!); if (classStyles) { point = { ...classStyles, ...point }; } From 18defaae6d82ad04a77776c6a22a4c63b2d87b40 Mon Sep 17 00:00:00 2001 From: Alexandre Colucci <738543+Timac@users.noreply.github.com> Date: Fri, 26 Apr 2024 08:17:40 +0200 Subject: [PATCH 12/50] Update integrations-community: Add MarkChart, a macOS app to preview Mermaid diagrams --- packages/mermaid/src/docs/ecosystem/integrations-community.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mermaid/src/docs/ecosystem/integrations-community.md b/packages/mermaid/src/docs/ecosystem/integrations-community.md index 95e71d626d..330a524104 100644 --- a/packages/mermaid/src/docs/ecosystem/integrations-community.md +++ b/packages/mermaid/src/docs/ecosystem/integrations-community.md @@ -244,6 +244,7 @@ Communication tools and platforms - [Jekyll](https://jekyllrb.com/) - [jekyll-mermaid](https://rubygems.org/gems/jekyll-mermaid) - [jekyll-mermaid-diagrams](https://github.com/fuzhibo/jekyll-mermaid-diagrams) +- [MarkChart: Preview Mermaid diagrams on macOS](https://markchart.app/) - [mermaid-isomorphic](https://github.com/remcohaszing/mermaid-isomorphic) - [mermaid-server: Generate diagrams using a HTTP request](https://github.com/TomWright/mermaid-server) - [NiceGUI: Let any browser be the frontend of your Python code](https://nicegui.io) ✅ From edad740e15fac589497b496ecc1094b2e3edcb7e Mon Sep 17 00:00:00 2001 From: Steph <35910788+huynhicode@users.noreply.github.com> Date: Fri, 26 Apr 2024 13:17:14 -0700 Subject: [PATCH 13/50] add ai blog post --- docs/news/blog.md | 6 ++++++ packages/mermaid/src/docs/news/blog.md | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/docs/news/blog.md b/docs/news/blog.md index d88c9ed236..3e7e4be4fb 100644 --- a/docs/news/blog.md +++ b/docs/news/blog.md @@ -6,6 +6,12 @@ # Blog +## [AI in software diagramming: What trends will define the future?](https://www.mermaidchart.com/blog/posts/ai-in-software-diagramming/) + +24 April 2024 ·5 mins + +Artificial intelligence (AI) tools are changing the way developers work. + ## [Mermaid Chart Unveils Visual Editor for Sequence Diagrams](https://www.mermaidchart.com/blog/posts/mermaid-chart-unveils-visual-editor-for-sequence-diagrams/) 8 April 2024 · 5 mins diff --git a/packages/mermaid/src/docs/news/blog.md b/packages/mermaid/src/docs/news/blog.md index 267bd48a61..5d3c6b9c33 100644 --- a/packages/mermaid/src/docs/news/blog.md +++ b/packages/mermaid/src/docs/news/blog.md @@ -1,5 +1,11 @@ # Blog +## [AI in software diagramming: What trends will define the future?](https://www.mermaidchart.com/blog/posts/ai-in-software-diagramming/) + +24 April 2024 ·5 mins + +Artificial intelligence (AI) tools are changing the way developers work. + ## [Mermaid Chart Unveils Visual Editor for Sequence Diagrams](https://www.mermaidchart.com/blog/posts/mermaid-chart-unveils-visual-editor-for-sequence-diagrams/) 8 April 2024 · 5 mins From 1ac9244e68973b39f269a4c7b237b33c49395992 Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Mon, 29 Apr 2024 09:46:50 -0500 Subject: [PATCH 14/50] style(mathml): linting --- packages/mermaid/src/diagrams/common/common.ts | 7 +++++-- packages/mermaid/src/docs/config/math.md | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/mermaid/src/diagrams/common/common.ts b/packages/mermaid/src/diagrams/common/common.ts index c6537e3904..66cc5ff6f0 100644 --- a/packages/mermaid/src/diagrams/common/common.ts +++ b/packages/mermaid/src/diagrams/common/common.ts @@ -342,7 +342,10 @@ export const renderKatex = async (text: string, config: MermaidConfig): Promise< } const { default: katex } = await import('katex'); - const outputMode = (config.forceLegacyMathML) || (!isMathMLSupported() && config.legacyMathML) ? 'htmlAndMathml' : 'mathml'; + const outputMode = + config.forceLegacyMathML || (!isMathMLSupported() && config.legacyMathML) + ? 'htmlAndMathml' + : 'mathml'; return text .split(lineBreakRegex) .map((line) => @@ -356,7 +359,7 @@ export const renderKatex = async (text: string, config: MermaidConfig): Promise< .renderToString(c, { throwOnError: true, displayMode: true, - output: outputMode + output: outputMode, }) .replace(/\n/g, ' ') .replace(//g, '') diff --git a/packages/mermaid/src/docs/config/math.md b/packages/mermaid/src/docs/config/math.md index 6b203c52d9..a53dceaf2a 100644 --- a/packages/mermaid/src/docs/config/math.md +++ b/packages/mermaid/src/docs/config/math.md @@ -63,7 +63,7 @@ Example with legacy mode enabled (the latest version of KaTeX's stylesheet can b ## Handling Rendering Differences -Due to differences between default fonts across operating systems and browser's MathML implementations, inconsistent results can be seen across platforms. If having consistent results are important, or the most optimal rendered results are desired, `forceLegacyMathML` can be enabled in the config. +Due to differences between default fonts across operating systems and browser's MathML implementations, inconsistent results can be seen across platforms. If having consistent results are important, or the most optimal rendered results are desired, `forceLegacyMathML` can be enabled in the config. This option will always use KaTeX's stylesheet instead of only when MathML is not supported (as with `legacyMathML`). Note that only `forceLegacyMathML` needs to be set. From c4ccfec3166be0cd6fba1ddd09beee818aa2356a Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Mon, 29 Apr 2024 14:49:56 +0000 Subject: [PATCH 15/50] Update docs --- docs/config/img/mathMLDifferences.png | Bin 0 -> 15108 bytes docs/config/math.md | 10 ++++++++++ 2 files changed, 10 insertions(+) create mode 100644 docs/config/img/mathMLDifferences.png diff --git a/docs/config/img/mathMLDifferences.png b/docs/config/img/mathMLDifferences.png new file mode 100644 index 0000000000000000000000000000000000000000..6b7a86400f44b00fd16acad5e3a66a1a9ff26d52 GIT binary patch literal 15108 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 XLkqWVSLh6AYX!+jD2P{y8U_6qGL%eZ literal 0 HcmV?d00001 diff --git a/docs/config/math.md b/docs/config/math.md index 1541585087..b2063e3af2 100644 --- a/docs/config/math.md +++ b/docs/config/math.md @@ -84,3 +84,13 @@ Example with legacy mode enabled (the latest version of KaTeX's stylesheet can b ``` + +## Handling Rendering Differences + +Due to differences between default fonts across operating systems and browser's MathML implementations, inconsistent results can be seen across platforms. If having consistent results are important, or the most optimal rendered results are desired, `forceLegacyMathML` can be enabled in the config. + +This option will always use KaTeX's stylesheet instead of only when MathML is not supported (as with `legacyMathML`). Note that only `forceLegacyMathML` needs to be set. + +If including KaTeX's stylesheet is not a concern, enabling this option is recommended to avoid scenarios where no MathML implementation within a browser provides the desired output (as seen below). + +![Image showing differences between Browsers](img/mathMLDifferences.png) From 76801ff564b2acfaf0b80772e621375d7470488c Mon Sep 17 00:00:00 2001 From: Steph <35910788+huynhicode@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:12:55 -0700 Subject: [PATCH 16/50] update content --- docs/ecosystem/mermaid-chart.md | 28 +++++++++++-------- .../src/docs/ecosystem/mermaid-chart.md | 28 +++++++++++-------- 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/docs/ecosystem/mermaid-chart.md b/docs/ecosystem/mermaid-chart.md index 07572d044f..f1ca85af0c 100644 --- a/docs/ecosystem/mermaid-chart.md +++ b/docs/ecosystem/mermaid-chart.md @@ -6,6 +6,10 @@ # Mermaid Chart +The Future of Diagramming & Visual Collaboration + +Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an account at [Mermaid Chart](https://www.mermaidchart.com/app/sign-up). +
Mermaid Chart - A smarter way to create diagrams | Product Hunt @@ -18,22 +22,26 @@ - **Editor** - A web based editor for creating and editing Mermaid diagrams. -- **Presentation** - A presentation mode for viewing Mermaid diagrams in a slideshow format. +- **Visual Editor** - The Visual Editor enables users of all skill levels to create diagrams easily and efficiently, with both GUI and code-based editing options. -- **Collaboration** - A web based collaboration feature for multi-user editing on Mermaid diagrams in real-time (Pro plan). +- **AI Chat** - Use our embedded AI Chat to generate diagrams from natural language descriptions. - **Plugins** - A plugin system for extending the functionality of Mermaid. - Plugins are available for: + Official Mermaid Chart plugins: - - [ChatGPT](https://docs.mermaidchart.com/plugins/chatgpt) + - [Mermaid Chart GPT](https://chat.openai.com/g/g-1IRFKwq4G-mermaid-chart) + - [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=MermaidChart.vscode-mermaid-chart) - [JetBrains IDE](https://plugins.jetbrains.com/plugin/23043-mermaid-chart) - [Microsoft PowerPoint and Word](https://appsource.microsoft.com/en-us/product/office/WA200006214?tab=Overview) - - [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=MermaidChart.vscode-mermaid-chart) -- **AI diagramming** - A feature for generating Mermaid diagrams from text using AI (Pro plan). + Visit our [Plugins](https://www.mermaidchart.com/plugins) page for more information. -- **More** - To learn more, visit our [Product](https://www.mermaidchart.com/product) page. +- **Collaboration** - A web based collaboration feature for multi-user editing on Mermaid diagrams in real-time (Pro and Enterprise plans). + +- **Comments** - Enhance collaboration by adding comments to diagrams. + +- **Presentations** - A presentation mode for viewing Mermaid diagrams in a slideshow format. ## Plans @@ -43,11 +51,9 @@ - **Enterprise** - A paid plan for enterprise use that includes all Pro features, and more. -## Access - -Sign up for a free account at [Mermaid Chart](https://www.mermaidchart.com/app/sign-up). +To learn more, visit our [Pricing](https://mermaidchart.com/pricing) page. -Mermaid Chart is currently offering a 14-day free trial of our newly-launched Pro tier. To learn more, visit our [Pricing](https://mermaidchart.com/pricing) page. +Mermaid Chart is currently offering a 14-day free trial on our Pro and Enterprise tiers. Sign up for a free account at [Mermaid Chart](https://www.mermaidchart.com/app/sign-up). ## Mermaid JS contributions diff --git a/packages/mermaid/src/docs/ecosystem/mermaid-chart.md b/packages/mermaid/src/docs/ecosystem/mermaid-chart.md index 94b6773e4b..732b9b68cd 100644 --- a/packages/mermaid/src/docs/ecosystem/mermaid-chart.md +++ b/packages/mermaid/src/docs/ecosystem/mermaid-chart.md @@ -1,5 +1,9 @@ # Mermaid Chart +The Future of Diagramming & Visual Collaboration + +Try the Ultimate AI, Mermaid, and Visual Diagramming Suite by creating an account at [Mermaid Chart](https://www.mermaidchart.com/app/sign-up). +
Mermaid Chart - A smarter way to create diagrams | Product Hunt @@ -12,22 +16,26 @@ - **Editor** - A web based editor for creating and editing Mermaid diagrams. -- **Presentation** - A presentation mode for viewing Mermaid diagrams in a slideshow format. +- **Visual Editor** - The Visual Editor enables users of all skill levels to create diagrams easily and efficiently, with both GUI and code-based editing options. -- **Collaboration** - A web based collaboration feature for multi-user editing on Mermaid diagrams in real-time (Pro plan). +- **AI Chat** - Use our embedded AI Chat to generate diagrams from natural language descriptions. - **Plugins** - A plugin system for extending the functionality of Mermaid. - Plugins are available for: + Official Mermaid Chart plugins: - - [ChatGPT](https://docs.mermaidchart.com/plugins/chatgpt) + - [Mermaid Chart GPT](https://chat.openai.com/g/g-1IRFKwq4G-mermaid-chart) + - [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=MermaidChart.vscode-mermaid-chart) - [JetBrains IDE](https://plugins.jetbrains.com/plugin/23043-mermaid-chart) - [Microsoft PowerPoint and Word](https://appsource.microsoft.com/en-us/product/office/WA200006214?tab=Overview) - - [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=MermaidChart.vscode-mermaid-chart) -- **AI diagramming** - A feature for generating Mermaid diagrams from text using AI (Pro plan). + Visit our [Plugins](https://www.mermaidchart.com/plugins) page for more information. -- **More** - To learn more, visit our [Product](https://www.mermaidchart.com/product) page. +- **Collaboration** - A web based collaboration feature for multi-user editing on Mermaid diagrams in real-time (Pro and Enterprise plans). + +- **Comments** - Enhance collaboration by adding comments to diagrams. + +- **Presentations** - A presentation mode for viewing Mermaid diagrams in a slideshow format. ## Plans @@ -37,11 +45,9 @@ - **Enterprise** - A paid plan for enterprise use that includes all Pro features, and more. -## Access - -Sign up for a free account at [Mermaid Chart](https://www.mermaidchart.com/app/sign-up). +To learn more, visit our [Pricing](https://mermaidchart.com/pricing) page. -Mermaid Chart is currently offering a 14-day free trial of our newly-launched Pro tier. To learn more, visit our [Pricing](https://mermaidchart.com/pricing) page. +Mermaid Chart is currently offering a 14-day free trial on our Pro and Enterprise tiers. Sign up for a free account at [Mermaid Chart](https://www.mermaidchart.com/app/sign-up). ## Mermaid JS contributions From 92f1941fb045e3b549b9c6ebfb0119697ad8010b Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Wed, 1 May 2024 10:42:55 -0700 Subject: [PATCH 17/50] fix: some changes --- packages/mermaid/src/diagrams/er/erRenderer.js | 2 +- packages/mermaid/src/diagrams/state/stateRenderer-v2.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/diagrams/er/erRenderer.js b/packages/mermaid/src/diagrams/er/erRenderer.js index 7f0a0e914a..33fb5bd4ae 100644 --- a/packages/mermaid/src/diagrams/er/erRenderer.js +++ b/packages/mermaid/src/diagrams/er/erRenderer.js @@ -296,7 +296,7 @@ const drawAttributes = (groupNode, entityTextNode, attributes) => { * Use D3 to construct the svg elements for the entities * * @param svgNode The svg node that contains the diagram - * @param entities The entities to be drawn + * @param {Map} entities The entities to be drawn * @param graph The graph that contains the vertex and edge definitions post-layout * @returns {object} The first entity that was inserted */ diff --git a/packages/mermaid/src/diagrams/state/stateRenderer-v2.js b/packages/mermaid/src/diagrams/state/stateRenderer-v2.js index 4d702bf3c1..264d4501f9 100644 --- a/packages/mermaid/src/diagrams/state/stateRenderer-v2.js +++ b/packages/mermaid/src/diagrams/state/stateRenderer-v2.js @@ -129,13 +129,13 @@ export function stateDomId(itemId = '', counter = 0, type = '', typeSpacer = DOM * @param g - graph * @param {object} parent * @param {object} parsedItem - parsed statement item - * @param {object[]} diagramStates - the list of all known states for the diagram + * @param {Map} diagramStates - the list of all known states for the diagram * @param {object} diagramDb * @param {boolean} altFlag - for clusters, add the "statediagram-cluster-alt" CSS class */ const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => { const itemId = parsedItem.id; - const classStr = getClassesFromDbInfo(diagramStates[itemId]); + const classStr = getClassesFromDbInfo(diagramStates.get(itemId)); if (itemId !== 'root') { let shape = SHAPE_STATE; @@ -303,7 +303,7 @@ const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => * @param g * @param parentParsedItem - parsed Item that is the parent of this document (doc) * @param doc - the document to set up; it is a list of parsed statements - * @param {object[]} diagramStates - the list of all known states for the diagram + * @param {Map} diagramStates - the list of all known states for the diagram * @param diagramDb * @param {boolean} altFlag * @todo This duplicates some of what is done in stateDb.js extract method From 6f1a553234b883015b6b96a23cc81a49092f84a2 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Fri, 3 May 2024 20:37:45 -0700 Subject: [PATCH 18/50] fix: git graph diffs --- .../src/diagrams/git/gitGraphRenderer.js | 91 ++++++++++--------- 1 file changed, 50 insertions(+), 41 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.js b/packages/mermaid/src/diagrams/git/gitGraphRenderer.js index 2576b26628..f4019448c3 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.js +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.js @@ -3,7 +3,12 @@ import { getConfig, setupGraphViewbox } from '../../diagram-api/diagramAPI.js'; import { log } from '../../logger.js'; import utils from '../../utils.js'; -let allCommitsDict = {}; +/** + * @typedef {Map} CommitMap + */ + +/** @type {CommitMap} */ +let allCommitsDict = new Map(); const commitType = { NORMAL: 0, @@ -22,9 +27,9 @@ let maxPos = 0; let dir = 'LR'; let defaultPos = 30; const clear = () => { - branchPos = {}; - commitPos = {}; - allCommitsDict = {}; + branchPos = new Map(); + commitPos = new Map(); + allCommitsDict = new Map(); maxPos = 0; lanes = []; dir = 'LR'; @@ -78,7 +83,7 @@ const findClosestParent = (parents) => { let maxPosition = 0; parents.forEach((parent) => { - const parentPosition = dir === 'TB' || dir === 'BT' ? commitPos[parent].y : commitPos[parent].x; + const parentPosition = dir === 'TB' || dir === 'BT' ? commitPos.get(parent).y : commitPos.get(parent).x; if (parentPosition >= maxPosition) { closestParent = parent; maxPosition = parentPosition; @@ -101,7 +106,7 @@ const findClosestParentBT = (parents) => { let maxPosition = Infinity; parents.forEach((parent) => { - const parentPosition = commitPos[parent].y; + const parentPosition = commitPos.get(parent).y; if (parentPosition <= maxPosition) { closestParent = parent; maxPosition = parentPosition; @@ -119,7 +124,7 @@ const findClosestParentBT = (parents) => { * of the remaining commits. * * @param {any} sortedKeys - * @param {any} commits + * @param {CommitMap} commits * @param {any} defaultPos * @param {any} commitStep * @param {any} layoutOffset @@ -132,35 +137,35 @@ const setParallelBTPos = (sortedKeys, commits, defaultPos, commitStep, layoutOff const commit = commits.get(key); if (commit.parents.length) { const closestParent = findClosestParent(commit.parents); - curPos = commitPos[closestParent].y + commitStep; + curPos = commitPos.get(closestParent).y + commitStep; if (curPos >= maxPosition) { maxPosition = curPos; } } else { roots.push(commit); } - const x = branchPos[commit.branch].pos; + const x = branchPos.get(commit.branch).pos; const y = curPos + layoutOffset; - commitPos[commit.id] = { x: x, y: y }; + commitPos.set(commit.id, { x: x, y: y }); }); curPos = maxPosition; roots.forEach((commit) => { const posWithOffset = curPos + defaultPos; const y = posWithOffset; - const x = branchPos[commit.branch].pos; - commitPos[commit.id] = { x: x, y: y }; + const x = branchPos.get(commit.branch).pos; + commitPos.set(commit.id, { x: x, y: y }); }); sortedKeys.forEach((key) => { const commit = commits.get(key); if (commit.parents.length) { const closestParent = findClosestParentBT(commit.parents); - curPos = commitPos[closestParent].y - commitStep; + curPos = commitPos.get(closestParent).y - commitStep; if (curPos <= maxPosition) { maxPosition = curPos; } - const x = branchPos[commit.branch].pos; + const x = branchPos.get(commit.branch).pos; const y = curPos - layoutOffset; - commitPos[commit.id] = { x: x, y: y }; + commitPos.set(commit.id, { x: x, y: y }); } }); }; @@ -171,7 +176,7 @@ const setParallelBTPos = (sortedKeys, commits, defaultPos, commitStep, layoutOff * vertical layering correct in the graph. * * @param {any} svg - * @param {any} commits + * @param {CommitMap} commits * @param {any} modifyGraph */ const drawCommits = (svg, commits, modifyGraph) => { @@ -209,25 +214,25 @@ const drawCommits = (svg, commits, modifyGraph) => { const closestParent = dir === 'BT' ? findClosestParentBT(commit.parents) : findClosestParent(commit.parents); if (dir === 'TB') { - pos = commitPos[closestParent].y + commitStep; + pos = commitPos.get(closestParent).y + commitStep; } else if (dir === 'BT') { - pos = commitPos[key].y - commitStep; + pos = commitPos.get(key).y - commitStep; } else { - pos = commitPos[closestParent].x + commitStep; + pos = commitPos.get(closestParent).x + commitStep; } } else { if (dir === 'TB') { pos = defaultPos; } else if (dir === 'BT') { - pos = commitPos[key].y - commitStep; + pos = commitPos.get(key).y - commitStep; } else { pos = 0; } } } const posWithOffset = dir === 'BT' && isParallelCommits ? pos : pos + layoutOffset; - const y = dir === 'TB' || dir === 'BT' ? posWithOffset : branchPos[commit.branch].pos; - const x = dir === 'TB' || dir === 'BT' ? branchPos[commit.branch].pos : posWithOffset; + const y = dir === 'TB' || dir === 'BT' ? posWithOffset : branchPos.get(commit.branch).pos; + const x = dir === 'TB' || dir === 'BT' ? branchPos.get(commit.branch).pos : posWithOffset; // Don't draw the commits now but calculate the positioning which is used by the branch lines etc. if (modifyGraph) { @@ -265,7 +270,7 @@ const drawCommits = (svg, commits, modifyGraph) => { circle.attr( 'class', `commit ${commit.id} commit-highlight${ - branchPos[commit.branch].index % THEME_COLOR_LIMIT + branchPos.get(commit.branch).index % THEME_COLOR_LIMIT } ${typeClass}-outer` ); gBullets @@ -277,7 +282,7 @@ const drawCommits = (svg, commits, modifyGraph) => { .attr( 'class', `commit ${commit.id} commit${ - branchPos[commit.branch].index % THEME_COLOR_LIMIT + branchPos.get(commit.branch).index % THEME_COLOR_LIMIT } ${typeClass}-inner` ); } else if (commitSymbolType === commitType.CHERRY_PICK) { @@ -324,7 +329,7 @@ const drawCommits = (svg, commits, modifyGraph) => { circle.attr('r', commit.type === commitType.MERGE ? 9 : 10); circle.attr( 'class', - `commit ${commit.id} commit${branchPos[commit.branch].index % THEME_COLOR_LIMIT}` + `commit ${commit.id} commit${branchPos.get(commit.branch).index % THEME_COLOR_LIMIT}` ); if (commitSymbolType === commitType.MERGE) { const circle2 = gBullets.append('circle'); @@ -334,7 +339,7 @@ const drawCommits = (svg, commits, modifyGraph) => { circle2.attr( 'class', `commit ${typeClass} ${commit.id} commit${ - branchPos[commit.branch].index % THEME_COLOR_LIMIT + branchPos.get(commit.branch).index % THEME_COLOR_LIMIT }` ); } @@ -345,16 +350,16 @@ const drawCommits = (svg, commits, modifyGraph) => { .attr( 'class', `commit ${typeClass} ${commit.id} commit${ - branchPos[commit.branch].index % THEME_COLOR_LIMIT + branchPos.get(commit.branch).index % THEME_COLOR_LIMIT }` ); } } } if (dir === 'TB' || dir === 'BT') { - commitPos[commit.id] = { x: x, y: posWithOffset }; + commitPos.set(commit.id, { x: x, y: posWithOffset }); } else { - commitPos[commit.id] = { x: posWithOffset, y: y }; + commitPos.set(commit.id, { x: posWithOffset, y: y }); } // The first iteration over the commits are for positioning purposes, this @@ -482,7 +487,7 @@ const drawCommits = (svg, commits, modifyGraph) => { * @param {any} commitB * @param p1 * @param p2 - * @param allCommits + * @param {CommitMap} allCommits * @returns {boolean} * If there are commits between * commitA's x-position @@ -496,7 +501,7 @@ const shouldRerouteArrow = (commitA, commitB, p1, p2, allCommits) => { const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch; const isOnBranchToGetCurve = (x) => x.branch === branchToGetCurve; const isBetweenCommits = (x) => x.seq > commitA.seq && x.seq < commitB.seq; - return Object.values(allCommits).some((commitX) => { + return [...allCommits.values()].some((commitX) => { return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX); }); }; @@ -531,11 +536,11 @@ const findLane = (y1, y2, depth = 0) => { * @param {any} svg * @param {any} commitA * @param {any} commitB - * @param {any} allCommits + * @param {CommitMap} allCommits */ const drawArrow = (svg, commitA, commitB, allCommits) => { - const p1 = commitPos[commitA.id]; // arrowStart - const p2 = commitPos[commitB.id]; // arrowEnd + const p1 = commitPos.get(commitA.id); // arrowStart + const p2 = commitPos.get(commitB.id); // arrowEnd const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits); // log.debug('drawArrow', p1, p2, arrowNeedsRerouting, commitA.id, commitB.id); @@ -545,9 +550,9 @@ const drawArrow = (svg, commitA, commitB, allCommits) => { let arc2 = ''; let radius = 0; let offset = 0; - let colorClassNum = branchPos[commitB.branch].index; + let colorClassNum = branchPos.get(commitB.branch).index; if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - colorClassNum = branchPos[commitA.branch].index; + colorClassNum = branchPos.get(commitA.branch).index; } let lineDef; @@ -570,7 +575,7 @@ const drawArrow = (svg, commitA, commitB, allCommits) => { } else { // Source commit is on branch position right of destination commit // so render arrow leftward with colour of source branch - colorClassNum = branchPos[commitA.branch].index; + colorClassNum = branchPos.get(commitA.branch).index; lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc} ${lineX} ${ p1.y + offset } L ${lineX} ${p2.y - radius} ${arc2} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`; @@ -585,7 +590,7 @@ const drawArrow = (svg, commitA, commitB, allCommits) => { } else { // Source commit is on branch position right of destination commit // so render arrow leftward with colour of source branch - colorClassNum = branchPos[commitA.branch].index; + colorClassNum = branchPos.get(commitA.branch).index; lineDef = `M ${p1.x} ${p1.y} L ${lineX + radius} ${p1.y} ${arc2} ${lineX} ${ p1.y - offset } L ${lineX} ${p2.y + radius} ${arc} ${lineX - offset} ${p2.y} L ${p2.x} ${p2.y}`; @@ -600,7 +605,7 @@ const drawArrow = (svg, commitA, commitB, allCommits) => { } else { // Source commit is on branch positioned below destination commit // so render arrow upward with colour of source branch - colorClassNum = branchPos[commitA.branch].index; + colorClassNum = branchPos.get(commitA.branch).index; lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${ p1.x + offset } ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`; @@ -710,6 +715,10 @@ const drawArrow = (svg, commitA, commitB, allCommits) => { .attr('class', 'arrow arrow' + (colorClassNum % THEME_COLOR_LIMIT)); }; +/** + * @param {*} svg + * @param {CommitMap} commits + */ const drawArrows = (svg, commits) => { const gArrows = svg.append('g').attr('class', 'commit-arrows'); [...commits.keys()].forEach((key) => { @@ -734,7 +743,7 @@ const drawBranches = (svg, branches) => { branches.forEach((branch, index) => { const adjustIndexForTheme = index % THEME_COLOR_LIMIT; - const pos = branchPos[branch.name].pos; + const pos = branchPos.get(branch.name).pos; const line = g.append('line'); line.attr('x1', 0); line.attr('y1', pos); @@ -822,7 +831,7 @@ export const draw = function (txt, id, ver, diagObj) { label.node().appendChild(labelElement); let bbox = labelElement.getBBox(); - branchPos[branch.name] = { pos, index }; + branchPos.set(branch.name, { pos, index }); pos += 50 + (gitGraphConfig.rotateCommitLabel ? 40 : 0) + From 1cbd730b8d45c811be399a945326ff748a059709 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Fri, 3 May 2024 21:07:09 -0700 Subject: [PATCH 19/50] fix: class diagram notes plss --- packages/mermaid/src/diagrams/class/classRenderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/class/classRenderer.js b/packages/mermaid/src/diagrams/class/classRenderer.js index 381b93341f..27e5255378 100644 --- a/packages/mermaid/src/diagrams/class/classRenderer.js +++ b/packages/mermaid/src/diagrams/class/classRenderer.js @@ -216,7 +216,7 @@ export const draw = function (text, id, _version, diagObj) { // metadata about the node. In this case we're going to add labels to each of // our nodes. g.setNode(node.id, node); - if (note.class && note.class in classes) { + if (note.class && classes.has(note.class)) { g.setEdge( note.id, getGraphId(note.class), From e2ca8e820e68a25cb4a70a9fcd379ced559cf992 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Fri, 3 May 2024 21:12:40 -0700 Subject: [PATCH 20/50] format --- packages/mermaid/src/diagrams/git/gitGraphRenderer.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.js b/packages/mermaid/src/diagrams/git/gitGraphRenderer.js index f4019448c3..b612b3c0a5 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.js +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.js @@ -83,7 +83,8 @@ const findClosestParent = (parents) => { let maxPosition = 0; parents.forEach((parent) => { - const parentPosition = dir === 'TB' || dir === 'BT' ? commitPos.get(parent).y : commitPos.get(parent).x; + const parentPosition = + dir === 'TB' || dir === 'BT' ? commitPos.get(parent).y : commitPos.get(parent).x; if (parentPosition >= maxPosition) { closestParent = parent; maxPosition = parentPosition; @@ -716,8 +717,8 @@ const drawArrow = (svg, commitA, commitB, allCommits) => { }; /** - * @param {*} svg - * @param {CommitMap} commits + * @param {*} svg + * @param {CommitMap} commits */ const drawArrows = (svg, commits) => { const gArrows = svg.append('g').attr('class', 'commit-arrows'); From 58af76384a1e878f3d0cabe42f0ab75d0a78c1d9 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Fri, 3 May 2024 21:19:52 -0700 Subject: [PATCH 21/50] fix: classrenderer v2 using in op --- packages/mermaid/src/diagrams/class/classRenderer-v2.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts index cf80a8a708..4a0967f794 100644 --- a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts +++ b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts @@ -187,7 +187,7 @@ export const addNotes = function ( g.setNode(vertex.id, node); log.info('setNode', node); - if (!vertex.class || !(vertex.class in classes)) { + if (!vertex.class || !classes.has(vertex.class)) { return; } const edgeId = startEdgeId + i; From 9986b023d71f866be8ac0873c2c3289784b8000d Mon Sep 17 00:00:00 2001 From: Igor Wessel Date: Sat, 4 May 2024 06:21:12 -0300 Subject: [PATCH 22/50] feat(state): add from, to in edge --- packages/mermaid/src/diagrams/state/stateRenderer-v2.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/state/stateRenderer-v2.js b/packages/mermaid/src/diagrams/state/stateRenderer-v2.js index 482e37caee..04bdd135e4 100644 --- a/packages/mermaid/src/diagrams/state/stateRenderer-v2.js +++ b/packages/mermaid/src/diagrams/state/stateRenderer-v2.js @@ -252,7 +252,6 @@ const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => type: 'group', padding: 0, //getConfig().flowchart.padding }; - graphItemCount++; const parentNodeId = itemId + PARENT_ID; g.setNode(parentNodeId, groupData); @@ -270,17 +269,21 @@ const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => from = noteData.id; to = itemId; } + g.setEdge(from, to, { arrowhead: 'none', arrowType: '', style: G_EDGE_STYLE, labelStyle: '', + id: 'edge' + graphItemCount + `_${from}_${to}`, classes: CSS_EDGE_NOTE_EDGE, arrowheadStyle: G_EDGE_ARROWHEADSTYLE, labelpos: G_EDGE_LABELPOS, labelType: G_EDGE_LABELTYPE, thickness: G_EDGE_THICKNESS, }); + + graphItemCount++; } else { g.setNode(itemId, nodeData); } @@ -324,7 +327,7 @@ const setupDoc = (g, parentParsedItem, doc, diagramStates, diagramDb, altFlag) = setupNode(g, parentParsedItem, item.state1, diagramStates, diagramDb, altFlag); setupNode(g, parentParsedItem, item.state2, diagramStates, diagramDb, altFlag); const edgeData = { - id: 'edge' + graphItemCount, + id: 'edge' + graphItemCount + `_${item.state1.id}_${item.state2.id}`, arrowhead: 'normal', arrowTypeEnd: 'arrow_barb', style: G_EDGE_STYLE, From ca4fa11859acac2b69642ad9a45125f2852b957b Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Sat, 4 May 2024 09:42:56 -0700 Subject: [PATCH 23/50] trigger e2e again From 50c9ede69da13809164ac4f54cbca44a1d141688 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Sat, 4 May 2024 09:44:08 -0700 Subject: [PATCH 24/50] chore: rm autocompleted import --- .../src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts index e59cc0fe20..d4bcdbf8ff 100644 --- a/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts +++ b/packages/mermaid/src/diagrams/quadrant-chart/parser/quadrant.jison.spec.ts @@ -2,7 +2,6 @@ import { parser } from './quadrant.jison'; import type { Mock } from 'vitest'; import { vi } from 'vitest'; -import { addClass } from '../../flowchart/flowDb.js'; const parserFnConstructor = (str: string) => { return () => { From 10871af93b3ca5a123463ab2d79d02c47e2c3834 Mon Sep 17 00:00:00 2001 From: cmmoran Date: Mon, 6 May 2024 07:06:55 +0000 Subject: [PATCH 25/50] chore: update browsers list --- pnpm-lock.yaml | 86 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2d636e3caf..82381338e1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -382,7 +382,7 @@ importers: version: 5.0.0 vitepress: specifier: ^1.0.1 - version: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5) + version: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(search-insights@2.13.0)(typescript@5.4.5) vitepress-plugin-search: specifier: 1.0.4-alpha.22 version: 1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4)(vue@3.4.26) @@ -500,7 +500,7 @@ importers: version: 0.19.8(vite@5.2.10)(workbox-build@7.1.0)(workbox-window@7.0.0) vitepress: specifier: 1.1.0 - version: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5) + version: 1.1.0(@algolia/client-search@4.23.3)(@types/node@20.12.7)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5) workbox-window: specifier: ^7.0.0 version: 7.0.0 @@ -4749,6 +4749,10 @@ packages: resolution: {integrity: sha512-yg6E+u0/+Zjva+buc3EIb+29XEg4wltq7cSmd4Uc2EE/1nUVmxyzpX6gUXD0V8jIrG0r7YeOGVIbYRkxeooCtw==} dev: true + /@types/linkify-it@5.0.0: + resolution: {integrity: sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==} + dev: true + /@types/lodash-es@4.17.12: resolution: {integrity: sha512-0NgftHUcV4v34VhXm8QBSftKVXtbkBG3ViCjs6+eJ5a6y6Mi/jiFGPc1sC7QK+9BFhWrURE3EOggmWaSxL9OzQ==} dependencies: @@ -4761,6 +4765,13 @@ packages: /@types/markdown-it@12.2.3: resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==} + dependencies: + '@types/linkify-it': 5.0.0 + '@types/mdurl': 2.0.0 + dev: true + + /@types/markdown-it@13.0.8: + resolution: {integrity: sha512-V+KmpgiipS+zoypeUSS9ojesWtY/0k4XfqcK2fnVrX/qInJhX7rsCxZ/rygiPH2zxlPPrhfuW0I6ddMcWTKLsg==} dependencies: '@types/linkify-it': 3.0.5 '@types/mdurl': 1.0.5 @@ -4788,6 +4799,10 @@ packages: resolution: {integrity: sha512-6L6VymKTzYSrEf4Nev4Xa1LCHKrlTlYCBMTlQKFuddo1CvQcE52I0mwfOJayueUC7MJuXOeHTcIU683lzd0cUA==} dev: true + /@types/mdurl@2.0.0: + resolution: {integrity: sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==} + dev: true + /@types/micromatch@4.0.7: resolution: {integrity: sha512-C/FMQ8HJAZhTsDpl4wDKZdMeeW5USjgzOczUwTGbRc1ZopPgOhIEnxY2ZgUrsuyy4DwK1JVOJZKFakv3TbCKiA==} dependencies: @@ -8293,7 +8308,7 @@ packages: engines: {node: '>=0.10.0'} hasBin: true dependencies: - jake: 10.8.7 + jake: 10.9.1 dev: true /electron-to-chromium@1.4.692: @@ -10807,8 +10822,8 @@ packages: optionalDependencies: '@pkgjs/parseargs': 0.11.0 - /jake@10.8.7: - resolution: {integrity: sha512-ZDi3aP+fG/LchyBzUM804VjddnwfSfsdeYkwt8NcbKRvo4rFkjhs456iLFn3k2ZUWvNe4i48WACDbza8fhq2+w==} + /jake@10.9.1: + resolution: {integrity: sha512-61btcOHNnLnsOdtLgA5efqQWjnSi/vow5HbI7HMdKKWqvrKR1bLK3BPlJn9gcSaP2ewuamUSMB5XEy76KUIS2w==} engines: {node: '>=10'} hasBin: true dependencies: @@ -15631,11 +15646,67 @@ packages: flexsearch: 0.7.43 glob-to-regexp: 0.4.1 markdown-it: 13.0.1 - vitepress: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5) + vitepress: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(search-insights@2.13.0)(typescript@5.4.5) vue: 3.4.26(typescript@5.4.5) dev: true - /vitepress@1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5): + /vitepress@1.1.0(@algolia/client-search@4.23.3)(@types/node@20.12.7)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5): + resolution: {integrity: sha512-G+NS5I2OETxC0SfGAMDO75JWNkrcir0UCptuhQMNoaZhhlqvYtTDQhph4qGc5dtiTtZkcFa/bCcSx+A2gSS3lA==} + hasBin: true + peerDependencies: + markdown-it-mathjax3: ^4 + postcss: ^8 + peerDependenciesMeta: + markdown-it-mathjax3: + optional: true + postcss: + optional: true + dependencies: + '@docsearch/css': 3.6.0 + '@docsearch/js': 3.6.0(@algolia/client-search@4.23.3)(search-insights@2.13.0) + '@shikijs/core': 1.4.0 + '@shikijs/transformers': 1.4.0 + '@types/markdown-it': 13.0.8 + '@vitejs/plugin-vue': 5.0.4(vite@5.2.10)(vue@3.4.26) + '@vue/devtools-api': 7.1.3(vue@3.4.26) + '@vueuse/core': 10.9.0(vue@3.4.26) + '@vueuse/integrations': 10.9.0(focus-trap@7.5.4)(vue@3.4.26) + focus-trap: 7.5.4 + mark.js: 8.11.1 + minisearch: 6.3.0 + postcss: 8.4.38 + shiki: 1.4.0 + vite: 5.2.10(@types/node@20.12.7) + vue: 3.4.26(typescript@5.4.5) + transitivePeerDependencies: + - '@algolia/client-search' + - '@types/node' + - '@types/react' + - '@vue/composition-api' + - async-validator + - axios + - change-case + - drauu + - fuse.js + - idb-keyval + - jwt-decode + - less + - lightningcss + - nprogress + - qrcode + - react + - react-dom + - sass + - search-insights + - sortablejs + - stylus + - sugarss + - terser + - typescript + - universal-cookie + dev: true + + /vitepress@1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(search-insights@2.13.0)(typescript@5.4.5): resolution: {integrity: sha512-bWIzFZXpPB6NIDBuWnS20aMADH+FcFKDfQNYFvbOWij03PR29eImTceQHIzCKordjXYBhM/TjE5VKFTUJ3EheA==} hasBin: true peerDependencies: @@ -15659,7 +15730,6 @@ packages: focus-trap: 7.5.4 mark.js: 8.11.1 minisearch: 6.3.0 - postcss: 8.4.38 shiki: 1.4.0 vite: 5.2.10(@types/node@20.12.7) vue: 3.4.26(typescript@5.4.5) From 1f6445271615eccdc7483327f8557286c31fcb91 Mon Sep 17 00:00:00 2001 From: Igor Wessel Date: Mon, 6 May 2024 07:46:42 -0300 Subject: [PATCH 26/50] feat(utils): create a standard edge id function --- packages/mermaid/src/utils.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/mermaid/src/utils.ts b/packages/mermaid/src/utils.ts index 06aca5ab27..99283f3598 100644 --- a/packages/mermaid/src/utils.ts +++ b/packages/mermaid/src/utils.ts @@ -929,3 +929,19 @@ export const decodeEntities = function (text: string): string { export const isString = (value: unknown): value is string => { return typeof value === 'string'; }; + +export const getEdgeId = ( + from: string, + to: string, + { + counter = 0, + prefix, + suffix, + }: { + counter?: number; + prefix?: string; + suffix?: string; + } +) => { + return `${prefix ? `${prefix}_` : ''}${from}_${to}_${counter}${suffix ? `_${suffix}` : ''}`; +}; From da150e8767eab63ef9e95be73a6696f34ffca161 Mon Sep 17 00:00:00 2001 From: Igor Wessel Date: Mon, 6 May 2024 08:07:47 -0300 Subject: [PATCH 27/50] feat: use standard edge id function for class,flow,state diagram --- .../mermaid/src/diagrams/class/classRenderer-v2.ts | 7 +++++-- .../mermaid/src/diagrams/flowchart/flowRenderer-v2.js | 11 ++++++++--- .../mermaid/src/diagrams/flowchart/flowRenderer.js | 7 +++++-- .../mermaid/src/diagrams/state/stateRenderer-v2.js | 10 +++++++--- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts index a01b1427b5..e8fb9a588d 100644 --- a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts +++ b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts @@ -4,7 +4,7 @@ import * as graphlib from 'dagre-d3-es/src/graphlib/index.js'; import { log } from '../../logger.js'; import { getConfig } from '../../diagram-api/diagramAPI.js'; import { render } from '../../dagre-wrapper/index.js'; -import utils from '../../utils.js'; +import utils, { getEdgeId } from '../../utils.js'; import { interpolateToCurve, getStylesFromArray } from '../../utils.js'; import { setupGraphViewbox } from '../../setupGraphViewbox.js'; import common from '../common/common.js'; @@ -231,7 +231,10 @@ export const addRelations = function (relations: ClassRelation[], g: graphlib.Gr //Set relationship style and line type classes: 'relation', pattern: edge.relation.lineType == 1 ? 'dashed' : 'solid', - id: `id_${edge.id1}_${edge.id2}_${cnt}`, + id: getEdgeId(edge.id1, edge.id2, { + prefix: 'id', + counter: cnt, + }), // Set link type for rendering arrowhead: edge.type === 'arrow_open' ? 'none' : 'normal', //Set edge extra labels diff --git a/packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js b/packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js index f27d8e3532..74c9dfb671 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js +++ b/packages/mermaid/src/diagrams/flowchart/flowRenderer-v2.js @@ -1,7 +1,7 @@ import * as graphlib from 'dagre-d3-es/src/graphlib/index.js'; import { select, curveLinear, selectAll } from 'd3'; import { getConfig } from '../../diagram-api/diagramAPI.js'; -import utils from '../../utils.js'; +import utils, { getEdgeId } from '../../utils.js'; import { render } from '../../dagre-wrapper/index.js'; import { addHtmlLabel } from 'dagre-d3-es/src/dagre-js/label/add-html-label.js'; import { log } from '../../logger.js'; @@ -210,7 +210,11 @@ export const addEdges = async function (edges, g, diagObj) { cnt++; // Identify Link - const linkIdBase = 'L-' + edge.start + '-' + edge.end; + const linkIdBase = getEdgeId(edge.start, edge.end, { + counter: cnt, + prefix: 'L', + }); + // count the links from+to the same node to give unique id if (linkIdCnt[linkIdBase] === undefined) { linkIdCnt[linkIdBase] = 0; @@ -219,7 +223,8 @@ export const addEdges = async function (edges, g, diagObj) { linkIdCnt[linkIdBase]++; log.info('abc78 new entry', linkIdBase, linkIdCnt[linkIdBase]); } - let linkId = linkIdBase + '-' + linkIdCnt[linkIdBase]; + let linkId = `${linkIdBase}_${linkIdCnt[linkIdBase]}`; + log.info('abc78 new link id to be used is', linkIdBase, linkId, linkIdCnt[linkIdBase]); const linkNameStart = 'LS-' + edge.start; const linkNameEnd = 'LE-' + edge.end; diff --git a/packages/mermaid/src/diagrams/flowchart/flowRenderer.js b/packages/mermaid/src/diagrams/flowchart/flowRenderer.js index b2e6bcc9cb..fdd52a763e 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowRenderer.js +++ b/packages/mermaid/src/diagrams/flowchart/flowRenderer.js @@ -6,7 +6,7 @@ import { applyStyle } from 'dagre-d3-es/src/dagre-js/util.js'; import { addHtmlLabel } from 'dagre-d3-es/src/dagre-js/label/add-html-label.js'; import { log } from '../../logger.js'; import common, { evaluate, renderKatex } from '../common/common.js'; -import { interpolateToCurve, getStylesFromArray } from '../../utils.js'; +import { interpolateToCurve, getStylesFromArray, getEdgeId } from '../../utils.js'; import { setupGraphViewbox } from '../../setupGraphViewbox.js'; import flowChartShapes from './flowChartShapes.js'; import { replaceIconSubstring } from '../../rendering-util/createText.js'; @@ -175,7 +175,10 @@ export const addEdges = async function (edges, g, diagObj) { cnt++; // Identify Link - const linkId = 'L-' + edge.start + '-' + edge.end; + const linkId = getEdgeId(edge.start, edge.end, { + counter: cnt, + prefix: 'L', + }); const linkNameStart = 'LS-' + edge.start; const linkNameEnd = 'LE-' + edge.end; diff --git a/packages/mermaid/src/diagrams/state/stateRenderer-v2.js b/packages/mermaid/src/diagrams/state/stateRenderer-v2.js index 04bdd135e4..8ebc948cdb 100644 --- a/packages/mermaid/src/diagrams/state/stateRenderer-v2.js +++ b/packages/mermaid/src/diagrams/state/stateRenderer-v2.js @@ -5,7 +5,7 @@ import { render } from '../../dagre-wrapper/index.js'; import { log } from '../../logger.js'; import { configureSvgSize } from '../../setupGraphViewbox.js'; import common from '../common/common.js'; -import utils from '../../utils.js'; +import utils, { getEdgeId } from '../../utils.js'; import { DEFAULT_DIAGRAM_DIRECTION, @@ -275,7 +275,9 @@ const setupNode = (g, parent, parsedItem, diagramStates, diagramDb, altFlag) => arrowType: '', style: G_EDGE_STYLE, labelStyle: '', - id: 'edge' + graphItemCount + `_${from}_${to}`, + id: getEdgeId(from, to, { + counter: graphItemCount, + }), classes: CSS_EDGE_NOTE_EDGE, arrowheadStyle: G_EDGE_ARROWHEADSTYLE, labelpos: G_EDGE_LABELPOS, @@ -327,7 +329,9 @@ const setupDoc = (g, parentParsedItem, doc, diagramStates, diagramDb, altFlag) = setupNode(g, parentParsedItem, item.state1, diagramStates, diagramDb, altFlag); setupNode(g, parentParsedItem, item.state2, diagramStates, diagramDb, altFlag); const edgeData = { - id: 'edge' + graphItemCount + `_${item.state1.id}_${item.state2.id}`, + id: getEdgeId(item.state1.id, item.state2.id, { + counter: graphItemCount, + }), arrowhead: 'normal', arrowTypeEnd: 'arrow_barb', style: G_EDGE_STYLE, From bb2bbfdf925ef54d6b5748d15ee0ab993b72597e Mon Sep 17 00:00:00 2001 From: Conrad Agramont <41589731+conradagramont@users.noreply.github.com> Date: Tue, 7 May 2024 13:24:04 -0700 Subject: [PATCH 28/50] Added to "others" section on integration with Astro --- packages/mermaid/src/docs/ecosystem/integrations-community.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/mermaid/src/docs/ecosystem/integrations-community.md b/packages/mermaid/src/docs/ecosystem/integrations-community.md index 95e71d626d..0d48a667c2 100644 --- a/packages/mermaid/src/docs/ecosystem/integrations-community.md +++ b/packages/mermaid/src/docs/ecosystem/integrations-community.md @@ -254,5 +254,7 @@ Communication tools and platforms - [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin) - [mermaid-isomorphic](https://github.com/remcohaszing/mermaid-isomorphic) - [mermaid-server: Generate diagrams using a HTTP request](https://github.com/TomWright/mermaid-server) +- [Astro](https://astro.build/) + - [Adding diagrams to your Astro site with MermaidJS and Playwright](https://agramont.net/blog/diagraming-with-mermaidjs-astro/) From edda73c7fc90f9128e2779a9ff86ee70a77fa811 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 8 May 2024 10:56:08 +0530 Subject: [PATCH 29/50] chore: Update ordering --- docs/ecosystem/integrations-community.md | 2 ++ packages/mermaid/src/docs/ecosystem/integrations-community.md | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/ecosystem/integrations-community.md b/docs/ecosystem/integrations-community.md index 01a32ae435..a38462ee85 100644 --- a/docs/ecosystem/integrations-community.md +++ b/docs/ecosystem/integrations-community.md @@ -240,6 +240,8 @@ Communication tools and platforms ### Other +- [Astro](https://astro.build/) + - [Adding diagrams to your Astro site with MermaidJS and Playwright](https://agramont.net/blog/diagraming-with-mermaidjs-astro/) - [Bisheng](https://www.npmjs.com/package/bisheng) - [bisheng-plugin-mermaid](https://github.com/yct21/bisheng-plugin-mermaid) - [Blazorade Mermaid: Render Mermaid diagrams in Blazor applications](https://github.com/Blazorade/Blazorade-Mermaid/wiki) diff --git a/packages/mermaid/src/docs/ecosystem/integrations-community.md b/packages/mermaid/src/docs/ecosystem/integrations-community.md index 0d48a667c2..f22166254c 100644 --- a/packages/mermaid/src/docs/ecosystem/integrations-community.md +++ b/packages/mermaid/src/docs/ecosystem/integrations-community.md @@ -235,6 +235,8 @@ Communication tools and platforms ### Other +- [Astro](https://astro.build/) + - [Adding diagrams to your Astro site with MermaidJS and Playwright](https://agramont.net/blog/diagraming-with-mermaidjs-astro/) - [Bisheng](https://www.npmjs.com/package/bisheng) - [bisheng-plugin-mermaid](https://github.com/yct21/bisheng-plugin-mermaid) - [Blazorade Mermaid: Render Mermaid diagrams in Blazor applications](https://github.com/Blazorade/Blazorade-Mermaid/wiki) @@ -254,7 +256,5 @@ Communication tools and platforms - [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin) - [mermaid-isomorphic](https://github.com/remcohaszing/mermaid-isomorphic) - [mermaid-server: Generate diagrams using a HTTP request](https://github.com/TomWright/mermaid-server) -- [Astro](https://astro.build/) - - [Adding diagrams to your Astro site with MermaidJS and Playwright](https://agramont.net/blog/diagraming-with-mermaidjs-astro/) From 9eb64cd6db0c18a9ac9ab0a0ee04e4aa562eb99e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 8 May 2024 10:59:18 +0530 Subject: [PATCH 30/50] Update docs --- docs/ecosystem/integrations-community.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ecosystem/integrations-community.md b/docs/ecosystem/integrations-community.md index a38462ee85..b7dd757b73 100644 --- a/docs/ecosystem/integrations-community.md +++ b/docs/ecosystem/integrations-community.md @@ -251,6 +251,7 @@ Communication tools and platforms - [Jekyll](https://jekyllrb.com/) - [jekyll-mermaid](https://rubygems.org/gems/jekyll-mermaid) - [jekyll-mermaid-diagrams](https://github.com/fuzhibo/jekyll-mermaid-diagrams) +- [MarkChart: Preview Mermaid diagrams on macOS](https://markchart.app/) - [mermaid-isomorphic](https://github.com/remcohaszing/mermaid-isomorphic) - [mermaid-server: Generate diagrams using a HTTP request](https://github.com/TomWright/mermaid-server) - [NiceGUI: Let any browser be the frontend of your Python code](https://nicegui.io) ✅ From 954f5d7d4209cb26fbdb8439cf6d4e77089ba659 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 8 May 2024 06:04:26 +0000 Subject: [PATCH 31/50] chore(deps): update all patch dependencies --- package.json | 4 +- packages/mermaid/src/docs/package.json | 2 +- pnpm-lock.yaml | 827 +++++++++++-------------- 3 files changed, 367 insertions(+), 466 deletions(-) diff --git a/package.json b/package.json index f3e0b4e289..393677907f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "10.2.4", "description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", "type": "module", - "packageManager": "pnpm@8.15.7", + "packageManager": "pnpm@8.15.8", "keywords": [ "diagram", "markdown", @@ -107,7 +107,7 @@ "jison": "^0.4.18", "js-yaml": "^4.1.0", "jsdom": "^24.0.0", - "langium-cli": "3.0.1", + "langium-cli": "3.0.3", "lint-staged": "^15.2.2", "markdown-table": "^3.0.3", "nyc": "^15.1.0", diff --git a/packages/mermaid/src/docs/package.json b/packages/mermaid/src/docs/package.json index 5f6e338a09..146c4d2d88 100644 --- a/packages/mermaid/src/docs/package.json +++ b/packages/mermaid/src/docs/package.json @@ -34,7 +34,7 @@ "unplugin-vue-components": "^0.26.0", "vite": "^5.0.0", "vite-plugin-pwa": "^0.19.7", - "vitepress": "1.1.0", + "vitepress": "1.1.4", "workbox-window": "^7.0.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 82381338e1..8b86c86c00 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,7 +21,7 @@ importers: version: 8.7.0(eslint@8.57.0) '@cypress/code-coverage': specifier: ^3.12.30 - version: 3.12.38(@babel/core@7.24.5)(@babel/preset-env@7.24.5)(babel-loader@9.1.3)(cypress@13.7.3)(webpack@5.91.0) + version: 3.12.39(@babel/core@7.24.5)(@babel/preset-env@7.24.5)(babel-loader@9.1.3)(cypress@13.7.3)(webpack@5.91.0) '@rollup/plugin-typescript': specifier: ^11.1.6 version: 11.1.6(typescript@5.4.5) @@ -42,13 +42,13 @@ importers: version: 21.1.6 '@types/lodash': specifier: ^4.17.0 - version: 4.17.0 + version: 4.17.1 '@types/mdast': specifier: ^4.0.3 version: 4.0.3 '@types/node': specifier: ^20.11.30 - version: 20.12.7 + version: 20.12.10 '@types/rollup-plugin-visualizer': specifier: ^4.2.4 version: 4.2.4 @@ -141,7 +141,7 @@ importers: version: 9.0.11 jest: specifier: ^29.7.0 - version: 29.7.0(@types/node@20.12.7) + version: 29.7.0(@types/node@20.12.10) jison: specifier: ^0.4.18 version: 0.4.18 @@ -152,8 +152,8 @@ importers: specifier: ^24.0.0 version: 24.0.0 langium-cli: - specifier: 3.0.1 - version: 3.0.1 + specifier: 3.0.3 + version: 3.0.3 lint-staged: specifier: ^15.2.2 version: 15.2.2 @@ -192,13 +192,13 @@ importers: version: 5.4.5 vite: specifier: ^5.2.3 - version: 5.2.10(@types/node@20.12.7) + version: 5.2.11(@types/node@20.12.10) vite-plugin-istanbul: specifier: ^6.0.0 - version: 6.0.0(vite@5.2.10) + version: 6.0.2(vite@5.2.11) vitest: specifier: ^1.4.0 - version: 1.5.3(@types/node@20.12.7)(@vitest/ui@1.5.3)(jsdom@24.0.0) + version: 1.5.3(@types/node@20.12.10)(@vitest/ui@1.5.3)(jsdom@24.0.0) packages/mermaid: dependencies: @@ -298,7 +298,7 @@ importers: version: 3.0.0 '@types/stylis': specifier: ^4.2.5 - version: 4.2.5 + version: 4.2.6 '@types/uuid': specifier: ^9.0.8 version: 9.0.8 @@ -382,10 +382,10 @@ importers: version: 5.0.0 vitepress: specifier: ^1.0.1 - version: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(search-insights@2.13.0)(typescript@5.4.5) + version: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.10)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5) vitepress-plugin-search: specifier: 1.0.4-alpha.22 - version: 1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4)(vue@3.4.26) + version: 1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4)(vue@3.4.27) packages/mermaid-example-diagram: dependencies: @@ -451,7 +451,7 @@ importers: version: 7.4.47 '@vueuse/core': specifier: ^10.9.0 - version: 10.9.0(vue@3.4.26) + version: 10.9.0(vue@3.4.27) font-awesome: specifier: ^4.7.0 version: 4.7.0 @@ -463,7 +463,7 @@ importers: version: link:../.. vue: specifier: ^3.4.21 - version: 3.4.26(typescript@5.4.5) + version: 3.4.27(typescript@5.4.5) devDependencies: '@iconify-json/carbon': specifier: ^1.1.31 @@ -476,7 +476,7 @@ importers: version: 0.4.0(vite-plugin-pwa@0.19.8) '@vitejs/plugin-vue': specifier: ^5.0.0 - version: 5.0.4(vite@5.2.10)(vue@3.4.26) + version: 5.0.4(vite@5.2.11)(vue@3.4.27) fast-glob: specifier: ^3.3.2 version: 3.3.2 @@ -488,19 +488,19 @@ importers: version: 1.1.2 unocss: specifier: ^0.59.0 - version: 0.59.4(postcss@8.4.38)(rollup@2.79.1)(vite@5.2.10) + version: 0.59.4(postcss@8.4.38)(rollup@2.79.1)(vite@5.2.11) unplugin-vue-components: specifier: ^0.26.0 - version: 0.26.0(rollup@2.79.1)(vue@3.4.26) + version: 0.26.0(rollup@2.79.1)(vue@3.4.27) vite: specifier: ^5.0.0 - version: 5.2.10(@types/node@20.12.7) + version: 5.2.11(@types/node@20.12.10) vite-plugin-pwa: specifier: ^0.19.7 - version: 0.19.8(vite@5.2.10)(workbox-build@7.1.0)(workbox-window@7.0.0) + version: 0.19.8(vite@5.2.11)(workbox-build@7.1.0)(workbox-window@7.0.0) vitepress: - specifier: 1.1.0 - version: 1.1.0(@algolia/client-search@4.23.3)(@types/node@20.12.7)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5) + specifier: 1.1.4 + version: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.10)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5) workbox-window: specifier: ^7.0.0 version: 7.0.0 @@ -1089,19 +1089,11 @@ packages: engines: {node: '>=12.13.0'} dev: true - /@babel/code-frame@7.23.5: - resolution: {integrity: sha512-CgH3s1a96LipHCmSUmYFPwY7MNx8C3avkq7i4Wl3cfa662ldtUe4VM1TPXX70pfmrlWTb6jLqTYrZyT2ZTJBgA==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/highlight': 7.24.2 - chalk: 2.4.2 - dev: true - /@babel/code-frame@7.24.2: resolution: {integrity: sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==} engines: {node: '>=6.9.0'} dependencies: - '@babel/highlight': 7.24.2 + '@babel/highlight': 7.24.5 picocolors: 1.0.0 dev: true @@ -1110,29 +1102,6 @@ packages: engines: {node: '>=6.9.0'} dev: true - /@babel/core@7.24.4: - resolution: {integrity: sha512-MBVlMXP+kkl5394RBLSxxk/iLTeVGuXTV3cIDXavPpMMqnSnt6apKgan/U8O3USWZCWZT/TbgfEpKa4uMgN4Dg==} - engines: {node: '>=6.9.0'} - dependencies: - '@ampproject/remapping': 2.3.0 - '@babel/code-frame': 7.24.2 - '@babel/generator': 7.24.4 - '@babel/helper-compilation-targets': 7.23.6 - '@babel/helper-module-transforms': 7.23.3(@babel/core@7.24.4) - '@babel/helpers': 7.24.4 - '@babel/parser': 7.24.5 - '@babel/template': 7.24.0 - '@babel/traverse': 7.24.1 - '@babel/types': 7.24.5 - convert-source-map: 2.0.0 - debug: 4.3.4(supports-color@8.1.1) - gensync: 1.0.0-beta.2 - json5: 2.2.3 - semver: 6.3.1 - transitivePeerDependencies: - - supports-color - dev: true - /@babel/core@7.24.5: resolution: {integrity: sha512-tVQRucExLQ02Boi4vdPp49svNGcfL2GhdTCT9aldhXgCJVAI21EtRfBettiuLUwce/7r6bFdgs6JFkcdTiFttA==} engines: {node: '>=6.9.0'} @@ -1156,16 +1125,6 @@ packages: - supports-color dev: true - /@babel/generator@7.24.4: - resolution: {integrity: sha512-Xd6+v6SnjWVx/nus+y0l1sxMOTOMBkyL4+BIdbALyatQnAe/SRVjANeDPSCYaX+i1iJmuGSKf3Z+E+V/va1Hvw==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/types': 7.24.5 - '@jridgewell/gen-mapping': 0.3.5 - '@jridgewell/trace-mapping': 0.3.25 - jsesc: 2.5.2 - dev: true - /@babel/generator@7.24.5: resolution: {integrity: sha512-x32i4hEXvr+iI0NEoEfDKzlemF8AmtOP8CcrRaEcpzysWuoEb1KknpcvMsHKPONoKZiDuItklgWhB18xEhr9PA==} engines: {node: '>=6.9.0'} @@ -1201,19 +1160,19 @@ packages: semver: 6.3.1 dev: true - /@babel/helper-create-class-features-plugin@7.24.4(@babel/core@7.24.4): + /@babel/helper-create-class-features-plugin@7.24.4(@babel/core@7.24.5): resolution: {integrity: sha512-lG75yeuUSVu0pIcbhiYMXBXANHrpUPaOfu7ryAzskCgKUHuAxRQI5ssrtmF0X9UXldPlvT0XM/A4F44OXRt6iQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@babel/helper-annotate-as-pure': 7.22.5 '@babel/helper-environment-visitor': 7.22.20 '@babel/helper-function-name': 7.23.0 '@babel/helper-member-expression-to-functions': 7.23.0 '@babel/helper-optimise-call-expression': 7.22.5 - '@babel/helper-replace-supers': 7.24.1(@babel/core@7.24.4) + '@babel/helper-replace-supers': 7.24.1(@babel/core@7.24.5) '@babel/helper-skip-transparent-expression-wrappers': 7.22.5 '@babel/helper-split-export-declaration': 7.22.6 semver: 6.3.1 @@ -1305,34 +1264,6 @@ packages: '@babel/types': 7.24.5 dev: true - /@babel/helper-module-transforms@7.23.3(@babel/core@7.24.4): - resolution: {integrity: sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-module-imports': 7.24.3 - '@babel/helper-simple-access': 7.22.5 - '@babel/helper-split-export-declaration': 7.22.6 - '@babel/helper-validator-identifier': 7.24.5 - dev: true - - /@babel/helper-module-transforms@7.23.3(@babel/core@7.24.5): - resolution: {integrity: sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - dependencies: - '@babel/core': 7.24.5 - '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-module-imports': 7.24.3 - '@babel/helper-simple-access': 7.22.5 - '@babel/helper-split-export-declaration': 7.22.6 - '@babel/helper-validator-identifier': 7.24.5 - dev: true - /@babel/helper-module-transforms@7.24.5(@babel/core@7.24.5): resolution: {integrity: sha512-9GxeY8c2d2mdQUP1Dye0ks3VDyIMS98kt/llQ2nUId8IsWqTF0l1LkSX0/uP7l7MCDrzXS009Hyhe2gzTiGW8A==} engines: {node: '>=6.9.0'} @@ -1376,18 +1307,6 @@ packages: '@babel/helper-wrap-function': 7.24.5 dev: true - /@babel/helper-replace-supers@7.24.1(@babel/core@7.24.4): - resolution: {integrity: sha512-QCR1UqC9BzG5vZl8BMicmZ28RuUBnHhAMddD8yHFHDRH9lLTZ9uUPehX8ctVPT8l0TKblJidqcgUUKGVrePleQ==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-member-expression-to-functions': 7.23.0 - '@babel/helper-optimise-call-expression': 7.22.5 - dev: true - /@babel/helper-replace-supers@7.24.1(@babel/core@7.24.5): resolution: {integrity: sha512-QCR1UqC9BzG5vZl8BMicmZ28RuUBnHhAMddD8yHFHDRH9lLTZ9uUPehX8ctVPT8l0TKblJidqcgUUKGVrePleQ==} engines: {node: '>=6.9.0'} @@ -1462,17 +1381,6 @@ packages: '@babel/types': 7.24.5 dev: true - /@babel/helpers@7.24.4: - resolution: {integrity: sha512-FewdlZbSiwaVGlgT1DPANDuCHaDMiOo+D/IDYRFYjHOuv66xMSJ7fQwwODwRNAPkADIO/z1EoF/l2BCWlWABDw==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/template': 7.24.0 - '@babel/traverse': 7.24.1 - '@babel/types': 7.24.5 - transitivePeerDependencies: - - supports-color - dev: true - /@babel/helpers@7.24.5: resolution: {integrity: sha512-CiQmBMMpMQHwM5m01YnrM6imUG1ebgYJ+fAIW4FZe6m4qHTPaRHti+R8cggAwkdz4oXhtO4/K9JWlh+8hIfR2Q==} engines: {node: '>=6.9.0'} @@ -1484,11 +1392,11 @@ packages: - supports-color dev: true - /@babel/highlight@7.24.2: - resolution: {integrity: sha512-Yac1ao4flkTxTteCDZLEvdxg2fZfz1v8M4QpaGypq/WPDqg3ijHYbDfs+LG5hvzSoqaSZ9/Z9lKSP3CjZjv+pA==} + /@babel/highlight@7.24.5: + resolution: {integrity: sha512-8lLmua6AVh/8SLJRRVD6V8p73Hir9w5mJrhE+IPpILG31KKlI9iz5zmBYKcWPS59qSfgP9RaSBQSHHE81WKuEw==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-validator-identifier': 7.22.20 + '@babel/helper-validator-identifier': 7.24.5 chalk: 2.4.2 js-tokens: 4.0.0 picocolors: 1.0.0 @@ -1554,15 +1462,6 @@ packages: '@babel/core': 7.24.5 dev: true - /@babel/plugin-syntax-async-generators@7.8.4(@babel/core@7.24.4): - resolution: {integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-async-generators@7.8.4(@babel/core@7.24.5): resolution: {integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==} peerDependencies: @@ -1572,21 +1471,12 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-bigint@7.8.3(@babel/core@7.24.4): + /@babel/plugin-syntax-bigint@7.8.3(@babel/core@7.24.5): resolution: {integrity: sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - - /@babel/plugin-syntax-class-properties@7.12.13(@babel/core@7.24.4): - resolution: {integrity: sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@babel/helper-plugin-utils': 7.24.0 dev: true @@ -1647,15 +1537,6 @@ packages: '@babel/helper-plugin-utils': 7.24.5 dev: true - /@babel/plugin-syntax-import-meta@7.10.4(@babel/core@7.24.4): - resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-import-meta@7.10.4(@babel/core@7.24.5): resolution: {integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==} peerDependencies: @@ -1665,15 +1546,6 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-json-strings@7.8.3(@babel/core@7.24.4): - resolution: {integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-json-strings@7.8.3(@babel/core@7.24.5): resolution: {integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==} peerDependencies: @@ -1683,22 +1555,13 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-jsx@7.24.1(@babel/core@7.24.4): + /@babel/plugin-syntax-jsx@7.24.1(@babel/core@7.24.5): resolution: {integrity: sha512-2eCtxZXf+kbkMIsXS4poTvT4Yu5rXiRa+9xGVT56raghjmBTKMpFNc9R4IDiB4emao9eO22Ox7CxuJG7BgExqA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - - /@babel/plugin-syntax-logical-assignment-operators@7.10.4(@babel/core@7.24.4): - resolution: {integrity: sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@babel/helper-plugin-utils': 7.24.0 dev: true @@ -1711,15 +1574,6 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(@babel/core@7.24.4): - resolution: {integrity: sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-nullish-coalescing-operator@7.8.3(@babel/core@7.24.5): resolution: {integrity: sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==} peerDependencies: @@ -1729,15 +1583,6 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-numeric-separator@7.10.4(@babel/core@7.24.4): - resolution: {integrity: sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-numeric-separator@7.10.4(@babel/core@7.24.5): resolution: {integrity: sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==} peerDependencies: @@ -1747,15 +1592,6 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-object-rest-spread@7.8.3(@babel/core@7.24.4): - resolution: {integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-object-rest-spread@7.8.3(@babel/core@7.24.5): resolution: {integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==} peerDependencies: @@ -1765,15 +1601,6 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-optional-catch-binding@7.8.3(@babel/core@7.24.4): - resolution: {integrity: sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-optional-catch-binding@7.8.3(@babel/core@7.24.5): resolution: {integrity: sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==} peerDependencies: @@ -1783,15 +1610,6 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-optional-chaining@7.8.3(@babel/core@7.24.4): - resolution: {integrity: sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-optional-chaining@7.8.3(@babel/core@7.24.5): resolution: {integrity: sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==} peerDependencies: @@ -1811,16 +1629,6 @@ packages: '@babel/helper-plugin-utils': 7.24.5 dev: true - /@babel/plugin-syntax-top-level-await@7.14.5(@babel/core@7.24.4): - resolution: {integrity: sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-plugin-utils': 7.24.0 - dev: true - /@babel/plugin-syntax-top-level-await@7.14.5(@babel/core@7.24.5): resolution: {integrity: sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==} engines: {node: '>=6.9.0'} @@ -1831,13 +1639,13 @@ packages: '@babel/helper-plugin-utils': 7.24.0 dev: true - /@babel/plugin-syntax-typescript@7.24.1(@babel/core@7.24.4): + /@babel/plugin-syntax-typescript@7.24.1(@babel/core@7.24.5): resolution: {integrity: sha512-Yhnmvy5HZEnHUty6i++gcfH1/l68AHnItFHnaCv6hn9dNh0hQvvQJsxpi4BMBFN5DLeHBuucT/0DgzXif/OyRw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@babel/helper-plugin-utils': 7.24.0 dev: true @@ -2098,18 +1906,6 @@ packages: '@babel/helper-plugin-utils': 7.24.5 dev: true - /@babel/plugin-transform-modules-commonjs@7.24.1(@babel/core@7.24.4): - resolution: {integrity: sha512-szog8fFTUxBfw0b98gEWPaEqF42ZUD/T3bkynW/wtgx2p/XCP55WEsb+VosKceRSd6njipdZvNogqdtI4Q0chw==} - engines: {node: '>=6.9.0'} - peerDependencies: - '@babel/core': ^7.0.0-0 - dependencies: - '@babel/core': 7.24.4 - '@babel/helper-module-transforms': 7.23.3(@babel/core@7.24.4) - '@babel/helper-plugin-utils': 7.24.0 - '@babel/helper-simple-access': 7.22.5 - dev: true - /@babel/plugin-transform-modules-commonjs@7.24.1(@babel/core@7.24.5): resolution: {integrity: sha512-szog8fFTUxBfw0b98gEWPaEqF42ZUD/T3bkynW/wtgx2p/XCP55WEsb+VosKceRSd6njipdZvNogqdtI4Q0chw==} engines: {node: '>=6.9.0'} @@ -2117,7 +1913,7 @@ packages: '@babel/core': ^7.0.0-0 dependencies: '@babel/core': 7.24.5 - '@babel/helper-module-transforms': 7.23.3(@babel/core@7.24.5) + '@babel/helper-module-transforms': 7.24.5(@babel/core@7.24.5) '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-simple-access': 7.22.5 dev: true @@ -2352,17 +2148,17 @@ packages: '@babel/helper-plugin-utils': 7.24.5 dev: true - /@babel/plugin-transform-typescript@7.24.4(@babel/core@7.24.4): + /@babel/plugin-transform-typescript@7.24.4(@babel/core@7.24.5): resolution: {integrity: sha512-79t3CQ8+oBGk/80SQ8MN3Bs3obf83zJ0YZjDmDaEZN8MqhMI760apl5z6a20kFeMXBwJX99VpKT8CKxEBp5H1g==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@babel/helper-annotate-as-pure': 7.22.5 - '@babel/helper-create-class-features-plugin': 7.24.4(@babel/core@7.24.4) + '@babel/helper-create-class-features-plugin': 7.24.4(@babel/core@7.24.5) '@babel/helper-plugin-utils': 7.24.0 - '@babel/plugin-syntax-typescript': 7.24.1(@babel/core@7.24.4) + '@babel/plugin-syntax-typescript': 7.24.1(@babel/core@7.24.5) dev: true /@babel/plugin-transform-unicode-escapes@7.24.1(@babel/core@7.24.5): @@ -2511,18 +2307,18 @@ packages: esutils: 2.0.3 dev: true - /@babel/preset-typescript@7.24.1(@babel/core@7.24.4): + /@babel/preset-typescript@7.24.1(@babel/core@7.24.5): resolution: {integrity: sha512-1DBaMmRDpuYQBPWD8Pf/WEwCrtgRHxsZnP4mIy9G/X+hFfbI47Q2G4t1Paakld84+qsk2fSsUPMKg71jkoOOaQ==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@babel/helper-plugin-utils': 7.24.0 '@babel/helper-validator-option': 7.23.5 - '@babel/plugin-syntax-jsx': 7.24.1(@babel/core@7.24.4) - '@babel/plugin-transform-modules-commonjs': 7.24.1(@babel/core@7.24.4) - '@babel/plugin-transform-typescript': 7.24.4(@babel/core@7.24.4) + '@babel/plugin-syntax-jsx': 7.24.1(@babel/core@7.24.5) + '@babel/plugin-transform-modules-commonjs': 7.24.1(@babel/core@7.24.5) + '@babel/plugin-transform-typescript': 7.24.4(@babel/core@7.24.5) dev: true /@babel/regjsgen@0.8.0: @@ -2559,24 +2355,6 @@ packages: '@babel/types': 7.24.5 dev: true - /@babel/traverse@7.24.1: - resolution: {integrity: sha512-xuU6o9m68KeqZbQuDt2TcKSxUw/mrsvavlEqQ1leZ/B+C9tk6E4sRWy97WaXgvq5E+nU3cXMxv3WKOCanVMCmQ==} - engines: {node: '>=6.9.0'} - dependencies: - '@babel/code-frame': 7.24.2 - '@babel/generator': 7.24.4 - '@babel/helper-environment-visitor': 7.22.20 - '@babel/helper-function-name': 7.23.0 - '@babel/helper-hoist-variables': 7.22.5 - '@babel/helper-split-export-declaration': 7.22.6 - '@babel/parser': 7.24.5 - '@babel/types': 7.24.5 - debug: 4.3.4(supports-color@8.1.1) - globals: 11.12.0 - transitivePeerDependencies: - - supports-color - dev: true - /@babel/traverse@7.24.5: resolution: {integrity: sha512-7aaBLeDQ4zYcUFDUD41lJc1fG8+5IU9DaNSJAgal866FGvmD5EbWQgnEC6kO1gGLsX0esNkfnJSndbTXA3r7UA==} engines: {node: '>=6.9.0'} @@ -2971,8 +2749,8 @@ packages: engines: {node: '>=18'} dev: true - /@cypress/code-coverage@3.12.38(@babel/core@7.24.5)(@babel/preset-env@7.24.5)(babel-loader@9.1.3)(cypress@13.7.3)(webpack@5.91.0): - resolution: {integrity: sha512-1jYHxAeweMBD5hvrHdzpwmS0yHQ/AKHC1BsoAgYtvYYRe/aOkAeWUwy3CaOTQzyVOMa+cWFElPYYusf1WiW85A==} + /@cypress/code-coverage@3.12.39(@babel/core@7.24.5)(@babel/preset-env@7.24.5)(babel-loader@9.1.3)(cypress@13.7.3)(webpack@5.91.0): + resolution: {integrity: sha512-ja7I/GRmkSAW9e3O7pideWcNUEHao0WT6sRyXQEURoxkJUASJssJ7Kb/bd3eMYmkUCiD5CRFqWR5BGF4mWVaUw==} peerDependencies: '@babel/core': ^7.0.1 '@babel/preset-env': ^7.0.0 @@ -3717,7 +3495,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 chalk: 4.1.2 jest-message-util: 29.7.0 jest-util: 29.7.0 @@ -3738,14 +3516,14 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 ansi-escapes: 4.3.2 chalk: 4.1.2 ci-info: 3.9.0 exit: 0.1.2 graceful-fs: 4.2.11 jest-changed-files: 29.7.0 - jest-config: 29.7.0(@types/node@20.12.7) + jest-config: 29.7.0(@types/node@20.12.10) jest-haste-map: 29.7.0 jest-message-util: 29.7.0 jest-regex-util: 29.6.3 @@ -3773,7 +3551,7 @@ packages: dependencies: '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 jest-mock: 29.7.0 dev: true @@ -3800,7 +3578,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@sinonjs/fake-timers': 10.3.0 - '@types/node': 20.12.7 + '@types/node': 20.12.10 jest-message-util: 29.7.0 jest-mock: 29.7.0 jest-util: 29.7.0 @@ -3833,7 +3611,7 @@ packages: '@jest/transform': 29.7.0 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.25 - '@types/node': 20.12.7 + '@types/node': 20.12.10 chalk: 4.1.2 collect-v8-coverage: 1.0.2 exit: 0.1.2 @@ -3895,7 +3673,7 @@ packages: resolution: {integrity: sha512-ok/BTPFzFKVMwO5eOHRrvnBVHdRy9IrsrW1GpMaQ9MCnilNLXQKmAX8s1YXDFaai9xJpac2ySzV0YeRRECr2Vw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@jest/types': 29.6.3 '@jridgewell/trace-mapping': 0.3.25 babel-plugin-istanbul: 6.1.1 @@ -3921,7 +3699,7 @@ packages: '@jest/schemas': 29.6.3 '@types/istanbul-lib-coverage': 2.0.6 '@types/istanbul-reports': 3.0.4 - '@types/node': 20.12.7 + '@types/node': 20.12.10 '@types/yargs': 17.0.32 chalk: 4.1.2 dev: true @@ -4370,13 +4148,13 @@ packages: resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==} dependencies: '@types/connect': 3.4.38 - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/bonjour@3.5.10: resolution: {integrity: sha512-p7ienRMiS41Nu2/igbJxxLDWrSZ0WxM8UQgCeO9KhoVF7cOVFkrKsiDr1EsJIla8vV3oEEjGcz11jc5yimhzZw==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/braces@3.0.4: @@ -4388,7 +4166,7 @@ packages: dependencies: '@types/http-cache-semantics': 4.0.4 '@types/keyv': 3.1.4 - '@types/node': 20.12.7 + '@types/node': 20.12.10 '@types/responselike': 1.0.3 dev: true @@ -4396,19 +4174,19 @@ packages: resolution: {integrity: sha512-4x5FkPpLipqwthjPsF7ZRbOv3uoLUFkTA9G9v583qi4pACvq0uTELrB8OLUzPWUI4IJIyvM85vzkV1nyiI2Lig==} dependencies: '@types/express-serve-static-core': 4.17.43 - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/connect@3.4.38: resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/cors@2.8.17: resolution: {integrity: sha512-8CGDvrBj1zgo2qE+oS3pOCyYNqCPryMWY2bGfwA0dcfopWGgxs+78df0Rs3rc9THP4JkOhLsAa+15VdpAqkcUA==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/cytoscape@3.21.0: @@ -4646,7 +4424,7 @@ packages: /@types/express-serve-static-core@4.17.43: resolution: {integrity: sha512-oaYtiBirUOPQGSWNGPWnzyAFJ0BP3cwvN4oWZQY+zUBwpVIGsKUkpBpSztp74drYcjavs7SKFZ4DX1V2QeN8rg==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 '@types/qs': 6.9.12 '@types/range-parser': 1.2.7 '@types/send': 0.17.4 @@ -4673,20 +4451,20 @@ packages: resolution: {integrity: sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==} dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/glob@8.1.0: resolution: {integrity: sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==} dependencies: '@types/minimatch': 5.1.2 - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/graceful-fs@4.1.9: resolution: {integrity: sha512-olP3sd1qOEe5dXTSaFvQG+02VdRXcdytWLAZsAq1PecU8uqQAhkrnbli7DagjtXKW/Bl7YJbUsa8MPcuc8LHEQ==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/http-cache-semantics@4.0.4: @@ -4700,7 +4478,7 @@ packages: /@types/http-proxy@1.17.11: resolution: {integrity: sha512-HC8G7c1WmaF2ekqpnFq626xd3Zz0uvaqFmBJNRZCGEZCXkvSdJoNFn/8Ygbd9fKNQj8UzLdCETaI0UWPAjK7IA==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/istanbul-lib-coverage@2.0.6: @@ -4742,7 +4520,7 @@ packages: /@types/keyv@3.1.4: resolution: {integrity: sha512-BQ5aZNSCpj7D6K2ksrRCTmKRLEpnPvWDiLPfoGyhZ++8YtiK9d/3DBKPJgry359X/P1PfruyYwvnvwFjuEiEIg==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/linkify-it@3.0.5: @@ -4763,6 +4541,10 @@ packages: resolution: {integrity: sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==} dev: true + /@types/lodash@4.17.1: + resolution: {integrity: sha512-X+2qazGS3jxLAIz5JDXDzglAF3KpijdhFxlf/V1+hEsOUc+HnWi81L/uv/EvGuV90WY+7mPGFCUDGfQC3Gj95Q==} + dev: true + /@types/markdown-it@12.2.3: resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==} dependencies: @@ -4770,13 +4552,6 @@ packages: '@types/mdurl': 2.0.0 dev: true - /@types/markdown-it@13.0.8: - resolution: {integrity: sha512-V+KmpgiipS+zoypeUSS9ojesWtY/0k4XfqcK2fnVrX/qInJhX7rsCxZ/rygiPH2zxlPPrhfuW0I6ddMcWTKLsg==} - dependencies: - '@types/linkify-it': 3.0.5 - '@types/mdurl': 1.0.5 - dev: true - /@types/markdown-it@14.0.1: resolution: {integrity: sha512-6WfOG3jXR78DW8L5cTYCVVGAsIFZskRHCDo5tbqa+qtKVt4oDRVH7hyIWu1SpDQJlmIoEivNQZ5h+AGAOrgOtQ==} dependencies: @@ -4824,8 +4599,8 @@ packages: /@types/ms@0.7.34: resolution: {integrity: sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==} - /@types/node@18.19.31: - resolution: {integrity: sha512-ArgCD39YpyyrtFKIqMDvjz79jto5fcI/SVUs2HwB+f0dAzq68yqOdyaSivLiLugSziTpNXLQrVb7RZFmdZzbhA==} + /@types/node@18.19.32: + resolution: {integrity: sha512-2bkg93YBSDKk8DLmmHnmj/Rwr18TLx7/n+I23BigFwgexUJoMHZOd8X1OFxuF/W3NN0S2W2E5sVabI5CPinNvA==} dependencies: undici-types: 5.26.5 dev: true @@ -4836,8 +4611,8 @@ packages: undici-types: 5.26.5 dev: true - /@types/node@20.12.7: - resolution: {integrity: sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==} + /@types/node@20.12.10: + resolution: {integrity: sha512-Eem5pH9pmWBHoGAT8Dr5fdc5rYA+4NAovdM4EktRPVAAiJhmWWfQrA0cFhAbOsQdSfIHjAud6YdkbL69+zSKjw==} dependencies: undici-types: 5.26.5 dev: true @@ -4878,7 +4653,7 @@ packages: /@types/responselike@1.0.3: resolution: {integrity: sha512-H/+L+UkTV33uf49PH5pCAUBVPNj2nDBXTN+qS1dOwyyg24l3CcicicCA7ca+HMvJBZcFgl5r8e+RR6elsb4Lyw==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/retry@0.12.0: @@ -4899,7 +4674,7 @@ packages: resolution: {integrity: sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==} dependencies: '@types/mime': 1.3.5 - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/serve-index@1.9.1: @@ -4913,7 +4688,7 @@ packages: dependencies: '@types/http-errors': 2.0.4 '@types/mime': 3.0.4 - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/sinonjs__fake-timers@8.1.1: @@ -4927,15 +4702,15 @@ packages: /@types/sockjs@0.3.33: resolution: {integrity: sha512-f0KEEe05NvUnat+boPTZ0dgaLZ4SfSouXUgv5noUiefG2ajgKjmETo9ZJyuqsl7dfl2aHlLJUiki6B4ZYldiiw==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/stack-utils@2.0.3: resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} dev: true - /@types/stylis@4.2.5: - resolution: {integrity: sha512-1Xve+NMN7FWjY14vLoY5tL3BVEQ/n42YLwaqJIPYhotZ9uBHt87VceMwWQpzmdEt2TNXIorIFG+YeCUUW7RInw==} + /@types/stylis@4.2.6: + resolution: {integrity: sha512-4nebF2ZJGzQk0ka0O6+FZUWceyFv4vWq/0dXBMmrSeAwzOuOd/GxE5Pa64d/ndeNLG73dXoBsRzvtsVsYUv6Uw==} dev: true /@types/tough-cookie@4.0.5: @@ -4966,7 +4741,7 @@ packages: /@types/ws@8.5.5: resolution: {integrity: sha512-lwhs8hktwxSjf9UaZ9tG5M03PGogvFaH8gUgLNbN9HKIg0dvv6q+gkSuJ8HN4/VbyxkuLzCjlN7GquQ0gUJfIg==} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true /@types/yargs-parser@21.0.3: @@ -4983,7 +4758,7 @@ packages: resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} requiresBuild: true dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 dev: true optional: true @@ -5097,7 +4872,7 @@ packages: debug: 4.3.4(supports-color@8.1.1) globby: 11.1.0 is-glob: 4.0.3 - semver: 7.6.0 + semver: 7.6.1 tsutils: 3.21.0(typescript@5.4.5) typescript: 5.4.5 transitivePeerDependencies: @@ -5140,7 +4915,7 @@ packages: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.4.5) eslint: 8.57.0 eslint-scope: 5.1.1 - semver: 7.6.0 + semver: 7.6.1 transitivePeerDependencies: - supports-color - typescript @@ -5185,7 +4960,7 @@ packages: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} dev: true - /@unocss/astro@0.59.4(rollup@2.79.1)(vite@5.2.10): + /@unocss/astro@0.59.4(rollup@2.79.1)(vite@5.2.11): resolution: {integrity: sha512-DU3OR5MMR1Uvvec4/wB9EetDASHRg19Moy6z/MiIhn8JWJ0QzWYgSeJcfUX8exomMYv6WUEQJL+CyLI34Wmn8w==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 @@ -5195,8 +4970,8 @@ packages: dependencies: '@unocss/core': 0.59.4 '@unocss/reset': 0.59.4 - '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.2.10) - vite: 5.2.10(@types/node@20.12.7) + '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.2.11) + vite: 5.2.11(@types/node@20.12.10) transitivePeerDependencies: - rollup dev: true @@ -5345,9 +5120,9 @@ packages: /@unocss/transformer-attributify-jsx-babel@0.59.4: resolution: {integrity: sha512-xtCRSgeTaDBiNJLVX7oOSFe63JiFB5nrdK23PHn3IlZM9O7Bxx4ZxI3MQJtFZFQNE+INFko+DVyY1WiFEm1p/Q==} dependencies: - '@babel/core': 7.24.4 - '@babel/plugin-syntax-jsx': 7.24.1(@babel/core@7.24.4) - '@babel/preset-typescript': 7.24.1(@babel/core@7.24.4) + '@babel/core': 7.24.5 + '@babel/plugin-syntax-jsx': 7.24.1(@babel/core@7.24.5) + '@babel/preset-typescript': 7.24.1(@babel/core@7.24.5) '@unocss/core': 0.59.4 transitivePeerDependencies: - supports-color @@ -5379,7 +5154,7 @@ packages: '@unocss/core': 0.59.4 dev: true - /@unocss/vite@0.59.4(rollup@2.79.1)(vite@5.2.10): + /@unocss/vite@0.59.4(rollup@2.79.1)(vite@5.2.11): resolution: {integrity: sha512-q7GN7vkQYn79n7vYIUlaa7gXGwc7pk0Qo3z3ZFwWGE43/DtZnn2Hwl5UjgBAgi9McA+xqHJEHRsJnI7HJPHUYA==} peerDependencies: vite: ^2.9.0 || ^3.0.0-0 || ^4.0.0 || ^5.0.0-0 @@ -5394,7 +5169,7 @@ packages: chokidar: 3.6.0 fast-glob: 3.3.2 magic-string: 0.30.10 - vite: 5.2.10(@types/node@20.12.7) + vite: 5.2.11(@types/node@20.12.10) transitivePeerDependencies: - rollup dev: true @@ -5408,7 +5183,7 @@ packages: '@vite-pwa/assets-generator': optional: true dependencies: - vite-plugin-pwa: 0.19.8(vite@5.2.10)(workbox-build@7.1.0)(workbox-window@7.0.0) + vite-plugin-pwa: 0.19.8(vite@5.2.11)(workbox-build@7.1.0)(workbox-window@7.0.0) dev: true /@vitejs/plugin-vue@5.0.4(vite@5.2.10)(vue@3.4.26): @@ -5418,10 +5193,21 @@ packages: vite: ^5.0.0 vue: ^3.2.25 dependencies: - vite: 5.2.10(@types/node@20.12.7) + vite: 5.2.10(@types/node@20.12.10) vue: 3.4.26(typescript@5.4.5) dev: true + /@vitejs/plugin-vue@5.0.4(vite@5.2.11)(vue@3.4.27): + resolution: {integrity: sha512-WS3hevEszI6CEVEx28F8RjTX97k3KsrcY6kvTg7+Whm5y3oYvcqzVeGCU3hxSAn4uY2CLCkeokkGKpoctccilQ==} + engines: {node: ^18.0.0 || >=20.0.0} + peerDependencies: + vite: ^5.0.0 + vue: ^3.2.25 + dependencies: + vite: 5.2.11(@types/node@20.12.10) + vue: 3.4.27(typescript@5.4.5) + dev: true + /@vitest/coverage-v8@1.5.3(vitest@1.5.3): resolution: {integrity: sha512-DPyGSu/fPHOJuPxzFSQoT4N/Fu/2aJfZRtEpEp8GI7NHsXBGE94CQ+pbEGBUMFjatsHPDJw/+TAF9r4ens2CNw==} peerDependencies: @@ -5440,7 +5226,7 @@ packages: std-env: 3.7.0 strip-literal: 2.1.0 test-exclude: 6.0.0 - vitest: 1.5.3(@types/node@20.12.7)(@vitest/ui@1.5.3)(jsdom@24.0.0) + vitest: 1.5.3(@types/node@20.12.10)(@vitest/ui@1.5.3)(jsdom@24.0.0) transitivePeerDependencies: - supports-color dev: true @@ -5487,7 +5273,7 @@ packages: pathe: 1.1.2 picocolors: 1.0.0 sirv: 2.0.4 - vitest: 1.5.3(@types/node@20.12.7)(@vitest/ui@1.5.3)(jsdom@24.0.0) + vitest: 1.5.3(@types/node@20.12.10)(@vitest/ui@1.5.3)(jsdom@24.0.0) dev: true /@vitest/utils@1.5.3: @@ -5528,6 +5314,16 @@ packages: entities: 4.5.0 estree-walker: 2.0.2 source-map-js: 1.2.0 + dev: true + + /@vue/compiler-core@3.4.27: + resolution: {integrity: sha512-E+RyqY24KnyDXsCuQrI+mlcdW3ALND6U7Gqa/+bVwbcpcR3BRRIckFoz7Qyd4TTlnugtwuI7YgjbvsLmxb+yvg==} + dependencies: + '@babel/parser': 7.24.5 + '@vue/shared': 3.4.27 + entities: 4.5.0 + estree-walker: 2.0.2 + source-map-js: 1.2.0 /@vue/compiler-dom@3.4.21: resolution: {integrity: sha512-IZC6FKowtT1sl0CR5DpXSiEB5ayw75oT2bma1BEhV7RRR1+cfwLrxc2Z8Zq/RGFzJ8w5r9QtCOvTjQgdn0IKmA==} @@ -5541,6 +5337,13 @@ packages: dependencies: '@vue/compiler-core': 3.4.26 '@vue/shared': 3.4.26 + dev: true + + /@vue/compiler-dom@3.4.27: + resolution: {integrity: sha512-kUTvochG/oVgE1w5ViSr3KUBh9X7CWirebA3bezTbB5ZKBQZwR2Mwj9uoSKRMFcz4gSMzzLXBPD6KpCLb9nvWw==} + dependencies: + '@vue/compiler-core': 3.4.27 + '@vue/shared': 3.4.27 /@vue/compiler-sfc@3.4.21: resolution: {integrity: sha512-me7epoTxYlY+2CUM7hy9PCDdpMPfIwrOvAXud2Upk10g4YLv9UBW7kL798TvMeDhPthkZ0CONNrK2GoeI1ODiQ==} @@ -5568,6 +5371,20 @@ packages: magic-string: 0.30.10 postcss: 8.4.38 source-map-js: 1.2.0 + dev: true + + /@vue/compiler-sfc@3.4.27: + resolution: {integrity: sha512-nDwntUEADssW8e0rrmE0+OrONwmRlegDA1pD6QhVeXxjIytV03yDqTey9SBDiALsvAd5U4ZrEKbMyVXhX6mCGA==} + dependencies: + '@babel/parser': 7.24.5 + '@vue/compiler-core': 3.4.27 + '@vue/compiler-dom': 3.4.27 + '@vue/compiler-ssr': 3.4.27 + '@vue/shared': 3.4.27 + estree-walker: 2.0.2 + magic-string: 0.30.10 + postcss: 8.4.38 + source-map-js: 1.2.0 /@vue/compiler-ssr@3.4.21: resolution: {integrity: sha512-M5+9nI2lPpAsgXOGQobnIueVqc9sisBFexh5yMIMRAPYLa7+5wEJs8iqOZc1WAa9WQbx9GR2twgznU8LTIiZ4Q==} @@ -5581,6 +5398,13 @@ packages: dependencies: '@vue/compiler-dom': 3.4.26 '@vue/shared': 3.4.26 + dev: true + + /@vue/compiler-ssr@3.4.27: + resolution: {integrity: sha512-CVRzSJIltzMG5FcidsW0jKNQnNRYC8bT21VegyMMtHmhW3UOI7knmUehzswXLrExDLE6lQCZdrhD4ogI7c+vuw==} + dependencies: + '@vue/compiler-dom': 3.4.27 + '@vue/shared': 3.4.27 /@vue/devtools-api@6.6.1: resolution: {integrity: sha512-LgPscpE3Vs0x96PzSSB4IGVSZXZBZHpfxs+ZA1d+VEPwHdOXowy/Y2CsvCAIFrf+ssVU1pD1jidj505EpUnfbA==} @@ -5623,6 +5447,12 @@ packages: resolution: {integrity: sha512-E/ynEAu/pw0yotJeLdvZEsp5Olmxt+9/WqzvKff0gE67tw73gmbx6tRkiagE/eH0UCubzSlGRebCbidB1CpqZQ==} dependencies: '@vue/shared': 3.4.26 + dev: true + + /@vue/reactivity@3.4.27: + resolution: {integrity: sha512-kK0g4NknW6JX2yySLpsm2jlunZJl2/RJGZ0H9ddHdfBVHcNzxmQ0sS0b09ipmBoQpY8JM2KmUw+a6sO8Zo+zIA==} + dependencies: + '@vue/shared': 3.4.27 /@vue/runtime-core@3.4.21: resolution: {integrity: sha512-pQthsuYzE1XcGZznTKn73G0s14eCJcjaLvp3/DKeYWoFacD9glJoqlNBxt3W2c5S40t6CCcpPf+jG01N3ULyrA==} @@ -5636,6 +5466,13 @@ packages: dependencies: '@vue/reactivity': 3.4.26 '@vue/shared': 3.4.26 + dev: true + + /@vue/runtime-core@3.4.27: + resolution: {integrity: sha512-7aYA9GEbOOdviqVvcuweTLe5Za4qBZkUY7SvET6vE8kyypxVgaT1ixHLg4urtOlrApdgcdgHoTZCUuTGap/5WA==} + dependencies: + '@vue/reactivity': 3.4.27 + '@vue/shared': 3.4.27 /@vue/runtime-dom@3.4.21: resolution: {integrity: sha512-gvf+C9cFpevsQxbkRBS1NpU8CqxKw0ebqMvLwcGQrNpx6gqRDodqKqA+A2VZZpQ9RpK2f9yfg8VbW/EpdFUOJw==} @@ -5651,6 +5488,14 @@ packages: '@vue/runtime-core': 3.4.26 '@vue/shared': 3.4.26 csstype: 3.1.3 + dev: true + + /@vue/runtime-dom@3.4.27: + resolution: {integrity: sha512-ScOmP70/3NPM+TW9hvVAz6VWWtZJqkbdf7w6ySsws+EsqtHvkhxaWLecrTorFxsawelM5Ys9FnDEMt6BPBDS0Q==} + dependencies: + '@vue/runtime-core': 3.4.27 + '@vue/shared': 3.4.27 + csstype: 3.1.3 /@vue/server-renderer@3.4.21(vue@3.4.21): resolution: {integrity: sha512-aV1gXyKSN6Rz+6kZ6kr5+Ll14YzmIbeuWe7ryJl5muJ4uwSwY/aStXTixx76TwkZFJLm1aAlA/HSWEJ4EyiMkg==} @@ -5670,6 +5515,16 @@ packages: '@vue/compiler-ssr': 3.4.26 '@vue/shared': 3.4.26 vue: 3.4.26(typescript@5.4.5) + dev: true + + /@vue/server-renderer@3.4.27(vue@3.4.27): + resolution: {integrity: sha512-dlAMEuvmeA3rJsOMJ2J1kXU7o7pOxgsNHVr9K8hB3ImIkSuBrIdy0vF66h8gf8Tuinf1TK3mPAz2+2sqyf3KzA==} + peerDependencies: + vue: 3.4.27 + dependencies: + '@vue/compiler-ssr': 3.4.27 + '@vue/shared': 3.4.27 + vue: 3.4.27(typescript@5.4.5) /@vue/shared@3.4.21: resolution: {integrity: sha512-PuJe7vDIi6VYSinuEbUIQgMIRZGgM8e4R+G+/dQTk0X1NEdvgvvgv7m+rfmDH1gZzyA1OjjoWskvHlfRNfQf3g==} @@ -5677,6 +5532,10 @@ packages: /@vue/shared@3.4.26: resolution: {integrity: sha512-Fg4zwR0GNnjzodMt3KRy2AWGMKQXByl56+4HjN87soxLNU9P5xcJkstAlIeEF3cU6UYOzmJl1tV0dVPGIljCnQ==} + dev: true + + /@vue/shared@3.4.27: + resolution: {integrity: sha512-DL3NmY2OFlqmYYrzp39yi3LDkKxa5vZVwxWdQ3rG0ekuWscHraeIbnI8t+aZK7qhYqEqWKTUdijadunb9pnrgA==} /@vueuse/core@10.9.0(vue@3.4.26): resolution: {integrity: sha512-/1vjTol8SXnx6xewDEKfS0Ra//ncg4Hb0DaZiwKf7drgfMsKFExQ+FnnENcN6efPen+1kIzhLQoGSy0eDUVOMg==} @@ -5688,6 +5547,19 @@ packages: transitivePeerDependencies: - '@vue/composition-api' - vue + dev: true + + /@vueuse/core@10.9.0(vue@3.4.27): + resolution: {integrity: sha512-/1vjTol8SXnx6xewDEKfS0Ra//ncg4Hb0DaZiwKf7drgfMsKFExQ+FnnENcN6efPen+1kIzhLQoGSy0eDUVOMg==} + dependencies: + '@types/web-bluetooth': 0.0.20 + '@vueuse/metadata': 10.9.0 + '@vueuse/shared': 10.9.0(vue@3.4.27) + vue-demi: 0.14.7(vue@3.4.27) + transitivePeerDependencies: + - '@vue/composition-api' + - vue + dev: false /@vueuse/integrations@10.9.0(focus-trap@7.5.4)(vue@3.4.26): resolution: {integrity: sha512-acK+A01AYdWSvL4BZmCoJAcyHJ6EqhmkQEXbQLwev1MY7NBnS+hcEMx/BzVoR9zKI+UqEPMD9u6PsyAuiTRT4Q==} @@ -5749,6 +5621,16 @@ packages: transitivePeerDependencies: - '@vue/composition-api' - vue + dev: true + + /@vueuse/shared@10.9.0(vue@3.4.27): + resolution: {integrity: sha512-Uud2IWncmAfJvRaFYzv5OHDli+FbOzxiVEQdLCKQKLyhz94PIyFC3CHcH7EDMwIn8NPtD06+PNbC/PiO0LGLtw==} + dependencies: + vue-demi: 0.14.7(vue@3.4.27) + transitivePeerDependencies: + - '@vue/composition-api' + - vue + dev: false /@wdio/config@7.31.1(typescript@5.4.5): resolution: {integrity: sha512-WAfswbCatwiaDVqy6kfF/5T8/WS/US/SRhBGUFrfBuGMIe+RRoHgy7jURFWSvUIE7CNHj8yvs46fLUcxhXjzcQ==} @@ -5788,7 +5670,7 @@ packages: typescript: optional: true dependencies: - '@types/node': 18.19.31 + '@types/node': 18.19.32 got: 11.8.6 typescript: 5.4.5 dev: true @@ -6404,17 +6286,17 @@ packages: - debug dev: true - /babel-jest@29.7.0(@babel/core@7.24.4): + /babel-jest@29.7.0(@babel/core@7.24.5): resolution: {integrity: sha512-BrvGY3xZSwEcCzKvKsCi2GgHqDqsYkOP4/by5xCgIwGXQxIEh+8ew3gmrE1y7XRR6LHZIj6yLYnUi/mm2KXKBg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: '@babel/core': ^7.8.0 dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@jest/transform': 29.7.0 '@types/babel__core': 7.20.5 babel-plugin-istanbul: 6.1.1 - babel-preset-jest: 29.6.3(@babel/core@7.24.4) + babel-preset-jest: 29.6.3(@babel/core@7.24.5) chalk: 4.1.2 graceful-fs: 4.2.11 slash: 3.0.0 @@ -6494,35 +6376,35 @@ packages: - supports-color dev: true - /babel-preset-current-node-syntax@1.0.1(@babel/core@7.24.4): + /babel-preset-current-node-syntax@1.0.1(@babel/core@7.24.5): resolution: {integrity: sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/core': 7.24.4 - '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.24.4) - '@babel/plugin-syntax-bigint': 7.8.3(@babel/core@7.24.4) - '@babel/plugin-syntax-class-properties': 7.12.13(@babel/core@7.24.4) - '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.24.4) - '@babel/plugin-syntax-json-strings': 7.8.3(@babel/core@7.24.4) - '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/core@7.24.4) - '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.24.4) - '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/core@7.24.4) - '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.24.4) - '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.24.4) - '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.24.4) - '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.24.4) - dev: true - - /babel-preset-jest@29.6.3(@babel/core@7.24.4): + '@babel/core': 7.24.5 + '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.24.5) + '@babel/plugin-syntax-bigint': 7.8.3(@babel/core@7.24.5) + '@babel/plugin-syntax-class-properties': 7.12.13(@babel/core@7.24.5) + '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.24.5) + '@babel/plugin-syntax-json-strings': 7.8.3(@babel/core@7.24.5) + '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/core@7.24.5) + '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.24.5) + '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/core@7.24.5) + '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.24.5) + '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.24.5) + '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.24.5) + '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.24.5) + dev: true + + /babel-preset-jest@29.6.3(@babel/core@7.24.5): resolution: {integrity: sha512-0B3bhxR6snWXJZtR/RliHTDPRgn1sNHOR0yVtq/IiQFyuOVjFS+wuio/R4gSNkyYmKmJB4wGZv2NZanmKmTnNA==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: '@babel/core': ^7.0.0 dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 babel-plugin-jest-hoist: 29.6.3 - babel-preset-current-node-syntax: 1.0.1(@babel/core@7.24.4) + babel-preset-current-node-syntax: 1.0.1(@babel/core@7.24.5) dev: true /bail@2.0.2: @@ -7368,7 +7250,7 @@ packages: p-map: 6.0.0 dev: true - /create-jest@29.7.0(@types/node@20.12.7): + /create-jest@29.7.0(@types/node@20.12.10): resolution: {integrity: sha512-Adz2bdH0Vq3F53KEMJOoftQFutWCukm6J24wbPWRO4k1kMY7gS7ds/uoJkNuV8wDCtWWnuwGcJwpWcih+zEW1Q==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -7377,7 +7259,7 @@ packages: chalk: 4.1.2 exit: 0.1.2 graceful-fs: 4.2.11 - jest-config: 29.7.0(@types/node@20.12.7) + jest-config: 29.7.0(@types/node@20.12.10) jest-util: 29.7.0 prompts: 2.4.2 transitivePeerDependencies: @@ -8670,7 +8552,7 @@ packages: '@typescript-eslint/eslint-plugin': 7.6.0(@typescript-eslint/parser@7.6.0)(eslint@8.57.0)(typescript@5.4.5) '@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.4.5) eslint: 8.57.0 - jest: 29.7.0(@types/node@20.12.7) + jest: 29.7.0(@types/node@20.12.10) transitivePeerDependencies: - supports-color - typescript @@ -10713,7 +10595,7 @@ packages: resolution: {integrity: sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==} engines: {node: '>=8'} dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.0 semver: 6.3.1 @@ -10725,7 +10607,7 @@ packages: resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==} engines: {node: '>=8'} dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@babel/parser': 7.24.5 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.2 @@ -10738,11 +10620,11 @@ packages: resolution: {integrity: sha512-1WUsZ9R1lA0HtBSohTkm39WTPlNKSJ5iFk7UwqXkBLoHQT+hfqPsfsTDVuZdKGaBwn7din9bS7SsnoAr943hvw==} engines: {node: '>=10'} dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@babel/parser': 7.24.5 '@istanbuljs/schema': 0.1.3 istanbul-lib-coverage: 3.2.2 - semver: 7.6.0 + semver: 7.6.1 transitivePeerDependencies: - supports-color dev: true @@ -10763,7 +10645,7 @@ packages: resolution: {integrity: sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==} engines: {node: '>=10'} dependencies: - istanbul-lib-coverage: 3.2.0 + istanbul-lib-coverage: 3.2.2 make-dir: 4.0.0 supports-color: 7.2.0 dev: true @@ -10850,7 +10732,7 @@ packages: '@jest/expect': 29.7.0 '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 chalk: 4.1.2 co: 4.6.0 dedent: 1.5.1 @@ -10871,7 +10753,7 @@ packages: - supports-color dev: true - /jest-cli@29.7.0(@types/node@20.12.7): + /jest-cli@29.7.0(@types/node@20.12.10): resolution: {integrity: sha512-OVVobw2IubN/GSYsxETi+gOe7Ka59EFMR/twOU3Jb2GnKKeMGJB5SGUUrEz3SFVmJASUdZUzy83sLNNQ2gZslg==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -10885,10 +10767,10 @@ packages: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 chalk: 4.1.2 - create-jest: 29.7.0(@types/node@20.12.7) + create-jest: 29.7.0(@types/node@20.12.10) exit: 0.1.2 import-local: 3.1.0 - jest-config: 29.7.0(@types/node@20.12.7) + jest-config: 29.7.0(@types/node@20.12.10) jest-util: 29.7.0 jest-validate: 29.7.0 yargs: 17.7.2 @@ -10899,7 +10781,7 @@ packages: - ts-node dev: true - /jest-config@29.7.0(@types/node@20.12.7): + /jest-config@29.7.0(@types/node@20.12.10): resolution: {integrity: sha512-uXbpfeQ7R6TZBqI3/TxCU4q4ttk3u0PJeC+E0zbfSoSjq6bJ7buBPxzQPL0ifrkY4DNu4JUdk0ImlBUYi840eQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} peerDependencies: @@ -10911,11 +10793,11 @@ packages: ts-node: optional: true dependencies: - '@babel/core': 7.24.4 + '@babel/core': 7.24.5 '@jest/test-sequencer': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.7 - babel-jest: 29.7.0(@babel/core@7.24.4) + '@types/node': 20.12.10 + babel-jest: 29.7.0(@babel/core@7.24.5) chalk: 4.1.2 ci-info: 3.9.0 deepmerge: 4.3.1 @@ -10974,7 +10856,7 @@ packages: '@jest/environment': 29.7.0 '@jest/fake-timers': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 jest-mock: 29.7.0 jest-util: 29.7.0 dev: true @@ -10990,7 +10872,7 @@ packages: dependencies: '@jest/types': 29.6.3 '@types/graceful-fs': 4.1.9 - '@types/node': 20.12.7 + '@types/node': 20.12.10 anymatch: 3.1.3 fb-watchman: 2.0.2 graceful-fs: 4.2.11 @@ -11012,7 +10894,7 @@ packages: chalk: 1.1.3 get-stdin: 5.0.1 glur: 1.1.2 - jest: 29.7.0(@types/node@20.12.7) + jest: 29.7.0(@types/node@20.12.10) lodash: 4.17.21 mkdirp: 0.5.6 pixelmatch: 5.3.0 @@ -11059,7 +10941,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 jest-util: 29.7.0 dev: true @@ -11114,7 +10996,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 chalk: 4.1.2 emittery: 0.13.1 graceful-fs: 4.2.11 @@ -11145,7 +11027,7 @@ packages: '@jest/test-result': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 chalk: 4.1.2 cjs-module-lexer: 1.2.3 collect-v8-coverage: 1.0.2 @@ -11168,15 +11050,15 @@ packages: resolution: {integrity: sha512-Rm0BMWtxBcioHr1/OX5YCP8Uov4riHvKPknOGs804Zg9JGZgmIBkbtlxJC/7Z4msKYVbIJtfU+tKb8xlYNfdkw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@babel/core': 7.24.4 - '@babel/generator': 7.24.4 - '@babel/plugin-syntax-jsx': 7.24.1(@babel/core@7.24.4) - '@babel/plugin-syntax-typescript': 7.24.1(@babel/core@7.24.4) + '@babel/core': 7.24.5 + '@babel/generator': 7.24.5 + '@babel/plugin-syntax-jsx': 7.24.1(@babel/core@7.24.5) + '@babel/plugin-syntax-typescript': 7.24.1(@babel/core@7.24.5) '@babel/types': 7.24.5 '@jest/expect-utils': 29.7.0 '@jest/transform': 29.7.0 '@jest/types': 29.6.3 - babel-preset-current-node-syntax: 1.0.1(@babel/core@7.24.4) + babel-preset-current-node-syntax: 1.0.1(@babel/core@7.24.5) chalk: 4.1.2 expect: 29.7.0 graceful-fs: 4.2.11 @@ -11187,7 +11069,7 @@ packages: jest-util: 29.7.0 natural-compare: 1.4.0 pretty-format: 29.7.0 - semver: 7.6.0 + semver: 7.6.1 transitivePeerDependencies: - supports-color dev: true @@ -11197,7 +11079,7 @@ packages: engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 chalk: 4.1.2 ci-info: 3.9.0 graceful-fs: 4.2.11 @@ -11222,7 +11104,7 @@ packages: dependencies: '@jest/test-result': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.12.7 + '@types/node': 20.12.10 ansi-escapes: 4.3.2 chalk: 4.1.2 emittery: 0.13.1 @@ -11234,7 +11116,7 @@ packages: resolution: {integrity: sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==} engines: {node: '>= 10.13.0'} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true @@ -11243,13 +11125,13 @@ packages: resolution: {integrity: sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 jest-util: 29.7.0 merge-stream: 2.0.0 supports-color: 8.1.1 dev: true - /jest@29.7.0(@types/node@20.12.7): + /jest@29.7.0(@types/node@20.12.10): resolution: {integrity: sha512-NIy3oAFp9shda19hy4HK0HRTWKtPJmGdnvywu01nOqNC2vZg+Z+fvJDxpMQA88eb2I9EcafcdjYgsDthnYTvGw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -11262,7 +11144,7 @@ packages: '@jest/core': 29.7.0 '@jest/types': 29.6.3 import-local: 3.1.0 - jest-cli: 29.7.0(@types/node@20.12.7) + jest-cli: 29.7.0(@types/node@20.12.10) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -11547,8 +11429,8 @@ packages: engines: {node: '>=12'} dev: true - /langium-cli@3.0.1: - resolution: {integrity: sha512-s1R/4GKkWItfu2o05DxqP71ID5MiGqb1BfXyPeFvIO3+aRSCj6fCj9EXtasvf18lSTUe27H37aO66TNU9VRr+Q==} + /langium-cli@3.0.3: + resolution: {integrity: sha512-g6PdhEq5IiYWK/oiySILglPvFdK6ofQdzC+U7PJmFH++bDKu0DGdxjWzDauUN5WUDyVQETWKgtYDmmbcxPzN0w==} engines: {node: '>=16.0.0'} hasBin: true dependencies: @@ -11895,7 +11777,7 @@ packages: resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} engines: {node: '>=10'} dependencies: - semver: 7.6.0 + semver: 7.6.1 dev: true /makeerror@1.0.12: @@ -12990,7 +12872,7 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} dependencies: - '@babel/code-frame': 7.23.5 + '@babel/code-frame': 7.24.2 error-ex: 1.3.2 json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 @@ -14046,6 +13928,12 @@ packages: lru-cache: 6.0.0 dev: true + /semver@7.6.1: + resolution: {integrity: sha512-f/vbBsu+fOiYt+lmwZV0rVwJScl46HppnOA1ZvIuBWKOTlllpyJ3bfVax76/OrhCH38dyxoDIA8K7uB963IYgA==} + engines: {node: '>=10'} + hasBin: true + dev: true + /send@0.18.0: resolution: {integrity: sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==} engines: {node: '>= 0.8.0'} @@ -15359,7 +15247,7 @@ packages: engines: {node: '>= 10.0.0'} dev: true - /unocss@0.59.4(postcss@8.4.38)(rollup@2.79.1)(vite@5.2.10): + /unocss@0.59.4(postcss@8.4.38)(rollup@2.79.1)(vite@5.2.11): resolution: {integrity: sha512-QmCVjRObvVu/gsGrJGVt0NnrdhFFn314BUZn2WQyXV9rIvHLRmG5bIu0j5vibJkj7ZhFchTrnTM1pTFXP1xt5g==} engines: {node: '>=14'} peerDependencies: @@ -15371,7 +15259,7 @@ packages: vite: optional: true dependencies: - '@unocss/astro': 0.59.4(rollup@2.79.1)(vite@5.2.10) + '@unocss/astro': 0.59.4(rollup@2.79.1)(vite@5.2.11) '@unocss/cli': 0.59.4(rollup@2.79.1) '@unocss/core': 0.59.4 '@unocss/extractor-arbitrary-variants': 0.59.4 @@ -15390,8 +15278,8 @@ packages: '@unocss/transformer-compile-class': 0.59.4 '@unocss/transformer-directives': 0.59.4 '@unocss/transformer-variant-group': 0.59.4 - '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.2.10) - vite: 5.2.10(@types/node@20.12.7) + '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.2.11) + vite: 5.2.11(@types/node@20.12.10) transitivePeerDependencies: - postcss - rollup @@ -15403,7 +15291,7 @@ packages: engines: {node: '>= 0.8'} dev: true - /unplugin-vue-components@0.26.0(rollup@2.79.1)(vue@3.4.26): + /unplugin-vue-components@0.26.0(rollup@2.79.1)(vue@3.4.27): resolution: {integrity: sha512-s7IdPDlnOvPamjunVxw8kNgKNK8A5KM1YpK5j/p97jEKTjlPNrA0nZBiSfAKKlK1gWZuyWXlKL5dk3EDw874LQ==} engines: {node: '>=14'} peerDependencies: @@ -15426,7 +15314,7 @@ packages: minimatch: 9.0.3 resolve: 1.22.4 unplugin: 1.4.0 - vue: 3.4.26(typescript@5.4.5) + vue: 3.4.27(typescript@5.4.5) transitivePeerDependencies: - rollup - supports-color @@ -15538,7 +15426,7 @@ packages: vfile-message: 4.0.2 dev: true - /vite-node@1.5.3(@types/node@20.12.7): + /vite-node@1.5.3(@types/node@20.12.10): resolution: {integrity: sha512-axFo00qiCpU/JLd8N1gu9iEYL3xTbMbMrbe5nDp9GL0nb6gurIdZLkkFogZXWnE8Oyy5kfSLwNVIcVsnhE7lgQ==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -15547,7 +15435,7 @@ packages: debug: 4.3.4(supports-color@8.1.1) pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.2.10(@types/node@20.12.7) + vite: 5.2.11(@types/node@20.12.10) transitivePeerDependencies: - '@types/node' - less @@ -15559,8 +15447,8 @@ packages: - terser dev: true - /vite-plugin-istanbul@6.0.0(vite@5.2.10): - resolution: {integrity: sha512-Vwh2XdesjcLwaPbHSOiWHh+0s7CNovQTPEjUCTkqmJUe0FN2TKsOp0qpoaklOuwrKlL9elhD5fPFxi5lmG62zA==} + /vite-plugin-istanbul@6.0.2(vite@5.2.11): + resolution: {integrity: sha512-0/sKwjEEIwbEyl43xX7onX3dIbMJAsigNsKyyVPalG1oRFo5jn3qkJbS2PUfp9wrr3piy1eT6qRoeeum2p4B2A==} peerDependencies: vite: '>=4 <=6' dependencies: @@ -15570,12 +15458,12 @@ packages: picocolors: 1.0.0 source-map: 0.7.4 test-exclude: 6.0.0 - vite: 5.2.10(@types/node@20.12.7) + vite: 5.2.11(@types/node@20.12.10) transitivePeerDependencies: - supports-color dev: true - /vite-plugin-pwa@0.19.8(vite@5.2.10)(workbox-build@7.1.0)(workbox-window@7.0.0): + /vite-plugin-pwa@0.19.8(vite@5.2.11)(workbox-build@7.1.0)(workbox-window@7.0.0): resolution: {integrity: sha512-e1oK0dfhzhDhY3VBuML6c0h8Xfx6EkOVYqolj7g+u8eRfdauZe5RLteCIA/c5gH0CBQ0CNFAuv/AFTx4Z7IXTw==} engines: {node: '>=16.0.0'} peerDependencies: @@ -15590,14 +15478,14 @@ packages: debug: 4.3.4(supports-color@8.1.1) fast-glob: 3.3.2 pretty-bytes: 6.1.1 - vite: 5.2.10(@types/node@20.12.7) + vite: 5.2.11(@types/node@20.12.10) workbox-build: 7.1.0 workbox-window: 7.0.0 transitivePeerDependencies: - supports-color dev: true - /vite@5.2.10(@types/node@20.12.7): + /vite@5.2.10(@types/node@20.12.10): resolution: {integrity: sha512-PAzgUZbP7msvQvqdSD+ErD5qGnSFiGOoWmV5yAKUEI0kdhjbH6nMWVyZQC/hSc4aXwc0oJ9aEdIiF9Oje0JFCw==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -15625,7 +15513,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 esbuild: 0.20.2 postcss: 8.4.38 rollup: 4.17.2 @@ -15633,7 +15521,43 @@ packages: fsevents: 2.3.3 dev: true - /vitepress-plugin-search@1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4)(vue@3.4.26): + /vite@5.2.11(@types/node@20.12.10): + resolution: {integrity: sha512-HndV31LWW05i1BLPMUCE1B9E9GFbOu1MbenhS58FuK6owSO5qHm7GiCotrNY1YE5rMeQSFBGmT5ZaLEjFizgiQ==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + peerDependencies: + '@types/node': ^18.0.0 || >=20.0.0 + less: '*' + lightningcss: ^1.21.0 + sass: '*' + stylus: '*' + sugarss: '*' + terser: ^5.4.0 + peerDependenciesMeta: + '@types/node': + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + dependencies: + '@types/node': 20.12.10 + esbuild: 0.20.2 + postcss: 8.4.38 + rollup: 4.17.2 + optionalDependencies: + fsevents: 2.3.3 + dev: true + + /vitepress-plugin-search@1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4)(vue@3.4.27): resolution: {integrity: sha512-IAOEJu+kjVY+0pb6/PeRjIbr175HFFbnMdLmLjqcy7VWxkabIRZbLoQL1VUYDZl804o/Or+GaX02gsiMOnVxFA==} engines: {node: ^14.13.1 || ^16.7.0 || >=18} peerDependencies: @@ -15646,67 +15570,11 @@ packages: flexsearch: 0.7.43 glob-to-regexp: 0.4.1 markdown-it: 13.0.1 - vitepress: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(search-insights@2.13.0)(typescript@5.4.5) - vue: 3.4.26(typescript@5.4.5) - dev: true - - /vitepress@1.1.0(@algolia/client-search@4.23.3)(@types/node@20.12.7)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5): - resolution: {integrity: sha512-G+NS5I2OETxC0SfGAMDO75JWNkrcir0UCptuhQMNoaZhhlqvYtTDQhph4qGc5dtiTtZkcFa/bCcSx+A2gSS3lA==} - hasBin: true - peerDependencies: - markdown-it-mathjax3: ^4 - postcss: ^8 - peerDependenciesMeta: - markdown-it-mathjax3: - optional: true - postcss: - optional: true - dependencies: - '@docsearch/css': 3.6.0 - '@docsearch/js': 3.6.0(@algolia/client-search@4.23.3)(search-insights@2.13.0) - '@shikijs/core': 1.4.0 - '@shikijs/transformers': 1.4.0 - '@types/markdown-it': 13.0.8 - '@vitejs/plugin-vue': 5.0.4(vite@5.2.10)(vue@3.4.26) - '@vue/devtools-api': 7.1.3(vue@3.4.26) - '@vueuse/core': 10.9.0(vue@3.4.26) - '@vueuse/integrations': 10.9.0(focus-trap@7.5.4)(vue@3.4.26) - focus-trap: 7.5.4 - mark.js: 8.11.1 - minisearch: 6.3.0 - postcss: 8.4.38 - shiki: 1.4.0 - vite: 5.2.10(@types/node@20.12.7) - vue: 3.4.26(typescript@5.4.5) - transitivePeerDependencies: - - '@algolia/client-search' - - '@types/node' - - '@types/react' - - '@vue/composition-api' - - async-validator - - axios - - change-case - - drauu - - fuse.js - - idb-keyval - - jwt-decode - - less - - lightningcss - - nprogress - - qrcode - - react - - react-dom - - sass - - search-insights - - sortablejs - - stylus - - sugarss - - terser - - typescript - - universal-cookie + vitepress: 1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.10)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5) + vue: 3.4.27(typescript@5.4.5) dev: true - /vitepress@1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.7)(search-insights@2.13.0)(typescript@5.4.5): + /vitepress@1.1.4(@algolia/client-search@4.23.3)(@types/node@20.12.10)(postcss@8.4.38)(search-insights@2.13.0)(typescript@5.4.5): resolution: {integrity: sha512-bWIzFZXpPB6NIDBuWnS20aMADH+FcFKDfQNYFvbOWij03PR29eImTceQHIzCKordjXYBhM/TjE5VKFTUJ3EheA==} hasBin: true peerDependencies: @@ -15730,8 +15598,9 @@ packages: focus-trap: 7.5.4 mark.js: 8.11.1 minisearch: 6.3.0 + postcss: 8.4.38 shiki: 1.4.0 - vite: 5.2.10(@types/node@20.12.7) + vite: 5.2.10(@types/node@20.12.10) vue: 3.4.26(typescript@5.4.5) transitivePeerDependencies: - '@algolia/client-search' @@ -15761,7 +15630,7 @@ packages: - universal-cookie dev: true - /vitest@1.5.3(@types/node@20.12.7)(@vitest/ui@1.5.3)(jsdom@24.0.0): + /vitest@1.5.3(@types/node@20.12.10)(@vitest/ui@1.5.3)(jsdom@24.0.0): resolution: {integrity: sha512-2oM7nLXylw3mQlW6GXnRriw+7YvZFk/YNV8AxIC3Z3MfFbuziLGWP9GPxxu/7nRlXhqyxBikpamr+lEEj1sUEw==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -15786,7 +15655,7 @@ packages: jsdom: optional: true dependencies: - '@types/node': 20.12.7 + '@types/node': 20.12.10 '@vitest/expect': 1.5.3 '@vitest/runner': 1.5.3 '@vitest/snapshot': 1.5.3 @@ -15806,8 +15675,8 @@ packages: strip-literal: 2.1.0 tinybench: 2.8.0 tinypool: 0.8.4 - vite: 5.2.10(@types/node@20.12.7) - vite-node: 1.5.3(@types/node@20.12.7) + vite: 5.2.11(@types/node@20.12.10) + vite-node: 1.5.3(@types/node@20.12.10) why-is-node-running: 2.2.2 transitivePeerDependencies: - less @@ -15898,6 +15767,22 @@ packages: optional: true dependencies: vue: 3.4.26(typescript@5.4.5) + dev: true + + /vue-demi@0.14.7(vue@3.4.27): + resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + peerDependencies: + '@vue/composition-api': ^1.0.0-rc.1 + vue: ^3.0.0-0 || ^2.6.0 + peerDependenciesMeta: + '@vue/composition-api': + optional: true + dependencies: + vue: 3.4.27(typescript@5.4.5) + dev: false /vue@3.4.21(typescript@5.4.5): resolution: {integrity: sha512-5hjyV/jLEIKD/jYl4cavMcnzKwjMKohureP8ejn3hhEjwhWIhWeuzL2kJAjzl/WyVsgPY56Sy4Z40C3lVshxXA==} @@ -15929,6 +15814,22 @@ packages: '@vue/server-renderer': 3.4.26(vue@3.4.26) '@vue/shared': 3.4.26 typescript: 5.4.5 + dev: true + + /vue@3.4.27(typescript@5.4.5): + resolution: {integrity: sha512-8s/56uK6r01r1icG/aEOHqyMVxd1bkYcSe9j8HcKtr/xTOFWvnzIVTehNW+5Yt89f+DLBe4A569pnZLS5HzAMA==} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + '@vue/compiler-dom': 3.4.27 + '@vue/compiler-sfc': 3.4.27 + '@vue/runtime-dom': 3.4.27 + '@vue/server-renderer': 3.4.27(vue@3.4.27) + '@vue/shared': 3.4.27 + typescript: 5.4.5 /vuex@4.1.0(vue@3.4.21): resolution: {integrity: sha512-hmV6UerDrPcgbSy9ORAtNXDr9M4wlNP4pEFKye4ujJF8oqgFFuxDCdOLS3eNoRTtq5O3hoBDh9Doj1bQMYHRbQ==} @@ -15989,7 +15890,7 @@ packages: resolution: {integrity: sha512-nCdJLxRnYvOMFqTEX7sqQtF/hV/Jgov0Y6ICeOm1DMTlZSRRDaUsBMlEAPkEwif9uBJYdM0znv8qzfX358AGqQ==} engines: {node: '>=12.0.0'} dependencies: - '@types/node': 18.19.31 + '@types/node': 18.19.32 '@wdio/config': 7.31.1(typescript@5.4.5) '@wdio/logger': 7.26.0 '@wdio/protocols': 7.27.0 From 3274f673ab1d8ed873a8c2d71161bd82df85a5b7 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 13 May 2024 08:46:13 +0530 Subject: [PATCH 32/50] chore: Ignore `vite.config.ts.timestamp-` --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index a0fd1c50b8..7948faee49 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,7 @@ demos/dev/** !/demos/dev/example.html !/demos/dev/reload.js tsx-0/** +vite.config.ts.timestamp-* # autogenereated by langium-cli -generated/ \ No newline at end of file +generated/ From 4885b311f8562ecf5cc06e95b21309d8a73030cd Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 13 May 2024 08:47:23 +0530 Subject: [PATCH 33/50] chore: Build config types before building types --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 393677907f..369fa31624 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build:esbuild": "pnpm run -r clean && tsx .esbuild/build.ts", "build:mermaid": "pnpm build:esbuild --mermaid", "build:viz": "pnpm build:esbuild --visualize", - "build:types": "tsx .build/types.ts", + "build:types": "pnpm --filter mermaid types:build-config && tsx .build/types.ts", "build:types:watch": "tsc -p ./packages/mermaid/tsconfig.json --emitDeclarationOnly --watch", "dev": "tsx .esbuild/server.ts", "dev:vite": "tsx .vite/server.ts", From c993adfcdb528248cb685d8a3d7a6f97acf7565e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 13 May 2024 10:14:28 +0530 Subject: [PATCH 34/50] chore: remove unrefSubSchemas --- .../scripts/create-types-from-json-schema.mts | 80 +- packages/mermaid/src/config.type.ts | 1500 ++++++++--------- 2 files changed, 756 insertions(+), 824 deletions(-) diff --git a/packages/mermaid/scripts/create-types-from-json-schema.mts b/packages/mermaid/scripts/create-types-from-json-schema.mts index a300ef00fb..57b0668129 100644 --- a/packages/mermaid/scripts/create-types-from-json-schema.mts +++ b/packages/mermaid/scripts/create-types-from-json-schema.mts @@ -10,18 +10,16 @@ /* eslint-disable no-console */ -import { readFile, writeFile } from 'node:fs/promises'; -import { join } from 'node:path'; +import _Ajv2019, { type JSONSchemaType } from 'ajv/dist/2019.js'; +import { JSON_SCHEMA, load } from 'js-yaml'; +import { compile, type JSONSchema } from 'json-schema-to-typescript'; import assert from 'node:assert'; import { execFile } from 'node:child_process'; +import { readFile, writeFile } from 'node:fs/promises'; +import { join } from 'node:path'; import { promisify } from 'node:util'; - -import { load, JSON_SCHEMA } from 'js-yaml'; -import { compile, type JSONSchema } from 'json-schema-to-typescript'; import prettier from 'prettier'; -import _Ajv2019, { type JSONSchemaType } from 'ajv/dist/2019.js'; - // Workaround for wrong AJV types, see // https://github.com/ajv-validator/ajv/issues/2132#issuecomment-1290409907 const Ajv2019 = _Ajv2019 as unknown as typeof _Ajv2019.default; @@ -34,28 +32,6 @@ const verifyOnly = process.argv.includes('--verify'); /** If `true`, automatically `git add` any changes (i.e. during `pnpm run pre-commit`)*/ const git = process.argv.includes('--git'); -/** - * 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', -]; - /** * Loads the MermaidConfig JSON schema YAML file. * @@ -148,53 +124,9 @@ async function generateTypescript(mermaidConfigSchema: JSONSchemaType>) { - return { - ...schema, - properties: Object.fromEntries( - Object.entries(schema.properties).map(([key, propertySchema]) => { - if (MERMAID_CONFIG_DIAGRAM_KEYS.includes(key)) { - const { $ref, ...propertySchemaWithoutRef } = propertySchema as JSONSchemaType; - if ($ref === undefined) { - throw Error( - `subSchema ${key} is in MERMAID_CONFIG_DIAGRAM_KEYS but does not have a $ref field` - ); - } - const [ - _root, // eslint-disable-line @typescript-eslint/no-unused-vars - _defs, // eslint-disable-line @typescript-eslint/no-unused-vars - defName, - ] = $ref.split('/'); - return [ - key, - { - ...propertySchemaWithoutRef, - tsType: defName, - }, - ]; - } - return [key, propertySchema]; - }) - ), - }; - } - assert.ok(mermaidConfigSchema.$defs); const modifiedSchema = { - ...unrefSubschemas(removeRequired(mermaidConfigSchema)), + ...removeRequired(mermaidConfigSchema), $defs: Object.fromEntries( Object.entries(mermaidConfigSchema.$defs).map(([key, subSchema]) => { diff --git a/packages/mermaid/src/config.type.ts b/packages/mermaid/src/config.type.ts index 775d49fb58..19e5bae723 100644 --- a/packages/mermaid/src/config.type.ts +++ b/packages/mermaid/src/config.type.ts @@ -5,10 +5,6 @@ * and run json-schema-to-typescript to regenerate this file. */ -/** - * Configuration options to pass to the `dompurify` library. - */ -export type DOMPurifyConfiguration = import('dompurify').Config; /** * JavaScript function that returns a `FontConfig`. * @@ -50,6 +46,10 @@ export type SankeyLinkColor = 'source' | 'target' | 'gradient'; * via the `definition` "SankeyNodeAlignment". */ export type SankeyNodeAlignment = 'left' | 'right' | 'center' | 'justify'; +/** + * Configuration options to pass to the `dompurify` library. + */ +export type DOMPurifyConfiguration = import('dompurify').Config; /** * The font size to use */ @@ -175,36 +175,77 @@ export interface MermaidConfig { suppressErrorRendering?: boolean; } /** - * The object containing configurations specific for packet diagrams. + * The object containing configurations specific for flowcharts * * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "PacketDiagramConfig". + * via the `definition` "FlowchartDiagramConfig". */ -export interface PacketDiagramConfig extends BaseDiagramConfig { +export interface FlowchartDiagramConfig extends BaseDiagramConfig { /** - * The height of each row in the packet diagram. + * Margin top for the text over the diagram */ - rowHeight?: number; + titleTopMargin?: number; /** - * The width of each bit in the packet diagram. + * Defines a top/bottom margin for subgraph titles + * */ - bitWidth?: number; + subGraphTitleMargin?: { + top?: number; + bottom?: number; + }; + arrowMarkerAbsolute?: boolean; /** - * The number of bits to display per row. + * The amount of padding around the diagram as a whole so that embedded + * diagrams have margins, expressed in pixels. + * */ - bitsPerRow?: number; + diagramPadding?: number; /** - * Toggle to display or hide bit numbers. + * Flag for setting whether or not a html tag should be used for rendering labels on the edges. + * */ - showBits?: boolean; + htmlLabels?: boolean; /** - * The horizontal padding between the blocks in a row. + * Defines the spacing between nodes on the same level + * + * Pertains to horizontal spacing for TB (top to bottom) or BT (bottom to top) graphs, + * and the vertical spacing for LR as well as RL graphs. + * */ - paddingX?: number; + nodeSpacing?: number; /** - * The vertical padding between the rows. + * Defines the spacing between nodes on different levels + * + * Pertains to horizontal spacing for TB (top to bottom) or BT (bottom to top) graphs, + * and the vertical spacing for LR as well as RL graphs. + * */ - paddingY?: number; + rankSpacing?: number; + /** + * Defines how mermaid renders curves for flowcharts. + * + */ + curve?: 'basis' | 'linear' | 'cardinal'; + /** + * Represents the padding between the labels and the shape + * + * **Only used in new experimental rendering.** + * + */ + padding?: number; + /** + * Decides which rendering engine that is to be used for the rendering. + * + */ + defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; + /** + * Width of nodes where text is wrapped. + * + * When using markdown strings the text ius wrapped automatically, this + * value sets the max width of a text before it continues on a new line. + * + */ + wrappingWidth?: number; } /** * This interface was referenced by `MermaidConfig`'s JSON-Schema @@ -221,455 +262,512 @@ export interface BaseDiagramConfig { useMaxWidth?: boolean; } /** - * The object containing configurations specific for block diagrams. - * - * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "BlockDiagramConfig". - */ -export interface BlockDiagramConfig extends BaseDiagramConfig { - padding?: number; -} -/** - * The object containing configurations specific for c4 diagrams + * The object containing configurations specific for sequence diagrams * * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "C4DiagramConfig". + * via the `definition` "SequenceDiagramConfig". */ -export interface C4DiagramConfig extends BaseDiagramConfig { +export interface SequenceDiagramConfig extends BaseDiagramConfig { + arrowMarkerAbsolute?: boolean; + hideUnusedParticipants?: boolean; /** - * Margin to the right and left of the c4 diagram, must be a positive value. - * + * Width of the activation rect */ - diagramMarginX?: number; + activationWidth?: number; /** - * Margin to the over and under the c4 diagram, must be a positive value. - * + * Margin to the right and left of the sequence diagram */ - diagramMarginY?: number; + diagramMarginX?: number; /** - * Margin between shapes + * Margin to the over and under the sequence diagram */ - c4ShapeMargin?: number; + diagramMarginY?: number; /** - * Padding between shapes + * Margin between actors */ - c4ShapePadding?: number; + actorMargin?: number; /** - * Width of person boxes + * Width of actor boxes */ width?: number; /** - * Height of person boxes + * Height of actor boxes */ height?: number; /** - * Margin around boxes + * Margin around loop boxes */ boxMargin?: number; /** - * How many shapes to place in each row. + * Margin around the text in loop/alt/opt boxes */ - c4ShapeInRow?: number; - nextLinePaddingX?: number; + boxTextMargin?: number; /** - * How many boundaries to place in each row. + * Margin around notes */ - c4BoundaryInRow?: number; + noteMargin?: number; /** - * This sets the font size of Person shape for the diagram + * Space between messages. */ - personFontSize?: string | number; + messageMargin?: number; /** - * This sets the font weight of Person shape for the diagram + * Multiline message alignment */ - personFontFamily?: string; + messageAlign?: 'left' | 'center' | 'right'; /** - * This sets the font weight of Person shape for the diagram + * Mirror actors under diagram + * */ - personFontWeight?: string | number; + mirrorActors?: boolean; /** - * This sets the font size of External Person shape for the diagram + * forces actor popup menus to always be visible (to support E2E testing). + * */ - external_personFontSize?: string | number; + forceMenus?: boolean; /** - * This sets the font family of External Person shape for the diagram + * Prolongs the edge of the diagram downwards. + * + * Depending on css styling this might need adjustment. + * */ - external_personFontFamily?: string; + bottomMarginAdj?: number; /** - * This sets the font weight of External Person shape for the diagram + * Curved Arrows become Right Angles + * + * This will display arrows that start and begin at the same node as + * right angles, rather than as curves. + * */ - external_personFontWeight?: string | number; + rightAngles?: boolean; /** - * This sets the font size of System shape for the diagram + * This will show the node numbers */ - systemFontSize?: string | number; + showSequenceNumbers?: boolean; /** - * This sets the font family of System shape for the diagram + * This sets the font size of the actor's description */ - systemFontFamily?: string; + actorFontSize?: string | number; /** - * This sets the font weight of System shape for the diagram + * This sets the font family of the actor's description */ - systemFontWeight?: string | number; + actorFontFamily?: string; /** - * This sets the font size of External System shape for the diagram + * This sets the font weight of the actor's description */ - external_systemFontSize?: string | number; + actorFontWeight?: string | number; /** - * This sets the font family of External System shape for the diagram + * This sets the font size of actor-attached notes */ - external_systemFontFamily?: string; + noteFontSize?: string | number; /** - * This sets the font weight of External System shape for the diagram + * This sets the font family of actor-attached notes */ - external_systemFontWeight?: string | number; + noteFontFamily?: string; /** - * This sets the font size of System DB shape for the diagram + * This sets the font weight of actor-attached notes */ - system_dbFontSize?: string | number; + noteFontWeight?: string | number; /** - * This sets the font family of System DB shape for the diagram + * This sets the text alignment of actor-attached notes */ - system_dbFontFamily?: string; + noteAlign?: 'left' | 'center' | 'right'; /** - * This sets the font weight of System DB shape for the diagram + * This sets the font size of actor messages */ - system_dbFontWeight?: string | number; + messageFontSize?: string | number; /** - * This sets the font size of External System DB shape for the diagram + * This sets the font family of actor messages */ - external_system_dbFontSize?: string | number; + messageFontFamily?: string; /** - * This sets the font family of External System DB shape for the diagram + * This sets the font weight of actor messages */ - external_system_dbFontFamily?: string; + messageFontWeight?: string | number; /** - * This sets the font weight of External System DB shape for the diagram + * This sets the auto-wrap state for the diagram */ - external_system_dbFontWeight?: string | number; + wrap?: boolean; /** - * This sets the font size of System Queue shape for the diagram + * This sets the auto-wrap padding for the diagram (sides only) */ - system_queueFontSize?: string | number; + wrapPadding?: number; /** - * This sets the font family of System Queue shape for the diagram + * This sets the width of the loop-box (loop, alt, opt, par) */ - system_queueFontFamily?: string; + labelBoxWidth?: number; /** - * This sets the font weight of System Queue shape for the diagram + * This sets the height of the loop-box (loop, alt, opt, par) */ - system_queueFontWeight?: string | number; + labelBoxHeight?: number; + messageFont?: FontCalculator; + noteFont?: FontCalculator; + actorFont?: FontCalculator; +} +/** + * The object containing configurations specific for gantt diagrams + * + * + * This interface was referenced by `MermaidConfig`'s JSON-Schema + * via the `definition` "GanttDiagramConfig". + */ +export interface GanttDiagramConfig extends BaseDiagramConfig { /** - * This sets the font size of External System Queue shape for the diagram + * Margin top for the text over the diagram */ - external_system_queueFontSize?: string | number; + titleTopMargin?: number; /** - * This sets the font family of External System Queue shape for the diagram + * The height of the bars in the graph */ - external_system_queueFontFamily?: string; + barHeight?: number; /** - * This sets the font weight of External System Queue shape for the diagram + * The margin between the different activities in the gantt diagram */ - external_system_queueFontWeight?: string | number; + barGap?: number; /** - * This sets the font size of Boundary shape for the diagram + * Margin between title and gantt diagram and between axis and gantt diagram. + * */ - boundaryFontSize?: string | number; + topPadding?: number; /** - * This sets the font family of Boundary shape for the diagram + * The space allocated for the section name to the right of the activities + * */ - boundaryFontFamily?: string; + rightPadding?: number; /** - * This sets the font weight of Boundary shape for the diagram - */ - boundaryFontWeight?: string | number; - /** - * This sets the font size of Message shape for the diagram - */ - messageFontSize?: string | number; - /** - * This sets the font family of Message shape for the diagram - */ - messageFontFamily?: string; - /** - * This sets the font weight of Message shape for the diagram - */ - messageFontWeight?: string | number; - /** - * This sets the font size of Container shape for the diagram + * The space allocated for the section name to the left of the activities + * */ - containerFontSize?: string | number; + leftPadding?: number; /** - * This sets the font family of Container shape for the diagram + * Vertical starting position of the grid lines */ - containerFontFamily?: string; + gridLineStartPadding?: number; /** - * This sets the font weight of Container shape for the diagram + * Font size */ - containerFontWeight?: string | number; + fontSize?: number; /** - * This sets the font size of External Container shape for the diagram + * Font size for sections */ - external_containerFontSize?: string | number; + sectionFontSize?: string | number; /** - * This sets the font family of External Container shape for the diagram + * The number of alternating section styles */ - external_containerFontFamily?: string; + numberSectionStyles?: number; /** - * This sets the font weight of External Container shape for the diagram + * Date/time format of the axis + * + * This might need adjustment to match your locale and preferences. + * */ - external_containerFontWeight?: string | number; + axisFormat?: string; /** - * This sets the font size of Container DB shape for the diagram + * axis ticks + * + * Pattern is: + * + * ```javascript + * /^([1-9][0-9]*)(millisecond|second|minute|hour|day|week|month)$/ + * ``` + * */ - container_dbFontSize?: string | number; + tickInterval?: string; /** - * This sets the font family of Container DB shape for the diagram + * When this flag is set, date labels will be added to the top of the chart + * */ - container_dbFontFamily?: string; + topAxis?: boolean; /** - * This sets the font weight of Container DB shape for the diagram + * Controls the display mode. + * */ - container_dbFontWeight?: string | number; + displayMode?: '' | 'compact'; /** - * This sets the font size of External Container DB shape for the diagram + * On which day a week-based interval should start + * */ - external_container_dbFontSize?: string | number; + weekday?: 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday'; +} +/** + * The object containing configurations specific for journey diagrams + * + * + * This interface was referenced by `MermaidConfig`'s JSON-Schema + * via the `definition` "JourneyDiagramConfig". + */ +export interface JourneyDiagramConfig extends BaseDiagramConfig { /** - * This sets the font family of External Container DB shape for the diagram + * Margin to the right and left of the c4 diagram, must be a positive value. + * */ - external_container_dbFontFamily?: string; + diagramMarginX?: number; /** - * This sets the font weight of External Container DB shape for the diagram + * Margin to the over and under the c4 diagram, must be a positive value. + * */ - external_container_dbFontWeight?: string | number; + diagramMarginY?: number; /** - * This sets the font size of Container Queue shape for the diagram + * Margin between actors */ - container_queueFontSize?: string | number; + leftMargin?: number; /** - * This sets the font family of Container Queue shape for the diagram + * Width of actor boxes */ - container_queueFontFamily?: string; + width?: number; /** - * This sets the font weight of Container Queue shape for the diagram + * Height of actor boxes */ - container_queueFontWeight?: string | number; + height?: number; /** - * This sets the font size of External Container Queue shape for the diagram + * Margin around loop boxes */ - external_container_queueFontSize?: string | number; + boxMargin?: number; /** - * This sets the font family of External Container Queue shape for the diagram + * Margin around the text in loop/alt/opt boxes */ - external_container_queueFontFamily?: string; + boxTextMargin?: number; /** - * This sets the font weight of External Container Queue shape for the diagram + * Margin around notes */ - external_container_queueFontWeight?: string | number; + noteMargin?: number; /** - * This sets the font size of Component shape for the diagram + * Space between messages. */ - componentFontSize?: string | number; + messageMargin?: number; /** - * This sets the font family of Component shape for the diagram + * Multiline message alignment */ - componentFontFamily?: string; + messageAlign?: 'left' | 'center' | 'right'; /** - * This sets the font weight of Component shape for the diagram + * Prolongs the edge of the diagram downwards. + * + * Depending on css styling this might need adjustment. + * */ - componentFontWeight?: string | number; + bottomMarginAdj?: number; /** - * This sets the font size of External Component shape for the diagram + * Curved Arrows become Right Angles + * + * This will display arrows that start and begin at the same node as + * right angles, rather than as curves. + * */ - external_componentFontSize?: string | number; + rightAngles?: boolean; + taskFontSize?: string | number; + taskFontFamily?: string; + taskMargin?: number; /** - * This sets the font family of External Component shape for the diagram + * Width of activation box */ - external_componentFontFamily?: string; + activationWidth?: number; /** - * This sets the font weight of External Component shape for the diagram + * text placement as: tspan | fo | old only text as before + * */ - external_componentFontWeight?: string | number; + textPlacement?: string; + actorColours?: string[]; + sectionFills?: string[]; + sectionColours?: string[]; +} +/** + * This interface was referenced by `MermaidConfig`'s JSON-Schema + * via the `definition` "TimelineDiagramConfig". + */ +export interface TimelineDiagramConfig extends BaseDiagramConfig { /** - * This sets the font size of Component DB shape for the diagram + * Margin to the right and left of the c4 diagram, must be a positive value. + * */ - component_dbFontSize?: string | number; + diagramMarginX?: number; /** - * This sets the font family of Component DB shape for the diagram + * Margin to the over and under the c4 diagram, must be a positive value. + * */ - component_dbFontFamily?: string; + diagramMarginY?: number; /** - * This sets the font weight of Component DB shape for the diagram + * Margin between actors */ - component_dbFontWeight?: string | number; + leftMargin?: number; /** - * This sets the font size of External Component DB shape for the diagram + * Width of actor boxes */ - external_component_dbFontSize?: string | number; + width?: number; /** - * This sets the font family of External Component DB shape for the diagram + * Height of actor boxes */ - external_component_dbFontFamily?: string; + height?: number; + padding?: number; /** - * This sets the font weight of External Component DB shape for the diagram + * Margin around loop boxes */ - external_component_dbFontWeight?: string | number; + boxMargin?: number; /** - * This sets the font size of Component Queue shape for the diagram + * Margin around the text in loop/alt/opt boxes */ - component_queueFontSize?: string | number; + boxTextMargin?: number; /** - * This sets the font family of Component Queue shape for the diagram + * Margin around notes */ - component_queueFontFamily?: string; + noteMargin?: number; /** - * This sets the font weight of Component Queue shape for the diagram + * Space between messages. */ - component_queueFontWeight?: string | number; + messageMargin?: number; /** - * This sets the font size of External Component Queue shape for the diagram + * Multiline message alignment */ - external_component_queueFontSize?: string | number; + messageAlign?: 'left' | 'center' | 'right'; /** - * This sets the font family of External Component Queue shape for the diagram + * Prolongs the edge of the diagram downwards. + * + * Depending on css styling this might need adjustment. + * */ - external_component_queueFontFamily?: string; + bottomMarginAdj?: number; /** - * This sets the font weight of External Component Queue shape for the diagram + * Curved Arrows become Right Angles + * + * This will display arrows that start and begin at the same node as + * right angles, rather than as curves. + * */ - external_component_queueFontWeight?: string | number; + rightAngles?: boolean; + taskFontSize?: string | number; + taskFontFamily?: string; + taskMargin?: number; /** - * This sets the auto-wrap state for the diagram + * Width of activation box */ - wrap?: boolean; + activationWidth?: number; /** - * This sets the auto-wrap padding for the diagram (sides only) + * text placement as: tspan | fo | old only text as before + * */ - wrapPadding?: number; - person_bg_color?: string; - person_border_color?: string; - external_person_bg_color?: string; - external_person_border_color?: string; - system_bg_color?: string; - system_border_color?: string; - system_db_bg_color?: string; - system_db_border_color?: string; - system_queue_bg_color?: string; - system_queue_border_color?: string; - external_system_bg_color?: string; - external_system_border_color?: string; - external_system_db_bg_color?: string; - external_system_db_border_color?: string; - external_system_queue_bg_color?: string; - external_system_queue_border_color?: string; - container_bg_color?: string; - container_border_color?: string; - container_db_bg_color?: string; - container_db_border_color?: string; - container_queue_bg_color?: string; - container_queue_border_color?: string; - external_container_bg_color?: string; - external_container_border_color?: string; - external_container_db_bg_color?: string; - external_container_db_border_color?: string; - external_container_queue_bg_color?: string; - external_container_queue_border_color?: string; - component_bg_color?: string; - component_border_color?: string; - component_db_bg_color?: string; - component_db_border_color?: string; - component_queue_bg_color?: string; - component_queue_border_color?: string; - external_component_bg_color?: string; - external_component_border_color?: string; - external_component_db_bg_color?: string; - external_component_db_border_color?: string; - external_component_queue_bg_color?: string; - external_component_queue_border_color?: string; - personFont?: FontCalculator; - external_personFont?: FontCalculator; - systemFont?: FontCalculator; - external_systemFont?: FontCalculator; - system_dbFont?: FontCalculator; - external_system_dbFont?: FontCalculator; - system_queueFont?: FontCalculator; - external_system_queueFont?: FontCalculator; - containerFont?: FontCalculator; - external_containerFont?: FontCalculator; - container_dbFont?: FontCalculator; - external_container_dbFont?: FontCalculator; - container_queueFont?: FontCalculator; - external_container_queueFont?: FontCalculator; - componentFont?: FontCalculator; - external_componentFont?: FontCalculator; - component_dbFont?: FontCalculator; - external_component_dbFont?: FontCalculator; - component_queueFont?: FontCalculator; - external_component_queueFont?: FontCalculator; - boundaryFont?: FontCalculator; - messageFont?: FontCalculator; + textPlacement?: string; + actorColours?: string[]; + sectionFills?: string[]; + sectionColours?: string[]; + disableMulticolor?: boolean; } /** * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "GitGraphDiagramConfig". + * via the `definition` "ClassDiagramConfig". */ -export interface GitGraphDiagramConfig extends BaseDiagramConfig { +export interface ClassDiagramConfig extends BaseDiagramConfig { /** * Margin top for the text over the diagram */ titleTopMargin?: number; - diagramPadding?: number; - nodeLabel?: NodeLabel; - mainBranchName?: string; - mainBranchOrder?: number; - showCommitLabel?: boolean; - showBranches?: boolean; - rotateCommitLabel?: boolean; - parallelCommits?: boolean; /** * Controls whether or arrow markers in html code are absolute paths or anchors. * This matters if you are using base tag settings. * */ arrowMarkerAbsolute?: boolean; + dividerMargin?: number; + padding?: number; + textHeight?: number; + /** + * Decides which rendering engine that is to be used for the rendering. + * + */ + defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; + nodeSpacing?: number; + rankSpacing?: number; + /** + * The amount of padding around the diagram as a whole so that embedded + * diagrams have margins, expressed in pixels. + * + */ + diagramPadding?: number; + htmlLabels?: boolean; } /** - * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "NodeLabel". - */ -export interface NodeLabel { - width?: number; - height?: number; - x?: number; - y?: number; -} -/** - * The object containing configurations specific for req diagrams + * The object containing configurations specific for entity relationship diagrams * * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "RequirementDiagramConfig". + * via the `definition` "StateDiagramConfig". */ -export interface RequirementDiagramConfig extends BaseDiagramConfig { - rect_fill?: string; - text_color?: string; - rect_border_size?: string; - rect_border_color?: string; - rect_min_width?: number; - rect_min_height?: number; +export interface StateDiagramConfig extends BaseDiagramConfig { + /** + * Margin top for the text over the diagram + */ + titleTopMargin?: number; + arrowMarkerAbsolute?: boolean; + dividerMargin?: number; + sizeUnit?: number; + padding?: number; + textHeight?: number; + titleShift?: number; + noteMargin?: number; + forkWidth?: number; + forkHeight?: number; + miniPadding?: number; + /** + * Font size factor, this is used to guess the width of the edges labels + * before rendering by dagre layout. + * This might need updating if/when switching font + * + */ + fontSizeFactor?: number; fontSize?: number; - rect_padding?: number; - line_height?: number; + labelHeight?: number; + edgeLengthFactor?: string; + compositTitleSize?: number; + radius?: number; + /** + * Decides which rendering engine that is to be used for the rendering. + * + */ + defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; } /** - * The object containing configurations specific for mindmap diagrams + * The object containing configurations specific for entity relationship diagrams * * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "MindmapDiagramConfig". + * via the `definition` "ErDiagramConfig". */ -export interface MindmapDiagramConfig extends BaseDiagramConfig { - padding?: number; - maxNodeWidth?: number; +export interface ErDiagramConfig extends BaseDiagramConfig { + /** + * Margin top for the text over the diagram + */ + titleTopMargin?: number; + /** + * The amount of padding around the diagram as a whole so that embedded + * diagrams have margins, expressed in pixels. + * + */ + diagramPadding?: number; + /** + * Directional bias for layout of entities + */ + layoutDirection?: 'TB' | 'BT' | 'LR' | 'RL'; + /** + * The minimum width of an entity box. Expressed in pixels. + */ + minEntityWidth?: number; + /** + * The minimum height of an entity box. Expressed in pixels. + */ + minEntityHeight?: number; + /** + * The minimum internal padding between text in an entity box and the enclosing box borders. + * Expressed in pixels. + * + */ + entityPadding?: number; + /** + * Stroke color of box edges and lines. + */ + stroke?: string; + /** + * Fill color of entity boxes + */ + fill?: string; + /** + * Font size (expressed as an integer representing a number of pixels) + */ + fontSize?: number; } /** * This interface was referenced by `MermaidConfig`'s JSON-Schema @@ -722,95 +820,43 @@ export interface QuadrantChartConfig extends BaseDiagramConfig { /** * y-axis label font size */ - yAxisLabelFontSize?: number; - /** - * quadrant title font size - */ - quadrantLabelFontSize?: number; - /** - * quadrant title padding from top if the quadrant is rendered on top - */ - quadrantTextTopPadding?: number; - /** - * padding between point and point label - */ - pointTextPadding?: number; - /** - * point title font size - */ - pointLabelFontSize?: number; - /** - * radius of the point to be drawn - */ - pointRadius?: number; - /** - * position of x-axis labels - */ - xAxisPosition?: 'top' | 'bottom'; - /** - * position of y-axis labels - */ - yAxisPosition?: 'left' | 'right'; - /** - * stroke width of edges of the box that are inside the quadrant - */ - quadrantInternalBorderStrokeWidth?: number; - /** - * stroke width of edges of the box that are outside the quadrant - */ - quadrantExternalBorderStrokeWidth?: number; -} -/** - * This object contains configuration for XYChart axis config - * - * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "XYChartAxisConfig". - */ -export interface XYChartAxisConfig { - /** - * Should show the axis labels (tick text) - */ - showLabel?: boolean; - /** - * font size of the axis labels (tick text) - */ - labelFontSize?: number; + yAxisLabelFontSize?: number; /** - * top and bottom space from axis label (tick text) + * quadrant title font size */ - labelPadding?: number; + quadrantLabelFontSize?: number; /** - * Should show the axis title + * quadrant title padding from top if the quadrant is rendered on top */ - showTitle?: boolean; + quadrantTextTopPadding?: number; /** - * font size of the axis title + * padding between point and point label */ - titleFontSize?: number; + pointTextPadding?: number; /** - * top and bottom space from axis title + * point title font size */ - titlePadding?: number; + pointLabelFontSize?: number; /** - * Should show the axis tick lines + * radius of the point to be drawn */ - showTick?: boolean; + pointRadius?: number; /** - * length of the axis tick lines + * position of x-axis labels */ - tickLength?: number; + xAxisPosition?: 'top' | 'bottom'; /** - * width of the axis tick lines + * position of y-axis labels */ - tickWidth?: number; + yAxisPosition?: 'left' | 'right'; /** - * Show line across the axis + * stroke width of edges of the box that are inside the quadrant */ - showAxisLine?: boolean; + quadrantInternalBorderStrokeWidth?: number; /** - * Width of the axis line + * stroke width of edges of the box that are outside the quadrant */ - axisLineWidth?: number; + quadrantExternalBorderStrokeWidth?: number; } /** * This object contains configuration specific to XYCharts @@ -851,211 +897,125 @@ export interface XYChartConfig extends BaseDiagramConfig { plotReservedSpacePercent?: number; } /** - * The object containing configurations specific for entity relationship diagrams + * This object contains configuration for XYChart axis config * * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "ErDiagramConfig". + * via the `definition` "XYChartAxisConfig". */ -export interface ErDiagramConfig extends BaseDiagramConfig { +export interface XYChartAxisConfig { /** - * Margin top for the text over the diagram + * Should show the axis labels (tick text) */ - titleTopMargin?: number; + showLabel?: boolean; /** - * The amount of padding around the diagram as a whole so that embedded - * diagrams have margins, expressed in pixels. - * + * font size of the axis labels (tick text) */ - diagramPadding?: number; + labelFontSize?: number; /** - * Directional bias for layout of entities + * top and bottom space from axis label (tick text) */ - layoutDirection?: 'TB' | 'BT' | 'LR' | 'RL'; + labelPadding?: number; /** - * The minimum width of an entity box. Expressed in pixels. + * Should show the axis title */ - minEntityWidth?: number; + showTitle?: boolean; /** - * The minimum height of an entity box. Expressed in pixels. + * font size of the axis title */ - minEntityHeight?: number; + titleFontSize?: number; /** - * The minimum internal padding between text in an entity box and the enclosing box borders. - * Expressed in pixels. - * + * top and bottom space from axis title */ - entityPadding?: number; + titlePadding?: number; /** - * Stroke color of box edges and lines. + * Should show the axis tick lines */ - stroke?: string; + showTick?: boolean; /** - * Fill color of entity boxes + * length of the axis tick lines */ - fill?: string; + tickLength?: number; /** - * Font size (expressed as an integer representing a number of pixels) + * width of the axis tick lines */ - fontSize?: number; + tickWidth?: number; + /** + * Show line across the axis + */ + showAxisLine?: boolean; + /** + * Width of the axis line + */ + axisLineWidth?: number; } /** - * The object containing configurations specific for entity relationship diagrams + * The object containing configurations specific for req diagrams * * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "StateDiagramConfig". + * via the `definition` "RequirementDiagramConfig". */ -export interface StateDiagramConfig extends BaseDiagramConfig { - /** - * Margin top for the text over the diagram - */ - titleTopMargin?: number; - arrowMarkerAbsolute?: boolean; - dividerMargin?: number; - sizeUnit?: number; - padding?: number; - textHeight?: number; - titleShift?: number; - noteMargin?: number; - forkWidth?: number; - forkHeight?: number; - miniPadding?: number; - /** - * Font size factor, this is used to guess the width of the edges labels - * before rendering by dagre layout. - * This might need updating if/when switching font - * - */ - fontSizeFactor?: number; +export interface RequirementDiagramConfig extends BaseDiagramConfig { + rect_fill?: string; + text_color?: string; + rect_border_size?: string; + rect_border_color?: string; + rect_min_width?: number; + rect_min_height?: number; fontSize?: number; - labelHeight?: number; - edgeLengthFactor?: string; - compositTitleSize?: number; - radius?: number; - /** - * Decides which rendering engine that is to be used for the rendering. - * - */ - defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; + rect_padding?: number; + line_height?: number; } /** + * The object containing configurations specific for mindmap diagrams + * * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "ClassDiagramConfig". + * via the `definition` "MindmapDiagramConfig". */ -export interface ClassDiagramConfig extends BaseDiagramConfig { - /** - * Margin top for the text over the diagram - */ - titleTopMargin?: number; - /** - * Controls whether or arrow markers in html code are absolute paths or anchors. - * This matters if you are using base tag settings. - * - */ - arrowMarkerAbsolute?: boolean; - dividerMargin?: number; +export interface MindmapDiagramConfig extends BaseDiagramConfig { padding?: number; - textHeight?: number; - /** - * Decides which rendering engine that is to be used for the rendering. - * - */ - defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; - nodeSpacing?: number; - rankSpacing?: number; - /** - * The amount of padding around the diagram as a whole so that embedded - * diagrams have margins, expressed in pixels. - * - */ - diagramPadding?: number; - htmlLabels?: boolean; + maxNodeWidth?: number; } /** - * The object containing configurations specific for journey diagrams - * - * * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "JourneyDiagramConfig". + * via the `definition` "GitGraphDiagramConfig". */ -export interface JourneyDiagramConfig extends BaseDiagramConfig { - /** - * Margin to the right and left of the c4 diagram, must be a positive value. - * - */ - diagramMarginX?: number; - /** - * Margin to the over and under the c4 diagram, must be a positive value. - * - */ - diagramMarginY?: number; - /** - * Margin between actors - */ - leftMargin?: number; - /** - * Width of actor boxes - */ - width?: number; - /** - * Height of actor boxes - */ - height?: number; - /** - * Margin around loop boxes - */ - boxMargin?: number; - /** - * Margin around the text in loop/alt/opt boxes - */ - boxTextMargin?: number; - /** - * Margin around notes - */ - noteMargin?: number; - /** - * Space between messages. - */ - messageMargin?: number; - /** - * Multiline message alignment - */ - messageAlign?: 'left' | 'center' | 'right'; - /** - * Prolongs the edge of the diagram downwards. - * - * Depending on css styling this might need adjustment. - * - */ - bottomMarginAdj?: number; - /** - * Curved Arrows become Right Angles - * - * This will display arrows that start and begin at the same node as - * right angles, rather than as curves. - * - */ - rightAngles?: boolean; - taskFontSize?: string | number; - taskFontFamily?: string; - taskMargin?: number; +export interface GitGraphDiagramConfig extends BaseDiagramConfig { /** - * Width of activation box + * Margin top for the text over the diagram */ - activationWidth?: number; + titleTopMargin?: number; + diagramPadding?: number; + nodeLabel?: NodeLabel; + mainBranchName?: string; + mainBranchOrder?: number; + showCommitLabel?: boolean; + showBranches?: boolean; + rotateCommitLabel?: boolean; + parallelCommits?: boolean; /** - * text placement as: tspan | fo | old only text as before + * Controls whether or arrow markers in html code are absolute paths or anchors. + * This matters if you are using base tag settings. * - */ - textPlacement?: string; - actorColours?: string[]; - sectionFills?: string[]; - sectionColours?: string[]; + */ + arrowMarkerAbsolute?: boolean; } /** * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "TimelineDiagramConfig". + * via the `definition` "NodeLabel". */ -export interface TimelineDiagramConfig extends BaseDiagramConfig { +export interface NodeLabel { + width?: number; + height?: number; + x?: number; + y?: number; +} +/** + * The object containing configurations specific for c4 diagrams + * + * This interface was referenced by `MermaidConfig`'s JSON-Schema + * via the `definition` "C4DiagramConfig". + */ +export interface C4DiagramConfig extends BaseDiagramConfig { /** * Margin to the right and left of the c4 diagram, must be a positive value. * @@ -1067,369 +1027,368 @@ export interface TimelineDiagramConfig extends BaseDiagramConfig { */ diagramMarginY?: number; /** - * Margin between actors + * Margin between shapes */ - leftMargin?: number; + c4ShapeMargin?: number; /** - * Width of actor boxes + * Padding between shapes + */ + c4ShapePadding?: number; + /** + * Width of person boxes */ width?: number; /** - * Height of actor boxes + * Height of person boxes */ height?: number; - padding?: number; /** - * Margin around loop boxes + * Margin around boxes */ boxMargin?: number; /** - * Margin around the text in loop/alt/opt boxes + * How many shapes to place in each row. */ - boxTextMargin?: number; + c4ShapeInRow?: number; + nextLinePaddingX?: number; /** - * Margin around notes + * How many boundaries to place in each row. */ - noteMargin?: number; + c4BoundaryInRow?: number; /** - * Space between messages. + * This sets the font size of Person shape for the diagram */ - messageMargin?: number; + personFontSize?: string | number; /** - * Multiline message alignment + * This sets the font weight of Person shape for the diagram */ - messageAlign?: 'left' | 'center' | 'right'; + personFontFamily?: string; /** - * Prolongs the edge of the diagram downwards. - * - * Depending on css styling this might need adjustment. - * + * This sets the font weight of Person shape for the diagram */ - bottomMarginAdj?: number; + personFontWeight?: string | number; /** - * Curved Arrows become Right Angles - * - * This will display arrows that start and begin at the same node as - * right angles, rather than as curves. - * + * This sets the font size of External Person shape for the diagram */ - rightAngles?: boolean; - taskFontSize?: string | number; - taskFontFamily?: string; - taskMargin?: number; + external_personFontSize?: string | number; /** - * Width of activation box + * This sets the font family of External Person shape for the diagram */ - activationWidth?: number; + external_personFontFamily?: string; /** - * text placement as: tspan | fo | old only text as before - * + * This sets the font weight of External Person shape for the diagram */ - textPlacement?: string; - actorColours?: string[]; - sectionFills?: string[]; - sectionColours?: string[]; - disableMulticolor?: boolean; -} -/** - * The object containing configurations specific for gantt diagrams - * - * - * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "GanttDiagramConfig". - */ -export interface GanttDiagramConfig extends BaseDiagramConfig { + external_personFontWeight?: string | number; /** - * Margin top for the text over the diagram + * This sets the font size of System shape for the diagram */ - titleTopMargin?: number; + systemFontSize?: string | number; /** - * The height of the bars in the graph + * This sets the font family of System shape for the diagram */ - barHeight?: number; + systemFontFamily?: string; /** - * The margin between the different activities in the gantt diagram + * This sets the font weight of System shape for the diagram */ - barGap?: number; + systemFontWeight?: string | number; /** - * Margin between title and gantt diagram and between axis and gantt diagram. - * + * This sets the font size of External System shape for the diagram */ - topPadding?: number; + external_systemFontSize?: string | number; /** - * The space allocated for the section name to the right of the activities - * + * This sets the font family of External System shape for the diagram */ - rightPadding?: number; + external_systemFontFamily?: string; /** - * The space allocated for the section name to the left of the activities - * + * This sets the font weight of External System shape for the diagram */ - leftPadding?: number; + external_systemFontWeight?: string | number; /** - * Vertical starting position of the grid lines + * This sets the font size of System DB shape for the diagram */ - gridLineStartPadding?: number; + system_dbFontSize?: string | number; /** - * Font size + * This sets the font family of System DB shape for the diagram */ - fontSize?: number; + system_dbFontFamily?: string; /** - * Font size for sections + * This sets the font weight of System DB shape for the diagram */ - sectionFontSize?: string | number; + system_dbFontWeight?: string | number; /** - * The number of alternating section styles + * This sets the font size of External System DB shape for the diagram */ - numberSectionStyles?: number; + external_system_dbFontSize?: string | number; /** - * Date/time format of the axis - * - * This might need adjustment to match your locale and preferences. - * + * This sets the font family of External System DB shape for the diagram */ - axisFormat?: string; + external_system_dbFontFamily?: string; /** - * axis ticks - * - * Pattern is: - * - * ```javascript - * /^([1-9][0-9]*)(millisecond|second|minute|hour|day|week|month)$/ - * ``` - * + * This sets the font weight of External System DB shape for the diagram */ - tickInterval?: string; + external_system_dbFontWeight?: string | number; /** - * When this flag is set, date labels will be added to the top of the chart - * + * This sets the font size of System Queue shape for the diagram */ - topAxis?: boolean; + system_queueFontSize?: string | number; /** - * Controls the display mode. - * + * This sets the font family of System Queue shape for the diagram */ - displayMode?: '' | 'compact'; + system_queueFontFamily?: string; /** - * On which day a week-based interval should start - * + * This sets the font weight of System Queue shape for the diagram */ - weekday?: 'monday' | 'tuesday' | 'wednesday' | 'thursday' | 'friday' | 'saturday' | 'sunday'; -} -/** - * The object containing configurations specific for sequence diagrams - * - * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "SequenceDiagramConfig". - */ -export interface SequenceDiagramConfig extends BaseDiagramConfig { - arrowMarkerAbsolute?: boolean; - hideUnusedParticipants?: boolean; + system_queueFontWeight?: string | number; /** - * Width of the activation rect + * This sets the font size of External System Queue shape for the diagram */ - activationWidth?: number; + external_system_queueFontSize?: string | number; /** - * Margin to the right and left of the sequence diagram + * This sets the font family of External System Queue shape for the diagram */ - diagramMarginX?: number; + external_system_queueFontFamily?: string; /** - * Margin to the over and under the sequence diagram + * This sets the font weight of External System Queue shape for the diagram */ - diagramMarginY?: number; + external_system_queueFontWeight?: string | number; /** - * Margin between actors + * This sets the font size of Boundary shape for the diagram */ - actorMargin?: number; + boundaryFontSize?: string | number; /** - * Width of actor boxes + * This sets the font family of Boundary shape for the diagram */ - width?: number; + boundaryFontFamily?: string; /** - * Height of actor boxes + * This sets the font weight of Boundary shape for the diagram */ - height?: number; + boundaryFontWeight?: string | number; /** - * Margin around loop boxes + * This sets the font size of Message shape for the diagram */ - boxMargin?: number; + messageFontSize?: string | number; /** - * Margin around the text in loop/alt/opt boxes + * This sets the font family of Message shape for the diagram */ - boxTextMargin?: number; + messageFontFamily?: string; /** - * Margin around notes + * This sets the font weight of Message shape for the diagram */ - noteMargin?: number; + messageFontWeight?: string | number; /** - * Space between messages. + * This sets the font size of Container shape for the diagram */ - messageMargin?: number; + containerFontSize?: string | number; /** - * Multiline message alignment + * This sets the font family of Container shape for the diagram */ - messageAlign?: 'left' | 'center' | 'right'; + containerFontFamily?: string; /** - * Mirror actors under diagram - * + * This sets the font weight of Container shape for the diagram */ - mirrorActors?: boolean; + containerFontWeight?: string | number; /** - * forces actor popup menus to always be visible (to support E2E testing). - * + * This sets the font size of External Container shape for the diagram + */ + external_containerFontSize?: string | number; + /** + * This sets the font family of External Container shape for the diagram + */ + external_containerFontFamily?: string; + /** + * This sets the font weight of External Container shape for the diagram + */ + external_containerFontWeight?: string | number; + /** + * This sets the font size of Container DB shape for the diagram + */ + container_dbFontSize?: string | number; + /** + * This sets the font family of Container DB shape for the diagram + */ + container_dbFontFamily?: string; + /** + * This sets the font weight of Container DB shape for the diagram + */ + container_dbFontWeight?: string | number; + /** + * This sets the font size of External Container DB shape for the diagram + */ + external_container_dbFontSize?: string | number; + /** + * This sets the font family of External Container DB shape for the diagram */ - forceMenus?: boolean; + external_container_dbFontFamily?: string; /** - * Prolongs the edge of the diagram downwards. - * - * Depending on css styling this might need adjustment. - * + * This sets the font weight of External Container DB shape for the diagram */ - bottomMarginAdj?: number; + external_container_dbFontWeight?: string | number; /** - * Curved Arrows become Right Angles - * - * This will display arrows that start and begin at the same node as - * right angles, rather than as curves. - * + * This sets the font size of Container Queue shape for the diagram */ - rightAngles?: boolean; + container_queueFontSize?: string | number; /** - * This will show the node numbers + * This sets the font family of Container Queue shape for the diagram */ - showSequenceNumbers?: boolean; + container_queueFontFamily?: string; /** - * This sets the font size of the actor's description + * This sets the font weight of Container Queue shape for the diagram */ - actorFontSize?: string | number; + container_queueFontWeight?: string | number; /** - * This sets the font family of the actor's description + * This sets the font size of External Container Queue shape for the diagram */ - actorFontFamily?: string; + external_container_queueFontSize?: string | number; /** - * This sets the font weight of the actor's description + * This sets the font family of External Container Queue shape for the diagram */ - actorFontWeight?: string | number; + external_container_queueFontFamily?: string; /** - * This sets the font size of actor-attached notes + * This sets the font weight of External Container Queue shape for the diagram */ - noteFontSize?: string | number; + external_container_queueFontWeight?: string | number; /** - * This sets the font family of actor-attached notes + * This sets the font size of Component shape for the diagram */ - noteFontFamily?: string; + componentFontSize?: string | number; /** - * This sets the font weight of actor-attached notes + * This sets the font family of Component shape for the diagram */ - noteFontWeight?: string | number; + componentFontFamily?: string; /** - * This sets the text alignment of actor-attached notes + * This sets the font weight of Component shape for the diagram */ - noteAlign?: 'left' | 'center' | 'right'; + componentFontWeight?: string | number; /** - * This sets the font size of actor messages + * This sets the font size of External Component shape for the diagram */ - messageFontSize?: string | number; + external_componentFontSize?: string | number; /** - * This sets the font family of actor messages + * This sets the font family of External Component shape for the diagram */ - messageFontFamily?: string; + external_componentFontFamily?: string; /** - * This sets the font weight of actor messages + * This sets the font weight of External Component shape for the diagram */ - messageFontWeight?: string | number; + external_componentFontWeight?: string | number; /** - * This sets the auto-wrap state for the diagram + * This sets the font size of Component DB shape for the diagram */ - wrap?: boolean; + component_dbFontSize?: string | number; /** - * This sets the auto-wrap padding for the diagram (sides only) + * This sets the font family of Component DB shape for the diagram */ - wrapPadding?: number; + component_dbFontFamily?: string; /** - * This sets the width of the loop-box (loop, alt, opt, par) + * This sets the font weight of Component DB shape for the diagram */ - labelBoxWidth?: number; + component_dbFontWeight?: string | number; /** - * This sets the height of the loop-box (loop, alt, opt, par) + * This sets the font size of External Component DB shape for the diagram */ - labelBoxHeight?: number; - messageFont?: FontCalculator; - noteFont?: FontCalculator; - actorFont?: FontCalculator; -} -/** - * The object containing configurations specific for flowcharts - * - * This interface was referenced by `MermaidConfig`'s JSON-Schema - * via the `definition` "FlowchartDiagramConfig". - */ -export interface FlowchartDiagramConfig extends BaseDiagramConfig { + external_component_dbFontSize?: string | number; /** - * Margin top for the text over the diagram + * This sets the font family of External Component DB shape for the diagram */ - titleTopMargin?: number; + external_component_dbFontFamily?: string; /** - * Defines a top/bottom margin for subgraph titles - * + * This sets the font weight of External Component DB shape for the diagram */ - subGraphTitleMargin?: { - top?: number; - bottom?: number; - }; - arrowMarkerAbsolute?: boolean; + external_component_dbFontWeight?: string | number; /** - * The amount of padding around the diagram as a whole so that embedded - * diagrams have margins, expressed in pixels. - * + * This sets the font size of Component Queue shape for the diagram */ - diagramPadding?: number; + component_queueFontSize?: string | number; /** - * Flag for setting whether or not a html tag should be used for rendering labels on the edges. - * + * This sets the font family of Component Queue shape for the diagram */ - htmlLabels?: boolean; + component_queueFontFamily?: string; /** - * Defines the spacing between nodes on the same level - * - * Pertains to horizontal spacing for TB (top to bottom) or BT (bottom to top) graphs, - * and the vertical spacing for LR as well as RL graphs. - * + * This sets the font weight of Component Queue shape for the diagram */ - nodeSpacing?: number; + component_queueFontWeight?: string | number; /** - * Defines the spacing between nodes on different levels - * - * Pertains to horizontal spacing for TB (top to bottom) or BT (bottom to top) graphs, - * and the vertical spacing for LR as well as RL graphs. - * + * This sets the font size of External Component Queue shape for the diagram */ - rankSpacing?: number; + external_component_queueFontSize?: string | number; /** - * Defines how mermaid renders curves for flowcharts. - * + * This sets the font family of External Component Queue shape for the diagram */ - curve?: 'basis' | 'linear' | 'cardinal'; + external_component_queueFontFamily?: string; /** - * Represents the padding between the labels and the shape - * - * **Only used in new experimental rendering.** - * + * This sets the font weight of External Component Queue shape for the diagram */ - padding?: number; + external_component_queueFontWeight?: string | number; /** - * Decides which rendering engine that is to be used for the rendering. - * + * This sets the auto-wrap state for the diagram */ - defaultRenderer?: 'dagre-d3' | 'dagre-wrapper' | 'elk'; + wrap?: boolean; /** - * Width of nodes where text is wrapped. - * - * When using markdown strings the text ius wrapped automatically, this - * value sets the max width of a text before it continues on a new line. - * + * This sets the auto-wrap padding for the diagram (sides only) */ - wrappingWidth?: number; + wrapPadding?: number; + person_bg_color?: string; + person_border_color?: string; + external_person_bg_color?: string; + external_person_border_color?: string; + system_bg_color?: string; + system_border_color?: string; + system_db_bg_color?: string; + system_db_border_color?: string; + system_queue_bg_color?: string; + system_queue_border_color?: string; + external_system_bg_color?: string; + external_system_border_color?: string; + external_system_db_bg_color?: string; + external_system_db_border_color?: string; + external_system_queue_bg_color?: string; + external_system_queue_border_color?: string; + container_bg_color?: string; + container_border_color?: string; + container_db_bg_color?: string; + container_db_border_color?: string; + container_queue_bg_color?: string; + container_queue_border_color?: string; + external_container_bg_color?: string; + external_container_border_color?: string; + external_container_db_bg_color?: string; + external_container_db_border_color?: string; + external_container_queue_bg_color?: string; + external_container_queue_border_color?: string; + component_bg_color?: string; + component_border_color?: string; + component_db_bg_color?: string; + component_db_border_color?: string; + component_queue_bg_color?: string; + component_queue_border_color?: string; + external_component_bg_color?: string; + external_component_border_color?: string; + external_component_db_bg_color?: string; + external_component_db_border_color?: string; + external_component_queue_bg_color?: string; + external_component_queue_border_color?: string; + personFont?: FontCalculator; + external_personFont?: FontCalculator; + systemFont?: FontCalculator; + external_systemFont?: FontCalculator; + system_dbFont?: FontCalculator; + external_system_dbFont?: FontCalculator; + system_queueFont?: FontCalculator; + external_system_queueFont?: FontCalculator; + containerFont?: FontCalculator; + external_containerFont?: FontCalculator; + container_dbFont?: FontCalculator; + external_container_dbFont?: FontCalculator; + container_queueFont?: FontCalculator; + external_container_queueFont?: FontCalculator; + componentFont?: FontCalculator; + external_componentFont?: FontCalculator; + component_dbFont?: FontCalculator; + external_component_dbFont?: FontCalculator; + component_queueFont?: FontCalculator; + external_component_queueFont?: FontCalculator; + boundaryFont?: FontCalculator; + messageFont?: FontCalculator; } /** * The object containing configurations specific for sankey diagrams. @@ -1463,6 +1422,47 @@ export interface SankeyDiagramConfig extends BaseDiagramConfig { */ suffix?: string; } +/** + * The object containing configurations specific for packet diagrams. + * + * This interface was referenced by `MermaidConfig`'s JSON-Schema + * via the `definition` "PacketDiagramConfig". + */ +export interface PacketDiagramConfig extends BaseDiagramConfig { + /** + * The height of each row in the packet diagram. + */ + rowHeight?: number; + /** + * The width of each bit in the packet diagram. + */ + bitWidth?: number; + /** + * The number of bits to display per row. + */ + bitsPerRow?: number; + /** + * Toggle to display or hide bit numbers. + */ + showBits?: boolean; + /** + * The horizontal padding between the blocks in a row. + */ + paddingX?: number; + /** + * The vertical padding between the rows. + */ + paddingY?: number; +} +/** + * The object containing configurations specific for block diagrams. + * + * This interface was referenced by `MermaidConfig`'s JSON-Schema + * via the `definition` "BlockDiagramConfig". + */ +export interface BlockDiagramConfig extends BaseDiagramConfig { + padding?: number; +} /** * This interface was referenced by `MermaidConfig`'s JSON-Schema * via the `definition` "FontConfig". From 730fa89e4c0b9ba81a6242753f8c78c71cce4174 Mon Sep 17 00:00:00 2001 From: Alois Klink Date: Tue, 14 May 2024 03:28:59 +0900 Subject: [PATCH 35/50] refactor: remove non-null assertion operator Remove the non-null assertion operator when possible from PR https://github.com/mermaid-js/mermaid/pull/5468 --- docs/config/setup/modules/mermaidAPI.md | 12 ++--- .../mermaid/src/diagrams/block/blockDB.ts | 36 +++++++------- .../mermaid/src/diagrams/class/classDb.ts | 9 ++-- .../src/diagrams/class/classRenderer-v2.ts | 18 +++---- .../mermaid/src/diagrams/flowchart/flowDb.ts | 48 ++++++++++--------- .../mermaid/src/diagrams/git/gitGraphAst.js | 4 +- .../src/diagrams/git/gitGraphParserV2.spec.js | 25 +++------- .../mermaid/src/diagrams/pie/pieRenderer.ts | 4 +- .../requirement/requirementRenderer.js | 16 +++++-- .../mermaid/src/diagrams/sankey/sankeyDB.ts | 10 ++-- .../src/diagrams/sequence/sequenceDb.ts | 8 +++- .../mermaid/src/diagrams/state/stateDb.js | 3 +- packages/mermaid/src/mermaidAPI.ts | 7 ++- 13 files changed, 96 insertions(+), 104 deletions(-) diff --git a/docs/config/setup/modules/mermaidAPI.md b/docs/config/setup/modules/mermaidAPI.md index d9b8f16eba..d17533a036 100644 --- a/docs/config/setup/modules/mermaidAPI.md +++ b/docs/config/setup/modules/mermaidAPI.md @@ -98,7 +98,7 @@ mermaid.initialize(config); #### Defined in -[mermaidAPI.ts:635](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L635) +[mermaidAPI.ts:634](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L634) ## Functions @@ -129,7 +129,7 @@ Return the last node appended #### Defined in -[mermaidAPI.ts:277](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L277) +[mermaidAPI.ts:276](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L276) --- @@ -155,7 +155,7 @@ the cleaned up svgCode #### Defined in -[mermaidAPI.ts:223](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L223) +[mermaidAPI.ts:222](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L222) --- @@ -203,7 +203,7 @@ the string with all the user styles #### Defined in -[mermaidAPI.ts:200](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L200) +[mermaidAPI.ts:199](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L199) --- @@ -256,7 +256,7 @@ Put the svgCode into an iFrame. Return the iFrame code #### Defined in -[mermaidAPI.ts:254](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L254) +[mermaidAPI.ts:253](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L253) --- @@ -281,4 +281,4 @@ Remove any existing elements from the given document #### Defined in -[mermaidAPI.ts:327](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L327) +[mermaidAPI.ts:326](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/mermaidAPI.ts#L326) diff --git a/packages/mermaid/src/diagrams/block/blockDB.ts b/packages/mermaid/src/diagrams/block/blockDB.ts index a31466729a..c017d7a0c3 100644 --- a/packages/mermaid/src/diagrams/block/blockDB.ts +++ b/packages/mermaid/src/diagrams/block/blockDB.ts @@ -26,10 +26,11 @@ let classes: Map = new Map(); */ export const addStyleClass = function (id: string, styleAttributes = '') { // create a new style class object with this id - if (!classes.has(id)) { - classes.set(id, { id: id, styles: [], textStyles: [] }); // This is a classDef + let foundClass = classes.get(id); + if (!foundClass) { + foundClass = { id: id, styles: [], textStyles: [] }; + classes.set(id, foundClass); // This is a classDef } - const foundClass = classes.get(id)!; if (styleAttributes !== undefined && styleAttributes !== null) { styleAttributes.split(STYLECLASS_SEP).forEach((attrib) => { // remove any trailing ; @@ -73,13 +74,13 @@ export const setCssClass = function (itemIds: string, cssClassName: string) { let foundBlock = blockDatabase.get(id); if (foundBlock === undefined) { const trimmedId = id.trim(); - blockDatabase.set(trimmedId, { id: trimmedId, type: 'na', children: [] } as Block); - foundBlock = blockDatabase.get(trimmedId); + foundBlock = { id: trimmedId, type: 'na', children: [] } as Block; + blockDatabase.set(trimmedId, foundBlock); } - if (!foundBlock!.classes) { - foundBlock!.classes = []; + if (!foundBlock.classes) { + foundBlock.classes = []; } - foundBlock!.classes.push(cssClassName); + foundBlock.classes.push(cssClassName); }); }; @@ -104,12 +105,9 @@ const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): if (block.type === 'column-setting') { parent.columns = block.columns || -1; } else if (block.type === 'edge') { - if (edgeCount.has(block.id)) { - edgeCount.set(block.id, edgeCount.get(block.id)! + 1); - } else { - edgeCount.set(block.id, 1); - } - block.id = edgeCount.get(block.id)! + '-' + block.id; + const count = (edgeCount.get(block.id) ?? 0) + 1; + edgeCount.set(block.id, count); + block.id = count + '-' + block.id; edgeList.push(block); } else { if (!block.label) { @@ -120,17 +118,17 @@ const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): block.label = block.id; } } - const isCreatingBlock = !blockDatabase.has(block.id); + const existingBlock = blockDatabase.get(block.id); - if (isCreatingBlock) { + if (existingBlock === undefined) { blockDatabase.set(block.id, block); } else { // Add newer relevant data to aggregated node if (block.type !== 'na') { - blockDatabase.get(block.id)!.type = block.type; + existingBlock.type = block.type; } if (block.label !== block.id) { - blockDatabase.get(block.id)!.label = block.label; + existingBlock.label = block.label; } } @@ -146,7 +144,7 @@ const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): blockDatabase.set(newBlock.id, newBlock); children.push(newBlock); } - } else if (isCreatingBlock) { + } else if (existingBlock === undefined) { children.push(block); } } diff --git a/packages/mermaid/src/diagrams/class/classDb.ts b/packages/mermaid/src/diagrams/class/classDb.ts index b3d6f04682..4cfa0bd293 100644 --- a/packages/mermaid/src/diagrams/class/classDb.ts +++ b/packages/mermaid/src/diagrams/class/classDb.ts @@ -226,8 +226,9 @@ export const setCssClass = function (ids: string, className: string) { if (_id[0].match(/\d/)) { id = MERMAID_DOM_ID_PREFIX + id; } - if (classes.has(id)) { - classes.get(id)!.cssClasses.push(className); + const classNode = classes.get(id); + if (classNode) { + classNode.cssClasses.push(className); } }); }; @@ -268,8 +269,8 @@ export const setLink = function (ids: string, linkStr: string, target: string) { if (_id[0].match(/\d/)) { id = MERMAID_DOM_ID_PREFIX + id; } - if (classes.has(id)) { - const theClass = classes.get(id)!; + const theClass = classes.get(id); + if (theClass) { theClass.link = utils.formatUrl(linkStr, config); if (config.securityLevel === 'sandbox') { theClass.linkTarget = '_top'; diff --git a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts index 4a0967f794..efae1874b5 100644 --- a/packages/mermaid/src/diagrams/class/classRenderer-v2.ts +++ b/packages/mermaid/src/diagrams/class/classRenderer-v2.ts @@ -44,14 +44,11 @@ export const addNamespaces = function ( _id: string, diagObj: any ) { - const keys = [...namespaces.keys()]; - log.info('keys:', keys); + log.info('keys:', [...namespaces.keys()]); log.info(namespaces); // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition - keys.forEach(function (id) { - const vertex = namespaces.get(id)!; - + namespaces.forEach(function (vertex) { // parent node must be one of [rect, roundedWithTitle, noteGroup, divider] const shape = 'rect'; @@ -89,16 +86,13 @@ export const addClasses = function ( diagObj: any, parent?: string ) { - const keys = [...classes.keys()]; - log.info('keys:', keys); + log.info('keys:', [...classes.keys()]); log.info(classes); // Iterate through each item in the vertex object (containing all the vertices found) in the graph definition - keys - .filter((id) => classes.get(id)!.parent == parent) - .forEach(function (id) { - const vertex = classes.get(id)!; - + [...classes.values()] + .filter((vertex) => vertex.parent === parent) + .forEach(function (vertex) { /** * Variable for storing the classes for the vertex */ diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.ts index d90cead4d0..797130e71c 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.ts @@ -40,10 +40,9 @@ const sanitizeText = (txt: string) => common.sanitizeText(txt, config); * @param id - id of the node */ export const lookUpDomId = function (id: string) { - const vertexKeys = vertices.keys(); - for (const vertexKey of vertexKeys) { - if (vertices.get(vertexKey)!.id === id) { - return vertices.get(vertexKey)!.domId; + for (const vertex of vertices.values()) { + if (vertex.id === id) { + return vertex.domId; } } return id; @@ -67,17 +66,18 @@ export const addVertex = function ( } let txt; - if (!vertices.has(id)) { - vertices.set(id, { + let vertex = vertices.get(id); + if (vertex === undefined) { + vertex = { id, labelType: 'text', domId: MERMAID_DOM_ID_PREFIX + id + '-' + vertexCounter, styles: [], classes: [], - }); + }; + vertices.set(id, vertex); } vertexCounter++; - const vertex = vertices.get(id)!; if (textObj !== undefined) { config = getConfig(); @@ -210,17 +210,19 @@ export const updateLink = function (positions: ('default' | number)[], style: st export const addClass = function (ids: string, style: string[]) { ids.split(',').forEach(function (id) { - if (!classes.has(id)) { - classes.set(id, { id, styles: [], textStyles: [] }); + let classNode = classes.get(id); + if (classNode === undefined) { + classNode = { id, styles: [], textStyles: [] }; + classes.set(id, classNode); } if (style !== undefined && style !== null) { style.forEach(function (s) { if (s.match('color')) { const newStyle = s.replace('fill', 'bgFill').replace('color', 'fill'); - classes.get(id)!.textStyles.push(newStyle); + classNode.textStyles.push(newStyle); } - classes.get(id)!.styles.push(s); + classNode.styles.push(s); }); } }); @@ -257,11 +259,13 @@ export const setDirection = function (dir: string) { */ export const setClass = function (ids: string, className: string) { for (const id of ids.split(',')) { - if (vertices.has(id)) { - vertices.get(id)!.classes.push(className); + const vertex = vertices.get(id); + if (vertex) { + vertex.classes.push(className); } - if (subGraphLookup.has(id)) { - subGraphLookup.get(id)!.classes.push(className); + const subGraph = subGraphLookup.get(id); + if (subGraph) { + subGraph.classes.push(className); } } }; @@ -305,8 +309,9 @@ const setClickFun = function (id: string, functionName: string, functionArgs: st argList.push(id); } - if (vertices.has(id)) { - vertices.get(id)!.haveCallback = true; + const vertex = vertices.get(id); + if (vertex) { + vertex.haveCallback = true; funs.push(function () { const elem = document.querySelector(`[id="${domId}"]`); if (elem !== null) { @@ -331,7 +336,7 @@ const setClickFun = function (id: string, functionName: string, functionArgs: st */ export const setLink = function (ids: string, linkStr: string, target: string) { ids.split(',').forEach(function (id) { - const vertex = vertices.get(id)!; + const vertex = vertices.get(id); if (vertex !== undefined) { vertex.link = utils.formatUrl(linkStr, config); vertex.linkTarget = target; @@ -341,10 +346,7 @@ export const setLink = function (ids: string, linkStr: string, target: string) { }; export const getTooltip = function (id: string) { - if (tooltips.has(id)) { - return tooltips.get(id)!; - } - return undefined; + return tooltips.get(id); }; /** diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.js b/packages/mermaid/src/diagrams/git/gitGraphAst.js index 269ffa2bf3..dc48a8f4b8 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.js +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.js @@ -479,9 +479,7 @@ export const getCommits = function () { return commits; }; export const getCommitsArray = function () { - const commitArr = [...commits.keys()].map(function (key) { - return commits.get(key); - }); + const commitArr = [...commits.values()]; commitArr.forEach(function (o) { log.debug(o.id); }); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js index 28174e823b..5e9cd98f7b 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js +++ b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js @@ -339,9 +339,7 @@ describe('when parsing a gitGraph', function () { expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); expect(parser.yy.getBranches().size).toBe(2); - const commit1 = commits.keys().next().value; - const commit2 = [...commits.keys()][1]; - const commit3 = [...commits.keys()][2]; + const [commit1, commit2, commit3] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit2).branch).toBe('branch'); expect(commits.get(commit3).branch).toBe('main'); @@ -477,8 +475,7 @@ describe('when parsing a gitGraph', function () { expect(parser.yy.getCurrentBranch()).toBe('testBranch'); expect(parser.yy.getDirection()).toBe('LR'); expect(parser.yy.getBranches().size).toBe(2); - const commit1 = commits.keys().next().value; - const commit2 = [...commits.keys()][1]; + const [commit1, commit2] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); expect(commits.get(commit2).branch).toBe('testBranch'); @@ -502,10 +499,7 @@ describe('when parsing a gitGraph', function () { expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); expect(parser.yy.getBranches().size).toBe(2); - const commit1 = commits.keys().next().value; - const commit2 = [...commits.keys()][1]; - const commit3 = [...commits.keys()][2]; - const commit4 = [...commits.keys()][3]; + const [commit1, commit2, commit3, commit4] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); expect(commits.get(commit2).branch).toBe('testBranch'); @@ -552,8 +546,7 @@ describe('when parsing a gitGraph', function () { expect(parser.yy.getCurrentBranch()).toBe('testBranch'); expect(parser.yy.getDirection()).toBe('LR'); expect(parser.yy.getBranches().size).toBe(2); - const commit1 = commits.keys().next().value; - const commit2 = [...commits.keys()][1]; + const [commit1, commit2] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); expect(commits.get(commit2).branch).toBe('testBranch'); @@ -577,10 +570,7 @@ describe('when parsing a gitGraph', function () { expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); expect(parser.yy.getBranches().size).toBe(2); - const commit1 = commits.keys().next().value; - const commit2 = [...commits.keys()][1]; - const commit3 = [...commits.keys()][2]; - const commit4 = [...commits.keys()][3]; + const [commit1, commit2, commit3, commit4] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); expect(commits.get(commit2).branch).toBe('testBranch'); @@ -614,10 +604,7 @@ describe('when parsing a gitGraph', function () { expect(parser.yy.getCurrentBranch()).toBe('main'); expect(parser.yy.getDirection()).toBe('LR'); expect(parser.yy.getBranches().size).toBe(2); - const commit1 = commits.keys().next().value; - const commit2 = [...commits.keys()][1]; - const commit3 = [...commits.keys()][2]; - + const [commit1, commit2, commit3] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); diff --git a/packages/mermaid/src/diagrams/pie/pieRenderer.ts b/packages/mermaid/src/diagrams/pie/pieRenderer.ts index 0f7b7da9aa..5a3698e1e1 100644 --- a/packages/mermaid/src/diagrams/pie/pieRenderer.ts +++ b/packages/mermaid/src/diagrams/pie/pieRenderer.ts @@ -105,8 +105,8 @@ export const draw: DrawDefinition = (text, id, _version, diagObj) => { .attr('class', 'pieCircle'); let sum = 0; - [...sections.keys()].forEach((key: string): void => { - sum += sections.get(key)!; + sections.forEach((section) => { + sum += section; }); // Now add the percentage. // Use the centroid method to get the best coordinates. diff --git a/packages/mermaid/src/diagrams/requirement/requirementRenderer.js b/packages/mermaid/src/diagrams/requirement/requirementRenderer.js index 274ae98c72..6b51437520 100644 --- a/packages/mermaid/src/diagrams/requirement/requirementRenderer.js +++ b/packages/mermaid/src/diagrams/requirement/requirementRenderer.js @@ -191,9 +191,13 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) { return; }; +/** + * @param {Map} reqs + * @param graph + * @param svgNode + */ export const drawReqs = (reqs, graph, svgNode) => { - [...reqs.keys()].forEach((reqName) => { - let req = reqs.get(reqName); + reqs.forEach((req, reqName) => { reqName = elementString(reqName); log.info('Added new requirement: ', reqName); @@ -236,9 +240,13 @@ export const drawReqs = (reqs, graph, svgNode) => { }); }; +/** + * @param {Map} els + * @param graph + * @param svgNode + */ export const drawElements = (els, graph, svgNode) => { - [...els.keys()].forEach((elName) => { - let el = els.get(elName); + els.forEach((el, elName) => { const id = elementString(elName); const groupNode = svgNode.append('g').attr('id', id); diff --git a/packages/mermaid/src/diagrams/sankey/sankeyDB.ts b/packages/mermaid/src/diagrams/sankey/sankeyDB.ts index d8fa19a68f..735ef045ba 100644 --- a/packages/mermaid/src/diagrams/sankey/sankeyDB.ts +++ b/packages/mermaid/src/diagrams/sankey/sankeyDB.ts @@ -48,11 +48,13 @@ class SankeyNode { const findOrCreateNode = (ID: string): SankeyNode => { ID = common.sanitizeText(ID, getConfig()); - if (!nodesMap.has(ID)) { - nodesMap.set(ID, new SankeyNode(ID)); - nodes.push(nodesMap.get(ID)!); + let node = nodesMap.get(ID); + if (node === undefined) { + node = new SankeyNode(ID); + nodesMap.set(ID, node); + nodes.push(node); } - return nodesMap.get(ID)!; + return node; }; const getNodes = () => nodes; diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDb.ts b/packages/mermaid/src/diagrams/sequence/sequenceDb.ts index 2058cac705..7e6c21b3cb 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDb.ts +++ b/packages/mermaid/src/diagrams/sequence/sequenceDb.ts @@ -99,8 +99,11 @@ export const addActor = function ( rectData: null, type: type ?? 'participant', }); - if (state.records.prevActor && state.records.actors.has(state.records.prevActor)) { - state.records.actors.get(state.records.prevActor)!.nextActor = id; + if (state.records.prevActor) { + const prevActorInRecords = state.records.actors.get(state.records.prevActor); + if (prevActorInRecords) { + prevActorInRecords.nextActor = id; + } } if (state.records.currentBox) { @@ -207,6 +210,7 @@ export const getDestroyedActors = function () { return state.records.destroyedActors; }; export const getActor = function (id: string) { + // TODO: do we ever use this function in a way that it might return undefined? return state.records.actors.get(id)!; }; export const getActorKeys = function () { diff --git a/packages/mermaid/src/diagrams/state/stateDb.js b/packages/mermaid/src/diagrams/state/stateDb.js index 780a531ad6..85c09c5365 100644 --- a/packages/mermaid/src/diagrams/state/stateDb.js +++ b/packages/mermaid/src/diagrams/state/stateDb.js @@ -239,8 +239,6 @@ export const addState = function ( } } - const doc2 = currentDocument.states.get(trimmedId); - if (descr) { log.info('Setting state description', trimmedId, descr); if (typeof descr === 'string') { @@ -253,6 +251,7 @@ export const addState = function ( } if (note) { + const doc2 = currentDocument.states.get(trimmedId); doc2.note = note; doc2.note.text = common.sanitizeText(doc2.note.text, getConfig()); } diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts index b13dd27b55..365467dbd6 100644 --- a/packages/mermaid/src/mermaidAPI.ts +++ b/packages/mermaid/src/mermaidAPI.ts @@ -171,7 +171,7 @@ export const createCssStyles = ( } // classDefs defined in the diagram text - if (!isEmpty(classDefs) && classDefs instanceof Map) { + if (classDefs instanceof Map) { const htmlLabels = config.htmlLabels || config.flowchart?.htmlLabels; // TODO why specifically check the Flowchart diagram config? const cssHtmlElements = ['> *', 'span']; // TODO make a constant @@ -180,8 +180,7 @@ export const createCssStyles = ( const cssElements = htmlLabels ? cssHtmlElements : cssShapeElements; // create the CSS styles needed for each styleClass definition and css element - for (const classId of classDefs!.keys()) { - const styleClassDef = classDefs.get(classId)!; + classDefs.forEach((styleClassDef) => { // create the css styles for each cssElement and the styles (only if there are styles) if (!isEmpty(styleClassDef.styles)) { cssElements.forEach((cssElement) => { @@ -192,7 +191,7 @@ export const createCssStyles = ( if (!isEmpty(styleClassDef.textStyles)) { cssStyles += cssImportantStyles(styleClassDef.id, 'tspan', styleClassDef.textStyles); } - } + }); } return cssStyles; }; From 4f26f3ae2e4e1f25364a811819084b68038823e7 Mon Sep 17 00:00:00 2001 From: Steph <35910788+huynhicode@users.noreply.github.com> Date: Tue, 14 May 2024 00:39:16 -0700 Subject: [PATCH 36/50] docs: Add blog post - Documentation Software (#5519) Add blog post documentation software --- docs/news/blog.md | 8 +++++++- packages/mermaid/src/docs/news/blog.md | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/news/blog.md b/docs/news/blog.md index 3e7e4be4fb..65fa9246e6 100644 --- a/docs/news/blog.md +++ b/docs/news/blog.md @@ -6,9 +6,15 @@ # Blog +## [How to Choose the Right Documentation Software](https://www.mermaidchart.com/blog/posts/how-to-choose-the-right-documentation-software/) + +7 May 2024 · 5 mins + +How to Choose the Right Documentation Software. Reliable and efficient documentation software is crucial in the fast-paced world of software development. + ## [AI in software diagramming: What trends will define the future?](https://www.mermaidchart.com/blog/posts/ai-in-software-diagramming/) -24 April 2024 ·5 mins +24 April 2024 · 5 mins Artificial intelligence (AI) tools are changing the way developers work. diff --git a/packages/mermaid/src/docs/news/blog.md b/packages/mermaid/src/docs/news/blog.md index 5d3c6b9c33..4ada1e05cd 100644 --- a/packages/mermaid/src/docs/news/blog.md +++ b/packages/mermaid/src/docs/news/blog.md @@ -1,8 +1,14 @@ # Blog +## [How to Choose the Right Documentation Software](https://www.mermaidchart.com/blog/posts/how-to-choose-the-right-documentation-software/) + +7 May 2024 · 5 mins + +How to Choose the Right Documentation Software. Reliable and efficient documentation software is crucial in the fast-paced world of software development. + ## [AI in software diagramming: What trends will define the future?](https://www.mermaidchart.com/blog/posts/ai-in-software-diagramming/) -24 April 2024 ·5 mins +24 April 2024 · 5 mins Artificial intelligence (AI) tools are changing the way developers work. From c7fe9a646574597adefe3e6fb2b3707112a151aa Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Tue, 14 May 2024 12:53:41 +0200 Subject: [PATCH 37/50] Fix for proper handling of block-diagram labels --- cypress/integration/other/xss.spec.js | 5 + cypress/platform/xss25.html | 108 ++++++++++++++++++ .../mermaid/src/diagrams/block/blockDB.ts | 8 ++ 3 files changed, 121 insertions(+) create mode 100644 cypress/platform/xss25.html diff --git a/cypress/integration/other/xss.spec.js b/cypress/integration/other/xss.spec.js index 678040f98a..d041fa5f4c 100644 --- a/cypress/integration/other/xss.spec.js +++ b/cypress/integration/other/xss.spec.js @@ -137,4 +137,9 @@ describe('XSS', () => { cy.wait(1000); cy.get('#the-malware').should('not.exist'); }); + it('should sanitize backticks block diagram labels properly', () => { + cy.visit('http://localhost:9000/xss25.html'); + cy.wait(1000); + cy.get('#the-malware').should('not.exist'); + }); }); diff --git a/cypress/platform/xss25.html b/cypress/platform/xss25.html new file mode 100644 index 0000000000..251e1ec23f --- /dev/null +++ b/cypress/platform/xss25.html @@ -0,0 +1,108 @@ + + + + + + + + + + +
Security check
+
+
+
+
+ + + diff --git a/packages/mermaid/src/diagrams/block/blockDB.ts b/packages/mermaid/src/diagrams/block/blockDB.ts index f4881a203b..b343a110c7 100644 --- a/packages/mermaid/src/diagrams/block/blockDB.ts +++ b/packages/mermaid/src/diagrams/block/blockDB.ts @@ -1,9 +1,11 @@ import type { DiagramDB } from '../../diagram-api/types.js'; import type { BlockConfig, BlockType, Block, ClassDef } from './blockTypes.js'; import * as configApi from '../../config.js'; +import { getConfig } from '../../diagram-api/diagramAPI.js'; import { clear as commonClear } from '../common/commonDb.js'; import { log } from '../../logger.js'; import clone from 'lodash-es/clone.js'; +import common from '../common/common.js'; // Initialize the node database for simple lookups let blockDatabase: Record = {}; @@ -14,9 +16,12 @@ const COLOR_KEYWORD = 'color'; const FILL_KEYWORD = 'fill'; const BG_FILL = 'bgFill'; const STYLECLASS_SEP = ','; +const config = getConfig(); let classes = {} as Record; +const sanitizeText = (txt) => common.sanitizeText(txt, config); + /** * Called when the parser comes across a (style) class definition * @example classDef my-style fill:#f96; @@ -87,6 +92,9 @@ const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): const blockList = _blockList.flat(); const children = []; for (const block of blockList) { + if (block.label) { + block.label = sanitizeText(block.label); + } if (block.type === 'classDef') { addStyleClass(block.id, block.css); continue; From dab26df9c4ca69cc4a8c46a22286a2f63ea9ed3e Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Tue, 14 May 2024 12:55:39 +0200 Subject: [PATCH 38/50] Fix for proper handling of block-diagram labels --- packages/mermaid/package.json | 2 +- packages/mermaid/src/diagrams/block/blockDB.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index edb069d98e..1175761ac8 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "10.9.0", + "version": "10.9.1", "description": "Markdown-ish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.", "type": "module", "module": "./dist/mermaid.core.mjs", diff --git a/packages/mermaid/src/diagrams/block/blockDB.ts b/packages/mermaid/src/diagrams/block/blockDB.ts index b343a110c7..a9ccdaa0c5 100644 --- a/packages/mermaid/src/diagrams/block/blockDB.ts +++ b/packages/mermaid/src/diagrams/block/blockDB.ts @@ -20,7 +20,7 @@ const config = getConfig(); let classes = {} as Record; -const sanitizeText = (txt) => common.sanitizeText(txt, config); +const sanitizeText = (txt:string) => common.sanitizeText(txt, config); /** * Called when the parser comes across a (style) class definition From 8d815f878ce7ba3bc820eb62e36b8a96d1debdbc Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Tue, 14 May 2024 13:00:45 +0200 Subject: [PATCH 39/50] Lint fix --- packages/mermaid/src/diagrams/block/blockDB.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/block/blockDB.ts b/packages/mermaid/src/diagrams/block/blockDB.ts index a9ccdaa0c5..f401495a50 100644 --- a/packages/mermaid/src/diagrams/block/blockDB.ts +++ b/packages/mermaid/src/diagrams/block/blockDB.ts @@ -93,7 +93,7 @@ const populateBlockDatabase = (_blockList: Block[] | Block[][], parent: Block): const children = []; for (const block of blockList) { if (block.label) { - block.label = sanitizeText(block.label); + block.label = sanitizeText(block.label); } if (block.type === 'classDef') { addStyleClass(block.id, block.css); From dd92aecdcab953b1a3ebf89f5d7e857019a59056 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Tue, 14 May 2024 18:33:34 -0700 Subject: [PATCH 40/50] chore: address @Yokozuna59's code reviews --- .../src/diagrams/class/parser/class.spec.js | 10 +------- .../src/diagrams/er/parser/erDiagram.spec.js | 23 +++++++------------ .../src/diagrams/flowchart/flowDb.spec.ts | 6 ++--- .../diagrams/sequence/sequenceDiagram.spec.js | 4 ++-- 4 files changed, 14 insertions(+), 29 deletions(-) diff --git a/packages/mermaid/src/diagrams/class/parser/class.spec.js b/packages/mermaid/src/diagrams/class/parser/class.spec.js index d5f1de276c..d611dfc02d 100644 --- a/packages/mermaid/src/diagrams/class/parser/class.spec.js +++ b/packages/mermaid/src/diagrams/class/parser/class.spec.js @@ -8,17 +8,9 @@ describe('class diagram', function () { }); describe('prototype properties', function () { - function validateProperty(prop) { + it.each(['__proto__', 'constructor'])('should work with a %s property', function (prop) { expect(() => parser.parse(`classDiagram\nclass ${prop}`)).not.toThrow(); expect(() => parser.parse(`classDiagram\nnamespace ${prop} {\n\tclass A\n}`)).not.toThrow(); - } - - it('should work with a __proto__ property', function () { - validateProperty('__proto__'); - }); - - it('should work with a constructor property', function () { - validateProperty('constructor'); }); }); }); diff --git a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js index bb747dcc67..e36454f313 100644 --- a/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js +++ b/packages/mermaid/src/diagrams/er/parser/erDiagram.spec.js @@ -794,20 +794,13 @@ describe('when parsing ER diagram it...', function () { }); describe('prototype properties', function () { - function validateProperty(prop) { - expect(() => erDiagram.parser.parse(`erDiagram\n${prop} ||--|{ ORDER : place`)).not.toThrow(); - } - - it('should work with a prototype property', function () { - validateProperty('prototype'); - }); - - it('should work with a __proto__ property', function () { - validateProperty('__proto__'); - }); - - it('should work with a constructor property', function () { - validateProperty('constructor'); - }); + it.each(['__proto__', 'constructor', 'prototype'])( + 'should work with a %s property', + function (prop) { + expect(() => + erDiagram.parser.parse(`erDiagram\n${prop} ||--|{ ORDER : place`) + ).not.toThrow(); + } + ); }); }); diff --git a/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts b/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts index 464faa1824..5983bf04cd 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowDb.spec.ts @@ -53,8 +53,8 @@ describe('flow db addClass', () => { expect(classes.has('a')).toBe(true); expect(classes.has('b')).toBe(true); - expect(classes.get('a')?.['styles']).toEqual(['stroke-width: 8px']); - expect(classes.get('b')?.['styles']).toEqual(['stroke-width: 8px']); + expect(classes.get('a')?.styles).toEqual(['stroke-width: 8px']); + expect(classes.get('b')?.styles).toEqual(['stroke-width: 8px']); }); it('should detect single class', () => { @@ -62,6 +62,6 @@ describe('flow db addClass', () => { const classes = flowDb.getClasses(); expect(classes.has('a')).toBe(true); - expect(classes.get('a')?.['styles']).toEqual(['stroke-width: 8px']); + expect(classes.get('a')?.styles).toEqual(['stroke-width: 8px']); }); }); diff --git a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js index 5fd4ef4cad..97d528df63 100644 --- a/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js +++ b/packages/mermaid/src/diagrams/sequence/sequenceDiagram.spec.js @@ -348,7 +348,7 @@ Bob-->Alice-in-Wonderland:I am good thanks!`; await mermaidAPI.parse(str); const actors = diagram.db.getActors(); - expect([...actors.keys()].sort()).toEqual(['Alice-in-Wonderland', 'Bob']); + expect([...actors.keys()]).toEqual(['Alice-in-Wonderland', 'Bob']); expect(actors.get('Alice-in-Wonderland').description).toBe('Alice-in-Wonderland'); expect(actors.get('Bob').description).toBe('Bob'); @@ -371,7 +371,7 @@ B-->A: I am good thanks!`; const actors = diagram.db.getActors(); - expect([...actors.keys()].sort()).toEqual(['A', 'B']); + expect([...actors.keys()]).toEqual(['A', 'B']); expect(actors.get('A').description).toBe('Alice'); expect(actors.get('B').description).toBe('Bob'); From 9a11cb7bb394fcc2f06017e0993c02d526c0710d Mon Sep 17 00:00:00 2001 From: GRASBOCK <31473223+GRASBOCK@users.noreply.github.com> Date: Mon, 13 May 2024 21:16:12 +0700 Subject: [PATCH 41/50] Update flowchart.md fix callback by setting the window callback to the respective callback function in the jsfiddle and code sample --- packages/mermaid/src/docs/syntax/flowchart.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/mermaid/src/docs/syntax/flowchart.md b/packages/mermaid/src/docs/syntax/flowchart.md index a097e9739a..c8ee020972 100644 --- a/packages/mermaid/src/docs/syntax/flowchart.md +++ b/packages/mermaid/src/docs/syntax/flowchart.md @@ -557,7 +557,7 @@ Examples of tooltip usage below: ```html @@ -578,7 +578,7 @@ flowchart LR > **Success** The tooltip functionality and the ability to link to urls are available from version 0.5.2. -?> Due to limitations with how Docsify handles JavaScript callback functions, an alternate working demo for the above code can be viewed at [this jsfiddle](https://jsfiddle.net/Ogglas/2o73vdez/7). +?> Due to limitations with how Docsify handles JavaScript callback functions, an alternate working demo for the above code can be viewed at [this jsfiddle](https://jsfiddle.net/yk4h7qou/2/). Links are opened in the same browser tab/window by default. It is possible to change this by adding a link target to the click definition (`_self`, `_blank`, `_parent` and `_top` are supported): @@ -610,7 +610,7 @@ Beginner's tip—a full example using interactive links in a html context: @@ -899,7 +899,7 @@ flowchart LR > **Success** The tooltip functionality and the ability to link to urls are available from version 0.5.2. -?> Due to limitations with how Docsify handles JavaScript callback functions, an alternate working demo for the above code can be viewed at [this jsfiddle](https://jsfiddle.net/Ogglas/2o73vdez/7). +?> Due to limitations with how Docsify handles JavaScript callback functions, an alternate working demo for the above code can be viewed at [this jsfiddle](https://jsfiddle.net/yk4h7qou/2/). Links are opened in the same browser tab/window by default. It is possible to change this by adding a link target to the click definition (`_self`, `_blank`, `_parent` and `_top` are supported): @@ -943,7 +943,7 @@ Beginner's tip—a full example using interactive links in a html context: