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 2.0.0-beta-5 to 2.0.0-beta-6

src/main/allowedvalues.js

2

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

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -66,3 +66,3 @@ # mscgen_js - core package

// node_modules.
define(['./node_modules/mscgenjs/index'], function(mscgenjs){
define(['./node_modules/mscgenjs/src/index'], function(mscgenjs){
// your code here

@@ -69,0 +69,0 @@ });

@@ -8,4 +8,5 @@ /* istanbul ignore else */

var _ = require("../lib/lodash/lodash.custom");
var cssTemplates = require("../render/graphics/csstemplates");
var _ = require("../lib/lodash/lodash.custom");
var allowedValues = require("./allowedvalues");
var normalizeOptions = require("./normalizeoptions");

@@ -37,13 +38,3 @@ function isProbablyAnASTAlready(pScript, pInputType){

renderMsc: function (pScript, pOptions, pCallBack, pGetParser, pGetGraphicsRenderer){
var lOptions = pOptions || {};
_.defaults(lOptions, {
inputType : "mscgen",
elementId : "__svg",
window : pOptions.window || window,
includeSource : true,
styleAdditions : null,
additionalTemplate : null,
mirrorEntitiesOnBottom : false,
regularArcTextVerticalAlignment: "middle"
});
var lOptions = normalizeOptions(pOptions, pScript);

@@ -54,3 +45,3 @@ try {

null,
pGetGraphicsRenderer().renderASTNew(
pGetGraphicsRenderer().render(
getAST(pScript, lOptions.inputType, pGetParser),

@@ -60,3 +51,3 @@ lOptions.window,

{
source: lOptions.includeSource ? pScript : null,
source: lOptions.source,
styleAdditions: lOptions.styleAdditions,

@@ -96,38 +87,6 @@ additionalTemplate: lOptions.additionalTemplate,

version: "2.0.0-beta-5",
version: "2.0.0-beta-6",
getAllowedValues: function() {
return Object.freeze({
inputType: [
{name: "mscgen", experimental: false},
{name: "msgenny", experimental: false},
{name: "xu", experimental: false},
{name: "json", experimental: false},
{name: "ast", experimental: false}
],
outputType: [
{name: "mscgen", experimental: false},
{name: "msgenny", experimental: false},
{name: "xu", experimental: false},
{name: "json", experimental: false},
{name: "ast", experimental: false},
{name: "dot", experimental: false},
{name: "doxygen", experimental: false}
],
regularArcTextVerticalAlignment: [
{name: "above", experimental: true},
{name: "middle", experimental: false},
{name: "below", experimental: true}
],
namedStyle: cssTemplates.namedStyles.map(
function(pStyle){
return {
name : pStyle.name,
description : pStyle.description,
experimental : pStyle.experimental,
deprecated : pStyle.deprecated
};
}
)
});
return allowedValues;
}

@@ -134,0 +93,0 @@ };

@@ -12,4 +12,2 @@ /* istanbul ignore else */

*
* @exports node/arcmappings
* @author {@link https://github.com/sverweij | Sander Verweij}
*/

@@ -63,5 +61,4 @@

return {
// all of em: graphics, massage, text (dot, doxygen, mscgen)
getAggregate : function(pKey) { return KIND2AGGREGATE[pKey]; }
return function(pKey) {
return KIND2AGGREGATE[pKey];
};

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

@@ -12,7 +12,2 @@ /*

define(function() {
/**
*
* @exports node/asttransform
* @author {@link https://github.com/sverweij | Sander Verweij}
*/
"use strict";

@@ -55,22 +50,20 @@

return {
/**
* Generic function for performing manipulations on abstract syntax trees. It takes a
* series of functions as arguments and applies them to the entities, arcs and arc
* rows in the syntax tree respectively.
*
* @param {ast} pAST - the syntax tree to transform
* @param {Array} pEntityTransforms - an array of functions. Each function shall take
* an entity as input an return the modified entity
* @param {Array} pArcTransforms - an array of functions. Each function shall take
* and arc and entities as input and return the modified arc
* @param {Array} pArcRowTransforms - an array of functions. Each function shall take
* an arc row and entities as input return the modified arc row
* @return {ast} - the modified syntax tree
*/
transform : function (pAST, pEnityTransforms, pArcTransforms) {
transformEntities(pAST.entities, pEnityTransforms);
transformArcRows(pAST.entities, pAST.arcs, pArcTransforms);
return pAST;
}
/**
* Generic function for performing manipulations on abstract syntax trees. It takes a
* series of functions as arguments and applies them to the entities, arcs and arc
* rows in the syntax tree respectively.
*
* @param {ast} pAST - the syntax tree to transform
* @param {Array} pEntityTransforms - an array of functions. Each function shall take
* an entity as input an return the modified entity
* @param {Array} pArcTransforms - an array of functions. Each function shall take
* and arc and entities as input and return the modified arc
* @param {Array} pArcRowTransforms - an array of functions. Each function shall take
* an arc row and entities as input return the modified arc row
* @return {ast} - the modified syntax tree
*/
return function (pAST, pEnityTransforms, pArcTransforms) {
transformEntities(pAST.entities, pEnityTransforms);
transformArcRows(pAST.entities, pAST.arcs, pArcTransforms);
return pAST;
};

@@ -77,0 +70,0 @@ });

@@ -206,3 +206,3 @@ /* Automatically adds colors to an AST:

} else {
return pColorScheme.aggregateArcColors[aggregatekind.getAggregate(pKind)];
return pColorScheme.aggregateArcColors[aggregatekind(pKind)];
}

@@ -263,3 +263,3 @@ }

return asttransform.transform(
return asttransform(
pForce ? _uncolor(pAST) : pAST,

@@ -282,3 +282,3 @@ [colorizeEntity(pColorScheme)],

function _uncolor(pAST) {
return asttransform.transform(pAST, [uncolorThing], [uncolorThing]);
return asttransform(pAST, [uncolorThing], [uncolorThing]);
}

@@ -285,0 +285,0 @@

@@ -45,4 +45,4 @@ /* istanbul ignore else */

function _swapRTLArc(pArc) {
if (pArc.kind && (normalizekind.getNormalizedKind(pArc.kind) !== pArc.kind)) {
pArc.kind = normalizekind.getNormalizedKind(pArc.kind);
if (pArc.kind && (normalizekind(pArc.kind) !== pArc.kind)) {
pArc.kind = normalizekind(pArc.kind);

@@ -95,3 +95,3 @@ var lTmp = pArc.from;

function(pArc){
if ("inline_expression" === aggregatekind.getAggregate(pArc.kind)) {
if ("inline_expression" === aggregatekind(pArc.kind)) {
pArc.depth = pDepth;

@@ -133,3 +133,3 @@ pArc.isVirtual = true;

} else {
if ((pFrom && pTo) && ("emptyarc" === aggregatekind.getAggregate(pArc.kind))) {
if ((pFrom && pTo) && ("emptyarc" === aggregatekind(pArc.kind))) {
pArc.from = pFrom;

@@ -255,3 +255,3 @@ pArc.to = pTo;

pAST.options = normalizeoptions(pAST.options);
return asttransform.transform(
return asttransform(
_unwind(pAST),

@@ -270,3 +270,3 @@ [nameAsLabel, unescapeLabels],

return _explodeBroadcasts(
asttransform.transform(
asttransform(
pAST,

@@ -273,0 +273,0 @@ [nameAsLabel],

@@ -25,5 +25,4 @@ /* istanbul ignore else */

return {
// graphics and flatten
getNormalizedKind : function(pKey) { return KIND2NORMALIZEDKIND[pKey] || pKey; }
return function(pKey) {
return KIND2NORMALIZEDKIND[pKey] || pKey;
};

@@ -30,0 +29,0 @@ });

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

function makeKindColorCombi (pKind, pColor) {
return KINDS[normalizekind.getNormalizedKind(pKind)].marker.name +
return KINDS[normalizekind(pKind)].marker.name +
(Boolean(pColor) ? " " + pColor : " black");

@@ -230,4 +230,4 @@ }

}
if (!!pArc.kind && !!KINDS[normalizekind.getNormalizedKind(pArc.kind)] &&
!!(KINDS[normalizekind.getNormalizedKind(pArc.kind)].marker) &&
if (!!pArc.kind && !!KINDS[normalizekind(pArc.kind)] &&
!!(KINDS[normalizekind(pArc.kind)].marker) &&
pKindColorCombis.indexOf(makeKindColorCombi(pArc.kind, pArc.linecolor)) < 0){

@@ -234,0 +234,0 @@ pKindColorCombis.push(makeKindColorCombi(pArc.kind, pArc.linecolor));

@@ -61,50 +61,27 @@ /* istanbul ignore else */

function renderAST(pAST, pWindow, pParentElementId, pOptions) {
var lAST = Object.freeze(flatten.flatten(pAST));
var lOptions = pOptions || {};
function getParentElement(pWindow, pParentElementId) {
return pWindow.document.getElementById(pParentElementId) || pWindow.document.body;
}
lOptions = _.defaults(lOptions, {
source : null,
styleAdditions : null,
mirrorEntitiesOnBottom : false,
regularArcTextVerticalAlignment: "middle"
});
function render(pAST, pWindow, pParentElementId, pOptions) {
var lFlattenedAST = Object.freeze(flatten.flatten(pAST));
var lParentElement = getParentElement(pWindow, pParentElementId);
idmanager.setPrefix(pParentElementId);
renderASTPre(
lAST,
lFlattenedAST,
pWindow,
pParentElementId,
lOptions
lParentElement,
pOptions || {}
);
renderASTMain(lAST);
renderASTPost(lAST);
var lElement = pWindow.document.getElementById(pParentElementId);
if (lElement) {
return svgutensils.webkitNamespaceBugWorkaround(lElement.innerHTML);
} else {
return svgutensils.webkitNamespaceBugWorkaround(pWindow.document.body.innerHTML);
}
}
renderASTMain(lFlattenedAST);
renderASTPost(lFlattenedAST);
function normalizeVerticalAlignment(pVerticalAlignment) {
var lRetval = "middle";
var VALID_ALIGNMENT_VALUES = ["above", "middle", "below"];
if (VALID_ALIGNMENT_VALUES.some(
function(pValue){
return pValue === pVerticalAlignment;
}
)){
lRetval = pVerticalAlignment;
}
return lRetval;
return svgutensils.webkitNamespaceBugWorkaround(lParentElement.innerHTML);
}
function renderASTPre(pAST, pWindow, pParentElementId, pOptions){
idmanager.setPrefix(pParentElementId);
function renderASTPre(pAST, pWindow, pParentElement, pOptions){
gChart.document = renderskeleton.bootstrap(
pWindow,
pParentElementId,
pParentElement,
idmanager.get(),

@@ -114,4 +91,4 @@ markermanager.getMarkerDefs(idmanager.get(), pAST),

);
gChart.mirrorEntitiesOnBottom = Boolean(pOptions.mirrorEntitiesOnBottom);
gChart.regularArcTextVerticalAlignment = normalizeVerticalAlignment(pOptions.regularArcTextVerticalAlignment);
gChart.mirrorEntitiesOnBottom = pOptions.mirrorEntitiesOnBottom;
gChart.regularArcTextVerticalAlignment = pOptions.regularArcTextVerticalAlignment;
svgutensils.init(gChart.document);

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

switch (aggregatekind.getAggregate(pArc.kind)) {
switch (aggregatekind(pArc.kind)) {
case ("emptyarc"):

@@ -431,3 +408,3 @@ lElement = renderEmptyArc(pArc, 0);

switch (aggregatekind.getAggregate(pArc.kind)) {
switch (aggregatekind(pArc.kind)) {
case ("emptyarc"):

@@ -1061,3 +1038,3 @@ lElement = renderEmptyArc(pArc, rowmemory.get(pRowNumber).y);

*/
renderASTNew : renderAST
render : render
};

@@ -1064,0 +1041,0 @@ });

@@ -185,8 +185,8 @@ /* istanbul ignore else */

function _splitLabel(pLabel, pKind, pWidth, pFontSize, pOptions) {
if (("box" === aggregatekind.getAggregate(pKind) && pOptions.wordwrapboxes) ||
if (("box" === aggregatekind(pKind) && pOptions.wordwrapboxes) ||
("entity" === pKind && pOptions.wordwrapentities) ||
("box" !== aggregatekind.getAggregate(pKind) && "entity" !== pKind && pOptions.wordwraparcs) ||
("box" !== aggregatekind(pKind) && "entity" !== pKind && pOptions.wordwraparcs) ||
typeof pKind === 'undefined'
){
return wrap.wrap(pLabel, _determineMaxTextWidthInChars(pWidth, pFontSize));
return wrap(pLabel, _determineMaxTextWidthInChars(pWidth, pFontSize));
} else {

@@ -193,0 +193,0 @@ return pLabel.split('\\n');

@@ -90,10 +90,6 @@ /* istanbul ignore else */

function _bootstrap(pWindow, pParentElementId, pSvgElementId, pMarkerDefs, pOptions) {
function _bootstrap(pWindow, pParentElement, pSvgElementId, pMarkerDefs, pOptions) {
gDocument = _init(pWindow);
var lParent = gDocument.getElementById(pParentElementId);
if (lParent === null) {
lParent = gDocument.body;
}
var lSkeletonSvg = svgelementfactory.createSVG(pSvgElementId, pSvgElementId, distillRenderMagic(pOptions));

@@ -105,3 +101,3 @@ if (Boolean(pOptions.source)) {

lSkeletonSvg.appendChild(setupBody(pSvgElementId));
lParent.appendChild(lSkeletonSvg);
pParentElement.appendChild(lSkeletonSvg);

@@ -194,6 +190,6 @@ return gDocument;

* Sets up a skeleton svg document with id pSvgElementId in the dom element
* with id pParentElementId, both in window pWindow. See the module
* pParentElement, both in window pWindow. See the module
* documentation for details on the structure of the skeleton.
*
* @param {string} pParentElementId
* @param {string} pParentElement
* @param {string} pSvgElementId

@@ -200,0 +196,0 @@ * @param {object} pMarkerDefs

@@ -8,7 +8,7 @@ /* istanbul ignore else */

var domprimitives = require("./domprimitives");
var geometry = require("./geometry");
var _ = require("../../../lib/lodash/lodash.custom");
var round = require("./round");
var PRECISION = 2;
var domprimitives = require("./domprimitives");
var getDiagonalAngle = require("./getdiagonalangle");
var _ = require("../../../lib/lodash/lodash.custom");
var round = require("./round");
var PRECISION = 2;

@@ -250,3 +250,3 @@ function point2String(pX, pY) {

"rotate(" +
round(geometry.getDiagonalAngle(pCanvas), PRECISION).toString() + " " +
round(getDiagonalAngle(pCanvas), PRECISION).toString() + " " +
round((pCanvas.width) / 2, PRECISION).toString() + " " +

@@ -253,0 +253,0 @@ round((pCanvas.height) / 2, PRECISION).toString() +

@@ -56,3 +56,3 @@ /*

function renderString(pString) {
var lStringAry = wrap.wrap(pString.replace(/"/g, "\\\""), MAX_TEXT_WIDTH);
var lStringAry = wrap(pString.replace(/"/g, "\\\""), MAX_TEXT_WIDTH);
var lString = lStringAry.slice(0, -1).reduce(function(pPrev, pLine){

@@ -172,3 +172,3 @@ return pPrev + pLine + "\n";

var lRetVal = "";
var lAggregatedKind = aggregatekind.getAggregate(pArc.kind);
var lAggregatedKind = aggregatekind(pArc.kind);

@@ -175,0 +175,0 @@ if (lAggregatedKind === "box") {

@@ -26,3 +26,3 @@ /*

function renderKind(pKind) {
if ("inline_expression" === aggregatekind.getAggregate(pKind)) {
if ("inline_expression" === aggregatekind(pKind)) {
return "--";

@@ -29,0 +29,0 @@ }

@@ -35,3 +35,3 @@ /*

function renderKind(pKind) {
if ("inline_expression" === aggregatekind.getAggregate(pKind)) {
if ("inline_expression" === aggregatekind(pKind)) {
return "--";

@@ -38,0 +38,0 @@ }

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

return {
/**

@@ -26,37 +25,36 @@ * Wraps text on the first space found before pMaxlength,

*/
wrap : function (pText, pMaxLength) {
var lCharCount = 0;
var lRetval = [];
var lStart = 0;
var lNewStart = 0;
var lEnd = 0;
return function (pText, pMaxLength) {
var lCharCount = 0;
var lRetval = [];
var lStart = 0;
var lNewStart = 0;
var lEnd = 0;
var i = 0;
var lText = pText.replace(/[\t\n]+/g, " ").replace(/\\n/g, "\n");
var i = 0;
var lText = pText.replace(/[\t\n]+/g, " ").replace(/\\n/g, "\n");
while (i <= lText.length) {
if (i >= (lText.length)) {
lRetval.push(lText.substring(lStart, i));
} else if (lText[i] === '\n') {
while (i <= lText.length) {
if (i >= (lText.length)) {
lRetval.push(lText.substring(lStart, i));
} else if (lText[i] === '\n') {
lCharCount = 0;
lEnd = i;
lRetval.push(lText.substring(lStart, lEnd));
lStart = lEnd + 1;
} else if ((lCharCount++ >= pMaxLength)) {
lEnd = lText.substring(0, i).lastIndexOf(' ');
if (lEnd === -1 || lEnd < lStart) {
lCharCount = 1;
lEnd = i;
lNewStart = i;
} else {
lCharCount = 0;
lEnd = i;
lRetval.push(lText.substring(lStart, lEnd));
lStart = lEnd + 1;
} else if ((lCharCount++ >= pMaxLength)) {
lEnd = lText.substring(0, i).lastIndexOf(' ');
if (lEnd === -1 || lEnd < lStart) {
lCharCount = 1;
lEnd = i;
lNewStart = i;
} else {
lCharCount = 0;
lNewStart = lEnd + 1;
}
lRetval.push(lText.substring(lStart, lEnd));
lStart = lNewStart;
lNewStart = lEnd + 1;
}
i++;
lRetval.push(lText.substring(lStart, lEnd));
lStart = lNewStart;
}
return lRetval;
i++;
}
return lRetval;
};

@@ -63,0 +61,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