From 1d0e98dd62541f1aeea6b1030a48aff559aae9ae Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sun, 21 Jul 2024 19:50:59 -0400 Subject: [PATCH 001/124] Added the langium module for gitGraph --- .../src/diagrams/git/parser/gitGraph.jison | 1 + packages/parser/langium-config.json | 5 + .../src/language/gitGraph/gitGraph.langium | 84 ++++++++++++++++ .../parser/src/language/gitGraph/index.ts | 1 + .../parser/src/language/gitGraph/module.ts | 53 ++++++++++ .../src/language/gitGraph/tokenBuilder.ts | 7 ++ packages/parser/src/language/index.ts | 10 ++ packages/parser/src/parse.ts | 11 ++- packages/parser/tests/gitGraph.test.ts | 99 +++++++++++++++++++ packages/parser/tests/test-util.ts | 26 ++++- 10 files changed, 293 insertions(+), 4 deletions(-) create mode 100644 packages/parser/src/language/gitGraph/gitGraph.langium create mode 100644 packages/parser/src/language/gitGraph/index.ts create mode 100644 packages/parser/src/language/gitGraph/module.ts create mode 100644 packages/parser/src/language/gitGraph/tokenBuilder.ts create mode 100644 packages/parser/tests/gitGraph.test.ts diff --git a/packages/mermaid/src/diagrams/git/parser/gitGraph.jison b/packages/mermaid/src/diagrams/git/parser/gitGraph.jison index fa2c70586..56ba1465e 100644 --- a/packages/mermaid/src/diagrams/git/parser/gitGraph.jison +++ b/packages/mermaid/src/diagrams/git/parser/gitGraph.jison @@ -138,6 +138,7 @@ mergeStatement | MERGE ref commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $5, $7, $3)} ; + commitStatement : COMMIT commit_arg {yy.commit($2)} | COMMIT commitTags {yy.commit('','',yy.commitType.NORMAL,$2)} diff --git a/packages/parser/langium-config.json b/packages/parser/langium-config.json index c750f049d..af8a4cfe6 100644 --- a/packages/parser/langium-config.json +++ b/packages/parser/langium-config.json @@ -15,6 +15,11 @@ "id": "pie", "grammar": "src/language/pie/pie.langium", "fileExtensions": [".mmd", ".mermaid"] + }, + { + "id": "gitGraph", + "grammar": "src/language/gitGraph/gitGraph.langium", + "fileExtensions": [".mmd", ".mermaid"] } ], "mode": "production", diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium new file mode 100644 index 000000000..4956a80a4 --- /dev/null +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -0,0 +1,84 @@ +grammar GitGraph + +import "../common/common"; +entry GitGraph: + NEWLINE* + 'gitGraph' Direction? ':'? + NEWLINE* + ( + Options? + NEWLINE* + (TitleAndAccessibilities | + statements+=Statement | + NEWLINE)* + ) +; + +Statement +: Commit +| Branch +| Merge +| Checkout +| CherryPicking +; + + +Options: + 'options' '{' rawOptions+=STRING* '}' EOL; + +Direction: + dir=('LR' | 'TB' | 'BT') EOL; + +Commit: + 'commit' properties+=CommitProperty* EOL; + +CommitProperty +: CommitId +| CommitMessage +| Tags +| CommitType +; + +CommitId: + 'id:' id=STRING; + +CommitMessage: + 'msg:'? message=STRING; + +Tags: + 'tag:' tags=STRING; + +CommitType: + 'type:' name=('NORMAL' | 'REVERSE' | 'HIGHLIGHT'); + +Branch: + 'branch' name=(ID|STRING) ('order:' order=INT)? EOL; + +Merge: + 'merge' name=(ID|STRING) properties+=MergeProperties* EOL; + +MergeProperties +: CommitId +| Tags +| CommitType +; + +Checkout: + ('checkout'|'switch') id=(ID|STRING) EOL; + +CherryPicking: + 'cherry-pick' properties+=CherryPickProperties* EOL; + +CherryPickProperties +: CommitId +| Tags +| ParentCommit +; + +ParentCommit: + 'parent:' id=STRING; + +terminal INT returns number: /[0-9]+(?=\s)/; +terminal ID returns string: /\w([-\./\w]*[-\w])?/; +terminal STRING: /"[^"]*"|'[^']*'/; + diff --git a/packages/parser/src/language/gitGraph/index.ts b/packages/parser/src/language/gitGraph/index.ts new file mode 100644 index 000000000..fd3c604b0 --- /dev/null +++ b/packages/parser/src/language/gitGraph/index.ts @@ -0,0 +1 @@ +export * from './module.js'; diff --git a/packages/parser/src/language/gitGraph/module.ts b/packages/parser/src/language/gitGraph/module.ts new file mode 100644 index 000000000..1630377e5 --- /dev/null +++ b/packages/parser/src/language/gitGraph/module.ts @@ -0,0 +1,53 @@ +import type { + DefaultSharedCoreModuleContext, + LangiumCoreServices, + LangiumSharedCoreServices, + Module, + PartialLangiumCoreServices, +} from 'langium'; +import { + inject, + createDefaultCoreModule, + createDefaultSharedCoreModule, + EmptyFileSystem, +} from 'langium'; + +import { CommonValueConverter } from '../common/valueConverter.js'; +import { MermaidGeneratedSharedModule, GitGraphGeneratedModule } from '../generated/module.js'; +import { GitGraphTokenBuilder } from './tokenBuilder.js'; + +interface GitGraphAddedServices { + parser: { + TokenBuilder: GitGraphTokenBuilder; + ValueConverter: CommonValueConverter; + }; +} + +export type GitGraphServices = LangiumCoreServices & GitGraphAddedServices; + +export const GitGraphModule: Module< + GitGraphServices, + PartialLangiumCoreServices & GitGraphAddedServices +> = { + parser: { + TokenBuilder: () => new GitGraphTokenBuilder(), + ValueConverter: () => new CommonValueConverter(), + }, +}; + +export function createGitGraphServices(context: DefaultSharedCoreModuleContext = EmptyFileSystem): { + shared: LangiumSharedCoreServices; + GitGraph: GitGraphServices; +} { + const shared: LangiumSharedCoreServices = inject( + createDefaultSharedCoreModule(context), + MermaidGeneratedSharedModule + ); + const GitGraph: GitGraphServices = inject( + createDefaultCoreModule({ shared }), + GitGraphGeneratedModule, + GitGraphModule + ); + shared.ServiceRegistry.register(GitGraph); + return { shared, GitGraph }; +} diff --git a/packages/parser/src/language/gitGraph/tokenBuilder.ts b/packages/parser/src/language/gitGraph/tokenBuilder.ts new file mode 100644 index 000000000..ccadf1a1f --- /dev/null +++ b/packages/parser/src/language/gitGraph/tokenBuilder.ts @@ -0,0 +1,7 @@ +import { AbstractMermaidTokenBuilder } from '../common/index.js'; + +export class GitGraphTokenBuilder extends AbstractMermaidTokenBuilder { + public constructor() { + super(['gitGraph']); + } +} diff --git a/packages/parser/src/language/index.ts b/packages/parser/src/language/index.ts index 9f1d92ba8..377013795 100644 --- a/packages/parser/src/language/index.ts +++ b/packages/parser/src/language/index.ts @@ -5,20 +5,30 @@ export { PacketBlock, Pie, PieSection, + GitGraph, + Branch, + Commit, + Merge, isCommon, isInfo, isPacket, isPacketBlock, isPie, isPieSection, + isGitGraph, + isBranch, + isCommit, + isMerge, } from './generated/ast.js'; export { InfoGeneratedModule, MermaidGeneratedSharedModule, PacketGeneratedModule, PieGeneratedModule, + GitGraphGeneratedModule, } from './generated/module.js'; +export * from './gitGraph/index.js'; export * from './common/index.js'; export * from './info/index.js'; export * from './packet/index.js'; diff --git a/packages/parser/src/parse.ts b/packages/parser/src/parse.ts index 992b96506..233faed00 100644 --- a/packages/parser/src/parse.ts +++ b/packages/parser/src/parse.ts @@ -1,8 +1,8 @@ import type { LangiumParser, ParseResult } from 'langium'; -import type { Info, Packet, Pie } from './index.js'; +import type { Info, Packet, Pie, GitGraph } from './index.js'; -export type DiagramAST = Info | Packet | Pie; +export type DiagramAST = Info | Packet | Pie | GitGraph; const parsers: Record = {}; const initializers = { @@ -21,11 +21,18 @@ const initializers = { const parser = createPieServices().Pie.parser.LangiumParser; parsers.pie = parser; }, + gitGraph: async () => { + const { createGitGraphServices } = await import('./language/gitGraph/index.js'); + const parser = createGitGraphServices().GitGraph.parser.LangiumParser; + parsers.gitGraph = parser; + }, } as const; export async function parse(diagramType: 'info', text: string): Promise; export async function parse(diagramType: 'packet', text: string): Promise; export async function parse(diagramType: 'pie', text: string): Promise; +export async function parse(diagramType: 'gitGraph', text: string): Promise; + export async function parse( diagramType: keyof typeof initializers, text: string diff --git a/packages/parser/tests/gitGraph.test.ts b/packages/parser/tests/gitGraph.test.ts new file mode 100644 index 000000000..e00ddfae8 --- /dev/null +++ b/packages/parser/tests/gitGraph.test.ts @@ -0,0 +1,99 @@ +import { describe, expect, it } from 'vitest'; +import { GitGraph } from '../src/language/index.js'; +import { gitGraphParse as parse } from './test-util.js'; + +describe('gitGraph', () => { + describe('Basic Parsing', () => { + it('should handle empty gitGraph', () => { + const result = parse(`gitGraph`); + expect(result.value.$type).toBe(GitGraph); + expect(result.value.statements).toHaveLength(0); + }); + + it('should handle multiple commits', () => { + const result = parse(` + gitGraph + commit + commit + `); + expect(result.value.$type).toBe(GitGraph); + expect(result.value.statements).toHaveLength(2); + expect( + result.value.statements.every((s: { $type: string }) => s.$type === 'Commit') + ).toBeTruthy(); + }); + + it('should handle branches and checkouts', () => { + const result = parse(` + gitGraph + branch feature + branch release + checkout feature + `); + expect(result.value.statements).toHaveLength(3); + expect(result.value.statements[0].$type).toBe('Branch'); + expect(result.value.statements[0].name).toBe('feature'); + expect(result.value.statements[1].$type).toBe('Branch'); + expect(result.value.statements[1].name).toBe('release'); + expect(result.value.statements[2].$type).toBe('Checkout'); + expect(result.value.statements[2].id).toBe('feature'); + }); + + it('should handle merges', () => { + const result = parse(` + gitGraph + branch feature + commit id: "A" + merge feature id: "M" + `); + expect(result.value.statements).toHaveLength(3); + expect(result.value.statements[2].$type).toBe('Merge'); + expect(result.value.statements[2].name).toBe('feature'); + expect(result.value.statements[2].properties[0].id).toBe('M'); + }); + + it('should handle cherry-picking with tags and parent', () => { + const result = parse(` + gitGraph + branch feature + commit id: "M" + checkout main + cherry-pick id: "M" tag: "v2.1:ZERO" parent:"ZERO" + `); + expect(result.value.statements).toHaveLength(4); + expect(result.value.statements[3].$type).toBe('CherryPicking'); + expect(result.value.statements[3].properties.length).toBe(3); + expect(result.value.statements[3].properties[0].id).toBe('M'); + expect(result.value.statements[3].properties[1].tags).toBe('v2.1:ZERO'); + expect(result.value.statements[3].properties[2].id).toBe('ZERO'); + }); + + it('should parse complex gitGraph interactions', () => { + const result = parse(` + gitGraph + commit id: "ZERO" + branch feature + branch release + checkout feature + commit id: "A" + commit id: "B" + checkout main + merge feature id: "M" + checkout release + commit id: "C" + cherry-pick id: "M" tag: "v2.1:ZERO" parent:"ZERO" + commit id: "D" + `); + expect(result.value.statements).toHaveLength(12); + expect(result.value.statements[0].$type).toBe('Commit'); + expect(result.value.statements[0].properties[0].id).toBe('ZERO'); + expect(result.value.statements[1].$type).toBe('Branch'); + expect(result.value.statements[6].$type).toBe('Merge'); + expect(result.value.statements[10].$type).toBe('CherryPicking'); + expect(result.value.statements[10].properties[0].id).toBe('M'); + expect(result.value.statements[10].properties[2].id).toBe('ZERO'); + expect(result.value.statements[11].$type).toBe('Commit'); + expect(result.value.statements[11].properties[0].id).toBe('D'); + }); + }); +}); diff --git a/packages/parser/tests/test-util.ts b/packages/parser/tests/test-util.ts index 9bdec348a..5cb487758 100644 --- a/packages/parser/tests/test-util.ts +++ b/packages/parser/tests/test-util.ts @@ -1,7 +1,18 @@ import type { LangiumParser, ParseResult } from 'langium'; import { expect, vi } from 'vitest'; -import type { Info, InfoServices, Pie, PieServices } from '../src/language/index.js'; -import { createInfoServices, createPieServices } from '../src/language/index.js'; +import type { + Info, + InfoServices, + Pie, + PieServices, + GitGraph, + GitGraphServices, +} from '../src/language/index.js'; +import { + createInfoServices, + createPieServices, + createGitGraphServices, +} from '../src/language/index.js'; const consoleMock = vi.spyOn(console, 'log').mockImplementation(() => undefined); @@ -40,3 +51,14 @@ export function createPieTestServices() { return { services: pieServices, parse }; } export const pieParse = createPieTestServices().parse; + +const gitGraphServices: GitGraphServices = createGitGraphServices().GitGraph; +const gitGraphParser: LangiumParser = gitGraphServices.parser.LangiumParser; +export function createGitGraphTestServices() { + const parse = (input: string) => { + return gitGraphParser.parse(input); + }; + + return { services: gitGraphServices, parse }; +} +export const gitGraphParse = createGitGraphTestServices().parse; From 6f7c291512ad54093f2e42beac86126bdf4fbc67 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Mon, 22 Jul 2024 04:10:36 -0400 Subject: [PATCH 002/124] Added gitGraphAst as typescript added gitGraphTypes and gitGraphParser --- .../git/{gitGraphAst.js => gitGraphAst.ts} | 265 +++++++++++------- .../src/diagrams/git/gitGraphParser.ts | 72 +++++ .../mermaid/src/diagrams/git/gitGraphTypes.ts | 55 ++++ .../src/language/gitGraph/gitGraph.langium | 70 ++--- packages/parser/tests/gitGraph.test.ts | 85 +----- 5 files changed, 312 insertions(+), 235 deletions(-) rename packages/mermaid/src/diagrams/git/{gitGraphAst.js => gitGraphAst.ts} (64%) create mode 100644 packages/mermaid/src/diagrams/git/gitGraphParser.ts create mode 100644 packages/mermaid/src/diagrams/git/gitGraphTypes.ts diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.js b/packages/mermaid/src/diagrams/git/gitGraphAst.ts similarity index 64% rename from packages/mermaid/src/diagrams/git/gitGraphAst.js rename to packages/mermaid/src/diagrams/git/gitGraphAst.ts index cebc4fc3e..b04e78d8c 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.js +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -11,16 +11,20 @@ import { setDiagramTitle, getDiagramTitle, } from '../common/commonDb.js'; +import defaultConfig from '../../defaultConfig.js'; +import type { DiagramOrientation, Commit } from './gitGraphTypes.js'; -let { mainBranchName, mainBranchOrder } = getConfig().gitGraph; -let commits = new Map(); -let head = null; -let branchesConfig = new Map(); +const mainBranchName = defaultConfig.gitGraph.mainBranchName; +const mainBranchOrder = defaultConfig.gitGraph.mainBranchOrder; + +let commits = new Map(); +let head: Commit | null = null; +let branchesConfig = new Map(); branchesConfig.set(mainBranchName, { name: mainBranchName, order: mainBranchOrder }); -let branches = new Map(); -branches.set(mainBranchName, head); +let branches = new Map(); +branches.set(mainBranchName, null); let curBranch = mainBranchName; -let direction = 'LR'; +let direction: DiagramOrientation = 'LR'; let seq = 0; /** @@ -57,8 +61,8 @@ function getId() { // } /** - * @param currentCommit - * @param otherCommit + * @param currentCommit - current commit + * @param otherCommit - other commit */ // function isReachableFrom(currentCommit, otherCommit) { // const currentSeq = currentCommit.seq; @@ -68,10 +72,10 @@ function getId() { // } /** - * @param list - * @param fn + * @param list - list of items + * @param fn - function to get the key */ -function uniqBy(list, fn) { +function uniqBy(list: any[], fn: (item: any) => any) { const recordMap = Object.create(null); return list.reduce((out, item) => { const key = fn(item); @@ -83,17 +87,18 @@ function uniqBy(list, fn) { }, []); } -export const setDirection = function (dir) { +export const setDirection = function (dir: DiagramOrientation) { direction = dir; }; + let options = {}; -export const setOptions = function (rawOptString) { +export const setOptions = function (rawOptString: string) { log.debug('options str', rawOptString); rawOptString = rawOptString?.trim(); rawOptString = rawOptString || '{}'; try { options = JSON.parse(rawOptString); - } catch (e) { + } catch (e: any) { log.error('error while parsing gitGraph options', e.message); } }; @@ -102,60 +107,65 @@ export const getOptions = function () { return options; }; -export const commit = function (msg, id, type, tags) { - log.debug('Entering commit:', msg, id, type, tags); - const config = getConfig(); - id = common.sanitizeText(id, config); - msg = common.sanitizeText(msg, config); - tags = tags?.map((tag) => common.sanitizeText(tag, config)); - const commit = { +export const commit = function (msg: string, id: string, type: number, tag: string) { + log.info('commit', msg, id, type, tag); + log.debug('Entering commit:', msg, id, type, tag); + id = common.sanitizeText(id, getConfig()); + msg = common.sanitizeText(msg, getConfig()); + tag = common.sanitizeText(tag, getConfig()); + const newCommit: Commit = { id: id ? id : seq + '-' + getId(), message: msg, seq: seq++, - type: type ? type : commitType.NORMAL, - tags: tags ?? [], + type: type, + tag: tag ? tag : '', parents: head == null ? [] : [head.id], branch: curBranch, }; - head = commit; - commits.set(commit.id, commit); - branches.set(curBranch, commit.id); - log.debug('in pushCommit ' + commit.id); + head = newCommit; + log.info('main branch', mainBranchName); + commits.set(newCommit.id, newCommit); + branches.set(curBranch, newCommit.id); + log.debug('in pushCommit ' + newCommit.id); }; -export const branch = function (name, order) { +export const branch = function (name: string, order: number) { name = common.sanitizeText(name, getConfig()); if (!branches.has(name)) { branches.set(name, head != null ? head.id : null); - branchesConfig.set(name, { name, order: order ? parseInt(order, 10) : null }); + branchesConfig.set(name, { name, order }); checkout(name); log.debug('in createBranch'); } else { - let error = new Error( - 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ' + - name + - '")' + throw new Error( + `Trying to create an existing branch: ${name}. Use 'checkout ${name}' instead.` ); - error.hash = { - text: 'branch ' + name, - token: 'branch ' + name, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, - expected: ['"checkout ' + name + '"'], - }; - throw error; } }; -export const merge = function (otherBranch, custom_id, override_type, custom_tags) { - const config = getConfig(); - otherBranch = common.sanitizeText(otherBranch, config); - custom_id = common.sanitizeText(custom_id, config); - - const currentCommit = commits.get(branches.get(curBranch)); - const otherCommit = commits.get(branches.get(otherBranch)); +export const merge = ( + otherBranch: string, + custom_id?: string, + override_type?: number, + custom_tag?: string +): void => { + otherBranch = common.sanitizeText(otherBranch, getConfig()); + if (custom_id) { + custom_id = common.sanitizeText(custom_id, getConfig()); + } + const currentBranchCheck: string | null | undefined = branches.get(curBranch); + const otherBranchCheck: string | null | undefined = branches.get(otherBranch); + const currentCommit: Commit | undefined = currentBranchCheck + ? commits.get(currentBranchCheck) + : undefined; + const otherCommit: Commit | undefined = otherBranchCheck + ? commits.get(otherBranchCheck) + : undefined; + if (currentCommit && otherCommit && currentCommit.branch === otherBranch) { + throw new Error(`Cannot merge branch '${otherBranch}' into itself.`); + } if (curBranch === otherBranch) { - let error = new Error('Incorrect usage of "merge". Cannot merge a branch to itself'); + const error: any = new Error('Incorrect usage of "merge". Cannot merge a branch to itself'); error.hash = { text: 'merge ' + otherBranch, token: 'merge ' + otherBranch, @@ -165,7 +175,7 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag }; throw error; } else if (currentCommit === undefined || !currentCommit) { - let error = new Error( + const error: any = new Error( 'Incorrect usage of "merge". Current branch (' + curBranch + ')has no commits' ); error.hash = { @@ -177,7 +187,7 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag }; throw error; } else if (!branches.has(otherBranch)) { - let error = new Error( + const error: any = new Error( 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ') does not exist' ); error.hash = { @@ -189,7 +199,7 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag }; throw error; } else if (otherCommit === undefined || !otherCommit) { - let error = new Error( + const error: any = new Error( 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ') has no commits' ); error.hash = { @@ -201,7 +211,7 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag }; throw error; } else if (currentCommit === otherCommit) { - let error = new Error('Incorrect usage of "merge". Both branches have same head'); + const error: any = new Error('Incorrect usage of "merge". Both branches have same head'); error.hash = { text: 'merge ' + otherBranch, token: 'merge ' + otherBranch, @@ -211,23 +221,24 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag }; throw error; } else if (custom_id && commits.has(custom_id)) { - let error = new Error( + const error: any = new Error( 'Incorrect usage of "merge". Commit with id:' + custom_id + ' already exists, use different custom Id' ); error.hash = { - text: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(','), - token: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(','), + text: 'merge ' + otherBranch + custom_id + override_type + custom_tag, + token: 'merge ' + otherBranch + custom_id + override_type + custom_tag, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: [ - `merge ${otherBranch} ${custom_id}_UNIQUE ${override_type} ${custom_tags?.join(',')}`, + 'merge ' + otherBranch + ' ' + custom_id + '_UNIQUE ' + override_type + ' ' + custom_tag, ], }; throw error; } + // if (isReachableFrom(currentCommit, otherCommit)) { // log.debug('Already merged'); // return; @@ -237,16 +248,19 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag // head = commits.get(branches.get(curBranch)); // } else { // create merge commit - const commit = { + + const verifiedBranch: string = otherBranchCheck ? otherBranchCheck : ''; //figure out a cleaner way to do this + + const commit: Commit = { id: custom_id ? custom_id : seq + '-' + getId(), message: 'merged branch ' + otherBranch + ' into ' + curBranch, seq: seq++, - parents: [head == null ? null : head.id, branches.get(otherBranch)], + parents: [head == null ? null : head.id, verifiedBranch], branch: curBranch, type: commitType.MERGE, - customType: override_type, - customId: custom_id ? true : false, - tags: custom_tags ? custom_tags : [], + customType: override_type, //TODO - need to make customType optional + customId: custom_id, //TODO - need to make customId optional as well as tag + tag: custom_tag ? custom_tag : '', }; head = commit; commits.set(commit.id, commit); @@ -256,16 +270,20 @@ export const merge = function (otherBranch, custom_id, override_type, custom_tag log.debug('in mergeBranch'); }; -export const cherryPick = function (sourceId, targetId, tags, parentCommitId) { - log.debug('Entering cherryPick:', sourceId, targetId, tags); - const config = getConfig(); - sourceId = common.sanitizeText(sourceId, config); - targetId = common.sanitizeText(targetId, config); - tags = tags?.map((tag) => common.sanitizeText(tag, config)); - parentCommitId = common.sanitizeText(parentCommitId, config); +export const cherryPick = function ( + sourceId: string, + targetId: string, + tag: string, + parentCommitId: string +) { + log.debug('Entering cherryPick:', sourceId, targetId, tag); + sourceId = common.sanitizeText(sourceId, getConfig()); + targetId = common.sanitizeText(targetId, getConfig()); + tag = common.sanitizeText(tag, getConfig()); + parentCommitId = common.sanitizeText(parentCommitId, getConfig()); if (!sourceId || !commits.has(sourceId)) { - let error = new Error( + const error: any = new Error( 'Incorrect usage of "cherryPick". Source commit id should exist and provided' ); error.hash = { @@ -277,19 +295,22 @@ export const cherryPick = function (sourceId, targetId, tags, parentCommitId) { }; throw error; } - let sourceCommit = commits.get(sourceId); - let sourceCommitBranch = sourceCommit.branch; + + const sourceCommit = commits.get(sourceId); + if ( - parentCommitId && - !(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId)) + !sourceCommit || + !parentCommitId || + !Array.isArray(sourceCommit.parents) || + !sourceCommit.parents.includes(parentCommitId) ) { - let error = new Error( + throw new Error( 'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.' ); - throw error; } + const sourceCommitBranch = sourceCommit.branch; if (sourceCommit.type === commitType.MERGE && !parentCommitId) { - let error = new Error( + const error = new Error( 'Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.' ); throw error; @@ -298,7 +319,7 @@ export const cherryPick = function (sourceId, targetId, tags, parentCommitId) { // cherry-pick source commit to current branch if (sourceCommitBranch === curBranch) { - let error = new Error( + const error: any = new Error( 'Incorrect usage of "cherryPick". Source commit is already on current branch' ); error.hash = { @@ -310,9 +331,24 @@ export const cherryPick = function (sourceId, targetId, tags, parentCommitId) { }; throw error; } - const currentCommit = commits.get(branches.get(curBranch)); + const currentCommitId = branches.get(curBranch); + if (currentCommitId === undefined || !currentCommitId) { + const error: any = new Error( + 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ')has no commits' + ); + error.hash = { + text: 'cherryPick ' + sourceId + ' ' + targetId, + token: 'cherryPick ' + sourceId + ' ' + targetId, + line: '1', + loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, + expected: ['cherry-pick abc'], + }; + throw error; + } + + const currentCommit = commits.get(currentCommitId); if (currentCommit === undefined || !currentCommit) { - let error = new Error( + const error: any = new Error( 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ')has no commits' ); error.hash = { @@ -326,18 +362,16 @@ export const cherryPick = function (sourceId, targetId, tags, parentCommitId) { } const commit = { id: seq + '-' + getId(), - message: 'cherry-picked ' + sourceCommit + ' into ' + curBranch, + message: 'cherry-picked ' + sourceCommit?.message + ' into ' + curBranch, seq: seq++, parents: [head == null ? null : head.id, sourceCommit.id], branch: curBranch, type: commitType.CHERRY_PICK, - tags: tags - ? tags.filter(Boolean) - : [ - `cherry-pick:${sourceCommit.id}${ - sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : '' - }`, - ], + tag: + tag ?? + `cherry-pick:${sourceCommit.id}${ + sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : '' + }`, }; head = commit; commits.set(commit.id, commit); @@ -346,10 +380,10 @@ export const cherryPick = function (sourceId, targetId, tags, parentCommitId) { log.debug('in cherryPick'); } }; -export const checkout = function (branch) { +export const checkout = function (branch: string) { branch = common.sanitizeText(branch, getConfig()); if (!branches.has(branch)) { - let error = new Error( + const error: any = new Error( 'Trying to checkout branch which is not yet created. (Help try using "branch ' + branch + '")' ); error.hash = { @@ -360,10 +394,19 @@ export const checkout = function (branch) { expected: ['"branch ' + branch + '"'], }; throw error; + //branches[branch] = head != null ? head.id : null; + //log.debug('in createBranch'); } else { curBranch = branch; const id = branches.get(curBranch); - head = commits.get(id); + + if (id === null || id === undefined) { + throw new Error('Branch ' + branch + ' has no commits'); + } + if (commits.get(id) === undefined) { + throw new Error('Branch ' + branch + ' has no commits'); + } + head = commits.get(id) ?? null; } }; @@ -387,11 +430,11 @@ export const checkout = function (branch) { // }; /** - * @param arr - * @param key - * @param newVal + * @param arr - array + * @param key - key + * @param newVal - new value */ -function upsert(arr, key, newVal) { +function upsert(arr: any[], key: any, newVal: any) { const index = arr.indexOf(key); if (index === -1) { arr.push(newVal); @@ -400,8 +443,8 @@ function upsert(arr, key, newVal) { } } -/** @param commitArr */ -function prettyPrintCommitHistory(commitArr) { +/** @param commitArr - array */ +function prettyPrintCommitHistory(commitArr: Commit[]) { const commit = commitArr.reduce((out, commit) => { if (out.seq > commit.seq) { return out; @@ -417,21 +460,25 @@ function prettyPrintCommitHistory(commitArr) { } }); const label = [line, commit.id, commit.seq]; - for (let branch in branches) { + for (const branch in branches) { if (branches.get(branch) === commit.id) { label.push(branch); } } log.debug(label.join(' ')); - if (commit.parents && commit.parents.length == 2) { + if (commit.parents && commit.parents.length == 2 && commit.parents[0] && commit.parents[1]) { const newCommit = commits.get(commit.parents[0]); upsert(commitArr, commit, newCommit); - commitArr.push(commits.get(commit.parents[1])); + if (commit.parents[1]) { + commitArr.push(commits.get(commit.parents[1])!); + } } else if (commit.parents.length == 0) { return; } else { - const nextCommit = commits.get(commit.parents); - upsert(commitArr, commit, nextCommit); + if (commit.parents[0]) { + const newCommit = commits.get(commit.parents[0]); + upsert(commitArr, commit, newCommit); + } } commitArr = uniqBy(commitArr, (c) => c.id); prettyPrintCommitHistory(commitArr); @@ -446,12 +493,13 @@ export const prettyPrint = function () { export const clear = function () { commits = new Map(); head = null; - const { mainBranchName, mainBranchOrder } = getConfig().gitGraph; + const mainBranch = defaultConfig.gitGraph.mainBranchName; + const mainBranchOrder = defaultConfig.gitGraph.mainBranchOrder; branches = new Map(); - branches.set(mainBranchName, null); + branches.set(mainBranch, null); branchesConfig = new Map(); - branchesConfig.set(mainBranchName, { name: mainBranchName, order: mainBranchOrder }); - curBranch = mainBranchName; + branchesConfig.set(mainBranch, { name: mainBranch, order: mainBranchOrder }); + curBranch = mainBranch; seq = 0; commonClear(); }; @@ -464,7 +512,7 @@ export const getBranchesAsObjArray = function () { } return { ...branchConfig, - order: parseFloat(`0.${i}`, 10), + order: parseFloat(`0.${i}`), }; }) .sort((a, b) => a.order - b.order) @@ -531,5 +579,4 @@ export default { setAccDescription, setDiagramTitle, getDiagramTitle, - commitType, }; diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts new file mode 100644 index 000000000..713992e0f --- /dev/null +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -0,0 +1,72 @@ +import type { GitGraph } from '@mermaid-js/parser'; +import { parse } from '@mermaid-js/parser'; +import type { ParserDefinition } from '../../diagram-api/types.js'; +import { log } from '../../logger.js'; +import { populateCommonDb } from '../common/populateCommonDb.js'; +import db from './gitGraphAst.js'; +import type { + Statement, + CommitAst, + Branch, + Merge, + Checkout, + CherryPicking, +} from './gitGraphTypes.js'; + +const populate = (ast: any) => { + populateCommonDb(ast, db); + for (const statement of ast.statements) { + parseStatement(statement); + } +}; + +const parseStatement = (statement: Statement) => { + switch (statement.$type) { + case 'Commit': + parseCommit(statement); + break; + case 'Branch': + parseBranch(statement); + break; + case 'Merge': + parseMerge(statement); + break; + case 'Checkout': + parseCheckout(statement); + break; + case 'CherryPicking': + parseCherryPicking(statement); + break; + default: + throw new Error(`Unknown statement type: ${(statement as any).$type}`); + } +}; + +function parseCommit(commit: CommitAst) { + const message = commit.message ?? ''; + db.commit(message, commit.id, commit.tags, commit.type); +} + +function parseBranch(branch: Branch) { + db.branch(branch.name, branch.order); +} + +function parseMerge(merge: Merge) { + db.merge(merge.branch, merge.id, merge.tags, merge.type); +} + +function parseCheckout(checkout: Checkout) { + db.checkout(checkout.branch); +} + +function parseCherryPicking(cherryPicking: CherryPicking) { + db.cherryPick(cherryPicking.id, cherryPicking.tags, cherryPicking.parent); +} + +export const parser: ParserDefinition = { + parse: async (input: string): Promise => { + const ast: GitGraph = await parse('gitGraph', input); + log.debug(ast); + populate(ast); + }, +}; diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts new file mode 100644 index 000000000..da7567b8d --- /dev/null +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -0,0 +1,55 @@ +export type CommitType = 'NORMAL' | 'REVERSE' | 'HIGHLIGHT' | 'MERGE' | 'CHERRY_PICK'; + +export interface Commit { + id: string; + message: string; + seq: number; + type: number; + tag: string; + parents: (string | null)[]; + branch: string; + customType?: number; + customId?: string; +} + +export interface GitGraph { + statements: Statement[]; +} + +export type Statement = CommitAst | Branch | Merge | Checkout | CherryPicking; + +export interface CommitAst { + $type: 'Commit'; + id: string; + message?: string; + tags?: string[]; + type?: 'NORMAL' | 'REVERSE' | 'HIGHLIGHT'; +} + +export interface Branch { + $type: 'Branch'; + name: string; + order?: number; +} + +export interface Merge { + $type: 'Merge'; + branch: string; + id?: string; + tags?: string[]; + type?: 'NORMAL' | 'REVERSE' | 'HIGHLIGHT'; +} + +export interface Checkout { + $type: 'Checkout'; + branch: string; +} + +export interface CherryPicking { + $type: 'CherryPicking'; + id: string; + tags?: string[]; + parent: string; +} + +export type DiagramOrientation = 'LR' | 'TB'; diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium index 4956a80a4..88adaf3f7 100644 --- a/packages/parser/src/language/gitGraph/gitGraph.langium +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -1,6 +1,7 @@ grammar GitGraph import "../common/common"; + entry GitGraph: NEWLINE* 'gitGraph' Direction? ':'? @@ -23,60 +24,43 @@ Statement ; -Options: - 'options' '{' rawOptions+=STRING* '}' EOL; - Direction: dir=('LR' | 'TB' | 'BT') EOL; +Options: + 'options' '{' rawOptions+=STRING* '}' EOL; + Commit: - 'commit' properties+=CommitProperty* EOL; - -CommitProperty -: CommitId -| CommitMessage -| Tags -| CommitType -; - -CommitId: - 'id:' id=STRING; - -CommitMessage: - 'msg:'? message=STRING; - -Tags: - 'tag:' tags=STRING; - -CommitType: - 'type:' name=('NORMAL' | 'REVERSE' | 'HIGHLIGHT'); - + 'commit' + ( + 'id:' id=STRING + |'msg:'? message=STRING + |'tag:' tags=STRING + |'type:' name=('NORMAL' | 'REVERSE' | 'HIGHLIGHT') + )* EOL; Branch: - 'branch' name=(ID|STRING) ('order:' order=INT)? EOL; + 'branch' name=(ID|STRING) + ('order:' order=INT)? + EOL; Merge: - 'merge' name=(ID|STRING) properties+=MergeProperties* EOL; - -MergeProperties -: CommitId -| Tags -| CommitType -; + 'merge' branch=(ID|STRING) + ( + 'id:' id=STRING + |'tag:' tags=STRING + |'type:' name=('NORMAL' | 'REVERSE' | 'HIGHLIGHT') + )* EOL; Checkout: - ('checkout'|'switch') id=(ID|STRING) EOL; + ('checkout'|'switch') branch=(ID|STRING) EOL; CherryPicking: - 'cherry-pick' properties+=CherryPickProperties* EOL; - -CherryPickProperties -: CommitId -| Tags -| ParentCommit -; - -ParentCommit: - 'parent:' id=STRING; + 'cherry-pick' + ( + 'id:' id=STRING + |'tag:' tags=STRING + |'parent:' id=STRING + )* EOL; terminal INT returns number: /[0-9]+(?=\s)/; terminal ID returns string: /\w([-\./\w]*[-\w])?/; diff --git a/packages/parser/tests/gitGraph.test.ts b/packages/parser/tests/gitGraph.test.ts index e00ddfae8..aff69977a 100644 --- a/packages/parser/tests/gitGraph.test.ts +++ b/packages/parser/tests/gitGraph.test.ts @@ -10,90 +10,9 @@ describe('gitGraph', () => { expect(result.value.statements).toHaveLength(0); }); - it('should handle multiple commits', () => { - const result = parse(` - gitGraph - commit - commit - `); + it('should handle gitGraph with one statement', () => { + const result = parse(`gitGraph\n A`); expect(result.value.$type).toBe(GitGraph); - expect(result.value.statements).toHaveLength(2); - expect( - result.value.statements.every((s: { $type: string }) => s.$type === 'Commit') - ).toBeTruthy(); - }); - - it('should handle branches and checkouts', () => { - const result = parse(` - gitGraph - branch feature - branch release - checkout feature - `); - expect(result.value.statements).toHaveLength(3); - expect(result.value.statements[0].$type).toBe('Branch'); - expect(result.value.statements[0].name).toBe('feature'); - expect(result.value.statements[1].$type).toBe('Branch'); - expect(result.value.statements[1].name).toBe('release'); - expect(result.value.statements[2].$type).toBe('Checkout'); - expect(result.value.statements[2].id).toBe('feature'); - }); - - it('should handle merges', () => { - const result = parse(` - gitGraph - branch feature - commit id: "A" - merge feature id: "M" - `); - expect(result.value.statements).toHaveLength(3); - expect(result.value.statements[2].$type).toBe('Merge'); - expect(result.value.statements[2].name).toBe('feature'); - expect(result.value.statements[2].properties[0].id).toBe('M'); - }); - - it('should handle cherry-picking with tags and parent', () => { - const result = parse(` - gitGraph - branch feature - commit id: "M" - checkout main - cherry-pick id: "M" tag: "v2.1:ZERO" parent:"ZERO" - `); - expect(result.value.statements).toHaveLength(4); - expect(result.value.statements[3].$type).toBe('CherryPicking'); - expect(result.value.statements[3].properties.length).toBe(3); - expect(result.value.statements[3].properties[0].id).toBe('M'); - expect(result.value.statements[3].properties[1].tags).toBe('v2.1:ZERO'); - expect(result.value.statements[3].properties[2].id).toBe('ZERO'); - }); - - it('should parse complex gitGraph interactions', () => { - const result = parse(` - gitGraph - commit id: "ZERO" - branch feature - branch release - checkout feature - commit id: "A" - commit id: "B" - checkout main - merge feature id: "M" - checkout release - commit id: "C" - cherry-pick id: "M" tag: "v2.1:ZERO" parent:"ZERO" - commit id: "D" - `); - expect(result.value.statements).toHaveLength(12); - expect(result.value.statements[0].$type).toBe('Commit'); - expect(result.value.statements[0].properties[0].id).toBe('ZERO'); - expect(result.value.statements[1].$type).toBe('Branch'); - expect(result.value.statements[6].$type).toBe('Merge'); - expect(result.value.statements[10].$type).toBe('CherryPicking'); - expect(result.value.statements[10].properties[0].id).toBe('M'); - expect(result.value.statements[10].properties[2].id).toBe('ZERO'); - expect(result.value.statements[11].$type).toBe('Commit'); - expect(result.value.statements[11].properties[0].id).toBe('D'); }); }); }); From 5460bc0a0c46dcd6dda345357d7ac418c9c20a74 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Wed, 24 Jul 2024 07:13:10 -0400 Subject: [PATCH 003/124] fixed checkout branch with no commits --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index b04e78d8c..9a26d32f7 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -399,14 +399,11 @@ export const checkout = function (branch: string) { } else { curBranch = branch; const id = branches.get(curBranch); - - if (id === null || id === undefined) { - throw new Error('Branch ' + branch + ' has no commits'); + if (id === undefined || !id) { + head = null; + } else { + head = commits.get(id) ?? null; } - if (commits.get(id) === undefined) { - throw new Error('Branch ' + branch + ' has no commits'); - } - head = commits.get(id) ?? null; } }; From d2e2017907913210e5b4c5ff39f518926dc71df1 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Wed, 24 Jul 2024 09:48:46 -0400 Subject: [PATCH 004/124] fixed undefined for type errors --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 64 +++++++++++-------- .../src/diagrams/git/gitGraphParser.ts | 53 +-------------- .../mermaid/src/diagrams/git/gitGraphTypes.ts | 4 +- 3 files changed, 41 insertions(+), 80 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 9a26d32f7..8148e0249 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -19,7 +19,7 @@ const mainBranchOrder = defaultConfig.gitGraph.mainBranchOrder; let commits = new Map(); let head: Commit | null = null; -let branchesConfig = new Map(); +let branchesConfig = new Map(); branchesConfig.set(mainBranchName, { name: mainBranchName, order: mainBranchOrder }); let branches = new Map(); branches.set(mainBranchName, null); @@ -107,18 +107,19 @@ export const getOptions = function () { return options; }; -export const commit = function (msg: string, id: string, type: number, tag: string) { - log.info('commit', msg, id, type, tag); - log.debug('Entering commit:', msg, id, type, tag); +export const commit = function (msg: string, id: string, type: number, tags: string[] | undefined) { + log.info('commit', msg, id, type, tags); + log.debug('Entering commit:', msg, id, type, tags); id = common.sanitizeText(id, getConfig()); msg = common.sanitizeText(msg, getConfig()); - tag = common.sanitizeText(tag, getConfig()); + const config = getConfig(); + tags = tags?.map((tag) => common.sanitizeText(tag, config)); const newCommit: Commit = { id: id ? id : seq + '-' + getId(), message: msg, seq: seq++, - type: type, - tag: tag ? tag : '', + type: type ? type : commitType.NORMAL, + tags: tags ? tags : [], parents: head == null ? [] : [head.id], branch: curBranch, }; @@ -129,7 +130,7 @@ export const commit = function (msg: string, id: string, type: number, tag: stri log.debug('in pushCommit ' + newCommit.id); }; -export const branch = function (name: string, order: number) { +export const branch = function (name: string, order: number | undefined) { name = common.sanitizeText(name, getConfig()); if (!branches.has(name)) { branches.set(name, head != null ? head.id : null); @@ -138,7 +139,7 @@ export const branch = function (name: string, order: number) { log.debug('in createBranch'); } else { throw new Error( - `Trying to create an existing branch: ${name}. Use 'checkout ${name}' instead.` + `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}" to switch to an existing branch)` ); } }; @@ -147,7 +148,7 @@ export const merge = ( otherBranch: string, custom_id?: string, override_type?: number, - custom_tag?: string + custom_tags?: string[] ): void => { otherBranch = common.sanitizeText(otherBranch, getConfig()); if (custom_id) { @@ -227,12 +228,19 @@ export const merge = ( ' already exists, use different custom Id' ); error.hash = { - text: 'merge ' + otherBranch + custom_id + override_type + custom_tag, - token: 'merge ' + otherBranch + custom_id + override_type + custom_tag, + text: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(' '), + token: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(' '), line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: [ - 'merge ' + otherBranch + ' ' + custom_id + '_UNIQUE ' + override_type + ' ' + custom_tag, + 'merge ' + + otherBranch + + ' ' + + custom_id + + '_UNIQUE ' + + override_type + + ' ' + + custom_tags?.join(' '), ], }; @@ -258,9 +266,9 @@ export const merge = ( parents: [head == null ? null : head.id, verifiedBranch], branch: curBranch, type: commitType.MERGE, - customType: override_type, //TODO - need to make customType optional - customId: custom_id, //TODO - need to make customId optional as well as tag - tag: custom_tag ? custom_tag : '', + customType: override_type, + customId: custom_id ? true : false, + tags: custom_tags ? custom_tags : [], }; head = commit; commits.set(commit.id, commit); @@ -273,13 +281,14 @@ export const merge = ( export const cherryPick = function ( sourceId: string, targetId: string, - tag: string, + tags: string[], parentCommitId: string ) { - log.debug('Entering cherryPick:', sourceId, targetId, tag); + log.debug('Entering cherryPick:', sourceId, targetId, tags); sourceId = common.sanitizeText(sourceId, getConfig()); targetId = common.sanitizeText(targetId, getConfig()); - tag = common.sanitizeText(tag, getConfig()); + const config = getConfig(); + tags = tags?.map((tag) => common.sanitizeText(tag, config)); parentCommitId = common.sanitizeText(parentCommitId, getConfig()); if (!sourceId || !commits.has(sourceId)) { @@ -367,11 +376,13 @@ export const cherryPick = function ( parents: [head == null ? null : head.id, sourceCommit.id], branch: curBranch, type: commitType.CHERRY_PICK, - tag: - tag ?? - `cherry-pick:${sourceCommit.id}${ - sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : '' - }`, + tags: tags + ? tags.filter(Boolean) + : [ + `cherry-pick:${sourceCommit.id}${ + sourceCommit.type === commitType.MERGE ? `|parent:${parentCommitId}` : '' + }`, + ], }; head = commit; commits.set(commit.id, commit); @@ -504,7 +515,7 @@ export const clear = function () { export const getBranchesAsObjArray = function () { const branchesArray = [...branchesConfig.values()] .map((branchConfig, i) => { - if (branchConfig.order !== null) { + if (branchConfig.order !== null && branchConfig.order !== undefined) { return branchConfig; } return { @@ -512,7 +523,7 @@ export const getBranchesAsObjArray = function () { order: parseFloat(`0.${i}`), }; }) - .sort((a, b) => a.order - b.order) + .sort((a, b) => (a.order ?? 0) - (b.order ?? 0)) .map(({ name }) => ({ name })); return branchesArray; @@ -551,6 +562,7 @@ export const commitType = { }; export default { + commitType, getConfig: () => getConfig().gitGraph, setDirection, setOptions, diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 713992e0f..d193109b4 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -4,65 +4,14 @@ import type { ParserDefinition } from '../../diagram-api/types.js'; import { log } from '../../logger.js'; import { populateCommonDb } from '../common/populateCommonDb.js'; import db from './gitGraphAst.js'; -import type { - Statement, - CommitAst, - Branch, - Merge, - Checkout, - CherryPicking, -} from './gitGraphTypes.js'; const populate = (ast: any) => { populateCommonDb(ast, db); for (const statement of ast.statements) { - parseStatement(statement); + log.debug(statement); } }; -const parseStatement = (statement: Statement) => { - switch (statement.$type) { - case 'Commit': - parseCommit(statement); - break; - case 'Branch': - parseBranch(statement); - break; - case 'Merge': - parseMerge(statement); - break; - case 'Checkout': - parseCheckout(statement); - break; - case 'CherryPicking': - parseCherryPicking(statement); - break; - default: - throw new Error(`Unknown statement type: ${(statement as any).$type}`); - } -}; - -function parseCommit(commit: CommitAst) { - const message = commit.message ?? ''; - db.commit(message, commit.id, commit.tags, commit.type); -} - -function parseBranch(branch: Branch) { - db.branch(branch.name, branch.order); -} - -function parseMerge(merge: Merge) { - db.merge(merge.branch, merge.id, merge.tags, merge.type); -} - -function parseCheckout(checkout: Checkout) { - db.checkout(checkout.branch); -} - -function parseCherryPicking(cherryPicking: CherryPicking) { - db.cherryPick(cherryPicking.id, cherryPicking.tags, cherryPicking.parent); -} - export const parser: ParserDefinition = { parse: async (input: string): Promise => { const ast: GitGraph = await parse('gitGraph', input); diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index da7567b8d..92bc3617a 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -5,11 +5,11 @@ export interface Commit { message: string; seq: number; type: number; - tag: string; + tags: string[] | undefined; parents: (string | null)[]; branch: string; customType?: number; - customId?: string; + customId?: boolean; } export interface GitGraph { From 0b67cffdfa5af394361376a3c028b063aee140e0 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Wed, 24 Jul 2024 10:37:21 -0400 Subject: [PATCH 005/124] fixed cherrypicking tests --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 8148e0249..e12e58f7d 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -139,7 +139,7 @@ export const branch = function (name: string, order: number | undefined) { log.debug('in createBranch'); } else { throw new Error( - `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}" to switch to an existing branch)` + `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")` ); } }; @@ -306,16 +306,17 @@ export const cherryPick = function ( } const sourceCommit = commits.get(sourceId); - + if (sourceCommit === undefined || !sourceCommit) { + throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided'); + } if ( - !sourceCommit || - !parentCommitId || - !Array.isArray(sourceCommit.parents) || - !sourceCommit.parents.includes(parentCommitId) + parentCommitId && + !(Array.isArray(sourceCommit.parents) && sourceCommit.parents.includes(parentCommitId)) ) { - throw new Error( + const error = new Error( 'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.' ); + throw error; } const sourceCommitBranch = sourceCommit.branch; if (sourceCommit.type === commitType.MERGE && !parentCommitId) { From 1a95d4885282b475ec898e111e031133eda83a5e Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Wed, 24 Jul 2024 13:53:00 -0400 Subject: [PATCH 006/124] added Imperative state --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 265 +++++++++--------- 1 file changed, 127 insertions(+), 138 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index e12e58f7d..13e54ddf4 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -13,19 +13,32 @@ import { } from '../common/commonDb.js'; import defaultConfig from '../../defaultConfig.js'; import type { DiagramOrientation, Commit } from './gitGraphTypes.js'; +import { ImperativeState } from '../../utils/imperativeState.js'; + +interface GitGraphState { + commits: Map; + head: Commit | null; + branchConfig: Map; + branches: Map; + currBranch: string; + direction: DiagramOrientation; + seq: number; + options: any; +} const mainBranchName = defaultConfig.gitGraph.mainBranchName; const mainBranchOrder = defaultConfig.gitGraph.mainBranchOrder; -let commits = new Map(); -let head: Commit | null = null; -let branchesConfig = new Map(); -branchesConfig.set(mainBranchName, { name: mainBranchName, order: mainBranchOrder }); -let branches = new Map(); -branches.set(mainBranchName, null); -let curBranch = mainBranchName; -let direction: DiagramOrientation = 'LR'; -let seq = 0; +const state = new ImperativeState(() => ({ + commits: new Map(), + head: null, + branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]), + branches: new Map([[mainBranchName, null]]), + currBranch: mainBranchName, + direction: 'LR', + seq: 0, + options: {}, +})); /** * @@ -34,11 +47,6 @@ function getId() { return random({ length: 7 }); } -// /** -// * @param currentCommit -// * @param otherCommit -// */ - // function isFastForwardable(currentCommit, otherCommit) { // log.debug('Entering isFastForwardable:', currentCommit.id, otherCommit.id); // let cnt = 0; @@ -60,10 +68,6 @@ function getId() { // return currentCommit.id === otherCommit.id; // } -/** - * @param currentCommit - current commit - * @param otherCommit - other commit - */ // function isReachableFrom(currentCommit, otherCommit) { // const currentSeq = currentCommit.seq; // const otherSeq = otherCommit.seq; @@ -88,23 +92,22 @@ function uniqBy(list: any[], fn: (item: any) => any) { } export const setDirection = function (dir: DiagramOrientation) { - direction = dir; + state.records.direction = dir; }; -let options = {}; export const setOptions = function (rawOptString: string) { log.debug('options str', rawOptString); rawOptString = rawOptString?.trim(); rawOptString = rawOptString || '{}'; try { - options = JSON.parse(rawOptString); + state.records.options = JSON.parse(rawOptString); } catch (e: any) { log.error('error while parsing gitGraph options', e.message); } }; export const getOptions = function () { - return options; + return state.records.options; }; export const commit = function (msg: string, id: string, type: number, tags: string[] | undefined) { @@ -115,26 +118,26 @@ export const commit = function (msg: string, id: string, type: number, tags: str const config = getConfig(); tags = tags?.map((tag) => common.sanitizeText(tag, config)); const newCommit: Commit = { - id: id ? id : seq + '-' + getId(), + id: id ? id : state.records.seq + '-' + getId(), message: msg, - seq: seq++, - type: type ? type : commitType.NORMAL, - tags: tags ? tags : [], - parents: head == null ? [] : [head.id], - branch: curBranch, + seq: state.records.seq++, + type: type ?? commitType.NORMAL, + tags: tags ?? [], + parents: state.records.head == null ? [] : [state.records.head.id], + branch: state.records.currBranch, }; - head = newCommit; + state.records.head = newCommit; log.info('main branch', mainBranchName); - commits.set(newCommit.id, newCommit); - branches.set(curBranch, newCommit.id); + state.records.commits.set(newCommit.id, newCommit); + state.records.branches.set(state.records.currBranch, newCommit.id); log.debug('in pushCommit ' + newCommit.id); }; export const branch = function (name: string, order: number | undefined) { name = common.sanitizeText(name, getConfig()); - if (!branches.has(name)) { - branches.set(name, head != null ? head.id : null); - branchesConfig.set(name, { name, order }); + if (!state.records.branches.has(name)) { + state.records.branches.set(name, state.records.head != null ? state.records.head.id : null); + state.records.branchConfig.set(name, { name, order }); checkout(name); log.debug('in createBranch'); } else { @@ -146,30 +149,32 @@ export const branch = function (name: string, order: number | undefined) { export const merge = ( otherBranch: string, - custom_id?: string, - override_type?: number, - custom_tags?: string[] + customId?: string, + overrideType?: number, + customTags?: string[] ): void => { otherBranch = common.sanitizeText(otherBranch, getConfig()); - if (custom_id) { - custom_id = common.sanitizeText(custom_id, getConfig()); + if (customId) { + customId = common.sanitizeText(customId, getConfig()); } - const currentBranchCheck: string | null | undefined = branches.get(curBranch); - const otherBranchCheck: string | null | undefined = branches.get(otherBranch); + const currentBranchCheck: string | null | undefined = state.records.branches.get( + state.records.currBranch + ); + const otherBranchCheck: string | null | undefined = state.records.branches.get(otherBranch); const currentCommit: Commit | undefined = currentBranchCheck - ? commits.get(currentBranchCheck) + ? state.records.commits.get(currentBranchCheck) : undefined; const otherCommit: Commit | undefined = otherBranchCheck - ? commits.get(otherBranchCheck) + ? state.records.commits.get(otherBranchCheck) : undefined; if (currentCommit && otherCommit && currentCommit.branch === otherBranch) { throw new Error(`Cannot merge branch '${otherBranch}' into itself.`); } - if (curBranch === otherBranch) { + if (state.records.currBranch === otherBranch) { const error: any = new Error('Incorrect usage of "merge". Cannot merge a branch to itself'); error.hash = { - text: 'merge ' + otherBranch, - token: 'merge ' + otherBranch, + text: `merge ${otherBranch}`, + token: `merge ${otherBranch}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['branch abc'], @@ -177,26 +182,26 @@ export const merge = ( throw error; } else if (currentCommit === undefined || !currentCommit) { const error: any = new Error( - 'Incorrect usage of "merge". Current branch (' + curBranch + ')has no commits' + `Incorrect usage of "merge". Current branch (${state.records.currBranch})has no commits` ); error.hash = { - text: 'merge ' + otherBranch, - token: 'merge ' + otherBranch, + text: `merge ${otherBranch}`, + token: `merge ${otherBranch}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['commit'], }; throw error; - } else if (!branches.has(otherBranch)) { + } else if (!state.records.branches.has(otherBranch)) { const error: any = new Error( 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ') does not exist' ); error.hash = { - text: 'merge ' + otherBranch, - token: 'merge ' + otherBranch, + text: `merge ${otherBranch}`, + token: `merge ${otherBranch}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, - expected: ['branch ' + otherBranch], + expected: [`branch ${otherBranch}`], }; throw error; } else if (otherCommit === undefined || !otherCommit) { @@ -204,8 +209,8 @@ export const merge = ( 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ') has no commits' ); error.hash = { - text: 'merge ' + otherBranch, - token: 'merge ' + otherBranch, + text: `merge ${otherBranch}`, + token: `merge ${otherBranch}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['"commit"'], @@ -214,33 +219,26 @@ export const merge = ( } else if (currentCommit === otherCommit) { const error: any = new Error('Incorrect usage of "merge". Both branches have same head'); error.hash = { - text: 'merge ' + otherBranch, - token: 'merge ' + otherBranch, + text: `merge ${otherBranch}`, + token: `merge ${otherBranch}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['branch abc'], }; throw error; - } else if (custom_id && commits.has(custom_id)) { + } else if (customId && state.records.commits.has(customId)) { const error: any = new Error( 'Incorrect usage of "merge". Commit with id:' + - custom_id + + customId + ' already exists, use different custom Id' ); error.hash = { - text: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(' '), - token: 'merge ' + otherBranch + custom_id + override_type + custom_tags?.join(' '), + text: `merge ${otherBranch} ${customId} ${overrideType} ${customTags?.join(' ')}`, + token: `merge ${otherBranch} ${customId} ${overrideType} ${customTags?.join(' ')}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: [ - 'merge ' + - otherBranch + - ' ' + - custom_id + - '_UNIQUE ' + - override_type + - ' ' + - custom_tags?.join(' '), + `merge ${otherBranch} ${customId}_UNIQUE ${overrideType} ${customTags?.join(' ')}`, ], }; @@ -260,21 +258,21 @@ export const merge = ( const verifiedBranch: string = otherBranchCheck ? otherBranchCheck : ''; //figure out a cleaner way to do this const commit: Commit = { - id: custom_id ? custom_id : seq + '-' + getId(), - message: 'merged branch ' + otherBranch + ' into ' + curBranch, - seq: seq++, - parents: [head == null ? null : head.id, verifiedBranch], - branch: curBranch, + id: customId ? customId : state.records.seq + '-' + getId(), + message: `merged branch ${otherBranch} into ${state.records.currBranch}`, + seq: state.records.seq++, + parents: [state.records.head == null ? null : state.records.head.id, verifiedBranch], + branch: state.records.currBranch, type: commitType.MERGE, - customType: override_type, - customId: custom_id ? true : false, - tags: custom_tags ? custom_tags : [], + customType: overrideType, + customId: customId ? true : false, + tags: customTags ? customTags : [], }; - head = commit; - commits.set(commit.id, commit); - branches.set(curBranch, commit.id); + state.records.head = commit; + state.records.commits.set(commit.id, commit); + state.records.branches.set(state.records.currBranch, commit.id); // } - log.debug(branches); + log.debug(state.records.branches); log.debug('in mergeBranch'); }; @@ -291,13 +289,13 @@ export const cherryPick = function ( tags = tags?.map((tag) => common.sanitizeText(tag, config)); parentCommitId = common.sanitizeText(parentCommitId, getConfig()); - if (!sourceId || !commits.has(sourceId)) { + if (!sourceId || !state.records.commits.has(sourceId)) { const error: any = new Error( 'Incorrect usage of "cherryPick". Source commit id should exist and provided' ); error.hash = { - text: 'cherryPick ' + sourceId + ' ' + targetId, - token: 'cherryPick ' + sourceId + ' ' + targetId, + text: `cherryPick ${sourceId} ${targetId}`, + token: `cherryPick ${sourceId} ${targetId}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['cherry-pick abc'], @@ -305,7 +303,7 @@ export const cherryPick = function ( throw error; } - const sourceCommit = commits.get(sourceId); + const sourceCommit = state.records.commits.get(sourceId); if (sourceCommit === undefined || !sourceCommit) { throw new Error('Incorrect usage of "cherryPick". Source commit id should exist and provided'); } @@ -325,30 +323,30 @@ export const cherryPick = function ( ); throw error; } - if (!targetId || !commits.has(targetId)) { + if (!targetId || !state.records.commits.has(targetId)) { // cherry-pick source commit to current branch - if (sourceCommitBranch === curBranch) { + if (sourceCommitBranch === state.records.currBranch) { const error: any = new Error( 'Incorrect usage of "cherryPick". Source commit is already on current branch' ); error.hash = { - text: 'cherryPick ' + sourceId + ' ' + targetId, - token: 'cherryPick ' + sourceId + ' ' + targetId, + text: `cherryPick ${sourceId} ${targetId}`, + token: `cherryPick ${sourceId} ${targetId}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['cherry-pick abc'], }; throw error; } - const currentCommitId = branches.get(curBranch); + const currentCommitId = state.records.branches.get(state.records.currBranch); if (currentCommitId === undefined || !currentCommitId) { const error: any = new Error( - 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ')has no commits' + `Incorrect usage of "cherry-pick". Current branch (${state.records.currBranch})has no commits` ); error.hash = { - text: 'cherryPick ' + sourceId + ' ' + targetId, - token: 'cherryPick ' + sourceId + ' ' + targetId, + text: `cherryPick ${sourceId} ${targetId}`, + token: `cherryPick ${sourceId} ${targetId}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['cherry-pick abc'], @@ -356,14 +354,14 @@ export const cherryPick = function ( throw error; } - const currentCommit = commits.get(currentCommitId); + const currentCommit = state.records.commits.get(currentCommitId); if (currentCommit === undefined || !currentCommit) { const error: any = new Error( - 'Incorrect usage of "cherry-pick". Current branch (' + curBranch + ')has no commits' + `Incorrect usage of "cherry-pick". Current branch (${state.records.currBranch})has no commits` ); error.hash = { - text: 'cherryPick ' + sourceId + ' ' + targetId, - token: 'cherryPick ' + sourceId + ' ' + targetId, + text: `cherryPick ${sourceId} ${targetId}`, + token: `cherryPick ${sourceId} ${targetId}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['cherry-pick abc'], @@ -371,11 +369,11 @@ export const cherryPick = function ( throw error; } const commit = { - id: seq + '-' + getId(), - message: 'cherry-picked ' + sourceCommit?.message + ' into ' + curBranch, - seq: seq++, - parents: [head == null ? null : head.id, sourceCommit.id], - branch: curBranch, + id: state.records.seq + '-' + getId(), + message: `cherry-picked ${sourceCommit?.message} into ${state.records.currBranch}`, + seq: state.records.seq++, + parents: [state.records.head == null ? null : state.records.head.id, sourceCommit.id], + branch: state.records.currBranch, type: commitType.CHERRY_PICK, tags: tags ? tags.filter(Boolean) @@ -385,36 +383,36 @@ export const cherryPick = function ( }`, ], }; - head = commit; - commits.set(commit.id, commit); - branches.set(curBranch, commit.id); - log.debug(branches); + state.records.head = commit; + state.records.commits.set(commit.id, commit); + state.records.branches.set(state.records.currBranch, commit.id); + log.debug(state.records.branches); log.debug('in cherryPick'); } }; export const checkout = function (branch: string) { branch = common.sanitizeText(branch, getConfig()); - if (!branches.has(branch)) { + if (!state.records.branches.has(branch)) { const error: any = new Error( - 'Trying to checkout branch which is not yet created. (Help try using "branch ' + branch + '")' + `Trying to checkout branch which is not yet created. (Help try using "branch ${branch}")` ); error.hash = { - text: 'checkout ' + branch, - token: 'checkout ' + branch, + text: `checkout ${branch}`, + token: `checkout ${branch}`, line: '1', loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, - expected: ['"branch ' + branch + '"'], + expected: [`branch ${branch}`], }; throw error; //branches[branch] = head != null ? head.id : null; //log.debug('in createBranch'); } else { - curBranch = branch; - const id = branches.get(curBranch); + state.records.currBranch = branch; + const id = state.records.branches.get(state.records.currBranch); if (id === undefined || !id) { - head = null; + state.records.head = null; } else { - head = commits.get(id) ?? null; + state.records.head = state.records.commits.get(id) ?? null; } } }; @@ -469,23 +467,23 @@ function prettyPrintCommitHistory(commitArr: Commit[]) { } }); const label = [line, commit.id, commit.seq]; - for (const branch in branches) { - if (branches.get(branch) === commit.id) { + for (const branch in state.records.branches) { + if (state.records.branches.get(branch) === commit.id) { label.push(branch); } } log.debug(label.join(' ')); if (commit.parents && commit.parents.length == 2 && commit.parents[0] && commit.parents[1]) { - const newCommit = commits.get(commit.parents[0]); + const newCommit = state.records.commits.get(commit.parents[0]); upsert(commitArr, commit, newCommit); if (commit.parents[1]) { - commitArr.push(commits.get(commit.parents[1])!); + commitArr.push(state.records.commits.get(commit.parents[1])!); } } else if (commit.parents.length == 0) { return; } else { if (commit.parents[0]) { - const newCommit = commits.get(commit.parents[0]); + const newCommit = state.records.commits.get(commit.parents[0]); upsert(commitArr, commit, newCommit); } } @@ -494,27 +492,18 @@ function prettyPrintCommitHistory(commitArr: Commit[]) { } export const prettyPrint = function () { - log.debug(commits); + log.debug(state.records.commits); const node = getCommitsArray()[0]; prettyPrintCommitHistory([node]); }; export const clear = function () { - commits = new Map(); - head = null; - const mainBranch = defaultConfig.gitGraph.mainBranchName; - const mainBranchOrder = defaultConfig.gitGraph.mainBranchOrder; - branches = new Map(); - branches.set(mainBranch, null); - branchesConfig = new Map(); - branchesConfig.set(mainBranch, { name: mainBranch, order: mainBranchOrder }); - curBranch = mainBranch; - seq = 0; + state.reset(); commonClear(); }; export const getBranchesAsObjArray = function () { - const branchesArray = [...branchesConfig.values()] + const branchesArray = [...state.records.branchConfig.values()] .map((branchConfig, i) => { if (branchConfig.order !== null && branchConfig.order !== undefined) { return branchConfig; @@ -531,13 +520,13 @@ export const getBranchesAsObjArray = function () { }; export const getBranches = function () { - return branches; + return state.records.branches; }; export const getCommits = function () { - return commits; + return state.records.commits; }; export const getCommitsArray = function () { - const commitArr = [...commits.values()]; + const commitArr = [...state.records.commits.values()]; commitArr.forEach(function (o) { log.debug(o.id); }); @@ -545,13 +534,13 @@ export const getCommitsArray = function () { return commitArr; }; export const getCurrentBranch = function () { - return curBranch; + return state.records.currBranch; }; export const getDirection = function () { - return direction; + return state.records.direction; }; export const getHead = function () { - return head; + return state.records.head; }; export const commitType = { From d0eadebb991e5f481360ac8b45766ffbd27aae6a Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Thu, 25 Jul 2024 05:25:19 -0400 Subject: [PATCH 007/124] added parser --- .../src/diagrams/git/gitGraphDiagram.ts | 4 +- .../src/diagrams/git/gitGraphParser.ts | 68 ++++++++++++++++++- .../mermaid/src/diagrams/git/gitGraphTypes.ts | 10 +-- .../src/language/gitGraph/gitGraph.langium | 26 ++++++- packages/parser/tests/gitGraph.test.ts | 14 +++- 5 files changed, 111 insertions(+), 11 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts b/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts index 2a9efdb59..e5534140b 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts @@ -1,12 +1,12 @@ // @ts-ignore: JISON doesn't support types -import gitGraphParser from './parser/gitGraph.jison'; +import { parser } from './gitGraphParser.js'; import gitGraphDb from './gitGraphAst.js'; import gitGraphRenderer from './gitGraphRenderer.js'; import gitGraphStyles from './styles.js'; import type { DiagramDefinition } from '../../diagram-api/types.js'; export const diagram: DiagramDefinition = { - parser: gitGraphParser, + parser: parser, db: gitGraphDb, renderer: gitGraphRenderer, styles: gitGraphStyles, diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index d193109b4..c9488173d 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -4,14 +4,78 @@ import type { ParserDefinition } from '../../diagram-api/types.js'; import { log } from '../../logger.js'; import { populateCommonDb } from '../common/populateCommonDb.js'; import db from './gitGraphAst.js'; +import { commitType } from './gitGraphAst.js'; +import type { + CheckoutAst, + CherryPickingAst, + MergeAst, + CommitAst, + BranchAst, +} from './gitGraphTypes.js'; -const populate = (ast: any) => { +const populate = (ast: GitGraph) => { populateCommonDb(ast, db); for (const statement of ast.statements) { - log.debug(statement); + parseStatement(statement); } }; +const parseStatement = (statement: any) => { + switch (statement.$type) { + case 'Commit': + parseCommit(statement); + break; + case 'Branch': + parseBranch(statement); + break; + case 'Merge': + parseMerge(statement); + break; + case 'Checkout': + parseCheckout(statement); + break; + case 'CherryPicking': + parseCherryPicking(statement); + break; + default: + log.warn(`Unknown statement type`); + } +}; + +const parseCommit = (commit: CommitAst) => { + const id = commit.id; + const message = commit.message ?? ''; + const tags = commit.tags ?? []; + const type = commit.type !== undefined ? commitType[commit.type] : 0; + db.commit(message, id, type, tags); +}; + +const parseBranch = (branch: BranchAst) => { + const name = branch.name; + const order = branch.order ?? 0; + db.branch(name, order); +}; + +const parseMerge = (merge: MergeAst) => { + const branch = merge.branch; + const id = merge.id ?? ''; + const tags = merge.tags ?? []; + const type = merge.type !== undefined ? commitType[merge.type] : 0; + db.merge(branch, id, type, tags); +}; + +const parseCheckout = (checkout: CheckoutAst) => { + const branch = checkout.branch; + db.checkout(branch); +}; + +const parseCherryPicking = (cherryPicking: CherryPickingAst) => { + const id = cherryPicking.id; + const tags = cherryPicking.tags ?? []; + const parent = cherryPicking.parent; + db.cherryPick(id, '', tags, parent); +}; + export const parser: ParserDefinition = { parse: async (input: string): Promise => { const ast: GitGraph = await parse('gitGraph', input); diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index 92bc3617a..36d88fd97 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -16,7 +16,7 @@ export interface GitGraph { statements: Statement[]; } -export type Statement = CommitAst | Branch | Merge | Checkout | CherryPicking; +export type Statement = CommitAst | BranchAst | MergeAst | CheckoutAst | CherryPickingAst; export interface CommitAst { $type: 'Commit'; @@ -26,13 +26,13 @@ export interface CommitAst { type?: 'NORMAL' | 'REVERSE' | 'HIGHLIGHT'; } -export interface Branch { +export interface BranchAst { $type: 'Branch'; name: string; order?: number; } -export interface Merge { +export interface MergeAst { $type: 'Merge'; branch: string; id?: string; @@ -40,12 +40,12 @@ export interface Merge { type?: 'NORMAL' | 'REVERSE' | 'HIGHLIGHT'; } -export interface Checkout { +export interface CheckoutAst { $type: 'Checkout'; branch: string; } -export interface CherryPicking { +export interface CherryPickingAst { $type: 'CherryPicking'; id: string; tags?: string[]; diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium index 88adaf3f7..8751dccc1 100644 --- a/packages/parser/src/language/gitGraph/gitGraph.langium +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -1,6 +1,28 @@ grammar GitGraph -import "../common/common"; +interface Common { + accDescr?: string; + accTitle?: string; + title?: string; +} + +fragment TitleAndAccessibilities: + ((accDescr=ACC_DESCR | accTitle=ACC_TITLE | title=TITLE) EOL)+ +; + +fragment EOL returns string: + NEWLINE+ | EOF +; + +terminal NEWLINE: /\r?\n/; +terminal ACC_DESCR: /[\t ]*accDescr(?:[\t ]*:([^\n\r]*?(?=%%)|[^\n\r]*)|\s*{([^}]*)})/; +terminal ACC_TITLE: /[\t ]*accTitle[\t ]*:(?:[^\n\r]*?(?=%%)|[^\n\r]*)/; +terminal TITLE: /[\t ]*title(?:[\t ][^\n\r]*?(?=%%)|[\t ][^\n\r]*|)/; + +hidden terminal WHITESPACE: /[\t ]+/; +hidden terminal YAML: /---[\t ]*\r?\n(?:[\S\s]*?\r?\n)?---(?:\r?\n|(?!\S))/; +hidden terminal DIRECTIVE: /[\t ]*%%{[\S\s]*?}%%(?:\r?\n|(?!\S))/; +hidden terminal SINGLE_LINE_COMMENT: /[\t ]*%%[^\n\r]*/; entry GitGraph: NEWLINE* @@ -62,6 +84,8 @@ CherryPicking: |'parent:' id=STRING )* EOL; + + terminal INT returns number: /[0-9]+(?=\s)/; terminal ID returns string: /\w([-\./\w]*[-\w])?/; terminal STRING: /"[^"]*"|'[^']*'/; diff --git a/packages/parser/tests/gitGraph.test.ts b/packages/parser/tests/gitGraph.test.ts index aff69977a..850b34bf9 100644 --- a/packages/parser/tests/gitGraph.test.ts +++ b/packages/parser/tests/gitGraph.test.ts @@ -8,11 +8,23 @@ describe('gitGraph', () => { const result = parse(`gitGraph`); expect(result.value.$type).toBe(GitGraph); expect(result.value.statements).toHaveLength(0); + expect(result.lexerErrors).toHaveLength(0); + expect(result.parserErrors).toHaveLength(0); }); it('should handle gitGraph with one statement', () => { - const result = parse(`gitGraph\n A`); + const result = parse(`gitGraph\n commit\n`); expect(result.value.$type).toBe(GitGraph); + expect(result.lexerErrors).toHaveLength(0); + expect(result.parserErrors).toHaveLength(0); + expect(result.value.statements).toHaveLength(1); + }); + + it('should handle gitGraph with multiple statements and use accTitle', () => { + const result = parse(`gitGraph\n commit\n commit\n accTitle: title\n commit\n`); + expect(result.value.$type).toBe(GitGraph); + expect(result.lexerErrors).toHaveLength(0); + expect(result.parserErrors).toHaveLength(0); }); }); }); From 1af90946bc1fd7e22169beb65b220565f41f2b4b Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Thu, 25 Jul 2024 06:22:37 -0400 Subject: [PATCH 008/124] fixed options e2e test --- packages/parser/src/language/gitGraph/gitGraph.langium | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium index 8751dccc1..9d08faf63 100644 --- a/packages/parser/src/language/gitGraph/gitGraph.langium +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -47,7 +47,7 @@ Statement Direction: - dir=('LR' | 'TB' | 'BT') EOL; + dir=('LR' | 'TB' | 'BT'); Options: 'options' '{' rawOptions+=STRING* '}' EOL; From a386bd0b74f7313ca9d33d30be70834c5c4f06c1 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Fri, 26 Jul 2024 22:55:40 -0400 Subject: [PATCH 009/124] fixed tags for gitGraph --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 2 +- packages/mermaid/src/diagrams/git/gitGraphParser.ts | 7 ++++--- packages/mermaid/src/diagrams/git/gitGraphTypes.ts | 2 +- packages/parser/src/language/gitGraph/gitGraph.langium | 7 +++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 13e54ddf4..23cd20d80 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -279,7 +279,7 @@ export const merge = ( export const cherryPick = function ( sourceId: string, targetId: string, - tags: string[], + tags: string[] | undefined, parentCommitId: string ) { log.debug('Entering cherryPick:', sourceId, targetId, tags); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index c9488173d..ff046a456 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -45,8 +45,9 @@ const parseStatement = (statement: any) => { const parseCommit = (commit: CommitAst) => { const id = commit.id; const message = commit.message ?? ''; - const tags = commit.tags ?? []; + const tags = commit.tags ?? undefined; const type = commit.type !== undefined ? commitType[commit.type] : 0; + log.info(`Commit: ${id} ${message} ${type}`); db.commit(message, id, type, tags); }; @@ -59,7 +60,7 @@ const parseBranch = (branch: BranchAst) => { const parseMerge = (merge: MergeAst) => { const branch = merge.branch; const id = merge.id ?? ''; - const tags = merge.tags ?? []; + const tags = merge.tags ?? undefined; const type = merge.type !== undefined ? commitType[merge.type] : 0; db.merge(branch, id, type, tags); }; @@ -71,7 +72,7 @@ const parseCheckout = (checkout: CheckoutAst) => { const parseCherryPicking = (cherryPicking: CherryPickingAst) => { const id = cherryPicking.id; - const tags = cherryPicking.tags ?? []; + const tags = cherryPicking.tags ?? undefined; const parent = cherryPicking.parent; db.cherryPick(id, '', tags, parent); }; diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index 36d88fd97..29e2781a9 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -5,7 +5,7 @@ export interface Commit { message: string; seq: number; type: number; - tags: string[] | undefined; + tags: string[]; parents: (string | null)[]; branch: string; customType?: number; diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium index 9d08faf63..682476260 100644 --- a/packages/parser/src/language/gitGraph/gitGraph.langium +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -45,7 +45,6 @@ Statement | CherryPicking ; - Direction: dir=('LR' | 'TB' | 'BT'); @@ -57,7 +56,7 @@ Commit: ( 'id:' id=STRING |'msg:'? message=STRING - |'tag:' tags=STRING + |'tag:' tags+=STRING |'type:' name=('NORMAL' | 'REVERSE' | 'HIGHLIGHT') )* EOL; Branch: @@ -69,7 +68,7 @@ Merge: 'merge' branch=(ID|STRING) ( 'id:' id=STRING - |'tag:' tags=STRING + |'tag:' tags+=STRING |'type:' name=('NORMAL' | 'REVERSE' | 'HIGHLIGHT') )* EOL; @@ -80,7 +79,7 @@ CherryPicking: 'cherry-pick' ( 'id:' id=STRING - |'tag:' tags=STRING + |'tag:' tags+=STRING |'parent:' id=STRING )* EOL; From 887e5803d8e6f01c82be21faca4d2f3cd86607ea Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Fri, 26 Jul 2024 23:28:07 -0400 Subject: [PATCH 010/124] fixed some features and added propper default direction --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 2 +- packages/mermaid/src/diagrams/git/gitGraphParser.ts | 1 + packages/parser/src/language/gitGraph/gitGraph.langium | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 23cd20d80..b0a5ffd31 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -35,7 +35,7 @@ const state = new ImperativeState(() => ({ branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]), branches: new Map([[mainBranchName, null]]), currBranch: mainBranchName, - direction: 'LR', + direction: 'TB', seq: 0, options: {}, })); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index ff046a456..8116d7d4c 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -46,6 +46,7 @@ const parseCommit = (commit: CommitAst) => { const id = commit.id; const message = commit.message ?? ''; const tags = commit.tags ?? undefined; + log.info(`Commit type`, commit.type); const type = commit.type !== undefined ? commitType[commit.type] : 0; log.info(`Commit: ${id} ${message} ${type}`); db.commit(message, id, type, tags); diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium index 682476260..9c97e6e84 100644 --- a/packages/parser/src/language/gitGraph/gitGraph.langium +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -57,7 +57,7 @@ Commit: 'id:' id=STRING |'msg:'? message=STRING |'tag:' tags+=STRING - |'type:' name=('NORMAL' | 'REVERSE' | 'HIGHLIGHT') + |'type:' type=('NORMAL' | 'REVERSE' | 'HIGHLIGHT') )* EOL; Branch: 'branch' name=(ID|STRING) From 3168084cf5987384c9adcd3d96a4f49d1b15c831 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 27 Jul 2024 00:03:59 -0400 Subject: [PATCH 011/124] fixed rendering --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 2 +- packages/mermaid/src/diagrams/git/gitGraphParser.ts | 7 +++++-- packages/parser/src/language/gitGraph/gitGraph.langium | 4 ---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index b0a5ffd31..23cd20d80 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -35,7 +35,7 @@ const state = new ImperativeState(() => ({ branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]), branches: new Map([[mainBranchName, null]]), currBranch: mainBranchName, - direction: 'TB', + direction: 'LR', seq: 0, options: {}, })); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 8116d7d4c..b657b94b8 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -15,6 +15,11 @@ import type { const populate = (ast: GitGraph) => { populateCommonDb(ast, db); + // @ts-ignore: this wont exist if the direction is not specified + if (ast.dir) { + // @ts-ignore: this wont exist if the direction is not specified + db.setDirection(ast.dir); + } for (const statement of ast.statements) { parseStatement(statement); } @@ -46,9 +51,7 @@ const parseCommit = (commit: CommitAst) => { const id = commit.id; const message = commit.message ?? ''; const tags = commit.tags ?? undefined; - log.info(`Commit type`, commit.type); const type = commit.type !== undefined ? commitType[commit.type] : 0; - log.info(`Commit: ${id} ${message} ${type}`); db.commit(message, id, type, tags); }; diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium index 9c97e6e84..176e6ee7e 100644 --- a/packages/parser/src/language/gitGraph/gitGraph.langium +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -29,7 +29,6 @@ entry GitGraph: 'gitGraph' Direction? ':'? NEWLINE* ( - Options? NEWLINE* (TitleAndAccessibilities | statements+=Statement | @@ -48,9 +47,6 @@ Statement Direction: dir=('LR' | 'TB' | 'BT'); -Options: - 'options' '{' rawOptions+=STRING* '}' EOL; - Commit: 'commit' ( From 9f6a7b79ac31f7577ce9fb9c8c727b064eb9b658 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 00:49:07 -0400 Subject: [PATCH 012/124] allows for custom merge type --- packages/mermaid/src/diagrams/git/gitGraphParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index b657b94b8..9ef5ae063 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -65,7 +65,7 @@ const parseMerge = (merge: MergeAst) => { const branch = merge.branch; const id = merge.id ?? ''; const tags = merge.tags ?? undefined; - const type = merge.type !== undefined ? commitType[merge.type] : 0; + const type = merge.type !== undefined ? commitType[merge.type] : undefined; db.merge(branch, id, type, tags); }; From 275dbe9b2edf29504d240afce7adfb3612961d19 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 27 Jul 2024 02:02:12 -0400 Subject: [PATCH 013/124] fixed all rendering differences --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 2 ++ packages/mermaid/src/diagrams/git/gitGraphParser.ts | 2 +- packages/parser/src/language/gitGraph/gitGraph.langium | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 23cd20d80..f31689452 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -287,6 +287,7 @@ export const cherryPick = function ( targetId = common.sanitizeText(targetId, getConfig()); const config = getConfig(); tags = tags?.map((tag) => common.sanitizeText(tag, config)); + parentCommitId = common.sanitizeText(parentCommitId, getConfig()); if (!sourceId || !state.records.commits.has(sourceId)) { @@ -383,6 +384,7 @@ export const cherryPick = function ( }`, ], }; + state.records.head = commit; state.records.commits.set(commit.id, commit); state.records.branches.set(state.records.currBranch, commit.id); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 9ef5ae063..9a5cbcb2b 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -76,7 +76,7 @@ const parseCheckout = (checkout: CheckoutAst) => { const parseCherryPicking = (cherryPicking: CherryPickingAst) => { const id = cherryPicking.id; - const tags = cherryPicking.tags ?? undefined; + const tags = cherryPicking.tags?.length === 0 ? undefined : cherryPicking.tags; const parent = cherryPicking.parent; db.cherryPick(id, '', tags, parent); }; diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium index 176e6ee7e..807f9382b 100644 --- a/packages/parser/src/language/gitGraph/gitGraph.langium +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -65,7 +65,7 @@ Merge: ( 'id:' id=STRING |'tag:' tags+=STRING - |'type:' name=('NORMAL' | 'REVERSE' | 'HIGHLIGHT') + |'type:' type=('NORMAL' | 'REVERSE' | 'HIGHLIGHT') )* EOL; Checkout: @@ -76,7 +76,7 @@ CherryPicking: ( 'id:' id=STRING |'tag:' tags+=STRING - |'parent:' id=STRING + |'parent:' parent=STRING )* EOL; From 0d4c3e5f72ba63d883776ca491a9b6683c018e4d Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 27 Jul 2024 03:51:28 -0400 Subject: [PATCH 014/124] added unit tests for gitGraph parser --- packages/parser/src/language/index.ts | 1 + packages/parser/tests/gitGraph.test.ts | 217 ++++++++++++++++++++++--- 2 files changed, 198 insertions(+), 20 deletions(-) diff --git a/packages/parser/src/language/index.ts b/packages/parser/src/language/index.ts index 377013795..8e8dbce4f 100644 --- a/packages/parser/src/language/index.ts +++ b/packages/parser/src/language/index.ts @@ -9,6 +9,7 @@ export { Branch, Commit, Merge, + Statement, isCommon, isInfo, isPacket, diff --git a/packages/parser/tests/gitGraph.test.ts b/packages/parser/tests/gitGraph.test.ts index 850b34bf9..2d7c21bbe 100644 --- a/packages/parser/tests/gitGraph.test.ts +++ b/packages/parser/tests/gitGraph.test.ts @@ -1,30 +1,207 @@ import { describe, expect, it } from 'vitest'; -import { GitGraph } from '../src/language/index.js'; +import type { Branch, Merge } from '../src/language/index.js'; import { gitGraphParse as parse } from './test-util.js'; +import type { Commit } from '../src/language/index.js'; +import type { Checkout, CherryPicking } from '../src/language/generated/ast.js'; -describe('gitGraph', () => { - describe('Basic Parsing', () => { - it('should handle empty gitGraph', () => { - const result = parse(`gitGraph`); - expect(result.value.$type).toBe(GitGraph); - expect(result.value.statements).toHaveLength(0); - expect(result.lexerErrors).toHaveLength(0); - expect(result.parserErrors).toHaveLength(0); +describe('Parsing Commit Statements', () => { + it('should parse a simple commit', () => { + const result = parse(`gitGraph\n commit\n`); + expect(result.value.statements[0].$type).toBe('Commit'); + }); + + it('should parse multiple commits', () => { + const result = parse(`gitGraph\n commit\n commit\n commit\n`); + expect(result.value.statements).toHaveLength(3); + }); + + it('should parse commits with all properties', () => { + const result = parse(`gitGraph\n commit id:"1" msg:"Fix bug" tag:"v1.2" type:NORMAL\n`); + const commit = result.value.statements[0] as Commit; + expect(commit.$type).toBe('Commit'); + expect(commit.id).toBe('1'); + expect(commit.message).toBe('Fix bug'); + expect(commit.tags).toEqual(['v1.2']); + expect(commit.type).toBe('NORMAL'); + }); + + it('should handle commit messages with special characters', () => { + const result = parse(`gitGraph\n commit msg:"Fix issue #123: Handle errors"\n`); + const commit = result.value.statements[0] as Commit; + expect(commit.message).toBe('Fix issue #123: Handle errors'); + }); + + it('should parse commits with only a message and no other properties', () => { + const result = parse(`gitGraph\n commit msg:"Initial release"\n`); + const commit = result.value.statements[0] as Commit; + expect(commit.message).toBe('Initial release'); + expect(commit.id).toBeUndefined(); + expect(commit.type).toBeUndefined(); + }); + + it('should ignore malformed properties and not break parsing', () => { + const result = parse(`gitGraph\n commit id:"2" msg:"Malformed commit" oops:"ignored"\n`); + const commit = result.value.statements[0] as Commit; + expect(commit.id).toBe('2'); + expect(commit.message).toBe('Malformed commit'); + expect(commit.hasOwnProperty('oops')).toBe(false); + }); + + it('should parse multiple commits with different types', () => { + const result = parse(`gitGraph\n commit type:NORMAL\n commit type:REVERSE\n`); + const commit1 = result.value.statements[0] as Commit; + const commit2 = result.value.statements[1] as Commit; + expect(commit1.type).toBe('NORMAL'); + expect(commit2.type).toBe('REVERSE'); + }); +}); + +describe('Parsing Branch Statements', () => { + it('should parse a branch with a simple name', () => { + const result = parse(`gitGraph\n commit\n commit\n branch master\n`); + const branch = result.value.statements[2] as Branch; + expect(branch.name).toBe('master'); + }); + + it('should parse a branch with an order property', () => { + const result = parse(`gitGraph\n commit\n branch feature order:1\n`); + const branch = result.value.statements[1] as Branch; + expect(branch.name).toBe('feature'); + expect(branch.order).toBe(1); + }); + + it('should handle branch names with special characters', () => { + const result = parse(`gitGraph\n branch feature/test-branch\n`); + const branch = result.value.statements[0] as Branch; + expect(branch.name).toBe('feature/test-branch'); + }); + + it('should parse branches with hyphens and underscores', () => { + const result = parse(`gitGraph\n branch my-feature_branch\n`); + const branch = result.value.statements[0] as Branch; + expect(branch.name).toBe('my-feature_branch'); + }); + + it('should correctly handle branch without order property', () => { + const result = parse(`gitGraph\n branch feature\n`); + const branch = result.value.statements[0] as Branch; + expect(branch.name).toBe('feature'); + expect(branch.order).toBeUndefined(); + }); +}); + +describe('Parsing Merge Statements', () => { + it('should parse a merge with a branch name', () => { + const result = parse(`gitGraph\n merge master\n`); + const merge = result.value.statements[0] as Merge; + expect(merge.branch).toBe('master'); + }); + + it('should handle merges with additional properties', () => { + const result = parse(`gitGraph\n merge feature id:"m1" tag:"release" type:HIGHLIGHT\n`); + const merge = result.value.statements[0] as Merge; + expect(merge.branch).toBe('feature'); + expect(merge.id).toBe('m1'); + expect(merge.tags).toEqual(['release']); + expect(merge.type).toBe('HIGHLIGHT'); + }); + + it('should parse merge without any properties', () => { + const result = parse(`gitGraph\n merge feature\n`); + const merge = result.value.statements[0] as Merge; + expect(merge.branch).toBe('feature'); + }); + + it('should ignore malformed properties in merge statements', () => { + const result = parse(`gitGraph\n merge feature random:"ignored"\n`); + const merge = result.value.statements[0] as Merge; + expect(merge.branch).toBe('feature'); + expect(merge.hasOwnProperty('random')).toBe(false); + }); +}); + +describe('Parsing Checkout Statements', () => { + it('should parse a checkout to a named branch', () => { + const result = parse( + `gitGraph\n commit id:"1"\n branch develop\n branch fun\n checkout develop\n` + ); + const checkout = result.value.statements[3] as Checkout; + expect(checkout.branch).toBe('develop'); + }); + + it('should parse checkout to branches with complex names', () => { + const result = parse(`gitGraph\n checkout hotfix-123\n`); + const checkout = result.value.statements[0] as Checkout; + expect(checkout.branch).toBe('hotfix-123'); + }); + + it('should parse checkouts with hyphens and numbers', () => { + const result = parse(`gitGraph\n checkout release-2021\n`); + const checkout = result.value.statements[0] as Checkout; + expect(checkout.branch).toBe('release-2021'); + }); +}); + +describe('Parsing CherryPicking Statements', () => { + it('should parse cherry-picking with a commit id', () => { + const result = parse(`gitGraph\n commit id:"123" commit id:"321" cherry-pick id:"123"\n`); + const cherryPick = result.value.statements[2] as CherryPicking; + expect(cherryPick.id).toBe('123'); + }); + + it('should parse cherry-picking with multiple properties', () => { + const result = parse(`gitGraph\n cherry-pick id:"123" tag:"urgent" parent:"100"\n`); + const cherryPick = result.value.statements[0] as CherryPicking; + expect(cherryPick.id).toBe('123'); + expect(cherryPick.tags).toEqual(['urgent']); + expect(cherryPick.parent).toBe('100'); + }); + + describe('Parsing with Accessibility Titles and Descriptions', () => { + it('should parse accessibility titles', () => { + const result = parse(`gitGraph\n accTitle: Accessible Graph\n commit\n`); + expect(result.value.accTitle).toBe('Accessible Graph'); }); - it('should handle gitGraph with one statement', () => { - const result = parse(`gitGraph\n commit\n`); - expect(result.value.$type).toBe(GitGraph); - expect(result.lexerErrors).toHaveLength(0); - expect(result.parserErrors).toHaveLength(0); - expect(result.value.statements).toHaveLength(1); + it('should parse multiline accessibility descriptions', () => { + const result = parse( + `gitGraph\n accDescr {\n Detailed description\n across multiple lines\n }\n commit\n` + ); + expect(result.value.accDescr).toBe('Detailed description\nacross multiple lines'); + }); + }); + + describe('Integration Tests', () => { + it('should correctly parse a complex graph with various elements', () => { + const result = parse(` + gitGraph TB: + accTitle: Complex Example + commit id:"init" type:NORMAL + branch feature + commit id:"feat1" msg:"Add feature" + checkout main + merge feature tag:"v1.0" + cherry-pick id:"feat1" tag:"critical fix" + `); + expect(result.value.accTitle).toBe('Complex Example'); + expect(result.value.statements[0].$type).toBe('Commit'); + expect(result.value.statements[1].$type).toBe('Branch'); + expect(result.value.statements[2].$type).toBe('Commit'); + expect(result.value.statements[3].$type).toBe('Checkout'); + expect(result.value.statements[4].$type).toBe('Merge'); + expect(result.value.statements[5].$type).toBe('CherryPicking'); + }); + }); + + describe('Error Handling for Invalid Syntax', () => { + it('should report errors for unknown properties in commit', () => { + const result = parse(`gitGraph\n commit unknown:"oops"\n`); + expect(result.parserErrors).not.toHaveLength(0); }); - it('should handle gitGraph with multiple statements and use accTitle', () => { - const result = parse(`gitGraph\n commit\n commit\n accTitle: title\n commit\n`); - expect(result.value.$type).toBe(GitGraph); - expect(result.lexerErrors).toHaveLength(0); - expect(result.parserErrors).toHaveLength(0); + it('should report errors for invalid branch order', () => { + const result = parse(`gitGraph\n branch feature order:xyz\n`); + expect(result.parserErrors).not.toHaveLength(0); }); }); }); From e57fee1f37ec82e082e147e0d258346dc8c5fd6d Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:02:49 -0400 Subject: [PATCH 015/124] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index f31689452..8ce891261 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -40,10 +40,7 @@ const state = new ImperativeState(() => ({ options: {}, })); -/** - * - */ -function getId() { +function getID() { return random({ length: 7 }); } From 62757c529ff65f9694252855f3655e86c07fb107 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:02:56 -0400 Subject: [PATCH 016/124] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 8ce891261..2f29a4531 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -44,33 +44,6 @@ function getID() { return random({ length: 7 }); } -// function isFastForwardable(currentCommit, otherCommit) { -// log.debug('Entering isFastForwardable:', currentCommit.id, otherCommit.id); -// let cnt = 0; -// while (currentCommit.seq <= otherCommit.seq && currentCommit !== otherCommit && cnt < 1000) { -// cnt++; -// // only if other branch has more commits -// if (otherCommit.parent == null) break; -// if (Array.isArray(otherCommit.parent)) { -// log.debug('In merge commit:', otherCommit.parent); -// return ( -// isFastForwardable(currentCommit, commits.get(otherCommit.parent[0])) || -// isFastForwardable(currentCommit, commits.get(otherCommit.parent[1])) -// ); -// } else { -// otherCommit = commits.get(otherCommit.parent); -// } -// } -// log.debug(currentCommit.id, otherCommit.id); -// return currentCommit.id === otherCommit.id; -// } - -// function isReachableFrom(currentCommit, otherCommit) { -// const currentSeq = currentCommit.seq; -// const otherSeq = otherCommit.seq; -// if (currentSeq > otherSeq) return isFastForwardable(otherCommit, currentCommit); -// return false; -// } /** * @param list - list of items From 281064f714cd7da9413a8a08c3a967a269c9bb6d Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:03:02 -0400 Subject: [PATCH 017/124] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 2f29a4531..48689d9c5 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -103,7 +103,7 @@ export const commit = function (msg: string, id: string, type: number, tags: str log.debug('in pushCommit ' + newCommit.id); }; -export const branch = function (name: string, order: number | undefined) { +export const branch = function (name: string, order?: number) { name = common.sanitizeText(name, getConfig()); if (!state.records.branches.has(name)) { state.records.branches.set(name, state.records.head != null ? state.records.head.id : null); From ec2d9c9a087eaf08387d6260519737b833710754 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:03:08 -0400 Subject: [PATCH 018/124] Update packages/mermaid/src/diagrams/git/gitGraphParser.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 9a5cbcb2b..b7522996a 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -43,7 +43,7 @@ const parseStatement = (statement: any) => { parseCherryPicking(statement); break; default: - log.warn(`Unknown statement type`); + log.error(`Unknown statement type`); } }; From 5dfc94e6f5064b767fbe6225def31c92a340c86d Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:03:14 -0400 Subject: [PATCH 019/124] Update packages/mermaid/src/diagrams/git/gitGraphParser.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index b7522996a..5598062b4 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -51,7 +51,7 @@ const parseCommit = (commit: CommitAst) => { const id = commit.id; const message = commit.message ?? ''; const tags = commit.tags ?? undefined; - const type = commit.type !== undefined ? commitType[commit.type] : 0; + const type = commit.type !== undefined ? commitType[commit.type] : commitType.NORMAL; db.commit(message, id, type, tags); }; From 871f0478c691ba3e5168fa90f583975704ded3c0 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:03:19 -0400 Subject: [PATCH 020/124] Update packages/parser/src/language/gitGraph/module.ts Co-authored-by: Sidharth Vinod --- packages/parser/src/language/gitGraph/module.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/parser/src/language/gitGraph/module.ts b/packages/parser/src/language/gitGraph/module.ts index 1630377e5..e2d45c8fa 100644 --- a/packages/parser/src/language/gitGraph/module.ts +++ b/packages/parser/src/language/gitGraph/module.ts @@ -11,7 +11,6 @@ import { createDefaultSharedCoreModule, EmptyFileSystem, } from 'langium'; - import { CommonValueConverter } from '../common/valueConverter.js'; import { MermaidGeneratedSharedModule, GitGraphGeneratedModule } from '../generated/module.js'; import { GitGraphTokenBuilder } from './tokenBuilder.js'; From 6e5e5f9c6188407a06e83ea043f8f54368a135b6 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:03:25 -0400 Subject: [PATCH 021/124] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 48689d9c5..577aefc3c 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -215,16 +215,6 @@ export const merge = ( throw error; } - // if (isReachableFrom(currentCommit, otherCommit)) { - // log.debug('Already merged'); - // return; - // } - // if (isFastForwardable(currentCommit, otherCommit)) { - // branches.set(curBranch, branches.get(otherBranch)); - // head = commits.get(branches.get(curBranch)); - // } else { - // create merge commit - const verifiedBranch: string = otherBranchCheck ? otherBranchCheck : ''; //figure out a cleaner way to do this const commit: Commit = { From 346efdd384e4970e545d00cea63ea05a34fbd6f5 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:04:16 -0400 Subject: [PATCH 022/124] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 577aefc3c..e2c77b708 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -83,9 +83,9 @@ export const getOptions = function () { export const commit = function (msg: string, id: string, type: number, tags: string[] | undefined) { log.info('commit', msg, id, type, tags); log.debug('Entering commit:', msg, id, type, tags); - id = common.sanitizeText(id, getConfig()); - msg = common.sanitizeText(msg, getConfig()); const config = getConfig(); + id = common.sanitizeText(id, config); + msg = common.sanitizeText(msg, config); tags = tags?.map((tag) => common.sanitizeText(tag, config)); const newCommit: Commit = { id: id ? id : state.records.seq + '-' + getId(), From a0207f9195b31d185dc3060654fff361f32f6631 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:04:23 -0400 Subject: [PATCH 023/124] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index e2c77b708..f7a732b3f 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -80,7 +80,7 @@ export const getOptions = function () { return state.records.options; }; -export const commit = function (msg: string, id: string, type: number, tags: string[] | undefined) { +export const commit = function (msg: string, id: string, type: number, tags?: string[]) { log.info('commit', msg, id, type, tags); log.debug('Entering commit:', msg, id, type, tags); const config = getConfig(); From 6c1e5aae9222fc3db9db775923d0d3b34591b736 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:05:34 -0400 Subject: [PATCH 024/124] Delete packages/mermaid/src/diagrams/git/parser/gitGraph.jison --- .../src/diagrams/git/parser/gitGraph.jison | 249 ------------------ 1 file changed, 249 deletions(-) delete mode 100644 packages/mermaid/src/diagrams/git/parser/gitGraph.jison diff --git a/packages/mermaid/src/diagrams/git/parser/gitGraph.jison b/packages/mermaid/src/diagrams/git/parser/gitGraph.jison deleted file mode 100644 index 56ba1465e..000000000 --- a/packages/mermaid/src/diagrams/git/parser/gitGraph.jison +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Parse following - * gitGraph: - * commit - * commit - * branch - */ -%lex - -%x string -%x options -%x acc_title -%x acc_descr -%x acc_descr_multiline -%options case-insensitive - - -%% -accTitle\s*":"\s* { this.begin("acc_title");return 'acc_title'; } -(?!\n|;|#)*[^\n]* { this.popState(); return "acc_title_value"; } -accDescr\s*":"\s* { this.begin("acc_descr");return 'acc_descr'; } -(?!\n|;|#)*[^\n]* { this.popState(); return "acc_descr_value"; } -accDescr\s*"{"\s* { this.begin("acc_descr_multiline");} -[\}] { this.popState(); } -[^\}]* return "acc_descr_multiline_value"; -(\r?\n)+ /*{console.log('New line');return 'NL';}*/ return 'NL'; -\#[^\n]* /* skip comments */ -\%%[^\n]* /* skip comments */ -"gitGraph" return 'GG'; -commit(?=\s|$) return 'COMMIT'; -"id:" return 'COMMIT_ID'; -"type:" return 'COMMIT_TYPE'; -"msg:" return 'COMMIT_MSG'; -"NORMAL" return 'NORMAL'; -"REVERSE" return 'REVERSE'; -"HIGHLIGHT" return 'HIGHLIGHT'; -"tag:" return 'COMMIT_TAG'; -branch(?=\s|$) return 'BRANCH'; -"order:" return 'ORDER'; -merge(?=\s|$) return 'MERGE'; -cherry\-pick(?=\s|$) return 'CHERRY_PICK'; -"parent:" return 'PARENT_COMMIT' -// "reset" return 'RESET'; -\b(checkout|switch)(?=\s|$) return 'CHECKOUT'; -"LR" return 'DIR'; -"TB" return 'DIR'; -"BT" return 'DIR'; -":" return ':'; -"^" return 'CARET' -"options"\r?\n this.begin("options"); // -[ \r\n\t]+"end" this.popState(); // not used anymore in the renderer, fixed for backward compatibility -[\s\S]+(?=[ \r\n\t]+"end") return 'OPT'; // -["]["] return 'EMPTYSTR'; -["] this.begin("string"); -["] this.popState(); -[^"]* return 'STR'; -[0-9]+(?=\s|$) return 'NUM'; -\w([-\./\w]*[-\w])? return 'ID'; // only a subset of https://git-scm.com/docs/git-check-ref-format -<> return 'EOF'; -\s+ /* skip all whitespace */ // lowest priority so we can use lookaheads in earlier regex - -/lex - -%left '^' - -%start start - -%% /* language grammar */ - -start - : eol start - | GG document EOF{ return $3; } - | GG ':' document EOF{ return $3; } - | GG DIR ':' document EOF {yy.setDirection($2); return $4;} - ; - - -document - : /*empty*/ - | options body { yy.setOptions($1); $$ = $2} - ; - -options - : options OPT {$1 +=$2; $$=$1} - | NL - ; -body - : /*empty*/ {$$ = []} - | body line {$1.push($2); $$=$1;} - ; -line - : statement eol {$$ =$1} - | NL - ; - -statement - : commitStatement - | mergeStatement - | cherryPickStatement - | acc_title acc_title_value { $$=$2.trim();yy.setAccTitle($$); } - | acc_descr acc_descr_value { $$=$2.trim();yy.setAccDescription($$); } - | acc_descr_multiline_value { $$=$1.trim();yy.setAccDescription($$); } | section {yy.addSection($1.substr(8));$$=$1.substr(8);} - | branchStatement - | CHECKOUT ref {yy.checkout($2)} - // | RESET reset_arg {yy.reset($2)} - ; -branchStatement - : BRANCH ref {yy.branch($2)} - | BRANCH ref ORDER NUM {yy.branch($2, $4)} - ; - -cherryPickStatement - : CHERRY_PICK COMMIT_ID STR {yy.cherryPick($3, '', undefined)} - | CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($3, '', undefined,$5)} - | CHERRY_PICK COMMIT_ID STR commitTags {yy.cherryPick($3, '', $4)} - | CHERRY_PICK COMMIT_ID STR PARENT_COMMIT STR commitTags {yy.cherryPick($3, '', $6,$5)} - | CHERRY_PICK COMMIT_ID STR commitTags PARENT_COMMIT STR {yy.cherryPick($3, '', $4,$6)} - | CHERRY_PICK commitTags COMMIT_ID STR {yy.cherryPick($4, '', $2)} - | CHERRY_PICK commitTags COMMIT_ID STR PARENT_COMMIT STR {yy.cherryPick($4, '', $2,$6)} - ; - -mergeStatement - : MERGE ref {yy.merge($2,'','', undefined)} - | MERGE ref COMMIT_ID STR {yy.merge($2, $4,'', undefined)} - | MERGE ref COMMIT_TYPE commitType {yy.merge($2,'', $4, undefined)} - | MERGE ref commitTags {yy.merge($2, '','',$3)} - | MERGE ref commitTags COMMIT_ID STR {yy.merge($2, $5,'', $3)} - | MERGE ref commitTags COMMIT_TYPE commitType {yy.merge($2, '',$5, $3)} - | MERGE ref COMMIT_TYPE commitType commitTags {yy.merge($2, '',$4, $5)} - | MERGE ref COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $4, $6, undefined)} - | MERGE ref COMMIT_ID STR commitTags {yy.merge($2, $4, '', $5)} - | MERGE ref COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $6,$4, undefined)} - | MERGE ref COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.merge($2, $4, $6, $7)} - | MERGE ref COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.merge($2, $7, $4, $5)} - | MERGE ref COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.merge($2, $4, $7, $5)} - | MERGE ref COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.merge($2, $6, $4, $7)} - | MERGE ref commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.merge($2, $7, $5, $3)} - | MERGE ref commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.merge($2, $5, $7, $3)} - ; - - -commitStatement - : COMMIT commit_arg {yy.commit($2)} - | COMMIT commitTags {yy.commit('','',yy.commitType.NORMAL,$2)} - | COMMIT COMMIT_TYPE commitType {yy.commit('','',$3, undefined)} - | COMMIT commitTags COMMIT_TYPE commitType {yy.commit('','',$4,$2)} - | COMMIT COMMIT_TYPE commitType commitTags {yy.commit('','',$3,$4)} - | COMMIT COMMIT_ID STR {yy.commit('',$3,yy.commitType.NORMAL, undefined)} - | COMMIT COMMIT_ID STR commitTags {yy.commit('',$3,yy.commitType.NORMAL,$4)} - | COMMIT commitTags COMMIT_ID STR {yy.commit('',$4,yy.commitType.NORMAL,$2)} - | COMMIT COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$3,$5, undefined)} - | COMMIT COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$5,$3, undefined)} - | COMMIT COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.commit('',$3,$5,$6)} - | COMMIT COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.commit('',$3,$6,$4)} - | COMMIT COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.commit('',$5,$3,$6)} - | COMMIT COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.commit('',$6,$3,$4)} - | COMMIT commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.commit('',$6,$4,$2)} - | COMMIT commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.commit('',$4,$6,$2)} - | COMMIT COMMIT_MSG STR {yy.commit($3,'',yy.commitType.NORMAL, undefined)} - | COMMIT commitTags COMMIT_MSG STR {yy.commit($4,'',yy.commitType.NORMAL,$2)} - | COMMIT COMMIT_MSG STR commitTags {yy.commit($3,'',yy.commitType.NORMAL,$4)} - | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($3,'',$5, undefined)} - | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($5,'',$3, undefined)} - | COMMIT COMMIT_ID STR COMMIT_MSG STR {yy.commit($5,$3,yy.commitType.NORMAL, undefined)} - | COMMIT COMMIT_MSG STR COMMIT_ID STR {yy.commit($3,$5,yy.commitType.NORMAL, undefined)} - - | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType commitTags {yy.commit($3,'',$5,$6)} - | COMMIT COMMIT_MSG STR commitTags COMMIT_TYPE commitType {yy.commit($3,'',$6,$4)} - | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR commitTags {yy.commit($5,'',$3,$6)} - | COMMIT COMMIT_TYPE commitType commitTags COMMIT_MSG STR {yy.commit($6,'',$3,$4)} - | COMMIT commitTags COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($6,'',$4,$2)} - | COMMIT commitTags COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($4,'',$6,$2)} - - | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$7,$5, undefined)} - | COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$5,$7, undefined)} - | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($5,$7,$3, undefined)} - | COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($7,$5,$3, undefined)} - | COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($7,$3,$5, undefined)} - | COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($5,$3,$7, undefined)} - - | COMMIT COMMIT_MSG STR commitTags COMMIT_ID STR {yy.commit($3,$6,yy.commitType.NORMAL,$4)} - | COMMIT COMMIT_MSG STR COMMIT_ID STR commitTags {yy.commit($3,$5,yy.commitType.NORMAL,$6)} - | COMMIT commitTags COMMIT_MSG STR COMMIT_ID STR {yy.commit($4,$6,yy.commitType.NORMAL,$2)} - | COMMIT commitTags COMMIT_ID STR COMMIT_MSG STR {yy.commit($6,$4,yy.commitType.NORMAL,$2)} - | COMMIT COMMIT_ID STR commitTags COMMIT_MSG STR {yy.commit($6,$3,yy.commitType.NORMAL,$4)} - | COMMIT COMMIT_ID STR COMMIT_MSG STR commitTags {yy.commit($5,$3,yy.commitType.NORMAL,$6)} - - | COMMIT COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType commitTags {yy.commit($3,$5,$7,$8)} - | COMMIT COMMIT_MSG STR COMMIT_ID STR commitTags COMMIT_TYPE commitType {yy.commit($3,$5,$8,$6)} - | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR commitTags {yy.commit($3,$7,$5,$8)} - | COMMIT COMMIT_MSG STR COMMIT_TYPE commitType commitTags COMMIT_ID STR {yy.commit($3,$8,$5,$6)} - | COMMIT COMMIT_MSG STR commitTags COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($3,$6,$8,$4)} - | COMMIT COMMIT_MSG STR commitTags COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($3,$8,$6,$4)} - - | COMMIT COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType commitTags {yy.commit($5,$3,$7,$8)} - | COMMIT COMMIT_ID STR COMMIT_MSG STR commitTags COMMIT_TYPE commitType {yy.commit($5,$3,$8,$6)} - | COMMIT COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR commitTags {yy.commit($7,$3,$5,$8)} - | COMMIT COMMIT_ID STR COMMIT_TYPE commitType commitTags COMMIT_MSG STR {yy.commit($8,$3,$5,$6)} - | COMMIT COMMIT_ID STR commitTags COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($6,$3,$8,$4)} - | COMMIT COMMIT_ID STR commitTags COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($8,$3,$6,$4)} - - | COMMIT commitTags COMMIT_ID STR COMMIT_TYPE commitType COMMIT_MSG STR {yy.commit($8,$4,$6,$2)} - | COMMIT commitTags COMMIT_ID STR COMMIT_MSG STR COMMIT_TYPE commitType {yy.commit($6,$4,$8,$2)} - | COMMIT commitTags COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR {yy.commit($8,$6,$4,$2)} - | COMMIT commitTags COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR {yy.commit($6,$8,$4,$2)} - | COMMIT commitTags COMMIT_MSG STR COMMIT_ID STR COMMIT_TYPE commitType {yy.commit($4,$6,$8,$2)} - | COMMIT commitTags COMMIT_MSG STR COMMIT_TYPE commitType COMMIT_ID STR {yy.commit($4,$8,$6,$2)} - - | COMMIT COMMIT_TYPE commitType COMMIT_ID STR COMMIT_MSG STR commitTags {yy.commit($7,$5,$3,$8)} - | COMMIT COMMIT_TYPE commitType COMMIT_ID STR commitTags COMMIT_MSG STR {yy.commit($8,$5,$3,$6)} - | COMMIT COMMIT_TYPE commitType commitTags COMMIT_MSG STR COMMIT_ID STR {yy.commit($6,$8,$3,$4)} - | COMMIT COMMIT_TYPE commitType commitTags COMMIT_ID STR COMMIT_MSG STR {yy.commit($8,$6,$3,$4)} - | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR COMMIT_ID STR commitTags {yy.commit($5,$7,$3,$8)} - | COMMIT COMMIT_TYPE commitType COMMIT_MSG STR commitTags COMMIT_ID STR {yy.commit($5,$8,$3,$6)} - ; -commit_arg - : /* empty */ {$$ = ""} - | STR {$$=$1} - ; -commitType - : NORMAL { $$=yy.commitType.NORMAL;} - | REVERSE { $$=yy.commitType.REVERSE;} - | HIGHLIGHT { $$=yy.commitType.HIGHLIGHT;} - ; -commitTags - : COMMIT_TAG STR {$$=[$2]} - | COMMIT_TAG EMPTYSTR {$$=['']} - | commitTags COMMIT_TAG STR {$commitTags.push($3); $$=$commitTags;} - | commitTags COMMIT_TAG EMPTYSTR {$commitTags.push(''); $$=$commitTags;} - ; - -ref - : ID - | STR - ; - -eol - : NL - | ';' - | EOF - ; -// reset_arg -// : 'HEAD' reset_parents{$$ = $1+ ":" + $2 } -// | ID reset_parents{$$ = $1+ ":" + yy.count; yy.count = 0} -// ; -// reset_parents -// : /* empty */ {yy.count = 0} -// | CARET reset_parents { yy.count += 1 } -// ; From ef25160b8ed36b465f825f50251fa4917d78353a Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:06:09 -0400 Subject: [PATCH 025/124] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index f7a732b3f..c12c646a4 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -105,16 +105,16 @@ export const commit = function (msg: string, id: string, type: number, tags?: st export const branch = function (name: string, order?: number) { name = common.sanitizeText(name, getConfig()); - if (!state.records.branches.has(name)) { + if (state.records.branches.has(name)) { + throw new Error( + `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")` + ); + } + state.records.branches.set(name, state.records.head != null ? state.records.head.id : null); state.records.branchConfig.set(name, { name, order }); checkout(name); log.debug('in createBranch'); - } else { - throw new Error( - `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")` - ); - } }; export const merge = ( From f30085c47e90a8cdeb94b2da281310a613f2e703 Mon Sep 17 00:00:00 2001 From: Austin-Fulbright <53443958+Austin-Fulbright@users.noreply.github.com> Date: Sat, 27 Jul 2024 04:06:43 -0400 Subject: [PATCH 026/124] Update packages/mermaid/src/diagrams/git/gitGraphAst.ts Co-authored-by: Sidharth Vinod --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index c12c646a4..3641853df 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -231,7 +231,6 @@ export const merge = ( state.records.head = commit; state.records.commits.set(commit.id, commit); state.records.branches.set(state.records.currBranch, commit.id); - // } log.debug(state.records.branches); log.debug('in mergeBranch'); }; From 2a38d46fd901df29e6e2a55d3759adf9dde6796c Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Mon, 5 Aug 2024 13:53:51 -0400 Subject: [PATCH 027/124] fixed the rest of the concerns, refactored portions of the gitGraphParser test to handle async actions --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 72 +-- .../src/diagrams/git/gitGraphParser.spec.js | 201 +++---- .../src/diagrams/git/gitGraphParserV2.spec.js | 550 +++++++++--------- .../src/language/gitGraph/gitGraph.langium | 2 +- 4 files changed, 378 insertions(+), 447 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 3641853df..008e7923f 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -44,7 +44,6 @@ function getID() { return random({ length: 7 }); } - /** * @param list - list of items * @param fn - function to get the key @@ -88,7 +87,7 @@ export const commit = function (msg: string, id: string, type: number, tags?: st msg = common.sanitizeText(msg, config); tags = tags?.map((tag) => common.sanitizeText(tag, config)); const newCommit: Commit = { - id: id ? id : state.records.seq + '-' + getId(), + id: id ? id : state.records.seq + '-' + getID(), message: msg, seq: state.records.seq++, type: type ?? commitType.NORMAL, @@ -109,12 +108,12 @@ export const branch = function (name: string, order?: number) { throw new Error( `Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${name}")` ); - } - - state.records.branches.set(name, state.records.head != null ? state.records.head.id : null); - state.records.branchConfig.set(name, { name, order }); - checkout(name); - log.debug('in createBranch'); + } + + state.records.branches.set(name, state.records.head != null ? state.records.head.id : null); + state.records.branchConfig.set(name, { name, order }); + checkout(name); + log.debug('in createBranch'); }; export const merge = ( @@ -123,9 +122,10 @@ export const merge = ( overrideType?: number, customTags?: string[] ): void => { - otherBranch = common.sanitizeText(otherBranch, getConfig()); + const config = getConfig(); + otherBranch = common.sanitizeText(otherBranch, config); if (customId) { - customId = common.sanitizeText(customId, getConfig()); + customId = common.sanitizeText(customId, config); } const currentBranchCheck: string | null | undefined = state.records.branches.get( state.records.currBranch @@ -150,7 +150,8 @@ export const merge = ( expected: ['branch abc'], }; throw error; - } else if (currentCommit === undefined || !currentCommit) { + } + if (currentCommit === undefined || !currentCommit) { const error: any = new Error( `Incorrect usage of "merge". Current branch (${state.records.currBranch})has no commits` ); @@ -162,7 +163,8 @@ export const merge = ( expected: ['commit'], }; throw error; - } else if (!state.records.branches.has(otherBranch)) { + } + if (!state.records.branches.has(otherBranch)) { const error: any = new Error( 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ') does not exist' ); @@ -174,7 +176,8 @@ export const merge = ( expected: [`branch ${otherBranch}`], }; throw error; - } else if (otherCommit === undefined || !otherCommit) { + } + if (otherCommit === undefined || !otherCommit) { const error: any = new Error( 'Incorrect usage of "merge". Branch to be merged (' + otherBranch + ') has no commits' ); @@ -186,7 +189,8 @@ export const merge = ( expected: ['"commit"'], }; throw error; - } else if (currentCommit === otherCommit) { + } + if (currentCommit === otherCommit) { const error: any = new Error('Incorrect usage of "merge". Both branches have same head'); error.hash = { text: `merge ${otherBranch}`, @@ -196,7 +200,8 @@ export const merge = ( expected: ['branch abc'], }; throw error; - } else if (customId && state.records.commits.has(customId)) { + } + if (customId && state.records.commits.has(customId)) { const error: any = new Error( 'Incorrect usage of "merge". Commit with id:' + customId + @@ -218,7 +223,7 @@ export const merge = ( const verifiedBranch: string = otherBranchCheck ? otherBranchCheck : ''; //figure out a cleaner way to do this const commit: Commit = { - id: customId ? customId : state.records.seq + '-' + getId(), + id: customId ? customId : state.records.seq + '-' + getID(), message: `merged branch ${otherBranch} into ${state.records.currBranch}`, seq: state.records.seq++, parents: [state.records.head == null ? null : state.records.head.id, verifiedBranch], @@ -242,12 +247,13 @@ export const cherryPick = function ( parentCommitId: string ) { log.debug('Entering cherryPick:', sourceId, targetId, tags); - sourceId = common.sanitizeText(sourceId, getConfig()); - targetId = common.sanitizeText(targetId, getConfig()); const config = getConfig(); + sourceId = common.sanitizeText(sourceId, config); + targetId = common.sanitizeText(targetId, config); + tags = tags?.map((tag) => common.sanitizeText(tag, config)); - parentCommitId = common.sanitizeText(parentCommitId, getConfig()); + parentCommitId = common.sanitizeText(parentCommitId, config); if (!sourceId || !state.records.commits.has(sourceId)) { const error: any = new Error( @@ -293,8 +299,6 @@ export const cherryPick = function ( error.hash = { text: `cherryPick ${sourceId} ${targetId}`, token: `cherryPick ${sourceId} ${targetId}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['cherry-pick abc'], }; throw error; @@ -307,8 +311,6 @@ export const cherryPick = function ( error.hash = { text: `cherryPick ${sourceId} ${targetId}`, token: `cherryPick ${sourceId} ${targetId}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['cherry-pick abc'], }; throw error; @@ -323,13 +325,12 @@ export const cherryPick = function ( text: `cherryPick ${sourceId} ${targetId}`, token: `cherryPick ${sourceId} ${targetId}`, line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['cherry-pick abc'], }; throw error; } const commit = { - id: state.records.seq + '-' + getId(), + id: state.records.seq + '-' + getID(), message: `cherry-picked ${sourceCommit?.message} into ${state.records.currBranch}`, seq: state.records.seq++, parents: [state.records.head == null ? null : state.records.head.id, sourceCommit.id], @@ -365,8 +366,6 @@ export const checkout = function (branch: string) { expected: [`branch ${branch}`], }; throw error; - //branches[branch] = head != null ? head.id : null; - //log.debug('in createBranch'); } else { state.records.currBranch = branch; const id = state.records.branches.get(state.records.currBranch); @@ -378,25 +377,6 @@ export const checkout = function (branch: string) { } }; -// export const reset = function (commitRef) { -// log.debug('in reset', commitRef); -// const ref = commitRef.split(':')[0]; -// let parentCount = parseInt(commitRef.split(':')[1]); -// let commit = ref === 'HEAD' ? head : commits.get(branches.get(ref)); -// log.debug(commit, parentCount); -// while (parentCount > 0) { -// commit = commits.get(commit.parent); -// parentCount--; -// if (!commit) { -// const err = 'Critical error - unique parent commit not found during reset'; -// log.error(err); -// throw err; -// } -// } -// head = commit; -// branches[curBranch] = commit.id; -// }; - /** * @param arr - array * @param key - key diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js index d498577fe..460d039aa 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js @@ -1,129 +1,92 @@ -import gitGraphAst from './gitGraphAst.js'; -import { parser } from './parser/gitGraph.jison'; +import db from './gitGraphAst.js'; +import { parser } from './gitGraphParser.js'; describe('when parsing a gitGraph', function () { beforeEach(function () { - parser.yy = gitGraphAst; - parser.yy.clear(); + db.clear(); }); - it('should handle a gitGraph definition', function () { - const str = 'gitGraph:\n' + 'commit\n'; - parser.parse(str); - const commits = parser.yy.getCommits(); + it('should handle a gitGraph definition', async () => { + const str = `gitGraph:\n commit\n`; + + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); }); - it('should handle a gitGraph definition with empty options', function () { - const str = 'gitGraph:\n' + 'options\n' + ' end\n' + 'commit\n'; - - parser.parse(str); - const commits = parser.yy.getCommits(); - - expect(parser.yy.getOptions()).toEqual({}); - expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); - }); - - it('should handle a gitGraph definition with valid options', function () { - const str = 'gitGraph:\n' + 'options\n' + '{"key": "value"}\n' + 'end\n' + 'commit\n'; - - parser.parse(str); - const commits = parser.yy.getCommits(); - expect(parser.yy.getOptions().key).toBe('value'); - expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); - }); - - it('should not fail on a gitGraph with malformed json', function () { - const str = 'gitGraph:\n' + 'options\n' + '{"key": "value"\n' + 'end\n' + 'commit\n'; - - parser.parse(str); - const commits = parser.yy.getCommits(); - expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); - }); - - it('should handle set direction top to bottom', function () { + it('should handle set direction top to bottom', async () => { const str = 'gitGraph TB:\n' + 'commit\n'; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('TB'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('TB'); + expect(db.getBranches().size).toBe(1); }); - it('should handle set direction bottom to top', function () { + it('should handle set direction bottom to top', async () => { const str = 'gitGraph BT:\n' + 'commit\n'; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('BT'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('BT'); + expect(db.getBranches().size).toBe(1); }); - it('should checkout a branch', function () { + it('should checkout a branch', async () => { const str = 'gitGraph:\n' + 'branch new\n' + 'checkout new\n'; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(0); - expect(parser.yy.getCurrentBranch()).toBe('new'); + expect(db.getCurrentBranch()).toBe('new'); }); - it('should switch a branch', function () { + it('should switch a branch', async () => { const str = 'gitGraph:\n' + 'branch new\n' + 'switch new\n'; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(0); - expect(parser.yy.getCurrentBranch()).toBe('new'); + expect(db.getCurrentBranch()).toBe('new'); }); - it('should add commits to checked out branch', function () { + it('should add commits to checked out branch', async () => { const str = 'gitGraph:\n' + 'branch new\n' + 'checkout new\n' + 'commit\n' + 'commit\n'; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(2); - expect(parser.yy.getCurrentBranch()).toBe('new'); - const branchCommit = parser.yy.getBranches().get('new'); + expect(db.getCurrentBranch()).toBe('new'); + const branchCommit = db.getBranches().get('new'); expect(branchCommit).not.toBeNull(); expect(commits.get(branchCommit).parent).not.toBeNull(); }); - it('should handle commit with args', function () { + it('should handle commit with args', async () => { const str = 'gitGraph:\n' + 'commit "a commit"\n'; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); 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'); + expect(db.getCurrentBranch()).toBe('main'); }); - // Reset has been commented out in JISON - it.skip('should reset a branch', function () { + it.skip('should reset a branch', async () => { const str = 'gitGraph:\n' + 'commit\n' + @@ -133,16 +96,16 @@ describe('when parsing a gitGraph', function () { 'commit\n' + 'reset main\n'; - parser.parse(str); + await parser.parse(str); - const commits = parser.yy.getCommits(); + const commits = db.getCommits(); expect(commits.size).toBe(3); - expect(parser.yy.getCurrentBranch()).toBe('newbranch'); - expect(parser.yy.getBranches().get('newbranch')).toEqual(parser.yy.getBranches().get('main')); - expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches().get('newbranch')); + expect(db.getCurrentBranch()).toBe('newbranch'); + expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); + expect(db.getHead().id).toEqual(db.getBranches().get('newbranch')); }); - it.skip('reset can take an argument', function () { + it.skip('reset can take an argument', async () => { const str = 'gitGraph:\n' + 'commit\n' + @@ -152,16 +115,16 @@ describe('when parsing a gitGraph', function () { 'commit\n' + 'reset main^\n'; - parser.parse(str); + await parser.parse(str); - const commits = parser.yy.getCommits(); + const commits = db.getCommits(); expect(commits.size).toBe(3); - expect(parser.yy.getCurrentBranch()).toBe('newbranch'); - const main = commits.get(parser.yy.getBranches().get('main')); - expect(parser.yy.getHead().id).toEqual(main.parent); + expect(db.getCurrentBranch()).toBe('newbranch'); + const main = commits.get(db.getBranches().get('main')); + expect(db.getHead().id).toEqual(main.parent); }); - it.skip('should handle fast forwardable merges', function () { + it.skip('should handle fast forwardable merges', async () => { const str = 'gitGraph:\n' + 'commit\n' + @@ -172,16 +135,16 @@ describe('when parsing a gitGraph', function () { 'checkout main\n' + 'merge newbranch\n'; - parser.parse(str); + await parser.parse(str); - const commits = parser.yy.getCommits(); + const commits = db.getCommits(); expect(commits.size).toBe(4); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getBranches().get('newbranch')).toEqual(parser.yy.getBranches().get('main')); - expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches().get('newbranch')); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); + expect(db.getHead().id).toEqual(db.getBranches().get('newbranch')); }); - it('should handle cases when merge is a noop', function () { + it('should handle cases when merge is a noop', async () => { const str = 'gitGraph:\n' + 'commit\n' + @@ -191,18 +154,16 @@ describe('when parsing a gitGraph', function () { 'commit\n' + 'merge main\n'; - parser.parse(str); + await parser.parse(str); - const commits = parser.yy.getCommits(); + const commits = db.getCommits(); expect(commits.size).toBe(4); - expect(parser.yy.getCurrentBranch()).toBe('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')); + expect(db.getCurrentBranch()).toBe('newbranch'); + expect(db.getBranches().get('newbranch')).not.toEqual(db.getBranches().get('main')); + expect(db.getHead().id).toEqual(db.getBranches().get('newbranch')); }); - it('should handle merge with 2 parents', function () { + it('should handle merge with 2 parents', async () => { const str = 'gitGraph:\n' + 'commit\n' + @@ -214,18 +175,16 @@ describe('when parsing a gitGraph', function () { 'commit\n' + 'merge newbranch\n'; - parser.parse(str); + await parser.parse(str); - const commits = parser.yy.getCommits(); + const commits = db.getCommits(); expect(commits.size).toBe(5); - expect(parser.yy.getCurrentBranch()).toBe('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')); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getBranches().get('newbranch')).not.toEqual(db.getBranches().get('main')); + expect(db.getHead().id).toEqual(db.getBranches().get('main')); }); - it.skip('should handle ff merge when history walk has two parents (merge commit)', function () { + it.skip('should handle ff merge when history walk has two parents (merge commit)', async () => { const str = 'gitGraph:\n' + 'commit\n' + @@ -240,18 +199,18 @@ describe('when parsing a gitGraph', function () { 'checkout newbranch\n' + 'merge main\n'; - parser.parse(str); + await parser.parse(str); - const commits = parser.yy.getCommits(); + const commits = db.getCommits(); expect(commits.size).toBe(7); - expect(parser.yy.getCurrentBranch()).toBe('newbranch'); - expect(parser.yy.getBranches().get('newbranch')).toEqual(parser.yy.getBranches().get('main')); - expect(parser.yy.getHead().id).toEqual(parser.yy.getBranches().get('main')); + expect(db.getCurrentBranch()).toBe('newbranch'); + expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); + expect(db.getHead().id).toEqual(db.getBranches().get('main')); - parser.yy.prettyPrint(); + db.prettyPrint(); }); - it('should generate an array of known branches', function () { + it('should generate an array of known branches', async () => { const str = 'gitGraph:\n' + 'commit\n' + @@ -261,8 +220,8 @@ describe('when parsing a gitGraph', function () { 'commit\n' + 'branch b2\n'; - parser.parse(str); - const branches = gitGraphAst.getBranchesAsObjArray(); + await parser.parse(str); + const branches = db.getBranchesAsObjArray(); expect(branches).toHaveLength(3); expect(branches[0]).toHaveProperty('name', 'main'); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js index 1fb64a5c4..e1e95551b 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js +++ b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js @@ -1,22 +1,21 @@ -import gitGraphAst from './gitGraphAst.js'; -import { parser } from './parser/gitGraph.jison'; +import db from './gitGraphAst.js'; +import { parser } from './gitGraphParser.js'; describe('when parsing a gitGraph', function () { beforeEach(function () { - parser.yy = gitGraphAst; - parser.yy.clear(); + db.clear(); }); - it('should handle a gitGraph commit with NO pararms, get auto-generated reandom ID', function () { + it('should handle a gitGraph commit with NO params, get auto-generated read-only ID', async () => { const str = `gitGraph: commit `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); //console.info(commits); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).not.toBeNull(); @@ -24,16 +23,16 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(0); }); - it('should handle a gitGraph commit with custom commit id only', function () { + it('should handle a gitGraph commit with custom commit id only', async () => { const str = `gitGraph: commit id:"1111" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).toBe('1111'); @@ -41,17 +40,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(0); }); - it('should handle a gitGraph commit with custom commit tag only', function () { + it('should handle a gitGraph commit with custom commit tag only', async () => { const str = `gitGraph: commit tag:"test" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).not.toBeNull(); @@ -59,17 +58,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(0); }); - it('should handle a gitGraph commit with custom commit type HIGHLIGHT only', function () { + it('should handle a gitGraph commit with custom commit type HIGHLIGHT only', async () => { const str = `gitGraph: commit type: HIGHLIGHT `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).not.toBeNull(); @@ -77,17 +76,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(2); }); - it('should handle a gitGraph commit with custom commit type REVERSE only', function () { + it('should handle a gitGraph commit with custom commit type REVERSE only', async () => { const str = `gitGraph: commit type: REVERSE `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).not.toBeNull(); @@ -95,17 +94,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(1); }); - it('should handle a gitGraph commit with custom commit type NORMAL only', function () { + it('should handle a gitGraph commit with custom commit type NORMAL only', async () => { const str = `gitGraph: commit type: NORMAL `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).not.toBeNull(); @@ -113,17 +112,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(0); }); - it('should handle a gitGraph commit with custom commit msg only', function () { + it('should handle a gitGraph commit with custom commit msg only', async () => { const str = `gitGraph: commit "test commit" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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(); @@ -131,17 +130,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(0); }); - it('should handle a gitGraph commit with custom commit "msg:" key only', function () { + it('should handle a gitGraph commit with custom commit "msg:" key only', async () => { const str = `gitGraph: commit msg: "test commit" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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(); @@ -149,17 +148,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(0); }); - it('should handle a gitGraph commit with custom commit id, tag only', function () { + it('should handle a gitGraph commit with custom commit id, tag only', async () => { const str = `gitGraph: commit id:"1111" tag: "test tag" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).toBe('1111'); @@ -167,17 +166,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(0); }); - it('should handle a gitGraph commit with custom commit type, tag only', function () { + it('should handle a gitGraph commit with custom commit type, tag only', async () => { const str = `gitGraph: commit type:HIGHLIGHT tag: "test tag" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).not.toBeNull(); @@ -185,17 +184,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(2); }); - it('should handle a gitGraph commit with custom commit tag and type only', function () { + it('should handle a gitGraph commit with custom commit tag and type only', async () => { const str = `gitGraph: commit tag: "test tag" type:HIGHLIGHT `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).not.toBeNull(); @@ -203,17 +202,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(2); }); - it('should handle a gitGraph commit with custom commit id, type and tag only', function () { + it('should handle a gitGraph commit with custom commit id, type and tag only', async () => { const str = `gitGraph: commit id:"1111" type:REVERSE tag: "test tag" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); const key = commits.keys().next().value; expect(commits.get(key).message).toBe(''); expect(commits.get(key).id).toBe('1111'); @@ -221,17 +220,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(1); }); - it('should handle a gitGraph commit with custom commit id, type, tag and msg', function () { + it('should handle a gitGraph commit with custom commit id, type, tag and msg', async () => { const str = `gitGraph: commit id:"1111" type:REVERSE tag: "test tag" msg:"test msg" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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'); @@ -239,18 +238,18 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(1); }); - it('should handle a gitGraph commit with custom type,tag, msg, commit id,', function () { + it('should handle a gitGraph commit with custom type,tag, msg, commit id,', async () => { const str = `gitGraph: commit type:REVERSE tag: "test tag" msg: "test msg" id: "1111" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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'); @@ -258,17 +257,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(1); }); - it('should handle a gitGraph commit with custom tag, msg, commit id, type,', function () { + it('should handle a gitGraph commit with custom tag, msg, commit id, type,', async () => { const str = `gitGraph: commit tag: "test tag" msg:"test msg" id:"1111" type:REVERSE `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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'); @@ -276,17 +275,17 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(1); }); - it('should handle a gitGraph commit with custom msg, commit id, type,tag', function () { + it('should handle a gitGraph commit with custom msg, commit id, type,tag', async () => { const str = `gitGraph: commit msg:"test msg" id:"1111" type:REVERSE tag: "test tag" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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'); @@ -294,36 +293,36 @@ describe('when parsing a gitGraph', function () { expect(commits.get(key).type).toBe(1); }); - it('should handle 3 straight commits', function () { + it('should handle 3 straight commits', async () => { const str = `gitGraph: commit commit commit `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(3); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); }); - it('should handle new branch creation', function () { + it('should handle new branch creation', async () => { const str = `gitGraph: commit branch testBranch `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('testBranch'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); }); - it('should allow quoted branch names', function () { + it('should allow quoted branch names', async () => { const str = `gitGraph: commit branch "branch" @@ -333,49 +332,49 @@ describe('when parsing a gitGraph', function () { merge "branch" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(3); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(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'); - expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'branch' }]); + expect(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'branch' }]); }); - it('should allow _-./ characters in branch names', function () { + it('should allow _-./ characters in branch names', async () => { const str = `gitGraph: commit branch azAZ_-./test `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('azAZ_-./test'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('azAZ_-./test'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); }); - it('should allow branch names starting with numbers', function () { + it('should allow branch names starting with numbers', async () => { const str = `gitGraph: commit %% branch names starting with numbers are not recommended, but are supported by git branch 1.0.1 `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('1.0.1'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('1.0.1'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); }); - it('should allow branch names starting with unusual prefixes', function () { + it('should allow branch names starting with unusual prefixes', async () => { const str = `gitGraph: commit %% branch names starting with numbers are not recommended, but are supported by git @@ -388,13 +387,13 @@ describe('when parsing a gitGraph', function () { branch A `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('A'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(7); - expect([...parser.yy.getBranches().keys()]).toEqual( + expect(db.getCurrentBranch()).toBe('A'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(7); + expect([...db.getBranches().keys()]).toEqual( expect.arrayContaining([ 'branch01', 'checkout02', @@ -406,21 +405,21 @@ describe('when parsing a gitGraph', function () { ); }); - it('should handle new branch checkout', function () { + it('should handle new branch checkout', async () => { const str = `gitGraph: commit branch testBranch checkout testBranch `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('testBranch'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); }); - it('should handle new branch checkout with order', function () { + it('should handle new branch checkout with order', async () => { const str = `gitGraph: commit branch test1 order: 3 @@ -428,19 +427,19 @@ describe('when parsing a gitGraph', function () { branch test3 order: 1 `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('test3'); - expect(parser.yy.getBranches().size).toBe(4); - expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ + expect(db.getCurrentBranch()).toBe('test3'); + expect(db.getBranches().size).toBe(4); + expect(db.getBranchesAsObjArray()).toStrictEqual([ { name: 'main' }, { name: 'test3' }, { name: 'test2' }, { name: 'test1' }, ]); }); - it('should handle new branch checkout with and without order', function () { + it('should handle new branch checkout with and without order', async () => { const str = `gitGraph: commit branch test1 order: 1 @@ -448,12 +447,12 @@ describe('when parsing a gitGraph', function () { branch test3 `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('test3'); - expect(parser.yy.getBranches().size).toBe(4); - expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ + expect(db.getCurrentBranch()).toBe('test3'); + expect(db.getBranches().size).toBe(4); + expect(db.getBranchesAsObjArray()).toStrictEqual([ { name: 'main' }, { name: 'test2' }, { name: 'test3' }, @@ -461,7 +460,7 @@ describe('when parsing a gitGraph', function () { ]); }); - it('should handle new branch checkout & commit', function () { + it('should handle new branch checkout & commit', async () => { const str = `gitGraph: commit branch testBranch @@ -469,12 +468,12 @@ describe('when parsing a gitGraph', function () { commit `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(2); - expect(parser.yy.getCurrentBranch()).toBe('testBranch'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); const [commit1, commit2] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); @@ -482,7 +481,7 @@ describe('when parsing a gitGraph', function () { expect(commits.get(commit2).parents).toStrictEqual([commit1]); }); - it('should handle new branch checkout & commit and merge', function () { + it('should handle new branch checkout & commit and merge', async () => { const str = `gitGraph: commit branch testBranch @@ -493,12 +492,12 @@ describe('when parsing a gitGraph', function () { merge testBranch `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(4); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); const [commit1, commit2, commit3, commit4] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); @@ -511,28 +510,25 @@ describe('when parsing a gitGraph', function () { commits.get(commit1).id, commits.get(commit3).id, ]); - expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ - { name: 'main' }, - { name: 'testBranch' }, - ]); + expect(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); }); - it('should handle new branch switch', function () { + it('should handle new branch switch', async () => { const str = `gitGraph: commit branch testBranch switch testBranch `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(1); - expect(parser.yy.getCurrentBranch()).toBe('testBranch'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); }); - it('should handle new branch switch & commit', function () { + it('should handle new branch switch & commit', async () => { const str = `gitGraph: commit branch testBranch @@ -540,12 +536,12 @@ describe('when parsing a gitGraph', function () { commit `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(2); - expect(parser.yy.getCurrentBranch()).toBe('testBranch'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); const [commit1, commit2] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); @@ -553,7 +549,7 @@ describe('when parsing a gitGraph', function () { expect(commits.get(commit2).parents).toStrictEqual([commit1]); }); - it('should handle new branch switch & commit and merge', function () { + it('should handle new branch switch & commit and merge', async () => { const str = `gitGraph: commit branch testBranch @@ -564,12 +560,12 @@ describe('when parsing a gitGraph', function () { merge testBranch `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(4); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); const [commit1, commit2, commit3, commit4] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); @@ -582,13 +578,10 @@ describe('when parsing a gitGraph', function () { commits.get(commit1).id, commits.get(commit3).id, ]); - expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ - { name: 'main' }, - { name: 'testBranch' }, - ]); + expect(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); }); - it('should handle merge tags', function () { + it('should handle merge tags', async () => { const str = `gitGraph: commit branch testBranch @@ -598,12 +591,12 @@ describe('when parsing a gitGraph', function () { merge testBranch tag: "merge-tag" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(3); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); - expect(parser.yy.getBranches().size).toBe(2); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); const [commit1, commit2, commit3] = commits.keys(); expect(commits.get(commit1).branch).toBe('main'); expect(commits.get(commit1).parents).toStrictEqual([]); @@ -617,13 +610,10 @@ describe('when parsing a gitGraph', function () { commits.get(commit2).id, ]); expect(commits.get(commit3).tags).toStrictEqual(['merge-tag']); - expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ - { name: 'main' }, - { name: 'testBranch' }, - ]); + expect(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); }); - it('should handle merge with custom ids, tags and typr', function () { + it('should handle merge with custom ids, tags and type', async () => { const str = `gitGraph: commit branch testBranch @@ -646,11 +636,11 @@ describe('when parsing a gitGraph', function () { merge testBranch3 id: "6-666" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); expect(commits.size).toBe(7); - expect(parser.yy.getCurrentBranch()).toBe('main'); - expect(parser.yy.getDirection()).toBe('LR'); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); // The order of these commits is in alphabetical order of IDs const [ @@ -685,7 +675,7 @@ describe('when parsing a gitGraph', function () { expect(testBranch3Merge.parents).toStrictEqual([testBranch2Merge.id, testBranch3Commit.id]); expect(testBranch3Merge.id).toBe('6-666'); - expect(parser.yy.getBranchesAsObjArray()).toStrictEqual([ + expect(db.getBranchesAsObjArray()).toStrictEqual([ { name: 'main' }, { name: 'testBranch' }, { name: 'testBranch2' }, @@ -693,7 +683,7 @@ describe('when parsing a gitGraph', function () { ]); }); - it('should support cherry-picking commits', function () { + it('should support cherry-picking commits', async () => { const str = `gitGraph commit id: "ZERO" branch develop @@ -702,14 +692,14 @@ describe('when parsing a gitGraph', function () { cherry-pick id:"A" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); const cherryPickCommitID = [...commits.keys()][2]; expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['cherry-pick:A']); expect(commits.get(cherryPickCommitID).branch).toBe('main'); }); - it('should support cherry-picking commits with custom tag', function () { + it('should support cherry-picking commits with custom tag', async () => { const str = `gitGraph commit id: "ZERO" branch develop @@ -718,14 +708,14 @@ describe('when parsing a gitGraph', function () { cherry-pick id:"A" tag:"MyTag" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); const cherryPickCommitID = [...commits.keys()][2]; expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['MyTag']); expect(commits.get(cherryPickCommitID).branch).toBe('main'); }); - it('should support cherry-picking commits with no tag', function () { + it('should support cherry-picking commits with no tag', async () => { const str = `gitGraph commit id: "ZERO" branch develop @@ -734,14 +724,14 @@ describe('when parsing a gitGraph', function () { cherry-pick id:"A" tag:"" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); const cherryPickCommitID = [...commits.keys()][2]; expect(commits.get(cherryPickCommitID).tags).toStrictEqual([]); expect(commits.get(cherryPickCommitID).branch).toBe('main'); }); - it('should support cherry-picking of merge commits', function () { + it('should support cherry-picking of merge commits', async () => { const str = `gitGraph commit id: "ZERO" branch feature @@ -755,14 +745,14 @@ describe('when parsing a gitGraph', function () { cherry-pick id: "M" parent:"B" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); const cherryPickCommitID = [...commits.keys()][4]; expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['cherry-pick:M|parent:B']); expect(commits.get(cherryPickCommitID).branch).toBe('release'); }); - it('should support cherry-picking of merge commits with tag', function () { + it('should support cherry-picking of merge commits with tag', async () => { const str = `gitGraph commit id: "ZERO" branch feature @@ -776,14 +766,14 @@ describe('when parsing a gitGraph', function () { cherry-pick id: "M" parent:"ZERO" tag: "v1.0" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); const cherryPickCommitID = [...commits.keys()][4]; expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['v1.0']); expect(commits.get(cherryPickCommitID).branch).toBe('release'); }); - it('should support cherry-picking of merge commits with additional commit', function () { + it('should support cherry-picking of merge commits with additional commit', async () => { const str = `gitGraph commit id: "ZERO" branch feature @@ -799,14 +789,14 @@ describe('when parsing a gitGraph', function () { commit id: "D" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); const cherryPickCommitID = [...commits.keys()][5]; expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['v2.1:ZERO']); expect(commits.get(cherryPickCommitID).branch).toBe('release'); }); - it('should support cherry-picking of merge commits with empty tag', function () { + it('should support cherry-picking of merge commits with empty tag', async () => { const str = `gitGraph commit id: "ZERO" branch feature @@ -823,8 +813,8 @@ describe('when parsing a gitGraph', function () { cherry-pick id:"M" tag:"" parent: "B" `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.getCommits(); const cherryPickCommitID = [...commits.keys()][5]; const cherryPickCommitID2 = [...commits.keys()][7]; expect(commits.get(cherryPickCommitID).tags).toStrictEqual([]); @@ -833,10 +823,11 @@ describe('when parsing a gitGraph', function () { }); it('should fail cherry-picking of merge commits if the parent of merge commits is not specified', function () { - expect(() => - parser - .parse( - `gitGraph + expect( + async () => + await parser + .parse( + `gitGraph commit id: "ZERO" branch feature branch release @@ -849,18 +840,19 @@ describe('when parsing a gitGraph', function () { commit id: "C" cherry-pick id:"M" ` - ) - .toThrow( - 'Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.' - ) + ) + .toThrow( + 'Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.' + ) ); }); it('should fail cherry-picking of merge commits when the parent provided is not an immediate parent of cherry picked commit', function () { - expect(() => - parser - .parse( - `gitGraph + expect( + async () => + await parser + .parse( + `gitGraph commit id: "ZERO" branch feature branch release @@ -873,14 +865,14 @@ describe('when parsing a gitGraph', function () { commit id: "C" cherry-pick id:"M" parent: "A" ` - ) - .toThrow( - 'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.' - ) + ) + .toThrow( + 'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.' + ) ); }); - it('should throw error when try to branch existing branch: main', function () { + it('should throw error when try to branch existing branch: main', async () => { const str = `gitGraph commit branch testBranch @@ -892,7 +884,7 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { @@ -901,7 +893,7 @@ describe('when parsing a gitGraph', function () { ); } }); - it('should throw error when try to branch existing branch: testBranch', function () { + it('should throw error when try to branch existing branch: testBranch', async () => { const str = `gitGraph commit branch testBranch @@ -913,7 +905,7 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { @@ -922,7 +914,7 @@ describe('when parsing a gitGraph', function () { ); } }); - it('should throw error when try to checkout unknown branch: testBranch', function () { + it('should throw error when try to checkout unknown branch: testBranch', async () => { const str = `gitGraph commit checkout testBranch @@ -934,7 +926,7 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { @@ -943,7 +935,7 @@ describe('when parsing a gitGraph', function () { ); } }); - it('should throw error when trying to merge, when current branch has no commits', function () { + it('should throw error when trying to merge, when current branch has no commits', async () => { const str = `gitGraph merge testBranch commit @@ -956,14 +948,14 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { expect(e.message).toBe('Incorrect usage of "merge". Current branch (main)has no commits'); } }); - it('should throw error when trying to merge unknown branch', function () { + it('should throw error when trying to merge unknown branch', async () => { const str = `gitGraph commit merge testBranch @@ -977,7 +969,7 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { @@ -986,7 +978,7 @@ describe('when parsing a gitGraph', function () { ); } }); - it('should throw error when trying to merge branch to itself', function () { + it('should throw error when trying to merge branch to itself', async () => { const str = `gitGraph commit branch testBranch @@ -994,7 +986,7 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { @@ -1002,7 +994,7 @@ describe('when parsing a gitGraph', function () { } }); - it('should throw error when using existing id as merge ID', function () { + it('should throw error when using existing id as merge ID', async () => { const str = `gitGraph commit id: "1-111" branch testBranch @@ -1013,7 +1005,7 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { @@ -1022,7 +1014,7 @@ describe('when parsing a gitGraph', function () { ); } }); - it('should throw error when trying to merge branches having same heads', function () { + it('should throw error when trying to merge branches having same heads', async () => { const str = `gitGraph commit branch testBranch @@ -1031,14 +1023,14 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { expect(e.message).toBe('Incorrect usage of "merge". Both branches have same head'); } }); - it('should throw error when trying to merge branch which has no commits', function () { + it('should throw error when trying to merge branch which has no commits', async () => { const str = `gitGraph branch test1 @@ -1048,7 +1040,7 @@ describe('when parsing a gitGraph', function () { `; try { - parser.parse(str); + await parser.parse(str); // Fail test if above expression doesn't throw anything. expect(true).toBe(false); } catch (e) { @@ -1058,17 +1050,17 @@ describe('when parsing a gitGraph', function () { } }); describe('accessibility', () => { - it('should handle a title and a description (accDescr)', () => { + it('should handle a title and a description (accDescr)', async () => { const str = `gitGraph: accTitle: This is a title accDescr: This is a description commit `; - parser.parse(str); - expect(parser.yy.getAccTitle()).toBe('This is a title'); - expect(parser.yy.getAccDescription()).toBe('This is a description'); + await parser.parse(str); + expect(db.getAccTitle()).toBe('This is a title'); + expect(db.getAccDescription()).toBe('This is a description'); }); - it('should handle a title and a multiline description (accDescr)', () => { + it('should handle a title and a multiline description (accDescr)', async () => { const str = `gitGraph: accTitle: This is a title accDescr { @@ -1077,15 +1069,15 @@ describe('when parsing a gitGraph', function () { } commit `; - parser.parse(str); - expect(parser.yy.getAccTitle()).toBe('This is a title'); - expect(parser.yy.getAccDescription()).toBe('This is a description\nusing multiple lines'); + await parser.parse(str); + expect(db.getAccTitle()).toBe('This is a title'); + expect(db.getAccDescription()).toBe('This is a description\nusing multiple lines'); }); }); describe('unsafe properties', () => { for (const prop of ['__proto__', 'constructor']) { - it(`should work with custom commit id or branch name ${prop}`, () => { + it(`should work with custom commit id or branch name ${prop}`, async () => { const str = `gitGraph commit id:"${prop}" branch ${prop} @@ -1094,13 +1086,13 @@ describe('when parsing a gitGraph', function () { checkout main merge ${prop} `; - parser.parse(str); - const commits = parser.yy.getCommits(); + await parser.parse(str); + const commits = db.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); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getBranches().size).toBe(2); + expect(db.getBranchesAsObjArray()[1].name).toBe(prop); }); } }); diff --git a/packages/parser/src/language/gitGraph/gitGraph.langium b/packages/parser/src/language/gitGraph/gitGraph.langium index 807f9382b..1571ebba8 100644 --- a/packages/parser/src/language/gitGraph/gitGraph.langium +++ b/packages/parser/src/language/gitGraph/gitGraph.langium @@ -26,7 +26,7 @@ hidden terminal SINGLE_LINE_COMMENT: /[\t ]*%%[^\n\r]*/; entry GitGraph: NEWLINE* - 'gitGraph' Direction? ':'? + ('gitGraph' | 'gitGraph' ':' | 'gitGraph:' | ('gitGraph' Direction ':')) NEWLINE* ( NEWLINE* From 38e048b94e6cb945627f10cf0cebea9932680b68 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Mon, 5 Aug 2024 14:08:42 -0400 Subject: [PATCH 028/124] fixed hash error loc & line properties --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 008e7923f..31302133a 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -145,8 +145,6 @@ export const merge = ( error.hash = { text: `merge ${otherBranch}`, token: `merge ${otherBranch}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['branch abc'], }; throw error; @@ -158,8 +156,6 @@ export const merge = ( error.hash = { text: `merge ${otherBranch}`, token: `merge ${otherBranch}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['commit'], }; throw error; @@ -171,8 +167,6 @@ export const merge = ( error.hash = { text: `merge ${otherBranch}`, token: `merge ${otherBranch}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: [`branch ${otherBranch}`], }; throw error; @@ -184,8 +178,6 @@ export const merge = ( error.hash = { text: `merge ${otherBranch}`, token: `merge ${otherBranch}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['"commit"'], }; throw error; @@ -195,8 +187,6 @@ export const merge = ( error.hash = { text: `merge ${otherBranch}`, token: `merge ${otherBranch}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['branch abc'], }; throw error; @@ -210,8 +200,6 @@ export const merge = ( error.hash = { text: `merge ${otherBranch} ${customId} ${overrideType} ${customTags?.join(' ')}`, token: `merge ${otherBranch} ${customId} ${overrideType} ${customTags?.join(' ')}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: [ `merge ${otherBranch} ${customId}_UNIQUE ${overrideType} ${customTags?.join(' ')}`, ], @@ -262,8 +250,6 @@ export const cherryPick = function ( error.hash = { text: `cherryPick ${sourceId} ${targetId}`, token: `cherryPick ${sourceId} ${targetId}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: ['cherry-pick abc'], }; throw error; @@ -324,7 +310,6 @@ export const cherryPick = function ( error.hash = { text: `cherryPick ${sourceId} ${targetId}`, token: `cherryPick ${sourceId} ${targetId}`, - line: '1', expected: ['cherry-pick abc'], }; throw error; @@ -361,8 +346,6 @@ export const checkout = function (branch: string) { error.hash = { text: `checkout ${branch}`, token: `checkout ${branch}`, - line: '1', - loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 }, expected: [`branch ${branch}`], }; throw error; From 8fe0ed1d037ac9eae3913b2f27d6af02aee0b79c Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Tue, 6 Aug 2024 19:26:13 -0400 Subject: [PATCH 029/124] added parser test and combined the two gitGraph tests --- .../src/diagrams/git/gitGraph.parser.spec.ts | 75 + .../mermaid/src/diagrams/git/gitGraph.spec.ts | 1322 +++++++++++++++++ .../src/diagrams/git/gitGraphParser.spec.js | 231 --- .../src/diagrams/git/gitGraphParser.ts | 5 +- .../src/diagrams/git/gitGraphParserV2.spec.js | 1099 -------------- packages/mermaid/tsconfig.json | 2 +- 6 files changed, 1401 insertions(+), 1333 deletions(-) create mode 100644 packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts create mode 100644 packages/mermaid/src/diagrams/git/gitGraph.spec.ts delete mode 100644 packages/mermaid/src/diagrams/git/gitGraphParser.spec.js delete mode 100644 packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js diff --git a/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts b/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts new file mode 100644 index 000000000..2c86d7c7b --- /dev/null +++ b/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts @@ -0,0 +1,75 @@ +import { describe, it, expect, beforeEach, vi } from 'vitest'; +import { parser } from './gitGraphParser.js'; +import db from './gitGraphAst.js'; +import { parse } from 'path'; + +const parseInput = async (input: string) => { + await parser.parse(input); +}; + +const spyOn = vi.spyOn; + +describe('GitGraph Parsing', function () { + beforeEach(() => { + db.clear(); + }); + it('should parse a default commit statement', async () => { + const input = `gitGraph: + commit + `; + const commitSpy = spyOn(db, 'commit'); + await parseInput(input); + + expect(commitSpy).toHaveBeenCalledWith('', undefined, 0, []); + commitSpy.mockRestore(); + }); + + it('should parse a basic branch statement with just a name', async () => { + const input = `gitGraph: + branch newBranch + `; + const branchSpy = spyOn(db, 'branch'); + await parseInput(input); + expect(branchSpy).toHaveBeenCalledWith('newBranch', 0); + branchSpy.mockRestore(); + }); + + it('should parse a basic checkout statement', async () => { + const input = `gitGraph: + branch newBranch + checkout newBranch + `; + const checkoutSpy = spyOn(db, 'checkout'); + await parseInput(input); + expect(checkoutSpy).toHaveBeenCalledWith('newBranch'); + checkoutSpy.mockRestore(); + }); + + it('should parse a basic merge statement', async () => { + const input = `gitGraph: + commit + branch newBranch + checkout newBranch + commit + checkout main + merge newBranch`; + const mergeSpy = spyOn(db, 'merge'); + await parseInput(input); + expect(mergeSpy).toHaveBeenCalledWith('newBranch', '', undefined, []); + mergeSpy.mockRestore(); + }); + + it('should parse cherry-picking', async () => { + const input = `gitGraph + commit id: "ZERO" + branch develop + commit id:"A" + checkout main + cherry-pick id:"A" + `; + const cherryPickSpy = spyOn(db, 'cherryPick'); + await parseInput(input); + expect(cherryPickSpy).toHaveBeenCalledWith('A', '', undefined, undefined); + cherryPickSpy.mockRestore(); + }); +}); diff --git a/packages/mermaid/src/diagrams/git/gitGraph.spec.ts b/packages/mermaid/src/diagrams/git/gitGraph.spec.ts new file mode 100644 index 000000000..ab315a82a --- /dev/null +++ b/packages/mermaid/src/diagrams/git/gitGraph.spec.ts @@ -0,0 +1,1322 @@ +import { rejects } from 'assert'; +import db from './gitGraphAst.js'; +import { parser } from './gitGraphParser.js'; + +describe('when parsing a gitGraph', function () { + beforeEach(function () { + db.clear(); + }); + describe('when parsing basic gitGraph', function () { + it('should handle a gitGraph definition', async () => { + const str = `gitGraph:\n commit\n`; + + await parser.parse(str); + const commits = db.getCommits(); + + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); + }); + + it('should handle set direction top to bottom', async () => { + const str = 'gitGraph TB:\n' + 'commit\n'; + + await parser.parse(str); + const commits = db.getCommits(); + + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('TB'); + expect(db.getBranches().size).toBe(1); + }); + + it('should handle set direction bottom to top', async () => { + const str = 'gitGraph BT:\n' + 'commit\n'; + + await parser.parse(str); + const commits = db.getCommits(); + + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('BT'); + expect(db.getBranches().size).toBe(1); + }); + + it('should checkout a branch', async () => { + const str = 'gitGraph:\n' + 'branch new\n' + 'checkout new\n'; + + await parser.parse(str); + const commits = db.getCommits(); + + expect(commits.size).toBe(0); + expect(db.getCurrentBranch()).toBe('new'); + }); + + it('should switch a branch', async () => { + const str = 'gitGraph:\n' + 'branch new\n' + 'switch new\n'; + + await parser.parse(str); + const commits = db.getCommits(); + + expect(commits.size).toBe(0); + expect(db.getCurrentBranch()).toBe('new'); + }); + + it('should add commits to checked out branch', async () => { + const str = 'gitGraph:\n' + 'branch new\n' + 'checkout new\n' + 'commit\n' + 'commit\n'; + + await parser.parse(str); + const commits = db.getCommits(); + + expect(commits.size).toBe(2); + expect(db.getCurrentBranch()).toBe('new'); + const branchCommit = db.getBranches().get('new'); + expect(branchCommit).not.toBeNull(); + if (branchCommit) { + expect(commits.get(branchCommit)?.parents).not.toBeNull(); + } + }); + it('should handle commit with args', async () => { + const str = 'gitGraph:\n' + 'commit "a commit"\n'; + + await parser.parse(str); + const commits = db.getCommits(); + + expect(commits.size).toBe(1); + const key = commits.keys().next().value; + expect(commits.get(key)?.message).toBe('a commit'); + expect(db.getCurrentBranch()).toBe('main'); + }); + + it.skip('should reset a branch', async () => { + const str = + 'gitGraph:\n' + + 'commit\n' + + 'commit\n' + + 'branch newbranch\n' + + 'checkout newbranch\n' + + 'commit\n' + + 'reset main\n'; + + await parser.parse(str); + + const commits = db.getCommits(); + expect(commits.size).toBe(3); + expect(db.getCurrentBranch()).toBe('newbranch'); + expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); + expect(db.getHead()?.id).toEqual(db.getBranches().get('newbranch')); + }); + + it.skip('reset can take an argument', async () => { + const str = + 'gitGraph:\n' + + 'commit\n' + + 'commit\n' + + 'branch newbranch\n' + + 'checkout newbranch\n' + + 'commit\n' + + 'reset main^\n'; + + await parser.parse(str); + + const commits = db.getCommits(); + expect(commits.size).toBe(3); + expect(db.getCurrentBranch()).toBe('newbranch'); + const branch = db.getBranches().get('main'); + const main = commits.get(branch ?? ''); + expect(db.getHead()?.id).toEqual(main?.parents); + }); + + it.skip('should handle fast forwardable merges', async () => { + const str = + 'gitGraph:\n' + + 'commit\n' + + 'branch newbranch\n' + + 'checkout newbranch\n' + + 'commit\n' + + 'commit\n' + + 'checkout main\n' + + 'merge newbranch\n'; + + await parser.parse(str); + + const commits = db.getCommits(); + expect(commits.size).toBe(4); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); + expect(db.getHead()?.id).toEqual(db.getBranches().get('newbranch')); + }); + + it('should handle cases when merge is a noop', async () => { + const str = + 'gitGraph:\n' + + 'commit\n' + + 'branch newbranch\n' + + 'checkout newbranch\n' + + 'commit\n' + + 'commit\n' + + 'merge main\n'; + + await parser.parse(str); + + const commits = db.getCommits(); + expect(commits.size).toBe(4); + expect(db.getCurrentBranch()).toBe('newbranch'); + expect(db.getBranches().get('newbranch')).not.toEqual(db.getBranches().get('main')); + expect(db.getHead()?.id).toEqual(db.getBranches().get('newbranch')); + }); + + it('should handle merge with 2 parents', async () => { + const str = + 'gitGraph:\n' + + 'commit\n' + + 'branch newbranch\n' + + 'checkout newbranch\n' + + 'commit\n' + + 'commit\n' + + 'checkout main\n' + + 'commit\n' + + 'merge newbranch\n'; + + await parser.parse(str); + + const commits = db.getCommits(); + expect(commits.size).toBe(5); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getBranches().get('newbranch')).not.toEqual(db.getBranches().get('main')); + expect(db.getHead()?.id).toEqual(db.getBranches().get('main')); + }); + + it.skip('should handle ff merge when history walk has two parents (merge commit)', async () => { + const str = + 'gitGraph:\n' + + 'commit\n' + + 'branch newbranch\n' + + 'checkout newbranch\n' + + 'commit\n' + + 'commit\n' + + 'checkout main\n' + + 'commit\n' + + 'merge newbranch\n' + + 'commit\n' + + 'checkout newbranch\n' + + 'merge main\n'; + + await parser.parse(str); + + const commits = db.getCommits(); + expect(commits.size).toBe(7); + expect(db.getCurrentBranch()).toBe('newbranch'); + expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); + expect(db.getHead()?.id).toEqual(db.getBranches().get('main')); + + db.prettyPrint(); + }); + + it('should generate an array of known branches', async () => { + const str = + 'gitGraph:\n' + + 'commit\n' + + 'branch b1\n' + + 'checkout b1\n' + + 'commit\n' + + 'commit\n' + + 'branch b2\n'; + + await parser.parse(str); + const branches = db.getBranchesAsObjArray(); + + expect(branches).toHaveLength(3); + expect(branches[0]).toHaveProperty('name', 'main'); + expect(branches[1]).toHaveProperty('name', 'b1'); + expect(branches[2]).toHaveProperty('name', 'b2'); + }); + }); + + describe('when parsing more advanced gitGraphs', () => { + it('should handle a gitGraph commit with NO params, get auto-generated read-only ID', async () => { + const str = `gitGraph: + commit + `; + await parser.parse(str); + const commits = db.getCommits(); + //console.info(commits); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual([]); + expect(commits.get(key)?.type).toBe(0); + }); + + it('should handle a gitGraph commit with custom commit id only', async () => { + const str = `gitGraph: + commit id:"1111" + `; + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual([]); + expect(commits.get(key)?.type).toBe(0); + }); + + it('should handle a gitGraph commit with custom commit tag only', async () => { + const str = `gitGraph: + commit tag:"test" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test']); + expect(commits.get(key)?.type).toBe(0); + }); + + it('should handle a gitGraph commit with custom commit type HIGHLIGHT only', async () => { + const str = `gitGraph: + commit type: HIGHLIGHT + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual([]); + expect(commits.get(key)?.type).toBe(2); + }); + + it('should handle a gitGraph commit with custom commit type REVERSE only', async () => { + const str = `gitGraph: + commit type: REVERSE + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual([]); + expect(commits.get(key)?.type).toBe(1); + }); + + it('should handle a gitGraph commit with custom commit type NORMAL only', async () => { + const str = `gitGraph: + commit type: NORMAL + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual([]); + expect(commits.get(key)?.type).toBe(0); + }); + + it('should handle a gitGraph commit with custom commit msg only', async () => { + const str = `gitGraph: + commit "test commit" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual([]); + expect(commits.get(key)?.type).toBe(0); + }); + + it('should handle a gitGraph commit with custom commit "msg:" key only', async () => { + const str = `gitGraph: + commit msg: "test commit" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual([]); + expect(commits.get(key)?.type).toBe(0); + }); + + it('should handle a gitGraph commit with custom commit id, tag only', async () => { + const str = `gitGraph: + commit id:"1111" tag: "test tag" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test tag']); + expect(commits.get(key)?.type).toBe(0); + }); + + it('should handle a gitGraph commit with custom commit type, tag only', async () => { + const str = `gitGraph: + commit type:HIGHLIGHT tag: "test tag" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test tag']); + expect(commits.get(key)?.type).toBe(2); + }); + + it('should handle a gitGraph commit with custom commit tag and type only', async () => { + const str = `gitGraph: + commit tag: "test tag" type:HIGHLIGHT + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test tag']); + expect(commits.get(key)?.type).toBe(2); + }); + + it('should handle a gitGraph commit with custom commit id, type and tag only', async () => { + const str = `gitGraph: + commit id:"1111" type:REVERSE tag: "test tag" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test tag']); + expect(commits.get(key)?.type).toBe(1); + }); + + it('should handle a gitGraph commit with custom commit id, type, tag and msg', async () => { + const str = `gitGraph: + commit id:"1111" type:REVERSE tag: "test tag" msg:"test msg" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test tag']); + expect(commits.get(key)?.type).toBe(1); + }); + + it('should handle a gitGraph commit with custom type,tag, msg, commit id,', async () => { + const str = `gitGraph: + commit type:REVERSE tag: "test tag" msg: "test msg" id: "1111" + + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test tag']); + expect(commits.get(key)?.type).toBe(1); + }); + + it('should handle a gitGraph commit with custom tag, msg, commit id, type,', async () => { + const str = `gitGraph: + commit tag: "test tag" msg:"test msg" id:"1111" type:REVERSE + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test tag']); + expect(commits.get(key)?.type).toBe(1); + }); + + it('should handle a gitGraph commit with custom msg, commit id, type,tag', async () => { + const str = `gitGraph: + commit msg:"test msg" id:"1111" type:REVERSE tag: "test tag" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.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)?.tags).toStrictEqual(['test tag']); + expect(commits.get(key)?.type).toBe(1); + }); + + it('should handle 3 straight commits', async () => { + const str = `gitGraph: + commit + commit + commit + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(3); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(1); + }); + + it('should handle new branch creation', async () => { + const str = `gitGraph: + commit + branch testBranch + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + }); + + it('should allow quoted branch names', async () => { + const str = `gitGraph: + commit + branch "branch" + checkout "branch" + commit + checkout main + merge "branch" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(3); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(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'); + expect(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'branch' }]); + }); + + it('should allow _-./ characters in branch names', async () => { + const str = `gitGraph: + commit + branch azAZ_-./test + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('azAZ_-./test'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + }); + + it('should allow branch names starting with numbers', async () => { + const str = `gitGraph: + commit + %% branch names starting with numbers are not recommended, but are supported by git + branch 1.0.1 + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('1.0.1'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + }); + + it('should allow branch names starting with unusual prefixes', async () => { + const str = `gitGraph: + commit + %% branch names starting with numbers are not recommended, but are supported by git + branch branch01 + branch checkout02 + branch cherry-pick03 + branch branch/example-branch + branch merge/test_merge + %% single character branch name + branch A + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('A'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(7); + expect([...db.getBranches().keys()]).toEqual( + expect.arrayContaining([ + 'branch01', + 'checkout02', + 'cherry-pick03', + 'branch/example-branch', + 'merge/test_merge', + 'A', + ]) + ); + }); + + it('should handle new branch checkout', async () => { + const str = `gitGraph: + commit + branch testBranch + checkout testBranch + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + }); + it('should handle new branch checkout with order', async () => { + const str = `gitGraph: + commit + branch test1 order: 3 + branch test2 order: 2 + branch test3 order: 1 + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('test3'); + expect(db.getBranches().size).toBe(4); + expect(db.getBranchesAsObjArray()).toStrictEqual([ + { name: 'main' }, + { name: 'test3' }, + { name: 'test2' }, + { name: 'test1' }, + ]); + }); + it('should handle new branch checkout with and without order', async () => { + const str = `gitGraph: + commit + branch test1 order: 1 + branch test2 + branch test3 + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('test3'); + expect(db.getBranches().size).toBe(4); + expect(db.getBranchesAsObjArray()).toStrictEqual([ + { name: 'main' }, + { name: 'test2' }, + { name: 'test3' }, + { name: 'test1' }, + ]); + }); + + it('should handle new branch checkout & commit', async () => { + const str = `gitGraph: + commit + branch testBranch + checkout testBranch + commit + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(2); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + 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'); + expect(commits.get(commit2)?.parents).toStrictEqual([commit1]); + }); + + it('should handle new branch checkout & commit and merge', async () => { + const str = `gitGraph: + commit + branch testBranch + checkout testBranch + commit + commit + checkout main + merge testBranch + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(4); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + 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'); + 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(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); + }); + + it('should handle new branch switch', async () => { + const str = `gitGraph: + commit + branch testBranch + switch testBranch + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(1); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + }); + + it('should handle new branch switch & commit', async () => { + const str = `gitGraph: + commit + branch testBranch + switch testBranch + commit + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(2); + expect(db.getCurrentBranch()).toBe('testBranch'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + 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'); + expect(commits.get(commit2)?.parents).toStrictEqual([commit1]); + }); + + it('should handle new branch switch & commit and merge', async () => { + const str = `gitGraph: + commit + branch testBranch + switch testBranch + commit + commit + switch main + merge testBranch + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(4); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + 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'); + 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(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); + }); + + it('should handle merge tags', async () => { + const str = `gitGraph: + commit + branch testBranch + checkout testBranch + commit + checkout main + merge testBranch tag: "merge-tag" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(3); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + expect(db.getBranches().size).toBe(2); + const [commit1, commit2, commit3] = commits.keys(); + 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('main'); + expect(commits.get(commit3)?.parents).toStrictEqual([ + commits.get(commit1)?.id, + commits.get(commit2)?.id, + ]); + expect(commits.get(commit3)?.tags).toStrictEqual(['merge-tag']); + expect(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); + }); + + it('should handle merge with custom ids, tags and type', async () => { + const str = `gitGraph: + commit + branch testBranch + checkout testBranch + commit + checkout main + %% Merge Tag and ID + merge testBranch tag: "merge-tag" id: "2-222" + branch testBranch2 + checkout testBranch2 + commit + checkout main + %% Merge ID and Tag (reverse order) + merge testBranch2 id: "4-444" tag: "merge-tag2" type:HIGHLIGHT + branch testBranch3 + checkout testBranch3 + commit + checkout main + %% just Merge ID + merge testBranch3 id: "6-666" + `; + + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(7); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getDirection()).toBe('LR'); + + // The order of these commits is in alphabetical order of IDs + const [ + mainCommit, + testBranchCommit, + testBranchMerge, + testBranch2Commit, + testBranch2Merge, + testBranch3Commit, + testBranch3Merge, + ] = [...commits.values()]; + + expect(mainCommit.branch).toBe('main'); + expect(mainCommit.parents).toStrictEqual([]); + + expect(testBranchCommit.branch).toBe('testBranch'); + expect(testBranchCommit.parents).toStrictEqual([mainCommit.id]); + + expect(testBranchMerge.branch).toBe('main'); + expect(testBranchMerge.parents).toStrictEqual([mainCommit.id, testBranchCommit.id]); + expect(testBranchMerge.tags).toStrictEqual(['merge-tag']); + expect(testBranchMerge.id).toBe('2-222'); + + expect(testBranch2Merge.branch).toBe('main'); + expect(testBranch2Merge.parents).toStrictEqual([testBranchMerge.id, testBranch2Commit.id]); + expect(testBranch2Merge.tags).toStrictEqual(['merge-tag2']); + expect(testBranch2Merge.id).toBe('4-444'); + expect(testBranch2Merge.customType).toBe(2); + expect(testBranch2Merge.customId).toBe(true); + + expect(testBranch3Merge.branch).toBe('main'); + expect(testBranch3Merge.parents).toStrictEqual([testBranch2Merge.id, testBranch3Commit.id]); + expect(testBranch3Merge.id).toBe('6-666'); + + expect(db.getBranchesAsObjArray()).toStrictEqual([ + { name: 'main' }, + { name: 'testBranch' }, + { name: 'testBranch2' }, + { name: 'testBranch3' }, + ]); + }); + + it('should support cherry-picking commits', async () => { + const str = `gitGraph + commit id: "ZERO" + branch develop + commit id:"A" + checkout main + cherry-pick id:"A" + `; + + await parser.parse(str); + const commits = db.getCommits(); + const cherryPickCommitID = [...commits.keys()][2]; + expect(commits.get(cherryPickCommitID)?.tags).toStrictEqual(['cherry-pick:A']); + expect(commits.get(cherryPickCommitID)?.branch).toBe('main'); + }); + + it('should support cherry-picking commits with custom tag', async () => { + const str = `gitGraph + commit id: "ZERO" + branch develop + commit id:"A" + checkout main + cherry-pick id:"A" tag:"MyTag" + `; + + await parser.parse(str); + const commits = db.getCommits(); + const cherryPickCommitID = [...commits.keys()][2]; + expect(commits.get(cherryPickCommitID)?.tags).toStrictEqual(['MyTag']); + expect(commits.get(cherryPickCommitID)?.branch).toBe('main'); + }); + + it('should support cherry-picking commits with no tag', async () => { + const str = `gitGraph + commit id: "ZERO" + branch develop + commit id:"A" + checkout main + cherry-pick id:"A" tag:"" + `; + + await parser.parse(str); + const commits = db.getCommits(); + const cherryPickCommitID = [...commits.keys()][2]; + expect(commits.get(cherryPickCommitID)?.tags).toStrictEqual([]); + expect(commits.get(cherryPickCommitID)?.branch).toBe('main'); + }); + + it('should support cherry-picking of merge commits', async () => { + const str = `gitGraph + commit id: "ZERO" + branch feature + branch release + checkout feature + commit id: "A" + commit id: "B" + checkout main + merge feature id: "M" + checkout release + cherry-pick id: "M" parent:"B" + `; + + await parser.parse(str); + const commits = db.getCommits(); + const cherryPickCommitID = [...commits.keys()][4]; + expect(commits.get(cherryPickCommitID)?.tags).toStrictEqual(['cherry-pick:M|parent:B']); + expect(commits.get(cherryPickCommitID)?.branch).toBe('release'); + }); + + it('should support cherry-picking of merge commits with tag', async () => { + const str = `gitGraph + commit id: "ZERO" + branch feature + branch release + checkout feature + commit id: "A" + commit id: "B" + checkout main + merge feature id: "M" + checkout release + cherry-pick id: "M" parent:"ZERO" tag: "v1.0" + `; + + await parser.parse(str); + const commits = db.getCommits(); + const cherryPickCommitID = [...commits.keys()][4]; + expect(commits.get(cherryPickCommitID)?.tags).toStrictEqual(['v1.0']); + expect(commits.get(cherryPickCommitID)?.branch).toBe('release'); + }); + + it('should support cherry-picking of merge commits with additional commit', async () => { + const str = `gitGraph + commit id: "ZERO" + branch feature + branch release + checkout feature + commit id: "A" + commit id: "B" + checkout main + merge feature id: "M" + checkout release + commit id: "C" + cherry-pick id: "M" tag: "v2.1:ZERO" parent:"ZERO" + commit id: "D" + `; + + await parser.parse(str); + const commits = db.getCommits(); + const cherryPickCommitID = [...commits.keys()][5]; + expect(commits.get(cherryPickCommitID)?.tags).toStrictEqual(['v2.1:ZERO']); + expect(commits.get(cherryPickCommitID)?.branch).toBe('release'); + }); + + it('should support cherry-picking of merge commits with empty tag', async () => { + const str = `gitGraph + commit id: "ZERO" + branch feature + branch release + checkout feature + commit id: "A" + commit id: "B" + checkout main + merge feature id: "M" + checkout release + commit id: "C" + cherry-pick id:"M" parent: "ZERO" tag:"" + commit id: "D" + cherry-pick id:"M" tag:"" parent: "B" + `; + + await parser.parse(str); + const commits = db.getCommits(); + const cherryPickCommitID = [...commits.keys()][5]; + const cherryPickCommitID2 = [...commits.keys()][7]; + expect(commits.get(cherryPickCommitID)?.tags).toStrictEqual([]); + expect(commits.get(cherryPickCommitID2)?.tags).toStrictEqual([]); + expect(commits.get(cherryPickCommitID)?.branch).toBe('release'); + }); + + it('should fail cherry-picking of merge commits if the parent of merge commits is not specified', async () => { + await expect( + parser.parse( + `gitGraph + commit id: "ZERO" + branch feature + branch release + checkout feature + commit id: "A" + commit id: "B" + checkout main + merge feature id: "M" + checkout release + commit id: "C" + cherry-pick id:"M" + ` + ) + ).rejects.toThrow( + 'Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.' + ); + }); + + it('should fail cherry-picking of merge commits when the parent provided is not an immediate parent of cherry picked commit', async () => { + await expect( + parser.parse( + `gitGraph + commit id: "ZERO" + branch feature + branch release + checkout feature + commit id: "A" + commit id: "B" + checkout main + merge feature id: "M" + checkout release + commit id: "C" + cherry-pick id:"M" parent: "A" + ` + ) + ).rejects.toThrow( + 'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.' + ); + }); + + it('should throw error when try to branch existing branch: main', async () => { + const str = `gitGraph + commit + branch testBranch + commit + branch main + commit + checkout main + merge testBranch + `; + + try { + await parser.parse(str); + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe( + 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout main")' + ); + } + }); + it('should throw error when try to branch existing branch: testBranch', async () => { + const str = `gitGraph + commit + branch testBranch + commit + branch testBranch + commit + checkout main + merge testBranch + `; + + try { + await parser.parse(str); + // Fail test if above expression doesn't throw anything. + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe( + 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout testBranch")' + ); + } + }); + it('should throw error when try to checkout unknown branch: testBranch', async () => { + const str = `gitGraph + commit + checkout testBranch + commit + branch testBranch + commit + checkout main + merge testBranch + `; + + try { + await parser.parse(str); + // Fail test if above expression doesn't throw anything. + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe( + 'Trying to checkout branch which is not yet created. (Help try using "branch testBranch")' + ); + } + }); + it('should throw error when trying to merge, when current branch has no commits', async () => { + const str = `gitGraph + merge testBranch + commit + checkout testBranch + commit + branch testBranch + commit + checkout main + merge testBranch + `; + + try { + await parser.parse(str); + // Fail test if above expression doesn't throw anything. + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe('Incorrect usage of "merge". Current branch (main)has no commits'); + } + }); + it('should throw error when trying to merge unknown branch', async () => { + const str = `gitGraph + commit + merge testBranch + commit + checkout testBranch + commit + branch testBranch + commit + checkout main + merge testBranch + `; + + try { + await parser.parse(str); + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe( + 'Incorrect usage of "merge". Branch to be merged (testBranch) does not exist' + ); + } + }); + it('should throw error when trying to merge branch to itself', async () => { + const str = `gitGraph + commit + branch testBranch + merge testBranch + `; + + try { + await parser.parse(str); + // Fail test if above expression doesn't throw anything. + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe('Incorrect usage of "merge". Cannot merge a branch to itself'); + } + }); + + it('should throw error when using existing id as merge ID', async () => { + const str = `gitGraph + commit id: "1-111" + branch testBranch + commit id: "2-222" + commit id: "3-333" + checkout main + merge testBranch id: "1-111" + `; + + try { + await parser.parse(str); + // Fail test if above expression doesn't throw anything. + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe( + 'Incorrect usage of "merge". Commit with id:1-111 already exists, use different custom Id' + ); + } + }); + it('should throw error when trying to merge branches having same heads', async () => { + const str = `gitGraph + commit + branch testBranch + checkout main + merge testBranch + `; + + try { + await parser.parse(str); + // Fail test if above expression doesn't throw anything. + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe('Incorrect usage of "merge". Both branches have same head'); + } + }); + it('should throw error when trying to merge branch which has no commits', async () => { + const str = `gitGraph + branch test1 + + checkout main + commit + merge test1 + `; + + try { + await parser.parse(str); + // Fail test if above expression doesn't throw anything. + expect(true).toBe(false); + } catch (e: any) { + expect(e.message).toBe( + 'Incorrect usage of "merge". Branch to be merged (test1) has no commits' + ); + } + }); + describe('accessibility', () => { + it('should handle a title and a description (accDescr)', async () => { + const str = `gitGraph: + accTitle: This is a title + accDescr: This is a description + commit + `; + await parser.parse(str); + expect(db.getAccTitle()).toBe('This is a title'); + expect(db.getAccDescription()).toBe('This is a description'); + }); + it('should handle a title and a multiline description (accDescr)', async () => { + const str = `gitGraph: + accTitle: This is a title + accDescr { + This is a description + using multiple lines + } + commit + `; + await parser.parse(str); + expect(db.getAccTitle()).toBe('This is a title'); + expect(db.getAccDescription()).toBe('This is a description\nusing multiple lines'); + }); + }); + + describe('unsafe properties', () => { + for (const prop of ['__proto__', 'constructor']) { + it(`should work with custom commit id or branch name ${prop}`, async () => { + const str = `gitGraph + commit id:"${prop}" + branch ${prop} + checkout ${prop} + commit + checkout main + merge ${prop} + `; + await parser.parse(str); + const commits = db.getCommits(); + expect(commits.size).toBe(3); + expect(commits.keys().next().value).toBe(prop); + expect(db.getCurrentBranch()).toBe('main'); + expect(db.getBranches().size).toBe(2); + expect(db.getBranchesAsObjArray()[1].name).toBe(prop); + }); + } + }); + }); +}); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js deleted file mode 100644 index 460d039aa..000000000 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.spec.js +++ /dev/null @@ -1,231 +0,0 @@ -import db from './gitGraphAst.js'; -import { parser } from './gitGraphParser.js'; - -describe('when parsing a gitGraph', function () { - beforeEach(function () { - db.clear(); - }); - - it('should handle a gitGraph definition', async () => { - const str = `gitGraph:\n commit\n`; - - await parser.parse(str); - const commits = db.getCommits(); - - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(1); - }); - - it('should handle set direction top to bottom', async () => { - const str = 'gitGraph TB:\n' + 'commit\n'; - - await parser.parse(str); - const commits = db.getCommits(); - - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('TB'); - expect(db.getBranches().size).toBe(1); - }); - - it('should handle set direction bottom to top', async () => { - const str = 'gitGraph BT:\n' + 'commit\n'; - - await parser.parse(str); - const commits = db.getCommits(); - - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('BT'); - expect(db.getBranches().size).toBe(1); - }); - - it('should checkout a branch', async () => { - const str = 'gitGraph:\n' + 'branch new\n' + 'checkout new\n'; - - await parser.parse(str); - const commits = db.getCommits(); - - expect(commits.size).toBe(0); - expect(db.getCurrentBranch()).toBe('new'); - }); - - it('should switch a branch', async () => { - const str = 'gitGraph:\n' + 'branch new\n' + 'switch new\n'; - - await parser.parse(str); - const commits = db.getCommits(); - - expect(commits.size).toBe(0); - expect(db.getCurrentBranch()).toBe('new'); - }); - - it('should add commits to checked out branch', async () => { - const str = 'gitGraph:\n' + 'branch new\n' + 'checkout new\n' + 'commit\n' + 'commit\n'; - - await parser.parse(str); - const commits = db.getCommits(); - - expect(commits.size).toBe(2); - expect(db.getCurrentBranch()).toBe('new'); - const branchCommit = db.getBranches().get('new'); - expect(branchCommit).not.toBeNull(); - expect(commits.get(branchCommit).parent).not.toBeNull(); - }); - it('should handle commit with args', async () => { - const str = 'gitGraph:\n' + 'commit "a commit"\n'; - - await parser.parse(str); - const commits = db.getCommits(); - - expect(commits.size).toBe(1); - const key = commits.keys().next().value; - expect(commits.get(key).message).toBe('a commit'); - expect(db.getCurrentBranch()).toBe('main'); - }); - - it.skip('should reset a branch', async () => { - const str = - 'gitGraph:\n' + - 'commit\n' + - 'commit\n' + - 'branch newbranch\n' + - 'checkout newbranch\n' + - 'commit\n' + - 'reset main\n'; - - await parser.parse(str); - - const commits = db.getCommits(); - expect(commits.size).toBe(3); - expect(db.getCurrentBranch()).toBe('newbranch'); - expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); - expect(db.getHead().id).toEqual(db.getBranches().get('newbranch')); - }); - - it.skip('reset can take an argument', async () => { - const str = - 'gitGraph:\n' + - 'commit\n' + - 'commit\n' + - 'branch newbranch\n' + - 'checkout newbranch\n' + - 'commit\n' + - 'reset main^\n'; - - await parser.parse(str); - - const commits = db.getCommits(); - expect(commits.size).toBe(3); - expect(db.getCurrentBranch()).toBe('newbranch'); - const main = commits.get(db.getBranches().get('main')); - expect(db.getHead().id).toEqual(main.parent); - }); - - it.skip('should handle fast forwardable merges', async () => { - const str = - 'gitGraph:\n' + - 'commit\n' + - 'branch newbranch\n' + - 'checkout newbranch\n' + - 'commit\n' + - 'commit\n' + - 'checkout main\n' + - 'merge newbranch\n'; - - await parser.parse(str); - - const commits = db.getCommits(); - expect(commits.size).toBe(4); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); - expect(db.getHead().id).toEqual(db.getBranches().get('newbranch')); - }); - - it('should handle cases when merge is a noop', async () => { - const str = - 'gitGraph:\n' + - 'commit\n' + - 'branch newbranch\n' + - 'checkout newbranch\n' + - 'commit\n' + - 'commit\n' + - 'merge main\n'; - - await parser.parse(str); - - const commits = db.getCommits(); - expect(commits.size).toBe(4); - expect(db.getCurrentBranch()).toBe('newbranch'); - expect(db.getBranches().get('newbranch')).not.toEqual(db.getBranches().get('main')); - expect(db.getHead().id).toEqual(db.getBranches().get('newbranch')); - }); - - it('should handle merge with 2 parents', async () => { - const str = - 'gitGraph:\n' + - 'commit\n' + - 'branch newbranch\n' + - 'checkout newbranch\n' + - 'commit\n' + - 'commit\n' + - 'checkout main\n' + - 'commit\n' + - 'merge newbranch\n'; - - await parser.parse(str); - - const commits = db.getCommits(); - expect(commits.size).toBe(5); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getBranches().get('newbranch')).not.toEqual(db.getBranches().get('main')); - expect(db.getHead().id).toEqual(db.getBranches().get('main')); - }); - - it.skip('should handle ff merge when history walk has two parents (merge commit)', async () => { - const str = - 'gitGraph:\n' + - 'commit\n' + - 'branch newbranch\n' + - 'checkout newbranch\n' + - 'commit\n' + - 'commit\n' + - 'checkout main\n' + - 'commit\n' + - 'merge newbranch\n' + - 'commit\n' + - 'checkout newbranch\n' + - 'merge main\n'; - - await parser.parse(str); - - const commits = db.getCommits(); - expect(commits.size).toBe(7); - expect(db.getCurrentBranch()).toBe('newbranch'); - expect(db.getBranches().get('newbranch')).toEqual(db.getBranches().get('main')); - expect(db.getHead().id).toEqual(db.getBranches().get('main')); - - db.prettyPrint(); - }); - - it('should generate an array of known branches', async () => { - const str = - 'gitGraph:\n' + - 'commit\n' + - 'branch b1\n' + - 'checkout b1\n' + - 'commit\n' + - 'commit\n' + - 'branch b2\n'; - - await parser.parse(str); - const branches = db.getBranchesAsObjArray(); - - expect(branches).toHaveLength(3); - expect(branches[0]).toHaveProperty('name', 'main'); - expect(branches[1]).toHaveProperty('name', 'b1'); - expect(branches[2]).toHaveProperty('name', 'b2'); - }); -}); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 5598062b4..93a671993 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -50,8 +50,9 @@ const parseStatement = (statement: any) => { const parseCommit = (commit: CommitAst) => { const id = commit.id; const message = commit.message ?? ''; - const tags = commit.tags ?? undefined; const type = commit.type !== undefined ? commitType[commit.type] : commitType.NORMAL; + const tags = commit.tags ?? undefined; + db.commit(message, id, type, tags); }; @@ -64,8 +65,8 @@ const parseBranch = (branch: BranchAst) => { const parseMerge = (merge: MergeAst) => { const branch = merge.branch; const id = merge.id ?? ''; - const tags = merge.tags ?? undefined; const type = merge.type !== undefined ? commitType[merge.type] : undefined; + const tags = merge.tags ?? undefined; db.merge(branch, id, type, tags); }; diff --git a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js b/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js deleted file mode 100644 index e1e95551b..000000000 --- a/packages/mermaid/src/diagrams/git/gitGraphParserV2.spec.js +++ /dev/null @@ -1,1099 +0,0 @@ -import db from './gitGraphAst.js'; -import { parser } from './gitGraphParser.js'; - -describe('when parsing a gitGraph', function () { - beforeEach(function () { - db.clear(); - }); - it('should handle a gitGraph commit with NO params, get auto-generated read-only ID', async () => { - const str = `gitGraph: - commit - `; - await parser.parse(str); - const commits = db.getCommits(); - //console.info(commits); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual([]); - expect(commits.get(key).type).toBe(0); - }); - - it('should handle a gitGraph commit with custom commit id only', async () => { - const str = `gitGraph: - commit id:"1111" - `; - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual([]); - expect(commits.get(key).type).toBe(0); - }); - - it('should handle a gitGraph commit with custom commit tag only', async () => { - const str = `gitGraph: - commit tag:"test" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test']); - expect(commits.get(key).type).toBe(0); - }); - - it('should handle a gitGraph commit with custom commit type HIGHLIGHT only', async () => { - const str = `gitGraph: - commit type: HIGHLIGHT - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual([]); - expect(commits.get(key).type).toBe(2); - }); - - it('should handle a gitGraph commit with custom commit type REVERSE only', async () => { - const str = `gitGraph: - commit type: REVERSE - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual([]); - expect(commits.get(key).type).toBe(1); - }); - - it('should handle a gitGraph commit with custom commit type NORMAL only', async () => { - const str = `gitGraph: - commit type: NORMAL - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual([]); - expect(commits.get(key).type).toBe(0); - }); - - it('should handle a gitGraph commit with custom commit msg only', async () => { - const str = `gitGraph: - commit "test commit" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual([]); - expect(commits.get(key).type).toBe(0); - }); - - it('should handle a gitGraph commit with custom commit "msg:" key only', async () => { - const str = `gitGraph: - commit msg: "test commit" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual([]); - expect(commits.get(key).type).toBe(0); - }); - - it('should handle a gitGraph commit with custom commit id, tag only', async () => { - const str = `gitGraph: - commit id:"1111" tag: "test tag" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test tag']); - expect(commits.get(key).type).toBe(0); - }); - - it('should handle a gitGraph commit with custom commit type, tag only', async () => { - const str = `gitGraph: - commit type:HIGHLIGHT tag: "test tag" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test tag']); - expect(commits.get(key).type).toBe(2); - }); - - it('should handle a gitGraph commit with custom commit tag and type only', async () => { - const str = `gitGraph: - commit tag: "test tag" type:HIGHLIGHT - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test tag']); - expect(commits.get(key).type).toBe(2); - }); - - it('should handle a gitGraph commit with custom commit id, type and tag only', async () => { - const str = `gitGraph: - commit id:"1111" type:REVERSE tag: "test tag" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test tag']); - expect(commits.get(key).type).toBe(1); - }); - - it('should handle a gitGraph commit with custom commit id, type, tag and msg', async () => { - const str = `gitGraph: - commit id:"1111" type:REVERSE tag: "test tag" msg:"test msg" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test tag']); - expect(commits.get(key).type).toBe(1); - }); - - it('should handle a gitGraph commit with custom type,tag, msg, commit id,', async () => { - const str = `gitGraph: - commit type:REVERSE tag: "test tag" msg: "test msg" id: "1111" - - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test tag']); - expect(commits.get(key).type).toBe(1); - }); - - it('should handle a gitGraph commit with custom tag, msg, commit id, type,', async () => { - const str = `gitGraph: - commit tag: "test tag" msg:"test msg" id:"1111" type:REVERSE - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test tag']); - expect(commits.get(key).type).toBe(1); - }); - - it('should handle a gitGraph commit with custom msg, commit id, type,tag', async () => { - const str = `gitGraph: - commit msg:"test msg" id:"1111" type:REVERSE tag: "test tag" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.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).tags).toStrictEqual(['test tag']); - expect(commits.get(key).type).toBe(1); - }); - - it('should handle 3 straight commits', async () => { - const str = `gitGraph: - commit - commit - commit - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(3); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(1); - }); - - it('should handle new branch creation', async () => { - const str = `gitGraph: - commit - branch testBranch - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('testBranch'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - }); - - it('should allow quoted branch names', async () => { - const str = `gitGraph: - commit - branch "branch" - checkout "branch" - commit - checkout main - merge "branch" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(3); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(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'); - expect(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'branch' }]); - }); - - it('should allow _-./ characters in branch names', async () => { - const str = `gitGraph: - commit - branch azAZ_-./test - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('azAZ_-./test'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - }); - - it('should allow branch names starting with numbers', async () => { - const str = `gitGraph: - commit - %% branch names starting with numbers are not recommended, but are supported by git - branch 1.0.1 - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('1.0.1'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - }); - - it('should allow branch names starting with unusual prefixes', async () => { - const str = `gitGraph: - commit - %% branch names starting with numbers are not recommended, but are supported by git - branch branch01 - branch checkout02 - branch cherry-pick03 - branch branch/example-branch - branch merge/test_merge - %% single character branch name - branch A - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('A'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(7); - expect([...db.getBranches().keys()]).toEqual( - expect.arrayContaining([ - 'branch01', - 'checkout02', - 'cherry-pick03', - 'branch/example-branch', - 'merge/test_merge', - 'A', - ]) - ); - }); - - it('should handle new branch checkout', async () => { - const str = `gitGraph: - commit - branch testBranch - checkout testBranch - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('testBranch'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - }); - it('should handle new branch checkout with order', async () => { - const str = `gitGraph: - commit - branch test1 order: 3 - branch test2 order: 2 - branch test3 order: 1 - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('test3'); - expect(db.getBranches().size).toBe(4); - expect(db.getBranchesAsObjArray()).toStrictEqual([ - { name: 'main' }, - { name: 'test3' }, - { name: 'test2' }, - { name: 'test1' }, - ]); - }); - it('should handle new branch checkout with and without order', async () => { - const str = `gitGraph: - commit - branch test1 order: 1 - branch test2 - branch test3 - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('test3'); - expect(db.getBranches().size).toBe(4); - expect(db.getBranchesAsObjArray()).toStrictEqual([ - { name: 'main' }, - { name: 'test2' }, - { name: 'test3' }, - { name: 'test1' }, - ]); - }); - - it('should handle new branch checkout & commit', async () => { - const str = `gitGraph: - commit - branch testBranch - checkout testBranch - commit - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(2); - expect(db.getCurrentBranch()).toBe('testBranch'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - 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'); - expect(commits.get(commit2).parents).toStrictEqual([commit1]); - }); - - it('should handle new branch checkout & commit and merge', async () => { - const str = `gitGraph: - commit - branch testBranch - checkout testBranch - commit - commit - checkout main - merge testBranch - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(4); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - 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'); - 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(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); - }); - - it('should handle new branch switch', async () => { - const str = `gitGraph: - commit - branch testBranch - switch testBranch - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(1); - expect(db.getCurrentBranch()).toBe('testBranch'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - }); - - it('should handle new branch switch & commit', async () => { - const str = `gitGraph: - commit - branch testBranch - switch testBranch - commit - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(2); - expect(db.getCurrentBranch()).toBe('testBranch'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - 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'); - expect(commits.get(commit2).parents).toStrictEqual([commit1]); - }); - - it('should handle new branch switch & commit and merge', async () => { - const str = `gitGraph: - commit - branch testBranch - switch testBranch - commit - commit - switch main - merge testBranch - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(4); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - 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'); - 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(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); - }); - - it('should handle merge tags', async () => { - const str = `gitGraph: - commit - branch testBranch - checkout testBranch - commit - checkout main - merge testBranch tag: "merge-tag" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(3); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - expect(db.getBranches().size).toBe(2); - const [commit1, commit2, commit3] = commits.keys(); - 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('main'); - expect(commits.get(commit3).parents).toStrictEqual([ - commits.get(commit1).id, - commits.get(commit2).id, - ]); - expect(commits.get(commit3).tags).toStrictEqual(['merge-tag']); - expect(db.getBranchesAsObjArray()).toStrictEqual([{ name: 'main' }, { name: 'testBranch' }]); - }); - - it('should handle merge with custom ids, tags and type', async () => { - const str = `gitGraph: - commit - branch testBranch - checkout testBranch - commit - checkout main - %% Merge Tag and ID - merge testBranch tag: "merge-tag" id: "2-222" - branch testBranch2 - checkout testBranch2 - commit - checkout main - %% Merge ID and Tag (reverse order) - merge testBranch2 id: "4-444" tag: "merge-tag2" type:HIGHLIGHT - branch testBranch3 - checkout testBranch3 - commit - checkout main - %% just Merge ID - merge testBranch3 id: "6-666" - `; - - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(7); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getDirection()).toBe('LR'); - - // The order of these commits is in alphabetical order of IDs - const [ - mainCommit, - testBranchCommit, - testBranchMerge, - testBranch2Commit, - testBranch2Merge, - testBranch3Commit, - testBranch3Merge, - ] = [...commits.values()]; - - expect(mainCommit.branch).toBe('main'); - expect(mainCommit.parents).toStrictEqual([]); - - expect(testBranchCommit.branch).toBe('testBranch'); - expect(testBranchCommit.parents).toStrictEqual([mainCommit.id]); - - expect(testBranchMerge.branch).toBe('main'); - expect(testBranchMerge.parents).toStrictEqual([mainCommit.id, testBranchCommit.id]); - expect(testBranchMerge.tags).toStrictEqual(['merge-tag']); - expect(testBranchMerge.id).toBe('2-222'); - - expect(testBranch2Merge.branch).toBe('main'); - expect(testBranch2Merge.parents).toStrictEqual([testBranchMerge.id, testBranch2Commit.id]); - expect(testBranch2Merge.tags).toStrictEqual(['merge-tag2']); - expect(testBranch2Merge.id).toBe('4-444'); - expect(testBranch2Merge.customType).toBe(2); - expect(testBranch2Merge.customId).toBe(true); - - expect(testBranch3Merge.branch).toBe('main'); - expect(testBranch3Merge.parents).toStrictEqual([testBranch2Merge.id, testBranch3Commit.id]); - expect(testBranch3Merge.id).toBe('6-666'); - - expect(db.getBranchesAsObjArray()).toStrictEqual([ - { name: 'main' }, - { name: 'testBranch' }, - { name: 'testBranch2' }, - { name: 'testBranch3' }, - ]); - }); - - it('should support cherry-picking commits', async () => { - const str = `gitGraph - commit id: "ZERO" - branch develop - commit id:"A" - checkout main - cherry-pick id:"A" - `; - - await parser.parse(str); - const commits = db.getCommits(); - const cherryPickCommitID = [...commits.keys()][2]; - expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['cherry-pick:A']); - expect(commits.get(cherryPickCommitID).branch).toBe('main'); - }); - - it('should support cherry-picking commits with custom tag', async () => { - const str = `gitGraph - commit id: "ZERO" - branch develop - commit id:"A" - checkout main - cherry-pick id:"A" tag:"MyTag" - `; - - await parser.parse(str); - const commits = db.getCommits(); - const cherryPickCommitID = [...commits.keys()][2]; - expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['MyTag']); - expect(commits.get(cherryPickCommitID).branch).toBe('main'); - }); - - it('should support cherry-picking commits with no tag', async () => { - const str = `gitGraph - commit id: "ZERO" - branch develop - commit id:"A" - checkout main - cherry-pick id:"A" tag:"" - `; - - await parser.parse(str); - const commits = db.getCommits(); - const cherryPickCommitID = [...commits.keys()][2]; - expect(commits.get(cherryPickCommitID).tags).toStrictEqual([]); - expect(commits.get(cherryPickCommitID).branch).toBe('main'); - }); - - it('should support cherry-picking of merge commits', async () => { - const str = `gitGraph - commit id: "ZERO" - branch feature - branch release - checkout feature - commit id: "A" - commit id: "B" - checkout main - merge feature id: "M" - checkout release - cherry-pick id: "M" parent:"B" - `; - - await parser.parse(str); - const commits = db.getCommits(); - const cherryPickCommitID = [...commits.keys()][4]; - expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['cherry-pick:M|parent:B']); - expect(commits.get(cherryPickCommitID).branch).toBe('release'); - }); - - it('should support cherry-picking of merge commits with tag', async () => { - const str = `gitGraph - commit id: "ZERO" - branch feature - branch release - checkout feature - commit id: "A" - commit id: "B" - checkout main - merge feature id: "M" - checkout release - cherry-pick id: "M" parent:"ZERO" tag: "v1.0" - `; - - await parser.parse(str); - const commits = db.getCommits(); - const cherryPickCommitID = [...commits.keys()][4]; - expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['v1.0']); - expect(commits.get(cherryPickCommitID).branch).toBe('release'); - }); - - it('should support cherry-picking of merge commits with additional commit', async () => { - const str = `gitGraph - commit id: "ZERO" - branch feature - branch release - checkout feature - commit id: "A" - commit id: "B" - checkout main - merge feature id: "M" - checkout release - commit id: "C" - cherry-pick id: "M" tag: "v2.1:ZERO" parent:"ZERO" - commit id: "D" - `; - - await parser.parse(str); - const commits = db.getCommits(); - const cherryPickCommitID = [...commits.keys()][5]; - expect(commits.get(cherryPickCommitID).tags).toStrictEqual(['v2.1:ZERO']); - expect(commits.get(cherryPickCommitID).branch).toBe('release'); - }); - - it('should support cherry-picking of merge commits with empty tag', async () => { - const str = `gitGraph - commit id: "ZERO" - branch feature - branch release - checkout feature - commit id: "A" - commit id: "B" - checkout main - merge feature id: "M" - checkout release - commit id: "C" - cherry-pick id:"M" parent: "ZERO" tag:"" - commit id: "D" - cherry-pick id:"M" tag:"" parent: "B" - `; - - await parser.parse(str); - const commits = db.getCommits(); - const cherryPickCommitID = [...commits.keys()][5]; - const cherryPickCommitID2 = [...commits.keys()][7]; - expect(commits.get(cherryPickCommitID).tags).toStrictEqual([]); - expect(commits.get(cherryPickCommitID2).tags).toStrictEqual([]); - 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 () { - expect( - async () => - await parser - .parse( - `gitGraph - commit id: "ZERO" - branch feature - branch release - checkout feature - commit id: "A" - commit id: "B" - checkout main - merge feature id: "M" - checkout release - commit id: "C" - cherry-pick id:"M" - ` - ) - .toThrow( - 'Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.' - ) - ); - }); - - it('should fail cherry-picking of merge commits when the parent provided is not an immediate parent of cherry picked commit', function () { - expect( - async () => - await parser - .parse( - `gitGraph - commit id: "ZERO" - branch feature - branch release - checkout feature - commit id: "A" - commit id: "B" - checkout main - merge feature id: "M" - checkout release - commit id: "C" - cherry-pick id:"M" parent: "A" - ` - ) - .toThrow( - 'Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.' - ) - ); - }); - - it('should throw error when try to branch existing branch: main', async () => { - const str = `gitGraph - commit - branch testBranch - commit - branch main - commit - checkout main - merge testBranch - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe( - 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout main")' - ); - } - }); - it('should throw error when try to branch existing branch: testBranch', async () => { - const str = `gitGraph - commit - branch testBranch - commit - branch testBranch - commit - checkout main - merge testBranch - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe( - 'Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout testBranch")' - ); - } - }); - it('should throw error when try to checkout unknown branch: testBranch', async () => { - const str = `gitGraph - commit - checkout testBranch - commit - branch testBranch - commit - checkout main - merge testBranch - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe( - 'Trying to checkout branch which is not yet created. (Help try using "branch testBranch")' - ); - } - }); - it('should throw error when trying to merge, when current branch has no commits', async () => { - const str = `gitGraph - merge testBranch - commit - checkout testBranch - commit - branch testBranch - commit - checkout main - merge testBranch - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe('Incorrect usage of "merge". Current branch (main)has no commits'); - } - }); - it('should throw error when trying to merge unknown branch', async () => { - const str = `gitGraph - commit - merge testBranch - commit - checkout testBranch - commit - branch testBranch - commit - checkout main - merge testBranch - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe( - 'Incorrect usage of "merge". Branch to be merged (testBranch) does not exist' - ); - } - }); - it('should throw error when trying to merge branch to itself', async () => { - const str = `gitGraph - commit - branch testBranch - merge testBranch - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe('Incorrect usage of "merge". Cannot merge a branch to itself'); - } - }); - - it('should throw error when using existing id as merge ID', async () => { - const str = `gitGraph - commit id: "1-111" - branch testBranch - commit id: "2-222" - commit id: "3-333" - checkout main - merge testBranch id: "1-111" - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe( - 'Incorrect usage of "merge". Commit with id:1-111 already exists, use different custom Id' - ); - } - }); - it('should throw error when trying to merge branches having same heads', async () => { - const str = `gitGraph - commit - branch testBranch - checkout main - merge testBranch - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe('Incorrect usage of "merge". Both branches have same head'); - } - }); - it('should throw error when trying to merge branch which has no commits', async () => { - const str = `gitGraph - branch test1 - - checkout main - commit - merge test1 - `; - - try { - await parser.parse(str); - // Fail test if above expression doesn't throw anything. - expect(true).toBe(false); - } catch (e) { - expect(e.message).toBe( - 'Incorrect usage of "merge". Branch to be merged (test1) has no commits' - ); - } - }); - describe('accessibility', () => { - it('should handle a title and a description (accDescr)', async () => { - const str = `gitGraph: - accTitle: This is a title - accDescr: This is a description - commit - `; - await parser.parse(str); - expect(db.getAccTitle()).toBe('This is a title'); - expect(db.getAccDescription()).toBe('This is a description'); - }); - it('should handle a title and a multiline description (accDescr)', async () => { - const str = `gitGraph: - accTitle: This is a title - accDescr { - This is a description - using multiple lines - } - commit - `; - await parser.parse(str); - expect(db.getAccTitle()).toBe('This is a title'); - expect(db.getAccDescription()).toBe('This is a description\nusing multiple lines'); - }); - }); - - describe('unsafe properties', () => { - for (const prop of ['__proto__', 'constructor']) { - it(`should work with custom commit id or branch name ${prop}`, async () => { - const str = `gitGraph - commit id:"${prop}" - branch ${prop} - checkout ${prop} - commit - checkout main - merge ${prop} - `; - await parser.parse(str); - const commits = db.getCommits(); - expect(commits.size).toBe(3); - expect(commits.keys().next().value).toBe(prop); - expect(db.getCurrentBranch()).toBe('main'); - expect(db.getBranches().size).toBe(2); - expect(db.getBranchesAsObjArray()[1].name).toBe(prop); - }); - } - }); -}); diff --git a/packages/mermaid/tsconfig.json b/packages/mermaid/tsconfig.json index 78e3cf2de..f4451225e 100644 --- a/packages/mermaid/tsconfig.json +++ b/packages/mermaid/tsconfig.json @@ -5,5 +5,5 @@ "outDir": "./dist", "types": ["vitest/importMeta", "vitest/globals"] }, - "include": ["./src/**/*.ts", "./package.json"] + "include": ["./src/**/*.ts", "./package.json", "src/diagrams/gantt/ganttDb.js"] } From 00603e7bac5ea7eb8e7a91f6dd668343584e98b3 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Thu, 8 Aug 2024 18:47:34 -0400 Subject: [PATCH 030/124] fix ts-ignore errors refactored large functions to use helpers --- .../src/diagrams/git/gitGraph.parser.spec.ts | 3 +- .../mermaid/src/diagrams/git/gitGraph.spec.ts | 2 +- .../mermaid/src/diagrams/git/gitGraphAst.ts | 7 +- .../src/diagrams/git/gitGraphDiagram.ts | 4 +- .../src/diagrams/git/gitGraphParser.ts | 2 +- .../src/diagrams/git/gitGraphRenderer.js | 893 ---------------- .../src/diagrams/git/gitGraphRenderer.ts | 968 ++++++++++++++++++ .../mermaid/src/diagrams/git/gitGraphTypes.ts | 59 +- packages/mermaid/tsconfig.json | 7 +- 9 files changed, 1040 insertions(+), 905 deletions(-) delete mode 100644 packages/mermaid/src/diagrams/git/gitGraphRenderer.js create mode 100644 packages/mermaid/src/diagrams/git/gitGraphRenderer.ts diff --git a/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts b/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts index 2c86d7c7b..1a38a8217 100644 --- a/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts +++ b/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts @@ -1,7 +1,6 @@ import { describe, it, expect, beforeEach, vi } from 'vitest'; import { parser } from './gitGraphParser.js'; -import db from './gitGraphAst.js'; -import { parse } from 'path'; +import { db } from './gitGraphAst.js'; const parseInput = async (input: string) => { await parser.parse(input); diff --git a/packages/mermaid/src/diagrams/git/gitGraph.spec.ts b/packages/mermaid/src/diagrams/git/gitGraph.spec.ts index ab315a82a..9b3236f90 100644 --- a/packages/mermaid/src/diagrams/git/gitGraph.spec.ts +++ b/packages/mermaid/src/diagrams/git/gitGraph.spec.ts @@ -1,5 +1,5 @@ import { rejects } from 'assert'; -import db from './gitGraphAst.js'; +import { db } from './gitGraphAst.js'; import { parser } from './gitGraphParser.js'; describe('when parsing a gitGraph', function () { diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 31302133a..53c361e3e 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -12,9 +12,8 @@ import { getDiagramTitle, } from '../common/commonDb.js'; import defaultConfig from '../../defaultConfig.js'; -import type { DiagramOrientation, Commit } from './gitGraphTypes.js'; +import type { DiagramOrientation, Commit, GitGraphDB, CommitType } from './gitGraphTypes.js'; import { ImperativeState } from '../../utils/imperativeState.js'; - interface GitGraphState { commits: Map; head: Commit | null; @@ -467,7 +466,7 @@ export const getHead = function () { return state.records.head; }; -export const commitType = { +export const commitType: CommitType = { NORMAL: 0, REVERSE: 1, HIGHLIGHT: 2, @@ -475,7 +474,7 @@ export const commitType = { CHERRY_PICK: 4, }; -export default { +export const db: GitGraphDB = { commitType, getConfig: () => getConfig().gitGraph, setDirection, diff --git a/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts b/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts index e5534140b..01537e551 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts @@ -1,13 +1,13 @@ // @ts-ignore: JISON doesn't support types import { parser } from './gitGraphParser.js'; -import gitGraphDb from './gitGraphAst.js'; +import { db } from './gitGraphAst.js'; import gitGraphRenderer from './gitGraphRenderer.js'; import gitGraphStyles from './styles.js'; import type { DiagramDefinition } from '../../diagram-api/types.js'; export const diagram: DiagramDefinition = { parser: parser, - db: gitGraphDb, + db: db, renderer: gitGraphRenderer, styles: gitGraphStyles, }; diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 93a671993..b014d7e57 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -3,7 +3,7 @@ import { parse } from '@mermaid-js/parser'; import type { ParserDefinition } from '../../diagram-api/types.js'; import { log } from '../../logger.js'; import { populateCommonDb } from '../common/populateCommonDb.js'; -import db from './gitGraphAst.js'; +import { db } from './gitGraphAst.js'; import { commitType } from './gitGraphAst.js'; import type { CheckoutAst, diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.js b/packages/mermaid/src/diagrams/git/gitGraphRenderer.js deleted file mode 100644 index b8b13e089..000000000 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.js +++ /dev/null @@ -1,893 +0,0 @@ -import { select } from 'd3'; -import { getConfig, setupGraphViewbox } from '../../diagram-api/diagramAPI.js'; -import { log } from '../../logger.js'; -import utils from '../../utils.js'; - -/** - * @typedef {Map} CommitMap - */ - -/** @type {CommitMap} */ -let allCommitsDict = new Map(); - -const commitType = { - NORMAL: 0, - REVERSE: 1, - HIGHLIGHT: 2, - MERGE: 3, - CHERRY_PICK: 4, -}; - -const THEME_COLOR_LIMIT = 8; - -let branchPos = {}; -let commitPos = {}; -let lanes = []; -let maxPos = 0; -let dir = 'LR'; -let defaultPos = 30; -const clear = () => { - branchPos = new Map(); - commitPos = new Map(); - allCommitsDict = new Map(); - maxPos = 0; - lanes = []; - dir = 'LR'; -}; - -/** - * Draws a text, used for labels of the branches - * - * @param {string} txt The text - * @returns {SVGElement} - */ -const drawText = (txt) => { - const svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text'); - let rows = []; - - // Handling of new lines in the label - if (typeof txt === 'string') { - rows = txt.split(/\\n|\n|/gi); - } else if (Array.isArray(txt)) { - rows = txt; - } else { - rows = []; - } - - for (const row of rows) { - const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan'); - tspan.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve'); - tspan.setAttribute('dy', '1em'); - tspan.setAttribute('x', '0'); - tspan.setAttribute('class', 'row'); - tspan.textContent = row.trim(); - svgLabel.appendChild(tspan); - } - /** - * @param svg - * @param selector - */ - return svgLabel; -}; - -/** - * Searches for the closest parent from the parents list passed as argument. - * The parents list comes from an individual commit. The closest parent is actually - * the one farther down the graph, since that means it is closer to its child. - * - * @param {string[]} parents - * @returns {string | undefined} - */ -const findClosestParent = (parents) => { - let closestParent = ''; - let maxPosition = 0; - - parents.forEach((parent) => { - const parentPosition = - dir === 'TB' || dir === 'BT' ? commitPos.get(parent).y : commitPos.get(parent).x; - if (parentPosition >= maxPosition) { - closestParent = parent; - maxPosition = parentPosition; - } - }); - - return closestParent || undefined; -}; - -/** - * Searches for the closest parent from the parents list passed as argument for Bottom-to-Top orientation. - * The parents list comes from an individual commit. The closest parent is actually - * the one farther down the graph, since that means it is closer to its child. - * - * @param {string[]} parents - * @returns {string | undefined} - */ -const findClosestParentBT = (parents) => { - let closestParent = ''; - let maxPosition = Infinity; - - parents.forEach((parent) => { - const parentPosition = commitPos.get(parent).y; - if (parentPosition <= maxPosition) { - closestParent = parent; - maxPosition = parentPosition; - } - }); - - return closestParent || undefined; -}; - -/** - * Sets the position of the commit elements when the orientation is set to BT-Parallel. - * This is needed to render the chart in Bottom-to-Top mode while keeping the parallel - * commits in the correct position. First, it finds the correct position of the root commit - * using the findClosestParent method. Then, it uses the findClosestParentBT to set the position - * of the remaining commits. - * - * @param {any} sortedKeys - * @param {CommitMap} commits - * @param {any} defaultPos - * @param {any} commitStep - * @param {any} layoutOffset - */ -const setParallelBTPos = (sortedKeys, commits, defaultPos, commitStep, layoutOffset) => { - let curPos = defaultPos; - let maxPosition = defaultPos; - let roots = []; - sortedKeys.forEach((key) => { - const commit = commits.get(key); - if (commit.parents.length) { - const closestParent = findClosestParent(commit.parents); - curPos = commitPos.get(closestParent).y + commitStep; - if (curPos >= maxPosition) { - maxPosition = curPos; - } - } else { - roots.push(commit); - } - const x = branchPos.get(commit.branch).pos; - const y = curPos + layoutOffset; - commitPos.set(commit.id, { x: x, y: y }); - }); - curPos = maxPosition; - roots.forEach((commit) => { - const posWithOffset = curPos + defaultPos; - const y = posWithOffset; - 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.get(closestParent).y - commitStep; - if (curPos <= maxPosition) { - maxPosition = curPos; - } - const x = branchPos.get(commit.branch).pos; - const y = curPos - layoutOffset; - commitPos.set(commit.id, { x: x, y: y }); - } - }); -}; - -/** - * Draws the commits with its symbol and labels. The function has two modes, one which only - * calculates the positions and one that does the actual drawing. This for a simple way getting the - * vertical layering correct in the graph. - * - * @param {any} svg - * @param {CommitMap} commits - * @param {any} modifyGraph - */ -const drawCommits = (svg, commits, modifyGraph) => { - const gitGraphConfig = getConfig().gitGraph; - const gBullets = svg.append('g').attr('class', 'commit-bullets'); - const gLabels = svg.append('g').attr('class', 'commit-labels'); - let pos = 0; - - if (dir === 'TB' || dir === 'BT') { - pos = defaultPos; - } - 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.get(a).seq - commits.get(b).seq; - }) - : keys - .sort((a, b) => { - return commits.get(a).seq - commits.get(b).seq; - }) - .reverse(); - - if (dir === 'BT' && isParallelCommits) { - setParallelBTPos(sortedKeys, commits, pos, commitStep, layoutOffset); - sortedKeys = sortedKeys.reverse(); - } - sortedKeys.forEach((key) => { - const commit = commits.get(key); - if (isParallelCommits) { - if (commit.parents.length) { - const closestParent = - dir === 'BT' ? findClosestParentBT(commit.parents) : findClosestParent(commit.parents); - if (dir === 'TB') { - pos = commitPos.get(closestParent).y + commitStep; - } else if (dir === 'BT') { - pos = commitPos.get(key).y - commitStep; - } else { - pos = commitPos.get(closestParent).x + commitStep; - } - } else { - if (dir === 'TB') { - pos = defaultPos; - } else if (dir === 'BT') { - 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.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) { - let typeClass; - let commitSymbolType = - commit.customType !== undefined && commit.customType !== '' - ? commit.customType - : commit.type; - switch (commitSymbolType) { - case commitType.NORMAL: - typeClass = 'commit-normal'; - break; - case commitType.REVERSE: - typeClass = 'commit-reverse'; - break; - case commitType.HIGHLIGHT: - typeClass = 'commit-highlight'; - break; - case commitType.MERGE: - typeClass = 'commit-merge'; - break; - case commitType.CHERRY_PICK: - typeClass = 'commit-cherry-pick'; - break; - default: - typeClass = 'commit-normal'; - } - - if (commitSymbolType === commitType.HIGHLIGHT) { - const circle = gBullets.append('rect'); - circle.attr('x', x - 10); - circle.attr('y', y - 10); - circle.attr('height', 20); - circle.attr('width', 20); - circle.attr( - 'class', - `commit ${commit.id} commit-highlight${ - branchPos.get(commit.branch).index % THEME_COLOR_LIMIT - } ${typeClass}-outer` - ); - gBullets - .append('rect') - .attr('x', x - 6) - .attr('y', y - 6) - .attr('height', 12) - .attr('width', 12) - .attr( - 'class', - `commit ${commit.id} commit${ - branchPos.get(commit.branch).index % THEME_COLOR_LIMIT - } ${typeClass}-inner` - ); - } else if (commitSymbolType === commitType.CHERRY_PICK) { - gBullets - .append('circle') - .attr('cx', x) - .attr('cy', y) - .attr('r', 10) - .attr('class', `commit ${commit.id} ${typeClass}`); - gBullets - .append('circle') - .attr('cx', x - 3) - .attr('cy', y + 2) - .attr('r', 2.75) - .attr('fill', '#fff') - .attr('class', `commit ${commit.id} ${typeClass}`); - gBullets - .append('circle') - .attr('cx', x + 3) - .attr('cy', y + 2) - .attr('r', 2.75) - .attr('fill', '#fff') - .attr('class', `commit ${commit.id} ${typeClass}`); - gBullets - .append('line') - .attr('x1', x + 3) - .attr('y1', y + 1) - .attr('x2', x) - .attr('y2', y - 5) - .attr('stroke', '#fff') - .attr('class', `commit ${commit.id} ${typeClass}`); - gBullets - .append('line') - .attr('x1', x - 3) - .attr('y1', y + 1) - .attr('x2', x) - .attr('y2', y - 5) - .attr('stroke', '#fff') - .attr('class', `commit ${commit.id} ${typeClass}`); - } else { - const circle = gBullets.append('circle'); - circle.attr('cx', x); - circle.attr('cy', y); - circle.attr('r', commit.type === commitType.MERGE ? 9 : 10); - circle.attr( - 'class', - `commit ${commit.id} commit${branchPos.get(commit.branch).index % THEME_COLOR_LIMIT}` - ); - if (commitSymbolType === commitType.MERGE) { - const circle2 = gBullets.append('circle'); - circle2.attr('cx', x); - circle2.attr('cy', y); - circle2.attr('r', 6); - circle2.attr( - 'class', - `commit ${typeClass} ${commit.id} commit${ - branchPos.get(commit.branch).index % THEME_COLOR_LIMIT - }` - ); - } - if (commitSymbolType === commitType.REVERSE) { - const cross = gBullets.append('path'); - cross - .attr('d', `M ${x - 5},${y - 5}L${x + 5},${y + 5}M${x - 5},${y + 5}L${x + 5},${y - 5}`) - .attr( - 'class', - `commit ${typeClass} ${commit.id} commit${ - branchPos.get(commit.branch).index % THEME_COLOR_LIMIT - }` - ); - } - } - } - if (dir === 'TB' || dir === 'BT') { - commitPos.set(commit.id, { x: x, y: posWithOffset }); - } else { - commitPos.set(commit.id, { x: posWithOffset, y: y }); - } - - // The first iteration over the commits are for positioning purposes, this - // is required for drawing the lines. The circles and labels is drawn after the labels - // placing them on top of the lines. - if (modifyGraph) { - const px = 4; - const py = 2; - // Draw the commit label - if ( - commit.type !== commitType.CHERRY_PICK && - ((commit.customId && commit.type === commitType.MERGE) || - commit.type !== commitType.MERGE) && - gitGraphConfig.showCommitLabel - ) { - const wrapper = gLabels.append('g'); - const labelBkg = wrapper.insert('rect').attr('class', 'commit-label-bkg'); - - const text = wrapper - .append('text') - .attr('x', pos) - .attr('y', y + 25) - .attr('class', 'commit-label') - .text(commit.id); - let bbox = text.node().getBBox(); - - // Now we have the label, lets position the background - labelBkg - .attr('x', posWithOffset - bbox.width / 2 - py) - .attr('y', y + 13.5) - .attr('width', bbox.width + 2 * py) - .attr('height', bbox.height + 2 * py); - - if (dir === 'TB' || dir === 'BT') { - labelBkg.attr('x', x - (bbox.width + 4 * px + 5)).attr('y', y - 12); - text.attr('x', x - (bbox.width + 4 * px)).attr('y', y + bbox.height - 12); - } else { - text.attr('x', posWithOffset - bbox.width / 2); - } - if (gitGraphConfig.rotateCommitLabel) { - if (dir === 'TB' || dir === 'BT') { - text.attr('transform', 'rotate(' + -45 + ', ' + x + ', ' + y + ')'); - labelBkg.attr('transform', 'rotate(' + -45 + ', ' + x + ', ' + y + ')'); - } else { - let r_x = -7.5 - ((bbox.width + 10) / 25) * 9.5; - let r_y = 10 + (bbox.width / 25) * 8.5; - wrapper.attr( - 'transform', - 'translate(' + r_x + ', ' + r_y + ') rotate(' + -45 + ', ' + pos + ', ' + y + ')' - ); - } - } - } - if (commit.tags.length > 0) { - let yOffset = 0; - let maxTagBboxWidth = 0; - let maxTagBboxHeight = 0; - const tagElements = []; - - for (const tagValue of commit.tags.reverse()) { - const rect = gLabels.insert('polygon'); - const hole = gLabels.append('circle'); - const tag = gLabels - .append('text') - // Note that we are delaying setting the x position until we know the width of the text - .attr('y', y - 16 - yOffset) - .attr('class', 'tag-label') - .text(tagValue); - let tagBbox = tag.node().getBBox(); - maxTagBboxWidth = Math.max(maxTagBboxWidth, tagBbox.width); - maxTagBboxHeight = Math.max(maxTagBboxHeight, tagBbox.height); - - // We don't use the max over here to center the text within the tags - tag.attr('x', posWithOffset - tagBbox.width / 2); - - tagElements.push({ - tag, - hole, - rect, - yOffset, - }); - - yOffset += 20; - } - - for (const { tag, hole, rect, yOffset } of tagElements) { - const h2 = maxTagBboxHeight / 2; - const ly = y - 19.2 - yOffset; - rect.attr('class', 'tag-label-bkg').attr( - 'points', - ` - ${pos - maxTagBboxWidth / 2 - px / 2},${ly + py} - ${pos - maxTagBboxWidth / 2 - px / 2},${ly - py} - ${posWithOffset - maxTagBboxWidth / 2 - px},${ly - h2 - py} - ${posWithOffset + maxTagBboxWidth / 2 + px},${ly - h2 - py} - ${posWithOffset + maxTagBboxWidth / 2 + px},${ly + h2 + py} - ${posWithOffset - maxTagBboxWidth / 2 - px},${ly + h2 + py}` - ); - - hole - .attr('cy', ly) - .attr('cx', pos - maxTagBboxWidth / 2 + px / 2) - .attr('r', 1.5) - .attr('class', 'tag-hole'); - - if (dir === 'TB' || dir === 'BT') { - const yOrigin = pos + yOffset; - - rect - .attr('class', 'tag-label-bkg') - .attr( - 'points', - ` - ${x},${yOrigin + py} - ${x},${yOrigin - py} - ${x + layoutOffset},${yOrigin - h2 - py} - ${x + layoutOffset + maxTagBboxWidth + px},${yOrigin - h2 - py} - ${x + layoutOffset + maxTagBboxWidth + px},${yOrigin + h2 + py} - ${x + layoutOffset},${yOrigin + h2 + py}` - ) - .attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); - hole - .attr('cx', x + px / 2) - .attr('cy', yOrigin) - .attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); - tag - .attr('x', x + 5) - .attr('y', yOrigin + 3) - .attr('transform', 'translate(14,14) rotate(45, ' + x + ',' + pos + ')'); - } - } - } - } - pos = dir === 'BT' && isParallelCommits ? pos + commitStep : pos + commitStep + layoutOffset; - if (pos > maxPos) { - maxPos = pos; - } - }); -}; - -/** - * Detect if there are commits - * between commitA's x-position - * and commitB's x-position on the - * same branch as commitA, where - * commitA isn't main - * - * @param {any} commitA - * @param {any} commitB - * @param p1 - * @param p2 - * @param {CommitMap} allCommits - * @returns {boolean} - * If there are commits between - * commitA's x-position - * and commitB's x-position - * on the source branch, where - * source branch is not main - * return true - */ -const shouldRerouteArrow = (commitA, commitB, p1, p2, allCommits) => { - const commitBIsFurthest = dir === 'TB' || dir === 'BT' ? p1.x < p2.x : p1.y < p2.y; - 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 [...allCommits.values()].some((commitX) => { - return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX); - }); -}; - -/** - * This function find a lane in the y-axis that is not overlapping with any other lanes. This is - * used for drawing the lines between commits. - * - * @param {any} y1 - * @param {any} y2 - * @param {any} depth - * @returns {number} Y value between y1 and y2 - */ -const findLane = (y1, y2, depth = 0) => { - const candidate = y1 + Math.abs(y1 - y2) / 2; - if (depth > 5) { - return candidate; - } - - let ok = lanes.every((lane) => Math.abs(lane - candidate) >= 10); - if (ok) { - lanes.push(candidate); - return candidate; - } - const diff = Math.abs(y1 - y2); - return findLane(y1, y2 - diff / 5, depth + 1); -}; - -/** - * Draw the lines between the commits. They were arrows initially. - * - * @param {any} svg - * @param {any} commitA - * @param {any} commitB - * @param {CommitMap} allCommits - */ -const drawArrow = (svg, commitA, commitB, allCommits) => { - 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); - - // Lower-right quadrant logic; top-left is 0,0 - - let arc = ''; - let arc2 = ''; - let radius = 0; - let offset = 0; - let colorClassNum = branchPos.get(commitB.branch).index; - if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - colorClassNum = branchPos.get(commitA.branch).index; - } - - let lineDef; - if (arrowNeedsRerouting) { - arc = 'A 10 10, 0, 0, 0,'; - arc2 = 'A 10 10, 0, 0, 1,'; - radius = 10; - offset = 10; - - const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y); - const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x); - - if (dir === 'TB') { - if (p1.x < p2.x) { - // Source commit is on branch position left of destination commit - // so render arrow rightward with colour of destination branch - 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}`; - } else { - // Source commit is on branch position right of destination commit - // so render arrow leftward with colour of source branch - 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}`; - } - } else if (dir === 'BT') { - if (p1.x < p2.x) { - // Source commit is on branch position left of destination commit - // so render arrow rightward with colour of destination branch - 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}`; - } else { - // Source commit is on branch position right of destination commit - // so render arrow leftward with colour of source branch - 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}`; - } - } else { - if (p1.y < p2.y) { - // Source commit is on branch positioned above destination commit - // so render arrow downward with colour of destination branch - lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${ - p1.x + offset - } ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`; - } else { - // Source commit is on branch positioned below destination commit - // so render arrow upward with colour of source branch - 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}`; - } - } - } else { - arc = 'A 20 20, 0, 0, 0,'; - arc2 = 'A 20 20, 0, 0, 1,'; - radius = 20; - offset = 20; - - if (dir === 'TB') { - if (p1.x < p2.x) { - if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${ - p2.y - } L ${p2.x} ${p2.y}`; - } else { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${ - p1.y + offset - } L ${p2.x} ${p2.y}`; - } - } - if (p1.x > p2.x) { - arc = 'A 20 20, 0, 0, 0,'; - arc2 = 'A 20 20, 0, 0, 1,'; - radius = 20; - offset = 20; - if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${ - p2.y - } L ${p2.x} ${p2.y}`; - } else { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${ - p1.y + offset - } L ${p2.x} ${p2.y}`; - } - } - - if (p1.x === p2.x) { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; - } - } else if (dir === 'BT') { - if (p1.x < p2.x) { - if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${ - p2.y - } L ${p2.x} ${p2.y}`; - } else { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ - p1.y - offset - } L ${p2.x} ${p2.y}`; - } - } - if (p1.x > p2.x) { - arc = 'A 20 20, 0, 0, 0,'; - arc2 = 'A 20 20, 0, 0, 1,'; - radius = 20; - offset = 20; - - if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc} ${p1.x - offset} ${ - p2.y - } L ${p2.x} ${p2.y}`; - } else { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ - p1.y - offset - } L ${p2.x} ${p2.y}`; - } - } - - if (p1.x === p2.x) { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; - } - } else { - if (p1.y < p2.y) { - if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${ - p1.y + offset - } L ${p2.x} ${p2.y}`; - } else { - lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${ - p2.y - } L ${p2.x} ${p2.y}`; - } - } - if (p1.y > p2.y) { - if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ - p1.y - offset - } L ${p2.x} ${p2.y}`; - } else { - lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${ - p2.y - } L ${p2.x} ${p2.y}`; - } - } - - if (p1.y === p2.y) { - lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; - } - } - } - svg - .append('path') - .attr('d', lineDef) - .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) => { - const commit = commits.get(key); - if (commit.parents && commit.parents.length > 0) { - commit.parents.forEach((parent) => { - drawArrow(gArrows, commits.get(parent), commit, commits); - }); - } - }); -}; - -/** - * Adds the branches and the branches' labels to the svg. - * - * @param svg - * @param branches - */ -const drawBranches = (svg, branches) => { - const gitGraphConfig = getConfig().gitGraph; - const g = svg.append('g'); - branches.forEach((branch, index) => { - const adjustIndexForTheme = index % THEME_COLOR_LIMIT; - - const pos = branchPos.get(branch.name).pos; - const line = g.append('line'); - line.attr('x1', 0); - line.attr('y1', pos); - line.attr('x2', maxPos); - line.attr('y2', pos); - line.attr('class', 'branch branch' + adjustIndexForTheme); - - if (dir === 'TB') { - line.attr('y1', defaultPos); - line.attr('x1', pos); - line.attr('y2', maxPos); - line.attr('x2', pos); - } else if (dir === 'BT') { - line.attr('y1', maxPos); - line.attr('x1', pos); - line.attr('y2', defaultPos); - line.attr('x2', pos); - } - lanes.push(pos); - - let name = branch.name; - - // Create the actual text element - const labelElement = drawText(name); - // Create outer g, edgeLabel, this will be positioned after graph layout - const bkg = g.insert('rect'); - const branchLabel = g.insert('g').attr('class', 'branchLabel'); - - // Create inner g, label, this will be positioned now for centering the text - const label = branchLabel.insert('g').attr('class', 'label branch-label' + adjustIndexForTheme); - label.node().appendChild(labelElement); - let bbox = labelElement.getBBox(); - bkg - .attr('class', 'branchLabelBkg label' + adjustIndexForTheme) - .attr('rx', 4) - .attr('ry', 4) - .attr('x', -bbox.width - 4 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) - .attr('y', -bbox.height / 2 + 8) - .attr('width', bbox.width + 18) - .attr('height', bbox.height + 4); - label.attr( - 'transform', - 'translate(' + - (-bbox.width - 14 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + - ', ' + - (pos - bbox.height / 2 - 1) + - ')' - ); - if (dir === 'TB') { - bkg.attr('x', pos - bbox.width / 2 - 10).attr('y', 0); - label.attr('transform', 'translate(' + (pos - bbox.width / 2 - 5) + ', ' + 0 + ')'); - } else if (dir === 'BT') { - bkg.attr('x', pos - bbox.width / 2 - 10).attr('y', maxPos); - label.attr('transform', 'translate(' + (pos - bbox.width / 2 - 5) + ', ' + maxPos + ')'); - } else { - bkg.attr('transform', 'translate(' + -19 + ', ' + (pos - bbox.height / 2) + ')'); - } - }); -}; - -/** - * @param txt - * @param id - * @param ver - * @param diagObj - */ -export const draw = function (txt, id, ver, diagObj) { - clear(); - const conf = getConfig(); - const gitGraphConfig = conf.gitGraph; - // try { - log.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver); - - allCommitsDict = diagObj.db.getCommits(); - const branches = diagObj.db.getBranchesAsObjArray(); - dir = diagObj.db.getDirection(); - const diagram = select(`[id="${id}"]`); - // Position branches - let pos = 0; - branches.forEach((branch, index) => { - const labelElement = drawText(branch.name); - const g = diagram.append('g'); - const branchLabel = g.insert('g').attr('class', 'branchLabel'); - const label = branchLabel.insert('g').attr('class', 'label branch-label'); - label.node().appendChild(labelElement); - let bbox = labelElement.getBBox(); - - branchPos.set(branch.name, { pos, index }); - pos += - 50 + - (gitGraphConfig.rotateCommitLabel ? 40 : 0) + - (dir === 'TB' || dir === 'BT' ? bbox.width / 2 : 0); - label.remove(); - branchLabel.remove(); - g.remove(); - }); - - drawCommits(diagram, allCommitsDict, false); - if (gitGraphConfig.showBranches) { - drawBranches(diagram, branches); - } - drawArrows(diagram, allCommitsDict); - drawCommits(diagram, allCommitsDict, true); - utils.insertTitle( - diagram, - 'gitTitleText', - gitGraphConfig.titleTopMargin, - diagObj.db.getDiagramTitle() - ); - - // Setup the view box and size of the svg element - setupGraphViewbox( - undefined, - diagram, - gitGraphConfig.diagramPadding, - gitGraphConfig.useMaxWidth ?? conf.useMaxWidth - ); -}; - -export default { - draw, -}; diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts new file mode 100644 index 000000000..ec9a39f2a --- /dev/null +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -0,0 +1,968 @@ +import { select } from 'd3'; +import { getConfig, setupGraphViewbox } from '../../diagram-api/diagramAPI.js'; +import { log } from '../../logger.js'; +import utils from '../../utils.js'; +import type { DrawDefinition } from '../../diagram-api/types.js'; +import type d3 from 'd3'; +import type { CommitType, Commit, GitGraphDB, DiagramOrientation } from './gitGraphTypes.js'; +import type { GitGraphDiagramConfig } from '../../config.type.js'; + +let allCommitsDict = new Map(); + +const commitType: CommitType = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4, +}; + +const THEME_COLOR_LIMIT = 8; + +interface BranchPosition { + pos: number; + index: number; +} + +interface CommitPosition { + x: number; + y: number; +} + +const branchPos = new Map(); +const commitPos = new Map(); +let lanes: number[] = []; +let maxPos = 0; +let dir: DiagramOrientation = 'LR'; +const defaultPos = 30; + +const clear = () => { + branchPos.clear(); + commitPos.clear(); + allCommitsDict.clear(); + maxPos = 0; + lanes = []; + dir = 'LR'; +}; + +const drawText = (txt: string | string[]) => { + const svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text'); + const rows = typeof txt === 'string' ? txt.split(/\\n|\n|/gi) : txt; + + rows.forEach((row) => { + const tspan = document.createElementNS('http://www.w3.org/2000/svg', 'tspan'); + tspan.setAttributeNS('http://www.w3.org/XML/1998/namespace', 'xml:space', 'preserve'); + tspan.setAttribute('dy', '1em'); + tspan.setAttribute('x', '0'); + tspan.setAttribute('class', 'row'); + tspan.textContent = row.trim(); + svgLabel.appendChild(tspan); + }); + + return svgLabel; +}; + +const findClosestParent = (parents: string[], useBTLogic = false): string | undefined => { + let closestParent: string | undefined; + let comparisonFunc; + let targetPosition: number; + + if (dir === 'BT' || useBTLogic) { + comparisonFunc = (a: number, b: number) => a <= b; + targetPosition = Infinity; + } else { + comparisonFunc = (a: number, b: number) => a >= b; + targetPosition = 0; + } + + parents.forEach((parent) => { + const parentPosition = + dir === 'TB' || dir == 'BT' || useBTLogic + ? commitPos.get(parent)?.y + : commitPos.get(parent)?.x; + + if (parentPosition !== undefined && comparisonFunc(parentPosition, targetPosition)) { + closestParent = parent; + targetPosition = parentPosition; + } + }); + + return closestParent; +}; + +const setParallelBTPos = ( + sortedKeys: string[], + commits: Map, + defaultPos: number, + commitStep: number, + layoutOffset: number +) => { + let curPos = defaultPos; + let maxPosition = defaultPos; + const roots: Commit[] = []; + + sortedKeys.forEach((key) => { + const commit = commits.get(key); + if (!commit) { + throw new Error(`Commit not found for key ${key}`); + } + + if (hasParents(commit)) { + curPos = calculateCommitPosition(commit, commitStep, maxPosition); + maxPosition = Math.max(curPos, maxPosition); + } else { + roots.push(commit); + } + setCommitPosition(commit, curPos, layoutOffset); + }); + + curPos = maxPosition; + roots.forEach((commit) => { + setRootPosition(commit, curPos, defaultPos); + }); +}; + +const hasParents = (commit: Commit): boolean => commit.parents?.length > 0; + +const findClosestParentPos = (commit: Commit): number => { + const closestParent = findClosestParent(commit.parents.filter((p) => p !== null) as string[]); + if (!closestParent) { + throw new Error(`Closest parent not found for commit ${commit.id}`); + } + + const closestParentPos = commitPos.get(closestParent)?.y; + if (closestParentPos === undefined) { + throw new Error(`Closest parent position not found for commit ${commit.id}`); + } + return closestParentPos; +}; + +const calculateCommitPosition = (commit: Commit, commitStep: number): number => { + const closestParentPos = findClosestParentPos(commit); + return closestParentPos + commitStep; +}; + +const setCommitPosition = (commit: Commit, curPos: number, layoutOffset: number) => { + const branch = branchPos.get(commit.branch); + if (!branch) { + throw new Error(`Branch not found for commit ${commit.id}`); + } + + const x = branch.pos; + const y = curPos + layoutOffset; + commitPos.set(commit.id, { x, y }); +}; + +const setRootPosition = (commit: Commit, curPos: number, defaultPos: number) => { + const branch = branchPos.get(commit.branch); + if (!branch) { + throw new Error(`Branch not found for commit ${commit.id}`); + } + + const y = curPos + defaultPos; + const x = branch.pos; + commitPos.set(commit.id, { x, y }); +}; + +const drawCommitBullet = ( + gBullets: d3.Selection, + commit: Commit, + x: number, + y: number, + typeClass: string, + branchIndex: number, + commitSymbolType: number +) => { + if (commitSymbolType === commitType.HIGHLIGHT) { + gBullets + .append('rect') + .attr('x', x - 10) + .attr('y', y - 10) + .attr('width', 20) + .attr('height', 20) + .attr( + 'class', + `commit ${commit.id} commit-highlights${branchIndex % THEME_COLOR_LIMIT} ${typeClass}-outer` + ); + gBullets + .append('rect') + .attr('x', x - 6) + .attr('y', y - 6) + .attr('width', 12) + .attr('height', 12) + .attr( + 'class', + `commit ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT} ${typeClass}-inner` + ); + } else if (commitSymbolType === commitType.CHERRY_PICK) { + gBullets + .append('circle') + .attr('cx', x) + .attr('cy', y) + .attr('r', 10) + .attr('class', `commit ${commit.id} ${typeClass}`); + gBullets + .append('circle') + .attr('cx', x - 3) + .attr('cy', y + 2) + .attr('r', 2.75) + .attr('fill', '#fff') + .attr('class', `commit ${commit.id} ${typeClass}`); + gBullets + .append('circle') + .attr('cx', x + 3) + .attr('cy', y + 2) + .attr('r', 2.75) + .attr('fill', '#fff') + .attr('class', `commit ${commit.id} ${typeClass}`); + gBullets + .append('line') + .attr('x1', x + 3) + .attr('y1', y + 1) + .attr('x2', x) + .attr('y2', y - 5) + .attr('stroke', '#fff') + .attr('class', `commit ${commit.id} ${typeClass}`); + gBullets + .append('line') + .attr('x1', x - 3) + .attr('y1', y + 1) + .attr('x2', x) + .attr('y2', y - 5) + .attr('stroke', '#fff') + .attr('class', `commit ${commit.id} ${typeClass}`); + } else { + const circle = gBullets.append('circle'); + circle.attr('cx', x); + circle.attr('cy', y); + circle.attr('r', commit.type === commitType.MERGE ? 9 : 10); + circle.attr('class', `commit ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); + if (commit.type === commitType.MERGE) { + const circle2 = gBullets.append('circle'); + circle2.attr('cx', x); + circle2.attr('cy', y); + circle2.attr('r', 6); + circle2.attr( + 'class', + `commit ${typeClass} ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}` + ); + } + if (commitSymbolType === commitType.REVERSE) { + const cross = gBullets.append('path'); + cross + .attr('d', `M ${x - 5},${y - 5}L${x + 5},${y + 5}M${x - 5},${y + 5}L${x + 5},${y - 5}`) + .attr('class', `commit ${typeClass} ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); + } + } +}; + +const drawCommitLabel = ( + gLabels: d3.Selection, + commit: Commit, + x: number, + y: number, + pos: number, + posWithOffset: number, + gitGraphConfig: GitGraphDiagramConfig +) => { + if ( + commit.type !== commitType.CHERRY_PICK && + ((commit.customId && commit.type === commitType.MERGE) || commit.type !== commitType.MERGE) && + gitGraphConfig.showCommitLabel + ) { + const wrapper = gLabels.append('g'); + const labelBkg = wrapper.insert('rect').attr('class', 'commit-label-bkg'); + const text = wrapper + .append('text') + .attr('x', x) + .attr('y', y + 25) + .attr('class', 'commit-label') + .text(commit.id); + const bbox = text.node()?.getBBox(); + + if (bbox) { + labelBkg + .attr('x', posWithOffset - bbox.width / 2 - 2) + .attr('y', y + 13.5) + .attr('width', bbox.width + 4) + .attr('height', bbox.height + 4); + + if (dir === 'TB' || dir === 'BT') { + labelBkg.attr('x', x - (bbox.width + 4)).attr('y', y - 12); + text.attr('x', x - (bbox.width + 2)).attr('y', y + bbox.height - 12); + } + + if (gitGraphConfig.rotateCommitLabel) { + if (dir === 'TB' || dir === 'BT') { + text.attr('transform', 'rotate(' + -45 + ', ' + x + ', ' + y + ')'); + labelBkg.attr('transform', 'rotate(' + -45 + ', ' + x + ', ' + y + ')'); + } else { + const r_x = -7.5 - ((bbox.width + 10) / 25) * 9.5; + const r_y = 10 + (bbox.width / 25) * 8.5; + wrapper.attr( + 'transform', + 'translate(' + r_x + ', ' + r_y + ') rotate(' + -45 + ', ' + pos + ', ' + y + ')' + ); + } + } + } + } +}; + +const drawCommitTags = ( + gLabels: d3.Selection, + commit: Commit, + x: number, + y: number, + pos: number, + posWithOffset: number, + layoutOffset: number +) => { + if (commit.tags.length > 0) { + let yOffset = 0; + let maxTagBboxWidth = 0; + let maxTagBboxHeight = 0; + const tagElements = []; + + for (const tagValue of commit.tags.reverse()) { + const rect = gLabels.insert('polygon'); + const hole = gLabels.append('circle'); + const tag = gLabels + .append('text') + .attr('y', y - 16 - yOffset) + .attr('class', 'tag-label') + .text(tagValue); + const tagBbox = tag.node()?.getBBox(); + if (!tagBbox) { + throw new Error('Tag bbox not found'); + } + maxTagBboxWidth = Math.max(maxTagBboxWidth, tagBbox.width); + maxTagBboxHeight = Math.max(maxTagBboxHeight, tagBbox.height); + + tag.attr('x', posWithOffset - tagBbox.width / 2); + + tagElements.push({ + tag, + hole, + rect, + yOffset, + }); + + yOffset += 20; + } + + for (const { tag, hole, rect, yOffset } of tagElements) { + const h2 = maxTagBboxHeight / 2; + const ly = y - 19.2 - yOffset; + rect.attr('class', 'tag-label-bkg').attr( + 'points', + ` + ${pos - maxTagBboxWidth / 2 - 2},${ly + 2} + ${pos - maxTagBboxWidth / 2 - 2},${ly - 2} + ${posWithOffset - maxTagBboxWidth / 2 - 4},${ly - h2 - 2} + ${posWithOffset + maxTagBboxWidth / 2 + 4},${ly - h2 - 2} + ${posWithOffset + maxTagBboxWidth / 2 + 4},${ly + h2 + 2} + ${posWithOffset - maxTagBboxWidth / 2 - 4},${ly + h2 + 2}` + ); + + hole + .attr('cy', ly) + .attr('cx', pos - maxTagBboxWidth / 2 + 2) + .attr('r', 1.5) + .attr('class', 'tag-hole'); + + if (dir === 'TB' || dir === 'BT') { + const yOrigin = pos + yOffset; + + rect + .attr('class', 'tag-label-bkg') + .attr( + 'points', + ` + ${x},${yOrigin + 2} + ${x},${yOrigin - 2} + ${x + layoutOffset},${yOrigin - h2 - 2} + ${x + layoutOffset + maxTagBboxWidth + 4},${yOrigin - h2 - 2} + ${x + layoutOffset + maxTagBboxWidth + 4},${yOrigin + h2 + 2} + ${x + layoutOffset},${yOrigin + h2 + 2}` + ) + .attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); + hole + .attr('cx', x + 2) + .attr('cy', yOrigin) + .attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); + tag + .attr('x', x + 5) + .attr('y', yOrigin + 3) + .attr('transform', 'translate(14,14) rotate(45, ' + x + ',' + pos + ')'); + } + } + } +}; + +const getCommitClassType = (commit: Commit): string => { + const commitSymbolType = commit.customType ?? commit.type; + switch (commitSymbolType) { + case commitType.NORMAL: + return 'commit-normal'; + case commitType.REVERSE: + return 'commit-reverse'; + case commitType.HIGHLIGHT: + return 'commit-highlight'; + case commitType.MERGE: + return 'commit-merge'; + case commitType.CHERRY_PICK: + return 'commit-cherry-pick'; + default: + return 'commit-normal'; + } +}; + +const calculatePosition = ( + commit: Commit, + dir: string, + isParallelCommits: boolean, + pos: number, + commitStep: number, + layoutOffset: number, + commitPos: Map +): number => { + const defaultCommitPosition = { x: 0, y: defaultPos }; // Default position if commit is not found + + if (isParallelCommits) { + if (commit.parents.length > 0) { + const closestParent = + dir === 'BT' ? findClosestParent(commit.parents) : findClosestParent(commit.parents); + + // Check if closestParent is defined + if (closestParent) { + const parentPosition = commitPos.get(closestParent) ?? defaultCommitPosition; + + if (dir === 'TB') { + return parentPosition.y + commitStep; + } else if (dir === 'BT') { + const currentPosition = commitPos.get(commit.id) ?? defaultCommitPosition; + return currentPosition.y - commitStep; + } else { + return parentPosition.x + commitStep; + } + } + } else { + if (dir === 'TB') { + return defaultPos; + } else if (dir === 'BT') { + const currentPosition = commitPos.get(commit.id) ?? defaultCommitPosition; + return currentPosition.y - commitStep; + } else { + return 0; + } + } + } + + return dir === 'TB' && isParallelCommits ? pos : pos + layoutOffset; +}; + +const drawCommits = ( + svg: d3.Selection, + commits: Map, + modifyGraph: boolean +) => { + const gitGraphConfig = getConfig().gitGraph; + if (!gitGraphConfig) { + throw new Error('GitGraph config not found'); + } + const gBullets = svg.append('g').attr('class', 'commit-bullets'); + const gLabels = svg.append('g').attr('class', 'commit-labels'); + let pos = dir === 'TB' || dir === 'BT' ? defaultPos : 0; + const keys = [...commits.keys()]; + const isParallelCommits = gitGraphConfig?.parallelCommits ?? false; + const layoutOffset = 10; + const commitStep = 40; + + const sortKeys = (a: string, b: string) => { + const seqA = commits.get(a)?.seq; + const seqB = commits.get(b)?.seq; + return seqA !== undefined && seqB !== undefined ? seqA - seqB : 0; + }; + + let sortedKeys = keys.sort(sortKeys); + + if (dir === 'BT' && !isParallelCommits) { + sortedKeys = sortedKeys.reverse(); + } + + if (dir === 'BT' && isParallelCommits) { + setParallelBTPos(sortedKeys, commits, pos, commitStep, layoutOffset); + sortedKeys = sortedKeys.reverse(); + } + + sortedKeys.forEach((key) => { + const commit = commits.get(key); + if (!commit) { + throw new Error(`Commit not found for key ${key}`); + } else { + pos = calculatePosition( + commit, + dir, + isParallelCommits, + pos, + commitStep, + layoutOffset, + commitPos + ); + const posWithOffset = dir === 'BT' && isParallelCommits ? pos : pos + layoutOffset; + const y = dir === 'TB' || dir === 'BT' ? posWithOffset : branchPos.get(commit.branch)?.pos; + const x = dir === 'TB' || dir === 'BT' ? branchPos.get(commit.branch)?.pos : posWithOffset; + if (x === undefined || y === undefined) { + throw new Error(`Position were undefined for commit ${commit.id}`); + } + // Don't draw the commits now but calculate the positioning which is used by the branch lines etc. + if (modifyGraph) { + const typeClass = getCommitClassType(commit); + const commitSymbolType = commit.customType ?? commit.type; + const branchIndex = branchPos.get(commit.branch)?.index ?? 0; + drawCommitBullet(gBullets, commit, x, y, typeClass, branchIndex, commitSymbolType); + drawCommitLabel(gLabels, commit, x, y, pos, posWithOffset, gitGraphConfig); + drawCommitTags(gLabels, commit, x, y, pos, posWithOffset, layoutOffset); + } + if (dir === 'TB' || dir === 'BT') { + commitPos.set(commit.id, { x: x, y: posWithOffset }); + } else { + commitPos.set(commit.id, { x: posWithOffset, y: y }); + } + pos = dir === 'BT' && isParallelCommits ? pos + commitStep : pos + commitStep + layoutOffset; + if (pos > maxPos) { + maxPos = pos; + } + } + }); +}; + +const shouldRerouteArrow = ( + commitA: Commit, + commitB: Commit, + p1: CommitPosition, + p2: CommitPosition, + allCommits: Map +) => { + const commitBIsFurthest = dir === 'TB' || dir === 'BT' ? p1.x < p2.x : p1.y < p2.y; + const branchToGetCurve = commitBIsFurthest ? commitB.branch : commitA.branch; + const isOnBranchToGetCurve = (x: Commit) => x.branch === branchToGetCurve; + const isBetweenCommits = (x: Commit) => x.seq > commitA.seq && x.seq < commitB.seq; + return [...allCommits.values()].some((commitX) => { + return isBetweenCommits(commitX) && isOnBranchToGetCurve(commitX); + }); +}; + +const findLane = (y1: number, y2: number, depth = 0): number => { + const candidate = y1 + Math.abs(y1 - y2) / 2; + if (depth > 5) { + return candidate; + } + + const ok = lanes.every((lane) => Math.abs(lane - candidate) >= 10); + if (ok) { + lanes.push(candidate); + return candidate; + } + const diff = Math.abs(y1 - y2); + return findLane(y1, y2 - diff / 5, depth + 1); +}; + +const drawArrow = ( + svg: d3.Selection, + commitA: Commit, + commitB: Commit, + allCommits: Map +) => { + const p1 = commitPos.get(commitA.id); // arrowStart + const p2 = commitPos.get(commitB.id); // arrowEnd + // @ts-ignore: TODO Fix ts errors + const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits); + // log.debug('drawArrow', p1, p2, arrowNeedsRerouting, commitA.id, commitB.id); + + // Lower-right quadrant logic; top-left is 0,0 + + let arc = ''; + let arc2 = ''; + let radius = 0; + let offset = 0; + // @ts-ignore: TODO Fix ts errors + let colorClassNum = branchPos.get(commitB.branch).index; + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + // @ts-ignore: TODO Fix ts errors + colorClassNum = branchPos.get(commitA.branch).index; + } + + let lineDef; + if (arrowNeedsRerouting) { + arc = 'A 10 10, 0, 0, 0,'; + arc2 = 'A 10 10, 0, 0, 1,'; + radius = 10; + offset = 10; + // @ts-ignore: TODO Fix ts errors + const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y); + // @ts-ignore: TODO Fix ts errors + const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x); + + if (dir === 'TB') { + // @ts-ignore: TODO Fix ts errors + if (p1.x < p2.x) { + // Source commit is on branch position left of destination commit + // so render arrow rightward with colour of destination branch + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${ + // @ts-ignore: TODO Fix ts errors + p1.y + offset + // @ts-ignore: TODO Fix ts errors + } L ${lineX} ${p2.y - radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`; + } else { + // Source commit is on branch position right of destination commit + // so render arrow leftward with colour of source branch + // @ts-ignore: TODO Fix ts errors + colorClassNum = branchPos.get(commitA.branch).index; + // @ts-ignore: TODO Fix ts errors + 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}`; + } + } else if (dir === 'BT') { + // @ts-ignore: TODO Fix ts errors + if (p1.x < p2.x) { + // Source commit is on branch position left of destination commit + // so render arrow rightward with colour of destination branch + // @ts-ignore: TODO Fix ts errors + 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}`; + } else { + // Source commit is on branch position right of destination commit + // so render arrow leftward with colour of source branch + // @ts-ignore: TODO Fix ts errors + colorClassNum = branchPos.get(commitA.branch).index; + // @ts-ignore: TODO Fix ts errors + 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}`; + } + } else { + // @ts-ignore: TODO Fix ts errors + if (p1.y < p2.y) { + // Source commit is on branch positioned above destination commit + // so render arrow downward with colour of destination branch + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${ + // @ts-ignore: TODO Fix ts errors + p1.x + offset + // @ts-ignore: TODO Fix ts errors + } ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`; + } else { + // Source commit is on branch positioned below destination commit + // so render arrow upward with colour of source branch + // @ts-ignore: TODO Fix ts errors + colorClassNum = branchPos.get(commitA.branch).index; + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${ + // @ts-ignore: TODO Fix ts errors + p1.x + offset + // @ts-ignore: TODO Fix ts errors + } ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`; + } + } + } else { + arc = 'A 20 20, 0, 0, 0,'; + arc2 = 'A 20 20, 0, 0, 1,'; + radius = 20; + offset = 20; + + if (dir === 'TB') { + // @ts-ignore: TODO Fix ts errors + if (p1.x < p2.x) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${ + // @ts-ignore: TODO Fix ts errors + p2.y + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } else { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${ + // @ts-ignore: TODO Fix ts errors + p1.y + offset + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } + } + // @ts-ignore: TODO Fix ts errors + if (p1.x > p2.x) { + arc = 'A 20 20, 0, 0, 0,'; + arc2 = 'A 20 20, 0, 0, 1,'; + radius = 20; + offset = 20; + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${ + // @ts-ignore: TODO Fix ts errors + p2.y + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } else { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${ + // @ts-ignore: TODO Fix ts errors + p1.y + offset + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } + } + // @ts-ignore: TODO Fix ts errors + if (p1.x === p2.x) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } else if (dir === 'BT') { + // @ts-ignore: TODO Fix ts errors + if (p1.x < p2.x) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${ + // @ts-ignore: TODO Fix ts errors + p2.y + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } else { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ + // @ts-ignore: TODO Fix ts errors + p1.y - offset + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } + } + // @ts-ignore: TODO Fix ts errors + if (p1.x > p2.x) { + arc = 'A 20 20, 0, 0, 0,'; + arc2 = 'A 20 20, 0, 0, 1,'; + radius = 20; + offset = 20; + + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc} ${p1.x - offset} ${ + // @ts-ignore: TODO Fix ts errors + p2.y + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } else { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ + // @ts-ignore: TODO Fix ts errors + p1.y - offset + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } + } + // @ts-ignore: TODO Fix ts errors + if (p1.x === p2.x) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } else { + // @ts-ignore: TODO Fix ts errors + if (p1.y < p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${ + // @ts-ignore: TODO Fix ts errors + p1.y + offset + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } else { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${ + // @ts-ignore: TODO Fix ts errors + p2.y + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } + } // @ts-ignore: TODO Fix ts errors + if (p1.y > p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ + // @ts-ignore: TODO Fix ts errors + p1.y - offset + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } else { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${ + // @ts-ignore: TODO Fix ts errors + p2.y + // @ts-ignore: TODO Fix ts errors + } L ${p2.x} ${p2.y}`; + } + } + // @ts-ignore: TODO Fix ts errors + if (p1.y === p2.y) { + // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; + } + } + } + svg + .append('path') + // @ts-ignore: TODO Fix ts errors + .attr('d', lineDef) + .attr('class', 'arrow arrow' + (colorClassNum % THEME_COLOR_LIMIT)); +}; + +const drawArrows = ( + svg: d3.Selection, + commits: Map +) => { + const gArrows = svg.append('g').attr('class', 'commit-arrows'); + [...commits.keys()].forEach((key) => { + const commit = commits.get(key); + // @ts-ignore: TODO Fix ts errors + if (commit.parents && commit.parents.length > 0) { + // @ts-ignore: TODO Fix ts errors + commit.parents.forEach((parent) => { + // @ts-ignore: TODO Fix ts errors + drawArrow(gArrows, commits.get(parent), commit, commits); + }); + } + }); +}; + +const drawBranches = ( + svg: d3.Selection, + branches: { name: string }[] +) => { + const gitGraphConfig = getConfig().gitGraph; + const g = svg.append('g'); + branches.forEach((branch, index) => { + // @ts-ignore: TODO Fix ts errors + const adjustIndexForTheme = index % THEME_COLOR_LIMIT; + // @ts-ignore: TODO Fix ts errors + const pos = branchPos.get(branch.name).pos; + const line = g.append('line'); + line.attr('x1', 0); + line.attr('y1', pos); + line.attr('x2', maxPos); + line.attr('y2', pos); + line.attr('class', 'branch branch' + adjustIndexForTheme); + + if (dir === 'TB') { + line.attr('y1', defaultPos); + line.attr('x1', pos); + line.attr('y2', maxPos); + line.attr('x2', pos); + } else if (dir === 'BT') { + line.attr('y1', maxPos); + line.attr('x1', pos); + line.attr('y2', defaultPos); + line.attr('x2', pos); + } + lanes.push(pos); + + const name = branch.name; + + // Create the actual text element + const labelElement = drawText(name); + // Create outer g, edgeLabel, this will be positioned after graph layout + const bkg = g.insert('rect'); + const branchLabel = g.insert('g').attr('class', 'branchLabel'); + + // Create inner g, label, this will be positioned now for centering the text + const label = branchLabel.insert('g').attr('class', 'label branch-label' + adjustIndexForTheme); + // @ts-ignore: TODO Fix ts errors + label.node().appendChild(labelElement); + const bbox = labelElement.getBBox(); + bkg + .attr('class', 'branchLabelBkg label' + adjustIndexForTheme) + .attr('rx', 4) + .attr('ry', 4) + // @ts-ignore: TODO Fix ts errors + .attr('x', -bbox.width - 4 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + .attr('y', -bbox.height / 2 + 8) + .attr('width', bbox.width + 18) + .attr('height', bbox.height + 4); + label.attr( + 'transform', + 'translate(' + + // @ts-ignore: TODO Fix ts errors + (-bbox.width - 14 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + + ', ' + + (pos - bbox.height / 2 - 1) + + ')' + ); + if (dir === 'TB') { + bkg.attr('x', pos - bbox.width / 2 - 10).attr('y', 0); + label.attr('transform', 'translate(' + (pos - bbox.width / 2 - 5) + ', ' + 0 + ')'); + } else if (dir === 'BT') { + bkg.attr('x', pos - bbox.width / 2 - 10).attr('y', maxPos); + label.attr('transform', 'translate(' + (pos - bbox.width / 2 - 5) + ', ' + maxPos + ')'); + } else { + bkg.attr('transform', 'translate(' + -19 + ', ' + (pos - bbox.height / 2) + ')'); + } + }); +}; + +export const draw: DrawDefinition = function (txt, id, ver, diagObj) { + clear(); + const conf = getConfig(); + const gitGraphConfig = conf.gitGraph; + // try { + log.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver); + const db = diagObj.db as GitGraphDB; + allCommitsDict = db.getCommits(); + const branches = db.getBranchesAsObjArray(); + dir = db.getDirection(); + const diagram = select(`[id="${id}"]`); + // Position branches + let pos = 0; + branches.forEach((branch, index) => { + const labelElement = drawText(branch.name); + const g = diagram.append('g'); + const branchLabel = g.insert('g').attr('class', 'branchLabel'); + const label = branchLabel.insert('g').attr('class', 'label branch-label'); + // @ts-ignore: TODO Fix ts errors + label.node().appendChild(labelElement); + const bbox = labelElement.getBBox(); + + branchPos.set(branch.name, { pos, index }); + pos += + 50 + + // @ts-ignore: TODO Fix ts errors + (gitGraphConfig.rotateCommitLabel ? 40 : 0) + + (dir === 'TB' || dir === 'BT' ? bbox.width / 2 : 0); + label.remove(); + branchLabel.remove(); + g.remove(); + }); + + drawCommits(diagram, allCommitsDict, false); + // @ts-ignore: TODO Fix ts errors + if (gitGraphConfig.showBranches) { + drawBranches(diagram, branches); + } + drawArrows(diagram, allCommitsDict); + drawCommits(diagram, allCommitsDict, true); + utils.insertTitle( + diagram, + 'gitTitleText', + // @ts-ignore: TODO Fix ts errors + gitGraphConfig.titleTopMargin, + db.getDiagramTitle() + ); + + // Setup the view box and size of the svg element + setupGraphViewbox( + undefined, + diagram, + // @ts-ignore: TODO Fix ts errors + gitGraphConfig.diagramPadding, + // @ts-ignore: TODO Fix ts errors + gitGraphConfig.useMaxWidth ?? conf.useMaxWidth + ); +}; + +export default { + draw, +}; diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index 29e2781a9..0e929666f 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -1,4 +1,13 @@ -export type CommitType = 'NORMAL' | 'REVERSE' | 'HIGHLIGHT' | 'MERGE' | 'CHERRY_PICK'; +import type { DiagramDB } from '../../diagram-api/types.js'; +import type { GitGraphDiagramConfig } from '../../config.type.js'; + +export interface CommitType { + NORMAL: number; + REVERSE: number; + HIGHLIGHT: number; + MERGE: number; + CHERRY_PICK: number; +} export interface Commit { id: string; @@ -16,6 +25,11 @@ export interface GitGraph { statements: Statement[]; } +export interface Position { + x: number; + y: number; +} + export type Statement = CommitAst | BranchAst | MergeAst | CheckoutAst | CherryPickingAst; export interface CommitAst { @@ -52,4 +66,47 @@ export interface CherryPickingAst { parent: string; } +export interface GitGraphDB extends DiagramDB { + // config + getConfig: () => GitGraphDiagramConfig | undefined; + + // common db + clear: () => void; + setDiagramTitle: (title: string) => void; + getDiagramTitle: () => string; + setAccTitle: (title: string) => void; + getAccTitle: () => string; + setAccDescription: (description: string) => void; + getAccDescription: () => string; + + // diagram db + commitType: CommitType; + setDirection: (direction: DiagramOrientation) => void; + getDirection: () => DiagramOrientation; + setOptions: (options: string) => void; + getOptions: () => string; + commit: (msg: string, id: string, type: number, tags?: string[] | undefined) => void; + branch: (name: string, order: number) => void; + merge: ( + otherBranch: string, + customId?: string, + overrideType?: number, + customTags?: string[] + ) => void; + cherryPick: ( + sourceId: string, + targetId: string, + tags: string[] | undefined, + parentCommitId: string + ) => void; + checkout: (branch: string) => void; + prettyPrint: () => void; + getBranchesAsObjArray: () => { name: string }[]; + getBranches: () => Map; + getCommits: () => Map; + getCommitsArray: () => Commit[]; + getCurrentBranch: () => string; + getHead: () => Commit | null; +} + export type DiagramOrientation = 'LR' | 'TB'; diff --git a/packages/mermaid/tsconfig.json b/packages/mermaid/tsconfig.json index f4451225e..66c6600f6 100644 --- a/packages/mermaid/tsconfig.json +++ b/packages/mermaid/tsconfig.json @@ -5,5 +5,10 @@ "outDir": "./dist", "types": ["vitest/importMeta", "vitest/globals"] }, - "include": ["./src/**/*.ts", "./package.json", "src/diagrams/gantt/ganttDb.js"] + "include": [ + "./src/**/*.ts", + "./package.json", + "src/diagrams/gantt/ganttDb.js", + "src/diagrams/git/gitGraphRenderer.js" + ] } From 2218929416b905a78c465041c1b0f73b4ad9594f Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Thu, 8 Aug 2024 19:49:09 -0400 Subject: [PATCH 031/124] fixed types in gitGraphTypes --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 4 ++-- packages/mermaid/src/diagrams/git/gitGraphTypes.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 53c361e3e..1a40450d9 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -213,7 +213,7 @@ export const merge = ( id: customId ? customId : state.records.seq + '-' + getID(), message: `merged branch ${otherBranch} into ${state.records.currBranch}`, seq: state.records.seq++, - parents: [state.records.head == null ? null : state.records.head.id, verifiedBranch], + parents: state.records.head == null ? [] : [state.records.head.id, verifiedBranch], branch: state.records.currBranch, type: commitType.MERGE, customType: overrideType, @@ -317,7 +317,7 @@ export const cherryPick = function ( id: state.records.seq + '-' + getID(), message: `cherry-picked ${sourceCommit?.message} into ${state.records.currBranch}`, seq: state.records.seq++, - parents: [state.records.head == null ? null : state.records.head.id, sourceCommit.id], + parents: state.records.head == null ? [] : [state.records.head.id, sourceCommit.id], branch: state.records.currBranch, type: commitType.CHERRY_PICK, tags: tags diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index 0e929666f..b473dd874 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -15,7 +15,7 @@ export interface Commit { seq: number; type: number; tags: string[]; - parents: (string | null)[]; + parents: string[]; branch: string; customType?: number; customId?: boolean; @@ -109,4 +109,4 @@ export interface GitGraphDB extends DiagramDB { getHead: () => Commit | null; } -export type DiagramOrientation = 'LR' | 'TB'; +export type DiagramOrientation = 'LR' | 'TB' | 'BT'; From a93b8324ad882f6ff085f02a2f550a5a7f2ed8a7 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 10 Aug 2024 06:08:57 -0400 Subject: [PATCH 032/124] made draw commit more readable, included more helper functions and interfaces, added in-source test suite to renderer --- .../src/diagrams/git/gitGraphRenderer.ts | 532 ++++++++++++------ 1 file changed, 373 insertions(+), 159 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index ec9a39f2a..3493fa995 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -9,6 +9,9 @@ import type { GitGraphDiagramConfig } from '../../config.type.js'; let allCommitsDict = new Map(); +const LAYOUT_OFFSET = 10; +const COMMIT_STEP = 40; + const commitType: CommitType = { NORMAL: 0, REVERSE: 1, @@ -29,6 +32,10 @@ interface CommitPosition { y: number; } +interface CommitPositionOffset extends CommitPosition { + posWithOffset: number; +} + const branchPos = new Map(); const commitPos = new Map(); let lanes: number[] = []; @@ -93,9 +100,7 @@ const findClosestParent = (parents: string[], useBTLogic = false): string | unde const setParallelBTPos = ( sortedKeys: string[], commits: Map, - defaultPos: number, - commitStep: number, - layoutOffset: number + defaultPos: number ) => { let curPos = defaultPos; let maxPosition = defaultPos; @@ -108,12 +113,12 @@ const setParallelBTPos = ( } if (hasParents(commit)) { - curPos = calculateCommitPosition(commit, commitStep, maxPosition); + curPos = calculateCommitPosition(commit); maxPosition = Math.max(curPos, maxPosition); } else { roots.push(commit); } - setCommitPosition(commit, curPos, layoutOffset); + setCommitPosition(commit, curPos); }); curPos = maxPosition; @@ -125,7 +130,7 @@ const setParallelBTPos = ( const hasParents = (commit: Commit): boolean => commit.parents?.length > 0; const findClosestParentPos = (commit: Commit): number => { - const closestParent = findClosestParent(commit.parents.filter((p) => p !== null) as string[]); + const closestParent = findClosestParent(commit.parents.filter((p) => p !== null)); if (!closestParent) { throw new Error(`Closest parent not found for commit ${commit.id}`); } @@ -137,19 +142,19 @@ const findClosestParentPos = (commit: Commit): number => { return closestParentPos; }; -const calculateCommitPosition = (commit: Commit, commitStep: number): number => { +const calculateCommitPosition = (commit: Commit): number => { const closestParentPos = findClosestParentPos(commit); - return closestParentPos + commitStep; + return closestParentPos + COMMIT_STEP; }; -const setCommitPosition = (commit: Commit, curPos: number, layoutOffset: number) => { +const setCommitPosition = (commit: Commit, curPos: number) => { const branch = branchPos.get(commit.branch); if (!branch) { throw new Error(`Branch not found for commit ${commit.id}`); } const x = branch.pos; - const y = curPos + layoutOffset; + const y = curPos + LAYOUT_OFFSET; commitPos.set(commit.id, { x, y }); }; @@ -167,8 +172,7 @@ const setRootPosition = (commit: Commit, curPos: number, defaultPos: number) => const drawCommitBullet = ( gBullets: d3.Selection, commit: Commit, - x: number, - y: number, + commitPosition: CommitPositionOffset, typeClass: string, branchIndex: number, commitSymbolType: number @@ -176,8 +180,8 @@ const drawCommitBullet = ( if (commitSymbolType === commitType.HIGHLIGHT) { gBullets .append('rect') - .attr('x', x - 10) - .attr('y', y - 10) + .attr('x', commitPosition.x - 10) + .attr('y', commitPosition.y - 10) .attr('width', 20) .attr('height', 20) .attr( @@ -186,8 +190,8 @@ const drawCommitBullet = ( ); gBullets .append('rect') - .attr('x', x - 6) - .attr('y', y - 6) + .attr('x', commitPosition.x - 6) + .attr('y', commitPosition.y - 6) .attr('width', 12) .attr('height', 12) .attr( @@ -197,50 +201,50 @@ const drawCommitBullet = ( } else if (commitSymbolType === commitType.CHERRY_PICK) { gBullets .append('circle') - .attr('cx', x) - .attr('cy', y) + .attr('cx', commitPosition.x) + .attr('cy', commitPosition.y) .attr('r', 10) .attr('class', `commit ${commit.id} ${typeClass}`); gBullets .append('circle') - .attr('cx', x - 3) - .attr('cy', y + 2) + .attr('cx', commitPosition.x - 3) + .attr('cy', commitPosition.y + 2) .attr('r', 2.75) .attr('fill', '#fff') .attr('class', `commit ${commit.id} ${typeClass}`); gBullets .append('circle') - .attr('cx', x + 3) - .attr('cy', y + 2) + .attr('cx', commitPosition.x + 3) + .attr('cy', commitPosition.y + 2) .attr('r', 2.75) .attr('fill', '#fff') .attr('class', `commit ${commit.id} ${typeClass}`); gBullets .append('line') - .attr('x1', x + 3) - .attr('y1', y + 1) - .attr('x2', x) - .attr('y2', y - 5) + .attr('x1', commitPosition.x + 3) + .attr('y1', commitPosition.y + 1) + .attr('x2', commitPosition.x) + .attr('y2', commitPosition.y - 5) .attr('stroke', '#fff') .attr('class', `commit ${commit.id} ${typeClass}`); gBullets .append('line') - .attr('x1', x - 3) - .attr('y1', y + 1) - .attr('x2', x) - .attr('y2', y - 5) + .attr('x1', commitPosition.x - 3) + .attr('y1', commitPosition.y + 1) + .attr('x2', commitPosition.x) + .attr('y2', commitPosition.y - 5) .attr('stroke', '#fff') .attr('class', `commit ${commit.id} ${typeClass}`); } else { const circle = gBullets.append('circle'); - circle.attr('cx', x); - circle.attr('cy', y); + circle.attr('cx', commitPosition.x); + circle.attr('cy', commitPosition.y); circle.attr('r', commit.type === commitType.MERGE ? 9 : 10); circle.attr('class', `commit ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); if (commit.type === commitType.MERGE) { const circle2 = gBullets.append('circle'); - circle2.attr('cx', x); - circle2.attr('cy', y); + circle2.attr('cx', commitPosition.x); + circle2.attr('cy', commitPosition.y); circle2.attr('r', 6); circle2.attr( 'class', @@ -250,7 +254,10 @@ const drawCommitBullet = ( if (commitSymbolType === commitType.REVERSE) { const cross = gBullets.append('path'); cross - .attr('d', `M ${x - 5},${y - 5}L${x + 5},${y + 5}M${x - 5},${y + 5}L${x + 5},${y - 5}`) + .attr( + 'd', + `M ${commitPosition.x - 5},${commitPosition.y - 5}L${commitPosition.x + 5},${commitPosition.y + 5}M${commitPosition.x - 5},${commitPosition.y + 5}L${commitPosition.x + 5},${commitPosition.y - 5}` + ) .attr('class', `commit ${typeClass} ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); } } @@ -259,10 +266,8 @@ const drawCommitBullet = ( const drawCommitLabel = ( gLabels: d3.Selection, commit: Commit, - x: number, - y: number, + commitPosition: CommitPositionOffset, pos: number, - posWithOffset: number, gitGraphConfig: GitGraphDiagramConfig ) => { if ( @@ -274,34 +279,52 @@ const drawCommitLabel = ( const labelBkg = wrapper.insert('rect').attr('class', 'commit-label-bkg'); const text = wrapper .append('text') - .attr('x', x) - .attr('y', y + 25) + .attr('x', commitPosition.x) + .attr('y', commitPosition.y + 25) .attr('class', 'commit-label') .text(commit.id); const bbox = text.node()?.getBBox(); if (bbox) { labelBkg - .attr('x', posWithOffset - bbox.width / 2 - 2) - .attr('y', y + 13.5) + .attr('x', commitPosition.posWithOffset - bbox.width / 2 - 2) + .attr('y', commitPosition.y + 13.5) .attr('width', bbox.width + 4) .attr('height', bbox.height + 4); if (dir === 'TB' || dir === 'BT') { - labelBkg.attr('x', x - (bbox.width + 4)).attr('y', y - 12); - text.attr('x', x - (bbox.width + 2)).attr('y', y + bbox.height - 12); + labelBkg.attr('x', commitPosition.x - (bbox.width + 4)).attr('y', commitPosition.y - 12); + text + .attr('x', commitPosition.x - (bbox.width + 2)) + .attr('y', commitPosition.y + bbox.height - 12); } if (gitGraphConfig.rotateCommitLabel) { if (dir === 'TB' || dir === 'BT') { - text.attr('transform', 'rotate(' + -45 + ', ' + x + ', ' + y + ')'); - labelBkg.attr('transform', 'rotate(' + -45 + ', ' + x + ', ' + y + ')'); + text.attr( + 'transform', + 'rotate(' + -45 + ', ' + commitPosition.x + ', ' + commitPosition.y + ')' + ); + labelBkg.attr( + 'transform', + 'rotate(' + -45 + ', ' + commitPosition.x + ', ' + commitPosition.y + ')' + ); } else { const r_x = -7.5 - ((bbox.width + 10) / 25) * 9.5; const r_y = 10 + (bbox.width / 25) * 8.5; wrapper.attr( 'transform', - 'translate(' + r_x + ', ' + r_y + ') rotate(' + -45 + ', ' + pos + ', ' + y + ')' + 'translate(' + + r_x + + ', ' + + r_y + + ') rotate(' + + -45 + + ', ' + + pos + + ', ' + + commitPosition.y + + ')' ); } } @@ -312,11 +335,8 @@ const drawCommitLabel = ( const drawCommitTags = ( gLabels: d3.Selection, commit: Commit, - x: number, - y: number, - pos: number, - posWithOffset: number, - layoutOffset: number + commitPosition: CommitPositionOffset, + pos: number ) => { if (commit.tags.length > 0) { let yOffset = 0; @@ -329,7 +349,7 @@ const drawCommitTags = ( const hole = gLabels.append('circle'); const tag = gLabels .append('text') - .attr('y', y - 16 - yOffset) + .attr('y', commitPosition.y - 16 - yOffset) .attr('class', 'tag-label') .text(tagValue); const tagBbox = tag.node()?.getBBox(); @@ -339,7 +359,7 @@ const drawCommitTags = ( maxTagBboxWidth = Math.max(maxTagBboxWidth, tagBbox.width); maxTagBboxHeight = Math.max(maxTagBboxHeight, tagBbox.height); - tag.attr('x', posWithOffset - tagBbox.width / 2); + tag.attr('x', commitPosition.posWithOffset - tagBbox.width / 2); tagElements.push({ tag, @@ -353,16 +373,16 @@ const drawCommitTags = ( for (const { tag, hole, rect, yOffset } of tagElements) { const h2 = maxTagBboxHeight / 2; - const ly = y - 19.2 - yOffset; + const ly = commitPosition.y - 19.2 - yOffset; rect.attr('class', 'tag-label-bkg').attr( 'points', ` ${pos - maxTagBboxWidth / 2 - 2},${ly + 2} ${pos - maxTagBboxWidth / 2 - 2},${ly - 2} - ${posWithOffset - maxTagBboxWidth / 2 - 4},${ly - h2 - 2} - ${posWithOffset + maxTagBboxWidth / 2 + 4},${ly - h2 - 2} - ${posWithOffset + maxTagBboxWidth / 2 + 4},${ly + h2 + 2} - ${posWithOffset - maxTagBboxWidth / 2 - 4},${ly + h2 + 2}` + ${commitPosition.posWithOffset - maxTagBboxWidth / 2 - 4},${ly - h2 - 2} + ${commitPosition.posWithOffset + maxTagBboxWidth / 2 + 4},${ly - h2 - 2} + ${commitPosition.posWithOffset + maxTagBboxWidth / 2 + 4},${ly + h2 + 2} + ${commitPosition.posWithOffset - maxTagBboxWidth / 2 - 4},${ly + h2 + 2}` ); hole @@ -379,22 +399,22 @@ const drawCommitTags = ( .attr( 'points', ` - ${x},${yOrigin + 2} - ${x},${yOrigin - 2} - ${x + layoutOffset},${yOrigin - h2 - 2} - ${x + layoutOffset + maxTagBboxWidth + 4},${yOrigin - h2 - 2} - ${x + layoutOffset + maxTagBboxWidth + 4},${yOrigin + h2 + 2} - ${x + layoutOffset},${yOrigin + h2 + 2}` + ${commitPosition.x},${yOrigin + 2} + ${commitPosition.x},${yOrigin - 2} + ${commitPosition.x + LAYOUT_OFFSET},${yOrigin - h2 - 2} + ${commitPosition.x + LAYOUT_OFFSET + maxTagBboxWidth + 4},${yOrigin - h2 - 2} + ${commitPosition.x + LAYOUT_OFFSET + maxTagBboxWidth + 4},${yOrigin + h2 + 2} + ${commitPosition.x + LAYOUT_OFFSET},${yOrigin + h2 + 2}` ) - .attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); + .attr('transform', 'translate(12,12) rotate(45, ' + commitPosition.x + ',' + pos + ')'); hole - .attr('cx', x + 2) + .attr('cx', commitPosition.x + 2) .attr('cy', yOrigin) - .attr('transform', 'translate(12,12) rotate(45, ' + x + ',' + pos + ')'); + .attr('transform', 'translate(12,12) rotate(45, ' + commitPosition.x + ',' + pos + ')'); tag - .attr('x', x + 5) + .attr('x', commitPosition.x + 5) .attr('y', yOrigin + 3) - .attr('transform', 'translate(14,14) rotate(45, ' + x + ',' + pos + ')'); + .attr('transform', 'translate(14,14) rotate(45, ' + commitPosition.x + ',' + pos + ')'); } } } @@ -421,45 +441,50 @@ const getCommitClassType = (commit: Commit): string => { const calculatePosition = ( commit: Commit, dir: string, - isParallelCommits: boolean, pos: number, - commitStep: number, - layoutOffset: number, commitPos: Map ): number => { - const defaultCommitPosition = { x: 0, y: defaultPos }; // Default position if commit is not found + const defaultCommitPosition = { x: 0, y: 0 }; // Default position if commit is not found - if (isParallelCommits) { - if (commit.parents.length > 0) { - const closestParent = - dir === 'BT' ? findClosestParent(commit.parents) : findClosestParent(commit.parents); + if (commit.parents.length > 0) { + const closestParent = findClosestParent(commit.parents); + if (closestParent) { + const parentPosition = commitPos.get(closestParent) ?? defaultCommitPosition; - // Check if closestParent is defined - if (closestParent) { - const parentPosition = commitPos.get(closestParent) ?? defaultCommitPosition; - - if (dir === 'TB') { - return parentPosition.y + commitStep; - } else if (dir === 'BT') { - const currentPosition = commitPos.get(commit.id) ?? defaultCommitPosition; - return currentPosition.y - commitStep; - } else { - return parentPosition.x + commitStep; - } - } - } else { if (dir === 'TB') { - return defaultPos; + return parentPosition.y + COMMIT_STEP; } else if (dir === 'BT') { const currentPosition = commitPos.get(commit.id) ?? defaultCommitPosition; - return currentPosition.y - commitStep; + return currentPosition.y - COMMIT_STEP; } else { - return 0; + return parentPosition.x + COMMIT_STEP; } } + } else { + if (dir === 'TB') { + return defaultPos; + } else if (dir === 'BT') { + const currentPosition = commitPos.get(commit.id) ?? defaultCommitPosition; + return currentPosition.y - COMMIT_STEP; + } else { + return 0; + } } + return 0; +}; - return dir === 'TB' && isParallelCommits ? pos : pos + layoutOffset; +const getCommitPosition = ( + commit: Commit, + pos: number, + isParallelCommits: boolean +): CommitPositionOffset => { + const posWithOffset = dir === 'BT' && isParallelCommits ? pos : pos + LAYOUT_OFFSET; + const y = dir === 'TB' || dir === 'BT' ? posWithOffset : branchPos.get(commit.branch)?.pos; + const x = dir === 'TB' || dir === 'BT' ? branchPos.get(commit.branch)?.pos : posWithOffset; + if (x === undefined || y === undefined) { + throw new Error(`Position were undefined for commit ${commit.id}`); + } + return { x, y, posWithOffset }; }; const drawCommits = ( @@ -476,8 +501,6 @@ const drawCommits = ( let pos = dir === 'TB' || dir === 'BT' ? defaultPos : 0; const keys = [...commits.keys()]; const isParallelCommits = gitGraphConfig?.parallelCommits ?? false; - const layoutOffset = 10; - const commitStep = 40; const sortKeys = (a: string, b: string) => { const seqA = commits.get(a)?.seq; @@ -487,12 +510,10 @@ const drawCommits = ( let sortedKeys = keys.sort(sortKeys); - if (dir === 'BT' && !isParallelCommits) { - sortedKeys = sortedKeys.reverse(); - } - - if (dir === 'BT' && isParallelCommits) { - setParallelBTPos(sortedKeys, commits, pos, commitStep, layoutOffset); + if (dir === 'BT') { + if (isParallelCommits) { + setParallelBTPos(sortedKeys, commits, pos); + } sortedKeys = sortedKeys.reverse(); } @@ -500,40 +521,29 @@ const drawCommits = ( const commit = commits.get(key); if (!commit) { throw new Error(`Commit not found for key ${key}`); + } + if (isParallelCommits) { + pos = calculatePosition(commit, dir, pos, commitPos); + } + + const commitPosition = getCommitPosition(commit, pos, isParallelCommits); + // Don't draw the commits now but calculate the positioning which is used by the branch lines etc. + if (modifyGraph) { + const typeClass = getCommitClassType(commit); + const commitSymbolType = commit.customType ?? commit.type; + const branchIndex = branchPos.get(commit.branch)?.index ?? 0; + drawCommitBullet(gBullets, commit, commitPosition, typeClass, branchIndex, commitSymbolType); + drawCommitLabel(gLabels, commit, commitPosition, pos, gitGraphConfig); + drawCommitTags(gLabels, commit, commitPosition, pos); + } + if (dir === 'TB' || dir === 'BT') { + commitPos.set(commit.id, { x: commitPosition.x, y: commitPosition.posWithOffset }); } else { - pos = calculatePosition( - commit, - dir, - isParallelCommits, - pos, - commitStep, - layoutOffset, - commitPos - ); - const posWithOffset = dir === 'BT' && isParallelCommits ? pos : pos + layoutOffset; - const y = dir === 'TB' || dir === 'BT' ? posWithOffset : branchPos.get(commit.branch)?.pos; - const x = dir === 'TB' || dir === 'BT' ? branchPos.get(commit.branch)?.pos : posWithOffset; - if (x === undefined || y === undefined) { - throw new Error(`Position were undefined for commit ${commit.id}`); - } - // Don't draw the commits now but calculate the positioning which is used by the branch lines etc. - if (modifyGraph) { - const typeClass = getCommitClassType(commit); - const commitSymbolType = commit.customType ?? commit.type; - const branchIndex = branchPos.get(commit.branch)?.index ?? 0; - drawCommitBullet(gBullets, commit, x, y, typeClass, branchIndex, commitSymbolType); - drawCommitLabel(gLabels, commit, x, y, pos, posWithOffset, gitGraphConfig); - drawCommitTags(gLabels, commit, x, y, pos, posWithOffset, layoutOffset); - } - if (dir === 'TB' || dir === 'BT') { - commitPos.set(commit.id, { x: x, y: posWithOffset }); - } else { - commitPos.set(commit.id, { x: posWithOffset, y: y }); - } - pos = dir === 'BT' && isParallelCommits ? pos + commitStep : pos + commitStep + layoutOffset; - if (pos > maxPos) { - maxPos = pos; - } + commitPos.set(commit.id, { x: commitPosition.posWithOffset, y: commitPosition.y }); + } + pos = dir === 'BT' && isParallelCommits ? pos + COMMIT_STEP : pos + COMMIT_STEP + LAYOUT_OFFSET; + if (pos > maxPos) { + maxPos = pos; } }); }; @@ -904,65 +914,269 @@ const drawBranches = ( }); }; +const setBranchPosition = function ( + name: string, + pos: number, + index: number, + bbox: DOMRect, + rotateCommitLabel: boolean +): number { + branchPos.set(name, { pos, index }); + pos += 50 + (rotateCommitLabel ? 40 : 0) + (dir === 'TB' || dir === 'BT' ? bbox.width / 2 : 0); + return pos; +}; + export const draw: DrawDefinition = function (txt, id, ver, diagObj) { clear(); const conf = getConfig(); const gitGraphConfig = conf.gitGraph; - // try { + log.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver); + if (!gitGraphConfig) { + throw new Error('GitGraph config not found'); + } + const rotateCommitLabel = gitGraphConfig.rotateCommitLabel ?? false; const db = diagObj.db as GitGraphDB; allCommitsDict = db.getCommits(); const branches = db.getBranchesAsObjArray(); dir = db.getDirection(); const diagram = select(`[id="${id}"]`); - // Position branches let pos = 0; + branches.forEach((branch, index) => { const labelElement = drawText(branch.name); const g = diagram.append('g'); const branchLabel = g.insert('g').attr('class', 'branchLabel'); const label = branchLabel.insert('g').attr('class', 'label branch-label'); - // @ts-ignore: TODO Fix ts errors - label.node().appendChild(labelElement); const bbox = labelElement.getBBox(); - - branchPos.set(branch.name, { pos, index }); - pos += - 50 + - // @ts-ignore: TODO Fix ts errors - (gitGraphConfig.rotateCommitLabel ? 40 : 0) + - (dir === 'TB' || dir === 'BT' ? bbox.width / 2 : 0); + pos = setBranchPosition(branch.name, pos, index, bbox, rotateCommitLabel); label.remove(); branchLabel.remove(); g.remove(); }); drawCommits(diagram, allCommitsDict, false); - // @ts-ignore: TODO Fix ts errors if (gitGraphConfig.showBranches) { drawBranches(diagram, branches); } drawArrows(diagram, allCommitsDict); drawCommits(diagram, allCommitsDict, true); + utils.insertTitle( diagram, 'gitTitleText', - // @ts-ignore: TODO Fix ts errors - gitGraphConfig.titleTopMargin, + gitGraphConfig.titleTopMargin ?? 0, db.getDiagramTitle() ); // Setup the view box and size of the svg element - setupGraphViewbox( - undefined, - diagram, - // @ts-ignore: TODO Fix ts errors - gitGraphConfig.diagramPadding, - // @ts-ignore: TODO Fix ts errors - gitGraphConfig.useMaxWidth ?? conf.useMaxWidth - ); + setupGraphViewbox(undefined, diagram, gitGraphConfig.diagramPadding, gitGraphConfig.useMaxWidth); }; export default { draw, }; + +if (import.meta.vitest) { + const { it, expect, describe } = import.meta.vitest; + + describe('drawText', () => { + it('should drawText', () => { + const svgLabel = drawText('main'); + expect(svgLabel).toBeDefined(); + expect(svgLabel.children[0].innerHTML).toBe('main'); + }); + }); + + describe('drawBranchPositions', () => { + const bbox: DOMRect = { + x: 0, + y: 0, + width: 10, + height: 10, + top: 0, + right: 0, + bottom: 0, + left: 0, + toJSON: () => '', + }; + + it('should setBranchPositions LR with two branches', () => { + dir = 'LR'; + + const pos = setBranchPosition('main', 0, 0, bbox, true); + expect(pos).toBe(90); + expect(branchPos.get('main')).toEqual({ pos: 0, index: 0 }); + const posNext = setBranchPosition('develop', pos, 1, bbox, true); + expect(posNext).toBe(180); + expect(branchPos.get('develop')).toEqual({ pos: pos, index: 1 }); + }); + + it('should setBranchPositions TB with two branches', () => { + dir = 'TB'; + bbox.width = 34.9921875; + + const pos = setBranchPosition('main', 0, 0, bbox, true); + expect(pos).toBe(107.49609375); + expect(branchPos.get('main')).toEqual({ pos: 0, index: 0 }); + + bbox.width = 56.421875; + const posNext = setBranchPosition('develop', pos, 1, bbox, true); + expect(posNext).toBe(225.70703125); + expect(branchPos.get('develop')).toEqual({ pos: pos, index: 1 }); + }); + }); + /* + describe('drawCommits', () => { + dir = 'TB'; + const commits = new Map([ + [ + 'commitZero', + { + id: 'ZERO', + message: '', + seq: 0, + type: commitType.NORMAL, + tags: [], + parents: [], + branch: 'main', + }, + ], + [ + 'commitA', + { + id: 'A', + message: '', + seq: 1, + type: commitType.NORMAL, + tags: [], + parents: ['ZERO'], + branch: 'feature', + }, + ], + [ + 'commitB', + { + id: 'B', + message: '', + seq: 2, + type: commitType.NORMAL, + tags: [], + parents: ['A'], + branch: 'feature', + }, + ], + [ + 'commitM', + { + id: 'M', + message: 'merged branch feature into main', + seq: 3, + type: commitType.MERGE, + tags: [], + parents: ['ZERO', 'B'], + branch: 'main', + customId: true, + }, + ], + [ + 'commitC', + { + id: 'C', + message: '', + seq: 4, + type: commitType.NORMAL, + tags: [], + parents: ['ZERO'], + branch: 'release', + }, + ], + [ + 'commit5_8928ea0', + { + id: '5-8928ea0', + message: 'cherry-picked [object Object] into release', + seq: 5, + type: commitType.CHERRY_PICK, + tags: [], + parents: ['C', 'M'], + branch: 'release', + }, + ], + [ + 'commitD', + { + id: 'D', + message: '', + seq: 6, + type: commitType.NORMAL, + tags: [], + parents: ['5-8928ea0'], + branch: 'release', + }, + ], + [ + 'commit7_ed848ba', + { + id: '7-ed848ba', + message: 'cherry-picked [object Object] into release', + seq: 7, + type: commitType.CHERRY_PICK, + tags: [], + parents: ['D', 'M'], + branch: 'release', + }, + ], + ]); + + branchPos.set('main', { pos: 0, index: 0 }); + branchPos.set('feature', { pos: 107.49609375, index: 1 }); + branchPos.set('release', { pos: 224.03515625, index: 2 }); + + commits.forEach((commit) => { + it(`should draw commit ${commit.id}`, () => { + const commitPosition = getCommitPosition(commit, 0, false); + expect(commitPosition).toBeDefined(); + }); + it(`should draw commit ${commit.id} with position`, () => { + const commitPosition = getCommitPosition(commit, 0, false); + expect(commitPosition.x).toBeDefined(); + expect(commitPosition.y).toBeDefined(); + expect(commitPosition.posWithOffset).toBeDefined(); + } + it(`should draw commit ${commit.id} bullet`, () => { + const gBullets = svg.append('g').attr('class', 'commit-bullets'); + const typeClass = getCommitClassType(commit); + const branchIndex = branchPos.get(commit.branch)?.index ?? 0; + drawCommitBullet(gBullets, commit, commitPosition, typeClass, branchIndex, commit.type); + } + it(`should draw commit ${commit.id} label`, () => { + const gLabels = svg.append('g').attr('class', 'commit-labels'); + drawCommitLabel(gLabels, commit, commitPosition, 0, gitGraphConfig); + } + }); +*/ + describe('drawBranches', () => { + it('should drawBranches', () => { + expect(true).toBe(true); + }); + }); + + describe('drawArrows', () => { + it('should drawArrows', () => { + expect(true).toBe(true); + }); + }); + + it('add', () => { + commitPos.set('parent1', { x: 1, y: 1 }); + commitPos.set('parent2', { x: 2, y: 2 }); + commitPos.set('parent3', { x: 3, y: 3 }); + dir = 'LR'; + const parents = ['parent1', 'parent2', 'parent3']; + const closestParent = findClosestParent(parents); + + expect(closestParent).toBe('parent3'); + commitPos.clear(); + }); +} From 62950c31a455ac35cb65883f05b9d89fd712f184 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 10 Aug 2024 07:46:10 -0400 Subject: [PATCH 033/124] finished gitGraphRenderer.ts --- .../src/diagrams/git/gitGraphRenderer.ts | 243 +++++++----------- 1 file changed, 91 insertions(+), 152 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index 3493fa995..0408baa23 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -11,6 +11,8 @@ let allCommitsDict = new Map(); const LAYOUT_OFFSET = 10; const COMMIT_STEP = 40; +const PX = 4; +const PY = 2; const commitType: CommitType = { NORMAL: 0, @@ -279,7 +281,7 @@ const drawCommitLabel = ( const labelBkg = wrapper.insert('rect').attr('class', 'commit-label-bkg'); const text = wrapper .append('text') - .attr('x', commitPosition.x) + .attr('x', pos) .attr('y', commitPosition.y + 25) .attr('class', 'commit-label') .text(commit.id); @@ -287,16 +289,20 @@ const drawCommitLabel = ( if (bbox) { labelBkg - .attr('x', commitPosition.posWithOffset - bbox.width / 2 - 2) + .attr('x', commitPosition.posWithOffset - bbox.width / 2 - PY) .attr('y', commitPosition.y + 13.5) - .attr('width', bbox.width + 4) - .attr('height', bbox.height + 4); + .attr('width', bbox.width + 2 * PY) + .attr('height', bbox.height + 2 * PY); if (dir === 'TB' || dir === 'BT') { - labelBkg.attr('x', commitPosition.x - (bbox.width + 4)).attr('y', commitPosition.y - 12); + labelBkg + .attr('x', commitPosition.x - (bbox.width + 4 * PX + 5)) + .attr('y', commitPosition.y - 12); text - .attr('x', commitPosition.x - (bbox.width + 2)) + .attr('x', commitPosition.x - (bbox.width + 4 * PX)) .attr('y', commitPosition.y + bbox.height - 12); + } else { + text.attr('x', commitPosition.posWithOffset - bbox.width / 2); } if (gitGraphConfig.rotateCommitLabel) { @@ -356,6 +362,7 @@ const drawCommitTags = ( if (!tagBbox) { throw new Error('Tag bbox not found'); } + maxTagBboxWidth = Math.max(maxTagBboxWidth, tagBbox.width); maxTagBboxHeight = Math.max(maxTagBboxHeight, tagBbox.height); @@ -377,17 +384,17 @@ const drawCommitTags = ( rect.attr('class', 'tag-label-bkg').attr( 'points', ` - ${pos - maxTagBboxWidth / 2 - 2},${ly + 2} - ${pos - maxTagBboxWidth / 2 - 2},${ly - 2} - ${commitPosition.posWithOffset - maxTagBboxWidth / 2 - 4},${ly - h2 - 2} - ${commitPosition.posWithOffset + maxTagBboxWidth / 2 + 4},${ly - h2 - 2} - ${commitPosition.posWithOffset + maxTagBboxWidth / 2 + 4},${ly + h2 + 2} - ${commitPosition.posWithOffset - maxTagBboxWidth / 2 - 4},${ly + h2 + 2}` + ${pos - maxTagBboxWidth / 2 - PX / 2},${ly + PY} + ${pos - maxTagBboxWidth / 2 - PX / 2},${ly - PY} + ${commitPosition.posWithOffset - maxTagBboxWidth / 2 - PX},${ly - h2 - PY} + ${commitPosition.posWithOffset + maxTagBboxWidth / 2 + PX},${ly - h2 - PY} + ${commitPosition.posWithOffset + maxTagBboxWidth / 2 + PX},${ly + h2 + PY} + ${commitPosition.posWithOffset - maxTagBboxWidth / 2 - PX},${ly + h2 + PY}` ); hole .attr('cy', ly) - .attr('cx', pos - maxTagBboxWidth / 2 + 2) + .attr('cx', pos - maxTagBboxWidth / 2 + PX / 2) .attr('r', 1.5) .attr('class', 'tag-hole'); @@ -408,7 +415,7 @@ const drawCommitTags = ( ) .attr('transform', 'translate(12,12) rotate(45, ' + commitPosition.x + ',' + pos + ')'); hole - .attr('cx', commitPosition.x + 2) + .attr('cx', commitPosition.x + PX / 2) .attr('cy', yOrigin) .attr('transform', 'translate(12,12) rotate(45, ' + commitPosition.x + ',' + pos + ')'); tag @@ -580,14 +587,16 @@ const findLane = (y1: number, y2: number, depth = 0): number => { }; const drawArrow = ( - svg: d3.Selection, + svg: d3.Selection, commitA: Commit, commitB: Commit, allCommits: Map ) => { const p1 = commitPos.get(commitA.id); // arrowStart const p2 = commitPos.get(commitB.id); // arrowEnd - // @ts-ignore: TODO Fix ts errors + if (p1 === undefined || p2 === undefined) { + throw new Error(`Commit positions not found for commits ${commitA.id} and ${commitB.id}`); + } const arrowNeedsRerouting = shouldRerouteArrow(commitA, commitB, p1, p2, allCommits); // log.debug('drawArrow', p1, p2, arrowNeedsRerouting, commitA.id, commitB.id); @@ -597,11 +606,10 @@ const drawArrow = ( let arc2 = ''; let radius = 0; let offset = 0; - // @ts-ignore: TODO Fix ts errors - let colorClassNum = branchPos.get(commitB.branch).index; + + let colorClassNum = branchPos.get(commitB.branch)?.index; if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - // @ts-ignore: TODO Fix ts errors - colorClassNum = branchPos.get(commitA.branch).index; + colorClassNum = branchPos.get(commitA.branch)?.index; } let lineDef; @@ -610,66 +618,57 @@ const drawArrow = ( arc2 = 'A 10 10, 0, 0, 1,'; radius = 10; offset = 10; - // @ts-ignore: TODO Fix ts errors + const lineY = p1.y < p2.y ? findLane(p1.y, p2.y) : findLane(p2.y, p1.y); - // @ts-ignore: TODO Fix ts errors + const lineX = p1.x < p2.x ? findLane(p1.x, p2.x) : findLane(p2.x, p1.x); if (dir === 'TB') { - // @ts-ignore: TODO Fix ts errors if (p1.x < p2.x) { // Source commit is on branch position left of destination commit // so render arrow rightward with colour of destination branch - // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${lineX - radius} ${p1.y} ${arc2} ${lineX} ${ - // @ts-ignore: TODO Fix ts errors p1.y + offset - // @ts-ignore: TODO Fix ts errors } L ${lineX} ${p2.y - radius} ${arc} ${lineX + offset} ${p2.y} L ${p2.x} ${p2.y}`; } else { // Source commit is on branch position right of destination commit // so render arrow leftward with colour of source branch - // @ts-ignore: TODO Fix ts errors - colorClassNum = branchPos.get(commitA.branch).index; - // @ts-ignore: TODO Fix ts errors + + 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}`; } } else if (dir === 'BT') { - // @ts-ignore: TODO Fix ts errors if (p1.x < p2.x) { // Source commit is on branch position left of destination commit // so render arrow rightward with colour of destination branch - // @ts-ignore: TODO Fix ts errors + 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}`; } else { // Source commit is on branch position right of destination commit // so render arrow leftward with colour of source branch - // @ts-ignore: TODO Fix ts errors - colorClassNum = branchPos.get(commitA.branch).index; - // @ts-ignore: TODO Fix ts errors + + 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}`; } } else { - // @ts-ignore: TODO Fix ts errors if (p1.y < p2.y) { // Source commit is on branch positioned above destination commit // so render arrow downward with colour of destination branch - // @ts-ignore: TODO Fix ts errors + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY - radius} ${arc} ${ - // @ts-ignore: TODO Fix ts errors p1.x + offset - // @ts-ignore: TODO Fix ts errors } ${lineY} L ${p2.x - radius} ${lineY} ${arc2} ${p2.x} ${lineY + offset} L ${p2.x} ${p2.y}`; } else { // Source commit is on branch positioned below destination commit // so render arrow upward with colour of source branch - // @ts-ignore: TODO Fix ts errors - colorClassNum = branchPos.get(commitA.branch).index; - // @ts-ignore: TODO Fix ts errors + + colorClassNum = branchPos.get(commitA.branch)?.index; + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${lineY + radius} ${arc2} ${ - // @ts-ignore: TODO Fix ts errors p1.x + offset - // @ts-ignore: TODO Fix ts errors } ${lineY} L ${p2.x - radius} ${lineY} ${arc} ${p2.x} ${lineY - offset} L ${p2.x} ${p2.y}`; } } @@ -680,71 +679,48 @@ const drawArrow = ( offset = 20; if (dir === 'TB') { - // @ts-ignore: TODO Fix ts errors if (p1.x < p2.x) { if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${ - // @ts-ignore: TODO Fix ts errors p2.y - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } else { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${ - // @ts-ignore: TODO Fix ts errors p1.y + offset - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } } - // @ts-ignore: TODO Fix ts errors + if (p1.x > p2.x) { arc = 'A 20 20, 0, 0, 0,'; arc2 = 'A 20 20, 0, 0, 1,'; radius = 20; offset = 20; if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc2} ${p1.x - offset} ${ - // @ts-ignore: TODO Fix ts errors p2.y - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } else { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p2.x + radius} ${p1.y} ${arc} ${p2.x} ${ - // @ts-ignore: TODO Fix ts errors p1.y + offset - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } } - // @ts-ignore: TODO Fix ts errors if (p1.x === p2.x) { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; } } else if (dir === 'BT') { - // @ts-ignore: TODO Fix ts errors if (p1.x < p2.x) { if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${ - // @ts-ignore: TODO Fix ts errors p2.y - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } else { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ - // @ts-ignore: TODO Fix ts errors p1.y - offset - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } } - // @ts-ignore: TODO Fix ts errors if (p1.x > p2.x) { arc = 'A 20 20, 0, 0, 0,'; arc2 = 'A 20 20, 0, 0, 1,'; @@ -752,74 +728,53 @@ const drawArrow = ( offset = 20; if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc} ${p1.x - offset} ${ - // @ts-ignore: TODO Fix ts errors p2.y - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } else { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ - // @ts-ignore: TODO Fix ts errors p1.y - offset - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } } - // @ts-ignore: TODO Fix ts errors + if (p1.x === p2.x) { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; } } else { - // @ts-ignore: TODO Fix ts errors if (p1.y < p2.y) { if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc2} ${p2.x} ${ - // @ts-ignore: TODO Fix ts errors p1.y + offset - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } else { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y - radius} ${arc} ${p1.x + offset} ${ - // @ts-ignore: TODO Fix ts errors p2.y - // @ts-ignore: TODO Fix ts errors - } L ${p2.x} ${p2.y}`; - } - } // @ts-ignore: TODO Fix ts errors - if (p1.y > p2.y) { - if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { - // @ts-ignore: TODO Fix ts errors - lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ - // @ts-ignore: TODO Fix ts errors - p1.y - offset - // @ts-ignore: TODO Fix ts errors - } L ${p2.x} ${p2.y}`; - } else { - // @ts-ignore: TODO Fix ts errors - lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${ - // @ts-ignore: TODO Fix ts errors - p2.y - // @ts-ignore: TODO Fix ts errors } L ${p2.x} ${p2.y}`; } } - // @ts-ignore: TODO Fix ts errors + if (p1.y > p2.y) { + if (commitB.type === commitType.MERGE && commitA.id !== commitB.parents[0]) { + lineDef = `M ${p1.x} ${p1.y} L ${p2.x - radius} ${p1.y} ${arc} ${p2.x} ${ + p1.y - offset + } L ${p2.x} ${p2.y}`; + } else { + lineDef = `M ${p1.x} ${p1.y} L ${p1.x} ${p2.y + radius} ${arc2} ${p1.x + offset} ${ + p2.y + } L ${p2.x} ${p2.y}`; + } + } + if (p1.y === p2.y) { - // @ts-ignore: TODO Fix ts errors lineDef = `M ${p1.x} ${p1.y} L ${p2.x} ${p2.y}`; } } } + svg .append('path') - // @ts-ignore: TODO Fix ts errors .attr('d', lineDef) - .attr('class', 'arrow arrow' + (colorClassNum % THEME_COLOR_LIMIT)); + .attr('class', 'arrow arrow' + (colorClassNum! % THEME_COLOR_LIMIT)); }; const drawArrows = ( @@ -829,12 +784,10 @@ const drawArrows = ( const gArrows = svg.append('g').attr('class', 'commit-arrows'); [...commits.keys()].forEach((key) => { const commit = commits.get(key); - // @ts-ignore: TODO Fix ts errors - if (commit.parents && commit.parents.length > 0) { - // @ts-ignore: TODO Fix ts errors - commit.parents.forEach((parent) => { - // @ts-ignore: TODO Fix ts errors - drawArrow(gArrows, commits.get(parent), commit, commits); + + if (commit!.parents && commit!.parents.length > 0) { + commit!.parents.forEach((parent) => { + drawArrow(gArrows, commits.get(parent)!, commit!, commits); }); } }); @@ -847,10 +800,12 @@ const drawBranches = ( const gitGraphConfig = getConfig().gitGraph; const g = svg.append('g'); branches.forEach((branch, index) => { - // @ts-ignore: TODO Fix ts errors const adjustIndexForTheme = index % THEME_COLOR_LIMIT; - // @ts-ignore: TODO Fix ts errors - const pos = branchPos.get(branch.name).pos; + + const pos = branchPos.get(branch.name)?.pos; + if (pos === undefined) { + throw new Error(`Position not found for branch ${branch.name}`); + } const line = g.append('line'); line.attr('x1', 0); line.attr('y1', pos); @@ -881,23 +836,21 @@ const drawBranches = ( // Create inner g, label, this will be positioned now for centering the text const label = branchLabel.insert('g').attr('class', 'label branch-label' + adjustIndexForTheme); - // @ts-ignore: TODO Fix ts errors - label.node().appendChild(labelElement); + + label.node()!.appendChild(labelElement); const bbox = labelElement.getBBox(); bkg .attr('class', 'branchLabelBkg label' + adjustIndexForTheme) .attr('rx', 4) .attr('ry', 4) - // @ts-ignore: TODO Fix ts errors - .attr('x', -bbox.width - 4 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + .attr('x', -bbox.width - 4 - (gitGraphConfig?.rotateCommitLabel === true ? 30 : 0)) .attr('y', -bbox.height / 2 + 8) .attr('width', bbox.width + 18) .attr('height', bbox.height + 4); label.attr( 'transform', 'translate(' + - // @ts-ignore: TODO Fix ts errors - (-bbox.width - 14 - (gitGraphConfig.rotateCommitLabel === true ? 30 : 0)) + + (-bbox.width - 14 - (gitGraphConfig?.rotateCommitLabel === true ? 30 : 0)) + ', ' + (pos - bbox.height / 2 - 1) + ')' @@ -988,7 +941,7 @@ if (import.meta.vitest) { }); }); - describe('drawBranchPositions', () => { + describe('branchPosition', () => { const bbox: DOMRect = { x: 0, y: 0, @@ -1026,8 +979,8 @@ if (import.meta.vitest) { expect(branchPos.get('develop')).toEqual({ pos: pos, index: 1 }); }); }); - /* - describe('drawCommits', () => { + + describe('commitPosition', () => { dir = 'TB'; const commits = new Map([ [ @@ -1129,42 +1082,28 @@ if (import.meta.vitest) { ], ]); + const expectedCommitPos = new Map([ + ['commitZero', { x: 0, y: 40, posWithOffset: 40 }], + ['commitA', { x: 107.49609375, y: 90, posWithOffset: 90 }], + ['commitB', { x: 107.49609375, y: 140, posWithOffset: 140 }], + ['commitM', { x: 0, y: 190, posWithOffset: 190 }], + ['commitC', { x: 224.03515625, y: 240, posWithOffset: 240 }], + ['commit5_8928ea0', { x: 224.03515625, y: 290, posWithOffset: 290 }], + ['commitD', { x: 224.03515625, y: 340, posWithOffset: 340 }], + ['commit7_ed848ba', { x: 224.03515625, y: 390, posWithOffset: 390 }], + ]); + branchPos.set('main', { pos: 0, index: 0 }); branchPos.set('feature', { pos: 107.49609375, index: 1 }); branchPos.set('release', { pos: 224.03515625, index: 2 }); - commits.forEach((commit) => { - it(`should draw commit ${commit.id}`, () => { - const commitPosition = getCommitPosition(commit, 0, false); - expect(commitPosition).toBeDefined(); + let pos = 30; + commits.forEach((commit, key) => { + it(`should give the correct position for commit ${key}`, () => { + const position = getCommitPosition(commit, pos, false); + expect(position).toEqual(expectedCommitPos.get(key)); + pos += 50; }); - it(`should draw commit ${commit.id} with position`, () => { - const commitPosition = getCommitPosition(commit, 0, false); - expect(commitPosition.x).toBeDefined(); - expect(commitPosition.y).toBeDefined(); - expect(commitPosition.posWithOffset).toBeDefined(); - } - it(`should draw commit ${commit.id} bullet`, () => { - const gBullets = svg.append('g').attr('class', 'commit-bullets'); - const typeClass = getCommitClassType(commit); - const branchIndex = branchPos.get(commit.branch)?.index ?? 0; - drawCommitBullet(gBullets, commit, commitPosition, typeClass, branchIndex, commit.type); - } - it(`should draw commit ${commit.id} label`, () => { - const gLabels = svg.append('g').attr('class', 'commit-labels'); - drawCommitLabel(gLabels, commit, commitPosition, 0, gitGraphConfig); - } - }); -*/ - describe('drawBranches', () => { - it('should drawBranches', () => { - expect(true).toBe(true); - }); - }); - - describe('drawArrows', () => { - it('should drawArrows', () => { - expect(true).toBe(true); }); }); From 269284c6d7f070e2f0c42a561333821fd0bc9a07 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 10 Aug 2024 10:37:24 -0400 Subject: [PATCH 034/124] added parser unit tests and organized config in gitGraphAst.ts --- .../src/diagrams/git/gitGraph.parser.spec.ts | 74 ------------- .../src/diagrams/git/gitGraphParser.ts | 101 ++++++++++++------ .../src/diagrams/git/gitGraphRenderer.ts | 13 ++- .../mermaid/src/diagrams/git/gitGraphTypes.ts | 63 +++++++---- 4 files changed, 121 insertions(+), 130 deletions(-) delete mode 100644 packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts diff --git a/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts b/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts deleted file mode 100644 index 1a38a8217..000000000 --- a/packages/mermaid/src/diagrams/git/gitGraph.parser.spec.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { describe, it, expect, beforeEach, vi } from 'vitest'; -import { parser } from './gitGraphParser.js'; -import { db } from './gitGraphAst.js'; - -const parseInput = async (input: string) => { - await parser.parse(input); -}; - -const spyOn = vi.spyOn; - -describe('GitGraph Parsing', function () { - beforeEach(() => { - db.clear(); - }); - it('should parse a default commit statement', async () => { - const input = `gitGraph: - commit - `; - const commitSpy = spyOn(db, 'commit'); - await parseInput(input); - - expect(commitSpy).toHaveBeenCalledWith('', undefined, 0, []); - commitSpy.mockRestore(); - }); - - it('should parse a basic branch statement with just a name', async () => { - const input = `gitGraph: - branch newBranch - `; - const branchSpy = spyOn(db, 'branch'); - await parseInput(input); - expect(branchSpy).toHaveBeenCalledWith('newBranch', 0); - branchSpy.mockRestore(); - }); - - it('should parse a basic checkout statement', async () => { - const input = `gitGraph: - branch newBranch - checkout newBranch - `; - const checkoutSpy = spyOn(db, 'checkout'); - await parseInput(input); - expect(checkoutSpy).toHaveBeenCalledWith('newBranch'); - checkoutSpy.mockRestore(); - }); - - it('should parse a basic merge statement', async () => { - const input = `gitGraph: - commit - branch newBranch - checkout newBranch - commit - checkout main - merge newBranch`; - const mergeSpy = spyOn(db, 'merge'); - await parseInput(input); - expect(mergeSpy).toHaveBeenCalledWith('newBranch', '', undefined, []); - mergeSpy.mockRestore(); - }); - - it('should parse cherry-picking', async () => { - const input = `gitGraph - commit id: "ZERO" - branch develop - commit id:"A" - checkout main - cherry-pick id:"A" - `; - const cherryPickSpy = spyOn(db, 'cherryPick'); - await parseInput(input); - expect(cherryPickSpy).toHaveBeenCalledWith('A', '', undefined, undefined); - cherryPickSpy.mockRestore(); - }); -}); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index b014d7e57..1ca863329 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -11,9 +11,10 @@ import type { MergeAst, CommitAst, BranchAst, + GitGraphDBProvider, } from './gitGraphTypes.js'; -const populate = (ast: GitGraph) => { +const populate = (ast: GitGraph, db: GitGraphDBProvider) => { populateCommonDb(ast, db); // @ts-ignore: this wont exist if the direction is not specified if (ast.dir) { @@ -21,71 +22,107 @@ const populate = (ast: GitGraph) => { db.setDirection(ast.dir); } for (const statement of ast.statements) { - parseStatement(statement); + parseStatement(statement, db); } }; -const parseStatement = (statement: any) => { - switch (statement.$type) { - case 'Commit': - parseCommit(statement); - break; - case 'Branch': - parseBranch(statement); - break; - case 'Merge': - parseMerge(statement); - break; - case 'Checkout': - parseCheckout(statement); - break; - case 'CherryPicking': - parseCherryPicking(statement); - break; - default: - log.error(`Unknown statement type`); +const parseStatement = (statement: any, db: GitGraphDBProvider) => { + const parsers: Record void> = { + Commit: (stmt) => db.commit(...parseCommit(stmt)), + Branch: (stmt) => db.branch(...parseBranch(stmt)), + Merge: (stmt) => db.merge(...parseMerge(stmt)), + Checkout: (stmt) => db.checkout(parseCheckout(stmt)), + CherryPicking: (stmt) => db.cherryPick(...parseCherryPicking(stmt)), + }; + + const parser = parsers[statement.$type]; + if (parser) { + parser(statement); + } else { + log.error(`Unknown statement type: ${statement.$type}`); } }; -const parseCommit = (commit: CommitAst) => { +const parseCommit = (commit: CommitAst): [string, string, number, string[] | undefined] => { const id = commit.id; const message = commit.message ?? ''; const type = commit.type !== undefined ? commitType[commit.type] : commitType.NORMAL; const tags = commit.tags ?? undefined; - db.commit(message, id, type, tags); + return [message, id, type, tags]; }; -const parseBranch = (branch: BranchAst) => { +const parseBranch = (branch: BranchAst): [string, number] => { const name = branch.name; const order = branch.order ?? 0; - db.branch(name, order); + return [name, order]; }; -const parseMerge = (merge: MergeAst) => { +const parseMerge = ( + merge: MergeAst +): [string, string, number | undefined, string[] | undefined] => { const branch = merge.branch; const id = merge.id ?? ''; const type = merge.type !== undefined ? commitType[merge.type] : undefined; const tags = merge.tags ?? undefined; - db.merge(branch, id, type, tags); + return [branch, id, type, tags]; }; -const parseCheckout = (checkout: CheckoutAst) => { +const parseCheckout = (checkout: CheckoutAst): string => { const branch = checkout.branch; - db.checkout(branch); + return branch; }; -const parseCherryPicking = (cherryPicking: CherryPickingAst) => { +const parseCherryPicking = ( + cherryPicking: CherryPickingAst +): [string, string, string[] | undefined, string] => { const id = cherryPicking.id; const tags = cherryPicking.tags?.length === 0 ? undefined : cherryPicking.tags; const parent = cherryPicking.parent; - db.cherryPick(id, '', tags, parent); + return [id, '', tags, parent]; }; export const parser: ParserDefinition = { parse: async (input: string): Promise => { const ast: GitGraph = await parse('gitGraph', input); log.debug(ast); - populate(ast); + populate(ast, db); }, }; + +if (import.meta.vitest) { + const { it, expect, describe } = import.meta.vitest; + + const mockDB: GitGraphDBProvider = { + commitType: commitType, + setDirection: vi.fn(), + commit: vi.fn(), + branch: vi.fn(), + merge: vi.fn(), + cherryPick: vi.fn(), + checkout: vi.fn(), + }; + + describe('GitGraph Parser', () => { + it('should parse a commit statement', () => { + const commit = { + $type: 'Commit', + id: '1', + message: 'test', + tags: ['tag1', 'tag2'], + type: 'NORMAL', + }; + parseStatement(commit, mockDB); + expect(mockDB.commit).toHaveBeenCalledWith('test', '1', 0, ['tag1', 'tag2']); + }); + it('should parse a branch statement', () => { + const branch = { + $type: 'Branch', + name: 'newBranch', + order: 1, + }; + parseStatement(branch, mockDB); + expect(mockDB.branch).toHaveBeenCalledWith('newBranch', 1); + }); + }); +} diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index 0408baa23..c3862e581 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -4,7 +4,12 @@ import { log } from '../../logger.js'; import utils from '../../utils.js'; import type { DrawDefinition } from '../../diagram-api/types.js'; import type d3 from 'd3'; -import type { CommitType, Commit, GitGraphDB, DiagramOrientation } from './gitGraphTypes.js'; +import type { + CommitType, + Commit, + GitGraphDBRenderProvider, + DiagramOrientation, +} from './gitGraphTypes.js'; import type { GitGraphDiagramConfig } from '../../config.type.js'; let allCommitsDict = new Map(); @@ -770,7 +775,9 @@ const drawArrow = ( } } } - + if (lineDef === undefined) { + throw new Error('Line definition not found'); + } svg .append('path') .attr('d', lineDef) @@ -889,7 +896,7 @@ export const draw: DrawDefinition = function (txt, id, ver, diagObj) { throw new Error('GitGraph config not found'); } const rotateCommitLabel = gitGraphConfig.rotateCommitLabel ?? false; - const db = diagObj.db as GitGraphDB; + const db = diagObj.db as GitGraphDBRenderProvider; allCommitsDict = db.getCommits(); const branches = db.getBranchesAsObjArray(); dir = db.getDirection(); diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index b473dd874..b888cc297 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -1,5 +1,5 @@ -import type { DiagramDB } from '../../diagram-api/types.js'; import type { GitGraphDiagramConfig } from '../../config.type.js'; +import type { DiagramDBBase } from '../../diagram-api/types.js'; export interface CommitType { NORMAL: number; @@ -66,27 +66,13 @@ export interface CherryPickingAst { parent: string; } -export interface GitGraphDB extends DiagramDB { - // config - getConfig: () => GitGraphDiagramConfig | undefined; - - // common db - clear: () => void; - setDiagramTitle: (title: string) => void; - getDiagramTitle: () => string; - setAccTitle: (title: string) => void; - getAccTitle: () => string; - setAccDescription: (description: string) => void; - getAccDescription: () => string; - - // diagram db +export interface GitGraphDB extends DiagramDBBase { commitType: CommitType; - setDirection: (direction: DiagramOrientation) => void; - getDirection: () => DiagramOrientation; - setOptions: (options: string) => void; - getOptions: () => string; - commit: (msg: string, id: string, type: number, tags?: string[] | undefined) => void; - branch: (name: string, order: number) => void; + setDirection: (dir: DiagramOrientation) => void; + setOptions: (rawOptString: string) => void; + getOptions: () => any; + commit: (msg: string, id: string, type: number, tags?: string[]) => void; + branch: (name: string, order?: number) => void; merge: ( otherBranch: string, customId?: string, @@ -101,12 +87,47 @@ export interface GitGraphDB extends DiagramDB { ) => void; checkout: (branch: string) => void; prettyPrint: () => void; + clear: () => void; getBranchesAsObjArray: () => { name: string }[]; getBranches: () => Map; getCommits: () => Map; getCommitsArray: () => Commit[]; getCurrentBranch: () => string; + getDirection: () => DiagramOrientation; getHead: () => Commit | null; } +export interface GitGraphDBParseProvider extends Partial { + commitType: CommitType; + setDirection: (dir: DiagramOrientation) => void; + commit: (msg: string, id: string, type: number, tags?: string[]) => void; + branch: (name: string, order?: number) => void; + merge: ( + otherBranch: string, + customId?: string, + overrideType?: number, + customTags?: string[] + ) => void; + cherryPick: ( + sourceId: string, + targetId: string, + tags: string[] | undefined, + parentCommitId: string + ) => void; + checkout: (branch: string) => void; +} + +export interface GitGraphDBRenderProvider extends Partial { + prettyPrint: () => void; + clear: () => void; + getBranchesAsObjArray: () => { name: string }[]; + getBranches: () => Map; + getCommits: () => Map; + getCommitsArray: () => Commit[]; + getCurrentBranch: () => string; + getDirection: () => DiagramOrientation; + getHead: () => Commit | null; + getDiagramTitle: () => string; +} + export type DiagramOrientation = 'LR' | 'TB' | 'BT'; From d684e0d92450dace5f93ccf47225b401fd9f5333 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 10 Aug 2024 11:22:22 -0400 Subject: [PATCH 035/124] added more unit tests to gitGraphParser.ts and gitGraphRenderer.ts --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 16 ++-- .../src/diagrams/git/gitGraphParser.ts | 90 ++++++++++++++++++- .../src/diagrams/git/gitGraphRenderer.ts | 78 ++++++++++++---- 3 files changed, 156 insertions(+), 28 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 1a40450d9..b47809aac 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -1,6 +1,5 @@ import { log } from '../../logger.js'; import { random } from '../../utils.js'; -import { getConfig } from '../../diagram-api/diagramAPI.js'; import common from '../common/common.js'; import { setAccTitle, @@ -11,9 +10,11 @@ import { setDiagramTitle, getDiagramTitle, } from '../common/commonDb.js'; -import defaultConfig from '../../defaultConfig.js'; import type { DiagramOrientation, Commit, GitGraphDB, CommitType } from './gitGraphTypes.js'; import { ImperativeState } from '../../utils/imperativeState.js'; + +import DEFAULT_CONFIG from '../../defaultConfig.js'; +import type { GitGraphDiagramConfig } from '../../config.type.js'; interface GitGraphState { commits: Map; head: Commit | null; @@ -25,8 +26,13 @@ interface GitGraphState { options: any; } -const mainBranchName = defaultConfig.gitGraph.mainBranchName; -const mainBranchOrder = defaultConfig.gitGraph.mainBranchOrder; +const DEFAULT_GITGRAPH_CONFIG: Required = DEFAULT_CONFIG.gitGraph; + +const mainBranchName = DEFAULT_GITGRAPH_CONFIG.mainBranchName; +const mainBranchOrder = DEFAULT_GITGRAPH_CONFIG.mainBranchOrder; +const config: Required = structuredClone(DEFAULT_GITGRAPH_CONFIG); + +const getConfig = (): Required => structuredClone(config); const state = new ImperativeState(() => ({ commits: new Map(), @@ -476,7 +482,7 @@ export const commitType: CommitType = { export const db: GitGraphDB = { commitType, - getConfig: () => getConfig().gitGraph, + getConfig, setDirection, setOptions, getOptions, diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 1ca863329..404f0c202 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -11,10 +11,10 @@ import type { MergeAst, CommitAst, BranchAst, - GitGraphDBProvider, + GitGraphDBParseProvider, } from './gitGraphTypes.js'; -const populate = (ast: GitGraph, db: GitGraphDBProvider) => { +const populate = (ast: GitGraph, db: GitGraphDBParseProvider) => { populateCommonDb(ast, db); // @ts-ignore: this wont exist if the direction is not specified if (ast.dir) { @@ -26,7 +26,7 @@ const populate = (ast: GitGraph, db: GitGraphDBProvider) => { } }; -const parseStatement = (statement: any, db: GitGraphDBProvider) => { +const parseStatement = (statement: any, db: GitGraphDBParseProvider) => { const parsers: Record void> = { Commit: (stmt) => db.commit(...parseCommit(stmt)), Branch: (stmt) => db.branch(...parseBranch(stmt)), @@ -93,7 +93,7 @@ export const parser: ParserDefinition = { if (import.meta.vitest) { const { it, expect, describe } = import.meta.vitest; - const mockDB: GitGraphDBProvider = { + const mockDB: GitGraphDBParseProvider = { commitType: commitType, setDirection: vi.fn(), commit: vi.fn(), @@ -124,5 +124,87 @@ if (import.meta.vitest) { parseStatement(branch, mockDB); expect(mockDB.branch).toHaveBeenCalledWith('newBranch', 1); }); + it('should parse a checkout statement', () => { + const checkout = { + $type: 'Checkout', + branch: 'newBranch', + }; + parseStatement(checkout, mockDB); + expect(mockDB.checkout).toHaveBeenCalledWith('newBranch'); + }); + it('should parse a merge statement', () => { + const merge = { + $type: 'Merge', + branch: 'newBranch', + id: '1', + tags: ['tag1', 'tag2'], + type: 'NORMAL', + }; + parseStatement(merge, mockDB); + expect(mockDB.merge).toHaveBeenCalledWith('newBranch', '1', 0, ['tag1', 'tag2']); + }); + it('should parse a cherry picking statement', () => { + const cherryPick = { + $type: 'CherryPicking', + id: '1', + tags: ['tag1', 'tag2'], + parent: '2', + }; + parseStatement(cherryPick, mockDB); + expect(mockDB.cherryPick).toHaveBeenCalledWith('1', '', ['tag1', 'tag2'], '2'); + }); + + it('should parse a langium generated gitGraph ast', () => { + const dummy: GitGraph = { + $type: 'GitGraph', + statements: [], + }; + const gitGraphAst: GitGraph = { + $type: 'GitGraph', + statements: [ + { + $container: dummy, + $type: 'Commit', + id: '1', + message: 'test', + tags: ['tag1', 'tag2'], + type: 'NORMAL', + }, + { + $container: dummy, + $type: 'Branch', + name: 'newBranch', + order: 1, + }, + { + $container: dummy, + $type: 'Merge', + branch: 'newBranch', + id: '1', + tags: ['tag1', 'tag2'], + type: 'NORMAL', + }, + { + $container: dummy, + $type: 'Checkout', + branch: 'newBranch', + }, + { + $container: dummy, + $type: 'CherryPicking', + id: '1', + tags: ['tag1', 'tag2'], + parent: '2', + }, + ], + }; + + populate(gitGraphAst, mockDB); + + expect(mockDB.commit).toHaveBeenCalledWith('test', '1', 0, ['tag1', 'tag2']); + expect(mockDB.branch).toHaveBeenCalledWith('newBranch', 1); + expect(mockDB.merge).toHaveBeenCalledWith('newBranch', '1', 0, ['tag1', 'tag2']); + expect(mockDB.checkout).toHaveBeenCalledWith('newBranch'); + }); }); } diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index c3862e581..dde171a62 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -988,7 +988,6 @@ if (import.meta.vitest) { }); describe('commitPosition', () => { - dir = 'TB'; const commits = new Map([ [ 'commitZero', @@ -1088,28 +1087,69 @@ if (import.meta.vitest) { }, ], ]); - - const expectedCommitPos = new Map([ - ['commitZero', { x: 0, y: 40, posWithOffset: 40 }], - ['commitA', { x: 107.49609375, y: 90, posWithOffset: 90 }], - ['commitB', { x: 107.49609375, y: 140, posWithOffset: 140 }], - ['commitM', { x: 0, y: 190, posWithOffset: 190 }], - ['commitC', { x: 224.03515625, y: 240, posWithOffset: 240 }], - ['commit5_8928ea0', { x: 224.03515625, y: 290, posWithOffset: 290 }], - ['commitD', { x: 224.03515625, y: 340, posWithOffset: 340 }], - ['commit7_ed848ba', { x: 224.03515625, y: 390, posWithOffset: 390 }], - ]); - + let pos = 0; branchPos.set('main', { pos: 0, index: 0 }); branchPos.set('feature', { pos: 107.49609375, index: 1 }); branchPos.set('release', { pos: 224.03515625, index: 2 }); - let pos = 30; - commits.forEach((commit, key) => { - it(`should give the correct position for commit ${key}`, () => { - const position = getCommitPosition(commit, pos, false); - expect(position).toEqual(expectedCommitPos.get(key)); - pos += 50; + describe('TB', () => { + pos = 30; + dir = 'TB'; + const expectedCommitPositionTB = new Map([ + ['commitZero', { x: 0, y: 40, posWithOffset: 40 }], + ['commitA', { x: 107.49609375, y: 90, posWithOffset: 90 }], + ['commitB', { x: 107.49609375, y: 140, posWithOffset: 140 }], + ['commitM', { x: 0, y: 190, posWithOffset: 190 }], + ['commitC', { x: 224.03515625, y: 240, posWithOffset: 240 }], + ['commit5_8928ea0', { x: 224.03515625, y: 290, posWithOffset: 290 }], + ['commitD', { x: 224.03515625, y: 340, posWithOffset: 340 }], + ['commit7_ed848ba', { x: 224.03515625, y: 390, posWithOffset: 390 }], + ]); + commits.forEach((commit, key) => { + it(`should give the correct position for commit ${key}`, () => { + const position = getCommitPosition(commit, pos, false); + expect(position).toEqual(expectedCommitPositionTB.get(key)); + pos += 50; + }); + }); + }); + describe('LR', () => { + let pos = 30; + dir = 'LR'; + const expectedCommitPositionLR = new Map([ + ['commitZero', { x: 0, y: 40, posWithOffset: 40 }], + ['commitA', { x: 107.49609375, y: 90, posWithOffset: 90 }], + ['commitB', { x: 107.49609375, y: 140, posWithOffset: 140 }], + ['commitM', { x: 0, y: 190, posWithOffset: 190 }], + ['commitC', { x: 224.03515625, y: 240, posWithOffset: 240 }], + ['commit5_8928ea0', { x: 224.03515625, y: 290, posWithOffset: 290 }], + ['commitD', { x: 224.03515625, y: 340, posWithOffset: 340 }], + ['commit7_ed848ba', { x: 224.03515625, y: 390, posWithOffset: 390 }], + ]); + commits.forEach((commit, key) => { + it(`should give the correct position for commit ${key}`, () => { + const position = getCommitPosition(commit, pos, false); + expect(position).toEqual(expectedCommitPositionLR.get(key)); + pos += 50; + }); + }); + }); + describe('getCommitClassType', () => { + const expectedCommitClassType = new Map([ + ['commitZero', 'commit-normal'], + ['commitA', 'commit-normal'], + ['commitB', 'commit-normal'], + ['commitM', 'commit-merge'], + ['commitC', 'commit-normal'], + ['commit5_8928ea0', 'commit-cherry-pick'], + ['commitD', 'commit-normal'], + ['commit7_ed848ba', 'commit-cherry-pick'], + ]); + commits.forEach((commit, key) => { + it(`should give the correct class type for commit ${key}`, () => { + const classType = getCommitClassType(commit); + expect(classType).toBe(expectedCommitClassType.get(key)); + }); }); }); }); From c49a1bf60c5502021a2a97aabed4b950ef11b101 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 10 Aug 2024 12:28:24 -0400 Subject: [PATCH 036/124] fixed custom type REVERSE for merge, fixed branch spacing for TB --- packages/mermaid/src/diagrams/git/gitGraphRenderer.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index dde171a62..ecf0f0767 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -248,7 +248,7 @@ const drawCommitBullet = ( circle.attr('cy', commitPosition.y); circle.attr('r', commit.type === commitType.MERGE ? 9 : 10); circle.attr('class', `commit ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); - if (commit.type === commitType.MERGE) { + if (commitSymbolType === commitType.MERGE) { const circle2 = gBullets.append('circle'); circle2.attr('cx', commitPosition.x); circle2.attr('cy', commitPosition.y); @@ -266,6 +266,7 @@ const drawCommitBullet = ( `M ${commitPosition.x - 5},${commitPosition.y - 5}L${commitPosition.x + 5},${commitPosition.y + 5}M${commitPosition.x - 5},${commitPosition.y + 5}L${commitPosition.x + 5},${commitPosition.y - 5}` ) .attr('class', `commit ${typeClass} ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); + log.info(); } } }; @@ -543,6 +544,7 @@ const drawCommits = ( if (modifyGraph) { const typeClass = getCommitClassType(commit); const commitSymbolType = commit.customType ?? commit.type; + log.info('commitSymbolType', commitSymbolType); const branchIndex = branchPos.get(commit.branch)?.index ?? 0; drawCommitBullet(gBullets, commit, commitPosition, typeClass, branchIndex, commitSymbolType); drawCommitLabel(gLabels, commit, commitPosition, pos, gitGraphConfig); @@ -883,6 +885,9 @@ const setBranchPosition = function ( ): number { branchPos.set(name, { pos, index }); pos += 50 + (rotateCommitLabel ? 40 : 0) + (dir === 'TB' || dir === 'BT' ? bbox.width / 2 : 0); + log.info('bbox.width', bbox.width); + log.info('setBranchPosition', name, pos, index, bbox); + log.info('branchPos', branchPos); return pos; }; @@ -908,7 +913,9 @@ export const draw: DrawDefinition = function (txt, id, ver, diagObj) { const g = diagram.append('g'); const branchLabel = g.insert('g').attr('class', 'branchLabel'); const label = branchLabel.insert('g').attr('class', 'label branch-label'); + label.node()?.appendChild(labelElement); const bbox = labelElement.getBBox(); + pos = setBranchPosition(branch.name, pos, index, bbox, rotateCommitLabel); label.remove(); branchLabel.remove(); From aba306b68556b45a1200625e4dd7b8498894a254 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 10 Aug 2024 12:32:25 -0400 Subject: [PATCH 037/124] fixed highlight color --- packages/mermaid/src/diagrams/git/gitGraphRenderer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index ecf0f0767..2aef672fc 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -193,7 +193,7 @@ const drawCommitBullet = ( .attr('height', 20) .attr( 'class', - `commit ${commit.id} commit-highlights${branchIndex % THEME_COLOR_LIMIT} ${typeClass}-outer` + `commit ${commit.id} commit-highlight${branchIndex % THEME_COLOR_LIMIT} ${typeClass}-outer` ); gBullets .append('rect') From d73a090875d45dabeec510ba6dd2b3c90a78b63b Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Sat, 10 Aug 2024 23:33:23 -0400 Subject: [PATCH 038/124] fixed BT with parallel commits and added more unit tests --- .../src/diagrams/git/gitGraphRenderer.ts | 224 ++++++++++++++++-- 1 file changed, 207 insertions(+), 17 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index 2aef672fc..b187bee91 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -76,12 +76,11 @@ const drawText = (txt: string | string[]) => { return svgLabel; }; -const findClosestParent = (parents: string[], useBTLogic = false): string | undefined => { +const findClosestParent = (parents: string[]): string | undefined => { let closestParent: string | undefined; let comparisonFunc; let targetPosition: number; - - if (dir === 'BT' || useBTLogic) { + if (dir === 'BT') { comparisonFunc = (a: number, b: number) => a <= b; targetPosition = Infinity; } else { @@ -91,9 +90,7 @@ const findClosestParent = (parents: string[], useBTLogic = false): string | unde parents.forEach((parent) => { const parentPosition = - dir === 'TB' || dir == 'BT' || useBTLogic - ? commitPos.get(parent)?.y - : commitPos.get(parent)?.x; + dir === 'TB' || dir == 'BT' ? commitPos.get(parent)?.y : commitPos.get(parent)?.x; if (parentPosition !== undefined && comparisonFunc(parentPosition, targetPosition)) { closestParent = parent; @@ -104,6 +101,20 @@ const findClosestParent = (parents: string[], useBTLogic = false): string | unde return closestParent; }; +const findClosestParentBT = (parents: string[]) => { + let closestParent = ''; + let maxPosition = Infinity; + + parents.forEach((parent) => { + const parentPosition = commitPos.get(parent)!.y; + if (parentPosition <= maxPosition) { + closestParent = parent; + maxPosition = parentPosition; + } + }); + return closestParent || undefined; +}; + const setParallelBTPos = ( sortedKeys: string[], commits: Map, @@ -119,7 +130,7 @@ const setParallelBTPos = ( throw new Error(`Commit not found for key ${key}`); } - if (hasParents(commit)) { + if (commit.parents.length) { curPos = calculateCommitPosition(commit); maxPosition = Math.max(curPos, maxPosition); } else { @@ -132,9 +143,21 @@ const setParallelBTPos = ( roots.forEach((commit) => { setRootPosition(commit, curPos, defaultPos); }); -}; + sortedKeys.forEach((key) => { + const commit = commits.get(key); -const hasParents = (commit: Commit): boolean => commit.parents?.length > 0; + if (commit?.parents.length) { + const closestParent = findClosestParentBT(commit.parents)!; + curPos = commitPos.get(closestParent)!.y - COMMIT_STEP; + if (curPos <= maxPosition) { + maxPosition = curPos; + } + const x = branchPos.get(commit.branch)!.pos; + const y = curPos - LAYOUT_OFFSET; + commitPos.set(commit.id, { x: x, y: y }); + } + }); +}; const findClosestParentPos = (commit: Commit): number => { const closestParent = findClosestParent(commit.parents.filter((p) => p !== null)); @@ -154,8 +177,9 @@ const calculateCommitPosition = (commit: Commit): number => { return closestParentPos + COMMIT_STEP; }; -const setCommitPosition = (commit: Commit, curPos: number) => { +const setCommitPosition = (commit: Commit, curPos: number): CommitPosition => { const branch = branchPos.get(commit.branch); + if (!branch) { throw new Error(`Branch not found for commit ${commit.id}`); } @@ -163,6 +187,7 @@ const setCommitPosition = (commit: Commit, curPos: number) => { const x = branch.pos; const y = curPos + LAYOUT_OFFSET; commitPos.set(commit.id, { x, y }); + return { x, y }; }; const setRootPosition = (commit: Commit, curPos: number, defaultPos: number) => { @@ -266,7 +291,6 @@ const drawCommitBullet = ( `M ${commitPosition.x - 5},${commitPosition.y - 5}L${commitPosition.x + 5},${commitPosition.y + 5}M${commitPosition.x - 5},${commitPosition.y + 5}L${commitPosition.x + 5},${commitPosition.y - 5}` ) .attr('class', `commit ${typeClass} ${commit.id} commit${branchIndex % THEME_COLOR_LIMIT}`); - log.info(); } } }; @@ -522,12 +546,13 @@ const drawCommits = ( }; let sortedKeys = keys.sort(sortKeys); - if (dir === 'BT') { if (isParallelCommits) { setParallelBTPos(sortedKeys, commits, pos); + sortedKeys = sortedKeys.reverse(); + } else { + sortedKeys = sortedKeys.reverse(); } - sortedKeys = sortedKeys.reverse(); } sortedKeys.forEach((key) => { @@ -544,7 +569,6 @@ const drawCommits = ( if (modifyGraph) { const typeClass = getCommitClassType(commit); const commitSymbolType = commit.customType ?? commit.type; - log.info('commitSymbolType', commitSymbolType); const branchIndex = branchPos.get(commit.branch)?.index ?? 0; drawCommitBullet(gBullets, commit, commitPosition, typeClass, branchIndex, commitSymbolType); drawCommitLabel(gLabels, commit, commitPosition, pos, gitGraphConfig); @@ -885,9 +909,6 @@ const setBranchPosition = function ( ): number { branchPos.set(name, { pos, index }); pos += 50 + (rotateCommitLabel ? 40 : 0) + (dir === 'TB' || dir === 'BT' ? bbox.width / 2 : 0); - log.info('bbox.width', bbox.width); - log.info('setBranchPosition', name, pos, index, bbox); - log.info('branchPos', branchPos); return pos; }; @@ -1160,6 +1181,175 @@ if (import.meta.vitest) { }); }); }); + describe('building BT parallel commit diagram', () => { + const commits = new Map([ + [ + '1-abcdefg', + { + id: '1-abcdefg', + message: '', + seq: 0, + type: 0, + tags: [], + parents: [], + branch: 'main', + }, + ], + [ + '2-abcdefg', + { + id: '2-abcdefg', + message: '', + seq: 1, + type: 0, + tags: [], + parents: ['1-abcdefg'], + branch: 'main', + }, + ], + [ + '3-abcdefg', + { + id: '3-abcdefg', + message: '', + seq: 2, + type: 0, + tags: [], + parents: ['2-abcdefg'], + branch: 'develop', + }, + ], + [ + '4-abcdefg', + { + id: '4-abcdefg', + message: '', + seq: 3, + type: 0, + tags: [], + parents: ['3-abcdefg'], + branch: 'develop', + }, + ], + [ + '5-abcdefg', + { + id: '5-abcdefg', + message: '', + seq: 4, + type: 0, + tags: [], + parents: ['2-abcdefg'], + branch: 'feature', + }, + ], + [ + '6-abcdefg', + { + id: '6-abcdefg', + message: '', + seq: 5, + type: 0, + tags: [], + parents: ['5-abcdefg'], + branch: 'feature', + }, + ], + [ + '7-abcdefg', + { + id: '7-abcdefg', + message: '', + seq: 6, + type: 0, + tags: [], + parents: ['2-abcdefg'], + branch: 'main', + }, + ], + [ + '8-abcdefg', + { + id: '8-abcdefg', + message: '', + seq: 7, + type: 0, + tags: [], + parents: ['7-abcdefg'], + branch: 'main', + }, + ], + ]); + const expectedCommitPosition = new Map([ + ['1-abcdefg', { x: 0, y: 40 }], + ['2-abcdefg', { x: 0, y: 90 }], + ['3-abcdefg', { x: 107.49609375, y: 140 }], + ['4-abcdefg', { x: 107.49609375, y: 190 }], + ['5-abcdefg', { x: 225.70703125, y: 140 }], + ['6-abcdefg', { x: 225.70703125, y: 190 }], + ['7-abcdefg', { x: 0, y: 140 }], + ['8-abcdefg', { x: 0, y: 190 }], + ]); + + const expectedCommitPositionAfterParallel = new Map([ + ['1-abcdefg', { x: 0, y: 210 }], + ['2-abcdefg', { x: 0, y: 160 }], + ['3-abcdefg', { x: 107.49609375, y: 110 }], + ['4-abcdefg', { x: 107.49609375, y: 60 }], + ['5-abcdefg', { x: 225.70703125, y: 110 }], + ['6-abcdefg', { x: 225.70703125, y: 60 }], + ['7-abcdefg', { x: 0, y: 110 }], + ['8-abcdefg', { x: 0, y: 60 }], + ]); + + const expectedCommitCurrentPosition = new Map([ + ['1-abcdefg', 30], + ['2-abcdefg', 80], + ['3-abcdefg', 130], + ['4-abcdefg', 180], + ['5-abcdefg', 130], + ['6-abcdefg', 180], + ['7-abcdefg', 130], + ['8-abcdefg', 180], + ]); + const sortedKeys = [...expectedCommitPosition.keys()]; + it('should get the correct commit position and current position', () => { + dir = 'BT'; + let curPos = 30; + commitPos.clear(); + branchPos.clear(); + branchPos.set('main', { pos: 0, index: 0 }); + branchPos.set('develop', { pos: 107.49609375, index: 1 }); + branchPos.set('feature', { pos: 225.70703125, index: 2 }); + //TODO: need to make sure you set the parallel commits to true + + commits.forEach((commit, key) => { + if (commit.parents.length > 0) { + curPos = calculateCommitPosition(commit); + } + const position = setCommitPosition(commit, curPos); + expect(position).toEqual(expectedCommitPosition.get(key)); + expect(curPos).toEqual(expectedCommitCurrentPosition.get(key)); + }); + }); + + it('should get the correct commit position after parallel commits', () => { + commitPos.clear(); + branchPos.clear(); + dir = 'BT'; + const curPos = 30; + commitPos.clear(); + branchPos.clear(); + branchPos.set('main', { pos: 0, index: 0 }); + branchPos.set('develop', { pos: 107.49609375, index: 1 }); + branchPos.set('feature', { pos: 225.70703125, index: 2 }); + setParallelBTPos(sortedKeys, commits, curPos); + sortedKeys.forEach((commit) => { + const position = commitPos.get(commit); + expect(position).toEqual(expectedCommitPositionAfterParallel.get(commit)); + }); + }); + }); it('add', () => { commitPos.set('parent1', { x: 1, y: 1 }); From 261aea308971322df69a30b5f64077fe4c93ba5d Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Mon, 12 Aug 2024 15:51:03 -0500 Subject: [PATCH 039/124] feat(er): allow multi-line relationship labels --- demos/er.html | 29 +++++++++++++++++++ docs/syntax/entityRelationshipDiagram.md | 1 + .../mermaid/src/diagrams/er/erRenderer.js | 18 ++++++++++-- .../docs/syntax/entityRelationshipDiagram.md | 1 + 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/demos/er.html b/demos/er.html index 0b4b82bac..b6c503c2e 100644 --- a/demos/er.html +++ b/demos/er.html @@ -125,6 +125,35 @@
+
+    erDiagram
+      p[Person] {
+          string firstName
+          string lastName
+      }
+      a["Customer Account"] {
+          string email
+      }
+
+      b["Customer Account Secondary"] {
+        string email
+      }
+      
+      c["Customer Account Tertiary"] {
+        string email
+      }
+      
+      d["Customer Account Nth"] {
+        string email
+      }
+
+      p ||--o| a : "has
one" + p ||--o| b : "has
one
two" + p ||--o| c : "has
one
two
three" + p ||--o| d : "has
one
two
three
...
Nth" +
+
+
     erDiagram
       _customer_order {
diff --git a/docs/syntax/entityRelationshipDiagram.md b/docs/syntax/entityRelationshipDiagram.md
index ae84d1e9e..def8c9f3a 100644
--- a/docs/syntax/entityRelationshipDiagram.md
+++ b/docs/syntax/entityRelationshipDiagram.md
@@ -286,6 +286,7 @@ erDiagram
 
 - If you want the relationship label to be more than one word, you must use double quotes around the phrase
 - If you don't want a label at all on a relationship, you must use an empty double-quoted string
+- If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) ## Styling diff --git a/packages/mermaid/src/diagrams/er/erRenderer.js b/packages/mermaid/src/diagrams/er/erRenderer.js index 33fb5bd4a..0327bfc9d 100644 --- a/packages/mermaid/src/diagrams/er/erRenderer.js +++ b/packages/mermaid/src/diagrams/er/erRenderer.js @@ -519,6 +519,8 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) { // Append a text node containing the label const labelId = 'rel' + relCnt; + const labelText = rel.roleA.split(/
/g); + const labelNode = svg .append('text') .classed('er relationshipLabel', true) @@ -528,8 +530,20 @@ const drawRelationshipFromLayout = function (svg, rel, g, insert, diagObj) { .style('text-anchor', 'middle') .style('dominant-baseline', 'middle') .style('font-family', getConfig().fontFamily) - .style('font-size', conf.fontSize + 'px') - .text(rel.roleA); + .style('font-size', conf.fontSize + 'px'); + + if (labelText.length == 1) { + labelNode.text(rel.roleA); + } else { + const firstShift = -(labelText.length - 1) * 0.5; + labelText.forEach((txt, i) => { + labelNode + .append('tspan') + .attr('x', labelPoint.x) + .attr('dy', `${i === 0 ? firstShift : 1}em`) + .text(txt); + }); + } // Figure out how big the opaque 'container' rectangle needs to be const labelBBox = labelNode.node().getBBox(); diff --git a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md index 3b874f689..e08b1930f 100644 --- a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md +++ b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md @@ -192,6 +192,7 @@ erDiagram - If you want the relationship label to be more than one word, you must use double quotes around the phrase - If you don't want a label at all on a relationship, you must use an empty double-quoted string +- If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) ## Styling From 731b330e402539c14b1d7c674c18b248eed117d6 Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Mon, 12 Aug 2024 16:00:44 -0500 Subject: [PATCH 040/124] docs(er): added min version req to multi-line labels --- docs/syntax/entityRelationshipDiagram.md | 2 +- packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/syntax/entityRelationshipDiagram.md b/docs/syntax/entityRelationshipDiagram.md index def8c9f3a..9023f763a 100644 --- a/docs/syntax/entityRelationshipDiagram.md +++ b/docs/syntax/entityRelationshipDiagram.md @@ -286,7 +286,7 @@ erDiagram - If you want the relationship label to be more than one word, you must use double quotes around the phrase - If you don't want a label at all on a relationship, you must use an empty double-quoted string -- If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) +- (v10.8.0+) If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) ## Styling diff --git a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md index e08b1930f..06e7c96b4 100644 --- a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md +++ b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md @@ -192,7 +192,7 @@ erDiagram - If you want the relationship label to be more than one word, you must use double quotes around the phrase - If you don't want a label at all on a relationship, you must use an empty double-quoted string -- If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) +- (v10.8.0+) If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) ## Styling From 3539a35578f28395f0aadbb54cbe90b440c05c0f Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 13 Aug 2024 21:56:26 +0000 Subject: [PATCH 041/124] [autofix.ci] apply automated fixes --- docs/config/setup/interfaces/mermaid.Mermaid.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/setup/interfaces/mermaid.Mermaid.md b/docs/config/setup/interfaces/mermaid.Mermaid.md index a340c7a97..86bdbe8fa 100644 --- a/docs/config/setup/interfaces/mermaid.Mermaid.md +++ b/docs/config/setup/interfaces/mermaid.Mermaid.md @@ -147,7 +147,7 @@ Internal helpers for mermaid | `common.sanitizeTextOrArray` | (`a`: `string` \| `string`\[] \| `string`\[]\[], `config`: [`MermaidConfig`](mermaid.MermaidConfig.md)) => `string` \| `string`\[] | | `common.splitBreaks` | (`text`: `string`) => `string`\[] | | `getConfig` | () => [`MermaidConfig`](mermaid.MermaidConfig.md) | -| `insertCluster` | (`elem`: `any`, `node`: `any`) => `any` | +| `insertCluster` | (`elem`: `any`, `node`: `any`) => `Promise`<`any`> | | `insertEdge` | (`elem`: `any`, `edge`: `any`, `clusterDb`: `any`, `diagramType`: `any`, `startNode`: `any`, `endNode`: `any`, `id`: `any`) => { `originalPath`: `any` ; `updatedPath`: `any` } | | `insertEdgeLabel` | (`elem`: `any`, `edge`: `any`) => `Promise`<`any`> | | `insertMarkers` | (`elem`: `any`, `markerArray`: `any`, `type`: `any`, `id`: `any`) => `void` | From 299e559aa518da4907dd624c76f866bed2428fda Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Wed, 14 Aug 2024 10:51:45 -0400 Subject: [PATCH 042/124] added config as global --- .../src/diagrams/git/gitGraphRenderer.ts | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index b187bee91..1aba40cec 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -12,6 +12,9 @@ import type { } from './gitGraphTypes.js'; import type { GitGraphDiagramConfig } from '../../config.type.js'; +const DEFAULT_CONFIG = getConfig(); +const DEFAULT_GITGRAPH_CONFIG: Required = DEFAULT_CONFIG.gitGraph; + let allCommitsDict = new Map(); const LAYOUT_OFFSET = 10; @@ -299,13 +302,12 @@ const drawCommitLabel = ( gLabels: d3.Selection, commit: Commit, commitPosition: CommitPositionOffset, - pos: number, - gitGraphConfig: GitGraphDiagramConfig + pos: number ) => { if ( commit.type !== commitType.CHERRY_PICK && ((commit.customId && commit.type === commitType.MERGE) || commit.type !== commitType.MERGE) && - gitGraphConfig.showCommitLabel + DEFAULT_GITGRAPH_CONFIG.showCommitLabel ) { const wrapper = gLabels.append('g'); const labelBkg = wrapper.insert('rect').attr('class', 'commit-label-bkg'); @@ -335,7 +337,7 @@ const drawCommitLabel = ( text.attr('x', commitPosition.posWithOffset - bbox.width / 2); } - if (gitGraphConfig.rotateCommitLabel) { + if (DEFAULT_GITGRAPH_CONFIG.rotateCommitLabel) { if (dir === 'TB' || dir === 'BT') { text.attr( 'transform', @@ -529,15 +531,14 @@ const drawCommits = ( commits: Map, modifyGraph: boolean ) => { - const gitGraphConfig = getConfig().gitGraph; - if (!gitGraphConfig) { + if (!DEFAULT_GITGRAPH_CONFIG) { throw new Error('GitGraph config not found'); } const gBullets = svg.append('g').attr('class', 'commit-bullets'); const gLabels = svg.append('g').attr('class', 'commit-labels'); let pos = dir === 'TB' || dir === 'BT' ? defaultPos : 0; const keys = [...commits.keys()]; - const isParallelCommits = gitGraphConfig?.parallelCommits ?? false; + const isParallelCommits = DEFAULT_GITGRAPH_CONFIG?.parallelCommits ?? false; const sortKeys = (a: string, b: string) => { const seqA = commits.get(a)?.seq; @@ -571,7 +572,7 @@ const drawCommits = ( const commitSymbolType = commit.customType ?? commit.type; const branchIndex = branchPos.get(commit.branch)?.index ?? 0; drawCommitBullet(gBullets, commit, commitPosition, typeClass, branchIndex, commitSymbolType); - drawCommitLabel(gLabels, commit, commitPosition, pos, gitGraphConfig); + drawCommitLabel(gLabels, commit, commitPosition, pos); drawCommitTags(gLabels, commit, commitPosition, pos); } if (dir === 'TB' || dir === 'BT') { @@ -830,7 +831,6 @@ const drawBranches = ( svg: d3.Selection, branches: { name: string }[] ) => { - const gitGraphConfig = getConfig().gitGraph; const g = svg.append('g'); branches.forEach((branch, index) => { const adjustIndexForTheme = index % THEME_COLOR_LIMIT; @@ -876,14 +876,14 @@ const drawBranches = ( .attr('class', 'branchLabelBkg label' + adjustIndexForTheme) .attr('rx', 4) .attr('ry', 4) - .attr('x', -bbox.width - 4 - (gitGraphConfig?.rotateCommitLabel === true ? 30 : 0)) + .attr('x', -bbox.width - 4 - (DEFAULT_GITGRAPH_CONFIG?.rotateCommitLabel === true ? 30 : 0)) .attr('y', -bbox.height / 2 + 8) .attr('width', bbox.width + 18) .attr('height', bbox.height + 4); label.attr( 'transform', 'translate(' + - (-bbox.width - 14 - (gitGraphConfig?.rotateCommitLabel === true ? 30 : 0)) + + (-bbox.width - 14 - (DEFAULT_GITGRAPH_CONFIG?.rotateCommitLabel === true ? 30 : 0)) + ', ' + (pos - bbox.height / 2 - 1) + ')' @@ -914,14 +914,12 @@ const setBranchPosition = function ( export const draw: DrawDefinition = function (txt, id, ver, diagObj) { clear(); - const conf = getConfig(); - const gitGraphConfig = conf.gitGraph; log.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver); - if (!gitGraphConfig) { + if (!DEFAULT_GITGRAPH_CONFIG) { throw new Error('GitGraph config not found'); } - const rotateCommitLabel = gitGraphConfig.rotateCommitLabel ?? false; + const rotateCommitLabel = DEFAULT_GITGRAPH_CONFIG.rotateCommitLabel ?? false; const db = diagObj.db as GitGraphDBRenderProvider; allCommitsDict = db.getCommits(); const branches = db.getBranchesAsObjArray(); @@ -944,7 +942,7 @@ export const draw: DrawDefinition = function (txt, id, ver, diagObj) { }); drawCommits(diagram, allCommitsDict, false); - if (gitGraphConfig.showBranches) { + if (DEFAULT_GITGRAPH_CONFIG.showBranches) { drawBranches(diagram, branches); } drawArrows(diagram, allCommitsDict); @@ -953,12 +951,17 @@ export const draw: DrawDefinition = function (txt, id, ver, diagObj) { utils.insertTitle( diagram, 'gitTitleText', - gitGraphConfig.titleTopMargin ?? 0, + DEFAULT_GITGRAPH_CONFIG.titleTopMargin ?? 0, db.getDiagramTitle() ); // Setup the view box and size of the svg element - setupGraphViewbox(undefined, diagram, gitGraphConfig.diagramPadding, gitGraphConfig.useMaxWidth); + setupGraphViewbox( + undefined, + diagram, + DEFAULT_GITGRAPH_CONFIG.diagramPadding, + DEFAULT_GITGRAPH_CONFIG.useMaxWidth + ); }; export default { @@ -1321,8 +1324,7 @@ if (import.meta.vitest) { branchPos.set('main', { pos: 0, index: 0 }); branchPos.set('develop', { pos: 107.49609375, index: 1 }); branchPos.set('feature', { pos: 225.70703125, index: 2 }); - //TODO: need to make sure you set the parallel commits to true - + DEFAULT_GITGRAPH_CONFIG.parallelCommits = true; commits.forEach((commit, key) => { if (commit.parents.length > 0) { curPos = calculateCommitPosition(commit); @@ -1350,7 +1352,7 @@ if (import.meta.vitest) { }); }); }); - + DEFAULT_GITGRAPH_CONFIG.parallelCommits = false; it('add', () => { commitPos.set('parent1', { x: 1, y: 1 }); commitPos.set('parent2', { x: 2, y: 2 }); From 53798beb9651ea6866520668ea88dd0b9ccd0fb0 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Thu, 15 Aug 2024 16:10:20 -0400 Subject: [PATCH 043/124] fixed gitgraphconfig problem --- packages/mermaid/src/diagrams/git/gitGraphRenderer.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index 1aba40cec..bd242ce06 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -10,10 +10,9 @@ import type { GitGraphDBRenderProvider, DiagramOrientation, } from './gitGraphTypes.js'; -import type { GitGraphDiagramConfig } from '../../config.type.js'; const DEFAULT_CONFIG = getConfig(); -const DEFAULT_GITGRAPH_CONFIG: Required = DEFAULT_CONFIG.gitGraph; +const DEFAULT_GITGRAPH_CONFIG = DEFAULT_CONFIG?.gitGraph; let allCommitsDict = new Map(); @@ -1324,7 +1323,7 @@ if (import.meta.vitest) { branchPos.set('main', { pos: 0, index: 0 }); branchPos.set('develop', { pos: 107.49609375, index: 1 }); branchPos.set('feature', { pos: 225.70703125, index: 2 }); - DEFAULT_GITGRAPH_CONFIG.parallelCommits = true; + DEFAULT_GITGRAPH_CONFIG!.parallelCommits = true; commits.forEach((commit, key) => { if (commit.parents.length > 0) { curPos = calculateCommitPosition(commit); @@ -1352,7 +1351,7 @@ if (import.meta.vitest) { }); }); }); - DEFAULT_GITGRAPH_CONFIG.parallelCommits = false; + DEFAULT_GITGRAPH_CONFIG!.parallelCommits = false; it('add', () => { commitPos.set('parent1', { x: 1, y: 1 }); commitPos.set('parent2', { x: 2, y: 2 }); From 66e53df04b04525e613deb908832eee81d0eaf74 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Tue, 20 Aug 2024 00:30:01 -0400 Subject: [PATCH 044/124] added most suggested changes --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 28 ++++------- .../src/diagrams/git/gitGraphDiagram.ts | 4 +- .../src/diagrams/git/gitGraphParser.ts | 2 +- .../src/diagrams/git/gitGraphRenderer.ts | 46 ++++++------------- .../mermaid/src/diagrams/git/gitGraphTypes.ts | 33 +++++++------ 5 files changed, 45 insertions(+), 68 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index b47809aac..c7ee21a14 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -10,7 +10,8 @@ import { setDiagramTitle, getDiagramTitle, } from '../common/commonDb.js'; -import type { DiagramOrientation, Commit, GitGraphDB, CommitType } from './gitGraphTypes.js'; +import type { DiagramOrientation, Commit, GitGraphDB } from './gitGraphTypes.js'; +import { commitType } from './gitGraphTypes.js'; import { ImperativeState } from '../../utils/imperativeState.js'; import DEFAULT_CONFIG from '../../defaultConfig.js'; @@ -132,11 +133,9 @@ export const merge = ( if (customId) { customId = common.sanitizeText(customId, config); } - const currentBranchCheck: string | null | undefined = state.records.branches.get( - state.records.currBranch - ); - const otherBranchCheck: string | null | undefined = state.records.branches.get(otherBranch); - const currentCommit: Commit | undefined = currentBranchCheck + const currentBranchCheck = state.records.branches.get(state.records.currBranch); + const otherBranchCheck = state.records.branches.get(otherBranch); + const currentCommit = currentBranchCheck ? state.records.commits.get(currentBranchCheck) : undefined; const otherCommit: Commit | undefined = otherBranchCheck @@ -215,8 +214,8 @@ export const merge = ( const verifiedBranch: string = otherBranchCheck ? otherBranchCheck : ''; //figure out a cleaner way to do this - const commit: Commit = { - id: customId ? customId : state.records.seq + '-' + getID(), + const commit = { + id: customId ?? `${state.records.seq}-${getID()}`, message: `merged branch ${otherBranch} into ${state.records.currBranch}`, seq: state.records.seq++, parents: state.records.head == null ? [] : [state.records.head.id, verifiedBranch], @@ -224,8 +223,8 @@ export const merge = ( type: commitType.MERGE, customType: overrideType, customId: customId ? true : false, - tags: customTags ? customTags : [], - }; + tags: customTags ?? [], + } satisfies Commit; state.records.head = commit; state.records.commits.set(commit.id, commit); state.records.branches.set(state.records.currBranch, commit.id); @@ -379,7 +378,6 @@ function upsert(arr: any[], key: any, newVal: any) { } } -/** @param commitArr - array */ function prettyPrintCommitHistory(commitArr: Commit[]) { const commit = commitArr.reduce((out, commit) => { if (out.seq > commit.seq) { @@ -472,14 +470,6 @@ export const getHead = function () { return state.records.head; }; -export const commitType: CommitType = { - NORMAL: 0, - REVERSE: 1, - HIGHLIGHT: 2, - MERGE: 3, - CHERRY_PICK: 4, -}; - export const db: GitGraphDB = { commitType, getConfig, diff --git a/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts b/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts index 01537e551..d6e8a0613 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphDiagram.ts @@ -6,8 +6,8 @@ import gitGraphStyles from './styles.js'; import type { DiagramDefinition } from '../../diagram-api/types.js'; export const diagram: DiagramDefinition = { - parser: parser, - db: db, + parser, + db, renderer: gitGraphRenderer, styles: gitGraphStyles, }; diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 404f0c202..6be06e84d 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -4,7 +4,7 @@ import type { ParserDefinition } from '../../diagram-api/types.js'; import { log } from '../../logger.js'; import { populateCommonDb } from '../common/populateCommonDb.js'; import { db } from './gitGraphAst.js'; -import { commitType } from './gitGraphAst.js'; +import { commitType } from './gitGraphTypes.js'; import type { CheckoutAst, CherryPickingAst, diff --git a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts index bd242ce06..39a64a623 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphRenderer.ts @@ -4,32 +4,8 @@ import { log } from '../../logger.js'; import utils from '../../utils.js'; import type { DrawDefinition } from '../../diagram-api/types.js'; import type d3 from 'd3'; -import type { - CommitType, - Commit, - GitGraphDBRenderProvider, - DiagramOrientation, -} from './gitGraphTypes.js'; - -const DEFAULT_CONFIG = getConfig(); -const DEFAULT_GITGRAPH_CONFIG = DEFAULT_CONFIG?.gitGraph; - -let allCommitsDict = new Map(); - -const LAYOUT_OFFSET = 10; -const COMMIT_STEP = 40; -const PX = 4; -const PY = 2; - -const commitType: CommitType = { - NORMAL: 0, - REVERSE: 1, - HIGHLIGHT: 2, - MERGE: 3, - CHERRY_PICK: 4, -}; - -const THEME_COLOR_LIMIT = 8; +import type { Commit, GitGraphDBRenderProvider, DiagramOrientation } from './gitGraphTypes.js'; +import { commitType } from './gitGraphTypes.js'; interface BranchPosition { pos: number; @@ -45,12 +21,22 @@ interface CommitPositionOffset extends CommitPosition { posWithOffset: number; } +const DEFAULT_CONFIG = getConfig(); +const DEFAULT_GITGRAPH_CONFIG = DEFAULT_CONFIG?.gitGraph; +const LAYOUT_OFFSET = 10; +const COMMIT_STEP = 40; +const PX = 4; +const PY = 2; + +const THEME_COLOR_LIMIT = 8; const branchPos = new Map(); const commitPos = new Map(); +const defaultPos = 30; + +let allCommitsDict = new Map(); let lanes: number[] = []; let maxPos = 0; let dir: DiagramOrientation = 'LR'; -const defaultPos = 30; const clear = () => { branchPos.clear(); @@ -306,7 +292,7 @@ const drawCommitLabel = ( if ( commit.type !== commitType.CHERRY_PICK && ((commit.customId && commit.type === commitType.MERGE) || commit.type !== commitType.MERGE) && - DEFAULT_GITGRAPH_CONFIG.showCommitLabel + DEFAULT_GITGRAPH_CONFIG?.showCommitLabel ) { const wrapper = gLabels.append('g'); const labelBkg = wrapper.insert('rect').attr('class', 'commit-label-bkg'); @@ -549,10 +535,8 @@ const drawCommits = ( if (dir === 'BT') { if (isParallelCommits) { setParallelBTPos(sortedKeys, commits, pos); - sortedKeys = sortedKeys.reverse(); - } else { - sortedKeys = sortedKeys.reverse(); } + sortedKeys = sortedKeys.reverse(); } sortedKeys.forEach((key) => { diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index b888cc297..0b1b4f714 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -1,13 +1,21 @@ import type { GitGraphDiagramConfig } from '../../config.type.js'; import type { DiagramDBBase } from '../../diagram-api/types.js'; -export interface CommitType { - NORMAL: number; - REVERSE: number; - HIGHLIGHT: number; - MERGE: number; - CHERRY_PICK: number; -} +export const commitType = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4, +} as const; + +export const gitcommitType = { + NORMAL: 0, + REVERSE: 1, + HIGHLIGHT: 2, + MERGE: 3, + CHERRY_PICK: 4, +} as const; export interface Commit { id: string; @@ -25,11 +33,6 @@ export interface GitGraph { statements: Statement[]; } -export interface Position { - x: number; - y: number; -} - export type Statement = CommitAst | BranchAst | MergeAst | CheckoutAst | CherryPickingAst; export interface CommitAst { @@ -62,12 +65,12 @@ export interface CheckoutAst { export interface CherryPickingAst { $type: 'CherryPicking'; id: string; - tags?: string[]; parent: string; + tags?: string[]; } export interface GitGraphDB extends DiagramDBBase { - commitType: CommitType; + commitType: typeof commitType; setDirection: (dir: DiagramOrientation) => void; setOptions: (rawOptString: string) => void; getOptions: () => any; @@ -98,7 +101,7 @@ export interface GitGraphDB extends DiagramDBBase { } export interface GitGraphDBParseProvider extends Partial { - commitType: CommitType; + commitType: typeof commitType; setDirection: (dir: DiagramOrientation) => void; commit: (msg: string, id: string, type: number, tags?: string[]) => void; branch: (name: string, order?: number) => void; From b93691be0e93044778ca5277f215376c4acad7cd Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Tue, 20 Aug 2024 01:00:13 -0400 Subject: [PATCH 045/124] fixed small error --- packages/mermaid/src/diagrams/git/gitGraphAst.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index c7ee21a14..0b09a6687 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -215,7 +215,7 @@ export const merge = ( const verifiedBranch: string = otherBranchCheck ? otherBranchCheck : ''; //figure out a cleaner way to do this const commit = { - id: customId ?? `${state.records.seq}-${getID()}`, + id: customId || `${state.records.seq}-${getID()}`, message: `merged branch ${otherBranch} into ${state.records.currBranch}`, seq: state.records.seq++, parents: state.records.head == null ? [] : [state.records.head.id, verifiedBranch], From d9d9cc9ddc8584ba5ba89a978c35cd04c5f3cf32 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Tue, 20 Aug 2024 06:06:19 -0400 Subject: [PATCH 046/124] added objects to be transfered from parser to db --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 1 + .../mermaid/src/diagrams/git/gitGraphTypes.ts | 32 +++++++++++++++---- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 0b09a6687..174283670 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -15,6 +15,7 @@ import { commitType } from './gitGraphTypes.js'; import { ImperativeState } from '../../utils/imperativeState.js'; import DEFAULT_CONFIG from '../../defaultConfig.js'; + import type { GitGraphDiagramConfig } from '../../config.type.js'; interface GitGraphState { commits: Map; diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index 0b1b4f714..90156cc58 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -9,13 +9,31 @@ export const commitType = { CHERRY_PICK: 4, } as const; -export const gitcommitType = { - NORMAL: 0, - REVERSE: 1, - HIGHLIGHT: 2, - MERGE: 3, - CHERRY_PICK: 4, -} as const; +export interface CommitDB { + message: string; + id: string; + type: typeof commitType; + tags?: string[]; +} + +export interface BranchDB { + name: string; + order: number; +} + +export interface MergeDB { + branch: string; + id: string; + type?: typeof commitType; + tags?: string[]; +} + +export interface CherryPickDB { + id: string; + targetId: string; + parent: string; + tags?: string[]; +} export interface Commit { id: string; From 7a7b41557d6494e3bd33614c36561158e40f5352 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Tue, 20 Aug 2024 06:37:49 -0400 Subject: [PATCH 047/124] implemented transfer objects from parser to db --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 43 ++++--- .../src/diagrams/git/gitGraphParser.ts | 107 ++++++++++++------ .../mermaid/src/diagrams/git/gitGraphTypes.ts | 42 ++----- 3 files changed, 109 insertions(+), 83 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 174283670..99d5340cd 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -10,7 +10,15 @@ import { setDiagramTitle, getDiagramTitle, } from '../common/commonDb.js'; -import type { DiagramOrientation, Commit, GitGraphDB } from './gitGraphTypes.js'; +import type { + DiagramOrientation, + Commit, + GitGraphDB, + CommitDB, + MergeDB, + BranchDB, + CherryPickDB, +} from './gitGraphTypes.js'; import { commitType } from './gitGraphTypes.js'; import { ImperativeState } from '../../utils/imperativeState.js'; @@ -86,7 +94,12 @@ export const getOptions = function () { return state.records.options; }; -export const commit = function (msg: string, id: string, type: number, tags?: string[]) { +export const commit = function (commitDB: CommitDB) { + let msg = commitDB.msg; + let id = commitDB.id; + const type = commitDB.type; + let tags = commitDB.tags; + log.info('commit', msg, id, type, tags); log.debug('Entering commit:', msg, id, type, tags); const config = getConfig(); @@ -109,7 +122,9 @@ export const commit = function (msg: string, id: string, type: number, tags?: st log.debug('in pushCommit ' + newCommit.id); }; -export const branch = function (name: string, order?: number) { +export const branch = function (branchDB: BranchDB) { + let name = branchDB.name; + const order = branchDB.order; name = common.sanitizeText(name, getConfig()); if (state.records.branches.has(name)) { throw new Error( @@ -123,12 +138,11 @@ export const branch = function (name: string, order?: number) { log.debug('in createBranch'); }; -export const merge = ( - otherBranch: string, - customId?: string, - overrideType?: number, - customTags?: string[] -): void => { +export const merge = (mergeDB: MergeDB): void => { + let otherBranch = mergeDB.branch; + let customId = mergeDB.id; + const overrideType = mergeDB.type; + const customTags = mergeDB.tags; const config = getConfig(); otherBranch = common.sanitizeText(otherBranch, config); if (customId) { @@ -233,12 +247,11 @@ export const merge = ( log.debug('in mergeBranch'); }; -export const cherryPick = function ( - sourceId: string, - targetId: string, - tags: string[] | undefined, - parentCommitId: string -) { +export const cherryPick = function (cherryPickDB: CherryPickDB) { + let sourceId = cherryPickDB.id; + let targetId = cherryPickDB.targetId; + let tags = cherryPickDB.tags; + let parentCommitId = cherryPickDB.parent; log.debug('Entering cherryPick:', sourceId, targetId, tags); const config = getConfig(); sourceId = common.sanitizeText(sourceId, config); diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index 6be06e84d..a6911d442 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -12,6 +12,10 @@ import type { CommitAst, BranchAst, GitGraphDBParseProvider, + CommitDB, + BranchDB, + MergeDB, + CherryPickDB, } from './gitGraphTypes.js'; const populate = (ast: GitGraph, db: GitGraphDBParseProvider) => { @@ -28,11 +32,11 @@ const populate = (ast: GitGraph, db: GitGraphDBParseProvider) => { const parseStatement = (statement: any, db: GitGraphDBParseProvider) => { const parsers: Record void> = { - Commit: (stmt) => db.commit(...parseCommit(stmt)), - Branch: (stmt) => db.branch(...parseBranch(stmt)), - Merge: (stmt) => db.merge(...parseMerge(stmt)), + Commit: (stmt) => db.commit(parseCommit(stmt)), + Branch: (stmt) => db.branch(parseBranch(stmt)), + Merge: (stmt) => db.merge(parseMerge(stmt)), Checkout: (stmt) => db.checkout(parseCheckout(stmt)), - CherryPicking: (stmt) => db.cherryPick(...parseCherryPicking(stmt)), + CherryPicking: (stmt) => db.cherryPick(parseCherryPicking(stmt)), }; const parser = parsers[statement.$type]; @@ -43,29 +47,32 @@ const parseStatement = (statement: any, db: GitGraphDBParseProvider) => { } }; -const parseCommit = (commit: CommitAst): [string, string, number, string[] | undefined] => { - const id = commit.id; - const message = commit.message ?? ''; - const type = commit.type !== undefined ? commitType[commit.type] : commitType.NORMAL; - const tags = commit.tags ?? undefined; - - return [message, id, type, tags]; +const parseCommit = (commit: CommitAst): CommitDB => { + const commitDB: CommitDB = { + id: commit.id, + msg: commit.message ?? '', + type: commit.type !== undefined ? commitType[commit.type] : commitType.NORMAL, + tags: commit.tags ?? undefined, + }; + return commitDB; }; -const parseBranch = (branch: BranchAst): [string, number] => { - const name = branch.name; - const order = branch.order ?? 0; - return [name, order]; +const parseBranch = (branch: BranchAst): BranchDB => { + const branchDB: BranchDB = { + name: branch.name, + order: branch.order ?? 0, + }; + return branchDB; }; -const parseMerge = ( - merge: MergeAst -): [string, string, number | undefined, string[] | undefined] => { - const branch = merge.branch; - const id = merge.id ?? ''; - const type = merge.type !== undefined ? commitType[merge.type] : undefined; - const tags = merge.tags ?? undefined; - return [branch, id, type, tags]; +const parseMerge = (merge: MergeAst): MergeDB => { + const mergeDB: MergeDB = { + branch: merge.branch, + id: merge.id ?? '', + type: merge.type !== undefined ? commitType[merge.type] : commitType.NORMAL, + tags: merge.tags ?? undefined, + }; + return mergeDB; }; const parseCheckout = (checkout: CheckoutAst): string => { @@ -73,13 +80,14 @@ const parseCheckout = (checkout: CheckoutAst): string => { return branch; }; -const parseCherryPicking = ( - cherryPicking: CherryPickingAst -): [string, string, string[] | undefined, string] => { - const id = cherryPicking.id; - const tags = cherryPicking.tags?.length === 0 ? undefined : cherryPicking.tags; - const parent = cherryPicking.parent; - return [id, '', tags, parent]; +const parseCherryPicking = (cherryPicking: CherryPickingAst): CherryPickDB => { + const cherryPickDB: CherryPickDB = { + id: cherryPicking.id, + targetId: '', + tags: cherryPicking.tags?.length === 0 ? undefined : cherryPicking.tags, + parent: cherryPicking.parent, + }; + return cherryPickDB; }; export const parser: ParserDefinition = { @@ -113,7 +121,12 @@ if (import.meta.vitest) { type: 'NORMAL', }; parseStatement(commit, mockDB); - expect(mockDB.commit).toHaveBeenCalledWith('test', '1', 0, ['tag1', 'tag2']); + expect(mockDB.commit).toHaveBeenCalledWith({ + id: '1', + msg: 'test', + tags: ['tag1', 'tag2'], + type: 0, + }); }); it('should parse a branch statement', () => { const branch = { @@ -122,7 +135,7 @@ if (import.meta.vitest) { order: 1, }; parseStatement(branch, mockDB); - expect(mockDB.branch).toHaveBeenCalledWith('newBranch', 1); + expect(mockDB.branch).toHaveBeenCalledWith({ name: 'newBranch', order: 1 }); }); it('should parse a checkout statement', () => { const checkout = { @@ -141,7 +154,12 @@ if (import.meta.vitest) { type: 'NORMAL', }; parseStatement(merge, mockDB); - expect(mockDB.merge).toHaveBeenCalledWith('newBranch', '1', 0, ['tag1', 'tag2']); + expect(mockDB.merge).toHaveBeenCalledWith({ + branch: 'newBranch', + id: '1', + tags: ['tag1', 'tag2'], + type: 0, + }); }); it('should parse a cherry picking statement', () => { const cherryPick = { @@ -151,7 +169,12 @@ if (import.meta.vitest) { parent: '2', }; parseStatement(cherryPick, mockDB); - expect(mockDB.cherryPick).toHaveBeenCalledWith('1', '', ['tag1', 'tag2'], '2'); + expect(mockDB.cherryPick).toHaveBeenCalledWith({ + id: '1', + targetId: '', + parent: '2', + tags: ['tag1', 'tag2'], + }); }); it('should parse a langium generated gitGraph ast', () => { @@ -201,9 +224,19 @@ if (import.meta.vitest) { populate(gitGraphAst, mockDB); - expect(mockDB.commit).toHaveBeenCalledWith('test', '1', 0, ['tag1', 'tag2']); - expect(mockDB.branch).toHaveBeenCalledWith('newBranch', 1); - expect(mockDB.merge).toHaveBeenCalledWith('newBranch', '1', 0, ['tag1', 'tag2']); + expect(mockDB.commit).toHaveBeenCalledWith({ + id: '1', + msg: 'test', + tags: ['tag1', 'tag2'], + type: 0, + }); + expect(mockDB.branch).toHaveBeenCalledWith({ name: 'newBranch', order: 1 }); + expect(mockDB.merge).toHaveBeenCalledWith({ + branch: 'newBranch', + id: '1', + tags: ['tag1', 'tag2'], + type: 0, + }); expect(mockDB.checkout).toHaveBeenCalledWith('newBranch'); }); }); diff --git a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts index 90156cc58..32b951bcc 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphTypes.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphTypes.ts @@ -10,9 +10,9 @@ export const commitType = { } as const; export interface CommitDB { - message: string; + msg: string; id: string; - type: typeof commitType; + type: number; tags?: string[]; } @@ -24,7 +24,7 @@ export interface BranchDB { export interface MergeDB { branch: string; id: string; - type?: typeof commitType; + type?: number; tags?: string[]; } @@ -92,20 +92,10 @@ export interface GitGraphDB extends DiagramDBBase { setDirection: (dir: DiagramOrientation) => void; setOptions: (rawOptString: string) => void; getOptions: () => any; - commit: (msg: string, id: string, type: number, tags?: string[]) => void; - branch: (name: string, order?: number) => void; - merge: ( - otherBranch: string, - customId?: string, - overrideType?: number, - customTags?: string[] - ) => void; - cherryPick: ( - sourceId: string, - targetId: string, - tags: string[] | undefined, - parentCommitId: string - ) => void; + commit: (commitDB: CommitDB) => void; + branch: (branchDB: BranchDB) => void; + merge: (mergeDB: MergeDB) => void; + cherryPick: (cherryPickDB: CherryPickDB) => void; checkout: (branch: string) => void; prettyPrint: () => void; clear: () => void; @@ -121,20 +111,10 @@ export interface GitGraphDB extends DiagramDBBase { export interface GitGraphDBParseProvider extends Partial { commitType: typeof commitType; setDirection: (dir: DiagramOrientation) => void; - commit: (msg: string, id: string, type: number, tags?: string[]) => void; - branch: (name: string, order?: number) => void; - merge: ( - otherBranch: string, - customId?: string, - overrideType?: number, - customTags?: string[] - ) => void; - cherryPick: ( - sourceId: string, - targetId: string, - tags: string[] | undefined, - parentCommitId: string - ) => void; + commit: (commitDB: CommitDB) => void; + branch: (branchDB: BranchDB) => void; + merge: (mergeDB: MergeDB) => void; + cherryPick: (cherryPickDB: CherryPickDB) => void; checkout: (branch: string) => void; } From 94ee076aad40b4009df672a8be9f17f03403f006 Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Tue, 20 Aug 2024 06:46:33 -0400 Subject: [PATCH 048/124] fixed config for user configs --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 99d5340cd..4b61c3563 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -1,5 +1,6 @@ import { log } from '../../logger.js'; -import { random } from '../../utils.js'; +import { cleanAndMerge, random } from '../../utils.js'; +import { getConfig as commonGetConfig } from '../../config.js'; import common from '../common/common.js'; import { setAccTitle, @@ -37,12 +38,16 @@ interface GitGraphState { } const DEFAULT_GITGRAPH_CONFIG: Required = DEFAULT_CONFIG.gitGraph; - -const mainBranchName = DEFAULT_GITGRAPH_CONFIG.mainBranchName; -const mainBranchOrder = DEFAULT_GITGRAPH_CONFIG.mainBranchOrder; -const config: Required = structuredClone(DEFAULT_GITGRAPH_CONFIG); - -const getConfig = (): Required => structuredClone(config); +const getConfig = (): Required => { + const config = cleanAndMerge({ + ...DEFAULT_GITGRAPH_CONFIG, + ...commonGetConfig().gitGraph, + }); + return config; +}; +const config = getConfig(); +const mainBranchName = config.mainBranchName; +const mainBranchOrder = config.mainBranchOrder; const state = new ImperativeState(() => ({ commits: new Map(), From 3ac242978ddc42e02c2ee569d6da72076a4028eb Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Tue, 20 Aug 2024 07:04:05 -0400 Subject: [PATCH 049/124] fixed merge --- packages/mermaid/src/diagrams/git/gitGraphParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphParser.ts b/packages/mermaid/src/diagrams/git/gitGraphParser.ts index a6911d442..c56bc6f44 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphParser.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphParser.ts @@ -69,7 +69,7 @@ const parseMerge = (merge: MergeAst): MergeDB => { const mergeDB: MergeDB = { branch: merge.branch, id: merge.id ?? '', - type: merge.type !== undefined ? commitType[merge.type] : commitType.NORMAL, + type: merge.type !== undefined ? commitType[merge.type] : undefined, tags: merge.tags ?? undefined, }; return mergeDB; From 24ba5b73da6bba144bac5535ff90bc6260c3f05b Mon Sep 17 00:00:00 2001 From: Austin Fulbright Date: Tue, 20 Aug 2024 14:53:01 -0400 Subject: [PATCH 050/124] added gitgraph in imperative state --- .../mermaid/src/diagrams/git/gitGraphAst.ts | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/packages/mermaid/src/diagrams/git/gitGraphAst.ts b/packages/mermaid/src/diagrams/git/gitGraphAst.ts index 4b61c3563..44597e9d7 100644 --- a/packages/mermaid/src/diagrams/git/gitGraphAst.ts +++ b/packages/mermaid/src/diagrams/git/gitGraphAst.ts @@ -45,20 +45,23 @@ const getConfig = (): Required => { }); return config; }; -const config = getConfig(); -const mainBranchName = config.mainBranchName; -const mainBranchOrder = config.mainBranchOrder; -const state = new ImperativeState(() => ({ - commits: new Map(), - head: null, - branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]), - branches: new Map([[mainBranchName, null]]), - currBranch: mainBranchName, - direction: 'LR', - seq: 0, - options: {}, -})); +const state = new ImperativeState(() => { + const config = getConfig(); + const mainBranchName = config.mainBranchName; + const mainBranchOrder = config.mainBranchOrder; + return { + mainBranchName, + commits: new Map(), + head: null, + branchConfig: new Map([[mainBranchName, { name: mainBranchName, order: mainBranchOrder }]]), + branches: new Map([[mainBranchName, null]]), + currBranch: mainBranchName, + direction: 'LR', + seq: 0, + options: {}, + }; +}); function getID() { return random({ length: 7 }); @@ -121,7 +124,7 @@ export const commit = function (commitDB: CommitDB) { branch: state.records.currBranch, }; state.records.head = newCommit; - log.info('main branch', mainBranchName); + log.info('main branch', config.mainBranchName); state.records.commits.set(newCommit.id, newCommit); state.records.branches.set(state.records.currBranch, newCommit.id); log.debug('in pushCommit ' + newCommit.id); From 3eaf8b717770a119cd0ea5303632b6430330f239 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Wed, 21 Aug 2024 19:54:59 +0530 Subject: [PATCH 051/124] feat: Add changesets --- .changeset/README.md | 8 + .changeset/config.json | 11 + package.json | 1 + packages/mermaid/src/docs/package.json | 3 +- pnpm-lock.yaml | 848 ++++++++++++++++++++----- tests/webpack/package.json | 2 +- 6 files changed, 705 insertions(+), 168 deletions(-) create mode 100644 .changeset/README.md create mode 100644 .changeset/config.json diff --git a/.changeset/README.md b/.changeset/README.md new file mode 100644 index 000000000..e5b6d8d6a --- /dev/null +++ b/.changeset/README.md @@ -0,0 +1,8 @@ +# Changesets + +Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works +with multi-package repos, or single-package repos to help you version and publish your code. You can +find the full documentation for it [in our repository](https://github.com/changesets/changesets) + +We have a quick list of common questions to get you started engaging with this project in +[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) diff --git a/.changeset/config.json b/.changeset/config.json new file mode 100644 index 000000000..c44652e6d --- /dev/null +++ b/.changeset/config.json @@ -0,0 +1,11 @@ +{ + "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", + "changelog": "@changesets/cli/changelog", + "commit": false, + "fixed": [], + "linked": [], + "access": "restricted", + "baseBranch": "develop", + "updateInternalDependencies": "patch", + "ignore": [] +} diff --git a/package.json b/package.json index fecb919d6..4b77591e2 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "devDependencies": { "@applitools/eyes-cypress": "^3.44.4", "@argos-ci/cypress": "^2.1.0", + "@changesets/cli": "^2.27.7", "@cspell/eslint-plugin": "^8.8.4", "@cypress/code-coverage": "^3.12.30", "@eslint/js": "^9.4.0", diff --git a/packages/mermaid/src/docs/package.json b/packages/mermaid/src/docs/package.json index 146c4d2d8..7cfb8ab6c 100644 --- a/packages/mermaid/src/docs/package.json +++ b/packages/mermaid/src/docs/package.json @@ -1,6 +1,7 @@ { - "name": "docs", + "name": "@mermaid-js/docs", "private": true, + "version": "0.0.1", "type": "module", "scripts": { "dev": "vitepress --port 3333 --open", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2a6b02fd4..22b554ae5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,22 +10,25 @@ importers: devDependencies: '@applitools/eyes-cypress': specifier: ^3.44.4 - version: 3.44.6(typescript@5.4.5) + version: 3.44.6(encoding@0.1.13)(typescript@5.4.5) '@argos-ci/cypress': specifier: ^2.1.0 version: 2.1.1(cypress@13.13.2) + '@changesets/cli': + specifier: ^2.27.7 + version: 2.27.7 '@cspell/eslint-plugin': specifier: ^8.8.4 version: 8.13.1(eslint@9.8.0) '@cypress/code-coverage': specifier: ^3.12.30 - version: 3.12.44(@babel/core@7.25.2)(@babel/preset-env@7.25.3)(babel-loader@9.1.3)(cypress@13.13.2)(webpack@5.93.0) + version: 3.12.44(@babel/core@7.25.2)(@babel/preset-env@7.25.3(@babel/core@7.25.2))(babel-loader@9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)))(cypress@13.13.2)(webpack@5.93.0(esbuild@0.21.5)) '@eslint/js': specifier: ^9.4.0 version: 9.8.0 '@rollup/plugin-typescript': specifier: ^11.1.6 - version: 11.1.6(typescript@5.4.5) + version: 11.1.6(rollup@4.20.0)(tslib@2.6.3)(typescript@5.4.5) '@types/cors': specifier: ^2.8.17 version: 2.8.17 @@ -52,7 +55,7 @@ importers: version: 4.2.4 '@vitest/coverage-v8': specifier: ^1.4.0 - version: 1.6.0(vitest@1.6.0) + version: 1.6.0(vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3)) '@vitest/spy': specifier: ^1.4.0 version: 1.6.0 @@ -82,7 +85,7 @@ importers: version: 13.13.2 cypress-image-snapshot: specifier: ^4.0.1 - version: 4.0.1(cypress@13.13.2)(jest@29.7.0) + version: 4.0.1(cypress@13.13.2)(jest@29.7.0(@types/node@20.14.14)) esbuild: specifier: ^0.21.5 version: 0.21.5 @@ -100,7 +103,7 @@ importers: version: 8.1.1 eslint-plugin-jest: specifier: ^28.6.0 - version: 28.7.0(eslint@9.8.0)(jest@29.7.0)(typescript@5.4.5) + version: 28.7.0(@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(jest@29.7.0(@types/node@20.14.14))(typescript@5.4.5) eslint-plugin-jsdoc: specifier: ^48.2.9 version: 48.11.0(eslint@9.8.0) @@ -175,7 +178,7 @@ importers: version: 5.0.10 rollup-plugin-visualizer: specifier: ^5.12.0 - version: 5.12.0 + version: 5.12.0(rollup@4.20.0) start-server-and-test: specifier: ^2.0.3 version: 2.0.5 @@ -190,13 +193,13 @@ importers: version: 8.0.0(eslint@9.8.0)(typescript@5.4.5) vite: specifier: ^5.2.3 - version: 5.3.5(@types/node@20.14.14) + version: 5.3.5(@types/node@20.14.14)(terser@5.31.3) vite-plugin-istanbul: specifier: ^6.0.0 - version: 6.0.2(vite@5.3.5) + version: 6.0.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) vitest: specifier: ^1.4.0 - version: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1) + version: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3) packages/mermaid: dependencies: @@ -362,7 +365,7 @@ importers: version: 0.25.13(typescript@5.4.5) typedoc-plugin-markdown: specifier: ^3.17.1 - version: 3.17.1(typedoc@0.25.13) + version: 3.17.1(typedoc@0.25.13(typescript@5.4.5)) typescript: specifier: ~5.4.3 version: 5.4.5 @@ -374,10 +377,10 @@ importers: version: 5.0.0 vitepress: specifier: ^1.0.1 - version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(postcss@8.4.40)(search-insights@2.15.0)(typescript@5.4.5) + version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(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.35) + version: 1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5))(vue@3.4.35(typescript@5.4.5)) packages/mermaid-example-diagram: dependencies: @@ -401,31 +404,6 @@ importers: specifier: ^5.0.5 version: 5.0.10 - packages/mermaid-flowchart-elk: - dependencies: - d3: - specifier: ^7.9.0 - version: 7.9.0 - dagre-d3-es: - specifier: 7.0.10 - version: 7.0.10 - elkjs: - specifier: ^0.9.2 - version: 0.9.3 - khroma: - specifier: ^2.1.0 - version: 2.1.0 - devDependencies: - concurrently: - specifier: ^8.2.2 - version: 8.2.2 - mermaid: - specifier: workspace:^ - version: link:../mermaid - rimraf: - specifier: ^5.0.5 - version: 5.0.10 - packages/mermaid-layout-elk: dependencies: d3: @@ -455,7 +433,7 @@ importers: version: 7.4.47 '@vueuse/core': specifier: ^10.9.0 - version: 10.11.0(vue@3.4.35) + version: 10.11.0(vue@3.4.35(typescript@5.4.5)) font-awesome: specifier: ^4.7.0 version: 4.7.0 @@ -477,10 +455,10 @@ importers: version: 0.59.4 '@vite-pwa/vitepress': specifier: ^0.4.0 - version: 0.4.0(vite-plugin-pwa@0.19.8) + version: 0.4.0(vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0)) '@vitejs/plugin-vue': specifier: ^5.0.0 - version: 5.1.2(vite@5.3.5)(vue@3.4.35) + version: 5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(vue@3.4.35(typescript@5.4.5)) fast-glob: specifier: ^3.3.2 version: 3.3.2 @@ -492,19 +470,19 @@ importers: version: 1.1.2 unocss: specifier: ^0.59.0 - version: 0.59.4(postcss@8.4.40)(rollup@2.79.1)(vite@5.3.5) + version: 0.59.4(postcss@8.4.40)(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) unplugin-vue-components: specifier: ^0.26.0 - version: 0.26.0(rollup@2.79.1)(vue@3.4.35) + version: 0.26.0(@babel/parser@7.25.3)(rollup@2.79.1)(vue@3.4.35(typescript@5.4.5)) vite: specifier: ^5.0.0 - version: 5.3.5(@types/node@20.14.14) + version: 5.3.5(@types/node@20.14.14)(terser@5.31.3) vite-plugin-pwa: specifier: ^0.19.7 - version: 0.19.8(vite@5.3.5)(workbox-build@7.1.1)(workbox-window@7.1.0) + version: 0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) vitepress: specifier: 1.1.4 - version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(postcss@8.4.40)(search-insights@2.15.0)(typescript@5.4.5) + version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5) workbox-window: specifier: ^7.0.0 version: 7.1.0 @@ -1374,6 +1352,61 @@ packages: '@braintree/sanitize-url@7.1.0': resolution: {integrity: sha512-o+UlMLt49RvtCASlOMW0AkHnabN9wR9rwCCherxO0yG4Npy34GkvrAqdXQvrhNs+jh+gkK8gB8Lf05qL/O7KWg==} + '@changesets/apply-release-plan@7.0.4': + resolution: {integrity: sha512-HLFwhKWayKinWAul0Vj+76jVx1Pc2v55MGPVjZ924Y/ROeSsBMFutv9heHmCUj48lJyRfOTJG5+ar+29FUky/A==} + + '@changesets/assemble-release-plan@6.0.3': + resolution: {integrity: sha512-bLNh9/Lgl1VwkjWZTq8JmRqH+hj7/Yzfz0jsQ/zJJ+FTmVqmqPj3szeKOri8O/hEM8JmHW019vh2gTO9iq5Cuw==} + + '@changesets/changelog-git@0.2.0': + resolution: {integrity: sha512-bHOx97iFI4OClIT35Lok3sJAwM31VbUM++gnMBV16fdbtBhgYu4dxsphBF/0AZZsyAHMrnM0yFcj5gZM1py6uQ==} + + '@changesets/cli@2.27.7': + resolution: {integrity: sha512-6lr8JltiiXPIjDeYg4iM2MeePP6VN/JkmqBsVA5XRiy01hGS3y629LtSDvKcycj/w/5Eur1rEwby/MjcYS+e2A==} + hasBin: true + + '@changesets/config@3.0.2': + resolution: {integrity: sha512-cdEhS4t8woKCX2M8AotcV2BOWnBp09sqICxKapgLHf9m5KdENpWjyrFNMjkLqGJtUys9U+w93OxWT0czorVDfw==} + + '@changesets/errors@0.2.0': + resolution: {integrity: sha512-6BLOQUscTpZeGljvyQXlWOItQyU71kCdGz7Pi8H8zdw6BI0g3m43iL4xKUVPWtG+qrrL9DTjpdn8eYuCQSRpow==} + + '@changesets/get-dependents-graph@2.1.1': + resolution: {integrity: sha512-LRFjjvigBSzfnPU2n/AhFsuWR5DK++1x47aq6qZ8dzYsPtS/I5mNhIGAS68IAxh1xjO9BTtz55FwefhANZ+FCA==} + + '@changesets/get-release-plan@4.0.3': + resolution: {integrity: sha512-6PLgvOIwTSdJPTtpdcr3sLtGatT+Jr22+cQwEBJBy6wP0rjB4yJ9lv583J9fVpn1bfQlBkDa8JxbS2g/n9lIyA==} + + '@changesets/get-version-range-type@0.4.0': + resolution: {integrity: sha512-hwawtob9DryoGTpixy1D3ZXbGgJu1Rhr+ySH2PvTLHvkZuQ7sRT4oQwMh0hbqZH1weAooedEjRsbrWcGLCeyVQ==} + + '@changesets/git@3.0.0': + resolution: {integrity: sha512-vvhnZDHe2eiBNRFHEgMiGd2CT+164dfYyrJDhwwxTVD/OW0FUD6G7+4DIx1dNwkwjHyzisxGAU96q0sVNBns0w==} + + '@changesets/logger@0.1.0': + resolution: {integrity: sha512-pBrJm4CQm9VqFVwWnSqKEfsS2ESnwqwH+xR7jETxIErZcfd1u2zBSqrHbRHR7xjhSgep9x2PSKFKY//FAshA3g==} + + '@changesets/parse@0.4.0': + resolution: {integrity: sha512-TS/9KG2CdGXS27S+QxbZXgr8uPsP4yNJYb4BC2/NeFUj80Rni3TeD2qwWmabymxmrLo7JEsytXH1FbpKTbvivw==} + + '@changesets/pre@2.0.0': + resolution: {integrity: sha512-HLTNYX/A4jZxc+Sq8D1AMBsv+1qD6rmmJtjsCJa/9MSRybdxh0mjbTvE6JYZQ/ZiQ0mMlDOlGPXTm9KLTU3jyw==} + + '@changesets/read@0.6.0': + resolution: {integrity: sha512-ZypqX8+/im1Fm98K4YcZtmLKgjs1kDQ5zHpc2U1qdtNBmZZfo/IBiG162RoP0CUF05tvp2y4IspH11PLnPxuuw==} + + '@changesets/should-skip-package@0.1.0': + resolution: {integrity: sha512-FxG6Mhjw7yFStlSM7Z0Gmg3RiyQ98d/9VpQAZ3Fzr59dCOM9G6ZdYbjiSAt0XtFr9JR5U2tBaJWPjrkGGc618g==} + + '@changesets/types@4.1.0': + resolution: {integrity: sha512-LDQvVDv5Kb50ny2s25Fhm3d9QSZimsoUGBsUioj6MC3qbMUCuC8GPIvk/M6IvXx3lYhAs0lwWUQLb+VIEUCECw==} + + '@changesets/types@6.0.0': + resolution: {integrity: sha512-b1UkfNulgKoWfqyHtzKS5fOZYSJO+77adgL7DLRDr+/7jhChN+QcHnbjiQVOz/U+Ts3PGNySq7diAItzDgugfQ==} + + '@changesets/write@0.3.1': + resolution: {integrity: sha512-SyGtMXzH3qFqlHKcvFY2eX+6b0NGiFcNav8AFsYwy5l8hejOeoeTDemu5Yjmke2V5jpzY+pBvM0vCCQ3gdZpfw==} + '@chevrotain/cst-dts-gen@11.0.3': resolution: {integrity: sha512-BvIKpRLeS/8UbfxXxgC33xOumsacaeCKAjAeLyOn7Pcp95HiRbrpl14S+9vaZLolnbssPIUuiUd8IvgkRyt6NQ==} @@ -2093,6 +2126,12 @@ packages: '@leichtgewicht/ip-codec@2.0.5': resolution: {integrity: sha512-Vo+PSpZG2/fmgmiNzYK9qWRh8h/CHrwD0mo1h1DzL4yzHNSfWYujGTYsWGreD000gcgmZ7K4Ys6Tx9TxtsKdDw==} + '@manypkg/find-root@1.1.0': + resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} + + '@manypkg/get-packages@1.1.3': + resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} + '@mdi/font@7.4.47': resolution: {integrity: sha512-43MtGpd585SNzHZPcYowu/84Vz2a2g31TvPMTm9uTiCSWzaheQySUcSyUH/46fPnuPQWof2yd0pGBtzee/IQWw==} @@ -2573,6 +2612,9 @@ packages: '@types/node-forge@1.3.11': resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==} + '@types/node@12.20.55': + resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} + '@types/node@18.19.43': resolution: {integrity: sha512-Mw/YlgXnyJdEwLoFv2dpuJaDFriX+Pc+0qOBJ57jC1H6cDxIj2xc5yUrdtArDVG0m+KV6622a4p2tenEqB3C/g==} @@ -2610,6 +2652,9 @@ packages: '@types/rollup-plugin-visualizer@4.2.4': resolution: {integrity: sha512-BW4Q6D1Qy5gno5qHWrnMDC2dOe/TAKXvqCpckOggCCu+XpS+ZZJJ1lq1+K3bvYccoO3Y7f5kglbFAgYGqCgULg==} + '@types/semver@7.5.8': + resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==} + '@types/send@0.17.4': resolution: {integrity: sha512-x2EM6TJOybec7c52BX0ZspPodMsQUd5L6PRwOunVyVUhXiBSKf3AezDL8Dgvgt5o0UfKNfuA0eMLr2wLT4AiBA==} @@ -3362,6 +3407,10 @@ packages: bcrypt-pbkdf@1.0.2: resolution: {integrity: sha512-qeFIXtP4MSoi6NLqO12WfqARWWuCKi2Rn/9hJLEmtB5yTNr9DqFWkJRCf2qShWzPeAMRnOgCrq0sg/KLv5ES9w==} + better-path-resolve@1.0.0: + resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} + engines: {node: '>=4'} + binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} @@ -3543,6 +3592,9 @@ packages: character-reference-invalid@1.1.4: resolution: {integrity: sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==} + chardet@0.7.0: + resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + check-error@1.0.3: resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} @@ -3829,6 +3881,9 @@ packages: engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} hasBin: true + cross-spawn@5.1.0: + resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} + cross-spawn@6.0.5: resolution: {integrity: sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==} engines: {node: '>=4.8'} @@ -4242,6 +4297,10 @@ packages: resolution: {integrity: sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==} engines: {node: '>= 0.8', npm: 1.2.8000 || >= 1.4.16} + detect-indent@6.1.0: + resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} + engines: {node: '>=8'} + detect-libc@2.0.3: resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} engines: {node: '>=8'} @@ -4663,6 +4722,13 @@ packages: extend@3.0.2: resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} + extendable-error@0.1.7: + resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==} + + external-editor@3.1.0: + resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==} + engines: {node: '>=4'} + extract-zip@2.0.1: resolution: {integrity: sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==} engines: {node: '>= 10.17.0'} @@ -4810,6 +4876,9 @@ packages: resolution: {integrity: sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + find-yarn-workspace-root2@1.2.16: + resolution: {integrity: sha512-hr6hb1w8ePMpPVUK39S4RlwJzi+xPLuVuG8XlwXU3KD5Yn3qgBWVfy3AzNlDhWvE1EORCE65/Qm26rFQt3VLVA==} + flat-cache@4.0.1: resolution: {integrity: sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==} engines: {node: '>=16'} @@ -4903,6 +4972,10 @@ packages: resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} engines: {node: '>=6 <7 || >=8'} + fs-extra@8.1.0: + resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} + engines: {node: '>=6 <7 || >=8'} + fs-extra@9.1.0: resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} engines: {node: '>=10'} @@ -5231,6 +5304,9 @@ packages: resolution: {integrity: sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw==} engines: {node: '>= 14'} + human-id@1.0.2: + resolution: {integrity: sha512-UNopramDEhHJD+VR+ehk8rOslwSfByxPIZyJRfV739NDhN5LF1fa1MqnzKm2lGTQRjNrjK19Q5fhkgIfjlVUKw==} + human-signals@1.1.1: resolution: {integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw==} engines: {node: '>=8.12.0'} @@ -5498,6 +5574,10 @@ packages: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} + is-subdir@1.2.0: + resolution: {integrity: sha512-2AT6j+gXe/1ueqbW6fLZJiIw3F8iXGJtt0yDrZaBhAZEG1raiTxKWU+IPqMCzQAXOUCKdA4UDMgacKH25XG2Cw==} + engines: {node: '>=4'} + is-symbol@1.0.4: resolution: {integrity: sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==} engines: {node: '>= 0.4'} @@ -5958,6 +6038,10 @@ packages: resolution: {integrity: sha512-opevsywziHd3zHCVQGAj8zu+Z3yHNkkoYhWIGnq54RrCVwLz0MozotJEDnKsIBLvkfLGN6BLOyAeRrYI0pKA4g==} engines: {node: '>=18.0.0'} + load-yaml-file@0.2.0: + resolution: {integrity: sha512-OfCBkGEw4nN6JLtgRidPX6QxjBQGQf72q3si2uvqyFEMbycSFFHwAZeXx6cJgFM9wmLrf9zBwCP3Ivqa+LLZPw==} + engines: {node: '>=6'} + loader-runner@4.3.0: resolution: {integrity: sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==} engines: {node: '>=6.11.5'} @@ -6010,6 +6094,9 @@ packages: lodash.sortby@4.7.0: resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==} + lodash.startcase@4.4.0: + resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} + lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} @@ -6045,6 +6132,9 @@ packages: lru-cache@10.4.3: resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==} + lru-cache@4.1.5: + resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} + lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} @@ -6355,6 +6445,10 @@ packages: mlly@1.7.1: resolution: {integrity: sha512-rrVRZRELyQzrIUAVMHxP97kv+G786pHmOKzuFII8zDYahFBS7qnHh2AlYSl1GAHhaMPCz6/oHjVMcfFYgFYHgA==} + mri@1.2.0: + resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} + engines: {node: '>=4'} + mrmime@2.0.0: resolution: {integrity: sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw==} engines: {node: '>=10'} @@ -6535,9 +6629,16 @@ packages: resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} engines: {node: '>= 0.8.0'} + os-tmpdir@1.0.2: + resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} + engines: {node: '>=0.10.0'} + ospath@1.2.2: resolution: {integrity: sha512-o6E5qJV5zkAbIDNhGSIlyOhScKXgQrSRMilfph0clDfM0nEnBOlKlH4sWDmG95BW/CvwNz0vmm7dJVtU2KlMiA==} + outdent@0.5.0: + resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} + p-cancelable@2.1.1: resolution: {integrity: sha512-BZOr3nRQHOntUjTrH8+Lh54smKHoHyur8We1V8DSMVrl5A2malOOwuJRnKRDjSnkoeBh4at6BwEnb5I7Jl31wg==} engines: {node: '>=8'} @@ -6546,6 +6647,10 @@ packages: resolution: {integrity: sha512-dd589iCQ7m1L0bmC5NLlVYfy3TbBEsMUfWx9PyAgPeIcFZ/E2yaTZ4Rz4MiBmmJShviiftHVXOqfnfzJ6kyMrQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + p-filter@2.1.0: + resolution: {integrity: sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw==} + engines: {node: '>=8'} + p-filter@3.0.0: resolution: {integrity: sha512-QtoWLjXAW++uTX67HZQz1dbTpqBfiidsB6VtQUC9iR85S120+s0T5sO6s+B5MLzFcZkrEd/DGMmCjR+f2Qpxwg==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -6590,6 +6695,10 @@ packages: resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + p-map@2.1.0: + resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} + engines: {node: '>=6'} + p-map@3.0.0: resolution: {integrity: sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==} engines: {node: '>=8'} @@ -6740,6 +6849,10 @@ packages: resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} engines: {node: '>=0.10.0'} + pify@4.0.1: + resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} + engines: {node: '>=6'} + pino-abstract-transport@1.2.0: resolution: {integrity: sha512-Guhh8EZfPCfH+PMXAb6rKOjGQEoy0xlAIn+irODG5kgfYV+BQ0rGYYWTIel3P5mmyXqkYkPmdIkywsn6QKUR1Q==} @@ -6858,6 +6971,10 @@ packages: preact@10.23.1: resolution: {integrity: sha512-O5UdRsNh4vdZaTieWe3XOgSpdMAmkIYBCT3VhQDlKrzyCm8lUYsk0fmVEvoQQifoOjFRTaHZO69ylrzTW2BH+A==} + preferred-pm@3.1.4: + resolution: {integrity: sha512-lEHd+yEm22jXdCphDrkvIJQU66EuLojPPtvZkpKIkiD+l0DMThF/niqZKJSoU8Vl7iuvtmzyMhir9LdVy5WMnA==} + engines: {node: '>=10'} + prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -6926,6 +7043,9 @@ packages: engines: {node: '>= 0.10'} hasBin: true + pseudomap@1.0.2: + resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==} + psl@1.9.0: resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==} @@ -6991,6 +7111,10 @@ packages: resolution: {integrity: sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==} engines: {node: '>=8'} + read-yaml-file@1.1.0: + resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==} + engines: {node: '>=6'} + readable-stream@2.3.8: resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==} @@ -7440,6 +7564,9 @@ packages: resolution: {integrity: sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==} engines: {node: '>=8'} + spawndamnit@2.0.0: + resolution: {integrity: sha512-j4JKEcncSjFlqIwU5L/rp2N5SIPsdxaRsIv678+TZxZ0SRDJTm8JrxJMjE/XuiEZNEir3S8l0Fa3Ke339WI4qA==} + spdx-correct@3.2.0: resolution: {integrity: sha512-kN9dJbvnySHULIluDHy32WHRUu3Og7B9sbY7tsFLctQkIqnMh3hErYgdMjTYuqmcXX+lK5T1lnUt3G7zNswmZA==} @@ -7571,6 +7698,10 @@ packages: resolution: {integrity: sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==} engines: {node: '>=12'} + strip-bom@3.0.0: + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} + engines: {node: '>=4'} + strip-bom@4.0.0: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} @@ -7669,6 +7800,10 @@ packages: resolution: {integrity: sha512-DFpBhaF5j+2f7kheKFc1ajsAUUDGOaNPpKPtiIMxlbfud6mvfFZuWGnTRpaujUa5J7yl6cIw/h6nyr4mSsENPg==} engines: {node: '>=8'} + term-size@2.2.1: + resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==} + engines: {node: '>=8'} + terser-webpack-plugin@5.3.10: resolution: {integrity: sha512-BKFPWlPDndPs+NGGCr1U59t0XScL5317Y0UReNrHaw9/FwhPENlq6bfgs+4yPfyP51vqC1bQ4rp1EfXW5ZSH9w==} engines: {node: '>= 10.13.0'} @@ -7738,6 +7873,10 @@ packages: resolution: {integrity: sha512-KYad6Vy5VDWV4GH3fjpseMQ/XU2BhIYP7Vzd0LG44qRWm/Yt2WCOTicFdvmgo6gWaqooMQCawTtILVQJupKu7A==} engines: {node: '>=14.0.0'} + tmp@0.0.33: + resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==} + engines: {node: '>=0.6.0'} + tmp@0.2.3: resolution: {integrity: sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==} engines: {node: '>=14.14'} @@ -8358,6 +8497,10 @@ packages: which-module@2.0.1: resolution: {integrity: sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==} + which-pm@2.2.0: + resolution: {integrity: sha512-MOiaDbA5ZZgUjkeMWM5EkJp4loW5ZRoa5bc3/aeMox/PJelMhE6t7S/mLuiY43DBupyxH+S0U1bTui9kWUlmsw==} + engines: {node: '>=8.15'} + which-typed-array@1.1.15: resolution: {integrity: sha512-oV0jmFtUky6CXfkqehVvBP/LSWJ2sy4vWMioiENyJLePrBO/yKyV9OyJySfAKosh+RYkIl5zJCNZ8/4JncrpdA==} engines: {node: '>= 0.4'} @@ -8526,6 +8669,9 @@ packages: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} + yallist@2.1.2: + resolution: {integrity: sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==} + yallist@3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} @@ -8728,7 +8874,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@applitools/core@4.18.0(typescript@5.4.5)': + '@applitools/core@4.18.0(encoding@0.1.13)(typescript@5.4.5)': dependencies: '@applitools/core-base': 1.16.0 '@applitools/dom-capture': 11.3.0 @@ -8741,7 +8887,7 @@ snapshots: '@applitools/screenshoter': 3.8.35 '@applitools/snippets': 2.4.27 '@applitools/socket': 1.1.18 - '@applitools/spec-driver-webdriver': 1.1.11(webdriver@7.31.1) + '@applitools/spec-driver-webdriver': 1.1.11(webdriver@7.31.1(typescript@5.4.5)) '@applitools/ufg-client': 1.12.3 '@applitools/utils': 1.7.4 '@types/ws': 8.5.5 @@ -8794,7 +8940,7 @@ snapshots: '@applitools/logger': 2.0.18 '@applitools/req': 1.7.2 '@applitools/socket': 1.1.18 - '@applitools/spec-driver-webdriver': 1.1.11(webdriver@7.31.1) + '@applitools/spec-driver-webdriver': 1.1.11(webdriver@7.31.1(typescript@5.4.5)) '@applitools/tunnel-client': 1.5.7 '@applitools/utils': 1.7.4 abort-controller: 3.0.0 @@ -8830,10 +8976,10 @@ snapshots: transitivePeerDependencies: - supports-color - '@applitools/eyes-cypress@3.44.6(typescript@5.4.5)': + '@applitools/eyes-cypress@3.44.6(encoding@0.1.13)(typescript@5.4.5)': dependencies: - '@applitools/core': 4.18.0(typescript@5.4.5) - '@applitools/eyes': 1.22.0(typescript@5.4.5) + '@applitools/core': 4.18.0(encoding@0.1.13)(typescript@5.4.5) + '@applitools/eyes': 1.22.0(encoding@0.1.13)(typescript@5.4.5) '@applitools/functional-commons': 1.6.0 '@applitools/logger': 2.0.18 '@applitools/utils': 1.7.4 @@ -8849,9 +8995,9 @@ snapshots: - typescript - utf-8-validate - '@applitools/eyes@1.22.0(typescript@5.4.5)': + '@applitools/eyes@1.22.0(encoding@0.1.13)(typescript@5.4.5)': dependencies: - '@applitools/core': 4.18.0(typescript@5.4.5) + '@applitools/core': 4.18.0(encoding@0.1.13)(typescript@5.4.5) '@applitools/logger': 2.0.18 '@applitools/utils': 1.7.4 transitivePeerDependencies: @@ -8923,7 +9069,7 @@ snapshots: transitivePeerDependencies: - supports-color - '@applitools/spec-driver-webdriver@1.1.11(webdriver@7.31.1)': + '@applitools/spec-driver-webdriver@1.1.11(webdriver@7.31.1(typescript@5.4.5))': dependencies: '@applitools/driver': 1.18.0 '@applitools/utils': 1.7.4 @@ -9797,6 +9943,162 @@ snapshots: '@braintree/sanitize-url@7.1.0': {} + '@changesets/apply-release-plan@7.0.4': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/config': 3.0.2 + '@changesets/get-version-range-type': 0.4.0 + '@changesets/git': 3.0.0 + '@changesets/should-skip-package': 0.1.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + detect-indent: 6.1.0 + fs-extra: 7.0.1 + lodash.startcase: 4.4.0 + outdent: 0.5.0 + prettier: 2.8.8 + resolve-from: 5.0.0 + semver: 7.6.3 + + '@changesets/assemble-release-plan@6.0.3': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.1.1 + '@changesets/should-skip-package': 0.1.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + semver: 7.6.3 + + '@changesets/changelog-git@0.2.0': + dependencies: + '@changesets/types': 6.0.0 + + '@changesets/cli@2.27.7': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/apply-release-plan': 7.0.4 + '@changesets/assemble-release-plan': 6.0.3 + '@changesets/changelog-git': 0.2.0 + '@changesets/config': 3.0.2 + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.1.1 + '@changesets/get-release-plan': 4.0.3 + '@changesets/git': 3.0.0 + '@changesets/logger': 0.1.0 + '@changesets/pre': 2.0.0 + '@changesets/read': 0.6.0 + '@changesets/should-skip-package': 0.1.0 + '@changesets/types': 6.0.0 + '@changesets/write': 0.3.1 + '@manypkg/get-packages': 1.1.3 + '@types/semver': 7.5.8 + ansi-colors: 4.1.3 + chalk: 2.4.2 + ci-info: 3.9.0 + enquirer: 2.4.1 + external-editor: 3.1.0 + fs-extra: 7.0.1 + human-id: 1.0.2 + mri: 1.2.0 + outdent: 0.5.0 + p-limit: 2.3.0 + preferred-pm: 3.1.4 + resolve-from: 5.0.0 + semver: 7.6.3 + spawndamnit: 2.0.0 + term-size: 2.2.1 + + '@changesets/config@3.0.2': + dependencies: + '@changesets/errors': 0.2.0 + '@changesets/get-dependents-graph': 2.1.1 + '@changesets/logger': 0.1.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + fs-extra: 7.0.1 + micromatch: 4.0.7 + + '@changesets/errors@0.2.0': + dependencies: + extendable-error: 0.1.7 + + '@changesets/get-dependents-graph@2.1.1': + dependencies: + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + chalk: 2.4.2 + fs-extra: 7.0.1 + semver: 7.6.3 + + '@changesets/get-release-plan@4.0.3': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/assemble-release-plan': 6.0.3 + '@changesets/config': 3.0.2 + '@changesets/pre': 2.0.0 + '@changesets/read': 0.6.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + + '@changesets/get-version-range-type@0.4.0': {} + + '@changesets/git@3.0.0': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/errors': 0.2.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + is-subdir: 1.2.0 + micromatch: 4.0.7 + spawndamnit: 2.0.0 + + '@changesets/logger@0.1.0': + dependencies: + chalk: 2.4.2 + + '@changesets/parse@0.4.0': + dependencies: + '@changesets/types': 6.0.0 + js-yaml: 3.14.1 + + '@changesets/pre@2.0.0': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/errors': 0.2.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + fs-extra: 7.0.1 + + '@changesets/read@0.6.0': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/git': 3.0.0 + '@changesets/logger': 0.1.0 + '@changesets/parse': 0.4.0 + '@changesets/types': 6.0.0 + chalk: 2.4.2 + fs-extra: 7.0.1 + p-filter: 2.1.0 + + '@changesets/should-skip-package@0.1.0': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/types': 6.0.0 + '@manypkg/get-packages': 1.1.3 + + '@changesets/types@4.1.0': {} + + '@changesets/types@6.0.0': {} + + '@changesets/write@0.3.1': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/types': 6.0.0 + fs-extra: 7.0.1 + human-id: 1.0.2 + prettier: 2.8.8 + '@chevrotain/cst-dts-gen@11.0.3': dependencies: '@chevrotain/gast': 11.0.3 @@ -10010,12 +10312,12 @@ snapshots: '@cspell/url@8.13.1': {} - '@cypress/code-coverage@3.12.44(@babel/core@7.25.2)(@babel/preset-env@7.25.3)(babel-loader@9.1.3)(cypress@13.13.2)(webpack@5.93.0)': + '@cypress/code-coverage@3.12.44(@babel/core@7.25.2)(@babel/preset-env@7.25.3(@babel/core@7.25.2))(babel-loader@9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)))(cypress@13.13.2)(webpack@5.93.0(esbuild@0.21.5))': dependencies: '@babel/core': 7.25.2 '@babel/preset-env': 7.25.3(@babel/core@7.25.2) - '@cypress/webpack-preprocessor': 6.0.2(@babel/core@7.25.2)(@babel/preset-env@7.25.3)(babel-loader@9.1.3)(webpack@5.93.0) - babel-loader: 9.1.3(@babel/core@7.25.2)(webpack@5.93.0) + '@cypress/webpack-preprocessor': 6.0.2(@babel/core@7.25.2)(@babel/preset-env@7.25.3(@babel/core@7.25.2))(babel-loader@9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)))(webpack@5.93.0(esbuild@0.21.5)) + babel-loader: 9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)) chalk: 4.1.2 cypress: 13.13.2 dayjs: 1.11.12 @@ -10025,7 +10327,7 @@ snapshots: istanbul-lib-coverage: 3.2.2 js-yaml: 4.1.0 nyc: 15.1.0 - webpack: 5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0) + webpack: 5.93.0(esbuild@0.21.5) transitivePeerDependencies: - supports-color @@ -10050,15 +10352,15 @@ snapshots: tunnel-agent: 0.6.0 uuid: 8.3.2 - '@cypress/webpack-preprocessor@6.0.2(@babel/core@7.25.2)(@babel/preset-env@7.25.3)(babel-loader@9.1.3)(webpack@5.93.0)': + '@cypress/webpack-preprocessor@6.0.2(@babel/core@7.25.2)(@babel/preset-env@7.25.3(@babel/core@7.25.2))(babel-loader@9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)))(webpack@5.93.0(esbuild@0.21.5))': dependencies: '@babel/core': 7.25.2 '@babel/preset-env': 7.25.3(@babel/core@7.25.2) - babel-loader: 9.1.3(@babel/core@7.25.2)(webpack@5.93.0) + babel-loader: 9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)) bluebird: 3.7.1 debug: 4.3.5 lodash: 4.17.21 - webpack: 5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0) + webpack: 5.93.0(esbuild@0.21.5) transitivePeerDependencies: - supports-color @@ -10090,6 +10392,7 @@ snapshots: '@algolia/autocomplete-preset-algolia': 1.9.3(@algolia/client-search@4.24.0)(algoliasearch@4.24.0) '@docsearch/css': 3.6.1 algoliasearch: 4.24.0 + optionalDependencies: search-insights: 2.15.0 transitivePeerDependencies: - '@algolia/client-search' @@ -10224,11 +10527,11 @@ snapshots: '@floating-ui/utils@0.2.5': {} - '@floating-ui/vue@1.1.2(vue@3.4.35)': + '@floating-ui/vue@1.1.2(vue@3.4.35(typescript@5.4.5))': dependencies: '@floating-ui/dom': 1.6.8 '@floating-ui/utils': 0.2.5 - vue-demi: 0.14.10(vue@3.4.35) + vue-demi: 0.14.10(vue@3.4.35(typescript@5.4.5)) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -10239,12 +10542,12 @@ snapshots: dependencies: '@hapi/hoek': 9.3.0 - '@headlessui-float/vue@0.14.0(@headlessui/vue@1.7.22)(vue@3.4.35)': + '@headlessui-float/vue@0.14.0(@headlessui/vue@1.7.22(vue@3.4.35(typescript@5.4.5)))(vue@3.4.35(typescript@5.4.5))': dependencies: '@floating-ui/core': 1.6.5 '@floating-ui/dom': 1.6.8 - '@floating-ui/vue': 1.1.2(vue@3.4.35) - '@headlessui/vue': 1.7.22(vue@3.4.35) + '@floating-ui/vue': 1.1.2(vue@3.4.35(typescript@5.4.5)) + '@headlessui/vue': 1.7.22(vue@3.4.35(typescript@5.4.5)) vue: 3.4.35(typescript@5.4.5) transitivePeerDependencies: - '@vue/composition-api' @@ -10253,9 +10556,9 @@ snapshots: dependencies: tailwindcss: 3.4.7 - '@headlessui/vue@1.7.22(vue@3.4.35)': + '@headlessui/vue@1.7.22(vue@3.4.35(typescript@5.4.5))': dependencies: - '@tanstack/vue-virtual': 3.8.5(vue@3.4.35) + '@tanstack/vue-virtual': 3.8.5(vue@3.4.35(typescript@5.4.5)) vue: 3.4.35(typescript@5.4.5) '@humanwhocodes/module-importer@1.0.1': {} @@ -10562,6 +10865,22 @@ snapshots: '@leichtgewicht/ip-codec@2.0.5': {} + '@manypkg/find-root@1.1.0': + dependencies: + '@babel/runtime': 7.25.0 + '@types/node': 12.20.55 + find-up: 4.1.0 + fs-extra: 8.1.0 + + '@manypkg/get-packages@1.1.3': + dependencies: + '@babel/runtime': 7.25.0 + '@changesets/types': 4.1.0 + '@manypkg/find-root': 1.1.0 + fs-extra: 8.1.0 + globby: 11.1.0 + read-yaml-file: 1.1.0 + '@mdi/font@7.4.47': {} '@microsoft/tsdoc-config@0.17.0': @@ -10592,12 +10911,14 @@ snapshots: '@polka/url@1.0.0-next.25': {} - '@rollup/plugin-babel@5.3.1(@babel/core@7.25.2)(rollup@2.79.1)': + '@rollup/plugin-babel@5.3.1(@babel/core@7.25.2)(@types/babel__core@7.20.5)(rollup@2.79.1)': dependencies: '@babel/core': 7.25.2 '@babel/helper-module-imports': 7.24.7 '@rollup/pluginutils': 3.1.0(rollup@2.79.1) rollup: 2.79.1 + optionalDependencies: + '@types/babel__core': 7.20.5 transitivePeerDependencies: - supports-color @@ -10609,6 +10930,7 @@ snapshots: is-builtin-module: 3.2.1 is-module: 1.0.0 resolve: 1.22.8 + optionalDependencies: rollup: 2.79.1 '@rollup/plugin-replace@2.4.2(rollup@2.79.1)': @@ -10619,16 +10941,20 @@ snapshots: '@rollup/plugin-terser@0.4.4(rollup@2.79.1)': dependencies: - rollup: 2.79.1 serialize-javascript: 6.0.2 smob: 1.5.0 terser: 5.31.3 + optionalDependencies: + rollup: 2.79.1 - '@rollup/plugin-typescript@11.1.6(typescript@5.4.5)': + '@rollup/plugin-typescript@11.1.6(rollup@4.20.0)(tslib@2.6.3)(typescript@5.4.5)': dependencies: - '@rollup/pluginutils': 5.1.0(rollup@2.79.1) + '@rollup/pluginutils': 5.1.0(rollup@4.20.0) resolve: 1.22.8 typescript: 5.4.5 + optionalDependencies: + rollup: 4.20.0 + tslib: 2.6.3 '@rollup/pluginutils@3.1.0(rollup@2.79.1)': dependencies: @@ -10642,8 +10968,17 @@ snapshots: '@types/estree': 1.0.5 estree-walker: 2.0.2 picomatch: 2.3.1 + optionalDependencies: rollup: 2.79.1 + '@rollup/pluginutils@5.1.0(rollup@4.20.0)': + dependencies: + '@types/estree': 1.0.5 + estree-walker: 2.0.2 + picomatch: 2.3.1 + optionalDependencies: + rollup: 4.20.0 + '@rollup/rollup-android-arm-eabi@4.20.0': optional: true @@ -10735,7 +11070,7 @@ snapshots: '@tanstack/virtual-core@3.8.4': {} - '@tanstack/vue-virtual@3.8.5(vue@3.4.35)': + '@tanstack/vue-virtual@3.8.5(vue@3.4.35(typescript@5.4.5))': dependencies: '@tanstack/virtual-core': 3.8.4 vue: 3.4.35(typescript@5.4.5) @@ -11059,6 +11394,8 @@ snapshots: dependencies: '@types/node': 20.14.14 + '@types/node@12.20.55': {} + '@types/node@18.19.43': dependencies: undici-types: 5.26.5 @@ -11095,6 +11432,8 @@ snapshots: dependencies: rollup: 2.79.1 + '@types/semver@7.5.8': {} + '@types/send@0.17.4': dependencies: '@types/mime': 1.3.5 @@ -11153,7 +11492,7 @@ snapshots: '@types/node': 20.14.14 optional: true - '@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0)(eslint@9.8.0)(typescript@5.4.5)': + '@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5)': dependencies: '@eslint-community/regexpp': 4.11.0 '@typescript-eslint/parser': 8.0.0(eslint@9.8.0)(typescript@5.4.5) @@ -11166,6 +11505,7 @@ snapshots: ignore: 5.3.1 natural-compare: 1.4.0 ts-api-utils: 1.3.0(typescript@5.4.5) + optionalDependencies: typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -11178,6 +11518,7 @@ snapshots: '@typescript-eslint/visitor-keys': 8.0.0 debug: 4.3.6(supports-color@8.1.1) eslint: 9.8.0 + optionalDependencies: typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -11193,6 +11534,7 @@ snapshots: '@typescript-eslint/utils': 8.0.0(eslint@9.8.0)(typescript@5.4.5) debug: 4.3.6(supports-color@8.1.1) ts-api-utils: 1.3.0(typescript@5.4.5) + optionalDependencies: typescript: 5.4.5 transitivePeerDependencies: - eslint @@ -11210,6 +11552,7 @@ snapshots: minimatch: 9.0.5 semver: 7.6.3 ts-api-utils: 1.3.0(typescript@5.4.5) + optionalDependencies: typescript: 5.4.5 transitivePeerDependencies: - supports-color @@ -11230,12 +11573,13 @@ snapshots: '@typescript-eslint/types': 8.0.0 eslint-visitor-keys: 3.4.3 - '@unocss/astro@0.59.4(rollup@2.79.1)(vite@5.3.5)': + '@unocss/astro@0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))': dependencies: '@unocss/core': 0.59.4 '@unocss/reset': 0.59.4 - '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.3.5) - vite: 5.3.5(@types/node@20.14.14) + '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) + optionalDependencies: + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) transitivePeerDependencies: - rollup @@ -11366,7 +11710,7 @@ snapshots: dependencies: '@unocss/core': 0.59.4 - '@unocss/vite@0.59.4(rollup@2.79.1)(vite@5.3.5)': + '@unocss/vite@0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))': dependencies: '@ampproject/remapping': 2.3.0 '@rollup/pluginutils': 5.1.0(rollup@2.79.1) @@ -11378,20 +11722,20 @@ snapshots: chokidar: 3.6.0 fast-glob: 3.3.2 magic-string: 0.30.11 - vite: 5.3.5(@types/node@20.14.14) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) transitivePeerDependencies: - rollup - '@vite-pwa/vitepress@0.4.0(vite-plugin-pwa@0.19.8)': + '@vite-pwa/vitepress@0.4.0(vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0))': dependencies: - vite-plugin-pwa: 0.19.8(vite@5.3.5)(workbox-build@7.1.1)(workbox-window@7.1.0) + vite-plugin-pwa: 0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) - '@vitejs/plugin-vue@5.1.2(vite@5.3.5)(vue@3.4.35)': + '@vitejs/plugin-vue@5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(vue@3.4.35(typescript@5.4.5))': dependencies: - vite: 5.3.5(@types/node@20.14.14) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) vue: 3.4.35(typescript@5.4.5) - '@vitest/coverage-v8@1.6.0(vitest@1.6.0)': + '@vitest/coverage-v8@1.6.0(vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3))': dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 0.2.3 @@ -11406,7 +11750,7 @@ snapshots: std-env: 3.7.0 strip-literal: 2.1.0 test-exclude: 6.0.0 - vitest: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1) + vitest: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3) transitivePeerDependencies: - supports-color @@ -11441,7 +11785,7 @@ snapshots: pathe: 1.1.2 picocolors: 1.0.1 sirv: 2.0.4 - vitest: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1) + vitest: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3) '@vitest/utils@1.6.0': dependencies: @@ -11450,7 +11794,7 @@ snapshots: loupe: 2.3.7 pretty-format: 29.7.0 - '@vue/compat@3.4.35(vue@3.4.35)': + '@vue/compat@3.4.35(vue@3.4.35(typescript@5.4.5))': dependencies: '@babel/parser': 7.25.3 estree-walker: 2.0.2 @@ -11523,7 +11867,7 @@ snapshots: '@vue/shared': 3.4.35 csstype: 3.1.3 - '@vue/server-renderer@3.4.35(vue@3.4.35)': + '@vue/server-renderer@3.4.35(vue@3.4.35(typescript@5.4.5))': dependencies: '@vue/compiler-ssr': 3.4.35 '@vue/shared': 3.4.35 @@ -11531,31 +11875,33 @@ snapshots: '@vue/shared@3.4.35': {} - '@vueuse/core@10.11.0(vue@3.4.35)': + '@vueuse/core@10.11.0(vue@3.4.35(typescript@5.4.5))': dependencies: '@types/web-bluetooth': 0.0.20 '@vueuse/metadata': 10.11.0 - '@vueuse/shared': 10.11.0(vue@3.4.35) - vue-demi: 0.14.10(vue@3.4.35) + '@vueuse/shared': 10.11.0(vue@3.4.35(typescript@5.4.5)) + vue-demi: 0.14.10(vue@3.4.35(typescript@5.4.5)) transitivePeerDependencies: - '@vue/composition-api' - vue - '@vueuse/integrations@10.11.0(focus-trap@7.5.4)(vue@3.4.35)': + '@vueuse/integrations@10.11.0(axios@1.7.3)(focus-trap@7.5.4)(vue@3.4.35(typescript@5.4.5))': dependencies: - '@vueuse/core': 10.11.0(vue@3.4.35) - '@vueuse/shared': 10.11.0(vue@3.4.35) + '@vueuse/core': 10.11.0(vue@3.4.35(typescript@5.4.5)) + '@vueuse/shared': 10.11.0(vue@3.4.35(typescript@5.4.5)) + vue-demi: 0.14.10(vue@3.4.35(typescript@5.4.5)) + optionalDependencies: + axios: 1.7.3(debug@4.3.6) focus-trap: 7.5.4 - vue-demi: 0.14.10(vue@3.4.35) transitivePeerDependencies: - '@vue/composition-api' - vue '@vueuse/metadata@10.11.0': {} - '@vueuse/shared@10.11.0(vue@3.4.35)': + '@vueuse/shared@10.11.0(vue@3.4.35(typescript@5.4.5))': dependencies: - vue-demi: 0.14.10(vue@3.4.35) + vue-demi: 0.14.10(vue@3.4.35(typescript@5.4.5)) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -11584,6 +11930,7 @@ snapshots: dependencies: '@types/node': 18.19.43 got: 11.8.6 + optionalDependencies: typescript: 5.4.5 '@wdio/utils@7.30.2(typescript@5.4.5)': @@ -11670,19 +12017,20 @@ snapshots: '@webassemblyjs/ast': 1.12.1 '@xtuc/long': 4.2.2 - '@webpack-cli/configtest@1.2.0(webpack-cli@4.10.0)(webpack@5.93.0)': + '@webpack-cli/configtest@1.2.0(webpack-cli@4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0))(webpack@5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0))': dependencies: webpack: 5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0) webpack-cli: 4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0) - '@webpack-cli/info@1.5.0(webpack-cli@4.10.0)': + '@webpack-cli/info@1.5.0(webpack-cli@4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0))': dependencies: envinfo: 7.13.0 webpack-cli: 4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0) - '@webpack-cli/serve@1.7.0(webpack-cli@4.10.0)(webpack-dev-server@4.15.2)': + '@webpack-cli/serve@1.7.0(webpack-cli@4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0))(webpack-dev-server@4.15.2(webpack-cli@4.10.0)(webpack@5.93.0))': dependencies: webpack-cli: 4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0) + optionalDependencies: webpack-dev-server: 4.15.2(webpack-cli@4.10.0)(webpack@5.93.0) '@xmldom/xmldom@0.8.10': {} @@ -11693,12 +12041,12 @@ snapshots: '@zenuml/core@3.24.2(typescript@5.4.5)': dependencies: - '@headlessui-float/vue': 0.14.0(@headlessui/vue@1.7.22)(vue@3.4.35) + '@headlessui-float/vue': 0.14.0(@headlessui/vue@1.7.22(vue@3.4.35(typescript@5.4.5)))(vue@3.4.35(typescript@5.4.5)) '@headlessui/tailwindcss': 0.2.1(tailwindcss@3.4.7) - '@headlessui/vue': 1.7.22(vue@3.4.35) + '@headlessui/vue': 1.7.22(vue@3.4.35(typescript@5.4.5)) '@types/assert': 1.5.10 '@types/ramda': 0.28.25 - '@vue/compat': 3.4.35(vue@3.4.35) + '@vue/compat': 3.4.35(vue@3.4.35(typescript@5.4.5)) antlr4: 4.11.0 color-string: 1.9.1 dom-to-image-more: 2.16.0 @@ -11713,7 +12061,7 @@ snapshots: ramda: 0.28.0 tailwindcss: 3.4.7 vue: 3.4.35(typescript@5.4.5) - vuex: 4.1.0(vue@3.4.35) + vuex: 4.1.0(vue@3.4.35(typescript@5.4.5)) transitivePeerDependencies: - '@vue/composition-api' - ts-node @@ -11771,7 +12119,7 @@ snapshots: indent-string: 5.0.0 ajv-formats@2.1.1(ajv@8.17.1): - dependencies: + optionalDependencies: ajv: 8.17.1 ajv-keywords@3.5.2(ajv@6.12.6): @@ -11976,12 +12324,12 @@ snapshots: transitivePeerDependencies: - supports-color - babel-loader@9.1.3(@babel/core@7.25.2)(webpack@5.93.0): + babel-loader@9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)): dependencies: '@babel/core': 7.25.2 find-cache-dir: 4.0.0 schema-utils: 4.2.0 - webpack: 5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0) + webpack: 5.93.0(esbuild@0.21.5) babel-plugin-istanbul@6.1.1: dependencies: @@ -12058,6 +12406,10 @@ snapshots: dependencies: tweetnacl: 0.14.5 + better-path-resolve@1.0.0: + dependencies: + is-windows: 1.0.2 + binary-extensions@2.3.0: {} binary-searching@2.0.5: {} @@ -12257,6 +12609,8 @@ snapshots: character-reference-invalid@1.1.4: {} + chardet@0.7.0: {} + check-error@1.0.3: dependencies: get-func-name: 2.0.2 @@ -12561,6 +12915,12 @@ snapshots: dependencies: cross-spawn: 7.0.3 + cross-spawn@5.1.0: + dependencies: + lru-cache: 4.1.5 + shebang-command: 1.2.0 + which: 1.3.1 + cross-spawn@6.0.5: dependencies: nice-try: 1.0.5 @@ -12687,13 +13047,13 @@ snapshots: cuint@0.2.2: {} - cypress-image-snapshot@4.0.1(cypress@13.13.2)(jest@29.7.0): + cypress-image-snapshot@4.0.1(cypress@13.13.2)(jest@29.7.0(@types/node@20.14.14)): dependencies: chalk: 2.4.2 cypress: 13.13.2 fs-extra: 7.0.1 glob: 7.2.3 - jest-image-snapshot: 4.2.0(jest@29.7.0) + jest-image-snapshot: 4.2.0(jest@29.7.0(@types/node@20.14.14)) pkg-dir: 3.0.0 term-img: 4.1.0 transitivePeerDependencies: @@ -12972,6 +13332,7 @@ snapshots: debug@3.2.7(supports-color@8.1.1): dependencies: ms: 2.1.3 + optionalDependencies: supports-color: 8.1.1 debug@4.3.3: @@ -12989,6 +13350,7 @@ snapshots: debug@4.3.6(supports-color@8.1.1): dependencies: ms: 2.1.2 + optionalDependencies: supports-color: 8.1.1 decamelize@1.2.0: {} @@ -13055,6 +13417,8 @@ snapshots: destroy@1.2.0: {} + detect-indent@6.1.0: {} + detect-libc@2.0.3: {} detect-newline@3.1.0: {} @@ -13327,10 +13691,12 @@ snapshots: dependencies: htmlparser2: 9.1.0 - eslint-plugin-jest@28.7.0(eslint@9.8.0)(jest@29.7.0)(typescript@5.4.5): + eslint-plugin-jest@28.7.0(@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(jest@29.7.0(@types/node@20.14.14))(typescript@5.4.5): dependencies: '@typescript-eslint/utils': 8.0.0(eslint@9.8.0)(typescript@5.4.5) eslint: 9.8.0 + optionalDependencies: + '@typescript-eslint/eslint-plugin': 8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5) jest: 29.7.0(@types/node@20.14.14) transitivePeerDependencies: - supports-color @@ -13622,6 +13988,14 @@ snapshots: extend@3.0.2: {} + extendable-error@0.1.7: {} + + external-editor@3.1.0: + dependencies: + chardet: 0.7.0 + iconv-lite: 0.4.24 + tmp: 0.0.33 + extract-zip@2.0.1(supports-color@8.1.1): dependencies: debug: 4.3.6(supports-color@8.1.1) @@ -13808,6 +14182,11 @@ snapshots: locate-path: 7.2.0 path-exists: 5.0.0 + find-yarn-workspace-root2@1.2.16: + dependencies: + micromatch: 4.0.7 + pkg-dir: 4.2.0 + flat-cache@4.0.1: dependencies: flatted: 3.3.1 @@ -13831,7 +14210,7 @@ snapshots: tabbable: 6.2.0 follow-redirects@1.15.6(debug@4.3.6): - dependencies: + optionalDependencies: debug: 4.3.6(supports-color@8.1.1) font-awesome@4.7.0: {} @@ -13896,6 +14275,12 @@ snapshots: jsonfile: 4.0.0 universalify: 0.1.2 + fs-extra@8.1.0: + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + fs-extra@9.1.0: dependencies: at-least-node: 1.0.0 @@ -14213,12 +14598,13 @@ snapshots: http-proxy-middleware@2.0.6(@types/express@4.17.21): dependencies: - '@types/express': 4.17.21 '@types/http-proxy': 1.17.14 http-proxy: 1.18.1 is-glob: 4.0.3 is-plain-obj: 3.0.0 micromatch: 4.0.7 + optionalDependencies: + '@types/express': 4.17.21 transitivePeerDependencies: - debug @@ -14266,6 +14652,8 @@ snapshots: transitivePeerDependencies: - supports-color + human-id@1.0.2: {} + human-signals@1.1.1: {} human-signals@2.1.0: {} @@ -14464,6 +14852,10 @@ snapshots: dependencies: has-tostringtag: 1.0.2 + is-subdir@1.2.0: + dependencies: + better-path-resolve: 1.0.0 + is-symbol@1.0.4: dependencies: has-symbols: 1.0.3 @@ -14643,7 +15035,6 @@ snapshots: '@babel/core': 7.25.2 '@jest/test-sequencer': 29.7.0 '@jest/types': 29.6.3 - '@types/node': 20.14.14 babel-jest: 29.7.0(@babel/core@7.25.2) chalk: 4.1.2 ci-info: 3.9.0 @@ -14663,6 +15054,8 @@ snapshots: pretty-format: 29.7.0 slash: 3.0.0 strip-json-comments: 3.1.1 + optionalDependencies: + '@types/node': 20.14.14 transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -14713,7 +15106,7 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - jest-image-snapshot@4.2.0(jest@29.7.0): + jest-image-snapshot@4.2.0(jest@29.7.0(@types/node@20.14.14)): dependencies: chalk: 1.1.3 get-stdin: 5.0.1 @@ -14757,7 +15150,7 @@ snapshots: jest-util: 29.7.0 jest-pnp-resolver@1.2.3(jest-resolve@29.7.0): - dependencies: + optionalDependencies: jest-resolve: 29.7.0 jest-regex-util@29.6.3: {} @@ -15154,13 +15547,14 @@ snapshots: dependencies: cli-truncate: 2.1.0 colorette: 2.0.20 - enquirer: 2.4.1 log-update: 4.0.0 p-map: 4.0.0 rfdc: 1.4.1 rxjs: 7.8.1 through: 2.3.8 wrap-ansi: 7.0.0 + optionalDependencies: + enquirer: 2.4.1 listr2@8.2.4: dependencies: @@ -15171,6 +15565,13 @@ snapshots: rfdc: 1.4.1 wrap-ansi: 9.0.0 + load-yaml-file@0.2.0: + dependencies: + graceful-fs: 4.2.11 + js-yaml: 3.14.1 + pify: 4.0.1 + strip-bom: 3.0.0 + loader-runner@4.3.0: {} local-pkg@0.4.3: {} @@ -15213,6 +15614,8 @@ snapshots: lodash.sortby@4.7.0: {} + lodash.startcase@4.4.0: {} + lodash@4.17.21: {} log-symbols@4.1.0: @@ -15249,6 +15652,11 @@ snapshots: lru-cache@10.4.3: {} + lru-cache@4.1.5: + dependencies: + pseudomap: 1.0.2 + yallist: 2.1.2 + lru-cache@5.1.1: dependencies: yallist: 3.1.1 @@ -15731,6 +16139,8 @@ snapshots: pkg-types: 1.1.3 ufo: 1.5.4 + mri@1.2.0: {} + mrmime@2.0.0: {} ms@2.0.0: {} @@ -15772,8 +16182,9 @@ snapshots: node-fetch@2.6.7(encoding@0.1.13): dependencies: - encoding: 0.1.13 whatwg-url: 5.0.0 + optionalDependencies: + encoding: 0.1.13 node-fetch@3.3.1: dependencies: @@ -15917,14 +16328,22 @@ snapshots: type-check: 0.4.0 word-wrap: 1.2.5 + os-tmpdir@1.0.2: {} + ospath@1.2.2: {} + outdent@0.5.0: {} + p-cancelable@2.1.1: {} p-event@5.0.1: dependencies: p-timeout: 5.1.0 + p-filter@2.1.0: + dependencies: + p-map: 2.1.0 + p-filter@3.0.0: dependencies: p-map: 5.5.0 @@ -15965,6 +16384,8 @@ snapshots: dependencies: p-limit: 4.0.0 + p-map@2.1.0: {} + p-map@3.0.0: dependencies: aggregate-error: 3.1.0 @@ -16087,6 +16508,8 @@ snapshots: pify@2.3.0: {} + pify@4.0.1: {} + pino-abstract-transport@1.2.0: dependencies: readable-stream: 4.5.2 @@ -16184,8 +16607,9 @@ snapshots: postcss-load-config@4.0.2(postcss@8.4.40): dependencies: lilconfig: 3.1.2 - postcss: 8.4.40 yaml: 2.5.0 + optionalDependencies: + postcss: 8.4.40 postcss-nested@6.2.0(postcss@8.4.40): dependencies: @@ -16207,6 +16631,13 @@ snapshots: preact@10.23.1: {} + preferred-pm@3.1.4: + dependencies: + find-up: 5.0.0 + find-yarn-workspace-root2: 1.2.16 + path-exists: 4.0.0 + which-pm: 2.2.0 + prelude-ls@1.2.1: {} prettier-plugin-jsdoc@1.3.0(prettier@3.3.3): @@ -16262,6 +16693,8 @@ snapshots: dependencies: event-stream: 3.3.4 + pseudomap@1.0.2: {} + psl@1.9.0: {} pump@3.0.0: @@ -16325,6 +16758,13 @@ snapshots: parse-json: 5.2.0 type-fest: 0.6.0 + read-yaml-file@1.1.0: + dependencies: + graceful-fs: 4.2.11 + js-yaml: 3.14.1 + pify: 4.0.1 + strip-bom: 3.0.0 + readable-stream@2.3.8: dependencies: core-util-is: 1.0.3 @@ -16515,12 +16955,14 @@ snapshots: robust-predicates@3.0.2: {} - rollup-plugin-visualizer@5.12.0: + rollup-plugin-visualizer@5.12.0(rollup@4.20.0): dependencies: open: 8.4.2 picomatch: 2.3.1 source-map: 0.7.4 yargs: 17.7.2 + optionalDependencies: + rollup: 4.20.0 rollup@2.79.1: optionalDependencies: @@ -16867,6 +17309,11 @@ snapshots: signal-exit: 3.0.7 which: 2.0.2 + spawndamnit@2.0.0: + dependencies: + cross-spawn: 5.1.0 + signal-exit: 3.0.7 + spdx-correct@3.2.0: dependencies: spdx-expression-parse: 3.0.1 @@ -17047,6 +17494,8 @@ snapshots: dependencies: ansi-regex: 6.0.1 + strip-bom@3.0.0: {} + strip-bom@4.0.0: {} strip-comments@2.0.1: {} @@ -17160,15 +17609,29 @@ snapshots: ansi-escapes: 4.3.2 iterm2-version: 4.2.0 - terser-webpack-plugin@5.3.10(esbuild@0.21.5)(webpack@5.93.0): + term-size@2.2.1: {} + + terser-webpack-plugin@5.3.10(esbuild@0.21.5)(webpack@5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0)): dependencies: '@jridgewell/trace-mapping': 0.3.25 - esbuild: 0.21.5 jest-worker: 27.5.1 schema-utils: 3.3.0 serialize-javascript: 6.0.2 terser: 5.31.3 webpack: 5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0) + optionalDependencies: + esbuild: 0.21.5 + + terser-webpack-plugin@5.3.10(esbuild@0.21.5)(webpack@5.93.0(esbuild@0.21.5)): + dependencies: + '@jridgewell/trace-mapping': 0.3.25 + jest-worker: 27.5.1 + schema-utils: 3.3.0 + serialize-javascript: 6.0.2 + terser: 5.31.3 + webpack: 5.93.0(esbuild@0.21.5) + optionalDependencies: + esbuild: 0.21.5 terser@5.31.3: dependencies: @@ -17218,6 +17681,10 @@ snapshots: tinyspy@2.2.1: {} + tmp@0.0.33: + dependencies: + os-tmpdir: 1.0.2 + tmp@0.2.3: {} tmpl@1.0.5: {} @@ -17343,7 +17810,7 @@ snapshots: dependencies: is-typedarray: 1.0.0 - typedoc-plugin-markdown@3.17.1(typedoc@0.25.13): + typedoc-plugin-markdown@3.17.1(typedoc@0.25.13(typescript@5.4.5)): dependencies: handlebars: 4.7.8 typedoc: 0.25.13(typescript@5.4.5) @@ -17358,9 +17825,10 @@ snapshots: typescript-eslint@8.0.0(eslint@9.8.0)(typescript@5.4.5): dependencies: - '@typescript-eslint/eslint-plugin': 8.0.0(@typescript-eslint/parser@8.0.0)(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/eslint-plugin': 8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5) '@typescript-eslint/parser': 8.0.0(eslint@9.8.0)(typescript@5.4.5) '@typescript-eslint/utils': 8.0.0(eslint@9.8.0)(typescript@5.4.5) + optionalDependencies: typescript: 5.4.5 transitivePeerDependencies: - eslint @@ -17463,9 +17931,9 @@ snapshots: universalify@2.0.1: {} - unocss@0.59.4(postcss@8.4.40)(rollup@2.79.1)(vite@5.3.5): + unocss@0.59.4(postcss@8.4.40)(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)): dependencies: - '@unocss/astro': 0.59.4(rollup@2.79.1)(vite@5.3.5) + '@unocss/astro': 0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) '@unocss/cli': 0.59.4(rollup@2.79.1) '@unocss/core': 0.59.4 '@unocss/extractor-arbitrary-variants': 0.59.4 @@ -17484,8 +17952,9 @@ snapshots: '@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.3.5) - vite: 5.3.5(@types/node@20.14.14) + '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) + optionalDependencies: + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) transitivePeerDependencies: - postcss - rollup @@ -17493,7 +17962,7 @@ snapshots: unpipe@1.0.0: {} - unplugin-vue-components@0.26.0(rollup@2.79.1)(vue@3.4.35): + unplugin-vue-components@0.26.0(@babel/parser@7.25.3)(rollup@2.79.1)(vue@3.4.35(typescript@5.4.5)): dependencies: '@antfu/utils': 0.7.10 '@rollup/pluginutils': 5.1.0(rollup@2.79.1) @@ -17506,6 +17975,8 @@ snapshots: resolve: 1.22.8 unplugin: 1.12.0 vue: 3.4.35(typescript@5.4.5) + optionalDependencies: + '@babel/parser': 7.25.3 transitivePeerDependencies: - rollup - supports-color @@ -17574,13 +18045,13 @@ snapshots: unist-util-stringify-position: 4.0.0 vfile-message: 4.0.2 - vite-node@1.6.0(@types/node@20.14.14): + vite-node@1.6.0(@types/node@20.14.14)(terser@5.31.3): dependencies: cac: 6.7.14 debug: 4.3.6(supports-color@8.1.1) pathe: 1.1.2 picocolors: 1.0.1 - vite: 5.3.5(@types/node@20.14.14) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) transitivePeerDependencies: - '@types/node' - less @@ -17591,7 +18062,7 @@ snapshots: - supports-color - terser - vite-plugin-istanbul@6.0.2(vite@5.3.5): + vite-plugin-istanbul@6.0.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)): dependencies: '@istanbuljs/load-nyc-config': 1.1.0 espree: 10.1.0 @@ -17599,58 +18070,60 @@ snapshots: picocolors: 1.0.1 source-map: 0.7.4 test-exclude: 6.0.0 - vite: 5.3.5(@types/node@20.14.14) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) transitivePeerDependencies: - supports-color - vite-plugin-pwa@0.19.8(vite@5.3.5)(workbox-build@7.1.1)(workbox-window@7.1.0): + vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0): dependencies: debug: 4.3.6(supports-color@8.1.1) fast-glob: 3.3.2 pretty-bytes: 6.1.1 - vite: 5.3.5(@types/node@20.14.14) - workbox-build: 7.1.1 + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + workbox-build: 7.1.1(@types/babel__core@7.20.5) workbox-window: 7.1.0 transitivePeerDependencies: - supports-color - vite@5.3.5(@types/node@20.14.14): + vite@5.3.5(@types/node@20.14.14)(terser@5.31.3): dependencies: - '@types/node': 20.14.14 esbuild: 0.21.5 postcss: 8.4.40 rollup: 4.20.0 optionalDependencies: + '@types/node': 20.14.14 fsevents: 2.3.3 + terser: 5.31.3 - vitepress-plugin-search@1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4)(vue@3.4.35): + vitepress-plugin-search@1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5))(vue@3.4.35(typescript@5.4.5)): dependencies: '@types/flexsearch': 0.7.6 '@types/markdown-it': 12.2.3 flexsearch: 0.7.43 glob-to-regexp: 0.4.1 markdown-it: 13.0.2 - vitepress: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(postcss@8.4.40)(search-insights@2.15.0)(typescript@5.4.5) + vitepress: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5) vue: 3.4.35(typescript@5.4.5) - vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(postcss@8.4.40)(search-insights@2.15.0)(typescript@5.4.5): + vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5): dependencies: '@docsearch/css': 3.6.1 '@docsearch/js': 3.6.1(@algolia/client-search@4.24.0)(search-insights@2.15.0) '@shikijs/core': 1.12.1 '@shikijs/transformers': 1.12.1 '@types/markdown-it': 14.1.2 - '@vitejs/plugin-vue': 5.1.2(vite@5.3.5)(vue@3.4.35) + '@vitejs/plugin-vue': 5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(vue@3.4.35(typescript@5.4.5)) '@vue/devtools-api': 7.3.7 - '@vueuse/core': 10.11.0(vue@3.4.35) - '@vueuse/integrations': 10.11.0(focus-trap@7.5.4)(vue@3.4.35) + '@vueuse/core': 10.11.0(vue@3.4.35(typescript@5.4.5)) + '@vueuse/integrations': 10.11.0(axios@1.7.3)(focus-trap@7.5.4)(vue@3.4.35(typescript@5.4.5)) focus-trap: 7.5.4 mark.js: 8.11.1 minisearch: 6.3.0 - postcss: 8.4.40 shiki: 1.12.1 - vite: 5.3.5(@types/node@20.14.14) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) vue: 3.4.35(typescript@5.4.5) + optionalDependencies: + postcss: 8.4.40 transitivePeerDependencies: - '@algolia/client-search' - '@types/node' @@ -17678,20 +18151,17 @@ snapshots: - typescript - universal-cookie - vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1): + vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3): dependencies: - '@types/node': 20.14.14 '@vitest/expect': 1.6.0 '@vitest/runner': 1.6.0 '@vitest/snapshot': 1.6.0 '@vitest/spy': 1.6.0 - '@vitest/ui': 1.6.0(vitest@1.6.0) '@vitest/utils': 1.6.0 acorn-walk: 8.3.3 chai: 4.5.0 debug: 4.3.6(supports-color@8.1.1) execa: 8.0.1 - jsdom: 24.1.1 local-pkg: 0.5.0 magic-string: 0.30.11 pathe: 1.1.2 @@ -17700,9 +18170,13 @@ snapshots: strip-literal: 2.1.0 tinybench: 2.9.0 tinypool: 0.8.4 - vite: 5.3.5(@types/node@20.14.14) - vite-node: 1.6.0(@types/node@20.14.14) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite-node: 1.6.0(@types/node@20.14.14)(terser@5.31.3) why-is-node-running: 2.3.0 + optionalDependencies: + '@types/node': 20.14.14 + '@vitest/ui': 1.6.0(vitest@1.6.0) + jsdom: 24.1.1 transitivePeerDependencies: - less - lightningcss @@ -17743,7 +18217,7 @@ snapshots: vscode-uri@3.0.8: {} - vue-demi@0.14.10(vue@3.4.35): + vue-demi@0.14.10(vue@3.4.35(typescript@5.4.5)): dependencies: vue: 3.4.35(typescript@5.4.5) @@ -17752,11 +18226,12 @@ snapshots: '@vue/compiler-dom': 3.4.35 '@vue/compiler-sfc': 3.4.35 '@vue/runtime-dom': 3.4.35 - '@vue/server-renderer': 3.4.35(vue@3.4.35) + '@vue/server-renderer': 3.4.35(vue@3.4.35(typescript@5.4.5)) '@vue/shared': 3.4.35 + optionalDependencies: typescript: 5.4.5 - vuex@4.1.0(vue@3.4.35): + vuex@4.1.0(vue@3.4.35(typescript@5.4.5)): dependencies: '@vue/devtools-api': 6.6.3 vue: 3.4.35(typescript@5.4.5) @@ -17813,9 +18288,9 @@ snapshots: webpack-cli@4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0): dependencies: '@discoveryjs/json-ext': 0.5.7 - '@webpack-cli/configtest': 1.2.0(webpack-cli@4.10.0)(webpack@5.93.0) - '@webpack-cli/info': 1.5.0(webpack-cli@4.10.0) - '@webpack-cli/serve': 1.7.0(webpack-cli@4.10.0)(webpack-dev-server@4.15.2) + '@webpack-cli/configtest': 1.2.0(webpack-cli@4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0))(webpack@5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0)) + '@webpack-cli/info': 1.5.0(webpack-cli@4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0)) + '@webpack-cli/serve': 1.7.0(webpack-cli@4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0))(webpack-dev-server@4.15.2(webpack-cli@4.10.0)(webpack@5.93.0)) colorette: 2.0.20 commander: 7.2.0 cross-spawn: 7.0.3 @@ -17824,10 +18299,11 @@ snapshots: interpret: 2.2.0 rechoir: 0.7.1 webpack: 5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0) - webpack-dev-server: 4.15.2(webpack-cli@4.10.0)(webpack@5.93.0) webpack-merge: 5.10.0 + optionalDependencies: + webpack-dev-server: 4.15.2(webpack-cli@4.10.0)(webpack@5.93.0) - webpack-dev-middleware@5.3.4(webpack@5.93.0): + webpack-dev-middleware@5.3.4(webpack@5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0)): dependencies: colorette: 2.0.20 memfs: 3.5.3 @@ -17866,10 +18342,11 @@ snapshots: serve-index: 1.9.1 sockjs: 0.3.24 spdy: 4.0.2 + webpack-dev-middleware: 5.3.4(webpack@5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0)) + ws: 8.18.0 + optionalDependencies: webpack: 5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0) webpack-cli: 4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0) - webpack-dev-middleware: 5.3.4(webpack@5.93.0) - ws: 8.18.0 transitivePeerDependencies: - bufferutil - debug @@ -17886,6 +18363,37 @@ snapshots: webpack-virtual-modules@0.6.2: {} + webpack@5.93.0(esbuild@0.21.5): + dependencies: + '@types/eslint-scope': 3.7.7 + '@types/estree': 1.0.5 + '@webassemblyjs/ast': 1.12.1 + '@webassemblyjs/wasm-edit': 1.12.1 + '@webassemblyjs/wasm-parser': 1.12.1 + acorn: 8.12.1 + acorn-import-attributes: 1.9.5(acorn@8.12.1) + browserslist: 4.23.3 + chrome-trace-event: 1.0.4 + enhanced-resolve: 5.17.1 + es-module-lexer: 1.5.4 + eslint-scope: 5.1.1 + events: 3.3.0 + glob-to-regexp: 0.4.1 + graceful-fs: 4.2.11 + json-parse-even-better-errors: 2.3.1 + loader-runner: 4.3.0 + mime-types: 2.1.35 + neo-async: 2.6.2 + schema-utils: 3.3.0 + tapable: 2.2.1 + terser-webpack-plugin: 5.3.10(esbuild@0.21.5)(webpack@5.93.0(esbuild@0.21.5)) + watchpack: 2.4.1 + webpack-sources: 3.2.3 + transitivePeerDependencies: + - '@swc/core' + - esbuild + - uglify-js + webpack@5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0): dependencies: '@types/eslint-scope': 3.7.7 @@ -17909,10 +18417,11 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(esbuild@0.21.5)(webpack@5.93.0) + terser-webpack-plugin: 5.3.10(esbuild@0.21.5)(webpack@5.93.0(esbuild@0.21.5)(webpack-cli@4.10.0)) watchpack: 2.4.1 - webpack-cli: 4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0) webpack-sources: 3.2.3 + optionalDependencies: + webpack-cli: 4.10.0(webpack-dev-server@4.15.2)(webpack@5.93.0) transitivePeerDependencies: - '@swc/core' - esbuild @@ -17958,6 +18467,11 @@ snapshots: which-module@2.0.1: {} + which-pm@2.2.0: + dependencies: + load-yaml-file: 0.2.0 + path-exists: 4.0.0 + which-typed-array@1.1.15: dependencies: available-typed-arrays: 1.0.7 @@ -17998,13 +18512,13 @@ snapshots: dependencies: workbox-core: 7.1.0 - workbox-build@7.1.1: + workbox-build@7.1.1(@types/babel__core@7.20.5): dependencies: '@apideck/better-ajv-errors': 0.3.6(ajv@8.17.1) '@babel/core': 7.25.2 '@babel/preset-env': 7.25.3(@babel/core@7.25.2) '@babel/runtime': 7.25.0 - '@rollup/plugin-babel': 5.3.1(@babel/core@7.25.2)(rollup@2.79.1) + '@rollup/plugin-babel': 5.3.1(@babel/core@7.25.2)(@types/babel__core@7.20.5)(rollup@2.79.1) '@rollup/plugin-node-resolve': 15.2.3(rollup@2.79.1) '@rollup/plugin-replace': 2.4.2(rollup@2.79.1) '@rollup/plugin-terser': 0.4.4(rollup@2.79.1) @@ -18162,6 +18676,8 @@ snapshots: y18n@5.0.8: {} + yallist@2.1.2: {} + yallist@3.1.1: {} yaml@2.5.0: {} diff --git a/tests/webpack/package.json b/tests/webpack/package.json index 5d211ca1b..12bb73195 100644 --- a/tests/webpack/package.json +++ b/tests/webpack/package.json @@ -1,5 +1,5 @@ { - "name": "webpack", + "name": "@mermaid-js/webpack-test", "version": "1.0.0", "description": "", "private": true, From dd5866a4cb5f2271af513a88edc9c5fce24b012a Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 14:10:08 +0530 Subject: [PATCH 052/124] chore: Add changeset workflow --- .github/workflows/release-draft.yml | 23 ------------------ .github/workflows/release.yml | 37 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 23 deletions(-) delete mode 100644 .github/workflows/release-draft.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml deleted file mode 100644 index 657bc767a..000000000 --- a/.github/workflows/release-draft.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Draft Release - -on: - push: - branches: - - master - -permissions: - contents: read - -jobs: - draft-release: - runs-on: ubuntu-latest - permissions: - contents: write # write permission is required to create a GitHub release - pull-requests: read # required to read PR titles/labels - steps: - - name: Draft Release - uses: release-drafter/release-drafter@v6 - with: - disable-autolabeler: true - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..9c94d759a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,37 @@ +name: Release + +on: + push: + branches: + - master + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - uses: pnpm/action-setup@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + cache: pnpm + node-version-file: '.node-version' + + - name: Install Packages + run: pnpm install --frozen-lockfile + + - name: Create Release Pull Request or Publish to npm + id: changesets + uses: changesets/action@v1 + with: + # This expects you to have a script called release which does a build for your packages and calls changeset publish + publish: pnpm release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From 03d6531a7d4a7e81dcb02cdba539858404ec5be2 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 14:10:25 +0530 Subject: [PATCH 053/124] chore: Revert package versions to match master --- packages/mermaid/package.json | 2 +- packages/parser/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index f3a2d8299..77e291e97 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "11.0.0-alpha.7", + "version": "10.9.1", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "type": "module", "module": "./dist/mermaid.core.mjs", diff --git a/packages/parser/package.json b/packages/parser/package.json index 17c4afd31..4f206ec3e 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@mermaid-js/parser", - "version": "0.1.0-rc.2", + "version": "0.1.0", "description": "MermaidJS parser", "author": "Yokozuna59", "contributors": [ From 6e4b349c3a0069cc8ad6b8534cbd879064e516f5 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 14:11:54 +0530 Subject: [PATCH 054/124] chore: Ignore packages in changeset --- .changeset/config.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/config.json b/.changeset/config.json index c44652e6d..ff71d7ec7 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -5,7 +5,7 @@ "fixed": [], "linked": [], "access": "restricted", - "baseBranch": "develop", + "baseBranch": "master", "updateInternalDependencies": "patch", - "ignore": [] + "ignore": ["@mermaid-js/docs", "@mermaid-js/webpack-test", "@mermaid-js/mermaid-example-diagram"] } From 90364a020b133334adf1bcd96e2241c3d563a226 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 14:19:44 +0530 Subject: [PATCH 055/124] docs: Add changeset --- .changeset/seven-paws-prove.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .changeset/seven-paws-prove.md diff --git a/.changeset/seven-paws-prove.md b/.changeset/seven-paws-prove.md new file mode 100644 index 000000000..c98e4104e --- /dev/null +++ b/.changeset/seven-paws-prove.md @@ -0,0 +1,11 @@ +--- +'mermaid': major +'@mermaid-js/layout-elk': minor +'@mermaid-js/parser': minor +--- + +Uses new rendering engine to simplify adding new diagrams +ELK layout engine is split into separate package +Replaces UMD with IIFE bundle +Adds Packet Diagram +Adds support for HandDrawn mode From 36444ab24231b5587a9b377579de7a84c7e56537 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 14:22:33 +0530 Subject: [PATCH 056/124] Update access --- .changeset/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/config.json b/.changeset/config.json index ff71d7ec7..5c22e9097 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -4,7 +4,7 @@ "commit": false, "fixed": [], "linked": [], - "access": "restricted", + "access": "public", "baseBranch": "master", "updateInternalDependencies": "patch", "ignore": ["@mermaid-js/docs", "@mermaid-js/webpack-test", "@mermaid-js/mermaid-example-diagram"] From d0ea3dd82b09ead6adb5fbc7bff70626e7331cdc Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 14:27:34 +0530 Subject: [PATCH 057/124] chore: Update release command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b77591e2..db234f662 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "dev": "tsx .esbuild/server.ts", "dev:vite": "tsx .vite/server.ts", "dev:coverage": "pnpm coverage:cypress:clean && VITE_COVERAGE=true pnpm dev:vite", - "release": "pnpm build", + "release": "pnpm build && changeset publish", "lint": "eslint --quiet --stats --cache --cache-strategy content . && pnpm lint:jison && prettier --cache --check .", "lint:fix": "eslint --cache --cache-strategy content --fix . && prettier --write . && tsx scripts/fixCSpell.ts", "lint:jison": "tsx ./scripts/jison/lint.mts", From 7a1c25bb3b11d3c5d77ad99fd5dd13d753e4ae34 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 08:57:34 +0000 Subject: [PATCH 058/124] [autofix.ci] apply automated fixes --- docs/config/usage.md | 4 ++-- docs/intro/getting-started.md | 4 ++-- docs/intro/index.md | 4 ++-- docs/syntax/mindmap.md | 2 +- docs/syntax/timeline.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/config/usage.md b/docs/config/usage.md index 2e207213c..186440b34 100644 --- a/docs/config/usage.md +++ b/docs/config/usage.md @@ -64,7 +64,7 @@ Example: ```html ``` @@ -83,7 +83,7 @@ Example: B-->D(fa:fa-spinner);
diff --git a/docs/intro/getting-started.md b/docs/intro/getting-started.md index a626d1f53..12649ace6 100644 --- a/docs/intro/getting-started.md +++ b/docs/intro/getting-started.md @@ -224,7 +224,7 @@ b. The importing of the Mermaid library through the `mermaid.esm.mjs` or `mermai ```html @@ -262,7 +262,7 @@ In this example, the `mermaidAPI` is being called through the `CDN`: diff --git a/docs/intro/index.md b/docs/intro/index.md index fda36f1da..725fd8407 100644 --- a/docs/intro/index.md +++ b/docs/intro/index.md @@ -319,7 +319,7 @@ To select a version: Replace `` with the desired version number. -Latest Version: +Latest Version: ## Deploying Mermaid @@ -337,7 +337,7 @@ To Deploy Mermaid: ```html ``` diff --git a/docs/syntax/mindmap.md b/docs/syntax/mindmap.md index dfdcdbdac..5e180b554 100644 --- a/docs/syntax/mindmap.md +++ b/docs/syntax/mindmap.md @@ -304,7 +304,7 @@ From version 9.4.0 you can simplify this code to: ```html ``` diff --git a/docs/syntax/timeline.md b/docs/syntax/timeline.md index 3d476c41d..0f8d426b6 100644 --- a/docs/syntax/timeline.md +++ b/docs/syntax/timeline.md @@ -469,7 +469,7 @@ You can use this method to add mermaid including the timeline diagram to a web p ```html ``` From c61159b63f2c81030294653b60e45facf025f8ee Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 14:37:17 +0530 Subject: [PATCH 059/124] Update release command --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index db234f662..f1587d05a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "dev": "tsx .esbuild/server.ts", "dev:vite": "tsx .vite/server.ts", "dev:coverage": "pnpm coverage:cypress:clean && VITE_COVERAGE=true pnpm dev:vite", - "release": "pnpm build && changeset publish", + "release": "pnpm build && pnpm --filter mermaid run docs:release-version && pnpm --filter mermaid run docs:build && changeset publish", "lint": "eslint --quiet --stats --cache --cache-strategy content . && pnpm lint:jison && prettier --cache --check .", "lint:fix": "eslint --cache --cache-strategy content --fix . && prettier --write . && tsx scripts/fixCSpell.ts", "lint:jison": "tsx ./scripts/jison/lint.mts", From 6e7a24e2007dc89ca0fafc8705fdd46217d036a7 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 15:21:48 +0530 Subject: [PATCH 060/124] Update version and publish scripts --- .github/workflows/release.yml | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c94d759a..0b36a82b3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,8 +30,8 @@ jobs: id: changesets uses: changesets/action@v1 with: - # This expects you to have a script called release which does a build for your packages and calls changeset publish - publish: pnpm release + version: pnpm changeset:version + publish: pnpm changeset:publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/package.json b/package.json index f1587d05a..7b77087d8 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ "dev": "tsx .esbuild/server.ts", "dev:vite": "tsx .vite/server.ts", "dev:coverage": "pnpm coverage:cypress:clean && VITE_COVERAGE=true pnpm dev:vite", - "release": "pnpm build && pnpm --filter mermaid run docs:release-version && pnpm --filter mermaid run docs:build && changeset publish", + "changeset:version": "changeset version && pnpm build && pnpm --filter mermaid run docs:release-version && pnpm --filter mermaid run docs:build && git add --all", + "changeset:publish": "changeset publish", "lint": "eslint --quiet --stats --cache --cache-strategy content . && pnpm lint:jison && prettier --cache --check .", "lint:fix": "eslint --cache --cache-strategy content --fix . && prettier --write . && tsx scripts/fixCSpell.ts", "lint:jison": "tsx ./scripts/jison/lint.mts", @@ -40,7 +41,6 @@ "test": "pnpm lint && vitest run", "test:watch": "vitest --watch", "test:coverage": "vitest --coverage", - "prepublishOnly": "pnpm build && pnpm test", "prepare": "husky install && pnpm build", "pre-commit": "lint-staged" }, From fc44d1fcddd1711fc3674d86c4a314b22eeb5646 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:56:56 +0000 Subject: [PATCH 061/124] [autofix.ci] apply automated fixes --- .../setup/interfaces/mermaid.LayoutLoaderDefinition.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/config/setup/interfaces/mermaid.LayoutLoaderDefinition.md b/docs/config/setup/interfaces/mermaid.LayoutLoaderDefinition.md index 441eb9209..90a64187c 100644 --- a/docs/config/setup/interfaces/mermaid.LayoutLoaderDefinition.md +++ b/docs/config/setup/interfaces/mermaid.LayoutLoaderDefinition.md @@ -16,7 +16,7 @@ #### Defined in -[packages/mermaid/src/rendering-util/render.ts:25](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L25) +[packages/mermaid/src/rendering-util/render.ts:24](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L24) --- @@ -26,7 +26,7 @@ #### Defined in -[packages/mermaid/src/rendering-util/render.ts:24](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L24) +[packages/mermaid/src/rendering-util/render.ts:23](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L23) --- @@ -36,4 +36,4 @@ #### Defined in -[packages/mermaid/src/rendering-util/render.ts:23](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L23) +[packages/mermaid/src/rendering-util/render.ts:22](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L22) From 7debe2fc593a718d661b5d241bab0ee0d0eae7bf Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 15:27:30 +0530 Subject: [PATCH 062/124] Split changesets --- .changeset/late-baboons-remember.md | 5 +++++ .changeset/quick-poets-act.md | 5 +++++ .changeset/seven-paws-prove.md | 4 ---- .changeset/tender-squids-boil.md | 5 +++++ 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 .changeset/late-baboons-remember.md create mode 100644 .changeset/quick-poets-act.md create mode 100644 .changeset/tender-squids-boil.md diff --git a/.changeset/late-baboons-remember.md b/.changeset/late-baboons-remember.md new file mode 100644 index 000000000..5097c0e6a --- /dev/null +++ b/.changeset/late-baboons-remember.md @@ -0,0 +1,5 @@ +--- +'mermaid': minor +--- + +Adds Packet Diagram diff --git a/.changeset/quick-poets-act.md b/.changeset/quick-poets-act.md new file mode 100644 index 000000000..444411aa8 --- /dev/null +++ b/.changeset/quick-poets-act.md @@ -0,0 +1,5 @@ +--- +'mermaid': major +--- + +Replaces UMD with IIFE bundle diff --git a/.changeset/seven-paws-prove.md b/.changeset/seven-paws-prove.md index c98e4104e..e48481be1 100644 --- a/.changeset/seven-paws-prove.md +++ b/.changeset/seven-paws-prove.md @@ -1,11 +1,7 @@ --- 'mermaid': major '@mermaid-js/layout-elk': minor -'@mermaid-js/parser': minor --- Uses new rendering engine to simplify adding new diagrams ELK layout engine is split into separate package -Replaces UMD with IIFE bundle -Adds Packet Diagram -Adds support for HandDrawn mode diff --git a/.changeset/tender-squids-boil.md b/.changeset/tender-squids-boil.md new file mode 100644 index 000000000..47cf8d237 --- /dev/null +++ b/.changeset/tender-squids-boil.md @@ -0,0 +1,5 @@ +--- +'mermaid': minor +--- + +Adds support for HandDrawn mode From c892a89536c7b376b589bfa5b82488cf752e8482 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 15:37:20 +0530 Subject: [PATCH 063/124] Mark @mermaid-js/mermaid-example-diagram as private --- packages/mermaid-example-diagram/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/mermaid-example-diagram/package.json b/packages/mermaid-example-diagram/package.json index b899e077b..18d123add 100644 --- a/packages/mermaid-example-diagram/package.json +++ b/packages/mermaid-example-diagram/package.json @@ -1,6 +1,7 @@ { "name": "@mermaid-js/mermaid-example-diagram", "version": "9.3.0", + "private": true, "description": "Example of external diagram module for MermaidJS.", "module": "dist/mermaid-example-diagram.core.mjs", "types": "dist/detector.d.ts", From c4b92069ba2375ec31055587cae3afeb508e5d04 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 15:45:20 +0530 Subject: [PATCH 064/124] chore: Copy readme before publish --- package.json | 4 +++- packages/mermaid/package.json | 5 +---- pnpm-lock.yaml | 6 +++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 7b77087d8..5f4f4a7e9 100644 --- a/package.json +++ b/package.json @@ -24,8 +24,9 @@ "dev": "tsx .esbuild/server.ts", "dev:vite": "tsx .vite/server.ts", "dev:coverage": "pnpm coverage:cypress:clean && VITE_COVERAGE=true pnpm dev:vite", + "copy-readme": "cpy './README.*' ./packages/mermaid/ --cwd=.", "changeset:version": "changeset version && pnpm build && pnpm --filter mermaid run docs:release-version && pnpm --filter mermaid run docs:build && git add --all", - "changeset:publish": "changeset publish", + "changeset:publish": "pnpm copy-readme && changeset publish", "lint": "eslint --quiet --stats --cache --cache-strategy content . && pnpm lint:jison && prettier --cache --check .", "lint:fix": "eslint --cache --cache-strategy content --fix . && prettier --write . && tsx scripts/fixCSpell.ts", "lint:jison": "tsx ./scripts/jison/lint.mts", @@ -83,6 +84,7 @@ "chokidar": "^3.6.0", "concurrently": "^8.2.2", "cors": "^2.8.5", + "cpy-cli": "^5.0.0", "cross-env": "^7.0.3", "cspell": "^8.6.0", "cypress": "^13.11.0", diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index 77e291e97..97e19c272 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -47,9 +47,7 @@ "docs:verify-version": "tsx scripts/update-release-version.mts --verify", "types:build-config": "tsx scripts/create-types-from-json-schema.mts", "types:verify-config": "tsx scripts/create-types-from-json-schema.mts --verify", - "checkCircle": "npx madge --circular ./src", - "release": "pnpm build", - "prepublishOnly": "cpy '../../README.*' ./ --cwd=. && pnpm docs:release-version && pnpm -w run build" + "checkCircle": "npx madge --circular ./src" }, "repository": { "type": "git", @@ -106,7 +104,6 @@ "ajv": "^8.12.0", "chokidar": "^3.6.0", "concurrently": "^8.2.2", - "cpy-cli": "^5.0.0", "csstree-validator": "^3.0.0", "globby": "^14.0.1", "jison": "^0.4.18", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 60d1c2898..175f16bc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -74,6 +74,9 @@ importers: cors: specifier: ^2.8.5 version: 2.8.5 + cpy-cli: + specifier: ^5.0.0 + version: 5.0.0 cross-env: specifier: ^7.0.3 version: 7.0.3 @@ -312,9 +315,6 @@ importers: concurrently: specifier: ^8.2.2 version: 8.2.2 - cpy-cli: - specifier: ^5.0.0 - version: 5.0.0 csstree-validator: specifier: ^3.0.0 version: 3.0.0 From 3d9a24dd283989b4bc21eb423ec4a27a1264809f Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 15:46:04 +0530 Subject: [PATCH 065/124] chore: Remove prePublishOnly --- packages/mermaid-example-diagram/package.json | 4 +--- packages/mermaid-layout-elk/package.json | 4 +--- packages/mermaid-zenuml/package.json | 3 +-- packages/parser/package.json | 3 +-- 4 files changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/mermaid-example-diagram/package.json b/packages/mermaid-example-diagram/package.json index 18d123add..28cb54b9e 100644 --- a/packages/mermaid-example-diagram/package.json +++ b/packages/mermaid-example-diagram/package.json @@ -19,9 +19,7 @@ "example", "mermaid" ], - "scripts": { - "prepublishOnly": "pnpm -w run build" - }, + "scripts": {}, "repository": { "type": "git", "url": "https://github.com/mermaid-js/mermaid" diff --git a/packages/mermaid-layout-elk/package.json b/packages/mermaid-layout-elk/package.json index f833dba52..7a0332f4f 100644 --- a/packages/mermaid-layout-elk/package.json +++ b/packages/mermaid-layout-elk/package.json @@ -18,9 +18,7 @@ "elk", "mermaid" ], - "scripts": { - "prepublishOnly": "pnpm -w run build" - }, + "scripts": {}, "repository": { "type": "git", "url": "https://github.com/mermaid-js/mermaid" diff --git a/packages/mermaid-zenuml/package.json b/packages/mermaid-zenuml/package.json index 1a47a99d8..3d0d25d7e 100644 --- a/packages/mermaid-zenuml/package.json +++ b/packages/mermaid-zenuml/package.json @@ -19,8 +19,7 @@ "mermaid" ], "scripts": { - "clean": "rimraf dist", - "prepublishOnly": "pnpm -w run build" + "clean": "rimraf dist" }, "repository": { "type": "git", diff --git a/packages/parser/package.json b/packages/parser/package.json index 4f206ec3e..a44174696 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -19,8 +19,7 @@ "scripts": { "clean": "rimraf dist src/language/generated", "langium:generate": "langium generate", - "langium:watch": "langium generate --watch", - "prepublishOnly": "pnpm -w run build" + "langium:watch": "langium generate --watch" }, "repository": { "type": "git", From 61632f2d7fc5f7647a19eb26e9135e3d4a503d6f Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 15:47:00 +0530 Subject: [PATCH 066/124] verify Docs version before publish --- packages/mermaid/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index 97e19c272..3de714139 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -47,7 +47,8 @@ "docs:verify-version": "tsx scripts/update-release-version.mts --verify", "types:build-config": "tsx scripts/create-types-from-json-schema.mts", "types:verify-config": "tsx scripts/create-types-from-json-schema.mts --verify", - "checkCircle": "npx madge --circular ./src" + "checkCircle": "npx madge --circular ./src", + "prepublishOnly": "pnpm docs:verify-version" }, "repository": { "type": "git", From cc545f443308e89009989574cfd79e5930160ed2 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 15:57:56 +0530 Subject: [PATCH 067/124] Update changelog format --- .changeset/config.json | 2 +- package.json | 1 + pnpm-lock.yaml | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/.changeset/config.json b/.changeset/config.json index 5c22e9097..1696bf66e 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -1,6 +1,6 @@ { "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", - "changelog": "@changesets/cli/changelog", + "changelog": ["@changesets/changelog-github", { "repo": "mermaid-js/mermaid" }], "commit": false, "fixed": [], "linked": [], diff --git a/package.json b/package.json index 5f4f4a7e9..f0045f7ae 100644 --- a/package.json +++ b/package.json @@ -64,6 +64,7 @@ "devDependencies": { "@applitools/eyes-cypress": "^3.44.4", "@argos-ci/cypress": "^2.1.0", + "@changesets/changelog-github": "^0.5.0", "@changesets/cli": "^2.27.7", "@cspell/eslint-plugin": "^8.8.4", "@cypress/code-coverage": "^3.12.30", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 175f16bc1..69526432e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: '@argos-ci/cypress': specifier: ^2.1.0 version: 2.1.1(cypress@13.13.2) + '@changesets/changelog-github': + specifier: ^0.5.0 + version: 0.5.0(encoding@0.1.13) '@changesets/cli': specifier: ^2.27.7 version: 2.27.7 @@ -1365,6 +1368,9 @@ packages: '@changesets/changelog-git@0.2.0': resolution: {integrity: sha512-bHOx97iFI4OClIT35Lok3sJAwM31VbUM++gnMBV16fdbtBhgYu4dxsphBF/0AZZsyAHMrnM0yFcj5gZM1py6uQ==} + '@changesets/changelog-github@0.5.0': + resolution: {integrity: sha512-zoeq2LJJVcPJcIotHRJEEA2qCqX0AQIeFE+L21L8sRLPVqDhSXY8ZWAt2sohtBpFZkBwu+LUwMSKRr2lMy3LJA==} + '@changesets/cli@2.27.7': resolution: {integrity: sha512-6lr8JltiiXPIjDeYg4iM2MeePP6VN/JkmqBsVA5XRiy01hGS3y629LtSDvKcycj/w/5Eur1rEwby/MjcYS+e2A==} hasBin: true @@ -1378,6 +1384,9 @@ packages: '@changesets/get-dependents-graph@2.1.1': resolution: {integrity: sha512-LRFjjvigBSzfnPU2n/AhFsuWR5DK++1x47aq6qZ8dzYsPtS/I5mNhIGAS68IAxh1xjO9BTtz55FwefhANZ+FCA==} + '@changesets/get-github-info@0.6.0': + resolution: {integrity: sha512-v/TSnFVXI8vzX9/w3DU2Ol+UlTZcu3m0kXTjTT4KlAdwSvwutcByYwyYn9hwerPWfPkT2JfpoX0KgvCEi8Q/SA==} + '@changesets/get-release-plan@4.0.3': resolution: {integrity: sha512-6PLgvOIwTSdJPTtpdcr3sLtGatT+Jr22+cQwEBJBy6wP0rjB4yJ9lv583J9fVpn1bfQlBkDa8JxbS2g/n9lIyA==} @@ -4156,6 +4165,9 @@ packages: resolution: {integrity: sha512-t/Ygsytq+R995EJ5PZlD4Cu56sWa8InXySaViRzw9apusqsOO2bQP+SbYzAhR0pFKoB+43lYy8rWban9JSuXnA==} engines: {node: '>= 0.4'} + dataloader@1.4.0: + resolution: {integrity: sha512-68s5jYdlvasItOJnCuI2Q9s4q98g0pCyL3HrcKJu8KNugUl8ahgmZYg38ysLTgQjjXX3H8CJLkAvWrclWfcalw==} + date-fns@2.30.0: resolution: {integrity: sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==} engines: {node: '>=0.11'} @@ -4360,6 +4372,10 @@ packages: resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==} engines: {node: '>=12'} + dotenv@8.6.0: + resolution: {integrity: sha512-IrPdXQsk2BbzvCBGBOTmmSH5SodmqZNt4ERAZDmW4CT+tL8VtvinqywuANaFu4bOMWki16nqf0e4oC0QIaDr/g==} + engines: {node: '>=10'} + duplexer@0.1.2: resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} @@ -9978,6 +9994,14 @@ snapshots: dependencies: '@changesets/types': 6.0.0 + '@changesets/changelog-github@0.5.0(encoding@0.1.13)': + dependencies: + '@changesets/get-github-info': 0.6.0(encoding@0.1.13) + '@changesets/types': 6.0.0 + dotenv: 8.6.0 + transitivePeerDependencies: + - encoding + '@changesets/cli@2.27.7': dependencies: '@babel/runtime': 7.25.0 @@ -10035,6 +10059,13 @@ snapshots: fs-extra: 7.0.1 semver: 7.6.3 + '@changesets/get-github-info@0.6.0(encoding@0.1.13)': + dependencies: + dataloader: 1.4.0 + node-fetch: 2.6.7(encoding@0.1.13) + transitivePeerDependencies: + - encoding + '@changesets/get-release-plan@4.0.3': dependencies: '@babel/runtime': 7.25.0 @@ -13323,6 +13354,8 @@ snapshots: es-errors: 1.3.0 is-data-view: 1.0.1 + dataloader@1.4.0: {} + date-fns@2.30.0: dependencies: '@babel/runtime': 7.25.0 @@ -13471,6 +13504,8 @@ snapshots: dotenv@16.4.5: {} + dotenv@8.6.0: {} + duplexer@0.1.2: {} eastasianwidth@0.2.0: {} From 598de7019aff4153e945a7ea7258fbadc5af85ce Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 16:11:31 +0530 Subject: [PATCH 068/124] Remove changesets --- .changeset/late-baboons-remember.md | 5 ----- .changeset/quick-poets-act.md | 5 ----- .changeset/seven-paws-prove.md | 7 ------- .changeset/tender-squids-boil.md | 5 ----- 4 files changed, 22 deletions(-) delete mode 100644 .changeset/late-baboons-remember.md delete mode 100644 .changeset/quick-poets-act.md delete mode 100644 .changeset/seven-paws-prove.md delete mode 100644 .changeset/tender-squids-boil.md diff --git a/.changeset/late-baboons-remember.md b/.changeset/late-baboons-remember.md deleted file mode 100644 index 5097c0e6a..000000000 --- a/.changeset/late-baboons-remember.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'mermaid': minor ---- - -Adds Packet Diagram diff --git a/.changeset/quick-poets-act.md b/.changeset/quick-poets-act.md deleted file mode 100644 index 444411aa8..000000000 --- a/.changeset/quick-poets-act.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'mermaid': major ---- - -Replaces UMD with IIFE bundle diff --git a/.changeset/seven-paws-prove.md b/.changeset/seven-paws-prove.md deleted file mode 100644 index e48481be1..000000000 --- a/.changeset/seven-paws-prove.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'mermaid': major -'@mermaid-js/layout-elk': minor ---- - -Uses new rendering engine to simplify adding new diagrams -ELK layout engine is split into separate package diff --git a/.changeset/tender-squids-boil.md b/.changeset/tender-squids-boil.md deleted file mode 100644 index 47cf8d237..000000000 --- a/.changeset/tender-squids-boil.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'mermaid': minor ---- - -Adds support for HandDrawn mode From eac845904131c548d0ac52407c43aac424d983ce Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 16:17:07 +0530 Subject: [PATCH 069/124] Add changeset to PR template --- .github/pull_request_template.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index cfd22a293..c22166619 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -15,4 +15,4 @@ Make sure you - [ ] :book: have read the [contribution guidelines](https://mermaid.js.org/community/contributing.html) - [ ] :computer: have added necessary unit/e2e tests. - [ ] :notebook: have added documentation. Make sure [`MERMAID_RELEASE_VERSION`](https://mermaid.js.org/community/contributing.html#update-documentation) is used for all new features. -- [ ] :bookmark: targeted `develop` branch +- [ ] :butterfly: If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running `pnpm changeset` and following the prompts. Changesets that add features should be `minor` and those that fix bugs should be `patch`. Please prefix changeset messages with `feat:`, `fix:`, or `chore:`. From 283ec73ed9b227f1e722b3e52ffde6cf6a47ad04 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 16:17:17 +0530 Subject: [PATCH 070/124] Remove release drafter --- .github/release-drafter.yml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 .github/release-drafter.yml diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml deleted file mode 100644 index 83138c3d4..000000000 --- a/.github/release-drafter.yml +++ /dev/null @@ -1,36 +0,0 @@ -name-template: '$NEXT_PATCH_VERSION' -tag-template: '$NEXT_PATCH_VERSION' -categories: - - title: '🚨 **Breaking Changes**' - labels: - - 'Breaking Change' - - title: '🚀 Features' - labels: - - 'Type: Enhancement' - - 'feature' # deprecated, new PRs shouldn't have this - - title: '🐛 Bug Fixes' - labels: - - 'Type: Bug / Error' - - 'fix' # deprecated, new PRs shouldn't have this - - title: '🧰 Maintenance' - labels: - - 'Type: Other' - - 'chore' # deprecated, new PRs shouldn't have this - - title: '⚡️ Performance' - labels: - - 'Type: Performance' - - title: '📚 Documentation' - labels: - - 'Area: Documentation' -change-template: '- $TITLE (#$NUMBER) @$AUTHOR' -sort-by: title -sort-direction: ascending -exclude-labels: - - 'Skip changelog' -no-changes-template: 'This release contains minor changes and bugfixes.' -template: | - # Release Notes - - $CHANGES - - 🎉 **Thanks to all contributors helping with this release!** 🎉 From 5ed5274256b84852091bde65f5033cbee605d3f6 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 16:18:39 +0530 Subject: [PATCH 071/124] chore: Revert version changes --- packages/mermaid/package.json | 2 +- packages/parser/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index 3de714139..c302e94d7 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "10.9.1", + "version": "11.0.0-alpha.7", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "type": "module", "module": "./dist/mermaid.core.mjs", diff --git a/packages/parser/package.json b/packages/parser/package.json index a44174696..da875ce45 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@mermaid-js/parser", - "version": "0.1.0", + "version": "0.1.0-rc.2", "description": "MermaidJS parser", "author": "Yokozuna59", "contributors": [ From 0c316d9dc296637a8f594638565c2e4d4365e99a Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 16:18:59 +0530 Subject: [PATCH 072/124] chore: Revert version changes --- docs/config/usage.md | 4 ++-- docs/intro/getting-started.md | 4 ++-- docs/intro/index.md | 4 ++-- docs/syntax/mindmap.md | 2 +- docs/syntax/timeline.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/config/usage.md b/docs/config/usage.md index 186440b34..2e207213c 100644 --- a/docs/config/usage.md +++ b/docs/config/usage.md @@ -64,7 +64,7 @@ Example: ```html ``` @@ -83,7 +83,7 @@ Example: B-->D(fa:fa-spinner); diff --git a/docs/intro/getting-started.md b/docs/intro/getting-started.md index 12649ace6..a626d1f53 100644 --- a/docs/intro/getting-started.md +++ b/docs/intro/getting-started.md @@ -224,7 +224,7 @@ b. The importing of the Mermaid library through the `mermaid.esm.mjs` or `mermai ```html @@ -262,7 +262,7 @@ In this example, the `mermaidAPI` is being called through the `CDN`: diff --git a/docs/intro/index.md b/docs/intro/index.md index 725fd8407..fda36f1da 100644 --- a/docs/intro/index.md +++ b/docs/intro/index.md @@ -319,7 +319,7 @@ To select a version: Replace `` with the desired version number. -Latest Version: +Latest Version: ## Deploying Mermaid @@ -337,7 +337,7 @@ To Deploy Mermaid: ```html ``` diff --git a/docs/syntax/mindmap.md b/docs/syntax/mindmap.md index 5e180b554..dfdcdbdac 100644 --- a/docs/syntax/mindmap.md +++ b/docs/syntax/mindmap.md @@ -304,7 +304,7 @@ From version 9.4.0 you can simplify this code to: ```html ``` diff --git a/docs/syntax/timeline.md b/docs/syntax/timeline.md index 0f8d426b6..3d476c41d 100644 --- a/docs/syntax/timeline.md +++ b/docs/syntax/timeline.md @@ -469,7 +469,7 @@ You can use this method to add mermaid including the timeline diagram to a web p ```html ``` From ad12fa7fffa17daea4a6b329cd0b971363a9dec2 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 19:35:10 +0530 Subject: [PATCH 073/124] Fix config --- .changeset/config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/config.json b/.changeset/config.json index 1696bf66e..ffda055e8 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -7,5 +7,6 @@ "access": "public", "baseBranch": "master", "updateInternalDependencies": "patch", + "bumpVersionsWithWorkspaceProtocolOnly": true, "ignore": ["@mermaid-js/docs", "@mermaid-js/webpack-test", "@mermaid-js/mermaid-example-diagram"] } From 0ad44c12feead9d20c6a870a49327ada58d6e657 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 19:41:19 +0530 Subject: [PATCH 074/124] chore: Fix peer dependencies --- packages/mermaid-layout-elk/package.json | 13 +++++++------ packages/mermaid-zenuml/package.json | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/mermaid-layout-elk/package.json b/packages/mermaid-layout-elk/package.json index f833dba52..a04a897ff 100644 --- a/packages/mermaid-layout-elk/package.json +++ b/packages/mermaid-layout-elk/package.json @@ -1,6 +1,6 @@ { "name": "@mermaid-js/layout-elk", - "version": "0.0.1", + "version": "0.1.0", "description": "ELK layout engine for mermaid", "module": "dist/mermaid-layout-elk.core.mjs", "types": "dist/packages/mermaid-layout-elk/src/index.d.ts", @@ -34,13 +34,14 @@ "d3": "^7.9.0", "elkjs": "^0.9.3" }, - "peerDependencies": { + "devDependencies": { + "@types/d3": "^7.4.3", "mermaid": "workspace:^" }, + "peerDependencies": { + "mermaid": "^11.0.0" + }, "files": [ "dist" - ], - "devDependencies": { - "@types/d3": "^7.4.3" - } + ] } diff --git a/packages/mermaid-zenuml/package.json b/packages/mermaid-zenuml/package.json index 1a47a99d8..43b950e12 100644 --- a/packages/mermaid-zenuml/package.json +++ b/packages/mermaid-zenuml/package.json @@ -40,7 +40,7 @@ "mermaid": "workspace:^" }, "peerDependencies": { - "mermaid": "workspace:>=10.0.0" + "mermaid": "^10 || ^11" }, "files": [ "dist" From ae2dc7038595e0a8b518b6198fa114261ee143b9 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 22 Aug 2024 19:45:49 +0530 Subject: [PATCH 075/124] chore: Update lockfile --- pnpm-lock.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3d65d772a..ee5527070 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -409,13 +409,13 @@ importers: elkjs: specifier: ^0.9.3 version: 0.9.3 - mermaid: - specifier: workspace:^ - version: link:../mermaid devDependencies: '@types/d3': specifier: ^7.4.3 version: 7.4.3 + mermaid: + specifier: workspace:^ + version: link:../mermaid packages/mermaid-zenuml: dependencies: From 19d46fc823915d2b672868ea127cbd29031468a6 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Thu, 22 Aug 2024 16:29:23 +0200 Subject: [PATCH 076/124] #5237 Fix for weird line intersection --- .../rendering-elements/edges.js | 29 ++++++++++--------- .../rendering-elements/shapes/question.ts | 9 +++++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/edges.js b/packages/mermaid/src/rendering-util/rendering-elements/edges.js index 087fcf0be..0502da097 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/edges.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/edges.js @@ -429,19 +429,22 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod const tail = startNode; var head = endNode; - if (head.intersect && tail.intersect) { - points = points.slice(1, edge.points.length - 1); - points.unshift(tail.intersect(points[0])); - log.debug( - 'Last point APA12', - edge.start, - '-->', - edge.end, - points[points.length - 1], - head, - head.intersect(points[points.length - 1]) - ); - points.push(head.intersect(points[points.length - 1])); + if (head.intersect && tail.intersect && points.length > 2) { + const initialStartPoint = Object.assign({}, points[0]); + const newEnd = head.intersect(points[points.length - 2]); + + const newStart = tail.intersect(points[1]); + if (newStart.x && newStart.y) { + points.unshift(newStart); + } else { + points.unshift(initialStartPoint); + } + if (newEnd.x && newEnd.y) { + const lastPoint = points[points.length - 1]; + if (lastPoint.x !== newEnd.x && lastPoint.y !== newEnd.y) { + points.push(newEnd); + } + } } if (edge.toCluster) { log.info('to cluster abc88', clusterDb.get(edge.toCluster)); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts index f6f3f3049..ba770ab4e 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts @@ -63,7 +63,14 @@ export const question = async (parent: SVGAElement, node: Node): Promise Date: Thu, 22 Aug 2024 17:52:48 +0200 Subject: [PATCH 077/124] Fix for text alignment issue --- packages/mermaid/src/rendering-util/createText.ts | 1 + .../rendering-elements/shapes/rectWithTitle.ts | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/mermaid/src/rendering-util/createText.ts b/packages/mermaid/src/rendering-util/createText.ts index c6ce204ba..a6ad7fa1c 100644 --- a/packages/mermaid/src/rendering-util/createText.ts +++ b/packages/mermaid/src/rendering-util/createText.ts @@ -36,6 +36,7 @@ async function addHtmlSpan(element, node, width, classes, addBackground = false) div.style('white-space', 'nowrap'); div.style('line-height', '1.5'); div.style('max-width', width + 'px'); + div.style('text-align', 'center'); div.attr('xmlns', 'http://www.w3.org/1999/xhtml'); if (addBackground) { div.attr('class', 'labelBkg'); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts index 43ce708d8..857e60b8b 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts @@ -62,13 +62,13 @@ export const rectWithTitle = async (parent: SVGElement, node: Node) => { ) ); - if (evaluate(getConfig()?.flowchart?.htmlLabels)) { - const div = descr.children[0]; - const dv = select(descr); - bbox = div.getBoundingClientRect(); - dv.attr('width', bbox.width); - dv.attr('height', bbox.height); - } + //if (evaluate(getConfig()?.flowchart?.htmlLabels)) { + const div = descr.children[0]; + const dv = select(descr); + bbox = div.getBoundingClientRect(); + dv.attr('width', bbox.width); + dv.attr('height', bbox.height); + // } const halfPadding = (node.padding || 0) / 2; select(descr).attr( From 09afb077f05f7b57a5639d8826e527d998a2bed5 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 23 Aug 2024 08:24:36 +0200 Subject: [PATCH 078/124] Basic fix for handdrawn subgraph styling --- .../rendering-elements/clusters.js | 5 ++++- .../shapes/handDrawnShapeStyles.ts | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js index 9546dfad4..ba87f78f5 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js @@ -19,7 +19,7 @@ const rect = async (parent, node) => { const { themeVariables, handDrawnSeed } = siteConfig; const { clusterBkg, clusterBorder } = themeVariables; - const { labelStyles, nodeStyles } = styles2String(node); + const { labelStyles, nodeStyles, borderStyles, backgroundStyles } = styles2String(node); // Add outer g element const shapeSvg = parent @@ -79,6 +79,9 @@ const rect = async (parent, node) => { log.debug('Rough node insert CXC', roughNode); return roughNode; }, ':first-child'); + // Should we affect the options instead of doing this? + rect.select('path:nth-child(2)').attr('style', borderStyles.join(';')); + rect.select('path').attr('style', backgroundStyles.join(';').replace('fill', 'stroke')); } else { // add the rect rect = shapeSvg.insert('rect', ':first-child'); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts index 11773f543..3840244e9 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts @@ -37,6 +37,8 @@ export const styles2String = (node: Node) => { const { stylesArray } = compileStyles(node); const labelStyles: string[] = []; const nodeStyles: string[] = []; + const borderStyles: string[] = []; + const backgroundStyles: string[] = []; stylesArray.forEach((style) => { const key = style[0]; @@ -63,10 +65,22 @@ export const styles2String = (node: Node) => { labelStyles.push(style.join(':') + ' !important'); } else { nodeStyles.push(style.join(':') + ' !important'); + if (key === 'stroke' || key === 'stroke-width') { + borderStyles.push(style.join(':') + ' !important'); + } + if (key === 'fill') { + backgroundStyles.push(style.join(':') + ' !important'); + } } }); - return { labelStyles: labelStyles.join(';'), nodeStyles: nodeStyles.join(';') }; + return { + labelStyles: labelStyles.join(';'), + nodeStyles: nodeStyles.join(';'), + stylesArray, + borderStyles, + backgroundStyles, + }; }; // Striped fill like start or fork nodes in state diagrams From 24490f7789a93977ac760b4af10be1212d47bfb5 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 23 Aug 2024 12:07:41 +0530 Subject: [PATCH 079/124] Update ComboStrap link --- docs/ecosystem/integrations-community.md | 2 +- packages/mermaid/src/docs/ecosystem/integrations-community.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ecosystem/integrations-community.md b/docs/ecosystem/integrations-community.md index 949e53277..75f20dd1a 100644 --- a/docs/ecosystem/integrations-community.md +++ b/docs/ecosystem/integrations-community.md @@ -135,7 +135,7 @@ Communication tools and platforms ### Wikis - [DokuWiki](https://dokuwiki.org) - - [ComboStrap](https://combostrap.com/mermaid) + - [ComboStrap](https://combostrap.com/utility/create-diagram-with-mermaid-vh3ab9yj) - [Mermaid Plugin](https://www.dokuwiki.org/plugin:mermaid) - [Foswiki](https://foswiki.org) - [Mermaid Plugin](https://foswiki.org/Extensions/MermaidPlugin) diff --git a/packages/mermaid/src/docs/ecosystem/integrations-community.md b/packages/mermaid/src/docs/ecosystem/integrations-community.md index f7bc859b1..81b0386b1 100644 --- a/packages/mermaid/src/docs/ecosystem/integrations-community.md +++ b/packages/mermaid/src/docs/ecosystem/integrations-community.md @@ -130,7 +130,7 @@ Communication tools and platforms ### Wikis - [DokuWiki](https://dokuwiki.org) - - [ComboStrap](https://combostrap.com/mermaid) + - [ComboStrap](https://combostrap.com/utility/create-diagram-with-mermaid-vh3ab9yj) - [Mermaid Plugin](https://www.dokuwiki.org/plugin:mermaid) - [Foswiki](https://foswiki.org) - [Mermaid Plugin](https://foswiki.org/Extensions/MermaidPlugin) From 46b7ee87dd2d681fc830237376845cb14ca9a53a Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 23 Aug 2024 09:42:02 +0200 Subject: [PATCH 080/124] Fix for turned arrow heads and missing edge sections --- .../rendering-elements/edges.js | 29 +++++++++---------- .../rendering-elements/shapes/cylinder.ts | 2 +- .../shapes/handDrawnShapeStyles.ts | 2 +- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/edges.js b/packages/mermaid/src/rendering-util/rendering-elements/edges.js index 0502da097..087fcf0be 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/edges.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/edges.js @@ -429,22 +429,19 @@ export const insertEdge = function (elem, edge, clusterDb, diagramType, startNod const tail = startNode; var head = endNode; - if (head.intersect && tail.intersect && points.length > 2) { - const initialStartPoint = Object.assign({}, points[0]); - const newEnd = head.intersect(points[points.length - 2]); - - const newStart = tail.intersect(points[1]); - if (newStart.x && newStart.y) { - points.unshift(newStart); - } else { - points.unshift(initialStartPoint); - } - if (newEnd.x && newEnd.y) { - const lastPoint = points[points.length - 1]; - if (lastPoint.x !== newEnd.x && lastPoint.y !== newEnd.y) { - points.push(newEnd); - } - } + if (head.intersect && tail.intersect) { + points = points.slice(1, edge.points.length - 1); + points.unshift(tail.intersect(points[0])); + log.debug( + 'Last point APA12', + edge.start, + '-->', + edge.end, + points[points.length - 1], + head, + head.intersect(points[points.length - 1]) + ); + points.push(head.intersect(points[points.length - 1])); } if (edge.toCluster) { log.info('to cluster abc88', clusterDb.get(edge.toCluster)); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts index 9d7e5445b..f85db0f05 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts @@ -103,7 +103,7 @@ export const cylinder = async (parent: SVGAElement, node: Node) => { Math.abs(pos.y - (node.y ?? 0)) > (node.height ?? 0) / 2 - ry)) ) { let y = ry * ry * (1 - (x * x) / (rx * rx)); - if (y != 0) { + if (y > 0) { y = Math.sqrt(y); } y = ry - y; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts index 3840244e9..a5c963e7c 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts @@ -65,7 +65,7 @@ export const styles2String = (node: Node) => { labelStyles.push(style.join(':') + ' !important'); } else { nodeStyles.push(style.join(':') + ' !important'); - if (key === 'stroke' || key === 'stroke-width') { + if (key.includes('stroke')) { borderStyles.push(style.join(':') + ' !important'); } if (key === 'fill') { From 48fd76e076603dc6b96acde33f7e6c61c3a68d08 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 23 Aug 2024 10:35:14 +0200 Subject: [PATCH 081/124] Fix for selecting the correct diagramPadding for flowcharts --- .../mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts | 2 +- packages/mermaid/src/rendering-util/setupViewPortForSVG.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts b/packages/mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts index 6289952ea..6cc15258d 100644 --- a/packages/mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts +++ b/packages/mermaid/src/diagrams/flowchart/flowRenderer-v3-unified.ts @@ -54,7 +54,7 @@ export const draw = async function (text: string, id: string, _version: string, data4Layout.diagramId = id; log.debug('REF1:', data4Layout); await render(data4Layout, svg); - const padding = data4Layout.config.flowchart?.padding ?? 8; + const padding = data4Layout.config.flowchart?.diagramPadding ?? 8; utils.insertTitle( svg, 'flowchartTitleText', diff --git a/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts b/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts index 1fa2de1fd..e21f3304b 100644 --- a/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts +++ b/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts @@ -22,7 +22,7 @@ export const setupViewPortForSVG = ( svg.attr('viewBox', viewBox); // Log the viewBox configuration for debugging - log.debug(`viewBox configured: ${viewBox}`); + log.debug(`viewBox configured: ${viewBox} with padding: ${padding}`); }; const calculateDimensionsWithPadding = (svg: SVG, padding: number) => { From efba4c18d1c1874a6d72a3e3981f32636db931c2 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 23 Aug 2024 12:08:09 +0200 Subject: [PATCH 082/124] Updating syntax reference with code showing how to select layout and look. --- docs/intro/syntax-reference.md | 100 +++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/docs/intro/syntax-reference.md b/docs/intro/syntax-reference.md index 00330f21d..3c7104d7f 100644 --- a/docs/intro/syntax-reference.md +++ b/docs/intro/syntax-reference.md @@ -83,3 +83,103 @@ Allows for the limited reconfiguration of a diagram just before it is rendered. ### [Theme Manipulation](../config/theming.md) An application of using Directives to change [Themes](../config/theming.md). `Theme` is a value within Mermaid's configuration that dictates the color scheme for diagrams. + +### Layout and look + +We've restructured how Mermaid renders diagrams, enabling new features like selecting layout and look. **Currently, this is supported for flowcharts and state diagrams**, with plans to extend support to all diagram types. + +### Selecting Diagram Looks + +Mermaid offers a variety of styles or “looks” for your diagrams, allowing you to tailor the visual appearance to match your specific needs or preferences. Whether you prefer a hand-drawn or classic style, you can easily customize your diagrams. + +**Available Looks:** + + • Hand-Drawn Look: For a more personal, creative touch, the hand-drawn look brings a sketch-like quality to your diagrams. This style is perfect for informal settings or when you want to add a bit of personality to your diagrams. + • Classic Look: If you prefer the traditional Mermaid style, the classic look maintains the original appearance that many users are familiar with. It’s great for consistency across projects or when you want to keep the familiar aesthetic. + +**How to Select a Look:** + +You can select a look by adding the look parameter in the metadata section of your Mermaid diagram code. Here’s an example: +```mermaid +--- +config: + look: handDrawn + theme: neutral +--- +flowchart LR + A[Start] --> B{Decision} + B -->|Yes| C[Continue] + B -->|No| D[Stop] +``` + +#### Selecting Layout Algorithms + +In addition to customizing the look of your diagrams, Mermaid Chart now allows you to choose different layout algorithms to better organize and present your diagrams, especially when dealing with more complex structures. The layout algorithm dictates how nodes and edges are arranged on the page. + +#### Supported Layout Algorithms: + + • Dagre (default): This is the classic layout algorithm that has been used in Mermaid for a long time. It provides a good balance of simplicity and visual clarity, making it ideal for most diagrams. + • ELK: For those who need more sophisticated layout capabilities, especially when working with large or intricate diagrams, the ELK (Eclipse Layout Kernel) layout offers advanced options. It provides a more optimized arrangement, potentially reducing overlapping and improving readability. This is not included out the box but needs to be added when integrating mermaid for sites/appliocations that want to have elk support. + +#### How to Select a Layout Algorithm: + +You can specify the layout algorithm directly in the metadata section of your Mermaid diagram code. Here’s an example: +```mermaid +--- +config: + layout: elk + look: handdrawn + theme: forest +--- +flowchart TB + A[Start] --> B{Decision} + B -->|Yes| C[Continue] + B -->|No| D[Stop] +``` +In this example, the `layout: elk` line configures the diagram to use the ELK layout algorithm, along with the handdrawn look and forest theme. + +#### Customizing ELK Layout: + +When using the ELK layout, you can further refine the diagram’s configuration, such as how nodes are placed and whether parallel edges should be combined: + +- To combine parallel edges, use mergeEdges: true | false. +- To configure node placement, use nodePlacementStrategy with the following options: + o SIMPLE + o NETWORK_SIMPLEX + o LINEAR_SEGMENTS + o BRANDES_KOEPF (default) + + +**Example configuration:** + +```mermaid +--- +config: + layout: elk + elk: + mergeEdges: true + nodePlacementStrategy: LINEAR_SEGMENTS +--- +flowchart LR + A[Start] --> B{Choose Path} + B -->|Option 1| C[Path 1] + B -->|Option 2| D[Path 2] + +#### Using Dagre Layout with Classic Look: +``` +--- +config: + layout: dagre + look: classic + theme: default +--- +flowchart LR + A[Start] --> B{Choose Path} + B -->|Option 1| C[Path 1] + B -->|Option 2| D[Path 2] +``` + +These options give you the flexibility to create diagrams that not only look great but are also arranged to best suit your data’s structure and flow. + +When integrating Mermaid, you can include look and layout configuration with the initialize call. This is also where you add the loading of elk. + From dd570307320fdf9c20686a0f45100c6cd67401c8 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 10:13:11 +0000 Subject: [PATCH 083/124] [autofix.ci] apply automated fixes --- docs/intro/syntax-reference.md | 100 --------------------------------- 1 file changed, 100 deletions(-) diff --git a/docs/intro/syntax-reference.md b/docs/intro/syntax-reference.md index 3c7104d7f..00330f21d 100644 --- a/docs/intro/syntax-reference.md +++ b/docs/intro/syntax-reference.md @@ -83,103 +83,3 @@ Allows for the limited reconfiguration of a diagram just before it is rendered. ### [Theme Manipulation](../config/theming.md) An application of using Directives to change [Themes](../config/theming.md). `Theme` is a value within Mermaid's configuration that dictates the color scheme for diagrams. - -### Layout and look - -We've restructured how Mermaid renders diagrams, enabling new features like selecting layout and look. **Currently, this is supported for flowcharts and state diagrams**, with plans to extend support to all diagram types. - -### Selecting Diagram Looks - -Mermaid offers a variety of styles or “looks” for your diagrams, allowing you to tailor the visual appearance to match your specific needs or preferences. Whether you prefer a hand-drawn or classic style, you can easily customize your diagrams. - -**Available Looks:** - - • Hand-Drawn Look: For a more personal, creative touch, the hand-drawn look brings a sketch-like quality to your diagrams. This style is perfect for informal settings or when you want to add a bit of personality to your diagrams. - • Classic Look: If you prefer the traditional Mermaid style, the classic look maintains the original appearance that many users are familiar with. It’s great for consistency across projects or when you want to keep the familiar aesthetic. - -**How to Select a Look:** - -You can select a look by adding the look parameter in the metadata section of your Mermaid diagram code. Here’s an example: -```mermaid ---- -config: - look: handDrawn - theme: neutral ---- -flowchart LR - A[Start] --> B{Decision} - B -->|Yes| C[Continue] - B -->|No| D[Stop] -``` - -#### Selecting Layout Algorithms - -In addition to customizing the look of your diagrams, Mermaid Chart now allows you to choose different layout algorithms to better organize and present your diagrams, especially when dealing with more complex structures. The layout algorithm dictates how nodes and edges are arranged on the page. - -#### Supported Layout Algorithms: - - • Dagre (default): This is the classic layout algorithm that has been used in Mermaid for a long time. It provides a good balance of simplicity and visual clarity, making it ideal for most diagrams. - • ELK: For those who need more sophisticated layout capabilities, especially when working with large or intricate diagrams, the ELK (Eclipse Layout Kernel) layout offers advanced options. It provides a more optimized arrangement, potentially reducing overlapping and improving readability. This is not included out the box but needs to be added when integrating mermaid for sites/appliocations that want to have elk support. - -#### How to Select a Layout Algorithm: - -You can specify the layout algorithm directly in the metadata section of your Mermaid diagram code. Here’s an example: -```mermaid ---- -config: - layout: elk - look: handdrawn - theme: forest ---- -flowchart TB - A[Start] --> B{Decision} - B -->|Yes| C[Continue] - B -->|No| D[Stop] -``` -In this example, the `layout: elk` line configures the diagram to use the ELK layout algorithm, along with the handdrawn look and forest theme. - -#### Customizing ELK Layout: - -When using the ELK layout, you can further refine the diagram’s configuration, such as how nodes are placed and whether parallel edges should be combined: - -- To combine parallel edges, use mergeEdges: true | false. -- To configure node placement, use nodePlacementStrategy with the following options: - o SIMPLE - o NETWORK_SIMPLEX - o LINEAR_SEGMENTS - o BRANDES_KOEPF (default) - - -**Example configuration:** - -```mermaid ---- -config: - layout: elk - elk: - mergeEdges: true - nodePlacementStrategy: LINEAR_SEGMENTS ---- -flowchart LR - A[Start] --> B{Choose Path} - B -->|Option 1| C[Path 1] - B -->|Option 2| D[Path 2] - -#### Using Dagre Layout with Classic Look: -``` ---- -config: - layout: dagre - look: classic - theme: default ---- -flowchart LR - A[Start] --> B{Choose Path} - B -->|Option 1| C[Path 1] - B -->|Option 2| D[Path 2] -``` - -These options give you the flexibility to create diagrams that not only look great but are also arranged to best suit your data’s structure and flow. - -When integrating Mermaid, you can include look and layout configuration with the initialize call. This is also where you add the loading of elk. - From 21c636c4c61003a22db80dfd63caa4c8b5d02f48 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 23 Aug 2024 16:23:45 +0530 Subject: [PATCH 084/124] Run release drafter in release branch --- .github/workflows/release-draft.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release-draft.yml b/.github/workflows/release-draft.yml index 657bc767a..849e69b52 100644 --- a/.github/workflows/release-draft.yml +++ b/.github/workflows/release-draft.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - release/** permissions: contents: read From 2cfdd1620a8ceef37c0b738569dfb8bcc0005547 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 23 Aug 2024 14:07:47 +0200 Subject: [PATCH 085/124] Mermaid version v11.0.0 --- packages/mermaid/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index f3a2d8299..ae555a682 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "11.0.0-alpha.7", + "version": "11.0.0", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "type": "module", "module": "./dist/mermaid.core.mjs", From 5deaef456e74d796866431c26f69360e4e74dbff Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 23 Aug 2024 19:11:04 +0530 Subject: [PATCH 086/124] chore: add changeset --- .changeset/dirty-mails-watch.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/dirty-mails-watch.md diff --git a/.changeset/dirty-mails-watch.md b/.changeset/dirty-mails-watch.md new file mode 100644 index 000000000..8fd5ec941 --- /dev/null +++ b/.changeset/dirty-mails-watch.md @@ -0,0 +1,6 @@ +--- +'@mermaid-js/parser': minor +'mermaid': patch +--- + +chore: Migrate git graph to langium, use typescript for internals From 50134849246141ec400e33e08c12c10539b84de9 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 23 Aug 2024 19:21:40 +0530 Subject: [PATCH 087/124] Release parser, v0.1.0, test changeset --- .changeset/perfect-teachers-whisper.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/perfect-teachers-whisper.md diff --git a/.changeset/perfect-teachers-whisper.md b/.changeset/perfect-teachers-whisper.md new file mode 100644 index 000000000..774c177eb --- /dev/null +++ b/.changeset/perfect-teachers-whisper.md @@ -0,0 +1,6 @@ +--- +'@mermaid-js/parser': minor +'mermaid': patch +--- + +Release parser, test changesets From eb3ed2a5e4762e34545dd7c776a3966225c9d717 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 23 Aug 2024 13:56:03 +0000 Subject: [PATCH 088/124] Version Packages --- .changeset/perfect-teachers-whisper.md | 6 ------ packages/mermaid/CHANGELOG.md | 10 ++++++++++ packages/mermaid/package.json | 2 +- packages/parser/CHANGELOG.md | 7 +++++++ packages/parser/package.json | 2 +- 5 files changed, 19 insertions(+), 8 deletions(-) delete mode 100644 .changeset/perfect-teachers-whisper.md create mode 100644 packages/mermaid/CHANGELOG.md create mode 100644 packages/parser/CHANGELOG.md diff --git a/.changeset/perfect-teachers-whisper.md b/.changeset/perfect-teachers-whisper.md deleted file mode 100644 index 774c177eb..000000000 --- a/.changeset/perfect-teachers-whisper.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@mermaid-js/parser': minor -'mermaid': patch ---- - -Release parser, test changesets diff --git a/packages/mermaid/CHANGELOG.md b/packages/mermaid/CHANGELOG.md new file mode 100644 index 000000000..2604152e7 --- /dev/null +++ b/packages/mermaid/CHANGELOG.md @@ -0,0 +1,10 @@ +# mermaid + +## 11.0.1 + +### Patch Changes + +- [#5744](https://github.com/mermaid-js/mermaid/pull/5744) [`5013484`](https://github.com/mermaid-js/mermaid/commit/50134849246141ec400e33e08c12c10539b84de9) Thanks [@sidharthv96](https://github.com/sidharthv96)! - Release parser, test changesets + +- Updated dependencies [[`5013484`](https://github.com/mermaid-js/mermaid/commit/50134849246141ec400e33e08c12c10539b84de9)]: + - @mermaid-js/parser@0.1.0 diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index c18190982..9994bb3a8 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "11.0.0", + "version": "11.0.1", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "type": "module", "module": "./dist/mermaid.core.mjs", diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md new file mode 100644 index 000000000..acbff369a --- /dev/null +++ b/packages/parser/CHANGELOG.md @@ -0,0 +1,7 @@ +# @mermaid-js/parser + +## 0.1.0 + +### Minor Changes + +- [#5744](https://github.com/mermaid-js/mermaid/pull/5744) [`5013484`](https://github.com/mermaid-js/mermaid/commit/50134849246141ec400e33e08c12c10539b84de9) Thanks [@sidharthv96](https://github.com/sidharthv96)! - Release parser, test changesets diff --git a/packages/parser/package.json b/packages/parser/package.json index da875ce45..a44174696 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@mermaid-js/parser", - "version": "0.1.0-rc.2", + "version": "0.1.0", "description": "MermaidJS parser", "author": "Yokozuna59", "contributors": [ From 83926c9707b09c34e300888186250191ee8ae30a Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 23 Aug 2024 20:18:23 +0530 Subject: [PATCH 089/124] Test changeset (#5746) --- .changeset/old-weeks-arrive.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/old-weeks-arrive.md diff --git a/.changeset/old-weeks-arrive.md b/.changeset/old-weeks-arrive.md new file mode 100644 index 000000000..5ef860f56 --- /dev/null +++ b/.changeset/old-weeks-arrive.md @@ -0,0 +1,5 @@ +--- +'@mermaid-js/parser': patch +--- + +test changeset From 5bbf3678c55da595523e8aeddd172e73664a90ca Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:22:20 +0530 Subject: [PATCH 090/124] Version Packages (#5748) Co-authored-by: github-actions[bot] --- .changeset/old-weeks-arrive.md | 5 ----- packages/mermaid/CHANGELOG.md | 7 +++++++ packages/mermaid/package.json | 2 +- packages/parser/CHANGELOG.md | 6 ++++++ packages/parser/package.json | 2 +- 5 files changed, 15 insertions(+), 7 deletions(-) delete mode 100644 .changeset/old-weeks-arrive.md diff --git a/.changeset/old-weeks-arrive.md b/.changeset/old-weeks-arrive.md deleted file mode 100644 index 5ef860f56..000000000 --- a/.changeset/old-weeks-arrive.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@mermaid-js/parser': patch ---- - -test changeset diff --git a/packages/mermaid/CHANGELOG.md b/packages/mermaid/CHANGELOG.md index 2604152e7..fe7360f81 100644 --- a/packages/mermaid/CHANGELOG.md +++ b/packages/mermaid/CHANGELOG.md @@ -1,5 +1,12 @@ # mermaid +## 11.0.2 + +### Patch Changes + +- Updated dependencies [[`83926c9`](https://github.com/mermaid-js/mermaid/commit/83926c9707b09c34e300888186250191ee8ae30a)]: + - @mermaid-js/parser@0.1.1 + ## 11.0.1 ### Patch Changes diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index 9994bb3a8..8956eb1e5 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "11.0.1", + "version": "11.0.2", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "type": "module", "module": "./dist/mermaid.core.mjs", diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index acbff369a..f6b145b5a 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -1,5 +1,11 @@ # @mermaid-js/parser +## 0.1.1 + +### Patch Changes + +- [#5746](https://github.com/mermaid-js/mermaid/pull/5746) [`83926c9`](https://github.com/mermaid-js/mermaid/commit/83926c9707b09c34e300888186250191ee8ae30a) Thanks [@sidharthv96](https://github.com/sidharthv96)! - test changeset + ## 0.1.0 ### Minor Changes diff --git a/packages/parser/package.json b/packages/parser/package.json index a44174696..157d4dd05 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@mermaid-js/parser", - "version": "0.1.0", + "version": "0.1.1", "description": "MermaidJS parser", "author": "Yokozuna59", "contributors": [ From f04fa4d5650042b91245f4fa588e2f69969a56ab Mon Sep 17 00:00:00 2001 From: Steph <35910788+huynhicode@users.noreply.github.com> Date: Fri, 23 Aug 2024 07:58:53 -0700 Subject: [PATCH 091/124] add latest blog posts --- .../setup/interfaces/mermaid.RenderOptions.md | 19 ------------------- docs/news/blog.md | 18 ++++++++++++++++++ packages/mermaid/src/docs/news/blog.md | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 19 deletions(-) delete mode 100644 docs/config/setup/interfaces/mermaid.RenderOptions.md diff --git a/docs/config/setup/interfaces/mermaid.RenderOptions.md b/docs/config/setup/interfaces/mermaid.RenderOptions.md deleted file mode 100644 index 9319cb3b1..000000000 --- a/docs/config/setup/interfaces/mermaid.RenderOptions.md +++ /dev/null @@ -1,19 +0,0 @@ -> **Warning** -> -> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. -> -> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/interfaces/mermaid.RenderOptions.md](../../../../packages/mermaid/src/docs/config/setup/interfaces/mermaid.RenderOptions.md). - -# Interface: RenderOptions - -[mermaid](../modules/mermaid.md).RenderOptions - -## Properties - -### algorithm - -• `Optional` **algorithm**: `string` - -#### Defined in - -[packages/mermaid/src/rendering-util/render.ts:8](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L8) diff --git a/docs/news/blog.md b/docs/news/blog.md index 4c7c982c3..372247b86 100644 --- a/docs/news/blog.md +++ b/docs/news/blog.md @@ -6,6 +6,24 @@ # Blog +## [Mermaid v11 is out!](https://www.mermaidchart.com/blog/posts/mermaid-v11/) + +23 August 2024 · 2 mins + +Mermaid v11 introduces advanced layout options, new diagram types, and enhanced customization features, thanks to the incredible contributions from our community. + +## [Mermaid Innovation - Introducing New Looks for Mermaid Diagrams](https://www.mermaidchart.com/blog/posts/mermaid-innovation-introducing-new-looks-for-mermaid-diagrams/) + +6 August 2024 ·3 mins + +Discover the fresh new and unique Neo and Hand-Drawn looks for Mermaid Diagrams, while still offering the classic look you love. + +## [The Mermaid Chart Plugin for Jira: A How-To User Guide](https://www.mermaidchart.com/blog/posts/the-mermaid-chart-plugin-for-jira-a-how-to-user-guide/) + +31 July 2024 · 5 mins + +The Mermaid Chart plugin for Jira has arrived! + ## [Mermaid AI Is Here to Change the Game For Diagram Creation](https://www.mermaidchart.com/blog/posts/mermaid-ai-is-here-to-change-the-game-for-diagram-creation/) 22 July 2024 · 5 mins diff --git a/packages/mermaid/src/docs/news/blog.md b/packages/mermaid/src/docs/news/blog.md index 10f7672fd..f7f28bf4b 100644 --- a/packages/mermaid/src/docs/news/blog.md +++ b/packages/mermaid/src/docs/news/blog.md @@ -1,5 +1,23 @@ # Blog +## [Mermaid v11 is out!](https://www.mermaidchart.com/blog/posts/mermaid-v11/) + +23 August 2024 · 2 mins + +Mermaid v11 introduces advanced layout options, new diagram types, and enhanced customization features, thanks to the incredible contributions from our community. + +## [Mermaid Innovation - Introducing New Looks for Mermaid Diagrams](https://www.mermaidchart.com/blog/posts/mermaid-innovation-introducing-new-looks-for-mermaid-diagrams/) + +6 August 2024 ·3 mins + +Discover the fresh new and unique Neo and Hand-Drawn looks for Mermaid Diagrams, while still offering the classic look you love. + +## [The Mermaid Chart Plugin for Jira: A How-To User Guide](https://www.mermaidchart.com/blog/posts/the-mermaid-chart-plugin-for-jira-a-how-to-user-guide/) + +31 July 2024 · 5 mins + +The Mermaid Chart plugin for Jira has arrived! + ## [Mermaid AI Is Here to Change the Game For Diagram Creation](https://www.mermaidchart.com/blog/posts/mermaid-ai-is-here-to-change-the-game-for-diagram-creation/) 22 July 2024 · 5 mins From 2efe741924ce6d3737da4885405060dda34fb0cd Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 23 Aug 2024 20:29:33 +0530 Subject: [PATCH 092/124] Revert mermaid version --- packages/mermaid/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index 8956eb1e5..c18190982 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "11.0.2", + "version": "11.0.0", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "type": "module", "module": "./dist/mermaid.core.mjs", From bf05d8781edacb580fdb053da167e968b7570117 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 23 Aug 2024 20:30:02 +0530 Subject: [PATCH 093/124] Bump mermaid minor --- .changeset/clever-ties-return.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/clever-ties-return.md diff --git a/.changeset/clever-ties-return.md b/.changeset/clever-ties-return.md new file mode 100644 index 000000000..ee2553120 --- /dev/null +++ b/.changeset/clever-ties-return.md @@ -0,0 +1,5 @@ +--- +'mermaid': patch +--- + +test changeset From 4d10e3f2586fb8b08b72d93a1036a17d53153997 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 20:33:20 +0530 Subject: [PATCH 094/124] Version Packages (#5749) Co-authored-by: github-actions[bot] --- .changeset/clever-ties-return.md | 5 ----- packages/mermaid/CHANGELOG.md | 6 ++++++ packages/mermaid/package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .changeset/clever-ties-return.md diff --git a/.changeset/clever-ties-return.md b/.changeset/clever-ties-return.md deleted file mode 100644 index ee2553120..000000000 --- a/.changeset/clever-ties-return.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'mermaid': patch ---- - -test changeset diff --git a/packages/mermaid/CHANGELOG.md b/packages/mermaid/CHANGELOG.md index fe7360f81..ae05b0637 100644 --- a/packages/mermaid/CHANGELOG.md +++ b/packages/mermaid/CHANGELOG.md @@ -1,5 +1,11 @@ # mermaid +## 11.0.1 + +### Patch Changes + +- [#2](https://github.com/calvinvette/mermaid/pull/2) [`bf05d87`](https://github.com/mermaid-js/mermaid/commit/bf05d8781edacb580fdb053da167e968b7570117) Thanks [@calvinvette](https://github.com/calvinvette)! - test changeset + ## 11.0.2 ### Patch Changes diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index c18190982..9994bb3a8 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "11.0.0", + "version": "11.0.1", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "type": "module", "module": "./dist/mermaid.core.mjs", From e391966de888d28c6be1e43c69bc4334bfccd9f4 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Fri, 23 Aug 2024 15:08:07 +0000 Subject: [PATCH 095/124] [autofix.ci] apply automated fixes --- .../setup/interfaces/mermaid.RenderOptions.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 docs/config/setup/interfaces/mermaid.RenderOptions.md diff --git a/docs/config/setup/interfaces/mermaid.RenderOptions.md b/docs/config/setup/interfaces/mermaid.RenderOptions.md new file mode 100644 index 000000000..9319cb3b1 --- /dev/null +++ b/docs/config/setup/interfaces/mermaid.RenderOptions.md @@ -0,0 +1,19 @@ +> **Warning** +> +> ## THIS IS AN AUTOGENERATED FILE. DO NOT EDIT. +> +> ## Please edit the corresponding file in [/packages/mermaid/src/docs/config/setup/interfaces/mermaid.RenderOptions.md](../../../../packages/mermaid/src/docs/config/setup/interfaces/mermaid.RenderOptions.md). + +# Interface: RenderOptions + +[mermaid](../modules/mermaid.md).RenderOptions + +## Properties + +### algorithm + +• `Optional` **algorithm**: `string` + +#### Defined in + +[packages/mermaid/src/rendering-util/render.ts:8](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/render.ts#L8) From d559fcc90bb765f90975f0d402dc24dcd195e251 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 23 Aug 2024 17:35:44 +0200 Subject: [PATCH 096/124] Updating syntax reference with code showing how to select layout and look. --- docs/intro/syntax-reference.md | 153 ++++++++++++++++++ .../src/docs/intro/syntax-reference.md | 108 +++++++++++++ 2 files changed, 261 insertions(+) diff --git a/docs/intro/syntax-reference.md b/docs/intro/syntax-reference.md index 00330f21d..2c204ba12 100644 --- a/docs/intro/syntax-reference.md +++ b/docs/intro/syntax-reference.md @@ -83,3 +83,156 @@ Allows for the limited reconfiguration of a diagram just before it is rendered. ### [Theme Manipulation](../config/theming.md) An application of using Directives to change [Themes](../config/theming.md). `Theme` is a value within Mermaid's configuration that dictates the color scheme for diagrams. + +### Layout and look + +We've restructured how Mermaid renders diagrams, enabling new features like selecting layout and look. **Currently, this is supported for flowcharts and state diagrams**, with plans to extend support to all diagram types. + +### Selecting Diagram Looks + +Mermaid offers a variety of styles or “looks” for your diagrams, allowing you to tailor the visual appearance to match your specific needs or preferences. Whether you prefer a hand-drawn or classic style, you can easily customize your diagrams. + +**Available Looks:** + +``` +• Hand-Drawn Look: For a more personal, creative touch, the hand-drawn look brings a sketch-like quality to your diagrams. This style is perfect for informal settings or when you want to add a bit of personality to your diagrams. +• Classic Look: If you prefer the traditional Mermaid style, the classic look maintains the original appearance that many users are familiar with. It’s great for consistency across projects or when you want to keep the familiar aesthetic. +``` + +**How to Select a Look:** + +You can select a look by adding the look parameter in the metadata section of your Mermaid diagram code. Here’s an example: + +```mermaid-example +--- +config: + look: handDrawn + theme: neutral +--- +flowchart LR + A[Start] --> B{Decision} + B -->|Yes| C[Continue] + B -->|No| D[Stop] +``` + +```mermaid +--- +config: + look: handDrawn + theme: neutral +--- +flowchart LR + A[Start] --> B{Decision} + B -->|Yes| C[Continue] + B -->|No| D[Stop] +``` + +#### Selecting Layout Algorithms + +In addition to customizing the look of your diagrams, Mermaid Chart now allows you to choose different layout algorithms to better organize and present your diagrams, especially when dealing with more complex structures. The layout algorithm dictates how nodes and edges are arranged on the page. + +#### Supported Layout Algorithms: + +``` +• Dagre (default): This is the classic layout algorithm that has been used in Mermaid for a long time. It provides a good balance of simplicity and visual clarity, making it ideal for most diagrams. +• ELK: For those who need more sophisticated layout capabilities, especially when working with large or intricate diagrams, the ELK (Eclipse Layout Kernel) layout offers advanced options. It provides a more optimized arrangement, potentially reducing overlapping and improving readability. This is not included out the box but needs to be added when integrating mermaid for sites/applications that want to have elk support. +``` + +#### How to Select a Layout Algorithm: + +You can specify the layout algorithm directly in the metadata section of your Mermaid diagram code. Here’s an example: + +```mermaid-example +--- +config: + layout: elk + look: handdrawn + theme: forest +--- +flowchart TB + A[Start] --> B{Decision} + B -->|Yes| C[Continue] + B -->|No| D[Stop] +``` + +```mermaid +--- +config: + layout: elk + look: handdrawn + theme: forest +--- +flowchart TB + A[Start] --> B{Decision} + B -->|Yes| C[Continue] + B -->|No| D[Stop] +``` + +In this example, the `layout: elk` line configures the diagram to use the ELK layout algorithm, along with the handdrawn look and forest theme. + +#### Customizing ELK Layout: + +When using the ELK layout, you can further refine the diagram’s configuration, such as how nodes are placed and whether parallel edges should be combined: + +- To combine parallel edges, use mergeEdges: true | false. +- To configure node placement, use nodePlacementStrategy with the following options: + o SIMPLE + o NETWORK_SIMPLEX + o LINEAR_SEGMENTS + o BRANDES_KOEPF (default) + +**Example configuration:** + +```mermaid-example +--- +config: + layout: elk + elk: + mergeEdges: true + nodePlacementStrategy: LINEAR_SEGMENTS +--- +flowchart LR + A[Start] --> B{Choose Path} + B -->|Option 1| C[Path 1] + B -->|Option 2| D[Path 2] + +#### Using Dagre Layout with Classic Look: +``` + +```mermaid +--- +config: + layout: elk + elk: + mergeEdges: true + nodePlacementStrategy: LINEAR_SEGMENTS +--- +flowchart LR + A[Start] --> B{Choose Path} + B -->|Option 1| C[Path 1] + B -->|Option 2| D[Path 2] + +#### Using Dagre Layout with Classic Look: +``` + +--- + +config: +layout: dagre +look: classic +theme: default + +--- + +flowchart LR +A\[Start] --> B{Choose Path} +B -->|Option 1| C\[Path 1] +B -->|Option 2| D\[Path 2] + +``` + +These options give you the flexibility to create diagrams that not only look great but are also arranged to best suit your data’s structure and flow. + +When integrating Mermaid, you can include look and layout configuration with the initialize call. This is also where you add the loading of elk. + +``` diff --git a/packages/mermaid/src/docs/intro/syntax-reference.md b/packages/mermaid/src/docs/intro/syntax-reference.md index d4ee1067f..7f36413b2 100644 --- a/packages/mermaid/src/docs/intro/syntax-reference.md +++ b/packages/mermaid/src/docs/intro/syntax-reference.md @@ -65,3 +65,111 @@ Allows for the limited reconfiguration of a diagram just before it is rendered. ### [Theme Manipulation](../config/theming.md) An application of using Directives to change [Themes](../config/theming.md). `Theme` is a value within Mermaid's configuration that dictates the color scheme for diagrams. + +### Layout and look + +We've restructured how Mermaid renders diagrams, enabling new features like selecting layout and look. **Currently, this is supported for flowcharts and state diagrams**, with plans to extend support to all diagram types. + +### Selecting Diagram Looks + +Mermaid offers a variety of styles or “looks” for your diagrams, allowing you to tailor the visual appearance to match your specific needs or preferences. Whether you prefer a hand-drawn or classic style, you can easily customize your diagrams. + +**Available Looks:** + + • Hand-Drawn Look: For a more personal, creative touch, the hand-drawn look brings a sketch-like quality to your diagrams. This style is perfect for informal settings or when you want to add a bit of personality to your diagrams. + • Classic Look: If you prefer the traditional Mermaid style, the classic look maintains the original appearance that many users are familiar with. It’s great for consistency across projects or when you want to keep the familiar aesthetic. + +**How to Select a Look:** + +You can select a look by adding the look parameter in the metadata section of your Mermaid diagram code. Here’s an example: + +```mermaid +--- +config: + look: handDrawn + theme: neutral +--- +flowchart LR + A[Start] --> B{Decision} + B -->|Yes| C[Continue] + B -->|No| D[Stop] +``` + +#### Selecting Layout Algorithms + +In addition to customizing the look of your diagrams, Mermaid Chart now allows you to choose different layout algorithms to better organize and present your diagrams, especially when dealing with more complex structures. The layout algorithm dictates how nodes and edges are arranged on the page. + +#### Supported Layout Algorithms: + + • Dagre (default): This is the classic layout algorithm that has been used in Mermaid for a long time. It provides a good balance of simplicity and visual clarity, making it ideal for most diagrams. + • ELK: For those who need more sophisticated layout capabilities, especially when working with large or intricate diagrams, the ELK (Eclipse Layout Kernel) layout offers advanced options. It provides a more optimized arrangement, potentially reducing overlapping and improving readability. This is not included out the box but needs to be added when integrating mermaid for sites/applications that want to have elk support. + +#### How to Select a Layout Algorithm: + +You can specify the layout algorithm directly in the metadata section of your Mermaid diagram code. Here’s an example: + +```mermaid +--- +config: + layout: elk + look: handdrawn + theme: forest +--- +flowchart TB + A[Start] --> B{Decision} + B -->|Yes| C[Continue] + B -->|No| D[Stop] +``` + +In this example, the `layout: elk` line configures the diagram to use the ELK layout algorithm, along with the handdrawn look and forest theme. + +#### Customizing ELK Layout: + +When using the ELK layout, you can further refine the diagram’s configuration, such as how nodes are placed and whether parallel edges should be combined: + +- To combine parallel edges, use mergeEdges: true | false. +- To configure node placement, use nodePlacementStrategy with the following options: + o SIMPLE + o NETWORK_SIMPLEX + o LINEAR_SEGMENTS + o BRANDES_KOEPF (default) + +**Example configuration:** + +```mermaid +--- +config: + layout: elk + elk: + mergeEdges: true + nodePlacementStrategy: LINEAR_SEGMENTS +--- +flowchart LR + A[Start] --> B{Choose Path} + B -->|Option 1| C[Path 1] + B -->|Option 2| D[Path 2] + +#### Using Dagre Layout with Classic Look: +``` + +--- + +config: +layout: dagre +look: classic +theme: default + +--- + +flowchart LR +A[Start] --> B{Choose Path} +B -->|Option 1| C[Path 1] +B -->|Option 2| D[Path 2] + +``` + +These options give you the flexibility to create diagrams that not only look great but are also arranged to best suit your data’s structure and flow. + +When integrating Mermaid, you can include look and layout configuration with the initialize call. This is also where you add the loading of elk. + +``` From e499f700ce058524bcdc824ccb1ef7815c560986 Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 23 Aug 2024 17:41:24 +0200 Subject: [PATCH 097/124] Updates to information about the new syntax --- docs/intro/syntax-reference.md | 45 ++++++------------- .../src/docs/intro/syntax-reference.md | 25 +++++------ 2 files changed, 26 insertions(+), 44 deletions(-) diff --git a/docs/intro/syntax-reference.md b/docs/intro/syntax-reference.md index 2c204ba12..006b6f3f7 100644 --- a/docs/intro/syntax-reference.md +++ b/docs/intro/syntax-reference.md @@ -147,7 +147,7 @@ You can specify the layout algorithm directly in the metadata section of your Me config: layout: elk look: handdrawn - theme: forest + theme: dark --- flowchart TB A[Start] --> B{Decision} @@ -160,7 +160,7 @@ flowchart TB config: layout: elk look: handdrawn - theme: forest + theme: dark --- flowchart TB A[Start] --> B{Decision} @@ -176,14 +176,14 @@ When using the ELK layout, you can further refine the diagram’s configuration, - To combine parallel edges, use mergeEdges: true | false. - To configure node placement, use nodePlacementStrategy with the following options: - o SIMPLE - o NETWORK_SIMPLEX - o LINEAR_SEGMENTS - o BRANDES_KOEPF (default) + - SIMPLE + - NETWORK_SIMPLEX + - LINEAR_SEGMENTS + - BRANDES_KOEPF (default) **Example configuration:** -```mermaid-example +``` --- config: layout: elk @@ -199,40 +199,23 @@ flowchart LR #### Using Dagre Layout with Classic Look: ``` -```mermaid ---- -config: - layout: elk - elk: - mergeEdges: true - nodePlacementStrategy: LINEAR_SEGMENTS ---- -flowchart LR - A[Start] --> B{Choose Path} - B -->|Option 1| C[Path 1] - B -->|Option 2| D[Path 2] +Another example: -#### Using Dagre Layout with Classic Look: ``` - --- - config: -layout: dagre -look: classic -theme: default - + layout: dagre + look: classic + theme: default --- flowchart LR -A\[Start] --> B{Choose Path} -B -->|Option 1| C\[Path 1] -B -->|Option 2| D\[Path 2] +A[Start] --> B{Choose Path} +B -->|Option 1| C[Path 1] +B -->|Option 2| D[Path 2] ``` These options give you the flexibility to create diagrams that not only look great but are also arranged to best suit your data’s structure and flow. When integrating Mermaid, you can include look and layout configuration with the initialize call. This is also where you add the loading of elk. - -``` diff --git a/packages/mermaid/src/docs/intro/syntax-reference.md b/packages/mermaid/src/docs/intro/syntax-reference.md index 7f36413b2..1e7cbc4bb 100644 --- a/packages/mermaid/src/docs/intro/syntax-reference.md +++ b/packages/mermaid/src/docs/intro/syntax-reference.md @@ -113,7 +113,7 @@ You can specify the layout algorithm directly in the metadata section of your Me config: layout: elk look: handdrawn - theme: forest + theme: dark --- flowchart TB A[Start] --> B{Decision} @@ -129,14 +129,14 @@ When using the ELK layout, you can further refine the diagram’s configuration, - To combine parallel edges, use mergeEdges: true | false. - To configure node placement, use nodePlacementStrategy with the following options: - o SIMPLE - o NETWORK_SIMPLEX - o LINEAR_SEGMENTS - o BRANDES_KOEPF (default) + - SIMPLE + - NETWORK_SIMPLEX + - LINEAR_SEGMENTS + - BRANDES_KOEPF (default) **Example configuration:** -```mermaid +``` --- config: layout: elk @@ -152,13 +152,14 @@ flowchart LR #### Using Dagre Layout with Classic Look: ``` +Another example: + +``` --- - config: -layout: dagre -look: classic -theme: default - + layout: dagre + look: classic + theme: default --- flowchart LR @@ -171,5 +172,3 @@ B -->|Option 2| D[Path 2] These options give you the flexibility to create diagrams that not only look great but are also arranged to best suit your data’s structure and flow. When integrating Mermaid, you can include look and layout configuration with the initialize call. This is also where you add the loading of elk. - -``` From a4e1479759b64e5a4b27fb2b4e5100be024fd77d Mon Sep 17 00:00:00 2001 From: Knut Sveidqvist Date: Fri, 23 Aug 2024 17:49:52 +0200 Subject: [PATCH 098/124] Correct casing for hand drawn --- docs/intro/syntax-reference.md | 6 +++--- packages/mermaid/src/docs/intro/syntax-reference.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/intro/syntax-reference.md b/docs/intro/syntax-reference.md index 006b6f3f7..f736840e6 100644 --- a/docs/intro/syntax-reference.md +++ b/docs/intro/syntax-reference.md @@ -146,7 +146,7 @@ You can specify the layout algorithm directly in the metadata section of your Me --- config: layout: elk - look: handdrawn + look: handDrawn theme: dark --- flowchart TB @@ -159,7 +159,7 @@ flowchart TB --- config: layout: elk - look: handdrawn + look: handDrawn theme: dark --- flowchart TB @@ -168,7 +168,7 @@ flowchart TB B -->|No| D[Stop] ``` -In this example, the `layout: elk` line configures the diagram to use the ELK layout algorithm, along with the handdrawn look and forest theme. +In this example, the `layout: elk` line configures the diagram to use the ELK layout algorithm, along with the hand drawn look and forest theme. #### Customizing ELK Layout: diff --git a/packages/mermaid/src/docs/intro/syntax-reference.md b/packages/mermaid/src/docs/intro/syntax-reference.md index 1e7cbc4bb..7d7fd5994 100644 --- a/packages/mermaid/src/docs/intro/syntax-reference.md +++ b/packages/mermaid/src/docs/intro/syntax-reference.md @@ -112,7 +112,7 @@ You can specify the layout algorithm directly in the metadata section of your Me --- config: layout: elk - look: handdrawn + look: handDrawn theme: dark --- flowchart TB @@ -121,7 +121,7 @@ flowchart TB B -->|No| D[Stop] ``` -In this example, the `layout: elk` line configures the diagram to use the ELK layout algorithm, along with the handdrawn look and forest theme. +In this example, the `layout: elk` line configures the diagram to use the ELK layout algorithm, along with the hand drawn look and forest theme. #### Customizing ELK Layout: From ca57235e056768e585f97b421b1ffcc86123c710 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 11:51:00 +0530 Subject: [PATCH 099/124] fix: Type export for layout-elk --- packages/mermaid-layout-elk/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/mermaid-layout-elk/package.json b/packages/mermaid-layout-elk/package.json index 78ad309b8..3c5d7a917 100644 --- a/packages/mermaid-layout-elk/package.json +++ b/packages/mermaid-layout-elk/package.json @@ -3,12 +3,12 @@ "version": "0.1.0", "description": "ELK layout engine for mermaid", "module": "dist/mermaid-layout-elk.core.mjs", - "types": "dist/packages/mermaid-layout-elk/src/index.d.ts", + "types": "dist/layout.d.ts", "type": "module", "exports": { ".": { "import": "./dist/mermaid-layout-elk.core.mjs", - "types": "./dist/packages/mermaid-layout-elk/src/index.d.ts" + "types": "./dist/layout.d.ts" }, "./*": "./*" }, From 501a55d8f225901ba345c498dec4298490a0196e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 11:51:33 +0530 Subject: [PATCH 100/124] chore: Add changeset --- .changeset/khaki-news-count.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/khaki-news-count.md diff --git a/.changeset/khaki-news-count.md b/.changeset/khaki-news-count.md new file mode 100644 index 000000000..1fcb629c9 --- /dev/null +++ b/.changeset/khaki-news-count.md @@ -0,0 +1,5 @@ +--- +'@mermaid-js/layout-elk': patch +--- + +fix: Types path From 17c0af1cf6546b94e6a631d40209f35d7b13f902 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 12:18:19 +0530 Subject: [PATCH 101/124] chore: Update flowchart widths --- cypress/integration/rendering/flowchart-v2.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js index c2fd0b011..452cdb5a0 100644 --- a/cypress/integration/rendering/flowchart-v2.spec.js +++ b/cypress/integration/rendering/flowchart-v2.spec.js @@ -99,7 +99,7 @@ describe('Flowchart v2', () => { const style = svg.attr('style'); expect(style).to.match(/^max-width: [\d.]+px;$/); const maxWidthValue = parseFloat(style.match(/[\d.]+/g).join('')); - expect(maxWidthValue).to.be.within(446 * 0.95 - 1, 446 * 1.05); + expect(maxWidthValue).to.be.within(417 * 0.95, 417 * 1.05); }); }); it('8: should render a flowchart when useMaxWidth is false', () => { @@ -118,7 +118,7 @@ describe('Flowchart v2', () => { const width = parseFloat(svg.attr('width')); // use within because the absolute value can be slightly different depending on the environment ±5% // expect(height).to.be.within(446 * 0.95, 446 * 1.05); - expect(width).to.be.within(446 * 0.95 - 1, 446 * 1.05); + expect(width).to.be.within(417 * 0.95, 417 * 1.05); expect(svg).to.not.have.attr('style'); }); }); From dab8f08a9e98b42951e8792899ff7f01c67213d3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 24 Aug 2024 07:03:01 +0000 Subject: [PATCH 102/124] Version Packages --- .changeset/dirty-mails-watch.md | 6 ------ .changeset/khaki-news-count.md | 5 ----- packages/mermaid-layout-elk/CHANGELOG.md | 10 ++++++++++ packages/mermaid-layout-elk/package.json | 2 +- packages/mermaid/CHANGELOG.md | 9 +++++++++ packages/mermaid/package.json | 2 +- packages/parser/CHANGELOG.md | 6 ++++++ packages/parser/package.json | 2 +- 8 files changed, 28 insertions(+), 14 deletions(-) delete mode 100644 .changeset/dirty-mails-watch.md delete mode 100644 .changeset/khaki-news-count.md create mode 100644 packages/mermaid-layout-elk/CHANGELOG.md diff --git a/.changeset/dirty-mails-watch.md b/.changeset/dirty-mails-watch.md deleted file mode 100644 index 8fd5ec941..000000000 --- a/.changeset/dirty-mails-watch.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -'@mermaid-js/parser': minor -'mermaid': patch ---- - -chore: Migrate git graph to langium, use typescript for internals diff --git a/.changeset/khaki-news-count.md b/.changeset/khaki-news-count.md deleted file mode 100644 index 1fcb629c9..000000000 --- a/.changeset/khaki-news-count.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@mermaid-js/layout-elk': patch ---- - -fix: Types path diff --git a/packages/mermaid-layout-elk/CHANGELOG.md b/packages/mermaid-layout-elk/CHANGELOG.md new file mode 100644 index 000000000..2db340af7 --- /dev/null +++ b/packages/mermaid-layout-elk/CHANGELOG.md @@ -0,0 +1,10 @@ +# @mermaid-js/layout-elk + +## 0.1.1 + +### Patch Changes + +- [#5758](https://github.com/mermaid-js/mermaid/pull/5758) [`501a55d`](https://github.com/mermaid-js/mermaid/commit/501a55d8f225901ba345c498dec4298490a0196e) Thanks [@sidharthv96](https://github.com/sidharthv96)! - fix: Types path + +- Updated dependencies [[`5deaef4`](https://github.com/mermaid-js/mermaid/commit/5deaef456e74d796866431c26f69360e4e74dbff)]: + - mermaid@11.0.2 diff --git a/packages/mermaid-layout-elk/package.json b/packages/mermaid-layout-elk/package.json index 3c5d7a917..f53302c09 100644 --- a/packages/mermaid-layout-elk/package.json +++ b/packages/mermaid-layout-elk/package.json @@ -1,6 +1,6 @@ { "name": "@mermaid-js/layout-elk", - "version": "0.1.0", + "version": "0.1.1", "description": "ELK layout engine for mermaid", "module": "dist/mermaid-layout-elk.core.mjs", "types": "dist/layout.d.ts", diff --git a/packages/mermaid/CHANGELOG.md b/packages/mermaid/CHANGELOG.md index ae05b0637..5a34667fa 100644 --- a/packages/mermaid/CHANGELOG.md +++ b/packages/mermaid/CHANGELOG.md @@ -1,5 +1,14 @@ # mermaid +## 11.0.2 + +### Patch Changes + +- [#5664](https://github.com/mermaid-js/mermaid/pull/5664) [`5deaef4`](https://github.com/mermaid-js/mermaid/commit/5deaef456e74d796866431c26f69360e4e74dbff) Thanks [@Austin-Fulbright](https://github.com/Austin-Fulbright)! - chore: Migrate git graph to langium, use typescript for internals + +- Updated dependencies [[`5deaef4`](https://github.com/mermaid-js/mermaid/commit/5deaef456e74d796866431c26f69360e4e74dbff)]: + - @mermaid-js/parser@0.2.0 + ## 11.0.1 ### Patch Changes diff --git a/packages/mermaid/package.json b/packages/mermaid/package.json index 9994bb3a8..8956eb1e5 100644 --- a/packages/mermaid/package.json +++ b/packages/mermaid/package.json @@ -1,6 +1,6 @@ { "name": "mermaid", - "version": "11.0.1", + "version": "11.0.2", "description": "Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.", "type": "module", "module": "./dist/mermaid.core.mjs", diff --git a/packages/parser/CHANGELOG.md b/packages/parser/CHANGELOG.md index f6b145b5a..4b864f523 100644 --- a/packages/parser/CHANGELOG.md +++ b/packages/parser/CHANGELOG.md @@ -1,5 +1,11 @@ # @mermaid-js/parser +## 0.2.0 + +### Minor Changes + +- [#5664](https://github.com/mermaid-js/mermaid/pull/5664) [`5deaef4`](https://github.com/mermaid-js/mermaid/commit/5deaef456e74d796866431c26f69360e4e74dbff) Thanks [@Austin-Fulbright](https://github.com/Austin-Fulbright)! - chore: Migrate git graph to langium, use typescript for internals + ## 0.1.1 ### Patch Changes diff --git a/packages/parser/package.json b/packages/parser/package.json index 157d4dd05..fc70e844b 100644 --- a/packages/parser/package.json +++ b/packages/parser/package.json @@ -1,6 +1,6 @@ { "name": "@mermaid-js/parser", - "version": "0.1.1", + "version": "0.2.0", "description": "MermaidJS parser", "author": "Yokozuna59", "contributors": [ From b34dfe8f45eded31da10965ced7ea40fde1ca76c Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 12:41:18 +0530 Subject: [PATCH 103/124] fix: Type file path for layout-elk --- .changeset/khaki-plants-watch.md | 5 +++++ packages/mermaid-layout-elk/package.json | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/khaki-plants-watch.md diff --git a/.changeset/khaki-plants-watch.md b/.changeset/khaki-plants-watch.md new file mode 100644 index 000000000..0849105f3 --- /dev/null +++ b/.changeset/khaki-plants-watch.md @@ -0,0 +1,5 @@ +--- +'@mermaid-js/layout-elk': patch +--- + +Fix type file path diff --git a/packages/mermaid-layout-elk/package.json b/packages/mermaid-layout-elk/package.json index f53302c09..56fa53f0e 100644 --- a/packages/mermaid-layout-elk/package.json +++ b/packages/mermaid-layout-elk/package.json @@ -3,12 +3,12 @@ "version": "0.1.1", "description": "ELK layout engine for mermaid", "module": "dist/mermaid-layout-elk.core.mjs", - "types": "dist/layout.d.ts", + "types": "dist/layouts.d.ts", "type": "module", "exports": { ".": { "import": "./dist/mermaid-layout-elk.core.mjs", - "types": "./dist/layout.d.ts" + "types": "./dist/layouts.d.ts" }, "./*": "./*" }, From 1532721f09ed52ac1e8b741086b369819147b41c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 24 Aug 2024 07:17:31 +0000 Subject: [PATCH 104/124] Version Packages --- .changeset/khaki-plants-watch.md | 5 ----- packages/mermaid-layout-elk/CHANGELOG.md | 6 ++++++ packages/mermaid-layout-elk/package.json | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) delete mode 100644 .changeset/khaki-plants-watch.md diff --git a/.changeset/khaki-plants-watch.md b/.changeset/khaki-plants-watch.md deleted file mode 100644 index 0849105f3..000000000 --- a/.changeset/khaki-plants-watch.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@mermaid-js/layout-elk': patch ---- - -Fix type file path diff --git a/packages/mermaid-layout-elk/CHANGELOG.md b/packages/mermaid-layout-elk/CHANGELOG.md index 2db340af7..e1ec1d2dd 100644 --- a/packages/mermaid-layout-elk/CHANGELOG.md +++ b/packages/mermaid-layout-elk/CHANGELOG.md @@ -1,5 +1,11 @@ # @mermaid-js/layout-elk +## 0.1.2 + +### Patch Changes + +- [#5761](https://github.com/mermaid-js/mermaid/pull/5761) [`b34dfe8`](https://github.com/mermaid-js/mermaid/commit/b34dfe8f45eded31da10965ced7ea40fde1ca76c) Thanks [@sidharthv96](https://github.com/sidharthv96)! - Fix type file path + ## 0.1.1 ### Patch Changes diff --git a/packages/mermaid-layout-elk/package.json b/packages/mermaid-layout-elk/package.json index 56fa53f0e..5fa491bc8 100644 --- a/packages/mermaid-layout-elk/package.json +++ b/packages/mermaid-layout-elk/package.json @@ -1,6 +1,6 @@ { "name": "@mermaid-js/layout-elk", - "version": "0.1.1", + "version": "0.1.2", "description": "ELK layout engine for mermaid", "module": "dist/mermaid-layout-elk.core.mjs", "types": "dist/layouts.d.ts", From 5c59505589a2ddec79be501811080eddd915e3e9 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 14:51:23 +0530 Subject: [PATCH 105/124] chore: Skip running E2E on Push to most branches --- .github/workflows/e2e.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 2600b3fb8..fe420a7eb 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -2,8 +2,10 @@ name: E2E on: push: - branches-ignore: - - 'gh-readonly-queue/**' + branches: + - develop + - master + - release/** pull_request: merge_group: From 1a1f6687455efb5cb8cff884fafab202c61a5a9d Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 15:04:14 +0530 Subject: [PATCH 106/124] chore: Add concurrency for actions --- .github/workflows/autofix.yml | 2 ++ .github/workflows/build-docs.yml | 2 ++ .github/workflows/e2e-applitools.yml | 2 ++ .github/workflows/e2e.yml | 2 ++ .github/workflows/lint.yml | 6 ++---- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index f26bf4ab8..1eef1eae2 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -7,6 +7,8 @@ on: permissions: contents: read +concurrency: ${{ github.workflow }}-${{ github.ref }} + jobs: autofix: runs-on: ubuntu-latest diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 0ce778957..ca422de52 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -8,6 +8,8 @@ on: pull_request: merge_group: +concurrency: ${{ github.workflow }}-${{ github.ref }} + permissions: contents: read diff --git a/.github/workflows/e2e-applitools.yml b/.github/workflows/e2e-applitools.yml index 5e5407a23..e75ad60d3 100644 --- a/.github/workflows/e2e-applitools.yml +++ b/.github/workflows/e2e-applitools.yml @@ -11,6 +11,8 @@ on: default: master description: 'Parent branch to use for PRs' +concurrency: ${{ github.workflow }}-${{ github.ref }} + permissions: contents: read diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index fe420a7eb..f7eb63a8c 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -9,6 +9,8 @@ on: pull_request: merge_group: +concurrency: ${{ github.workflow }}-${{ github.ref }} + permissions: contents: read diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 632cd6ddc..25de168c1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -4,12 +4,10 @@ on: push: merge_group: pull_request: - types: - - opened - - synchronize - - ready_for_review workflow_dispatch: +concurrency: ${{ github.workflow }}-${{ github.ref }} + permissions: contents: write From ab4ba4cf2fa67fa4c339d741eefc5ad068ce4565 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 15:05:28 +0530 Subject: [PATCH 107/124] chore: Remove unnecessary workflows --- .github/workflows/build.yml | 49 --------------------------- .github/workflows/release-publish.yml | 47 ------------------------- 2 files changed, 96 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 .github/workflows/release-publish.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index c6e96912e..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Build - -on: - push: {} - merge_group: - pull_request: - types: - - opened - - synchronize - - ready_for_review - -permissions: - contents: read - -jobs: - build-mermaid: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - uses: pnpm/action-setup@v4 - # uses version from "packageManager" field in package.json - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: pnpm - node-version-file: '.node-version' - - - name: Install Packages - run: | - pnpm install --frozen-lockfile - env: - CYPRESS_CACHE_FOLDER: .cache/Cypress - - - name: Run Build - run: pnpm run build - - - name: Upload Mermaid Build as Artifact - uses: actions/upload-artifact@v4 - with: - name: mermaid-build - path: packages/mermaid/dist - - - name: Upload Mermaid Mindmap Build as Artifact - uses: actions/upload-artifact@v4 - with: - name: mermaid-mindmap-build - path: packages/mermaid-mindmap/dist diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml deleted file mode 100644 index 4dcf709c0..000000000 --- a/.github/workflows/release-publish.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Publish release - -on: - release: - types: [published] - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: fregante/setup-git-user@v2 - - - uses: pnpm/action-setup@v4 - # uses version from "packageManager" field in package.json - - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - cache: pnpm - node-version-file: '.node-version' - - - name: Install Packages - run: | - pnpm install --frozen-lockfile - npm i json --global - env: - CYPRESS_CACHE_FOLDER: .cache/Cypress - - - name: Prepare release - run: | - VERSION=${GITHUB_REF:10} - echo "Preparing release $VERSION" - git checkout -t origin/release/$VERSION - npm version --no-git-tag-version --allow-same-version $VERSION - git add package.json - git commit -nm "Bump version $VERSION" - git checkout -t origin/master - git merge -m "Release $VERSION" --no-ff release/$VERSION - git push --no-verify - - - name: Publish - run: | - npm set //registry.npmjs.org/:_authToken $NPM_TOKEN - npm publish - env: - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} From d08ef70e0fc55ef9c28df6c976b0006c1bf8c1be Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 15:06:08 +0530 Subject: [PATCH 108/124] chore: Merge checks into lint --- .github/workflows/checks.yml | 26 -------------------------- .github/workflows/lint.yml | 7 +++++++ 2 files changed, 7 insertions(+), 26 deletions(-) delete mode 100644 .github/workflows/checks.yml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml deleted file mode 100644 index 012fbf19d..000000000 --- a/.github/workflows/checks.yml +++ /dev/null @@ -1,26 +0,0 @@ -on: - push: - merge_group: - pull_request: - types: - - opened - - synchronize - - ready_for_review - -name: Static analysis on Test files - -jobs: - check-tests: - runs-on: ubuntu-latest - name: check tests - if: github.repository_owner == 'mermaid-js' - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: testomatio/check-tests@stable - with: - framework: cypress - tests: './cypress/e2e/**/**.spec.js' - token: ${{ secrets.GITHUB_TOKEN }} - has-tests-label: true diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 25de168c1..a32a60ab2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -80,3 +80,10 @@ jobs: working-directory: ./packages/mermaid continue-on-error: ${{ github.event_name == 'push' }} run: pnpm run docs:verify + + - uses: testomatio/check-tests@stable + with: + framework: cypress + tests: './cypress/e2e/**/**.spec.js' + token: ${{ secrets.GITHUB_TOKEN }} + has-tests-label: true From f6333b4a5e08743bb6c92212517bebafb159606c Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 15:34:53 +0530 Subject: [PATCH 109/124] chore: Add provenance flag --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b36a82b3..607f8de97 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,3 +35,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_CONFIG_PROVENANCE: true From 83ee06e9e7152fb55151258118715c016d5d1cec Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sat, 24 Aug 2024 09:26:49 +0000 Subject: [PATCH 110/124] chore: define scorecard workflow --- .github/workflows/autofix.yml | 8 ++-- .github/workflows/build-docs.yml | 6 +-- .github/workflows/check-readme-in-sync.yml | 2 +- .github/workflows/codeql.yml | 11 ++++-- .github/workflows/dependency-review.yml | 4 +- .github/workflows/e2e-applitools.yml | 8 ++-- .github/workflows/e2e.yml | 26 ++++++------- .github/workflows/issue-triage.yml | 8 +++- .github/workflows/link-checker.yml | 9 +++-- .github/workflows/lint.yml | 6 +-- .github/workflows/pr-labeler.yml | 2 +- .github/workflows/publish-docs.yml | 12 +++--- .github/workflows/release-preview-publish.yml | 6 +-- .github/workflows/release.yml | 14 +++++-- .github/workflows/scorecard.yml | 37 +++++++++++++++++++ .github/workflows/test.yml | 8 ++-- .github/workflows/unlock-reopened-issues.yml | 2 +- .github/workflows/update-browserlist.yml | 8 ++-- README.md | 1 + 19 files changed, 117 insertions(+), 61 deletions(-) create mode 100644 .github/workflows/scorecard.yml diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml index 1eef1eae2..6a43791ed 100644 --- a/.github/workflows/autofix.yml +++ b/.github/workflows/autofix.yml @@ -13,13 +13,13 @@ jobs: autofix: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 # uses version from "packageManager" field in package.json - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: pnpm node-version-file: '.node-version' @@ -42,4 +42,4 @@ jobs: working-directory: ./packages/mermaid run: pnpm run docs:build - - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c + - uses: autofix-ci/action@ff86a557419858bb967097bfc916833f5647fa8c # main diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index ca422de52..eb0c4594a 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -18,12 +18,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: pnpm node-version-file: '.node-version' diff --git a/.github/workflows/check-readme-in-sync.yml b/.github/workflows/check-readme-in-sync.yml index ad6df66b5..5c940c087 100644 --- a/.github/workflows/check-readme-in-sync.yml +++ b/.github/workflows/check-readme-in-sync.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Check for difference in README.md and docs/README.md run: | diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 764ec598c..65962ce64 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -11,6 +11,9 @@ on: - synchronize - ready_for_review +permissions: # added using https://github.com/step-security/secure-repo + contents: read + jobs: analyze: name: Analyze @@ -29,11 +32,11 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v3 + uses: github/codeql-action/init@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 with: config-file: ./.github/codeql/codeql-config.yml languages: ${{ matrix.language }} @@ -45,7 +48,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v3 + uses: github/codeql-action/autobuild@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 # ℹ️ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -59,4 +62,4 @@ jobs: # make release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 + uses: github/codeql-action/analyze@2c779ab0d087cd7fe7b826087247c2c81f27bfa6 # v3.26.5 diff --git a/.github/workflows/dependency-review.yml b/.github/workflows/dependency-review.yml index 0d4a01360..521735e6e 100644 --- a/.github/workflows/dependency-review.yml +++ b/.github/workflows/dependency-review.yml @@ -15,6 +15,6 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout Repository' - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: 'Dependency Review' - uses: actions/dependency-review-action@v4 + uses: actions/dependency-review-action@5a2ce3f5b92ee19cbb1541a4984c76d921601d7c # v4.3.4 diff --git a/.github/workflows/e2e-applitools.yml b/.github/workflows/e2e-applitools.yml index e75ad60d3..6da65afe5 100644 --- a/.github/workflows/e2e-applitools.yml +++ b/.github/workflows/e2e-applitools.yml @@ -32,13 +32,13 @@ jobs: run: | echo "::error,title=Not using Applitools::APPLITOOLS_API_KEY is empty, disabling Applitools for this run." - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 # uses version from "packageManager" field in package.json - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version-file: '.node-version' @@ -54,7 +54,7 @@ jobs: APPLITOOLS_SERVER_URL: 'https://eyesapi.applitools.com' - name: Cypress run - uses: cypress-io/github-action@v4 + uses: cypress-io/github-action@d79d2d530a66e641eb4a5f227e13bc985c60b964 # v4.2.2 id: cypress with: start: pnpm run dev diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index f7eb63a8c..2b91d078e 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -36,15 +36,15 @@ jobs: image: cypress/browsers:node-20.11.0-chrome-121.0.6167.85-1-ff-120.0-edge-121.0.2277.83-1 options: --user 1001 steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version-file: '.node-version' - name: Cache snapshots id: cache-snapshot - uses: actions/cache@v4 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: save-always: true path: ./cypress/snapshots @@ -53,13 +53,13 @@ jobs: # If a snapshot for a given Hash is not found, we checkout that commit, run the tests and cache the snapshots. - name: Switch to base branch if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }} - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: ref: ${{ env.targetHash }} - name: Install dependencies if: ${{ steps.cache-snapshot.outputs.cache-hit != 'true' }} - uses: cypress-io/github-action@v6 + uses: cypress-io/github-action@df7484c5ba85def7eef30db301afa688187bc378 # v6.7.2 with: # just perform install runTests: false @@ -82,26 +82,26 @@ jobs: matrix: containers: [1, 2, 3, 4] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 # uses version from "packageManager" field in package.json - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: node-version-file: '.node-version' # These cached snapshots are downloaded, providing the reference snapshots. - name: Cache snapshots id: cache-snapshot - uses: actions/cache/restore@v4 + uses: actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ./cypress/snapshots key: ${{ runner.os }}-snapshots-${{ env.targetHash }} - name: Install dependencies - uses: cypress-io/github-action@v6 + uses: cypress-io/github-action@df7484c5ba85def7eef30db301afa688187bc378 # v6.7.2 with: runTests: false @@ -117,7 +117,7 @@ jobs: # Install NPM dependencies, cache them correctly # and run all Cypress tests - name: Cypress run - uses: cypress-io/github-action@v6 + uses: cypress-io/github-action@df7484c5ba85def7eef30db301afa688187bc378 # v6.7.2 id: cypress # If CYPRESS_RECORD_KEY is set, run in parallel on all containers # Otherwise (e.g. if running from fork), we run on a single container only @@ -141,7 +141,7 @@ jobs: ARGOS_PARALLEL_INDEX: ${{ matrix.containers }} - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 # Run step only pushes to develop and pull_requests if: ${{ steps.cypress.conclusion == 'success' && (github.event_name == 'pull_request' || github.ref == 'refs/heads/develop')}} with: diff --git a/.github/workflows/issue-triage.yml b/.github/workflows/issue-triage.yml index 129bd62b6..87a6e958b 100644 --- a/.github/workflows/issue-triage.yml +++ b/.github/workflows/issue-triage.yml @@ -4,11 +4,17 @@ on: issues: types: [opened] +permissions: # added using https://github.com/step-security/secure-repo + contents: read + jobs: triage: + permissions: + issues: write # for andymckay/labeler to label issues + pull-requests: write # for andymckay/labeler to label PRs runs-on: ubuntu-latest steps: - - uses: andymckay/labeler@1.0.4 + - uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 # 1.0.4 with: repo-token: '${{ secrets.GITHUB_TOKEN }}' add-labels: 'Status: Triage' diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml index bf54d7df2..0a2b74dfe 100644 --- a/.github/workflows/link-checker.yml +++ b/.github/workflows/link-checker.yml @@ -19,6 +19,9 @@ on: # * is a special character in YAML so you have to quote this string - cron: '30 8 * * *' +permissions: # added using https://github.com/step-security/secure-repo + contents: read + jobs: link-checker: runs-on: ubuntu-latest @@ -26,17 +29,17 @@ jobs: # lychee only uses the GITHUB_TOKEN to avoid rate-limiting contents: read steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - name: Restore lychee cache - uses: actions/cache@v4 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: .lycheecache key: cache-lychee-${{ github.sha }} restore-keys: cache-lychee- - name: Link Checker - uses: lycheeverse/lychee-action@v1.9.3 + uses: lycheeverse/lychee-action@c053181aa0c3d17606addfe97a9075a32723548a # v1.9.3 with: args: >- --config .github/lychee.toml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a32a60ab2..9cb58f0ea 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,13 +15,13 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 # uses version from "packageManager" field in package.json - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: pnpm node-version-file: '.node-version' diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index 096590346..c9faaa062 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -22,7 +22,7 @@ jobs: pull-requests: write # write permission is required to label PRs steps: - name: Label PR - uses: release-drafter/release-drafter@v6 + uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v6.0.0 with: config-name: pr-labeler.yml disable-autolabeler: false diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 4ff5f4117..ecb411b5c 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -23,12 +23,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: pnpm node-version-file: '.node-version' @@ -37,13 +37,13 @@ jobs: run: pnpm install --frozen-lockfile - name: Setup Pages - uses: actions/configure-pages@v4 + uses: actions/configure-pages@1f0c5cde4bc74cd7e1254d0cb4de8d49e9068c7d # v4.0.0 - name: Run Build run: pnpm --filter mermaid run docs:build:vitepress - name: Upload artifact - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 with: path: packages/mermaid/src/vitepress/.vitepress/dist @@ -56,4 +56,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 diff --git a/.github/workflows/release-preview-publish.yml b/.github/workflows/release-preview-publish.yml index 91e3ac981..a9332d9a1 100644 --- a/.github/workflows/release-preview-publish.yml +++ b/.github/workflows/release-preview-publish.yml @@ -9,14 +9,14 @@ jobs: publish-preview: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 with: fetch-depth: 0 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: pnpm node-version-file: '.node-version' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 607f8de97..91153084e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,18 +7,24 @@ on: concurrency: ${{ github.workflow }}-${{ github.ref }} +permissions: # added using https://github.com/step-security/secure-repo + contents: read + jobs: release: + permissions: + contents: write # for changesets/action to push to the repo + pull-requests: write # for changesets/action to create PRs name: Release runs-on: ubuntu-latest steps: - name: Checkout Repo - uses: actions/checkout@v3 + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: pnpm node-version-file: '.node-version' @@ -28,7 +34,7 @@ jobs: - name: Create Release Pull Request or Publish to npm id: changesets - uses: changesets/action@v1 + uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7 with: version: pnpm changeset:version publish: pnpm changeset:publish diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml new file mode 100644 index 000000000..bca8b4430 --- /dev/null +++ b/.github/workflows/scorecard.yml @@ -0,0 +1,37 @@ +name: Scorecard supply-chain security +on: + branch_protection_rule: + push: + branches: + - main + schedule: + - cron: 29 15 * * 0 +permissions: read-all +jobs: + analysis: + name: Scorecard analysis + permissions: + id-token: write + security-events: write + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + persist-credentials: false + - name: Run analysis + uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1 + with: + results_file: results.sarif + results_format: sarif + publish_results: true + - name: Upload artifact + uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20 + with: + name: SARIF file + path: results.sarif + retention-days: 5 + - name: Upload to code-scanning + uses: github/codeql-action/upload-sarif@f0f3afee809481da311ca3a6ff1ff51d81dbeb24 # v3.26.4 + with: + sarif_file: results.sarif diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0b284a68..375d5fada 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,13 +9,13 @@ jobs: unit-test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - uses: pnpm/action-setup@v4 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 # uses version from "packageManager" field in package.json - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 with: cache: pnpm node-version-file: '.node-version' @@ -39,7 +39,7 @@ jobs: pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts --coverage - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v4 + uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 # Run step only pushes to develop and pull_requests if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/develop' }} with: diff --git a/.github/workflows/unlock-reopened-issues.yml b/.github/workflows/unlock-reopened-issues.yml index 4c5379729..b854eeb4b 100644 --- a/.github/workflows/unlock-reopened-issues.yml +++ b/.github/workflows/unlock-reopened-issues.yml @@ -8,6 +8,6 @@ jobs: triage: runs-on: ubuntu-latest steps: - - uses: Dunning-Kruger/unlock-issues@v1 + - uses: Dunning-Kruger/unlock-issues@b06b7f7e5c3f2eaa1c6d5d89f40930e4d6d9699e # v1 with: repo-token: '${{ secrets.GITHUB_TOKEN }}' diff --git a/.github/workflows/update-browserlist.yml b/.github/workflows/update-browserlist.yml index f8f7696cd..1b26271f7 100644 --- a/.github/workflows/update-browserlist.yml +++ b/.github/workflows/update-browserlist.yml @@ -8,18 +8,18 @@ jobs: update-browser-list: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v4 + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 - run: npx update-browserslist-db@latest - name: Commit changes - uses: EndBug/add-and-commit@v9 + uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 with: author_name: ${{ github.actor }} author_email: ${{ github.actor }}@users.noreply.github.com message: 'chore: update browsers list' push: false - name: Create Pull Request - uses: peter-evans/create-pull-request@v6 + uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6.1.0 with: branch: update-browserslist title: Update Browserslist diff --git a/README.md b/README.md index 8d5eebfeb..4a092f137 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ Try Live Editor previews of future releases: From 7e9946eea81536aa922f04ffdc23f6bc79512c17 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sat, 24 Aug 2024 13:31:03 +0200 Subject: [PATCH 111/124] fix: correct target branch for scorecard --- .github/workflows/scorecard.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index bca8b4430..0dee2e666 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -3,7 +3,7 @@ on: branch_protection_rule: push: branches: - - main + - develop schedule: - cron: 29 15 * * 0 permissions: read-all From db1b055c7f3253ea443e7bb9ed338a5c54feae37 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 17:21:21 +0530 Subject: [PATCH 112/124] chore: Update husky --- .husky/pre-commit | 4 +--- package.json | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index ad85fc42c..cc173f4a5 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,2 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - +#!/usr/bin/env sh NODE_OPTIONS="--max_old_space_size=8192" pnpm run pre-commit diff --git a/package.json b/package.json index f0045f7ae..21ae5360c 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "test": "pnpm lint && vitest run", "test:watch": "vitest --watch", "test:coverage": "vitest --coverage", - "prepare": "husky install && pnpm build", + "prepare": "husky && pnpm build", "pre-commit": "lint-staged" }, "repository": { From c95e997f8ff42fdd18987bf93b5e126b9facc4eb Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 17:31:37 +0530 Subject: [PATCH 113/124] fix: Revert accidental change of MERMAID_RELEASE_VERSION --- docs/community/contributing.md | 4 ++-- packages/mermaid/scripts/update-release-version.mts | 10 +++++----- packages/mermaid/src/docs/community/contributing.md | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/community/contributing.md b/docs/community/contributing.md index c78a3cb40..9f0bbfb49 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -370,9 +370,9 @@ If the users have no way to know that things have changed, then you haven't real Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. The documentation has to be updated for users to know that things have been changed and added! -If you are adding a new feature, add `(v10.8.0+)` in the title or description. It will be replaced automatically with the current version number when the release happens. +If you are adding a new feature, add `(vMERMAID_RELEASE_VERSION+)` in the title or description. It will be replaced automatically with the current version number when the release happens. -eg: `# Feature Name (v10.8.0+)` +eg: `# Feature Name (vMERMAID_RELEASE_VERSION+)` We know it can sometimes be hard to code _and_ write user documentation. diff --git a/packages/mermaid/scripts/update-release-version.mts b/packages/mermaid/scripts/update-release-version.mts index a5943b37b..970bef1d3 100644 --- a/packages/mermaid/scripts/update-release-version.mts +++ b/packages/mermaid/scripts/update-release-version.mts @@ -5,15 +5,15 @@ * So contributors adding new features will only have to add the placeholder and not worry about updating the version number. * */ +import { writeFile } from 'fs/promises'; import { posix } from 'path'; import { - getGlobs, getFilesFromGlobs, - SOURCE_DOCS_DIR, - readSyncedUTF8file, + getGlobs, MERMAID_RELEASE_VERSION, + readSyncedUTF8file, + SOURCE_DOCS_DIR, } from './docs.mjs'; -import { writeFile } from 'fs/promises'; const verifyOnly: boolean = process.argv.includes('--verify'); const versionPlaceholder = ''; @@ -21,7 +21,7 @@ const versionPlaceholder = ''; const main = async () => { const sourceDirGlob = posix.join('.', SOURCE_DOCS_DIR, '**'); const mdFileGlobs = getGlobs([posix.join(sourceDirGlob, '*.md')]); - mdFileGlobs.push('!**/community/development.md', '!**/community/code.md'); + mdFileGlobs.push('!**/community/contributing.md'); const mdFiles = await getFilesFromGlobs(mdFileGlobs); mdFiles.sort(); const mdFilesWithPlaceholder: string[] = []; diff --git a/packages/mermaid/src/docs/community/contributing.md b/packages/mermaid/src/docs/community/contributing.md index 71048d095..1521c7ace 100644 --- a/packages/mermaid/src/docs/community/contributing.md +++ b/packages/mermaid/src/docs/community/contributing.md @@ -371,9 +371,9 @@ If the users have no way to know that things have changed, then you haven't real Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. The documentation has to be updated for users to know that things have been changed and added! -If you are adding a new feature, add `(v10.8.0+)` in the title or description. It will be replaced automatically with the current version number when the release happens. +If you are adding a new feature, add `(vMERMAID_RELEASE_VERSION+)` in the title or description. It will be replaced automatically with the current version number when the release happens. -eg: `# Feature Name (v10.8.0+)` +eg: `# Feature Name (vMERMAID_RELEASE_VERSION+)` We know it can sometimes be hard to code _and_ write user documentation. From 0bfb42c68f27862455407ae9566b3711caf62c7e Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 17:57:36 +0530 Subject: [PATCH 114/124] feat: Add verification script for MERMAID_RELEASE_VERSION --- docs/community/contributing.md | 4 ++-- packages/mermaid/scripts/update-release-version.mts | 13 ++++++++++++- packages/mermaid/src/docs/community/contributing.md | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/docs/community/contributing.md b/docs/community/contributing.md index 9f0bbfb49..792c90a98 100644 --- a/docs/community/contributing.md +++ b/docs/community/contributing.md @@ -370,9 +370,9 @@ If the users have no way to know that things have changed, then you haven't real Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. The documentation has to be updated for users to know that things have been changed and added! -If you are adding a new feature, add `(vMERMAID_RELEASE_VERSION+)` in the title or description. It will be replaced automatically with the current version number when the release happens. +If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. -eg: `# Feature Name (vMERMAID_RELEASE_VERSION+)` +eg: `# Feature Name (v+)` We know it can sometimes be hard to code _and_ write user documentation. diff --git a/packages/mermaid/scripts/update-release-version.mts b/packages/mermaid/scripts/update-release-version.mts index 970bef1d3..0459d3444 100644 --- a/packages/mermaid/scripts/update-release-version.mts +++ b/packages/mermaid/scripts/update-release-version.mts @@ -5,7 +5,7 @@ * So contributors adding new features will only have to add the placeholder and not worry about updating the version number. * */ -import { writeFile } from 'fs/promises'; +import { readFile, writeFile } from 'fs/promises'; import { posix } from 'path'; import { getFilesFromGlobs, @@ -18,7 +18,18 @@ import { const verifyOnly: boolean = process.argv.includes('--verify'); const versionPlaceholder = ''; +const verifyDocumentation = async () => { + const fileContent = await readFile('./src/docs/community/contributing.md', 'utf-8'); + if (!fileContent.includes(versionPlaceholder)) { + console.error( + `The placeholder ${versionPlaceholder} is not present in the contributing.md file.` + ); + process.exit(1); + } +}; + const main = async () => { + await verifyDocumentation(); const sourceDirGlob = posix.join('.', SOURCE_DOCS_DIR, '**'); const mdFileGlobs = getGlobs([posix.join(sourceDirGlob, '*.md')]); mdFileGlobs.push('!**/community/contributing.md'); diff --git a/packages/mermaid/src/docs/community/contributing.md b/packages/mermaid/src/docs/community/contributing.md index 1521c7ace..4cd649563 100644 --- a/packages/mermaid/src/docs/community/contributing.md +++ b/packages/mermaid/src/docs/community/contributing.md @@ -371,9 +371,9 @@ If the users have no way to know that things have changed, then you haven't real Likewise, if users don't know that there is a new feature that you've implemented, it will forever remain unknown and unused. The documentation has to be updated for users to know that things have been changed and added! -If you are adding a new feature, add `(vMERMAID_RELEASE_VERSION+)` in the title or description. It will be replaced automatically with the current version number when the release happens. +If you are adding a new feature, add `(v+)` in the title or description. It will be replaced automatically with the current version number when the release happens. -eg: `# Feature Name (vMERMAID_RELEASE_VERSION+)` +eg: `# Feature Name (v+)` We know it can sometimes be hard to code _and_ write user documentation. From 559be33ff74792e1483f8aa9c12c45487c40d178 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 18:01:34 +0530 Subject: [PATCH 115/124] docs: Fix --- docs/syntax/entityRelationshipDiagram.md | 2 +- packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/syntax/entityRelationshipDiagram.md b/docs/syntax/entityRelationshipDiagram.md index 9023f763a..74b545abf 100644 --- a/docs/syntax/entityRelationshipDiagram.md +++ b/docs/syntax/entityRelationshipDiagram.md @@ -286,7 +286,7 @@ erDiagram - If you want the relationship label to be more than one word, you must use double quotes around the phrase - If you don't want a label at all on a relationship, you must use an empty double-quoted string -- (v10.8.0+) If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) +- (v\+) If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) ## Styling diff --git a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md index 06e7c96b4..7fed4a527 100644 --- a/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md +++ b/packages/mermaid/src/docs/syntax/entityRelationshipDiagram.md @@ -192,7 +192,7 @@ erDiagram - If you want the relationship label to be more than one word, you must use double quotes around the phrase - If you don't want a label at all on a relationship, you must use an empty double-quoted string -- (v10.8.0+) If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) +- (v+) If you want a multi-line label on a relationship, use `
` between the two lines (`"first line
second line"`) ## Styling From 8e640da5436e8ae013b11b1c1821a9afcc15d0d3 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Sat, 24 Aug 2024 18:03:45 +0530 Subject: [PATCH 116/124] docs: Add changeset --- .changeset/khaki-items-leave.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/khaki-items-leave.md diff --git a/.changeset/khaki-items-leave.md b/.changeset/khaki-items-leave.md new file mode 100644 index 000000000..d84776eb2 --- /dev/null +++ b/.changeset/khaki-items-leave.md @@ -0,0 +1,5 @@ +--- +'mermaid': minor +--- + +feat(er): allow multi-line relationship labels From 221aedc5f5f5570492c6e70f4a14962cffc062e2 Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sat, 24 Aug 2024 08:10:52 +0000 Subject: [PATCH 117/124] chore: use corepack to install pnpm --- .github/workflows/lint.yml | 8 ++++++++ .hadolint.yaml | 2 ++ Dockerfile | 12 ++++++++++-- docker-compose.yml | 3 --- docker-entrypoint.sh | 3 --- 5 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 .hadolint.yaml delete mode 100755 docker-entrypoint.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9cb58f0ea..bb8eeb578 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,6 +12,14 @@ permissions: contents: write jobs: + docker-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - uses: hadolint/hadolint-action@54c9adbab1582c2ef04b2016b760714a4bfde3cf # v3.1.0 + with: + verbose: true lint: runs-on: ubuntu-latest steps: diff --git a/.hadolint.yaml b/.hadolint.yaml new file mode 100644 index 000000000..853c0983e --- /dev/null +++ b/.hadolint.yaml @@ -0,0 +1,2 @@ +ignored: + - DL3002 # TODO: Last USER should not be root \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 7bec3bd4b..ec4dc9329 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,2 +1,10 @@ -FROM node:20.12.2-alpine3.19 AS base -RUN wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.shrc" SHELL="$(which sh)" sh - +FROM node:20.12.2-alpine3.19 + +USER 0:0 + +RUN corepack enable \ + && corepack enable pnpm + +ENV NODE_OPTIONS="--max_old_space_size=8192" + +EXPOSE 9000 3333 diff --git a/docker-compose.yml b/docker-compose.yml index 841f07ff9..5fa1ff04a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,9 +7,6 @@ services: tty: true working_dir: /mermaid mem_limit: '8G' - entrypoint: ./docker-entrypoint.sh - environment: - - NODE_OPTIONS=--max_old_space_size=8192 volumes: - ./:/mermaid - root_cache:/root/.cache diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh deleted file mode 100755 index c222b7fd5..000000000 --- a/docker-entrypoint.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -source /root/.shrc -exec "$@" From ed352debd58cb42fee75334d67c10ea0bd97db30 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Sat, 24 Aug 2024 11:42:16 +0000 Subject: [PATCH 118/124] [autofix.ci] apply automated fixes --- .hadolint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.hadolint.yaml b/.hadolint.yaml index 853c0983e..280ff9592 100644 --- a/.hadolint.yaml +++ b/.hadolint.yaml @@ -1,2 +1,2 @@ ignored: - - DL3002 # TODO: Last USER should not be root \ No newline at end of file + - DL3002 # TODO: Last USER should not be root From 6585380a4c6ae16f45555624dd9d6f23033a20f3 Mon Sep 17 00:00:00 2001 From: Alexandre Djerbetian Date: Sun, 25 Aug 2024 11:18:27 +0300 Subject: [PATCH 119/124] Fix tutorials.md with url safe encoding See https://github.com/jihchi/mermaid.ink/issues/396 for the bug that this PR fixes. --- packages/mermaid/src/docs/ecosystem/tutorials.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/docs/ecosystem/tutorials.md b/packages/mermaid/src/docs/ecosystem/tutorials.md index d5bf9330d..7258361bf 100644 --- a/packages/mermaid/src/docs/ecosystem/tutorials.md +++ b/packages/mermaid/src/docs/ecosystem/tutorials.md @@ -57,7 +57,7 @@ import matplotlib.pyplot as plt def mm(graph): graphbytes = graph.encode("utf8") - base64_bytes = base64.b64encode(graphbytes) + base64_bytes = base64.urlsafe_b64encode(graphbytes) base64_string = base64_bytes.decode("ascii") display(Image(url="https://mermaid.ink/img/" + base64_string)) From efcafd99db55b7028de6c2de5f610c12a2201b5d Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sun, 25 Aug 2024 09:01:32 +0000 Subject: [PATCH 120/124] chore: pin dependencies --- .github/workflows/lint.yml | 2 +- .github/workflows/release-preview-publish.yml | 2 +- Dockerfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index bb8eeb578..febd2f92d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -89,7 +89,7 @@ jobs: continue-on-error: ${{ github.event_name == 'push' }} run: pnpm run docs:verify - - uses: testomatio/check-tests@stable + - uses: testomatio/check-tests@0ea638fcec1820cf2e7b9854fdbdd04128a55bd4 # stable with: framework: cypress tests: './cypress/e2e/**/**.spec.js' diff --git a/.github/workflows/release-preview-publish.yml b/.github/workflows/release-preview-publish.yml index a9332d9a1..96556aa26 100644 --- a/.github/workflows/release-preview-publish.yml +++ b/.github/workflows/release-preview-publish.yml @@ -28,7 +28,7 @@ jobs: CYPRESS_CACHE_FOLDER: .cache/Cypress - name: Install Json - run: npm i json --global + run: npm i json@11.0.0 --global - name: Publish working-directory: ./packages/mermaid diff --git a/Dockerfile b/Dockerfile index ec4dc9329..fa933f999 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20.12.2-alpine3.19 +FROM node:20.12.2-alpine3.19@sha256:7a91aa397f2e2dfbfcdad2e2d72599f374e0b0172be1d86eeb73f1d33f36a4b2 USER 0:0 From 940146fadd42f8347db436548f87941a91bd147f Mon Sep 17 00:00:00 2001 From: NicolasNewman Date: Sun, 25 Aug 2024 12:52:29 -0500 Subject: [PATCH 121/124] tests(er): added test for line breaks --- .../integration/rendering/erDiagram.spec.js | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/cypress/integration/rendering/erDiagram.spec.js b/cypress/integration/rendering/erDiagram.spec.js index 1a2340906..aad9b1cf7 100644 --- a/cypress/integration/rendering/erDiagram.spec.js +++ b/cypress/integration/rendering/erDiagram.spec.js @@ -321,4 +321,37 @@ ORDER ||--|{ LINE-ITEM : contains { logLevel: 1 } ); }); + + it('should render relationship labels with line breaks', () => { + imgSnapshotTest( + ` + erDiagram + p[Person] { + string firstName + string lastName + } + a["Customer Account"] { + string email + } + + b["Customer Account Secondary"] { + string email + } + + c["Customer Account Tertiary"] { + string email + } + + d["Customer Account Nth"] { + string email + } + + p ||--o| a : "has
one" + p ||--o| b : "has
one
two" + p ||--o| c : "has
one
two
three" + p ||--o| d : "has
one
two
three
...
Nth" + `, + { logLevel: 1 } + ); + }); }); From efc1a0adc417f85fcfeb7a901e5b2460978d914a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 04:39:18 +0000 Subject: [PATCH 122/124] chore(deps): update eslint --- pnpm-lock.yaml | 813 ++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 672 insertions(+), 141 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b377a1570..554af5eeb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -22,7 +22,7 @@ importers: version: 2.27.7 '@cspell/eslint-plugin': specifier: ^8.8.4 - version: 8.13.1(eslint@9.8.0) + version: 8.13.3(eslint@9.8.0) '@cypress/code-coverage': specifier: ^3.12.30 version: 3.12.44(@babel/core@7.25.2)(@babel/preset-env@7.25.3(@babel/core@7.25.2))(babel-loader@9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)))(cypress@13.13.2)(webpack@5.93.0(esbuild@0.21.5)) @@ -31,7 +31,7 @@ importers: version: 9.8.0 '@rollup/plugin-typescript': specifier: ^11.1.6 - version: 11.1.6(rollup@4.20.0)(tslib@2.6.3)(typescript@5.4.5) + version: 11.1.6(rollup@4.20.0)(tslib@2.7.0)(typescript@5.4.5) '@types/cors': specifier: ^2.8.17 version: 2.8.17 @@ -58,7 +58,7 @@ importers: version: 4.2.4 '@vitest/coverage-v8': specifier: ^1.4.0 - version: 1.6.0(vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3)) + version: 1.6.0(vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.6)) '@vitest/spy': specifier: ^1.4.0 version: 1.6.0 @@ -109,13 +109,13 @@ importers: version: 8.1.1 eslint-plugin-jest: specifier: ^28.6.0 - version: 28.7.0(@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(jest@29.7.0(@types/node@20.14.14))(typescript@5.4.5) + version: 28.7.0(@typescript-eslint/eslint-plugin@8.0.1(@typescript-eslint/parser@8.0.1(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(jest@29.7.0(@types/node@20.14.14))(typescript@5.4.5) eslint-plugin-jsdoc: specifier: ^48.2.9 version: 48.11.0(eslint@9.8.0) eslint-plugin-json: specifier: ^4.0.0 - version: 4.0.0 + version: 4.0.1 eslint-plugin-lodash: specifier: ^8.0.0 version: 8.0.0(eslint@9.8.0) @@ -196,16 +196,16 @@ importers: version: 5.4.5 typescript-eslint: specifier: ^8.0.0-alpha.34 - version: 8.0.0(eslint@9.8.0)(typescript@5.4.5) + version: 8.0.1(eslint@9.8.0)(typescript@5.4.5) vite: specifier: ^5.2.3 - version: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + version: 5.3.5(@types/node@20.14.14)(terser@5.31.6) vite-plugin-istanbul: specifier: ^6.0.0 - version: 6.0.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) + version: 6.0.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6)) vitest: specifier: ^1.4.0 - version: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3) + version: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.6) packages/mermaid: dependencies: @@ -380,10 +380,10 @@ importers: version: 5.0.0 vitepress: specifier: ^1.0.1 - version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5) + version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.6)(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(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5))(vue@3.4.35(typescript@5.4.5)) + version: 1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.6)(typescript@5.4.5))(vue@3.4.35(typescript@5.4.5)) packages/mermaid-example-diagram: dependencies: @@ -462,10 +462,10 @@ importers: version: 0.59.4 '@vite-pwa/vitepress': specifier: ^0.4.0 - version: 0.4.0(vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0)) + version: 0.4.0(vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0)) '@vitejs/plugin-vue': specifier: ^5.0.0 - version: 5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(vue@3.4.35(typescript@5.4.5)) + version: 5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))(vue@3.4.35(typescript@5.4.5)) fast-glob: specifier: ^3.3.2 version: 3.3.2 @@ -477,19 +477,19 @@ importers: version: 1.1.2 unocss: specifier: ^0.59.0 - version: 0.59.4(postcss@8.4.40)(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) + version: 0.59.4(postcss@8.4.40)(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6)) unplugin-vue-components: specifier: ^0.26.0 - version: 0.26.0(@babel/parser@7.25.3)(rollup@2.79.1)(vue@3.4.35(typescript@5.4.5)) + version: 0.26.0(@babel/parser@7.25.4)(rollup@2.79.1)(vue@3.4.35(typescript@5.4.5)) vite: specifier: ^5.0.0 - version: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + version: 5.3.5(@types/node@20.14.14)(terser@5.31.6) vite-plugin-pwa: specifier: ^0.19.7 - version: 0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) + version: 0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) vitepress: specifier: 1.1.4 - version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5) + version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.6)(typescript@5.4.5) workbox-window: specifier: ^7.0.0 version: 7.1.0 @@ -756,6 +756,10 @@ packages: resolution: {integrity: sha512-bYcppcpKBvX4znYaPEeFau03bp89ShqNMLs+rmdptMw+heSZh9+z84d2YG+K7cYLbWwzdjtDoW/uqZmPjulClQ==} engines: {node: '>=6.9.0'} + '@babel/compat-data@7.25.4': + resolution: {integrity: sha512-+LGRog6RAsCJrrrg/IO6LGmpphNe5DiK30dGjCoxxeGv49B10/3XYGxPsAwrDlMFcFEvdAUavDT8r9k/hSyQqQ==} + engines: {node: '>=6.9.0'} + '@babel/core@7.25.2': resolution: {integrity: sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==} engines: {node: '>=6.9.0'} @@ -764,6 +768,10 @@ packages: resolution: {integrity: sha512-3LEEcj3PVW8pW2R1SR1M89g/qrYk/m/mB/tLqn7dn4sbBUQyTqnlod+II2U4dqiGtUmkcnAmkMDralTFZttRiw==} engines: {node: '>=6.9.0'} + '@babel/generator@7.25.5': + resolution: {integrity: sha512-abd43wyLfbWoxC6ahM8xTkqLpGB2iWBVyuKC9/srhFunCd1SDNrV1s72bBpK4hLj8KLzHBBcOblvLQZBNw9r3w==} + engines: {node: '>=6.9.0'} + '@babel/helper-annotate-as-pure@7.24.7': resolution: {integrity: sha512-BaDeOonYvhdKw+JoMVkAixAAJzG2jVPIwWoKBPdYuY9b452e2rPuI9QPYh3KpofZ3pW2akOmwZLOiOsHMiqRAg==} engines: {node: '>=6.9.0'} @@ -782,6 +790,12 @@ packages: peerDependencies: '@babel/core': ^7.0.0 + '@babel/helper-create-class-features-plugin@7.25.4': + resolution: {integrity: sha512-ro/bFs3/84MDgDmMwbcHgDa8/E6J3QKNTk4xJJnVeFtGE+tL0K26E3pNxhYz2b67fJpt7Aphw5XcploKXuCvCQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/helper-create-regexp-features-plugin@7.25.2': resolution: {integrity: sha512-+wqVGP+DFmqwFD3EH6TMTfUNeqDehV3E/dl+Sd54eaXqm17tEUNbEIn4sVivVowbvUpOtIGxdo3GoXyDH9N/9g==} engines: {node: '>=6.9.0'} @@ -864,6 +878,11 @@ packages: engines: {node: '>=6.0.0'} hasBin: true + '@babel/parser@7.25.4': + resolution: {integrity: sha512-nq+eWrOgdtu3jG5Os4TQP3x3cLA8hR8TvJNjD8vnPa20WGycimcparWnLK4jJhElTK6SDyuJo1weMKO/5LpmLA==} + engines: {node: '>=6.0.0'} + hasBin: true + '@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.25.3': resolution: {integrity: sha512-wUrcsxZg6rqBXG05HG1FPYgsP6EvwF4WpBbxIpWIIYnH8wG0gzx3yZY3dtEHas4sTAOGkbTsc9EGPxwff8lRoA==} engines: {node: '>=6.9.0'} @@ -1019,8 +1038,8 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/plugin-transform-async-generator-functions@7.25.0': - resolution: {integrity: sha512-uaIi2FdqzjpAMvVqvB51S42oC2JEVgh0LDsGfZVDysWE8LrJtQC2jvKmOqEYThKyB7bDEb7BP1GYWDm7tABA0Q==} + '@babel/plugin-transform-async-generator-functions@7.25.4': + resolution: {integrity: sha512-jz8cV2XDDTqjKPwVPJBIjORVEmSGYhdRa8e5k5+vN+uwcjSrSxUaebBRa4ko1jqNF2uxyg8G6XYk30Jv285xzg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 @@ -1043,8 +1062,8 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/plugin-transform-class-properties@7.24.7': - resolution: {integrity: sha512-vKbfawVYayKcSeSR5YYzzyXvsDFWU2mD8U5TFeXtbCPLFUqe7GyCgvO6XDHzje862ODrOwy6WCPmKeWHbCFJ4w==} + '@babel/plugin-transform-class-properties@7.25.4': + resolution: {integrity: sha512-nZeZHyCWPfjkdU5pA/uHiTaDAFUEqkpzf1YoQT2NeSynCGYq9rxfyI3XpQbfx/a0hSnFH6TGlEXvae5Vi7GD8g==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 @@ -1055,8 +1074,8 @@ packages: peerDependencies: '@babel/core': ^7.12.0 - '@babel/plugin-transform-classes@7.25.0': - resolution: {integrity: sha512-xyi6qjr/fYU304fiRwFbekzkqVJZ6A7hOjWZd+89FVcBqPV3S9Wuozz82xdpLspckeaafntbzglaW4pqpzvtSw==} + '@babel/plugin-transform-classes@7.25.4': + resolution: {integrity: sha512-oexUfaQle2pF/b6E0dwsxQtAol9TLSO88kQvym6HHBWFliV2lGdrPieX+WgMRLSJDVzdYywk7jXbLPuO2KLTLg==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 @@ -1223,8 +1242,8 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/plugin-transform-private-methods@7.24.7': - resolution: {integrity: sha512-COTCOkG2hn4JKGEKBADkA8WNb35TGkkRbI5iT845dB+NyqgO8Hn+ajPbSnIQznneJTa3d30scb6iz/DhH8GsJQ==} + '@babel/plugin-transform-private-methods@7.25.4': + resolution: {integrity: sha512-ao8BG7E2b/URaUQGqN3Tlsg+M3KlHY6rJ1O1gXAEUnZoyNQnvKyH87Kfg+FoxSeyWUB8ISZZsC91C44ZuBFytw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 @@ -1307,8 +1326,8 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 - '@babel/plugin-transform-unicode-sets-regex@7.24.7': - resolution: {integrity: sha512-2G8aAvF4wy1w/AGZkemprdGMRg5o6zPNhbHVImRz3lss55TYCBd6xStN19rt8XJHq20sqV0JbyWjOWwQRwV/wg==} + '@babel/plugin-transform-unicode-sets-regex@7.25.4': + resolution: {integrity: sha512-qesBxiWkgN1Q+31xUE9RcMk79eOXXDCv6tfyGMRSs4RGlioSg2WVyQAm07k726cSE56pa+Kb0y9epX2qaXzTvA==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0 @@ -1319,6 +1338,12 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/preset-env@7.25.4': + resolution: {integrity: sha512-W9Gyo+KmcxjGahtt3t9fb14vFRWvPpu5pT6GBlovAK6BTBcxgjfVMSQCfJl4oi35ODrxP6xx2Wr8LNST57Mraw==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/preset-modules@0.1.6-no-external-plugins': resolution: {integrity: sha512-HrcgcIESLm9aIR842yhJ5RWan/gebQUJ6E/E5+rf0y9o6oj7w0Br+sWuL6kEQ/o/AdfvR1Je9jG18/gnpwjEyA==} peerDependencies: @@ -1337,6 +1362,10 @@ packages: resolution: {integrity: sha512-7dRy4DwXwtzBrPbZflqxnvfxLF8kdZXPkhymtDeFoFqE6ldzjQFgYTtYIFARcLEYDrqfBfYcZt1WqFxRoyC9Rw==} engines: {node: '>=6.9.0'} + '@babel/runtime@7.25.4': + resolution: {integrity: sha512-DSgLeL/FNcpXuzav5wfYvHCGvynXkJbn3Zvc3823AEe9nPwW9IK4UoCSS5yGymmQzN0pCPvivtgS6/8U2kkm1w==} + engines: {node: '>=6.9.0'} + '@babel/template@7.25.0': resolution: {integrity: sha512-aOOgh1/5XzKvg1jvVz7AVrx2piJ2XBi227DHmbY6y+bM9H2FlN+IfecYu4Xl0cNiiVejlsCri89LUsbj8vJD9Q==} engines: {node: '>=6.9.0'} @@ -1345,10 +1374,18 @@ packages: resolution: {integrity: sha512-HefgyP1x754oGCsKmV5reSmtV7IXj/kpaE1XYY+D9G5PvKKoFfSbiS4M77MdjuwlZKDIKFCffq9rPU+H/s3ZdQ==} engines: {node: '>=6.9.0'} + '@babel/traverse@7.25.4': + resolution: {integrity: sha512-VJ4XsrD+nOvlXyLzmLzUs/0qjFS4sK30te5yEFlvbbUNEgKaVb2BHZUpAL+ttLPQAHNrsI3zZisbfha5Cvr8vg==} + engines: {node: '>=6.9.0'} + '@babel/types@7.25.2': resolution: {integrity: sha512-YTnYtra7W9e6/oAZEHj0bJehPRUlLH9/fbpT5LfB0NhQXyALCRkRs3zH9v07IYhkgpqX6Z78FnuccZr/l4Fs4Q==} engines: {node: '>=6.9.0'} + '@babel/types@7.25.4': + resolution: {integrity: sha512-zQ1ijeeCXVEh+aNL0RlmkPkG8HUiDcU2pzQQFjtbntgAczRASFzj4H+6+bV+dy1ntKR14I/DypeuRG1uma98iQ==} + engines: {node: '>=6.9.0'} + '@bcherny/json-schema-ref-parser@10.0.5-fork': resolution: {integrity: sha512-E/jKbPoca1tfUPj3iSbitDZTGnq6FUFjkH6L8U2oDwSuwK1WhnnVtCG7oFOTg/DDnyoXbQYUiUiGOibHqaGVnw==} engines: {node: '>= 16'} @@ -1443,6 +1480,10 @@ packages: resolution: {integrity: sha512-ylAwnIdxBMJ9v6BHpFAQFZM+5zbybLtqVQJG7zQePts4e0/Qr2xjYFbC3F+fovZqyXPIx24BR+S6gFJNO1OdAw==} engines: {node: '>=18'} + '@cspell/cspell-bundled-dicts@8.13.3': + resolution: {integrity: sha512-OfCxUBMyayxKyeDaUZG3LQpiyH8MFUbg9nbIZCGh2x8U6N0fHaP9uR6R+gPzdi/bJp32Kr+RC/Yebojd+AQCGA==} + engines: {node: '>=18'} + '@cspell/cspell-json-reporter@8.13.1': resolution: {integrity: sha512-vYZTBRkYjpNBifGNbYQsgIXesDEdUa9QAwllDcLZGKbhh5mY/C1ygPnAVpYDYiJNt1WCeIqW286DUyjRjkmHeA==} engines: {node: '>=18'} @@ -1451,18 +1492,34 @@ packages: resolution: {integrity: sha512-acLWTQv3yWfeWXMds/cfQKZapslOrLHVL4VDp4rFyL/EnfgaCr7Ew9hQ7zAIARY3r/n0dByqWbOt2HKthdhx/g==} engines: {node: '>=18'} + '@cspell/cspell-pipe@8.13.3': + resolution: {integrity: sha512-6a9Zd+fDltgXoJ0fosWqEMx0UdXBXZ7iakhslMNPRmv7GhVAoHBoIXzMVilOE4kYT2Mh/9NM/QW/NbNEpneZIQ==} + engines: {node: '>=18'} + '@cspell/cspell-resolver@8.13.1': resolution: {integrity: sha512-EGdb7KLYCklV3sLxf/895b7s6sExh8DCHZFpDos2hjKwMt+F4ynsu1+ceybQtqoUF/MsyLoJXrrmPvV2uGVmUQ==} engines: {node: '>=18'} + '@cspell/cspell-resolver@8.13.3': + resolution: {integrity: sha512-vlwtMTEWsPPtWfktzT75eGQ0n+0M+9kN+89eSvUUYdCfvY9XAS6z+bTmhS2ULJgntgWtX6gUjABQK0PYYVedOg==} + engines: {node: '>=18'} + '@cspell/cspell-service-bus@8.13.1': resolution: {integrity: sha512-oLFJfxuB1rwGXn3eD5qSF9nf0lHu6YjO0JcrjWhAZQ0r3AsO97gsX50wwCFCw6szVU3rd1cTUktW0KYEZUY6dA==} engines: {node: '>=18'} + '@cspell/cspell-service-bus@8.13.3': + resolution: {integrity: sha512-mFkeWXwGQSDxRiN6Kez77GaMNGNgG7T6o9UE42jyXEgf/bLJTpefbUy4fY5pU3p2mA0eoMzmnJX8l+TC5YJpbA==} + engines: {node: '>=18'} + '@cspell/cspell-types@8.13.1': resolution: {integrity: sha512-9dJdmyXLXJVesCJa/DWgwKsEC9p2RRFc6KORcLhNvtm1tE9TvCXiu5jV47sOmYXd6Hwan8IurBXXTz82CLVjPQ==} engines: {node: '>=18'} + '@cspell/cspell-types@8.13.3': + resolution: {integrity: sha512-lA5GbhLOL6FlKCWNMbooRFgNGfTsM6NJnHz60+EEN7XD9OgpFc7w+MBcK4aHsVCxcrIvnejIc8xQDqPnrdmN3w==} + engines: {node: '>=18'} + '@cspell/dict-ada@4.0.2': resolution: {integrity: sha512-0kENOWQeHjUlfyId/aCM/mKXtkEgV0Zu2RhUXCBr4hHo9F9vph+Uu8Ww2b0i5a4ZixoIkudGA+eJvyxrG1jUpA==} @@ -1478,6 +1535,9 @@ packages: '@cspell/dict-cpp@5.1.12': resolution: {integrity: sha512-6lXLOFIa+k/qBcu0bjaE/Kc6v3sh9VhsDOXD1Dalm3zgd0QIMjp5XBmkpSdCAK3pWCPV0Se7ysVLDfCea1BuXg==} + '@cspell/dict-cpp@5.1.15': + resolution: {integrity: sha512-5X8SouN/qIUrBTcDEevnKU6G3cRSm3Vm7dQEcjHaptIWp+/2YMknIfYbnhKeR1G9V/sbQaY4CVsVAKEaehY+7Q==} + '@cspell/dict-cryptocurrencies@5.0.0': resolution: {integrity: sha512-Z4ARIw5+bvmShL+4ZrhDzGhnc9znaAGHOEMaB/GURdS/jdoreEDY34wdN0NtdLHDO5KO7GduZnZyqGdRoiSmYA==} @@ -1487,6 +1547,9 @@ packages: '@cspell/dict-css@4.0.12': resolution: {integrity: sha512-vGBgPM92MkHQF5/2jsWcnaahOZ+C6OE/fPvd5ScBP72oFY9tn5GLuomcyO0z8vWCr2e0nUSX1OGimPtcQAlvSw==} + '@cspell/dict-css@4.0.13': + resolution: {integrity: sha512-WfOQkqlAJTo8eIQeztaH0N0P+iF5hsJVKFuhy4jmARPISy8Efcv8QXk2/IVbmjJH0/ZV7dKRdnY5JFVXuVz37g==} + '@cspell/dict-dart@2.0.3': resolution: {integrity: sha512-cLkwo1KT5CJY5N5RJVHks2genFkNCl/WLfj+0fFjqNR+tk3tBI1LY7ldr9piCtSFSm4x9pO1x6IV3kRUY1lLiw==} @@ -1502,6 +1565,9 @@ packages: '@cspell/dict-dotnet@5.0.2': resolution: {integrity: sha512-UD/pO2A2zia/YZJ8Kck/F6YyDSpCMq0YvItpd4YbtDVzPREfTZ48FjZsbYi4Jhzwfvc6o8R56JusAE58P+4sNQ==} + '@cspell/dict-dotnet@5.0.3': + resolution: {integrity: sha512-q8+b8YWYv+9Q+AbU3mH/RHE9aovhCuGtMuNSsx+YnTofEhVQkJR3vdrYjhOBg3epIiZVUS83VP0vxPLPa+UTug==} + '@cspell/dict-elixir@4.0.3': resolution: {integrity: sha512-g+uKLWvOp9IEZvrIvBPTr/oaO6619uH/wyqypqvwpmnmpjcfi8+/hqZH8YNKt15oviK8k4CkINIqNhyndG9d9Q==} @@ -1532,6 +1598,9 @@ packages: '@cspell/dict-git@3.0.0': resolution: {integrity: sha512-simGS/lIiXbEaqJu9E2VPoYW1OTC2xrwPPXNXFMa2uo/50av56qOuaxDrZ5eH1LidFXwoc8HROCHYeKoNrDLSw==} + '@cspell/dict-golang@6.0.11': + resolution: {integrity: sha512-BMFIDGh1HaFUe1cYBT1dotqyIQG2j3VkNntGQTBa/7i0aBnC5PBJDiAXnUeBHi0AVrz0hyAc7xtcK5KyKCEzwg==} + '@cspell/dict-golang@6.0.9': resolution: {integrity: sha512-etDt2WQauyEQDA+qPS5QtkYTb2I9l5IfQftAllVoB1aOrT6bxxpHvMEpJ0Hsn/vezxrCqa/BmtUbRxllIxIuSg==} @@ -1586,9 +1655,15 @@ packages: '@cspell/dict-public-licenses@2.0.7': resolution: {integrity: sha512-KlBXuGcN3LE7tQi/GEqKiDewWGGuopiAD0zRK1QilOx5Co8XAvs044gk4MNIQftc8r0nHeUI+irJKLGcR36DIQ==} + '@cspell/dict-public-licenses@2.0.8': + resolution: {integrity: sha512-Sup+tFS7cDV0fgpoKtUqEZ6+fA/H+XUgBiqQ/Fbs6vUE3WCjJHOIVsP+udHuyMH7iBfJ4UFYOYeORcY4EaKdMg==} + '@cspell/dict-python@4.2.3': resolution: {integrity: sha512-C1CPX9wwEGgcHv/p7KfjuIOp1G6KNyx5gWYweAd6/KPv+ZpeM1v572zFUTmpO8WDuAfKFf00nqYL8/GmCENWBw==} + '@cspell/dict-python@4.2.4': + resolution: {integrity: sha512-sCtLBqMreb+8zRW2bXvFsfSnRUVU6IFm4mT6Dc4xbz0YajprbaPPh/kOUTw5IJRP8Uh+FFb7Xp2iH03CNWRq/A==} + '@cspell/dict-r@2.0.1': resolution: {integrity: sha512-KCmKaeYMLm2Ip79mlYPc8p+B2uzwBp4KMkzeLd5E6jUlCL93Y5Nvq68wV5fRLDRTf7N1LvofkVFWfDcednFOgA==} @@ -1601,12 +1676,18 @@ packages: '@cspell/dict-scala@5.0.3': resolution: {integrity: sha512-4yGb4AInT99rqprxVNT9TYb1YSpq58Owzq7zi3ZS5T0u899Y4VsxsBiOgHnQ/4W+ygi+sp+oqef8w8nABR2lkg==} + '@cspell/dict-software-terms@4.0.10': + resolution: {integrity: sha512-FwFwPnTlzyjtndCxUnaVHk7wYpWRC4EqY9/Q5q2pROKt1rQILRmutjIqzHLH6WX9sb/+wVNb7UKwKO32eflp4g==} + '@cspell/dict-software-terms@4.0.4': resolution: {integrity: sha512-AHr3Wxa4pxbpKgxhyQseBmoJhdyeraeRGdQn0e8YD5pz4J6Mu47MLzKysasDKWK/yzmHQfwAsb2zm2k+ItMEUw==} '@cspell/dict-sql@2.1.4': resolution: {integrity: sha512-wsrNK6UBQ92IzQ4SqQqgM04BEYzqVsk3qZH3ZgascaqDtUgK6GI+z3Czi0rQ+9Qe2zKiklGnGMC8sJwYdlIw7g==} + '@cspell/dict-sql@2.1.5': + resolution: {integrity: sha512-FmxanytHXss7GAWAXmgaxl3icTCW7YxlimyOSPNfm+njqeUDjw3kEv4mFNDDObBJv8Ec5AWCbUDkWIpkE3IpKg==} + '@cspell/dict-svelte@1.0.2': resolution: {integrity: sha512-rPJmnn/GsDs0btNvrRBciOhngKV98yZ9SHmg8qI6HLS8hZKvcXc0LMsf9LLuMK1TmS2+WQFAan6qeqg6bBxL2Q==} @@ -1626,8 +1707,12 @@ packages: resolution: {integrity: sha512-jMqJHWmQy+in99JMSFlaGV9P033gCx7DCZvGO/ZSeZ2EatrUTanJk3oTG1TZknZydb0nnxr1mgTWXN7PCAAXDg==} engines: {node: '>=18.0'} - '@cspell/eslint-plugin@8.13.1': - resolution: {integrity: sha512-rn/9wrKj3dytuMzdqh29eBSicyzuMLUf7h4iNQn3ivl9YiwpLr6ShiRX4uS5Mid9wbcY6sgutWNAYqMl5/vqzg==} + '@cspell/dynamic-import@8.13.3': + resolution: {integrity: sha512-YN83CFWnMkt9B0q0RBadfEoptUaDRqBikh8b91MOQ0haEnUo6t57j4jAaLnbIEP4ynzMhgruWFKpIC/QaEtCuA==} + engines: {node: '>=18.0'} + + '@cspell/eslint-plugin@8.13.3': + resolution: {integrity: sha512-wb4+WoirtqP4ijcLhCXWbgfE94ggU9D+ENMjTldBNABjcoDse1UyPIR1gSM/oNAAOLaSLtXbeOx7tnWuurjVaQ==} engines: {node: '>=18'} peerDependencies: eslint: ^7 || ^8 || ^9 @@ -1636,10 +1721,18 @@ packages: resolution: {integrity: sha512-ga1ibI9ZLJWNszfP7e6qQ8gnoQOP9rE/clALMAim9ssO6cmMhEEm+i1ROH4nsDfThd6sVlUJ0IOtx5dEqPmWxw==} engines: {node: '>=18'} + '@cspell/strong-weak-map@8.13.3': + resolution: {integrity: sha512-/QYUEthesPuDarOHa6kcWKJmVq0HIotjPrmAWQ5QpH+dDik1Qin4G/9QdnWX75ueR4DC4WFjBNBU14C4TVSwHQ==} + engines: {node: '>=18'} + '@cspell/url@8.13.1': resolution: {integrity: sha512-cCyojz5ovgGCexhez2urle4Q1UOEsp96lvl4pDmWNDHa/6n8dqiIn60SVzQIsAHzJ4yEV077RSaIrTlq/T+oSQ==} engines: {node: '>=18.0'} + '@cspell/url@8.13.3': + resolution: {integrity: sha512-hsxoTnZHwtdR2x9QEE6yfDBB1LUwAj67o1GyKTvI8A2OE/AfzAttirZs+9sxgOGWoBdTOxM9sMLtqB3SxtDB3A==} + engines: {node: '>=18.0'} + '@cypress/code-coverage@3.12.44': resolution: {integrity: sha512-5Eau3tnJqZJo1OddOOEMyWs1HCwlAOgDs1rFPaCXJ4a5Y2BR4PH4fAzCdMvIqpBnCiVSL8gOYv6JfND3aUuJJQ==} peerDependencies: @@ -2725,8 +2818,8 @@ packages: '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} - '@typescript-eslint/eslint-plugin@8.0.0': - resolution: {integrity: sha512-STIZdwEQRXAHvNUS6ILDf5z3u95Gc8jzywunxSNqX00OooIemaaNIA0vEgynJlycL5AjabYLLrIyHd4iazyvtg==} + '@typescript-eslint/eslint-plugin@8.0.1': + resolution: {integrity: sha512-5g3Y7GDFsJAnY4Yhvk8sZtFfV6YNF2caLzjrRPUBzewjPCaj0yokePB4LJSobyCzGMzjZZYFbwuzbfDHlimXbQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: '@typescript-eslint/parser': ^8.0.0 || ^8.0.0-alpha.0 @@ -2736,8 +2829,8 @@ packages: typescript: optional: true - '@typescript-eslint/parser@8.0.0': - resolution: {integrity: sha512-pS1hdZ+vnrpDIxuFXYQpLTILglTjSYJ9MbetZctrUawogUsPdz31DIIRZ9+rab0LhYNTsk88w4fIzVheiTbWOQ==} + '@typescript-eslint/parser@8.0.1': + resolution: {integrity: sha512-5IgYJ9EO/12pOUwiBKFkpU7rS3IU21mtXzB81TNwq2xEybcmAZrE9qwDtsb5uQd9aVO9o0fdabFyAmKveXyujg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 @@ -2750,8 +2843,12 @@ packages: resolution: {integrity: sha512-V0aa9Csx/ZWWv2IPgTfY7T4agYwJyILESu/PVqFtTFz9RIS823mAze+NbnBI8xiwdX3iqeQbcTYlvB04G9wyQw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} - '@typescript-eslint/type-utils@8.0.0': - resolution: {integrity: sha512-mJAFP2mZLTBwAn5WI4PMakpywfWFH5nQZezUQdSKV23Pqo6o9iShQg1hP2+0hJJXP2LnZkWPphdIq4juYYwCeg==} + '@typescript-eslint/scope-manager@8.0.1': + resolution: {integrity: sha512-NpixInP5dm7uukMiRyiHjRKkom5RIFA4dfiHvalanD2cF0CLUuQqxfg8PtEUo9yqJI2bBhF+pcSafqnG3UBnRQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/type-utils@8.0.1': + resolution: {integrity: sha512-+/UT25MWvXeDX9YaHv1IS6KI1fiuTto43WprE7pgSMswHbn1Jm9GEM4Txp+X74ifOWV8emu2AWcbLhpJAvD5Ng==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -2763,6 +2860,10 @@ packages: resolution: {integrity: sha512-wgdSGs9BTMWQ7ooeHtu5quddKKs5Z5dS+fHLbrQI+ID0XWJLODGMHRfhwImiHoeO2S5Wir2yXuadJN6/l4JRxw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/types@8.0.1': + resolution: {integrity: sha512-PpqTVT3yCA/bIgJ12czBuE3iBlM3g4inRSC5J0QOdQFAn07TYrYEQBBKgXH1lQpglup+Zy6c1fxuwTk4MTNKIw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/typescript-estree@8.0.0': resolution: {integrity: sha512-5b97WpKMX+Y43YKi4zVcCVLtK5F98dFls3Oxui8LbnmRsseKenbbDinmvxrWegKDMmlkIq/XHuyy0UGLtpCDKg==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -2772,16 +2873,35 @@ packages: typescript: optional: true + '@typescript-eslint/typescript-estree@8.0.1': + resolution: {integrity: sha512-8V9hriRvZQXPWU3bbiUV4Epo7EvgM6RTs+sUmxp5G//dBGy402S7Fx0W0QkB2fb4obCF8SInoUzvTYtc3bkb5w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + '@typescript-eslint/utils@8.0.0': resolution: {integrity: sha512-k/oS/A/3QeGLRvOWCg6/9rATJL5rec7/5s1YmdS0ZU6LHveJyGFwBvLhSRBv6i9xaj7etmosp+l+ViN1I9Aj/Q==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: eslint: ^8.57.0 || ^9.0.0 + '@typescript-eslint/utils@8.0.1': + resolution: {integrity: sha512-CBFR0G0sCt0+fzfnKaciu9IBsKvEKYwN9UZ+eeogK1fYHg4Qxk1yf/wLQkLXlq8wbU2dFlgAesxt8Gi76E8RTA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 + '@typescript-eslint/visitor-keys@8.0.0': resolution: {integrity: sha512-oN0K4nkHuOyF3PVMyETbpP5zp6wfyOvm7tWhTMfoqxSSsPmJIh6JNASuZDlODE8eE+0EB9uar+6+vxr9DBTYOA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@typescript-eslint/visitor-keys@8.0.1': + resolution: {integrity: sha512-W5E+o0UfUcK5EgchLZsyVWqARmsM7v54/qEq6PY3YI5arkgmCzHiuk0zKSJJbm71V0xdRna4BGomkCTXz2/LkQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@unocss/astro@0.59.4': resolution: {integrity: sha512-DU3OR5MMR1Uvvec4/wB9EetDASHRg19Moy6z/MiIhn8JWJ0QzWYgSeJcfUX8exomMYv6WUEQJL+CyLI34Wmn8w==} peerDependencies: @@ -3331,6 +3451,9 @@ packages: async@3.2.5: resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} + async@3.2.6: + resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==} + asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} @@ -3781,6 +3904,10 @@ packages: resolution: {integrity: sha512-E5AjpSW+O+N5T2GsOQMHLLsJvrYw6G/AFt9GvU6NguEAfzKShh7hRiLtVo6S9KbRpFMGqE5ojo0/hE+sdteWvQ==} engines: {node: '>= 6'} + comment-json@4.2.5: + resolution: {integrity: sha512-bKw/r35jR3HGt5PEPm1ljsQQGyCrR8sFGNiN5L+ykDHdpO8Smxkrkla9Yi6NkQyUrb8V54PGhfMs6NrIwtxtdw==} + engines: {node: '>= 6'} + comment-parser@1.4.1: resolution: {integrity: sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==} engines: {node: '>= 12.0.0'} @@ -3858,6 +3985,9 @@ packages: core-js-compat@3.38.0: resolution: {integrity: sha512-75LAicdLa4OJVwFxFbQR3NdnZjNgX6ILpVcVzcC4T2smerB5lELMrJQQQoWV6TiuC/vlaFqgU2tKQx9w5s0e0A==} + core-js-compat@3.38.1: + resolution: {integrity: sha512-JRH6gfXxGmrzF3tZ57lFx97YARxCXPaMzPo6jELZhv88pBH5VXpQ+y0znKGlFnzuaihqhLbefxSJxWJMPtfDzw==} + core-util-is@1.0.2: resolution: {integrity: sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==} @@ -3913,10 +4043,18 @@ packages: resolution: {integrity: sha512-sXUFOyxvk+qDkoQdFkVEqj1hfQWzMi+tbi6ksiotQaqpm7r+YitZLSgwJjN4xgDO/rTLyP70k9fagdZ67MVZbw==} engines: {node: '>=18'} + cspell-config-lib@8.13.3: + resolution: {integrity: sha512-dzVdar8Kenwxho0PnUxOxwjUvyFYn6Q9mQAMHcQNXQrvo32bdpoF+oNtWC/5FfrQgUgyl19CVQ607bRigYWoOQ==} + engines: {node: '>=18'} + cspell-dictionary@8.13.1: resolution: {integrity: sha512-Z0T4J4ahOJaHmWq83w24KXGik1zeauO5WvDRyzDyaSgpbA5MN2hN98LvxaIx72g3I+trtRK77XFcKginuME9EA==} engines: {node: '>=18'} + cspell-dictionary@8.13.3: + resolution: {integrity: sha512-DQ3Tee7LIoy+9Mu52ht32O/MNBZ6i4iUeSTY2sMDDwogno3361BLRyfEjyiYNo3Fqf0Pcnt5MqY2DqIhrF/H/Q==} + engines: {node: '>=18'} + cspell-gitignore@8.13.1: resolution: {integrity: sha512-XyZ3X5d6x0gkWtNXSAQRcPMG41bEdLx9cTgZCYCJhEZCesU1VpNm60F3oc11dMLkO+BqPH3An+AO/YEIiaje3A==} engines: {node: '>=18'} @@ -3926,23 +4064,44 @@ packages: resolution: {integrity: sha512-rW1A3t7YvPXxcC4z1pp1m9coeWzUVUmRjUw3vMNGlEDC2zecB39KKbEqesziBqnBceNAY7O5itllIGFKr03vqA==} engines: {node: '>=18'} + cspell-glob@8.13.3: + resolution: {integrity: sha512-+jGIMYyKDLmoOJIxNPXRdI7utcvw+9FMSmj1ApIdEff5dCkehi0gtzK4H7orXGYEvRdKQvfaXiyduVi79rXsZQ==} + engines: {node: '>=18'} + cspell-grammar@8.13.1: resolution: {integrity: sha512-HUkd24bulvBwee1UNBurxGlPUOiywb9pB34iXXoxFWuloHohZ/DuFlE8B/31ZtjW48ffEYIu3QZfWhcnD8e81w==} engines: {node: '>=18'} hasBin: true + cspell-grammar@8.13.3: + resolution: {integrity: sha512-xPSgKk9HY5EsI8lkMPC9hiZCeAUs+RY/IVliUBW1xEicAJhP4RZIGRdIwtDNNJGwKfNXazjqYhcS4LS0q7xPAQ==} + engines: {node: '>=18'} + hasBin: true + cspell-io@8.13.1: resolution: {integrity: sha512-t2sgZuWGBzPSOAStfvz/U3KoFEfDxEt1cXZj0Kd0Vs36v2uoLktm6ihMe7XNFu7zIdOFSajsYQ8Bi4RSLPGPxQ==} engines: {node: '>=18'} + cspell-io@8.13.3: + resolution: {integrity: sha512-AeMIkz7+4VuJaPKO/v1pUpyUSOOTyLOAfzeTRRAXEt+KRKOUe36MyUmBMza6gzNcX2yD04VgJukRL408TY9ntw==} + engines: {node: '>=18'} + cspell-lib@8.13.1: resolution: {integrity: sha512-H1HHG1pmATSeAaY0KmQ0xnkbSqJLvh9QpXWARDLWKUBvtE+/l44H4yVhIp/No3rM7PKMmb82GuSJzMaoIhHFLQ==} engines: {node: '>=18'} + cspell-lib@8.13.3: + resolution: {integrity: sha512-aEqxIILeqDtNoCa47/oSl5c926b50ue3PobYs4usn0Ymf0434RopCP+DCGsF7BPtog4j4XWnEmvkcJs57DYWDg==} + engines: {node: '>=18'} + cspell-trie-lib@8.13.1: resolution: {integrity: sha512-2moCsIYDmMT7hp5Non3CvWatfXptFWCuxjbXQGDNvWJ2Cj3oso/oBe4802GJv5GEenv9QBWmEtum/E7rFcx4JA==} engines: {node: '>=18'} + cspell-trie-lib@8.13.3: + resolution: {integrity: sha512-Z0iLGi9HI+Vf+WhVVeru6dYgQdtaYCKWRlc1SayLfAZhw9BcjrXL8KTXDfAfv/lUgnRu6xwP1isLlDNZECsKVQ==} + engines: {node: '>=18'} + cspell@8.13.1: resolution: {integrity: sha512-Bqppilpwx9xt3jZPaYcqe1JPteNmfKhx9pw9YglZEePDUzdiJQNVIfs31589GAnXjgdqqctR8N87ffLcaBNPXw==} engines: {node: '>=18'} @@ -4572,8 +4731,8 @@ packages: peerDependencies: eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 - eslint-plugin-json@4.0.0: - resolution: {integrity: sha512-l/P3WTzl2HI8PbwsbDIrZ+6jvwQI4TGuz20ReJkG3Y+gZS5ZurTgx+gBmuLpOgiqMyDJWyJ7+GCjevWtNYQcUg==} + eslint-plugin-json@4.0.1: + resolution: {integrity: sha512-3An5ISV5dq/kHfXdNyY5TUe2ONC3yXFSkLX2gu+W8xAhKhfvrRvkSAeKXCxZqZ0KJLX15ojBuLPyj+UikQMkOA==} engines: {node: '>=18.0'} eslint-plugin-lodash@8.0.0: @@ -5362,6 +5521,10 @@ packages: resolution: {integrity: sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==} engines: {node: '>= 4'} + ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} + engines: {node: '>= 4'} + import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} engines: {node: '>=6'} @@ -6385,6 +6548,10 @@ packages: resolution: {integrity: sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==} engines: {node: '>=8.6'} + micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + mime-db@1.52.0: resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} engines: {node: '>= 0.6'} @@ -7845,6 +8012,11 @@ packages: engines: {node: '>=10'} hasBin: true + terser@5.31.6: + resolution: {integrity: sha512-PQ4DAriWzKj+qgehQ7LK5bQqCFNMmlhjR2PFFLuqGCpuCAauxemVBWwWOxo3UIwWQx8+Pr61Df++r76wDmkQBg==} + engines: {node: '>=10'} + hasBin: true + test-exclude@6.0.0: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} @@ -7963,6 +8135,9 @@ packages: tslib@2.6.3: resolution: {integrity: sha512-xNvxJEOUiWPGhUuUdQgAJPKOOJfGnIyKySOc09XkKsgdUV/3E2zvwZYdejjmRgPCgcym1juLH3226yA7sEFJKQ==} + tslib@2.7.0: + resolution: {integrity: sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==} + tsx@4.16.5: resolution: {integrity: sha512-ArsiAQHEW2iGaqZ8fTA1nX0a+lN5mNTyuGRRO6OW3H/Yno1y9/t1f9YOI1Cfoqz63VAthn++ZYcbDP7jPflc+A==} engines: {node: '>=18.0.0'} @@ -8048,8 +8223,8 @@ packages: peerDependencies: typescript: 4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x - typescript-eslint@8.0.0: - resolution: {integrity: sha512-yQWBJutWL1PmpmDddIOl9/Mi6vZjqNCjqSGBMQ4vsc2Aiodk0SnbQQWPXbSy0HNuKCuGkw1+u4aQ2mO40TdhDQ==} + typescript-eslint@8.0.1: + resolution: {integrity: sha512-V3Y+MdfhawxEjE16dWpb7/IOgeXnLwAEEkS7v8oDqNcR1oYlqWhGH/iHqHdKVdpWme1VPZ0SoywXAkCqawj2eQ==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} peerDependencies: typescript: '*' @@ -9161,6 +9336,8 @@ snapshots: '@babel/compat-data@7.25.2': {} + '@babel/compat-data@7.25.4': {} + '@babel/core@7.25.2': dependencies: '@ampproject/remapping': 2.3.0 @@ -9188,14 +9365,21 @@ snapshots: '@jridgewell/trace-mapping': 0.3.25 jsesc: 2.5.2 + '@babel/generator@7.25.5': + dependencies: + '@babel/types': 7.25.4 + '@jridgewell/gen-mapping': 0.3.5 + '@jridgewell/trace-mapping': 0.3.25 + jsesc: 2.5.2 + '@babel/helper-annotate-as-pure@7.24.7': dependencies: '@babel/types': 7.25.2 '@babel/helper-builder-binary-assignment-operator-visitor@7.24.7': dependencies: - '@babel/traverse': 7.25.3 - '@babel/types': 7.25.2 + '@babel/traverse': 7.25.4 + '@babel/types': 7.25.4 transitivePeerDependencies: - supports-color @@ -9220,6 +9404,19 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-create-class-features-plugin@7.25.4(@babel/core@7.25.2)': + dependencies: + '@babel/core': 7.25.2 + '@babel/helper-annotate-as-pure': 7.24.7 + '@babel/helper-member-expression-to-functions': 7.24.8 + '@babel/helper-optimise-call-expression': 7.24.7 + '@babel/helper-replace-supers': 7.25.0(@babel/core@7.25.2) + '@babel/helper-skip-transparent-expression-wrappers': 7.24.7 + '@babel/traverse': 7.25.4 + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + '@babel/helper-create-regexp-features-plugin@7.25.2(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 @@ -9273,7 +9470,7 @@ snapshots: '@babel/core': 7.25.2 '@babel/helper-annotate-as-pure': 7.24.7 '@babel/helper-wrap-function': 7.25.0 - '@babel/traverse': 7.25.3 + '@babel/traverse': 7.25.4 transitivePeerDependencies: - supports-color @@ -9309,8 +9506,8 @@ snapshots: '@babel/helper-wrap-function@7.25.0': dependencies: '@babel/template': 7.25.0 - '@babel/traverse': 7.25.3 - '@babel/types': 7.25.2 + '@babel/traverse': 7.25.4 + '@babel/types': 7.25.4 transitivePeerDependencies: - supports-color @@ -9330,11 +9527,15 @@ snapshots: dependencies: '@babel/types': 7.25.2 + '@babel/parser@7.25.4': + dependencies: + '@babel/types': 7.25.4 + '@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.25.3(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/traverse': 7.25.3 + '@babel/traverse': 7.25.4 transitivePeerDependencies: - supports-color @@ -9361,7 +9562,7 @@ snapshots: dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/traverse': 7.25.3 + '@babel/traverse': 7.25.4 transitivePeerDependencies: - supports-color @@ -9480,13 +9681,13 @@ snapshots: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/plugin-transform-async-generator-functions@7.25.0(@babel/core@7.25.2)': + '@babel/plugin-transform-async-generator-functions@7.25.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 '@babel/helper-remap-async-to-generator': 7.25.0(@babel/core@7.25.2) '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.25.2) - '@babel/traverse': 7.25.3 + '@babel/traverse': 7.25.4 transitivePeerDependencies: - supports-color @@ -9509,10 +9710,10 @@ snapshots: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/plugin-transform-class-properties@7.24.7(@babel/core@7.25.2)': + '@babel/plugin-transform-class-properties@7.25.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 - '@babel/helper-create-class-features-plugin': 7.25.0(@babel/core@7.25.2) + '@babel/helper-create-class-features-plugin': 7.25.4(@babel/core@7.25.2) '@babel/helper-plugin-utils': 7.24.8 transitivePeerDependencies: - supports-color @@ -9520,20 +9721,20 @@ snapshots: '@babel/plugin-transform-class-static-block@7.24.7(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 - '@babel/helper-create-class-features-plugin': 7.25.0(@babel/core@7.25.2) + '@babel/helper-create-class-features-plugin': 7.25.4(@babel/core@7.25.2) '@babel/helper-plugin-utils': 7.24.8 '@babel/plugin-syntax-class-static-block': 7.14.5(@babel/core@7.25.2) transitivePeerDependencies: - supports-color - '@babel/plugin-transform-classes@7.25.0(@babel/core@7.25.2)': + '@babel/plugin-transform-classes@7.25.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-annotate-as-pure': 7.24.7 '@babel/helper-compilation-targets': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 '@babel/helper-replace-supers': 7.25.0(@babel/core@7.25.2) - '@babel/traverse': 7.25.3 + '@babel/traverse': 7.25.4 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -9599,7 +9800,7 @@ snapshots: '@babel/core': 7.25.2 '@babel/helper-compilation-targets': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/traverse': 7.25.3 + '@babel/traverse': 7.25.4 transitivePeerDependencies: - supports-color @@ -9648,7 +9849,7 @@ snapshots: '@babel/helper-module-transforms': 7.25.2(@babel/core@7.25.2) '@babel/helper-plugin-utils': 7.24.8 '@babel/helper-validator-identifier': 7.24.7 - '@babel/traverse': 7.25.3 + '@babel/traverse': 7.25.4 transitivePeerDependencies: - supports-color @@ -9719,10 +9920,10 @@ snapshots: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/plugin-transform-private-methods@7.24.7(@babel/core@7.25.2)': + '@babel/plugin-transform-private-methods@7.25.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 - '@babel/helper-create-class-features-plugin': 7.25.0(@babel/core@7.25.2) + '@babel/helper-create-class-features-plugin': 7.25.4(@babel/core@7.25.2) '@babel/helper-plugin-utils': 7.24.8 transitivePeerDependencies: - supports-color @@ -9731,7 +9932,7 @@ snapshots: dependencies: '@babel/core': 7.25.2 '@babel/helper-annotate-as-pure': 7.24.7 - '@babel/helper-create-class-features-plugin': 7.25.0(@babel/core@7.25.2) + '@babel/helper-create-class-features-plugin': 7.25.4(@babel/core@7.25.2) '@babel/helper-plugin-utils': 7.24.8 '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/core@7.25.2) transitivePeerDependencies: @@ -9809,7 +10010,7 @@ snapshots: '@babel/helper-create-regexp-features-plugin': 7.25.2(@babel/core@7.25.2) '@babel/helper-plugin-utils': 7.24.8 - '@babel/plugin-transform-unicode-sets-regex@7.24.7(@babel/core@7.25.2)': + '@babel/plugin-transform-unicode-sets-regex@7.25.4(@babel/core@7.25.2)': dependencies: '@babel/core': 7.25.2 '@babel/helper-create-regexp-features-plugin': 7.25.2(@babel/core@7.25.2) @@ -9817,7 +10018,7 @@ snapshots: '@babel/preset-env@7.25.3(@babel/core@7.25.2)': dependencies: - '@babel/compat-data': 7.25.2 + '@babel/compat-data': 7.25.4 '@babel/core': 7.25.2 '@babel/helper-compilation-targets': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 @@ -9847,13 +10048,13 @@ snapshots: '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.25.2) '@babel/plugin-syntax-unicode-sets-regex': 7.18.6(@babel/core@7.25.2) '@babel/plugin-transform-arrow-functions': 7.24.7(@babel/core@7.25.2) - '@babel/plugin-transform-async-generator-functions': 7.25.0(@babel/core@7.25.2) + '@babel/plugin-transform-async-generator-functions': 7.25.4(@babel/core@7.25.2) '@babel/plugin-transform-async-to-generator': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-block-scoped-functions': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-block-scoping': 7.25.0(@babel/core@7.25.2) - '@babel/plugin-transform-class-properties': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-class-properties': 7.25.4(@babel/core@7.25.2) '@babel/plugin-transform-class-static-block': 7.24.7(@babel/core@7.25.2) - '@babel/plugin-transform-classes': 7.25.0(@babel/core@7.25.2) + '@babel/plugin-transform-classes': 7.25.4(@babel/core@7.25.2) '@babel/plugin-transform-computed-properties': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-destructuring': 7.24.8(@babel/core@7.25.2) '@babel/plugin-transform-dotall-regex': 7.24.7(@babel/core@7.25.2) @@ -9881,7 +10082,7 @@ snapshots: '@babel/plugin-transform-optional-catch-binding': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-optional-chaining': 7.24.8(@babel/core@7.25.2) '@babel/plugin-transform-parameters': 7.24.7(@babel/core@7.25.2) - '@babel/plugin-transform-private-methods': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-private-methods': 7.25.4(@babel/core@7.25.2) '@babel/plugin-transform-private-property-in-object': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-property-literals': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-regenerator': 7.24.7(@babel/core@7.25.2) @@ -9894,12 +10095,101 @@ snapshots: '@babel/plugin-transform-unicode-escapes': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-unicode-property-regex': 7.24.7(@babel/core@7.25.2) '@babel/plugin-transform-unicode-regex': 7.24.7(@babel/core@7.25.2) - '@babel/plugin-transform-unicode-sets-regex': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-unicode-sets-regex': 7.25.4(@babel/core@7.25.2) '@babel/preset-modules': 0.1.6-no-external-plugins(@babel/core@7.25.2) babel-plugin-polyfill-corejs2: 0.4.11(@babel/core@7.25.2) babel-plugin-polyfill-corejs3: 0.10.6(@babel/core@7.25.2) babel-plugin-polyfill-regenerator: 0.6.2(@babel/core@7.25.2) - core-js-compat: 3.38.0 + core-js-compat: 3.38.1 + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + + '@babel/preset-env@7.25.4(@babel/core@7.25.2)': + dependencies: + '@babel/compat-data': 7.25.4 + '@babel/core': 7.25.2 + '@babel/helper-compilation-targets': 7.25.2 + '@babel/helper-plugin-utils': 7.24.8 + '@babel/helper-validator-option': 7.24.8 + '@babel/plugin-bugfix-firefox-class-in-computed-class-key': 7.25.3(@babel/core@7.25.2) + '@babel/plugin-bugfix-safari-class-field-initializer-scope': 7.25.0(@babel/core@7.25.2) + '@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression': 7.25.0(@babel/core@7.25.2) + '@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly': 7.25.0(@babel/core@7.25.2) + '@babel/plugin-proposal-private-property-in-object': 7.21.0-placeholder-for-preset-env.2(@babel/core@7.25.2) + '@babel/plugin-syntax-async-generators': 7.8.4(@babel/core@7.25.2) + '@babel/plugin-syntax-class-properties': 7.12.13(@babel/core@7.25.2) + '@babel/plugin-syntax-class-static-block': 7.14.5(@babel/core@7.25.2) + '@babel/plugin-syntax-dynamic-import': 7.8.3(@babel/core@7.25.2) + '@babel/plugin-syntax-export-namespace-from': 7.8.3(@babel/core@7.25.2) + '@babel/plugin-syntax-import-assertions': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-syntax-import-attributes': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-syntax-import-meta': 7.10.4(@babel/core@7.25.2) + '@babel/plugin-syntax-json-strings': 7.8.3(@babel/core@7.25.2) + '@babel/plugin-syntax-logical-assignment-operators': 7.10.4(@babel/core@7.25.2) + '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3(@babel/core@7.25.2) + '@babel/plugin-syntax-numeric-separator': 7.10.4(@babel/core@7.25.2) + '@babel/plugin-syntax-object-rest-spread': 7.8.3(@babel/core@7.25.2) + '@babel/plugin-syntax-optional-catch-binding': 7.8.3(@babel/core@7.25.2) + '@babel/plugin-syntax-optional-chaining': 7.8.3(@babel/core@7.25.2) + '@babel/plugin-syntax-private-property-in-object': 7.14.5(@babel/core@7.25.2) + '@babel/plugin-syntax-top-level-await': 7.14.5(@babel/core@7.25.2) + '@babel/plugin-syntax-unicode-sets-regex': 7.18.6(@babel/core@7.25.2) + '@babel/plugin-transform-arrow-functions': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-async-generator-functions': 7.25.4(@babel/core@7.25.2) + '@babel/plugin-transform-async-to-generator': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-block-scoped-functions': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-block-scoping': 7.25.0(@babel/core@7.25.2) + '@babel/plugin-transform-class-properties': 7.25.4(@babel/core@7.25.2) + '@babel/plugin-transform-class-static-block': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-classes': 7.25.4(@babel/core@7.25.2) + '@babel/plugin-transform-computed-properties': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-destructuring': 7.24.8(@babel/core@7.25.2) + '@babel/plugin-transform-dotall-regex': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-duplicate-keys': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-duplicate-named-capturing-groups-regex': 7.25.0(@babel/core@7.25.2) + '@babel/plugin-transform-dynamic-import': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-exponentiation-operator': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-export-namespace-from': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-for-of': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-function-name': 7.25.1(@babel/core@7.25.2) + '@babel/plugin-transform-json-strings': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-literals': 7.25.2(@babel/core@7.25.2) + '@babel/plugin-transform-logical-assignment-operators': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-member-expression-literals': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-modules-amd': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-modules-commonjs': 7.24.8(@babel/core@7.25.2) + '@babel/plugin-transform-modules-systemjs': 7.25.0(@babel/core@7.25.2) + '@babel/plugin-transform-modules-umd': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-named-capturing-groups-regex': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-new-target': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-nullish-coalescing-operator': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-numeric-separator': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-object-rest-spread': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-object-super': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-optional-catch-binding': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-optional-chaining': 7.24.8(@babel/core@7.25.2) + '@babel/plugin-transform-parameters': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-private-methods': 7.25.4(@babel/core@7.25.2) + '@babel/plugin-transform-private-property-in-object': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-property-literals': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-regenerator': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-reserved-words': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-shorthand-properties': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-spread': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-sticky-regex': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-template-literals': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-typeof-symbol': 7.24.8(@babel/core@7.25.2) + '@babel/plugin-transform-unicode-escapes': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-unicode-property-regex': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-unicode-regex': 7.24.7(@babel/core@7.25.2) + '@babel/plugin-transform-unicode-sets-regex': 7.25.4(@babel/core@7.25.2) + '@babel/preset-modules': 0.1.6-no-external-plugins(@babel/core@7.25.2) + babel-plugin-polyfill-corejs2: 0.4.11(@babel/core@7.25.2) + babel-plugin-polyfill-corejs3: 0.10.6(@babel/core@7.25.2) + babel-plugin-polyfill-regenerator: 0.6.2(@babel/core@7.25.2) + core-js-compat: 3.38.1 semver: 6.3.1 transitivePeerDependencies: - supports-color @@ -9908,7 +10198,7 @@ snapshots: dependencies: '@babel/core': 7.25.2 '@babel/helper-plugin-utils': 7.24.8 - '@babel/types': 7.25.2 + '@babel/types': 7.25.4 esutils: 2.0.3 '@babel/preset-typescript@7.24.7(@babel/core@7.25.2)': @@ -9928,6 +10218,10 @@ snapshots: dependencies: regenerator-runtime: 0.14.1 + '@babel/runtime@7.25.4': + dependencies: + regenerator-runtime: 0.14.1 + '@babel/template@7.25.0': dependencies: '@babel/code-frame': 7.24.7 @@ -9946,12 +10240,30 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/traverse@7.25.4': + dependencies: + '@babel/code-frame': 7.24.7 + '@babel/generator': 7.25.5 + '@babel/parser': 7.25.4 + '@babel/template': 7.25.0 + '@babel/types': 7.25.4 + debug: 4.3.6(supports-color@8.1.1) + globals: 11.12.0 + transitivePeerDependencies: + - supports-color + '@babel/types@7.25.2': dependencies: '@babel/helper-string-parser': 7.24.8 '@babel/helper-validator-identifier': 7.24.7 to-fast-properties: 2.0.0 + '@babel/types@7.25.4': + dependencies: + '@babel/helper-string-parser': 7.24.8 + '@babel/helper-validator-identifier': 7.24.7 + to-fast-properties: 2.0.0 + '@bcherny/json-schema-ref-parser@10.0.5-fork': dependencies: '@jsdevtools/ono': 7.1.3 @@ -10209,20 +10521,85 @@ snapshots: '@cspell/dict-typescript': 3.1.6 '@cspell/dict-vue': 3.0.0 + '@cspell/cspell-bundled-dicts@8.13.3': + dependencies: + '@cspell/dict-ada': 4.0.2 + '@cspell/dict-aws': 4.0.3 + '@cspell/dict-bash': 4.1.3 + '@cspell/dict-companies': 3.1.4 + '@cspell/dict-cpp': 5.1.15 + '@cspell/dict-cryptocurrencies': 5.0.0 + '@cspell/dict-csharp': 4.0.2 + '@cspell/dict-css': 4.0.13 + '@cspell/dict-dart': 2.0.3 + '@cspell/dict-django': 4.1.0 + '@cspell/dict-docker': 1.1.7 + '@cspell/dict-dotnet': 5.0.3 + '@cspell/dict-elixir': 4.0.3 + '@cspell/dict-en-common-misspellings': 2.0.4 + '@cspell/dict-en-gb': 1.1.33 + '@cspell/dict-en_us': 4.3.23 + '@cspell/dict-filetypes': 3.0.4 + '@cspell/dict-fonts': 4.0.0 + '@cspell/dict-fsharp': 1.0.1 + '@cspell/dict-fullstack': 3.2.0 + '@cspell/dict-gaming-terms': 1.0.5 + '@cspell/dict-git': 3.0.0 + '@cspell/dict-golang': 6.0.11 + '@cspell/dict-google': 1.0.1 + '@cspell/dict-haskell': 4.0.1 + '@cspell/dict-html': 4.0.5 + '@cspell/dict-html-symbol-entities': 4.0.0 + '@cspell/dict-java': 5.0.7 + '@cspell/dict-julia': 1.0.1 + '@cspell/dict-k8s': 1.0.6 + '@cspell/dict-latex': 4.0.0 + '@cspell/dict-lorem-ipsum': 4.0.0 + '@cspell/dict-lua': 4.0.3 + '@cspell/dict-makefile': 1.0.0 + '@cspell/dict-monkeyc': 1.0.6 + '@cspell/dict-node': 5.0.1 + '@cspell/dict-npm': 5.0.18 + '@cspell/dict-php': 4.0.8 + '@cspell/dict-powershell': 5.0.5 + '@cspell/dict-public-licenses': 2.0.8 + '@cspell/dict-python': 4.2.4 + '@cspell/dict-r': 2.0.1 + '@cspell/dict-ruby': 5.0.2 + '@cspell/dict-rust': 4.0.5 + '@cspell/dict-scala': 5.0.3 + '@cspell/dict-software-terms': 4.0.10 + '@cspell/dict-sql': 2.1.5 + '@cspell/dict-svelte': 1.0.2 + '@cspell/dict-swift': 2.0.1 + '@cspell/dict-terraform': 1.0.0 + '@cspell/dict-typescript': 3.1.6 + '@cspell/dict-vue': 3.0.0 + '@cspell/cspell-json-reporter@8.13.1': dependencies: '@cspell/cspell-types': 8.13.1 '@cspell/cspell-pipe@8.13.1': {} + '@cspell/cspell-pipe@8.13.3': {} + '@cspell/cspell-resolver@8.13.1': dependencies: global-directory: 4.0.1 + '@cspell/cspell-resolver@8.13.3': + dependencies: + global-directory: 4.0.1 + '@cspell/cspell-service-bus@8.13.1': {} + '@cspell/cspell-service-bus@8.13.3': {} + '@cspell/cspell-types@8.13.1': {} + '@cspell/cspell-types@8.13.3': {} + '@cspell/dict-ada@4.0.2': {} '@cspell/dict-aws@4.0.3': {} @@ -10233,12 +10610,16 @@ snapshots: '@cspell/dict-cpp@5.1.12': {} + '@cspell/dict-cpp@5.1.15': {} + '@cspell/dict-cryptocurrencies@5.0.0': {} '@cspell/dict-csharp@4.0.2': {} '@cspell/dict-css@4.0.12': {} + '@cspell/dict-css@4.0.13': {} + '@cspell/dict-dart@2.0.3': {} '@cspell/dict-data-science@2.0.1': {} @@ -10249,6 +10630,8 @@ snapshots: '@cspell/dict-dotnet@5.0.2': {} + '@cspell/dict-dotnet@5.0.3': {} + '@cspell/dict-elixir@4.0.3': {} '@cspell/dict-en-common-misspellings@2.0.4': {} @@ -10269,6 +10652,8 @@ snapshots: '@cspell/dict-git@3.0.0': {} + '@cspell/dict-golang@6.0.11': {} + '@cspell/dict-golang@6.0.9': {} '@cspell/dict-google@1.0.1': {} @@ -10305,10 +10690,16 @@ snapshots: '@cspell/dict-public-licenses@2.0.7': {} + '@cspell/dict-public-licenses@2.0.8': {} + '@cspell/dict-python@4.2.3': dependencies: '@cspell/dict-data-science': 2.0.1 + '@cspell/dict-python@4.2.4': + dependencies: + '@cspell/dict-data-science': 2.0.1 + '@cspell/dict-r@2.0.1': {} '@cspell/dict-ruby@5.0.2': {} @@ -10317,10 +10708,14 @@ snapshots: '@cspell/dict-scala@5.0.3': {} + '@cspell/dict-software-terms@4.0.10': {} + '@cspell/dict-software-terms@4.0.4': {} '@cspell/dict-sql@2.1.4': {} + '@cspell/dict-sql@2.1.5': {} + '@cspell/dict-svelte@1.0.2': {} '@cspell/dict-swift@2.0.1': {} @@ -10335,18 +10730,26 @@ snapshots: dependencies: import-meta-resolve: 4.1.0 - '@cspell/eslint-plugin@8.13.1(eslint@9.8.0)': + '@cspell/dynamic-import@8.13.3': dependencies: - '@cspell/cspell-types': 8.13.1 - '@cspell/url': 8.13.1 - cspell-lib: 8.13.1 + import-meta-resolve: 4.1.0 + + '@cspell/eslint-plugin@8.13.3(eslint@9.8.0)': + dependencies: + '@cspell/cspell-types': 8.13.3 + '@cspell/url': 8.13.3 + cspell-lib: 8.13.3 eslint: 9.8.0 synckit: 0.9.1 '@cspell/strong-weak-map@8.13.1': {} + '@cspell/strong-weak-map@8.13.3': {} + '@cspell/url@8.13.1': {} + '@cspell/url@8.13.3': {} + '@cypress/code-coverage@3.12.44(@babel/core@7.25.2)(@babel/preset-env@7.25.3(@babel/core@7.25.2))(babel-loader@9.1.3(@babel/core@7.25.2)(webpack@5.93.0(esbuild@0.21.5)))(cypress@13.13.2)(webpack@5.93.0(esbuild@0.21.5))': dependencies: '@babel/core': 7.25.2 @@ -10434,7 +10837,7 @@ snapshots: '@emnapi/runtime@1.2.0': dependencies: - tslib: 2.6.3 + tslib: 2.7.0 optional: true '@es-joy/jsdoccomment@0.46.0': @@ -10978,18 +11381,18 @@ snapshots: dependencies: serialize-javascript: 6.0.2 smob: 1.5.0 - terser: 5.31.3 + terser: 5.31.6 optionalDependencies: rollup: 2.79.1 - '@rollup/plugin-typescript@11.1.6(rollup@4.20.0)(tslib@2.6.3)(typescript@5.4.5)': + '@rollup/plugin-typescript@11.1.6(rollup@4.20.0)(tslib@2.7.0)(typescript@5.4.5)': dependencies: '@rollup/pluginutils': 5.1.0(rollup@4.20.0) resolve: 1.22.8 typescript: 5.4.5 optionalDependencies: rollup: 4.20.0 - tslib: 2.6.3 + tslib: 2.7.0 '@rollup/pluginutils@3.1.0(rollup@2.79.1)': dependencies: @@ -11527,17 +11930,17 @@ snapshots: '@types/node': 20.14.14 optional: true - '@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5)': + '@typescript-eslint/eslint-plugin@8.0.1(@typescript-eslint/parser@8.0.1(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5)': dependencies: '@eslint-community/regexpp': 4.11.0 - '@typescript-eslint/parser': 8.0.0(eslint@9.8.0)(typescript@5.4.5) - '@typescript-eslint/scope-manager': 8.0.0 - '@typescript-eslint/type-utils': 8.0.0(eslint@9.8.0)(typescript@5.4.5) - '@typescript-eslint/utils': 8.0.0(eslint@9.8.0)(typescript@5.4.5) - '@typescript-eslint/visitor-keys': 8.0.0 + '@typescript-eslint/parser': 8.0.1(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/scope-manager': 8.0.1 + '@typescript-eslint/type-utils': 8.0.1(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/utils': 8.0.1(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/visitor-keys': 8.0.1 eslint: 9.8.0 graphemer: 1.4.0 - ignore: 5.3.1 + ignore: 5.3.2 natural-compare: 1.4.0 ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: @@ -11545,12 +11948,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5)': + '@typescript-eslint/parser@8.0.1(eslint@9.8.0)(typescript@5.4.5)': dependencies: - '@typescript-eslint/scope-manager': 8.0.0 - '@typescript-eslint/types': 8.0.0 - '@typescript-eslint/typescript-estree': 8.0.0(typescript@5.4.5) - '@typescript-eslint/visitor-keys': 8.0.0 + '@typescript-eslint/scope-manager': 8.0.1 + '@typescript-eslint/types': 8.0.1 + '@typescript-eslint/typescript-estree': 8.0.1(typescript@5.4.5) + '@typescript-eslint/visitor-keys': 8.0.1 debug: 4.3.6(supports-color@8.1.1) eslint: 9.8.0 optionalDependencies: @@ -11563,10 +11966,15 @@ snapshots: '@typescript-eslint/types': 8.0.0 '@typescript-eslint/visitor-keys': 8.0.0 - '@typescript-eslint/type-utils@8.0.0(eslint@9.8.0)(typescript@5.4.5)': + '@typescript-eslint/scope-manager@8.0.1': dependencies: - '@typescript-eslint/typescript-estree': 8.0.0(typescript@5.4.5) - '@typescript-eslint/utils': 8.0.0(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/types': 8.0.1 + '@typescript-eslint/visitor-keys': 8.0.1 + + '@typescript-eslint/type-utils@8.0.1(eslint@9.8.0)(typescript@5.4.5)': + dependencies: + '@typescript-eslint/typescript-estree': 8.0.1(typescript@5.4.5) + '@typescript-eslint/utils': 8.0.1(eslint@9.8.0)(typescript@5.4.5) debug: 4.3.6(supports-color@8.1.1) ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: @@ -11577,6 +11985,8 @@ snapshots: '@typescript-eslint/types@8.0.0': {} + '@typescript-eslint/types@8.0.1': {} + '@typescript-eslint/typescript-estree@8.0.0(typescript@5.4.5)': dependencies: '@typescript-eslint/types': 8.0.0 @@ -11592,6 +12002,21 @@ snapshots: transitivePeerDependencies: - supports-color + '@typescript-eslint/typescript-estree@8.0.1(typescript@5.4.5)': + dependencies: + '@typescript-eslint/types': 8.0.1 + '@typescript-eslint/visitor-keys': 8.0.1 + debug: 4.3.6(supports-color@8.1.1) + globby: 11.1.0 + is-glob: 4.0.3 + minimatch: 9.0.5 + semver: 7.6.3 + ts-api-utils: 1.3.0(typescript@5.4.5) + optionalDependencies: + typescript: 5.4.5 + transitivePeerDependencies: + - supports-color + '@typescript-eslint/utils@8.0.0(eslint@9.8.0)(typescript@5.4.5)': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.8.0) @@ -11603,18 +12028,34 @@ snapshots: - supports-color - typescript + '@typescript-eslint/utils@8.0.1(eslint@9.8.0)(typescript@5.4.5)': + dependencies: + '@eslint-community/eslint-utils': 4.4.0(eslint@9.8.0) + '@typescript-eslint/scope-manager': 8.0.1 + '@typescript-eslint/types': 8.0.1 + '@typescript-eslint/typescript-estree': 8.0.1(typescript@5.4.5) + eslint: 9.8.0 + transitivePeerDependencies: + - supports-color + - typescript + '@typescript-eslint/visitor-keys@8.0.0': dependencies: '@typescript-eslint/types': 8.0.0 eslint-visitor-keys: 3.4.3 - '@unocss/astro@0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))': + '@typescript-eslint/visitor-keys@8.0.1': + dependencies: + '@typescript-eslint/types': 8.0.1 + eslint-visitor-keys: 3.4.3 + + '@unocss/astro@0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))': dependencies: '@unocss/core': 0.59.4 '@unocss/reset': 0.59.4 - '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) + '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6)) optionalDependencies: - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) transitivePeerDependencies: - rollup @@ -11745,7 +12186,7 @@ snapshots: dependencies: '@unocss/core': 0.59.4 - '@unocss/vite@0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))': + '@unocss/vite@0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))': dependencies: '@ampproject/remapping': 2.3.0 '@rollup/pluginutils': 5.1.0(rollup@2.79.1) @@ -11757,20 +12198,20 @@ snapshots: chokidar: 3.6.0 fast-glob: 3.3.2 magic-string: 0.30.11 - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) transitivePeerDependencies: - rollup - '@vite-pwa/vitepress@0.4.0(vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0))': + '@vite-pwa/vitepress@0.4.0(vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0))': dependencies: - vite-plugin-pwa: 0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) + vite-plugin-pwa: 0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) - '@vitejs/plugin-vue@5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(vue@3.4.35(typescript@5.4.5))': + '@vitejs/plugin-vue@5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))(vue@3.4.35(typescript@5.4.5))': dependencies: - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) vue: 3.4.35(typescript@5.4.5) - '@vitest/coverage-v8@1.6.0(vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3))': + '@vitest/coverage-v8@1.6.0(vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.6))': dependencies: '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 0.2.3 @@ -11785,7 +12226,7 @@ snapshots: std-env: 3.7.0 strip-literal: 2.1.0 test-exclude: 6.0.0 - vitest: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3) + vitest: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.6) transitivePeerDependencies: - supports-color @@ -11820,7 +12261,7 @@ snapshots: pathe: 1.1.2 picocolors: 1.0.1 sirv: 2.0.4 - vitest: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3) + vitest: 1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.6) '@vitest/utils@1.6.0': dependencies: @@ -12315,6 +12756,8 @@ snapshots: async@3.2.5: {} + async@3.2.6: {} + asynckit@0.4.0: {} at-least-node@1.0.0: {} @@ -12385,7 +12828,7 @@ snapshots: babel-plugin-polyfill-corejs2@0.4.11(@babel/core@7.25.2): dependencies: - '@babel/compat-data': 7.25.2 + '@babel/compat-data': 7.25.4 '@babel/core': 7.25.2 '@babel/helper-define-polyfill-provider': 0.6.2(@babel/core@7.25.2) semver: 6.3.1 @@ -12396,7 +12839,7 @@ snapshots: dependencies: '@babel/core': 7.25.2 '@babel/helper-define-polyfill-provider': 0.6.2(@babel/core@7.25.2) - core-js-compat: 3.38.0 + core-js-compat: 3.38.1 transitivePeerDependencies: - supports-color @@ -12823,6 +13266,14 @@ snapshots: has-own-prop: 2.0.0 repeat-string: 1.6.1 + comment-json@4.2.5: + dependencies: + array-timsort: 1.0.3 + core-util-is: 1.0.3 + esprima: 4.0.1 + has-own-prop: 2.0.0 + repeat-string: 1.6.1 + comment-parser@1.4.1: {} common-path-prefix@3.0.0: {} @@ -12896,6 +13347,10 @@ snapshots: dependencies: browserslist: 4.23.3 + core-js-compat@3.38.1: + dependencies: + browserslist: 4.23.3 + core-util-is@1.0.2: {} core-util-is@1.0.3: {} @@ -12978,6 +13433,12 @@ snapshots: comment-json: 4.2.4 yaml: 2.5.0 + cspell-config-lib@8.13.3: + dependencies: + '@cspell/cspell-types': 8.13.3 + comment-json: 4.2.5 + yaml: 2.5.0 + cspell-dictionary@8.13.1: dependencies: '@cspell/cspell-pipe': 8.13.1 @@ -12985,6 +13446,13 @@ snapshots: cspell-trie-lib: 8.13.1 fast-equals: 5.0.1 + cspell-dictionary@8.13.3: + dependencies: + '@cspell/cspell-pipe': 8.13.3 + '@cspell/cspell-types': 8.13.3 + cspell-trie-lib: 8.13.3 + fast-equals: 5.0.1 + cspell-gitignore@8.13.1: dependencies: '@cspell/url': 8.13.1 @@ -12997,16 +13465,31 @@ snapshots: '@cspell/url': 8.13.1 micromatch: 4.0.7 + cspell-glob@8.13.3: + dependencies: + '@cspell/url': 8.13.3 + micromatch: 4.0.8 + cspell-grammar@8.13.1: dependencies: '@cspell/cspell-pipe': 8.13.1 '@cspell/cspell-types': 8.13.1 + cspell-grammar@8.13.3: + dependencies: + '@cspell/cspell-pipe': 8.13.3 + '@cspell/cspell-types': 8.13.3 + cspell-io@8.13.1: dependencies: '@cspell/cspell-service-bus': 8.13.1 '@cspell/url': 8.13.1 + cspell-io@8.13.3: + dependencies: + '@cspell/cspell-service-bus': 8.13.3 + '@cspell/url': 8.13.3 + cspell-lib@8.13.1: dependencies: '@cspell/cspell-bundled-dicts': 8.13.1 @@ -13033,12 +13516,44 @@ snapshots: vscode-uri: 3.0.8 xdg-basedir: 5.1.0 + cspell-lib@8.13.3: + dependencies: + '@cspell/cspell-bundled-dicts': 8.13.3 + '@cspell/cspell-pipe': 8.13.3 + '@cspell/cspell-resolver': 8.13.3 + '@cspell/cspell-types': 8.13.3 + '@cspell/dynamic-import': 8.13.3 + '@cspell/strong-weak-map': 8.13.3 + '@cspell/url': 8.13.3 + clear-module: 4.1.2 + comment-json: 4.2.5 + cspell-config-lib: 8.13.3 + cspell-dictionary: 8.13.3 + cspell-glob: 8.13.3 + cspell-grammar: 8.13.3 + cspell-io: 8.13.3 + cspell-trie-lib: 8.13.3 + env-paths: 3.0.0 + fast-equals: 5.0.1 + gensequence: 7.0.0 + import-fresh: 3.3.0 + resolve-from: 5.0.0 + vscode-languageserver-textdocument: 1.0.12 + vscode-uri: 3.0.8 + xdg-basedir: 5.1.0 + cspell-trie-lib@8.13.1: dependencies: '@cspell/cspell-pipe': 8.13.1 '@cspell/cspell-types': 8.13.1 gensequence: 7.0.0 + cspell-trie-lib@8.13.3: + dependencies: + '@cspell/cspell-pipe': 8.13.3 + '@cspell/cspell-types': 8.13.3 + gensequence: 7.0.0 + cspell@8.13.1: dependencies: '@cspell/cspell-json-reporter': 8.13.1 @@ -13730,12 +14245,12 @@ snapshots: dependencies: htmlparser2: 9.1.0 - eslint-plugin-jest@28.7.0(@typescript-eslint/eslint-plugin@8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(jest@29.7.0(@types/node@20.14.14))(typescript@5.4.5): + eslint-plugin-jest@28.7.0(@typescript-eslint/eslint-plugin@8.0.1(@typescript-eslint/parser@8.0.1(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(jest@29.7.0(@types/node@20.14.14))(typescript@5.4.5): dependencies: '@typescript-eslint/utils': 8.0.0(eslint@9.8.0)(typescript@5.4.5) eslint: 9.8.0 optionalDependencies: - '@typescript-eslint/eslint-plugin': 8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/eslint-plugin': 8.0.1(@typescript-eslint/parser@8.0.1(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5) jest: 29.7.0(@types/node@20.14.14) transitivePeerDependencies: - supports-color @@ -13758,7 +14273,7 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-json@4.0.0: + eslint-plugin-json@4.0.1: dependencies: lodash: 4.17.21 vscode-json-languageservice: 4.2.1 @@ -14102,7 +14617,7 @@ snapshots: proxy-addr: 2.0.7 rfdc: 1.4.1 secure-json-parse: 2.7.0 - semver: 7.6.3 + semver: 7.6.2 tiny-lru: 8.0.2 transitivePeerDependencies: - supports-color @@ -14482,7 +14997,7 @@ snapshots: dependencies: dir-glob: 3.0.1 fast-glob: 3.3.2 - ignore: 5.3.1 + ignore: 5.3.2 merge2: 1.4.1 slash: 4.0.0 @@ -14715,6 +15230,8 @@ snapshots: ignore@5.3.1: {} + ignore@5.3.2: {} + import-fresh@3.3.0: dependencies: parent-module: 1.0.1 @@ -15013,7 +15530,7 @@ snapshots: jake@10.9.2: dependencies: - async: 3.2.5 + async: 3.2.6 chalk: 4.1.2 filelist: 1.0.4 minimatch: 3.1.2 @@ -16121,6 +16638,11 @@ snapshots: braces: 3.0.3 picomatch: 2.3.1 + micromatch@4.0.8: + dependencies: + braces: 3.0.3 + picomatch: 2.3.1 + mime-db@1.52.0: {} mime-db@1.53.0: {} @@ -16848,7 +17370,7 @@ snapshots: regenerator-transform@0.15.2: dependencies: - '@babel/runtime': 7.25.0 + '@babel/runtime': 7.25.4 regexp-tree@0.1.27: {} @@ -17592,7 +18114,7 @@ snapshots: synckit@0.9.1: dependencies: '@pkgr/core': 0.1.1 - tslib: 2.6.3 + tslib: 2.7.0 tabbable@6.2.0: {} @@ -17679,6 +18201,13 @@ snapshots: commander: 2.20.3 source-map-support: 0.5.21 + terser@5.31.6: + dependencies: + '@jridgewell/source-map': 0.3.6 + acorn: 8.12.1 + commander: 2.20.3 + source-map-support: 0.5.21 + test-exclude@6.0.0: dependencies: '@istanbuljs/schema': 0.1.3 @@ -17773,6 +18302,8 @@ snapshots: tslib@2.6.3: {} + tslib@2.7.0: {} + tsx@4.16.5: dependencies: esbuild: 0.21.5 @@ -17862,11 +18393,11 @@ snapshots: shiki: 0.14.7 typescript: 5.4.5 - typescript-eslint@8.0.0(eslint@9.8.0)(typescript@5.4.5): + typescript-eslint@8.0.1(eslint@9.8.0)(typescript@5.4.5): dependencies: - '@typescript-eslint/eslint-plugin': 8.0.0(@typescript-eslint/parser@8.0.0(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5) - '@typescript-eslint/parser': 8.0.0(eslint@9.8.0)(typescript@5.4.5) - '@typescript-eslint/utils': 8.0.0(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/eslint-plugin': 8.0.1(@typescript-eslint/parser@8.0.1(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/parser': 8.0.1(eslint@9.8.0)(typescript@5.4.5) + '@typescript-eslint/utils': 8.0.1(eslint@9.8.0)(typescript@5.4.5) optionalDependencies: typescript: 5.4.5 transitivePeerDependencies: @@ -17970,9 +18501,9 @@ snapshots: universalify@2.0.1: {} - unocss@0.59.4(postcss@8.4.40)(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)): + unocss@0.59.4(postcss@8.4.40)(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6)): dependencies: - '@unocss/astro': 0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)) + '@unocss/astro': 0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6)) '@unocss/cli': 0.59.4(rollup@2.79.1) '@unocss/core': 0.59.4 '@unocss/extractor-arbitrary-variants': 0.59.4 @@ -17991,9 +18522,9 @@ snapshots: '@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.3.5(@types/node@20.14.14)(terser@5.31.3)) + '@unocss/vite': 0.59.4(rollup@2.79.1)(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6)) optionalDependencies: - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) transitivePeerDependencies: - postcss - rollup @@ -18001,7 +18532,7 @@ snapshots: unpipe@1.0.0: {} - unplugin-vue-components@0.26.0(@babel/parser@7.25.3)(rollup@2.79.1)(vue@3.4.35(typescript@5.4.5)): + unplugin-vue-components@0.26.0(@babel/parser@7.25.4)(rollup@2.79.1)(vue@3.4.35(typescript@5.4.5)): dependencies: '@antfu/utils': 0.7.10 '@rollup/pluginutils': 5.1.0(rollup@2.79.1) @@ -18015,7 +18546,7 @@ snapshots: unplugin: 1.12.0 vue: 3.4.35(typescript@5.4.5) optionalDependencies: - '@babel/parser': 7.25.3 + '@babel/parser': 7.25.4 transitivePeerDependencies: - rollup - supports-color @@ -18084,13 +18615,13 @@ snapshots: unist-util-stringify-position: 4.0.0 vfile-message: 4.0.2 - vite-node@1.6.0(@types/node@20.14.14)(terser@5.31.3): + vite-node@1.6.0(@types/node@20.14.14)(terser@5.31.6): dependencies: cac: 6.7.14 debug: 4.3.6(supports-color@8.1.1) pathe: 1.1.2 picocolors: 1.0.1 - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) transitivePeerDependencies: - '@types/node' - less @@ -18101,7 +18632,7 @@ snapshots: - supports-color - terser - vite-plugin-istanbul@6.0.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3)): + vite-plugin-istanbul@6.0.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6)): dependencies: '@istanbuljs/load-nyc-config': 1.1.0 espree: 10.1.0 @@ -18109,22 +18640,22 @@ snapshots: picocolors: 1.0.1 source-map: 0.7.4 test-exclude: 6.0.0 - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) transitivePeerDependencies: - supports-color - vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0): + vite-plugin-pwa@0.19.8(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0): dependencies: debug: 4.3.6(supports-color@8.1.1) fast-glob: 3.3.2 pretty-bytes: 6.1.1 - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) workbox-build: 7.1.1(@types/babel__core@7.20.5) workbox-window: 7.1.0 transitivePeerDependencies: - supports-color - vite@5.3.5(@types/node@20.14.14)(terser@5.31.3): + vite@5.3.5(@types/node@20.14.14)(terser@5.31.6): dependencies: esbuild: 0.21.5 postcss: 8.4.40 @@ -18132,26 +18663,26 @@ snapshots: optionalDependencies: '@types/node': 20.14.14 fsevents: 2.3.3 - terser: 5.31.3 + terser: 5.31.6 - vitepress-plugin-search@1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5))(vue@3.4.35(typescript@5.4.5)): + vitepress-plugin-search@1.0.4-alpha.22(flexsearch@0.7.43)(vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.6)(typescript@5.4.5))(vue@3.4.35(typescript@5.4.5)): dependencies: '@types/flexsearch': 0.7.6 '@types/markdown-it': 12.2.3 flexsearch: 0.7.43 glob-to-regexp: 0.4.1 markdown-it: 13.0.2 - vitepress: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5) + vitepress: 1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.6)(typescript@5.4.5) vue: 3.4.35(typescript@5.4.5) - vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.3)(typescript@5.4.5): + vitepress@1.1.4(@algolia/client-search@4.24.0)(@types/node@20.14.14)(axios@1.7.3)(postcss@8.4.40)(search-insights@2.15.0)(terser@5.31.6)(typescript@5.4.5): dependencies: '@docsearch/css': 3.6.1 '@docsearch/js': 3.6.1(@algolia/client-search@4.24.0)(search-insights@2.15.0) '@shikijs/core': 1.12.1 '@shikijs/transformers': 1.12.1 '@types/markdown-it': 14.1.2 - '@vitejs/plugin-vue': 5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.3))(vue@3.4.35(typescript@5.4.5)) + '@vitejs/plugin-vue': 5.1.2(vite@5.3.5(@types/node@20.14.14)(terser@5.31.6))(vue@3.4.35(typescript@5.4.5)) '@vue/devtools-api': 7.3.7 '@vueuse/core': 10.11.0(vue@3.4.35(typescript@5.4.5)) '@vueuse/integrations': 10.11.0(axios@1.7.3)(focus-trap@7.5.4)(vue@3.4.35(typescript@5.4.5)) @@ -18159,7 +18690,7 @@ snapshots: mark.js: 8.11.1 minisearch: 6.3.0 shiki: 1.12.1 - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) vue: 3.4.35(typescript@5.4.5) optionalDependencies: postcss: 8.4.40 @@ -18190,7 +18721,7 @@ snapshots: - typescript - universal-cookie - vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.3): + vitest@1.6.0(@types/node@20.14.14)(@vitest/ui@1.6.0)(jsdom@24.1.1)(terser@5.31.6): dependencies: '@vitest/expect': 1.6.0 '@vitest/runner': 1.6.0 @@ -18209,8 +18740,8 @@ snapshots: strip-literal: 2.1.0 tinybench: 2.9.0 tinypool: 0.8.4 - vite: 5.3.5(@types/node@20.14.14)(terser@5.31.3) - vite-node: 1.6.0(@types/node@20.14.14)(terser@5.31.3) + vite: 5.3.5(@types/node@20.14.14)(terser@5.31.6) + vite-node: 1.6.0(@types/node@20.14.14)(terser@5.31.6) why-is-node-running: 2.3.0 optionalDependencies: '@types/node': 20.14.14 @@ -18555,8 +19086,8 @@ snapshots: dependencies: '@apideck/better-ajv-errors': 0.3.6(ajv@8.17.1) '@babel/core': 7.25.2 - '@babel/preset-env': 7.25.3(@babel/core@7.25.2) - '@babel/runtime': 7.25.0 + '@babel/preset-env': 7.25.4(@babel/core@7.25.2) + '@babel/runtime': 7.25.4 '@rollup/plugin-babel': 5.3.1(@babel/core@7.25.2)(@types/babel__core@7.20.5)(rollup@2.79.1) '@rollup/plugin-node-resolve': 15.2.3(rollup@2.79.1) '@rollup/plugin-replace': 2.4.2(rollup@2.79.1) From 0049372b2e28c40f839db100173bf755c8384061 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 26 Aug 2024 10:25:56 +0530 Subject: [PATCH 123/124] chore: Add urlsafe to cspell --- .cspell/code-terms.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.cspell/code-terms.txt b/.cspell/code-terms.txt index 6d6dad045..d0e40e8f2 100644 --- a/.cspell/code-terms.txt +++ b/.cspell/code-terms.txt @@ -138,6 +138,7 @@ tsdoc typeof typestr unshift +urlsafe verifymethod VERIFYMTHD WARN_DOCSDIR_DOESNT_MATCH From 49a77dda3a55ae32a7b38ee3bdd7c9cf33e0ddc3 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 26 Aug 2024 05:00:41 +0000 Subject: [PATCH 124/124] [autofix.ci] apply automated fixes --- docs/ecosystem/tutorials.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ecosystem/tutorials.md b/docs/ecosystem/tutorials.md index 26498f090..6d7966c31 100644 --- a/docs/ecosystem/tutorials.md +++ b/docs/ecosystem/tutorials.md @@ -63,7 +63,7 @@ import matplotlib.pyplot as plt def mm(graph): graphbytes = graph.encode("utf8") - base64_bytes = base64.b64encode(graphbytes) + base64_bytes = base64.urlsafe_b64encode(graphbytes) base64_string = base64_bytes.decode("ascii") display(Image(url="https://mermaid.ink/img/" + base64_string))