New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mscgenjs

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mscgenjs - npm Package Compare versions

Comparing version 2.0.0-beta-4 to 2.0.0-beta-5

9

package.json
{
"name": "mscgenjs",
"version": "2.0.0-beta-4",
"version": "2.0.0-beta-5",
"description": "Sequence chart rendering library",

@@ -18,6 +18,6 @@ "main": "src/index.js",

"eslint-plugin-security": "1.4.0",
"jest": "22.4.4",
"jest": "23.0.0",
"jest-json-schema": "2.0.0",
"js-makedepend": "3.0.0",
"jsdom": "11.10.0",
"jsdom": "11.11.0",
"lodash-cli": "4.17.5",

@@ -68,3 +68,4 @@ "npm-check-updates": "2.14.2",

"src/render/graphics/styling",
"src/render/graphics/svgelementfactory/wobbly\\.js"
"src/render/graphics/svgelementfactory/wobbly\\.js",
"src/parse/.+parser\\.js"
],

@@ -71,0 +72,0 @@ "coverageThreshold": {

@@ -160,5 +160,2 @@ # mscgen_js - core package

);
// result:

@@ -165,0 +162,0 @@ //

@@ -92,3 +92,3 @@ /* istanbul ignore else */

version: "2.0.0-beta-4",
version: "2.0.0-beta-5",

@@ -95,0 +95,0 @@ getAllowedValues: function() {

@@ -9,3 +9,7 @@ /* istanbul ignore else */

var renderlabels = require("./renderlabels");
var renderlabels = require("./renderlabels");
var svgelementfactory = require("./svgelementfactory/index");
var svgutensils = require("./svgutensils");
var constants = require("./constants");
var _ = require("../../lib/lodash/lodash.custom");

@@ -19,3 +23,4 @@ var DEFAULT_INTER_ENTITY_SPACING = 160; // px

height : DEFAULT_ENTITY_HEIGHT,
width : DEFAULT_ENTITY_WIDTH
width : DEFAULT_ENTITY_WIDTH,
entityXHWM : 0
});

@@ -25,6 +30,110 @@

