Merge remote-tracking branch 'origin/release/9.2.0' into release/9.2.0

This commit is contained in:
Knut Sveidqvist
2022-10-19 07:52:14 +02:00
2 changed files with 8 additions and 4 deletions

View File

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

View File

@@ -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;
}; };
/** /**