Merge branch 'sidv/esbuild' into sidv/esbuildFail

* sidv/esbuild:
  chore(deps): bump dompurify from 2.3.10 to 2.4.0 (#3444)
  chore(deps): bump stylis from 4.1.1 to 4.1.2 (#3439)
  chore(deps-dev): bump webpack-dev-server from 4.10.1 to 4.11.0 (#3450)
  Cleanup fixing som lingering issues
  Apply suggestions from code review
  chore: fix eslint warnings
  chore: Turn off eslint rules in spec, demos, etc.
This commit is contained in:
Sidharth Vinod
2022-09-15 23:01:24 +05:30
26 changed files with 39 additions and 144 deletions

View File

@@ -63,6 +63,13 @@
"rules": {
"no-console": "off"
}
},
{
"files": ["./**/*.spec.{ts,js}", "./cypress/**", "./demos/**", "./**/docs/**"],
"rules": {
"jsdoc/require-jsdoc": "off",
"@typescript-eslint/no-unused-vars": "off"
}
}
]
}

View File

@@ -69,14 +69,14 @@
"d3": "^7.0.0",
"dagre": "^0.8.5",
"dagre-d3": "^0.6.4",
"dompurify": "2.3.10",
"dompurify": "2.4.0",
"fast-clone": "^1.5.13",
"graphlib": "^2.1.8",
"khroma": "^2.0.0",
"lodash": "^4.17.21",
"moment-mini": "^2.24.0",
"non-layered-tidy-tree-layout": "^2.0.2",
"stylis": "^4.0.10"
"stylis": "^4.1.2"
},
"devDependencies": {
"@applitools/eyes-cypress": "^3.25.7",

View File

@@ -1,11 +1,9 @@
import { select } from 'd3';
import { log } from '../logger';
import { getConfig } from '../config';
import { sanitizeText, evaluate } from '../diagrams/common/common';
import { evaluate } from '../diagrams/common/common';
import { decodeEntities } from '../mermaidAPI';
const sanitizeTxt = (txt) => sanitizeText(txt, getConfig());
/**
* @param dom
* @param styleFn

View File

@@ -6,9 +6,7 @@ import intersect from './intersect/index.js';
import createLabel from './createLabel';
import note from './shapes/note';
import { parseMember } from '../diagrams/class/svgDraw';
import { evaluate, sanitizeText as sanitize } from '../diagrams/common/common';
const sanitizeText = (txt) => sanitize(txt, getConfig());
import { evaluate } from '../diagrams/common/common';
const question = (parent, node) => {
const { shapeSvg, bbox } = labelHelper(parent, node, undefined, true);
@@ -348,7 +346,7 @@ const rect = (parent, node) => {
};
const labelRect = (parent, node) => {
const { shapeSvg, bbox, halfPadding } = labelHelper(parent, node, 'label', true);
const { shapeSvg } = labelHelper(parent, node, 'label', true);
log.trace('Classes = ', node.classes);
// add the rect

View File

@@ -1,6 +1,5 @@
import mermaidAPI from '../../mermaidAPI';
import * as configApi from '../../config';
import { log } from '../../logger';
import { sanitizeText } from '../common/common';
import { setAccTitle, getAccTitle, getAccDescription, setAccDescription } from '../../commonDb';
@@ -21,7 +20,6 @@ let boundarys = [
let rels = [];
let title = '';
let wrapEnabled = false;
let description = '';
let c4ShapeInRow = 4;
let c4BoundaryInRow = 2;
var c4Type;
@@ -636,13 +634,13 @@ export const updateLayoutConfig = function (typeC4Shape, c4ShapeInRowParam, c4Bo
let c4BoundaryInRowValue = c4BoundaryInRow;
if (typeof c4ShapeInRowParam === 'object') {
let [key, value] = Object.entries(c4ShapeInRowParam)[0];
const value = Object.values(c4ShapeInRowParam)[0];
c4ShapeInRowValue = parseInt(value);
} else {
c4ShapeInRowValue = parseInt(c4ShapeInRowParam);
}
if (typeof c4BoundaryInRowParam === 'object') {
let [key, value] = Object.entries(c4BoundaryInRowParam)[0];
const value = Object.values(c4BoundaryInRowParam)[0];
c4BoundaryInRowValue = parseInt(value);
} else {
c4BoundaryInRowValue = parseInt(c4BoundaryInRowParam);
@@ -721,7 +719,6 @@ export const clear = function () {
boundaryParseStack = [''];
title = '';
wrapEnabled = false;
description = '';
c4ShapeInRow = 4;
c4BoundaryInRow = 2;
};

View File

@@ -298,7 +298,7 @@ export const drawC4ShapeArray = function (currentBounds, diagram, c4ShapeArray,
currentBounds.insert(c4Shape);
const height = svgDraw.drawC4Shape(diagram, c4Shape, conf);
svgDraw.drawC4Shape(diagram, c4Shape, conf);
}
currentBounds.bumpLastMargin(conf.c4ShapeMargin);
@@ -616,7 +616,6 @@ export const draw = function (_text, id, _version, diagObj) {
globalBoundaryMaxY = conf.diagramMarginY;
const title = diagObj.db.getTitle();
const c4type = diagObj.db.getC4Type();
let currentBoundarys = diagObj.db.getBoundarys('');
// switch (c4type) {
// case 'C4Context':

View File

@@ -1,5 +1,4 @@
import common from '../common/common';
import { addFunction } from '../../interactionDb';
import { sanitizeUrl } from '@braintree/sanitize-url';
export const drawRect = function (elem, rectData) {

View File

@@ -3,7 +3,6 @@ import graphlib from 'graphlib';
import { log } from '../../logger';
import { getConfig } from '../../config';
import { render } from '../../dagre-wrapper/index.js';
// import addHtmlLabel from 'dagre-d3/lib/label/add-html-label.js';
import { curveLinear } from 'd3';
import { interpolateToCurve, getStylesFromArray } from '../../utils';
import { setupGraphViewbox } from '../../setupGraphViewbox';
@@ -11,7 +10,6 @@ import common from '../common/common';
import addSVGAccessibilityFields from '../../accessibility';
let idCache = {};
const padding = 20;
const sanitizeText = (txt) => common.sanitizeText(txt, getConfig());
@@ -235,20 +233,6 @@ export const addRelations = function (relations, g) {
});
};
/**
* Gets the ID with the same label as in the cache
*
* @param {string} label The label to look for
* @returns {string} The resulting ID
*/
const getGraphId = function (label) {
const foundEntry = Object.entries(idCache).find((entry) => entry[1].label === label);
if (foundEntry) {
return foundEntry[0];
}
};
/**
* Merges the value of `conf` with the passed `cnf`
*

View File

@@ -10,12 +10,6 @@ import addSVGAccessibilityFields from '../../accessibility';
let idCache = {};
const padding = 20;
const confa = {
dividerMargin: 10,
padding: 5,
textHeight: 10,
};
/**
* Gets the ID with the same label as in the cache
*
@@ -163,7 +157,6 @@ export const draw = function (text, id, _version, diagObj) {
securityLevel === 'sandbox'
? select(sandboxElement.nodes()[0].contentDocument.body)
: select('body');
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;
// Fetch the default direction, use TD if none was found
const diagram = root.select(`[id='${id}']`);

View File

@@ -1,7 +1,7 @@
import { log } from '../../logger';
import mermaidAPI from '../../mermaidAPI';
import * as configApi from '../../config';
import common from '../common/common';
import {
setAccTitle,
getAccTitle,
@@ -12,8 +12,6 @@ import {
let entities = {};
let relationships = [];
let title = '';
let description = '';
const Cardinality = {
ZERO_OR_ONE: 'ZERO_OR_ONE',
@@ -78,7 +76,6 @@ const getRelationships = () => relationships;
const clear = function () {
entities = {};
relationships = [];
title = '';
commonClear();
};

View File

@@ -29,8 +29,6 @@ export const setConf = function (cnf) {
* @param diagObj
*/
export const addVertices = function (vert, g, svgId, root, _doc, diagObj) {
const securityLevel = getConfig().securityLevel;
const svg = !root ? select(`[id="${svgId}"]`) : root.select(`[id="${svgId}"]`);
const doc = !_doc ? document : _doc;
const keys = Object.keys(vert);

View File

@@ -4,7 +4,7 @@ import { log } from '../../logger';
import * as configApi from '../../config';
import utils from '../../utils';
import mermaidAPI from '../../mermaidAPI';
import common from '../common/common';
import {
setAccTitle,
getAccTitle,
@@ -21,8 +21,6 @@ let todayMarker = '';
let includes = [];
let excludes = [];
let links = {};
let title = '';
let accDescription = '';
let sections = [];
let tasks = [];
let currentSection = '';
@@ -34,10 +32,6 @@ let topAxis = false;
// The serial order of the task in the script
let lastOrder = 0;
const sanitizeText = function (txt) {
return common.sanitizeText(txt, configApi.getConfig());
};
export const parseDirective = function (statement, context, type) {
mermaidAPI.parseDirective(this, statement, context, type);
};
@@ -47,7 +41,6 @@ export const clear = function () {
tasks = [];
currentSection = '';
funs = [];
title = '';
taskCnt = 0;
lastTask = undefined;
lastTaskID = undefined;
@@ -247,7 +240,8 @@ const getStartDate = function (prevTime, dateFormat, str) {
* - `ms` for milliseconds
*
* @param {string} str - A string representing the duration.
* @returns {moment.Duration} A moment duration, including an invalid moment for invalid input string.
* @returns {moment.Duration} A moment duration, including an invalid moment for invalid input
* string.
*/
const parseDuration = function (str) {
const statement = /^(\d+(?:\.\d+)?)([yMwdhms]|ms)$/.exec(str.trim());

View File

@@ -391,7 +391,6 @@ export const draw = function (text, id, version, diagObj) {
if (securityLevel === 'sandbox') {
let sandboxElement;
sandboxElement = select('#i' + id);
const root = select(sandboxElement.nodes()[0].contentDocument.body);
const doc = sandboxElement.nodes()[0].contentDocument;
rectangles

View File

@@ -5,7 +5,6 @@ import { getConfig } from '../../config';
import addSVGAccessibilityFields from '../../accessibility';
let allCommitsDict = {};
let branchNum;
const commitType = {
NORMAL: 0,
@@ -83,7 +82,7 @@ const drawCommits = (svg, commits, modifyGraph) => {
const sortedKeys = keys.sort((a, b) => {
return commits[a].seq - commits[b].seq;
});
sortedKeys.forEach((key, index) => {
sortedKeys.forEach((key) => {
const commit = commits[key];
const y = branchPos[commit.branch].pos;
@@ -292,18 +291,15 @@ const drawCommits = (svg, commits, modifyGraph) => {
};
/**
* Detect if there are other commits between commit1's x-position and commit2's x-position on the same
* branch as commit2.
* Detect if there are other commits between commit1's x-position and commit2's x-position on the
* same branch as commit2.
*
* @param {any} commit1
* @param {any} commit2
* @param allCommits
* @returns {boolean} if there are commits between commit1's x-position and commit2's x-position
* @returns {boolean} If there are commits between commit1's x-position and commit2's x-position
*/
const hasOverlappingCommits = (commit1, commit2, allCommits) => {
const commit1Pos = commitPos[commit2.id];
const commit2Pos = commitPos[commit1.id];
// Find commits on the same branch as commit2
const keys = Object.keys(allCommits);
const overlappingComits = keys.filter((key) => {
@@ -324,7 +320,7 @@ const hasOverlappingCommits = (commit1, commit2, allCommits) => {
* @param {any} y1
* @param {any} y2
* @param {any} _depth
* @returns {number} y value between y1 and y2
* @returns {number} Y value between y1 and y2
*/
const findLane = (y1, y2, _depth) => {
const depth = _depth || 0;
@@ -357,25 +353,11 @@ const findLane = (y1, y2, _depth) => {
* @param {any} allCommits
*/
const drawArrow = (svg, commit1, commit2, allCommits) => {
const conf = getConfig();
const p1 = commitPos[commit1.id];
const p2 = commitPos[commit2.id];
const overlappingCommits = hasOverlappingCommits(commit1, commit2, allCommits);
// log.debug('drawArrow', p1, p2, overlappingCommits, commit1.id, commit2.id);
let url = '';
if (conf.arrowMarkerAbsolute) {
url =
window.location.protocol +
'//' +
window.location.host +
window.location.pathname +
window.location.search;
url = url.replace(/\(/g, '\\(');
url = url.replace(/\)/g, '\\)');
}
let arc = '';
let arc2 = '';
let radius = 0;
@@ -433,7 +415,7 @@ const drawArrow = (svg, commit1, commit2, allCommits) => {
} ${p2.y}`;
}
}
const arrow = svg
svg
.append('path')
.attr('d', lineDef)
.attr('class', 'arrow arrow' + (colorClassNum % THEME_COLOR_LIMIT));
@@ -441,10 +423,7 @@ const drawArrow = (svg, commit1, commit2, allCommits) => {
const drawArrows = (svg, commits) => {
const gArrows = svg.append('g').attr('class', 'commit-arrows');
let pos = 0;
const k = Object.keys(commits);
k.forEach((key, index) => {
Object.keys(commits).forEach((key) => {
const commit = commits[key];
if (commit.parents && commit.parents.length > 0) {
commit.parents.forEach((parent) => {

View File

@@ -27,7 +27,6 @@ export const draw = (text, id, version, diagObj) => {
securityLevel === 'sandbox'
? select(sandboxElement.nodes()[0].contentDocument.body)
: select('body');
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;
// Parse the graph definition
// parser.parse(text);

View File

@@ -2,7 +2,7 @@
import { select } from 'd3';
import { log, getConfig, setupGraphViewbox } from '../../diagram-api/diagramAPI';
import svgDraw from './svgDraw';
import { BoundingBox, Layout, Tree } from 'non-layered-tidy-tree-layout';
import { BoundingBox, Layout } from 'non-layered-tidy-tree-layout';
import clone from 'fast-clone';
import * as db from './mindmapDb';
@@ -192,8 +192,7 @@ function layoutMindmap(node, conf) {
});
// Merge the trees into a single tree
const result = mergeTrees(node, trees);
eachNode;
mergeTrees(node, trees);
return node;
}
/**
@@ -232,13 +231,11 @@ export const draw = (text, id, version, diagObj) => {
securityLevel === 'sandbox'
? select(sandboxElement.nodes()[0].contentDocument.body)
: select('body');
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;
// Parse the graph definition
const svg = root.select('#' + id);
const g = svg.append('g');
svg.append('g');
const mm = diagObj.db.getMindmap();
// Draw the graph and start with drawing the nodes without proper position

View File

@@ -1,4 +1,4 @@
import { darken, lighten, adjust, invert, isDark } from 'khroma';
import { darken, lighten, isDark } from 'khroma';
const genSections = (options) => {
let sections = '';

View File

@@ -13,8 +13,6 @@ import {
} from '../../commonDb';
let sections = {};
let title = '';
let description = '';
let showData = false;
export const parseDirective = function (statement, context, type) {
@@ -49,7 +47,6 @@ const cleanupValue = function (value) {
const clear = function () {
sections = {};
title = '';
showData = false;
commonClear();
};

View File

@@ -1,7 +1,7 @@
import * as configApi from '../../config';
import { log } from '../../logger';
import mermaidAPI from '../../mermaidAPI';
import common from '../common/common';
import {
setAccTitle,
getAccTitle,
@@ -15,10 +15,6 @@ let latestRequirement = {};
let requirements = {};
let latestElement = {};
let elements = {};
let title = '';
let accDescription = '';
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
const RequirementType = {
REQUIREMENT: 'Requirement',

View File

@@ -320,7 +320,6 @@ export const draw = (text, id, _version, diagObj) => {
securityLevel === 'sandbox'
? select(sandboxElement.nodes()[0].contentDocument.body)
: select('body');
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;
const svg = root.select(`[id='${id}']`);
markers.insertLineEndings(svg, conf);

View File

@@ -16,8 +16,6 @@ let prevActor = undefined;
let actors = {};
let messages = [];
const notes = [];
let diagramTitle = '';
let description = '';
let sequenceNumbersEnabled = false;
let wrapEnabled;
@@ -153,7 +151,6 @@ export const clear = function () {
actors = {};
messages = [];
sequenceNumbersEnabled = false;
diagramTitle = '';
commonClear();
};

View File

@@ -11,8 +11,6 @@ import {
clear as commonClear,
} from '../../commonDb';
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
const clone = (o) => JSON.parse(JSON.stringify(o));
let rootDoc = [];
@@ -121,10 +119,6 @@ let documents = {
let currentDocument = documents.root;
let startCnt = 0;
let endCnt = 0; // let stateCnt = 0;
let title = 'State diagram';
let description = '';
/**
* Function called by parser when a node definition has been found.
@@ -179,7 +173,6 @@ export const clear = function (saveCommon) {
currentDocument = documents.root;
startCnt = 0;
endCnt = 0;
classes = [];
if (!saveCommon) {
commonClear();
@@ -211,7 +204,6 @@ export const addRelation = function (_id1, _id2, title) {
type1 = 'start';
}
if (_id2 === '[*]') {
endCnt++;
id2 = 'end' + startCnt;
type2 = 'end';
}

View File

@@ -283,7 +283,6 @@ export const draw = function (text, id, _version, diag) {
securityLevel === 'sandbox'
? select(sandboxElement.nodes()[0].contentDocument.body)
: select('body');
const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;
const svg = root.select(`[id="${id}"]`);
// Run the renderer. This is what draws the final graph.

View File

@@ -1,6 +1,5 @@
import mermaidAPI from '../../mermaidAPI';
import * as configApi from '../../config';
import common from '../common/common';
import {
setAccTitle,
getAccTitle,
@@ -11,10 +10,6 @@ import {
clear as commonClear,
} from '../../commonDb';
const sanitizeText = (txt) => common.sanitizeText(txt, configApi.getConfig());
let title = '';
let description = '';
let currentSection = '';
const sections = [];
@@ -29,8 +24,6 @@ export const clear = function () {
sections.length = 0;
tasks.length = 0;
currentSection = '';
title = '';
description = '';
rawTasks.length = 0;
commonClear();
};

View File

@@ -40,7 +40,6 @@ const directive =
/[%]{2}[{]\s*(?:(?:(\w+)\s*:|(\w+))\s*(?:(?:(\w+))|((?:(?![}][%]{2}).|\r?\n)*))?\s*)(?:[}][%]{2})?/gi;
const directiveWithoutOpen =
/\s*(?:(?:(\w+)(?=:):|(\w+))\s*(?:(?:(\w+))|((?:(?![}][%]{2}).|\r?\n)*))?\s*)(?:[}][%]{2})?/gi;
const anyComment = /\s*%%.*\n/gm;
/**
* @function detectInit Detects the init config object from the text
@@ -308,7 +307,6 @@ const calcLabelPosition = (points) => {
const calcCardinalityPosition = (isRelationTypePresent, points, initialPosition) => {
let prevPoint;
let totalDistance = 0;
log.info('our points', points);
if (points[0] !== initialPosition) {
points = points.reverse();
@@ -368,7 +366,6 @@ const calcTerminalLabelPosition = (terminalMarkerSize, position, _points) => {
// Todo looking to faster cloning method
let points = JSON.parse(JSON.stringify(_points));
let prevPoint;
let totalDistance = 0;
log.info('our points', points);
if (position !== 'start_left' && position !== 'start_right') {
points = points.reverse();
@@ -707,19 +704,6 @@ export const calculateTextDimensions = memoize(
(text, config) => `${text}${config.fontSize}${config.fontWeight}${config.fontFamily}`
);
/**
* Applys d3 attributes
*
* @param {any} d3Elem D3 Element to apply the attributes onto
* @param {[string, string][]} attrs Object.keys equivalent format of key to value mapping of
* attributes
*/
const d3Attrs = function (d3Elem, attrs) {
for (const attr of attrs) {
d3Elem.attr(attr[0], attr[1]);
}
};
export const initIdGenerator = class iterator {
constructor(deterministic, seed) {
this.deterministic = deterministic;

View File

@@ -4955,10 +4955,10 @@ domhandler@^5.0.1, domhandler@^5.0.2:
dependencies:
domelementtype "^2.3.0"
dompurify@2.3.10:
version "2.3.10"
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.3.10.tgz#901f7390ffe16a91a5a556b94043314cd4850385"
integrity sha512-o7Fg/AgC7p/XpKjf/+RC3Ok6k4St5F7Q6q6+Nnm3p2zGWioAY6dh0CbbuwOhH2UcSzKsdniE/YnE2/92JcsA+g==
dompurify@2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/dompurify/-/dompurify-2.4.0.tgz#c9c88390f024c2823332615c9e20a453cf3825dd"
integrity sha512-Be9tbQMZds4a3C6xTmz68NlMfeONA//4dOavl/1rNw50E+/QO0KVpbcU0PcaW0nsQxurXls9ZocqFxk8R2mWEA==
domutils@^3.0.1:
version "3.0.1"
@@ -10789,10 +10789,10 @@ strip-json-comments@^3.1.0, strip-json-comments@^3.1.1:
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
stylis@^4.0.10:
version "4.1.1"
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.1.tgz#e46c6a9bbf7c58db1e65bb730be157311ae1fe12"
integrity sha512-lVrM/bNdhVX2OgBFNa2YJ9Lxj7kPzylieHd3TNjuGE0Re9JB7joL5VUKOVH1kdNNJTgGPpT8hmwIAPLaSyEVFQ==
stylis@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.2.tgz#870b3c1c2275f51b702bb3da9e94eedad87bba41"
integrity sha512-Nn2CCrG2ZaFziDxaZPN43CXqn+j7tcdjPFCkRBkFue8QYXC2HdEwnw5TCBo4yQZ2WxKYeSi0fdoOrtEqgDrXbA==
subarg@^1.0.0:
version "1.0.0"