replace mermaid/dist with relative paths

This commit is contained in:
Nicholas Bollweg 2024-09-08 12:47:19 -05:00
parent 6a3f1d194a
commit 571dfda629
44 changed files with 100 additions and 106 deletions

View File

@ -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) => {

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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;

View File

@ -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 {

View File

@ -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);

View File

@ -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

View File

@ -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';

View File

@ -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.
*

View File

@ -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';

View File

@ -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) => {

View File

@ -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';

View File

@ -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);

View File

@ -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<SVGAElement> => {

View File

@ -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 = (

View File

@ -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<SVGAElement> => {

View File

@ -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) => {

View File

@ -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();

View File

@ -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) => {

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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';

View File

@ -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) => {

View File

@ -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';

View File

@ -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';

View File

@ -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);

View File

@ -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) => {

View File

@ -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) => {

View File

@ -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';

View File

@ -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) => {

View File

@ -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();

View File

@ -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();

View File

@ -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';

View File

@ -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';

View File

@ -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;

View File

@ -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,

View File

@ -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