From 59d6f04e4bd2fdcf2f98cf0d80abfed884493fe3 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 30 Aug 2024 08:38:41 -0500 Subject: [PATCH 01/21] make rendering-util/types a real ts file --- packages/mermaid-layout-elk/src/render.ts | 10 +++++----- .../src/rendering-util/{types.d.ts => types.ts} | 11 +++++------ 2 files changed, 10 insertions(+), 11 deletions(-) rename packages/mermaid/src/rendering-util/{types.d.ts => types.ts} (95%) diff --git a/packages/mermaid-layout-elk/src/render.ts b/packages/mermaid-layout-elk/src/render.ts index 117ca62763..96f919e4b7 100644 --- a/packages/mermaid-layout-elk/src/render.ts +++ b/packages/mermaid-layout-elk/src/render.ts @@ -224,7 +224,7 @@ export const render = async ( * Add edges to graph based on parsed graph definition */ const addEdges = async function ( - dataForLayout: { edges: any; direction: string }, + dataForLayout: { edges: any; direction?: string }, graph: { id?: string; layoutOptions?: { @@ -749,8 +749,8 @@ export const render = async ( layoutOptions: { 'elk.hierarchyHandling': 'INCLUDE_CHILDREN', 'elk.algorithm': algorithm, - 'nodePlacement.strategy': data4Layout.config.elk.nodePlacementStrategy, - 'elk.layered.mergeEdges': data4Layout.config.elk.mergeEdges, + 'nodePlacement.strategy': data4Layout.config.elk?.nodePlacementStrategy, + 'elk.layered.mergeEdges': data4Layout.config.elk?.mergeEdges, 'elk.direction': 'DOWN', 'spacing.baseValue': 30, // 'spacing.nodeNode': 40, @@ -817,8 +817,8 @@ export const render = async ( ...node.layoutOptions, 'elk.algorithm': algorithm, 'elk.direction': dir2ElkDirection(node.dir), - 'nodePlacement.strategy': data4Layout.config['elk.nodePlacement.strategy'], - 'elk.layered.mergeEdges': data4Layout.config['elk.mergeEdges'], + 'nodePlacement.strategy': data4Layout.config.elk?.nodePlacementStrategy, + 'elk.layered.mergeEdges': data4Layout.config.elk?.mergeEdges, 'elk.hierarchyHandling': 'SEPARATE_CHILDREN', }; } diff --git a/packages/mermaid/src/rendering-util/types.d.ts b/packages/mermaid/src/rendering-util/types.ts similarity index 95% rename from packages/mermaid/src/rendering-util/types.d.ts rename to packages/mermaid/src/rendering-util/types.ts index 67f8de40e8..ba6b2ae878 100644 --- a/packages/mermaid/src/rendering-util/types.d.ts +++ b/packages/mermaid/src/rendering-util/types.ts @@ -1,5 +1,5 @@ export type MarkdownWordType = 'normal' | 'strong' | 'em'; -import type { MermaidConfig } from '../../dist/config.type'; +import type { MermaidConfig } from '../../dist/config.type.js'; export interface MarkdownWord { content: string; type: MarkdownWordType; @@ -9,7 +9,7 @@ export type MarkdownLine = MarkdownWord[]; export type CheckFitFunction = (text: MarkdownLine) => boolean; // Common properties for any node in the system -interface Node { +export interface Node { id: string; label?: string; description?: string[]; @@ -38,7 +38,6 @@ interface Node { tooltip?: string; padding?: number; //REMOVE?, use from LayoutData.config - Keep, this could be shape specific shape?: string; - tooltip?: string; isGroup: boolean; width?: number; height?: number; @@ -68,7 +67,7 @@ interface Node { } // Common properties for any edge in the system -interface Edge { +export interface Edge { id: string; label?: string; classes?: string; @@ -98,7 +97,7 @@ interface Edge { look?: string; } -interface RectOptions { +export interface RectOptions { rx: number; ry: number; labelPaddingX: number; @@ -107,7 +106,7 @@ interface RectOptions { } // Extending the Node interface for specific types if needed -interface ClassDiagramNode extends Node { +export interface ClassDiagramNode extends Node { memberData: any; // Specific property for class diagram nodes } From a176d64389352b3f26b50f29060b1167dbcfedcd Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 30 Aug 2024 08:51:40 -0500 Subject: [PATCH 02/21] fix import --- packages/mermaid/src/rendering-util/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid/src/rendering-util/types.ts b/packages/mermaid/src/rendering-util/types.ts index ba6b2ae878..8280f96761 100644 --- a/packages/mermaid/src/rendering-util/types.ts +++ b/packages/mermaid/src/rendering-util/types.ts @@ -1,5 +1,5 @@ export type MarkdownWordType = 'normal' | 'strong' | 'em'; -import type { MermaidConfig } from '../../dist/config.type.js'; +import type { MermaidConfig } from '../config.type.js'; export interface MarkdownWord { content: string; type: MarkdownWordType; From 3e922c83f0480b8a4fa7dd0a168def64d57ddefd Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 30 Aug 2024 09:10:53 -0500 Subject: [PATCH 03/21] pass linter --- eslint.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/eslint.config.js b/eslint.config.js index 8b4807bc57..3278c7eb42 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -23,6 +23,7 @@ export default tseslint.config( '**/generated/', '**/coverage/', 'packages/mermaid/src/config.type.ts', + 'packages/mermaid/src/docs/.vitepress/components.d.ts', ], }, { From 6a97f80cc33d8e2f5a26eb9f973c28f7592f5621 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 30 Aug 2024 09:16:38 -0500 Subject: [PATCH 04/21] add another maybe-undefined operator elk --- packages/mermaid-layout-elk/src/render.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/mermaid-layout-elk/src/render.ts b/packages/mermaid-layout-elk/src/render.ts index 52cb8aa728..e647422ecc 100644 --- a/packages/mermaid-layout-elk/src/render.ts +++ b/packages/mermaid-layout-elk/src/render.ts @@ -754,7 +754,7 @@ export const render = async ( 'elk.direction': 'DOWN', 'spacing.baseValue': 35, 'elk.layered.unnecessaryBendpoints': true, - 'elk.layered.cycleBreaking.strategy': data4Layout.config.elk.cycleBreakingStrategy, + 'elk.layered.cycleBreaking.strategy': data4Layout.config.elk?.cycleBreakingStrategy, // 'spacing.nodeNode': 20, // 'spacing.nodeNodeBetweenLayers': 25, // 'spacing.edgeNode': 20, From 73f8d70b864bd2a8121508d52fc8f247d2250912 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Fri, 30 Aug 2024 09:21:11 -0500 Subject: [PATCH 05/21] rebuild docs --- docs/config/setup/interfaces/mermaid.LayoutData.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/config/setup/interfaces/mermaid.LayoutData.md b/docs/config/setup/interfaces/mermaid.LayoutData.md index 6f128f4a71..f45d5f0e70 100644 --- a/docs/config/setup/interfaces/mermaid.LayoutData.md +++ b/docs/config/setup/interfaces/mermaid.LayoutData.md @@ -16,11 +16,11 @@ ### config -• **config**: `MermaidConfig` +• **config**: [`MermaidConfig`](mermaid.MermaidConfig.md) #### Defined in -[packages/mermaid/src/rendering-util/types.d.ts:118](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.d.ts#L118) +[packages/mermaid/src/rendering-util/types.ts:117](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L117) --- @@ -30,7 +30,7 @@ #### Defined in -[packages/mermaid/src/rendering-util/types.d.ts:117](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.d.ts#L117) +[packages/mermaid/src/rendering-util/types.ts:116](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L116) --- @@ -40,4 +40,4 @@ #### Defined in -[packages/mermaid/src/rendering-util/types.d.ts:116](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.d.ts#L116) +[packages/mermaid/src/rendering-util/types.ts:115](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/rendering-util/types.ts#L115) From 1b7433b637f9a80986b3a2c9d53744ee3e90aaf8 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Sat, 31 Aug 2024 09:12:59 -0500 Subject: [PATCH 06/21] replace with mermaid/dist --- .../src/diagrams/architecture/icons/svgRegister.ts | 2 +- packages/mermaid/src/rendering-util/createText.ts | 4 ++-- .../layout-algorithms/dagre/index.js | 2 +- .../layout-algorithms/dagre/mermaid-graphlib.js | 2 +- .../dagre/mermaid-graphlib.spec.js | 2 +- packages/mermaid/src/rendering-util/render.ts | 7 +++---- .../rendering-util/rendering-elements/clusters.js | 10 +++++----- .../rendering-elements/createLabel.js | 8 ++++---- .../rendering-elements/edgeMarker.spec.ts | 2 +- .../rendering-elements/edgeMarker.ts | 6 +++--- .../src/rendering-util/rendering-elements/edges.js | 14 +++++++------- .../rendering-util/rendering-elements/markers.js | 2 +- .../src/rendering-util/rendering-elements/nodes.js | 4 ++-- .../rendering-elements/shapes/choice.ts | 6 +++--- .../rendering-elements/shapes/circle.ts | 6 +++--- .../rendering-elements/shapes/cylinder.ts | 4 ++-- .../rendering-elements/shapes/doubleCircle.ts | 6 +++--- .../rendering-elements/shapes/drawRect.ts | 4 ++-- .../rendering-elements/shapes/forkJoin.ts | 6 +++--- .../shapes/handDrawnShapeStyles.ts | 4 ++-- .../rendering-elements/shapes/hexagon.ts | 4 ++-- .../rendering-elements/shapes/invertedTrapezoid.ts | 4 ++-- .../rendering-elements/shapes/labelRect.ts | 2 +- .../rendering-elements/shapes/leanLeft.ts | 4 ++-- .../rendering-elements/shapes/leanRight.ts | 4 ++-- .../rendering-elements/shapes/note.ts | 6 +++--- .../rendering-elements/shapes/question.ts | 6 +++--- .../rendering-elements/shapes/rectLeftInvArrow.ts | 4 ++-- .../rendering-elements/shapes/rectWithTitle.ts | 10 +++++----- .../rendering-elements/shapes/roundedRect.ts | 2 +- .../rendering-elements/shapes/squareRect.ts | 2 +- .../rendering-elements/shapes/stadium.ts | 4 ++-- .../rendering-elements/shapes/state.ts | 2 +- .../rendering-elements/shapes/stateEnd.ts | 6 +++--- .../rendering-elements/shapes/stateStart.ts | 6 +++--- .../rendering-elements/shapes/subroutine.ts | 4 ++-- .../rendering-elements/shapes/trapezoid.ts | 4 ++-- .../rendering-elements/shapes/util.js | 8 ++++---- .../src/rendering-util/setupViewPortForSVG.ts | 6 +++--- packages/mermaid/tsconfig.json | 2 +- vite.config.ts | 2 +- 41 files changed, 96 insertions(+), 97 deletions(-) diff --git a/packages/mermaid/src/diagrams/architecture/icons/svgRegister.ts b/packages/mermaid/src/diagrams/architecture/icons/svgRegister.ts index 712644afa6..0049e2d480 100644 --- a/packages/mermaid/src/diagrams/architecture/icons/svgRegister.ts +++ b/packages/mermaid/src/diagrams/architecture/icons/svgRegister.ts @@ -1,4 +1,4 @@ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import type { Selection } from 'd3-selection'; export type IconResolver = ( diff --git a/packages/mermaid/src/rendering-util/createText.ts b/packages/mermaid/src/rendering-util/createText.ts index a6ad7fa1c0..0a205ea317 100644 --- a/packages/mermaid/src/rendering-util/createText.ts +++ b/packages/mermaid/src/rendering-util/createText.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ // @ts-nocheck TODO: Fix types -import { getConfig } from '$root/diagram-api/diagramAPI.js'; -import common, { hasKatex, renderKatex } from '$root/diagrams/common/common.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import common, { hasKatex, renderKatex } from 'mermaid/dist/diagrams/common/common.js'; import { select } from 'd3'; import type { MermaidConfig } from '../config.type.js'; import type { SVGGroup } from '../diagram-api/types.js'; diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js index 307242675a..044e14dadd 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js +++ b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js @@ -23,7 +23,7 @@ import { insertEdge, clear as clearEdges, } from '../../rendering-elements/edges.js'; -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import { getSubGraphTitleMargins } from '../../../utils/subGraphTitleMargins.js'; import { getConfig } from '../../../diagram-api/diagramAPI.js'; diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js index 54ad5d27f8..0cde897ae7 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js +++ b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js @@ -1,5 +1,5 @@ /** Decorates with functions required by mermaids dagre-wrapper. */ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import * as graphlib from 'dagre-d3-es/src/graphlib/index.js'; import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js'; diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js index dd71a2f7e3..545a35a928 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js +++ b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js @@ -6,7 +6,7 @@ import { extractDescendants, sortNodesByHierarchy, } from './mermaid-graphlib.js'; -import { setLogLevel, log } from '$root/logger.js'; +import { setLogLevel, log } from 'mermaid/dist/logger.js'; describe('Graphlib decorations', () => { let g; diff --git a/packages/mermaid/src/rendering-util/render.ts b/packages/mermaid/src/rendering-util/render.ts index 013be7ba40..e3118b5b78 100644 --- a/packages/mermaid/src/rendering-util/render.ts +++ b/packages/mermaid/src/rendering-util/render.ts @@ -1,7 +1,6 @@ -import type { SVG } from '$root/diagram-api/types.js'; -import type { InternalHelpers } from '$root/internals.js'; -import { internalHelpers } from '$root/internals.js'; -import { log } from '$root/logger.js'; +import type { SVG } from 'mermaid/dist/diagram-api/types.js'; +import type { InternalHelpers, internalHelpers } from 'mermaid/dist/internals.js'; +import { log } from 'mermaid/dist/logger.js'; import type { LayoutData } from './types.js'; export interface RenderOptions { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js index ba87f78f53..a963bba9b8 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js @@ -1,7 +1,7 @@ -import { getConfig } from '$root/diagram-api/diagramAPI.js'; -import { evaluate } from '$root/diagrams/common/common.js'; -import { log } from '$root/logger.js'; -import { getSubGraphTitleMargins } from '$root/utils/subGraphTitleMargins.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { evaluate } from 'mermaid/dist/diagrams/common/common.js'; +import { log } from 'mermaid/dist/logger.js'; +import { getSubGraphTitleMargins } from 'mermaid/dist/utils/subGraphTitleMargins.js'; import { select } from 'd3'; import rough from 'roughjs'; import { createText } from '../createText.ts'; @@ -11,7 +11,7 @@ import { createRoundedRectPathD } from './shapes/roundedRectPath.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; const rect = async (parent, node) => { log.info('Creating subgraph rect for ', node.id, node); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/createLabel.js b/packages/mermaid/src/rendering-util/rendering-elements/createLabel.js index 0afdbb7145..2d560e85da 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/createLabel.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/createLabel.js @@ -1,8 +1,8 @@ import { select } from 'd3'; -import { log } from '$root/logger.js'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; -import common, { evaluate, renderKatex, hasKatex } from '$root/diagrams/common/common.js'; -import { decodeEntities } from '$root/utils.js'; +import { log } from 'mermaid/dist/logger.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import common, { evaluate, renderKatex, hasKatex } from 'mermaid/dist/diagrams/common/common.js'; +import { decodeEntities } from 'mermaid/dist/utils.js'; /** * @param dom diff --git a/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.spec.ts b/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.spec.ts index 05c7472c95..313dc1d018 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.spec.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import type { SVG } from '$root/diagram-api/types.js'; +import type { SVG } from 'mermaid/dist/diagram-api/types.js'; import type { Mocked } from 'vitest'; import { addEdgeMarkers } from './edgeMarker.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.ts b/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.ts index ea748d8aae..032b3989c1 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.ts @@ -1,6 +1,6 @@ -import type { SVG } from '$root/diagram-api/types.js'; -import { log } from '$root/logger.js'; -import type { EdgeData } from '$root/types.js'; +import type { SVG } from 'mermaid/dist/diagram-api/types.js'; +import { log } from 'mermaid/dist/logger.js'; +import type { EdgeData } from 'mermaid/dist/types.js'; /** * Adds SVG markers to a path element based on the arrow types specified in the edge. * diff --git a/packages/mermaid/src/rendering-util/rendering-elements/edges.js b/packages/mermaid/src/rendering-util/rendering-elements/edges.js index 087fcf0bec..999dc3d1cc 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/edges.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/edges.js @@ -1,10 +1,10 @@ -import { getConfig } from '$root/diagram-api/diagramAPI.js'; -import { evaluate } from '$root/diagrams/common/common.js'; -import { log } from '$root/logger.js'; -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 { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { evaluate } from 'mermaid/dist/diagrams/common/common.js'; +import { log } from 'mermaid/dist/logger.js'; +import { createText } from 'mermaid/dist/rendering-util/createText.ts'; +import utils from 'mermaid/dist/utils.js'; +import { getLineFunctionsWithOffset } from 'mermaid/dist/utils/lineWithOffset.js'; +import { getSubGraphTitleMargins } from 'mermaid/dist/utils/subGraphTitleMargins.js'; import { curveBasis, line, select } from 'd3'; import rough from 'roughjs'; import createLabel from './createLabel.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/markers.js b/packages/mermaid/src/rendering-util/rendering-elements/markers.js index 0b0972a8ad..b9494c4c1a 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/markers.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/markers.js @@ -1,5 +1,5 @@ /** Setup arrow head and define the marker. The result is appended to the svg. */ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; // Only add the number of markers that the diagram needs const insertMarkers = (elem, markerArray, type, id) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/nodes.js b/packages/mermaid/src/rendering-util/rendering-elements/nodes.js index 54d4ddf3ee..830639f0c7 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/nodes.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/nodes.js @@ -1,4 +1,4 @@ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import { state } from './shapes/state.ts'; import { roundedRect } from './shapes/roundedRect.ts'; import { squareRect } from './shapes/squareRect.ts'; @@ -9,7 +9,7 @@ import { choice } from './shapes/choice.ts'; import { note } from './shapes/note.ts'; import { stadium } from './shapes/stadium.js'; import { rectWithTitle } from './shapes/rectWithTitle.js'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; import { subroutine } from './shapes/subroutine.js'; import { cylinder } from './shapes/cylinder.js'; import { circle } from './shapes/circle.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/choice.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/choice.ts index 3d6f085a4b..9b99b8e7f2 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/choice.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/choice.ts @@ -1,10 +1,10 @@ import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; -import type { SVG } from '$root/diagram-api/types.js'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { SVG } from 'mermaid/dist/diagram-api/types.js'; // @ts-ignore TODO: Fix rough typings import rough from 'roughjs'; import { solidStateFill, styles2String } from './handDrawnShapeStyles.js'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; export const choice = (parent: SVG, node: Node) => { const { labelStyles, nodeStyles } = styles2String(node); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts index 1474b778f7..3c301a0255 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts @@ -1,11 +1,11 @@ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; export const circle = async (parent: SVGAElement, node: Node): Promise => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts index f85db0f05e..c92b40138b 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; export const createCylinderPathD = ( diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts index 5ce616c0ba..8672ffbfff 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts @@ -1,11 +1,11 @@ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; export const doublecircle = async (parent: SVGAElement, node: Node): Promise => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts index 645f69177f..e9643ba4f5 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts @@ -1,11 +1,11 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node, RectOptions } from '$root/rendering-util/types.d.ts'; +import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; import { createRoundedRectPathD } from './roundedRectPath.js'; import { userNodeOverrides, styles2String, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; export const drawRect = async (parent: SVGAElement, node: Node, options: RectOptions) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/forkJoin.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/forkJoin.ts index 07978be106..324bb31343 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/forkJoin.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/forkJoin.ts @@ -1,10 +1,10 @@ import { updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; -import type { SVG } from '$root/diagram-api/types.js'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { SVG } from 'mermaid/dist/diagram-api/types.js'; import rough from 'roughjs'; import { solidStateFill } from './handDrawnShapeStyles.js'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; export const forkJoin = (parent: SVG, node: Node, dir: string) => { const { themeVariables } = getConfig(); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts index a5c963e7cc..d764527d83 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts @@ -1,5 +1,5 @@ -import { getConfig } from '$root/diagram-api/diagramAPI.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; // Striped fill like start or fork nodes in state diagrams export const solidStateFill = (color: string) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts index 3b0ce30819..5a1197c51a 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts index 37f4152477..5a8bf9765a 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts index 2d5c6d6eaf..51605eae49 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts @@ -1,4 +1,4 @@ -import type { Node, RectOptions } from '$root/rendering-util/types.d.ts'; +import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; import { drawRect } from './drawRect.js'; import { labelHelper, updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts index bb57925e20..8e06096f1d 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts index 37604e7e77..b4c1ae7053 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/note.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/note.ts index 77fabf2718..a567c33128 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/note.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/note.ts @@ -1,8 +1,8 @@ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import { labelHelper, updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import rough from 'roughjs'; export const note = async (parent: SVGAElement, node: Node) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts index ba770ab4e0..b3eed0f665 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts @@ -1,11 +1,11 @@ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts index b5000ac77e..4d7611331c 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts index 857e60b8b0..27ef201ee6 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts @@ -1,17 +1,17 @@ -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { select } from 'd3'; -import { evaluate } from '$root/diagrams/common/common.js'; +import { evaluate } from 'mermaid/dist/diagrams/common/common.js'; import { updateNodeBounds } from './util.js'; import createLabel from '../createLabel.js'; import intersect from '../intersect/index.js'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; import { createRoundedRectPathD } from './roundedRectPath.js'; -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; export const rectWithTitle = async (parent: SVGElement, node: Node) => { const { labelStyles, nodeStyles } = styles2String(node); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/roundedRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/roundedRect.ts index 8a28b63ad4..5342965872 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/roundedRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/roundedRect.ts @@ -1,4 +1,4 @@ -import type { Node, RectOptions } from '$root/rendering-util/types.d.ts'; +import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; import { drawRect } from './drawRect.js'; export const roundedRect = async (parent: SVGAElement, node: Node) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/squareRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/squareRect.ts index 8daeaec7a9..2070e6a149 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/squareRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/squareRect.ts @@ -1,4 +1,4 @@ -import type { Node, RectOptions } from '$root/rendering-util/types.d.ts'; +import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; import { drawRect } from './drawRect.js'; export const squareRect = async (parent: SVGAElement, node: Node) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts index 14504b3a08..bc42d5e6fd 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { createRoundedRectPathD } from './roundedRectPath.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/state.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/state.ts index fac2557353..06cbc636f2 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/state.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/state.ts @@ -1,4 +1,4 @@ -import type { Node, RectOptions } from '$root/rendering-util/types.d.ts'; +import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; import { drawRect } from './drawRect.js'; export const state = async (parent: SVGAElement, node: Node) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateEnd.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateEnd.ts index a277ff0b9a..57f3916574 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateEnd.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateEnd.ts @@ -1,10 +1,10 @@ import { updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; -import type { SVG } from '$root/diagram-api/types.js'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { SVG } from 'mermaid/dist/diagram-api/types.js'; import rough from 'roughjs'; import { solidStateFill } from './handDrawnShapeStyles.js'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; export const stateEnd = (parent: SVG, node: Node) => { const { themeVariables } = getConfig(); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts index 341b82e1cc..f8d0e084d8 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts @@ -1,10 +1,10 @@ import { updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; -import type { SVG } from '$root/diagram-api/types.js'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { SVG } from 'mermaid/dist/diagram-api/types.js'; import rough from 'roughjs'; import { solidStateFill } from './handDrawnShapeStyles.js'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; export const stateStart = (parent: SVG, node: Node) => { const { themeVariables } = getConfig(); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts index c4393c25fa..fbfa3ed5cd 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts index b2013097a8..701747c1c1 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from '$root/rendering-util/types.d.ts'; +import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; import { styles2String, userNodeOverrides, -} from '$root/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.js b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.js index ca1290668a..633171d5ca 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.js @@ -1,8 +1,8 @@ -import { createText } from '$root/rendering-util/createText.ts'; -import { getConfig } from '$root/diagram-api/diagramAPI.js'; +import { createText } from 'mermaid/dist/rendering-util/createText.ts'; +import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; import { select } from 'd3'; -import { evaluate, sanitizeText } from '$root/diagrams/common/common.js'; -import { decodeEntities } from '$root/utils.js'; +import { evaluate, sanitizeText } from 'mermaid/dist/diagrams/common/common.js'; +import { decodeEntities } from 'mermaid/dist/utils.js'; export const labelHelper = async (parent, node, _classes) => { let cssClasses; diff --git a/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts b/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts index e21f3304b3..00d8080667 100644 --- a/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts +++ b/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts @@ -1,6 +1,6 @@ -import { configureSvgSize } from '$root/setupGraphViewbox.js'; -import type { SVG } from '$root/diagram-api/types.js'; -import { log } from '$root/logger.js'; +import { configureSvgSize } from 'mermaid/dist/setupGraphViewbox.js'; +import type { SVG } from 'mermaid/dist/diagram-api/types.js'; +import { log } from 'mermaid/dist/logger.js'; export const setupViewPortForSVG = ( svg: SVG, diff --git a/packages/mermaid/tsconfig.json b/packages/mermaid/tsconfig.json index 0f06a17313..3c7ed2b5e5 100644 --- a/packages/mermaid/tsconfig.json +++ b/packages/mermaid/tsconfig.json @@ -6,7 +6,7 @@ "types": ["vitest/importMeta", "vitest/globals"], "baseUrl": ".", // This must be set if "paths" is set "paths": { - "$root/*": ["src/*"] + "mermaid/dist/*": ["src/*"] } }, "include": [ diff --git a/vite.config.ts b/vite.config.ts index ed0ba10f73..2db66b7a40 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,7 +9,7 @@ export default defineConfig({ extensions: ['.js'], alias: { // Define your alias here - $root: path.resolve(__dirname, 'packages/mermaid/src'), + 'mermaid/dist': path.resolve(__dirname, 'packages/mermaid/src'), }, }, plugins: [ From 0b672e2636ace82a816f54a21ef207f7a87efe42 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Sun, 1 Sep 2024 16:40:12 -0500 Subject: [PATCH 07/21] add test for out-of-tree tsc project --- .github/workflows/test.yml | 4 + package.json | 1 + packages/mermaid/src/rendering-util/render.ts | 3 +- scripts/tsc-check.ts | 175 ++++++++++++++++++ 4 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 scripts/tsc-check.ts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 375d5fada3..026ca0fb7f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,6 +38,10 @@ jobs: run: | pnpm exec vitest run ./packages/mermaid/src/diagrams/gantt/ganttDb.spec.ts --coverage + - name: Verify out-of-tree build with TypeScript + run: | + pnpm test:check:tsc + - name: Upload Coverage to Codecov uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 # Run step only pushes to develop and pull_requests diff --git a/package.json b/package.json index 21ae5360c4..ff100f1f6e 100644 --- a/package.json +++ b/package.json @@ -42,6 +42,7 @@ "test": "pnpm lint && vitest run", "test:watch": "vitest --watch", "test:coverage": "vitest --coverage", + "test:check:tsc": "tsx scripts/tsc-check.ts", "prepare": "husky && pnpm build", "pre-commit": "lint-staged" }, diff --git a/packages/mermaid/src/rendering-util/render.ts b/packages/mermaid/src/rendering-util/render.ts index e3118b5b78..8306bc15a0 100644 --- a/packages/mermaid/src/rendering-util/render.ts +++ b/packages/mermaid/src/rendering-util/render.ts @@ -1,5 +1,6 @@ import type { SVG } from 'mermaid/dist/diagram-api/types.js'; -import type { InternalHelpers, internalHelpers } from 'mermaid/dist/internals.js'; +import type { InternalHelpers } from 'mermaid/dist/internals.js'; +import { internalHelpers } from 'mermaid/dist/internals.js'; import { log } from 'mermaid/dist/logger.js'; import type { LayoutData } from './types.js'; diff --git a/scripts/tsc-check.ts b/scripts/tsc-check.ts new file mode 100644 index 0000000000..7a5ff50a9b --- /dev/null +++ b/scripts/tsc-check.ts @@ -0,0 +1,175 @@ +/** + * Verify the as-built tarballs can be imported into a fresh, out-of-tree TypeScript project. + */ + +/* eslint-disable no-console */ +import { mkdtemp, mkdir, writeFile, readFile, readdir, copyFile, rm } from 'node:fs/promises'; +import { execFileSync } from 'child_process'; +import * as path from 'path'; +import { fileURLToPath } from 'url'; +import { tmpdir } from 'node:os'; + +const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file +const __dirname = path.dirname(__filename); // get the name of the directory + +/** + * Packages to build and import + */ +const PACKAGES = { + mermaid: 'mermaid', + '@mermaid-js/layout-elk': 'mermaid-layout-elk', + // TODO: these don't import cleanly yet due to exotic tsconfig.json requirements + // '@mermaid-js/mermaid-zenuml': 'mermaid-zenuml', + // '@mermaid-js/parser': 'parser', +}; + +/** + * Files to create in the temporary package. + */ +const SRC = { + // a minimal description of a buildable package + 'package.json': (tarballs: Record) => + JSON.stringify( + { + dependencies: tarballs, + scripts: { build: 'tsc -b --verbose' }, + devDependencies: { + // these are somewhat-unexpectedly required, and a downstream would need + // to match the real `package.json` values + 'type-fest': '*', + '@types/d3': '^7.4.3', + '@types/dompurify': '^3.0.5', + typescript: '*', + }, + }, + null, + 2 + ), + // a fairly strict TypeScript configuration + 'tsconfig.json': () => + JSON.stringify( + { + compilerOptions: { + allowSyntheticDefaultImports: true, + composite: true, + declaration: true, + esModuleInterop: true, + incremental: true, + lib: ['dom', 'es2020'], + module: 'esnext', + moduleResolution: 'node', + noEmitOnError: true, + noImplicitAny: true, + noUnusedLocals: true, + sourceMap: true, + target: 'es2020', + rootDir: './src', + outDir: './lib', + strict: true, + tsBuildInfoFile: 'lib/.tsbuildinfo', + }, + }, + null, + 2 + ), + // the simplest possible script: will everything even import? + 'src/index.ts': (tarballs) => { + const imports: string[] = []; + const outputs: string[] = []; + let i = 0; + for (const pkg of Object.keys(tarballs)) { + imports.push(`import * as pkg_${i} from '${pkg}';`); + outputs.push(`console.log(pkg_${i});`); + i++; + } + return [...imports, ...outputs].join('\n'); + }, +}; + +/** + * Commands to run after source files are created. + * + * `npm` is used to detect any unwanted `pnpm`-specific runtime "features". + */ +const COMMANDS = [ + ['npm', 'install'], + ['npm', 'run', 'build'], +]; + +/** + * Built files to expect after commands are executed. + */ +const LIB = ['lib/index.js', 'lib/index.js.map', 'lib/index.d.ts', 'lib/.tsbuildinfo']; + +/** + * Run a small out-of-tree build. + */ +async function main() { + console.warn('Checking out-of-tree TypeScript build using', Object.keys(PACKAGES).join('\n')); + const cwd = await mkdtemp(path.join(tmpdir(), 'mermaid-tsc-check-')); + console.warn('... creating temporary folder', cwd); + const tarballs = await buildTarballs(cwd); + + for (const [filename, generate] of Object.entries(SRC)) { + const dest = path.join(cwd, filename); + await mkdir(path.dirname(dest), { recursive: true }); + console.warn('... creating', dest); + const text = generate(tarballs); + await writeFile(dest, text); + console.info(text); + } + + for (const argv of COMMANDS) { + console.warn('... in', cwd); + console.warn('>>>', ...argv); + execFileSync(argv[0], argv.slice(1), { cwd }); + } + + for (const lib of LIB) { + const checkLib = path.join(cwd, lib); + console.warn('... checking built file', checkLib); + await readFile(checkLib, 'utf-8'); + } + + console.warn('... deleting', cwd); + await rm(cwd, { recursive: true, force: true }); + console.warn('... tsc-check OK for\n', Object.keys(PACKAGES).join('\n')); +} + +/** Build all the tarballs. */ +async function buildTarballs(tmp: string): Promise> { + const dist = path.join(tmp, 'dist'); + await mkdir(dist); + const promises: Promise[] = []; + const tarballs: Record = {}; + for (const [pkg, srcPath] of Object.entries(PACKAGES)) { + promises.push(buildOneTarball(pkg, srcPath, dist, tarballs)); + } + await Promise.all(promises); + return tarballs; +} + +/** Build a single tarball. */ +async function buildOneTarball( + pkg: string, + srcPath: string, + dist: string, + tarballs: Record +): Promise { + const cwd = await mkdtemp(path.join(dist, 'pack-')); + const pkgDir = path.join(__dirname, '../packages', srcPath); + const argv = ['pnpm', 'pack', '--pack-destination', cwd]; + console.warn('>>>', ...argv); + execFileSync(argv[0], argv.slice(1), { cwd: pkgDir }); + const built = await readdir(cwd); + const dest = path.join(dist, built[0]); + await copyFile(path.join(cwd, built[0]), dest); + await rm(cwd, { recursive: true, force: true }); + tarballs[pkg] = dest; +} + +void main().catch((err) => { + console.error(err); + console.error('!!! tsc-check FAIL: temp folder left in place. see logs above for failure notes'); + process.exit(1); +}); From b56fe796d69c77f11b2d63557b2abc1dbdd9b345 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Mon, 2 Sep 2024 16:07:28 -0500 Subject: [PATCH 08/21] more , linting --- .../architecture/architectureIcons.ts | 2 +- .../architecture/architectureRenderer.ts | 2 +- .../src/diagrams/architecture/svgDraw.ts | 6 +- packages/mermaid/src/mermaid.ts | 2 +- packages/mermaid/src/rendering-util/icons.ts | 2 +- pnpm-lock.yaml | 153 ------------------ 6 files changed, 7 insertions(+), 160 deletions(-) diff --git a/packages/mermaid/src/diagrams/architecture/architectureIcons.ts b/packages/mermaid/src/diagrams/architecture/architectureIcons.ts index dd6c99f9c9..bf6bfd4f1c 100644 --- a/packages/mermaid/src/diagrams/architecture/architectureIcons.ts +++ b/packages/mermaid/src/diagrams/architecture/architectureIcons.ts @@ -1,4 +1,4 @@ -import { unknownIcon } from '$root/rendering-util/icons.js'; +import { unknownIcon } from 'mermaid/dist/rendering-util/icons.js'; import type { IconifyJSON } from '@iconify/types'; const wrapIcon = (icon: string) => { diff --git a/packages/mermaid/src/diagrams/architecture/architectureRenderer.ts b/packages/mermaid/src/diagrams/architecture/architectureRenderer.ts index 3abb69b9f7..f7dcd325ce 100644 --- a/packages/mermaid/src/diagrams/architecture/architectureRenderer.ts +++ b/packages/mermaid/src/diagrams/architecture/architectureRenderer.ts @@ -1,4 +1,4 @@ -import { registerIconPacks } from '$root/rendering-util/icons.js'; +import { registerIconPacks } from 'mermaid/dist/rendering-util/icons.js'; import type { Position } from 'cytoscape'; import cytoscape from 'cytoscape'; import type { FcoseLayoutOptions } from 'cytoscape-fcose'; diff --git a/packages/mermaid/src/diagrams/architecture/svgDraw.ts b/packages/mermaid/src/diagrams/architecture/svgDraw.ts index 3578393949..0a4a44d9cd 100644 --- a/packages/mermaid/src/diagrams/architecture/svgDraw.ts +++ b/packages/mermaid/src/diagrams/architecture/svgDraw.ts @@ -1,4 +1,4 @@ -import { getIconSVG } from '$root/rendering-util/icons.js'; +import { getIconSVG } from 'mermaid/dist/rendering-util/icons.js'; import type cytoscape from 'cytoscape'; import { getConfig } from '../../diagram-api/diagramAPI.js'; import { createText } from '../../rendering-util/createText.js'; @@ -170,8 +170,8 @@ export const drawEdges = async function (edgesEl: D3Element, cy: cytoscape.Core) textElem.attr( 'transform', ` - translate(${midX}, ${midY - bboxOrig.height / 2}) - translate(${(x * bboxNew.width) / 2}, ${(y * bboxNew.height) / 2}) + translate(${midX}, ${midY - bboxOrig.height / 2}) + translate(${(x * bboxNew.width) / 2}, ${(y * bboxNew.height) / 2}) rotate(${-1 * x * y * 45}, 0, ${bboxOrig.height / 2}) ` ); diff --git a/packages/mermaid/src/mermaid.ts b/packages/mermaid/src/mermaid.ts index 52cca1cfe4..6a7efb3754 100644 --- a/packages/mermaid/src/mermaid.ts +++ b/packages/mermaid/src/mermaid.ts @@ -2,7 +2,7 @@ * Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid * functionality and to render the diagrams to svg code! */ -import { registerIconPacks } from '$root/rendering-util/icons.js'; +import { registerIconPacks } from 'mermaid/dist/rendering-util/icons.js'; import { dedent } from 'ts-dedent'; import type { MermaidConfig } from './config.type.js'; import { detectType, registerLazyLoadedDiagrams } from './diagram-api/detectType.js'; diff --git a/packages/mermaid/src/rendering-util/icons.ts b/packages/mermaid/src/rendering-util/icons.ts index 27709b8229..d08d55f430 100644 --- a/packages/mermaid/src/rendering-util/icons.ts +++ b/packages/mermaid/src/rendering-util/icons.ts @@ -1,4 +1,4 @@ -import { log } from '$root/logger.js'; +import { log } from 'mermaid/dist/logger.js'; import type { ExtendedIconifyIcon, IconifyIcon, IconifyJSON } from '@iconify/types'; import type { IconifyIconCustomisations } from '@iconify/utils'; import { getIconData, iconToHTML, iconToSVG, replaceIDs, stringToIcon } from '@iconify/utils'; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7fcdbb5f3f..cfdb457320 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -503,67 +503,6 @@ importers: specifier: ^7.0.0 version: 7.1.0 - packages/mermaid/src/vitepress: - dependencies: - '@mdi/font': - specifier: ^7.0.0 - version: 7.4.47 - '@vueuse/core': - specifier: ^10.9.0 - version: 10.11.1(vue@3.4.38(typescript@5.4.5)) - font-awesome: - specifier: ^4.7.0 - version: 4.7.0 - jiti: - specifier: ^1.21.0 - version: 1.21.6 - mermaid: - specifier: workspace:^ - version: link:../.. - vue: - specifier: ^3.4.21 - version: 3.4.38(typescript@5.4.5) - devDependencies: - '@iconify-json/carbon': - specifier: ^1.1.31 - version: 1.1.37 - '@unocss/reset': - specifier: ^0.59.0 - version: 0.59.4 - '@vite-pwa/vitepress': - specifier: ^0.4.0 - version: 0.4.0(vite-plugin-pwa@0.19.8(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0)) - '@vitejs/plugin-vue': - specifier: ^5.0.0 - version: 5.1.2(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(vue@3.4.38(typescript@5.4.5)) - fast-glob: - specifier: ^3.3.2 - version: 3.3.2 - https-localhost: - specifier: ^4.7.1 - version: 4.7.1 - pathe: - specifier: ^1.1.2 - version: 1.1.2 - unocss: - specifier: ^0.59.0 - version: 0.59.4(postcss@8.4.41)(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)) - unplugin-vue-components: - specifier: ^0.26.0 - version: 0.26.0(@babel/parser@7.25.4)(rollup@4.21.1)(vue@3.4.38(typescript@5.4.5)) - vite: - specifier: ^5.0.0 - version: 5.4.2(@types/node@22.5.1)(terser@5.31.6) - vite-plugin-pwa: - specifier: ^0.19.7 - version: 0.19.8(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) - vitepress: - specifier: 1.1.4 - version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@22.5.1)(axios@1.7.5)(postcss@8.4.41)(search-insights@2.15.0)(terser@5.31.6)(typescript@5.4.5) - workbox-window: - specifier: ^7.0.0 - version: 7.1.0 - packages/parser: dependencies: langium: @@ -12389,16 +12328,6 @@ snapshots: transitivePeerDependencies: - rollup - '@unocss/astro@0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))': - dependencies: - '@unocss/core': 0.59.4 - '@unocss/reset': 0.59.4 - '@unocss/vite': 0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)) - optionalDependencies: - vite: 5.4.2(@types/node@22.5.1)(terser@5.31.6) - transitivePeerDependencies: - - rollup - '@unocss/cli@0.59.4(rollup@2.79.1)': dependencies: '@ampproject/remapping': 2.3.0 @@ -12417,24 +12346,6 @@ snapshots: transitivePeerDependencies: - rollup - '@unocss/cli@0.59.4(rollup@4.21.1)': - dependencies: - '@ampproject/remapping': 2.3.0 - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) - '@unocss/config': 0.59.4 - '@unocss/core': 0.59.4 - '@unocss/preset-uno': 0.59.4 - cac: 6.7.14 - chokidar: 3.6.0 - colorette: 2.0.20 - consola: 3.2.3 - fast-glob: 3.3.2 - magic-string: 0.30.11 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - transitivePeerDependencies: - - rollup - '@unocss/config@0.59.4': dependencies: '@unocss/core': 0.59.4 @@ -12560,22 +12471,6 @@ snapshots: transitivePeerDependencies: - rollup - '@unocss/vite@0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))': - dependencies: - '@ampproject/remapping': 2.3.0 - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) - '@unocss/config': 0.59.4 - '@unocss/core': 0.59.4 - '@unocss/inspector': 0.59.4 - '@unocss/scope': 0.59.4 - '@unocss/transformer-directives': 0.59.4 - chokidar: 3.6.0 - fast-glob: 3.3.2 - magic-string: 0.30.11 - vite: 5.4.2(@types/node@22.5.1)(terser@5.31.6) - transitivePeerDependencies: - - rollup - '@vite-pwa/vitepress@0.4.0(vite-plugin-pwa@0.19.8(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0))': dependencies: vite-plugin-pwa: 0.19.8(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) @@ -18977,35 +18872,6 @@ snapshots: - rollup - supports-color - unocss@0.59.4(postcss@8.4.41)(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)): - dependencies: - '@unocss/astro': 0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)) - '@unocss/cli': 0.59.4(rollup@4.21.1) - '@unocss/core': 0.59.4 - '@unocss/extractor-arbitrary-variants': 0.59.4 - '@unocss/postcss': 0.59.4(postcss@8.4.41) - '@unocss/preset-attributify': 0.59.4 - '@unocss/preset-icons': 0.59.4 - '@unocss/preset-mini': 0.59.4 - '@unocss/preset-tagify': 0.59.4 - '@unocss/preset-typography': 0.59.4 - '@unocss/preset-uno': 0.59.4 - '@unocss/preset-web-fonts': 0.59.4 - '@unocss/preset-wind': 0.59.4 - '@unocss/reset': 0.59.4 - '@unocss/transformer-attributify-jsx': 0.59.4 - '@unocss/transformer-attributify-jsx-babel': 0.59.4 - '@unocss/transformer-compile-class': 0.59.4 - '@unocss/transformer-directives': 0.59.4 - '@unocss/transformer-variant-group': 0.59.4 - '@unocss/vite': 0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)) - optionalDependencies: - vite: 5.4.2(@types/node@22.5.1)(terser@5.31.6) - transitivePeerDependencies: - - postcss - - rollup - - supports-color - unpipe@1.0.0: {} unplugin-vue-components@0.26.0(@babel/parser@7.25.4)(rollup@2.79.1)(vue@3.4.38(typescript@5.4.5)): @@ -19027,25 +18893,6 @@ snapshots: - rollup - supports-color - unplugin-vue-components@0.26.0(@babel/parser@7.25.4)(rollup@4.21.1)(vue@3.4.38(typescript@5.4.5)): - dependencies: - '@antfu/utils': 0.7.10 - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) - chokidar: 3.6.0 - debug: 4.3.6(supports-color@8.1.1) - fast-glob: 3.3.2 - local-pkg: 0.4.3 - magic-string: 0.30.11 - minimatch: 9.0.5 - resolve: 1.22.8 - unplugin: 1.12.0 - vue: 3.4.38(typescript@5.4.5) - optionalDependencies: - '@babel/parser': 7.25.4 - transitivePeerDependencies: - - rollup - - supports-color - unplugin@1.12.0: dependencies: acorn: 8.12.1 From cd67fdf89d61d7fbec4bced23ae4e19a250bc279 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Tue, 3 Sep 2024 23:58:55 +0530 Subject: [PATCH 09/21] docs: Fix SMW link --- docs/ecosystem/integrations-community.md | 2 +- packages/mermaid/src/docs/ecosystem/integrations-community.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/ecosystem/integrations-community.md b/docs/ecosystem/integrations-community.md index a9687359be..ef51b423ce 100644 --- a/docs/ecosystem/integrations-community.md +++ b/docs/ecosystem/integrations-community.md @@ -145,7 +145,7 @@ Communication tools and platforms - [Mermaid Extension](https://www.mediawiki.org/wiki/Extension:Mermaid) - [PmWiki](https://www.pmwiki.org) - [MermaidJs Cookbook recipe](https://www.pmwiki.org/wiki/Cookbook/MermaidJs) -- [Semantic Media Wiki](https://semantic-mediawiki.org) +- [Semantic Media Wiki](https://www.semantic-mediawiki.org) - [Mermaid Plugin](https://github.com/SemanticMediaWiki/Mermaid) - [TiddlyWiki](https://tiddlywiki.com/) - [mermaid-tw5: wrapper for Mermaid Live](https://github.com/efurlanm/mermaid-tw5) diff --git a/packages/mermaid/src/docs/ecosystem/integrations-community.md b/packages/mermaid/src/docs/ecosystem/integrations-community.md index 15f802ed55..9970d1e9c6 100644 --- a/packages/mermaid/src/docs/ecosystem/integrations-community.md +++ b/packages/mermaid/src/docs/ecosystem/integrations-community.md @@ -140,7 +140,7 @@ Communication tools and platforms - [Mermaid Extension](https://www.mediawiki.org/wiki/Extension:Mermaid) - [PmWiki](https://www.pmwiki.org) - [MermaidJs Cookbook recipe](https://www.pmwiki.org/wiki/Cookbook/MermaidJs) -- [Semantic Media Wiki](https://semantic-mediawiki.org) +- [Semantic Media Wiki](https://www.semantic-mediawiki.org) - [Mermaid Plugin](https://github.com/SemanticMediaWiki/Mermaid) - [TiddlyWiki](https://tiddlywiki.com/) - [mermaid-tw5: wrapper for Mermaid Live](https://github.com/efurlanm/mermaid-tw5) From 64abf29ea870eaa47148197f95ce714f85bd7eea Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 6 Sep 2024 23:05:30 +0530 Subject: [PATCH 10/21] feat: Return parsed config from `mermaid.parse` --- .changeset/giant-steaks-argue.md | 5 ++ .../setup/interfaces/mermaid.ParseOptions.md | 2 +- .../setup/interfaces/mermaid.ParseResult.md | 14 +++- .../setup/interfaces/mermaid.RenderResult.md | 6 +- packages/mermaid/src/mermaidAPI.spec.ts | 73 +++++++++++++++++-- packages/mermaid/src/mermaidAPI.ts | 4 +- packages/mermaid/src/types.ts | 6 ++ 7 files changed, 97 insertions(+), 13 deletions(-) create mode 100644 .changeset/giant-steaks-argue.md diff --git a/.changeset/giant-steaks-argue.md b/.changeset/giant-steaks-argue.md new file mode 100644 index 0000000000..0abefe3fc4 --- /dev/null +++ b/.changeset/giant-steaks-argue.md @@ -0,0 +1,5 @@ +--- +'mermaid': minor +--- + +feat: Return parsed config from mermaid.parse diff --git a/docs/config/setup/interfaces/mermaid.ParseOptions.md b/docs/config/setup/interfaces/mermaid.ParseOptions.md index 2b80842090..54a1dfcaae 100644 --- a/docs/config/setup/interfaces/mermaid.ParseOptions.md +++ b/docs/config/setup/interfaces/mermaid.ParseOptions.md @@ -19,4 +19,4 @@ The `parseError` function will not be called. #### Defined in -[packages/mermaid/src/types.ts:43](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L43) +[packages/mermaid/src/types.ts:45](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L45) diff --git a/docs/config/setup/interfaces/mermaid.ParseResult.md b/docs/config/setup/interfaces/mermaid.ParseResult.md index 42f8ea8ba4..452c90b320 100644 --- a/docs/config/setup/interfaces/mermaid.ParseResult.md +++ b/docs/config/setup/interfaces/mermaid.ParseResult.md @@ -10,6 +10,18 @@ ## Properties +### config + +• `Optional` **config**: [`MermaidConfig`](mermaid.MermaidConfig.md) + +The config passed as YAML frontmatter or directives + +#### Defined in + +[packages/mermaid/src/types.ts:56](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L56) + +--- + ### diagramType • **diagramType**: `string` @@ -18,4 +30,4 @@ The diagram type, e.g. 'flowchart', 'sequence', etc. #### Defined in -[packages/mermaid/src/types.ts:50](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L50) +[packages/mermaid/src/types.ts:52](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L52) diff --git a/docs/config/setup/interfaces/mermaid.RenderResult.md b/docs/config/setup/interfaces/mermaid.RenderResult.md index f2b5c7872a..369243331b 100644 --- a/docs/config/setup/interfaces/mermaid.RenderResult.md +++ b/docs/config/setup/interfaces/mermaid.RenderResult.md @@ -39,7 +39,7 @@ bindFunctions?.(div); // To call bindFunctions only if it's present. #### Defined in -[packages/mermaid/src/types.ts:73](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L73) +[packages/mermaid/src/types.ts:79](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L79) --- @@ -51,7 +51,7 @@ The diagram type, e.g. 'flowchart', 'sequence', etc. #### Defined in -[packages/mermaid/src/types.ts:63](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L63) +[packages/mermaid/src/types.ts:69](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L69) --- @@ -63,4 +63,4 @@ The svg code for the rendered graph. #### Defined in -[packages/mermaid/src/types.ts:59](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L59) +[packages/mermaid/src/types.ts:65](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/types.ts#L65) diff --git a/packages/mermaid/src/mermaidAPI.spec.ts b/packages/mermaid/src/mermaidAPI.spec.ts index dd8b3bbc81..f51bc0795a 100644 --- a/packages/mermaid/src/mermaidAPI.spec.ts +++ b/packages/mermaid/src/mermaidAPI.spec.ts @@ -1,4 +1,4 @@ -import { vi, it, expect, describe, beforeEach } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; // ------------------------------------- // Mocks and mocking @@ -66,8 +66,8 @@ vi.mock('stylis', () => { }); import { compile, serialize } from 'stylis'; -import { decodeEntities, encodeEntities } from './utils.js'; import { Diagram } from './Diagram.js'; +import { decodeEntities, encodeEntities } from './utils.js'; import { toBase64 } from './utils/base64.js'; /** @@ -693,18 +693,79 @@ describe('mermaidAPI', () => { await expect(mermaidAPI.parse('graph TD;A--x|text including URL space|B;')).resolves .toMatchInlineSnapshot(` { + "config": {}, "diagramType": "flowchart-v2", } `); }); + it('returns config when defined in frontmatter', async () => { + await expect( + mermaidAPI.parse(`--- +config: + theme: base + flowchart: + htmlLabels: true +--- +graph TD;A--x|text including URL space|B;`) + ).resolves.toMatchInlineSnapshot(` + { + "config": { + "flowchart": { + "htmlLabels": true, + }, + "theme": "base", + }, + "diagramType": "flowchart-v2", + } +`); + }); + + it('returns config when defined in directive', async () => { + await expect( + mermaidAPI.parse(`%%{init: { 'theme': 'base' } }%% +graph TD;A--x|text including URL space|B;`) + ).resolves.toMatchInlineSnapshot(` + { + "config": { + "theme": "base", + }, + "diagramType": "flowchart-v2", + } +`); + }); + + it('returns merged config when defined in frontmatter and directive', async () => { + await expect( + mermaidAPI.parse(`--- +config: + theme: forest + flowchart: + htmlLabels: true +--- +%%{init: { 'theme': 'base' } }%% +graph TD;A--x|text including URL space|B;`) + ).resolves.toMatchInlineSnapshot(` + { + "config": { + "flowchart": { + "htmlLabels": true, + }, + "theme": "base", + }, + "diagramType": "flowchart-v2", + } +`); + }); + it('returns true for valid definition with silent option', async () => { await expect( mermaidAPI.parse('graph TD;A--x|text including URL space|B;', { suppressErrors: true }) ).resolves.toMatchInlineSnapshot(` - { - "diagramType": "flowchart-v2", - } - `); + { + "config": {}, + "diagramType": "flowchart-v2", + } + `); }); }); diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts index 3fdd967f17..c44161a520 100644 --- a/packages/mermaid/src/mermaidAPI.ts +++ b/packages/mermaid/src/mermaidAPI.ts @@ -73,9 +73,9 @@ async function parse(text: string, parseOptions?: ParseOptions): Promise { addDiagrams(); try { - const { code } = processAndSetConfigs(text); + const { code, config } = processAndSetConfigs(text); const diagram = await getDiagramFromText(code); - return { diagramType: diagram.type }; + return { diagramType: diagram.type, config }; } catch (error) { if (parseOptions?.suppressErrors) { return false; diff --git a/packages/mermaid/src/types.ts b/packages/mermaid/src/types.ts index 9f4d772253..ae97bd69b0 100644 --- a/packages/mermaid/src/types.ts +++ b/packages/mermaid/src/types.ts @@ -1,3 +1,5 @@ +import type { MermaidConfig } from './config.type.js'; + export interface Point { x: number; y: number; @@ -48,6 +50,10 @@ export interface ParseResult { * The diagram type, e.g. 'flowchart', 'sequence', etc. */ diagramType: string; + /** + * The config passed as YAML frontmatter or directives + */ + config?: MermaidConfig; } // This makes it clear that we're working with a d3 selected element of some kind, even though it's hard to specify the exact type. export type D3Element = any; From 57d2d905efc0e87fbb49b312f0c5df1d5645f39f Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 6 Sep 2024 23:18:27 +0530 Subject: [PATCH 11/21] feat: Preview release --- .github/workflows/release-preview.yml | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/release-preview.yml diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml new file mode 100644 index 0000000000..1f54774ef7 --- /dev/null +++ b/.github/workflows/release-preview.yml @@ -0,0 +1,43 @@ +name: Preview release + +on: + pull_request: + branches: [develop] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.number }} + cancel-in-progress: true + +permissions: + contents: read + actions: write + +jobs: + preview: + if: | + ${{ github.repository_owner == 'mermaid-js' && github.event.issue.pull_request && contains(github.event.pull_request.labels.*.name, 'pr: preview') }} + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + issues: write + pull-requests: write + name: Publish preview release + timeout-minutes: 5 + steps: + - name: Checkout Repo + uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 + + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 + + - name: Setup Node.js + uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b # v4.0.3 + with: + cache: pnpm + node-version-file: '.node-version' + + - name: Install Packages + run: pnpm install --frozen-lockfile + + - name: Publish packages + run: pnpx pkg-pr-new publish --pnpm './packages/*' From 58524aceaae82efba209491f6ba0964435a0d780 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 6 Sep 2024 23:25:23 +0530 Subject: [PATCH 12/21] chore: Fix check --- .github/workflows/release-preview.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release-preview.yml b/.github/workflows/release-preview.yml index 1f54774ef7..283c316fbc 100644 --- a/.github/workflows/release-preview.yml +++ b/.github/workflows/release-preview.yml @@ -14,8 +14,7 @@ permissions: jobs: preview: - if: | - ${{ github.repository_owner == 'mermaid-js' && github.event.issue.pull_request && contains(github.event.pull_request.labels.*.name, 'pr: preview') }} + if: ${{ github.repository_owner == 'mermaid-js' }} runs-on: ubuntu-latest permissions: contents: read From 2879f3775be7eff3a07b3b88653f9535f1865b44 Mon Sep 17 00:00:00 2001 From: kairi003 Date: Sun, 8 Sep 2024 02:39:29 +0900 Subject: [PATCH 13/21] chore: add git command and set safe dir --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index fa933f999f..7be53d24ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,6 +5,9 @@ USER 0:0 RUN corepack enable \ && corepack enable pnpm +RUN apk add --no-cache git~=2.43.4 \ + && git config --add --system safe.directory /mermaid + ENV NODE_OPTIONS="--max_old_space_size=8192" EXPOSE 9000 3333 From 571dfda62913c5f0417fd4ce396ea23f55328c61 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Sun, 8 Sep 2024 12:47:19 -0500 Subject: [PATCH 14/21] replace mermaid/dist with relative paths --- .../src/diagrams/architecture/architectureIcons.ts | 2 +- .../diagrams/architecture/architectureRenderer.ts | 2 +- .../mermaid/src/diagrams/architecture/svgDraw.ts | 2 +- packages/mermaid/src/mermaid.ts | 2 +- packages/mermaid/src/rendering-util/createText.ts | 4 ++-- packages/mermaid/src/rendering-util/icons.ts | 2 +- .../layout-algorithms/dagre/index.js | 2 +- .../layout-algorithms/dagre/mermaid-graphlib.js | 2 +- .../dagre/mermaid-graphlib.spec.js | 2 +- packages/mermaid/src/rendering-util/render.ts | 8 ++++---- .../rendering-util/rendering-elements/clusters.js | 10 +++++----- .../rendering-elements/createLabel.js | 8 ++++---- .../rendering-elements/edgeMarker.spec.ts | 2 +- .../rendering-elements/edgeMarker.ts | 6 +++--- .../src/rendering-util/rendering-elements/edges.js | 14 +++++++------- .../rendering-util/rendering-elements/markers.js | 2 +- .../src/rendering-util/rendering-elements/nodes.js | 4 ++-- .../rendering-elements/shapes/choice.ts | 6 +++--- .../rendering-elements/shapes/circle.ts | 6 +++--- .../rendering-elements/shapes/cylinder.ts | 4 ++-- .../rendering-elements/shapes/doubleCircle.ts | 6 +++--- .../rendering-elements/shapes/drawRect.ts | 4 ++-- .../rendering-elements/shapes/forkJoin.ts | 6 +++--- .../shapes/handDrawnShapeStyles.ts | 4 ++-- .../rendering-elements/shapes/hexagon.ts | 4 ++-- .../rendering-elements/shapes/invertedTrapezoid.ts | 4 ++-- .../rendering-elements/shapes/labelRect.ts | 2 +- .../rendering-elements/shapes/leanLeft.ts | 4 ++-- .../rendering-elements/shapes/leanRight.ts | 4 ++-- .../rendering-elements/shapes/note.ts | 6 +++--- .../rendering-elements/shapes/question.ts | 6 +++--- .../rendering-elements/shapes/rectLeftInvArrow.ts | 4 ++-- .../rendering-elements/shapes/rectWithTitle.ts | 10 +++++----- .../rendering-elements/shapes/roundedRect.ts | 2 +- .../rendering-elements/shapes/squareRect.ts | 2 +- .../rendering-elements/shapes/stadium.ts | 4 ++-- .../rendering-elements/shapes/state.ts | 2 +- .../rendering-elements/shapes/stateEnd.ts | 6 +++--- .../rendering-elements/shapes/stateStart.ts | 6 +++--- .../rendering-elements/shapes/subroutine.ts | 4 ++-- .../rendering-elements/shapes/trapezoid.ts | 4 ++-- .../rendering-elements/shapes/util.js | 8 ++++---- .../src/rendering-util/setupViewPortForSVG.ts | 6 +++--- vite.config.ts | 8 +------- 44 files changed, 100 insertions(+), 106 deletions(-) diff --git a/packages/mermaid/src/diagrams/architecture/architectureIcons.ts b/packages/mermaid/src/diagrams/architecture/architectureIcons.ts index bf6bfd4f1c..fac4a7b122 100644 --- a/packages/mermaid/src/diagrams/architecture/architectureIcons.ts +++ b/packages/mermaid/src/diagrams/architecture/architectureIcons.ts @@ -1,4 +1,4 @@ -import { unknownIcon } from 'mermaid/dist/rendering-util/icons.js'; +import { unknownIcon } from '../../rendering-util/icons.js'; import type { IconifyJSON } from '@iconify/types'; const wrapIcon = (icon: string) => { diff --git a/packages/mermaid/src/diagrams/architecture/architectureRenderer.ts b/packages/mermaid/src/diagrams/architecture/architectureRenderer.ts index f7dcd325ce..af94295392 100644 --- a/packages/mermaid/src/diagrams/architecture/architectureRenderer.ts +++ b/packages/mermaid/src/diagrams/architecture/architectureRenderer.ts @@ -1,4 +1,4 @@ -import { registerIconPacks } from 'mermaid/dist/rendering-util/icons.js'; +import { registerIconPacks } from '../../rendering-util/icons.js'; import type { Position } from 'cytoscape'; import cytoscape from 'cytoscape'; import type { FcoseLayoutOptions } from 'cytoscape-fcose'; diff --git a/packages/mermaid/src/diagrams/architecture/svgDraw.ts b/packages/mermaid/src/diagrams/architecture/svgDraw.ts index 0a4a44d9cd..b10a451fea 100644 --- a/packages/mermaid/src/diagrams/architecture/svgDraw.ts +++ b/packages/mermaid/src/diagrams/architecture/svgDraw.ts @@ -1,4 +1,4 @@ -import { getIconSVG } from 'mermaid/dist/rendering-util/icons.js'; +import { getIconSVG } from '../../rendering-util/icons.js'; import type cytoscape from 'cytoscape'; import { getConfig } from '../../diagram-api/diagramAPI.js'; import { createText } from '../../rendering-util/createText.js'; diff --git a/packages/mermaid/src/mermaid.ts b/packages/mermaid/src/mermaid.ts index 6a7efb3754..e9fc9196aa 100644 --- a/packages/mermaid/src/mermaid.ts +++ b/packages/mermaid/src/mermaid.ts @@ -2,7 +2,7 @@ * Web page integration module for the mermaid framework. It uses the mermaidAPI for mermaid * functionality and to render the diagrams to svg code! */ -import { registerIconPacks } from 'mermaid/dist/rendering-util/icons.js'; +import { registerIconPacks } from './rendering-util/icons.js'; import { dedent } from 'ts-dedent'; import type { MermaidConfig } from './config.type.js'; import { detectType, registerLazyLoadedDiagrams } from './diagram-api/detectType.js'; diff --git a/packages/mermaid/src/rendering-util/createText.ts b/packages/mermaid/src/rendering-util/createText.ts index 0a205ea317..845705210f 100644 --- a/packages/mermaid/src/rendering-util/createText.ts +++ b/packages/mermaid/src/rendering-util/createText.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ // @ts-nocheck TODO: Fix types -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; -import common, { hasKatex, renderKatex } from 'mermaid/dist/diagrams/common/common.js'; +import { getConfig } from '../diagram-api/diagramAPI.js'; +import common, { hasKatex, renderKatex } from '../diagrams/common/common.js'; import { select } from 'd3'; import type { MermaidConfig } from '../config.type.js'; import type { SVGGroup } from '../diagram-api/types.js'; diff --git a/packages/mermaid/src/rendering-util/icons.ts b/packages/mermaid/src/rendering-util/icons.ts index d08d55f430..5eef3f7eb3 100644 --- a/packages/mermaid/src/rendering-util/icons.ts +++ b/packages/mermaid/src/rendering-util/icons.ts @@ -1,4 +1,4 @@ -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../logger.js'; import type { ExtendedIconifyIcon, IconifyIcon, IconifyJSON } from '@iconify/types'; import type { IconifyIconCustomisations } from '@iconify/utils'; import { getIconData, iconToHTML, iconToSVG, replaceIDs, stringToIcon } from '@iconify/utils'; diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js index afd1f4a9c9..9367a65a54 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js +++ b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/index.js @@ -23,7 +23,7 @@ import { insertEdge, clear as clearEdges, } from '../../rendering-elements/edges.js'; -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../../logger.js'; import { getSubGraphTitleMargins } from '../../../utils/subGraphTitleMargins.js'; import { getConfig } from '../../../diagram-api/diagramAPI.js'; diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js index 0cde897ae7..f0e5cd5ed9 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js +++ b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.js @@ -1,5 +1,5 @@ /** Decorates with functions required by mermaids dagre-wrapper. */ -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../../logger.js'; import * as graphlib from 'dagre-d3-es/src/graphlib/index.js'; import * as graphlibJson from 'dagre-d3-es/src/graphlib/json.js'; diff --git a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js index 545a35a928..11acd44eb1 100644 --- a/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js +++ b/packages/mermaid/src/rendering-util/layout-algorithms/dagre/mermaid-graphlib.spec.js @@ -6,7 +6,7 @@ import { extractDescendants, sortNodesByHierarchy, } from './mermaid-graphlib.js'; -import { setLogLevel, log } from 'mermaid/dist/logger.js'; +import { setLogLevel, log } from '../../../logger.js'; describe('Graphlib decorations', () => { let g; diff --git a/packages/mermaid/src/rendering-util/render.ts b/packages/mermaid/src/rendering-util/render.ts index 8306bc15a0..b975e7bf97 100644 --- a/packages/mermaid/src/rendering-util/render.ts +++ b/packages/mermaid/src/rendering-util/render.ts @@ -1,7 +1,7 @@ -import type { SVG } from 'mermaid/dist/diagram-api/types.js'; -import type { InternalHelpers } from 'mermaid/dist/internals.js'; -import { internalHelpers } from 'mermaid/dist/internals.js'; -import { log } from 'mermaid/dist/logger.js'; +import type { SVG } from '../diagram-api/types.js'; +import type { InternalHelpers } from '../internals.js'; +import { internalHelpers } from '../internals.js'; +import { log } from '../logger.js'; import type { LayoutData } from './types.js'; export interface RenderOptions { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js index a963bba9b8..c5fd0a91d8 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js @@ -1,7 +1,7 @@ -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; -import { evaluate } from 'mermaid/dist/diagrams/common/common.js'; -import { log } from 'mermaid/dist/logger.js'; -import { getSubGraphTitleMargins } from 'mermaid/dist/utils/subGraphTitleMargins.js'; +import { getConfig } from '../../diagram-api/diagramAPI.js'; +import { evaluate } from '../../diagrams/common/common.js'; +import { log } from '../../logger.js'; +import { getSubGraphTitleMargins } from '../../utils/subGraphTitleMargins.js'; import { select } from 'd3'; import rough from 'roughjs'; import { createText } from '../createText.ts'; @@ -11,7 +11,7 @@ import { createRoundedRectPathD } from './shapes/roundedRectPath.ts'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './shapes/handDrawnShapeStyles.js'; const rect = async (parent, node) => { log.info('Creating subgraph rect for ', node.id, node); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/createLabel.js b/packages/mermaid/src/rendering-util/rendering-elements/createLabel.js index 2d560e85da..482dbb9f13 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/createLabel.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/createLabel.js @@ -1,8 +1,8 @@ import { select } from 'd3'; -import { log } from 'mermaid/dist/logger.js'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; -import common, { evaluate, renderKatex, hasKatex } from 'mermaid/dist/diagrams/common/common.js'; -import { decodeEntities } from 'mermaid/dist/utils.js'; +import { log } from '../../logger.js'; +import { getConfig } from '../../diagram-api/diagramAPI.js'; +import common, { evaluate, renderKatex, hasKatex } from '../../diagrams/common/common.js'; +import { decodeEntities } from '../../utils.js'; /** * @param dom diff --git a/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.spec.ts b/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.spec.ts index 313dc1d018..7702782c21 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.spec.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.spec.ts @@ -1,5 +1,5 @@ /* eslint-disable @typescript-eslint/unbound-method */ -import type { SVG } from 'mermaid/dist/diagram-api/types.js'; +import type { SVG } from '../../diagram-api/types.js'; import type { Mocked } from 'vitest'; import { addEdgeMarkers } from './edgeMarker.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.ts b/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.ts index 032b3989c1..5371ac32d1 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/edgeMarker.ts @@ -1,6 +1,6 @@ -import type { SVG } from 'mermaid/dist/diagram-api/types.js'; -import { log } from 'mermaid/dist/logger.js'; -import type { EdgeData } from 'mermaid/dist/types.js'; +import type { SVG } from '../../diagram-api/types.js'; +import { log } from '../../logger.js'; +import type { EdgeData } from '../../types.js'; /** * Adds SVG markers to a path element based on the arrow types specified in the edge. * diff --git a/packages/mermaid/src/rendering-util/rendering-elements/edges.js b/packages/mermaid/src/rendering-util/rendering-elements/edges.js index 999dc3d1cc..41368ee1e2 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/edges.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/edges.js @@ -1,10 +1,10 @@ -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; -import { evaluate } from 'mermaid/dist/diagrams/common/common.js'; -import { log } from 'mermaid/dist/logger.js'; -import { createText } from 'mermaid/dist/rendering-util/createText.ts'; -import utils from 'mermaid/dist/utils.js'; -import { getLineFunctionsWithOffset } from 'mermaid/dist/utils/lineWithOffset.js'; -import { getSubGraphTitleMargins } from 'mermaid/dist/utils/subGraphTitleMargins.js'; +import { getConfig } from '../../diagram-api/diagramAPI.js'; +import { evaluate } from '../../diagrams/common/common.js'; +import { log } from '../../logger.js'; +import { createText } from '../createText.js'; +import utils from '../../utils.js'; +import { getLineFunctionsWithOffset } from '../../utils/lineWithOffset.js'; +import { getSubGraphTitleMargins } from '../../utils/subGraphTitleMargins.js'; import { curveBasis, line, select } from 'd3'; import rough from 'roughjs'; import createLabel from './createLabel.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/markers.js b/packages/mermaid/src/rendering-util/rendering-elements/markers.js index b9494c4c1a..b2592e20ec 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/markers.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/markers.js @@ -1,5 +1,5 @@ /** Setup arrow head and define the marker. The result is appended to the svg. */ -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../logger.js'; // Only add the number of markers that the diagram needs const insertMarkers = (elem, markerArray, type, id) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/nodes.js b/packages/mermaid/src/rendering-util/rendering-elements/nodes.js index 830639f0c7..2f69a36bcd 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/nodes.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/nodes.js @@ -1,4 +1,4 @@ -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../logger.js'; import { state } from './shapes/state.ts'; import { roundedRect } from './shapes/roundedRect.ts'; import { squareRect } from './shapes/squareRect.ts'; @@ -9,7 +9,7 @@ import { choice } from './shapes/choice.ts'; import { note } from './shapes/note.ts'; import { stadium } from './shapes/stadium.js'; import { rectWithTitle } from './shapes/rectWithTitle.js'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { getConfig } from '../../diagram-api/diagramAPI.js'; import { subroutine } from './shapes/subroutine.js'; import { cylinder } from './shapes/cylinder.js'; import { circle } from './shapes/circle.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/choice.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/choice.ts index 9b99b8e7f2..000d627cf3 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/choice.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/choice.ts @@ -1,10 +1,10 @@ import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; -import type { SVG } from 'mermaid/dist/diagram-api/types.js'; +import type { Node } from '../../types.js'; +import type { SVG } from '../../../diagram-api/types.js'; // @ts-ignore TODO: Fix rough typings import rough from 'roughjs'; import { solidStateFill, styles2String } from './handDrawnShapeStyles.js'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { getConfig } from '../../../diagram-api/diagramAPI.js'; export const choice = (parent: SVG, node: Node) => { const { labelStyles, nodeStyles } = styles2String(node); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts index 3c301a0255..601bc7a0f1 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts @@ -1,11 +1,11 @@ -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../../logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; export const circle = async (parent: SVGAElement, node: Node): Promise => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts index c92b40138b..c1181c4e15 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; export const createCylinderPathD = ( diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts index 8672ffbfff..d83b48514d 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts @@ -1,11 +1,11 @@ -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../../logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; export const doublecircle = async (parent: SVGAElement, node: Node): Promise => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts index e9643ba4f5..41ec14c265 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts @@ -1,11 +1,11 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node, RectOptions } from '../../types.js'; import { createRoundedRectPathD } from './roundedRectPath.js'; import { userNodeOverrides, styles2String, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; export const drawRect = async (parent: SVGAElement, node: Node, options: RectOptions) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/forkJoin.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/forkJoin.ts index 324bb31343..b2dead73e8 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/forkJoin.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/forkJoin.ts @@ -1,10 +1,10 @@ import { updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; -import type { SVG } from 'mermaid/dist/diagram-api/types.js'; +import type { Node } from '../../types.js'; +import type { SVG } from '../../../diagram-api/types.js'; import rough from 'roughjs'; import { solidStateFill } from './handDrawnShapeStyles.js'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { getConfig } from '../../../diagram-api/diagramAPI.js'; export const forkJoin = (parent: SVG, node: Node, dir: string) => { const { themeVariables } = getConfig(); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts index d764527d83..99edc4874e 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts @@ -1,5 +1,5 @@ -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import { getConfig } from '../../../diagram-api/diagramAPI.js'; +import type { Node } from '../../types.js'; // Striped fill like start or fork nodes in state diagrams export const solidStateFill = (color: string) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts index 5a1197c51a..a8242ce50b 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts index 5a8bf9765a..f4654e4eb8 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts index 51605eae49..852f33e8a6 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/labelRect.ts @@ -1,4 +1,4 @@ -import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node, RectOptions } from '../../types.js'; import { drawRect } from './drawRect.js'; import { labelHelper, updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts index 8e06096f1d..54467a4833 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts index b4c1ae7053..90257086fc 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/note.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/note.ts index a567c33128..d337c85d46 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/note.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/note.ts @@ -1,8 +1,8 @@ -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../../logger.js'; import { labelHelper, updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import { getConfig } from '../../../diagram-api/diagramAPI.js'; +import type { Node } from '../../types.js'; import rough from 'roughjs'; export const note = async (parent: SVGAElement, node: Node) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts index b3eed0f665..765e5c129c 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts @@ -1,11 +1,11 @@ -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../../logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts index 4d7611331c..899dc8d6eb 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts index 27ef201ee6..db9804c550 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts @@ -1,17 +1,17 @@ -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { select } from 'd3'; -import { evaluate } from 'mermaid/dist/diagrams/common/common.js'; +import { evaluate } from '../../../diagrams/common/common.js'; import { updateNodeBounds } from './util.js'; import createLabel from '../createLabel.js'; import intersect from '../intersect/index.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { getConfig } from '../../../diagram-api/diagramAPI.js'; import { createRoundedRectPathD } from './roundedRectPath.js'; -import { log } from 'mermaid/dist/logger.js'; +import { log } from '../../../logger.js'; export const rectWithTitle = async (parent: SVGElement, node: Node) => { const { labelStyles, nodeStyles } = styles2String(node); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/roundedRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/roundedRect.ts index 5342965872..ab31a510e2 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/roundedRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/roundedRect.ts @@ -1,4 +1,4 @@ -import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node, RectOptions } from '../../types.js'; import { drawRect } from './drawRect.js'; export const roundedRect = async (parent: SVGAElement, node: Node) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/squareRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/squareRect.ts index 2070e6a149..5ab8e2833a 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/squareRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/squareRect.ts @@ -1,4 +1,4 @@ -import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node, RectOptions } from '../../types.js'; import { drawRect } from './drawRect.js'; export const squareRect = async (parent: SVGAElement, node: Node) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts index bc42d5e6fd..0363bba7df 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { createRoundedRectPathD } from './roundedRectPath.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/state.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/state.ts index 06cbc636f2..7341947378 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/state.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/state.ts @@ -1,4 +1,4 @@ -import type { Node, RectOptions } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node, RectOptions } from '../../types.js'; import { drawRect } from './drawRect.js'; export const state = async (parent: SVGAElement, node: Node) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateEnd.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateEnd.ts index 57f3916574..fde5b03679 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateEnd.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateEnd.ts @@ -1,10 +1,10 @@ import { updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; -import type { SVG } from 'mermaid/dist/diagram-api/types.js'; +import type { Node } from '../../types.js'; +import type { SVG } from '../../../diagram-api/types.js'; import rough from 'roughjs'; import { solidStateFill } from './handDrawnShapeStyles.js'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { getConfig } from '../../../diagram-api/diagramAPI.js'; export const stateEnd = (parent: SVG, node: Node) => { const { themeVariables } = getConfig(); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts index f8d0e084d8..30d606a847 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stateStart.ts @@ -1,10 +1,10 @@ import { updateNodeBounds } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; -import type { SVG } from 'mermaid/dist/diagram-api/types.js'; +import type { Node } from '../../types.js'; +import type { SVG } from '../../../diagram-api/types.js'; import rough from 'roughjs'; import { solidStateFill } from './handDrawnShapeStyles.js'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { getConfig } from '../../../diagram-api/diagramAPI.js'; export const stateStart = (parent: SVG, node: Node) => { const { themeVariables } = getConfig(); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts index fbfa3ed5cd..b77e533ede 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts index 701747c1c1..0629badde2 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts @@ -1,10 +1,10 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; -import type { Node } from 'mermaid/dist/rendering-util/types.d.ts'; +import type { Node } from '../../types.js'; import { styles2String, userNodeOverrides, -} from 'mermaid/dist/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.js'; +} from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.js b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.js index 633171d5ca..2b6a8c2f63 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/util.js @@ -1,8 +1,8 @@ -import { createText } from 'mermaid/dist/rendering-util/createText.ts'; -import { getConfig } from 'mermaid/dist/diagram-api/diagramAPI.js'; +import { createText } from '../../createText.js'; +import { getConfig } from '../../../diagram-api/diagramAPI.js'; import { select } from 'd3'; -import { evaluate, sanitizeText } from 'mermaid/dist/diagrams/common/common.js'; -import { decodeEntities } from 'mermaid/dist/utils.js'; +import { evaluate, sanitizeText } from '../../../diagrams/common/common.js'; +import { decodeEntities } from '../../../utils.js'; export const labelHelper = async (parent, node, _classes) => { let cssClasses; diff --git a/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts b/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts index 00d8080667..d3df5ddb7a 100644 --- a/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts +++ b/packages/mermaid/src/rendering-util/setupViewPortForSVG.ts @@ -1,6 +1,6 @@ -import { configureSvgSize } from 'mermaid/dist/setupGraphViewbox.js'; -import type { SVG } from 'mermaid/dist/diagram-api/types.js'; -import { log } from 'mermaid/dist/logger.js'; +import { configureSvgSize } from '../setupGraphViewbox.js'; +import type { SVG } from '../diagram-api/types.js'; +import { log } from '../logger.js'; export const setupViewPortForSVG = ( svg: SVG, diff --git a/vite.config.ts b/vite.config.ts index 2db66b7a40..16d5801d2b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -2,16 +2,10 @@ import jison from './.vite/jisonPlugin.js'; import jsonSchemaPlugin from './.vite/jsonSchemaPlugin.js'; import typescript from '@rollup/plugin-typescript'; import { defaultExclude, defineConfig } from 'vitest/config'; -import path from 'path'; export default defineConfig({ resolve: { - extensions: ['.js'], - alias: { - // Define your alias here - 'mermaid/dist': path.resolve(__dirname, 'packages/mermaid/src'), - }, - }, + extensions: ['.js'] }, plugins: [ jison(), jsonSchemaPlugin(), // handles .schema.yaml JSON Schema files From 94deacb1b56a2777c4777f2f540e39d132641014 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Sun, 8 Sep 2024 12:48:41 -0500 Subject: [PATCH 15/21] linting --- .../src/rendering-util/rendering-elements/clusters.js | 5 +---- .../src/rendering-util/rendering-elements/shapes/circle.ts | 5 +---- .../src/rendering-util/rendering-elements/shapes/cylinder.ts | 5 +---- .../rendering-util/rendering-elements/shapes/doubleCircle.ts | 5 +---- .../src/rendering-util/rendering-elements/shapes/drawRect.ts | 5 +---- .../src/rendering-util/rendering-elements/shapes/hexagon.ts | 5 +---- .../rendering-elements/shapes/invertedTrapezoid.ts | 5 +---- .../src/rendering-util/rendering-elements/shapes/leanLeft.ts | 5 +---- .../rendering-util/rendering-elements/shapes/leanRight.ts | 5 +---- .../src/rendering-util/rendering-elements/shapes/question.ts | 5 +---- .../rendering-elements/shapes/rectLeftInvArrow.ts | 5 +---- .../rendering-elements/shapes/rectWithTitle.ts | 5 +---- .../src/rendering-util/rendering-elements/shapes/stadium.ts | 5 +---- .../rendering-util/rendering-elements/shapes/subroutine.ts | 5 +---- .../rendering-util/rendering-elements/shapes/trapezoid.ts | 5 +---- vite.config.ts | 3 ++- 16 files changed, 17 insertions(+), 61 deletions(-) diff --git a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js index c5fd0a91d8..a62a920136 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/clusters.js +++ b/packages/mermaid/src/rendering-util/rendering-elements/clusters.js @@ -8,10 +8,7 @@ import { createText } from '../createText.ts'; import intersectRect from '../rendering-elements/intersect/intersect-rect.js'; import createLabel from './createLabel.js'; import { createRoundedRectPathD } from './shapes/roundedRectPath.ts'; -import { - styles2String, - userNodeOverrides, -} from './shapes/handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './shapes/handDrawnShapeStyles.js'; const rect = async (parent, node) => { log.info('Creating subgraph rect for ', node.id, node); diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts index 601bc7a0f1..1e67cee8f3 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/circle.ts @@ -2,10 +2,7 @@ import { log } from '../../../logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; export const circle = async (parent: SVGAElement, node: Node): Promise => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts index c1181c4e15..237239171b 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/cylinder.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; export const createCylinderPathD = ( diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts index d83b48514d..44e357b029 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/doubleCircle.ts @@ -2,10 +2,7 @@ import { log } from '../../../logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; export const doublecircle = async (parent: SVGAElement, node: Node): Promise => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts index 41ec14c265..36816fa154 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/drawRect.ts @@ -2,10 +2,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node, RectOptions } from '../../types.js'; import { createRoundedRectPathD } from './roundedRectPath.js'; -import { - userNodeOverrides, - styles2String, -} from './handDrawnShapeStyles.js'; +import { userNodeOverrides, styles2String } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; export const drawRect = async (parent: SVGAElement, node: Node, options: RectOptions) => { diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts index a8242ce50b..faf6b4e170 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/hexagon.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts index f4654e4eb8..92ad1145c4 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/invertedTrapezoid.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts index 54467a4833..bd06854d8f 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanLeft.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts index 90257086fc..63b55b3648 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/leanRight.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts index 765e5c129c..d571e49274 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/question.ts @@ -2,10 +2,7 @@ import { log } from '../../../logger.js'; import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts index 899dc8d6eb..767e46a3fd 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectLeftInvArrow.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts index db9804c550..a71ebabd72 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/rectWithTitle.ts @@ -4,10 +4,7 @@ import { evaluate } from '../../../diagrams/common/common.js'; import { updateNodeBounds } from './util.js'; import createLabel from '../createLabel.js'; import intersect from '../intersect/index.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { getConfig } from '../../../diagram-api/diagramAPI.js'; import { createRoundedRectPathD } from './roundedRectPath.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts index 0363bba7df..78904e84cf 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/stadium.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { createRoundedRectPathD } from './roundedRectPath.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts index b77e533ede..32a0634cf3 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/subroutine.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts b/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts index 0629badde2..fc5a6d87fb 100644 --- a/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts +++ b/packages/mermaid/src/rendering-util/rendering-elements/shapes/trapezoid.ts @@ -1,10 +1,7 @@ import { labelHelper, updateNodeBounds, getNodeClasses } from './util.js'; import intersect from '../intersect/index.js'; import type { Node } from '../../types.js'; -import { - styles2String, - userNodeOverrides, -} from './handDrawnShapeStyles.js'; +import { styles2String, userNodeOverrides } from './handDrawnShapeStyles.js'; import rough from 'roughjs'; import { insertPolygonShape } from './insertPolygonShape.js'; diff --git a/vite.config.ts b/vite.config.ts index 16d5801d2b..fb31841d6f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,7 +5,8 @@ import { defaultExclude, defineConfig } from 'vitest/config'; export default defineConfig({ resolve: { - extensions: ['.js'] }, + extensions: ['.js'], + }, plugins: [ jison(), jsonSchemaPlugin(), // handles .schema.yaml JSON Schema files From fd3c3fc022d97669a196b45b470d1bc7c3ddd742 Mon Sep 17 00:00:00 2001 From: Nicholas Bollweg Date: Sun, 8 Sep 2024 13:57:56 -0500 Subject: [PATCH 16/21] remove tsconfig compiler option paths --- packages/mermaid/tsconfig.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/mermaid/tsconfig.json b/packages/mermaid/tsconfig.json index 3c7ed2b5e5..66c6600f63 100644 --- a/packages/mermaid/tsconfig.json +++ b/packages/mermaid/tsconfig.json @@ -3,11 +3,7 @@ "compilerOptions": { "rootDir": "./src", "outDir": "./dist", - "types": ["vitest/importMeta", "vitest/globals"], - "baseUrl": ".", // This must be set if "paths" is set - "paths": { - "mermaid/dist/*": ["src/*"] - } + "types": ["vitest/importMeta", "vitest/globals"] }, "include": [ "./src/**/*.ts", From b830e6151bff1c6bb2b515ef609c6251794115c4 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 00:15:23 +0000 Subject: [PATCH 17/21] chore(deps): update dependency eslint-plugin-jsdoc to v50 --- package.json | 2 +- pnpm-lock.yaml | 179 ++++--------------------------------------------- 2 files changed, 14 insertions(+), 167 deletions(-) diff --git a/package.json b/package.json index 5683b6ed98..9e79d49e62 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "eslint-plugin-cypress": "^3.3.0", "eslint-plugin-html": "^8.1.1", "eslint-plugin-jest": "^28.6.0", - "eslint-plugin-jsdoc": "^48.2.9", + "eslint-plugin-jsdoc": "^50.0.0", "eslint-plugin-json": "^4.0.0", "eslint-plugin-lodash": "^8.0.0", "eslint-plugin-markdown": "^5.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7fcdbb5f3f..e424b07b43 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -111,8 +111,8 @@ importers: specifier: ^28.6.0 version: 28.7.0(@typescript-eslint/eslint-plugin@8.0.1(@typescript-eslint/parser@8.0.1(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(typescript@5.4.5))(eslint@9.8.0)(jest@29.7.0(@types/node@20.16.2))(typescript@5.4.5) eslint-plugin-jsdoc: - specifier: ^48.2.9 - version: 48.11.0(eslint@9.8.0) + specifier: ^50.0.0 + version: 50.2.2(eslint@9.8.0) eslint-plugin-json: specifier: ^4.0.0 version: 4.0.1 @@ -503,67 +503,6 @@ importers: specifier: ^7.0.0 version: 7.1.0 - packages/mermaid/src/vitepress: - dependencies: - '@mdi/font': - specifier: ^7.0.0 - version: 7.4.47 - '@vueuse/core': - specifier: ^10.9.0 - version: 10.11.1(vue@3.4.38(typescript@5.4.5)) - font-awesome: - specifier: ^4.7.0 - version: 4.7.0 - jiti: - specifier: ^1.21.0 - version: 1.21.6 - mermaid: - specifier: workspace:^ - version: link:../.. - vue: - specifier: ^3.4.21 - version: 3.4.38(typescript@5.4.5) - devDependencies: - '@iconify-json/carbon': - specifier: ^1.1.31 - version: 1.1.37 - '@unocss/reset': - specifier: ^0.59.0 - version: 0.59.4 - '@vite-pwa/vitepress': - specifier: ^0.4.0 - version: 0.4.0(vite-plugin-pwa@0.19.8(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0)) - '@vitejs/plugin-vue': - specifier: ^5.0.0 - version: 5.1.2(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(vue@3.4.38(typescript@5.4.5)) - fast-glob: - specifier: ^3.3.2 - version: 3.3.2 - https-localhost: - specifier: ^4.7.1 - version: 4.7.1 - pathe: - specifier: ^1.1.2 - version: 1.1.2 - unocss: - specifier: ^0.59.0 - version: 0.59.4(postcss@8.4.41)(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)) - unplugin-vue-components: - specifier: ^0.26.0 - version: 0.26.0(@babel/parser@7.25.4)(rollup@4.21.1)(vue@3.4.38(typescript@5.4.5)) - vite: - specifier: ^5.0.0 - version: 5.4.2(@types/node@22.5.1)(terser@5.31.6) - vite-plugin-pwa: - specifier: ^0.19.7 - version: 0.19.8(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) - vitepress: - specifier: 1.1.4 - version: 1.1.4(@algolia/client-search@4.24.0)(@types/node@22.5.1)(axios@1.7.5)(postcss@8.4.41)(search-insights@2.15.0)(terser@5.31.6)(typescript@5.4.5) - workbox-window: - specifier: ^7.0.0 - version: 7.1.0 - packages/parser: dependencies: langium: @@ -1871,8 +1810,8 @@ packages: '@emnapi/runtime@1.2.0': resolution: {integrity: sha512-bV21/9LQmcQeCPEg3BDFtvwL6cwiTMksYNWQQ4KOxCZikEGalWtenoZ0wCiukJINlGCIi2KXx01g4FoH/LxpzQ==} - '@es-joy/jsdoccomment@0.46.0': - resolution: {integrity: sha512-C3Axuq1xd/9VqFZpW4YAzOx5O9q/LP46uIQy/iNDpHG3fmPa6TBtvfglMCs3RBiBxAIi0Go97r8+jvTt55XMyQ==} + '@es-joy/jsdoccomment@0.48.0': + resolution: {integrity: sha512-G6QUWIcC+KvSwXNsJyDTHvqUdNoAVJPPgkc3+Uk4WBKqZvoXhlvazOgm9aL0HwihJLQf0l+tOE2UFzXBqCqgDw==} engines: {node: '>=16'} '@esbuild/aix-ppc64@0.21.5': @@ -5013,8 +4952,8 @@ packages: jest: optional: true - eslint-plugin-jsdoc@48.11.0: - resolution: {integrity: sha512-d12JHJDPNo7IFwTOAItCeJY1hcqoIxE0lHA8infQByLilQ9xkqrRa6laWCnsuCrf+8rUnvxXY1XuTbibRBNylA==} + eslint-plugin-jsdoc@50.2.2: + resolution: {integrity: sha512-i0ZMWA199DG7sjxlzXn5AeYZxpRfMJjDPUl7lL9eJJX8TPRoIaxJU4ys/joP5faM5AXE1eqW/dslCj3uj4Nqpg==} engines: {node: '>=18'} peerDependencies: eslint: ^7.0.0 || ^8.0.0 || ^9.0.0 @@ -6329,8 +6268,8 @@ packages: jsbn@0.1.1: resolution: {integrity: sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==} - jsdoc-type-pratt-parser@4.0.0: - resolution: {integrity: sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==} + jsdoc-type-pratt-parser@4.1.0: + resolution: {integrity: sha512-Hicd6JK5Njt2QB6XYFS7ok9e37O8AYk3jTcppG4YVQnYjOemymvTcmc7OWsmq/Qqj5TdRFO5/x/tIPmBeRtGHg==} engines: {node: '>=12.0.0'} jsdom@24.1.3: @@ -11072,11 +11011,11 @@ snapshots: tslib: 2.7.0 optional: true - '@es-joy/jsdoccomment@0.46.0': + '@es-joy/jsdoccomment@0.48.0': dependencies: comment-parser: 1.4.1 esquery: 1.6.0 - jsdoc-type-pratt-parser: 4.0.0 + jsdoc-type-pratt-parser: 4.1.0 '@esbuild/aix-ppc64@0.21.5': optional: true @@ -12389,16 +12328,6 @@ snapshots: transitivePeerDependencies: - rollup - '@unocss/astro@0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))': - dependencies: - '@unocss/core': 0.59.4 - '@unocss/reset': 0.59.4 - '@unocss/vite': 0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)) - optionalDependencies: - vite: 5.4.2(@types/node@22.5.1)(terser@5.31.6) - transitivePeerDependencies: - - rollup - '@unocss/cli@0.59.4(rollup@2.79.1)': dependencies: '@ampproject/remapping': 2.3.0 @@ -12417,24 +12346,6 @@ snapshots: transitivePeerDependencies: - rollup - '@unocss/cli@0.59.4(rollup@4.21.1)': - dependencies: - '@ampproject/remapping': 2.3.0 - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) - '@unocss/config': 0.59.4 - '@unocss/core': 0.59.4 - '@unocss/preset-uno': 0.59.4 - cac: 6.7.14 - chokidar: 3.6.0 - colorette: 2.0.20 - consola: 3.2.3 - fast-glob: 3.3.2 - magic-string: 0.30.11 - pathe: 1.1.2 - perfect-debounce: 1.0.0 - transitivePeerDependencies: - - rollup - '@unocss/config@0.59.4': dependencies: '@unocss/core': 0.59.4 @@ -12560,22 +12471,6 @@ snapshots: transitivePeerDependencies: - rollup - '@unocss/vite@0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))': - dependencies: - '@ampproject/remapping': 2.3.0 - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) - '@unocss/config': 0.59.4 - '@unocss/core': 0.59.4 - '@unocss/inspector': 0.59.4 - '@unocss/scope': 0.59.4 - '@unocss/transformer-directives': 0.59.4 - chokidar: 3.6.0 - fast-glob: 3.3.2 - magic-string: 0.30.11 - vite: 5.4.2(@types/node@22.5.1)(terser@5.31.6) - transitivePeerDependencies: - - rollup - '@vite-pwa/vitepress@0.4.0(vite-plugin-pwa@0.19.8(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0))': dependencies: vite-plugin-pwa: 0.19.8(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6))(workbox-build@7.1.1(@types/babel__core@7.20.5))(workbox-window@7.1.0) @@ -14694,9 +14589,9 @@ snapshots: - supports-color - typescript - eslint-plugin-jsdoc@48.11.0(eslint@9.8.0): + eslint-plugin-jsdoc@50.2.2(eslint@9.8.0): dependencies: - '@es-joy/jsdoccomment': 0.46.0 + '@es-joy/jsdoccomment': 0.48.0 are-docs-informative: 0.0.2 comment-parser: 1.4.1 debug: 4.3.6(supports-color@8.1.1) @@ -16347,7 +16242,7 @@ snapshots: jsbn@0.1.1: {} - jsdoc-type-pratt-parser@4.0.0: {} + jsdoc-type-pratt-parser@4.1.0: {} jsdom@24.1.3: dependencies: @@ -18977,35 +18872,6 @@ snapshots: - rollup - supports-color - unocss@0.59.4(postcss@8.4.41)(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)): - dependencies: - '@unocss/astro': 0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)) - '@unocss/cli': 0.59.4(rollup@4.21.1) - '@unocss/core': 0.59.4 - '@unocss/extractor-arbitrary-variants': 0.59.4 - '@unocss/postcss': 0.59.4(postcss@8.4.41) - '@unocss/preset-attributify': 0.59.4 - '@unocss/preset-icons': 0.59.4 - '@unocss/preset-mini': 0.59.4 - '@unocss/preset-tagify': 0.59.4 - '@unocss/preset-typography': 0.59.4 - '@unocss/preset-uno': 0.59.4 - '@unocss/preset-web-fonts': 0.59.4 - '@unocss/preset-wind': 0.59.4 - '@unocss/reset': 0.59.4 - '@unocss/transformer-attributify-jsx': 0.59.4 - '@unocss/transformer-attributify-jsx-babel': 0.59.4 - '@unocss/transformer-compile-class': 0.59.4 - '@unocss/transformer-directives': 0.59.4 - '@unocss/transformer-variant-group': 0.59.4 - '@unocss/vite': 0.59.4(rollup@4.21.1)(vite@5.4.2(@types/node@22.5.1)(terser@5.31.6)) - optionalDependencies: - vite: 5.4.2(@types/node@22.5.1)(terser@5.31.6) - transitivePeerDependencies: - - postcss - - rollup - - supports-color - unpipe@1.0.0: {} unplugin-vue-components@0.26.0(@babel/parser@7.25.4)(rollup@2.79.1)(vue@3.4.38(typescript@5.4.5)): @@ -19027,25 +18893,6 @@ snapshots: - rollup - supports-color - unplugin-vue-components@0.26.0(@babel/parser@7.25.4)(rollup@4.21.1)(vue@3.4.38(typescript@5.4.5)): - dependencies: - '@antfu/utils': 0.7.10 - '@rollup/pluginutils': 5.1.0(rollup@4.21.1) - chokidar: 3.6.0 - debug: 4.3.6(supports-color@8.1.1) - fast-glob: 3.3.2 - local-pkg: 0.4.3 - magic-string: 0.30.11 - minimatch: 9.0.5 - resolve: 1.22.8 - unplugin: 1.12.0 - vue: 3.4.38(typescript@5.4.5) - optionalDependencies: - '@babel/parser': 7.25.4 - transitivePeerDependencies: - - rollup - - supports-color - unplugin@1.12.0: dependencies: acorn: 8.12.1 From 5e75320d49eab65aca630dcc3c04c8d620a8bbf7 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 9 Sep 2024 09:38:02 +0530 Subject: [PATCH 18/21] Create red-beans-cross.md --- .changeset/red-beans-cross.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/red-beans-cross.md diff --git a/.changeset/red-beans-cross.md b/.changeset/red-beans-cross.md new file mode 100644 index 0000000000..57a1e6b686 --- /dev/null +++ b/.changeset/red-beans-cross.md @@ -0,0 +1,5 @@ +--- +"mermaid": patch +--- + +fix: Replace $root with relative paths From 1951a0cdc8e4b657a38ef7eb43bca9d33d3020c7 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 04:12:51 +0000 Subject: [PATCH 19/21] [autofix.ci] apply automated fixes --- .changeset/red-beans-cross.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/red-beans-cross.md b/.changeset/red-beans-cross.md index 57a1e6b686..3337d11897 100644 --- a/.changeset/red-beans-cross.md +++ b/.changeset/red-beans-cross.md @@ -1,5 +1,5 @@ --- -"mermaid": patch +'mermaid': patch --- fix: Replace $root with relative paths From c0187101e9cb3ea9d1966575efcd80ebb6a9a203 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Mon, 9 Sep 2024 17:30:22 +0530 Subject: [PATCH 20/21] fix: Return type, make config non optional Co-authored-by: Alois Klink --- packages/mermaid/src/preprocess.ts | 4 ++-- packages/mermaid/src/types.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/mermaid/src/preprocess.ts b/packages/mermaid/src/preprocess.ts index 10bc0adea6..a623260703 100644 --- a/packages/mermaid/src/preprocess.ts +++ b/packages/mermaid/src/preprocess.ts @@ -49,7 +49,7 @@ const processDirectives = (code: string) => { * @param code - The code to preprocess. * @returns The object containing the preprocessed code, title, and configuration. */ -export function preprocessDiagram(code: string): DiagramMetadata & { code: string } { +export function preprocessDiagram(code: string) { const cleanedCode = cleanupText(code); const frontMatterResult = processFrontmatter(cleanedCode); const directiveResult = processDirectives(frontMatterResult.text); @@ -59,5 +59,5 @@ export function preprocessDiagram(code: string): DiagramMetadata & { code: strin code, title: frontMatterResult.title, config, - }; + } satisfies DiagramMetadata & { code: string }; } diff --git a/packages/mermaid/src/types.ts b/packages/mermaid/src/types.ts index ae97bd69b0..d8b4c4aa07 100644 --- a/packages/mermaid/src/types.ts +++ b/packages/mermaid/src/types.ts @@ -53,7 +53,7 @@ export interface ParseResult { /** * The config passed as YAML frontmatter or directives */ - config?: MermaidConfig; + config: MermaidConfig; } // This makes it clear that we're working with a d3 selected element of some kind, even though it's hard to specify the exact type. export type D3Element = any; From d053284536e0b1f9f03e20d825b60b059479546b Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 9 Sep 2024 12:11:29 +0000 Subject: [PATCH 21/21] [autofix.ci] apply automated fixes --- docs/config/setup/interfaces/mermaid.ParseResult.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/config/setup/interfaces/mermaid.ParseResult.md b/docs/config/setup/interfaces/mermaid.ParseResult.md index 452c90b320..e6ff154c85 100644 --- a/docs/config/setup/interfaces/mermaid.ParseResult.md +++ b/docs/config/setup/interfaces/mermaid.ParseResult.md @@ -12,7 +12,7 @@ ### config -• `Optional` **config**: [`MermaidConfig`](mermaid.MermaidConfig.md) +• **config**: [`MermaidConfig`](mermaid.MermaidConfig.md) The config passed as YAML frontmatter or directives