mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-17 22:39:56 +02:00
Added logger for dealing with issue #179
Added markdown files for the documentation. parseError exposed from the mermaidAPI
This commit is contained in:
337
dist/mermaid.js
vendored
337
dist/mermaid.js
vendored
@@ -25049,19 +25049,19 @@ module.exports={
|
||||
|
||||
},{}],87:[function(require,module,exports){
|
||||
/* global window */
|
||||
//console.log('Setting up d3');
|
||||
//log.debug('Setting up d3');
|
||||
var d3;
|
||||
|
||||
if (require) {
|
||||
try {
|
||||
d3 = require("d3");
|
||||
} catch (e) {
|
||||
console.log('Exception ... but ok');
|
||||
//console.log(e);
|
||||
//log.debug('Exception ... but ok');
|
||||
//log.debug(e);
|
||||
}
|
||||
}
|
||||
|
||||
//console.log(d3);
|
||||
//log.debug(d3);
|
||||
|
||||
if (!d3) {
|
||||
//if(typeof window !== 'undefined')
|
||||
@@ -25072,10 +25072,10 @@ if (!d3) {
|
||||
// window = {};
|
||||
// window.d3 = d3;
|
||||
//}
|
||||
//console.log('window');
|
||||
//console.log(window);
|
||||
//log.debug('window');
|
||||
//log.debug(window);
|
||||
module.exports = d3;
|
||||
|
||||
/* jshint ignore:start */
|
||||
/*
|
||||
|
||||
D3 Text Wrap
|
||||
@@ -25530,11 +25530,12 @@ Detailed instructions at http://www.github.com/vijithassar/d3textwrap
|
||||
}
|
||||
|
||||
})();
|
||||
/* jshint ignore:end */
|
||||
},{"d3":1}],88:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 15-01-14.
|
||||
*/
|
||||
|
||||
var log = require('../../logger').create();
|
||||
var message = '';
|
||||
var info = false;
|
||||
|
||||
@@ -25555,16 +25556,16 @@ exports.getInfo = function(){
|
||||
};
|
||||
|
||||
exports.parseError = function(err,hash){
|
||||
mermaid.parseError(err,hash);
|
||||
mermaidAPI.parseError(err,hash);
|
||||
};
|
||||
},{}],89:[function(require,module,exports){
|
||||
},{"../../logger":104}],89:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
var db = require('./exampleDb');
|
||||
var exampleParser = require('./parser/example.js');
|
||||
var d3 = require('../../d3');
|
||||
|
||||
var log = require('../../logger').create();
|
||||
/**
|
||||
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
||||
* @param text
|
||||
@@ -25602,7 +25603,7 @@ exports.draw = function (txt, id, ver) {
|
||||
svg.attr("width", 400 );
|
||||
//svg.attr("viewBox", '0 0 300 150');
|
||||
};
|
||||
},{"../../d3":87,"./exampleDb":88,"./parser/example.js":90}],90:[function(require,module,exports){
|
||||
},{"../../d3":87,"../../logger":104,"./exampleDb":88,"./parser/example.js":90}],90:[function(require,module,exports){
|
||||
(function (process){
|
||||
/* parser generated by jison 0.4.15 */
|
||||
/*
|
||||
@@ -26231,14 +26232,14 @@ if (typeof module !== 'undefined' && require.main === module) {
|
||||
}).call(this,require("1YiZ5S"))
|
||||
},{"1YiZ5S":82,"fs":80,"path":81}],91:[function(require,module,exports){
|
||||
/* global window */
|
||||
|
||||
var log = require('../../logger').create();
|
||||
var dagreD3;
|
||||
//console.log('setting up dagre-d3');
|
||||
//log.debug('setting up dagre-d3');
|
||||
if (require) {
|
||||
try {
|
||||
dagreD3 = require("dagre-d3");
|
||||
//console.log('Got it (dagre-d3)');
|
||||
} catch (e) {console.log('Could not load dagre-d3');}
|
||||
//log.debug('Got it (dagre-d3)');
|
||||
} catch (e) {log.debug('Could not load dagre-d3');}
|
||||
}
|
||||
|
||||
if (!dagreD3) {
|
||||
@@ -26247,7 +26248,7 @@ if (!dagreD3) {
|
||||
|
||||
module.exports = dagreD3;
|
||||
|
||||
},{"dagre-d3":2}],92:[function(require,module,exports){
|
||||
},{"../../logger":104,"dagre-d3":2}],92:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-12-11.
|
||||
*/
|
||||
@@ -26256,6 +26257,8 @@ var flow = require('./parser/flow');
|
||||
var dot = require('./parser/dot');
|
||||
var d3 = require('../../d3');
|
||||
var dagreD3 = require('./dagre-d3');
|
||||
var log = require('../../logger').create();
|
||||
|
||||
var conf = {
|
||||
};
|
||||
module.exports.setConf = function(cnf){
|
||||
@@ -26299,7 +26302,7 @@ exports.addVertices = function (vert, g) {
|
||||
*/
|
||||
var classStr = '';
|
||||
|
||||
//console.log(vertice.classes);
|
||||
//log.debug(vertice.classes);
|
||||
|
||||
if(vertice.classes.length >0){
|
||||
classStr = vertice.classes.join(" ");
|
||||
@@ -26480,7 +26483,7 @@ exports.getClasses = function (text, isDot) {
|
||||
* @param id
|
||||
*/
|
||||
exports.draw = function (text, id,isDot) {
|
||||
|
||||
log.debug('Drawing flowchart');
|
||||
var parser;
|
||||
graph.clear();
|
||||
if(isDot){
|
||||
@@ -26533,7 +26536,7 @@ exports.draw = function (text, id,isDot) {
|
||||
// Fetch the verices/nodes and edges/links from the parsed graph definition
|
||||
var vert = graph.getVertices();
|
||||
|
||||
//console.log(vert);
|
||||
//log.debug(vert);
|
||||
var edges = graph.getEdges();
|
||||
|
||||
i = 0;
|
||||
@@ -26544,7 +26547,7 @@ exports.draw = function (text, id,isDot) {
|
||||
d3.selectAll('cluster').append('text');
|
||||
|
||||
for(j=0;j<subG.nodes.length;j++){
|
||||
//console.log('Setting node',subG.nodes[j],' to subgraph '+id);
|
||||
//log.debug('Setting node',subG.nodes[j],' to subgraph '+id);
|
||||
g.setParent(subG.nodes[j],subG.id);
|
||||
}
|
||||
}
|
||||
@@ -26688,7 +26691,7 @@ exports.draw = function (text, id,isDot) {
|
||||
|
||||
if (subG.title !== 'undefined') {
|
||||
var clusterRects = document.querySelectorAll('#' + id + ' #' + subG.id + ' rect');
|
||||
//console.log('looking up: #' + id + ' #' + subG.id)
|
||||
//log.debug('looking up: #' + id + ' #' + subG.id)
|
||||
var clusterEl = document.querySelectorAll('#' + id + ' #' + subG.id);
|
||||
|
||||
var xPos = clusterRects[0].x.baseVal.value;
|
||||
@@ -26715,11 +26718,11 @@ exports.draw = function (text, id,isDot) {
|
||||
};
|
||||
|
||||
|
||||
},{"../../d3":87,"./dagre-d3":91,"./graphDb":93,"./parser/dot":94,"./parser/flow":95}],93:[function(require,module,exports){
|
||||
},{"../../d3":87,"../../logger":104,"./dagre-d3":91,"./graphDb":93,"./parser/dot":94,"./parser/flow":95}],93:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-11-03.
|
||||
*/
|
||||
|
||||
var log = require('../../logger').create();
|
||||
var vertices = {};
|
||||
var edges = [];
|
||||
var classes = [];
|
||||
@@ -26781,7 +26784,7 @@ exports.addVertex = function (id, text, type, style) {
|
||||
* @param linktext
|
||||
*/
|
||||
exports.addLink = function (start, end, type, linktext) {
|
||||
//console.log('Got edge', start, end);
|
||||
//log.debug('Got edge', start, end);
|
||||
var edge = {start: start, end: end, type: undefined, text: ''};
|
||||
linktext = type.text;
|
||||
|
||||
@@ -26876,7 +26879,7 @@ exports.setClickEvent = function (id,functionName) {
|
||||
}
|
||||
});
|
||||
}else{
|
||||
//console.log('Checking now for ::'+id);
|
||||
//log.debug('Checking now for ::'+id);
|
||||
if(typeof vertices[id] !== 'undefined'){
|
||||
funs.push(function(){
|
||||
var elem = document.getElementById(id);
|
||||
@@ -26884,7 +26887,7 @@ exports.setClickEvent = function (id,functionName) {
|
||||
elem.onclick = function(){eval(functionName+'(\'' + id + '\')');}; // jshint ignore:line
|
||||
}
|
||||
else{
|
||||
//console.log('id was null: '+id);
|
||||
//log.debug('id was null: '+id);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -26969,8 +26972,8 @@ exports.addSubGraph = function (list, title) {
|
||||
|
||||
|
||||
var subGraph = {id:'subGraph'+subCount, nodes:nodeList,title:title};
|
||||
//console.log('subGraph:' + subGraph.title + subGraph.id);
|
||||
//console.log(subGraph.nodes);
|
||||
//log.debug('subGraph:' + subGraph.title + subGraph.id);
|
||||
//log.debug(subGraph.nodes);
|
||||
subGraphs.push(subGraph);
|
||||
subCount = subCount + 1;
|
||||
return subGraph.id;
|
||||
@@ -26980,11 +26983,11 @@ var getPosForId = function(id){
|
||||
var i;
|
||||
for(i=0;i<subGraphs.length;i++){
|
||||
if(subGraphs[i].id===id){
|
||||
//console.log('Found pos for ',id,' ',i);
|
||||
//log.debug('Found pos for ',id,' ',i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
//console.log('No pos found for ',id,' ',i);
|
||||
//log.debug('No pos found for ',id,' ',i);
|
||||
return -1;
|
||||
};
|
||||
var secCount = -1;
|
||||
@@ -27050,9 +27053,9 @@ exports.getSubGraphs = function (list) {
|
||||
};
|
||||
|
||||
exports.parseError = function(err,hash){
|
||||
mermaid.parseError(err,hash);
|
||||
mermaidAPI.parseError(err,hash);
|
||||
};
|
||||
},{}],94:[function(require,module,exports){
|
||||
},{"../../logger":104}],94:[function(require,module,exports){
|
||||
(function (process){
|
||||
/* parser generated by jison 0.4.15 */
|
||||
/*
|
||||
@@ -28720,6 +28723,7 @@ if (typeof module !== 'undefined' && require.main === module) {
|
||||
* Created by knut on 15-01-14.
|
||||
*/
|
||||
var moment = require('moment');
|
||||
var log = require('../../logger').create();
|
||||
|
||||
var dateFormat = '';
|
||||
var title = '';
|
||||
@@ -28777,8 +28781,8 @@ exports.getTasks=function(){
|
||||
|
||||
|
||||
var getStartDate = function(prevTime, dateFormat, str){
|
||||
//console.log('Deciding start date:'+str);
|
||||
//console.log('with dateformat:'+dateFormat);
|
||||
//log.debug('Deciding start date:'+str);
|
||||
//log.debug('with dateformat:'+dateFormat);
|
||||
|
||||
str = str.trim();
|
||||
|
||||
@@ -28799,9 +28803,9 @@ var getStartDate = function(prevTime, dateFormat, str){
|
||||
if(moment(str,dateFormat.trim(),true).isValid()){
|
||||
return moment(str,dateFormat.trim(),true).toDate();
|
||||
}else{
|
||||
console.log('Invalid date:'+str);
|
||||
console.log('With date format:'+dateFormat.trim());
|
||||
//console.log('----');
|
||||
log.debug('Invalid date:'+str);
|
||||
log.debug('With date format:'+dateFormat.trim());
|
||||
//log.debug('----');
|
||||
}
|
||||
|
||||
// Default date - now
|
||||
@@ -28948,14 +28952,14 @@ exports.addTask = function(descr,data){
|
||||
};
|
||||
|
||||
exports.parseError = function(err,hash){
|
||||
mermaid.parseError(err,hash);
|
||||
mermaidAPI.parseError(err,hash);
|
||||
};
|
||||
},{"moment":85}],97:[function(require,module,exports){
|
||||
},{"../../logger":104,"moment":85}],97:[function(require,module,exports){
|
||||
var gantt = require('./parser/gantt').parser;
|
||||
gantt.yy = require('./ganttDb');
|
||||
var d3 = require('../../d3');
|
||||
var moment = require('moment');
|
||||
|
||||
var log = require('../../logger').create();
|
||||
|
||||
var daysInChart;
|
||||
var conf = {
|
||||
@@ -29318,7 +29322,7 @@ module.exports.draw = function (text, id) {
|
||||
if (i > 0) {
|
||||
for (var j = 0; j < i; j++) {
|
||||
prevGap += numOccurances[i - 1][1];
|
||||
// console.log(prevGap);
|
||||
// log.debug(prevGap);
|
||||
return d[1] * theGap / 2 + prevGap * theGap + theTopPad;
|
||||
}
|
||||
} else {
|
||||
@@ -29378,7 +29382,7 @@ module.exports.draw = function (text, id) {
|
||||
return getCounts(arr)[word] || 0;
|
||||
}
|
||||
};
|
||||
},{"../../d3":87,"./ganttDb":96,"./parser/gantt":98,"moment":85}],98:[function(require,module,exports){
|
||||
},{"../../d3":87,"../../logger":104,"./ganttDb":96,"./parser/gantt":98,"moment":85}],98:[function(require,module,exports){
|
||||
(function (process){
|
||||
/* parser generated by jison 0.4.15 */
|
||||
/*
|
||||
@@ -30783,15 +30787,15 @@ var actors = {};
|
||||
var actorKeys = [];
|
||||
var messages = [];
|
||||
var notes = [];
|
||||
var log = require('../../logger').create();
|
||||
|
||||
|
||||
exports.addActor = function(id,name,description){
|
||||
//console.log('Adding actor: '+id);
|
||||
actors[id] = {name:name, description:description};
|
||||
actorKeys.push(id);
|
||||
};
|
||||
|
||||
exports.addMessage = function(idFrom, idTo, message, answer){
|
||||
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
||||
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
|
||||
};
|
||||
|
||||
@@ -30799,7 +30803,7 @@ exports.addMessage = function(idFrom, idTo, message, answer){
|
||||
*
|
||||
*/
|
||||
exports.addSignal = function(idFrom, idTo, message, messageType){
|
||||
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
||||
log.debug('Adding message from='+idFrom+' to='+idTo+' message='+message+' type='+messageType);
|
||||
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
|
||||
};
|
||||
|
||||
@@ -30859,7 +30863,7 @@ exports.addNote = function (actor, placement, message){
|
||||
|
||||
|
||||
exports.parseError = function(err,hash){
|
||||
mermaid.parseError(err,hash);
|
||||
mermaidAPI.parseError(err,hash);
|
||||
};
|
||||
|
||||
exports.apply = function(param){
|
||||
@@ -30868,7 +30872,7 @@ exports.apply = function(param){
|
||||
exports.apply(item);
|
||||
});
|
||||
} else {
|
||||
// console.log(param);
|
||||
// log.debug(param);
|
||||
switch(param.type){
|
||||
case 'addActor':
|
||||
exports.addActor(param.actor, param.actor, param.actor);
|
||||
@@ -30880,7 +30884,7 @@ exports.apply = function(param){
|
||||
exports.addSignal(param.from, param.to, param.msg, param.signalType);
|
||||
break;
|
||||
case 'loopStart':
|
||||
//console.log('Loop text: ',param.loopText);
|
||||
//log.debug('Loop text: ',param.loopText);
|
||||
exports.addSignal(undefined, undefined, param.loopText, param.signalType);
|
||||
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START);
|
||||
break;
|
||||
@@ -30888,7 +30892,7 @@ exports.apply = function(param){
|
||||
exports.addSignal(undefined, undefined, undefined, param.signalType);
|
||||
break;
|
||||
case 'optStart':
|
||||
//console.log('Loop text: ',param.loopText);
|
||||
//log.debug('Loop text: ',param.loopText);
|
||||
exports.addSignal(undefined, undefined, param.optText, param.signalType);
|
||||
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START);
|
||||
break;
|
||||
@@ -30896,7 +30900,7 @@ exports.apply = function(param){
|
||||
exports.addSignal(undefined, undefined, undefined, param.signalType);
|
||||
break;
|
||||
case 'altStart':
|
||||
//console.log('Loop text: ',param.loopText);
|
||||
//log.debug('Loop text: ',param.loopText);
|
||||
exports.addSignal(undefined, undefined, param.altText, param.signalType);
|
||||
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START);
|
||||
break;
|
||||
@@ -30907,11 +30911,9 @@ exports.apply = function(param){
|
||||
exports.addSignal(undefined, undefined, undefined, param.signalType);
|
||||
break;
|
||||
}
|
||||
|
||||
// console.log('xxx',param);
|
||||
}
|
||||
};
|
||||
},{}],101:[function(require,module,exports){
|
||||
},{"../../logger":104}],101:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-11-23.
|
||||
*/
|
||||
@@ -30920,6 +30922,8 @@ var sq = require('./parser/sequenceDiagram').parser;
|
||||
sq.yy = require('./sequenceDb');
|
||||
var svgDraw = require('./svgDraw');
|
||||
var d3 = require('../../d3');
|
||||
var log = require('../../logger').create();
|
||||
|
||||
var conf = {
|
||||
|
||||
diagramMarginX:50,
|
||||
@@ -31294,7 +31298,7 @@ module.exports.draw = function (text, id) {
|
||||
if(conf.useMaxWidth) {
|
||||
diagram.attr("height", '100%');
|
||||
diagram.attr("width", '100%');
|
||||
diagram.attr('style', 'max-width:' + (width) + 'px;')
|
||||
diagram.attr('style', 'max-width:' + (width) + 'px;');
|
||||
}else{
|
||||
diagram.attr("height",height);
|
||||
diagram.attr("width", width );
|
||||
@@ -31302,10 +31306,11 @@ module.exports.draw = function (text, id) {
|
||||
diagram.attr("viewBox", (box.startx-conf.diagramMarginX) + ' -' +conf.diagramMarginY + ' ' + width + ' ' + height);
|
||||
};
|
||||
|
||||
},{"../../d3":87,"./parser/sequenceDiagram":99,"./sequenceDb":100,"./svgDraw":102}],102:[function(require,module,exports){
|
||||
},{"../../d3":87,"../../logger":104,"./parser/sequenceDiagram":99,"./sequenceDb":100,"./svgDraw":102}],102:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-12-20.
|
||||
*/
|
||||
var log = require('../../logger').create();
|
||||
exports.drawRect = function(elem , rectData){
|
||||
var rectElem = elem.append("rect");
|
||||
rectElem.attr("x", rectData.x);
|
||||
@@ -31550,14 +31555,20 @@ exports.getNoteRect = function(){
|
||||
return rect;
|
||||
};
|
||||
|
||||
},{}],103:[function(require,module,exports){
|
||||
},{"../../logger":104}],103:[function(require,module,exports){
|
||||
(function (global){
|
||||
/**
|
||||
* Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid functionality and to render
|
||||
* the diagrams to svg code.
|
||||
*/
|
||||
var he = require('he');
|
||||
var mermaidAPI = require('./mermaidAPI');
|
||||
var nextId = 0;
|
||||
var log = require('./logger').create();
|
||||
|
||||
module.exports.mermaidAPI = mermaidAPI;
|
||||
/**
|
||||
* ## init
|
||||
* Function that goes through the document to find the chart definitions in there and render them.
|
||||
*
|
||||
* The function tags the processed attributes with the attribute data-processed and ignores found elements with the
|
||||
@@ -31568,21 +31579,19 @@ module.exports.mermaidAPI = mermaidAPI;
|
||||
* - an array of DOM nodes (as would come from a jQuery selector)
|
||||
* - a W3C selector, a la `.mermaid`
|
||||
*
|
||||
* ```
|
||||
* ```mermaid
|
||||
* graph LR;
|
||||
* a(Find elements)-->b{Processed};
|
||||
* b-->|Yes|c(Leave element);
|
||||
* c-->|No |d(Transform);
|
||||
* a(Find elements)-->b{Processed}
|
||||
* b-->|Yes|c(Leave element)
|
||||
* b-->|No |d(Transform)
|
||||
* ```
|
||||
*/
|
||||
/**
|
||||
* Renders the mermaid diagrams
|
||||
* @* param nodes- a css selector or an array of nodes
|
||||
* @param nodes a css selector or an array of nodes
|
||||
*/
|
||||
var init = function () {
|
||||
var nodes;
|
||||
if(arguments.length === 2){
|
||||
// sequence config was passed as #1
|
||||
/*! sequence config was passed as #1 */
|
||||
if(typeof arguments[0] !== 'undefined'){
|
||||
mermaid.sequenceConfig = arguments[0];
|
||||
}
|
||||
@@ -31596,7 +31605,7 @@ var init = function () {
|
||||
nodes = nodes === undefined ? document.querySelectorAll('.mermaid')
|
||||
: typeof nodes === "string" ? document.querySelectorAll(nodes)
|
||||
: nodes instanceof Node ? [nodes]
|
||||
// Last case - sequence config was passed pick next
|
||||
/*! Last case - sequence config was passed pick next */
|
||||
: nodes;
|
||||
|
||||
var i;
|
||||
@@ -31605,7 +31614,15 @@ var init = function () {
|
||||
mermaidAPI.initialize(mermaid_config);
|
||||
|
||||
}
|
||||
|
||||
|
||||
log.debug('STar On Load (0): '+mermaid.startOnLoad);
|
||||
if(typeof mermaid.startOnLoad !== 'undefined'){
|
||||
log.debug('STar On Load: '+mermaid.startOnLoad);
|
||||
mermaidAPI.initialize({startOnLoad:mermaid.startOnLoad});
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(typeof mermaid.ganttConfig !== 'undefined'){
|
||||
mermaidAPI.initialize({gantt:mermaid.ganttConfig});
|
||||
}
|
||||
@@ -31617,7 +31634,7 @@ var init = function () {
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
var element = nodes[i];
|
||||
|
||||
// Check if previously processed
|
||||
/*! Check if previously processed */
|
||||
if(!element.getAttribute("data-processed")) {
|
||||
element.setAttribute("data-processed", true);
|
||||
} else {
|
||||
@@ -31637,11 +31654,10 @@ var init = function () {
|
||||
|
||||
};
|
||||
|
||||
exports.tester = function(){};
|
||||
|
||||
exports.init = init;
|
||||
|
||||
exports.parse = mermaidAPI.parse;
|
||||
/**
|
||||
* ## version
|
||||
* Function returning version information
|
||||
* @returns {string} A string containing the version info
|
||||
*/
|
||||
@@ -31649,10 +31665,16 @@ exports.version = function(){
|
||||
return 'v'+require('../package.json').version;
|
||||
};
|
||||
|
||||
/**
|
||||
* ## initialize
|
||||
* This function overrides the default configuration.
|
||||
* @param config
|
||||
*/
|
||||
exports.initialize = function(config){
|
||||
mermaidAPI.initialize(config);
|
||||
};
|
||||
|
||||
|
||||
var equals = function (val, variable){
|
||||
if(typeof variable === 'undefined'){
|
||||
return false;
|
||||
@@ -31662,6 +31684,15 @@ var equals = function (val, variable){
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Global mermaid object. Contains the functions:
|
||||
* * init
|
||||
* * initialize
|
||||
* * version
|
||||
* * parse
|
||||
* * parseError
|
||||
* * render
|
||||
*/
|
||||
global.mermaid = {
|
||||
startOnLoad: true,
|
||||
htmlLabels: true,
|
||||
@@ -31679,14 +31710,26 @@ global.mermaid = {
|
||||
return mermaidAPI.parse(text);
|
||||
},
|
||||
parseError: function(err, hash) {
|
||||
console.log('Mermaid Syntax error:');
|
||||
console.log(err);
|
||||
log.debug('Mermaid Syntax error:');
|
||||
log.debug(err);
|
||||
},
|
||||
render:function(id, text,callback, element){
|
||||
return mermaidAPI.render(id, text,callback, element);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* ## parseError
|
||||
* This function overrides the default configuration.
|
||||
* @param config
|
||||
*/
|
||||
exports.parseError = global.mermaid.parseError;
|
||||
|
||||
/**
|
||||
* ##contentLoaded
|
||||
* Callback function that is called when page is loaded. This functions fetches configuration for mermaid rendering and
|
||||
* calls init for rendering the mermaid diagrams on the page.
|
||||
*/
|
||||
exports.contentLoaded = function(){
|
||||
var config;
|
||||
// Check state of start config mermaid namespace
|
||||
@@ -31697,7 +31740,6 @@ exports.contentLoaded = function(){
|
||||
}
|
||||
|
||||
if(global.mermaid.startOnLoad) {
|
||||
|
||||
// For backwards compatability reasons also check mermaid_config variable
|
||||
if (typeof mermaid_config !== 'undefined') {
|
||||
// Check if property startOnLoad is set
|
||||
@@ -31706,6 +31748,7 @@ exports.contentLoaded = function(){
|
||||
}
|
||||
}
|
||||
else {
|
||||
mermaidAPI.initialize({startOnLoad:global.mermaid.startOnLoad});
|
||||
// No config found, do check API config
|
||||
config = mermaidAPI.getConfig();
|
||||
if(config.startOnLoad){
|
||||
@@ -31725,7 +31768,7 @@ exports.contentLoaded = function(){
|
||||
|
||||
|
||||
if(typeof document !== 'undefined'){
|
||||
/**
|
||||
/*!
|
||||
* Wait for document loaded before starting the execution
|
||||
*/
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
@@ -31734,7 +31777,104 @@ if(typeof document !== 'undefined'){
|
||||
}
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../package.json":86,"./mermaidAPI":104,"he":83}],104:[function(require,module,exports){
|
||||
},{"../package.json":86,"./logger":104,"./mermaidAPI":105,"he":83}],104:[function(require,module,exports){
|
||||
(function (process){
|
||||
/**
|
||||
* #logger
|
||||
* logger = require('logger').create()
|
||||
* logger.info("blah")
|
||||
* => [2011-3-3T20:24:4.810 info (5021)] blah
|
||||
* logger.debug("boom")
|
||||
* =>
|
||||
* logger.level = Logger.levels.debug
|
||||
* logger.debug(function() { return "booom" })
|
||||
* => [2011-3-3T20:24:4.810 error (5021)] booom
|
||||
*/
|
||||
var Logger;
|
||||
|
||||
Logger = (function() {
|
||||
function Logger(options) {
|
||||
var level, num, ref;
|
||||
this.options = options || {};
|
||||
this.level = this.options.level || Logger.levels.default;
|
||||
ref = Logger.levels;
|
||||
for (level in ref) {
|
||||
num = ref[level];
|
||||
Logger.define(this, level);
|
||||
}
|
||||
}
|
||||
|
||||
Logger.prototype.add = function(level, message, callback) {
|
||||
if (this.level > (Logger.levels[level] || 5)) {
|
||||
return;
|
||||
}
|
||||
if (callback) {
|
||||
message = callback();
|
||||
} else if (typeof message === 'function') {
|
||||
message = message();
|
||||
}
|
||||
return this.write({
|
||||
timestamp: new Date,
|
||||
severity: level,
|
||||
message: message,
|
||||
pid: process.pid
|
||||
});
|
||||
};
|
||||
|
||||
function formatTime(timestamp){
|
||||
var hh = timestamp.getUTCHours();
|
||||
var mm = timestamp.getUTCMinutes();
|
||||
var ss = timestamp.getSeconds();
|
||||
var ms = timestamp.getMilliseconds();
|
||||
// If you were building a timestamp instead of a duration, you would uncomment the following line to get 12-hour (not 24) time
|
||||
// if (hh > 12) {hh = hh % 12;}
|
||||
// These lines ensure you have two-digits
|
||||
if (hh < 10) {hh = "0"+hh;}
|
||||
if (mm < 10) {mm = "0"+mm;}
|
||||
if (ss < 10) {ss = "0"+ss;}
|
||||
if (ms < 100){ms = "0"+ms;}
|
||||
if (ms < 10) {ms = "00"+ms;}
|
||||
// This formats your string to HH:MM:SS
|
||||
var t = hh+":"+mm+":"+ss +' ('+ms+')';
|
||||
return t;
|
||||
}
|
||||
|
||||
Logger.prototype.write = function(options) {
|
||||
if(typeof console !== 'undefined'){
|
||||
if(typeof log.debug !== 'undefined'){
|
||||
return log.debug(this.build_message(options));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Logger.prototype.build_message = function(options) {
|
||||
return "[" + formatTime(options.timestamp) + "] " + options.message;
|
||||
};
|
||||
|
||||
return Logger;
|
||||
|
||||
})();
|
||||
|
||||
Logger.define = function(logger, level) {
|
||||
return logger[level] = function(message, callback) {
|
||||
return this.add(level, message, callback);
|
||||
};
|
||||
};
|
||||
|
||||
Logger.levels = {
|
||||
debug: 1,
|
||||
info: 2,
|
||||
warn: 3,
|
||||
error: 4,
|
||||
fatal: 5,
|
||||
default:3
|
||||
};
|
||||
|
||||
exports.create = function(type, options) {
|
||||
return new Logger(options);
|
||||
};
|
||||
}).call(this,require("1YiZ5S"))
|
||||
},{"1YiZ5S":82}],105:[function(require,module,exports){
|
||||
(function (global){
|
||||
var graph = require('./diagrams/flowchart/graphDb');
|
||||
var flow = require('./diagrams/flowchart/parser/flow');
|
||||
@@ -31753,6 +31893,7 @@ var ganttParser = require('./diagrams/gantt/parser/gantt');
|
||||
var ganttDb = require('./diagrams/gantt/ganttDb');
|
||||
var d3 = require('./d3');
|
||||
var nextId = 0;
|
||||
var log = require('./logger').create();
|
||||
|
||||
// Default options, can be overridden at initialization time
|
||||
/**
|
||||
@@ -31972,7 +32113,7 @@ var setConf = function(cnf){
|
||||
|
||||
var j;
|
||||
for(j=0;j<lvl2Keys.length;j++) {
|
||||
//console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
|
||||
//log.debug('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j]);
|
||||
if(typeof config[lvl1Keys[i]] === 'undefined'){
|
||||
|
||||
config[lvl1Keys[i]] = {};
|
||||
@@ -31994,20 +32135,43 @@ exports.initialize = function(options){
|
||||
exports.getConfig = function(){
|
||||
return config;
|
||||
};
|
||||
|
||||
exports.parseError = function(err, hash) {
|
||||
if(typeof mermaid !== 'undefined') {
|
||||
mermaid.parseError(err,hash);
|
||||
}else{
|
||||
log.debug('Mermaid Syntax error:');
|
||||
log.debug(err);
|
||||
}
|
||||
};
|
||||
global.mermaidAPI = {
|
||||
render : exports.render,
|
||||
parse : exports.parse,
|
||||
initialize : exports.initialize,
|
||||
detectType : utils.detectType
|
||||
detectType : utils.detectType,
|
||||
parseError : exports.parseError
|
||||
};
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../package.json":86,"./d3":87,"./diagrams/example/exampleDb":88,"./diagrams/example/exampleRenderer":89,"./diagrams/example/parser/example":90,"./diagrams/flowchart/flowRenderer":92,"./diagrams/flowchart/graphDb":93,"./diagrams/flowchart/parser/dot":94,"./diagrams/flowchart/parser/flow":95,"./diagrams/gantt/ganttDb":96,"./diagrams/gantt/ganttRenderer":97,"./diagrams/gantt/parser/gantt":98,"./diagrams/sequenceDiagram/parser/sequenceDiagram":99,"./diagrams/sequenceDiagram/sequenceDb":100,"./diagrams/sequenceDiagram/sequenceRenderer":101,"./utils":105}],105:[function(require,module,exports){
|
||||
},{"../package.json":86,"./d3":87,"./diagrams/example/exampleDb":88,"./diagrams/example/exampleRenderer":89,"./diagrams/example/parser/example":90,"./diagrams/flowchart/flowRenderer":92,"./diagrams/flowchart/graphDb":93,"./diagrams/flowchart/parser/dot":94,"./diagrams/flowchart/parser/flow":95,"./diagrams/gantt/ganttDb":96,"./diagrams/gantt/ganttRenderer":97,"./diagrams/gantt/parser/gantt":98,"./diagrams/sequenceDiagram/parser/sequenceDiagram":99,"./diagrams/sequenceDiagram/sequenceDb":100,"./diagrams/sequenceDiagram/sequenceRenderer":101,"./logger":104,"./utils":106}],106:[function(require,module,exports){
|
||||
/**
|
||||
* Created by knut on 14-11-23.
|
||||
*/
|
||||
var log = require('./logger').create();
|
||||
/**
|
||||
* @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
|
||||
* @param {string} text The second text defining the graph
|
||||
* @returns {string} A graph definition key
|
||||
@@ -32018,22 +32182,27 @@ module.exports.detectType = function(text,a){
|
||||
}
|
||||
|
||||
if(text.match(/^\s*sequence/)){
|
||||
//console.log('Detected sequence syntax');
|
||||
/* ```mermaid
|
||||
graph TB
|
||||
a-->b
|
||||
b-->c
|
||||
```
|
||||
*/
|
||||
return "sequence";
|
||||
}
|
||||
|
||||
if(text.match(/^\s*digraph/)) {
|
||||
//console.log('Detected dot syntax');
|
||||
//log.debug('Detected dot syntax');
|
||||
return "dotGraph";
|
||||
}
|
||||
|
||||
if(text.match(/^\s*info/)) {
|
||||
//console.log('Detected info syntax');
|
||||
//log.debug('Detected info syntax');
|
||||
return "info";
|
||||
}
|
||||
|
||||
if(text.match(/^\s*gantt/)) {
|
||||
//console.log('Detected info syntax');
|
||||
//log.debug('Detected info syntax');
|
||||
return "gantt";
|
||||
}
|
||||
|
||||
@@ -32126,4 +32295,4 @@ module.exports.cloneCssStyles = function(svg, classes){
|
||||
}
|
||||
};
|
||||
|
||||
},{}]},{},[103])
|
||||
},{"./logger":104}]},{},[103])
|
Reference in New Issue
Block a user