mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-20 07:49:43 +02:00
Merge remote-tracking branch 'origin/release/9.2.0' into release/9.2.0
This commit is contained in:
@@ -48,6 +48,7 @@ export const setLogLevel = function (level: keyof typeof LEVELS | number | strin
|
|||||||
log.warn = () => {};
|
log.warn = () => {};
|
||||||
log.error = () => {};
|
log.error = () => {};
|
||||||
log.fatal = () => {};
|
log.fatal = () => {};
|
||||||
|
|
||||||
if (numericLevel <= LEVELS.fatal) {
|
if (numericLevel <= LEVELS.fatal) {
|
||||||
log.fatal = console.error
|
log.fatal = console.error
|
||||||
? console.error.bind(console, format('FATAL'), 'color: orange')
|
? console.error.bind(console, format('FATAL'), 'color: orange')
|
||||||
|
@@ -159,7 +159,7 @@ const initThrowsErrors = function (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let lazyLoadingPromise: Promise<unknown> | undefined;
|
let lazyLoadingPromise: Promise<unknown> | undefined = undefined;
|
||||||
/**
|
/**
|
||||||
* @param conf
|
* @param conf
|
||||||
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
* @deprecated This is an internal function and should not be used. Will be removed in v10.
|
||||||
@@ -179,12 +179,15 @@ const registerLazyLoadedDiagrams = async (conf: MermaidConfig) => {
|
|||||||
await lazyLoadingPromise;
|
await lazyLoadingPromise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let loadingPromise: Promise<unknown> | undefined = undefined;
|
||||||
|
|
||||||
const loadExternalDiagrams = async (conf: MermaidConfig) => {
|
const loadExternalDiagrams = async (conf: MermaidConfig) => {
|
||||||
// Only lazy load once
|
// Only lazy load once
|
||||||
// TODO: This is a hack. We should either throw error when new diagrams are added, or load them anyway.
|
// TODO: This is a hack. We should either throw error when new diagrams are added, or load them anyway.
|
||||||
if (lazyLoadingPromise === undefined) {
|
if (loadingPromise === undefined) {
|
||||||
|
log.debug(`Loading ${conf?.lazyLoadedDiagrams?.length} external diagrams`);
|
||||||
// Load all lazy loaded diagrams in parallel
|
// Load all lazy loaded diagrams in parallel
|
||||||
lazyLoadingPromise = Promise.allSettled(
|
loadingPromise = Promise.allSettled(
|
||||||
(conf?.lazyLoadedDiagrams ?? []).map(async (url: string) => {
|
(conf?.lazyLoadedDiagrams ?? []).map(async (url: string) => {
|
||||||
const { id, detector, loadDiagram } = await import(url);
|
const { id, detector, loadDiagram } = await import(url);
|
||||||
const { diagram } = await loadDiagram();
|
const { diagram } = await loadDiagram();
|
||||||
@@ -192,7 +195,7 @@ const loadExternalDiagrams = async (conf: MermaidConfig) => {
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await lazyLoadingPromise;
|
await loadingPromise;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user