MC-1730 Lint fixes

This commit is contained in:
Knut Sveidqvist
2024-07-19 14:29:52 +02:00
parent cc0dcd68f8
commit e6722bc7f6
8 changed files with 8948 additions and 12219 deletions

View File

@@ -1,21 +1,5 @@
import { layout as dagreLayout } from 'dagre-d3-es/src/dagre/index.js';
import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js';
import * as graphlib from 'dagre-d3-es/src/graphlib/index.js';
import insertMarkers from '../../rendering-elements/markers.js';
import { updateNodeBounds } from '../../rendering-elements/shapes/util.js';
// import {
// clear as clearGraphlib,
// clusterDb,
// adjustClustersAndEdges,
// findNonClusterChild,
// sortNodesByHierarchy,
// } from './mermaid-graphlib.js';
import {
insertNode,
positionNode,
clear as clearNodes,
setNodeElem,
} from '../../rendering-elements/nodes.js';
import { insertNode, positionNode, clear as clearNodes } from '../../rendering-elements/nodes.js';
import {
insertCluster,
clear as clearClusters,
@@ -27,13 +11,9 @@ import {
insertEdge,
clear as clearEdges,
} from '../../rendering-elements/edges.js';
import { log } from '$root/logger.js';
import { getSubGraphTitleMargins } from '../../../utils/subGraphTitleMargins.js';
import { getConfig } from '../../../diagram-api/diagramAPI.js';
const fixInterSections = (points, startNode, endNode) => {
console.log('Fixing intersections - ', points, startNode, endNode);
// Get the intersections
const startIntersection = startNode.intersect(points[1]);
const endIntersection = endNode.intersect(points[points.length - 2]);
@@ -46,14 +26,14 @@ const fixInterSections = (points, startNode, endNode) => {
const doRender = async (_elem, data4Layout, siteConfig, positions) => {
const elem = _elem.insert('g').attr('class', 'root');
const clusters = elem.insert('g').attr('class', 'clusters');
elem.insert('g').attr('class', 'clusters');
const edgePaths = elem.insert('g').attr('class', 'edgePaths');
const edgeLabels = elem.insert('g').attr('class', 'edgeLabels');
const nodes = elem.insert('g').attr('class', 'nodes');
// Insert nodes, this will insert them into the dom and each node will get a size. The size is updated
// to the abstract node and is later used by dagre for the layout
let freePos = 0;
const nodeDB = {};
await Promise.all(
data4Layout.nodes.map(async function (node) {
@@ -83,30 +63,31 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
})
);
data4Layout.edges.forEach(function (edge) {
edge.x = edge?.x || 0;
edge.y = edge?.y || 0;
insertEdgeLabel(edgeLabels, edge);
});
await Promise.all(
data4Layout.edges.forEach(async function (edge) {
edge.x = edge?.x || 0;
edge.y = edge?.y || 0;
await insertEdgeLabel(edgeLabels, edge);
})
);
// log.info('############################################# XXX');
// log.info('### Layout ### XXX');
// log.info('############################################# XXX');
// Position the nodes
await Promise.all(
data4Layout.nodes.map(async function (node) {
if (node.isGroup) {
positionCluster(node);
} else {
positionNode(node);
}
})
);
data4Layout.nodes.map((node) => {
if (node.isGroup) {
positionCluster(node);
} else {
positionNode(node);
}
});
// Insert the edges and position the edge labels
data4Layout.edges.forEach(function (edge) {
console.log('Edge: ', edge, nodes[edge.start]);
// console.log('Edge: ', edge, nodes[edge.start]);
// log.info('Edge ' + e.v + ' -> ' + e.w + ': ' + JSON.stringify(edge), edge);
edge.points = fixInterSections(
@@ -123,7 +104,6 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
data4Layout.diagramId
);
paths.updatedPath = paths.originalPath;
console.log('Paths = ', paths);
positionEdgeLabel(edge, paths);
});
@@ -239,15 +219,8 @@ const doRender = async (_elem, data4Layout, siteConfig, positions) => {
* ###############################################################
* Render the graph
* ###############################################################
* @param data4Layout
* @param svg
* @param element
* @param algoritm
* @param algorithm
* @param positions
*/
export const render = async (data4Layout, svg, element, algorithm, positions) => {
console.log('Graph in render, positions: ', positions);
// Org
insertMarkers(element, data4Layout.markers, data4Layout.type, data4Layout.diagramId);
clearNodes();

View File

@@ -5,7 +5,8 @@ import { createText } from '$root/rendering-util/createText.ts';
import utils from '$root/utils.js';
import { getLineFunctionsWithOffset } from '$root/utils/lineWithOffset.js';
import { getSubGraphTitleMargins } from '$root/utils/subGraphTitleMargins.js';
import { curveBasis, curveLinear, curveCardinal, line, select } from 'd3';
// import { curveBasis, curveLinear, curveCardinal, line, select } from 'd3';
import { curveBasis, line, select } from 'd3';
import rough from 'roughjs';
import createLabel from './createLabel.js';
import { addEdgeMarkers } from './edgeMarker.ts';

View File

@@ -1,6 +1,5 @@
import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js';
import intersect from '../intersect/index.js';
import { select } from 'd3';
import type { Node } from '$root/rendering-util/types.d.ts';
import { getConfig } from '$root/diagram-api/diagramAPI.js';
import {

View File

@@ -1,9 +1,7 @@
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
import { drawRect } from './drawRect.js';
import { getConfig } from '$root/diagram-api/diagramAPI.js';
export const roundedRect = async (parent: SVGAElement, node: Node) => {
const { look } = getConfig();
const options = {
rx: node.look === 'neo' ? 3 : 5,
ry: node.look === 'neo' ? 3 : 5,

View File

@@ -1,9 +1,7 @@
import type { Node, RectOptions } from '$root/rendering-util/types.d.ts';
import { drawRect } from './drawRect.js';
import { getConfig } from '$root/diagram-api/diagramAPI.js';
export const state = async (parent: SVGAElement, node: Node) => {
const { look } = getConfig();
const options = {
rx: node.look === 'neo' ? 3 : 5,
ry: node.look === 'neo' ? 3 : 5,

View File

@@ -37,11 +37,10 @@ export const createSubroutinePathD = (
export const subroutine = async (parent: SVGAElement, node: Node) => {
const { themeVariables } = getConfig();
const { useGradient, mainBkg } = themeVariables;
const { useGradient } = themeVariables;
const { labelStyles, nodeStyles } = styles2String(node);
node.labelStyle = labelStyles;
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
const halfPadding = (node?.padding || 8) / 2;
const nodePadding = node?.padding || 8;
// const labelPaddingX = node.padding;
// const labelPaddingY = node.padding;
@@ -51,8 +50,7 @@ export const subroutine = async (parent: SVGAElement, node: Node) => {
const h = bbox.height + labelPaddingY;
const x = -bbox.width / 2 - labelPaddingX / 2;
const y = -bbox.height / 2 - labelPaddingY / 2;
let rect;
const { cssStyles } = node;
const points = [
{ x: 0, y: 0 },
{ x: w, y: 0 },
@@ -78,7 +76,7 @@ export const subroutine = async (parent: SVGAElement, node: Node) => {
// options.strokeWidth = 0
}
const roughNode = rc.rectangle(x - 8, y, w + 16, h, options);
rc.rectangle(x - 8, y, w + 16, h, options);
const l1 = rc.line(x, y, x, y + h, options);
const l2 = rc.line(x + w, y, x + w, y + h, options);
@@ -86,7 +84,7 @@ export const subroutine = async (parent: SVGAElement, node: Node) => {
const l2El = shapeSvg.insert(() => l2, ':first-child');
l1El.attr('class', 'neo-line');
l2El.attr('class', 'neo-line');
rect = shapeSvg.insert(() => roughNode, ':first-child');
// rect = shapeSvg.insert(() => roughNode, ':first-child');
// rect.attr('class', 'basic label-container').attr('style', cssStyles);
} else {

View File

@@ -1,4 +1,4 @@
import { darken, lighten, adjust, invert, isDark, toRgba } from 'khroma';
import { darken, lighten, adjust, invert, isDark } from 'khroma';
import { mkBorder } from './theme-helpers.js';
import {
oldAttributeBackgroundColorEven,

21082
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff