Comparing version 1.12.6 to 1.12.7
@@ -95,6 +95,6 @@ /* istanbul ignore else */ | ||
version: "1.12.6", | ||
version: "1.12.7", | ||
getAllowedValues: function() { | ||
return Object.seal({ | ||
return Object.freeze({ | ||
inputType: [ | ||
@@ -101,0 +101,0 @@ {name: "mscgen", experimental: false}, |
@@ -8,9 +8,9 @@ module.exports = (function(){ | ||
var gLang2Parser = { | ||
var gLang2Parser = Object.freeze({ | ||
mscgen : "../parse/mscgenparser", | ||
xu : "../parse/xuparser", | ||
msgenny : "../parse/msgennyparser" | ||
}; | ||
}); | ||
var gLang2TextRenderer = { | ||
var gLang2TextRenderer = Object.freeze({ | ||
mscgen : "../render/text/ast2mscgen", | ||
@@ -21,3 +21,3 @@ msgenny : "../render/text/ast2msgenny", | ||
doxygen : "../render/text/ast2doxygen" | ||
}; | ||
}); | ||
@@ -52,2 +52,17 @@ return { | ||
})(); | ||
/* eslint security/detect-object-injection: 0*/ | ||
/* The 'generic object injection sink' is to a frozen object, | ||
attempts to modify it will be moot => we can safely use the [] | ||
notation | ||
*/ | ||
/* eslint security/detect-non-literal-require: 0 */ | ||
/* eslint import/no-dynamic-require: 0 */ | ||
/* The whole idea of this module is to do non-literarl requires. | ||
Believed to be 'safe' because the values are not (cannot be) | ||
supplied externaly, but only indirectly through a lookup | ||
table | ||
*/ | ||
/* | ||
@@ -54,0 +69,0 @@ This file is part of mscgen_js. |
@@ -23,9 +23,9 @@ /* istanbul ignore else */ | ||
var gLang2Parser = { | ||
var gLang2Parser = Object.freeze({ | ||
mscgen : mscgenparser, | ||
xu : xuparser, | ||
msgenny : msgennyparser | ||
}; | ||
}); | ||
var gLang2TextRenderer = { | ||
var gLang2TextRenderer = Object.freeze({ | ||
mscgen : ast2mscgen, | ||
@@ -36,3 +36,3 @@ msgenny : ast2msgenny, | ||
doxygen : ast2doxygen | ||
}; | ||
}); | ||
@@ -57,2 +57,9 @@ return { | ||
}); | ||
/* eslint security/detect-object-injection: 0*/ | ||
/* The 'generic object injection sink' is to a frozen object, | ||
attempts to modify it will be moot => we can safely use the [] | ||
notation | ||
*/ | ||
/* | ||
@@ -59,0 +66,0 @@ This file is part of mscgen_js. |
{ | ||
"name": "mscgenjs", | ||
"version": "1.12.6", | ||
"description": "Implementation of MscGen in JavaScript", | ||
"version": "1.12.7", | ||
"description": "Sequence chart rendering library", | ||
"main": "index.js", | ||
@@ -13,7 +13,9 @@ "dependencies": { | ||
"chai-xml": "0.3.1", | ||
"dependency-cruiser": "2.7.2", | ||
"eslint": "4.11.0", | ||
"dependency-cruiser": "2.8.0", | ||
"eslint": "4.12.1", | ||
"eslint-plugin-import": "2.8.0", | ||
"eslint-plugin-security": "1.4.0", | ||
"istanbul": "0.4.5", | ||
"js-makedepend": "2.4.0", | ||
"jsdom": "11.4.0", | ||
"js-makedepend": "2.4.1", | ||
"jsdom": "11.5.1", | ||
"lodash-cli": "4.17.4", | ||
@@ -20,0 +22,0 @@ "mocha": "4.0.1", |
@@ -16,3 +16,3 @@ /* istanbul ignore else */ | ||
var KIND2AGGREGATE = { | ||
var KIND2AGGREGATE = Object.freeze({ | ||
"|||" : "emptyarc", | ||
@@ -61,3 +61,3 @@ "..." : "emptyarc", | ||
"exc" : "inline_expression" | ||
}; | ||
}); | ||
@@ -69,2 +69,8 @@ return { | ||
}); | ||
/* eslint security/detect-object-injection: 0*/ | ||
/* The 'generic object injection sink' is to a frozen object, | ||
attempts to modify it will be moot => we can safely use the [] | ||
notation | ||
*/ | ||
/* | ||
@@ -71,0 +77,0 @@ This file is part of mscgen_js. |
@@ -96,2 +96,3 @@ /* istanbul ignore else */ | ||
pArc.depth = pDepth; | ||
pArc.isVirtual = true; | ||
if (Boolean(pArc.arcs)) { | ||
@@ -127,3 +128,4 @@ var lInlineExpression = _.cloneDeep(pArc); | ||
from : pArc.from, | ||
to : pArc.to | ||
to : pArc.to, | ||
isVirtual : true | ||
}]); | ||
@@ -130,0 +132,0 @@ } else { |
@@ -16,3 +16,3 @@ /* istanbul ignore else */ | ||
var KIND2NORMALIZEDKIND = { | ||
var KIND2NORMALIZEDKIND = Object.freeze({ | ||
"<-" : "->", | ||
@@ -24,3 +24,3 @@ "<=" : "=>", | ||
"x-" : "-x" | ||
}; | ||
}); | ||
@@ -32,2 +32,7 @@ return { | ||
}); | ||
/* eslint security/detect-object-injection: 0*/ | ||
/* The 'generic object injection sink' is to a frozen object, | ||
attempts to modify it will be moot => we can safely use the [] | ||
notation | ||
*/ | ||
/* | ||
@@ -34,0 +39,0 @@ This file is part of mscgen_js. |
@@ -8,88 +8,87 @@ /* istanbul ignore else */ | ||
"use strict"; | ||
return { | ||
return Object.freeze({ | ||
baseTemplate : "svg.<%=id%>{font-family:Helvetica,sans-serif;font-size:<%=fontSize%>px;font-weight:normal;font-style:normal;text-decoration:none;background-color:white;stroke:black;stroke-width:<%=lineWidth%>}.<%=id%> path, .<%=id%> rect{fill:none}.<%=id%> .label-text-background{fill:white;stroke:white;stroke-width:0}.<%=id%> .bglayer{fill:white;stroke:white;stroke-width:0}.<%=id%> line{}.<%=id%> .return, .<%=id%> .comment{stroke-dasharray:5,3}.<%=id%> .inline_expression_divider{stroke-dasharray:10,5}.<%=id%> text{color:inherit;stroke:none;text-anchor:middle}.<%=id%> text.anchor-start{text-anchor:start}.<%=id%> .arrow-marker{overflow:visible}.<%=id%> .arrow-style{stroke-width:1}.<%=id%> .arcrow, .<%=id%> .arcrowomit, .<%=id%> .emphasised{stroke-linecap:butt}.<%=id%> .arcrowomit{stroke-dasharray:2,2}.<%=id%> .box, .<%=id%> .entity{fill:white;stroke-linejoin:round}.<%=id%> .inherit{stroke:inherit;color:inherit}.<%=id%> .inherit-fill{fill:inherit}.<%=id%> .watermark{font-size:48pt;font-weight:bold;opacity:0.14}", | ||
namedStyles : [ | ||
{ | ||
"name": "basic", | ||
"description": "Basic", | ||
"experimental": false, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> text.entity-text{text-decoration:underline;}" | ||
}, | ||
{ | ||
"name": "lazy", | ||
"description": "Lazy", | ||
"experimental": false, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> text.entity-text{font-weight:bold;}.<%=id%> text.return-text{font-style:italic}.<%=id%> path.note{fill:#FFFFCC}.<%=id%> rect.label-text-background{opacity:0.9}.<%=id%> line.comment,.<%=id%> rect.inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{stroke:grey}" | ||
}, | ||
{ | ||
"name": "classic", | ||
"description": "Classic", | ||
"experimental": false, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> text.entity-text{text-decoration:none}.<%=id%> .entity{stroke:none;}.<%=id%> line,.<%=id%> rect,.<%=id%> path{stroke-width:1px}.<%=id%> .arrow-style{stroke-width:2;}.<%=id%> .inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{stroke-width: 1px}" | ||
}, | ||
{ | ||
"name": "fountainpen", | ||
"description": "Fountain pen", | ||
"experimental": true, | ||
"deprecated": false, | ||
"renderMagic": "wobbly", | ||
"cssBefore": "@import 'https://fonts.googleapis.com/css?family=Gochi+Hand';", | ||
"cssAfter": "svg.<%=id%>{font-family:'Gochi Hand', cursive;font-size:14px;stroke-opacity:0.4;stroke-linecap:round;background-color:transparent}.<%=id%> text{fill:rgba(0,0,128,0.7)}.<%=id%> marker polygon{fill:rgba(0,0,255,0.4);stroke-linejoin:round}.<%=id%> line, .<%=id%> path, .<%=id%> rect, .<%=id%> polygon{stroke:blue !important}.<%=id%> text.entity-text{font-weight:bold;text-decoration:none}.<%=id%> text.return-text{font-style:italic}.<%=id%> path.note{fill:#FFFFCC;}.<%=id%> .label-text-background{opacity:0}" | ||
}, | ||
{ | ||
"name": "cygne", | ||
"description": "Cygne (best with msgenny)", | ||
"experimental": true, | ||
"deprecated": true, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> line, .<%=id%> path{stroke:#00A1DE}.<%=id%> text{fill:#005B82}.<%=id%> .entity,.<%=id%> .box{fill:#00A1DE;stroke:#00A1DE}.<%=id%> text.box-text{fill:white}.<%=id%> text.entity-text{font-weight:bold;fill:white;text-decoration:none}.<%=id%> text.return-text{font-style:italic}.<%=id%> path.note{fill:#E77B2F;stroke:white}.<%=id%> .comment,.<%=id%> .inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{fill:white}" | ||
}, | ||
{ | ||
"name": "pegasse", | ||
"description": "Pégase (best with msgenny)", | ||
"experimental": false, | ||
"deprecated": true, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> line, .<%=id%> path{stroke:rgba(0, 43, 84, 1)}.<%=id%> text{fill:rgba(0, 43, 84, 1)}.<%=id%> .entity,.<%=id%> .box{fill:rgba(0, 43, 84, 1);stroke:rgba(0, 43, 84, 1)}.<%=id%> text.box-text{fill:white}.<%=id%> text.entity-text{font-weight:bold;fill:white;text-decoration:none}.<%=id%> text.return-text{font-style:italic}.<%=id%> path.note{fill:rgba(255, 50, 0, 1);stroke:white}.<%=id%> .comment,.<%=id%> .inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{fill:white}" | ||
}, | ||
{ | ||
"name": "grayscaled", | ||
"description": "Grayscaled (not in IE or Safari)", | ||
"experimental": true, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": "svg.<%=id%>{filter:grayscale(1);-webkit-filter:grayscale(1);}" | ||
}, | ||
{ | ||
"name": "inverted", | ||
"description": "Inverted (not in IE or Safari)", | ||
"experimental": true, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": "svg.<%=id%>{filter:invert(1);-webkit-filter:invert(1);}" | ||
}, | ||
{ | ||
"name": "noentityboxes", | ||
"description": "No entity boxes", | ||
"experimental": false, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> .entity{fill:none;stroke:none;}.<%=id%> text.entity-text{text-decoration:underline;}" | ||
} | ||
] | ||
}; | ||
Object.freeze({ | ||
"name": "basic", | ||
"description": "Basic", | ||
"experimental": false, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> text.entity-text{text-decoration:underline;}" | ||
}), | ||
Object.freeze({ | ||
"name": "lazy", | ||
"description": "Lazy", | ||
"experimental": false, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> text.entity-text{font-weight:bold;}.<%=id%> text.return-text{font-style:italic}.<%=id%> path.note{fill:#FFFFCC}.<%=id%> rect.label-text-background{opacity:0.9}.<%=id%> line.comment,.<%=id%> rect.inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{stroke:grey}" | ||
}), | ||
Object.freeze({ | ||
"name": "classic", | ||
"description": "Classic", | ||
"experimental": false, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> text.entity-text{text-decoration:none}.<%=id%> .entity{stroke:none;}.<%=id%> line,.<%=id%> rect,.<%=id%> path{stroke-width:1px}.<%=id%> .arrow-style{stroke-width:2;}.<%=id%> .inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{stroke-width: 1px}" | ||
}), | ||
Object.freeze({ | ||
"name": "fountainpen", | ||
"description": "Fountain pen", | ||
"experimental": true, | ||
"deprecated": false, | ||
"renderMagic": "wobbly", | ||
"cssBefore": "@import 'https://fonts.googleapis.com/css?family=Gochi+Hand';", | ||
"cssAfter": "svg.<%=id%>{font-family:'Gochi Hand', cursive;font-size:14px;stroke-opacity:0.4;stroke-linecap:round;background-color:transparent}.<%=id%> text{fill:rgba(0,0,128,0.7)}.<%=id%> marker polygon{fill:rgba(0,0,255,0.4);stroke-linejoin:round}.<%=id%> line, .<%=id%> path, .<%=id%> rect, .<%=id%> polygon{stroke:blue !important}.<%=id%> text.entity-text{font-weight:bold;text-decoration:none}.<%=id%> text.return-text{font-style:italic}.<%=id%> path.note{fill:#FFFFCC;}.<%=id%> .label-text-background{opacity:0}" | ||
}), | ||
Object.freeze({ | ||
"name": "cygne", | ||
"description": "Cygne (best with msgenny)", | ||
"experimental": true, | ||
"deprecated": true, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> line, .<%=id%> path{stroke:#00A1DE}.<%=id%> text{fill:#005B82}.<%=id%> .entity,.<%=id%> .box{fill:#00A1DE;stroke:#00A1DE}.<%=id%> text.box-text{fill:white}.<%=id%> text.entity-text{font-weight:bold;fill:white;text-decoration:none}.<%=id%> text.return-text{font-style:italic}.<%=id%> path.note{fill:#E77B2F;stroke:white}.<%=id%> .comment,.<%=id%> .inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{fill:white}" | ||
}), | ||
Object.freeze({ | ||
"name": "pegasse", | ||
"description": "Pégase (best with msgenny)", | ||
"experimental": false, | ||
"deprecated": true, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> line, .<%=id%> path{stroke:rgba(0, 43, 84, 1)}.<%=id%> text{fill:rgba(0, 43, 84, 1)}.<%=id%> .entity,.<%=id%> .box{fill:rgba(0, 43, 84, 1);stroke:rgba(0, 43, 84, 1)}.<%=id%> text.box-text{fill:white}.<%=id%> text.entity-text{font-weight:bold;fill:white;text-decoration:none}.<%=id%> text.return-text{font-style:italic}.<%=id%> path.note{fill:rgba(255, 50, 0, 1);stroke:white}.<%=id%> .comment,.<%=id%> .inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{fill:white}" | ||
}), | ||
Object.freeze({ | ||
"name": "grayscaled", | ||
"description": "Grayscaled (not in IE or Safari)", | ||
"experimental": true, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": "svg.<%=id%>{filter:grayscale(1);-webkit-filter:grayscale(1);}" | ||
}), | ||
Object.freeze({ | ||
"name": "inverted", | ||
"description": "Inverted (not in IE or Safari)", | ||
"experimental": true, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": "svg.<%=id%>{filter:invert(1);-webkit-filter:invert(1);}" | ||
}), | ||
Object.freeze({ | ||
"name": "noentityboxes", | ||
"description": "No entity boxes", | ||
"experimental": false, | ||
"deprecated": false, | ||
"renderMagic": "straight", | ||
"cssBefore": "", | ||
"cssAfter": ".<%=id%> .entity{fill:none;stroke:none;}.<%=id%> text.entity-text{text-decoration:underline;}" | ||
})] | ||
}); | ||
}); | ||
@@ -96,0 +95,0 @@ /* |
@@ -15,7 +15,7 @@ /* istanbul ignore else */ | ||
var gEntityDims = { | ||
var gEntityDims = Object.seal({ | ||
interEntitySpacing : DEFAULT_INTER_ENTITY_SPACING, | ||
height : DEFAULT_ENTITY_HEIGHT, | ||
width : DEFAULT_ENTITY_WIDTH | ||
}; | ||
}); | ||
@@ -61,2 +61,8 @@ var gEntity2X = {}; | ||
}); | ||
/* eslint security/detect-object-injection: 0*/ | ||
/* The 'generic object injection sink' is to a frozen object, | ||
attempts to modify it will be moot => we can safely use the [] | ||
notation | ||
*/ | ||
/* | ||
@@ -63,0 +69,0 @@ This file is part of mscgen_js. |
@@ -9,3 +9,3 @@ /* istanbul ignore else */ | ||
var KIND2CLASS = { | ||
var KIND2CLASS = Object.freeze({ | ||
"|||" : "empty-row", | ||
@@ -35,5 +35,5 @@ "..." : "omitted-row", | ||
"::" : "emphasised" | ||
}; | ||
}); | ||
var KIND2AGGREGATECLASS = { | ||
var KIND2AGGREGATECLASS = Object.freeze({ | ||
"|||" : "empty", | ||
@@ -82,3 +82,3 @@ "..." : "empty", | ||
"exc" : "inline_expression" | ||
}; | ||
}); | ||
@@ -90,2 +90,8 @@ return { | ||
}); | ||
/* eslint security/detect-object-injection: 0*/ | ||
/* The 'generic object injection sink' is to a frozen object, | ||
attempts to modify it will be moot => we can safely use the [] | ||
notation | ||
*/ | ||
/* | ||
@@ -92,0 +98,0 @@ This file is part of mscgen_js. |
@@ -62,3 +62,3 @@ /* istanbul ignore else */ | ||
function _renderASTNew(pAST, pWindow, pParentElementId, pOptions) { | ||
var lAST = Object.seal(flatten.flatten(pAST)); | ||
var lAST = Object.freeze(flatten.flatten(pAST)); | ||
var lOptions = pOptions || {}; | ||
@@ -405,3 +405,3 @@ | ||
function renderBroadcastArc(pArc, pEntities, pRowMemory, pY, pOptions) { | ||
function renderBroadcastArc(pArc, pEntities, pRowMemory, pRowNumber, pOptions) { | ||
var xTo = 0; | ||
@@ -418,3 +418,3 @@ var lLabel = pArc.label; | ||
xTo = entities.getX(pEntity.name); | ||
lElement = createArc(pArc, xFrom, xTo, pY, pOptions); | ||
lElement = createArc(pArc, xFrom, xTo, pRowNumber, pOptions); | ||
pRowMemory.push({ | ||
@@ -430,3 +430,3 @@ layer : gChart.layer.sequence, | ||
function renderRegularArc(pArc, pEntities, pRowMemory, pY, pOptions){ | ||
function renderRegularArc(pArc, pEntities, pRowMemory, pRowNumber, pOptions){ | ||
var lElement = {}; | ||
@@ -436,3 +436,3 @@ | ||
if (pArc.to === "*") { // it's a broadcast arc | ||
renderBroadcastArc(pArc, pEntities, pRowMemory, pY, pOptions); | ||
renderBroadcastArc(pArc, pEntities, pRowMemory, pRowNumber, pOptions); | ||
/* creates a label on the current line, smack in the middle */ | ||
@@ -444,3 +444,3 @@ lElement = | ||
x : 0, | ||
y : pY, | ||
y : rowmemory.get(pRowNumber).y, | ||
width : gChart.arcEndX | ||
@@ -467,3 +467,3 @@ }, | ||
entities.getX(pArc.to), | ||
pY, | ||
pRowNumber, | ||
pOptions | ||
@@ -500,3 +500,3 @@ ); | ||
lArc.arcskip = 0; /* ignore arc skips when calculating row heights */ | ||
lElement = renderRegularArc(lArc, pEntities, [], 0, pOptions); | ||
lElement = renderRegularArc(lArc, pEntities, [], 0, pOptions); // TODO is 0 a good row number for this? | ||
}// switch | ||
@@ -517,10 +517,2 @@ | ||
rowmemory.set( | ||
pRowNumber, | ||
Math.max( | ||
rowmemory.get(pRowNumber).height, | ||
getArcRowHeight(pArcRow, pRowNumber, pEntities, pOptions) | ||
) | ||
); | ||
pArcRow.forEach(function(pArc){ | ||
@@ -569,3 +561,3 @@ var lElement = {}; | ||
lRowMemory, | ||
rowmemory.get(pRowNumber).y, | ||
pRowNumber, | ||
pOptions | ||
@@ -599,2 +591,32 @@ ); | ||
function precalculateArcRowHeights (pArcRows, pEntities, pOptions) { | ||
var lRealRowNumber = 0; | ||
pArcRows.forEach(function(pArcRow, pRowNumber) { | ||
function isVirtualArc(pArc) { | ||
return pArc.isVirtual; | ||
} | ||
if (pArcRow.some(isVirtualArc)){ | ||
rowmemory.set( | ||
pRowNumber, | ||
Math.max( | ||
rowmemory.get(pRowNumber).height, | ||
getArcRowHeight(pArcRow, pRowNumber, pEntities, pOptions) | ||
) | ||
); | ||
} else { | ||
rowmemory.set( | ||
pRowNumber, | ||
Math.max( | ||
rowmemory.get(pRowNumber).height, | ||
getArcRowHeight(pArcRow, pRowNumber, pEntities, pOptions) | ||
), | ||
lRealRowNumber | ||
); | ||
lRealRowNumber++; | ||
} | ||
}); | ||
} | ||
/** renderArcRows() - renders the arcrows from an AST | ||
@@ -619,6 +641,6 @@ * | ||
if (pArcRows) { | ||
for (var i = 0; i < pArcRows.length; i++){ | ||
renderArcRow(pArcRows[i], i, pEntities, pOptions); | ||
} | ||
// pArcRows.forEach(renderArcRow); | ||
precalculateArcRowHeights(pArcRows, pEntities, pOptions); | ||
pArcRows.forEach(function(pArcRow, pCounter) { | ||
renderArcRow(pArcRow, pCounter, pEntities, pOptions); | ||
}); | ||
renderInlineExpressions(gInlineExpressionMemory); | ||
@@ -649,4 +671,7 @@ } // if pArcRows | ||
var lStart = | ||
(lOnD.from - ((entities.getDims().interEntitySpacing - 3 * constants.LINE_WIDTH - lMaxDepthCorrection) / 2) - | ||
(gChart.maxDepth - pArc.depth) * 2 * constants.LINE_WIDTH); | ||
( | ||
lOnD.from - | ||
((entities.getDims().interEntitySpacing - 3 * constants.LINE_WIDTH - lMaxDepthCorrection) / 2) - | ||
(gChart.maxDepth - pArc.depth) * 2 * constants.LINE_WIDTH | ||
); | ||
@@ -831,7 +856,16 @@ var lGroup = svgelementfactory.createGroup(); | ||
function determineArcYTo(pArcSkip, pArcRowHeight, pArcGradient){ | ||
var lRetval = pArcGradient; | ||
function determineYToAbsolute(pRowNumber, pArcSkip, pArcGradient) { | ||
var lRetval = rowmemory.get(pRowNumber).y + pArcGradient; | ||
if (pArcSkip) { | ||
lRetval = (pArcSkip * pArcRowHeight); | ||
if (Boolean(pArcSkip)){ | ||
var lWholeArcSkip = Math.floor(pArcSkip); | ||
var lRestArcSkip = pArcSkip - lWholeArcSkip; | ||
var lCurrentRealRowNumber = rowmemory.get(pRowNumber).realRowNumber; | ||
lRetval = | ||
rowmemory.getByRealRowNumber(lCurrentRealRowNumber + lWholeArcSkip).y + | ||
lRestArcSkip * ( | ||
rowmemory.getByRealRowNumber(lCurrentRealRowNumber + lWholeArcSkip + 1).y - | ||
rowmemory.getByRealRowNumber(lCurrentRealRowNumber + lWholeArcSkip).y | ||
); | ||
} | ||
@@ -850,3 +884,3 @@ return lRetval; | ||
function createArc(pArc, pFrom, pTo, pY, pOptions) { | ||
function createArc(pArc, pFrom, pTo, pRowNumber, pOptions) { | ||
var lGroup = svgelementfactory.createGroup(); | ||
@@ -857,3 +891,3 @@ var lClass = "arc "; | ||
var lDoubleLine = [":>", "::", "<:>"].indexOf(pArc.kind) > -1; | ||
var lYTo = determineArcYTo(pArc.arcskip, gChart.arcRowHeight, gChart.arcGradient); | ||
var lYToAbsolute = determineYToAbsolute(pRowNumber, pArc.arcskip, gChart.arcGradient); | ||
@@ -864,3 +898,10 @@ pTo = renderutensils.determineArcXTo(pArc.kind, pFrom, pTo); | ||
lGroup.appendChild( | ||
createSelfRefArc(pArc.kind, pFrom, lYTo - gChart.arcGradient, lDoubleLine, pArc.linecolor, pY) | ||
createSelfRefArc( | ||
pArc.kind, | ||
pFrom, | ||
lYToAbsolute - rowmemory.get(pRowNumber).y - gChart.arcGradient, | ||
lDoubleLine, | ||
pArc.linecolor, | ||
rowmemory.get(pRowNumber).y | ||
) | ||
); | ||
@@ -875,3 +916,3 @@ | ||
x:pFrom + 1.5 * constants.LINE_WIDTH - (lTextWidth / 2), | ||
y:pY - (gChart.arcRowHeight / 5) - constants.LINE_WIDTH / 2, | ||
y:rowmemory.get(pRowNumber).y - (gChart.arcRowHeight / 5) - constants.LINE_WIDTH / 2, | ||
width:lTextWidth | ||
@@ -891,4 +932,9 @@ }, | ||
var lLine = svgelementfactory.createLine( | ||
{xFrom: pFrom, yFrom: pY, xTo: pTo, yTo: pY + lYTo}, | ||
{ | ||
xFrom: pFrom, | ||
yFrom: rowmemory.get(pRowNumber).y, | ||
xTo: pTo, | ||
yTo: lYToAbsolute | ||
}, | ||
{ | ||
class: lClass, | ||
@@ -909,3 +955,7 @@ doubleLine: lDoubleLine | ||
pArc, | ||
{x: pFrom, y: pY + (lYTo / 2), width: pTo - pFrom}, | ||
{ | ||
x: pFrom, | ||
y: rowmemory.get(pRowNumber).y + ((lYToAbsolute - rowmemory.get(pRowNumber).y) / 2), | ||
width: pTo - pFrom | ||
}, | ||
_.defaults( | ||
@@ -1052,3 +1102,6 @@ _.cloneDeep(pOptions), | ||
var lTextBBox = svgutensils.getBBox(lTextGroup); | ||
var lHeight = Math.max(lTextBBox.height + 2 * constants.LINE_WIDTH, gChart.arcRowHeight - 2 * constants.LINE_WIDTH); | ||
var lHeight = Math.max( | ||
lTextBBox.height + 2 * constants.LINE_WIDTH, | ||
gChart.arcRowHeight - 2 * constants.LINE_WIDTH | ||
); | ||
var lBBox = {width: lWidth, height: lHeight, x: lStart, y: (pY - lHeight / 2)}; | ||
@@ -1055,0 +1108,0 @@ |
@@ -133,3 +133,5 @@ /* istanbul ignore else */ | ||
} | ||
lStartY = pDims.y - (lLines.length - 1) / 2 * (svgutensils.calculateTextHeight() + constants.LINE_WIDTH + 1); | ||
lStartY = | ||
pDims.y - | ||
(lLines.length - 1) / 2 * (svgutensils.calculateTextHeight() + constants.LINE_WIDTH + 1); | ||
} | ||
@@ -136,0 +138,0 @@ lLines |
@@ -218,2 +218,7 @@ /* istanbul ignore else */ | ||
}); | ||
/* eslint security/detect-object-injection: 0*/ | ||
/* The 'generic object injection sink' is to a frozen object, | ||
attempts to modify it will be moot => we can safely use the [] | ||
notation | ||
*/ | ||
/* | ||
@@ -220,0 +225,0 @@ This file is part of mscgen_js. |
@@ -13,3 +13,3 @@ /* istanbul ignore else */ | ||
*/ | ||
var gRowInfo = []; | ||
var gRowInfoArray = []; | ||
var gDefaultEntityHeight = 0; | ||
@@ -19,4 +19,4 @@ var gDefaultArcRowHeight = 0; | ||
function get(pRowNumber) { | ||
if (gRowInfo[pRowNumber]) { | ||
return gRowInfo[pRowNumber]; | ||
if (gRowInfoArray[pRowNumber]) { | ||
return gRowInfoArray[pRowNumber]; | ||
} else { | ||
@@ -30,2 +30,6 @@ return { | ||
function getLast(){ | ||
return get(gRowInfoArray.length - 1); | ||
} | ||
return { | ||
@@ -37,3 +41,3 @@ | ||
clear: function(pEntityHeight, pArcRowHeight) { | ||
gRowInfo = []; | ||
gRowInfoArray = []; | ||
gDefaultEntityHeight = pEntityHeight; | ||
@@ -52,6 +56,27 @@ gDefaultArcRowHeight = pArcRowHeight; | ||
getLast: function(){ | ||
return get(gRowInfo.length - 1); | ||
/** | ||
* the row info for a given pRealRowNumber. | ||
* | ||
* If the function couldn't find the real row number it'll | ||
* return the virtual instead. | ||
* | ||
* @param <int> pRealRowNumber | ||
*/ | ||
getByRealRowNumber: function (pRealRowNumber) { | ||
var lRetval = 0; | ||
var lRowInfoArray = gRowInfoArray.filter(function(pRowInfo){ | ||
return pRowInfo.realRowNumber === pRealRowNumber; | ||
}); | ||
if (lRowInfoArray.length > 0){ | ||
lRetval = lRowInfoArray[0]; | ||
} else { // most likely asking for something below the bottom of the chart => return the bottom | ||
lRetval = getLast(); | ||
} | ||
return lRetval; | ||
}, | ||
getLast: getLast, | ||
/** | ||
@@ -64,8 +89,9 @@ * set() - stores the pHeight for the given pRowNumber, and sets | ||
*/ | ||
set: function (pRowNumber, pHeight) { | ||
set: function (pRowNumber, pHeight, pRealRowNumber) { | ||
var lPreviousRowInfo = get(pRowNumber - 1); | ||
gRowInfo[pRowNumber] = { | ||
gRowInfoArray[pRowNumber] = { | ||
y : lPreviousRowInfo.y + (lPreviousRowInfo.height + pHeight) / 2, | ||
height : pHeight | ||
height : pHeight, | ||
realRowNumber : pRealRowNumber | ||
}; | ||
@@ -72,0 +98,0 @@ } |
@@ -8,6 +8,6 @@ /* istanbul ignore else */ | ||
"use strict"; | ||
return { | ||
return Object.freeze({ | ||
baseTemplate : "<%=baseTemplateString%>", | ||
namedStyles : <%=additionalTemplates%> | ||
}; | ||
}); | ||
}); | ||
@@ -14,0 +14,0 @@ /* |
@@ -1,3 +0,3 @@ | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
@@ -8,15 +8,15 @@ const MULTILINE_COMMENT_RE = /\/\*(.)*?\*\//g; | ||
let compress = pString => | ||
const compress = pString => | ||
pString.replace(SPACES_RE, "").replace(MULTILINE_COMMENT_RE, ""); | ||
let dirNameIsAddition = pDirName => | ||
const dirNameIsAddition = pDirName => | ||
Boolean(pDirName.match(ADDITION_RE)); | ||
let extractName = pFileName => | ||
const extractName = pFileName => | ||
pFileName.substr(3, pFileName.match(ADDITION_RE).index - 3); | ||
let extractFileContents = pFilePath => | ||
const extractFileContents = pFilePath => | ||
fileExists(pFilePath) ? compress(fs.readFileSync(pFilePath, 'utf-8')) : ""; | ||
let fileExists = pFileName => { | ||
const fileExists = pFileName => { | ||
try { | ||
@@ -30,5 +30,5 @@ fs.readFileSync(pFileName, 'utf-8'); | ||
let dirNameToAdditionNode = pRootDirName => | ||
const dirNameToAdditionNode = pRootDirName => | ||
pDirName => { | ||
let $config = require("./" + path.join(pDirName, "config.json")); | ||
const $config = require("./" + path.join(pDirName, "config.json")); | ||
@@ -46,6 +46,13 @@ return { | ||
let dirToAdditionsArray = pRootDirName => | ||
const dirToAdditionsArray = pRootDirName => | ||
fs.readdirSync(pRootDirName) | ||
.filter(dirNameIsAddition) | ||
.map(dirNameToAdditionNode(pRootDirName)); | ||
.map((pDirName) => | ||
` | ||
Object.freeze(${JSON.stringify( | ||
dirNameToAdditionNode(pRootDirName)(pDirName), | ||
null, | ||
" " | ||
)})` | ||
); | ||
@@ -56,7 +63,3 @@ process.stdout.write( | ||
/<%=additionalTemplates%>/g, | ||
JSON.stringify( | ||
dirToAdditionsArray("render/graphics/styling/"), | ||
null, | ||
" " | ||
) | ||
`[${dirToAdditionsArray("render/graphics/styling/")}]` | ||
) | ||
@@ -68,1 +71,6 @@ .replace( | ||
); | ||
/* eslint security/detect-non-literal-fs-filename: 0, security/detect-non-literal-require: 0 */ | ||
/* eslint import/no-dynamic-require: 0 */ | ||
/* the purpose of this utility is to write to a file, | ||
so non-literal-fs filenames are ok here | ||
*/ |
@@ -214,2 +214,7 @@ /* | ||
}); | ||
/* eslint security/detect-object-injection: 0 */ | ||
/* translateAttributes has two of these => local variables only | ||
so we're good here | ||
*/ | ||
/* | ||
@@ -216,0 +221,0 @@ This file is part of mscgen_js. |
@@ -26,3 +26,11 @@ /* | ||
"renderKindfn" : renderKind, | ||
"supportedOptions" : ["hscale", "width", "arcgradient", "wordwraparcs", "watermark", "wordwrapentities", "wordwrapboxes"], | ||
"supportedOptions" : [ | ||
"hscale", | ||
"width", | ||
"arcgradient", | ||
"wordwraparcs", | ||
"watermark", | ||
"wordwrapentities", | ||
"wordwrapboxes" | ||
], | ||
"supportedEntityAttributes" : ["label"], | ||
@@ -29,0 +37,0 @@ "supportedArcAttributes" : ["label"], |
@@ -15,3 +15,3 @@ /* istanbul ignore else */ | ||
*/ | ||
var KIND2ARROW = { | ||
var KIND2ARROW = Object.freeze({ | ||
"->" : "rvee", | ||
@@ -22,4 +22,4 @@ "<->" : "rvee", | ||
"-x" : "oinvonormal" | ||
}; | ||
var KIND2SHAPE = { | ||
}); | ||
var KIND2SHAPE = Object.freeze({ | ||
"box" : "box", | ||
@@ -29,4 +29,4 @@ "abox" : "hexagon", | ||
"note" : "note" | ||
}; | ||
var KIND2STYLE = { | ||
}); | ||
var KIND2STYLE = Object.freeze({ | ||
">>" : "dashed", | ||
@@ -39,3 +39,3 @@ "<<>>" : "dashed", | ||
"rbox" : "rounded" | ||
}; | ||
}); | ||
@@ -49,2 +49,8 @@ return { | ||
}); | ||
/* eslint security/detect-object-injection: 0*/ | ||
/* The 'generic object injection sink' is to a frozen object, | ||
attempts to modify it will be moot => we can safely use the [] | ||
notation | ||
*/ | ||
/* | ||
@@ -51,0 +57,0 @@ This file is part of mscgen_js. |
@@ -62,2 +62,6 @@ /* istanbul ignore else */ | ||
}); | ||
/* eslint security/detect-object-injection: 0 */ | ||
/* the array indexing flagged here as object injection is done | ||
with a local variable only. | ||
*/ | ||
/* | ||
@@ -64,0 +68,0 @@ This file is part of mscgen_js. |
Sorry, the diff of this file is not supported yet
932286
19650
15