This commit is contained in:
sidharthv96
2021-12-29 17:32:05 +00:00
parent 936308d39e
commit b6f416ce68
13 changed files with 1316 additions and 9 deletions
+18
View File
@@ -0,0 +1,18 @@
var S=Object.defineProperty,b=Object.defineProperties;var k=Object.getOwnPropertyDescriptors;var d=Object.getOwnPropertySymbols;var v=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var u=(t,e,s)=>e in t?S(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,i=(t,e)=>{for(var s in e||(e={}))v.call(e,s)&&u(t,s,e[s]);if(d)for(var s of d(e))C.call(e,s)&&u(t,s,e[s]);return t},o=(t,e)=>b(t,k(e));import{C as m,J as L,K as O,L as _,M as N,N as l,O as T}from"./vendor-df9de99c.js";import{_ as g}from"./preload-helper-1db36302.js";const D={loading:!1},f=m(D),B=async(t,e)=>{f.set({loading:!0,message:t});const s=await e;return f.set({loading:!1}),s};let n;const G=async()=>{if(!n)try{const{Analytics:t}=await g(()=>import("./analytics.browser.es-6f4635ad.js"),[]),e=await g(()=>import("./analytics-plugin-ga.browser.es-1cdb0512.js"),[]);n=t({app:"mermaid-live-editor",plugins:[e.init({trackingId:"UA-153180559-1"})]})}catch{console.info("Analytics blocked ;)")}},J=t=>t.replace(/^\s*%%.*\n/g,`
`).trimStart().split(" ")[0];let p;const w=t=>{n&&(clearTimeout(p),p=setTimeout(function(){const e=J(t);console.debug("ga:","send","event","render",e),n.track("render",{graphType:e})},5e3))},A={code:`graph TD
A[Christmas] -->|Get money| B(Go shopping)
B --> C{Let me think}
C -->|One| D[Laptop]
C -->|Two| E[iPhone]
C -->|Three| F[fa:fa-car Car]
`,mermaid:JSON.stringify({theme:"default"},null,2),updateEditor:!1,autoSync:!0,updateDiagram:!0},E=`graph TD
A[Loading URL failed. We can try to figure out why.] -->|Decode JSON| B(Please check the console to see the JSON and error details.)
B --> C{Is the JSON correct?}
C -->|Yes| D(Please Click here to Raise an issue in github.<br/>Including the broken link in the issue <br/> will speed up the fix.)
C -->|No| E{Did someone <br/>send you this link?}
E -->|Yes| F[Ask them to send <br/>you the complete link]
E -->|No| G{Did you copy <br/> the complete URL?}
G --> |Yes| D
G --> |"No :("| H(Try using the Timeline tab in History <br/>from same browser you used to create the diagram.)
click D href "https://github.com/mermaid-js/mermaid-live-editor/issues/new?assignees=&labels=bug&template=bug_report.md&title=Broken%20link" "Raise issue"`,a=L(m(A),O(),"codeStore"),R=_([a],([t],e)=>{e(N(JSON.stringify(t),!0))}),U=t=>{let e;try{const s=T(t);console.log(`Trying to load state: ${s}`),e=JSON.parse(s);const r=typeof e.mermaid=="string"?JSON.parse(e.mermaid):e.mermaid;r.securityLevel&&r.securityLevel!=="strict"&&confirm(`Removing "securityLevel":"${r.securityLevel}" from the config for safety.
Click Cancel if you trust the source of this Diagram.`)&&delete r.securityLevel,e.mermaid=JSON.stringify(r,null,2)}catch(s){e=l(a),t&&(console.error("Init error",s),e.code=E)}y(o(i({},e),{updateEditor:!0}))},y=t=>{a.update(e=>i(i({},e),t))};let h=!1;const F=(t,e,s=!1)=>{if(w(t),(t.match(/\n/g)||"").length+1>50&&!h&&l(a).autoSync){const c=confirm("Long diagram detected. Turn off Auto Sync? Click the sync logo to manually sync.");h=!0,c&&y({autoSync:!1})}a.update(c=>o(i({},c),{code:t,updateEditor:e,updateDiagram:s}))},Y=(t,e)=>{a.update(s=>o(i({},s),{mermaid:t,updateEditor:e}))},$=t=>{a.update(e=>{const s=JSON.parse(e.mermaid);return(!s.theme||["dark","default"].includes(s.theme))&&(s.theme=t?"dark":"default"),o(i({},e),{mermaid:JSON.stringify(s,null,2),updateEditor:!0})})},x=()=>{R.subscribe(t=>{history.replaceState(void 0,void 0,`#${t}`)})},H=()=>JSON.stringify(l(a));export{n as a,R as b,a as c,Y as d,A as e,y as f,H as g,x as h,B as i,G as j,U as k,f as l,$ as t,F as u};
+1
View File
@@ -0,0 +1 @@
import{J as e,K as t,C as o}from"./vendor-df9de99c.js";const r=e(o({isDark:!1}),t(),"themeStore"),l=["dark","synthwave","halloween","aqua","forest","luxury","black","dracula"],i=s=>{s.includes(" ")&&(s=s.split(" ")[1].trim());const a=l.includes(s);console.log("Setting theme",s),r.set({theme:s,isDark:a})};export{i as s,r as t};
+1
View File
@@ -0,0 +1 @@
var K=Object.defineProperty,X=Object.defineProperties;var Y=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var Z=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable;var O=(t,e,a)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[e]=a,_=(t,e)=>{for(var a in e||(e={}))Z.call(e,a)&&O(t,a,e[a]);if(L)for(var a of L(e))x.call(e,a)&&O(t,a,e[a]);return t},w=(t,e)=>X(t,Y(e));import{C as f,S as B,i as Q,s as W,e as j,c as T,a as U,d as S,b as p,Z as m,f as $,E as tt,P as F,I as et,A as at,ab as ot,ac as G,R as N,J as v,K as b,L as st,ad as rt,N as D}from"./vendor-df9de99c.js";import{c as H,e as I,f as R,i as it,h as nt,j as ct,a as lt,k as ut}from"./state-a3541b23.js";const dt=f(void 0);function ft(t){let e,a;return{c(){e=j("div"),a=j("div"),this.h()},l(s){e=T(s,"DIV",{id:!0,class:!0});var o=U(e);a=T(o,"DIV",{id:!0,class:!0}),U(a).forEach(S),o.forEach(S),this.h()},h(){p(a,"id","container"),p(a,"class","flex-1 overflow-auto"),p(e,"id","view"),p(e,"class","p-2 svelte-5ndy2s"),m(e,"error",t[2]),m(e,"outOfSync",t[3])},m(s,o){$(s,e,o),tt(e,a),t[4](a),t[5](e)},p(s,[o]){o&4&&m(e,"error",s[2]),o&8&&m(e,"outOfSync",s[3])},i:F,o:F,d(s){s&&S(e),t[4](null),t[5](null)}}}function pt(t,e,a){let s;et(t,H,i=>a(9,s=i));let o="",u="",r,c,n=!1,l=!1,d=!0;at(()=>{H.subscribe(i=>{try{if(r&&i&&(i.updateDiagram||i.autoSync)){if(i.autoSync||ot(H,s.updateDiagram=!1,s),a(3,l=!1),d=!0,o===i.code&&u===i.mermaid)return;o=i.code,u=i.mermaid;const y=c.parentElement.scrollTop;delete r.dataset.processed,G.initialize(Object.assign({},JSON.parse(i.mermaid))),G.render("graph-div",o,z=>{a(0,r.innerHTML=z,r)}),a(1,c.parentElement.scrollTop=y,c),a(2,n=!1)}else d?d=!1:a(3,l=!0)}catch(y){console.log("view fail",y),a(2,n=!0)}}),dt.subscribe(i=>{typeof i=="undefined"?a(2,n=!1):(a(2,n=!0),console.log("Error: ",i))})});function M(i){N[i?"unshift":"push"](()=>{r=i,a(0,r)})}function q(i){N[i?"unshift":"push"](()=>{c=i,a(1,c)})}return[r,c,n,l,M,q]}class It extends B{constructor(e){super();Q(this,e,pt,ft,W,{})}}const mt=30,E=v(f("manual"),b(),"autoHistoryMode"),g=v(f([]),b(),"autoHistoryStore"),h=v(f([]),b(),"manualHistoryStore"),V=f([]),Et=st([E,g,h,V],([t,e,a,s],o)=>{o(t==="auto"?e:t==="manual"?a:t==="loader"?s:e)}),gt=t=>{if(t.type==="loader"){V.update(e=>[t,...e]);return}if(t.name=rt(2),t.type!=="auto"){h.update(e=>[t,...e]);return}g.update(e=>(e.length===mt&&e.pop(),[t,...e]))},Lt=t=>{(D(E)==="auto"?g:h).update(e=>(D(E)!=="loader"&&(e=e.filter(a=>t&&a.time!=t)),e))},Ot=t=>{const e=D(t?g:h);return e.length>0?JSON.stringify(e[0].state):""},k="code.mmd",A="config.json",ht=t=>k in t,C=async t=>t.truncated?await(await fetch(t.raw_url)).text():t.content,yt=async t=>{const[e,a,s,o]=t.split("github.com").pop().split("/"),{html_url:u,files:r,history:c}=await(await fetch(`https://api.github.com/gists/${s}${o?"/"+o:""}`)).json();if(ht(r)){const n=await C(r[k]);let l;A in r&&(l=await C(r[A]));const d=c[0];return{url:`${u}/${d.version}`,code:n,config:l,author:d.user.login,time:new Date(d.committed_at).getTime(),version:d.version.slice(-7)}}else throw"Invalid gist provided"},P=(t,e=t.url)=>{const a=w(_({},I),{code:t.code,loader:{type:"gist",config:{url:e}}});return t.config&&(a.mermaid=t.config),a},_t=async t=>{try{const[e,a,s,o]=t.split("github.com").pop().split("/"),{history:u}=await(await fetch(`https://api.github.com/gists/${s}${o?"/"+o:""}`)).json(),r=[];for(const n of u){const l=await yt(n.url).catch(()=>{});l&&r.push(l)}if(r.length===0)throw"Invalid gist provided";r.reverse();const c=P(r.slice(-1).pop(),t);for(const n of r)gt({state:P(n),time:n.time,type:"loader",url:n.url,name:`${n.author} v${n.version}`});return c}catch(e){console.error(e)}},J={gist:_t},wt=async()=>{const t=new URLSearchParams(window.location.search);let e=I,a,s,o=!1;const u=t.get("code"),r=t.get("config");if(u&&(a=await(await fetch(u)).text(),o=!0),r?s=await(await fetch(r)).text():s=I.mermaid,a)e={code:a,mermaid:s,loader:{type:"files",config:{codeURL:u,configURL:r}}};else for(const[c,n]of t.entries())if(c in J)try{e=await J[c](n),o=!0;break}catch(l){console.error(l)}o&&R(w(_({},e),{autoSync:!0,updateDiagram:!0,updateEditor:!0}))},St=()=>{ut(window.location.hash.slice(1))},vt=()=>{R({updateDiagram:!0})},jt=async()=>{var t;St(),await it("Loading Gist...",wt().catch(console.error)),vt(),nt(),await ct(),(t=lt)==null||t.page()};export{It as V,Et as a,gt as b,Lt as c,dt as e,Ot as g,E as h,jt as i,V as l,vt as s};
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
import{S as y,i as z,s as A,e as d,t as E,c as v,a as b,g as P,d as _,f as u,E as R,h as N,k as S,l as q,n as h,P as C}from"./chunks/vendor-df9de99c.js";function H(r){let f,t=r[1].frame+"",a;return{c(){f=d("pre"),a=E(t)},l(l){f=v(l,"PRE",{});var s=b(f);a=P(s,t),s.forEach(_)},m(l,s){u(l,f,s),R(f,a)},p(l,s){s&2&&t!==(t=l[1].frame+"")&&N(a,t)},d(l){l&&_(f)}}}function w(r){let f,t=r[1].stack+"",a;return{c(){f=d("pre"),a=E(t)},l(l){f=v(l,"PRE",{});var s=b(f);a=P(s,t),s.forEach(_)},m(l,s){u(l,f,s),R(f,a)},p(l,s){s&2&&t!==(t=l[1].stack+"")&&N(a,t)},d(l){l&&_(f)}}}function B(r){let f,t,a,l,s=r[1].message+"",c,k,m,p,i=r[1].frame&&H(r),n=r[1].stack&&w(r);return{c(){f=d("h1"),t=E(r[0]),a=S(),l=d("pre"),c=E(s),k=S(),i&&i.c(),m=S(),n&&n.c(),p=q()},l(e){f=v(e,"H1",{});var o=b(f);t=P(o,r[0]),o.forEach(_),a=h(e),l=v(e,"PRE",{});var j=b(l);c=P(j,s),j.forEach(_),k=h(e),i&&i.l(e),m=h(e),n&&n.l(e),p=q()},m(e,o){u(e,f,o),R(f,t),u(e,a,o),u(e,l,o),R(l,c),u(e,k,o),i&&i.m(e,o),u(e,m,o),n&&n.m(e,o),u(e,p,o)},p(e,[o]){o&1&&N(t,e[0]),o&2&&s!==(s=e[1].message+"")&&N(c,s),e[1].frame?i?i.p(e,o):(i=H(e),i.c(),i.m(m.parentNode,m)):i&&(i.d(1),i=null),e[1].stack?n?n.p(e,o):(n=w(e),n.c(),n.m(p.parentNode,p)):n&&(n.d(1),n=null)},i:C,o:C,d(e){e&&_(f),e&&_(a),e&&_(l),e&&_(k),i&&i.d(e),e&&_(m),n&&n.d(e),e&&_(p)}}}function G({error:r,status:f}){return{props:{error:r,status:f}}}function D(r,f,t){let{status:a}=f,{error:l}=f;return r.$$set=s=>{"status"in s&&t(0,a=s.status),"error"in s&&t(1,l=s.error)},[a,l]}class I extends y{constructor(f){super();z(this,f,D,B,A,{status:0,error:1})}}export{I as default,G as load};
+1
View File
@@ -0,0 +1 @@
import{S as I,i as w,s as M,D as V,e as u,k as b,t as $,c as d,a as m,d as f,n as k,g as A,b as p,f as v,E as _,h as N,l as y,F as T,G as W,H as q,x,u as z,I as S,A as B}from"../chunks/vendor-df9de99c.js";import{b as j}from"../chunks/paths-28a87002.js";import{l as C,t as F}from"../chunks/state-a3541b23.js";import{t as D,s as G}from"../chunks/theme-83f39d3d.js";import"../chunks/preload-helper-1db36302.js";function E(n){let o,i,l,r,c,s=n[0].message+"",t;return{c(){o=u("div"),i=u("div"),l=u("div"),r=b(),c=u("div"),t=$(s),this.h()},l(e){o=d(e,"DIV",{class:!0});var a=m(o);i=d(a,"DIV",{class:!0});var h=m(i);l=d(h,"DIV",{class:!0}),m(l).forEach(f),r=k(h),c=d(h,"DIV",{});var g=m(c);t=A(g,s),g.forEach(f),h.forEach(f),a.forEach(f),this.h()},h(){p(l,"class","loader mx-auto svelte-1ub1m40"),p(i,"class","text-indigo-100 text-4xl font-bold my-auto"),p(o,"class","w-screen h-screen z-50 absolute left-0 top-0 bg-gray-600 opacity-50 flex align-middle justify-center")},m(e,a){v(e,o,a),_(o,i),_(i,l),_(i,r),_(i,c),_(c,t)},p(e,a){a&1&&s!==(s=e[0].message+"")&&N(t,s)},d(e){e&&f(o)}}}function H(n){let o,i,l,r;const c=n[2].default,s=V(c,n,n[1],null);let t=n[0].loading&&E(n);return{c(){o=u("main"),s&&s.c(),i=b(),t&&t.c(),l=y(),this.h()},l(e){o=d(e,"MAIN",{class:!0});var a=m(o);s&&s.l(a),a.forEach(f),i=k(e),t&&t.l(e),l=y(),this.h()},h(){p(o,"class","h-screen text-primary-content")},m(e,a){v(e,o,a),s&&s.m(o,null),v(e,i,a),t&&t.m(e,a),v(e,l,a),r=!0},p(e,[a]){s&&s.p&&(!r||a&2)&&T(s,c,e,e[1],r?q(c,e[1],a,null):W(e[1]),null),e[0].loading?t?t.p(e,a):(t=E(e),t.c(),t.m(l.parentNode,l)):t&&(t.d(1),t=null)},i(e){r||(x(s,e),r=!0)},o(e){z(s,e),r=!1},d(e){e&&f(o),s&&s.d(e),e&&f(i),t&&t.d(e),e&&f(l)}}}function R(n,o,i){let l,r;S(n,D,t=>i(3,l=t)),S(n,C,t=>i(0,r=t));let{$$slots:c={},$$scope:s}=o;return B(()=>{"serviceWorker"in navigator&&navigator.serviceWorker.register(`${j}/service-worker.js`,{scope:`${j}/`}).then(function(e){console.log("Registration successful, scope is:",e.scope)}).catch(function(e){console.log("Service worker registration failed, error:",e)});const t=window.matchMedia("(prefers-color-scheme: dark)").matches;l.theme===void 0&&G(t?"dark":"light"),D.subscribe(({theme:e,isDark:a})=>{e&&(document.getElementsByTagName("html")[0].setAttribute("data-theme",e),F(a))})}),n.$$set=t=>{"$$scope"in t&&i(1,s=t.$$scope)},[r,s,c]}class Q extends I{constructor(o){super();w(this,o,R,H,M,{})}}export{Q as default};
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
import{S as n,i as e,s as a,A as r}from"../chunks/vendor-df9de99c.js";import{r as c}from"../chunks/singletons-12a22614.js";import{b as i}from"../chunks/paths-28a87002.js";const u=c,l=f;async function f(s,t){return u.goto(s,t,[])}function h(s){return r(async()=>{const t=window.location.hash.split("/");let o="edit";t.length>2&&(o=`${t[1]}#${t[2]}`),await l(`${i}/${o}`,{replaceState:!0})}),[]}class $ extends n{constructor(t){super();e(this,t,h,null,a,{})}}export{$ as default};
+1
View File
@@ -0,0 +1 @@
import{S as o,i as r,s as i,j as c,m as u,o as m,P as f,x as p,u as l,v as d,A as _}from"../chunks/vendor-df9de99c.js";import{V as $,i as h}from"../chunks/util-20af176b.js";import"../chunks/state-a3541b23.js";import"../chunks/preload-helper-1db36302.js";function g(s){let t,n;return t=new $({}),{c(){c(t.$$.fragment)},l(e){u(t.$$.fragment,e)},m(e,a){m(t,e,a),n=!0},p:f,i(e){n||(p(t.$$.fragment,e),n=!0)},o(e){l(t.$$.fragment,e),n=!1},d(e){d(t,e)}}}function j(s){return _(h),[]}class b extends o{constructor(t){super();r(this,t,j,g,i,{})}}export{b as default};
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -43,15 +43,15 @@
<link rel="modulepreload" href="/mermaid-live-editor/_app/start-90bfd580.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/vendor-e606199c.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/start-f961bab1.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/vendor-df9de99c.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/preload-helper-1db36302.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/singletons-12a22614.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/paths-28a87002.js">
<link rel="stylesheet" href="/mermaid-live-editor/_app/assets/start-464e9d0a.css">
<script type="module">
import { start } from "/mermaid-live-editor/_app/start-90bfd580.js";
import { start } from "/mermaid-live-editor/_app/start-f961bab1.js";
start({
target: document.querySelector("#svelte"),
paths: {"base":"/mermaid-live-editor","assets":""},
+3 -3
View File
@@ -43,15 +43,15 @@
<link rel="modulepreload" href="/mermaid-live-editor/_app/start-90bfd580.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/vendor-e606199c.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/start-f961bab1.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/vendor-df9de99c.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/preload-helper-1db36302.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/singletons-12a22614.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/paths-28a87002.js">
<link rel="stylesheet" href="/mermaid-live-editor/_app/assets/start-464e9d0a.css">
<script type="module">
import { start } from "/mermaid-live-editor/_app/start-90bfd580.js";
import { start } from "/mermaid-live-editor/_app/start-f961bab1.js";
start({
target: document.querySelector("#svelte"),
paths: {"base":"/mermaid-live-editor","assets":""},
+3 -3
View File
@@ -43,15 +43,15 @@
<link rel="modulepreload" href="/mermaid-live-editor/_app/start-90bfd580.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/vendor-e606199c.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/start-f961bab1.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/vendor-df9de99c.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/preload-helper-1db36302.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/singletons-12a22614.js">
<link rel="modulepreload" href="/mermaid-live-editor/_app/chunks/paths-28a87002.js">
<link rel="stylesheet" href="/mermaid-live-editor/_app/assets/start-464e9d0a.css">
<script type="module">
import { start } from "/mermaid-live-editor/_app/start-90bfd580.js";
import { start } from "/mermaid-live-editor/_app/start-f961bab1.js";
start({
target: document.querySelector("#svelte"),
paths: {"base":"/mermaid-live-editor","assets":""},