New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

markmap-lib

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

markmap-lib - npm Package Compare versions

Comparing version 0.7.5 to 0.7.6

22

dist/browser/view.js

@@ -1,2 +0,2 @@

/*! markmap-lib v0.7.5 | MIT License */
/*! markmap-lib v0.7.6 | MIT License */
(function (exports, d3) {

@@ -1138,14 +1138,18 @@ 'use strict';

}
Markmap.processors = [];
function markmap(svg, data, opts) {
const mm = new Markmap(svg, opts);
static create(svg, opts, data) {
const mm = new Markmap(svg, opts);
if (data) {
mm.setData(data);
mm.fit(); // always fit for the first render
if (data) {
mm.setData(data);
mm.fit(); // always fit for the first render
}
return mm;
}
return mm;
}
Markmap.processors = [];
function markmap(svg, data, opts) {
return Markmap.create(svg, opts, data);
}
async function loadPlugins(items, options) {

@@ -1152,0 +1156,0 @@ items = items.map(item => {

@@ -1,2 +0,2 @@

/*! markmap-lib v0.7.5 | MIT License */
!function(t,e){"use strict";function n(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function r(t,e){var n,r,s,l,c,h=new o(t),d=+t.value&&(h.value=t.value),p=[h];for(null==e&&(e=i);n=p.pop();)if(d&&(n.value=+n.data.value),(s=e(n.data))&&(c=s.length))for(n.children=new Array(c),l=c-1;l>=0;--l)p.push(r=n.children[l]=new o(s[l])),r.parent=n,r.depth=n.depth+1;return h.eachBefore(a)}function i(t){return t.children}function s(t){t.data=t.data.data}function a(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function o(t){this.data=t,this.depth=this.height=0,this.parent=null}o.prototype=r.prototype={constructor:o,count:function(){return this.eachAfter(n)},each:function(t){var e,n,r,i,s=this,a=[s];do{for(e=a.reverse(),a=[];s=e.pop();)if(t(s),n=s.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this},eachAfter:function(t){for(var e,n,r,i=this,s=[i],a=[];i=s.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)s.push(e[n]);for(;i=a.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return r(this).eachBefore(s)}};const l=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function c(t){const e=Object.assign({},l,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function i(t){const e=a(function(){const t=s(),e=n("nodeSize"),r=n("spacing");return class extends t{constructor(t){super(t),Object.assign(this,{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:this,lExtRelX:0,lThr:null,rExt:this,rExtRelX:0,rThr:null})}get size(){return e(this.data)}spacing(t){return r(this.data,t.data)}get x(){return this.data.x}set x(t){this.data.x=t}get y(){return this.data.y}set y(t){this.data.y=t}update(){return h(this),d(this),this}}}(),t,t=>t.children);return e.update(),e.data}function s(){const t=n("nodeSize"),e=n("spacing");return class n extends r.prototype.constructor{constructor(t){super(t)}copy(){const t=a(this.constructor,this,t=>t.children);return t.each(t=>t.data=t.data.data),t}get size(){return t(this)}spacing(t){return e(this,t)}get nodes(){return this.descendants()}get xSize(){return this.size[0]}get ySize(){return this.size[1]}get top(){return this.y}get bottom(){return this.y+this.ySize}get left(){return this.x-this.xSize/2}get right(){return this.x+this.xSize/2}get root(){const t=this.ancestors();return t[t.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return null===this.children}get firstChild(){return this.hasChildren?this.children[0]:null}get lastChild(){return this.hasChildren?this.children[this.numChildren-1]:null}get extents(){return(this.children||[]).reduce((t,e)=>n.maxExtents(t,e.extents),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}}}}function a(t,e,n){const r=(e,i)=>{const s=new t(e);Object.assign(s,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const a=n(e)||[];return s.children=0===a.length?null:a.map(t=>r(t,s)),s.children&&Object.assign(s,s.children.reduce((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length}),s)),s};return r(e,null)}return Object.assign(i,{nodeSize(t){return arguments.length?(e.nodeSize=t,i):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,i):e.spacing},children(t){return arguments.length?(e.children=t,i):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return a(s(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",s=t+" ",{x:a,y:o}=n,l=e(n),c=n.children||[],h=0===c.length?" ":`,${i}children: [${s}${c.map(r(s)).join(s)}${i}],${t}`;return`{ size: [${l.join(", ")}],${i}x: ${a}, y: ${o}${h}},`};return r("\n")(t)}}),i}c.version="2.1.1";const h=(t,e=0)=>(t.y=e,(t.children||[]).reduce((e,n)=>{const[r,i]=e;h(n,t.y+t.ySize);const s=(0===r?n.lExt:n.rExt).bottom;return 0!==r&&u(t,r,i),[r+1,S(s,r,i)]},[0,null]),p(t),z(t),t),d=(t,e,n)=>{void 0===e&&(e=-t.relX-t.prelim,n=0);const r=e+t.relX;return t.relX=r+t.prelim-n,t.prelim=0,t.x=n+t.relX,(t.children||[]).forEach(e=>d(e,r,t.x)),t},p=t=>{(t.children||[]).reduce((t,e)=>{const[n,r]=t,i=n+e.shift,s=r+i+e.change;return e.relX+=s,[i,s]},[0,0])},u=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let s=r,a=r.relX,o=i,l=i.relX,c=!0;for(;s&&o;){s.bottom>n.lowY&&(n=n.next);const r=a+s.prelim-(l+o.prelim)+s.xSize/2+o.xSize/2+s.spacing(o);(r>0||r<0&&c)&&(l+=r,f(i,r),g(t,e,n.index,r)),c=!1;const h=s.bottom,d=o.bottom;h<=d&&(s=x(s),s&&(a+=s.relX)),h>=d&&(o=m(o),o&&(l+=o.relX))}!s&&o?y(t,e,o,l):s&&!o&&v(t,e,s,a)},f=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},g=(t,e,n,r)=>{const i=t.children[e],s=e-n;if(s>1){const e=r/s;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},m=t=>t.hasChildren?t.firstChild:t.lThr,x=t=>t.hasChildren?t.lastChild:t.rThr,y=(t,e,n,r)=>{const i=t.firstChild,s=i.lExt,a=t.children[e];s.lThr=n;const o=r-n.relX-i.lExtRelX;s.relX+=o,s.prelim-=o,i.lExt=a.lExt,i.lExtRelX=a.lExtRelX},v=(t,e,n,r)=>{const i=t.children[e],s=i.rExt,a=t.children[e-1];s.rThr=n;const o=r-n.relX-i.rExtRelX;s.relX+=o,s.prelim-=o,i.rExt=a.rExt,i.rExtRelX=a.rExtRelX},z=t=>{if(t.hasChildren){const e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},S=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}};function j(t,e,n){const r=document.createElement(t);return e&&Object.entries(e).forEach(([t,e])=>{r[t]=e}),n&&Object.entries(n).forEach(([t,e])=>{r.setAttribute(t,e)}),r}const b=function(t){const e={};return function(...n){const r=""+n[0];let i=e[r];return i||(i={value:t(...n)},e[r]=i),i.value}}(t=>{document.head.append(j("link",{rel:"preload",as:"script",href:t}))});function E(t,e){if("script"===t.type)return new Promise((e,n)=>{document.head.append(j("script",Object.assign(Object.assign({},t.data),{},{onload:e,onerror:n})))});if("iife"===t.type){const{fn:n,getParams:r}=t.data;n(...(null==r?void 0:r(e))||[])}}function w(t){"style"===t.type?document.head.append(j("style",{textContent:t.data})):"stylesheet"===t.type&&document.head.append(j("link",Object.assign({rel:"stylesheet"},t.data)))}async function $(t,e){return e=Object.assign({},e),await Promise.all(t.map(t=>(function(t){for(const e of t)w(e)}(t.styles),async function(t,e){const n=t.filter(t=>"script"===t.type);n.length>1&&n.forEach(t=>b(t.data.src));for(const n of t)await E(n,e)}(t.scripts,e)))),t.map(({transform:t})=>t)}const X=Math.random().toString(36).slice(2,8);let O=0;function k(t,e,n="c"){const r=(t,i)=>e(t,()=>{var e;null==(e=t[n])||e.forEach(e=>{r(e,t)})},i);r(t)}function C(t){const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function M(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach(t=>{t&&n.indexOf(t)<0&&n.push(t)}),n.join(" ")}function R(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=C(this.childNodes);return e&&(t=t.filter(t=>e(t))),t}}const I=[{type:"iife",data:{fn:t=>{t.options=Object.assign({skipHtmlTags:{"[-]":["code","pre"]}},t.options),t.startup=Object.assign({typeset:!1},t.startup),window.MathJax=t},getParams:t=>[Object.assign({},t.mathJax)]}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"}}];var A=Object.freeze({__proto__:null,styles:[],scripts:I,transform:function(t,e){var n,r;null==(n=(r=window.MathJax).typeset)||n.call(r,t)}});const _=[{type:"iife",data:{fn:()=>{window.Prism={manual:!0}}}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-core.min.js"}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js"}}];var B=Object.freeze({__proto__:null,styles:[{type:"stylesheet",data:{href:"https://cdn.jsdelivr.net/npm/prismjs@1/themes/prism.css"}}],scripts:_,transform:function(t,e){const{Prism:n}=window,r=t.flatMap(t=>Array.from(t.querySelectorAll("code[class*=language-]"))).map(t=>{const e=t.className.match(/(?:^|\s)language-(\S+)|$/)[1];if(!n.languages[e])return e;n.highlightElement(t)}).filter(Boolean);r.length&&n.plugins.autoloader.loadLanguages(r,()=>{e.setData(),e.fit()})}}),D=Object.freeze({__proto__:null,mathJax:A,prism:B});function N(t){const e=t.data;return Math.max(6-2*e.d,1.5)}class T{constructor(t,n){this.options=void 0,this.state=void 0,this.svg=void 0,this.styleNode=void 0,this.g=void 0,this.zoom=void 0,["handleZoom","handleClick"].forEach(t=>{this[t]=this[t].bind(this)}),this.svg=t.datum?t:e.select(t),this.styleNode=this.svg.append("style"),this.zoom=e.zoom().on("zoom",this.handleZoom),this.options=Object.assign({duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:e.scaleOrdinal(e.schemeCategory10),colorDepth:0,paddingX:8},n),this.state={id:this.options.id||(O+=1,`mm-${X}-${O}`)},this.g=this.svg.append("g").attr("class",this.state.id+"-g"),this.updateStyle(),this.svg.call(this.zoom)}getStyleContent(){const{style:t,nodeFont:e}=this.options,{id:n}=this.state;return`.${n} a { color: #0097e6; }\n.${n} a:hover { color: #00a8ff; }\n.${n}-g > path { fill: none; }\n.${n}-fo > div { font: ${e}; white-space: nowrap; }\n.${n}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${n}-fo del { text-decoration: line-through; }\n.${n}-fo em { font-style: italic; }\n.${n}-fo strong { font-weight: 500; }\n.${n}-fo pre { margin: 0; }\n.${n}-fo pre[class*=language-] { padding: 0; }\n.${n}-g > g { cursor: pointer; }\n${"function"==typeof t?t(n):""}\n`}updateStyle(){this.svg.attr("class",M(this.svg.attr("class"),this.state.id)),this.styleNode.text(this.getStyleContent())}handleZoom(){const{transform:t}=e.event;this.g.attr("transform",t)}handleClick(t){var e;const{data:n}=t;n.p=Object.assign(Object.assign({},n.p),{},{f:!(null==(e=n.p)?void 0:e.f)}),this.renderData(t.data)}initializeData(t){var e;let n=0,r=0;const{colorDepth:i,nodeFont:s,color:a,nodeMinHeight:o}=this.options,{id:l}=this.state,c=document.createElement("div"),h=l+"-container";c.className=M(c.className,l+"-fo",h);const d=document.createElement("style");if(d.textContent=`\n${this.getStyleContent()}\n.${h} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${s};\n}\n.${h} > div {\n display: inline-block;\n}\n`,document.body.append(d,c),k(t,(t,e)=>{var s;t.c=null==(s=t.c)?void 0:s.map(t=>Object.assign({},t)),n+=1,a(""+r);const o=document.createElement("div");o.innerHTML=t.v,c.append(o),t.p=Object.assign(Object.assign({},t.p),{},{i:n,c:r,el:o}),e(),i&&t.d!==i||(r+=1)}),null==(e=T.processors)?void 0:e.length){const t=C(c.childNodes);T.processors.forEach(e=>{e(t,this)})}k(t,(t,e,n)=>{var r;const i=t.p.el.getBoundingClientRect();t.v=t.p.el.innerHTML,t.p.s=[Math.ceil(i.width),Math.max(Math.ceil(i.height),o)],t.p.k=`${(null==n||null==(r=n.p)?void 0:r.i)||""}.${t.p.i}:${t.v}`,e()}),c.remove(),d.remove()}setOptions(t){Object.assign(this.options,t)}setData(t,e){t||(t=Object.assign({},this.state.data)),this.state.data=t,this.initializeData(t),e&&this.setOptions(e),this.renderData()}renderData(t){var n,r;if(!this.state.data)return;const{spacingHorizontal:i,paddingX:s,spacingVertical:a,autoFit:o,color:l}=this.options,{id:h}=this.state,d=c().children(t=>{var e;return!(null==(e=t.p)?void 0:e.f)&&t.c}).nodeSize(t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*s:0)+i]}).spacing((t,e)=>t.parent===e.parent?a:2*a),p=d.hierarchy(this.state.data);d(p),function(t,e){k(t,(t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()},"children")}(p,i);const u=p.descendants().reverse(),f=p.links(),g=e.linkHorizontal(),m=e.min(u,t=>t.x-t.xSize/2),x=e.max(u,t=>t.x+t.xSize/2),y=e.min(u,t=>t.y),v=e.max(u,t=>t.y+t.ySizeInner);Object.assign(this.state,{minX:m,maxX:x,minY:y,maxY:v}),o&&this.fit();const z=t&&u.find(e=>e.data===t)||p,S=null!=(n=z.data.p.x0)?n:z.x,j=null!=(r=z.data.p.y0)?r:z.y,b=this.g.selectAll(R("g")).data(u,t=>t.data.p.k),E=b.enter().append("g").attr("transform",t=>`translate(${j+z.ySizeInner-t.ySizeInner},${S+z.xSize/2-t.xSize})`).on("click",this.handleClick),w=this.transition(b.exit());w.select("rect").attr("width",0).attr("x",t=>t.ySizeInner),w.select("foreignObject").style("opacity",0),w.attr("transform",t=>`translate(${z.y+z.ySizeInner-t.ySizeInner},${z.x+z.xSize/2-t.xSize})`).remove();const $=b.merge(E);this.transition($).attr("transform",t=>`translate(${t.y},${t.x-t.xSize/2})`);const X=$.selectAll(R("rect")).data(t=>[t],t=>t.data.p.k).join(t=>t.append("rect").attr("x",t=>t.ySizeInner).attr("y",t=>t.xSize-N(t)/2).attr("width",0).attr("height",N),t=>t,t=>t.remove());this.transition(X).attr("x",-1).attr("width",t=>t.ySizeInner+2).attr("fill",t=>l(t.data.p.c));const O=$.selectAll(R("circle")).data(t=>t.data.c?[t]:[],t=>t.data.p.k).join(t=>t.append("circle").attr("stroke-width","1.5").attr("cx",t=>t.ySizeInner).attr("cy",t=>t.xSize).attr("r",0),t=>t,t=>t.remove());this.transition(O).attr("r",6).attr("stroke",t=>l(t.data.p.c)).attr("fill",t=>{var e;return(null==(e=t.data.p)?void 0:e.f)?l(t.data.p.c):"#fff"});const C=$.selectAll(R("foreignObject")).data(t=>[t],t=>t.data.p.k).join(t=>{const e=t.append("foreignObject").attr("class",h+"-fo").attr("x",s).attr("y",0).style("opacity",0).attr("height",t=>t.xSize);return e.append("xhtml:div").select((function(t){const e=t.data.p.el.cloneNode(!0);return this.replaceWith(e),e})).attr("xmlns","http://www.w3.org/1999/xhtml"),e},t=>t,t=>t.remove()).attr("width",t=>Math.max(0,t.ySizeInner-2*s));this.transition(C).style("opacity",1);const M=this.g.selectAll(R("path")).data(f,t=>t.target.data.p.k).join(t=>{const e=[j+z.ySizeInner,S+z.xSize/2];return t.insert("path","g").attr("d",g({source:e,target:e}))},t=>t,t=>{const e=[z.y+z.ySizeInner,z.x+z.xSize/2];return this.transition(t).attr("d",g({source:e,target:e})).remove()});this.transition(M).attr("stroke",t=>l(t.target.data.p.c)).attr("stroke-width",t=>N(t.target)).attr("d",t=>{const e=[t.source.y+t.source.ySizeInner,t.source.x+t.source.xSize/2],n=[t.target.y,t.target.x+t.target.xSize/2];return g({source:e,target:n})}),u.forEach(t=>{t.data.p.x0=t.x,t.data.p.y0=t.y})}transition(t){const{duration:e}=this.options;return e?t.transition().duration(e):t}fit(){const t=this.svg.node(),{width:n,height:r}=t.getBoundingClientRect(),{fitRatio:i}=this.options,{minX:s,maxX:a,minY:o,maxY:l}=this.state,c=l-o,h=a-s,d=Math.min(n/c*i,r/h*i,2),p=e.zoomIdentity.translate((n-c*d)/2-o*d,(r-h*d)/2-s*d).scale(d);this.transition(this.svg).call(this.zoom.transform,p)}rescale(t){const n=this.svg.node(),{width:r,height:i}=n.getBoundingClientRect(),s=r/2,a=i/2,o=e.zoomTransform(n),l=o.translate((s-o.x)*(1-t)/o.k,(a-o.y)*(1-t)/o.k).scale(t);this.transition(this.svg).call(this.zoom.transform,l)}}T.processors=[],t.Markmap=T,t.loadPlugins=async function(t,e){t=t.map(t=>{if("string"==typeof t){const e=t;(t=D[e])||console.warn("[markmap] Unknown plugin: "+e)}return t}).filter(Boolean),T.processors=[...T.processors,...await $(t,e)]},t.markmap=function(t,e,n){const r=new T(t,n);return e&&(r.setData(e),r.fit()),r},t.plugins=D}(this.markmap=this.markmap||{},d3);
/*! markmap-lib v0.7.6 | MIT License */
!function(t,e){"use strict";function n(t){var e=0,n=t.children,r=n&&n.length;if(r)for(;--r>=0;)e+=n[r].value;else e=1;t.value=e}function r(t,e){var n,r,s,c,l,h=new o(t),d=+t.value&&(h.value=t.value),p=[h];for(null==e&&(e=i);n=p.pop();)if(d&&(n.value=+n.data.value),(s=e(n.data))&&(l=s.length))for(n.children=new Array(l),c=l-1;c>=0;--c)p.push(r=n.children[c]=new o(s[c])),r.parent=n,r.depth=n.depth+1;return h.eachBefore(a)}function i(t){return t.children}function s(t){t.data=t.data.data}function a(t){var e=0;do{t.height=e}while((t=t.parent)&&t.height<++e)}function o(t){this.data=t,this.depth=this.height=0,this.parent=null}o.prototype=r.prototype={constructor:o,count:function(){return this.eachAfter(n)},each:function(t){var e,n,r,i,s=this,a=[s];do{for(e=a.reverse(),a=[];s=e.pop();)if(t(s),n=s.children)for(r=0,i=n.length;r<i;++r)a.push(n[r])}while(a.length);return this},eachAfter:function(t){for(var e,n,r,i=this,s=[i],a=[];i=s.pop();)if(a.push(i),e=i.children)for(n=0,r=e.length;n<r;++n)s.push(e[n]);for(;i=a.pop();)t(i);return this},eachBefore:function(t){for(var e,n,r=this,i=[r];r=i.pop();)if(t(r),e=r.children)for(n=e.length-1;n>=0;--n)i.push(e[n]);return this},sum:function(t){return this.eachAfter((function(e){for(var n=+t(e.data)||0,r=e.children,i=r&&r.length;--i>=0;)n+=r[i].value;e.value=n}))},sort:function(t){return this.eachBefore((function(e){e.children&&e.children.sort(t)}))},path:function(t){for(var e=this,n=function(t,e){if(t===e)return t;var n=t.ancestors(),r=e.ancestors(),i=null;t=n.pop(),e=r.pop();for(;t===e;)i=t,t=n.pop(),e=r.pop();return i}(e,t),r=[e];e!==n;)e=e.parent,r.push(e);for(var i=r.length;t!==n;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,e=[t];t=t.parent;)e.push(t);return e},descendants:function(){var t=[];return this.each((function(e){t.push(e)})),t},leaves:function(){var t=[];return this.eachBefore((function(e){e.children||t.push(e)})),t},links:function(){var t=this,e=[];return t.each((function(n){n!==t&&e.push({source:n.parent,target:n})})),e},copy:function(){return r(this).eachBefore(s)}};const c=Object.freeze({children:t=>t.children,nodeSize:t=>t.data.size,spacing:0});function l(t){const e=Object.assign({},c,t);function n(t){const n=e[t];return"function"==typeof n?n:()=>n}function i(t){const e=a(function(){const t=s(),e=n("nodeSize"),r=n("spacing");return class extends t{constructor(t){super(t),Object.assign(this,{x:0,y:0,relX:0,prelim:0,shift:0,change:0,lExt:this,lExtRelX:0,lThr:null,rExt:this,rExtRelX:0,rThr:null})}get size(){return e(this.data)}spacing(t){return r(this.data,t.data)}get x(){return this.data.x}set x(t){this.data.x=t}get y(){return this.data.y}set y(t){this.data.y=t}update(){return h(this),d(this),this}}}(),t,t=>t.children);return e.update(),e.data}function s(){const t=n("nodeSize"),e=n("spacing");return class n extends r.prototype.constructor{constructor(t){super(t)}copy(){const t=a(this.constructor,this,t=>t.children);return t.each(t=>t.data=t.data.data),t}get size(){return t(this)}spacing(t){return e(this,t)}get nodes(){return this.descendants()}get xSize(){return this.size[0]}get ySize(){return this.size[1]}get top(){return this.y}get bottom(){return this.y+this.ySize}get left(){return this.x-this.xSize/2}get right(){return this.x+this.xSize/2}get root(){const t=this.ancestors();return t[t.length-1]}get numChildren(){return this.hasChildren?this.children.length:0}get hasChildren(){return!this.noChildren}get noChildren(){return null===this.children}get firstChild(){return this.hasChildren?this.children[0]:null}get lastChild(){return this.hasChildren?this.children[this.numChildren-1]:null}get extents(){return(this.children||[]).reduce((t,e)=>n.maxExtents(t,e.extents),this.nodeExtents)}get nodeExtents(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}static maxExtents(t,e){return{top:Math.min(t.top,e.top),bottom:Math.max(t.bottom,e.bottom),left:Math.min(t.left,e.left),right:Math.max(t.right,e.right)}}}}function a(t,e,n){const r=(e,i)=>{const s=new t(e);Object.assign(s,{parent:i,depth:null===i?0:i.depth+1,height:0,length:1});const a=n(e)||[];return s.children=0===a.length?null:a.map(t=>r(t,s)),s.children&&Object.assign(s,s.children.reduce((t,e)=>({height:Math.max(t.height,e.height+1),length:t.length+e.length}),s)),s};return r(e,null)}return Object.assign(i,{nodeSize(t){return arguments.length?(e.nodeSize=t,i):e.nodeSize},spacing(t){return arguments.length?(e.spacing=t,i):e.spacing},children(t){return arguments.length?(e.children=t,i):e.children},hierarchy(t,n){const r=void 0===n?e.children:n;return a(s(),t,r)},dump(t){const e=n("nodeSize"),r=t=>n=>{const i=t+" ",s=t+" ",{x:a,y:o}=n,c=e(n),l=n.children||[],h=0===l.length?" ":`,${i}children: [${s}${l.map(r(s)).join(s)}${i}],${t}`;return`{ size: [${c.join(", ")}],${i}x: ${a}, y: ${o}${h}},`};return r("\n")(t)}}),i}l.version="2.1.1";const h=(t,e=0)=>(t.y=e,(t.children||[]).reduce((e,n)=>{const[r,i]=e;h(n,t.y+t.ySize);const s=(0===r?n.lExt:n.rExt).bottom;return 0!==r&&u(t,r,i),[r+1,S(s,r,i)]},[0,null]),p(t),z(t),t),d=(t,e,n)=>{void 0===e&&(e=-t.relX-t.prelim,n=0);const r=e+t.relX;return t.relX=r+t.prelim-n,t.prelim=0,t.x=n+t.relX,(t.children||[]).forEach(e=>d(e,r,t.x)),t},p=t=>{(t.children||[]).reduce((t,e)=>{const[n,r]=t,i=n+e.shift,s=r+i+e.change;return e.relX+=s,[i,s]},[0,0])},u=(t,e,n)=>{const r=t.children[e-1],i=t.children[e];let s=r,a=r.relX,o=i,c=i.relX,l=!0;for(;s&&o;){s.bottom>n.lowY&&(n=n.next);const r=a+s.prelim-(c+o.prelim)+s.xSize/2+o.xSize/2+s.spacing(o);(r>0||r<0&&l)&&(c+=r,f(i,r),g(t,e,n.index,r)),l=!1;const h=s.bottom,d=o.bottom;h<=d&&(s=x(s),s&&(a+=s.relX)),h>=d&&(o=m(o),o&&(c+=o.relX))}!s&&o?y(t,e,o,c):s&&!o&&v(t,e,s,a)},f=(t,e)=>{t.relX+=e,t.lExtRelX+=e,t.rExtRelX+=e},g=(t,e,n,r)=>{const i=t.children[e],s=e-n;if(s>1){const e=r/s;t.children[n+1].shift+=e,i.shift-=e,i.change-=r-e}},m=t=>t.hasChildren?t.firstChild:t.lThr,x=t=>t.hasChildren?t.lastChild:t.rThr,y=(t,e,n,r)=>{const i=t.firstChild,s=i.lExt,a=t.children[e];s.lThr=n;const o=r-n.relX-i.lExtRelX;s.relX+=o,s.prelim-=o,i.lExt=a.lExt,i.lExtRelX=a.lExtRelX},v=(t,e,n,r)=>{const i=t.children[e],s=i.rExt,a=t.children[e-1];s.rThr=n;const o=r-n.relX-i.rExtRelX;s.relX+=o,s.prelim-=o,i.rExt=a.rExt,i.rExtRelX=a.rExtRelX},z=t=>{if(t.hasChildren){const e=t.firstChild,n=t.lastChild,r=(e.prelim+e.relX-e.xSize/2+n.relX+n.prelim+n.xSize/2)/2;Object.assign(t,{prelim:r,lExt:e.lExt,lExtRelX:e.lExtRelX,rExt:n.rExt,rExtRelX:n.rExtRelX})}},S=(t,e,n)=>{for(;null!==n&&t>=n.lowY;)n=n.next;return{lowY:t,index:e,next:n}};function j(t,e,n){const r=document.createElement(t);return e&&Object.entries(e).forEach(([t,e])=>{r[t]=e}),n&&Object.entries(n).forEach(([t,e])=>{r.setAttribute(t,e)}),r}const b=function(t){const e={};return function(...n){const r=""+n[0];let i=e[r];return i||(i={value:t(...n)},e[r]=i),i.value}}(t=>{document.head.append(j("link",{rel:"preload",as:"script",href:t}))});function E(t,e){if("script"===t.type)return new Promise((e,n)=>{document.head.append(j("script",Object.assign(Object.assign({},t.data),{},{onload:e,onerror:n})))});if("iife"===t.type){const{fn:n,getParams:r}=t.data;n(...(null==r?void 0:r(e))||[])}}function w(t){"style"===t.type?document.head.append(j("style",{textContent:t.data})):"stylesheet"===t.type&&document.head.append(j("link",Object.assign({rel:"stylesheet"},t.data)))}async function $(t,e){return e=Object.assign({},e),await Promise.all(t.map(t=>(function(t){for(const e of t)w(e)}(t.styles),async function(t,e){const n=t.filter(t=>"script"===t.type);n.length>1&&n.forEach(t=>b(t.data.src));for(const n of t)await E(n,e)}(t.scripts,e)))),t.map(({transform:t})=>t)}const X=Math.random().toString(36).slice(2,8);let O=0;function k(t,e,n="c"){const r=(t,i)=>e(t,()=>{var e;null==(e=t[n])||e.forEach(e=>{r(e,t)})},i);r(t)}function C(t){const e=[];for(let n=0;n<t.length;n+=1)e.push(t[n]);return e}function M(t,...e){const n=(t||"").split(" ").filter(Boolean);return e.forEach(t=>{t&&n.indexOf(t)<0&&n.push(t)}),n.join(" ")}function R(t){if("string"==typeof t){const e=t;t=t=>t.tagName===e}const e=t;return function(){let t=C(this.childNodes);return e&&(t=t.filter(t=>e(t))),t}}const I=[{type:"iife",data:{fn:t=>{t.options=Object.assign({skipHtmlTags:{"[-]":["code","pre"]}},t.options),t.startup=Object.assign({typeset:!1},t.startup),window.MathJax=t},getParams:t=>[Object.assign({},t.mathJax)]}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"}}];var A=Object.freeze({__proto__:null,styles:[],scripts:I,transform:function(t,e){var n,r;null==(n=(r=window.MathJax).typeset)||n.call(r,t)}});const _=[{type:"iife",data:{fn:()=>{window.Prism={manual:!0}}}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/prismjs@1/components/prism-core.min.js"}},{type:"script",data:{src:"https://cdn.jsdelivr.net/npm/prismjs@1/plugins/autoloader/prism-autoloader.min.js"}}];var B=Object.freeze({__proto__:null,styles:[{type:"stylesheet",data:{href:"https://cdn.jsdelivr.net/npm/prismjs@1/themes/prism.css"}}],scripts:_,transform:function(t,e){const{Prism:n}=window,r=t.flatMap(t=>Array.from(t.querySelectorAll("code[class*=language-]"))).map(t=>{const e=t.className.match(/(?:^|\s)language-(\S+)|$/)[1];if(!n.languages[e])return e;n.highlightElement(t)}).filter(Boolean);r.length&&n.plugins.autoloader.loadLanguages(r,()=>{e.setData(),e.fit()})}}),D=Object.freeze({__proto__:null,mathJax:A,prism:B});function N(t){const e=t.data;return Math.max(6-2*e.d,1.5)}class T{constructor(t,n){this.options=void 0,this.state=void 0,this.svg=void 0,this.styleNode=void 0,this.g=void 0,this.zoom=void 0,["handleZoom","handleClick"].forEach(t=>{this[t]=this[t].bind(this)}),this.svg=t.datum?t:e.select(t),this.styleNode=this.svg.append("style"),this.zoom=e.zoom().on("zoom",this.handleZoom),this.options=Object.assign({duration:500,nodeFont:"300 16px/20px sans-serif",nodeMinHeight:16,spacingVertical:5,spacingHorizontal:80,autoFit:!1,fitRatio:.95,color:e.scaleOrdinal(e.schemeCategory10),colorDepth:0,paddingX:8},n),this.state={id:this.options.id||(O+=1,`mm-${X}-${O}`)},this.g=this.svg.append("g").attr("class",this.state.id+"-g"),this.updateStyle(),this.svg.call(this.zoom)}getStyleContent(){const{style:t,nodeFont:e}=this.options,{id:n}=this.state;return`.${n} a { color: #0097e6; }\n.${n} a:hover { color: #00a8ff; }\n.${n}-g > path { fill: none; }\n.${n}-fo > div { font: ${e}; white-space: nowrap; }\n.${n}-fo code { padding: .2em .4em; font-size: calc(1em - 2px); color: #555; background-color: #f0f0f0; border-radius: 2px; }\n.${n}-fo del { text-decoration: line-through; }\n.${n}-fo em { font-style: italic; }\n.${n}-fo strong { font-weight: 500; }\n.${n}-fo pre { margin: 0; }\n.${n}-fo pre[class*=language-] { padding: 0; }\n.${n}-g > g { cursor: pointer; }\n${"function"==typeof t?t(n):""}\n`}updateStyle(){this.svg.attr("class",M(this.svg.attr("class"),this.state.id)),this.styleNode.text(this.getStyleContent())}handleZoom(){const{transform:t}=e.event;this.g.attr("transform",t)}handleClick(t){var e;const{data:n}=t;n.p=Object.assign(Object.assign({},n.p),{},{f:!(null==(e=n.p)?void 0:e.f)}),this.renderData(t.data)}initializeData(t){var e;let n=0,r=0;const{colorDepth:i,nodeFont:s,color:a,nodeMinHeight:o}=this.options,{id:c}=this.state,l=document.createElement("div"),h=c+"-container";l.className=M(l.className,c+"-fo",h);const d=document.createElement("style");if(d.textContent=`\n${this.getStyleContent()}\n.${h} {\n position: absolute;\n width: 0;\n height: 0;\n top: -100px;\n left: -100px;\n overflow: hidden;\n font: ${s};\n}\n.${h} > div {\n display: inline-block;\n}\n`,document.body.append(d,l),k(t,(t,e)=>{var s;t.c=null==(s=t.c)?void 0:s.map(t=>Object.assign({},t)),n+=1,a(""+r);const o=document.createElement("div");o.innerHTML=t.v,l.append(o),t.p=Object.assign(Object.assign({},t.p),{},{i:n,c:r,el:o}),e(),i&&t.d!==i||(r+=1)}),null==(e=T.processors)?void 0:e.length){const t=C(l.childNodes);T.processors.forEach(e=>{e(t,this)})}k(t,(t,e,n)=>{var r;const i=t.p.el.getBoundingClientRect();t.v=t.p.el.innerHTML,t.p.s=[Math.ceil(i.width),Math.max(Math.ceil(i.height),o)],t.p.k=`${(null==n||null==(r=n.p)?void 0:r.i)||""}.${t.p.i}:${t.v}`,e()}),l.remove(),d.remove()}setOptions(t){Object.assign(this.options,t)}setData(t,e){t||(t=Object.assign({},this.state.data)),this.state.data=t,this.initializeData(t),e&&this.setOptions(e),this.renderData()}renderData(t){var n,r;if(!this.state.data)return;const{spacingHorizontal:i,paddingX:s,spacingVertical:a,autoFit:o,color:c}=this.options,{id:h}=this.state,d=l().children(t=>{var e;return!(null==(e=t.p)?void 0:e.f)&&t.c}).nodeSize(t=>{const[e,n]=t.data.p.s;return[n,e+(e?2*s:0)+i]}).spacing((t,e)=>t.parent===e.parent?a:2*a),p=d.hierarchy(this.state.data);d(p),function(t,e){k(t,(t,n)=>{t.ySizeInner=t.ySize-e,t.y+=e,n()},"children")}(p,i);const u=p.descendants().reverse(),f=p.links(),g=e.linkHorizontal(),m=e.min(u,t=>t.x-t.xSize/2),x=e.max(u,t=>t.x+t.xSize/2),y=e.min(u,t=>t.y),v=e.max(u,t=>t.y+t.ySizeInner);Object.assign(this.state,{minX:m,maxX:x,minY:y,maxY:v}),o&&this.fit();const z=t&&u.find(e=>e.data===t)||p,S=null!=(n=z.data.p.x0)?n:z.x,j=null!=(r=z.data.p.y0)?r:z.y,b=this.g.selectAll(R("g")).data(u,t=>t.data.p.k),E=b.enter().append("g").attr("transform",t=>`translate(${j+z.ySizeInner-t.ySizeInner},${S+z.xSize/2-t.xSize})`).on("click",this.handleClick),w=this.transition(b.exit());w.select("rect").attr("width",0).attr("x",t=>t.ySizeInner),w.select("foreignObject").style("opacity",0),w.attr("transform",t=>`translate(${z.y+z.ySizeInner-t.ySizeInner},${z.x+z.xSize/2-t.xSize})`).remove();const $=b.merge(E);this.transition($).attr("transform",t=>`translate(${t.y},${t.x-t.xSize/2})`);const X=$.selectAll(R("rect")).data(t=>[t],t=>t.data.p.k).join(t=>t.append("rect").attr("x",t=>t.ySizeInner).attr("y",t=>t.xSize-N(t)/2).attr("width",0).attr("height",N),t=>t,t=>t.remove());this.transition(X).attr("x",-1).attr("width",t=>t.ySizeInner+2).attr("fill",t=>c(t.data.p.c));const O=$.selectAll(R("circle")).data(t=>t.data.c?[t]:[],t=>t.data.p.k).join(t=>t.append("circle").attr("stroke-width","1.5").attr("cx",t=>t.ySizeInner).attr("cy",t=>t.xSize).attr("r",0),t=>t,t=>t.remove());this.transition(O).attr("r",6).attr("stroke",t=>c(t.data.p.c)).attr("fill",t=>{var e;return(null==(e=t.data.p)?void 0:e.f)?c(t.data.p.c):"#fff"});const C=$.selectAll(R("foreignObject")).data(t=>[t],t=>t.data.p.k).join(t=>{const e=t.append("foreignObject").attr("class",h+"-fo").attr("x",s).attr("y",0).style("opacity",0).attr("height",t=>t.xSize);return e.append("xhtml:div").select((function(t){const e=t.data.p.el.cloneNode(!0);return this.replaceWith(e),e})).attr("xmlns","http://www.w3.org/1999/xhtml"),e},t=>t,t=>t.remove()).attr("width",t=>Math.max(0,t.ySizeInner-2*s));this.transition(C).style("opacity",1);const M=this.g.selectAll(R("path")).data(f,t=>t.target.data.p.k).join(t=>{const e=[j+z.ySizeInner,S+z.xSize/2];return t.insert("path","g").attr("d",g({source:e,target:e}))},t=>t,t=>{const e=[z.y+z.ySizeInner,z.x+z.xSize/2];return this.transition(t).attr("d",g({source:e,target:e})).remove()});this.transition(M).attr("stroke",t=>c(t.target.data.p.c)).attr("stroke-width",t=>N(t.target)).attr("d",t=>{const e=[t.source.y+t.source.ySizeInner,t.source.x+t.source.xSize/2],n=[t.target.y,t.target.x+t.target.xSize/2];return g({source:e,target:n})}),u.forEach(t=>{t.data.p.x0=t.x,t.data.p.y0=t.y})}transition(t){const{duration:e}=this.options;return e?t.transition().duration(e):t}fit(){const t=this.svg.node(),{width:n,height:r}=t.getBoundingClientRect(),{fitRatio:i}=this.options,{minX:s,maxX:a,minY:o,maxY:c}=this.state,l=c-o,h=a-s,d=Math.min(n/l*i,r/h*i,2),p=e.zoomIdentity.translate((n-l*d)/2-o*d,(r-h*d)/2-s*d).scale(d);this.transition(this.svg).call(this.zoom.transform,p)}rescale(t){const n=this.svg.node(),{width:r,height:i}=n.getBoundingClientRect(),s=r/2,a=i/2,o=e.zoomTransform(n),c=o.translate((s-o.x)*(1-t)/o.k,(a-o.y)*(1-t)/o.k).scale(t);this.transition(this.svg).call(this.zoom.transform,c)}static create(t,e,n){const r=new T(t,e);return n&&(r.setData(n),r.fit()),r}}T.processors=[],t.Markmap=T,t.loadPlugins=async function(t,e){t=t.map(t=>{if("string"==typeof t){const e=t;(t=D[e])||console.warn("[markmap] Unknown plugin: "+e)}return t}).filter(Boolean),T.processors=[...T.processors,...await $(t,e)]},t.markmap=function(t,e,n){return T.create(t,n,e)},t.plugins=D}(this.markmap=this.markmap||{},d3);

@@ -11,3 +11,3 @@ "use strict";

const template = "<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"UTF-8\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">\n<title>Markmap</title>\n<style>\n* {\n margin: 0;\n padding: 0;\n}\n#mindmap {\n display: block;\n width: 100vw;\n height: 100vh;\n}\n</style>\n<!--CSS-->\n</head>\n<body>\n<svg id=\"mindmap\"></svg>\n<!--JS-->\n</body>\n</html>\n";
const baseJs = ['https://cdn.jsdelivr.net/npm/d3@5', 'https://cdn.jsdelivr.net/npm/markmap-lib@0.7.5/dist/browser/view.min.js'].map(src => ({
const baseJs = ['https://cdn.jsdelivr.net/npm/d3@5', 'https://cdn.jsdelivr.net/npm/markmap-lib@0.7.6/dist/browser/view.min.js'].map(src => ({
type: 'script',

@@ -30,6 +30,6 @@ data: {

const {
markmap
Markmap
} = window.markmap;
markmap.processors = processors;
markmap('svg#mindmap', data);
Markmap.processors = processors;
Markmap.create('svg#mindmap', null, data);
},

@@ -36,0 +36,0 @@ getParams: ({

@@ -356,2 +356,13 @@ "use strict";

static create(svg, opts, data) {
const mm = new Markmap(svg, opts);
if (data) {
mm.setData(data);
mm.fit(); // always fit for the first render
}
return mm;
}
}

@@ -363,10 +374,3 @@

function markmap(svg, data, opts) {
const mm = new Markmap(svg, opts);
if (data) {
mm.setData(data);
mm.fit(); // always fit for the first render
}
return mm;
return Markmap.create(svg, opts, data);
}

@@ -373,0 +377,0 @@

{
"name": "markmap-lib",
"version": "0.7.5",
"version": "0.7.6",
"description": "Visualize your Markdown as mindmaps with Markmap",

@@ -5,0 +5,0 @@ "author": "Gerald <i@gerald.top>",

@@ -99,9 +99,9 @@ # markmap-lib

```js
import { markmap } from 'markmap-lib/dist/view';
import { Markmap } from 'markmap-lib/dist/view';
markmap('#markmap', data);
Markmap.create('#markmap', null, data);
// or pass an SVG element directly
const svgEl = document.querySelector('#markmap');
markmap(svgEl, data);
Markmap.create(svgEl, null, data);
```

@@ -111,4 +111,4 @@

- MathJax
- PrismJS
- `mathJax` - MathJax
- `prism` - PrismJS

@@ -128,3 +128,3 @@ #### Command-line

```js
import { markmap, loadPlugins } from 'markmap-lib/dist/view';
import { Markmap, loadPlugins } from 'markmap-lib/dist/view';

@@ -136,3 +136,3 @@ loadPlugins([

.then(() => {
markmap('#markmap', data);
Markmap.create('#markmap', null, data);
});

@@ -139,0 +139,0 @@ ```

@@ -26,4 +26,5 @@ import * as d3 from 'd3';

rescale(scale: number): void;
static create(svg: string | SVGElement | ID3SVGElement, opts?: IMarkmapOptions, data?: INode): Markmap;
}
export declare function markmap(svg: string | SVGElement | ID3SVGElement, data?: INode, opts?: IMarkmapOptions): Markmap;
export declare function loadPlugins(items: any[], options: any): Promise<void>;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc