Socket
Socket
Sign inDemoInstall

mermaid

Package Overview
Dependencies
Maintainers
2
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mermaid - npm Package Compare versions

Comparing version 7.0.10 to 7.0.11

dist/mermaid.core.js

6

package.json
{
"name": "mermaid",
"version": "7.0.10",
"version": "7.0.11",
"description": "Markdownish syntax for generating flowcharts, sequence diagrams, class diagrams, gantt charts and git graphs.",
"main": "src/mermaid.js",
"main": "dist/mermaid.core.js",
"keywords": [

@@ -28,3 +28,3 @@ "diagram",

"jison": "gulp jison",
"prepublishOnly": "yarn build && yarn release && yarn test"
"prepublishOnly": "yarn build && yarn test"
},

@@ -31,0 +31,0 @@ "repository": {

@@ -45,4 +45,4 @@

log.warn('Adding relation: ' + JSON.stringify(relation))
exports.addClass(relation.id1)
exports.addClass(relation.id2)
module.exports.addClass(relation.id1)
module.exports.addClass(relation.id2)

@@ -49,0 +49,0 @@ relations.push(relation)

@@ -27,3 +27,3 @@ /**

*/
exports.addVertices = function (vert, g) {
module.exports.addVertices = function (vert, g) {
var keys = Object.keys(vert)

@@ -143,3 +143,3 @@

*/
exports.addEdges = function (edges, g) {
module.exports.addEdges = function (edges, g) {
var cnt = 0

@@ -224,3 +224,3 @@

*/
exports.getClasses = function (text, isDot) {
module.exports.getClasses = function (text, isDot) {
var parser

@@ -256,3 +256,3 @@ graph.clear()

*/
exports.draw = function (text, id, isDot) {
module.exports.draw = function (text, id, isDot) {
log.debug('Drawing flowchart')

@@ -321,4 +321,4 @@ var parser

}
exports.addVertices(vert, g)
exports.addEdges(edges, g)
module.exports.addVertices(vert, g)
module.exports.addEdges(edges, g)

@@ -325,0 +325,0 @@ // Create the renderer

@@ -14,3 +14,3 @@ /**

exports.clear = function () {
module.exports.clear = function () {
sections = []

@@ -26,18 +26,18 @@ tasks = []

exports.setDateFormat = function (txt) {
module.exports.setDateFormat = function (txt) {
dateFormat = txt
}
exports.getDateFormat = function () {
module.exports.getDateFormat = function () {
return dateFormat
}
exports.setTitle = function (txt) {
module.exports.setTitle = function (txt) {
title = txt
}
exports.getTitle = function () {
module.exports.getTitle = function () {
return title
}
exports.addSection = function (txt) {
module.exports.addSection = function (txt) {
currentSection = txt

@@ -47,3 +47,3 @@ sections.push(txt)

exports.getTasks = function () {
module.exports.getTasks = function () {
var allItemsPricessed = compileTasks()

@@ -70,3 +70,3 @@ var maxDepth = 10

if (afterStatement !== null) {
var task = exports.findTaskById(afterStatement[1])
var task = module.exports.findTaskById(afterStatement[1])

@@ -161,3 +161,3 @@ if (typeof task === 'undefined') {

var task = {}
var df = exports.getDateFormat()
var df = module.exports.getDateFormat()

@@ -275,3 +275,3 @@ // Get tags like active, done cand crit

var taskDb = {}
exports.addTask = function (descr, data) {
module.exports.addTask = function (descr, data) {
var rawTask = {

@@ -300,3 +300,3 @@ section: currentSection,

exports.findTaskById = function (id) {
module.exports.findTaskById = function (id) {
var pos = taskDb[id]

@@ -306,3 +306,3 @@ return rawTasks[pos]

exports.addTaskOrg = function (descr, data) {
module.exports.addTaskOrg = function (descr, data) {
var newTask = {

@@ -326,3 +326,3 @@ section: currentSection,

var compileTasks = function () {
var df = exports.getDateFormat()
var df = module.exports.getDateFormat()

@@ -334,3 +334,3 @@ var compileTask = function (pos) {

case 'prevTaskEnd':
var prevTask = exports.findTaskById(task.prevTaskId)
var prevTask = module.exports.findTaskById(task.prevTaskId)
task.startTime = prevTask.endTime

@@ -366,4 +366,4 @@ break

exports.parseError = function (err, hash) {
module.exports.parseError = function (err, hash) {
global.mermaidAPI.parseError(err, hash)
}

@@ -50,7 +50,7 @@ import _ from 'lodash'

exports.setDirection = function (dir) {
module.exports.setDirection = function (dir) {
direction = dir
}
var options = {}
exports.setOptions = function (rawOptString) {
module.exports.setOptions = function (rawOptString) {
log.debug('options str', rawOptString)

@@ -66,7 +66,7 @@ rawOptString = rawOptString && rawOptString.trim()

exports.getOptions = function () {
module.exports.getOptions = function () {
return options
}
exports.commit = function (msg) {
module.exports.commit = function (msg) {
var commit = {

@@ -84,3 +84,3 @@ id: getId(),

exports.branch = function (name) {
module.exports.branch = function (name) {
branches[name] = head != null ? head.id : null

@@ -90,3 +90,3 @@ log.debug('in createBranch')

exports.merge = function (otherBranch) {
module.exports.merge = function (otherBranch) {
var currentCommit = commits[branches[curBranch]]

@@ -117,3 +117,3 @@ var otherCommit = commits[branches[otherBranch]]

exports.checkout = function (branch) {
module.exports.checkout = function (branch) {
log.debug('in checkout')

@@ -125,3 +125,3 @@ curBranch = branch

exports.reset = function (commitRef) {
module.exports.reset = function (commitRef) {
log.debug('in reset', commitRef)

@@ -183,9 +183,9 @@ var ref = commitRef.split(':')[0]

exports.prettyPrint = function () {
module.exports.prettyPrint = function () {
log.debug(commits)
var node = exports.getCommitsArray()[0]
var node = module.exports.getCommitsArray()[0]
prettyPrintCommitHistory([node])
}
exports.clear = function () {
module.exports.clear = function () {
commits = {}

@@ -198,3 +198,3 @@ head = null

exports.getBranchesAsObjArray = function () {
module.exports.getBranchesAsObjArray = function () {
const branchArr = _.map(branches, function (value, key) {

@@ -206,5 +206,5 @@ return { 'name': key, 'commit': commits[value] }

exports.getBranches = function () { return branches }
exports.getCommits = function () { return commits }
exports.getCommitsArray = function () {
module.exports.getBranches = function () { return branches }
module.exports.getCommits = function () { return commits }
module.exports.getCommitsArray = function () {
var commitArr = Object.keys(commits).map(function (key) {

@@ -216,4 +216,4 @@ return commits[key]

}
exports.getCurrentBranch = function () { return curBranch }
exports.getDirection = function () { return direction }
exports.getHead = function () { return head }
module.exports.getCurrentBranch = function () { return curBranch }
module.exports.getDirection = function () { return direction }
module.exports.getHead = function () { return head }

@@ -11,3 +11,3 @@ /**

exports.addActor = function (id, name, description) {
module.exports.addActor = function (id, name, description) {
// Don't allow description nulling

@@ -23,7 +23,7 @@ var old = actors[id]

exports.addMessage = function (idFrom, idTo, message, answer) {
module.exports.addMessage = function (idFrom, idTo, message, answer) {
messages.push({ from: idFrom, to: idTo, message: message, answer: answer })
}
exports.addSignal = function (idFrom, idTo, message, messageType) {
module.exports.addSignal = function (idFrom, idTo, message, messageType) {
log.debug('Adding message from=' + idFrom + ' to=' + idTo + ' message=' + message + ' type=' + messageType)

@@ -33,20 +33,20 @@ messages.push({ from: idFrom, to: idTo, message: message, type: messageType })

exports.getMessages = function () {
module.exports.getMessages = function () {
return messages
}
exports.getActors = function () {
module.exports.getActors = function () {
return actors
}
exports.getActor = function (id) {
module.exports.getActor = function (id) {
return actors[id]
}
exports.getActorKeys = function () {
module.exports.getActorKeys = function () {
return Object.keys(actors)
}
exports.getTitle = function () {
module.exports.getTitle = function () {
return title
}
exports.clear = function () {
module.exports.clear = function () {
actors = {}

@@ -56,3 +56,3 @@ messages = []

exports.LINETYPE = {
module.exports.LINETYPE = {
SOLID: 0,

@@ -79,3 +79,3 @@ DOTTED: 1,

exports.ARROWTYPE = {
module.exports.ARROWTYPE = {
FILLED: 0,

@@ -85,3 +85,3 @@ OPEN: 1

exports.PLACEMENT = {
module.exports.PLACEMENT = {
LEFTOF: 0,

@@ -92,3 +92,3 @@ RIGHTOF: 1,

exports.addNote = function (actor, placement, message) {
module.exports.addNote = function (actor, placement, message) {
var note = { actor: actor, placement: placement, message: message }

@@ -100,17 +100,17 @@

notes.push(note)
messages.push({ from: actors[0], to: actors[1], message: message, type: exports.LINETYPE.NOTE, placement: placement })
messages.push({ from: actors[0], to: actors[1], message: message, type: module.exports.LINETYPE.NOTE, placement: placement })
}
exports.setTitle = function (titleText) {
module.exports.setTitle = function (titleText) {
title = titleText
}
exports.parseError = function (err, hash) {
module.exports.parseError = function (err, hash) {
global.mermaidAPI.parseError(err, hash)
}
exports.apply = function (param) {
module.exports.apply = function (param) {
if (param instanceof Array) {
param.forEach(function (item) {
exports.apply(item)
module.exports.apply(item)
})

@@ -120,48 +120,48 @@ } else {

case 'addActor':
exports.addActor(param.actor, param.actor, param.description)
module.exports.addActor(param.actor, param.actor, param.description)
break
case 'activeStart':
exports.addSignal(param.actor, undefined, undefined, param.signalType)
module.exports.addSignal(param.actor, undefined, undefined, param.signalType)
break
case 'activeEnd':
exports.addSignal(param.actor, undefined, undefined, param.signalType)
module.exports.addSignal(param.actor, undefined, undefined, param.signalType)
break
case 'addNote':
exports.addNote(param.actor, param.placement, param.text)
module.exports.addNote(param.actor, param.placement, param.text)
break
case 'addMessage':
exports.addSignal(param.from, param.to, param.msg, param.signalType)
module.exports.addSignal(param.from, param.to, param.msg, param.signalType)
break
case 'loopStart':
exports.addSignal(undefined, undefined, param.loopText, param.signalType)
module.exports.addSignal(undefined, undefined, param.loopText, param.signalType)
break
case 'loopEnd':
exports.addSignal(undefined, undefined, undefined, param.signalType)
module.exports.addSignal(undefined, undefined, undefined, param.signalType)
break
case 'optStart':
exports.addSignal(undefined, undefined, param.optText, param.signalType)
module.exports.addSignal(undefined, undefined, param.optText, param.signalType)
break
case 'optEnd':
exports.addSignal(undefined, undefined, undefined, param.signalType)
module.exports.addSignal(undefined, undefined, undefined, param.signalType)
break
case 'altStart':
exports.addSignal(undefined, undefined, param.altText, param.signalType)
module.exports.addSignal(undefined, undefined, param.altText, param.signalType)
break
case 'else':
exports.addSignal(undefined, undefined, param.altText, param.signalType)
module.exports.addSignal(undefined, undefined, param.altText, param.signalType)
break
case 'altEnd':
exports.addSignal(undefined, undefined, undefined, param.signalType)
module.exports.addSignal(undefined, undefined, undefined, param.signalType)
break
case 'setTitle':
exports.setTitle(param.text)
module.exports.setTitle(param.text)
break
case 'parStart':
exports.addSignal(undefined, undefined, param.parText, param.signalType)
module.exports.addSignal(undefined, undefined, param.parText, param.signalType)
break
case 'and':
exports.addSignal(undefined, undefined, param.parText, param.signalType)
module.exports.addSignal(undefined, undefined, param.parText, param.signalType)
break
case 'parEnd':
exports.addSignal(undefined, undefined, undefined, param.signalType)
module.exports.addSignal(undefined, undefined, undefined, param.signalType)
break

@@ -168,0 +168,0 @@ }

@@ -41,3 +41,3 @@ /**

exports.bounds = {
module.exports.bounds = {
data: {

@@ -83,4 +83,4 @@ startx: undefined,

_self.updateVal(exports.bounds.data, 'startx', startx - n * conf.boxMargin, Math.min)
_self.updateVal(exports.bounds.data, 'stopx', stopx + n * conf.boxMargin, Math.max)
_self.updateVal(module.exports.bounds.data, 'startx', startx - n * conf.boxMargin, Math.min)
_self.updateVal(module.exports.bounds.data, 'stopx', stopx + n * conf.boxMargin, Math.max)

@@ -91,4 +91,4 @@ if (!(type === 'activation')) {

_self.updateVal(exports.bounds.data, 'starty', starty - n * conf.boxMargin, Math.min)
_self.updateVal(exports.bounds.data, 'stopy', stopy + n * conf.boxMargin, Math.max)
_self.updateVal(module.exports.bounds.data, 'starty', starty - n * conf.boxMargin, Math.min)
_self.updateVal(module.exports.bounds.data, 'stopy', stopy + n * conf.boxMargin, Math.max)
}

@@ -109,6 +109,6 @@ }

this.updateVal(exports.bounds.data, 'startx', _startx, Math.min)
this.updateVal(exports.bounds.data, 'starty', _starty, Math.min)
this.updateVal(exports.bounds.data, 'stopx', _stopx, Math.max)
this.updateVal(exports.bounds.data, 'stopy', _stopy, Math.max)
this.updateVal(module.exports.bounds.data, 'startx', _startx, Math.min)
this.updateVal(module.exports.bounds.data, 'starty', _starty, Math.min)
this.updateVal(module.exports.bounds.data, 'stopx', _stopx, Math.max)
this.updateVal(module.exports.bounds.data, 'stopy', _stopy, Math.max)

@@ -149,3 +149,3 @@ this.updateBounds(_startx, _starty, _stopx, _stopy)

loop.sectionTitles = loop.sectionTitles || []
loop.sections.push(exports.bounds.getVerticalPos())
loop.sections.push(module.exports.bounds.getVerticalPos())
loop.sectionTitles.push(message)

@@ -200,9 +200,9 @@ this.sequenceItems.push(loop)

rectElem.attr('width', 2 * rect.width)
exports.bounds.insert(startx, verticalPos, startx + 2 * rect.width, verticalPos + 2 * conf.noteMargin + textHeight)
module.exports.bounds.insert(startx, verticalPos, startx + 2 * rect.width, verticalPos + 2 * conf.noteMargin + textHeight)
} else {
exports.bounds.insert(startx, verticalPos, startx + rect.width, verticalPos + 2 * conf.noteMargin + textHeight)
module.exports.bounds.insert(startx, verticalPos, startx + rect.width, verticalPos + 2 * conf.noteMargin + textHeight)
}
rectElem.attr('height', textHeight + 2 * conf.noteMargin)
exports.bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin)
module.exports.bounds.bumpVerticalPos(textHeight + 2 * conf.noteMargin)
}

@@ -245,5 +245,5 @@

exports.bounds.bumpVerticalPos(30)
module.exports.bounds.bumpVerticalPos(30)
var dx = Math.max(textWidth / 2, 100)
exports.bounds.insert(startx - dx, exports.bounds.getVerticalPos() - 10, stopx + dx, exports.bounds.getVerticalPos())
module.exports.bounds.insert(startx - dx, module.exports.bounds.getVerticalPos() - 10, stopx + dx, module.exports.bounds.getVerticalPos())
} else {

@@ -255,3 +255,3 @@ line = g.append('line')

line.attr('y2', verticalPos)
exports.bounds.insert(startx, exports.bounds.getVerticalPos() - 10, stopx, exports.bounds.getVerticalPos())
module.exports.bounds.insert(startx, module.exports.bounds.getVerticalPos() - 10, stopx, module.exports.bounds.getVerticalPos())
}

@@ -300,7 +300,7 @@ // Make an SVG Container

svgDraw.drawActor(diagram, actors[key].x, verticalPos, actors[key].description, conf)
exports.bounds.insert(actors[key].x, verticalPos, actors[key].x + conf.width, conf.height)
module.exports.bounds.insert(actors[key].x, verticalPos, actors[key].x + conf.width, conf.height)
}
// Add a margin between the actor boxes and the first arrow
exports.bounds.bumpVerticalPos(conf.height)
module.exports.bounds.bumpVerticalPos(conf.height)
}

@@ -341,3 +341,3 @@

exports.bounds.init()
module.exports.bounds.init()
var diagram = d3.select('#' + id)

@@ -361,3 +361,3 @@

function activeEnd (msg, verticalPos) {
var activationData = exports.bounds.endActivation(msg)
var activationData = module.exports.bounds.endActivation(msg)
if (activationData.starty + 18 > verticalPos) {

@@ -369,3 +369,3 @@ activationData.starty = verticalPos - 6

exports.bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos)
module.exports.bounds.insert(activationData.startx, verticalPos - 10, activationData.stopx, verticalPos)
}

@@ -381,3 +381,3 @@

case sq.yy.LINETYPE.NOTE:
exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)

@@ -388,12 +388,12 @@ startx = actors[msg.from].x

if (msg.placement === sq.yy.PLACEMENT.RIGHTOF) {
drawNote(diagram, startx + (conf.width + conf.actorMargin) / 2, exports.bounds.getVerticalPos(), msg)
drawNote(diagram, startx + (conf.width + conf.actorMargin) / 2, module.exports.bounds.getVerticalPos(), msg)
} else if (msg.placement === sq.yy.PLACEMENT.LEFTOF) {
drawNote(diagram, startx - (conf.width + conf.actorMargin) / 2, exports.bounds.getVerticalPos(), msg)
drawNote(diagram, startx - (conf.width + conf.actorMargin) / 2, module.exports.bounds.getVerticalPos(), msg)
} else if (msg.to === msg.from) {
// Single-actor over
drawNote(diagram, startx, exports.bounds.getVerticalPos(), msg)
drawNote(diagram, startx, module.exports.bounds.getVerticalPos(), msg)
} else {
// Multi-actor over
forceWidth = Math.abs(startx - stopx) + conf.actorMargin
drawNote(diagram, (startx + stopx + conf.width - forceWidth) / 2, exports.bounds.getVerticalPos(), msg,
drawNote(diagram, (startx + stopx + conf.width - forceWidth) / 2, module.exports.bounds.getVerticalPos(), msg,
forceWidth)

@@ -403,59 +403,59 @@ }

case sq.yy.LINETYPE.ACTIVE_START:
exports.bounds.newActivation(msg, diagram)
module.exports.bounds.newActivation(msg, diagram)
break
case sq.yy.LINETYPE.ACTIVE_END:
activeEnd(msg, exports.bounds.getVerticalPos())
activeEnd(msg, module.exports.bounds.getVerticalPos())
break
case sq.yy.LINETYPE.LOOP_START:
exports.bounds.bumpVerticalPos(conf.boxMargin)
exports.bounds.newLoop(msg.message)
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.newLoop(msg.message)
module.exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
break
case sq.yy.LINETYPE.LOOP_END:
loopData = exports.bounds.endLoop()
loopData = module.exports.bounds.endLoop()
svgDraw.drawLoop(diagram, loopData, 'loop', conf)
exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
break
case sq.yy.LINETYPE.OPT_START:
exports.bounds.bumpVerticalPos(conf.boxMargin)
exports.bounds.newLoop(msg.message)
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.newLoop(msg.message)
module.exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
break
case sq.yy.LINETYPE.OPT_END:
loopData = exports.bounds.endLoop()
loopData = module.exports.bounds.endLoop()
svgDraw.drawLoop(diagram, loopData, 'opt', conf)
exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
break
case sq.yy.LINETYPE.ALT_START:
exports.bounds.bumpVerticalPos(conf.boxMargin)
exports.bounds.newLoop(msg.message)
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.newLoop(msg.message)
module.exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
break
case sq.yy.LINETYPE.ALT_ELSE:
exports.bounds.bumpVerticalPos(conf.boxMargin)
loopData = exports.bounds.addSectionToLoop(msg.message)
exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
loopData = module.exports.bounds.addSectionToLoop(msg.message)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
break
case sq.yy.LINETYPE.ALT_END:
loopData = exports.bounds.endLoop()
loopData = module.exports.bounds.endLoop()
svgDraw.drawLoop(diagram, loopData, 'alt', conf)
exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
break
case sq.yy.LINETYPE.PAR_START:
exports.bounds.bumpVerticalPos(conf.boxMargin)
exports.bounds.newLoop(msg.message)
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.newLoop(msg.message)
module.exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin)
break
case sq.yy.LINETYPE.PAR_AND:
exports.bounds.bumpVerticalPos(conf.boxMargin)
loopData = exports.bounds.addSectionToLoop(msg.message)
exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
loopData = module.exports.bounds.addSectionToLoop(msg.message)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
break
case sq.yy.LINETYPE.PAR_END:
loopData = exports.bounds.endLoop()
loopData = module.exports.bounds.endLoop()
svgDraw.drawLoop(diagram, loopData, 'par', conf)
exports.bounds.bumpVerticalPos(conf.boxMargin)
module.exports.bounds.bumpVerticalPos(conf.boxMargin)
break

@@ -465,3 +465,3 @@ default:

// lastMsg = msg
exports.bounds.bumpVerticalPos(conf.messageMargin)
module.exports.bounds.bumpVerticalPos(conf.messageMargin)
var fromBounds = actorFlowVerticaBounds(msg.from)

@@ -474,6 +474,6 @@ var toBounds = actorFlowVerticaBounds(msg.to)

var verticalPos = exports.bounds.getVerticalPos()
var verticalPos = module.exports.bounds.getVerticalPos()
drawMessage(diagram, startx, stopx, verticalPos, msg)
var allBounds = fromBounds.concat(toBounds)
exports.bounds.insert(Math.min.apply(null, allBounds), verticalPos, Math.max.apply(null, allBounds), verticalPos)
module.exports.bounds.insert(Math.min.apply(null, allBounds), verticalPos, Math.max.apply(null, allBounds), verticalPos)
} catch (e) {

@@ -487,7 +487,7 @@ console.error('error while drawing message', e)

// Draw actors below diagram
exports.bounds.bumpVerticalPos(conf.boxMargin * 2)
module.exports.drawActors(diagram, actors, actorKeys, exports.bounds.getVerticalPos())
module.exports.bounds.bumpVerticalPos(conf.boxMargin * 2)
module.exports.drawActors(diagram, actors, actorKeys, module.exports.bounds.getVerticalPos())
}
var box = exports.bounds.getBounds()
var box = module.exports.bounds.getBounds()

@@ -494,0 +494,0 @@ // Adjust line height of actor lines now that the height of the diagram is known

/**
* Created by knut on 14-12-20.
*/
exports.drawRect = function (elem, rectData) {
module.exports.drawRect = function (elem, rectData) {
var rectElem = elem.append('rect')

@@ -22,3 +22,3 @@ rectElem.attr('x', rectData.x)

exports.drawText = function (elem, textData, width) {
module.exports.drawText = function (elem, textData, width) {
// Remove and ignore br:s

@@ -52,3 +52,3 @@ var nText = textData.text.replace(/<br\/?>/ig, ' ')

exports.drawLabel = function (elem, txtObject) {
module.exports.drawLabel = function (elem, txtObject) {
function genPoints (x, y, width, height, cut) {

@@ -67,3 +67,3 @@ return x + ',' + y + ' ' +

txtObject.x = txtObject.x + 0.5 * txtObject.labelMargin
exports.drawText(elem, txtObject)
module.exports.drawText(elem, txtObject)
}

@@ -77,3 +77,3 @@ var actorCnt = -1

*/
exports.drawActor = function (elem, left, verticalPos, description, conf) {
module.exports.drawActor = function (elem, left, verticalPos, description, conf) {
var center = left + (conf.width / 2)

@@ -94,3 +94,3 @@ var g = elem.append('g')

var rect = exports.getNoteRect()
var rect = module.exports.getNoteRect()
rect.x = left

@@ -104,3 +104,3 @@ rect.y = verticalPos

rect.ry = 3
exports.drawRect(g, rect)
module.exports.drawRect(g, rect)

@@ -111,3 +111,3 @@ _drawTextCandidateFunc(conf)(description, g,

exports.anchorElement = function (elem) {
module.exports.anchorElement = function (elem) {
return elem.append('g')

@@ -121,4 +121,4 @@ }

*/
exports.drawActivation = function (elem, bounds, verticalPos) {
var rect = exports.getNoteRect()
module.exports.drawActivation = function (elem, bounds, verticalPos) {
var rect = module.exports.getNoteRect()
var g = bounds.anchored

@@ -130,3 +130,3 @@ rect.x = bounds.startx

rect.height = verticalPos - bounds.starty
exports.drawRect(g, rect)
module.exports.drawRect(g, rect)
}

@@ -140,3 +140,3 @@

*/
exports.drawLoop = function (elem, bounds, labelText, conf) {
module.exports.drawLoop = function (elem, bounds, labelText, conf) {
var g = elem.append('g')

@@ -161,3 +161,3 @@ var drawLoopLine = function (startx, starty, stopx, stopy) {

var txt = exports.getTextObj()
var txt = module.exports.getTextObj()
txt.text = labelText

@@ -169,5 +169,5 @@ txt.x = bounds.startx

exports.drawLabel(g, txt)
module.exports.drawLabel(g, txt)
txt = exports.getTextObj()
txt = module.exports.getTextObj()
txt.text = '[ ' + bounds.title + ' ]'

@@ -179,3 +179,3 @@ txt.x = bounds.startx + (bounds.stopx - bounds.startx) / 2

exports.drawText(g, txt)
module.exports.drawText(g, txt)

@@ -187,3 +187,3 @@ if (typeof bounds.sectionTitles !== 'undefined') {

txt.y = bounds.sections[idx] + 1.5 * conf.boxMargin
exports.drawText(g, txt)
module.exports.drawText(g, txt)
}

@@ -197,3 +197,3 @@ })

*/
exports.insertArrowHead = function (elem) {
module.exports.insertArrowHead = function (elem) {
elem.append('defs').append('marker')

@@ -212,3 +212,3 @@ .attr('id', 'arrowhead')

*/
exports.insertArrowCrossHead = function (elem) {
module.exports.insertArrowCrossHead = function (elem) {
var defs = elem.append('defs')

@@ -241,3 +241,3 @@ var marker = defs.append('marker')

exports.getTextObj = function () {
module.exports.getTextObj = function () {
var txt = {

@@ -258,3 +258,3 @@ x: 0,

exports.getNoteRect = function () {
module.exports.getNoteRect = function () {
var rect = {

@@ -261,0 +261,0 @@ x: 0,

@@ -1,52 +0,16 @@

/**
* #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
*/
import moment from 'moment'
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
const format = (level) => {
const time = moment().format('HH:mm:ss (SSS)')
return `%c ${time} :%c${level}: `
}
function format (level) {
const time = formatTime(new Date())
return '%c ' + time + ' :%c' + level + ': '
export const Log = {
debug: () => {},
info: () => {},
warn: () => {},
error: () => {},
fatal: () => {}
}
var debug = function () { }
var info = function () { }
var warn = function () { }
var error = function () { }
var fatal = function () { }
/**

@@ -60,26 +24,18 @@ * logLevel , decides the amount of logging to be used.

*/
exports.setLogLevel = function (level) {
export const setLogLevel = function (level) {
if (level < 6) {
exports.Log.fatal = console.log.bind(console, format('FATAL'), 'color:grey;', 'color: red;')
Log.fatal = console.log.bind(console, format('FATAL'), 'color:grey;', 'color: red;')
}
if (level < 5) {
exports.Log.error = console.log.bind(console, format('ERROR'), 'color:grey;', 'color: red;')
Log.error = console.log.bind(console, format('ERROR'), 'color:grey;', 'color: red;')
}
if (level < 4) {
exports.Log.warn = console.log.bind(console, format('WARN'), 'color:grey;', 'color: orange;')
Log.warn = console.log.bind(console, format('WARN'), 'color:grey;', 'color: orange;')
}
if (level < 3) {
exports.Log.info = console.log.bind(console, format('INFO'), 'color:grey;', 'color: info;')
Log.info = console.log.bind(console, format('INFO'), 'color:grey;', 'color: info;')
}
if (level < 2) {
exports.Log.debug = console.log.bind(console, format('DEBUG'), 'color:grey;', 'color: green;')
Log.debug = console.log.bind(console, format('DEBUG'), 'color:grey;', 'color: green;')
}
}
exports.Log = {
debug: debug,
info: info,
warn: warn,
error: error,
fatal: fatal
}

@@ -5,2 +5,3 @@ /**

*/
var he = require('he')

@@ -12,5 +13,2 @@ var Logger = require('./logger')

var he = require('he')
module.exports.mermaidAPI = mermaidAPI
/**

@@ -116,19 +114,7 @@ * ## init

exports.init = init
exports.parse = mermaidAPI.parse
/**
* ## version
* Function returning version information
* @returns {string} A string containing the version info
*/
exports.version = function () {
const version = function () {
return 'v' + require('../package.json').version
}
/**
* ## initialize
* This function overrides the default configuration.
* @param config
*/
exports.initialize = function (config) {
const initialize = function (config) {
log.debug('Initializing mermaid')

@@ -146,52 +132,3 @@ if (typeof config.mermaid !== 'undefined') {

var equals = function (val, variable) {
if (typeof variable === 'undefined') {
return false
} else {
return (val === variable)
}
}
/**
* Global mermaid object. Contains the functions:
* * init
* * initialize
* * version
* * parse
* * parseError
* * render
*/
global.mermaid = {
startOnLoad: true,
htmlLabels: true,
init: function () {
init.apply(null, arguments)
},
initialize: function (config) {
exports.initialize(config)
},
version: function () {
return mermaidAPI.version()
},
parse: function (text) {
return mermaidAPI.parse(text)
},
parseError: function (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

@@ -201,7 +138,7 @@ * Callback function that is called when page is loaded. This functions fetches configuration for mermaid rendering and

*/
exports.contentLoaded = function () {
const contentLoaded = function () {
var config
// Check state of start config mermaid namespace
if (typeof global.mermaid_config !== 'undefined') {
if (equals(false, global.mermaid_config.htmlLabels)) {
if (global.mermaid_config.htmlLabels === false) {
global.mermaid.htmlLabels = false

@@ -215,3 +152,3 @@ }

// Check if property startOnLoad is set
if (equals(true, global.mermaid_config.startOnLoad)) {
if (global.mermaid_config.startOnLoad === true) {
global.mermaid.init()

@@ -242,4 +179,25 @@ }

window.addEventListener('load', function () {
exports.contentLoaded()
contentLoaded()
}, false)
}
const mermaid = {
mermaidAPI,
startOnLoad: true,
htmlLabels: true,
init,
initialize,
version,
parse: mermaidAPI.parse,
parseError: function (err) {
log.debug('Mermaid Syntax error:')
log.debug(err)
},
render: mermaidAPI.render,
contentLoaded
}
export default mermaid

@@ -8,4 +8,6 @@ /* eslint-env jasmine */

*/
var mermaid = require('./mermaid')
import mermaid from './mermaid'
global.mermaid = mermaid
describe('when using mermaid and ', function () {

@@ -12,0 +14,0 @@ describe('when detecting chart type ', function () {

@@ -293,3 +293,3 @@ /**

}
exports.parse = parse
module.exports.parse = parse

@@ -301,7 +301,7 @@ /**

*/
exports.version = function () {
module.exports.version = function () {
return require('../package.json').version
}
exports.encodeEntities = function (text) {
module.exports.encodeEntities = function (text) {
var txt = text

@@ -332,3 +332,3 @@

exports.decodeEntities = function (text) {
module.exports.decodeEntities = function (text) {
var txt = text

@@ -398,3 +398,3 @@

window.txt = txt
txt = exports.encodeEntities(txt)
txt = module.exports.encodeEntities(txt)

@@ -454,3 +454,3 @@ var element = d3.select('#d' + id).node()

config.info.arrowMarkerAbsolute = config.arrowMarkerAbsolute
info.draw(txt, id, exports.version())
info.draw(txt, id, module.exports.version())
if (config.cloneCssStyles) {

@@ -474,3 +474,3 @@ utils.cloneCssStyles(element.firstChild, [])

svgCode = exports.decodeEntities(svgCode)
svgCode = module.exports.decodeEntities(svgCode)

@@ -491,3 +491,3 @@ if (typeof cb !== 'undefined') {

exports.render = function (id, text, cb, containerElement) {
module.exports.render = function (id, text, cb, containerElement) {
try {

@@ -533,3 +533,3 @@ if (arguments.length === 1) {

exports.initialize = function (options) {
module.exports.initialize = function (options) {
log.debug('Initializing mermaidAPI')

@@ -542,7 +542,7 @@ // Update default config with options supplied at initialization

}
exports.getConfig = function () {
module.exports.getConfig = function () {
return config
}
exports.parseError = function (err, hash) {
module.exports.parseError = function (err, hash) {
if (typeof mermaid !== 'undefined') {

@@ -556,8 +556,8 @@ global.mermaid.parseError(err, hash)

global.mermaidAPI = {
render: exports.render,
parse: exports.parse,
initialize: exports.initialize,
render: module.exports.render,
parse: module.exports.parse,
initialize: module.exports.initialize,
detectType: utils.detectType,
parseError: exports.parseError,
getConfig: exports.getConfig
parseError: module.exports.parseError,
getConfig: module.exports.getConfig
}

@@ -1,6 +0,2 @@

/**
* Created by knut on 14-11-23.
*/
var Logger = require('./logger')
var log = Logger.Log
import { Log } from './logger'

@@ -24,3 +20,3 @@ /**

*/
var detectType = function (text) {
export const detectType = function (text) {
text = text.replace(/^\s*%%.*\n/g, '\n')

@@ -44,3 +40,3 @@ if (text.match(/^\s*sequenceDiagram/)) {

if (text.match(/^\s*classDiagram/)) {
log.debug('Detected classDiagram syntax')
Log.debug('Detected classDiagram syntax')
return 'classDiagram'

@@ -50,3 +46,3 @@ }

if (text.match(/^\s*gitGraph/)) {
log.debug('Detected gitGraph syntax')
Log.debug('Detected gitGraph syntax')
return 'gitGraph'

@@ -56,3 +52,2 @@ }

}
exports.detectType = detectType

@@ -65,17 +60,16 @@ /**

*/
var cloneCssStyles = function (svg, classes) {
var usedStyles = ''
var sheets = document.styleSheets
var rule
for (var i = 0; i < sheets.length; i++) {
export const cloneCssStyles = function (svg, classes) {
let usedStyles = ''
const sheets = document.styleSheets
let rule
for (let 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
const rules = sheets[i].cssRules
if (rules !== null) {
for (var j = 0; j < rules.length; j++) {
for (let j = 0; j < rules.length; j++) {
rule = rules[j]
if (typeof (rule.style) !== 'undefined') {
var elems
elems = svg.querySelectorAll(rule.selectorText)
const elems = svg.querySelectorAll(rule.selectorText)
if (elems.length > 0) {

@@ -89,3 +83,3 @@ usedStyles += rule.selectorText + ' { ' + rule.style.cssText + '}\n'

if (typeof (rule) !== 'undefined') {
log.warn('Invalid CSS selector "' + rule.selectorText + '"', err)
Log.warn('Invalid CSS selector "' + rule.selectorText + '"', err)
}

@@ -96,6 +90,5 @@ }

var defaultStyles = ''
var embeddedStyles = ''
for (var className in classes) {
let defaultStyles = ''
let embeddedStyles = ''
for (const className in classes) {
if (classes.hasOwnProperty(className) && typeof (className) !== 'undefined') {

@@ -124,3 +117,3 @@ if (className === 'default') {

if (usedStyles !== '' || defaultStyles !== '' || embeddedStyles !== '') {
var s = document.createElement('style')
const s = document.createElement('style')
s.setAttribute('type', 'text/css')

@@ -144,4 +137,2 @@ s.setAttribute('title', 'mermaid-svg-internal-css')

exports.cloneCssStyles = cloneCssStyles
/**

@@ -154,4 +145,4 @@ * @function isSubstringInArray

**/
var isSubstringInArray = function (str, arr) {
for (var i = 0; i < arr.length; i++) {
export const isSubstringInArray = function (str, arr) {
for (let i = 0; i < arr.length; i++) {
if (arr[i].match(str)) return i

@@ -161,3 +152,1 @@ }

}
exports.isSubstringInArray = isSubstringInArray

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc