@diplodoc/mermaid-extension 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/hooks/index.js +2 -2
- package/hooks/index.js.map +2 -2
- package/hooks/useMermaid.d.ts +2 -1
- package/package.json +1 -1
- package/runtime/index.js +1 -1
- package/runtime/index.js.map +3 -3
package/hooks/index.js
CHANGED
|
@@ -23,10 +23,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
23
23
|
import { useEffect, useState, useCallback } from "react";
|
|
24
24
|
function useMermaid() {
|
|
25
25
|
const [mermaid, setMermaid] = useState(null);
|
|
26
|
-
const render = useCallback((config) => __async(this, null, function* () {
|
|
26
|
+
const render = useCallback((config, options) => __async(this, null, function* () {
|
|
27
27
|
if (mermaid) {
|
|
28
28
|
mermaid.initialize(config);
|
|
29
|
-
return mermaid.run();
|
|
29
|
+
return mermaid.run(options);
|
|
30
30
|
}
|
|
31
31
|
}), [mermaid]);
|
|
32
32
|
useEffect(() => {
|
package/hooks/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/hooks/useMermaid.ts"],
|
|
4
|
-
"sourcesContent": ["import type { MermaidConfig } from 'mermaid';\nimport { useEffect, useState, useCallback } from 'react';\nimport { Callback } from '../@types/common';\n\nexport function useMermaid() {\n const [ mermaid, setMermaid ] = useState<Parameters<Callback>[0] | null>(null);\n const render = useCallback(async (config: MermaidConfig) => {\n if (mermaid) {\n mermaid.initialize(config);\n return mermaid.run();\n }\n }, [ mermaid ]);\n\n useEffect(() => {\n (window.mermaidJsonp = window.mermaidJsonp || []).push(setMermaid);\n\n return () => {\n const index = window.mermaidJsonp.indexOf(setMermaid);\n if (index > -1) {\n window.mermaidJsonp.splice(index, 1);\n }\n };\n }, []);\n\n return render;\n}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,WAAW,UAAU,mBAAmB;AAG1C,SAAS,aAAa;AACzB,QAAM,CAAE,SAAS,UAAW,IAAI,SAAyC,IAAI;AAC7E,QAAM,SAAS,YAAY,CAAO,
|
|
4
|
+
"sourcesContent": ["import type { MermaidConfig } from 'mermaid';\nimport { useEffect, useState, useCallback } from 'react';\nimport { Callback, RunOptions } from '../@types/common';\n\nexport function useMermaid() {\n const [ mermaid, setMermaid ] = useState<Parameters<Callback>[0] | null>(null);\n const render = useCallback(async (config: MermaidConfig, options?: RunOptions) => {\n if (mermaid) {\n mermaid.initialize(config);\n return mermaid.run(options);\n }\n }, [ mermaid ]);\n\n useEffect(() => {\n (window.mermaidJsonp = window.mermaidJsonp || []).push(setMermaid);\n\n return () => {\n const index = window.mermaidJsonp.indexOf(setMermaid);\n if (index > -1) {\n window.mermaidJsonp.splice(index, 1);\n }\n };\n }, []);\n\n return render;\n}"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;AACA,SAAS,WAAW,UAAU,mBAAmB;AAG1C,SAAS,aAAa;AACzB,QAAM,CAAE,SAAS,UAAW,IAAI,SAAyC,IAAI;AAC7E,QAAM,SAAS,YAAY,CAAO,QAAuB,YAAyB;AAC9E,QAAI,SAAS;AACT,cAAQ,WAAW,MAAM;AACzB,aAAO,QAAQ,IAAI,OAAO;AAAA,IAC9B;AAAA,EACJ,IAAG,CAAE,OAAQ,CAAC;AAEd,YAAU,MAAM;AACZ,KAAC,OAAO,eAAe,OAAO,gBAAgB,CAAC,GAAG,KAAK,UAAU;AAEjE,WAAO,MAAM;AACT,YAAM,QAAQ,OAAO,aAAa,QAAQ,UAAU;AACpD,UAAI,QAAQ,IAAI;AACZ,eAAO,aAAa,OAAO,OAAO,CAAC;AAAA,MACvC;AAAA,IACJ;AAAA,EACJ,GAAG,CAAC,CAAC;AAEL,SAAO;AACX;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/hooks/useMermaid.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { MermaidConfig } from 'mermaid';
|
|
2
|
-
|
|
2
|
+
import { RunOptions } from '../@types/common';
|
|
3
|
+
export declare function useMermaid(): (config: MermaidConfig, options?: RunOptions) => Promise<void>;
|
package/package.json
CHANGED
package/runtime/index.js
CHANGED
|
@@ -1562,7 +1562,7 @@ ${i.themeCSS}`),i.fontFamily!==void 0&&(b+=`
|
|
|
1562
1562
|
`)})}g[0]=g[0].replace(/^\r?\n/,"");var E=g[0];return o.forEach(function(w,L){var O=E.match(/(?:^|\n)( *)$/),B=O?O[1]:"",P=w;typeof w=="string"&&w.includes(`
|
|
1563
1563
|
`)&&(P=String(w).split(`
|
|
1564
1564
|
`).map(function(j,G){return G===0?j:""+B+j}).join(`
|
|
1565
|
-
`)),E+=P+g[L+1]}),E}var Wht=L1n;lu();g1();Tv();var ZOr=is(Zf(),1),JOr=is(Dh(),1);var tNr=is(V1(),1);sc();var rOn=(i,o,h)=>{jt.warn(i),DDt(i)?(h&&h(i.str,i.hash),o.push({...i,message:i.str,error:i})):(h&&h(i),i instanceof Error&&o.push({str:i.message,message:i.message,hash:i.name,error:i}))},zOe=async function(i={querySelector:".mermaid"}){try{await iOn(i)}catch(o){if(DDt(o)&&jt.error(o.str),Nv.parseError&&Nv.parseError(o),!i.suppressErrors)throw jt.error("Use the suppressErrors option to suppress these errors"),o}},iOn=async function({postRenderCallback:i,querySelector:o,nodes:h}={querySelector:".mermaid"}){let g=Mu.getConfig();jt.debug(`${i?"":"No "}Callback function found`);let b;if(h)b=h;else if(o)b=document.querySelectorAll(o);else throw new Error("Nodes and querySelector are both undefined");jt.debug(`Found ${b.length} diagrams`),g?.startOnLoad!==void 0&&(jt.debug("Start On Load: "+g?.startOnLoad),Mu.updateSiteConfig({startOnLoad:g?.startOnLoad}));let x=new Gs.initIdGenerator(g.deterministicIds,g.deterministicIDSeed),E,w=[];for(let L of Array.from(b)){jt.info("Rendering diagram: "+L.id);if(L.getAttribute("data-processed"))continue;L.setAttribute("data-processed","true");let O=`mermaid-${x.next()}`;E=L.innerHTML,E=Wht(Gs.entityDecode(E)).trim().replace(/<br\s*\/?>/gi,"<br/>");let B=Gs.detectInit(E);B&&jt.debug("Detected early reinit: ",B);try{let{svg:P,bindFunctions:j}=await VOe(O,E,L);L.innerHTML=P,i&&await i(O),j&&j(L)}catch(P){rOn(P,w,Nv.parseError)}}if(w.length>0)throw w[0]},HOe=function(i){Mu.initialize(i)},sOn=async function(i,o,h){jt.warn("mermaid.init is deprecated. Please use run instead."),i&&HOe(i);let g={postRenderCallback:h,querySelector:".mermaid"};typeof o=="string"?g.querySelector=o:o&&(o instanceof HTMLElement?g.nodes=[o]:g.nodes=o),await zOe(g)},aOn=async(i,{lazyLoad:o=!0}={})=>{Ndt(...i),o===!1&&await lEe()},$Oe=function(){if(Nv.startOnLoad){let{startOnLoad:i}=Mu.getConfig();i&&Nv.run().catch(o=>jt.error("Mermaid failed to initialize",o))}};if(typeof document<"u"){window.addEventListener("load",$Oe,!1)}var oOn=function(i){Nv.parseError=i},dgt=[],eBt=!1,GOe=async()=>{if(!eBt){for(eBt=!0;dgt.length>0;){let i=dgt.shift();if(i)try{await i()}catch(o){jt.error("Error executing queue",o)}}eBt=!1}},cOn=async(i,o)=>new Promise((h,g)=>{let b=()=>new Promise((x,E)=>{Mu.parse(i,o).then(w=>{x(w),h(w)},w=>{var L;jt.error("Error parsing",w),(L=Nv.parseError)==null||L.call(Nv,w),E(w),g(w)})});dgt.push(b),GOe().catch(g)}),VOe=(i,o,h)=>new Promise((g,b)=>{let x=()=>new Promise((E,w)=>{Mu.render(i,o,h).then(L=>{E(L),g(L)},L=>{var O;jt.error("Error parsing",L),(O=Nv.parseError)==null||O.call(Nv,L),w(L),b(L)})});dgt.push(x),GOe().catch(b)}),Nv={startOnLoad:!0,mermaidAPI:Mu,parse:cOn,render:VOe,init:sOn,run:zOe,registerExternalDiagrams:aOn,initialize:HOe,parseError:void 0,contentLoaded:$Oe,setParseErrorHandler:oOn};Nv.initialize({startOnLoad:!1,theme:"forest"});var nBt=window.mermaidJsonp=window.mermaidJsonp||[],rBt=nBt.splice(0,nBt.length);nBt.push=function(...i){return i.forEach(o=>{rBt.push(o),qOe()}),rBt.length};var iBt=!1;function qOe(){iBt||UOe()}async function UOe(){iBt=!0;let i=rBt.shift();if(i)return await i({run:async({querySelector:o=".mermaid"}={})=>{let h
|
|
1565
|
+
`)),E+=P+g[L+1]}),E}var Wht=L1n;lu();g1();Tv();var ZOr=is(Zf(),1),JOr=is(Dh(),1);var tNr=is(V1(),1);sc();var rOn=(i,o,h)=>{jt.warn(i),DDt(i)?(h&&h(i.str,i.hash),o.push({...i,message:i.str,error:i})):(h&&h(i),i instanceof Error&&o.push({str:i.message,message:i.message,hash:i.name,error:i}))},zOe=async function(i={querySelector:".mermaid"}){try{await iOn(i)}catch(o){if(DDt(o)&&jt.error(o.str),Nv.parseError&&Nv.parseError(o),!i.suppressErrors)throw jt.error("Use the suppressErrors option to suppress these errors"),o}},iOn=async function({postRenderCallback:i,querySelector:o,nodes:h}={querySelector:".mermaid"}){let g=Mu.getConfig();jt.debug(`${i?"":"No "}Callback function found`);let b;if(h)b=h;else if(o)b=document.querySelectorAll(o);else throw new Error("Nodes and querySelector are both undefined");jt.debug(`Found ${b.length} diagrams`),g?.startOnLoad!==void 0&&(jt.debug("Start On Load: "+g?.startOnLoad),Mu.updateSiteConfig({startOnLoad:g?.startOnLoad}));let x=new Gs.initIdGenerator(g.deterministicIds,g.deterministicIDSeed),E,w=[];for(let L of Array.from(b)){jt.info("Rendering diagram: "+L.id);if(L.getAttribute("data-processed"))continue;L.setAttribute("data-processed","true");let O=`mermaid-${x.next()}`;E=L.innerHTML,E=Wht(Gs.entityDecode(E)).trim().replace(/<br\s*\/?>/gi,"<br/>");let B=Gs.detectInit(E);B&&jt.debug("Detected early reinit: ",B);try{let{svg:P,bindFunctions:j}=await VOe(O,E,L);L.innerHTML=P,i&&await i(O),j&&j(L)}catch(P){rOn(P,w,Nv.parseError)}}if(w.length>0)throw w[0]},HOe=function(i){Mu.initialize(i)},sOn=async function(i,o,h){jt.warn("mermaid.init is deprecated. Please use run instead."),i&&HOe(i);let g={postRenderCallback:h,querySelector:".mermaid"};typeof o=="string"?g.querySelector=o:o&&(o instanceof HTMLElement?g.nodes=[o]:g.nodes=o),await zOe(g)},aOn=async(i,{lazyLoad:o=!0}={})=>{Ndt(...i),o===!1&&await lEe()},$Oe=function(){if(Nv.startOnLoad){let{startOnLoad:i}=Mu.getConfig();i&&Nv.run().catch(o=>jt.error("Mermaid failed to initialize",o))}};if(typeof document<"u"){window.addEventListener("load",$Oe,!1)}var oOn=function(i){Nv.parseError=i},dgt=[],eBt=!1,GOe=async()=>{if(!eBt){for(eBt=!0;dgt.length>0;){let i=dgt.shift();if(i)try{await i()}catch(o){jt.error("Error executing queue",o)}}eBt=!1}},cOn=async(i,o)=>new Promise((h,g)=>{let b=()=>new Promise((x,E)=>{Mu.parse(i,o).then(w=>{x(w),h(w)},w=>{var L;jt.error("Error parsing",w),(L=Nv.parseError)==null||L.call(Nv,w),E(w),g(w)})});dgt.push(b),GOe().catch(g)}),VOe=(i,o,h)=>new Promise((g,b)=>{let x=()=>new Promise((E,w)=>{Mu.render(i,o,h).then(L=>{E(L),g(L)},L=>{var O;jt.error("Error parsing",L),(O=Nv.parseError)==null||O.call(Nv,L),w(L),b(L)})});dgt.push(x),GOe().catch(b)}),Nv={startOnLoad:!0,mermaidAPI:Mu,parse:cOn,render:VOe,init:sOn,run:zOe,registerExternalDiagrams:aOn,initialize:HOe,parseError:void 0,contentLoaded:$Oe,setParseErrorHandler:oOn};Nv.initialize({startOnLoad:!1,theme:"forest"});var nBt=window.mermaidJsonp=window.mermaidJsonp||[],rBt=nBt.splice(0,nBt.length);nBt.push=function(...i){return i.forEach(o=>{rBt.push(o),qOe()}),rBt.length};var iBt=!1;function qOe(){iBt||UOe()}async function UOe(){iBt=!0;let i=rBt.shift();if(i)return await i({run:async({querySelector:o=".mermaid",nodes:h}={})=>{let g=h||document.querySelectorAll(o);for(let b of Array.from(g)){let x=`mermaid-${Date.now()}`,E=b.getAttribute("data-content")||"",w=Wht(decodeURIComponent(E)).trim().replace(/<br\s*\/?>/gi,"<br/>"),{svg:L,bindFunctions:O}=await Nv.render(x,w,b);b.innerHTML=L,O&&O(b)}},initialize:o=>{Nv.initialize({startOnLoad:!1,...o})}}),UOe();iBt=!1}qOe();})();
|
|
1566
1566
|
/*! Bundled license information:
|
|
1567
1567
|
|
|
1568
1568
|
dompurify/dist/purify.js:
|