diff --git a/.esbuild/esbuild.cjs b/.esbuild/esbuild.cjs deleted file mode 100644 index 393dadcf31..0000000000 --- a/.esbuild/esbuild.cjs +++ /dev/null @@ -1,20 +0,0 @@ -const { esmBuild, esmCoreBuild, iifeBuild } = require('./util.cjs'); -const { build } = require('esbuild'); - -const handler = (e) => { - console.error(e); - process.exit(1); -}; -const watch = process.argv.includes('--watch'); - -// mermaid.js -build(iifeBuild({ minify: false, watch })).catch(handler); -// mermaid.esm.mjs -build(esmBuild({ minify: false, watch })).catch(handler); - -// mermaid.min.js -build(iifeBuild()).catch(handler); -// mermaid.esm.min.mjs -build(esmBuild()).catch(handler); -// mermaid.core.mjs (node_modules unbundled) -build(esmCoreBuild()).catch(handler); diff --git a/.esbuild/serve.cjs b/.esbuild/serve.cjs deleted file mode 100644 index 4c06572f3e..0000000000 --- a/.esbuild/serve.cjs +++ /dev/null @@ -1,79 +0,0 @@ -const esbuild = require('esbuild'); -const http = require('http'); -const { iifeBuild, esmBuild } = require('./util.cjs'); -const express = require('express'); - -// Start 2 esbuild servers. One for IIFE and one for ESM -// Serve 2 static directories: demo & cypress/platform -// Have 3 entry points: -// mermaid: './src/mermaid', -// e2e: './cypress/platform/viewer.js', -// 'bundle-test': './cypress/platform/bundle-test.js', - -const getEntryPointsAndExtensions = (format) => { - return { - entryPoints: { - mermaid: './src/mermaid', - e2e: 'cypress/platform/viewer.js', - 'bundle-test': 'cypress/platform/bundle-test.js', - }, - outExtension: { '.js': format === 'iife' ? '.js' : '.esm.mjs' }, - }; -}; - -const generateHandler = (server) => { - return (req, res) => { - const options = { - hostname: server.host, - port: server.port, - path: req.url, - method: req.method, - headers: req.headers, - }; - // Forward each incoming request to esbuild - const proxyReq = http.request(options, (proxyRes) => { - // If esbuild returns "not found", send a custom 404 page - if (proxyRes.statusCode === 404) { - if (!req.url.endsWith('.html')) { - res.writeHead(404, { 'Content-Type': 'text/html' }); - res.end('
-flowchart LR - a --- -
flowchart LR - a2 --- + subgraph one + direction LR + A[myClass1] --> B[default] + subgraph two + direction BT + C[myClass2] --> D[default] + end + end +
flowchart LR @@ -79,7 +83,7 @@ end end-
+flowchart TD release-branch[Create Release Branch]:::relClass @@ -131,7 +135,7 @@ class A someclass; class C someclass;-+sequenceDiagram title: My Sequence Diagram Title accTitle: My Acc Sequence Diagram @@ -141,14 +145,14 @@ John-->>Alice: Great! Alice-)John: See you later!-+graph TD A -->|000| B B -->|111| C linkStyle 1 stroke:#ff3,stroke-width:4px,color:red;-+journey accTitle: My User Journey Diagram accDescr: My User Journey Diagram Description @@ -162,10 +166,10 @@ Go downstairs: 5: Me Sit down: 5: Me-+info-+requirementDiagram accTitle: My req Diagram accDescr: My req Diagram Description @@ -206,7 +210,7 @@ test_req - contains -> test_req3 test_req <- copies - test_entity2-+gantt dateFormat YYYY-MM-DD title Adding GANTT diagram functionality to mermaid @@ -238,7 +242,7 @@ Add gantt diagram to demo page :20h Add another diagram to demo page :48h-+stateDiagram state Active { Idle @@ -266,7 +270,7 @@ end B ->> A: Return-+classDiagram accTitle: My class diagram accDescr: My class diagram Description @@ -291,7 +295,7 @@ A->>Bob: Hola Bob-->A: Pasten !-+gitGraph commit id: "ZERO" branch develop @@ -320,7 +324,7 @@ C -->|Two| E[iPhone] C -->|Three| F[fa:fa-car Car]-+classDiagram Animal "1" <|-- Duck Animal <|-- Fish @@ -343,7 +347,7 @@ +run() }-+erDiagram CAR ||--o{ NAMED-DRIVER : allows CAR { diff --git a/cypress/platform/viewer.js b/cypress/platform/viewer.js index 00f45ff943..53ba75d744 100644 --- a/cypress/platform/viewer.js +++ b/cypress/platform/viewer.js @@ -1,6 +1,9 @@ -import { Base64 } from 'js-base64'; import mermaid2 from '../../src/mermaid'; +function b64ToUtf8(str) { + return decodeURIComponent(escape(window.atob(str))); +} + /** * ##contentLoaded Callback function that is called when page is loaded. This functions fetches * configuration for mermaid rendering and calls init for rendering the mermaid diagrams on the @@ -11,7 +14,7 @@ const contentLoaded = function () { if (pos > 0) { pos = pos + 7; const graphBase64 = document.location.href.substr(pos); - const graphObj = JSON.parse(Base64.decode(graphBase64)); + const graphObj = JSON.parse(b64ToUtf8(graphBase64)); if (graphObj.mermaid && graphObj.mermaid.theme === 'dark') { document.body.style.background = '#3f3f3f'; } @@ -67,7 +70,7 @@ const contentLoadedApi = function () { if (pos > 0) { pos = pos + 7; const graphBase64 = document.location.href.substr(pos); - const graphObj = JSON.parse(Base64.decode(graphBase64)); + const graphObj = JSON.parse(b64ToUtf8(graphBase64)); // const graph = 'hello' if (Array.isArray(graphObj.code)) { const numCodes = graphObj.code.length; diff --git a/cypress/platform/webpackUsage.html b/cypress/platform/webpackUsage.html index ec6edb4ea5..23df19f49e 100644 --- a/cypress/platform/webpackUsage.html +++ b/cypress/platform/webpackUsage.html @@ -12,6 +12,8 @@ - +