UNPKG

mermaid

Version:

Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.

1,520 lines (1,349 loc) 492 kB
(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_7__, __WEBPACK_EXTERNAL_MODULE_21__, __WEBPACK_EXTERNAL_MODULE_26__, __WEBPACK_EXTERNAL_MODULE_28__, __WEBPACK_EXTERNAL_MODULE_30__, __WEBPACK_EXTERNAL_MODULE_36__, __WEBPACK_EXTERNAL_MODULE_38__, __WEBPACK_EXTERNAL_MODULE_39__, __WEBPACK_EXTERNAL_MODULE_40__, __WEBPACK_EXTERNAL_MODULE_41__, __WEBPACK_EXTERNAL_MODULE_42__, __WEBPACK_EXTERNAL_MODULE_43__, __WEBPACK_EXTERNAL_MODULE_44__, __WEBPACK_EXTERNAL_MODULE_45__) { 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 = 24); /******/ }) /************************************************************************/ /******/ ([ /* 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__(7); 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__(28); 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) { // 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; }; /***/ }), /* 3 */ /***/ (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; }; /***/ }), /* 4 */ /***/ (function(module, exports) { /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {// Copyright Joyent, Inc. and other Node contributors. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to permit // persons to whom the Software is furnished to do so, subject to the // following conditions: // // The above copyright notice and this permission notice shall be included // in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE // USE OR OTHER DEALINGS IN THE SOFTWARE. // resolves . and .. elements in a path array with directory names there // must be no slashes, empty elements, or device names (c:\) in the array // (so also no leading and trailing slashes - it does not distinguish // relative and absolute paths) function normalizeArray(parts, allowAboveRoot) { // if the path tries to go above the root, `up` ends up > 0 var up = 0; for (var i = parts.length - 1; i >= 0; i--) { var last = parts[i]; if (last === '.') { parts.splice(i, 1); } else if (last === '..') { parts.splice(i, 1); up++; } else if (up) { parts.splice(i, 1); up--; } } // if the path is allowed to go above the root, restore leading ..s if (allowAboveRoot) { for (; up--; up) { parts.unshift('..'); } } return parts; } // Split a filename into [root, dir, basename, ext], unix version // 'root' is just a slash, or nothing. var splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/; var splitPath = function(filename) { return splitPathRe.exec(filename).slice(1); }; // path.resolve([from ...], to) // posix version exports.resolve = function() { var resolvedPath = '', resolvedAbsolute = false; for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { var path = (i >= 0) ? arguments[i] : process.cwd(); // Skip empty and invalid entries if (typeof path !== 'string') { throw new TypeError('Arguments to path.resolve must be strings'); } else if (!path) { continue; } resolvedPath = path + '/' + resolvedPath; resolvedAbsolute = path.charAt(0) === '/'; } // At this point the path should be resolved to a full absolute path, but // handle relative paths to be safe (might happen when process.cwd() fails) // Normalize the path resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { return !!p; }), !resolvedAbsolute).join('/'); return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; }; // path.normalize(path) // posix version exports.normalize = function(path) { var isAbsolute = exports.isAbsolute(path), trailingSlash = substr(path, -1) === '/'; // Normalize the path path = normalizeArray(filter(path.split('/'), function(p) { return !!p; }), !isAbsolute).join('/'); if (!path && !isAbsolute) { path = '.'; } if (path && trailingSlash) { path += '/'; } return (isAbsolute ? '/' : '') + path; }; // posix version exports.isAbsolute = function(path) { return path.charAt(0) === '/'; }; // posix version exports.join = function() { var paths = Array.prototype.slice.call(arguments, 0); return exports.normalize(filter(paths, function(p, index) { if (typeof p !== 'string') { throw new TypeError('Arguments to path.join must be strings'); } return p; }).join('/')); }; // path.relative(from, to) // posix version exports.relative = function(from, to) { from = exports.resolve(from).substr(1); to = exports.resolve(to).substr(1); function trim(arr) { var start = 0; for (; start < arr.length; start++) { if (arr[start] !== '') break; } var end = arr.length - 1; for (; end >= 0; end--) { if (arr[end] !== '') break; } if (start > end) return []; return arr.slice(start, end - start + 1); } var fromParts = trim(from.split('/')); var toParts = trim(to.split('/')); var length = Math.min(fromParts.length, toParts.length); var samePartsLength = length; for (var i = 0; i < length; i++) { if (fromParts[i] !== toParts[i]) { samePartsLength = i; break; } } var outputParts = []; for (var i = samePartsLength; i < fromParts.length; i++) { outputParts.push('..'); } outputParts = outputParts.concat(toParts.slice(samePartsLength)); return outputParts.join('/'); }; exports.sep = '/'; exports.delimiter = ':'; exports.dirname = function(path) { var result = splitPath(path), root = result[0], dir = result[1]; if (!root && !dir) { // No dirname whatsoever return '.'; } if (dir) { // It has a dirname, strip trailing slash dir = dir.substr(0, dir.length - 1); } return root + dir; }; exports.basename = function(path, ext) { var f = splitPath(path)[2]; // TODO: make this comparison case-insensitive on windows? if (ext && f.substr(-1 * ext.length) === ext) { f = f.substr(0, f.length - ext.length); } return f; }; exports.extname = function(path) { return splitPath(path)[3]; }; function filter (xs, f) { if (xs.filter) return xs.filter(f); var res = []; for (var i = 0; i < xs.length; i++) { if (f(xs[i], i, xs)) res.push(xs[i]); } return res; } // String.prototype.substr - negative index don't work in IE8 var substr = 'ab'.substr(-1) === 'b' ? function (str, start, len) { return str.substr(start, len) } : function (str, start, len) { if (start < 0) start = str.length + start; return str.substr(start, len); } ; /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(2))) /***/ }), /* 6 */ /***/ (function(module, exports) { /* MIT License http://www.opensource.org/licenses/mit-license.php Author Tobias Koppers @sokra */ // css base code, injected by the css-loader module.exports = function(useSourceMap) { var list = []; // return the list of modules as css string list.toString = function toString() { return this.map(function (item) { var content = cssWithMappingToString(item, useSourceMap); if(item[2]) { return "@media " + item[2] + "{" + content + "}"; } else { return content; } }).join(""); }; // import a list of modules into the list list.i = function(modules, mediaQuery) { if(typeof modules === "string") modules = [[null, modules, ""]]; var alreadyImportedModules = {}; for(var i = 0; i < this.length; i++) { var id = this[i][0]; if(typeof id === "number") alreadyImportedModules[id] = true; } for(i = 0; i < modules.length; i++) { var item = modules[i]; // skip already imported module // this implementation is not 100% perfect for weird media query combinations // when a module is imported multiple times with different media queries. // I hope this will never occur (Hey this way we have smaller bundles) if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) { if(mediaQuery && !item[2]) { item[2] = mediaQuery; } else if(mediaQuery) { item[2] = "(" + item[2] + ") and (" + mediaQuery + ")"; } list.push(item); } } }; return list; }; function cssWithMappingToString(item, useSourceMap) { var content = item[1] || ''; var cssMapping = item[3]; if (!cssMapping) { return content; } if (useSourceMap && typeof btoa === 'function') { var sourceMapping = toComment(cssMapping); var sourceURLs = cssMapping.sources.map(function (source) { return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */' }); return [content].concat(sourceURLs).concat([sourceMapping]).join('\n'); } return [content].join('\n'); } // Adapted from convert-source-map (MIT) function toComment(sourceMap) { // eslint-disable-next-line no-undef var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))); var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64; return '/*# ' + data + ' */'; } /***/ }), /* 7 */ /***/ (function(module, exports) { module.exports = require("moment"); /***/ }), /* 8 */ /***/ (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__(9); 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: