Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@gitgraph/core

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gitgraph/core - npm Package Compare versions

Comparing version 1.4.4 to 1.4.5

6

CHANGELOG.md

@@ -7,2 +7,8 @@ ### Changelog

#### [1.4.5](https://github.com/nicoespeon/gitgraph.js/compare/@gitgraph/core@1.4.4...@gitgraph/core@1.4.5)
> 4 April 2020
- Fix undefined current when importing parent branches [`#352`](https://github.com/nicoespeon/gitgraph.js/pull/352)
#### [1.4.4](https://github.com/nicoespeon/gitgraph.js/compare/@gitgraph/core@1.4.3...@gitgraph/core@1.4.4)

@@ -9,0 +15,0 @@

4

lib/bundle.js

@@ -686,3 +686,3 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){

result.set(currentHash, prevBranches);
if (current.parents.length > 0) {
if (current && current.parents && current.parents.length > 0) {
queue.push(current.parents[0]);

@@ -1453,3 +1453,3 @@ }

result.set(currentHash, prevBranches);
if (current.parents.length > 0) {
if (current && current.parents && current.parents.length > 0) {
queue.push(current.parents[0]);

@@ -1456,0 +1456,0 @@ }

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

!function(){return function t(e,s,r){function i(o,n){if(!s[o]){if(!e[o]){var h="function"==typeof require&&require;if(!n&&h)return h(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var m=s[o]={exports:{}};e[o][0].call(m.exports,function(t){return i(e[o][1][t]||t)},m,m.exports,t,e,s,r)}return s[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}}()({1:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./user-api/branch-user-api"),i="";s.DELETED_BRANCH_NAME=i;class a{constructor(t){this.gitgraph=t.gitgraph,this.name=t.name,this.style=t.style,this.parentCommitHash=t.parentCommitHash,this.commitDefaultOptions=t.commitDefaultOptions||{style:{}},this.onGraphUpdate=t.onGraphUpdate,this.renderLabel=t.renderLabel}getUserApi(){return new r.BranchUserApi(this,this.gitgraph,this.onGraphUpdate)}isDeleted(){return this.name===i}}s.Branch=a,s.createDeletedBranch=function(t,e,s){return new a({name:i,gitgraph:t,style:e,onGraphUpdate:s})}},{"./user-api/branch-user-api":15}],2:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.BranchesOrder=class{constructor(t,e,s){this.branches=new Set,this.colors=e,t.forEach(t=>this.branches.add(t.branchToDisplay)),s&&(this.branches=new Set(Array.from(this.branches).sort(s)))}get(t){return Array.from(this.branches).findIndex(e=>e===t)}getColorOf(t){return this.colors[this.get(t)%this.colors.length]}}},{}],3:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./utils");s.BranchesPathsCalculator=class{constructor(t,e,s,r,i,a){this.branchesPaths=new Map,this.commits=t,this.branches=e,this.commitSpacing=s,this.isGraphVertical=r,this.isGraphReverse=i,this.createDeletedBranch=a}execute(){return this.fromCommits(),this.withMergeCommits(),this.smoothBranchesPaths()}fromCommits(){this.commits.forEach(t=>{let e=this.branches.get(t.branchToDisplay);e||(e=this.getDeletedBranchInPath()||this.createDeletedBranch());const s=[],r=this.branchesPaths.get(e),i=this.commits.find(({hash:e})=>e===t.parents[0]);r?s.push(...r):i&&s.push({x:i.x,y:i.y}),s.push({x:t.x,y:t.y}),this.branchesPaths.set(e,s)})}withMergeCommits(){this.commits.filter(({parents:t})=>t.length>1).forEach(t=>{const e=this.commits.find(({hash:e})=>e===t.parents[1]);if(!e)return;const s=e.branches?e.branches[0]:"";let r=this.branches.get(s);if(!r&&!(r=this.getDeletedBranchInPath()))return;const i=[...this.branchesPaths.get(r)||[]];this.branchesPaths.set(r,[...i,{x:t.x,y:t.y,mergeCommit:!0}])})}getDeletedBranchInPath(){return Array.from(this.branchesPaths.keys()).find(t=>t.isDeleted())}smoothBranchesPaths(){const t=new Map;return this.branchesPaths.forEach((e,s)=>{if(e.length<=1)return void t.set(s,[e]);e=this.isGraphVertical?e.sort((t,e)=>t.y>e.y?-1:1):e.sort((t,e)=>t.x>e.x?1:-1),this.isGraphReverse&&(e=e.reverse());const i=e.reduce((t,s,i)=>{if(s.mergeCommit){t[t.length-1].push(r.pick(s,["x","y"]));let a=i-1,o=e[a];for(;a>=0&&o.mergeCommit;)o=e[--a];a>=0&&t.push([o])}else t[t.length-1].push(s);return t},[[]]);this.isGraphReverse&&i.forEach(t=>t.reverse()),this.isGraphVertical?i.forEach(e=>{if(e.length<=1)return;const r=e[0],i=e[e.length-1],a=e[1].x,o=Math.round(Math.abs(r.y-i.y)/this.commitSpacing)-1,n=o>0?new Array(o).fill(0).map((t,s)=>({x:a,y:e[0].y-this.commitSpacing*(s+1)})):[],h=t.get(s)||[];t.set(s,[...h,[r,...n,i]])}):i.forEach(e=>{if(e.length<=1)return;const r=e[0],i=e[e.length-1],a=e[1].y,o=Math.round(Math.abs(r.x-i.x)/this.commitSpacing)-1,n=o>0?new Array(o).fill(0).map((t,s)=>({y:a,x:e[0].x+this.commitSpacing*(s+1)})):[],h=t.get(s)||[];t.set(s,[...h,[r,...n,i]])})}),t}},s.toSvgPath=function(t,e,s){return t.map(t=>"M"+t.map(({x:t,y:r},i,a)=>{if(e&&a.length>1&&(1===i||i===a.length-1)){const e=a[i-1];if(s){const s=(e.y+r)/2;return`C ${e.x} ${s} ${t} ${s} ${t} ${r}`}{const s=(e.x+t)/2;return`C ${s} ${e.y} ${s} ${r} ${t} ${r}`}}return`L ${t} ${r}`}).join(" ").slice(1)).join(" ")}},{"./utils":17}],4:[function(t,e,s){var r;r=function(){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var e=t("./gitgraph");s.GitgraphCore=e.GitgraphCore;var r=t("./mode");s.Mode=r.Mode;var i=t("./user-api/gitgraph-user-api");s.GitgraphUserApi=i.GitgraphUserApi;var a=t("./user-api/branch-user-api");s.BranchUserApi=a.BranchUserApi;var o=t("./branch");s.Branch=o.Branch;var n=t("./commit");s.Commit=n.Commit;var h=t("./tag");s.Tag=h.Tag;var c=t("./refs");s.Refs=c.Refs;var m=t("./template");s.MergeStyle=m.MergeStyle,s.TemplateName=m.TemplateName,s.templateExtend=m.templateExtend;var l=t("./orientation");s.Orientation=l.Orientation;var p=t("./branches-paths");s.toSvgPath=p.toSvgPath;var u=t("./utils");s.arrowSvgPath=u.arrowSvgPath},"object"==typeof s&&void 0!==e?r():"function"==typeof define&&define.amd?define(r):r()},{"./branch":1,"./branches-paths":3,"./commit":5,"./gitgraph":6,"./mode":10,"./orientation":11,"./refs":12,"./tag":13,"./template":14,"./user-api/branch-user-api":15,"./user-api/gitgraph-user-api":16,"./utils":17}],5:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./tag"),i=()=>(Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)).substring(0,40);class a{constructor(t){let e,s;this.refs=[],this.x=0,this.y=0;try{[,e,s]=t.author.match(/(.*) <(.*)>/)}catch(r){[e,s]=[t.author,""]}this.author={name:e,email:s,timestamp:Date.now()},this.committer={name:e,email:s,timestamp:Date.now()},this.subject=t.subject,this.body=t.body||"",this.hash=t.hash||i(),this.hashAbbrev=this.hash.substring(0,7),this.parents=t.parents?t.parents:[],this.parentsAbbrev=this.parents.map(t=>t.substring(0,7)),this.style=Object.assign({},t.style,{message:Object.assign({},t.style.message),dot:Object.assign({},t.style.dot)}),this.dotText=t.dotText,this.onClick=(()=>t.onClick?t.onClick(this):void 0),this.onMessageClick=(()=>t.onMessageClick?t.onMessageClick(this):void 0),this.onMouseOver=(()=>t.onMouseOver?t.onMouseOver(this):void 0),this.onMouseOut=(()=>t.onMouseOut?t.onMouseOut(this):void 0),this.renderDot=t.renderDot,this.renderMessage=t.renderMessage,this.renderTooltip=t.renderTooltip}get message(){let t="";return this.style.message.displayHash&&(t+=`${this.hashAbbrev} `),t+=this.subject,this.style.message.displayAuthor&&(t+=` - ${this.author.name} <${this.author.email}>`),t}get branchToDisplay(){return this.branches?this.branches[0]:""}setRefs(t){return this.refs=t.getNames(this.hash),this}setTags(t,e,s){return this.tags=t.getNames(this.hash).map(t=>new r.Tag(t,e(t),s(t),this.style)),this}setBranches(t){return this.branches=t,this}setPosition({x:t,y:e}){return this.x=t,this.y=e,this}withDefaultColor(t){const e=Object.assign({},this.style,{dot:Object.assign({},this.style.dot),message:Object.assign({},this.style.message)});e.color||(e.color=t),e.dot.color||(e.dot.color=t),e.message.color||(e.message.color=t);const s=this.cloneCommit();return s.style=e,s}cloneCommit(){const t=new a({author:`${this.author.name} <${this.author.email}>`,subject:this.subject,style:this.style,body:this.body,hash:this.hash,parents:this.parents,dotText:this.dotText,onClick:this.onClick,onMessageClick:this.onMessageClick,onMouseOver:this.onMouseOver,onMouseOut:this.onMouseOut,renderDot:this.renderDot,renderMessage:this.renderMessage,renderTooltip:this.renderTooltip});return t.refs=this.refs,t.branches=this.branches,t.tags=this.tags,t.x=this.x,t.y=this.y,t}}s.Commit=a},{"./tag":13}],6:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./branch"),i=t("./graph-rows"),a=t("./mode"),o=t("./branches-order"),n=t("./template"),h=t("./refs"),c=t("./branches-paths"),m=t("./utils"),l=t("./orientation"),p=t("./user-api/gitgraph-user-api");s.GitgraphCore=class{constructor(t={}){this.refs=new h.Refs,this.tags=new h.Refs,this.tagStyles={},this.tagRenders={},this.commits=[],this.branches=new Map,this.listeners=[],this.nextTimeoutId=null,this.template=n.getTemplate(t.template),this.currentBranch=this.createBranch("master"),this.orientation=t.orientation,this.reverseArrow=m.booleanOptionOr(t.reverseArrow,!1),this.initCommitOffsetX=m.numberOptionOr(t.initCommitOffsetX,0),this.initCommitOffsetY=m.numberOptionOr(t.initCommitOffsetY,0),this.mode=t.mode,this.author=t.author||"Sergio Flores <saxo-guy@epic.com>",this.commitMessage=t.commitMessage||"He doesn't like George Michael! Boooo!",this.generateCommitHash="function"==typeof t.generateCommitHash?t.generateCommitHash:()=>void 0,this.branchesOrderFunction="function"==typeof t.compareBranchesOrder?t.compareBranchesOrder:void 0,this.branchLabelOnEveryCommit=m.booleanOptionOr(t.branchLabelOnEveryCommit,!1)}get isHorizontal(){return this.orientation===l.Orientation.Horizontal||this.orientation===l.Orientation.HorizontalReverse}get isVertical(){return!this.isHorizontal}get isReverse(){return this.orientation===l.Orientation.HorizontalReverse||this.orientation===l.Orientation.VerticalReverse}get shouldDisplayCommitMessage(){return!this.isHorizontal&&this.mode!==a.Mode.Compact}getUserApi(){return new p.GitgraphUserApi(this,()=>this.next())}subscribe(t){this.listeners.push(t);let e=!0;return()=>{if(!e)return;e=!1;const s=this.listeners.indexOf(t);this.listeners.splice(s,1)}}getRenderedData(){const t=this.computeRenderedCommits(),e=this.computeRenderedBranchesPaths(t),s=this.computeCommitMessagesX(e);return this.computeBranchesColor(t,e),{commits:t,branchesPaths:e,commitMessagesX:s}}createBranch(t){let e={gitgraph:this,name:"",parentCommitHash:this.refs.getCommit("HEAD"),style:this.template.branch,onGraphUpdate:()=>this.next()};if("string"==typeof t)e.name=t,e.parentCommitHash=this.refs.getCommit("HEAD");else{const s=t.from?t.from.name:"HEAD",r=this.refs.getCommit(s)||(this.refs.hasCommit(t.from)?t.from:void 0);t.style=t.style||{},e=Object.assign({},e,t,{parentCommitHash:r,style:Object.assign({},e.style,t.style,{label:Object.assign({},e.style.label,t.style.label)})})}const s=new r.Branch(e);return this.branches.set(s.name,s),s}computeRenderedCommits(){const t=this.getBranches(),e=this.commits.map(e=>this.withBranches(t,e)),s=i.createGraphRows(this.mode,this.commits),r=new o.BranchesOrder(e,this.template.colors,this.branchesOrderFunction);return e.map(t=>t.setRefs(this.refs)).map(t=>this.withPosition(s,r,t)).map(t=>t.withDefaultColor(this.getBranchDefaultColor(r,t.branchToDisplay))).map(t=>t.setTags(this.tags,t=>Object.assign({},this.tagStyles[t],this.template.tag),t=>this.tagRenders[t]))}computeRenderedBranchesPaths(t){return new c.BranchesPathsCalculator(t,this.branches,this.template.commit.spacing,this.isVertical,this.isReverse,()=>r.createDeletedBranch(this,this.template.branch,()=>this.next())).execute()}computeBranchesColor(t,e){const s=new o.BranchesOrder(t,this.template.colors,this.branchesOrderFunction);Array.from(e).forEach(([t])=>{t.computedColor=t.style.color||this.getBranchDefaultColor(s,t.name)})}computeCommitMessagesX(t){return Array.from(t).length*this.template.branch.spacing}withBranches(t,e){let s=Array.from((t.get(e.hash)||new Set).values());return 0===s.length&&(s=[r.DELETED_BRANCH_NAME]),e.setBranches(s)}getBranches(){const t=new Map,e=[];return this.refs.getAllNames().filter(t=>"HEAD"!==t).forEach(s=>{const r=this.refs.getCommit(s);for(r&&e.push(r);e.length>0;){const r=e.pop(),i=this.commits.find(({hash:t})=>t===r),a=t.get(r)||new Set;a.add(s),t.set(r,a),i.parents.length>0&&e.push(i.parents[0])}}),t}withPosition(t,e,s){const r=t.getRowOf(s.hash),i=t.getMaxRow(),a=e.get(s.branchToDisplay);switch(this.orientation){default:return s.setPosition({x:this.initCommitOffsetX+this.template.branch.spacing*a,y:this.initCommitOffsetY+this.template.commit.spacing*(i-r)});case l.Orientation.VerticalReverse:return s.setPosition({x:this.initCommitOffsetX+this.template.branch.spacing*a,y:this.initCommitOffsetY+this.template.commit.spacing*r});case l.Orientation.Horizontal:return s.setPosition({x:this.initCommitOffsetX+this.template.commit.spacing*r,y:this.initCommitOffsetY+this.template.branch.spacing*a});case l.Orientation.HorizontalReverse:return s.setPosition({x:this.initCommitOffsetX+this.template.commit.spacing*(i-r),y:this.initCommitOffsetY+this.template.branch.spacing*a})}}getBranchDefaultColor(t,e){return t.getColorOf(e)}next(){this.nextTimeoutId&&window.clearTimeout(this.nextTimeoutId),this.nextTimeoutId=window.setTimeout(()=>{this.listeners.forEach(t=>t(this.getRenderedData()))},0)}}},{"./branch":1,"./branches-order":2,"./branches-paths":3,"./graph-rows":8,"./mode":10,"./orientation":11,"./refs":12,"./template":14,"./user-api/gitgraph-user-api":16,"./utils":17}],7:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./regular");s.CompactGraphRows=class extends r.RegularGraphRows{computeRowsFromCommits(t){t.forEach((e,s)=>{let r=s;if(0!==s){const i=this.getRowOf(e.parents[0]),a=t[s-1];r=Math.max(i+1,this.getRowOf(a.hash)),e.parents.length>1&&i<this.getRowOf(e.parents[1])&&r++}this.rows.set(e.hash,r)})}}},{"./regular":9}],8:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("../mode"),i=t("./compact"),a=t("./regular");s.GraphRows=a.RegularGraphRows,s.createGraphRows=function(t,e){return t===r.Mode.Compact?new i.CompactGraphRows(e):new a.RegularGraphRows(e)}},{"../mode":10,"./compact":7,"./regular":9}],9:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.RegularGraphRows=class{constructor(t){this.rows=new Map,this.maxRowCache=void 0,this.computeRowsFromCommits(t)}getRowOf(t){return this.rows.get(t)||0}getMaxRow(){return void 0===this.maxRowCache&&(this.maxRowCache=function(t){const e=new Set;return t.forEach(t=>e.add(t)),Array.from(e)}(Array.from(this.rows.values())).length-1),this.maxRowCache}computeRowsFromCommits(t){t.forEach((t,e)=>{this.rows.set(t.hash,e)}),this.maxRowCache=void 0}}},{}],10:[function(t,e,s){"use strict";var r;Object.defineProperty(s,"__esModule",{value:!0}),function(t){t.Compact="compact"}(r||(r={})),s.Mode=r},{}],11:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0}),function(t){t.VerticalReverse="vertical-reverse",t.Horizontal="horizontal",t.HorizontalReverse="horizontal-reverse"}(s.Orientation||(s.Orientation={}))},{}],12:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.Refs=class{constructor(){this.commitPerName=new Map,this.namesPerCommit=new Map}set(t,e){const s=this.commitPerName.get(t);return s&&this.removeNameFrom(s,t),this.addNameTo(e,t),this.addCommitTo(t,e),this}getCommit(t){return this.commitPerName.get(t)}getNames(t){return this.namesPerCommit.get(t)||[]}getAllNames(){return Array.from(this.commitPerName.keys())}hasCommit(t){return this.namesPerCommit.has(t)}hasName(t){return this.commitPerName.has(t)}removeNameFrom(t,e){const s=this.namesPerCommit.get(t)||[];this.namesPerCommit.set(t,s.filter(t=>t!==e))}addNameTo(t,e){const s=this.namesPerCommit.get(t)||[];this.namesPerCommit.set(t,[...s,e])}addCommitTo(t,e){this.commitPerName.set(t,e)}}},{}],13:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./template"),i=t("./utils");s.Tag=class{constructor(t,e,s,r){this.name=t,this.tagStyle=e,this.commitStyle=r,this.render=s}get style(){return{strokeColor:this.tagStyle.strokeColor||this.commitStyle.color,bgColor:this.tagStyle.bgColor||this.commitStyle.color,color:this.tagStyle.color||"white",font:this.tagStyle.font||this.commitStyle.message.font||r.DEFAULT_FONT,borderRadius:i.numberOptionOr(this.tagStyle.borderRadius,10),pointerWidth:i.numberOptionOr(this.tagStyle.pointerWidth,12)}}}},{"./template":14,"./utils":17}],14:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./utils");var i;!function(t){t.Bezier="bezier",t.Straight="straight"}(i||(i={})),s.MergeStyle=i,s.DEFAULT_FONT="normal 12pt Calibri";class a{constructor(t){t.branch=t.branch||{},t.branch.label=t.branch.label||{},t.arrow=t.arrow||{},t.commit=t.commit||{},t.commit.dot=t.commit.dot||{},t.commit.message=t.commit.message||{},this.colors=t.colors||["#000000"],this.branch={color:t.branch.color,lineWidth:t.branch.lineWidth||2,mergeStyle:t.branch.mergeStyle||i.Bezier,spacing:r.numberOptionOr(t.branch.spacing,20),label:{display:r.booleanOptionOr(t.branch.label.display,!0),color:t.branch.label.color||t.commit.color,strokeColor:t.branch.label.strokeColor||t.commit.color,bgColor:t.branch.label.bgColor||"white",font:t.branch.label.font||t.commit.message.font||s.DEFAULT_FONT,borderRadius:r.numberOptionOr(t.branch.label.borderRadius,10)}},this.arrow={size:t.arrow.size||null,color:t.arrow.color||null,offset:t.arrow.offset||2},this.commit={color:t.commit.color,spacing:r.numberOptionOr(t.commit.spacing,25),hasTooltipInCompactMode:r.booleanOptionOr(t.commit.hasTooltipInCompactMode,!0),dot:{color:t.commit.dot.color||t.commit.color,size:t.commit.dot.size||3,strokeWidth:r.numberOptionOr(t.commit.dot.strokeWidth,0),strokeColor:t.commit.dot.strokeColor,font:t.commit.dot.font||t.commit.message.font||"normal 10pt Calibri"},message:{display:r.booleanOptionOr(t.commit.message.display,!0),displayAuthor:r.booleanOptionOr(t.commit.message.displayAuthor,!0),displayHash:r.booleanOptionOr(t.commit.message.displayHash,!0),color:t.commit.message.color||t.commit.color,font:t.commit.message.font||s.DEFAULT_FONT}},this.tag=t.tag||{}}}s.Template=a;const o=new a({colors:["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],branch:{color:"#000000",lineWidth:4,spacing:50,mergeStyle:i.Straight},commit:{spacing:60,dot:{size:16,strokeColor:"#000000",strokeWidth:4},message:{color:"black"}},arrow:{size:16,offset:-1.5}});s.blackArrowTemplate=o;const n=new a({colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacing:50},commit:{spacing:80,dot:{size:14},message:{font:"normal 14pt Arial"}}});var h;function c(t){return t?"string"==typeof t?{[h.BlackArrow]:o,[h.Metro]:n}[t]:t:n}s.metroTemplate=n,function(t){t.Metro="metro",t.BlackArrow="blackarrow"}(h||(h={})),s.TemplateName=h,s.templateExtend=function(t,e){const s=c(t);return e.branch||(e.branch={}),e.commit||(e.commit={}),{colors:e.colors||s.colors,arrow:Object.assign({},s.arrow,e.arrow),branch:Object.assign({},s.branch,e.branch,{label:Object.assign({},s.branch.label,e.branch.label)}),commit:Object.assign({},s.commit,e.commit,{dot:Object.assign({},s.commit.dot,e.commit.dot),message:Object.assign({},s.commit.message,e.commit.message)}),tag:Object.assign({},s.tag,e.tag)}},s.getTemplate=c},{"./utils":17}],15:[function(t,e,s){"use strict";var r=this&&this.__rest||function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(s[r[i]]=t[r[i]])}return s};Object.defineProperty(s,"__esModule",{value:!0});const i=t("../commit"),a=t("../utils");class o{constructor(t,e,s){this._branch=t,this.name=t.name,this._graph=e,this._onGraphUpdate=s}branch(t){const e="string"==typeof t?{name:t}:t;return e.from=this,this._graph.createBranch(e).getUserApi()}commit(t){return"string"==typeof t&&(t={subject:t}),t||(t={}),this._commitWithParents(t,[]),this._onGraphUpdate(),this}merge(...t){let e=t[0];(function(t){return"object"==typeof t&&!(t instanceof o)})(e)||(e={branch:t[0],fastForward:!1,commitOptions:{subject:t[1]}});const{branch:s,fastForward:r,commitOptions:i}=e,a="string"==typeof s?s:s.name,n=this._graph.refs.getCommit(a);if(!n)throw new Error(`The branch called "${a}" is unknown`);let h=!1;if(r){const t=this._graph.refs.getCommit(this._branch.name);t&&(h=this._areCommitsConnected(t,n))}return r&&h?this._fastForwardTo(n):this._commitWithParents(Object.assign({},i,{subject:i&&i.subject||`Merge branch ${a}`}),[n]),this._onGraphUpdate(),this}tag(t){return"string"==typeof t?this._graph.getUserApi().tag({name:t,ref:this._branch.name}):this._graph.getUserApi().tag(Object.assign({},t,{ref:this._branch.name})),this}checkout(){const t=this._branch,e=this._graph.refs.getCommit(t.name);return this._graph.currentBranch=t,e&&this._graph.refs.set("HEAD",e),this}_commitWithParents(t,e){const s=this._graph.refs.getCommit(this._branch.name);s?e.unshift(s):this._branch.parentCommitHash&&e.unshift(this._branch.parentCommitHash);const{tag:a}=t,o=r(t,["tag"]),n=new i.Commit(Object.assign({hash:this._graph.generateCommitHash(),author:this._branch.commitDefaultOptions.author||this._graph.author,subject:this._branch.commitDefaultOptions.subject||this._graph.commitMessage},o,{parents:e,style:this._getCommitStyle(t.style)}));if(s){this._graph.refs.getNames(s).forEach(t=>this._graph.refs.set(t,n.hash))}else this._graph.refs.set(this._branch.name,n.hash);this._graph.commits.push(n),this.checkout(),a&&this.tag(a)}_areCommitsConnected(t,e){const s=this._graph.commits.find(({hash:t})=>e===t);return!!s&&(!(0===s.parents.length)&&(!!s.parents.includes(t)||s.parents.some(e=>this._areCommitsConnected(t,e))))}_fastForwardTo(t){this._graph.refs.set(this._branch.name,t)}_getCommitStyle(t={}){return Object.assign({},a.withoutUndefinedKeys(this._graph.template.commit),a.withoutUndefinedKeys(this._branch.commitDefaultOptions.style),t,{message:Object.assign({},a.withoutUndefinedKeys(this._graph.template.commit.message),a.withoutUndefinedKeys(this._branch.commitDefaultOptions.style.message),t.message,a.withoutUndefinedKeys({display:this._graph.shouldDisplayCommitMessage&&void 0})),dot:Object.assign({},a.withoutUndefinedKeys(this._graph.template.commit.dot),a.withoutUndefinedKeys(this._branch.commitDefaultOptions.style.dot),t.dot)})}}s.BranchUserApi=o},{"../commit":5,"../utils":17}],16:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("../commit"),i=t("../branch"),a=t("../refs");s.GitgraphUserApi=class{constructor(t,e){this._graph=t,this._onGraphUpdate=e}clear(){return this._graph.refs=new a.Refs,this._graph.tags=new a.Refs,this._graph.commits=[],this._graph.branches=new Map,this._graph.currentBranch=this._graph.createBranch("master"),this._onGraphUpdate(),this}commit(t){return this._graph.currentBranch.getUserApi().commit(t),this}branch(t){return this._graph.createBranch(t).getUserApi()}tag(...t){let e,s,r,i,a;if("string"==typeof t[0]?(e=t[0],s=t[1]):(e=t[0].name,s=t[0].ref,r=t[0].style,i=t[0].render),!s){const t=this._graph.refs.getCommit("HEAD");if(!t)return this;s=t}if(this._graph.refs.hasCommit(s)&&(a=s),this._graph.refs.hasName(s)&&(a=this._graph.refs.getCommit(s)),!a)throw new Error(`The ref "${s}" does not exist`);return this._graph.tags.set(e,a),this._graph.tagStyles[e]=r,this._graph.tagRenders[e]=i,this._onGraphUpdate(),this}import(t){const e=new Error("Only `git2json` format is supported for imported data.");if(!Array.isArray(t))throw e;if(!t.every(t=>"object"==typeof t&&"object"==typeof t.author&&Array.isArray(t.refs)))throw e;const s=t.map(t=>Object.assign({},t,{style:Object.assign({},this._graph.template.commit,{message:Object.assign({},this._graph.template.commit.message,{display:this._graph.shouldDisplayCommitMessage})}),author:`${t.author.name} <${t.author.email}>`})).reverse();this.clear(),this._graph.commits=s.map(t=>new r.Commit(t)),s.forEach(({refs:t,hash:e})=>{t&&e&&(t.map(t=>t.split("tag: ")).map(([t,e])=>e).filter(t=>"string"==typeof t).forEach(t=>this._graph.tags.set(t,e)),t.filter(t=>!t.startsWith("tag: ")).forEach(t=>this._graph.refs.set(t,e)))});const i=this._getBranches();return this._graph.commits.map(t=>this._withBranches(i,t)).reduce((t,e)=>e.branches?(e.branches.forEach(e=>t.add(e)),t):t,new Set).forEach(t=>this.branch(t)),this._onGraphUpdate(),this}_withBranches(t,e){let s=Array.from((t.get(e.hash)||new Set).values());return 0===s.length&&(s=[i.DELETED_BRANCH_NAME]),e.setBranches(s)}_getBranches(){const t=new Map,e=[];return this._graph.refs.getAllNames().filter(t=>"HEAD"!==t).forEach(s=>{const r=this._graph.refs.getCommit(s);for(r&&e.push(r);e.length>0;){const r=e.pop(),i=this._graph.commits.find(({hash:t})=>t===r),a=t.get(r)||new Set;a.add(s),t.set(r,a),i.parents.length>0&&e.push(i.parents[0])}}),t}}},{"../branch":1,"../commit":5,"../refs":12}],17:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./orientation");function i(t,e){return Object.assign({},e.reduce((e,s)=>Object.assign({},e,{[s]:t[s]}),{}))}function a(t){return void 0===t}s.booleanOptionOr=function(t,e){return"boolean"==typeof t?t:e},s.numberOptionOr=function(t,e){return"number"==typeof t?t:e},s.pick=i,s.debug=function(t,e){console.log(JSON.stringify(t.map(t=>i(t,e)),null,2))},s.isUndefined=a,s.withoutUndefinedKeys=function(t={}){return Object.keys(t).reduce((e,s)=>a(t[s])?e:Object.assign({},e,{[s]:t[s]}),{})},s.arrowSvgPath=function(t,e,s){const i=s.style.dot.size,a=t.template.arrow.size,o=i+t.template.arrow.offset,n=Math.PI/7,h=function(t,e,s){const i=e.x-s.x,a=e.y-s.y,o=t.template.commit.spacing;let n,h;switch(t.orientation){case r.Orientation.Horizontal:n=a,h=-o;break;case r.Orientation.HorizontalReverse:n=a,h=o;break;case r.Orientation.VerticalReverse:n=-o,h=i;break;default:n=o,h=i}return t.isVertical?Math.abs(a)>o&&(h=0):Math.abs(i)>o&&(n=0),t.reverseArrow&&(n*=-1,h*=-1),Math.atan2(n,h)}(t,e,s),c=o*Math.cos(h),m=o*Math.sin(h),l=(o+a)*Math.cos(h-n),p=(o+a)*Math.sin(h-n),u=(o+a/2)*Math.cos(h),g=(o+a/2)*Math.sin(h),f=(o+a)*Math.cos(h+n),d=(o+a)*Math.sin(h+n);return`M${c},${m} L${l},${p} Q${u},${g} ${f},${d} L${f},${d}`}},{"./orientation":11}]},{},[4]);
!function(){return function t(e,s,r){function i(o,n){if(!s[o]){if(!e[o]){var h="function"==typeof require&&require;if(!n&&h)return h(o,!0);if(a)return a(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var m=s[o]={exports:{}};e[o][0].call(m.exports,function(t){return i(e[o][1][t]||t)},m,m.exports,t,e,s,r)}return s[o].exports}for(var a="function"==typeof require&&require,o=0;o<r.length;o++)i(r[o]);return i}}()({1:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./user-api/branch-user-api"),i="";s.DELETED_BRANCH_NAME=i;class a{constructor(t){this.gitgraph=t.gitgraph,this.name=t.name,this.style=t.style,this.parentCommitHash=t.parentCommitHash,this.commitDefaultOptions=t.commitDefaultOptions||{style:{}},this.onGraphUpdate=t.onGraphUpdate,this.renderLabel=t.renderLabel}getUserApi(){return new r.BranchUserApi(this,this.gitgraph,this.onGraphUpdate)}isDeleted(){return this.name===i}}s.Branch=a,s.createDeletedBranch=function(t,e,s){return new a({name:i,gitgraph:t,style:e,onGraphUpdate:s})}},{"./user-api/branch-user-api":15}],2:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.BranchesOrder=class{constructor(t,e,s){this.branches=new Set,this.colors=e,t.forEach(t=>this.branches.add(t.branchToDisplay)),s&&(this.branches=new Set(Array.from(this.branches).sort(s)))}get(t){return Array.from(this.branches).findIndex(e=>e===t)}getColorOf(t){return this.colors[this.get(t)%this.colors.length]}}},{}],3:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./utils");s.BranchesPathsCalculator=class{constructor(t,e,s,r,i,a){this.branchesPaths=new Map,this.commits=t,this.branches=e,this.commitSpacing=s,this.isGraphVertical=r,this.isGraphReverse=i,this.createDeletedBranch=a}execute(){return this.fromCommits(),this.withMergeCommits(),this.smoothBranchesPaths()}fromCommits(){this.commits.forEach(t=>{let e=this.branches.get(t.branchToDisplay);e||(e=this.getDeletedBranchInPath()||this.createDeletedBranch());const s=[],r=this.branchesPaths.get(e),i=this.commits.find(({hash:e})=>e===t.parents[0]);r?s.push(...r):i&&s.push({x:i.x,y:i.y}),s.push({x:t.x,y:t.y}),this.branchesPaths.set(e,s)})}withMergeCommits(){this.commits.filter(({parents:t})=>t.length>1).forEach(t=>{const e=this.commits.find(({hash:e})=>e===t.parents[1]);if(!e)return;const s=e.branches?e.branches[0]:"";let r=this.branches.get(s);if(!r&&!(r=this.getDeletedBranchInPath()))return;const i=[...this.branchesPaths.get(r)||[]];this.branchesPaths.set(r,[...i,{x:t.x,y:t.y,mergeCommit:!0}])})}getDeletedBranchInPath(){return Array.from(this.branchesPaths.keys()).find(t=>t.isDeleted())}smoothBranchesPaths(){const t=new Map;return this.branchesPaths.forEach((e,s)=>{if(e.length<=1)return void t.set(s,[e]);e=this.isGraphVertical?e.sort((t,e)=>t.y>e.y?-1:1):e.sort((t,e)=>t.x>e.x?1:-1),this.isGraphReverse&&(e=e.reverse());const i=e.reduce((t,s,i)=>{if(s.mergeCommit){t[t.length-1].push(r.pick(s,["x","y"]));let a=i-1,o=e[a];for(;a>=0&&o.mergeCommit;)o=e[--a];a>=0&&t.push([o])}else t[t.length-1].push(s);return t},[[]]);this.isGraphReverse&&i.forEach(t=>t.reverse()),this.isGraphVertical?i.forEach(e=>{if(e.length<=1)return;const r=e[0],i=e[e.length-1],a=e[1].x,o=Math.round(Math.abs(r.y-i.y)/this.commitSpacing)-1,n=o>0?new Array(o).fill(0).map((t,s)=>({x:a,y:e[0].y-this.commitSpacing*(s+1)})):[],h=t.get(s)||[];t.set(s,[...h,[r,...n,i]])}):i.forEach(e=>{if(e.length<=1)return;const r=e[0],i=e[e.length-1],a=e[1].y,o=Math.round(Math.abs(r.x-i.x)/this.commitSpacing)-1,n=o>0?new Array(o).fill(0).map((t,s)=>({y:a,x:e[0].x+this.commitSpacing*(s+1)})):[],h=t.get(s)||[];t.set(s,[...h,[r,...n,i]])})}),t}},s.toSvgPath=function(t,e,s){return t.map(t=>"M"+t.map(({x:t,y:r},i,a)=>{if(e&&a.length>1&&(1===i||i===a.length-1)){const e=a[i-1];if(s){const s=(e.y+r)/2;return`C ${e.x} ${s} ${t} ${s} ${t} ${r}`}{const s=(e.x+t)/2;return`C ${s} ${e.y} ${s} ${r} ${t} ${r}`}}return`L ${t} ${r}`}).join(" ").slice(1)).join(" ")}},{"./utils":17}],4:[function(t,e,s){var r;r=function(){"use strict";Object.defineProperty(s,"__esModule",{value:!0});var e=t("./gitgraph");s.GitgraphCore=e.GitgraphCore;var r=t("./mode");s.Mode=r.Mode;var i=t("./user-api/gitgraph-user-api");s.GitgraphUserApi=i.GitgraphUserApi;var a=t("./user-api/branch-user-api");s.BranchUserApi=a.BranchUserApi;var o=t("./branch");s.Branch=o.Branch;var n=t("./commit");s.Commit=n.Commit;var h=t("./tag");s.Tag=h.Tag;var c=t("./refs");s.Refs=c.Refs;var m=t("./template");s.MergeStyle=m.MergeStyle,s.TemplateName=m.TemplateName,s.templateExtend=m.templateExtend;var l=t("./orientation");s.Orientation=l.Orientation;var p=t("./branches-paths");s.toSvgPath=p.toSvgPath;var u=t("./utils");s.arrowSvgPath=u.arrowSvgPath},"object"==typeof s&&void 0!==e?r():"function"==typeof define&&define.amd?define(r):r()},{"./branch":1,"./branches-paths":3,"./commit":5,"./gitgraph":6,"./mode":10,"./orientation":11,"./refs":12,"./tag":13,"./template":14,"./user-api/branch-user-api":15,"./user-api/gitgraph-user-api":16,"./utils":17}],5:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./tag"),i=()=>(Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)+Math.random().toString(16).substring(3)).substring(0,40);class a{constructor(t){let e,s;this.refs=[],this.x=0,this.y=0;try{[,e,s]=t.author.match(/(.*) <(.*)>/)}catch(r){[e,s]=[t.author,""]}this.author={name:e,email:s,timestamp:Date.now()},this.committer={name:e,email:s,timestamp:Date.now()},this.subject=t.subject,this.body=t.body||"",this.hash=t.hash||i(),this.hashAbbrev=this.hash.substring(0,7),this.parents=t.parents?t.parents:[],this.parentsAbbrev=this.parents.map(t=>t.substring(0,7)),this.style=Object.assign({},t.style,{message:Object.assign({},t.style.message),dot:Object.assign({},t.style.dot)}),this.dotText=t.dotText,this.onClick=(()=>t.onClick?t.onClick(this):void 0),this.onMessageClick=(()=>t.onMessageClick?t.onMessageClick(this):void 0),this.onMouseOver=(()=>t.onMouseOver?t.onMouseOver(this):void 0),this.onMouseOut=(()=>t.onMouseOut?t.onMouseOut(this):void 0),this.renderDot=t.renderDot,this.renderMessage=t.renderMessage,this.renderTooltip=t.renderTooltip}get message(){let t="";return this.style.message.displayHash&&(t+=`${this.hashAbbrev} `),t+=this.subject,this.style.message.displayAuthor&&(t+=` - ${this.author.name} <${this.author.email}>`),t}get branchToDisplay(){return this.branches?this.branches[0]:""}setRefs(t){return this.refs=t.getNames(this.hash),this}setTags(t,e,s){return this.tags=t.getNames(this.hash).map(t=>new r.Tag(t,e(t),s(t),this.style)),this}setBranches(t){return this.branches=t,this}setPosition({x:t,y:e}){return this.x=t,this.y=e,this}withDefaultColor(t){const e=Object.assign({},this.style,{dot:Object.assign({},this.style.dot),message:Object.assign({},this.style.message)});e.color||(e.color=t),e.dot.color||(e.dot.color=t),e.message.color||(e.message.color=t);const s=this.cloneCommit();return s.style=e,s}cloneCommit(){const t=new a({author:`${this.author.name} <${this.author.email}>`,subject:this.subject,style:this.style,body:this.body,hash:this.hash,parents:this.parents,dotText:this.dotText,onClick:this.onClick,onMessageClick:this.onMessageClick,onMouseOver:this.onMouseOver,onMouseOut:this.onMouseOut,renderDot:this.renderDot,renderMessage:this.renderMessage,renderTooltip:this.renderTooltip});return t.refs=this.refs,t.branches=this.branches,t.tags=this.tags,t.x=this.x,t.y=this.y,t}}s.Commit=a},{"./tag":13}],6:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./branch"),i=t("./graph-rows"),a=t("./mode"),o=t("./branches-order"),n=t("./template"),h=t("./refs"),c=t("./branches-paths"),m=t("./utils"),l=t("./orientation"),p=t("./user-api/gitgraph-user-api");s.GitgraphCore=class{constructor(t={}){this.refs=new h.Refs,this.tags=new h.Refs,this.tagStyles={},this.tagRenders={},this.commits=[],this.branches=new Map,this.listeners=[],this.nextTimeoutId=null,this.template=n.getTemplate(t.template),this.currentBranch=this.createBranch("master"),this.orientation=t.orientation,this.reverseArrow=m.booleanOptionOr(t.reverseArrow,!1),this.initCommitOffsetX=m.numberOptionOr(t.initCommitOffsetX,0),this.initCommitOffsetY=m.numberOptionOr(t.initCommitOffsetY,0),this.mode=t.mode,this.author=t.author||"Sergio Flores <saxo-guy@epic.com>",this.commitMessage=t.commitMessage||"He doesn't like George Michael! Boooo!",this.generateCommitHash="function"==typeof t.generateCommitHash?t.generateCommitHash:()=>void 0,this.branchesOrderFunction="function"==typeof t.compareBranchesOrder?t.compareBranchesOrder:void 0,this.branchLabelOnEveryCommit=m.booleanOptionOr(t.branchLabelOnEveryCommit,!1)}get isHorizontal(){return this.orientation===l.Orientation.Horizontal||this.orientation===l.Orientation.HorizontalReverse}get isVertical(){return!this.isHorizontal}get isReverse(){return this.orientation===l.Orientation.HorizontalReverse||this.orientation===l.Orientation.VerticalReverse}get shouldDisplayCommitMessage(){return!this.isHorizontal&&this.mode!==a.Mode.Compact}getUserApi(){return new p.GitgraphUserApi(this,()=>this.next())}subscribe(t){this.listeners.push(t);let e=!0;return()=>{if(!e)return;e=!1;const s=this.listeners.indexOf(t);this.listeners.splice(s,1)}}getRenderedData(){const t=this.computeRenderedCommits(),e=this.computeRenderedBranchesPaths(t),s=this.computeCommitMessagesX(e);return this.computeBranchesColor(t,e),{commits:t,branchesPaths:e,commitMessagesX:s}}createBranch(t){let e={gitgraph:this,name:"",parentCommitHash:this.refs.getCommit("HEAD"),style:this.template.branch,onGraphUpdate:()=>this.next()};if("string"==typeof t)e.name=t,e.parentCommitHash=this.refs.getCommit("HEAD");else{const s=t.from?t.from.name:"HEAD",r=this.refs.getCommit(s)||(this.refs.hasCommit(t.from)?t.from:void 0);t.style=t.style||{},e=Object.assign({},e,t,{parentCommitHash:r,style:Object.assign({},e.style,t.style,{label:Object.assign({},e.style.label,t.style.label)})})}const s=new r.Branch(e);return this.branches.set(s.name,s),s}computeRenderedCommits(){const t=this.getBranches(),e=this.commits.map(e=>this.withBranches(t,e)),s=i.createGraphRows(this.mode,this.commits),r=new o.BranchesOrder(e,this.template.colors,this.branchesOrderFunction);return e.map(t=>t.setRefs(this.refs)).map(t=>this.withPosition(s,r,t)).map(t=>t.withDefaultColor(this.getBranchDefaultColor(r,t.branchToDisplay))).map(t=>t.setTags(this.tags,t=>Object.assign({},this.tagStyles[t],this.template.tag),t=>this.tagRenders[t]))}computeRenderedBranchesPaths(t){return new c.BranchesPathsCalculator(t,this.branches,this.template.commit.spacing,this.isVertical,this.isReverse,()=>r.createDeletedBranch(this,this.template.branch,()=>this.next())).execute()}computeBranchesColor(t,e){const s=new o.BranchesOrder(t,this.template.colors,this.branchesOrderFunction);Array.from(e).forEach(([t])=>{t.computedColor=t.style.color||this.getBranchDefaultColor(s,t.name)})}computeCommitMessagesX(t){return Array.from(t).length*this.template.branch.spacing}withBranches(t,e){let s=Array.from((t.get(e.hash)||new Set).values());return 0===s.length&&(s=[r.DELETED_BRANCH_NAME]),e.setBranches(s)}getBranches(){const t=new Map,e=[];return this.refs.getAllNames().filter(t=>"HEAD"!==t).forEach(s=>{const r=this.refs.getCommit(s);for(r&&e.push(r);e.length>0;){const r=e.pop(),i=this.commits.find(({hash:t})=>t===r),a=t.get(r)||new Set;a.add(s),t.set(r,a),i&&i.parents&&i.parents.length>0&&e.push(i.parents[0])}}),t}withPosition(t,e,s){const r=t.getRowOf(s.hash),i=t.getMaxRow(),a=e.get(s.branchToDisplay);switch(this.orientation){default:return s.setPosition({x:this.initCommitOffsetX+this.template.branch.spacing*a,y:this.initCommitOffsetY+this.template.commit.spacing*(i-r)});case l.Orientation.VerticalReverse:return s.setPosition({x:this.initCommitOffsetX+this.template.branch.spacing*a,y:this.initCommitOffsetY+this.template.commit.spacing*r});case l.Orientation.Horizontal:return s.setPosition({x:this.initCommitOffsetX+this.template.commit.spacing*r,y:this.initCommitOffsetY+this.template.branch.spacing*a});case l.Orientation.HorizontalReverse:return s.setPosition({x:this.initCommitOffsetX+this.template.commit.spacing*(i-r),y:this.initCommitOffsetY+this.template.branch.spacing*a})}}getBranchDefaultColor(t,e){return t.getColorOf(e)}next(){this.nextTimeoutId&&window.clearTimeout(this.nextTimeoutId),this.nextTimeoutId=window.setTimeout(()=>{this.listeners.forEach(t=>t(this.getRenderedData()))},0)}}},{"./branch":1,"./branches-order":2,"./branches-paths":3,"./graph-rows":8,"./mode":10,"./orientation":11,"./refs":12,"./template":14,"./user-api/gitgraph-user-api":16,"./utils":17}],7:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./regular");s.CompactGraphRows=class extends r.RegularGraphRows{computeRowsFromCommits(t){t.forEach((e,s)=>{let r=s;if(0!==s){const i=this.getRowOf(e.parents[0]),a=t[s-1];r=Math.max(i+1,this.getRowOf(a.hash)),e.parents.length>1&&i<this.getRowOf(e.parents[1])&&r++}this.rows.set(e.hash,r)})}}},{"./regular":9}],8:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("../mode"),i=t("./compact"),a=t("./regular");s.GraphRows=a.RegularGraphRows,s.createGraphRows=function(t,e){return t===r.Mode.Compact?new i.CompactGraphRows(e):new a.RegularGraphRows(e)}},{"../mode":10,"./compact":7,"./regular":9}],9:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.RegularGraphRows=class{constructor(t){this.rows=new Map,this.maxRowCache=void 0,this.computeRowsFromCommits(t)}getRowOf(t){return this.rows.get(t)||0}getMaxRow(){return void 0===this.maxRowCache&&(this.maxRowCache=function(t){const e=new Set;return t.forEach(t=>e.add(t)),Array.from(e)}(Array.from(this.rows.values())).length-1),this.maxRowCache}computeRowsFromCommits(t){t.forEach((t,e)=>{this.rows.set(t.hash,e)}),this.maxRowCache=void 0}}},{}],10:[function(t,e,s){"use strict";var r;Object.defineProperty(s,"__esModule",{value:!0}),function(t){t.Compact="compact"}(r||(r={})),s.Mode=r},{}],11:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0}),function(t){t.VerticalReverse="vertical-reverse",t.Horizontal="horizontal",t.HorizontalReverse="horizontal-reverse"}(s.Orientation||(s.Orientation={}))},{}],12:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});s.Refs=class{constructor(){this.commitPerName=new Map,this.namesPerCommit=new Map}set(t,e){const s=this.commitPerName.get(t);return s&&this.removeNameFrom(s,t),this.addNameTo(e,t),this.addCommitTo(t,e),this}getCommit(t){return this.commitPerName.get(t)}getNames(t){return this.namesPerCommit.get(t)||[]}getAllNames(){return Array.from(this.commitPerName.keys())}hasCommit(t){return this.namesPerCommit.has(t)}hasName(t){return this.commitPerName.has(t)}removeNameFrom(t,e){const s=this.namesPerCommit.get(t)||[];this.namesPerCommit.set(t,s.filter(t=>t!==e))}addNameTo(t,e){const s=this.namesPerCommit.get(t)||[];this.namesPerCommit.set(t,[...s,e])}addCommitTo(t,e){this.commitPerName.set(t,e)}}},{}],13:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./template"),i=t("./utils");s.Tag=class{constructor(t,e,s,r){this.name=t,this.tagStyle=e,this.commitStyle=r,this.render=s}get style(){return{strokeColor:this.tagStyle.strokeColor||this.commitStyle.color,bgColor:this.tagStyle.bgColor||this.commitStyle.color,color:this.tagStyle.color||"white",font:this.tagStyle.font||this.commitStyle.message.font||r.DEFAULT_FONT,borderRadius:i.numberOptionOr(this.tagStyle.borderRadius,10),pointerWidth:i.numberOptionOr(this.tagStyle.pointerWidth,12)}}}},{"./template":14,"./utils":17}],14:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./utils");var i;!function(t){t.Bezier="bezier",t.Straight="straight"}(i||(i={})),s.MergeStyle=i,s.DEFAULT_FONT="normal 12pt Calibri";class a{constructor(t){t.branch=t.branch||{},t.branch.label=t.branch.label||{},t.arrow=t.arrow||{},t.commit=t.commit||{},t.commit.dot=t.commit.dot||{},t.commit.message=t.commit.message||{},this.colors=t.colors||["#000000"],this.branch={color:t.branch.color,lineWidth:t.branch.lineWidth||2,mergeStyle:t.branch.mergeStyle||i.Bezier,spacing:r.numberOptionOr(t.branch.spacing,20),label:{display:r.booleanOptionOr(t.branch.label.display,!0),color:t.branch.label.color||t.commit.color,strokeColor:t.branch.label.strokeColor||t.commit.color,bgColor:t.branch.label.bgColor||"white",font:t.branch.label.font||t.commit.message.font||s.DEFAULT_FONT,borderRadius:r.numberOptionOr(t.branch.label.borderRadius,10)}},this.arrow={size:t.arrow.size||null,color:t.arrow.color||null,offset:t.arrow.offset||2},this.commit={color:t.commit.color,spacing:r.numberOptionOr(t.commit.spacing,25),hasTooltipInCompactMode:r.booleanOptionOr(t.commit.hasTooltipInCompactMode,!0),dot:{color:t.commit.dot.color||t.commit.color,size:t.commit.dot.size||3,strokeWidth:r.numberOptionOr(t.commit.dot.strokeWidth,0),strokeColor:t.commit.dot.strokeColor,font:t.commit.dot.font||t.commit.message.font||"normal 10pt Calibri"},message:{display:r.booleanOptionOr(t.commit.message.display,!0),displayAuthor:r.booleanOptionOr(t.commit.message.displayAuthor,!0),displayHash:r.booleanOptionOr(t.commit.message.displayHash,!0),color:t.commit.message.color||t.commit.color,font:t.commit.message.font||s.DEFAULT_FONT}},this.tag=t.tag||{}}}s.Template=a;const o=new a({colors:["#6963FF","#47E8D4","#6BDB52","#E84BA5","#FFA657"],branch:{color:"#000000",lineWidth:4,spacing:50,mergeStyle:i.Straight},commit:{spacing:60,dot:{size:16,strokeColor:"#000000",strokeWidth:4},message:{color:"black"}},arrow:{size:16,offset:-1.5}});s.blackArrowTemplate=o;const n=new a({colors:["#979797","#008fb5","#f1c109"],branch:{lineWidth:10,spacing:50},commit:{spacing:80,dot:{size:14},message:{font:"normal 14pt Arial"}}});var h;function c(t){return t?"string"==typeof t?{[h.BlackArrow]:o,[h.Metro]:n}[t]:t:n}s.metroTemplate=n,function(t){t.Metro="metro",t.BlackArrow="blackarrow"}(h||(h={})),s.TemplateName=h,s.templateExtend=function(t,e){const s=c(t);return e.branch||(e.branch={}),e.commit||(e.commit={}),{colors:e.colors||s.colors,arrow:Object.assign({},s.arrow,e.arrow),branch:Object.assign({},s.branch,e.branch,{label:Object.assign({},s.branch.label,e.branch.label)}),commit:Object.assign({},s.commit,e.commit,{dot:Object.assign({},s.commit.dot,e.commit.dot),message:Object.assign({},s.commit.message,e.commit.message)}),tag:Object.assign({},s.tag,e.tag)}},s.getTemplate=c},{"./utils":17}],15:[function(t,e,s){"use strict";var r=this&&this.__rest||function(t,e){var s={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(s[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(s[r[i]]=t[r[i]])}return s};Object.defineProperty(s,"__esModule",{value:!0});const i=t("../commit"),a=t("../utils");class o{constructor(t,e,s){this._branch=t,this.name=t.name,this._graph=e,this._onGraphUpdate=s}branch(t){const e="string"==typeof t?{name:t}:t;return e.from=this,this._graph.createBranch(e).getUserApi()}commit(t){return"string"==typeof t&&(t={subject:t}),t||(t={}),this._commitWithParents(t,[]),this._onGraphUpdate(),this}merge(...t){let e=t[0];(function(t){return"object"==typeof t&&!(t instanceof o)})(e)||(e={branch:t[0],fastForward:!1,commitOptions:{subject:t[1]}});const{branch:s,fastForward:r,commitOptions:i}=e,a="string"==typeof s?s:s.name,n=this._graph.refs.getCommit(a);if(!n)throw new Error(`The branch called "${a}" is unknown`);let h=!1;if(r){const t=this._graph.refs.getCommit(this._branch.name);t&&(h=this._areCommitsConnected(t,n))}return r&&h?this._fastForwardTo(n):this._commitWithParents(Object.assign({},i,{subject:i&&i.subject||`Merge branch ${a}`}),[n]),this._onGraphUpdate(),this}tag(t){return"string"==typeof t?this._graph.getUserApi().tag({name:t,ref:this._branch.name}):this._graph.getUserApi().tag(Object.assign({},t,{ref:this._branch.name})),this}checkout(){const t=this._branch,e=this._graph.refs.getCommit(t.name);return this._graph.currentBranch=t,e&&this._graph.refs.set("HEAD",e),this}_commitWithParents(t,e){const s=this._graph.refs.getCommit(this._branch.name);s?e.unshift(s):this._branch.parentCommitHash&&e.unshift(this._branch.parentCommitHash);const{tag:a}=t,o=r(t,["tag"]),n=new i.Commit(Object.assign({hash:this._graph.generateCommitHash(),author:this._branch.commitDefaultOptions.author||this._graph.author,subject:this._branch.commitDefaultOptions.subject||this._graph.commitMessage},o,{parents:e,style:this._getCommitStyle(t.style)}));if(s){this._graph.refs.getNames(s).forEach(t=>this._graph.refs.set(t,n.hash))}else this._graph.refs.set(this._branch.name,n.hash);this._graph.commits.push(n),this.checkout(),a&&this.tag(a)}_areCommitsConnected(t,e){const s=this._graph.commits.find(({hash:t})=>e===t);return!!s&&(!(0===s.parents.length)&&(!!s.parents.includes(t)||s.parents.some(e=>this._areCommitsConnected(t,e))))}_fastForwardTo(t){this._graph.refs.set(this._branch.name,t)}_getCommitStyle(t={}){return Object.assign({},a.withoutUndefinedKeys(this._graph.template.commit),a.withoutUndefinedKeys(this._branch.commitDefaultOptions.style),t,{message:Object.assign({},a.withoutUndefinedKeys(this._graph.template.commit.message),a.withoutUndefinedKeys(this._branch.commitDefaultOptions.style.message),t.message,a.withoutUndefinedKeys({display:this._graph.shouldDisplayCommitMessage&&void 0})),dot:Object.assign({},a.withoutUndefinedKeys(this._graph.template.commit.dot),a.withoutUndefinedKeys(this._branch.commitDefaultOptions.style.dot),t.dot)})}}s.BranchUserApi=o},{"../commit":5,"../utils":17}],16:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("../commit"),i=t("../branch"),a=t("../refs");s.GitgraphUserApi=class{constructor(t,e){this._graph=t,this._onGraphUpdate=e}clear(){return this._graph.refs=new a.Refs,this._graph.tags=new a.Refs,this._graph.commits=[],this._graph.branches=new Map,this._graph.currentBranch=this._graph.createBranch("master"),this._onGraphUpdate(),this}commit(t){return this._graph.currentBranch.getUserApi().commit(t),this}branch(t){return this._graph.createBranch(t).getUserApi()}tag(...t){let e,s,r,i,a;if("string"==typeof t[0]?(e=t[0],s=t[1]):(e=t[0].name,s=t[0].ref,r=t[0].style,i=t[0].render),!s){const t=this._graph.refs.getCommit("HEAD");if(!t)return this;s=t}if(this._graph.refs.hasCommit(s)&&(a=s),this._graph.refs.hasName(s)&&(a=this._graph.refs.getCommit(s)),!a)throw new Error(`The ref "${s}" does not exist`);return this._graph.tags.set(e,a),this._graph.tagStyles[e]=r,this._graph.tagRenders[e]=i,this._onGraphUpdate(),this}import(t){const e=new Error("Only `git2json` format is supported for imported data.");if(!Array.isArray(t))throw e;if(!t.every(t=>"object"==typeof t&&"object"==typeof t.author&&Array.isArray(t.refs)))throw e;const s=t.map(t=>Object.assign({},t,{style:Object.assign({},this._graph.template.commit,{message:Object.assign({},this._graph.template.commit.message,{display:this._graph.shouldDisplayCommitMessage})}),author:`${t.author.name} <${t.author.email}>`})).reverse();this.clear(),this._graph.commits=s.map(t=>new r.Commit(t)),s.forEach(({refs:t,hash:e})=>{t&&e&&(t.map(t=>t.split("tag: ")).map(([t,e])=>e).filter(t=>"string"==typeof t).forEach(t=>this._graph.tags.set(t,e)),t.filter(t=>!t.startsWith("tag: ")).forEach(t=>this._graph.refs.set(t,e)))});const i=this._getBranches();return this._graph.commits.map(t=>this._withBranches(i,t)).reduce((t,e)=>e.branches?(e.branches.forEach(e=>t.add(e)),t):t,new Set).forEach(t=>this.branch(t)),this._onGraphUpdate(),this}_withBranches(t,e){let s=Array.from((t.get(e.hash)||new Set).values());return 0===s.length&&(s=[i.DELETED_BRANCH_NAME]),e.setBranches(s)}_getBranches(){const t=new Map,e=[];return this._graph.refs.getAllNames().filter(t=>"HEAD"!==t).forEach(s=>{const r=this._graph.refs.getCommit(s);for(r&&e.push(r);e.length>0;){const r=e.pop(),i=this._graph.commits.find(({hash:t})=>t===r),a=t.get(r)||new Set;a.add(s),t.set(r,a),i&&i.parents&&i.parents.length>0&&e.push(i.parents[0])}}),t}}},{"../branch":1,"../commit":5,"../refs":12}],17:[function(t,e,s){"use strict";Object.defineProperty(s,"__esModule",{value:!0});const r=t("./orientation");function i(t,e){return Object.assign({},e.reduce((e,s)=>Object.assign({},e,{[s]:t[s]}),{}))}function a(t){return void 0===t}s.booleanOptionOr=function(t,e){return"boolean"==typeof t?t:e},s.numberOptionOr=function(t,e){return"number"==typeof t?t:e},s.pick=i,s.debug=function(t,e){console.log(JSON.stringify(t.map(t=>i(t,e)),null,2))},s.isUndefined=a,s.withoutUndefinedKeys=function(t={}){return Object.keys(t).reduce((e,s)=>a(t[s])?e:Object.assign({},e,{[s]:t[s]}),{})},s.arrowSvgPath=function(t,e,s){const i=s.style.dot.size,a=t.template.arrow.size,o=i+t.template.arrow.offset,n=Math.PI/7,h=function(t,e,s){const i=e.x-s.x,a=e.y-s.y,o=t.template.commit.spacing;let n,h;switch(t.orientation){case r.Orientation.Horizontal:n=a,h=-o;break;case r.Orientation.HorizontalReverse:n=a,h=o;break;case r.Orientation.VerticalReverse:n=-o,h=i;break;default:n=o,h=i}return t.isVertical?Math.abs(a)>o&&(h=0):Math.abs(i)>o&&(n=0),t.reverseArrow&&(n*=-1,h*=-1),Math.atan2(n,h)}(t,e,s),c=o*Math.cos(h),m=o*Math.sin(h),l=(o+a)*Math.cos(h-n),p=(o+a)*Math.sin(h-n),u=(o+a/2)*Math.cos(h),g=(o+a/2)*Math.sin(h),f=(o+a)*Math.cos(h+n),d=(o+a)*Math.sin(h+n);return`M${c},${m} L${l},${p} Q${u},${g} ${f},${d} L${f},${d}`}},{"./orientation":11}]},{},[4]);

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

