diff --git a/.gitignore b/.gitignore index 6e4fe723a..8cc09354b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ cypress/snapshots/ .eslintcache .tsbuildinfo tsconfig.tsbuildinfo + +knsv*.html +local*.html diff --git a/.npmrc b/.npmrc index f87a04434..4c2f52b3b 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ -auto-install-peers=true \ No newline at end of file +auto-install-peers=true +strict-peer-dependencies=false diff --git a/.vite/build.ts b/.vite/build.ts index 7398d30d5..ba31c2907 100644 --- a/.vite/build.ts +++ b/.vite/build.ts @@ -6,6 +6,7 @@ import pkg from '../package.json' assert { type: 'json' }; const { dependencies } = pkg; const watch = process.argv.includes('--watch'); +const mermaidOnly = process.argv.includes('--mermaid'); const __dirname = fileURLToPath(new URL('.', import.meta.url)); type OutputOptions = Exclude< @@ -22,23 +23,13 @@ const packageOptions = { 'mermaid-mindmap': { name: 'mermaid-mindmap', packageName: 'mermaid-mindmap', - file: 'diagram-definition.ts', - }, - 'mermaid-mindmap-detector': { - name: 'mermaid-mindmap-detector', - packageName: 'mermaid-mindmap', - file: 'detector.ts', - }, - 'mermaid-example-diagram': { - name: 'mermaid-example-diagram', - packageName: 'mermaid-example-diagram', - file: 'diagram-definition.ts', - }, - 'mermaid-example-diagram-detector': { - name: 'mermaid-example-diagram-detector', - packageName: 'mermaid-example-diagram', file: 'detector.ts', }, + // 'mermaid-example-diagram-detector': { + // name: 'mermaid-example-diagram-detector', + // packageName: 'mermaid-example-diagram', + // file: 'detector.ts', + // }, }; interface BuildOptions { @@ -110,7 +101,7 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions) include: [ 'packages/mermaid-mindmap/src/**', 'packages/mermaid/src/**', - 'packages/mermaid-example-diagram/src/**', + // 'packages/mermaid-example-diagram/src/**', ], }; } @@ -134,9 +125,11 @@ const main = async () => { }; if (watch) { - build(getBuildConfig({ minify: false, watch, entryName: 'mermaid' })); - build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-mindmap' })); - build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-example-diagram' })); + build(getBuildConfig({ minify: false, watch, core: true, entryName: 'mermaid' })); + if (!mermaidOnly) { + build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-mindmap' })); + // build(getBuildConfig({ minify: false, watch, entryName: 'mermaid-example-diagram' })); + } } else { void main(); } diff --git a/cypress/integration/other/external-diagrams.spec.js b/cypress/integration/other/external-diagrams.spec.js new file mode 100644 index 000000000..3a6c37e88 --- /dev/null +++ b/cypress/integration/other/external-diagrams.spec.js @@ -0,0 +1,13 @@ +describe('mermaid', () => { + describe('registerDiagram', () => { + it('should work on @mermaid-js/mermaid-mindmap and mermaid-example-diagram', () => { + const url = 'http://localhost:9000/external-diagrams-mindmap.html'; + cy.visit(url); + + cy.get('svg', { + // may be a bit slower than normal, since vite might need to re-compile mermaid/mermaid-mindmap/mermaid-example-diagram + timeout: 10000, + }).matchImageSnapshot(); + }); + }); +}); diff --git a/cypress/platform/external-diagrams-mindmap.html b/cypress/platform/external-diagrams-mindmap.html new file mode 100644 index 000000000..e5eded4ba --- /dev/null +++ b/cypress/platform/external-diagrams-mindmap.html @@ -0,0 +1,49 @@ + +
++mindmap + root + A + B + C + D + E + A2 + B2 + C2 + D2 + E2 + child1((Circle)) + grandchild 1 + grandchild 2 + child2(Round rectangle) + grandchild 3 + grandchild 4 + child3[Square] + grandchild 5 + ::icon(mdi mdi-fire) + gc6((grand+ + + + + + + + + + diff --git a/cypress/platform/knsv2.html b/cypress/platform/knsv2.html index f30f993fa..084b8151e 100644 --- a/cypress/platform/knsv2.html +++ b/cypress/platform/knsv2.html @@ -63,24 +63,19 @@ flowchart TD
child 6)) + ::icon(mdi mdi-fire) + gc7((grand
grand
child 8)) +
mindmap - root((mindmap)) - Origins - Long history - ::icon(fa fa-book) - Popularisation - ::icon(fa fa-book) - British popular psychology author Tony Buzan - Research - ::icon(fa fa-book) - On effectivness
and features - On Automatic creation - Uses - Creative techniques - Strategic planning - Argument mapping - Tools - Pen and paper - Mermaid + root + child1((Circle)) + grandchild 1 + grandchild 2 + child2(Round rectangle) + grandchild 3 + grandchild 4 + child3[Square] + grandchild 5 + ::icon(mdi mdi-fire) + gc6((grand
child 6)) + ::icon(mdi mdi-fire) + gc7((grand
grand
child 8))
gantt diff --git a/cypress/platform/render-after-error.html b/cypress/platform/render-after-error.html index 059f79345..f5165e0ee 100644 --- a/cypress/platform/render-after-error.html +++ b/cypress/platform/render-after-error.html @@ -14,16 +14,14 @@ mermaid.init({ startOnLoad: false }); mermaid.mermaidAPI.initialize({ securityLevel: 'strict' }); - (async () => { - try { - console.log('rendering'); - await mermaid.mermaidAPI.render('graphDiv', `>`); - } catch (e) {} + try { + console.log('rendering'); + mermaid.mermaidAPI.render('graphDiv', `>`); + } catch (e) {} - await mermaid.mermaidAPI.render('graphDiv', `graph LR\n a --> b`, (html) => { - document.getElementById('graph').innerHTML = html; - }); - })(); + mermaid.mermaidAPI.render('graphDiv', `graph LR\n a --> b`, (html) => { + document.getElementById('graph').innerHTML = html; + });