mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-23 18:26:39 +02:00
fix: TS errors
This commit is contained in:
@@ -7,7 +7,7 @@ import { log } from './logger';
|
|||||||
import utils from './utils';
|
import utils from './utils';
|
||||||
import { mermaidAPI } from './mermaidAPI';
|
import { mermaidAPI } from './mermaidAPI';
|
||||||
import { addDetector } from './diagram-api/detectType';
|
import { addDetector } from './diagram-api/detectType';
|
||||||
import { isDetailedError } from './utils';
|
import { isDetailedError, DetailedError } from './utils';
|
||||||
import { registerDiagram } from './diagram-api/diagramAPI';
|
import { registerDiagram } from './diagram-api/diagramAPI';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -103,7 +103,7 @@ const initThrowsErrors = function (
|
|||||||
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
||||||
|
|
||||||
let txt: string;
|
let txt: string;
|
||||||
const errors = [];
|
const errors: DetailedError[] = [];
|
||||||
|
|
||||||
// element is the current div with mermaid class
|
// element is the current div with mermaid class
|
||||||
for (const element of Array.from(nodesToProcess)) {
|
for (const element of Array.from(nodesToProcess)) {
|
||||||
@@ -144,8 +144,12 @@ const initThrowsErrors = function (
|
|||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.warn('Catching Error (bootstrap)', error);
|
log.warn('Catching Error (bootstrap)', error);
|
||||||
// @ts-ignore: TODO Fix ts errors
|
const mermaidError: DetailedError = {
|
||||||
const mermaidError = { error, str: error.str, hash: error.hash, message: error.str };
|
error,
|
||||||
|
str: error.str,
|
||||||
|
hash: error.hash,
|
||||||
|
message: error.str,
|
||||||
|
};
|
||||||
if (typeof mermaid.parseError === 'function') {
|
if (typeof mermaid.parseError === 'function') {
|
||||||
mermaid.parseError(mermaidError);
|
mermaid.parseError(mermaidError);
|
||||||
}
|
}
|
||||||
@@ -240,7 +244,7 @@ const initThrowsErrorsAsync = async function (
|
|||||||
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
const idGenerator = new utils.initIdGenerator(conf.deterministicIds, conf.deterministicIDSeed);
|
||||||
|
|
||||||
let txt: string;
|
let txt: string;
|
||||||
const errors = [];
|
const errors: DetailedError[] = [];
|
||||||
|
|
||||||
// element is the current div with mermaid class
|
// element is the current div with mermaid class
|
||||||
for (const element of Array.from(nodesToProcess)) {
|
for (const element of Array.from(nodesToProcess)) {
|
||||||
@@ -281,8 +285,12 @@ const initThrowsErrorsAsync = async function (
|
|||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.warn('Catching Error (bootstrap)', error);
|
log.warn('Catching Error (bootstrap)', error);
|
||||||
// @ts-ignore: TODO Fix ts errors
|
const mermaidError: DetailedError = {
|
||||||
const mermaidError = { error, str: error.str, hash: error.hash, message: error.str };
|
error,
|
||||||
|
str: error.str,
|
||||||
|
hash: error.hash,
|
||||||
|
message: error.str,
|
||||||
|
};
|
||||||
if (typeof mermaid.parseError === 'function') {
|
if (typeof mermaid.parseError === 'function') {
|
||||||
mermaid.parseError(mermaidError);
|
mermaid.parseError(mermaidError);
|
||||||
}
|
}
|
||||||
@@ -355,24 +363,23 @@ const parse = (txt: string) => {
|
|||||||
return mermaidAPI.parse(txt, mermaid.parseError);
|
return mermaidAPI.parse(txt, mermaid.parseError);
|
||||||
};
|
};
|
||||||
|
|
||||||
// @ts-ignore: TODO Fix ts errors
|
const executionQueue: (() => Promise<unknown>)[] = [];
|
||||||
const executionQueue = [];
|
|
||||||
let executionQueueRunning = false;
|
let executionQueueRunning = false;
|
||||||
const executeQueue = async () => {
|
const executeQueue = async () => {
|
||||||
if (executionQueueRunning) {
|
if (executionQueueRunning) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
executionQueueRunning = true;
|
executionQueueRunning = true;
|
||||||
// @ts-ignore: TODO Fix ts errors
|
|
||||||
while (executionQueue.length > 0) {
|
while (executionQueue.length > 0) {
|
||||||
// @ts-ignore: TODO Fix ts errors
|
|
||||||
const f = executionQueue.shift();
|
const f = executionQueue.shift();
|
||||||
|
if (f) {
|
||||||
try {
|
try {
|
||||||
await f();
|
await f();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error('Error executing queue', e);
|
log.error('Error executing queue', e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
executionQueueRunning = false;
|
executionQueueRunning = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -497,10 +504,8 @@ const mermaid: {
|
|||||||
mermaidAPI,
|
mermaidAPI,
|
||||||
parse,
|
parse,
|
||||||
parseAsync,
|
parseAsync,
|
||||||
// parseAsync: mermaidAPI.parseAsync,
|
|
||||||
render: mermaidAPI.render,
|
render: mermaidAPI.render,
|
||||||
renderAsync,
|
renderAsync,
|
||||||
// renderAsync: mermaidAPI.renderAsync,
|
|
||||||
init,
|
init,
|
||||||
initThrowsErrors,
|
initThrowsErrors,
|
||||||
initialize,
|
initialize,
|
||||||
@@ -508,8 +513,6 @@ const mermaid: {
|
|||||||
parseError: undefined,
|
parseError: undefined,
|
||||||
contentLoaded,
|
contentLoaded,
|
||||||
setParseErrorHandler,
|
setParseErrorHandler,
|
||||||
// test1,
|
|
||||||
// executeQueue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default mermaid;
|
export default mermaid;
|
||||||
|
@@ -825,6 +825,8 @@ export const sanitizeCss = (str) => {
|
|||||||
export interface DetailedError {
|
export interface DetailedError {
|
||||||
str: string;
|
str: string;
|
||||||
hash: any;
|
hash: any;
|
||||||
|
error?: Error;
|
||||||
|
message?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param error */
|
/** @param error */
|
||||||
|
Reference in New Issue
Block a user