Skip to content

Commit

Permalink
fix(mermaid): fix Mermaid integration for v9.2 release (#8282)
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Nov 10, 2022
1 parent 04eb04c commit 1d5afba
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 31 deletions.
1 change: 0 additions & 1 deletion packages/docusaurus-mdx-loader/package.json
Expand Up @@ -40,7 +40,6 @@
"@docusaurus/types": "^3.0.0-alpha.0",
"@types/escape-html": "^1.0.2",
"@types/mdast": "^3.0.10",
"@types/mermaid": "^8.2.9",
"@types/stringify-object": "^3.3.1",
"@types/unist": "^2.0.6",
"rehype-stringify": "^8.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/docusaurus-theme-mermaid/package.json
Expand Up @@ -39,12 +39,11 @@
"@docusaurus/types": "^3.0.0-alpha.0",
"@docusaurus/utils-validation": "^3.0.0-alpha.0",
"@mdx-js/react": "^1.6.22",
"mermaid": "^9.1.1",
"mermaid": "^9.2.2",
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/mdx-js__react": "^1.5.5",
"@types/mermaid": "^8.2.9",
"react-test-renderer": "^17.0.2"
},
"peerDependencies": {
Expand Down
7 changes: 3 additions & 4 deletions packages/docusaurus-theme-mermaid/src/client/index.ts
Expand Up @@ -7,8 +7,7 @@

import {useMemo} from 'react';
import {useColorMode, useThemeConfig} from '@docusaurus/theme-common';
import mermaid from 'mermaid';
import type mermaidAPI from 'mermaid/mermaidAPI';
import mermaid, {type MermaidConfig} from 'mermaid';
import type {ThemeConfig} from '@docusaurus/theme-mermaid';

// Stable className to allow users to easily target with CSS
Expand All @@ -18,7 +17,7 @@ export function useMermaidThemeConfig(): ThemeConfig['mermaid'] {
return (useThemeConfig() as unknown as ThemeConfig).mermaid;
}

export function useMermaidConfig(): mermaidAPI.Config {
export function useMermaidConfig(): MermaidConfig {
const {colorMode} = useColorMode();
const mermaidThemeConfig = useMermaidThemeConfig();

Expand All @@ -33,7 +32,7 @@ export function useMermaidConfig(): mermaidAPI.Config {

export function useMermaidSvg(
txt: string,
mermaidConfigParam?: mermaidAPI.Config,
mermaidConfigParam?: MermaidConfig,
): string {
/*
For flexibility, we allow the hook to receive a custom Mermaid config
Expand Down
5 changes: 2 additions & 3 deletions packages/docusaurus-theme-mermaid/src/validateThemeConfig.ts
Expand Up @@ -7,14 +7,13 @@

import {Joi} from '@docusaurus/utils-validation';
import type {ThemeConfig} from '@docusaurus/theme-mermaid';
import type mermaidAPI from 'mermaid/mermaidAPI';
import type {ThemeConfigValidationContext} from '@docusaurus/types';

export const DEFAULT_THEME_CONFIG: ThemeConfig = {
mermaid: {
theme: {
dark: 'dark' as mermaidAPI.Theme,
light: 'default' as mermaidAPI.Theme,
dark: 'dark',
light: 'default',
},
options: {},
},
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-mermaid/tsconfig.client.json
Expand Up @@ -10,6 +10,6 @@
"module": "esnext",
"target": "esnext"
},
"include": ["src/theme", "src/*.d.ts"],
"include": ["src/client", "src/theme", "src/*.d.ts"],
"exclude": ["**/__tests__/**"]
}
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-mermaid/tsconfig.json
Expand Up @@ -10,5 +10,5 @@
"outDir": "lib"
},
"include": ["src"],
"exclude": ["src/theme", "**/__tests__/**"]
"exclude": ["src/client", "src/theme", "**/__tests__/**"]
}
52 changes: 33 additions & 19 deletions yarn.lock
Expand Up @@ -3659,11 +3659,6 @@
dependencies:
"@types/react" "*"

"@types/mermaid@^8.2.9":
version "8.2.9"
resolved "https://registry.yarnpkg.com/@types/mermaid/-/mermaid-8.2.9.tgz#1844505dcffcd47703e94628a6200583d35c2c76"
integrity sha512-f1i8fNoVFVJXedk+R7GcEk4KoOWzWAU3CzFqlVw1qWKktfsataBERezCz1pOdKy8Ec02ZdPQXGM7NU2lPHABYQ==

"@types/micromatch@^4.0.2":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/micromatch/-/micromatch-4.0.2.tgz#ce29c8b166a73bf980a5727b1e4a4d099965151d"
Expand Down Expand Up @@ -7918,6 +7913,11 @@ extglob@^2.0.4:
snapdragon "^0.8.1"
to-regex "^3.0.1"

fast-clone@^1.5.13:
version "1.5.13"
resolved "https://registry.yarnpkg.com/fast-clone/-/fast-clone-1.5.13.tgz#7fe17542ae1c872e71bf80d177d00c11f51c2ea7"
integrity sha512-0ez7coyFBQFjZtId+RJqJ+EQs61w9xARfqjqK0AD9vIUkSxWD4HvPt80+5evebZ1tTnv1GYKrPTipx7kOW5ipA==

fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525"
Expand Down Expand Up @@ -11112,20 +11112,24 @@ merge2@^1.3.0, merge2@^1.4.1:
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==

mermaid@^9.1.1:
version "9.1.7"
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-9.1.7.tgz#e24de9b2d36c8cb25a09d72ffce966941b24bd6e"
integrity sha512-MRVHXy5FLjnUQUG7YS3UN9jEN6FXCJbFCXVGJQjVIbiR6Vhw0j/6pLIjqsiah9xoHmQU6DEaKOvB3S1g/1nBPA==
mermaid@^9.2.2:
version "9.2.2"
resolved "https://registry.yarnpkg.com/mermaid/-/mermaid-9.2.2.tgz#73cca1f0b74e7e674c0de3519d7e7e8ea83bea4a"
integrity sha512-6s7eKMqFJGS+0MYjmx8f6ZigqKBJVoSx5ql2gw6a4Aa+WJ49QiEJg7gPwywaBg3DZMs79UP7trESp4+jmaQccw==
dependencies:
"@braintree/sanitize-url" "^6.0.0"
d3 "^7.0.0"
dagre "^0.8.5"
dagre-d3 "^0.6.4"
dompurify "2.4.0"
fast-clone "^1.5.13"
graphlib "^2.1.8"
khroma "^2.0.0"
moment-mini "2.24.0"
stylis "^4.0.10"
lodash "^4.17.21"
moment-mini "^2.24.0"
non-layered-tidy-tree-layout "^2.0.2"
stylis "^4.1.2"
uuid "^9.0.0"

methods@~1.1.2:
version "1.1.2"
Expand Down Expand Up @@ -11402,10 +11406,10 @@ modify-values@^1.0.0:
resolved "https://registry.yarnpkg.com/modify-values/-/modify-values-1.0.1.tgz#b3939fa605546474e3e3e3c63d64bd43b4ee6022"
integrity sha512-xV2bxeN6F7oYjZWTe/YPAy6MN2M+sL4u/Rlm2AHCIVGfo2p1yGmBHQ6vHehl4bRTZBdHu3TSkWdYgkwpYzAGSw==

moment-mini@2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/moment-mini/-/moment-mini-2.24.0.tgz#fa68d98f7fe93ae65bf1262f6abb5fb6983d8d18"
integrity sha512-9ARkWHBs+6YJIvrIp0Ik5tyTTtP9PoV0Ssu2Ocq5y9v8+NOOpWiRshAp8c4rZVWTOe+157on/5G+zj5pwIQFEQ==
moment-mini@^2.24.0:
version "2.29.4"
resolved "https://registry.yarnpkg.com/moment-mini/-/moment-mini-2.29.4.tgz#cbbcdc58ce1b267506f28ea6668dbe060a32758f"
integrity sha512-uhXpYwHFeiTbY9KSgPPRoo1nt8OxNVdMVoTBYHfSEKeRkIkwGpO+gERmhuhBtzfaeOyTkykSrm2+noJBgqt3Hg==

mrmime@^1.0.0:
version "1.0.1"
Expand Down Expand Up @@ -11604,6 +11608,11 @@ node-releases@^2.0.6:
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-2.0.6.tgz#8a7088c63a55e493845683ebf3c828d8c51c5503"
integrity sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==

non-layered-tidy-tree-layout@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/non-layered-tidy-tree-layout/-/non-layered-tidy-tree-layout-2.0.2.tgz#57d35d13c356643fc296a55fb11ac15e74da7804"
integrity sha512-gkXMxRzUH+PB0ax9dUN0yYF0S25BqeAYqhgMaLUFmpXLEk7Fcu8f4emJuOAY0V8kjDICxROIKsTAKsV/v355xw==

nopt@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/nopt/-/nopt-5.0.0.tgz#530942bb58a512fccafe53fe210f13a25355dc88"
Expand Down Expand Up @@ -14916,10 +14925,10 @@ stylelint@^14.11.0:
v8-compile-cache "^2.3.0"
write-file-atomic "^4.0.2"

stylis@^4.0.10:
version "4.1.2"
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.2.tgz#870b3c1c2275f51b702bb3da9e94eedad87bba41"
integrity sha512-Nn2CCrG2ZaFziDxaZPN43CXqn+j7tcdjPFCkRBkFue8QYXC2HdEwnw5TCBo4yQZ2WxKYeSi0fdoOrtEqgDrXbA==
stylis@^4.1.2:
version "4.1.3"
resolved "https://registry.yarnpkg.com/stylis/-/stylis-4.1.3.tgz#fd2fbe79f5fed17c55269e16ed8da14c84d069f7"
integrity sha512-GP6WDNWf+o403jrEp9c5jibKavrtLW+/qYGhFxFrG8maXhwTBI7gLLhiBb0o7uFccWN+EOS9aMO6cGHWAO07OA==

supports-color@^5.3.0:
version "5.5.0"
Expand Down Expand Up @@ -15886,6 +15895,11 @@ uuid@^8.3.2:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

uuid@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.0.tgz#592f550650024a38ceb0c562f2f6aa435761efb5"
integrity sha512-MXcSTerfPa4uqyzStbRoTgt5XIe3x5+42+q1sDuy3R5MDk66URdLMOZe5aPX/SQd+kuYAh0FdP/pO28IkQyTeg==

v8-compile-cache@2.3.0, v8-compile-cache@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"
Expand Down

0 comments on commit 1d5afba

Please sign in to comment.