Merge branch 'master' into develop

This commit is contained in:
ashishj 2022-04-07 21:06:04 +02:00
commit 0c5252594e
16 changed files with 740 additions and 484 deletions

View File

@ -26,24 +26,28 @@
</head>
<body>
<h1>info below</h1>
<div class="mermaid2" style="width: 100%; height: 20%;">
%%{init: { 'logLevel': 'debug', 'theme': 'neutral' } }%%
<div class="mermaid" style="width: 100%; height: 20%;">
%%{init: { "logLevel": "debug", "theme": "default" , "gitGraph" : {"showBranches":"false"},"themeVariables": {
"gitBranchLabel0": "#ff0000",
"gitBranchLabel1": "#00ff00",
"gitBranchLabel2": "#0000ff",
"git0": "#550055"
} } }%%
gitGraph
commit "Ashish"
branch newbranch
checkout newbranch
commit id:"1111"
commit tag:"test"
commit
branch develop
commit tag:"v1.0.0"
commit
checkout main
commit type: HIGHLIGHT
commit
merge newbranch
merge develop
commit
branch b2
branch featureA
commit
</div>
<div class="mermaid" style="width: 100%; height: 20%;">
<div class="mermaid2" style="width: 100%; height: 20%;">
gitGraph
commit type:HIGHLIGHT
branch hotfix
@ -101,18 +105,19 @@
// console.error('Mermaid error: ', err);
};
mermaid.initialize({
theme: 'dark',
// themeVariables: {
// primaryColor: '#9400D3',
// darkMode: true,
// background: '#222',
// // textColor: 'white',
// // primaryTextColor: '#f4f4f4',
//theme: 'dark',
themeVariables: {
commitLabelColor: '#9400D3',
commitLabelBackground: '#FFFFFF',
// darkMode: true,
// background: '#222',
// // textColor: 'white',
// // primaryTextColor: '#f4f4f4',
// // // nodeBkg: '#ff0000',
// // // mainBkg: '#0000ff',
// // // tertiaryColor: '#ffffcc',
// },
// // // nodeBkg: '#ff0000',
// // // mainBkg: '#0000ff',
// // // tertiaryColor: '#ffffcc',
},
// theme: 'forest',
// theme: 'neutral',
// theme: 'dark',

View File

@ -43,7 +43,7 @@
</div>
<div class="mermaid" style="width: 100%; height: 20%;">
%%{init: { "gitGraph": { "showBranches": false, "mainBranchName": "APA" }}}%%
%%{init: { "gitGraph": { "showBranches": true, "mainBranchName": "APA" }}}%%
gitGraph
commit
branch hotfix
@ -55,14 +55,14 @@
branch featureB
checkout featureB
commit type:HIGHLIGHT
checkout main
checkout APA
checkout hotfix
commit type:NORMAL
checkout develop
commit type:REVERSE
checkout featureB
commit
checkout main
checkout APA
merge hotfix
checkout featureB
commit
@ -80,10 +80,10 @@
branch release
checkout release
commit
checkout main
checkout APA
commit
checkout release
merge main
merge APA
checkout develop
merge release

364
dist/mermaid.core.js vendored
View File

@ -13283,24 +13283,6 @@ var config = {
*/
defaultRenderer: 'dagre-wrapper'
},
git: {
arrowMarkerAbsolute: false,
useWidth: undefined,
/**
* | Parameter | Description | Type | Required | Values |
* | ----------- | ----------- | ------- | -------- | ----------- |
* | useMaxWidth | See notes | boolean | 4 | true, false |
*
* **Notes:**
*
* When this flag is set the height and width is set to 100% and is then scaling with the
* available space if not the absolute space required is used.
*
* Default value: true
*/
useMaxWidth: true
},
state: {
dividerMargin: 10,
sizeUnit: 5,
@ -13505,26 +13487,19 @@ var config = {
},
gitGraph: {
diagramPadding: 8,
nodeSpacing: 150,
nodeFillColor: 'yellow',
nodeStrokeWidth: 2,
nodeStrokeColor: 'grey',
lineStrokeWidth: 4,
branchOffset: 50,
lineColor: 'grey',
leftMargin: 50,
branchColors: ['#442f74', '#983351', '#609732', '#AA9A39'],
nodeRadius: 10,
nodeLabel: {
width: 75,
height: 100,
x: -25,
y: 0
}
},
mainBranchName: 'main',
showCommitLabel: true,
showBranches: true
}
};
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
config.git.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
config.gitGraph.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
var keyify = function keyify(obj) {
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
@ -19792,33 +19767,34 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ "setDirection": () => (/* binding */ setDirection),
/* harmony export */ "setOptions": () => (/* binding */ setOptions)
/* harmony export */ });
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils */ "./src/utils.js");
/* harmony import */ var _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../mermaidAPI */ "./src/mermaidAPI.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../config */ "./src/config.js");
/* harmony import */ var _common_common__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../common/common */ "./src/diagrams/common/common.js");
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/utils.js");
/* harmony import */ var _mermaidAPI__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../mermaidAPI */ "./src/mermaidAPI.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../config */ "./src/config.js");
/* harmony import */ var _common_common__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/common */ "./src/diagrams/common/common.js");
var mainBranchName = (0,_config__WEBPACK_IMPORTED_MODULE_0__.getConfig)().gitGraph.mainBranchName;
var commits = {};
var head = null;
var branches = {
main: head
};
var curBranch = 'main';
var branches = {};
branches[mainBranchName] = head;
var curBranch = mainBranchName;
var direction = 'LR';
var seq = 0;
function getId() {
return (0,_utils__WEBPACK_IMPORTED_MODULE_0__.random)({
return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.random)({
length: 7
});
}
var parseDirective = function parseDirective(statement, context, type) {
_mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].parseDirective(this, statement, context, type);
_mermaidAPI__WEBPACK_IMPORTED_MODULE_2__["default"].parseDirective(this, statement, context, type);
}; // /**
// * @param currentCommit
// * @param otherCommit
@ -19879,24 +19855,24 @@ var setDirection = function setDirection(dir) {
};
var options = {};
var setOptions = function setOptions(rawOptString) {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('options str', rawOptString);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('options str', rawOptString);
rawOptString = rawOptString && rawOptString.trim();
rawOptString = rawOptString || '{}';
try {
options = JSON.parse(rawOptString);
} catch (e) {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.error('error while parsing gitGraph options', e.message);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.error('error while parsing gitGraph options', e.message);
}
};
var getOptions = function getOptions() {
return options;
};
var commit = function commit(msg, id, type, tag) {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('Entering commit:', msg, id, type, tag);
id = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(id, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
msg = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(msg, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
tag = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(tag, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('Entering commit:', msg, id, type, tag);
id = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(id, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
msg = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(msg, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
tag = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(tag, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
var commit = {
id: id ? id : seq + '-' + getId(),
message: msg,
@ -19909,15 +19885,15 @@ var commit = function commit(msg, id, type, tag) {
head = commit;
commits[commit.id] = commit;
branches[curBranch] = commit.id;
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('in pushCommit ' + commit.id);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('in pushCommit ' + commit.id);
};
var branch = function branch(name) {
name = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(name, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
name = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(name, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
if (typeof branches[name] === 'undefined') {
branches[name] = head != null ? head.id : null;
checkout(name);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('in createBranch');
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('in createBranch');
} else {
var 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 + '")');
error.hash = {
@ -19936,7 +19912,7 @@ var branch = function branch(name) {
}
};
var merge = function merge(otherBranch) {
otherBranch = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(otherBranch, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
otherBranch = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(otherBranch, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
var currentCommit = commits[branches[curBranch]];
var otherCommit = commits[branches[otherBranch]];
@ -20042,12 +20018,11 @@ var merge = function merge(otherBranch) {
commits[commit.id] = commit;
branches[curBranch] = commit.id; // }
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug(branches);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('in mergeBranch');
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(branches);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('in mergeBranch');
};
var checkout = function checkout(branch) {
branch = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(branch, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
console.info(branches);
branch = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(branch, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
if (typeof branches[branch] === 'undefined') {
var error = new Error('Trying to checkout branch which is not yet created. (Help try using "branch ' + branch + '")');
@ -20068,9 +20043,6 @@ var checkout = function checkout(branch) {
} else {
curBranch = branch;
var id = branches[curBranch];
console.log(id);
console.log('hi');
console.log(commits);
head = commits[id];
}
}; // export const reset = function (commitRef) {
@ -20129,7 +20101,7 @@ function prettyPrintCommitHistory(commitArr) {
if (branches[_branch] === commit.id) label.push(_branch);
}
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug(label.join(' '));
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(label.join(' '));
if (commit.parents && commit.parents.length == 2) {
var newCommit = commits[commit.parents[0]];
@ -20149,17 +20121,17 @@ function prettyPrintCommitHistory(commitArr) {
}
var prettyPrint = function prettyPrint() {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug(commits);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(commits);
var node = getCommitsArray()[0];
prettyPrintCommitHistory([node]);
};
var clear = function clear() {
commits = {};
head = null;
branches = {
main: head
};
curBranch = 'main';
var mainBranch = (0,_config__WEBPACK_IMPORTED_MODULE_0__.getConfig)().gitGraph.mainBranchName;
branches = {};
branches[mainBranch] = null;
curBranch = mainBranch;
seq = 0;
};
var getBranchesAsObjArray = function getBranchesAsObjArray() {
@ -20185,7 +20157,7 @@ var getCommitsArray = function getCommitsArray() {
return commits[key];
});
commitArr.forEach(function (o) {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug(o.id);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(o.id);
});
commitArr.sort(function (a, b) {
return a.seq - b.seq;
@ -20210,7 +20182,7 @@ var commitType = {
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
parseDirective: parseDirective,
getConfig: function getConfig() {
return _config__WEBPACK_IMPORTED_MODULE_4__.getConfig().gitGraph;
return _config__WEBPACK_IMPORTED_MODULE_0__.getConfig().gitGraph;
},
setDirection: setDirection,
setOptions: setOptions,
@ -20249,26 +20221,19 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "d3");
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(d3__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utils */ "./src/utils.js");
/* harmony import */ var _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gitGraphAst */ "./src/diagrams/git/gitGraphAst.js");
/* harmony import */ var _parser_gitGraph__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./parser/gitGraph */ "./src/diagrams/git/parser/gitGraph.jison");
/* harmony import */ var _parser_gitGraph__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_parser_gitGraph__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gitGraphAst */ "./src/diagrams/git/gitGraphAst.js");
/* harmony import */ var _parser_gitGraph__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./parser/gitGraph */ "./src/diagrams/git/parser/gitGraph.jison");
/* harmony import */ var _parser_gitGraph__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_parser_gitGraph__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../config */ "./src/config.js");
/* eslint-disable */
//import * as db from './mockDb';
/* eslint-disable */
//import * as configApi from '../../config';
var allCommitsDict = {};
var branchNum; //let conf = configApi.getConfig();
//const commitType = db.commitType;
var branchNum;
var commitType = {
NORMAL: 0,
REVERSE: 1,
@ -20286,46 +20251,18 @@ var clear = function clear() {
allCommitsDict = {};
maxPos = 0;
lanes = [];
}; // let apiConfig = {};
// export const setConf = function(c) {
// apiConfig = c;
// };
/** @param svg */
function svgCreateDefs(svg) {
var config = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)().gitGraph;
svg.append('defs').append('g').attr('id', 'def-commit').append('circle').attr('r', config.nodeRadius).attr('cx', 0).attr('cy', 0);
svg.select('#def-commit').append('foreignObject').attr('width', config.nodeLabel.width).attr('height', config.nodeLabel.height).attr('x', config.nodeLabel.x).attr('y', config.nodeLabel.y).attr('class', 'node-label').attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility').append('p').html('');
}
};
/**
* @param svg
* @param points
* @param colorIdx
* @param interpolate
*/
/**
// Pass in the element and its pre-transform coords
* Draws a text, used for labels of the branches
*
* @param element
* @param coords
*/
/**
* @param svg
* @param fromId
* @param toId
* @param direction
* @param color
* @param {string} txt The text
* @returns {SVGElement}
*/
var drawText = function drawText(txt) {
var svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text'); // svgLabel.setAttribute('style', style.replace('color:', 'fill:'));
var rows = [];
var svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text');
var rows = []; // Handling of new lines in the label
if (typeof txt === 'string') {
rows = txt.split(/\\n|\n|<br\s*\/?>/gi);
@ -20352,8 +20289,19 @@ var drawText = function drawText(txt) {
return svgLabel;
};
/**
* Draws the commits with its symbol and labels. The function has tywo modes, one which only
* calculates the positions and one that does the actual drawing. This for a simple way getting the
* vertical leyering rcorrect in the graph.
*
* @param {any} svg
* @param {any} commits
* @param {any} modifyGraph
*/
var drawCommits = function drawCommits(svg, commits, modifyGraph) {
var gitGraphConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)().gitGraph;
var gBullets = svg.append('g').attr('class', 'commit-bullets');
var gLabels = svg.append('g').attr('class', 'commit-labels');
var pos = 0;
@ -20364,7 +20312,7 @@ var drawCommits = function drawCommits(svg, commits, modifyGraph) {
sortedKeys.forEach(function (key, index) {
var commit = commits[key];
var y = branchPos[commit.branch].pos;
var x = pos + 10; // Don't draw the commits now but calculate the positioning which is used by the branmch lines etc.
var x = pos + 10; // Don't draw the commits now but calculate the positioning which is used by the branch lines etc.
if (modifyGraph) {
var typeClass;
@ -20433,9 +20381,9 @@ var drawCommits = function drawCommits(svg, commits, modifyGraph) {
if (modifyGraph) {
var px = 4;
var py = 2;
var py = 2; // Draw the commit label
if (commit.type !== commitType.MERGE) {
if (commit.type !== commitType.MERGE && gitGraphConfig.showCommitLabel) {
var labelBkg = gLabels.insert('rect').attr('class', 'commit-label-bkg');
var text = gLabels.append('text').attr('x', pos).attr('y', y + 25).attr('class', 'commit-label').text(commit.id);
var bbox = text.node().getBBox(); // Now we have the label, lets position the background
@ -20466,9 +20414,12 @@ var drawCommits = function drawCommits(svg, commits, modifyGraph) {
});
};
/**
* Detect if there are other commits between commit1s x-position and commit2s x-position on the same branch as commit2.
* @param {*} commit1
* @param {*} commit2
* Detect if there are other commits between commit1s x-position and commit2s x-position on the same
* branch as commit2.
*
* @param {any} commit1
* @param {any} commit2
* @param allCommits
* @returns
*/
@ -20484,7 +20435,13 @@ var hasOverlappingCommits = function hasOverlappingCommits(commit1, commit2, all
return overlappingComits.length > 0;
};
/**
* 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
*/
@ -20512,13 +20469,22 @@ var findLane = function findLane(y1, y2, _depth) {
var diff = Math.abs(y1 - y2);
return findLane(y1, y2 - diff / 5, depth);
};
/**
* This function draw trhe lines between the commits. They were arrows initially.
*
* @param {any} svg
* @param {any} commit1
* @param {any} commit2
* @param {any} allCommits
*/
var drawArrow = function drawArrow(svg, commit1, commit2, allCommits) {
var conf = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)();
var p1 = commitPos[commit1.id];
var p2 = commitPos[commit2.id];
var overlappingCommits = hasOverlappingCommits(commit1, commit2, allCommits);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('drawArrow', p1, p2, overlappingCommits, commit1.id, commit2.id);
var overlappingCommits = hasOverlappingCommits(commit1, commit2, allCommits); // log.debug('drawArrow', p1, p2, overlappingCommits, commit1.id, commit2.id);
var url = '';
if (conf.arrowMarkerAbsolute) {
@ -20591,6 +20557,8 @@ var drawArrows = function drawArrows(svg, commits) {
});
};
/**
* This function adds the branches and the branches' labels to the svg.
*
* @param svg
* @param commitid
* @param branches
@ -20599,6 +20567,7 @@ var drawArrows = function drawArrows(svg, commits) {
var drawBranches = function drawBranches(svg, branches) {
var gitGraphConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)().gitGraph;
var g = svg.append('g');
branches.forEach(function (branch, index) {
var pos = branchPos[branch.name].pos;
@ -20608,9 +20577,10 @@ var drawBranches = function drawBranches(svg, branches) {
line.attr('x2', maxPos);
line.attr('y2', pos);
line.attr('class', 'branch branch' + index);
lanes.push(pos); // Create the actual text element
lanes.push(pos);
var name = index === 0 ? gitGraphConfig.mainBranchName : branch.name; // Create the actual text element
var labelElement = drawText(branch.name); // Create outer g, edgeLabel, this will be positioned after graph layout
var labelElement = drawText(name); // Create outer g, edgeLabel, this will be positioned after graph layout
var bkg = g.insert('rect');
var branchLabel = g.insert('g').attr('class', 'branchLabel'); // Create inner g, label, this will be positioned now for centering the text
@ -20628,24 +20598,26 @@ var drawBranches = function drawBranches(svg, branches) {
* @param commit
* @param direction
* @param branchColor
* @param txt
* @param id
* @param ver
*/
var draw = function draw(txt, id, ver) {
clear();
var conf = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)();
var config = conf.gitGraph; // try {
var gitGraphConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)().gitGraph; // try {
var parser = (_parser_gitGraph__WEBPACK_IMPORTED_MODULE_3___default().parser);
parser.yy = _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__["default"];
var parser = (_parser_gitGraph__WEBPACK_IMPORTED_MODULE_2___default().parser);
parser.yy = _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__["default"];
parser.yy.clear();
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver); // // Parse the graph definition
_logger__WEBPACK_IMPORTED_MODULE_4__.log.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver); // // Parse the graph definition
parser.parse(txt + '\n'); // config = Object.assign(config, apiConfig, db.getOptions());
var direction = _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__["default"].getDirection();
allCommitsDict = _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__["default"].getCommits();
var branches = _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__["default"].getBranchesAsObjArray(); // Position branches vertically
parser.parse(txt + '\n');
var direction = _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__["default"].getDirection();
allCommitsDict = _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__["default"].getCommits();
var branches = _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__["default"].getBranchesAsObjArray(); // Position branches vertically
var pos = 0;
branches.forEach(function (branch, index) {
@ -20655,24 +20627,21 @@ var draw = function draw(txt, id, ver) {
};
pos += 50;
});
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('brach pos ', branchPos);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('effective options', config, branches);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('commits', allCommitsDict);
var diagram = (0,d3__WEBPACK_IMPORTED_MODULE_0__.select)("[id=\"".concat(id, "\"]"));
svgCreateDefs(diagram);
diagram.append('defs').append('marker').attr('id', 'arrowhead').attr('refX', 24).attr('refY', 10).attr('markerUnits', 'userSpaceOnUse').attr('markerWidth', 24).attr('markerHeight', 24).attr('orient', 'auto').append('path').attr('d', 'M 0 0 L 20 10 L 0 20 z'); // this is actual shape for arrowhead
drawCommits(diagram, allCommitsDict, false);
drawBranches(diagram, branches);
if (gitGraphConfig.showBranches) {
drawBranches(diagram, branches);
}
drawArrows(diagram, allCommitsDict);
drawCommits(diagram, allCommitsDict, true);
var padding = config.diagramPadding;
var padding = gitGraphConfig.diagramPadding;
var svgBounds = diagram.node().getBBox();
var width = svgBounds.width + padding * 2;
var height = svgBounds.height + padding * 2;
(0,_utils__WEBPACK_IMPORTED_MODULE_5__.configureSvgSize)(diagram, height, width, conf.useMaxWidth);
var vBox = "".concat(svgBounds.x - padding, " ").concat(svgBounds.y - padding, " ").concat(width, " ").concat(height); // logger.debug(`viewBox ${vBox}`);
var vBox = "".concat(svgBounds.x - padding, " ").concat(svgBounds.y - padding, " ").concat(width, " ").concat(height);
diagram.attr('viewBox', vBox);
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
@ -26956,7 +26925,7 @@ function parse(text) {
if (graphInit) {
reinitialize(graphInit);
_logger__WEBPACK_IMPORTED_MODULE_4__.log.debug('reinit ', graphInit);
_logger__WEBPACK_IMPORTED_MODULE_4__.log.info('reinit ', graphInit);
}
var graphType = _utils__WEBPACK_IMPORTED_MODULE_3__["default"].detectType(text, cnf);
@ -26964,7 +26933,7 @@ function parse(text) {
_logger__WEBPACK_IMPORTED_MODULE_4__.log.debug('Type ' + graphType);
switch (graphType) {
case 'git':
case 'gitGraph':
parser = (_diagrams_git_parser_gitGraph__WEBPACK_IMPORTED_MODULE_5___default());
parser.parser.yy = _diagrams_git_gitGraphAst__WEBPACK_IMPORTED_MODULE_6__["default"];
break;
@ -27128,7 +27097,8 @@ var render = function render(id, _txt, cb, container) {
_config__WEBPACK_IMPORTED_MODULE_2__.addDirective(graphInit);
}
var cnf = _config__WEBPACK_IMPORTED_MODULE_2__.getConfig(); // Check the maximum allowed text size
var cnf = _config__WEBPACK_IMPORTED_MODULE_2__.getConfig();
_logger__WEBPACK_IMPORTED_MODULE_4__.log.debug(cnf); // Check the maximum allowed text size
if (_txt.length > cnf.maxTextSize) {
txt = 'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa';
@ -27280,7 +27250,7 @@ var render = function render(id, _txt, cb, container) {
try {
switch (graphType) {
case 'git':
case 'gitGraph':
// cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
//gitGraphRenderer.setConf(cnf.git);
_diagrams_git_gitGraphRenderer__WEBPACK_IMPORTED_MODULE_29__["default"].draw(txt, id, false);
@ -27719,7 +27689,7 @@ var themes = {
class: _diagrams_class_styles__WEBPACK_IMPORTED_MODULE_3__["default"],
stateDiagram: _diagrams_state_styles__WEBPACK_IMPORTED_MODULE_4__["default"],
state: _diagrams_state_styles__WEBPACK_IMPORTED_MODULE_4__["default"],
git: _diagrams_git_styles__WEBPACK_IMPORTED_MODULE_5__["default"],
gitGraph: _diagrams_git_styles__WEBPACK_IMPORTED_MODULE_5__["default"],
info: _diagrams_info_styles__WEBPACK_IMPORTED_MODULE_6__["default"],
pie: _diagrams_pie_styles__WEBPACK_IMPORTED_MODULE_7__["default"],
er: _diagrams_er_styles__WEBPACK_IMPORTED_MODULE_8__["default"],
@ -28054,14 +28024,14 @@ var Theme = /*#__PURE__*/function () {
this.git7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)(this.git7, 25);
}
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.branchLabelColor = this.branchLabelColor || (this.darkMode ? 'black' : this.labelTextColor);
this.gitBranchLabel0 = this.gitBranchLabel0 || this.branchLabelColor;
this.gitBranchLabel1 = this.gitBranchLabel1 || this.branchLabelColor;
@ -28354,14 +28324,14 @@ var Theme = /*#__PURE__*/function () {
this.git7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.lighten)(this.pie8 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.adjust)(this.primaryColor, {
h: +120
}), 20);
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;
this.tagLabelBorder = this.tagBorder || this.primaryBorderColor;
@ -28706,22 +28676,22 @@ var Theme = /*#__PURE__*/function () {
this.git7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)(this.git7, 25);
}
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)((0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0), 25);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitBranchLabel0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.labelTextColor);
this.gitBranchLabel1 = this.labelTextColor;
this.gitBranchLabel2 = this.labelTextColor;
this.gitBranchLabel3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.labelTextColor);
this.gitBranchLabel4 = this.labelTextColor;
this.gitBranchLabel5 = this.labelTextColor;
this.gitBranchLabel6 = this.labelTextColor;
this.gitBranchLabel7 = this.labelTextColor;
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)((0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0), 25);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitBranchLabel0 = this.gitBranchLabel0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.labelTextColor);
this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor;
this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor;
this.gitBranchLabel3 = this.gitBranchLabel3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.labelTextColor);
this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor;
this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor;
this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor;
this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor;
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;
this.tagLabelBorder = this.tagBorder || this.primaryBorderColor;
@ -29034,14 +29004,14 @@ var Theme = /*#__PURE__*/function () {
this.git7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)(this.git7, 25);
}
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;
this.tagLabelBorder = this.tagBorder || this.primaryBorderColor;
@ -29373,14 +29343,14 @@ var Theme = /*#__PURE__*/function () {
this.git7 = this.pie8 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.adjust)(this.primaryColor, {
h: +120
});
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.branchLabelColor = this.branchLabelColor || this.labelTextColor;
this.gitBranchLabel0 = this.branchLabelColor;
this.gitBranchLabel1 = 'white';
@ -29702,7 +29672,7 @@ var detectType = function detectType(text, cnf) {
}
if (text.match(/^\s*gitGraph/)) {
return 'git';
return 'gitGraph';
}
if (text.match(/^\s*flowchart/)) {
@ -31411,7 +31381,7 @@ module.exports = require("stylis");
/***/ ((module) => {
"use strict";
module.exports = JSON.parse('{"name":"mermaid","version":"8.14.0","description":"Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.","main":"dist/mermaid.core.js","module":"dist/mermaid.esm.min.mjs","exports":{".":{"require":"./dist/mermaid.core.js","import":"./dist/mermaid.esm.min.mjs"},"./*":"./*"},"keywords":["diagram","markdown","flowchart","sequence diagram","gantt","class diagram","git graph"],"scripts":{"build:development":"webpack --mode development --progress --color","build:production":"webpack --mode production --progress --color","build":"concurrently \\"yarn build:development\\" \\"yarn build:production\\"","postbuild":"documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md","build:watch":"yarn build:development --watch","release":"yarn build","lint":"eslint ./ --ext js,html","lint:fix":"yarn lint --fix","e2e:depr":"yarn lint && jest e2e --config e2e/jest.config.js","cypress":"cypress run","e2e":"start-server-and-test dev http://localhost:9000/ cypress","e2e-upd":"yarn lint && jest e2e -u --config e2e/jest.config.js","dev":"webpack serve --config ./.webpack/webpack.config.e2e.babel.js","test":"yarn lint && jest src/.*","test:watch":"jest --watch src","prepublishOnly":"yarn build && yarn test","prepare":"husky install && yarn build","pre-commit":"lint-staged"},"repository":{"type":"git","url":"https://github.com/knsv/mermaid"},"author":"Knut Sveidqvist","license":"MIT","standard":{"ignore":["**/parser/*.js","dist/**/*.js","cypress/**/*.js"],"globals":["page"]},"dependencies":{"@braintree/sanitize-url":"^6.0.0","cypress-image-snapshot":"^4.0.1","d3":"^7.0.0","dagre":"^0.8.5","dagre-d3":"^0.6.4","dompurify":"2.3.6","graphlib":"^2.1.8","khroma":"^1.4.1","moment-mini":"^2.24.0","stylis":"^4.0.10"},"devDependencies":{"@babel/core":"^7.14.6","@babel/eslint-parser":"^7.14.7","@babel/preset-env":"^7.14.7","@babel/register":"^7.14.5","@commitlint/cli":"^16.0.0","@commitlint/config-conventional":"^16.0.0","babel-jest":"^27.0.6","babel-loader":"^8.2.2","concurrently":"^7.0.0","coveralls":"^3.0.2","css-to-string-loader":"^0.1.3","cypress":"9.5.2","documentation":"13.2.0","eslint":"^8.2.0","eslint-config-prettier":"^8.3.0","eslint-plugin-cypress":"^2.12.1","eslint-plugin-html":"^6.2.0","eslint-plugin-jest":"^26.0.0","eslint-plugin-jsdoc":"^38.0.3","eslint-plugin-markdown":"^2.2.1","eslint-plugin-prettier":"^4.0.0","husky":"^7.0.1","identity-obj-proxy":"^3.0.0","jest":"^27.0.6","jison":"^0.4.18","js-base64":"3.7.2","lint-staged":"^12.1.2","moment":"^2.23.0","path-browserify":"^1.0.1","prettier":"^2.3.2","prettier-plugin-jsdoc":"^0.3.30","start-server-and-test":"^1.12.6","terser-webpack-plugin":"^5.2.4","webpack":"^5.53.0","webpack-cli":"^4.7.2","webpack-dev-server":"^4.3.0","webpack-merge":"^5.8.0","webpack-node-externals":"^3.0.0"},"files":["dist"],"sideEffects":["**/*.css","**/*.scss"]}');
module.exports = JSON.parse('{"name":"mermaid","version":"9.0.0","description":"Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.","main":"dist/mermaid.core.js","module":"dist/mermaid.esm.min.mjs","exports":{".":{"require":"./dist/mermaid.core.js","import":"./dist/mermaid.esm.min.mjs"},"./*":"./*"},"keywords":["diagram","markdown","flowchart","sequence diagram","gantt","class diagram","git graph"],"scripts":{"build:development":"webpack --mode development --progress --color","build:production":"webpack --mode production --progress --color","build":"concurrently \\"yarn build:development\\" \\"yarn build:production\\"","postbuild":"documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md","build:watch":"yarn build:development --watch","release":"yarn build","lint":"eslint ./ --ext js,html","lint:fix":"yarn lint --fix","e2e:depr":"yarn lint && jest e2e --config e2e/jest.config.js","cypress":"cypress run","e2e":"start-server-and-test dev http://localhost:9000/ cypress","e2e-upd":"yarn lint && jest e2e -u --config e2e/jest.config.js","dev":"webpack serve --config ./.webpack/webpack.config.e2e.babel.js","test":"yarn lint && jest src/.*","test:watch":"jest --watch src","prepublishOnly":"yarn build && yarn test","prepare":"husky install && yarn build","pre-commit":"lint-staged"},"repository":{"type":"git","url":"https://github.com/knsv/mermaid"},"author":"Knut Sveidqvist","license":"MIT","standard":{"ignore":["**/parser/*.js","dist/**/*.js","cypress/**/*.js"],"globals":["page"]},"dependencies":{"@braintree/sanitize-url":"^6.0.0","cypress-image-snapshot":"^4.0.1","d3":"^7.0.0","dagre":"^0.8.5","dagre-d3":"^0.6.4","dompurify":"2.3.6","graphlib":"^2.1.8","khroma":"^1.4.1","moment-mini":"^2.24.0","stylis":"^4.0.10"},"devDependencies":{"@babel/core":"^7.14.6","@babel/eslint-parser":"^7.14.7","@babel/preset-env":"^7.14.7","@babel/register":"^7.14.5","@commitlint/cli":"^16.0.0","@commitlint/config-conventional":"^16.0.0","babel-jest":"^27.0.6","babel-loader":"^8.2.2","concurrently":"^7.0.0","coveralls":"^3.0.2","css-to-string-loader":"^0.1.3","cypress":"9.5.2","documentation":"13.2.0","eslint":"^8.2.0","eslint-config-prettier":"^8.3.0","eslint-plugin-cypress":"^2.12.1","eslint-plugin-html":"^6.2.0","eslint-plugin-jest":"^26.0.0","eslint-plugin-jsdoc":"^38.0.3","eslint-plugin-markdown":"^2.2.1","eslint-plugin-prettier":"^4.0.0","husky":"^7.0.1","identity-obj-proxy":"^3.0.0","jest":"^27.0.6","jison":"^0.4.18","js-base64":"3.7.2","lint-staged":"^12.1.2","moment":"^2.23.0","path-browserify":"^1.0.1","prettier":"^2.3.2","prettier-plugin-jsdoc":"^0.3.30","start-server-and-test":"^1.12.6","terser-webpack-plugin":"^5.2.4","webpack":"^5.53.0","webpack-cli":"^4.7.2","webpack-dev-server":"^4.3.0","webpack-merge":"^5.8.0","webpack-node-externals":"^3.0.0"},"files":["dist"],"sideEffects":["**/*.css","**/*.scss"]}');
/***/ })

File diff suppressed because one or more lines are too long

364
dist/mermaid.js vendored
View File

@ -13327,24 +13327,6 @@ var config = {
*/
defaultRenderer: 'dagre-wrapper'
},
git: {
arrowMarkerAbsolute: false,
useWidth: undefined,
/**
* | Parameter | Description | Type | Required | Values |
* | ----------- | ----------- | ------- | -------- | ----------- |
* | useMaxWidth | See notes | boolean | 4 | true, false |
*
* **Notes:**
*
* When this flag is set the height and width is set to 100% and is then scaling with the
* available space if not the absolute space required is used.
*
* Default value: true
*/
useMaxWidth: true
},
state: {
dividerMargin: 10,
sizeUnit: 5,
@ -13549,26 +13531,19 @@ var config = {
},
gitGraph: {
diagramPadding: 8,
nodeSpacing: 150,
nodeFillColor: 'yellow',
nodeStrokeWidth: 2,
nodeStrokeColor: 'grey',
lineStrokeWidth: 4,
branchOffset: 50,
lineColor: 'grey',
leftMargin: 50,
branchColors: ['#442f74', '#983351', '#609732', '#AA9A39'],
nodeRadius: 10,
nodeLabel: {
width: 75,
height: 100,
x: -25,
y: 0
}
},
mainBranchName: 'main',
showCommitLabel: true,
showBranches: true
}
};
config.class.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
config.git.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
config.gitGraph.arrowMarkerAbsolute = config.arrowMarkerAbsolute;
var keyify = function keyify(obj) {
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
@ -19826,33 +19801,34 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ "setDirection": () => (/* binding */ setDirection),
/* harmony export */ "setOptions": () => (/* binding */ setOptions)
/* harmony export */ });
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils */ "./src/utils.js");
/* harmony import */ var _mermaidAPI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../mermaidAPI */ "./src/mermaidAPI.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../config */ "./src/config.js");
/* harmony import */ var _common_common__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../common/common */ "./src/diagrams/common/common.js");
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../utils */ "./src/utils.js");
/* harmony import */ var _mermaidAPI__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../mermaidAPI */ "./src/mermaidAPI.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../config */ "./src/config.js");
/* harmony import */ var _common_common__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../common/common */ "./src/diagrams/common/common.js");
var mainBranchName = (0,_config__WEBPACK_IMPORTED_MODULE_0__.getConfig)().gitGraph.mainBranchName;
var commits = {};
var head = null;
var branches = {
main: head
};
var curBranch = 'main';
var branches = {};
branches[mainBranchName] = head;
var curBranch = mainBranchName;
var direction = 'LR';
var seq = 0;
function getId() {
return (0,_utils__WEBPACK_IMPORTED_MODULE_0__.random)({
return (0,_utils__WEBPACK_IMPORTED_MODULE_1__.random)({
length: 7
});
}
var parseDirective = function parseDirective(statement, context, type) {
_mermaidAPI__WEBPACK_IMPORTED_MODULE_1__["default"].parseDirective(this, statement, context, type);
_mermaidAPI__WEBPACK_IMPORTED_MODULE_2__["default"].parseDirective(this, statement, context, type);
}; // /**
// * @param currentCommit
// * @param otherCommit
@ -19913,24 +19889,24 @@ var setDirection = function setDirection(dir) {
};
var options = {};
var setOptions = function setOptions(rawOptString) {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('options str', rawOptString);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('options str', rawOptString);
rawOptString = rawOptString && rawOptString.trim();
rawOptString = rawOptString || '{}';
try {
options = JSON.parse(rawOptString);
} catch (e) {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.error('error while parsing gitGraph options', e.message);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.error('error while parsing gitGraph options', e.message);
}
};
var getOptions = function getOptions() {
return options;
};
var commit = function commit(msg, id, type, tag) {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('Entering commit:', msg, id, type, tag);
id = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(id, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
msg = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(msg, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
tag = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(tag, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('Entering commit:', msg, id, type, tag);
id = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(id, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
msg = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(msg, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
tag = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(tag, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
var commit = {
id: id ? id : seq + '-' + getId(),
message: msg,
@ -19943,15 +19919,15 @@ var commit = function commit(msg, id, type, tag) {
head = commit;
commits[commit.id] = commit;
branches[curBranch] = commit.id;
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('in pushCommit ' + commit.id);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('in pushCommit ' + commit.id);
};
var branch = function branch(name) {
name = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(name, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
name = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(name, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
if (typeof branches[name] === 'undefined') {
branches[name] = head != null ? head.id : null;
checkout(name);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('in createBranch');
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('in createBranch');
} else {
var 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 + '")');
error.hash = {
@ -19970,7 +19946,7 @@ var branch = function branch(name) {
}
};
var merge = function merge(otherBranch) {
otherBranch = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(otherBranch, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
otherBranch = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(otherBranch, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
var currentCommit = commits[branches[curBranch]];
var otherCommit = commits[branches[otherBranch]];
@ -20076,12 +20052,11 @@ var merge = function merge(otherBranch) {
commits[commit.id] = commit;
branches[curBranch] = commit.id; // }
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug(branches);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('in mergeBranch');
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(branches);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('in mergeBranch');
};
var checkout = function checkout(branch) {
branch = _common_common__WEBPACK_IMPORTED_MODULE_3__["default"].sanitizeText(branch, _config__WEBPACK_IMPORTED_MODULE_4__.getConfig());
console.info(branches);
branch = _common_common__WEBPACK_IMPORTED_MODULE_4__["default"].sanitizeText(branch, _config__WEBPACK_IMPORTED_MODULE_0__.getConfig());
if (typeof branches[branch] === 'undefined') {
var error = new Error('Trying to checkout branch which is not yet created. (Help try using "branch ' + branch + '")');
@ -20102,9 +20077,6 @@ var checkout = function checkout(branch) {
} else {
curBranch = branch;
var id = branches[curBranch];
console.log(id);
console.log('hi');
console.log(commits);
head = commits[id];
}
}; // export const reset = function (commitRef) {
@ -20163,7 +20135,7 @@ function prettyPrintCommitHistory(commitArr) {
if (branches[_branch] === commit.id) label.push(_branch);
}
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug(label.join(' '));
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(label.join(' '));
if (commit.parents && commit.parents.length == 2) {
var newCommit = commits[commit.parents[0]];
@ -20183,17 +20155,17 @@ function prettyPrintCommitHistory(commitArr) {
}
var prettyPrint = function prettyPrint() {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug(commits);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(commits);
var node = getCommitsArray()[0];
prettyPrintCommitHistory([node]);
};
var clear = function clear() {
commits = {};
head = null;
branches = {
main: head
};
curBranch = 'main';
var mainBranch = (0,_config__WEBPACK_IMPORTED_MODULE_0__.getConfig)().gitGraph.mainBranchName;
branches = {};
branches[mainBranch] = null;
curBranch = mainBranch;
seq = 0;
};
var getBranchesAsObjArray = function getBranchesAsObjArray() {
@ -20219,7 +20191,7 @@ var getCommitsArray = function getCommitsArray() {
return commits[key];
});
commitArr.forEach(function (o) {
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug(o.id);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(o.id);
});
commitArr.sort(function (a, b) {
return a.seq - b.seq;
@ -20244,7 +20216,7 @@ var commitType = {
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
parseDirective: parseDirective,
getConfig: function getConfig() {
return _config__WEBPACK_IMPORTED_MODULE_4__.getConfig().gitGraph;
return _config__WEBPACK_IMPORTED_MODULE_0__.getConfig().gitGraph;
},
setDirection: setDirection,
setOptions: setOptions,
@ -20282,26 +20254,19 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export */ });
/* harmony import */ var d3__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! d3 */ "./node_modules/d3/src/index.js");
/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../utils */ "./src/utils.js");
/* harmony import */ var _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gitGraphAst */ "./src/diagrams/git/gitGraphAst.js");
/* harmony import */ var _parser_gitGraph__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./parser/gitGraph */ "./src/diagrams/git/parser/gitGraph.jison");
/* harmony import */ var _parser_gitGraph__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_parser_gitGraph__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gitGraphAst */ "./src/diagrams/git/gitGraphAst.js");
/* harmony import */ var _parser_gitGraph__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./parser/gitGraph */ "./src/diagrams/git/parser/gitGraph.jison");
/* harmony import */ var _parser_gitGraph__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_parser_gitGraph__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../logger */ "./src/logger.js");
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../config */ "./src/config.js");
/* eslint-disable */
//import * as db from './mockDb';
/* eslint-disable */
//import * as configApi from '../../config';
var allCommitsDict = {};
var branchNum; //let conf = configApi.getConfig();
//const commitType = db.commitType;
var branchNum;
var commitType = {
NORMAL: 0,
REVERSE: 1,
@ -20319,46 +20284,18 @@ var clear = function clear() {
allCommitsDict = {};
maxPos = 0;
lanes = [];
}; // let apiConfig = {};
// export const setConf = function(c) {
// apiConfig = c;
// };
/** @param svg */
function svgCreateDefs(svg) {
var config = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)().gitGraph;
svg.append('defs').append('g').attr('id', 'def-commit').append('circle').attr('r', config.nodeRadius).attr('cx', 0).attr('cy', 0);
svg.select('#def-commit').append('foreignObject').attr('width', config.nodeLabel.width).attr('height', config.nodeLabel.height).attr('x', config.nodeLabel.x).attr('y', config.nodeLabel.y).attr('class', 'node-label').attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility').append('p').html('');
}
};
/**
* @param svg
* @param points
* @param colorIdx
* @param interpolate
*/
/**
// Pass in the element and its pre-transform coords
* Draws a text, used for labels of the branches
*
* @param element
* @param coords
*/
/**
* @param svg
* @param fromId
* @param toId
* @param direction
* @param color
* @param {string} txt The text
* @returns {SVGElement}
*/
var drawText = function drawText(txt) {
var svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text'); // svgLabel.setAttribute('style', style.replace('color:', 'fill:'));
var rows = [];
var svgLabel = document.createElementNS('http://www.w3.org/2000/svg', 'text');
var rows = []; // Handling of new lines in the label
if (typeof txt === 'string') {
rows = txt.split(/\\n|\n|<br\s*\/?>/gi);
@ -20385,8 +20322,19 @@ var drawText = function drawText(txt) {
return svgLabel;
};
/**
* Draws the commits with its symbol and labels. The function has tywo modes, one which only
* calculates the positions and one that does the actual drawing. This for a simple way getting the
* vertical leyering rcorrect in the graph.
*
* @param {any} svg
* @param {any} commits
* @param {any} modifyGraph
*/
var drawCommits = function drawCommits(svg, commits, modifyGraph) {
var gitGraphConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)().gitGraph;
var gBullets = svg.append('g').attr('class', 'commit-bullets');
var gLabels = svg.append('g').attr('class', 'commit-labels');
var pos = 0;
@ -20397,7 +20345,7 @@ var drawCommits = function drawCommits(svg, commits, modifyGraph) {
sortedKeys.forEach(function (key, index) {
var commit = commits[key];
var y = branchPos[commit.branch].pos;
var x = pos + 10; // Don't draw the commits now but calculate the positioning which is used by the branmch lines etc.
var x = pos + 10; // Don't draw the commits now but calculate the positioning which is used by the branch lines etc.
if (modifyGraph) {
var typeClass;
@ -20466,9 +20414,9 @@ var drawCommits = function drawCommits(svg, commits, modifyGraph) {
if (modifyGraph) {
var px = 4;
var py = 2;
var py = 2; // Draw the commit label
if (commit.type !== commitType.MERGE) {
if (commit.type !== commitType.MERGE && gitGraphConfig.showCommitLabel) {
var labelBkg = gLabels.insert('rect').attr('class', 'commit-label-bkg');
var text = gLabels.append('text').attr('x', pos).attr('y', y + 25).attr('class', 'commit-label').text(commit.id);
var bbox = text.node().getBBox(); // Now we have the label, lets position the background
@ -20499,9 +20447,12 @@ var drawCommits = function drawCommits(svg, commits, modifyGraph) {
});
};
/**
* Detect if there are other commits between commit1s x-position and commit2s x-position on the same branch as commit2.
* @param {*} commit1
* @param {*} commit2
* Detect if there are other commits between commit1s x-position and commit2s x-position on the same
* branch as commit2.
*
* @param {any} commit1
* @param {any} commit2
* @param allCommits
* @returns
*/
@ -20517,7 +20468,13 @@ var hasOverlappingCommits = function hasOverlappingCommits(commit1, commit2, all
return overlappingComits.length > 0;
};
/**
* 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
*/
@ -20545,13 +20502,22 @@ var findLane = function findLane(y1, y2, _depth) {
var diff = Math.abs(y1 - y2);
return findLane(y1, y2 - diff / 5, depth);
};
/**
* This function draw trhe lines between the commits. They were arrows initially.
*
* @param {any} svg
* @param {any} commit1
* @param {any} commit2
* @param {any} allCommits
*/
var drawArrow = function drawArrow(svg, commit1, commit2, allCommits) {
var conf = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)();
var p1 = commitPos[commit1.id];
var p2 = commitPos[commit2.id];
var overlappingCommits = hasOverlappingCommits(commit1, commit2, allCommits);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('drawArrow', p1, p2, overlappingCommits, commit1.id, commit2.id);
var overlappingCommits = hasOverlappingCommits(commit1, commit2, allCommits); // log.debug('drawArrow', p1, p2, overlappingCommits, commit1.id, commit2.id);
var url = '';
if (conf.arrowMarkerAbsolute) {
@ -20624,6 +20590,8 @@ var drawArrows = function drawArrows(svg, commits) {
});
};
/**
* This function adds the branches and the branches' labels to the svg.
*
* @param svg
* @param commitid
* @param branches
@ -20632,6 +20600,7 @@ var drawArrows = function drawArrows(svg, commits) {
var drawBranches = function drawBranches(svg, branches) {
var gitGraphConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)().gitGraph;
var g = svg.append('g');
branches.forEach(function (branch, index) {
var pos = branchPos[branch.name].pos;
@ -20641,9 +20610,10 @@ var drawBranches = function drawBranches(svg, branches) {
line.attr('x2', maxPos);
line.attr('y2', pos);
line.attr('class', 'branch branch' + index);
lanes.push(pos); // Create the actual text element
lanes.push(pos);
var name = index === 0 ? gitGraphConfig.mainBranchName : branch.name; // Create the actual text element
var labelElement = drawText(branch.name); // Create outer g, edgeLabel, this will be positioned after graph layout
var labelElement = drawText(name); // Create outer g, edgeLabel, this will be positioned after graph layout
var bkg = g.insert('rect');
var branchLabel = g.insert('g').attr('class', 'branchLabel'); // Create inner g, label, this will be positioned now for centering the text
@ -20661,24 +20631,26 @@ var drawBranches = function drawBranches(svg, branches) {
* @param commit
* @param direction
* @param branchColor
* @param txt
* @param id
* @param ver
*/
var draw = function draw(txt, id, ver) {
clear();
var conf = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)();
var config = conf.gitGraph; // try {
var gitGraphConfig = (0,_config__WEBPACK_IMPORTED_MODULE_1__.getConfig)().gitGraph; // try {
var parser = (_parser_gitGraph__WEBPACK_IMPORTED_MODULE_3___default().parser);
parser.yy = _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__["default"];
var parser = (_parser_gitGraph__WEBPACK_IMPORTED_MODULE_2___default().parser);
parser.yy = _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__["default"];
parser.yy.clear();
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver); // // Parse the graph definition
_logger__WEBPACK_IMPORTED_MODULE_4__.log.debug('in gitgraph renderer', txt + '\n', 'id:', id, ver); // // Parse the graph definition
parser.parse(txt + '\n'); // config = Object.assign(config, apiConfig, db.getOptions());
var direction = _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__["default"].getDirection();
allCommitsDict = _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__["default"].getCommits();
var branches = _gitGraphAst__WEBPACK_IMPORTED_MODULE_4__["default"].getBranchesAsObjArray(); // Position branches vertically
parser.parse(txt + '\n');
var direction = _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__["default"].getDirection();
allCommitsDict = _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__["default"].getCommits();
var branches = _gitGraphAst__WEBPACK_IMPORTED_MODULE_3__["default"].getBranchesAsObjArray(); // Position branches vertically
var pos = 0;
branches.forEach(function (branch, index) {
@ -20688,24 +20660,21 @@ var draw = function draw(txt, id, ver) {
};
pos += 50;
});
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('brach pos ', branchPos);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('effective options', config, branches);
_logger__WEBPACK_IMPORTED_MODULE_2__.log.debug('commits', allCommitsDict);
var diagram = (0,d3__WEBPACK_IMPORTED_MODULE_0__.select)("[id=\"".concat(id, "\"]"));
svgCreateDefs(diagram);
diagram.append('defs').append('marker').attr('id', 'arrowhead').attr('refX', 24).attr('refY', 10).attr('markerUnits', 'userSpaceOnUse').attr('markerWidth', 24).attr('markerHeight', 24).attr('orient', 'auto').append('path').attr('d', 'M 0 0 L 20 10 L 0 20 z'); // this is actual shape for arrowhead
drawCommits(diagram, allCommitsDict, false);
drawBranches(diagram, branches);
if (gitGraphConfig.showBranches) {
drawBranches(diagram, branches);
}
drawArrows(diagram, allCommitsDict);
drawCommits(diagram, allCommitsDict, true);
var padding = config.diagramPadding;
var padding = gitGraphConfig.diagramPadding;
var svgBounds = diagram.node().getBBox();
var width = svgBounds.width + padding * 2;
var height = svgBounds.height + padding * 2;
(0,_utils__WEBPACK_IMPORTED_MODULE_5__.configureSvgSize)(diagram, height, width, conf.useMaxWidth);
var vBox = "".concat(svgBounds.x - padding, " ").concat(svgBounds.y - padding, " ").concat(width, " ").concat(height); // logger.debug(`viewBox ${vBox}`);
var vBox = "".concat(svgBounds.x - padding, " ").concat(svgBounds.y - padding, " ").concat(width, " ").concat(height);
diagram.attr('viewBox', vBox);
};
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
@ -26977,7 +26946,7 @@ function parse(text) {
if (graphInit) {
reinitialize(graphInit);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('reinit ', graphInit);
_logger__WEBPACK_IMPORTED_MODULE_3__.log.info('reinit ', graphInit);
}
var graphType = _utils__WEBPACK_IMPORTED_MODULE_2__["default"].detectType(text, cnf);
@ -26985,7 +26954,7 @@ function parse(text) {
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug('Type ' + graphType);
switch (graphType) {
case 'git':
case 'gitGraph':
parser = (_diagrams_git_parser_gitGraph__WEBPACK_IMPORTED_MODULE_4___default());
parser.parser.yy = _diagrams_git_gitGraphAst__WEBPACK_IMPORTED_MODULE_5__["default"];
break;
@ -27149,7 +27118,8 @@ var render = function render(id, _txt, cb, container) {
_config__WEBPACK_IMPORTED_MODULE_1__.addDirective(graphInit);
}
var cnf = _config__WEBPACK_IMPORTED_MODULE_1__.getConfig(); // Check the maximum allowed text size
var cnf = _config__WEBPACK_IMPORTED_MODULE_1__.getConfig();
_logger__WEBPACK_IMPORTED_MODULE_3__.log.debug(cnf); // Check the maximum allowed text size
if (_txt.length > cnf.maxTextSize) {
txt = 'graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa';
@ -27301,7 +27271,7 @@ var render = function render(id, _txt, cb, container) {
try {
switch (graphType) {
case 'git':
case 'gitGraph':
// cnf.flowchart.arrowMarkerAbsolute = cnf.arrowMarkerAbsolute;
//gitGraphRenderer.setConf(cnf.git);
_diagrams_git_gitGraphRenderer__WEBPACK_IMPORTED_MODULE_30__["default"].draw(txt, id, false);
@ -27740,7 +27710,7 @@ var themes = {
class: _diagrams_class_styles__WEBPACK_IMPORTED_MODULE_3__["default"],
stateDiagram: _diagrams_state_styles__WEBPACK_IMPORTED_MODULE_4__["default"],
state: _diagrams_state_styles__WEBPACK_IMPORTED_MODULE_4__["default"],
git: _diagrams_git_styles__WEBPACK_IMPORTED_MODULE_5__["default"],
gitGraph: _diagrams_git_styles__WEBPACK_IMPORTED_MODULE_5__["default"],
info: _diagrams_info_styles__WEBPACK_IMPORTED_MODULE_6__["default"],
pie: _diagrams_pie_styles__WEBPACK_IMPORTED_MODULE_7__["default"],
er: _diagrams_er_styles__WEBPACK_IMPORTED_MODULE_8__["default"],
@ -28075,14 +28045,14 @@ var Theme = /*#__PURE__*/function () {
this.git7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)(this.git7, 25);
}
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.branchLabelColor = this.branchLabelColor || (this.darkMode ? 'black' : this.labelTextColor);
this.gitBranchLabel0 = this.gitBranchLabel0 || this.branchLabelColor;
this.gitBranchLabel1 = this.gitBranchLabel1 || this.branchLabelColor;
@ -28375,14 +28345,14 @@ var Theme = /*#__PURE__*/function () {
this.git7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.lighten)(this.pie8 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.adjust)(this.primaryColor, {
h: +120
}), 20);
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;
this.tagLabelBorder = this.tagBorder || this.primaryBorderColor;
@ -28727,22 +28697,22 @@ var Theme = /*#__PURE__*/function () {
this.git7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)(this.git7, 25);
}
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)((0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0), 25);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitBranchLabel0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.labelTextColor);
this.gitBranchLabel1 = this.labelTextColor;
this.gitBranchLabel2 = this.labelTextColor;
this.gitBranchLabel3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.labelTextColor);
this.gitBranchLabel4 = this.labelTextColor;
this.gitBranchLabel5 = this.labelTextColor;
this.gitBranchLabel6 = this.labelTextColor;
this.gitBranchLabel7 = this.labelTextColor;
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)((0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0), 25);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitBranchLabel0 = this.gitBranchLabel0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.labelTextColor);
this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor;
this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor;
this.gitBranchLabel3 = this.gitBranchLabel3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.labelTextColor);
this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor;
this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor;
this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor;
this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor;
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;
this.tagLabelBorder = this.tagBorder || this.primaryBorderColor;
@ -29055,14 +29025,14 @@ var Theme = /*#__PURE__*/function () {
this.git7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.darken)(this.git7, 25);
}
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;
this.tagLabelBorder = this.tagBorder || this.primaryBorderColor;
@ -29394,14 +29364,14 @@ var Theme = /*#__PURE__*/function () {
this.git7 = this.pie8 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.adjust)(this.primaryColor, {
h: +120
});
this.gitInv0 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.gitInv0 = this.gitInv0 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git0);
this.gitInv1 = this.gitInv1 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git1);
this.gitInv2 = this.gitInv2 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git2);
this.gitInv3 = this.gitInv3 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git3);
this.gitInv4 = this.gitInv4 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git4);
this.gitInv5 = this.gitInv5 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git5);
this.gitInv6 = this.gitInv6 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git6);
this.gitInv7 = this.gitInv7 || (0,khroma__WEBPACK_IMPORTED_MODULE_0__.invert)(this.git7);
this.branchLabelColor = this.branchLabelColor || this.labelTextColor;
this.gitBranchLabel0 = this.branchLabelColor;
this.gitBranchLabel1 = 'white';
@ -29721,7 +29691,7 @@ var detectType = function detectType(text, cnf) {
}
if (text.match(/^\s*gitGraph/)) {
return 'git';
return 'gitGraph';
}
if (text.match(/^\s*flowchart/)) {
@ -129115,7 +129085,7 @@ function combine (array, callback) {
/***/ ((module) => {
"use strict";
module.exports = JSON.parse('{"name":"mermaid","version":"8.14.0","description":"Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.","main":"dist/mermaid.core.js","module":"dist/mermaid.esm.min.mjs","exports":{".":{"require":"./dist/mermaid.core.js","import":"./dist/mermaid.esm.min.mjs"},"./*":"./*"},"keywords":["diagram","markdown","flowchart","sequence diagram","gantt","class diagram","git graph"],"scripts":{"build:development":"webpack --mode development --progress --color","build:production":"webpack --mode production --progress --color","build":"concurrently \\"yarn build:development\\" \\"yarn build:production\\"","postbuild":"documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md","build:watch":"yarn build:development --watch","release":"yarn build","lint":"eslint ./ --ext js,html","lint:fix":"yarn lint --fix","e2e:depr":"yarn lint && jest e2e --config e2e/jest.config.js","cypress":"cypress run","e2e":"start-server-and-test dev http://localhost:9000/ cypress","e2e-upd":"yarn lint && jest e2e -u --config e2e/jest.config.js","dev":"webpack serve --config ./.webpack/webpack.config.e2e.babel.js","test":"yarn lint && jest src/.*","test:watch":"jest --watch src","prepublishOnly":"yarn build && yarn test","prepare":"husky install && yarn build","pre-commit":"lint-staged"},"repository":{"type":"git","url":"https://github.com/knsv/mermaid"},"author":"Knut Sveidqvist","license":"MIT","standard":{"ignore":["**/parser/*.js","dist/**/*.js","cypress/**/*.js"],"globals":["page"]},"dependencies":{"@braintree/sanitize-url":"^6.0.0","cypress-image-snapshot":"^4.0.1","d3":"^7.0.0","dagre":"^0.8.5","dagre-d3":"^0.6.4","dompurify":"2.3.6","graphlib":"^2.1.8","khroma":"^1.4.1","moment-mini":"^2.24.0","stylis":"^4.0.10"},"devDependencies":{"@babel/core":"^7.14.6","@babel/eslint-parser":"^7.14.7","@babel/preset-env":"^7.14.7","@babel/register":"^7.14.5","@commitlint/cli":"^16.0.0","@commitlint/config-conventional":"^16.0.0","babel-jest":"^27.0.6","babel-loader":"^8.2.2","concurrently":"^7.0.0","coveralls":"^3.0.2","css-to-string-loader":"^0.1.3","cypress":"9.5.2","documentation":"13.2.0","eslint":"^8.2.0","eslint-config-prettier":"^8.3.0","eslint-plugin-cypress":"^2.12.1","eslint-plugin-html":"^6.2.0","eslint-plugin-jest":"^26.0.0","eslint-plugin-jsdoc":"^38.0.3","eslint-plugin-markdown":"^2.2.1","eslint-plugin-prettier":"^4.0.0","husky":"^7.0.1","identity-obj-proxy":"^3.0.0","jest":"^27.0.6","jison":"^0.4.18","js-base64":"3.7.2","lint-staged":"^12.1.2","moment":"^2.23.0","path-browserify":"^1.0.1","prettier":"^2.3.2","prettier-plugin-jsdoc":"^0.3.30","start-server-and-test":"^1.12.6","terser-webpack-plugin":"^5.2.4","webpack":"^5.53.0","webpack-cli":"^4.7.2","webpack-dev-server":"^4.3.0","webpack-merge":"^5.8.0","webpack-node-externals":"^3.0.0"},"files":["dist"],"sideEffects":["**/*.css","**/*.scss"]}');
module.exports = JSON.parse('{"name":"mermaid","version":"9.0.0","description":"Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.","main":"dist/mermaid.core.js","module":"dist/mermaid.esm.min.mjs","exports":{".":{"require":"./dist/mermaid.core.js","import":"./dist/mermaid.esm.min.mjs"},"./*":"./*"},"keywords":["diagram","markdown","flowchart","sequence diagram","gantt","class diagram","git graph"],"scripts":{"build:development":"webpack --mode development --progress --color","build:production":"webpack --mode production --progress --color","build":"concurrently \\"yarn build:development\\" \\"yarn build:production\\"","postbuild":"documentation build src/mermaidAPI.js src/config.js src/defaultConfig.js --shallow -f md --markdown-toc false > docs/Setup.md","build:watch":"yarn build:development --watch","release":"yarn build","lint":"eslint ./ --ext js,html","lint:fix":"yarn lint --fix","e2e:depr":"yarn lint && jest e2e --config e2e/jest.config.js","cypress":"cypress run","e2e":"start-server-and-test dev http://localhost:9000/ cypress","e2e-upd":"yarn lint && jest e2e -u --config e2e/jest.config.js","dev":"webpack serve --config ./.webpack/webpack.config.e2e.babel.js","test":"yarn lint && jest src/.*","test:watch":"jest --watch src","prepublishOnly":"yarn build && yarn test","prepare":"husky install && yarn build","pre-commit":"lint-staged"},"repository":{"type":"git","url":"https://github.com/knsv/mermaid"},"author":"Knut Sveidqvist","license":"MIT","standard":{"ignore":["**/parser/*.js","dist/**/*.js","cypress/**/*.js"],"globals":["page"]},"dependencies":{"@braintree/sanitize-url":"^6.0.0","cypress-image-snapshot":"^4.0.1","d3":"^7.0.0","dagre":"^0.8.5","dagre-d3":"^0.6.4","dompurify":"2.3.6","graphlib":"^2.1.8","khroma":"^1.4.1","moment-mini":"^2.24.0","stylis":"^4.0.10"},"devDependencies":{"@babel/core":"^7.14.6","@babel/eslint-parser":"^7.14.7","@babel/preset-env":"^7.14.7","@babel/register":"^7.14.5","@commitlint/cli":"^16.0.0","@commitlint/config-conventional":"^16.0.0","babel-jest":"^27.0.6","babel-loader":"^8.2.2","concurrently":"^7.0.0","coveralls":"^3.0.2","css-to-string-loader":"^0.1.3","cypress":"9.5.2","documentation":"13.2.0","eslint":"^8.2.0","eslint-config-prettier":"^8.3.0","eslint-plugin-cypress":"^2.12.1","eslint-plugin-html":"^6.2.0","eslint-plugin-jest":"^26.0.0","eslint-plugin-jsdoc":"^38.0.3","eslint-plugin-markdown":"^2.2.1","eslint-plugin-prettier":"^4.0.0","husky":"^7.0.1","identity-obj-proxy":"^3.0.0","jest":"^27.0.6","jison":"^0.4.18","js-base64":"3.7.2","lint-staged":"^12.1.2","moment":"^2.23.0","path-browserify":"^1.0.1","prettier":"^2.3.2","prettier-plugin-jsdoc":"^0.3.30","start-server-and-test":"^1.12.6","terser-webpack-plugin":"^5.2.4","webpack":"^5.53.0","webpack-cli":"^4.7.2","webpack-dev-server":"^4.3.0","webpack-merge":"^5.8.0","webpack-node-externals":"^3.0.0"},"files":["dist"],"sideEffects":["**/*.css","**/*.scss"]}');
/***/ })

2
dist/mermaid.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,7 @@
- [Gantt](gantt.md)
- [Pie Chart](pie.md)
- [Requirement Diagram](requirementDiagram.md)
- [Gitgraph (Git) Diagram 🔥🔥🔥](gitgraph.md)
- [Other Examples](examples.md)
- ⚙️ Deployment and Configuration

View File

@ -3,7 +3,7 @@
**Edit this Page** [![N|Solid](img/GitHub-Mark-32px.png)](https://github.com/mermaid-js/mermaid/blob/develop/docs/gitgraph.md)
> A Git Graph is a pictorial representation of git commits and git actions(commands) on various branches.
These kind of diagram are particularyly helpful to developers and devops teams to share their Git branching strategies. For example, it makes it easier to visualize how git flow works.
These kind of diagram are particularly helpful to developers and devops teams to share their Git branching strategies. For example, it makes it easier to visualize how git flow works.
Mermaid can render Git diagrams
@ -28,11 +28,11 @@ In Mermaid, we support the basic git operations like:
- *merge* : To merge an existing branch onto the current branch.
With the help of these key git commands, you will be able to draw a gitgraph in Mermaid very easily and quickly.
Entity names are often capitalised, although there is no accepted standard on this, and it is not required in Mermaid.
Entity names are often capitalized, although there is no accepted standard on this, and it is not required in Mermaid.
## Syntax
Mermaid syntax for Gitgraph is very straigth-forward and simple. It follows a declarative-approach, where each commit is drawn on the timeline in the diagram, in order of its occurance/presence in code. Basically, it follows the insertion order for each command.
Mermaid syntax for Gitgraph is very straight-forward and simple. It follows a declarative-approach, where each commit is drawn on the timeline in the diagram, in order of its occurrences/presence in code. Basically, it follows the insertion order for each command.
First thing you do is to declare your diagram type using the **gitgraph** keyword. This `gitgraph` keyword, tells Mermaid that you wish to draw a gitgraph, and parse the diagram code accordingly.
@ -84,7 +84,7 @@ Let us see how these different commit type look with the help of the following d
commit
commit id: "Reverse" type: REVERSE
commit
commit id: "Hightlight" type: HIGHLIGHT
commit id: "Highlight" type: HIGHLIGHT
commit
```
@ -104,7 +104,7 @@ Let us see how this works with the help of the following diagram:
commit
commit id: "Reverse" type: REVERSE tag: "RC_1"
commit
commit id: "Hightlight" type: HIGHLIGHT tag: "8.8.4"
commit id: "Highlight" type: HIGHLIGHT tag: "8.8.4"
commit
```
@ -182,9 +182,145 @@ After this we made use of the `checkout` keyword to set the current branch as `m
After this we merge the `develop` branch onto the current branch `main`, resulting in a merge commit.
Since the current branch at this point is still `main`, the last two commits are registered against that.
## Gitgraph specific configuration options
In Mermaid, you have the option to configure the gitgraph diagram. You can configure the following options:
- `showBranches` : Boolean, default is `true`. If set to `false`, the branches are not shown in the diagram.
- `showCommitLabel` : Boolean, default is `true`. If set to `false`, the commit labels are not shown in the diagram.
- `mainBranchName` : String, default is `main`. The name of the default/root branch.
Let's look at them one by one.
## Hiding Branch names and lines
Sometimes you may want to hide the branch names and lines from the diagram. You can do this by using the `showBranches` keyword. Bye default its value is `true`. You can set it to false using directives
Usage example:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'showBranches': false}} }%%
gitGraph
commit
branch hotfix
checkout hotfix
commit
branch develop
checkout develop
commit id:"ash" tag:"abc"
branch featureB
checkout featureB
commit type:HIGHLIGHT
checkout main
checkout hotfix
commit type:NORMAL
checkout develop
commit type:REVERSE
checkout featureB
commit
checkout main
merge hotfix
checkout featureB
commit
checkout develop
branch featureA
commit
checkout develop
merge hotfix
checkout featureA
commit
checkout featureB
commit
checkout develop
merge featureA
branch release
checkout release
commit
checkout main
commit
checkout release
merge main
checkout develop
merge release
```
## Hiding commit labels
Sometimes you may want to hide the commit labels from the diagram. You can do this by using the `showCommitLabel` keyword. By default its value is `true`. You can set it to `false` using directives.
Usage example:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'showBranches': false,'showCommitLabel': false}} }%%
gitGraph
commit
branch hotfix
checkout hotfix
commit
branch develop
checkout develop
commit id:"ash"
branch featureB
checkout featureB
commit type:HIGHLIGHT
checkout main
checkout hotfix
commit type:NORMAL
checkout develop
commit type:REVERSE
checkout featureB
commit
checkout main
merge hotfix
checkout featureB
commit
checkout develop
branch featureA
commit
checkout develop
merge hotfix
checkout featureA
commit
checkout featureB
commit
checkout develop
merge featureA
branch release
checkout release
commit
checkout main
commit
checkout release
merge main
checkout develop
merge release
```
## Customizing the main/default branch name
Sometimes you may want to customize the name of the main/default branch. You can do this by using the `mainBranchName` keyword. By default its value is `main`. You can set it to any string using directives.
Usage example:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'base', 'gitGraph': {'showBranches': true, 'showCommitLabel':true,'mainBranchName': 'MetroLine1'}} }%%
gitGraph
commit id:"NewYork"
commit id:"Dallas"
branch MetroLine2
commit id:"LosAngeles"
commit id:"Chicago"
commit id:"Houston"
branch MetroLine3
commit id:"Phoenix"
commit type: HIGHLIGHT id:"Denver"
commit id:"Boston"
checkout MetroLine1
commit id:"Atlanta"
merge MetroLine3
commit id:"Miami"
commit id:"Washington"
merge MetroLine2
commit id:"Boston"
commit id:"Detroit"
commit type:REVERSE id:"SanFrancisco"
```
Looks at the imaginary rail road map created using these Mermaid. Here, we have changed the default main branch name to `MetroLine1`.
## Themes
Mermaid supports a bunch of pre-defined themes which you can use to find the right one for you. PS: you can actually override an existing theme's variable to get your own custom theme going. Learn more about themeing your diagram [here](./theming.md).
Mermaid supports a bunch of pre-defined themes which you can use to find the right one for you. PS: you can actually override an existing theme's variable to get your own custom theme going. Learn more about theming your diagram [here](./theming.md).
Following are the different pre-defined theme options:
- `base`
@ -434,4 +570,172 @@ Let's put them to use, add see how our sample diagram looks like in different th
merge release
```
## Customize using Theme Variables
## Customize using Theme Variables
Mermaid allows you to customize your diagram using theme variables which govern the look and feel of various elements of the diagram.
For understanding let us take a sample diagram with theme `default`, the default values of the theme variables is picked automatically from the theme. Later on we will see how to override the default values of the theme variables.
See how the default theme is used to set the colors for the branches:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'default' } }%%
gitGraph
commit
branch develop
commit tag:"v1.0.0"
commit
checkout main
commit type: HIGHLIGHT
commit
merge develop
commit
branch featureA
commit
```
### Customizing branch colors
You can customize the branch colors using the `git0` to `git7` theme variables. Mermaid allows you to set the colors for up-to 8 branches, where `git0` variable will drive the value of the first branch, `git1` will drive the value of the second branch and so on.
NOTE: Default values for these theme variables are picked from the selected theme. If you want to override the default values, you can use the `initialize` call to add your custom theme variable values.
Example:
Now let's override the default values for the `git0` to `git3` variables:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': {
'git0': '#ff0000',
'git1': '#00ff00',
'git2': '#0000ff',
'git3': '#ff00ff',
'git4': '#00ffff',
'git5': '#ffff00',
'git6': '#ff00ff',
'git7': '#00ffff'
} } }%%
gitGraph
commit
branch develop
commit tag:"v1.0.0"
commit
checkout main
commit type: HIGHLIGHT
commit
merge develop
commit
branch featureA
commit
```
See how the branch colors are changed to the values specified in the theme variables.
### Customizing branch label colors
You can customize the branch label colors using the `gitBranchLabel0` to `gitBranchLabel7` theme variables. Mermaid allows you to set the colors for up-to 8 branches, where `gitBranchLabel0` variable will drive the value of the first branch label, `gitBranchLabel1` will drive the value of the second branch label and so on.
Lets see how the default theme is used to set the colors for the branch labels:
Now let's override the default values for the `gitBranchLabel0` to `gitBranchLabel2` variables:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': {
'gitBranchLabel0': '#ff0000',
'gitBranchLabel1': '#00ff00',
'gitBranchLabel2': '#0000ff'
} } }%%
gitGraph
commit
branch develop
commit tag:"v1.0.0"
commit
checkout main
commit type: HIGHLIGHT
commit
merge develop
commit
branch featureA
commit
```
See how the branch label colors are changed to the values specified in the theme variables.
### Customizing Commit colors
You can customize commit using the `commitLabelColor` and `commitLabelBackground` theme variables for changes in the commit label color and background color respectively.
Example:
Now let's override the default values for the `commitLabelColor` to `commitLabelBackground` variables:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': {
'commitLabelColor': '#ff0000',
'commitLabelBackground': '#00ff00'
} } }%%
gitGraph
commit
branch develop
commit tag:"v1.0.0"
commit
checkout main
commit type: HIGHLIGHT
commit
merge develop
commit
branch featureA
commit
```
See how the commit label color and background color are changed to the values specified in the theme variables.
### Customizing Tag colors
You can customize tag using the `tagLabelColor`,`tagLabelBackground` and `tagLabelBorder` theme variables for changes in the tag label color,tag label background color and tag label border respectively.
Example:
Now let's override the default values for the `tagLabelColor`, `tagLabelBackground` and to `tagLabelBorder` variables:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': {
'tagLabelColor': '#ff0000',
'tagLabelBackground': '#00ff00',
'tagLabelBorder': '#0000ff'
} } }%%
gitGraph
commit
branch develop
commit tag:"v1.0.0"
commit
checkout main
commit type: HIGHLIGHT
commit
merge develop
commit
branch featureA
commit
```
See how the tag colors are changed to the values specified in the theme variables.
### Customizing Highlight commit colors
You can customize the highlight commit colors in relation to the branch it is on using the `gitInv0` to `gitInv7` theme variables. Mermaid allows you to set the colors for up-to 8 branches specific highlight commit, where `gitInv0` variable will drive the value of the first branch's highlight commits, `gitInv1` will drive the value of the second branch's highlight commit label and so on.
Example:
Now let's override the default values for the `git0` to `git3` variables:
```mermaid-example
%%{init: { 'logLevel': 'debug', 'theme': 'default' , 'themeVariables': {
'gitInv0': '#ff0000'
} } }%%
gitGraph
commit
branch develop
commit tag:"v1.0.0"
commit
checkout main
commit type: HIGHLIGHT
commit
merge develop
commit
branch featureA
commit
```
Se how the highlight commit color on the first branch is changed to the value specified in the theme variable `gitInv0`.

View File

@ -17,8 +17,8 @@
/>
<!-- <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css"> -->
<link rel="stylesheet" href="theme.css" />
<!-- <script src="//cdn.jsdelivr.net/npm/mermaid@8.14.0/dist/mermaid.min.js"></script> -->
<script src="http://localhost:9000/mermaid.js"></script>
<script src="//cdn.jsdelivr.net/npm/mermaid@9.0.0/dist/mermaid.min.js"></script>
<!-- <script src="http://localhost:9000/mermaid.js"></script> -->
<script>
// prettier-ignore
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

View File

@ -1,6 +1,6 @@
{
"name": "mermaid",
"version": "8.14.0",
"version": "9.0.0",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
"main": "dist/mermaid.core.js",
"module": "dist/mermaid.esm.min.mjs",

View File

@ -2,11 +2,15 @@ import { log } from '../../logger';
import { random } from '../../utils';
import mermaidAPI from '../../mermaidAPI';
import * as configApi from '../../config';
import { getConfig } from '../../config';
import common from '../common/common';
let mainBranchName = getConfig().gitGraph.mainBranchName;
let commits = {};
let head = null;
let branches = { main: head };
let curBranch = 'main';
let branches = {};
branches[mainBranchName] = head;
let curBranch = mainBranchName;
let direction = 'LR';
let seq = 0;
@ -316,8 +320,10 @@ export const prettyPrint = function () {
export const clear = function () {
commits = {};
head = null;
branches = { main: head };
curBranch = 'main';
let mainBranch = getConfig().gitGraph.mainBranchName;
branches = {};
branches[mainBranch] = null;
curBranch = mainBranch;
seq = 0;
};

View File

@ -206,14 +206,14 @@ class Theme {
this.git6 = darken(this.git6, 25);
this.git7 = darken(this.git7, 25);
}
this.gitInv0 = invert(this.git0);
this.gitInv1 = invert(this.git1);
this.gitInv2 = invert(this.git2);
this.gitInv3 = invert(this.git3);
this.gitInv4 = invert(this.git4);
this.gitInv5 = invert(this.git5);
this.gitInv6 = invert(this.git6);
this.gitInv7 = invert(this.git7);
this.gitInv0 = this.gitInv0 || invert(this.git0);
this.gitInv1 = this.gitInv1 || invert(this.git1);
this.gitInv2 = this.gitInv2 || invert(this.git2);
this.gitInv3 = this.gitInv3 || invert(this.git3);
this.gitInv4 = this.gitInv4 || invert(this.git4);
this.gitInv5 = this.gitInv5 || invert(this.git5);
this.gitInv6 = this.gitInv6 || invert(this.git6);
this.gitInv7 = this.gitInv7 || invert(this.git7);
this.branchLabelColor =
this.branchLabelColor || (this.darkMode ? 'black' : this.labelTextColor);
this.gitBranchLabel0 = this.gitBranchLabel0 || this.branchLabelColor;

View File

@ -197,14 +197,14 @@ class Theme {
this.git5 = lighten(this.pie6 || adjust(this.primaryColor, { h: -90 }), 10);
this.git6 = lighten(this.pie7 || adjust(this.primaryColor, { h: +60 }), 10);
this.git7 = lighten(this.pie8 || adjust(this.primaryColor, { h: +120 }), 20);
this.gitInv0 = invert(this.git0);
this.gitInv1 = invert(this.git1);
this.gitInv2 = invert(this.git2);
this.gitInv3 = invert(this.git3);
this.gitInv4 = invert(this.git4);
this.gitInv5 = invert(this.git5);
this.gitInv6 = invert(this.git6);
this.gitInv7 = invert(this.git7);
this.gitInv0 = this.gitInv0 || invert(this.git0);
this.gitInv1 = this.gitInv1 || invert(this.git1);
this.gitInv2 = this.gitInv2 || invert(this.git2);
this.gitInv3 = this.gitInv3 || invert(this.git3);
this.gitInv4 = this.gitInv4 || invert(this.git4);
this.gitInv5 = this.gitInv5 || invert(this.git5);
this.gitInv6 = this.gitInv6 || invert(this.git6);
this.gitInv7 = this.gitInv7 || invert(this.git7);
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;

View File

@ -228,22 +228,22 @@ class Theme {
this.git6 = darken(this.git6, 25);
this.git7 = darken(this.git7, 25);
}
this.gitInv0 = darken(invert(this.git0), 25);
this.gitInv1 = invert(this.git1);
this.gitInv2 = invert(this.git2);
this.gitInv3 = invert(this.git3);
this.gitInv4 = invert(this.git4);
this.gitInv5 = invert(this.git5);
this.gitInv6 = invert(this.git6);
this.gitInv7 = invert(this.git7);
this.gitBranchLabel0 = invert(this.labelTextColor);
this.gitBranchLabel1 = this.labelTextColor;
this.gitBranchLabel2 = this.labelTextColor;
this.gitBranchLabel3 = invert(this.labelTextColor);
this.gitBranchLabel4 = this.labelTextColor;
this.gitBranchLabel5 = this.labelTextColor;
this.gitBranchLabel6 = this.labelTextColor;
this.gitBranchLabel7 = this.labelTextColor;
this.gitInv0 = this.gitInv0 || darken(invert(this.git0), 25);
this.gitInv1 = this.gitInv1 || invert(this.git1);
this.gitInv2 = this.gitInv2 || invert(this.git2);
this.gitInv3 = this.gitInv3 || invert(this.git3);
this.gitInv4 = this.gitInv4 || invert(this.git4);
this.gitInv5 = this.gitInv5 || invert(this.git5);
this.gitInv6 = this.gitInv6 || invert(this.git6);
this.gitInv7 = this.gitInv7 || invert(this.git7);
this.gitBranchLabel0 = this.gitBranchLabel0 || invert(this.labelTextColor);
this.gitBranchLabel1 = this.gitBranchLabel1 || this.labelTextColor;
this.gitBranchLabel2 = this.gitBranchLabel2 || this.labelTextColor;
this.gitBranchLabel3 = this.gitBranchLabel3 || invert(this.labelTextColor);
this.gitBranchLabel4 = this.gitBranchLabel4 || this.labelTextColor;
this.gitBranchLabel5 = this.gitBranchLabel5 || this.labelTextColor;
this.gitBranchLabel6 = this.gitBranchLabel6 || this.labelTextColor;
this.gitBranchLabel7 = this.gitBranchLabel7 || this.labelTextColor;
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;

View File

@ -198,14 +198,14 @@ class Theme {
this.git6 = darken(this.git6, 25);
this.git7 = darken(this.git7, 25);
}
this.gitInv0 = invert(this.git0);
this.gitInv1 = invert(this.git1);
this.gitInv2 = invert(this.git2);
this.gitInv3 = invert(this.git3);
this.gitInv4 = invert(this.git4);
this.gitInv5 = invert(this.git5);
this.gitInv6 = invert(this.git6);
this.gitInv7 = invert(this.git7);
this.gitInv0 = this.gitInv0 || invert(this.git0);
this.gitInv1 = this.gitInv1 || invert(this.git1);
this.gitInv2 = this.gitInv2 || invert(this.git2);
this.gitInv3 = this.gitInv3 || invert(this.git3);
this.gitInv4 = this.gitInv4 || invert(this.git4);
this.gitInv5 = this.gitInv5 || invert(this.git5);
this.gitInv6 = this.gitInv6 || invert(this.git6);
this.gitInv7 = this.gitInv7 || invert(this.git7);
this.tagLabelColor = this.tagLabelColor || this.primaryTextColor;
this.tagLabelBackground = this.tagLabelBackground || this.primaryColor;

View File

@ -230,14 +230,14 @@ class Theme {
this.git6 = this.pie7 || adjust(this.primaryColor, { h: +60 });
this.git7 = this.pie8 || adjust(this.primaryColor, { h: +120 });
this.gitInv0 = invert(this.git0);
this.gitInv1 = invert(this.git1);
this.gitInv2 = invert(this.git2);
this.gitInv3 = invert(this.git3);
this.gitInv4 = invert(this.git4);
this.gitInv5 = invert(this.git5);
this.gitInv6 = invert(this.git6);
this.gitInv7 = invert(this.git7);
this.gitInv0 = this.gitInv0 || invert(this.git0);
this.gitInv1 = this.gitInv1 || invert(this.git1);
this.gitInv2 = this.gitInv2 || invert(this.git2);
this.gitInv3 = this.gitInv3 || invert(this.git3);
this.gitInv4 = this.gitInv4 || invert(this.git4);
this.gitInv5 = this.gitInv5 || invert(this.git5);
this.gitInv6 = this.gitInv6 || invert(this.git6);
this.gitInv7 = this.gitInv7 || invert(this.git7);
this.branchLabelColor = this.branchLabelColor || this.labelTextColor;
this.gitBranchLabel0 = this.branchLabelColor;