diff --git a/.cspell/code-terms.txt b/.cspell/code-terms.txt index 8b549f888..5f72ea221 100644 --- a/.cspell/code-terms.txt +++ b/.cspell/code-terms.txt @@ -1,3 +1,5 @@ +!viewbox +# It should be viewBox # This file contains coding related terms ALPHANUM antiscript diff --git a/.cspell/libraries.txt b/.cspell/libraries.txt index feee10fd1..4fceed5bb 100644 --- a/.cspell/libraries.txt +++ b/.cspell/libraries.txt @@ -64,6 +64,7 @@ rscratch shiki Slidev sparkline +speccharts sphinxcontrib ssim stylis diff --git a/.esbuild/util.ts b/.esbuild/util.ts index 3a0ec6b41..a3e2ffe55 100644 --- a/.esbuild/util.ts +++ b/.esbuild/util.ts @@ -71,6 +71,9 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => { const external: string[] = ['require', 'fs', 'path']; const outFileName = getFileName(name, options); + const { dependencies, version } = JSON.parse( + readFileSync(resolve(__dirname, `../packages/${packageName}/package.json`), 'utf-8') + ); const output: BuildOptions = buildOptions({ ...rest, absWorkingDir: resolve(__dirname, `../packages/${packageName}`), @@ -82,15 +85,13 @@ export const getBuildConfig = (options: MermaidBuildOptions): BuildOptions => { chunkNames: `chunks/${outFileName}/[name]-[hash]`, define: { // This needs to be stringified for esbuild - includeLargeFeatures: `${includeLargeFeatures}`, + 'injected.includeLargeFeatures': `${includeLargeFeatures}`, + 'injected.version': `'${version}'`, 'import.meta.vitest': 'undefined', }, }); if (core) { - const { dependencies } = JSON.parse( - readFileSync(resolve(__dirname, `../packages/${packageName}/package.json`), 'utf-8') - ); // Core build is used to generate file without bundled dependencies. // This is used by downstream projects to bundle dependencies themselves. // Ignore dependencies and any dependencies of dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7dbf85d94..ece84ac20 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,5 +42,4 @@ jobs: publish: pnpm changeset:publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: true diff --git a/.github/workflows/validate-lockfile.yml b/.github/workflows/validate-lockfile.yml index 119f43180..dcfb255b6 100644 --- a/.github/workflows/validate-lockfile.yml +++ b/.github/workflows/validate-lockfile.yml @@ -18,13 +18,6 @@ jobs: ref: ${{ github.event.pull_request.head.sha }} repository: ${{ github.event.pull_request.head.repo.full_name }} - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 - - name: Validate pnpm-lock.yaml entries id: validate # give this step an ID so we can reference its outputs run: | diff --git a/.vite/build.ts b/.vite/build.ts index 480dd6b30..d59f0fac3 100644 --- a/.vite/build.ts +++ b/.vite/build.ts @@ -78,6 +78,8 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions) }, define: { 'import.meta.vitest': 'undefined', + 'injected.includeLargeFeatures': 'true', + 'injected.version': `'0.0.0'`, }, resolve: { extensions: [], @@ -94,10 +96,6 @@ export const getBuildConfig = ({ minify, core, watch, entryName }: BuildOptions) }), ...visualizerOptions(packageName, core), ], - define: { - // Needs to be string - includeLargeFeatures: 'true', - }, }; if (watch && config.build) { diff --git a/cypress/helpers/util.ts b/cypress/helpers/util.ts index d02e9da87..0332178f6 100644 --- a/cypress/helpers/util.ts +++ b/cypress/helpers/util.ts @@ -99,6 +99,7 @@ export const openURLAndVerifyRendering = ( cy.visit(url); cy.window().should('have.property', 'rendered', true); cy.get('svg').should('be.visible'); + // cspell:ignore viewbox cy.get('svg').should('not.have.attr', 'viewbox'); if (validation) { diff --git a/docs/ecosystem/integrations-community.md b/docs/ecosystem/integrations-community.md index 6bc16e3e2..4cb73eb67 100644 --- a/docs/ecosystem/integrations-community.md +++ b/docs/ecosystem/integrations-community.md @@ -57,6 +57,8 @@ To add an integration to this list, see the [Integrations - create page](./integ - [GitHub Writer](https://github.com/ckeditor/github-writer) - [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator) - [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅ +- [GNU Octave](https://octave.org/) ✅ + - [octave_mermaid_js](https://github.com/CNOCTAVE/octave_mermaid_js) ✅ - [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid) - [MonsterWriter](https://www.monsterwriter.com/) ✅ - [Joplin](https://joplinapp.org) ✅ @@ -272,6 +274,7 @@ Communication tools and platforms - [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin) - [Reveal CK](https://github.com/jedcn/reveal-ck) - [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin) +- [speccharts: Turn your test suites into specification diagrams](https://github.com/arnaudrenaud/speccharts) - [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer) diff --git a/packages/mermaid-layout-elk/package.json b/packages/mermaid-layout-elk/package.json index 91c1ae81f..e47d64edf 100644 --- a/packages/mermaid-layout-elk/package.json +++ b/packages/mermaid-layout-elk/package.json @@ -18,7 +18,9 @@ "elk", "mermaid" ], - "scripts": {}, + "scripts": { + "clean": "rimraf dist" + }, "repository": { "type": "git", "url": "https://github.com/mermaid-js/mermaid" diff --git a/packages/mermaid-layout-tidy-tree/package.json b/packages/mermaid-layout-tidy-tree/package.json index bdc15869f..2abaaa211 100644 --- a/packages/mermaid-layout-tidy-tree/package.json +++ b/packages/mermaid-layout-tidy-tree/package.json @@ -19,7 +19,9 @@ "mermaid", "layout" ], - "scripts": {}, + "scripts": { + "clean": "rimraf dist" + }, "repository": { "type": "git", "url": "https://github.com/mermaid-js/mermaid" diff --git a/packages/mermaid/src/diagram-api/diagram-orchestration.ts b/packages/mermaid/src/diagram-api/diagram-orchestration.ts index 97b9852ff..fa90e1df9 100644 --- a/packages/mermaid/src/diagram-api/diagram-orchestration.ts +++ b/packages/mermaid/src/diagram-api/diagram-orchestration.ts @@ -72,7 +72,7 @@ export const addDiagrams = () => { } ); - if (includeLargeFeatures) { + if (injected.includeLargeFeatures) { registerLazyLoadedDiagrams(flowchartElk, mindmap, architecture); } diff --git a/packages/mermaid/src/diagrams/common/common.ts b/packages/mermaid/src/diagrams/common/common.ts index 045a729f7..444c9e930 100644 --- a/packages/mermaid/src/diagrams/common/common.ts +++ b/packages/mermaid/src/diagrams/common/common.ts @@ -333,7 +333,7 @@ const renderKatexUnsanitized = async (text: string, config: MermaidConfig): Prom return text.replace(katexRegex, 'MathML is unsupported in this environment.'); } - if (includeLargeFeatures) { + if (injected.includeLargeFeatures) { const { default: katex } = await import('katex'); const outputMode = config.forceLegacyMathML || (!isMathMLSupported() && config.legacyMathML) diff --git a/packages/mermaid/src/diagrams/info/infoDb.ts b/packages/mermaid/src/diagrams/info/infoDb.ts index 169ceaf27..4c1a6778c 100644 --- a/packages/mermaid/src/diagrams/info/infoDb.ts +++ b/packages/mermaid/src/diagrams/info/infoDb.ts @@ -1,8 +1,7 @@ import type { InfoFields, InfoDB } from './infoTypes.js'; -import packageJson from '../../../package.json' assert { type: 'json' }; export const DEFAULT_INFO_DB: InfoFields = { - version: packageJson.version + (includeLargeFeatures ? '' : '-tiny'), + version: injected.version + (injected.includeLargeFeatures ? '' : '-tiny'), } as const; export const getVersion = (): string => DEFAULT_INFO_DB.version; diff --git a/packages/mermaid/src/docs/.vitepress/config.ts b/packages/mermaid/src/docs/.vitepress/config.ts index 066fde693..55bed31da 100644 --- a/packages/mermaid/src/docs/.vitepress/config.ts +++ b/packages/mermaid/src/docs/.vitepress/config.ts @@ -1,6 +1,6 @@ import type { MarkdownOptions } from 'vitepress'; import { defineConfig } from 'vitepress'; -import packageJson from '../../../package.json' assert { type: 'json' }; +import packageJson from '../../../package.json' with { type: 'json' }; import { addCanonicalUrls } from './canonical-urls.js'; import MermaidExample from './mermaid-markdown-all.js'; diff --git a/packages/mermaid/src/docs/ecosystem/integrations-community.md b/packages/mermaid/src/docs/ecosystem/integrations-community.md index a4a68e6ab..9ac390367 100644 --- a/packages/mermaid/src/docs/ecosystem/integrations-community.md +++ b/packages/mermaid/src/docs/ecosystem/integrations-community.md @@ -52,6 +52,8 @@ To add an integration to this list, see the [Integrations - create page](./integ - [GitHub Writer](https://github.com/ckeditor/github-writer) - [SVG diagram generator](https://github.com/SimonKenyonShepard/mermaidjs-github-svg-generator) - [GitLab](https://docs.gitlab.com/ee/user/markdown.html#diagrams-and-flowcharts) ✅ +- [GNU Octave](https://octave.org/) ✅ + - [octave_mermaid_js](https://github.com/CNOCTAVE/octave_mermaid_js) ✅ - [Mermaid Plugin for JetBrains IDEs](https://plugins.jetbrains.com/plugin/20146-mermaid) - [MonsterWriter](https://www.monsterwriter.com/) ✅ - [Joplin](https://joplinapp.org) ✅ @@ -267,6 +269,7 @@ Communication tools and platforms - [reveal.js-mermaid-plugin](https://github.com/ludwick/reveal.js-mermaid-plugin) - [Reveal CK](https://github.com/jedcn/reveal-ck) - [reveal-ck-mermaid-plugin](https://github.com/tmtm/reveal-ck-mermaid-plugin) +- [speccharts: Turn your test suites into specification diagrams](https://github.com/arnaudrenaud/speccharts) - [Vitepress Plugin](https://github.com/sametcn99/vitepress-mermaid-renderer) diff --git a/packages/mermaid/src/mermaidAPI.ts b/packages/mermaid/src/mermaidAPI.ts index cf08d02f8..80deda740 100644 --- a/packages/mermaid/src/mermaidAPI.ts +++ b/packages/mermaid/src/mermaidAPI.ts @@ -7,7 +7,6 @@ import { select } from 'd3'; import { compile, serialize, stringify } from 'stylis'; import DOMPurify from 'dompurify'; import isEmpty from 'lodash-es/isEmpty.js'; -import packageJson from '../package.json' assert { type: 'json' }; import { addSVGa11yTitleDescription, setA11yDiagramInfo } from './accessibility.js'; import assignWithDepth from './assignWithDepth.js'; import * as configApi from './config.js'; @@ -421,12 +420,12 @@ const render = async function ( // ------------------------------------------------------------------------------- // Draw the diagram with the renderer try { - await diag.renderer.draw(text, id, packageJson.version, diag); + await diag.renderer.draw(text, id, injected.version, diag); } catch (e) { if (config.suppressErrorRendering) { removeTempElements(); } else { - errorRenderer.draw(text, id, packageJson.version); + errorRenderer.draw(text, id, injected.version); } throw e; } diff --git a/packages/mermaid/src/rendering-util/render.ts b/packages/mermaid/src/rendering-util/render.ts index aa4bceca3..c14af2391 100644 --- a/packages/mermaid/src/rendering-util/render.ts +++ b/packages/mermaid/src/rendering-util/render.ts @@ -42,7 +42,7 @@ const registerDefaultLayoutLoaders = () => { name: 'dagre', loader: async () => await import('./layout-algorithms/dagre/index.js'), }, - ...(includeLargeFeatures + ...(injected.includeLargeFeatures ? [ { name: 'cose-bilkent', diff --git a/packages/mermaid/src/type.d.ts b/packages/mermaid/src/type.d.ts index 0c88e4866..515c774b4 100644 --- a/packages/mermaid/src/type.d.ts +++ b/packages/mermaid/src/type.d.ts @@ -1,2 +1,5 @@ // eslint-disable-next-line no-var -declare var includeLargeFeatures: boolean; +declare var injected: { + version: string; + includeLargeFeatures: boolean; +}; diff --git a/vite.config.ts b/vite.config.ts index c4738458e..f86711e9a 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -35,7 +35,8 @@ export default defineConfig({ }, define: { // Needs to be string - includeLargeFeatures: 'true', + 'injected.includeLargeFeatures': 'true', 'import.meta.vitest': 'undefined', + packageVersion: "'0.0.0'", }, });