mermaid
Version:
Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.
1,484 lines (1,337 loc) • 462 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("moment"), require("lodash/each"), require("he"), require("d3"), require("dagre-d3-renderer"), require("dagre-layout"), require("lodash/extend"), require("lodash/isArray"), require("lodash/find"), require("lodash/isString"), require("lodash/orderBy"), require("lodash/map"), require("lodash/uniqBy"), require("lodash/maxBy"));
else if(typeof define === 'function' && define.amd)
define(["moment", "lodash/each", "he", "d3", "dagre-d3-renderer", "dagre-layout", "lodash/extend", "lodash/isArray", "lodash/find", "lodash/isString", "lodash/orderBy", "lodash/map", "lodash/uniqBy", "lodash/maxBy"], factory);
else if(typeof exports === 'object')
exports["mermaid"] = factory(require("moment"), require("lodash/each"), require("he"), require("d3"), require("dagre-d3-renderer"), require("dagre-layout"), require("lodash/extend"), require("lodash/isArray"), require("lodash/find"), require("lodash/isString"), require("lodash/orderBy"), require("lodash/map"), require("lodash/uniqBy"), require("lodash/maxBy"));
else
root["mermaid"] = factory(root["moment"], root["lodash/each"], root["he"], root["d3"], root["dagre-d3-renderer"], root["dagre-layout"], root["lodash/extend"], root["lodash/isArray"], root["lodash/find"], root["lodash/isString"], root["lodash/orderBy"], root["lodash/map"], root["lodash/uniqBy"], root["lodash/maxBy"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_4__, __WEBPACK_EXTERNAL_MODULE_18__, __WEBPACK_EXTERNAL_MODULE_23__, __WEBPACK_EXTERNAL_MODULE_25__, __WEBPACK_EXTERNAL_MODULE_27__, __WEBPACK_EXTERNAL_MODULE_33__, __WEBPACK_EXTERNAL_MODULE_35__, __WEBPACK_EXTERNAL_MODULE_36__, __WEBPACK_EXTERNAL_MODULE_37__, __WEBPACK_EXTERNAL_MODULE_38__, __WEBPACK_EXTERNAL_MODULE_39__, __WEBPACK_EXTERNAL_MODULE_40__, __WEBPACK_EXTERNAL_MODULE_41__, __WEBPACK_EXTERNAL_MODULE_42__) {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 21);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setLogLevel = exports.logger = exports.LEVELS = undefined;
var _moment = __webpack_require__(4);
var _moment2 = _interopRequireDefault(_moment);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var LEVELS = exports.LEVELS = {
debug: 1,
info: 2,
warn: 3,
error: 4,
fatal: 5
};
var logger = exports.logger = {
debug: function debug() {},
info: function info() {},
warn: function warn() {},
error: function error() {},
fatal: function fatal() {}
};
var setLogLevel = exports.setLogLevel = function setLogLevel(level) {
logger.debug = function () {};
logger.info = function () {};
logger.warn = function () {};
logger.error = function () {};
logger.fatal = function () {};
if (level <= LEVELS.fatal) {
logger.fatal = console.log.bind(console, '\x1b[35m', format('FATAL'));
}
if (level <= LEVELS.error) {
logger.error = console.log.bind(console, '\x1b[31m', format('ERROR'));
}
if (level <= LEVELS.warn) {
logger.warn = console.log.bind(console, '\x1B[33m', format('WARN'));
}
if (level <= LEVELS.info) {
logger.info = console.log.bind(console, '\x1b[34m', format('INFO'));
}
if (level <= LEVELS.debug) {
logger.debug = console.log.bind(console, '\x1b[32m', format('DEBUG'));
}
};
var format = function format(level) {
var time = (0, _moment2.default)().format('HH:mm:ss.SSS');
return time + ' : ' + level + ' : ';
};
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _d = __webpack_require__(25);
var _d2 = _interopRequireDefault(_d);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*
D3 Text Wrap
By Vijith Assar
http://www.vijithassar.com
http://www.github.com/vijithassar
@vijithassar
Detailed instructions at http://www.github.com/vijithassar/d3textwrap
*/
(function () {
// set this variable to a string value to always force a particular
// wrap method for development purposes, for example to check tspan
// rendering using a foreignobject-enabled browser. set to 'tspan' to
// use tspans and 'foreignobject' to use foreignobject
var forceWrapMethod = false; // by default no wrap method is forced
forceWrapMethod = 'tspans'; // uncomment this statement to force tspans
// force_wrap_method = 'foreignobjects'; // uncomment this statement to force foreignobjects
// exit immediately if something in this location
// has already been defined; the plugin will defer to whatever
// else you're doing in your code
if (_d2.default.selection.prototype.textwrap) {
return false;
}
// double check the force_wrap_method flag
// and reset if someone screwed up the above
// settings
if (typeof forceWrapMethod === 'undefined') {
forceWrapMethod = false;
}
// create the plugin method twice, both for regular use
// and again for use inside the enter() selection
_d2.default.selection.prototype.textwrap = _d2.default.selection.enter.prototype.textwrap = function (bounds, padding) {
// default value of padding is zero if it's undefined
padding = parseInt(padding) || 0;
// save callee into a variable so we can continue to refer to it
// as the function scope changes
var selection = this;
// create a variable to store desired return values in
var returnValue;
// extract wrap boundaries from any d3-selected rect and return them
// in a format that matches the simpler object argument option
var extractBounds = function extractBounds(bounds) {
// discard the nested array wrappers added by d3
var boundingRect = bounds[0][0];
// sanitize the svg element name so we can test against it
var elementType = boundingRect.tagName.toString();
// if it's not a rect, exit
if (elementType !== 'rect') {
return false;
// if it's a rect, proceed to extracting the position attributes
} else {
var boundsExtracted = {};
boundsExtracted.x = _d2.default.select(boundingRect).attr('x') || 0;
boundsExtracted.y = _d2.default.select(boundingRect).attr('y') || 0;
boundsExtracted.width = _d2.default.select(boundingRect).attr('width') || 0;
boundsExtracted.height = _d2.default.select(boundingRect).attr('height') || 0;
// also pass along the getter function
boundsExtracted.attr = bounds.attr;
}
return boundsExtracted;
};
// double check the input argument for the wrapping
// boundaries to make sure it actually contains all
// the information we'll need in order to wrap successfully
var verifyBounds = function verifyBounds(bounds) {
// quickly add a simple getter method so you can use either
// bounds.x or bounds.attr('x') as your notation,
// the latter being a common convention among D3
// developers
if (!bounds.attr) {
bounds.attr = function (property) {
if (this[property]) {
return this[property];
}
};
}
// if it's an associative array, make sure it has all the
// necessary properties represented directly
if ((typeof bounds === 'undefined' ? 'undefined' : _typeof(bounds)) === 'object' && typeof bounds.x !== 'undefined' && typeof bounds.y !== 'undefined' && typeof bounds.width !== 'undefined' && typeof bounds.height !== 'undefined'
// if that's the case, then the bounds are fine
) {
// return the lightly modified bounds
return bounds;
// if it's a numerically indexed array, assume it's a
// d3-selected rect and try to extract the positions
} else if (
// first try to make sure it's an array using Array.isArray
typeof Array.isArray === 'function' && Array.isArray(bounds) ||
// but since Array.isArray isn't always supported, fall
// back to casting to the object to string when it's not
Object.prototype.toString.call(bounds) === '[object Array]') {
// once you're sure it's an array, extract the boundaries
// from the rect
var extractedBounds = extractBounds(bounds);
return extractedBounds;
} else {
// but if the bounds are neither an object nor a numerical
// array, then the bounds argument is invalid and you'll
// need to fix it
return false;
}
};
var applyPadding = function applyPadding(bounds, padding) {
var paddedBounds = bounds;
if (padding !== 0) {
paddedBounds.x = parseInt(paddedBounds.x) + padding;
paddedBounds.y = parseInt(paddedBounds.y) + padding;
paddedBounds.width -= padding * 2;
paddedBounds.height -= padding * 2;
}
return paddedBounds;
};
// verify bounds
var verifiedBounds = verifyBounds(bounds);
// modify bounds if a padding value is provided
if (padding) {
verifiedBounds = applyPadding(verifiedBounds, padding);
}
// check that we have the necessary conditions for this function to operate properly
if (
// selection it's operating on cannot be not empty
selection.length === 0 ||
// d3 must be available
!_d2.default ||
// desired wrapping bounds must be provided as an input argument
!bounds ||
// input bounds must validate
!verifiedBounds) {
// try to return the calling selection if possible
// so as not to interfere with methods downstream in the
// chain
if (selection) {
return selection;
// if all else fails, just return false. if you hit this point then you're
// almost certainly trying to call the textwrap() method on something that
// doesn't make sense!
} else {
return false;
}
// if we've validated everything then we can finally proceed
// to the meat of this operation
} else {
// reassign the verified bounds as the set we want
// to work with from here on; this ensures that we're
// using the same data structure for our bounds regardless
// of whether the input argument was a simple object or
// a d3 selection
bounds = verifiedBounds;
// wrap using html and foreignObjects if they are supported
var wrapWithForeignobjects = function wrapWithForeignobjects(item) {
// establish variables to quickly reference target nodes later
var parent = _d2.default.select(item[0].parentNode);
var textNode = parent.select('text');
var styledLineHeight = textNode.style('line-height');
// extract our desired content from the single text element
var textToWrap = textNode.text();
// remove the text node and replace with a foreign object
textNode.remove();
var foreignObject = parent.append('foreignObject');
// add foreign object and set dimensions, position, etc
foreignObject.attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility').attr('x', bounds.x).attr('y', bounds.y).attr('width', bounds.width).attr('height', bounds.height);
// insert an HTML div
var wrapDiv = foreignObject.append('xhtml:div')
// this class is currently hardcoded
// probably not necessary but easy to
// override using .classed() and for now
// it's nice to avoid a litany of input
// arguments
.attr('class', 'wrapped');
// set div to same dimensions as foreign object
wrapDiv.style('height', bounds.height).style('width', bounds.width)
// insert text content
.html(textToWrap);
if (styledLineHeight) {
wrapDiv.style('line-height', styledLineHeight);
}
returnValue = parent.select('foreignObject');
};
// wrap with tspans if foreignObject is undefined
var wrapWithTspans = function wrapWithTspans(item) {
// operate on the first text item in the selection
var textNode = item[0];
var parent = textNode.parentNode;
var textNodeSelected = _d2.default.select(textNode);
// measure initial size of the text node as rendered
var textNodeHeight = textNode.getBBox().height;
var textNodeWidth = textNode.getBBox().width;
// figure out the line height, either from rendered height
// of the font or attached styling
var lineHeight;
var renderedLineHeight = textNodeHeight;
var styledLineHeight = textNodeSelected.style('line-height');
if (styledLineHeight && parseInt(styledLineHeight)) {
lineHeight = parseInt(styledLineHeight.replace('px', ''));
} else {
lineHeight = renderedLineHeight;
}
// only fire the rest of this if the text content
// overflows the desired dimensions
if (textNodeWidth > bounds.width) {
// store whatever is inside the text node
// in a variable and then zero out the
// initial content; we'll reinsert in a moment
// using tspan elements.
var textToWrap = textNodeSelected.text();
textNodeSelected.text('');
if (textToWrap) {
// keep track of whether we are splitting by spaces
// so we know whether to reinsert those spaces later
var breakDelimiter;
// split at spaces to create an array of individual words
var textToWrapArray;
if (textToWrap.indexOf(' ') !== -1) {
breakDelimiter = ' ';
textToWrapArray = textToWrap.split(' ');
} else {
// if there are no spaces, figure out the split
// points by comparing rendered text width against
// bounds and translating that into character position
// cuts
breakDelimiter = '';
var stringLength = textToWrap.length;
var numberOfSubstrings = Math.ceil(textNodeWidth / bounds.width);
var spliceInterval = Math.floor(stringLength / numberOfSubstrings);
if (!(spliceInterval * numberOfSubstrings >= stringLength)) {
numberOfSubstrings++;
}
textToWrapArray = [];
var substring;
var startPosition;
for (var i = 0; i < numberOfSubstrings; i++) {
startPosition = i * spliceInterval;
substring = textToWrap.substr(startPosition, spliceInterval);
textToWrapArray.push(substring);
}
}
// new array where we'll store the words re-assembled into
// substrings that have been tested against the desired
// maximum wrapping width
var substrings = [];
// computed text length is arguably incorrectly reported for
// all tspans after the first one, in that they will include
// the width of previous separate tspans. to compensate we need
// to manually track the computed text length of all those
// previous tspans and substrings, and then use that to offset
// the miscalculation. this then gives us the actual correct
// position we want to use in rendering the text in the SVG.
var totalOffset = 0;
// object for storing the results of text length computations later
var temp = {};
// loop through the words and test the computed text length
// of the string against the maximum desired wrapping width
for (i = 0; i < textToWrapArray.length; i++) {
var word = textToWrapArray[i];
var previousString = textNodeSelected.text();
var previousWidth = textNode.getComputedTextLength();
// initialize the current word as the first word
// or append to the previous string if one exists
var newstring;
if (previousString) {
newstring = previousString + breakDelimiter + word;
} else {
newstring = word;
}
// add the newest substring back to the text node and
// measure the length
textNodeSelected.text(newstring);
var newWidth = textNode.getComputedTextLength();
// adjust the length by the offset we've tracked
// due to the misreported length discussed above
// if our latest version of the string is too
// big for the bounds, use the previous
// version of the string (without the newest word
// added) and use the latest word to restart the
// process with a new tspan
if (newWidth > bounds.width) {
if (previousString && previousString !== '') {
totalOffset = totalOffset + previousWidth;
temp = { string: previousString, width: previousWidth, offset: totalOffset };
substrings.push(temp);
textNodeSelected.text('');
textNodeSelected.text(word);
// Handle case where there is just one more word to be wrapped
if (i === textToWrapArray.length - 1) {
newstring = word;
textNodeSelected.text(newstring);
newWidth = textNode.getComputedTextLength();
}
}
}
// if we're up to the last word in the array,
// get the computed length as is without
// appending anything further to it
if (i === textToWrapArray.length - 1) {
textNodeSelected.text('');
var finalString = newstring;
if (finalString && finalString !== '') {
if (newWidth - totalOffset > 0) {
newWidth = newWidth - totalOffset;
}
temp = { string: finalString, width: newWidth, offset: totalOffset };
substrings.push(temp);
}
}
}
// append each substring as a tspan
var currentTspan;
// var tspanCount
// double check that the text content has been removed
// before we start appending tspans
textNodeSelected.text('');
for (i = 0; i < substrings.length; i++) {
substring = substrings[i].string;
// only append if we're sure it won't make the tspans
// overflow the bounds.
if (i * lineHeight < bounds.height - lineHeight * 1.5) {
currentTspan = textNodeSelected.append('tspan').text(substring);
// vertical shift to all tspans after the first one
currentTspan.attr('dy', function (d) {
if (i > 0) {
return lineHeight;
}
});
// shift left from default position, which
// is probably based on the full length of the
// text string until we make this adjustment
currentTspan.attr('x', function () {
var xOffset = bounds.x;
if (padding) {
xOffset += padding;
}
return xOffset;
});
}
}
}
}
// position the overall text node, whether wrapped or not
textNodeSelected.attr('y', function () {
var yOffset = bounds.y;
// shift by line-height to move the baseline into
// the bounds – otherwise the text baseline would be
// at the top of the bounds
if (lineHeight) {
yOffset += lineHeight;
}
// shift by padding, if it's there
if (padding) {
yOffset += padding;
}
return yOffset;
});
// shift to the right by the padding value
textNodeSelected.attr('x', function () {
var xOffset = bounds.x;
if (padding) {
xOffset += padding;
}
return xOffset;
});
// assign our modified text node with tspans
// to the return value
returnValue = _d2.default.select(parent).selectAll('text');
};
// variable used to hold the functions that let us
// switch between the wrap methods
var wrapMethod;
// if a wrap method if being forced, assign that
// function
if (forceWrapMethod) {
if (forceWrapMethod === 'foreignobjects') {
wrapMethod = wrapWithForeignobjects;
} else if (forceWrapMethod === 'tspans') {
wrapMethod = wrapWithTspans;
}
}
// if no wrap method is being forced, then instead
// test for browser support of foreignobject and
// use whichever wrap method makes sense accordingly
if (!forceWrapMethod) {
if (typeof SVGForeignObjectElement !== 'undefined') {
wrapMethod = wrapWithForeignobjects;
} else {
wrapMethod = wrapWithTspans;
}
}
// run the desired wrap function for each item
// in the d3 selection that called .textwrap()
for (var i = 0; i < selection.length; i++) {
var item = selection[i];
wrapMethod(item);
}
// return the modified nodes so we can chain other
// methods to them.
return returnValue;
}
};
})();
exports.default = _d2.default;
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = function(module) {
if(!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if(!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}
return module;
};
/***/ }),
/* 3 */
/***/ (function(module, exports) {
// shim for using process in browser
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while(len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
// v8 likes predictible objects
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {
this.fun.apply(null, this.array);
};
process.title = 'browser';
process.browser = true;
process.env = {};
process.argv = [];
process.version = ''; // empty string to avoid regexp issues
process.versions = {};
function noop() {}
process.on = noop;
process.addListener = noop;
process.once = noop;
process.off = noop;
process.removeListener = noop;
process.removeAllListeners = noop;
process.emit = noop;
process.prependListener = noop;
process.prependOnceListener = noop;
process.listeners = function (name) { return [] }
process.binding = function (name) {
throw new Error('process.binding is not supported');
};
process.cwd = function () { return '/' };
process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
process.umask = function() { return 0; };
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = require("moment");
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getSubGraphs = exports.indexNodes = exports.getDepthFirstPos = exports.addSubGraph = exports.defaultStyle = exports.clear = exports.getClasses = exports.getEdges = exports.getVertices = exports.getDirection = exports.bindFunctions = exports.setClickEvent = exports.getTooltip = exports.setClass = exports.setDirection = exports.addClass = exports.updateLink = exports.updateLinkInterpolate = exports.addLink = exports.addVertex = undefined;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _logger = __webpack_require__(0);
var _utils = __webpack_require__(6);
var _utils2 = _interopRequireDefault(_utils);
var _d = __webpack_require__(1);
var _d2 = _interopRequireDefault(_d);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var vertices = {};
var edges = [];
var classes = [];
var subGraphs = [];
var tooltips = {};
var subCount = 0;
var direction;
// Functions to be run after graph rendering
var funs = [];
/**
* Function called by parser when a node definition has been found
* @param id
* @param text
* @param type
* @param style
*/
var addVertex = exports.addVertex = function addVertex(id, text, type, style) {
var txt;
if (typeof id === 'undefined') {
return;
}
if (id.trim().length === 0) {
return;
}
if (typeof vertices[id] === 'undefined') {
vertices[id] = { id: id, styles: [], classes: [] };
}
if (typeof text !== 'undefined') {
txt = text.trim();
// strip quotes if string starts and exnds with a quote
if (txt[0] === '"' && txt[txt.length - 1] === '"') {
txt = txt.substring(1, txt.length - 1);
}
vertices[id].text = txt;
}
if (typeof type !== 'undefined') {
vertices[id].type = type;
}
if (typeof type !== 'undefined') {
vertices[id].type = type;
}
if (typeof style !== 'undefined') {
if (style !== null) {
style.forEach(function (s) {
vertices[id].styles.push(s);
});
}
}
};
/**
* Function called by parser when a link/edge definition has been found
* @param start
* @param end
* @param type
* @param linktext
*/
var addLink = exports.addLink = function addLink(start, end, type, linktext) {
_logger.logger.info('Got edge...', start, end);
var edge = { start: start, end: end, type: undefined, text: '' };
linktext = type.text;
if (typeof linktext !== 'undefined') {
edge.text = linktext.trim();
// strip quotes if string starts and exnds with a quote
if (edge.text[0] === '"' && edge.text[edge.text.length - 1] === '"') {
edge.text = edge.text.substring(1, edge.text.length - 1);
}
}
if (typeof type !== 'undefined') {
edge.type = type.type;
edge.stroke = type.stroke;
}
edges.push(edge);
};
/**
* Updates a link's line interpolation algorithm
* @param pos
* @param interpolate
*/
var updateLinkInterpolate = exports.updateLinkInterpolate = function updateLinkInterpolate(pos, interp) {
if (pos === 'default') {
edges.defaultInterpolate = interp;
} else {
edges[pos].interpolate = interp;
}
};
/**
* Updates a link with a style
* @param pos
* @param style
*/
var updateLink = exports.updateLink = function updateLink(pos, style) {
if (pos === 'default') {
edges.defaultStyle = style;
} else {
if (_utils2.default.isSubstringInArray('fill', style) === -1) {
style.push('fill:none');
}
edges[pos].style = style;
}
};
var addClass = exports.addClass = function addClass(id, style) {
if (typeof classes[id] === 'undefined') {
classes[id] = { id: id, styles: [] };
}
if (typeof style !== 'undefined') {
if (style !== null) {
style.forEach(function (s) {
classes[id].styles.push(s);
});
}
}
};
/**
* Called by parser when a graph definition is found, stores the direction of the chart.
* @param dir
*/
var setDirection = exports.setDirection = function setDirection(dir) {
direction = dir;
};
/**
* Called by parser when a graph definition is found, stores the direction of the chart.
* @param dir
*/
var setClass = exports.setClass = function setClass(id, className) {
if (id.indexOf(',') > 0) {
id.split(',').forEach(function (id2) {
if (typeof vertices[id2] !== 'undefined') {
vertices[id2].classes.push(className);
}
});
} else {
if (typeof vertices[id] !== 'undefined') {
vertices[id].classes.push(className);
}
}
};
var setTooltip = function setTooltip(id, tooltip) {
if (typeof tooltip !== 'undefined') {
tooltips[id] = tooltip;
}
};
var setClickFun = function setClickFun(id, functionName) {
if (typeof functionName === 'undefined') {
return;
}
if (typeof vertices[id] !== 'undefined') {
funs.push(function (element) {
var elem = _d2.default.select(element).select('#' + id);
if (elem !== null) {
elem.on('click', function () {
window[functionName](id);
});
}
});
}
};
var setLink = function setLink(id, linkStr) {
if (typeof linkStr === 'undefined') {
return;
}
if (typeof vertices[id] !== 'undefined') {
funs.push(function (element) {
var elem = _d2.default.select(element).select('#' + id);
if (elem !== null) {
elem.on('click', function () {
window.open(linkStr, 'newTab');
});
}
});
}
};
var getTooltip = exports.getTooltip = function getTooltip(id) {
return tooltips[id];
};
/**
* Called by parser when a graph definition is found, stores the direction of the chart.
* @param dir
*/
var setClickEvent = exports.setClickEvent = function setClickEvent(id, functionName, link, tooltip) {
if (id.indexOf(',') > 0) {
id.split(',').forEach(function (id2) {
setTooltip(id2, tooltip);
setClickFun(id2, functionName);
setLink(id2, link);
});
} else {
setTooltip(id, tooltip);
setClickFun(id, functionName);
setLink(id, link);
}
};
var bindFunctions = exports.bindFunctions = function bindFunctions(element) {
funs.forEach(function (fun) {
fun(element);
});
};
var getDirection = exports.getDirection = function getDirection() {
return direction;
};
/**
* Retrieval function for fetching the found nodes after parsing has completed.
* @returns {{}|*|vertices}
*/
var getVertices = exports.getVertices = function getVertices() {
return vertices;
};
/**
* Retrieval function for fetching the found links after parsing has completed.
* @returns {{}|*|edges}
*/
var getEdges = exports.getEdges = function getEdges() {
return edges;
};
/**
* Retrieval function for fetching the found class definitions after parsing has completed.
* @returns {{}|*|classes}
*/
var getClasses = exports.getClasses = function getClasses() {
return classes;
};
var setupToolTips = function setupToolTips(element) {
var tooltipElem = _d2.default.select('.mermaidTooltip');
if (tooltipElem[0][0] === null) {
tooltipElem = _d2.default.select('body').append('div').attr('class', 'mermaidTooltip').style('opacity', 0);
}
var svg = _d2.default.select(element).select('svg');
var nodes = svg.selectAll('g.node');
nodes.on('mouseover', function () {
var el = _d2.default.select(this);
var title = el.attr('title');
// Dont try to draw a tooltip if no data is provided
if (title === null) {
return;
}
var rect = this.getBoundingClientRect();
tooltipElem.transition().duration(200).style('opacity', '.9');
tooltipElem.html(el.attr('title')).style('left', rect.left + (rect.right - rect.left) / 2 + 'px').style('top', rect.top - 14 + document.body.scrollTop + 'px');
el.classed('hover', true);
}).on('mouseout', function () {
tooltipElem.transition().duration(500).style('opacity', 0);
var el = _d2.default.select(this);
el.classed('hover', false);
});
};
funs.push(setupToolTips);
/**
* Clears the internal graph db so that a new graph can be parsed.
*/
var clear = exports.clear = function clear() {
vertices = {};
classes = {};
edges = [];
funs = [];
funs.push(setupToolTips);
subGraphs = [];
subCount = 0;
tooltips = [];
};
/**
*
* @returns {string}
*/
var defaultStyle = exports.defaultStyle = function defaultStyle() {
return 'fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;';
};
/**
* Clears the internal graph db so that a new graph can be parsed.
*/
var addSubGraph = exports.addSubGraph = function addSubGraph(list, title) {
function uniq(a) {
var prims = { 'boolean': {}, 'number': {}, 'string': {} };
var objs = [];
return a.filter(function (item) {
var type = typeof item === 'undefined' ? 'undefined' : _typeof(item);
if (item === ' ') {
return false;
}
if (type in prims) {
return prims[type].hasOwnProperty(item) ? false : prims[type][item] = true;
} else {
return objs.indexOf(item) >= 0 ? false : objs.push(item);
}
});
}
var nodeList = [];
nodeList = uniq(nodeList.concat.apply(nodeList, list));
var subGraph = { id: 'subGraph' + subCount, nodes: nodeList, title: title };
subGraphs.push(subGraph);
subCount = subCount + 1;
return subGraph.id;
};
var getPosForId = function getPosForId(id) {
var i;
for (i = 0; i < subGraphs.length; i++) {
if (subGraphs[i].id === id) {
return i;
}
}
return -1;
};
var secCount = -1;
var posCrossRef = [];
var indexNodes2 = function indexNodes2(id, pos) {
var nodes = subGraphs[pos].nodes;
secCount = secCount + 1;
if (secCount > 2000) {
return;
}
posCrossRef[secCount] = pos;
// Check if match
if (subGraphs[pos].id === id) {
return {
result: true,
count: 0
};
}
var count = 0;
var posCount = 1;
while (count < nodes.length) {
var childPos = getPosForId(nodes[count]);
// Ignore regular nodes (pos will be -1)
if (childPos >= 0) {
var res = indexNodes2(id, childPos);
if (res.result) {
return {
result: true,
count: posCount + res.count
};
} else {
posCount = posCount + res.count;
}
}
count = count + 1;
}
return {
result: false,
count: posCount
};
};
var getDepthFirstPos = exports.getDepthFirstPos = function getDepthFirstPos(pos) {
return posCrossRef[pos];
};
var indexNodes = exports.indexNodes = function indexNodes() {
secCount = -1;
if (subGraphs.length > 0) {
indexNodes2('none', subGraphs.length - 1, 0);
}
};
var getSubGraphs = exports.getSubGraphs = function getSubGraphs() {
return subGraphs;
};
exports.default = {
addVertex: addVertex,
addLink: addLink,
updateLinkInterpolate: updateLinkInterpolate,
updateLink: updateLink,
addClass: addClass,
setDirection: setDirection,
setClass: setClass,
getTooltip: getTooltip,
setClickEvent: setClickEvent,
bindFunctions: bindFunctions,
getDirection: getDirection,
getVertices: getVertices,
getEdges: getEdges,
getClasses: getClasses,
clear: clear,
defaultStyle: defaultStyle,
addSubGraph: addSubGraph,
getDepthFirstPos: getDepthFirstPos,
indexNodes: indexNodes,
getSubGraphs: getSubGraphs
};
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isSubstringInArray = exports.cloneCssStyles = exports.detectType = undefined;
var _logger = __webpack_require__(0);
/**
* @function detectType
* Detects the type of the graph text.
* ```mermaid
* graph LR
* a-->b
* b-->c
* c-->d
* d-->e
* e-->f
* f-->g
* g-->h
* ```
*
* @param {string} text The text defining the graph
* @returns {string} A graph definition key
*/
var detectType = exports.detectType = function detectType(text) {
text = text.replace(/^\s*%%.*\n/g, '\n');
if (text.match(/^\s*sequenceDiagram/)) {
return 'sequenceDiagram';
}
if (text.match(/^\s*digraph/)) {
return 'dotGraph';
}
if (text.match(/^\s*info/)) {
return 'info';
}
if (text.match(/^\s*gantt/)) {
return 'gantt';
}
if (text.match(/^\s*classDiagram/)) {
_logger.logger.debug('Detected classDiagram syntax');
return 'classDiagram';
}
if (text.match(/^\s*gitGraph/)) {
_logger.logger.debug('Detected gitGraph syntax');
return 'gitGraph';
}
return 'graph';
};
/**
* Copies all relevant CSS content into the graph SVG.
* This allows the SVG to be copied as is while keeping class based styling
* @param {element} svg The root element of the SVG
* @param {object} Hash table of class definitions from the graph definition
*/
var cloneCssStyles = exports.cloneCssStyles = function cloneCssStyles(svg, classes) {
var usedStyles = '';
var sheets = document.styleSheets;
var rule = void 0;
for (var i = 0; i < sheets.length; i++) {
// Avoid multiple inclusion on pages with multiple graphs
if (sheets[i].title !== 'mermaid-svg-internal-css') {
try {
var rules = sheets[i].cssRules;
if (rules !== null) {
for (var j = 0; j < rules.length; j++) {
rule = rules[j];
if (typeof rule.style !== 'undefined') {
var elems = svg.querySelectorAll(rule.selectorText);
if (elems.length > 0) {
usedStyles += rule.selectorText + ' { ' + rule.style.cssText + '}\n';
}
}
}
}
} catch (err) {
if (typeof rule !== 'undefined') {
_logger.logger.warn('Invalid CSS selector "' + rule.selectorText + '"', err);
}
}
}
}
var defaultStyles = '';
var embeddedStyles = '';
for (var className in classes) {
if (classes.hasOwnProperty(className) && typeof className !== 'undefined') {
if (className === 'default') {
if (classes.default.styles instanceof Array) {
defaultStyles += '#' + svg.id.trim() + ' .node' + '>rect { ' + classes[className].styles.join('; ') + '; }\n';
}
if (classes.default.nodeLabelStyles instanceof Array) {
defaultStyles += '#' + svg.id.trim() + ' .node text ' + ' { ' + classes[className].nodeLabelStyles.join('; ') + '; }\n';
}
if (classes.default.edgeLabelStyles instanceof Array) {
defaultStyles += '#' + svg.id.trim() + ' .edgeLabel text ' + ' { ' + classes[className].edgeLabelStyles.join('; ') + '; }\n';
}
if (classes.default.clusterStyles instanceof Array) {
defaultStyles += '#' + svg.id.trim() + ' .cluster rect ' + ' { ' + classes[className].clusterStyles.join('; ') + '; }\n';
}
} else {
if (classes[className].styles instanceof Array) {
embeddedStyles += '#' + svg.id.trim() + ' .' + className + '>rect, .' + className + '>polygon, .' + className + '>circle, .' + className + '>ellipse { ' + classes[className].styles.join('; ') + '; }\n';
}
}
}
}
if (usedStyles !== '' || defaultStyles !== '' || embeddedStyles !== '') {
var s = document.createElement('style');
s.setAttribute('type', 'text/css');
s.setAttribute('title', 'mermaid-svg-internal-css');
s.innerHTML = '/* <![CDATA[ */\n';
// Make this CSS local to this SVG
if (defaultStyles !== '') {
s.innerHTML += defaultStyles;
}
if (usedStyles !== '') {
s.innerHTML += usedStyles;
}
if (embeddedStyles !== '') {
s.innerHTML += embeddedStyles;
}
s.innerHTML += '/* ]]> */\n';
svg.insertBefore(s, svg.firstChild);
}
};
/**
* @function isSubstringInArray
* Detects whether a substring in present in a given array
* @param {string} str The substring to detect
* @param {array} arr The array to search
* @returns {number} the array index containing the substring or -1 if not present
**/
var isSubstringInArray = exports.isSubstringInArray = function isSubstringInArray(str, arr) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].match(str)) return i;
}
return -1;
};
exports.default = {
detectType: detectType,
cloneCssStyles: cloneCssStyles,
isSubstringInArray: isSubstringInArray
};
/***/ }),
/* 7 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(module, process) {
/* parser generated by jison 0.4.17 */
/*
Returns a Parser object of the following structure:
Parser: {
yy: {}
}
Parser.prototype: {
yy: {},
trace: function(),
symbols_: {associative list: name ==> number},
terminals_: {associative list: number ==> name},
productions_: [...],
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
table: [...],
defaultActions: {...},
parseError: function(str, hash),
parse: function(input),
lexer: {
EOF: 1,
parseError: function(str, hash),
setInput: function(input),
input: function(),
unput: function(str),
more: function(),
less: function(n),
pastInput: function(),
upcomingInput: function(),
showPosition: function(),
test_match: function(regex_match_array, rule_index),
next: function(),
lex: function(),
begin: function(condition),
popState: function(),
_currentRules: function(),
topState: function(),
pushState: function(condition),
options: {
ranges: boolean (optional: true ==> token location info will include a .range[] member)
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
},
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
rules: [...],
conditions: {associative list: name ==> set},
}
}
token location info (@$, _$, etc.): {
first_line: n,
last_line: n,
first_column: n,
last_column: n,
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
}
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
text: (matched text)
token: (the produced terminal token, if any)
line: (yylineno)
}
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
loc: (yylloc)
expected: (string describing the set of expected tokens)
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
}
*/
var parser = function () {
var o = function o(k, v, _o, l) {
for (_o = _o || {}, l = k.length; l--;