diff --git a/.commitlintrc.json b/.commitlintrc.json
new file mode 100644
index 000000000..67b3aa185
--- /dev/null
+++ b/.commitlintrc.json
@@ -0,0 +1,5 @@
+{
+ "extends": [
+ "@commitlint/config-conventional"
+ ]
+}
\ No newline at end of file
diff --git a/.eslintrc.json b/.eslintrc.json
index 87bc4f2da..7f25c4ec7 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -13,8 +13,8 @@
},
"sourceType": "module"
},
- "extends": ["eslint:recommended", "plugin:jsdoc/recommended", "plugin:prettier/recommended"],
- "plugins": ["jest", "jsdoc", "prettier"],
+ "extends": ["eslint:recommended", "plugin:jsdoc/recommended", "plugin:markdown/recommended", "plugin:prettier/recommended"],
+ "plugins": ["html", "jest", "jsdoc", "prettier"],
"rules": {
"no-prototype-builtins": 0,
"no-unused-vars": 0,
@@ -23,6 +23,16 @@
"jsdoc/check-line-alignment": 0,
"jsdoc/multiline-blocks": 0,
"jsdoc/newline-after-description": 0,
- "jsdoc/tag-lines": 0
- }
-}
+ "jsdoc/tag-lines": 0,
+ "no-empty": ["error", { "allowEmptyCatch": true }]
+ },
+ "overrides": [
+ {
+ "files": "./**/*.html",
+ "rules": {
+ "no-undef": "off",
+ "jsdoc/require-jsdoc": "off"
+ }
+ }
+ ]
+}
diff --git a/.github/workflows/update-browserlist.yml b/.github/workflows/update-browserlist.yml
new file mode 100644
index 000000000..5ad70a9f5
--- /dev/null
+++ b/.github/workflows/update-browserlist.yml
@@ -0,0 +1,16 @@
+name: Update Browserslist
+on:
+ workflow_dispatch:
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - run: npx browserslist@latest --update-db
+ - name: Commit changes
+ uses: EndBug/add-and-commit@v7
+ with:
+ author_name: ${{ github.actor }}
+ author_email: ${{ github.actor }}@users.noreply.github.com
+ message: 'Update Browserslist'
diff --git a/.gitignore b/.gitignore
index efe4e39ac..9b28eb1d8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,8 +4,7 @@ node_modules/
coverage/
.idea/
-dist/*.js
-dist/*.map
+dist
yarn-error.log
.npmrc
@@ -13,10 +12,6 @@ token
package-lock.json
-dist/classTest.html
-
-dist/sequenceTest.html
-
.vscode/
cypress/platform/current.html
cypress/platform/experimental.html
diff --git a/.husky/commit-msg b/.husky/commit-msg
new file mode 100644
index 000000000..e8511eaea
--- /dev/null
+++ b/.husky/commit-msg
@@ -0,0 +1,4 @@
+#!/bin/sh
+. "$(dirname "$0")/_/husky.sh"
+
+npx --no-install commitlint --edit $1
diff --git a/.husky/pre-commit b/.husky/pre-commit
old mode 100755
new mode 100644
index a3c12e267..025779ed2
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
-yarn dlx lint-staged
+yarn pre-commit
diff --git a/.lintstagedrc.json b/.lintstagedrc.json
index f9b7eed74..f42adf44f 100644
--- a/.lintstagedrc.json
+++ b/.lintstagedrc.json
@@ -1,5 +1,5 @@
{
- "*": [
+ "*.{js,html,md}": [
"yarn lint:fix"
]
-}
+}
\ No newline at end of file
diff --git a/jison/loader.js b/.webpack/loaders/jison.js
similarity index 60%
rename from jison/loader.js
rename to .webpack/loaders/jison.js
index b819b79dd..0d5ebc7e5 100644
--- a/jison/loader.js
+++ b/.webpack/loaders/jison.js
@@ -1,6 +1,19 @@
const { Generator } = require('jison');
const validate = require('schema-utils');
-const schema = require('./parser-options-schema.json');
+
+const schema = {
+ title: 'Jison Parser options',
+ type: 'object',
+ properties: {
+ 'token-stack': {
+ type: 'boolean',
+ },
+ debug: {
+ type: 'boolean',
+ },
+ },
+ additionalProperties: false,
+};
module.exports = function jisonLoader(source) {
const options = this.getOptions();
diff --git a/.webpack/webpack.config.babel.js b/.webpack/webpack.config.babel.js
new file mode 100644
index 000000000..9dfd834b7
--- /dev/null
+++ b/.webpack/webpack.config.babel.js
@@ -0,0 +1,45 @@
+import { merge, mergeWithCustomize, customizeObject } from 'webpack-merge';
+import nodeExternals from 'webpack-node-externals';
+import baseConfig from './webpack.config.base';
+
+export default (_env, args) => {
+ switch (args.mode) {
+ case 'development':
+ return [
+ baseConfig,
+ merge(baseConfig, {
+ externals: [nodeExternals()],
+ output: {
+ filename: '[name].core.js',
+ },
+ }),
+ ];
+ case 'production':
+ return [
+ // umd
+ merge(baseConfig, {
+ output: {
+ filename: '[name].min.js',
+ },
+ }),
+ // esm
+ mergeWithCustomize({
+ customizeObject: customizeObject({
+ 'output.library': 'replace',
+ }),
+ })(baseConfig, {
+ experiments: {
+ outputModule: true,
+ },
+ output: {
+ library: {
+ type: 'module',
+ },
+ filename: '[name].esm.min.mjs',
+ },
+ }),
+ ];
+ default:
+ throw new Error('No matching configuration was found!');
+ }
+};
diff --git a/.webpack/webpack.config.base.js b/.webpack/webpack.config.base.js
new file mode 100644
index 000000000..055f59dfc
--- /dev/null
+++ b/.webpack/webpack.config.base.js
@@ -0,0 +1,54 @@
+import path from 'path';
+
+export const resolveRoot = (...relativePath) => path.resolve(__dirname, '..', ...relativePath);
+
+export default {
+ amd: false, // https://github.com/lodash/lodash/issues/3052
+ target: 'web',
+ entry: {
+ mermaid: './src/mermaid.js',
+ },
+ resolve: {
+ extensions: ['.wasm', '.mjs', '.js', '.json', '.jison'],
+ fallback: {
+ fs: false, // jison generated code requires 'fs'
+ path: require.resolve('path-browserify'),
+ },
+ },
+ output: {
+ path: resolveRoot('./dist'),
+ filename: '[name].js',
+ library: {
+ name: 'mermaid',
+ type: 'umd',
+ export: 'default',
+ },
+ globalObject: 'typeof self !== "undefined" ? self : this',
+ },
+ module: {
+ rules: [
+ {
+ test: /\.js$/,
+ include: [resolveRoot('./src'), resolveRoot('./node_modules/dagre-d3-renderer/lib')],
+ use: {
+ loader: 'babel-loader',
+ },
+ },
+ {
+ // load scss to string
+ test: /\.scss$/,
+ use: ['css-to-string-loader', 'css-loader', 'sass-loader'],
+ },
+ {
+ test: /\.jison$/,
+ use: {
+ loader: path.resolve(__dirname, './loaders/jison.js'),
+ options: {
+ 'token-stack': true,
+ },
+ },
+ },
+ ],
+ },
+ devtool: 'source-map',
+};
diff --git a/.webpack/webpack.config.e2e.babel.js b/.webpack/webpack.config.e2e.babel.js
new file mode 100644
index 000000000..3ec2bdcd7
--- /dev/null
+++ b/.webpack/webpack.config.e2e.babel.js
@@ -0,0 +1,37 @@
+import baseConfig, { resolveRoot } from './webpack.config.base';
+import { merge } from 'webpack-merge';
+
+export default merge(baseConfig, {
+ mode: 'development',
+ entry: {
+ mermaid: './src/mermaid.js',
+ e2e: './cypress/platform/viewer.js',
+ 'bundle-test': './cypress/platform/bundle-test.js',
+ },
+ output: {
+ globalObject: 'window',
+ },
+ devServer: {
+ compress: true,
+ port: 9000,
+ static: [
+ { directory: resolveRoot('cypress', 'platform') },
+ { directory: resolveRoot('dist') },
+ { directory: resolveRoot('demos') },
+ ],
+ },
+ externals: {
+ mermaid: 'mermaid',
+ },
+ module: {
+ rules: [
+ {
+ test: /\.js$/,
+ exclude: /node_modules/,
+ use: {
+ loader: 'babel-loader',
+ },
+ },
+ ],
+ },
+});
diff --git a/Renfay.md b/Renfay.md
deleted file mode 100644
index 2028f9cfb..000000000
--- a/Renfay.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Renfay project
-
-A note system!
diff --git a/cypress/integration/rendering/flowchart-v2.spec.js b/cypress/integration/rendering/flowchart-v2.spec.js
index 28ee03014..60fba981e 100644
--- a/cypress/integration/rendering/flowchart-v2.spec.js
+++ b/cypress/integration/rendering/flowchart-v2.spec.js
@@ -610,7 +610,7 @@ flowchart RL
imgSnapshotTest(
`flowchart TB
a{{"Lorem 'ipsum' dolor 'sit' amet, 'consectetur' adipiscing 'elit'."}}
- --> b{{"Lorem #quot;ipsum#quot; dolor #quot;sit#quot; amet,#quot;consectetur#quot; adipiscing #quot;elit#quot;."}}
+ --> b{{"Lorem #quot;ipsum#quot; dolor #quot;sit#quot; amet,#quot;consectetur#quot; adipiscing #quot;elit#quot;."}}
`,
{ htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
);
@@ -638,4 +638,15 @@ flowchart RL
{ htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
);
});
+
+ it('2388: handling default in the node name', () => {
+ imgSnapshotTest(
+ `
+ flowchart LR
+ default-index.js --> dot.template.js
+ index.js --> module-utl.js
+ `,
+ { htmlLabels: true, flowchart: { htmlLabels: true }, securityLevel: 'loose' }
+ );
+ });
});
diff --git a/cypress/integration/rendering/theme.spec.js b/cypress/integration/rendering/theme.spec.js
index f42dd0c2f..30a7efb7f 100644
--- a/cypress/integration/rendering/theme.spec.js
+++ b/cypress/integration/rendering/theme.spec.js
@@ -1,5 +1,30 @@
import { imgSnapshotTest } from '../../helpers/util.js';
+describe('themeCSS balancing, it', () => {
+ it('should not allow unbalanced CSS definitions', () => {
+ imgSnapshotTest(
+ `
+ %%{init: { 'themeCSS': '} * { background: red }' } }%%
+ flowchart TD
+ a --> b
+ `,
+ {}
+ );
+ cy.get('svg');
+ });
+ it('should not allow unbalanced CSS definitions 2', () => {
+ imgSnapshotTest(
+ `
+ %%{init: { 'themeCSS': '\u007D * { background: red }' } }%%
+ flowchart TD
+ a2 --> b2
+ `,
+ {}
+ );
+ cy.get('svg');
+ });
+});
+
describe('Pie Chart', () => {
// beforeEach(()=>{
// cy.clock((new Date('2014-06-09')).getTime());
diff --git a/cypress/platform/class.html b/cypress/platform/class.html
index a766639bd..ae4e18a5b 100644
--- a/cypress/platform/class.html
+++ b/cypress/platform/class.html
@@ -115,14 +115,14 @@