fix: Remove changes to parse

This commit is contained in:
Sidharth Vinod
2024-09-13 20:54:59 +05:30
parent 19e79fda73
commit 4cbb0004be

View File

@@ -30,7 +30,7 @@ export type {
MermaidConfig, MermaidConfig,
ParseErrorFunction, ParseErrorFunction,
ParseOptions, ParseOptions,
ParseResultWithConfigs as ParseResult, ParseResult,
RenderOptions, RenderOptions,
RenderResult, RenderResult,
SVG, SVG,
@@ -321,12 +321,6 @@ const executeQueue = async () => {
executionQueueRunning = false; executionQueueRunning = false;
}; };
interface ParseResultWithConfigs extends Omit<ParseResult, 'config'> {
/** Config the user has defined in the text as frontmatter or directives */
userConfig: MermaidConfig;
defaultConfig: MermaidConfig;
config: MermaidConfig;
}
/** /**
* Parse the text and validate the syntax. * Parse the text and validate the syntax.
* @param text - The mermaid diagram definition. * @param text - The mermaid diagram definition.
@@ -349,20 +343,14 @@ interface ParseResultWithConfigs extends Omit<ParseResult, 'config'> {
const parse = async ( const parse = async (
text: string, text: string,
parseOptions?: ParseOptions parseOptions?: ParseOptions
): Promise<boolean | void | ParseResultWithConfigs> => { ): Promise<boolean | void | ParseResult> => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// This promise will resolve when the render call is done. // This promise will resolve when the render call is done.
// It will be queued first and will be executed when it is first in line // It will be queued first and will be executed when it is first in line
const performCall = () => const performCall = () =>
new Promise((res, rej) => { new Promise((res, rej) => {
mermaidAPI.parse(text, parseOptions).then( mermaidAPI.parse(text, parseOptions).then(
(r) => { (result) => {
const result = {
diagram: r.diagram,
userConfig: r.config,
defaultConfig: mermaidAPI.defaultConfig,
config: mermaidAPI.getConfig(),
} satisfies ParseResultWithConfigs;
// This resolves for the promise for the queue handling // This resolves for the promise for the queue handling
res(result); res(result);
// This fulfills the promise sent to the value back to the original caller // This fulfills the promise sent to the value back to the original caller