This commit is contained in:
Sidharth Vinod
2023-02-08 16:01:29 +05:30
parent d562a81019
commit 7f254e37e9
6 changed files with 3 additions and 1863 deletions

View File

@@ -41,26 +41,6 @@ const packageOptions = {
packageName: 'mermaid-mindmap',
file: 'detector.ts',
},
// 'mermaid-timeline': {
// name: 'mermaid-timeline',
// packageName: 'mermaid-timeline',
// file: 'detector.ts',
// },
// 'mermaid-timeline-detector': {
// name: 'mermaid-timeline-detector',
// packageName: 'mermaid-timeline',
// file: 'detector.ts',
// },
// 'mermaid-example-diagram': {
// name: 'mermaid-example-diagram',
// packageName: 'mermaid-example-diagram',
// file: 'diagram-definition.ts',
// },
// 'mermaid-example-diagram-detector': {
// name: 'mermaid-example-diagram-detector',
// packageName: 'mermaid-example-diagram',
// file: 'detector.ts',
// },
};
interface BuildOptions {
@@ -134,12 +114,7 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions)
if (watch && config.build) {
config.build.watch = {
include: [
'packages/mermaid-mindmap/src/**',
'packages/mermaid/src/**',
// 'packages/mermaid-example-diagram/src/**',
// 'packages/mermaid-timeline/src/**',
],
include: ['packages/mermaid-mindmap/src/**', 'packages/mermaid/src/**'],
};
}
@@ -165,9 +140,6 @@ if (watch) {
build(getBuildConfig({ minify: false, watch, core: false, entryName: 'mermaid' }));
if (!mermaidOnly) {
build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-mindmap' }));
// build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-example-diagram' }));
//build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-timeline' }));
//build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-timeline-detector' }));
}
} else if (visualize) {
await build(getBuildConfig({ minify: false, core: true, entryName: 'mermaid' }));

View File

@@ -1,6 +1,5 @@
import express, { NextFunction, Request, Response } from 'express';
import { createServer as createViteServer } from 'vite';
// import { getBuildConfig } from './build';
const cors = (req: Request, res: Response, next: NextFunction) => {
res.header('Access-Control-Allow-Origin', '*');
@@ -22,9 +21,8 @@ async function createServer() {
app.use(cors);
app.use(express.static('./packages/mermaid/dist'));
app.use(express.static('./packages/mermaid-example-diagram/dist'));
// app.use(express.static('./packages/mermaid-example-diagram/dist'));
app.use(express.static('./packages/mermaid-mindmap/dist'));
//app.use(express.static('./packages/mermaid-timeline/dist'));
app.use(vite.middlewares);
app.use(express.static('demos'));
app.use(express.static('cypress/platform'));
@@ -34,5 +32,4 @@ async function createServer() {
});
}
// build(getBuildConfig({ minify: false, watch: true }));
createServer();

1755
Setup.md

File diff suppressed because it is too large Load Diff

View File

@@ -3,12 +3,10 @@ import parser from './parser/timeline.jison';
import * as db from './timelineDb';
import renderer from './timelineRenderer';
import styles from './styles';
import { injectUtils } from './mermaidUtils';
export const diagram = {
db,
renderer,
parser,
styles,
injectUtils,
};

View File

@@ -1,72 +0,0 @@
const warning = () => null;
let localCommonDb = {};
export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
export const LEVELS: Record<LogLevel, number> = {
trace: 0,
debug: 1,
info: 2,
warn: 3,
error: 4,
fatal: 5,
};
export const log: Record<keyof typeof LEVELS, typeof console.log> = {
trace: warning,
debug: warning,
info: warning,
warn: warning,
error: warning,
fatal: warning,
};
export let setLogLevel: (level: keyof typeof LEVELS | number | string) => void;
export let getConfig: () => object;
export let sanitizeText: (str: string) => string;
export const getCommonDb = () => localCommonDb;
export let parseDirective = (p: any, statement: string, context: string, type: string) => {
return;
};
/**
* Placeholder for the real function that will be injected by mermaid.
*/
// eslint-disable @typescript-eslint/no-explicit-any
export let setupGraphViewbox: (
graph: any,
svgElem: any,
padding: any,
useMaxWidth: boolean
) => void;
/**
* Function called by mermaid that injects utility functions that help the diagram to be a good citizen.
* @param _log - The log function to use
* @param _setLogLevel - The function to set the log level
* @param _getConfig - The function to get the configuration
* @param _sanitizeText - The function to sanitize text
* @param _setupGraphViewbox - The function to setup the graph view-box
* @param _commonDb - The common database
*/
export const injectUtils = (
_log: Record<keyof typeof LEVELS, typeof console.log>,
_setLogLevel: any,
_getConfig: any,
_sanitizeText: any,
_setupGraphViewbox: any,
_commonDb: any,
_parseDirective: any
) => {
_log.debug('Mermaid utils injected into timeline-diagram');
log.trace = _log.trace;
log.debug = _log.debug;
log.info = _log.info;
log.warn = _log.warn;
log.error = _log.error;
log.fatal = _log.fatal;
setLogLevel = _setLogLevel;
getConfig = _getConfig;
sanitizeText = _sanitizeText;
setupGraphViewbox = _setupGraphViewbox;
localCommonDb = _commonDb;
parseDirective = _parseDirective;
};

View File

@@ -1,6 +1,6 @@
/** mermaid
* https://mermaidjs.github.io/
* (c) 2015 Knut Sveidqvist
* (c) 2023 Knut Sveidqvist
* MIT license.
*/
%lex