function getX (pName){
function getX(pName){
return gEntity2X[pName];
}
function setX(pEntity, pX){
gEntity2X[pEntity.name] = pX + (gEntityDims.width / 2);
}
function getDims(){
return gEntityDims;
}
function getNoEntityLines(pLabel, pFontSize, pOptions){
return renderlabels.splitLabel(pLabel, "entity", gEntityDims.width, pFontSize, pOptions).length;
}
function sizeEntityBoxToLabel(pLabel, pBBox) {
var lLabelWidth = Math.min(
svgutensils.getBBox(pLabel).width + (4 * constants.LINE_WIDTH),
(pBBox.interEntitySpacing / 3) + pBBox.width
);
if (lLabelWidth >= pBBox.width) {
pBBox.x -= (lLabelWidth - pBBox.width) / 2;
pBBox.width = lLabelWidth;
}
return pBBox;
}
function renderEntity(pEntity, pX, pY, pOptions) {
var lGroup = svgelementfactory.createGroup();
var lBBox = _.cloneDeep(gEntityDims);
lBBox.x = pX ? pX : 0;
lBBox.y = pY ? pY : 0;
var lLabel = renderlabels.createLabel(
_.defaults(
pEntity,
{
kind: "entity"
}
),
{
x:lBBox.x,
y:pY + (lBBox.height / 2),
width:lBBox.width
},
pOptions
);
lGroup.appendChild(
svgelementfactory.createRect(
sizeEntityBoxToLabel(lLabel, lBBox),
"entity",
pEntity.linecolor,
pEntity.textbgcolor
)
);
lGroup.appendChild(lLabel);
return lGroup;
}
function renderEntities(pEntities, pEntityYPos, pOptions){
var lEntityGroup = svgelementfactory.createGroup();
gEntityDims.entityXHWM = 0;
gEntityDims.height = getMaxEntityHeight(pEntities, pOptions) + constants.LINE_WIDTH * 2;
pEntities.forEach(function(pEntity){
lEntityGroup.appendChild(renderEntity(pEntity, gEntityDims.entityXHWM, pEntityYPos, pOptions));
setX(pEntity, gEntityDims.entityXHWM);
gEntityDims.entityXHWM += gEntityDims.interEntitySpacing;
});
return lEntityGroup;
}
/**
* getMaxEntityHeight() -
* crude method for determining the max entity height;
* - take the entity with the most number of lines
* - if that number > 2 (default entity hight easily fits 2 lines of text)
* - render that entity
* - return the height of its bbox
*
* @param <object> - pEntities - the entities subtree of the AST
* @return <int> - height - the height of the heighest entity
*/
function getMaxEntityHeight(pEntities, pOptions){
var lHighestEntity = pEntities[0];
var lHWM = 2;
pEntities.forEach(function(pEntity){
var lNoEntityLines = getNoEntityLines(pEntity.label, constants.FONT_SIZE, pOptions);
if (lNoEntityLines > lHWM){
lHWM = lNoEntityLines;
lHighestEntity = pEntity;
}
});
if (lHWM > 2){
return Math.max(
gEntityDims.height,
svgutensils.getBBox(
renderEntity(lHighestEntity, 0, 0, pOptions)
).height
);
}
return gEntityDims.height;
}
return {

@@ -35,2 +144,3 @@ init: function (pHScale){

gEntityDims.width = DEFAULT_ENTITY_WIDTH;
gEntityDims.entityXHWM = 0;

@@ -44,5 +154,2 @@ if (pHScale) {

getX: getX,
setX: function (pEntity, pX){
gEntity2X[pEntity.name] = pX + (gEntityDims.width / 2);
},
getOAndD: function (pFrom, pTo){

@@ -54,11 +161,4 @@ return {

},
setHeight: function (pHeight){
gEntityDims.height = pHeight;
},
getDims: function (){
return gEntityDims;
},
getNoEntityLines: function(pLabel, pFontSize, pOptions){
return renderlabels.splitLabel(pLabel, "entity", gEntityDims.width, pFontSize, pOptions).length;
}
getDims: getDims,
renderEntities: renderEntities
};

@@ -65,0 +165,0 @@ });

@@ -43,16 +43,16 @@ /* istanbul ignore else */

var gChart = Object.seal({
"arcRowHeight" : DEFAULT_ARCROW_HEIGHT,
"arcGradient" : DEFAULT_ARC_GRADIENT,
"arcEndX" : 0,
"wordWrapArcs" : false,
"mirrorEntitiesOnBottom" : false,
"regularArcTextVerticalAlignment": "middle",
"maxDepth" : 0,
"document" : {},
"layer" : {
"lifeline" : {},
"sequence" : {},
"notes" : {},
"inline" : {},
"watermark" : {}
arcRowHeight : DEFAULT_ARCROW_HEIGHT,
arcGradient : DEFAULT_ARC_GRADIENT,
arcEndX : 0,
wordWrapArcs : false,
mirrorEntitiesOnBottom : false,
regularArcTextVerticalAlignment: "middle",
maxDepth : 0,
document : {},
layer : {
lifeline : {},
sequence : {},
notes : {},
inline : {},
watermark : {}
}

@@ -62,3 +62,3 @@ });

function _renderASTNew(pAST, pWindow, pParentElementId, pOptions) {
function renderAST(pAST, pWindow, pParentElementId, pOptions) {
var lAST = Object.freeze(flatten.flatten(pAST));

@@ -195,15 +195,15 @@ var lOptions = pOptions || {};

var lCanvas = {
"width" :
width :
(pAST.entities.length * entities.getDims().interEntitySpacing) + lDepthCorrection,
"height" :
height :
Boolean(gChart.mirrorEntitiesOnBottom)
? (2 * entities.getDims().height) + lRowInfo.y + lRowInfo.height + 2 * PAD_VERTICAL
: lRowInfo.y + (lRowInfo.height / 2) + 2 * PAD_VERTICAL,
"horizontaltransform" :
horizontaltransform :
(entities.getDims().interEntitySpacing + lDepthCorrection - entities.getDims().width) / 2,
"autoscale" :
autoscale :
!!pAST.options && !!pAST.options.width && pAST.options.width === "auto",
"verticaltransform" :
verticaltransform :
PAD_VERTICAL,
"scale" : 1
scale : 1
};

@@ -269,79 +269,3 @@ lCanvas.x = 0 - lCanvas.horizontaltransform;

/* ----------------------START entity shizzle-------------------------------- */
/**
* getMaxEntityHeight() -
* crude method for determining the max entity height;
* - take the entity with the most number of lines
* - if that number > 2 (default entity hight easily fits 2 lines of text)
* - render that entity
* - return the height of its bbox
*
* @param <object> - pEntities - the entities subtree of the AST
* @return <int> - height - the height of the heighest entity
*/
function getMaxEntityHeight(pEntities, pOptions){
var lHighestEntity = pEntities[0];
var lHWM = 2;
pEntities.forEach(function(pEntity){
var lNoEntityLines = entities.getNoEntityLines(pEntity.label, constants.FONT_SIZE, pOptions);
if (lNoEntityLines > lHWM){
lHWM = lNoEntityLines;
lHighestEntity = pEntity;
}
});
if (lHWM > 2){
return Math.max(
entities.getDims().height,
svgutensils.getBBox(
renderEntity(lHighestEntity, 0, 0, pOptions)
).height
);
}
return entities.getDims().height;
}
function sizeEntityBoxToLabel(pLabel, pBBox) {
var lLabelWidth = Math.min(
svgutensils.getBBox(pLabel).width + (4 * constants.LINE_WIDTH),
(pBBox.interEntitySpacing / 3) + pBBox.width
);
if (lLabelWidth >= pBBox.width) {
pBBox.x -= (lLabelWidth - pBBox.width) / 2;
pBBox.width = lLabelWidth;
}
return pBBox;
}
function renderEntity(pEntity, pX, pY, pOptions) {
var lGroup = svgelementfactory.createGroup();
var lBBox = _.cloneDeep(entities.getDims());
lBBox.x = pX ? pX : 0;
lBBox.y = pY ? pY : 0;
var lLabel = renderlabels.createLabel(
_.defaults(
pEntity,
{
kind: "entity"
}
),
{
x:lBBox.x,
y:pY + (lBBox.height / 2),
width:lBBox.width
},
pOptions
);
lGroup.appendChild(
svgelementfactory.createRect(
sizeEntityBoxToLabel(lLabel, lBBox),
"entity",
pEntity.linecolor,
pEntity.textbgcolor
)
);
lGroup.appendChild(lLabel);
return lGroup;
}
function renderEntitiesOnBottom(pEntities, pOptions) {

@@ -383,23 +307,15 @@ var lLifeLineSpacerY = rowmemory.getLast().y + (rowmemory.getLast().height + gChart.arcRowHeight) / 2;

* @param <object> - pEntities - the entities to render
* @param <int> - pEntityYPos - the Y position to render the entities on
* @param <object> - pOptions
*
*/
function renderEntities(pEntities, pEntityYPos, pOptions) {
var lEntityXPos = 0;
var lEntityGroup = svgelementfactory.createGroup();
if (pEntities) {
entities.setHeight(getMaxEntityHeight(pEntities, pOptions) + constants.LINE_WIDTH * 2);
pEntities.forEach(function(pEntity){
lEntityGroup.appendChild(renderEntity(pEntity, lEntityXPos, pEntityYPos, pOptions));
entities.setX(pEntity, lEntityXPos);
lEntityXPos += entities.getDims().interEntitySpacing;
});
gChart.layer.sequence.appendChild(
lEntityGroup
entities.renderEntities(pEntities, pEntityYPos, pOptions)
);
}
gChart.arcEndX =
lEntityXPos -
entities.getDims().entityXHWM -
entities.getDims().interEntitySpacing + entities.getDims().width;
}

@@ -1131,25 +1047,2 @@

/**
* renders the given abstract syntax tree pAST as svg
* in the element with id pParentELementId in the window pWindow
*
* @param {object} pAST - the abstract syntax tree
* @param {string} pSource - the source msc to embed in the svg
* @param {string} pParentElementId - the id of the parent element in which
* to put the __svg_output element
* @param {window} pWindow - the browser window to put the svg in
* @param {string} pStyleAdditions - valid css that augments the default style
*/
renderAST : function (pAST, pSource, pParentElementId, pWindow, pStyleAdditions) {
return _renderASTNew(
pAST,
pWindow,
pParentElementId,
{
source: pSource,
styleAdditions: pStyleAdditions
}
);
},
/**
* renders the given abstract syntax tree pAST as svg

@@ -1170,3 +1063,3 @@ * in the element with id pParentELementId in the window pWindow

*/
renderASTNew : _renderASTNew
renderASTNew : renderAST
};

@@ -1173,0 +1066,0 @@ });

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