-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4761 from mermaid-js/sidv/RemoveCircularDeps
Remove Circular Dependencies
- Loading branch information
Showing
13 changed files
with
111 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,7 @@ | |
"rects", | ||
"reda", | ||
"redmine", | ||
"regexes", | ||
"rehype", | ||
"roledescription", | ||
"rozhkov", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"detectiveOptions": { | ||
"ts": { | ||
"skipTypeImports": true | ||
}, | ||
"es6": { | ||
"skipTypeImports": true | ||
} | ||
}, | ||
"fileExtensions": [ | ||
"js", | ||
"ts" | ||
], | ||
"excludeRegExp": [ | ||
"node_modules", | ||
"docs", | ||
"vitepress", | ||
"detector", | ||
"Detector" | ||
], | ||
"tsConfig": "./tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { log } from '../logger.js'; | ||
import { detectors } from './detectType.js'; | ||
import { getDiagram, registerDiagram } from './diagramAPI.js'; | ||
|
||
export const loadRegisteredDiagrams = async () => { | ||
log.debug(`Loading registered diagrams`); | ||
// Load all lazy loaded diagrams in parallel | ||
const results = await Promise.allSettled( | ||
Object.entries(detectors).map(async ([key, { detector, loader }]) => { | ||
if (loader) { | ||
try { | ||
getDiagram(key); | ||
} catch (error) { | ||
try { | ||
// Register diagram if it is not already registered | ||
const { diagram, id } = await loader(); | ||
registerDiagram(id, diagram, detector); | ||
} catch (err) { | ||
// Remove failed diagram from detectors | ||
log.error(`Failed to load external diagram with key ${key}. Removing from detectors.`); | ||
delete detectors[key]; | ||
throw err; | ||
} | ||
} | ||
} | ||
}) | ||
); | ||
const failed = results.filter((result) => result.status === 'rejected'); | ||
if (failed.length > 0) { | ||
log.error(`Failed to load ${failed.length} external diagrams`); | ||
for (const res of failed) { | ||
log.error(res); | ||
} | ||
throw new Error(`Failed to load ${failed.length} external diagrams`); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Match Jekyll-style front matter blocks (https://jekyllrb.com/docs/front-matter/). | ||
// Based on regex used by Jekyll: https://github.com/jekyll/jekyll/blob/6dd3cc21c40b98054851846425af06c64f9fb466/lib/jekyll/document.rb#L10 | ||
// Note that JS doesn't support the "\A" anchor, which means we can't use | ||
// multiline mode. | ||
// Relevant YAML spec: https://yaml.org/spec/1.2.2/#914-explicit-documents | ||
export const frontMatterRegex = /^-{3}\s*[\n\r](.*?)[\n\r]-{3}\s*[\n\r]+/s; | ||
|
||
export const directiveRegex = | ||
/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi; | ||
|
||
export const anyCommentRegex = /\s*%%.*\n/gm; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.