Huge News!Announcing our $40M Series B led by Abstract Ventures.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 1.5.3 to 1.6.0

render/graphics/straight.js

6

doc/samples/sample-requirejs.js

@@ -11,3 +11,3 @@ define(function (require) {

elementId: "output",
additionalTemplate: "lazy"
additionalTemplate: "fountainpen"
},

@@ -30,3 +30,3 @@ function (pError, pSuccess) {

function(){
window.inputscript.value += "\nAlice loop Bob: condition {\n Alice =>> Bob: do stuff;\n};\n";
window.inputscript.value += "\na loop d: condition {\n a =>> d: do stuff;\n};\n";
render();

@@ -39,3 +39,3 @@ },

function(){
window.inputscript.value += "\nAlice alt Bob: happyflow {\n # happy flow here\n\n ---: alternateflow; \n # alternate flow here\n};\n";
window.inputscript.value += "\na alt d: happyflow {\n # happy flow here\n\n ---: alternateflow; \n # alternate flow here\n};\n";
render();

@@ -42,0 +42,0 @@ },

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

version: "1.5.3",
version: "1.6.0",

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

{
"name": "mscgenjs",
"version": "1.5.3",
"version": "1.6.0",
"description": "Implementation of MscGen in JavaScript",

@@ -13,9 +13,9 @@ "main": "index.js",

"chai-xml": "0.3.1",
"eslint": "3.7.1",
"eslint": "3.8.1",
"istanbul": "0.4.5",
"js-makedepend": "1.0.5",
"jsdom": "9.6.0",
"jsdom": "9.8.0",
"lodash-cli": "4.16.4",
"mocha": "3.1.0",
"npm-check-updates": "2.8.4",
"mocha": "3.1.2",
"npm-check-updates": "2.8.5",
"nsp": "2.6.2",

@@ -22,0 +22,0 @@ "pegjs": "0.10.0",

@@ -15,2 +15,3 @@ /* istanbul ignore else */

"experimental": false,
"renderMagic": "straight",
"cssBefore": "",

@@ -23,2 +24,3 @@ "cssAfter": ".<%=id%> text.entity-text{font-weight:bold;text-decoration:none;}.<%=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}"

"experimental": false,
"renderMagic": "straight",
"cssBefore": "",

@@ -31,2 +33,3 @@ "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}"

"experimental": true,
"renderMagic": "wobbly",
"cssBefore": "@import 'https://fonts.googleapis.com/css?family=Gochi+Hand';",

@@ -39,2 +42,3 @@ "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}.<%=id%> .comment,.<%=id%> .inline_expression,.<%=id%> .inline_expression_divider,.<%=id%> .inline_expression_label{stroke:black}"

"experimental": false,
"renderMagic": "straight",
"cssBefore": "",

@@ -47,2 +51,3 @@ "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}"

"experimental": false,
"renderMagic": "straight",
"cssBefore": "",

@@ -55,2 +60,3 @@ "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}"

"experimental": true,
"renderMagic": "straight",
"cssBefore": "",

@@ -63,2 +69,3 @@ "cssAfter": "svg.<%=id%>{filter:grayscale(1);-webkit-filter:grayscale(1);}"

"experimental": true,
"renderMagic": "straight",
"cssBefore": "",

@@ -65,0 +72,0 @@ "cssAfter": "svg.<%=id%>{filter:invert(1);-webkit-filter:invert(1);}"

@@ -44,2 +44,6 @@ /* istanbul ignore else */

function round(pNumber) {
return Math.round(pNumber * 1000) / 1000;
}
function getBetweenPoints(pLine, pInterval, pWobble) {

@@ -62,6 +66,6 @@ if (pInterval <= 0) {

lCurveSection = {
controlX : pLine.xFrom + (i - 0.5) * lIntervalX + getRandomDeviation(pWobble),
controlY : pLine.yFrom + (i - 0.5) * lIntervalY + getRandomDeviation(pWobble),
x : pLine.xFrom + i * lIntervalX,
y : pLine.yFrom + i * lIntervalY
controlX : round(pLine.xFrom + (i - 0.5) * lIntervalX + getRandomDeviation(pWobble)),
controlY : round(pLine.yFrom + (i - 0.5) * lIntervalY + getRandomDeviation(pWobble)),
x : round(pLine.xFrom + i * lIntervalX),
y : round(pLine.yFrom + i * lIntervalY)
};

@@ -85,2 +89,4 @@ if (pInterval >

return {
round: round,
/**

@@ -87,0 +93,0 @@ * returns the angle (in degrees) of the line from the

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

}
var lSkeletonSvg = fact.createSVG(pSvgElementId, pSvgElementId);
var lSkeletonSvg = fact.createSVG(pSvgElementId, pSvgElementId, distillRenderMagic(pOptions));
lSkeletonSvg.appendChild(setupDesc(pWindow, pSvgElementId, pOptions.source));

@@ -109,5 +109,37 @@ lSkeletonSvg.appendChild(setupDefs(pSvgElementId, pMarkerDefs, pOptions));

function findNamedStyle(pAdditionalTemplate) {
var lRetval = null;
var lNamedStyles = csstemplates.namedStyles.filter(
function(tpl) {
return tpl.name === pAdditionalTemplate;
}
);
if (lNamedStyles.length > 0) {
lRetval = lNamedStyles[0];
}
return lRetval;
}
function distillRenderMagic(pOptions) {
var lRetval = "";
var lNamedStyle = {};
/* istanbul ignore if */
if (!Boolean(pOptions)) {
return "";
}
if (Boolean(pOptions.additionalTemplate)) {
lNamedStyle = findNamedStyle(pOptions.additionalTemplate);
if (Boolean(lNamedStyle)){
lRetval = lNamedStyle.renderMagic;
}
}
return lRetval;
}
function distillCSS(pOptions, pPosition) {
var lStyleString = "";
var lNamedStyles = [];
var lNamedStyle = {};

@@ -120,12 +152,8 @@ /* istanbul ignore if */

if (Boolean(pOptions.additionalTemplate)) {
lNamedStyles =
csstemplates.namedStyles.filter(
function(tpl) {
return tpl.name === pOptions.additionalTemplate;
}
);
if (lNamedStyles.length > 0) {
lStyleString = lNamedStyles[0][pPosition];
lNamedStyle = findNamedStyle(pOptions.additionalTemplate);
if (Boolean(lNamedStyle)){
lStyleString = lNamedStyle[pPosition];
}
}
return lStyleString;

@@ -132,0 +160,0 @@ }

{
"experimental": false,
"description": "Lazy"
"description": "Lazy",
"renderMagic": "straight"
}
{
"experimental": false,
"description": "Classic"
"description": "Classic",
"renderMagic": "straight"
}
{
"experimental": true,
"description": "Fountain pen (experimental!)"
"description": "Fountain pen (experimental!)",
"renderMagic": "wobbly"
}
{
"experimental": false,
"description": "Cygne (best with msgenny)"
"description": "Cygne (best with msgenny)",
"renderMagic": "straight"
}
{
"experimental": false,
"description": "Pégasse (best with msgenny)"
"description": "Pégasse (best with msgenny)",
"renderMagic": "straight"
}
{
"experimental": true,
"description": "Grayscaled (not in IE or Safari)"
"description": "Grayscaled (not in IE or Safari)",
"renderMagic": "straight"
}
{
"experimental": true,
"description": "Inverted (not in IE or Safari)"
"description": "Inverted (not in IE or Safari)",
"renderMagic": "straight"
}

@@ -37,2 +37,3 @@ var fs = require('fs');

experimental : $config.experimental,
renderMagic : $config.renderMagic,
cssBefore : extractFileContents(path.join(pRootDirName, pDirName, "before.css")),

@@ -39,0 +40,0 @@ cssAfter : extractFileContents(path.join(pRootDirName, pDirName, "after.css"))

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

define([
"./constants",
"./svglowlevelfactory",
"./geometry",
"../../lib/lodash/lodash.custom"], function(C, factll, math, _) {
define(function(require) {
/**

@@ -27,67 +23,13 @@ * Renders individual elements in sequence charts

var C = require("./constants");
var factll = require("./svglowlevelfactory");
var prim = require("./svgprimitives");
var geo = require("./geometry");
var straight = require("./straight");
var wobbly = require("./wobbly");
var _ = require("../../lib/lodash/lodash.custom");
var gDocument = {};
var gRenderMagic = straight;
function point2String(pX, pY) {
return pX.toString() + "," + pY.toString() + " ";
}
function pathPoint2String(pType, pX, pY) {
return pType + point2String(pX, pY);
}
/**
* Creates an svg path element given the path pD, with pClass applied
* (if provided)
* @param {string} pD - the path
* @param {string} pClass - reference to a css class
* @return {SVGElement}
*/
function _createPath(pD, pClass, pColor, pBgColor) {
return colorBox(
factll.createElement(
"path",
{
d: pD,
class: pClass
}
),
pColor,
pBgColor
);
}
function _createPolygon(pPoints, pClass) {
return factll.createElement(
"polygon",
{
points: pPoints,
class: pClass
}
);
}
function colorBox(pElement, pColor, pBgColor){
var lStyleString = "";
if (pBgColor) {
lStyleString += "fill:" + pBgColor + ";";
}
if (pColor) {
lStyleString += "stroke:" + pColor + ";";
}
return factll.setAttribute(pElement, "style", lStyleString);
}
function createSingleLine(pLine, pOptions) {
return factll.createElement(
"line",
{
x1: pLine.xFrom.toString(),
y1: pLine.yFrom.toString(),
x2: pLine.xTo.toString(),
y2: pLine.yTo.toString(),
class: pOptions ? pOptions.class : null
}
);
}
function createLink (pURL, pElementToWrap){

@@ -144,54 +86,2 @@ var lA = gDocument.createElementNS(C.SVGNS, "a");

function determineEndCorrection(pLine, pClass){
var lRetval = 0;
if (pClass.indexOf("nodi") < 0){
lRetval = pLine.xTo > pLine.xFrom ? -7.5 * C.LINE_WIDTH : 7.5 * C.LINE_WIDTH;
}
return lRetval;
}
function determineStartCorrection(pLine, pClass){
var lRetval = 0;
if (pClass.indexOf("nodi") < 0){
if (pClass.indexOf("bidi") > -1) {
if (pLine.xTo > pLine.xFrom){
lRetval = 7.5 * C.LINE_WIDTH;
} else {
lRetval = -7.5 * C.LINE_WIDTH;
}
}
}
return lRetval;
}
function createDoubleLine(pLine, pOptions) {
var lSpace = C.LINE_WIDTH;
var lClass = pOptions ? pOptions.class : null;
var lDir = math.getDirection(pLine);
var lEndCorr = determineEndCorrection(pLine, lClass);
var lStartCorr = determineStartCorrection(pLine, lClass);
var lLenX = (pLine.xTo - pLine.xFrom + lEndCorr - lStartCorr).toString();
var lLenY = (pLine.yTo - pLine.yFrom).toString();
var lStubble = pathPoint2String("l", lDir.signX, lDir.dy);
var lLine = pathPoint2String("l", lLenX, lLenY);
return _createPath(
pathPoint2String("M", pLine.xFrom, (pLine.yFrom - 7.5 * C.LINE_WIDTH * lDir.dy)) +
// left stubble:
lStubble +
pathPoint2String("M", pLine.xFrom + lStartCorr, pLine.yFrom - lSpace) +
// upper line:
lLine +
pathPoint2String("M", pLine.xFrom + lStartCorr, pLine.yFrom + lSpace) +
// lower line
lLine +
pathPoint2String("M", pLine.xTo - lDir.signX, pLine.yTo + 7.5 * C.LINE_WIDTH * lDir.dy) +
// right stubble
lStubble,
lClass
);
}
function _createMarker(pId, pClass, pOrient, pViewBox) {

@@ -230,2 +120,12 @@ /* so, why not start at refX=0, refY=0? It would simplify reasoning

function determineRenderMagic(pRenderMagic) {
if (!Boolean(pRenderMagic)) {
return gRenderMagic;
}
if ("wobbly" === pRenderMagic){
return wobbly;
}
return straight;
}
return {

@@ -248,3 +148,4 @@ /**

*/
createSVG: function (pId, pClass) {
createSVG: function (pId, pClass, pRenderMagic) {
gRenderMagic = determineRenderMagic(pRenderMagic);
return factll.createElement(

@@ -298,16 +199,3 @@ "svg",

createRect : function (pBBox, pClass, pColor, pBgColor) {
return colorBox(
factll.createElement(
"rect",
{
width: pBBox.width,
height: pBBox.height,
x: pBBox.x,
y: pBBox.y,
class: pClass
}
),
pColor,
pBgColor
);
return gRenderMagic.createRect(pBBox, {class: pClass, color: pColor, bgColor: pBgColor});
},

@@ -324,20 +212,3 @@

createRBox: function (pBBox, pClass, pColor, pBgColor) {
var RBOX_CORNER_RADIUS = 6; // px
return colorBox(
factll.createElement(
"rect",
{
width: pBBox.width,
height: pBBox.height,
x: pBBox.x,
y: pBBox.y,
rx: RBOX_CORNER_RADIUS,
ry: RBOX_CORNER_RADIUS,
class: pClass
}
),
pColor,
pBgColor
);
return gRenderMagic.createRBox(pBBox, {class: pClass, color: pColor, bgColor: pBgColor});
},

@@ -354,17 +225,3 @@

createABox: function (pBBox, pClass, pColor, pBgColor) {
var lSlopeOffset = 3;
return _createPath(
// start
"M" + pBBox.x + "," + (pBBox.y + (pBBox.height / 2)) +
"l" + lSlopeOffset + ", -" + pBBox.height / 2 +
// top line
"l" + (pBBox.width - 2 * lSlopeOffset) + ",0" +
// right wedge
"l" + lSlopeOffset + "," + pBBox.height / 2 +
"l-" + lSlopeOffset + "," + pBBox.height / 2 +
// bottom line:
"l-" + (pBBox.width - 2 * lSlopeOffset) + ",0 " +
"z",
pClass, pColor, pBgColor
);
return gRenderMagic.createABox(pBBox, {class: pClass, color: pColor, bgColor: pBgColor});
},

@@ -383,28 +240,3 @@

createNote: function (pBBox, pClass, pColor, pBgColor) {
var lFoldSizeN = Math.max(9, Math.min(4.5 * C.LINE_WIDTH, pBBox.height / 2));
var lFoldSize = lFoldSizeN.toString(10);
return _createPath(
"M" + pBBox.x + "," + pBBox.y +
// top line:
"l" + (pBBox.width - lFoldSizeN) + ",0 " +
// fold:
// we lift the pen of the paper here to make sure the fold
// gets the fill color as well when such is specified
"l0," + lFoldSize + " l" + lFoldSize + ",0 m-" + lFoldSize + ",-" +
lFoldSize + " l" + lFoldSize + "," + lFoldSize + " " +
// down:
"l0," + (pBBox.height - lFoldSizeN) + " " +
// bottom line:
"l-" + pBBox.width + ",0 " +
"l0,-" + pBBox.height + " " +
// because we lifted the pen from the paper in the fold (see
// the m over there) - svg interpreters consider that to be
// the start of the path. So, although we're already 'home'
// visually we need to do one step extra.
// If we don't we end up with a little gap on the top left
// corner when our stroke-linecap===butt
"z",
pClass, pColor, pBgColor
);
return gRenderMagic.createNote(pBBox, {class: pClass, color: pColor, bgColor: pBgColor});
},

@@ -423,15 +255,10 @@

createEdgeRemark: function (pBBox, pClass, pColor, pBgColor, pFoldSize) {
var lFoldSize = pFoldSize ? pFoldSize : 7;
return _createPath(
// start:
"M" + pBBox.x + "," + pBBox.y +
// top line:
" l" + pBBox.width + ",0 " +
// down:
" l0," + (pBBox.height - lFoldSize) +
// fold:
" l-" + lFoldSize.toString(10) + "," + lFoldSize.toString(10) +
// bottom line:
" l-" + (pBBox.width - lFoldSize) + ",0 ",
pClass, pColor, pBgColor
return gRenderMagic.createEdgeRemark(
pBBox,
{
class: pClass,
color: pColor,
bgColor: pBgColor,
foldSize: pFoldSize
}
);

@@ -468,3 +295,3 @@ },

"rotate(" +
math.getDiagonalAngle(pCanvas).toString() + " " +
geo.getDiagonalAngle(pCanvas).toString() + " " +
((pCanvas.width) / 2).toString() + " " +

@@ -486,5 +313,5 @@ ((pCanvas.height) / 2).toString() +

if (Boolean(pOptions) && Boolean(pOptions.doubleLine)) {
return createDoubleLine(pLine, pOptions);
return gRenderMagic.createDoubleLine(pLine, pOptions);
} else {
return createSingleLine(pLine, pOptions);
return gRenderMagic.createSingleLine(pLine, pOptions);
}

@@ -506,12 +333,12 @@ },

return _createPath(
return prim.createPath(
// point to start from:
pathPoint2String("M", pPoint.x, -pPoint.y) +
prim.pathPoint2String("M", pPoint.x, -pPoint.y) +
// curve first to:
pathPoint2String("C", pPoint.x + pWidth, pPoint.y - 7.5 * C.LINE_WIDTH) +
prim.pathPoint2String("C", pPoint.x + pWidth, pPoint.y - 7.5 * C.LINE_WIDTH) +
// curve back from.:
point2String(pPoint.x + pWidth, pEndY + 0) +
prim.point2String(pPoint.x + pWidth, pEndY + 0) +
// curve end-pont:
point2String(lEndX, pEndY),
pClass
prim.point2String(lEndX, pEndY),
{class: pClass}
);

@@ -569,3 +396,3 @@ },

factll.setAttributes(
_createPath(pD, "arrow-style"),
prim.createPath(pD, {class: "arrow-style"}),
{

@@ -590,3 +417,3 @@ style: "stroke-dasharray:100,1;stroke:" + pColor || "black"

factll.setAttributes(
_createPolygon(pPoints, "arrow-style"),
prim.createPolygon(pPoints, "arrow-style"),
{

@@ -593,0 +420,0 @@ "stroke": pColor || "black",

@@ -177,22 +177,22 @@ var geo = require("../../../render/graphics/geometry");

{
"controlX": 8.939339828220179,
"controlY": 1.0606601717798212,
"x": 7.878679656440358,
"y": 2.1213203435596424
"controlX": 8.939,
"controlY": 1.061,
"x": 7.879,
"y": 2.121
},
{
"controlX": 6.818019484660536,
"controlY": 3.181980515339464,
"x": 5.757359312880715,
"y": 4.242640687119285
"controlX": 6.818,
"controlY": 3.182,
"x": 5.757,
"y": 4.243
},
{
"controlX": 4.696699141100894,
"controlY": 5.303300858899106,
"x": 3.6360389693210724,
"y": 6.363961030678928
"controlX": 4.697,
"controlY": 5.303,
"x": 3.636,
"y": 6.364
},
{
"controlX": 2.5753787975412514,
"controlY": 7.424621202458749,
"controlX": 2.575,
"controlY": 7.425,
"x": 0,

@@ -199,0 +199,0 @@ "y": 10

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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