result.set(currentHash, prevBranches);
if (current.parents.length > 0) {
if (current && current.parents && current.parents.length > 0) {
queue.push(current.parents[0]);

@@ -203,0 +203,0 @@ }

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

result.set(currentHash, prevBranches);
if (current.parents.length > 0) {
if (current && current.parents && current.parents.length > 0) {
queue.push(current.parents[0]);

@@ -166,0 +166,0 @@ }

{
"name": "@gitgraph/core",
"version": "1.4.4",
"version": "1.4.5",
"description": "Core of gitgraph, a JavaScript library to draw pretty git graphs",

@@ -67,3 +67,3 @@ "author": "Nicolas Carlo <nicolascarlo.espeon@gmail.com>",

},
"gitHead": "93450f5e55e3a1c09c8e14f6c74977d273c1d4be"
"gitHead": "bc40f5a245d76b7c113da1f0c073d0da2e59b115"
}

@@ -343,3 +343,3 @@ import { Branch, DELETED_BRANCH_NAME, createDeletedBranch } from "./branch";

({ hash }) => hash === currentHash,
) as Commit<TNode>;
) as Commit<TNode> | null;
const prevBranches =

@@ -349,3 +349,3 @@ result.get(currentHash) || new Set<Branch["name"]>();

result.set(currentHash, prevBranches);
if (current.parents.length > 0) {
if (current && current.parents && current.parents.length > 0) {
queue.push(current.parents[0]);

@@ -352,0 +352,0 @@ }

@@ -310,3 +310,3 @@ import { TagStyle, TemplateOptions } from "../template";

({ hash }) => hash === currentHash,
) as Commit<TNode>;
) as Commit<TNode> | null;
const prevBranches =

@@ -316,3 +316,3 @@ result.get(currentHash) || new Set<Branch["name"]>();

result.set(currentHash, prevBranches);
if (current.parents.length > 0) {
if (current && current.parents && current.parents.length > 0) {
queue.push(current.parents[0]);

@@ -319,0 +319,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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