flatboard 2026-8-23:20:42:59
This commit is contained in:
1 parent
b1c0affa60
commit
ba9dd7935d
679 files changed
+158609
No files matched your search
+427
@@ -0,0 +1,427 @@
|
||||
/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source visit the plugins github repository (https://github.com/denolehov/obsidian-git)
|
||||
*/
|
||||
|
||||
"use strict";var E$=Object.create;var gc=Object.defineProperty;var S$=Object.getOwnPropertyDescriptor;var k$=Object.getOwnPropertyNames;var C$=Object.getPrototypeOf,A$=Object.prototype.hasOwnProperty;var Eb=t=>{throw TypeError(t)};var T$=(t,e,r)=>e in t?gc(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var P$=(t,e,r)=>()=>{if(r)throw r[0];try{return t&&(e=t(t=0)),e}catch(i){throw r=[i],i}};var U=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},R$=(t,e)=>{for(var r in e)gc(t,r,{get:e[r],enumerable:!0})},Sb=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of k$(e))!A$.call(t,n)&&n!==r&&gc(t,n,{get:()=>e[n],enumerable:!(i=S$(e,n))||i.enumerable});return t};var ft=(t,e,r)=>(r=t!=null?E$(C$(t)):{},Sb(e||!t||!t.__esModule?gc(r,"default",{value:t,enumerable:!0}):r,t)),$$=t=>Sb(gc({},"__esModule",{value:!0}),t);var He=(t,e,r)=>T$(t,typeof e!="symbol"?e+"":e,r),tm=(t,e,r)=>e.has(t)||Eb("Cannot "+r);var $=(t,e,r)=>(tm(t,e,"read from private field"),r?r.call(t):e.get(t)),me=(t,e,r)=>e.has(t)?Eb("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),fe=(t,e,r,i)=>(tm(t,e,"write to private field"),i?i.call(t,r):e.set(t,r),r),Ee=(t,e,r)=>(tm(t,e,"access private method"),r);var Ab=U(Rf=>{"use strict";m();Rf.byteLength=I$;Rf.toByteArray=D$;Rf.fromByteArray=N$;var ln=[],pi=[],F$=typeof Uint8Array!="undefined"?Uint8Array:Array,rm="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(ia=0,kb=rm.length;ia<kb;++ia)ln[ia]=rm[ia],pi[rm.charCodeAt(ia)]=ia;var ia,kb;pi[45]=62;pi[95]=63;function Cb(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");r===-1&&(r=e);var i=r===e?0:4-r%4;return[r,i]}function I$(t){var e=Cb(t),r=e[0],i=e[1];return(r+i)*3/4-i}function M$(t,e,r){return(e+r)*3/4-r}function D$(t){var e,r=Cb(t),i=r[0],n=r[1],s=new F$(M$(t,i,n)),a=0,o=n>0?i-4:i,l;for(l=0;l<o;l+=4)e=pi[t.charCodeAt(l)]<<18|pi[t.charCodeAt(l+1)]<<12|pi[t.charCodeAt(l+2)]<<6|pi[t.charCodeAt(l+3)],s[a++]=e>>16&255,s[a++]=e>>8&255,s[a++]=e&255;return n===2&&(e=pi[t.charCodeAt(l)]<<2|pi[t.charCodeAt(l+1)]>>4,s[a++]=e&255),n===1&&(e=pi[t.charCodeAt(l)]<<10|pi[t.charCodeAt(l+1)]<<4|pi[t.charCodeAt(l+2)]>>2,s[a++]=e>>8&255,s[a++]=e&255),s}function O$(t){return ln[t>>18&63]+ln[t>>12&63]+ln[t>>6&63]+ln[t&63]}function L$(t,e,r){for(var i,n=[],s=e;s<r;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(t[s+2]&255),n.push(O$(i));return n.join("")}function N$(t){for(var e,r=t.length,i=r%3,n=[],s=16383,a=0,o=r-i;a<o;a+=s)n.push(L$(t,a,a+s>o?o:a+s));return i===1?(e=t[r-1],n.push(ln[e>>2]+ln[e<<4&63]+"==")):i===2&&(e=(t[r-2]<<8)+t[r-1],n.push(ln[e>>10]+ln[e>>4&63]+ln[e<<2&63]+"=")),n.join("")}});var Tb=U(im=>{m();im.read=function(t,e,r,i,n){var s,a,o=n*8-i-1,l=(1<<o)-1,c=l>>1,u=-7,f=r?n-1:0,d=r?-1:1,h=t[e+f];for(f+=d,s=h&(1<<-u)-1,h>>=-u,u+=o;u>0;s=s*256+t[e+f],f+=d,u-=8);for(a=s&(1<<-u)-1,s>>=-u,u+=i;u>0;a=a*256+t[e+f],f+=d,u-=8);if(s===0)s=1-c;else{if(s===l)return a?NaN:(h?-1:1)*(1/0);a=a+Math.pow(2,i),s=s-c}return(h?-1:1)*a*Math.pow(2,s-i)};im.write=function(t,e,r,i,n,s){var a,o,l,c=s*8-n-1,u=(1<<c)-1,f=u>>1,d=n===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:s-1,p=i?1:-1,g=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(o=isNaN(e)?1:0,a=u):(a=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+f>=1?e+=d/l:e+=d*Math.pow(2,1-f),e*l>=2&&(a++,l/=2),a+f>=u?(o=0,a=u):a+f>=1?(o=(e*l-1)*Math.pow(2,n),a=a+f):(o=e*Math.pow(2,f-1)*Math.pow(2,n),a=0));n>=8;t[r+h]=o&255,h+=p,o/=256,n-=8);for(a=a<<n|o,c+=n;c>0;t[r+h]=a&255,h+=p,a/=256,c-=8);t[r+h-p]|=g*128}});var dm=U(Eo=>{"use strict";m();var nm=Ab(),yo=Tb(),Pb=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;Eo.Buffer=M;Eo.SlowBuffer=V$;Eo.INSPECT_MAX_BYTES=50;var $f=2147483647;Eo.kMaxLength=$f;M.TYPED_ARRAY_SUPPORT=B$();!M.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function B$(){try{let t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),t.foo()===42}catch(t){return!1}}Object.defineProperty(M.prototype,"parent",{enumerable:!0,get:function(){if(M.isBuffer(this))return this.buffer}});Object.defineProperty(M.prototype,"offset",{enumerable:!0,get:function(){if(M.isBuffer(this))return this.byteOffset}});function Gn(t){if(t>$f)throw new RangeError('The value "'+t+'" is invalid for option "size"');let e=new Uint8Array(t);return Object.setPrototypeOf(e,M.prototype),e}function M(t,e,r){if(typeof t=="number"){if(typeof e=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return lm(t)}return Ib(t,e,r)}M.poolSize=8192;function Ib(t,e,r){if(typeoLine truncated
|
||||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VB(t,e){if(t){if(typeof t=="string")return jS(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return jS(t,e)}}function jS(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function zB(t,e){if(!(typeof Symbol=="undefined"||!(Symbol.iterator in Object(t)))){var r=[],i=!0,n=!1,s=void 0;try{for(var a=t[Symbol.iterator](),o;!(i=(o=a.next()).done)&&(r.push(o.value),!(e&&r.length===e));i=!0);}catch(l){n=!0,s=l}finally{try{!i&&a.return!=null&&a.return()}finally{if(n)throw s}}return r}}function WB(t){if(Array.isArray(t))return t}var zS=/^#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?$/,WS=/^#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])?$/,qS=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/,YS=/^rgba?\(\s*(\d+)\s+(\d+)\s+(\d+)(?:\s*\/\s*(0|1|0?\.\d+|\d+%))?\s*\)$/,ZS=/^rgba?\(\s*(\d+%)\s*,\s*(\d+%)\s*,\s*(\d+%)(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/,KS=/^rgba?\(\s*(\d+%)\s+(\d+%)\s+(\d+%)(?:\s*\/\s*(0|1|0?\.\d+|\d+%))?\s*\)$/,XS=/^hsla?\(\s*(\d+)(deg|rad|grad|turn)?\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*(0|1|0?\.\d+|\d+%))?\s*\)$/;function vu(t,e){return t.indexOf(e)>-1}function qB(t,e,r){var i=t/255,n=e/255,s=r/255,a=Math.max(i,n,s),o=Math.min(i,n,s),l=a-o,c=(a+o)/2;if(l===0)return[0,0,c*100];var u=l/(1-Math.abs(2*c-1)),f=(function(){switch(a){case i:return(n-s)/l%6;case n:return(s-i)/l+2;default:return(i-n)/l+4}})();return[f*60,u*100,c*100]}function YB(t,e,r){var i=t/60,n=e/100,s=r/100,a=(1-Math.abs(2*s-1))*n,o=a*(1-Math.abs(i%2-1)),l=s-a/2,c=(function(){return i<1?[a,o,0]:i<2?[o,a,0]:i<3?[0,a,o]:i<4?[0,o,a]:i<5?[o,0,a]:[a,0,o]})(),u=_r(c,3),f=u[0],d=u[1],h=u[2];return[(f+l)*255,(d+l)*255,(h+l)*255]}var ZB=(function(){function t(e){var r=_r(e,4),i=r[0],n=r[1],s=r[2],a=r[3];UB(this,t),this.values=[Math.max(Math.min(parseInt(i,10),255),0),Math.max(Math.min(parseInt(n,10),255),0),Math.max(Math.min(parseInt(s,10),255),0),a==null?1:Math.max(Math.min(parseFloat(a),255),0)]}return GB(t,[{key:"toRgbString",value:function(){var r=_r(this.values,4),i=r[0],n=r[1],s=r[2],a=r[3];return a===1?"rgb(".concat(i,", ").concat(n,", ").concat(s,")"):"rgba(".concat(i,", ").concat(n,", ").concat(s,", ").concat(a,")")}},{key:"toHslString",value:function(){var r=this.toHslaArray(),i=_r(r,4),n=i[0],s=i[1],a=i[2],o=i[3];return o===1?"hsl(".concat(n,", ").concat(s,"%, ").concat(a,"%)"):"hsla(".concat(n,", ").concat(s,"%, ").concat(a,"%, ").concat(o,")")}},{key:"toHexString",value:function(){var r=_r(this.values,4),i=r[0],n=r[1],s=r[2],a=r[3];return i=Number(i).toString(16).padStart(2,"0"),n=Number(n).toString(16).padStart(2,"0"),s=Number(s).toString(16).padStart(2,"0"),a=a<1?parseInt(a*255,10).toString(16).padStart(2,"0"):"","#".concat(i).concat(n).concat(s).concat(a)}},{key:"toRgbaArray",value:function(){return this.values}},{key:"toHslaArray",value:function(){var r=_r(this.values,4),i=r[0],n=r[1],s=r[2],a=r[3],o=qB(i,n,s),l=_r(o,3),c=l[0],u=l[1],f=l[2];return[c,u,f,a]}}]),t})();function sl(t){var e=_r(t,4),r=e[0],i=e[1],n=e[2],s=e[3];return new ZB([r,i,n,s])}function av(t){var e=_r(t,3),r=e[0],i=e[1],n=e[2];return sl([r,i,n,1])}function Ld(t){var e=_r(t,4),r=e[0],i=e[1],n=e[2],s=e[3],a=YB(r,i,n),o=_r(a,3),l=o[0],c=o[1],u=o[2];return sl([l,c,u,s])}function QS(t){var e=_r(t,3),r=e[0],i=e[1],n=e[2];return Ld([r,i,n,1])}function KB(t){var e=zS.exec(t)||WS.exec(t),r=_r(e,5),i=r[1],n=r[2],s=r[3],a=r[4];return i=parseInt(i.length<2?i.repeat(2):i,16),n=parseInt(n.length<2?n.repeat(2):n,16),s=parseInt(s.length<2?s.repeat(2):s,16),a=a&&(parseInt(a.length<2?a.repeat(2):a,16)/255).toPrecision(1)||1,sl([i,n,s,a])}function XB(t){var e=qS.exec(t)||ZS.exec(t)||YS.exec(t)||KS.exec(t),r=_r(e,5),i=r[1],n=r[2],s=r[3],a=r[4];return i=vu(i,"%")?parseInt(i,10)*255/100:parseInt(i,10),n=vu(n,"%")?parseInt(n,10)*255/100:parseInt(n,10),s=vu(s,"%")>0?parseInt(s,10)*255/100:parseInt(s,10),a=a===void 0?1:parseFloat(a)/(vu(a,"%")?100:1),sl([i,n,s,a])}function QB(t){var e=XS.exec(t),r=_r(e,6),i=r[1],n=r[2],s=r[3],a=r[4],o=r[5];return n=n||"deg",i=(0,HB.default)(parseFloat(i),n,"deg"),s=parseFloat(s),a=parseFloat(a),o=o===void 0?1:parseFloat(o)/(vu(o,"%")?100:1),Ld([i,s,a,o])}function JS(t){return US.default[t]?av(US.default[t]):zS.test(t)||WS.test(t)?KB(t):qS.test(t)||ZS.test(t)||YS.test(t)||KS.test(t)?XB(t):XS.test(t)?QB(t):null}var JB={fromString:JS,fromRgb:av,fromRgba:sl,fromHsl:QS,fromHsla:Ld};Kn.default=JB});var dk=U((v9,fk)=>{m();fk.exports=function(t,e){var r=t,i=e,n=r.length,s=i.length,a=!1,o=n+1,l=[],c=[],u,f,d=function(){n>=s&&(u=r,f=n,r=i,i=u,n=s,s=f,a=!0,o=n+1)},h=function(g,v,b,_,C){return{startX:g,startY:v,endX:b,endY:_,r:C}},p=function(g,v,b){var _,C,x,S,A;for(v>b?_=l[g-1+o]:_=l[g+1+o],A=x=Math
Line truncated
|
||||
`});ce=!1,W=K.length}function Ie(Rt,$t){var Xe="="+G,ee=Rt.indexOf(Xe,$t),N=c(Rt.substring(Rt.indexOf("=",$t)+1,ee)).split(" ");return X=N[0],G=N[N.length-1],ee+Xe.length-1}for(y&&(y=y.split(" "),X=y[0],G=y[1]),pe=0;pe<P;pe++)H==T?u(X,E,pe)?(--pe,Be(),H=I):E.charAt(pe)==`
|
||||
`?Ut(ce):Z+=E.charAt(pe):H==I?(pe+=X.length-1,xe=t.tags[E.charAt(pe+1)],te=xe?E.charAt(pe+1):"_v",te=="="?(pe=Ie(E,pe),H=T):(xe&&pe++,H=L),ce=pe):u(G,E,pe)?(K.push({tag:te,n:c(Z),otag:X,ctag:G,i:te=="/"?ce-X.length:pe+G.length}),Z="",pe+=G.length-1,H=T,te=="{"&&(G=="}}"?pe++:l(K[K.length-1]))):Z+=E.charAt(pe);return Ut(ce,!0),K};function l(w){w.n.substr(w.n.length-1)==="}"&&(w.n=w.n.substring(0,w.n.length-1))}function c(w){return w.trim?w.trim():w.replace(/^\s*|\s*$/g,"")}function u(w,E,y){if(E.charAt(y)!=w.charAt(0))return!1;for(var P=1,T=w.length;P<T;P++)if(E.charAt(y+P)!=w.charAt(P))return!1;return!0}var f={_t:!0,"\n":!0,$:!0,"/":!0};function d(w,E,y,P){var T=[],I=null,L=null,H=null;for(L=y[y.length-1];w.length>0;){if(H=w.shift(),L&&L.tag=="<"&&!(H.tag in f))throw new Error("Illegal content in < super tag.");if(t.tags[H.tag]<=t.tags.$||h(H,P))y.push(H),H.nodes=d(w,H.tag,y,P);else if(H.tag=="/"){if(y.length===0)throw new Error("Closing tag without opener: /"+H.n);if(I=y.pop(),H.n!=I.n&&!p(H.n,I.n,P))throw new Error("Nesting error: "+I.n+" vs. "+H.n);return I.end=H.i,T}else H.tag==`
|
||||
`&&(H.last=w.length==0||w[0].tag==`
|
||||
`);T.push(H)}if(y.length>0)throw new Error("missing closing tag: "+y.pop().n);return T}function h(w,E){for(var y=0,P=E.length;y<P;y++)if(E[y].o==w.n)return w.tag="#",!0}function p(w,E,y){for(var P=0,T=y.length;P<T;P++)if(y[P].c==w&&y[P].o==E)return!0}function g(w){var E=[];for(var y in w)E.push('"'+_(y)+'": function(c,p,t,i) {'+w[y]+"}");return"{ "+E.join(",")+" }"}function v(w){var E=[];for(var y in w.partials)E.push('"'+_(y)+'":{name:"'+_(w.partials[y].name)+'", '+v(w.partials[y])+"}");return"partials: {"+E.join(",")+"}, subs: "+g(w.subs)}t.stringify=function(w,E,y){return"{code: function (c,p,i) { "+t.wrapMain(w.code)+" },"+v(w)+"}"};var b=0;t.generate=function(w,E,y){b=0;var P={code:"",subs:{},partials:{}};return t.walk(w,P),y.asString?this.stringify(P,E,y):this.makeTemplate(P,E,y)},t.wrapMain=function(w){return'var t=this;t.b(i=i||"");'+w+"return t.fl();"},t.template=t.Template,t.makeTemplate=function(w,E,y){var P=this.makePartials(w);return P.code=new Function("c","p","i",this.wrapMain(w.code)),new this.template(P,E,this,y)},t.makePartials=function(w){var E,y={subs:{},partials:w.partials,name:w.name};for(E in y.partials)y.partials[E]=this.makePartials(y.partials[E]);for(E in w.subs)y.subs[E]=new Function("c","p","t","i",w.subs[E]);return y};function _(w){return w.replace(s,"\\\\").replace(r,'\\"').replace(i,"\\n").replace(n,"\\r").replace(a,"\\u2028").replace(o,"\\u2029")}function C(w){return~w.indexOf(".")?"d":"f"}function x(w,E){var y="<"+(E.prefix||""),P=y+w.n+b++;return E.partials[P]={name:w.n,partials:{}},E.code+='t.b(t.rp("'+_(P)+'",c,p,"'+(w.indent||"")+'"));',P}t.codegen={"#":function(w,E){E.code+="if(t.s(t."+C(w.n)+'("'+_(w.n)+'",c,p,1),c,p,0,'+w.i+","+w.end+',"'+w.otag+" "+w.ctag+'")){t.rs(c,p,function(c,p,t){',t.walk(w.nodes,E),E.code+="});c.pop();}"},"^":function(w,E){E.code+="if(!t.s(t."+C(w.n)+'("'+_(w.n)+'",c,p,1),c,p,1,0,0,"")){',t.walk(w.nodes,E),E.code+="};"},">":x,"<":function(w,E){var y={partials:{},code:"",subs:{},inPartial:!0};t.walk(w.nodes,y);var P=E.partials[x(w,E)];P.subs=y.subs,P.partials=y.partials},$:function(w,E){var y={subs:{},code:"",partials:E.partials,prefix:w.n};t.walk(w.nodes,y),E.subs[w.n]=y.code,E.inPartial||(E.code+='t.sub("'+_(w.n)+'",c,p,i);')},"\n":function(w,E){E.code+=A('"\\n"'+(w.last?"":" + i"))},_v:function(w,E){E.code+="t.b(t.v(t."+C(w.n)+'("'+_(w.n)+'",c,p,0)));'},_t:function(w,E){E.code+=A('"'+_(w.text)+'"')},"{":S,"&":S};function S(w,E){E.code+="t.b(t.t(t."+C(w.n)+'("'+_(w.n)+'",c,p,0)));'}function A(w){return"t.b("+w+");"}t.walk=function(w,E){for(var y,P=0,T=w.length;P<T;P++)y=t.codegen[w[P].tag],y&&y(w[P],E);return E},t.parse=function(w,E,y){return y=y||{},d(w,"",[],y.sectionTags||[])},t.cache={},t.cacheKey=function(w,E){return[w,!!E.asString,!!E.disableLambda,E.delimiters,!!E.modelGet].join("||")},t.compile=function(w,E){E=E||{};var y=t.cacheKey(w,E),P=this.cache[y];if(P){var T=P.partials;for(var I in T)delete T[I].instance;return P}return P=this.generate(this.parse(this.scan(w,E.delimiters),w,E),w,E),this.cache[y]=P}})(typeof Vw!="undefined"?Vw:Hogan)});var Z2=U(zw=>{m();var b5={};(function(t){t.Template=function(d,h,p,g){d=d||{},this.r=d.code||this.r,this.c=p,this.options=g||{},this.text=h||"",this.partials=d.partials||{},this.subs=d.subs||{},this.buf=""},t.Template.prototype={r:function(d,h,p){return""},v:u,t:c,render:function(h,p,g){return this.ri([h],p||{},g)},ri:function(d,h,p){return this.r(d,h,p)},ep:function(d,h){var p=this.partials[d],g=h[p.name];if(p.instance&&p.base==g)return p.instance;if(typeof g=="string"){if(!this.c)throw new Error("No compiler available.");g=this.c.compile(g,this.options)}if(!g)return null;if(this.partials[d].base=g,p.subs){h.stackText||(h.stackText={});for(key in p.subs)h.stackText[key]||(h.stackText[key]=this.activeSub!==void 0&&h.stackText[this.activeSub]?h.stackText[this.activeSub]:this.text);g=r(g,p.subs,p.partials,this.stackSubs,this.stackPartials,h.stackText)}return this.partials[d].instance=g,g},rp:function(d,h,p,g){var v=this.ep(d,p);return v?v.ri(h,p,g):""},rs:function(d,h,p){var g=d[d.length-1];if(!f(g)){p(d,h,this);return}for(var v=0;v<g.length;v++)d.push(g[v]),p(d,h,this),d.pop()},s:function(d,h,p,g,v,b,_){var C;return f(d)&&d.length===0?!1:(typeof d=="function"&&(d=this.ms(d,h,p,g,v,b,_)),C=!!d,!g&&C&&h&&h.push(typeof d=="object"?d:h[h.length-1]),C)},d:function(d,h,p,g){var v,b=d.split("."),_=this.f(b[0],h,p,g),C=this.options.modelGet,x=null;if(d==="."&&f(h[h.length-2]))_=h[h.length-1];else for(var S=1;S<b.length;S++)v=e(b[S],_,C),v!==void 0?(x=_,_=v):_="";return g&&!_?!1:(!g&&typeof _=="function"&&(h.push(x),_=this.mv(_,h,p),h.pop()),_)},f:function(d,h,p,g){for(var v=!1,b=null,_=!1,C=this.options.modelGet,x=h.length-1;x>=0;x--)if(b=h[x],v=e(d,b,C),v!==void 0){_=!0;break}return _?(!g&&typeof v=="function"&&(v=this.mv(v,h,p)),v):g?!1:""},ls:function(d,h,p,g,v,b){var _=this.options.delimiters;return this.options.delimiters=b,this.b(this.ct(c(d.call(h,v,p)),h,g)),this.options.delimiters=_,!1},ct:functio
Line truncated
|
||||
|
||||
If you're using an application that depends on isomorphic-git, please report this error to that application's developers.
|
||||
|
||||
If you're a developer and you believe this is a bug in isomorphic-git, please file an issue at https://github.com/isomorphic-git/isomorphic-git/issues with a minimal reproduction, version and environment details, and this error message: ${e}`),this.code=this.name=t.code,this.data={message:e}}};he.code="InternalError";var va=class t extends Te{constructor(e){super(`The filepath "${e}" contains unsafe character sequences`),this.code=this.name=t.code,this.data={filepath:e}}};va.code="UnsafeFilepathError";var Ui=class{constructor(e){this.buffer=e,this._start=0}eof(){return this._start>=this.buffer.length}tell(){return this._start}seek(e){this._start=e}slice(e){let r=this.buffer.slice(this._start,this._start+e);return this._start+=e,r}toString(e,r){let i=this.buffer.toString(e,this._start,this._start+r);return this._start+=r,i}write(e,r,i){let n=this.buffer.write(e,this._start,r,i);return this._start+=r,n}copy(e,r,i){let n=e.copy(this.buffer,this._start,r,i);return this._start+=n,n}readUInt8(){let e=this.buffer.readUInt8(this._start);return this._start+=1,e}writeUInt8(e){let r=this.buffer.writeUInt8(e,this._start);return this._start+=1,r}readUInt16BE(){let e=this.buffer.readUInt16BE(this._start);return this._start+=2,e}writeUInt16BE(e){let r=this.buffer.writeUInt16BE(e,this._start);return this._start+=2,r}readUInt32BE(){let e=this.buffer.readUInt32BE(this._start);return this._start+=4,e}writeUInt32BE(e){let r=this.buffer.writeUInt32BE(e,this._start);return this._start+=4,r}};function Td(t,e){return-(t<e)||+(t>e)}function VE(t,e){return Td(t.path,e.path)}function zE(t){let e=t>0?t>>12:0;e!==4&&e!==8&&e!==10&&e!==14&&(e=8);let r=t&511;return r&73?r=493:r=420,e!==8&&(r=0),(e<<12)+r}var vn=2**32;function wE(t,e,r,i){if(t!==void 0&&e!==void 0)return[t,e];r===void 0&&(r=i.valueOf());let n=Math.floor(r/1e3),s=(r-n*1e3)*1e6;return[n,s]}function Wo(t){let[e,r]=wE(t.ctimeSeconds,t.ctimeNanoseconds,t.ctimeMs,t.ctime),[i,n]=wE(t.mtimeSeconds,t.mtimeNanoseconds,t.mtimeMs,t.mtime);return{ctimeSeconds:e%vn,ctimeNanoseconds:r%vn,mtimeSeconds:i%vn,mtimeNanoseconds:n%vn,dev:t.dev%vn,ino:t.ino%vn,mode:zE(t.mode%vn),uid:t.uid%vn,gid:t.gid%vn,size:t.size>-1?t.size%vn:0}}function bO(t){let e="";for(let r of new Uint8Array(t))r<16&&(e+="0"),e+=r.toString(16);return e}var Sg=null;async function bn(t){return Sg===null&&(Sg=await yO()),Sg?WE(t):_O(t)}function _O(t){return new Yg.default().update(t).digest("hex")}async function WE(t){let e=await crypto.subtle.digest("SHA-1",t);return bO(e)}async function yO(){try{return await WE(new Uint8Array([]))==="da39a3ee5e6b4b0d3255bfef95601890afd80709"}catch(t){}return!1}function xO(t){return{assumeValid:!!(t&32768),extended:!!(t&16384),stage:(t&12288)>>12,nameLength:t&4095}}function EO(t){let e=t.flags;return e.extended=!1,e.nameLength=Math.min(k.from(t.path).length,4095),(e.assumeValid?32768:0)+(e.extended?16384:0)+((e.stage&3)<<12)+(e.nameLength&4095)}var Og=class t{constructor(e,r){this._dirty=!1,this._unmergedPaths=r||new Set,this._entries=e||new Map}_addEntry(e){if(e.flags.stage===0)e.stages=[e],this._entries.set(e.path,e),this._unmergedPaths.delete(e.path);else{let r=this._entries.get(e.path);r||(this._entries.set(e.path,e),r=e),r.stages[e.flags.stage]=e,this._unmergedPaths.add(e.path)}}static async from(e){if(k.isBuffer(e))return t.fromBuffer(e);if(e===null)return new t(null);throw new he("invalid type passed to GitIndex.from")}static async fromBuffer(e){if(e.length===0)throw new he("Index file is empty (.git/index)");let r=new t,i=new Ui(e),n=i.toString("utf8",4);if(n!=="DIRC")throw new he(`Invalid dircache magic file number: ${n}`);let s=await bn(e.slice(0,-20)),a=e.slice(-20).toString("hex");if(a!==s)throw new he(`Invalid checksum in GitIndex buffer: expected ${a} but saw ${s}`);let o=i.readUInt32BE();if(o!==2)throw new he(`Unsupported dircache version: ${o}`);let l=i.readUInt32BE(),c=0;for(;!i.eof()&&c<l;){let u={};u.ctimeSeconds=i.readUInt32BE(),u.ctimeNanoseconds=i.readUInt32BE(),u.mtimeSeconds=i.readUInt32BE(),u.mtimeNanoseconds=i.readUInt32BE(),u.dev=i.readUInt32BE(),u.ino=i.readUInt32BE(),u.mode=i.readUInt32BE(),u.uid=i.readUInt32BE(),u.gid=i.readUInt32BE(),u.size=i.readUInt32BE(),u.oid=i.slice(20).toString("hex");let f=i.readUInt16BE();u.flags=xO(f);let d=e.indexOf(0,i.tell()+1)-i.tell();if(d<1)throw new he(`Got a path length of: ${d}`);if(u.path=i.toString("utf8",d),u.path.includes("..\\")||u.path.includes("../"))throw new va(u.path);let h=8-(i.tell()-12)%8;for(h===0&&(h=8);h--;){let p=i.readUInt8();if(p!==0)throw new he(`Expected 1-8 null characters but got '${p}' after ${u.path}`);if(i.eof())throw new he("Unexpected end of file")}u.stages=[],r._addEntry(u),c++}return r}get unmergedPaths(){return[...this._unmergedPaths]}get entries(){return[...this._entries.values()].sort(VE)}get entriesMap(){return this._entries}get entriesFlat(){return[...this.entries].flatMap(e=>e.stages.length>1?e.stages.filter(r=>r):e)}*[Symbol.iterator](){for(let e of this.entries)yield e}insert({filepath
Line truncated
|
||||
`)}static async _entryToBuffer(e){let r=k.from(e.path),i=Math.ceil((62+r.length+1)/8)*8,n=k.alloc(i),s=new Ui(n),a=Wo(e);return s.writeUInt32BE(a.ctimeSeconds),s.writeUInt32BE(a.ctimeNanoseconds),s.writeUInt32BE(a.mtimeSeconds),s.writeUInt32BE(a.mtimeNanoseconds),s.writeUInt32BE(a.dev),s.writeUInt32BE(a.ino),s.writeUInt32BE(a.mode),s.writeUInt32BE(a.uid),s.writeUInt32BE(a.gid),s.writeUInt32BE(a.size),s.write(e.oid,20,"hex"),s.writeUInt16BE(EO(e)),s.write(e.path,r.length,"utf8"),n}async toObject(){let e=k.alloc(12),r=new Ui(e);r.write("DIRC",4,"utf8"),r.writeUInt32BE(2),r.writeUInt32BE(this.entriesFlat.length);let i=[];for(let o of this.entries)if(i.push(t._entryToBuffer(o)),o.stages.length>1)for(let l of o.stages)l&&l!==o&&i.push(t._entryToBuffer(l));i=await Promise.all(i);let n=k.concat(i),s=k.concat([e,n]),a=await bn(s);return k.concat([s,k.from(a,"hex")])}};function gd(t,e,r=!0,i=!0){let n=Wo(t),s=Wo(e);return r&&n.mode!==s.mode||n.mtimeSeconds!==s.mtimeSeconds||n.ctimeSeconds!==s.ctimeSeconds||n.uid!==s.uid||n.gid!==s.gid||i&&n.ino!==s.ino||n.size!==s.size}var kg=null,Cg=Symbol("IndexCache");function SO(){return{map:new Map,stats:new Map}}async function kO(t,e,r){let[i,n]=await Promise.all([t.lstat(e),t.read(e)]),s=await Og.from(n);r.map.set(e,s),r.stats.set(e,i)}async function CO(t,e,r){let i=r.stats.get(e);if(i===void 0)return!0;if(i===null)return!1;let n=await t.lstat(e);return n===null?!1:gd(i,n)}var dt=class{static async acquire({fs:e,gitdir:r,cache:i,allowUnmerged:n=!0},s){i[Cg]||(i[Cg]=SO());let a=`${r}/index`;kg===null&&(kg=new Vo.default({maxPending:1/0}));let o,l=[];return await kg.acquire(a,async()=>{let c=i[Cg];await CO(e,a,c)&&await kO(e,a,c);let u=c.map.get(a);if(l=u.unmergedPaths,l.length&&!n)throw new Uc(l);if(o=await s(u),u._dirty){let f=await u.toObject();await e.write(a,f),c.stats.set(a,await e.lstat(a)),u._dirty=!1}}),o}};function vd(t){let e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e>-1&&(t=t.slice(e+1)),t}function wa(t){let e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return e===-1?".":e===0?"/":t.slice(0,e)}function qE(t){let e=new Map,r=function(n){if(!e.has(n)){let s={type:"tree",fullpath:n,basename:vd(n),metadata:{},children:[]};e.set(n,s),s.parent=r(wa(n)),s.parent&&s.parent!==s&&s.parent.children.push(s)}return e.get(n)},i=function(n,s){if(!e.has(n)){let a={type:"blob",fullpath:n,basename:vd(n),metadata:s,parent:r(wa(n)),children:[]};a.parent&&a.parent.children.push(a),e.set(n,a)}return e.get(n)};r(".");for(let n of t)i(n.path,n);return e}function AO(t){switch(t){case 16384:return"tree";case 33188:return"blob";case 33261:return"blob";case 40960:return"blob";case 57344:return"commit"}throw new he(`Unexpected GitTree entry mode: ${t.toString(8)}`)}var Lg=class{constructor({fs:e,gitdir:r,cache:i}){this.treePromise=dt.acquire({fs:e,gitdir:r,cache:i},async function(s){return qE(s.entries)});let n=this;this.ConstructEntry=class{constructor(a){this._fullpath=a,this._type=!1,this._mode=!1,this._stat=!1,this._oid=!1}async type(){return n.type(this)}async mode(){return n.mode(this)}async stat(){return n.stat(this)}async content(){return n.content(this)}async oid(){return n.oid(this)}}}async readdir(e){let r=e._fullpath,n=(await this.treePromise).get(r);if(!n||n.type==="blob")return null;if(n.type!=="tree")throw new Error(`ENOTDIR: not a directory, scandir '${r}'`);let s=n.children.map(a=>a.fullpath);return s.sort(Td),s}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let i=(await this.treePromise).get(e._fullpath);if(!i)throw new Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let n=i.type==="tree"?{}:Wo(i.metadata);e._type=i.type==="tree"?"tree":AO(n.mode),e._mode=n.mode,i.type==="tree"?e._stat=void 0:e._stat=n}return e._stat}async content(e){}async oid(e){if(e._oid===!1){let i=(await this.treePromise).get(e._fullpath);e._oid=i.metadata.oid}return e._oid}},Pd=Symbol("GitWalkSymbol");function tl(){let t=Object.create(null);return Object.defineProperty(t,Pd,{value:function({fs:e,gitdir:r,cache:i}){return new Lg({fs:e,gitdir:r,cache:i})}}),Object.freeze(t),t}var Ve=class t extends Te{constructor(e){super(`Could not find ${e}.`),this.code=this.name=t.code,this.data={what:e}}};Ve.code="NotFoundError";var br=class t extends Te{constructor(e,r,i,n){super(`Object ${e} ${n?`at ${n}`:""}was anticipated to be a ${i} but it is a ${r}.`),this.code=this.name=t.code,this.data={oid:e,actual:r,expected:i,filepath:n}}};br.code="ObjectTypeError";var Rs=class t extends Te{constructor(e){super(`Expected a 40-char hex object id but saw "${e}".`),this.code=this.name=t.code,this.data={value:e}}};Rs.code="InvalidOidError";var Gc=class t extends Te{constructor(e){super(`Could not find a fetch refspec for remote "${e}". Make sure the config file has an entry like the following:
|
||||
[remote "${e}"]
|
||||
fetch = +refs/heads/*:refs/remotes/origin/*
|
||||
`),this.code=this.name=t.code,this.data={remote:e}}};Gc.code="NoRefspecError";var wd=class t{constructor(e){if(this.refs=new Map,this.parsedConfig=[],e){let r=null;this.parsedConfig=e.trim().split(`
|
||||
`).map(i=>{if(/^\s*#/.test(i))return{line:i,comment:!0};let n=i.indexOf(" ");if(i.startsWith("^")){let s=i.slice(1);return this.refs.set(r+"^{}",s),{line:i,ref:r,peeled:s}}else{let s=i.slice(0,n);return r=i.slice(n+1),this.refs.set(r,s),{line:i,ref:r,oid:s}}})}return this}static from(e){return new t(e)}delete(e){this.parsedConfig=this.parsedConfig.filter(r=>r.ref!==e),this.refs.delete(e)}toString(){return this.parsedConfig.map(({line:e})=>e).join(`
|
||||
`)+`
|
||||
`}},bd=class t{constructor({remotePath:e,localPath:r,force:i,matchPrefix:n}){Object.assign(this,{remotePath:e,localPath:r,force:i,matchPrefix:n})}static from(e){let[r,i,n,s,a]=e.match(/^(\+?)(.*?)(\*?):(.*?)(\*?)$/).slice(1),o=r==="+",l=n==="*";if(l!==(a==="*"))throw new he("Invalid refspec");return new t({remotePath:i,localPath:s,force:o,matchPrefix:l})}translate(e){if(this.matchPrefix){if(e.startsWith(this.remotePath))return this.localPath+e.replace(this.remotePath,"")}else if(e===this.remotePath)return this.localPath;return null}reverseTranslate(e){if(this.matchPrefix){if(e.startsWith(this.localPath))return this.remotePath+e.replace(this.localPath,"")}else if(e===this.localPath)return this.remotePath;return null}},Ng=class t{constructor(e=[]){this.rules=e}static from(e){let r=[];for(let i of e)r.push(bd.from(i));return new t(r)}add(e){let r=bd.from(e);this.rules.push(r)}translate(e){let r=[];for(let i of this.rules)for(let n of e){let s=i.translate(n);s&&r.push([n,s])}return r}translateOne(e){let r=null;for(let i of this.rules){let n=i.translate(e);n&&(r=n)}return r}localNamespaces(){return this.rules.filter(e=>e.matchPrefix).map(e=>e.localPath.replace(/\/$/,""))}};function TO(t,e){let r=t.replace(/\^\{\}$/,""),i=e.replace(/\^\{\}$/,""),n=-(r<i)||+(r>i);return n===0?t.endsWith("^{}")?1:-1:n}function PO(t,e){let r="",i=0,n=-1,s=0,a="\0";for(let o=0;o<=t.length;++o){if(o<t.length)a=t[o];else{if(a==="/")break;a="/"}if(a==="/"){if(!(n===o-1||s===1))if(s===2){if(r.length<2||i!==2||r.at(-1)!=="."||r.at(-2)!=="."){if(r.length>2){let l=r.lastIndexOf("/");l===-1?(r="",i=0):(r=r.slice(0,l),i=r.length-1-r.lastIndexOf("/")),n=o,s=0;continue}else if(r.length!==0){r="",i=0,n=o,s=0;continue}}e&&(r+=r.length>0?"/..":"..",i=2)}else r.length>0?r+="/"+t.slice(n+1,o):r=t.slice(n+1,o),i=o-n-1;n=o,s=0}else a==="."&&s!==-1?++s:s=-1}return r}function RO(t){return t.length>=2&&/^[a-zA-Z]:/.test(t)?t.slice(0,2):null}function $O(t){if(!t.length)return".";t=t.replace(/\\/g,"/");let e=RO(t),r=t[0]==="/"||e!==null&&t[2]==="/",i=t.at(-1)==="/",n=e?t.slice(2):t,s=PO(n,!r);if(!s.length){let a=e?r?e+"/":e:r?"/":".";return i&&!r?a+"/":a}return i&&(s+="/"),e?r?`${e}/${s}`:`${e}${s}`:r?`/${s}`:s}function B(...t){if(t.length===0)return".";let e;for(let r=0;r<t.length;++r){let i=t[r].replace(/\\/g,"/");i.length!==0&&(/^[a-zA-Z]:\//.test(i)||e===void 0?e=i:e+="/"+i)}return e===void 0?".":$O(e)}var FO=t=>{if(typeof t=="number")return t;t=t.toLowerCase();let e=parseInt(t);return t.endsWith("k")&&(e*=1024),t.endsWith("m")&&(e*=1024*1024),t.endsWith("g")&&(e*=1024*1024*1024),e},Bc=t=>{if(typeof t=="boolean")return t;if(t=t.trim().toLowerCase(),t==="true"||t==="yes"||t==="on")return!0;if(t==="false"||t==="no"||t==="off")return!1;throw Error(`Expected 'true', 'false', 'yes', 'no', 'on', or 'off', but got ${t}`)},bE={core:{filemode:Bc,bare:Bc,logallrefupdates:Bc,symlinks:Bc,ignorecase:Bc,bigFileThreshold:FO}},IO=/^\[([A-Za-z0-9-.]+)(?: "(.*)")?\]$/,MO=/^[A-Za-z0-9-.]+$/,DO=/^([A-Za-z][A-Za-z-]*)(?: *= *(.*))?$/,OO=/^[A-Za-z][A-Za-z-]*$/,LO=/^(.*?)( *[#;].*)$/,NO=t=>{let e=IO.exec(t);if(e!=null){let[r,i]=e.slice(1);return[r,i]}return null},BO=t=>{let e=DO.exec(t);if(e!=null){let[r,i="true"]=e.slice(1),n=HO(i),s=UO(n);return[r,s]}return null},HO=t=>{let e=LO.exec(t);if(e==null)return t;let[r,i]=e.slice(1);return _E(r)&&_E(i)?`${r}${i}`:r},_E=t=>(t.match(/(?:^|[^\\])"/g)||[]).length%2!==0,UO=t=>t.split("").reduce((e,r,i,n)=>{let s=r==='"'&&n[i-1]!=="\\",a=r==="\\"&&n[i+1]==='"';return s||a?e:e+r},""),yE=t=>t!=null?t.toLowerCase():null,Bg=(t,e,r)=>[yE(t),e,yE(r)].filter(i=>i!=null).join("."),xE=t=>{let e=t.split("."),r=e.shift(),i=e.pop(),n=e.length?e.join("."):void 0;return{section:r,subsection:n,name:i,path:Bg(r,n,i),sectionPath:Bg(r,n,null),isSection:!!r}},GO=(t,e)=>t.reduce((r,i,n)=>e(i)?n:r,-1),Hg=class t{constructor(e){let r=null,i=null;this.parsedConfig=e?e.split(`
|
||||
`).map(n=>{let s=null,a=null,o=n.trim(),l=NO(o),c=l!=null;if(c)[r,i]=l;else{let f=BO(o);f!=null&&([s,a]=f)}let u=Bg(r,i,s);return{line:n,isSection:c,section:r,subsection:i,name:s,value:a,path:u}}):[]}static from(e){return new t(e)}async get(e,r=!1){let i=xE(e).path,n=this.parsedConfig.filter(s=>s.path===i).map(({section:s,name:a,value:o})=>{let l=bE[s]&&bE[s][a];return l?l(o):o});return r?n:n.pop()}async getall(e){return this.get(e,!0)}async getSubsections(e){return this.parsedConfig.filter(r=>r.isSection&&r.section===e).map(r=>r.subsection)}async deleteSection(e,r){this.parsedConfig=this.parsedConfig.filter(i=>!(i.section===e&&i.subsection===r))}async append(e,r){return this.set(e,r,!0)}async set(e,r,i=!1){let{section:n,subsection:s,name:a,path:o,sectionPath:l,isSection:c}=xE(e),u=GO(this.parsedConfig,f=>f.path===o);if(r==null)u!==-1&&this.parsedConfig.splice(u,1);else if(u!==-1){let f=this.parsedConfig[u],d=Object.assign({},f,{name:a,value:r,modified:!0});i?this.parsedConfig.splice(u+1,0,d):this.parsedConfig[u]=d}else{let f=this.parsedConfig.findIndex(h=>h.path===l),d={section:n,subsection:s,name:a,value:r,modified:!0,path:o};if(MO.test(n)&&OO.test(a))if(f>=0)this.parsedConfig.splice(f+1,0,d);else{let h={isSection:c,section:n,subsection:s,modified:!0,path:l};this.parsedConfig.push(h,d)}}}toString(){return this.parsedConfig.map(({line:e,section:r,subsection:i,name:n,value:s,modified:a=!1})=>a?n!=null&&s!=null?typeof s=="string"&&/[#;]/.test(s)?` ${n} = "${s}"`:` ${n} = ${s}`:i!=null?`[${r} "${i}"]`:`[${r}]`:e).join(`
|
||||
`)}},ht=class{static async get({fs:e,gitdir:r}){let i=await e.read(`${r}/config`,{encoding:"utf8"});return Hg.from(i)}static async save({fs:e,gitdir:r,config:i}){await e.write(`${r}/config`,i.toString(),{encoding:"utf8"})}},pd=t=>[`${t}`,`refs/${t}`,`refs/tags/${t}`,`refs/heads/${t}`,`refs/remotes/${t}`,`refs/remotes/${t}/HEAD`],jO=["config","description","index","shallow","commondir"],Ag;async function Ts(t,e){return Ag===void 0&&(Ag=new Vo.default),Ag.acquire(t,e)}var q=class t{static async updateRemoteRefs({fs:e,gitdir:r,remote:i,refs:n,symrefs:s,tags:a,refspecs:o=void 0,prune:l=!1,pruneTags:c=!1}){for(let v of n.values())if(!v.match(/[0-9a-f]{40}/))throw new Rs(v);let u=await ht.get({fs:e,gitdir:r});if(!o){if(o=await u.getall(`remote.${i}.fetch`),o.length===0)throw new Gc(i);o.unshift(`+HEAD:refs/remotes/${i}/HEAD`)}let f=Ng.from(o),d=new Map;if(c){let v=await t.listRefs({fs:e,gitdir:r,filepath:"refs/tags"});await t.deleteRefs({fs:e,gitdir:r,refs:v.map(b=>`refs/tags/${b}`)})}if(a){for(let v of n.keys())if(v.startsWith("refs/tags")&&!v.endsWith("^{}")&&!await t.exists({fs:e,gitdir:r,ref:v})){let b=n.get(v);d.set(v,b)}}let h=f.translate([...n.keys()]);for(let[v,b]of h){let _=n.get(v);d.set(b,_)}let p=f.translate([...s.keys()]);for(let[v,b]of p){let _=s.get(v),C=f.translateOne(_);C&&d.set(b,`ref: ${C}`)}let g=[];if(l){for(let v of f.localNamespaces()){let b=(await t.listRefs({fs:e,gitdir:r,filepath:v})).map(_=>`${v}/${_}`);for(let _ of b)d.has(_)||g.push(_)}g.length>0&&await t.deleteRefs({fs:e,gitdir:r,refs:g})}for(let[v,b]of d)await Ts(v,async()=>e.write(B(r,v),`${b.trim()}
|
||||
`,"utf8"));return{pruned:g}}static async writeRef({fs:e,gitdir:r,ref:i,value:n}){if(!n.match(/[0-9a-f]{40}/))throw new Rs(n);await Ts(i,async()=>e.write(B(r,i),`${n.trim()}
|
||||
`,"utf8"))}static async writeSymbolicRef({fs:e,gitdir:r,ref:i,value:n}){await Ts(i,async()=>e.write(B(r,i),`ref: ${n.trim()}
|
||||
`,"utf8"))}static async deleteRef({fs:e,gitdir:r,ref:i}){return t.deleteRefs({fs:e,gitdir:r,refs:[i]})}static async deleteRefs({fs:e,gitdir:r,refs:i}){await Promise.all(i.map(o=>e.rm(B(r,o))));let n=await Ts("packed-refs",async()=>e.read(`${r}/packed-refs`,{encoding:"utf8"})),s=wd.from(n),a=s.refs.size;for(let o of i)s.refs.has(o)&&s.delete(o);s.refs.size<a&&(n=s.toString(),await Ts("packed-refs",async()=>e.write(`${r}/packed-refs`,n,{encoding:"utf8"})))}static async resolve({fs:e,gitdir:r,ref:i,depth:n=void 0,visited:s=new Set}){if(n!==void 0&&(n--,n===-1))return i;if(i.startsWith("ref: "))return i=i.slice(5),t.resolve({fs:e,gitdir:r,ref:i,depth:n,visited:s});if(i.length===40&&/[0-9a-f]{40}/.test(i))return i;let a=await t.packedRefs({fs:e,gitdir:r}),o=pd(i).filter(l=>!jO.includes(l));for(let l of o){let c=await Ts(l,async()=>await e.read(`${r}/${l}`,{encoding:"utf8"})||a.get(l));if(c){if(s.has(l))throw new he(`Circular reference detected while resolving ref "${l}"`);return s.add(l),t.resolve({fs:e,gitdir:r,ref:c.trim(),depth:n,visited:s})}}throw new Ve(i)}static async exists({fs:e,gitdir:r,ref:i}){try{return await t.expand({fs:e,gitdir:r,ref:i}),!0}catch(n){return!1}}static async expand({fs:e,gitdir:r,ref:i}){if(i.length===40&&/[0-9a-f]{40}/.test(i))return i;let n=await t.packedRefs({fs:e,gitdir:r}),s=pd(i);for(let a of s)if(await Ts(a,async()=>e.exists(`${r}/${a}`))||n.has(a))return a;throw new Ve(i)}static async expandAgainstMap({ref:e,map:r}){let i=pd(e);for(let n of i)if(await r.has(n))return n;throw new Ve(e)}static resolveAgainstMap({ref:e,fullref:r=e,depth:i=void 0,map:n}){if(i!==void 0&&(i--,i===-1))return{fullref:r,oid:e};if(e.startsWith("ref: "))return e=e.slice(5),t.resolveAgainstMap({ref:e,fullref:r,depth:i,map:n});if(e.length===40&&/[0-9a-f]{40}/.test(e))return{fullref:r,oid:e};let s=pd(e);for(let a of s){let o=n.get(a);if(o)return t.resolveAgainstMap({ref:o.trim(),fullref:a,depth:i,map:n})}throw new Ve(e)}static async packedRefs({fs:e,gitdir:r}){let i=await Ts("packed-refs",async()=>e.read(`${r}/packed-refs`,{encoding:"utf8"}));return wd.from(i).refs}static async listRefs({fs:e,gitdir:r,filepath:i}){let n=t.packedRefs({fs:e,gitdir:r}),s=null;try{s=await e.readdirDeep(`${r}/${i}`),s=s.map(a=>a.replace(`${r}/${i}/`,""))}catch(a){s=[]}for(let a of(await n).keys())a.startsWith(i)&&(a=a.replace(i+"/",""),s.includes(a)||s.push(a));return s.sort(TO),s}static async listBranches({fs:e,gitdir:r,remote:i}){return i?t.listRefs({fs:e,gitdir:r,filepath:`refs/remotes/${i}`}):t.listRefs({fs:e,gitdir:r,filepath:"refs/heads"})}static async listTags({fs:e,gitdir:r}){return(await t.listRefs({fs:e,gitdir:r,filepath:"refs/tags"})).filter(n=>!n.endsWith("^{}"))}};function VO(t,e){return Td(EE(t),EE(e))}function EE(t){return t.mode==="040000"?t.path+"/":t.path}function YE(t){switch(t){case"040000":return"tree";case"100644":return"blob";case"100755":return"blob";case"120000":return"blob";case"160000":return"commit"}throw new he(`Unexpected GitTree entry mode: ${t}`)}function zO(t){let e=[],r=0;for(;r<t.length;){let i=t.indexOf(32,r);if(i===-1)throw new he(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next space character.`);let n=t.indexOf(0,r);if(n===-1)throw new he(`GitTree: Error parsing buffer at byte location ${r}: Could not find the next null character.`);let s=t.slice(r,i).toString("utf8");s==="40000"&&(s="040000");let a=YE(s),o=t.slice(i+1,n).toString("utf8"),l=o.replace(/[\u200C-\u200F\u202A-\u202E\u206A-\u206F\uFEFF]/g,""),u=l.split(":")[0].toLowerCase().replace(/[. ]+$/,"");if(o.includes("\\")||o.includes("/")||l==="."||l===".."||u===".git"||/^\.?git~[1-9]$/.test(u))throw new va(o);let f=t.slice(n+1,n+21).toString("hex");r=n+21,e.push({mode:s,path:o,oid:f,type:a})}return e}function WO(t){if(typeof t=="number"&&(t=t.toString(8)),t.match(/^0?4.*/))return"040000";if(t.match(/^1006.*/))return"100644";if(t.match(/^1007.*/))return"100755";if(t.match(/^120.*/))return"120000";if(t.match(/^160.*/))return"160000";throw new he(`Could not understand file mode: ${t}`)}function qO(t){return!t.oid&&t.sha&&(t.oid=t.sha),t.mode=WO(t.mode),t.type||(t.type=YE(t.mode)),t}var Mr=class t{constructor(e){if(k.isBuffer(e))this._entries=zO(e);else if(Array.isArray(e))this._entries=e.map(qO);else throw new he("invalid type passed to GitTree constructor");this._entries.sort(VE)}static from(e){return new t(e)}render(){return this._entries.map(e=>`${e.mode} ${e.type} ${e.oid} ${e.path}`).join(`
|
||||
`)}toObject(){let e=[...this._entries];return e.sort(VO),k.concat(e.map(r=>{let i=k.from(r.mode.replace(/^0/,"")),n=k.from(" "),s=k.from(r.path,"utf8"),a=k.from([0]),o=k.from(r.oid,"hex");return k.concat([i,n,s,a,o])}))}entries(){return this._entries}*[Symbol.iterator](){for(let e of this._entries)yield e}},$s=class{static wrap({type:e,object:r}){let i=`${e} ${r.length}\0`,n=i.length,s=n+r.length,a=new Uint8Array(s);for(let o=0;o<n;o++)a[o]=i.charCodeAt(o);return a.set(r,n),a}static unwrap(e){let r=e.indexOf(32),i=e.indexOf(0),n=e.slice(0,r).toString("utf8"),s=e.slice(r+1,i).toString("utf8"),a=e.length-(i+1);if(parseInt(s)!==a)throw new he(`Length mismatch: expected ${s} bytes but got ${a} instead.`);return{type:n,object:k.from(e.slice(i+1))}}};async function ZE({fs:t,gitdir:e,oid:r}){let i=`objects/${r.slice(0,2)}/${r.slice(2)}`,n=await t.read(`${e}/${i}`);return n?{object:n,format:"deflated",source:i}:null}function YO(t,e){let r=new Ui(t),i=SE(r);if(i!==e.byteLength)throw new he(`applyDelta expected source buffer to be ${i} bytes but the provided buffer was ${e.length} bytes`);let n=SE(r),s,a=CE(r,e);if(a.byteLength===n)s=a;else{let o=[a],l=a.byteLength;for(;!r.eof();){let c=CE(r,e);o.push(c),l+=c.byteLength}if(n!==l)throw new he(`applyDelta expected target buffer to be ${n} bytes but the resulting buffer was ${l} bytes`);s=k.concat(o,n)}return s}function SE(t){let e=0,r=0,i=null;do i=t.readUInt8(),e|=(i&127)<<r,r+=7;while(i&128);return e}function kE(t,e,r){let i=0,n=0;for(;r--;)e&1&&(i|=t.readUInt8()<<n),e>>=1,n+=8;return i}function CE(t,e){let r=t.readUInt8(),i=128,n=15,s=112;if(r&i){let a=kE(t,r&n,4),o=kE(t,(r&s)>>4,3);return o===0&&(o=65536),e.slice(a,a+o)}else return t.slice(r)}function ZO(t){let e=[t];return{next(){return Promise.resolve({done:e.length===0,value:e.pop()})},return(){return e=[],{}},[Symbol.asyncIterator](){return this}}}function KE(t){return t[Symbol.asyncIterator]?t[Symbol.asyncIterator]():t[Symbol.iterator]?t[Symbol.iterator]():t.next?t:ZO(t)}var _d=class{constructor(e){if(typeof k=="undefined")throw new Error("Missing Buffer dependency");this.stream=KE(e),this.buffer=null,this.cursor=0,this.undoCursor=0,this.started=!1,this._ended=!1,this._discardedBytes=0}eof(){return this._ended&&this.cursor===this.buffer.length}tell(){return this._discardedBytes+this.cursor}async byte(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(1),this.buffer[this.undoCursor]}async chunk(){if(!this.eof()&&(this.started||await this._init(),!(this.cursor===this.buffer.length&&(await this._loadnext(),this._ended))))return this._moveCursor(this.buffer.length),this.buffer.slice(this.undoCursor,this.cursor)}async read(e){if(!this.eof())return this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e),this.buffer.slice(this.undoCursor,this.cursor)}async skip(e){this.eof()||(this.started||await this._init(),this.cursor+e>this.buffer.length&&(this._trim(),await this._accumulate(e)),this._moveCursor(e))}async undo(){this.cursor=this.undoCursor}async _next(){this.started=!0;let{done:e,value:r}=await this.stream.next();return e&&(this._ended=!0,!r)?k.alloc(0):(r&&(r=k.from(r)),r)}_trim(){this.buffer=this.buffer.slice(this.undoCursor),this.cursor-=this.undoCursor,this._discardedBytes+=this.undoCursor,this.undoCursor=0}_moveCursor(e){this.undoCursor=this.cursor,this.cursor+=e,this.cursor>this.buffer.length&&(this.cursor=this.buffer.length)}async _accumulate(e){if(this._ended)return;let r=[this.buffer];for(;this.cursor+e>KO(r);){let i=await this._next();if(this._ended)break;r.push(i)}this.buffer=k.concat(r)}async _loadnext(){this._discardedBytes+=this.buffer.length,this.undoCursor=0,this.cursor=0,this.buffer=await this._next()}async _init(){this.buffer=await this._next()}};function KO(t){return t.reduce((e,r)=>e+r.length,0)}async function XO(t,e){let r=new _d(t),i=await r.read(4);if(i=i.toString("utf8"),i!=="PACK")throw new he(`Invalid PACK header '${i}'`);let n=await r.read(4);if(n=n.readUInt32BE(0),n!==2)throw new he(`Invalid packfile version: ${n}`);let s=await r.read(4);if(s=s.readUInt32BE(0),!(s<1))for(;!r.eof()&&s--;){let a=r.tell(),{type:o,length:l,ofs:c,reference:u}=await QO(r),f=new Ad.default.Inflate;for(;!f.result;){let d=await r.chunk();if(!d)break;if(f.push(d,!1),f.err)throw new he(`Pako error: ${f.msg}`);if(f.result){if(f.result.length!==l)throw new he("Inflated object size is different from that stated in packfile.");await r.undo(),await r.read(d.length-f.strm.avail_in);let h=r.tell();await e({data:f.result,type:o,num:s,offset:a,end:h,reference:u,ofs:c})}}}}async function QO(t){let e=await t.byte(),r=e>>4&7,i=e&15;if(e&128){let a=4;do e=await t.byte(),i|=(e&127)<<a,a+=7;while(e&128)}let n,s;if(r===6){let a=0;n=0;let o=[];do e=await t.byte(),n|=(e&127)<<a,a+=7,o.push(e);while(e&128);s=k.from(o)}return r===7&&(s=await t.read(20)),{type:r,l
Line truncated
|
||||
`,t}function yd(t){let[,e,r,i,n]=t.match(/^(.*) <(.*)> (.*) (.*)$/);return{name:e,email:r,timestamp:Number(i),timezoneOffset:cL(n)}}function cL(t){let[,e,r,i]=t.match(/(\+|-)(\d\d)(\d\d)/);return i=(e==="+"?1:-1)*(Number(r)*60+Number(i)),uL(i)}function uL(t){return t===0?t:-t}var Jr=class t{constructor(e){if(typeof e=="string")this._tag=e;else if(k.isBuffer(e))this._tag=e.toString("utf8");else if(typeof e=="object")this._tag=t.render(e);else throw new he("invalid type passed to GitAnnotatedTag constructor")}static from(e){return new t(e)}static render(e){return`object ${e.object}
|
||||
type ${e.type}
|
||||
tag ${e.tag}
|
||||
tagger ${Ug(e.tagger)}
|
||||
|
||||
${e.message}
|
||||
${e.gpgsig?e.gpgsig:""}`}justHeaders(){return this._tag.slice(0,this._tag.indexOf(`
|
||||
|
||||
`))}message(){let e=this.withoutSignature();return e.slice(e.indexOf(`
|
||||
|
||||
`)+2)}parse(){return Object.assign(this.headers(),{message:this.message(),gpgsig:this.gpgsig()})}render(){return this._tag}headers(){let e=this.justHeaders().split(`
|
||||
`),r=[];for(let n of e)n[0]===" "?r[r.length-1]+=`
|
||||
`+n.slice(1):r.push(n);let i={};for(let n of r){let s=n.slice(0,n.indexOf(" ")),a=n.slice(n.indexOf(" ")+1);Array.isArray(i[s])?i[s].push(a):i[s]=a}return i.tagger&&(i.tagger=yd(i.tagger)),i.committer&&(i.committer=yd(i.committer)),i}withoutSignature(){let e=Yn(this._tag);return e.indexOf(`
|
||||
-----BEGIN PGP SIGNATURE-----`)===-1?e:e.slice(0,e.lastIndexOf(`
|
||||
-----BEGIN PGP SIGNATURE-----`))}gpgsig(){if(this._tag.indexOf(`
|
||||
-----BEGIN PGP SIGNATURE-----`)===-1)return;let e=this._tag.slice(this._tag.indexOf("-----BEGIN PGP SIGNATURE-----"),this._tag.indexOf("-----END PGP SIGNATURE-----")+27);return Yn(e)}payload(){return this.withoutSignature()+`
|
||||
`}toObject(){return k.from(this._tag,"utf8")}static async sign(e,r,i){let n=e.payload(),{signature:s}=await r({payload:n,secretKey:i});s=Yn(s);let a=n+s;return t.from(a)}};function Pg(t){return t.trim().split(`
|
||||
`).map(e=>" "+e).join(`
|
||||
`)+`
|
||||
`}function fL(t){return t.split(`
|
||||
`).map(e=>e.replace(/^ /,"")).join(`
|
||||
`)}var Dr=class t{constructor(e){if(typeof e=="string")this._commit=e;else if(k.isBuffer(e))this._commit=e.toString("utf8");else if(typeof e=="object")this._commit=t.render(e);else throw new he("invalid type passed to GitCommit constructor")}static fromPayloadSignature({payload:e,signature:r}){let i=t.justHeaders(e),n=t.justMessage(e),s=Yn(i+`
|
||||
gpgsig`+Pg(r)+`
|
||||
`+n);return new t(s)}static from(e){return new t(e)}toObject(){return k.from(this._commit,"utf8")}headers(){return this.parseHeaders()}message(){return t.justMessage(this._commit)}parse(){return Object.assign({message:this.message()},this.headers())}static justMessage(e){return Yn(e.slice(e.indexOf(`
|
||||
|
||||
`)+2))}static justHeaders(e){return e.slice(0,e.indexOf(`
|
||||
|
||||
`))}parseHeaders(){let e=t.justHeaders(this._commit).split(`
|
||||
`),r=[];for(let n of e)n[0]===" "?r[r.length-1]+=`
|
||||
`+n.slice(1):r.push(n);let i={parent:[]};for(let n of r){let s=n.slice(0,n.indexOf(" ")),a=n.slice(n.indexOf(" ")+1);Array.isArray(i[s])?i[s].push(a):i[s]=a}return i.author&&(i.author=yd(i.author)),i.committer&&(i.committer=yd(i.committer)),i}static renderHeaders(e){let r="";if(e.tree?r+=`tree ${e.tree}
|
||||
`:r+=`tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
`,e.parent){if(e.parent.length===void 0)throw new he("commit 'parent' property should be an array");for(let s of e.parent)r+=`parent ${s}
|
||||
`}let i=e.author;r+=`author ${Ug(i)}
|
||||
`;let n=e.committer||e.author;return r+=`committer ${Ug(n)}
|
||||
`,e.gpgsig&&(r+="gpgsig"+Pg(e.gpgsig)),r}static render(e){return t.renderHeaders(e)+`
|
||||
`+Yn(e.message)}render(){return this._commit}withoutSignature(){let e=Yn(this._commit);if(e.indexOf(`
|
||||
gpgsig`)===-1)return e;let r=e.slice(0,e.indexOf(`
|
||||
gpgsig`)),i=e.slice(e.indexOf(`-----END PGP SIGNATURE-----
|
||||
`)+28);return Yn(r+`
|
||||
`+i)}isolateSignature(){let e=this._commit.slice(this._commit.indexOf("-----BEGIN PGP SIGNATURE-----"),this._commit.indexOf("-----END PGP SIGNATURE-----")+27);return fL(e)}static async sign(e,r,i){let n=e.withoutSignature(),s=t.justMessage(e._commit),{signature:a}=await r({payload:n,secretKey:i});a=Yn(a);let l=t.justHeaders(e._commit)+`
|
||||
gpgsig`+Pg(a)+`
|
||||
`+s;return t.from(l)}};async function Xo({fs:t,cache:e,gitdir:r,oid:i}){if(i==="4b825dc642cb6eb9a060e54bf8d69288fbee4904")return{tree:Mr.from([]),oid:i};let{type:n,object:s}=await tt({fs:t,cache:e,gitdir:r,oid:i});if(n==="tag")return i=Jr.from(s).parse().object,Xo({fs:t,cache:e,gitdir:r,oid:i});if(n==="commit")return i=Dr.from(s).parse().tree,Xo({fs:t,cache:e,gitdir:r,oid:i});if(n!=="tree")throw new br(i,n,"tree");return{tree:Mr.from(s),oid:i}}var Gg=class{constructor({fs:e,gitdir:r,ref:i,cache:n}){this.fs=e,this.cache=n,this.gitdir=r,this.mapPromise=(async()=>{let a=new Map,o;try{o=await q.resolve({fs:e,gitdir:r,ref:i})}catch(c){c instanceof Ve&&(o="4b825dc642cb6eb9a060e54bf8d69288fbee4904")}let l=await Xo({fs:e,cache:this.cache,gitdir:r,oid:o});return l.type="tree",l.mode="40000",a.set(".",l),a})();let s=this;this.ConstructEntry=class{constructor(o){this._fullpath=o,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return s.type(this)}async mode(){return s.mode(this)}async stat(){return s.stat(this)}async content(){return s.content(this)}async oid(){return s.oid(this)}}}async readdir(e){let r=e._fullpath,{fs:i,cache:n,gitdir:s}=this,a=await this.mapPromise,o=a.get(r);if(!o)throw new Error(`No obj for ${r}`);let l=o.oid;if(!l)throw new Error(`No oid for obj ${JSON.stringify(o)}`);if(o.type!=="tree")return null;let{type:c,object:u}=await tt({fs:i,cache:n,gitdir:s,oid:l});if(c!==o.type)throw new br(l,c,o.type);let f=Mr.from(u);for(let d of f)a.set(B(r,d.path),d);return f.entries().map(d=>B(r,d.path))}async type(e){if(e._type===!1){let r=await this.mapPromise,{type:i}=r.get(e._fullpath);e._type=i}return e._type}async mode(e){if(e._mode===!1){let r=await this.mapPromise,{mode:i}=r.get(e._fullpath);e._mode=zE(parseInt(i,8))}return e._mode}async stat(e){}async content(e){if(e._content===!1){let r=await this.mapPromise,{fs:i,cache:n,gitdir:s}=this,o=r.get(e._fullpath).oid,{type:l,object:c}=await tt({fs:i,cache:n,gitdir:s,oid:o});l!=="blob"?e._content=void 0:e._content=new Uint8Array(c)}return e._content}async oid(e){if(e._oid===!1){let i=(await this.mapPromise).get(e._fullpath);e._oid=i.oid}return e._oid}};function Fr({ref:t="HEAD"}={}){let e=Object.create(null);return Object.defineProperty(e,Pd,{value:function({fs:r,gitdir:i,cache:n}){return new Gg({fs:r,gitdir:i,ref:t,cache:n})}}),Object.freeze(e),e}var jg=class{constructor({fs:e,dir:r,gitdir:i,cache:n,refresh:s=!0}){this.fs=e,this.cache=n,this.dir=r,this.gitdir=i,this.refresh=s,this.config=null;let a=this;this.ConstructEntry=class{constructor(l){this._fullpath=l,this._type=!1,this._mode=!1,this._stat=!1,this._content=!1,this._oid=!1}async type(){return a.type(this)}async mode(){return a.mode(this)}async stat(){return a.stat(this)}async content(){return a.content(this)}async oid(){return a.oid(this)}}}async readdir(e){if(await e.type()!=="tree")return null;let r=e._fullpath,{fs:i,dir:n}=this,s=await i.readdir(B(n,r));return s===null?null:s.map(a=>B(r,a))}async type(e){return e._type===!1&&await e.stat(),e._type}async mode(e){return e._mode===!1&&await e.stat(),e._mode}async stat(e){if(e._stat===!1){let{fs:r,dir:i}=this,n=await r.lstat(`${i}/${e._fullpath}`);if(!n)throw new Error(`ENOENT: no such file or directory, lstat '${e._fullpath}'`);let s=n.isDirectory()?"tree":"blob";s==="blob"&&!n.isFile()&&!n.isSymbolicLink()&&(s="special"),e._type=s,n=Wo(n),e._mode=n.mode,n.size===-1&&e._actualSize&&(n.size=e._actualSize),e._stat=n}return e._stat}async content(e){if(e._content===!1){let{fs:r,dir:i,gitdir:n}=this;if(await e.type()==="tree")e._content=void 0;else{let s;if(await e.mode()>>12===10)s=await r.readlink(`${i}/${e._fullpath}`);else{let o=await(await this._getGitConfig(r,n)).get("core.autocrlf");s=await r.read(`${i}/${e._fullpath}`,{autocrlf:o})}e._actualSize=s.length,e._stat&&e._stat.size===-1&&(e._stat.size=e._actualSize),e._content=new Uint8Array(s)}}return e._content}async oid(e){if(e._oid===!1){let r=this,{fs:i,gitdir:n,cache:s}=this,a;await dt.acquire({fs:i,gitdir:n,cache:s},async function(o){let l=o.entriesMap.get(e._fullpath),c=await e.stat(),f=await(await r._getGitConfig(i,n)).get("core.filemode"),d=typeof process!="undefined"?process.platform!=="win32":!0;if(!l||gd(c,l,f,d)){let h=await e.content();h===void 0?a=void 0:(a=await bn($s.wrap({type:"blob",object:h})),r.refresh&&l&&a===l.oid&&(!f||c.mode===l.mode)&&gd(c,l,f,d)&&o.insert({filepath:e._fullpath,stats:c,oid:a}))}else a=l.oid}),e._oid=a}return e._oid}async _getGitConfig(e,r){return this.config?this.config:(this.config=await ht.get({fs:e,gitdir:r}),this.config)}};function cu({refresh:t=!0}={}){let e=Object.create(null);return Object.defineProperty(e,Pd,{value:function({fs:r,dir:i,gitdir:n,cache:s}){return new jg({fs:r,dir:i,gitdir:n,cache:s,refresh:t})}}),Object.freeze(e),e}function dL(t,e){let r=e-t;return Array.from({length:r},(i,n)=>t+n)}var QE=typeof Array.prototype.flat=="undefined"?t=>t.reduce((e,r)=>e.concat(r),[]):t=>t.flat(),Vg=class{constructor(){this
Line truncated
|
||||
`),i=new TextEncoder().encode(i)}catch(n){}return typeof i!="string"&&(i=k.from(i)),i}catch(i){return null}}async write(e,r,i={}){try{await this._writeFile(e,r,i)}catch(n){await this.mkdir(wa(e)),await this._writeFile(e,r,i)}}async mkdir(e,r=!1){try{await this._mkdir(e)}catch(i){if(i===null||i.code==="EEXIST")return;if(r)throw i;if(i.code==="ENOENT"){let n=wa(e);if(n==="."||n==="/"||n===e)throw i;await this.mkdir(n),await this.mkdir(e,!0)}}}async rm(e){try{await this._unlink(e)}catch(r){if(r.code!=="ENOENT")throw r}}async rmdir(e,r){try{r&&r.recursive?await this._rm(e,r):await this._rmdir(e)}catch(i){if(i.code!=="ENOENT")throw i}}async readdir(e){try{let r=await this._readdir(e);return r.sort(Td),r}catch(r){return r.code==="ENOTDIR"?null:[]}}async readdirDeep(e){let r=await this._readdir(e);return(await Promise.all(r.map(async n=>{let s=e+"/"+n;return(await this._stat(s)).isDirectory()?this.readdirDeep(s):s}))).reduce((n,s)=>n.concat(s),[])}async lstat(e){try{return await this._lstat(e)}catch(r){if(r.code==="ENOENT"||(r.code||"").includes("ENS"))return null;throw r}}async readlink(e,r={encoding:"buffer"}){try{let i=await this._readlink(e,r);return k.isBuffer(i)?i:k.from(i)}catch(i){if(i.code==="ENOENT"||(i.code||"").includes("ENS"))return null;throw i}}async writelink(e,r){return this._symlink(r.toString("utf8"),e)}};function R(t,e){if(e===void 0)throw new Ir(t)}function gL(t){return t.startsWith("/")||/^[a-zA-Z]:[\\/]/.test(t)}async function re({fsp:t,dotgit:e}){R("fsp",t),R("dotgit",e);let r=await t._stat(e).catch(()=>({isFile:()=>!1,isDirectory:()=>!1}));return r.isDirectory()?e:r.isFile()?t._readFile(e,"utf8").then(i=>i.trimRight().substr(8)).then(i=>gL(i)?i:B(wa(e),i)):e}async function xd(t,e){return!t&&!e?!1:t&&!e||!t&&e?!0:!(await t.type()==="tree"&&await e.type()==="tree"||await t.type()===await e.type()&&await t.mode()===await e.mode()&&await t.oid()===await e.oid())}async function vL({fs:t,dir:e,gitdir:r=B(e,".git"),commit:i="HEAD",cache:n={}}){try{R("fs",t),R("dir",e),R("gitdir",r);let s=new J(t),a=[Fr({ref:i}),cu(),tl()],o=[],l=await re({fsp:s,dotgit:r});await dt.acquire({fs:s,gitdir:l,cache:n},async function(u){o=u.unmergedPaths});let c=await Zn({fs:s,cache:n,dir:e,gitdir:l,trees:a,map:async function(u,[f,d,h]){let p=!await xd(d,h),g=o.includes(u),v=!await xd(h,f);if(p||g)return f?{path:u,mode:await f.mode(),oid:await f.oid(),type:await f.type(),content:await f.content()}:void 0;if(v)return!1;throw new iu(u)}});await dt.acquire({fs:s,gitdir:l,cache:n},async function(u){for(let f of c)if(f!==!1){if(!f){await s.rmdir(`${e}/${f.path}`,{recursive:!0}),u.delete({filepath:f.path});continue}if(f.type==="blob"){let d=new TextDecoder().decode(f.content);await s.write(`${e}/${f.path}`,d,{mode:f.mode}),u.insert({filepath:f.path,oid:f.oid,stage:0})}}})}catch(s){throw s.caller="git.abortMerge",s}}var Is=class{static async isIgnored({fs:e,dir:r,gitdir:i=B(r,".git"),filepath:n}){if(vd(n)===".git")return!0;if(n===".")return!1;let s="",a=B(i,"info","exclude");await e.exists(a)&&(s=await e.read(a,"utf8"));let o=[{gitignore:B(r,".gitignore"),filepath:n}],l=n.split("/").filter(Boolean);for(let u=1;u<l.length;u++){let f=l.slice(0,u).join("/"),d=l.slice(u).join("/");o.push({gitignore:B(r,f,".gitignore"),filepath:d})}let c=!1;for(let u of o){let f;try{f=await e.read(u.gitignore,"utf8")}catch(p){if(p.code==="NOENT")continue}let d=(0,GE.default)().add(s);d.add(f);let h=wa(u.filepath);if(h!=="."&&d.ignores(h))return!0;c?c=!d.test(u.filepath).unignored:c=d.test(u.filepath).ignored}return c}};async function wL({fs:t,gitdir:e,object:r,format:i,oid:n}){if(i!=="deflated")throw new he("GitObjectStoreLoose expects objects to write to be in deflated format");let s=`objects/${n.slice(0,2)}/${n.slice(2)}`,a=`${e}/${s}`;await t.exists(a)||await t.write(a,r)}var Rg=null;async function JE(t){return Rg===null&&(Rg=_L()),Rg?bL(t):Ad.default.deflate(t)}async function bL(t){let e=new CompressionStream("deflate"),r=new Blob([t]).stream().pipeThrough(e);return new Uint8Array(await new Response(r).arrayBuffer())}function _L(){try{return new CompressionStream("deflate").writable.close(),new Blob([]).stream().cancel(),!0}catch(t){return!1}}async function Or({fs:t,gitdir:e,type:r,object:i,format:n="content",oid:s=void 0,dryRun:a=!1}){return n!=="deflated"&&(n!=="wrapped"&&(i=$s.wrap({type:r,object:i})),s=await bn(i),i=k.from(await JE(i))),a||await wL({fs:t,gitdir:e,object:i,format:"deflated",oid:s}),s}function eS(t){let e;for(;~(e=t.indexOf(92));)t[e]=47;return t}async function yL({fs:t,dir:e,gitdir:r=B(e,".git"),filepath:i,cache:n={},force:s=!1,parallel:a=!0}){try{R("fs",t),R("dir",e),R("gitdir",r),R("filepath",i);let o=new J(t),l=await re({fsp:o,dotgit:r});await dt.acquire({fs:o,gitdir:l,cache:n},async c=>{let f=await(await ht.get({fs:o,gitdir:l})).get("core.autocrlf");return Wg({dir:e,gitdir:l,fs:o,filepath:i,index:c,force:s,parallel:a,autocrlf:f})})}catch(o){throw o.caller="git.add",o}}async function Wg({dir:t,gitdir:e,fs:r,filepath:i,in
Line truncated
|
||||
`,author:l,committer:c,signingKey:u})}async function SL({fs:t,onSign:e,dir:r,gitdir:i=B(r,".git"),ref:n="refs/notes/commits",oid:s,note:a,force:o,author:l,committer:c,signingKey:u,cache:f={}}){try{R("fs",t),R("gitdir",i),R("oid",s),R("note",a),u&&R("onSign",e);let d=new J(t),h=await Ms({fs:d,gitdir:i,author:l});if(!h)throw new Kt("author");let p=await xa({fs:d,gitdir:i,author:h,committer:c});if(!p)throw new Kt("committer");let g=await re({fsp:d,dotgit:i});return await EL({fs:d,cache:f,onSign:e,gitdir:g,ref:n,oid:s,note:a,force:o,author:h,committer:p,signingKey:u})}catch(d){throw d.caller="git.addNote",d}}var kL=/(^|[/.])([/.]|$)|^@$|@{|[\x00-\x20\x7f~^:?*[\\]|\.lock(\/|$)/;function au(t,e){if(typeof t!="string")throw new TypeError("Reference name must be a string");return!kL.test(t)&&(!!e||t.includes("/"))}async function sS({fs:t,gitdir:e,remote:r,url:i,force:n}){if(!au(r,!0))throw new ji(r,zo.default.clean(r));let s=await ht.get({fs:t,gitdir:e});if(!n&&(await s.getSubsections("remote")).includes(r)&&i!==await s.get(`remote.${r}.url`))throw new Gi("remote",r);await s.set(`remote.${r}.url`,i),await s.set(`remote.${r}.fetch`,`+refs/heads/*:refs/remotes/${r}/*`),await ht.save({fs:t,gitdir:e,config:s})}async function CL({fs:t,dir:e,gitdir:r=B(e,".git"),remote:i,url:n,force:s=!1}){try{R("fs",t),R("gitdir",r),R("remote",i),R("url",n);let a=new J(t),o=await re({fsp:a,dotgit:r});return await sS({fs:a,gitdir:o,remote:i,url:n,force:s})}catch(a){throw a.caller="git.addRemote",a}}async function AL({fs:t,cache:e,onSign:r,gitdir:i,ref:n,tagger:s,message:a=n,gpgsig:o,object:l,signingKey:c,force:u=!1}){if(n=n.startsWith("refs/tags/")?n:`refs/tags/${n}`,!u&&await q.exists({fs:t,gitdir:i,ref:n}))throw new Gi("tag",n);let f=await q.resolve({fs:t,gitdir:i,ref:l||"HEAD"}),{type:d}=await tt({fs:t,cache:e,gitdir:i,oid:f}),h=Jr.from({object:f,type:d,tag:n.replace("refs/tags/",""),tagger:s,message:a,gpgsig:o});c&&(h=await Jr.sign(h,r,c));let p=await Or({fs:t,gitdir:i,type:"tag",object:h.toObject()});await q.writeRef({fs:t,gitdir:i,ref:n,value:p})}async function TL({fs:t,onSign:e,dir:r,gitdir:i=B(r,".git"),ref:n,tagger:s,message:a=n,gpgsig:o,object:l,signingKey:c,force:u=!1,cache:f={}}){try{R("fs",t),R("gitdir",i),R("ref",n),c&&R("onSign",e);let d=new J(t),h=await re({fsp:d,dotgit:i}),p=await Ms({fs:d,gitdir:h,author:s});if(!p)throw new Kt("tagger");return await AL({fs:d,cache:f,onSign:e,gitdir:h,ref:n,tagger:p,message:a,gpgsig:o,object:l,signingKey:c,force:u})}catch(d){throw d.caller="git.annotatedTag",d}}async function PL({fs:t,gitdir:e,ref:r,object:i,checkout:n=!1,force:s=!1}){if(!au(r,!0))throw new ji(r,zo.default.clean(r));let a=`refs/heads/${r}`;if(!s&&await q.exists({fs:t,gitdir:e,ref:a}))throw new Gi("branch",r,!1);let o;try{o=await q.resolve({fs:t,gitdir:e,ref:i||"HEAD"})}catch(l){}o&&await q.writeRef({fs:t,gitdir:e,ref:a,value:o}),n&&await q.writeSymbolicRef({fs:t,gitdir:e,ref:"HEAD",value:a})}async function RL({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i,object:n,checkout:s=!1,force:a=!1}){try{R("fs",t),R("gitdir",r),R("ref",i);let o=new J(t),l=await re({fsp:o,dotgit:r});return await PL({fs:o,gitdir:l,ref:i,object:n,checkout:s,force:a})}catch(o){throw o.caller="git.branch",o}}async function ou(t,e,r){let i=r.split("/");i.pop();let n=e;for(let s of i){if(s===""||s===".")continue;n=`${n}/${s}`;let a=await t.lstat(n);if(a&&a.isSymbolicLink())throw new va(r)}}var aS=(t,e)=>t==="."||e==null||e.length===0||e==="."?!0:e.length>=t.length?e.startsWith(t):t.startsWith(e);async function Kg({fs:t,cache:e,onProgress:r,onPostCheckout:i,dir:n,gitdir:s,remote:a,ref:o,filepaths:l,noCheckout:c,noUpdateHead:u,dryRun:f,force:d,track:h=!0,nonBlocking:p=!1,batchSize:g=100}){let v;if(i)try{v=await q.resolve({fs:t,gitdir:s,ref:"HEAD"})}catch(_){v="0000000000000000000000000000000000000000"}let b;try{b=await q.resolve({fs:t,gitdir:s,ref:o})}catch(_){if(o==="HEAD")throw _;let C=`${a}/${o}`;if(b=await q.resolve({fs:t,gitdir:s,ref:C}),h){let x=await ht.get({fs:t,gitdir:s});await x.set(`branch.${o}.remote`,a),await x.set(`branch.${o}.merge`,`refs/heads/${o}`),await ht.save({fs:t,gitdir:s,config:x})}await q.writeRef({fs:t,gitdir:s,ref:`refs/heads/${o}`,value:b})}if(!c){let _;try{_=await $L({fs:t,cache:e,onProgress:r,dir:n,gitdir:s,ref:o,force:d,filepaths:l})}catch(w){throw w instanceof Ve&&w.data.what===b?new Yc(o,b):w}let C=_.filter(([w])=>w==="conflict").map(([w,E])=>E);if(C.length>0)throw new zc(C);let x=_.filter(([w])=>w==="error").map(([w,E])=>E);if(x.length>0)throw new he(x.join(", "));if(f){i&&await i({previousHead:v,newHead:b,type:l!=null&&l.length>0?"file":"branch"});return}let S=0,A=_.length;if(await dt.acquire({fs:t,gitdir:s,cache:e},async function(w){await Promise.all(_.filter(([E])=>E==="delete"||E==="delete-index").map(async function([E,y]){let P=`${n}/${y}`;E==="delete"&&await t.rm(P),w.delete({filepath:y}),r&&await r({phase:"Updating workdir",loaded:++S,total:A})}))}),await dt.acquire({fs:t,gitdir:s,cache:e},async function(w){for(let[E,y]of
Line truncated
|
||||
`,d+=p.conflict.a.join(""),d+=`${"=".repeat(f)}
|
||||
`,d+=p.conflict.b.join(""),d+=`${">".repeat(f)} ${i}
|
||||
`);return{cleanMerge:h,mergedText:d}}async function lS({fs:t,cache:e,dir:r,gitdir:i=B(r,".git"),index:n,ourOid:s,baseOid:a,theirOid:o,ourName:l="ours",baseName:c="base",theirName:u="theirs",dryRun:f=!1,abortOnConflict:d=!0,mergeDriver:h}){let p=Fr({ref:s}),g=Fr({ref:a}),v=Fr({ref:o}),b=[],_=[],C=[],x=[],S=await Zn({fs:t,cache:e,dir:r,gitdir:i,trees:[p,g,v],map:async function(A,[w,E,y]){let P=vd(A),T=await xd(w,E),I=await xd(y,E);switch(`${T}-${I}`){case"false-false":return{mode:await E.mode(),path:P,oid:await E.oid(),type:await E.type()};case"false-true":return!y&&await w.type()==="tree"?{mode:await w.mode(),path:P,oid:await w.oid(),type:await w.type()}:y?{mode:await y.mode(),path:P,oid:await y.oid(),type:await y.type()}:void 0;case"true-false":return!w&&await y.type()==="tree"?{mode:await y.mode(),path:P,oid:await y.oid(),type:await y.type()}:w?{mode:await w.mode(),path:P,oid:await w.oid(),type:await w.type()}:void 0;case"true-true":{if(w&&y&&await w.type()==="tree"&&await y.type()==="tree")return{mode:await w.mode(),path:P,oid:await w.oid(),type:"tree"};if(w&&y&&await w.type()==="blob"&&await y.type()==="blob")return DL({fs:t,gitdir:i,path:P,ours:w,base:E,theirs:y,ourName:l,baseName:c,theirName:u,mergeDriver:h}).then(async L=>{if(L.cleanMerge)d||n.insert({filepath:A,oid:L.mergeResult.oid,stage:0});else if(b.push(A),_.push(A),!d){let H="";E&&await E.type()==="blob"&&(H=await E.oid());let te=await w.oid(),xe=await y.oid();n.delete({filepath:A}),H&&n.insert({filepath:A,oid:H,stage:1}),n.insert({filepath:A,oid:te,stage:2}),n.insert({filepath:A,oid:xe,stage:3})}return L.mergeResult});if(E&&!w&&y&&await E.type()==="blob"&&await y.type()==="blob"){if(b.push(A),C.push(A),!d){let L=await E.oid(),H=await y.oid();n.delete({filepath:A}),n.insert({filepath:A,oid:L,stage:1}),n.insert({filepath:A,oid:H,stage:3})}return{mode:await y.mode(),oid:await y.oid(),type:"blob",path:P}}if(E&&w&&!y&&await E.type()==="blob"&&await w.type()==="blob"){if(b.push(A),x.push(A),!d){let L=await E.oid(),H=await w.oid();n.delete({filepath:A}),n.insert({filepath:A,oid:L,stage:1}),n.insert({filepath:A,oid:H,stage:2})}return{mode:await w.mode(),oid:await w.oid(),type:"blob",path:P}}if(E&&!w&&!y&&(await E.type()==="blob"||await E.type()==="tree"))return;throw new Yo}}},reduce:b.length!==0&&(!r||d)?void 0:async(A,w)=>{let E=w.filter(Boolean);if(A&&!(A&&A.type==="tree"&&E.length===0&&A.path!==".")){if(E.length>0||A.path==="."&&E.length===0){let P=new Mr(E).toObject(),T=await Or({fs:t,gitdir:i,type:"tree",object:P,dryRun:f});A.oid=T}return A}}});return b.length!==0?(r&&!d&&await Zn({fs:t,cache:e,dir:r,gitdir:i,trees:[Fr({ref:S.oid})],map:async function(A,[w]){let E=`${r}/${A}`;if(await w.type()==="blob"){let y=await w.mode(),P=await w.content();await t.write(E,P,{mode:y})}return!0}}),new ba(b,_,C,x)):S.oid}async function DL({fs:t,gitdir:e,path:r,ours:i,base:n,theirs:s,ourName:a,theirName:o,baseName:l,dryRun:c,mergeDriver:u=ML}){let f="blob",d="100755",h="",p="";n&&await n.type()==="blob"&&(d=await n.mode(),h=await n.oid(),p=k.from(await n.content()).toString("utf8"));let g=d===await i.mode()?await s.mode():await i.mode();if(await i.oid()===await s.oid())return{cleanMerge:!0,mergeResult:{mode:g,path:r,oid:await i.oid(),type:f}};if(await i.oid()===h)return{cleanMerge:!0,mergeResult:{mode:g,path:r,oid:await s.oid(),type:f}};if(await s.oid()===h)return{cleanMerge:!0,mergeResult:{mode:g,path:r,oid:await i.oid(),type:f}};let v=k.from(await i.content()).toString("utf8"),b=k.from(await s.content()).toString("utf8"),{mergedText:_,cleanMerge:C}=await u({branches:[l,a,o],contents:[p,v,b],path:r}),x=await Or({fs:t,gitdir:e,type:"blob",object:k.from(_,"utf8"),dryRun:c});return{cleanMerge:C,mergeResult:{mode:g,path:r,oid:x,type:f}}}var OL={stage:tl,workdir:cu},Fg;async function Qo(t,e){return Fg===void 0&&(Fg=new Vo.default),Fg.acquire(t,e)}async function LL(t,e,r,i,n=null){let s=B(r,i),a=await t.lstat(s);if(!a)throw new Ve(s);if(a.isDirectory())throw new he(`${s}: file expected, but found directory`);let o=n?await ZE({fs:t,gitdir:e,oid:n}):void 0,l=o?n:void 0;return o||await Qo({fs:t,gitdir:e,currentFilepath:s},async()=>{let c=a.isSymbolicLink()?await t.readlink(s).then(eS):await t.read(s);if(c===null)throw new Ve(s);l=await Or({fs:t,gitdir:e,type:"blob",object:c})}),l}async function NL({fs:t,dir:e,gitdir:r,entries:i}){async function n(s){if(s.type==="tree"){if(!s.oid){let a=await Promise.all(s.children.map(n));s.oid=await du({fs:t,gitdir:r,tree:a}),s.mode=16384}}else s.type==="blob"&&(s.oid=await LL(t,r,e,s.path,s.oid),s.mode=33188);return s.path=s.path.split("/").pop(),s}return Promise.all(i.map(n))}async function FE({fs:t,dir:e,gitdir:r,treePair:i}){let n=i[1]==="stage",s=i.map(h=>typeof h=="string"?OL[h]():h),a=[],u=await Zn({fs:t,cache:{},dir:e,gitdir:r,trees:s,map:async(h,[p,g])=>{if(!(h==="."||await Is.isIgnored({fs:t,dir:e,gitdir:r,filepath:h}))&&g)return(!p||await p.oid()!==await g.oid()&&await g.oid()!==void 0)&&a.push([p,g]),{mode:await g.mode(),pa
Line truncated
|
||||
`).map(a=>n.add(a))}),n}static async write({fs:e,gitdir:r,oids:i}){ma===null&&(ma=new Vo.default);let n=B(r,"shallow");if(i.size>0){let s=[...i].join(`
|
||||
`)+`
|
||||
`;await ma.acquire(n,async function(){await e.write(n,s,{encoding:"utf8"})})}else await ma.acquire(n,async function(){await e.rm(n)})}};async function jL({fs:t,gitdir:e,oid:r}){let i=`objects/${r.slice(0,2)}/${r.slice(2)}`;return t.exists(`${e}/${i}`)}async function VL({fs:t,cache:e,gitdir:r,oid:i,getExternalRefDelta:n}){let s=await t.readdir(B(r,"objects/pack"));s=s.filter(a=>a.endsWith(".idx"));for(let a of s){let o=`${r}/objects/pack/${a}`,l=await Zg({fs:t,cache:e,filename:o,getExternalRefDelta:n});if(l.error)throw new he(l.error);if(l.offsets.has(i))return!0}return!1}async function BE({fs:t,cache:e,gitdir:r,oid:i,format:n="content"}){let s=o=>tt({fs:t,cache:e,gitdir:r,oid:o}),a=await jL({fs:t,gitdir:r,oid:i});return a||(a=await VL({fs:t,cache:e,gitdir:r,oid:i,getExternalRefDelta:s})),a}function Sd({config:t,onAuth:e}){return e&&(async(r,i)=>{let n=i.username||await t.get(`credential.${r}.username`);return e(r,n?{...i,username:n}:i)})}function zL(t){let n="5041434b"+"00000002"+"00000000";return t.slice(0,12).toString("hex")===n}function fS(t,e){let r=t.map(i=>i.split("=",1)[0]);return e.filter(i=>{let n=i.split("=",1)[0];return r.includes(n)})}var Rd={name:"isomorphic-git",version:"1.40.0",agent:"git/isomorphic-git@1.40.0"},jo=class{constructor(){this._queue=[]}write(e){if(this._ended)throw Error("You cannot write to a FIFO that has already been ended!");if(this._waiting){let r=this._waiting;this._waiting=null,r({value:e})}else this._queue.push(e)}end(){if(this._ended=!0,this._waiting){let e=this._waiting;this._waiting=null,e({done:!0})}}destroy(e){this.error=e,this.end()}async next(){if(this._queue.length>0)return{value:this._queue.shift()};if(this._ended)return{done:!0};if(this._waiting)throw Error("You cannot call read until the previous call to read has returned!");return new Promise(e=>{this._waiting=e})}};function WL(t){let e=t.indexOf("\r"),r=t.indexOf(`
|
||||
`);return e===-1&&r===-1?-1:e===-1?r+1:r===-1?e+1:r===e+1?r+1:Math.min(e,r)+1}function dS(t){let e=new jo,r="";return(async()=>(await hu(t,i=>{for(i=i.toString("utf8"),r+=i;;){let n=WL(r);if(n===-1)break;e.write(r.slice(0,n)),r=r.slice(n)}}),r.length>0&&e.write(r),e.end()))(),e}var kd=class{static demux(e){let r=ot.streamReader(e),i=new jo,n=new jo,s=new jo,a=async function(){let o=await r();if(o===null)return a();if(o===!0){i.end(),s.end(),e.error?n.destroy(e.error):n.end();return}switch(o[0]){case 1:{n.write(o.slice(1));break}case 2:{s.write(o.slice(1));break}case 3:{let l=o.slice(1);s.write(l),i.end(),s.end(),n.destroy(new Error(l.toString("utf8")));return}default:i.write(o)}a()};return a(),{packetlines:i,packfile:n,progress:s}}};async function qL(t){let{packetlines:e,packfile:r,progress:i}=kd.demux(t),n=[],s=[],a=[],o=!1,l=!1;return new Promise((c,u)=>{hu(e,f=>{let d=f.toString("utf8").trim();if(d.startsWith("shallow")){let h=d.slice(-41).trim();h.length!==40&&u(new Rs(h)),n.push(h)}else if(d.startsWith("unshallow")){let h=d.slice(-41).trim();h.length!==40&&u(new Rs(h)),s.push(h)}else if(d.startsWith("ACK")){let[,h,p]=d.split(" ");a.push({oid:h,status:p}),p||(l=!0)}else d.startsWith("NAK")?(o=!0,l=!0):(l=!0,o=!0);l&&(t.error?u(t.error):c({shallows:n,unshallows:s,acks:a,nak:o,packfile:r,progress:i}))}).finally(()=>{l||(t.error?u(t.error):c({shallows:n,unshallows:s,acks:a,nak:o,packfile:r,progress:i}))})})}function YL({capabilities:t=[],wants:e=[],haves:r=[],shallows:i=[],depth:n=null,since:s=null,exclude:a=[]}){let o=[];e=[...new Set(e)];let l=` ${t.join(" ")}`;for(let c of e)o.push(ot.encode(`want ${c}${l}
|
||||
`)),l="";for(let c of i)o.push(ot.encode(`shallow ${c}
|
||||
`));n!==null&&o.push(ot.encode(`deepen ${n}
|
||||
`)),s!==null&&o.push(ot.encode(`deepen-since ${Math.floor(s.valueOf()/1e3)}
|
||||
`));for(let c of a)o.push(ot.encode(`deepen-not ${c}
|
||||
`));o.push(ot.flush());for(let c of r)o.push(ot.encode(`have ${c}
|
||||
`));return o.push(ot.encode(`done
|
||||
`)),o}async function Xg({fs:t,cache:e,http:r,onProgress:i,onMessage:n,onAuth:s,onAuthSuccess:a,onAuthFailure:o,gitdir:l,ref:c,remoteRef:u,remote:f,url:d,corsProxy:h,depth:p=null,since:g=null,exclude:v=[],relative:b=!1,tags:_=!1,singleBranch:C=!1,headers:x={},prune:S=!1,pruneTags:A=!1}){let w=c||await Ds({fs:t,gitdir:l,test:!0}),E=await ht.get({fs:t,gitdir:l}),y=f||w&&await E.get(`branch.${w}.remote`)||"origin",P=d||await E.get(`remote.${y}.url`);if(typeof P=="undefined")throw new Ir("remote OR url");let T=u||w&&await E.get(`branch.${w}.merge`)||c||"HEAD";h===void 0&&(h=await E.get("http.corsProxy"));let I=el.getRemoteHelperFor({url:P}),L=await I.discover({http:r,onAuth:Sd({config:E,onAuth:s}),onAuthSuccess:a,onAuthFailure:Sd({config:E,onAuth:o}),corsProxy:h,service:"git-upload-pack",url:P,headers:x,protocolVersion:1}),H=L.auth,te=L.refs;if(te.size===0)return{defaultBranch:null,fetchHead:null,fetchHeadDescription:null};if(p!==null&&!L.capabilities.has("shallow"))throw new Ps("shallow","depth");if(g!==null&&!L.capabilities.has("deepen-since"))throw new Ps("deepen-since","since");if(v.length>0&&!L.capabilities.has("deepen-not"))throw new Ps("deepen-not","exclude");if(b===!0&&!L.capabilities.has("deepen-relative"))throw new Ps("deepen-relative","relative");let{oid:xe,fullref:Z}=q.resolveAgainstMap({ref:T,map:te});for(let N of te.keys())N===Z||N==="HEAD"||N.startsWith("refs/heads/")||_&&N.startsWith("refs/tags/")||te.delete(N);let K=fS([...L.capabilities],["multi_ack_detailed","no-done","side-band-64k","ofs-delta",`agent=${Rd.agent}`]);b&&K.push("deepen-relative");let ce=C?[xe]:te.values(),pe=C?[w]:await q.listRefs({fs:t,gitdir:l,filepath:"refs"}),W=[];for(let N of pe)try{N=await q.expand({fs:t,gitdir:l,ref:N});let O=await q.resolve({fs:t,gitdir:l,ref:N});await BE({fs:t,cache:e,gitdir:l,oid:O})&&W.push(O)}catch(O){}W=[...new Set(W)];let X=await Ea.read({fs:t,gitdir:l}),G=L.capabilities.has("shallow")?[...X]:[],Be=YL({capabilities:K,wants:ce,haves:W,shallows:G,depth:p,since:g,exclude:v}),pr=k.from(await Ed(Be)),Ut=await I.connect({http:r,onProgress:i,corsProxy:h,service:"git-upload-pack",url:P,auth:H,body:[pr],headers:x}),Ie=await qL(Ut.body);Ut.headers&&(Ie.headers=Ut.headers);for(let N of Ie.shallows)if(!X.has(N))try{let{object:O}=await tt({fs:t,cache:e,gitdir:l,oid:N}),ue=new Dr(O),$e=await Promise.all(ue.headers().parent.map(Tr=>BE({fs:t,cache:e,gitdir:l,oid:Tr})));$e.length===0||$e.every(Tr=>Tr)||X.add(N)}catch(O){X.add(N)}for(let N of Ie.unshallows)X.delete(N);if(await Ea.write({fs:t,gitdir:l,oids:X}),C){let N=new Map([[Z,xe]]),O=new Map,ue=10,$e=Z;for(;ue--;){let go=L.symrefs.get($e);if(go===void 0)break;O.set($e,go),$e=go}let Gt=te.get($e);Gt&&N.set($e,Gt);let{pruned:Tr}=await q.updateRemoteRefs({fs:t,gitdir:l,remote:y,refs:N,symrefs:O,tags:_,prune:S});S&&(Ie.pruned=Tr)}else{let{pruned:N}=await q.updateRemoteRefs({fs:t,gitdir:l,remote:y,refs:te,symrefs:L.symrefs,tags:_,prune:S,pruneTags:A});S&&(Ie.pruned=N)}if(Ie.HEAD=L.symrefs.get("HEAD"),Ie.HEAD===void 0){let{oid:N}=q.resolveAgainstMap({ref:"HEAD",map:te});for(let[O,ue]of te.entries())if(O!=="HEAD"&&ue===N){Ie.HEAD=O;break}}let Rt=Z.startsWith("refs/tags")?"tag":"branch";if(Ie.FETCH_HEAD={oid:xe,description:`${Rt} '${ga(Z)}' of ${P}`},i||n){let N=dS(Ie.progress);hu(N,async O=>{if(n&&await n(O),i){let ue=O.match(/([^:]*).*\((\d+?)\/(\d+?)\)/);ue&&await i({phase:ue[1].trim(),loaded:parseInt(ue[2],10),total:parseInt(ue[3],10)})}})}let $t=k.from(await Ed(Ie.packfile));if(Ut.body.error)throw Ut.body.error;let Xe=$t.slice(-20).toString("hex"),ee={defaultBranch:Ie.HEAD,fetchHead:Ie.FETCH_HEAD.oid,fetchHeadDescription:Ie.FETCH_HEAD.description};if(Ie.headers&&(ee.headers=Ie.headers),S&&(ee.pruned=Ie.pruned),Xe!==""&&!zL($t)){ee.packfile=`objects/pack/pack-${Xe}.pack`;let N=B(l,ee.packfile);await t.write(N,$t);let O=$e=>tt({fs:t,cache:e,gitdir:l,oid:$e}),ue=await jc.fromPack({pack:$t,getExternalRefDelta:O,onProgress:i});await t.write(N.replace(/\.pack$/,".idx"),await ue.toBuffer())}return ee}async function hS({fs:t,bare:e=!1,dir:r,gitdir:i=e?r:B(r,".git"),defaultBranch:n="master"}){if(await t.exists(i+"/config"))return;let s=["hooks","info","objects/info","objects/pack","refs/heads","refs/tags"];s=s.map(a=>i+"/"+a);for(let a of s)await t.mkdir(a);await t.write(i+"/config",`[core]
|
||||
repositoryformatversion = 0
|
||||
filemode = false
|
||||
bare = ${e}
|
||||
`+(e?"":` logallrefupdates = true
|
||||
`)+` symlinks = false
|
||||
ignorecase = true
|
||||
`),await t.write(i+"/HEAD",`ref: refs/heads/${n}
|
||||
`)}async function ZL({fs:t,cache:e,http:r,onProgress:i,onMessage:n,onAuth:s,onAuthSuccess:a,onAuthFailure:o,onPostCheckout:l,dir:c,gitdir:u,url:f,corsProxy:d,ref:h,remote:p,depth:g,since:v,exclude:b,relative:_,singleBranch:C,noCheckout:x,noTags:S,headers:A,nonBlocking:w,batchSize:E=100}){try{if(await hS({fs:t,gitdir:u}),await sS({fs:t,gitdir:u,remote:p,url:f,force:!1}),d){let T=await ht.get({fs:t,gitdir:u});await T.set("http.corsProxy",d),await ht.save({fs:t,gitdir:u,config:T})}let{defaultBranch:y,fetchHead:P}=await Xg({fs:t,cache:e,http:r,onProgress:i,onMessage:n,onAuth:s,onAuthSuccess:a,onAuthFailure:o,gitdir:u,ref:h,remote:p,corsProxy:d,depth:g,since:v,exclude:b,relative:_,singleBranch:C,headers:A,tags:!S});if(P===null)return;h=h||y,h=h.replace("refs/heads/",""),await Kg({fs:t,cache:e,onProgress:i,onPostCheckout:l,dir:c,gitdir:u,ref:h,remote:p,noCheckout:x,nonBlocking:w,batchSize:E})}catch(y){throw await t.rmdir(u,{recursive:!0,maxRetries:10}).catch(()=>{}),y}}async function KL({fs:t,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:s,onAuthFailure:a,onPostCheckout:o,dir:l,gitdir:c=B(l,".git"),url:u,corsProxy:f=void 0,ref:d=void 0,remote:h="origin",depth:p=void 0,since:g=void 0,exclude:v=[],relative:b=!1,singleBranch:_=!1,noCheckout:C=!1,noTags:x=!1,headers:S={},cache:A={},nonBlocking:w=!1,batchSize:E=100}){try{R("fs",t),R("http",e),R("gitdir",c),C||R("dir",l),R("url",u);let y=new J(t),P=await re({fsp:y,dotgit:c});return await ZL({fs:y,cache:A,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:s,onAuthFailure:a,onPostCheckout:o,dir:l,gitdir:P,url:u,corsProxy:f,ref:d,remote:h,depth:p,since:g,exclude:v,relative:b,singleBranch:_,noCheckout:C,noTags:x,headers:S,nonBlocking:w,batchSize:E})}catch(y){throw y.caller="git.clone",y}}async function XL({fs:t,onSign:e,dir:r,gitdir:i=B(r,".git"),message:n,author:s,committer:a,signingKey:o,amend:l=!1,dryRun:c=!1,noUpdateBranch:u=!1,disallowEmpty:f=!1,ref:d,parent:h,tree:p,cache:g={}}){try{R("fs",t),l||R("message",n),o&&R("onSign",e);let v=new J(t),b=await re({fsp:v,dotgit:i});return await uu({fs:v,cache:g,onSign:e,gitdir:b,message:n,author:s,committer:a,signingKey:o,amend:l,dryRun:c,noUpdateBranch:u,disallowEmpty:f,ref:d,parent:h,tree:p})}catch(v){throw v.caller="git.commit",v}}async function QL({fs:t,dir:e,gitdir:r=B(e,".git"),fullname:i=!1,test:n=!1}){try{R("fs",t),R("gitdir",r);let s=new J(t),a=await re({fsp:s,dotgit:r});return await Ds({fs:s,gitdir:a,fullname:i,test:n})}catch(s){throw s.caller="git.currentBranch",s}}async function JL({fs:t,gitdir:e,ref:r}){if(r=r.startsWith("refs/heads/")?r:`refs/heads/${r}`,!await q.exists({fs:t,gitdir:e,ref:r}))throw new Ve(r);let n=await q.expand({fs:t,gitdir:e,ref:r}),s=await Ds({fs:t,gitdir:e,fullname:!0});if(n===s){let l=await q.resolve({fs:t,gitdir:e,ref:n});await q.writeRef({fs:t,gitdir:e,ref:"HEAD",value:l})}await q.deleteRef({fs:t,gitdir:e,ref:n});let a=ga(r),o=await ht.get({fs:t,gitdir:e});await o.deleteSection("branch",a),await ht.save({fs:t,gitdir:e,config:o})}async function eN({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i}){try{R("fs",t),R("ref",i);let n=new J(t),s=await re({fsp:n,dotgit:r});return await JL({fs:n,gitdir:s,ref:i})}catch(n){throw n.caller="git.deleteBranch",n}}async function tN({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i}){try{R("fs",t),R("ref",i);let n=new J(t),s=await re({fsp:n,dotgit:r});await q.deleteRef({fs:n,gitdir:s,ref:i})}catch(n){throw n.caller="git.deleteRef",n}}async function rN({fs:t,gitdir:e,remote:r}){let i=await ht.get({fs:t,gitdir:e});await i.deleteSection("remote",r),await ht.save({fs:t,gitdir:e,config:i})}async function iN({fs:t,dir:e,gitdir:r=B(e,".git"),remote:i}){try{R("fs",t),R("remote",i);let n=new J(t),s=await re({fsp:n,dotgit:r});return await rN({fs:n,gitdir:s,remote:i})}catch(n){throw n.caller="git.deleteRemote",n}}async function nN({fs:t,gitdir:e,ref:r}){r=r.startsWith("refs/tags/")?r:`refs/tags/${r}`,await q.deleteRef({fs:t,gitdir:e,ref:r})}async function sN({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i}){try{R("fs",t),R("ref",i);let n=new J(t),s=await re({fsp:n,dotgit:r});return await nN({fs:n,gitdir:s,ref:i})}catch(n){throw n.caller="git.deleteTag",n}}async function aN({fs:t,gitdir:e,oid:r}){let i=r.slice(0,2);return(await t.readdir(`${e}/objects/${i}`)).map(s=>`${i}${s}`).filter(s=>s.startsWith(r))}async function oN({fs:t,cache:e,gitdir:r,oid:i,getExternalRefDelta:n}){let s=[],a=await t.readdir(B(r,"objects/pack"));a=a.filter(o=>o.endsWith(".idx"));for(let o of a){let l=`${r}/objects/pack/${o}`,c=await Zg({fs:t,cache:e,filename:l,getExternalRefDelta:n});if(c.error)throw new he(c.error);for(let u of c.offsets.keys())u.startsWith(i)&&s.push(u)}return s}async function lN({fs:t,cache:e,gitdir:r,oid:i}){let n=o=>tt({fs:t,cache:e,gitdir:r,oid:o}),s=await aN({fs:t,gitdir:r,oid:i}),a=await oN({fs:t,cache:e,gitdir:r,oid:i,getExternalRefDelta:n});for(let o of a)s.indexOf(o)===-1&&s.push(o);if(s.length===1)return s[0];throw s.length>1?new Vc("oids",i,s):new Ve(`an object matching "${i}"`)}as
Line truncated
|
||||
`)),i.push(ot.encode(`agent=${Rd.agent}
|
||||
`)),(r||e||t)&&i.push(ot.delim()),r&&i.push(ot.encode("peel")),e&&i.push(ot.encode("symrefs")),t&&i.push(ot.encode(`ref-prefix ${t}`)),i.push(ot.flush()),i}async function LN({http:t,onAuth:e,onAuthSuccess:r,onAuthFailure:i,corsProxy:n,url:s,headers:a={},forPush:o=!1,protocolVersion:l=2,prefix:c,symrefs:u,peelTags:f}){try{R("http",t),R("url",s);let d=await Jo.discover({http:t,onAuth:e,onAuthSuccess:r,onAuthFailure:i,corsProxy:n,service:o?"git-receive-pack":"git-upload-pack",url:s,headers:a,protocolVersion:l});if(d.protocolVersion===1)return vS(d,c,u,f);let h=await ON({prefix:c,symrefs:u,peelTags:f}),p=await Jo.connect({http:t,auth:d.auth,headers:a,corsProxy:n,service:o?"git-receive-pack":"git-upload-pack",url:s,body:h});return DN(p.body)}catch(d){throw d.caller="git.listServerRefs",d}}async function NN({fs:t,dir:e,gitdir:r=B(e,".git")}){try{R("fs",t),R("gitdir",r);let i=new J(t),n=await re({fsp:i,dotgit:r});return q.listTags({fs:i,gitdir:n})}catch(i){throw i.caller="git.listTags",i}}function BN(t,e){return t.committer.timestamp-e.committer.timestamp}var HN="e69de29bb2d1d6434b8b29ae775ad8c2e48c5391";async function HE({fs:t,cache:e,gitdir:r,oid:i,fileId:n}){if(n===HN)return;let s=i,a,o=await Xo({fs:t,cache:e,gitdir:r,oid:i}),l=o.tree;return n===o.oid?a=o.path:(a=await _S({fs:t,cache:e,gitdir:r,tree:l,fileId:n,oid:s}),Array.isArray(a)&&(a.length===0?a=void 0:a.length===1&&(a=a[0]))),a}async function _S({fs:t,cache:e,gitdir:r,tree:i,fileId:n,oid:s,filepaths:a=[],parentPath:o=""}){let l=i.entries().map(function(c){let u;return c.oid===n?(u=B(o,c.path),a.push(u)):c.type==="tree"&&(u=tt({fs:t,cache:e,gitdir:r,oid:c.oid}).then(function({object:f}){return _S({fs:t,cache:e,gitdir:r,tree:Mr.from(f),fileId:n,oid:s,filepaths:a,parentPath:B(o,c.path)})})),u});return await Promise.all(l),a}async function UN({fs:t,cache:e,gitdir:r,filepath:i,ref:n,depth:s,since:a,force:o,follow:l,includeChanges:c}){let u=typeof a=="undefined"?void 0:Math.floor(a.valueOf()/1e3),f=[],d=await Ea.read({fs:t,gitdir:r}),h=await q.resolve({fs:t,gitdir:r,ref:n}),p=[await wn({fs:t,cache:e,gitdir:r,oid:h})],g,v,b;function _(C){b&&i&&f.push(C)}for(;p.length>0;){let C=p.pop();if(u!==void 0&&C.commit.committer.timestamp<=u)break;if(i){let x;try{x=await fu({fs:t,cache:e,gitdir:r,oid:C.commit.tree,filepath:i}),v&&g!==x&&f.push(v),g=x,v=C,b=!0}catch(S){if(S instanceof Ve){let A=l&&g;if(A&&(A=await HE({fs:t,cache:e,gitdir:r,oid:C.commit.tree,fileId:g}),A))if(Array.isArray(A)){if(v){let w=await HE({fs:t,cache:e,gitdir:r,oid:v.commit.tree,fileId:g});if(Array.isArray(w))if(A=A.filter(E=>w.indexOf(E)===-1),A.length===1)A=A[0],i=A,v&&f.push(v);else{A=!1,v&&f.push(v);break}}}else i=A,v&&f.push(v);if(!A){if(b&&g&&(f.push(v),!o))break;if(!o&&!l)throw S}v=C,b=!1}else throw S}}else f.push(C);if(s!==void 0&&f.length===s){_(C);break}if(!d.has(C.oid))for(let x of C.commit.parent){let S=await wn({fs:t,cache:e,gitdir:r,oid:x});p.map(A=>A.oid).includes(S.oid)||p.push(S)}p.length===0&&_(C),p.sort((x,S)=>BN(x.commit,S.commit))}if(c)for(let C of f)C.commit.changes=await GN({fs:t,cache:e,gitdir:r,commit:C,shallow:d.has(C.oid)});return f}async function GN({fs:t,cache:e,gitdir:r,commit:i,shallow:n}){let s=n||!i.commit.parent[0]?"4b825dc642cb6eb9a060e54bf8d69288fbee4904":i.commit.parent[0];return Zn({fs:t,cache:e,gitdir:r,trees:[Fr({ref:i.oid}),Fr({ref:s})],map:async(a,[o,l])=>{let[c,u]=await Promise.all([o&&o.type(),l&&l.type()]);if(c==="tree")return u&&u!=="tree"?[null,await l.oid(),a]:void 0;if(u==="tree")return c?[await o.oid(),null,a]:void 0;let[f,d]=await Promise.all([o?o.oid():null,l?l.oid():null]);if(f!==d)return[f,d,a]}})}async function jN({fs:t,dir:e,gitdir:r=B(e,".git"),filepath:i,ref:n="HEAD",depth:s,since:a,force:o,follow:l,includeChanges:c=!1,cache:u={}}){try{R("fs",t),R("gitdir",r),R("ref",n);let f=new J(t),d=await re({fsp:f,dotgit:r});return await UN({fs:f,cache:u,gitdir:d,filepath:i,ref:n,depth:s,since:a,force:o,follow:l,includeChanges:c})}catch(f){throw f.caller="git.log",f}}async function VN({fs:t,onSign:e,dir:r,gitdir:i=B(r,".git"),ours:n,theirs:s,fastForward:a=!0,fastForwardOnly:o=!1,dryRun:l=!1,noUpdateBranch:c=!1,abortOnConflict:u=!0,message:f,author:d,committer:h,signingKey:p,cache:g={},mergeDriver:v,allowUnrelatedHistories:b=!1}){try{R("fs",t),p&&R("onSign",e);let _=new J(t),C=await re({fsp:_,dotgit:i}),x=await Ms({fs:_,gitdir:C,author:d});if(!x&&(!o||!a))throw new Kt("author");let S=await xa({fs:_,gitdir:C,author:x,committer:h});if(!S&&(!o||!a))throw new Kt("committer");return await pS({fs:_,cache:g,dir:r,gitdir:C,ours:n,theirs:s,fastForward:a,fastForwardOnly:o,dryRun:l,noUpdateBranch:c,abortOnConflict:u,message:f,author:x,committer:S,signingKey:p,onSign:e,mergeDriver:v,allowUnrelatedHistories:b})}catch(_){throw _.caller="git.merge",_}}var zN={commit:16,tree:32,blob:48,tag:64,ofs_delta:96,ref_delta:112};async function yS({fs:t,cache:e,dir:r,gitdir:i=B(r,".git"),oids:n}){let s=new Yg.default,a=[];function o(u,f){let d=k.from(u,f);a.push(d),s.update(d)}as
Line truncated
|
||||
`),n=await i();let s=r.toString("utf8").split(`
|
||||
`);if(n=s.shift(),!n.startsWith("unpack "))throw new ya('unpack ok" or "unpack [error message]',n);e.ok=n==="unpack ok",e.ok||(e.error=n.slice(7)),e.refs={};for(let a of s){if(a.trim()==="")continue;let o=a.slice(0,2),l=a.slice(3),c=l.indexOf(" ");c===-1&&(c=l.length);let u=l.slice(0,c),f=l.slice(c+1);e.refs[u]={ok:o==="ok",error:f}}return e}async function XN({capabilities:t=[],triplets:e=[]}){let r=[],i=`\0 ${t.join(" ")}`;for(let n of e)r.push(ot.encode(`${n.oldoid} ${n.oid} ${n.fullRef}${i}
|
||||
`)),i="";return r.push(ot.flush()),r}async function QN({fs:t,cache:e,http:r,onProgress:i,onMessage:n,onAuth:s,onAuthSuccess:a,onAuthFailure:o,onPrePush:l,gitdir:c,ref:u,remoteRef:f,remote:d,url:h,force:p=!1,delete:g=!1,corsProxy:v,headers:b={}}){let _=u||await Ds({fs:t,gitdir:c});if(typeof _=="undefined")throw new Ir("ref");let C=await ht.get({fs:t,gitdir:c});d=d||await C.get(`branch.${_}.pushRemote`)||await C.get("remote.pushDefault")||await C.get(`branch.${_}.remote`)||"origin";let x=h||await C.get(`remote.${d}.pushurl`)||await C.get(`remote.${d}.url`);if(typeof x=="undefined")throw new Ir("remote OR url");let S=f||await C.get(`branch.${_}.merge`);if(typeof x=="undefined")throw new Ir("remoteRef");v===void 0&&(v=await C.get("http.corsProxy"));let A=await q.expand({fs:t,gitdir:c,ref:_}),w=g?"0000000000000000000000000000000000000000":await q.resolve({fs:t,gitdir:c,ref:A}),E=el.getRemoteHelperFor({url:x}),y=await E.discover({http:r,onAuth:Sd({config:C,onAuth:s}),onAuthSuccess:a,onAuthFailure:Sd({config:C,onAuth:o}),corsProxy:v,service:"git-receive-pack",url:x,headers:b,protocolVersion:1}),P=y.auth,T;if(!S)T=A;else try{T=await q.expandAgainstMap({ref:S,map:y.refs})}catch(X){if(X instanceof Ve)T=S.startsWith("refs/")?S:`refs/heads/${S}`;else throw X}let I=y.refs.get(T)||"0000000000000000000000000000000000000000";if(l&&!await l({remote:d,url:x,localRef:{ref:g?"(delete)":A,oid:w},remoteRef:{ref:T,oid:I}}))throw new Ko;let L=!y.capabilities.has("no-thin"),H=new Set;if(!g){let X=[...y.refs.values()],G=new Set;if(I!=="0000000000000000000000000000000000000000"){let Be=await Qg({fs:t,cache:e,gitdir:c,oids:[w,I]});for(let pr of Be)X.push(pr);L&&(G=await Dg({fs:t,cache:e,gitdir:c,oids:Be}))}if(!X.includes(w)){let Be=await ZN({fs:t,cache:e,gitdir:c,start:[w],finish:X});H=await Dg({fs:t,cache:e,gitdir:c,oids:Be})}if(L){try{let Be=await q.resolve({fs:t,gitdir:c,ref:`refs/remotes/${d}/HEAD`,depth:2}),{oid:pr}=await q.resolveAgainstMap({ref:Be.replace(`refs/remotes/${d}/`,""),fullref:Be,map:y.refs}),Ut=[pr];for(let Ie of await Dg({fs:t,cache:e,gitdir:c,oids:Ut}))G.add(Ie)}catch(Be){}for(let Be of G)H.delete(Be)}if(w===I&&(p=!0),!p){if(A.startsWith("refs/tags")&&I!=="0000000000000000000000000000000000000000")throw new Zo("tag-exists");if(w!=="0000000000000000000000000000000000000000"&&I!=="0000000000000000000000000000000000000000"&&!await wS({fs:t,cache:e,gitdir:c,oid:w,ancestor:I,depth:-1}))throw new Zo("not-fast-forward")}}let te=fS([...y.capabilities],["report-status","side-band-64k",`agent=${Rd.agent}`]),xe=await XN({capabilities:te,triplets:[{oldoid:I,oid:w,fullRef:T}]}),Z=g?[]:await yS({fs:t,cache:e,gitdir:c,oids:[...H]}),K=await E.connect({http:r,onProgress:i,corsProxy:v,service:"git-receive-pack",url:x,auth:P,headers:b,body:[...xe,...Z]}),{packfile:ce,progress:pe}=await kd.demux(K.body);if(n){let X=dS(pe);hu(X,async G=>{await n(G)})}let W=await KN(ce);if(K.headers&&(W.headers=K.headers),d&&W.ok&&W.refs[T].ok&&!A.startsWith("refs/tags")){let X=`refs/remotes/${d}/${T.replace("refs/heads","")}`;g?await q.deleteRef({fs:t,gitdir:c,ref:X}):await q.writeRef({fs:t,gitdir:c,ref:X,value:w})}if(W.ok&&Object.values(W.refs).every(X=>X.ok))return W;{let X=Object.entries(W.refs).filter(([G,Be])=>!Be.ok).map(([G,Be])=>`
|
||||
- ${G}: ${Be.error}`).join("");throw new Qc(X,W)}}async function JN({fs:t,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:s,onAuthFailure:a,onPrePush:o,dir:l,gitdir:c=B(l,".git"),ref:u,remoteRef:f,remote:d="origin",url:h,force:p=!1,delete:g=!1,corsProxy:v,headers:b={},cache:_={}}){try{R("fs",t),R("http",e),R("gitdir",c);let C=new J(t),x=await re({fsp:C,dotgit:c});return await QN({fs:C,cache:_,http:e,onProgress:r,onMessage:i,onAuth:n,onAuthSuccess:s,onAuthFailure:a,onPrePush:o,gitdir:x,ref:u,remoteRef:f,remote:d,url:h,force:p,delete:g,corsProxy:v,headers:b})}catch(C){throw C.caller="git.push",C}}async function xS({fs:t,cache:e,gitdir:r,oid:i}){let{type:n,object:s}=await tt({fs:t,cache:e,gitdir:r,oid:i});if(n==="tag")return i=Jr.from(s).parse().object,xS({fs:t,cache:e,gitdir:r,oid:i});if(n!=="blob")throw new br(i,n,"blob");return{oid:i,blob:new Uint8Array(s)}}async function ES({fs:t,cache:e,gitdir:r,oid:i,filepath:n=void 0}){return n!==void 0&&(i=await fu({fs:t,cache:e,gitdir:r,oid:i,filepath:n})),await xS({fs:t,cache:e,gitdir:r,oid:i})}async function pu({fs:t,dir:e,gitdir:r=B(e,".git"),oid:i,filepath:n,cache:s={}}){try{R("fs",t),R("gitdir",r),R("oid",i);let a=new J(t),o=await re({fsp:a,dotgit:r});return await ES({fs:a,cache:s,gitdir:o,oid:i,filepath:n})}catch(a){throw a.caller="git.readBlob",a}}async function SS({fs:t,dir:e,gitdir:r=B(e,".git"),oid:i,cache:n={}}){try{R("fs",t),R("gitdir",r),R("oid",i);let s=new J(t),a=await re({fsp:s,dotgit:r});return await wn({fs:s,cache:n,gitdir:a,oid:i})}catch(s){throw s.caller="git.readCommit",s}}async function eB({fs:t,cache:e,gitdir:r,ref:i="refs/notes/commits",oid:n}){let s=await q.resolve({gitdir:r,fs:t,ref:i}),{blob:a}=await ES({fs:t,cache:e,gitdir:r,oid:s,filepath:n});return a}async function tB({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i="refs/notes/commits",oid:n,cache:s={}}){try{R("fs",t),R("gitdir",r),R("ref",i),R("oid",n);let a=new J(t),o=await re({fsp:a,dotgit:r});return await eB({fs:a,cache:s,gitdir:o,ref:i,oid:n})}catch(a){throw a.caller="git.readNote",a}}async function rB({fs:t,dir:e,gitdir:r=B(e,".git"),oid:i,format:n="parsed",filepath:s=void 0,encoding:a=void 0,cache:o={}}){try{R("fs",t),R("gitdir",r),R("oid",i);let l=new J(t),c=await re({fsp:l,dotgit:r});s!==void 0&&(i=await fu({fs:l,cache:o,gitdir:c,oid:i,filepath:s}));let f=await tt({fs:l,cache:o,gitdir:c,oid:i,format:n==="parsed"?"content":n});if(f.oid=i,n==="parsed")switch(f.format="parsed",f.type){case"commit":f.object=Dr.from(f.object).parse();break;case"tree":f.object=Mr.from(f.object).entries();break;case"blob":a?f.object=f.object.toString(a):(f.object=new Uint8Array(f.object),f.format="content");break;case"tag":f.object=Jr.from(f.object).parse();break;default:throw new br(f.oid,f.type,"blob|commit|tag|tree")}else(f.format==="deflated"||f.format==="wrapped")&&(f.type=f.format);return f}catch(l){throw l.caller="git.readObject",l}}async function iB({fs:t,cache:e,gitdir:r,oid:i}){let{type:n,object:s}=await tt({fs:t,cache:e,gitdir:r,oid:i,format:"content"});if(n!=="tag")throw new br(i,n,"tag");let a=Jr.from(s);return{oid:i,tag:a.parse(),payload:a.payload()}}async function nB({fs:t,dir:e,gitdir:r=B(e,".git"),oid:i,cache:n={}}){try{R("fs",t),R("gitdir",r),R("oid",i);let s=new J(t),a=await re({fsp:s,dotgit:r});return await iB({fs:s,cache:n,gitdir:a,oid:i})}catch(s){throw s.caller="git.readTag",s}}async function sB({fs:t,dir:e,gitdir:r=B(e,".git"),oid:i,filepath:n=void 0,cache:s={}}){try{R("fs",t),R("gitdir",r),R("oid",i);let a=new J(t),o=await re({fsp:a,dotgit:r});return await rl({fs:a,cache:s,gitdir:o,oid:i,filepath:n})}catch(a){throw a.caller="git.readTree",a}}async function aB({fs:t,dir:e,gitdir:r=B(e,".git"),filepath:i,cache:n={}}){try{R("fs",t),R("gitdir",r),R("filepath",i);let s=new J(t),a=await re({fsp:s,dotgit:r});await dt.acquire({fs:s,gitdir:a,cache:n},async function(o){o.delete({filepath:i})})}catch(s){throw s.caller="git.remove",s}}async function oB({fs:t,cache:e,onSign:r,gitdir:i,ref:n="refs/notes/commits",oid:s,author:a,committer:o,signingKey:l}){let c;try{c=await q.resolve({gitdir:i,fs:t,ref:n})}catch(p){if(!(p instanceof Ve))throw p}let f=(await rl({fs:t,cache:e,gitdir:i,oid:c||"4b825dc642cb6eb9a060e54bf8d69288fbee4904"})).tree;f=f.filter(p=>p.path!==s);let d=await du({fs:t,gitdir:i,tree:f});return await uu({fs:t,cache:e,onSign:r,gitdir:i,ref:n,tree:d,parent:c&&[c],message:`Note removed by 'isomorphic-git removeNote'
|
||||
`,author:a,committer:o,signingKey:l})}async function lB({fs:t,onSign:e,dir:r,gitdir:i=B(r,".git"),ref:n="refs/notes/commits",oid:s,author:a,committer:o,signingKey:l,cache:c={}}){try{R("fs",t),R("gitdir",i),R("oid",s);let u=new J(t),f=await re({fsp:u,dotgit:i}),d=await Ms({fs:u,gitdir:f,author:a});if(!d)throw new Kt("author");let h=await xa({fs:u,gitdir:f,author:d,committer:o});if(!h)throw new Kt("committer");return await oB({fs:u,cache:c,onSign:e,gitdir:f,ref:n,oid:s,author:d,committer:h,signingKey:l})}catch(u){throw u.caller="git.removeNote",u}}async function cB({fs:t,gitdir:e,oldref:r,ref:i,checkout:n=!1}){if(!au(i,!0))throw new ji(i,zo.default.clean(i));if(!au(r,!0))throw new ji(r,zo.default.clean(r));let s=`refs/heads/${r}`,a=`refs/heads/${i}`;if(await q.exists({fs:t,gitdir:e,ref:a}))throw new Gi("branch",i,!1);let l=await q.resolve({fs:t,gitdir:e,ref:s,depth:1});await q.writeRef({fs:t,gitdir:e,ref:a,value:l}),await q.deleteRef({fs:t,gitdir:e,ref:s});let u=await Ds({fs:t,gitdir:e,fullname:!0})===s;(n||u)&&await q.writeSymbolicRef({fs:t,gitdir:e,ref:"HEAD",value:a})}async function uB({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i,oldref:n,checkout:s=!1}){try{R("fs",t),R("gitdir",r),R("ref",i),R("oldref",n);let a=new J(t),o=await re({fsp:a,dotgit:r});return await cB({fs:a,gitdir:o,ref:i,oldref:n,checkout:s})}catch(a){throw a.caller="git.renameBranch",a}}async function kS({gitdir:t,type:e,object:r}){return bn($s.wrap({type:e,object:r}))}async function fB({fs:t,dir:e,gitdir:r=B(e,".git"),filepath:i,ref:n,cache:s={}}){try{R("fs",t),R("gitdir",r),R("filepath",i);let a=new J(t),o=await re({fsp:a,dotgit:r}),l,c;try{l=await q.resolve({fs:a,gitdir:o,ref:n||"HEAD"})}catch(d){if(n)throw d}if(l)try{l=await fu({fs:a,cache:s,gitdir:o,oid:l,filepath:i})}catch(d){l=null}let u={ctime:new Date(0),mtime:new Date(0),dev:0,ino:0,mode:0,uid:0,gid:0,size:0},f=e&&await a.read(B(e,i));f&&(c=await kS({gitdir:o,type:"blob",object:f}),l===c&&(u=await a.lstat(B(e,i)))),await dt.acquire({fs:a,gitdir:o,cache:s},async function(d){d.delete({filepath:i}),l&&d.insert({filepath:i,stats:u,oid:l})})}catch(a){throw a.caller="git.reset",a}}async function dB({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i,depth:n}){try{R("fs",t),R("gitdir",r),R("ref",i);let s=new J(t),a=await re({fsp:s,dotgit:r});return await q.resolve({fs:s,gitdir:a,ref:i,depth:n})}catch(s){throw s.caller="git.resolveRef",s}}async function hB({fs:t,dir:e,gitdir:r=B(e,".git"),path:i,value:n,append:s=!1}){try{R("fs",t),R("gitdir",r),R("path",i);let a=new J(t),o=await re({fsp:a,dotgit:r}),l=await ht.get({fs:a,gitdir:o});s?await l.append(i,n):await l.set(i,n),await ht.save({fs:a,gitdir:o,config:l})}catch(a){throw a.caller="git.setConfig",a}}async function CS({fs:t,gitdir:e,commit:r}){let i=Dr.from(r).toObject();return await Or({fs:t,gitdir:e,type:"commit",object:i,format:"content"})}var Cd=class t{static get timezoneOffsetForRefLogEntry(){let e=new Date().getTimezoneOffset(),r=Math.abs(Math.floor(e/60)),i=Math.abs(e%60).toString().padStart(2,"0");return`${e>0?"-":"+"}${r.toString().padStart(2,"0")}${i}`}static createStashReflogEntry(e,r,i){let n=e.name.replace(/\s/g,""),s="0000000000000000000000000000000000000000",a=Math.floor(Date.now()/1e3),o=t.timezoneOffsetForRefLogEntry;return`${s} ${r} ${n} ${e.email} ${a} ${o} ${i}
|
||||
`}static getStashReflogEntry(e,r=!1){return e.split(`
|
||||
`).filter(s=>s).reverse().map((s,a)=>r?`stash@{${a}}: ${s.split(" ")[1]}`:s)}},Sa=class t{constructor({fs:e,dir:r,gitdir:i=B(r,".git")}){Object.assign(this,{fs:e,dir:r,gitdir:i,_author:null})}static get refStash(){return"refs/stash"}static get refLogsStash(){return"logs/refs/stash"}get refStashPath(){return B(this.gitdir,t.refStash)}get refLogsStashPath(){return B(this.gitdir,t.refLogsStash)}async getAuthor(){if(!this._author&&(this._author=await Ms({fs:this.fs,gitdir:this.gitdir,author:{}}),!this._author))throw new Kt("author");return this._author}async getStashSHA(e,r){return await this.fs.exists(this.refStashPath)?(r||await this.readStashReflogs({parsed:!1}))[e].split(" ")[1]:null}async writeStashCommit({message:e,tree:r,parent:i}){return CS({fs:this.fs,gitdir:this.gitdir,commit:{message:e,tree:r,parent:i,author:await this.getAuthor(),committer:await this.getAuthor()}})}async readStashCommit(e){let r=await this.readStashReflogs({parsed:!1});if(e!==0&&(e<0||e>r.length-1))throw new ji(`stash@${e}`,"number that is in range of [0, num of stash pushed]");let i=await this.getStashSHA(e,r);return i?wn({fs:this.fs,cache:{},gitdir:this.gitdir,oid:i}):{}}async writeStashRef(e){return q.writeRef({fs:this.fs,gitdir:this.gitdir,ref:t.refStash,value:e})}async writeStashReflogEntry({stashCommit:e,message:r}){let i=await this.getAuthor(),n=Cd.createStashReflogEntry(i,e,r),s=this.refLogsStashPath;await Qo({filepath:s,entry:n},async()=>{let a=await this.fs.exists(s)?await this.fs.read(s,"utf8"):"";await this.fs.write(s,a+n,"utf8")})}async readStashReflogs({parsed:e=!1}){if(!await this.fs.exists(this.refLogsStashPath))return[];let r=await this.fs.read(this.refLogsStashPath,"utf8");return Cd.getStashReflogEntry(r,e)}};async function AS({fs:t,dir:e,gitdir:r,message:i=""}){let n=new Sa({fs:t,dir:e,gitdir:r});await n.getAuthor();let s=await Ds({fs:t,gitdir:r,fullname:!1}),a=await q.resolve({fs:t,gitdir:r,ref:"HEAD"}),l=(await SS({fs:t,dir:e,gitdir:r,oid:a})).commit.message,c=[a],u=null,f=Fr({ref:"HEAD"}),d=await FE({fs:t,dir:e,gitdir:r,treePair:[Fr({ref:"HEAD"}),"stage"]});if(d){let v=await n.writeStashCommit({message:`stash-Index: WIP on ${s} - ${new Date().toISOString()}`,tree:d,parent:c});c.push(v),u=d,f=tl()}let h=await FE({fs:t,dir:e,gitdir:r,treePair:[f,"workdir"]});if(h){let v=await n.writeStashCommit({message:`stash-WorkDir: WIP on ${s} - ${new Date().toISOString()}`,tree:h,parent:[c[c.length-1]]});c.push(v),u=h}if(!u||!d&&!h)throw new Ve("changes, nothing to stash");let p=(i.trim()||`WIP on ${s}`)+`: ${a.substring(0,7)} ${l}`;return{stashCommit:await n.writeStashCommit({message:p,tree:u,parent:c}),stashMsg:p,branch:s,stashMgr:n}}async function pB({fs:t,dir:e,gitdir:r,message:i=""}){let{stashCommit:n,stashMsg:s,branch:a,stashMgr:o}=await AS({fs:t,dir:e,gitdir:r,message:i});return await o.writeStashRef(n),await o.writeStashReflogEntry({stashCommit:n,message:s}),await oS({fs:t,dir:e,gitdir:r,ref:a,track:!1,force:!0}),n}async function mB({fs:t,dir:e,gitdir:r,message:i=""}){let{stashCommit:n}=await AS({fs:t,dir:e,gitdir:r,message:i});return n}async function TS({fs:t,dir:e,gitdir:r,refIdx:i=0}){let s=await new Sa({fs:t,dir:e,gitdir:r}).readStashCommit(i),{parent:a=null}=s.commit?s.commit:{};if(!(!a||!Array.isArray(a)))for(let o=0;o<a.length-1;o++){let c=(await wn({fs:t,cache:{},gitdir:r,oid:a[o+1]})).commit.message.startsWith("stash-Index");await cS({fs:t,dir:e,gitdir:r,stashCommit:a[o+1],parentCommit:a[o],wasStaged:c})}}async function PS({fs:t,dir:e,gitdir:r,refIdx:i=0}){let n=new Sa({fs:t,dir:e,gitdir:r});if(!(await n.readStashCommit(i)).commit)return;let a=n.refStashPath;await Qo(a,async()=>{await t.exists(a)&&await t.rm(a)});let o=await n.readStashReflogs({parsed:!1});if(!o.length)return;o.splice(i,1);let l=n.refLogsStashPath;await Qo({reflogEntries:o,stashReflogPath:l,stashMgr:n},async()=>{if(o.length){await t.write(l,o.reverse().join(`
|
||||
`)+`
|
||||
`,"utf8");let c=o[o.length-1].split(" ")[1];await n.writeStashRef(c)}else await t.rm(l)})}async function gB({fs:t,dir:e,gitdir:r}){return new Sa({fs:t,dir:e,gitdir:r}).readStashReflogs({parsed:!0})}async function vB({fs:t,dir:e,gitdir:r}){let i=new Sa({fs:t,dir:e,gitdir:r}),n=[i.refStashPath,i.refLogsStashPath];await Qo(n,async()=>{await Promise.all(n.map(async s=>{if(await t.exists(s))return t.rm(s)}))})}async function wB({fs:t,dir:e,gitdir:r,refIdx:i=0}){await TS({fs:t,dir:e,gitdir:r,refIdx:i}),await PS({fs:t,dir:e,gitdir:r,refIdx:i})}async function bB({fs:t,dir:e,gitdir:r=B(e,".git"),op:i="push",message:n="",refIdx:s=0}){R("fs",t),R("dir",e),R("gitdir",r),R("op",i);let a={push:pB,apply:TS,drop:PS,list:gB,clear:vB,pop:wB,create:mB},o=["apply","drop","pop"];try{let l=new J(t),c=await re({fsp:l,dotgit:r});["refs","logs","logs/refs"].map(d=>B(c,d)).forEach(async d=>{await l.exists(d)||await l.mkdir(d)});let f=a[i];if(f){if(o.includes(i)&&s<0)throw new ji(`stash@${s}`,"number that is in range of [0, num of stash pushed]");return await f({fs:l,dir:e,gitdir:c,message:n,refIdx:s})}throw new Error(`To be implemented: ${i}`)}catch(l){throw l.caller="git.stash",l}}async function _B({fs:t,dir:e,gitdir:r=B(e,".git"),filepath:i,cache:n={},refresh:s=!0}){try{R("fs",t),R("gitdir",r),R("filepath",i);let a=new J(t),o=await re({fsp:a,dotgit:r});if(await Is.isIgnored({fs:a,gitdir:o,dir:e,filepath:i}))return"ignored";let c=await yB({fs:a,cache:n,gitdir:o}),u=await RS({fs:a,cache:n,gitdir:o,tree:c,path:i}),f=await dt.acquire({fs:a,gitdir:o,cache:n},async function(b){for(let _ of b)if(_.path===i)return _;return null}),d=await a.lstat(B(e,i)),h=u!==null,p=f!==null,g=d!==null,v=async()=>{if(p&&!gd(f,d))return f.oid;{let b=await a.read(B(e,i)),_=await kS({gitdir:o,type:"blob",object:b});return s&&p&&f.oid===_&&d.size!==-1&&dt.acquire({fs:a,gitdir:o,cache:n},async function(C){C.insert({filepath:i,stats:d,oid:_})}),_}};if(!h&&!g&&!p)return"absent";if(!h&&!g&&p)return"*absent";if(!h&&g&&!p)return"*added";if(!h&&g&&p)return await v()===f.oid?"added":"*added";if(h&&!g&&!p)return"deleted";if(h&&!g&&p)return u===f.oid,"*deleted";if(h&&g&&!p)return await v()===u?"*undeleted":"*undeletemodified";if(h&&g&&p){let b=await v();return b===u?b===f.oid?"unmodified":"*unmodified":b===f.oid?"modified":"*modified"}}catch(a){throw a.caller="git.status",a}}async function RS({fs:t,cache:e,gitdir:r,tree:i,path:n}){typeof n=="string"&&(n=n.split("/"));let s=n.shift();for(let a of i)if(a.path===s){if(n.length===0)return a.oid;let{type:o,object:l}=await tt({fs:t,cache:e,gitdir:r,oid:a.oid});if(o==="tree"){let c=Mr.from(l);return RS({fs:t,cache:e,gitdir:r,tree:c,path:n})}if(o==="blob")throw new br(a.oid,o,"blob",n.join("/"))}return null}async function yB({fs:t,cache:e,gitdir:r}){let i;try{i=await q.resolve({fs:t,gitdir:r,ref:"HEAD"})}catch(s){if(s instanceof Ve)return[]}let{tree:n}=await rl({fs:t,cache:e,gitdir:r,oid:i});return n}async function xB({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i="HEAD",filepaths:n=["."],filter:s,cache:a={},ignored:o=!1,refresh:l=!0}){try{R("fs",t),R("gitdir",r),R("ref",i);let c=new J(t),u=await re({fsp:c,dotgit:r});return await Zn({fs:c,cache:a,dir:e,gitdir:u,trees:[Fr({ref:i}),cu({refresh:l}),tl()],map:async function(f,[d,h,p]){if(!d&&!p&&h&&!o&&await Is.isIgnored({fs:c,dir:e,filepath:f})||!n.some(E=>aS(f,E)))return null;if(s&&!s(f))return;let[g,v,b]=await Promise.all([d&&d.type(),h&&h.type(),p&&p.type()]),_=[g,v,b].includes("blob");if((g==="tree"||g==="special")&&!_)return;if(g==="commit")return null;if((v==="tree"||v==="special")&&!_)return;if(b==="commit")return null;if((b==="tree"||b==="special")&&!_)return;let C=g==="blob"?await d.oid():void 0,x=b==="blob"?await p.oid():void 0,S;g!=="blob"&&v==="blob"&&b!=="blob"?S="42":v==="blob"&&(S=await h.oid());let A=[void 0,C,S,x],w=A.map(E=>A.indexOf(E));return w.shift(),[f,...w]}})}catch(c){throw c.caller="git.statusMatrix",c}}async function EB({fs:t,dir:e,gitdir:r=B(e,".git"),ref:i,object:n,force:s=!1}){try{R("fs",t),R("gitdir",r),R("ref",i);let a=new J(t);if(i===void 0)throw new Ir("ref");i=i.startsWith("refs/tags/")?i:`refs/tags/${i}`;let o=await re({fsp:a,dotgit:r}),l=await q.resolve({fs:a,gitdir:o,ref:n||"HEAD"});if(!s&&await q.exists({fs:a,gitdir:o,ref:i}))throw new Gi("tag",i);await q.writeRef({fs:a,gitdir:o,ref:i,value:l})}catch(a){throw a.caller="git.tag",a}}async function SB({fs:t,dir:e,gitdir:r=B(e,".git"),cache:i={},filepath:n,oid:s,mode:a,add:o,remove:l,force:c}){try{R("fs",t),R("gitdir",r),R("filepath",n);let u=new J(t),f=await re({fsp:u,dotgit:r});if(l)return await dt.acquire({fs:u,gitdir:f,cache:i},async function(h){if(!c){let p=await u.lstat(B(e,n));if(p){if(p.isDirectory())throw new Fs("directory");return}}h.has({filepath:n})&&h.delete({filepath:n})});let d;if(!s){if(d=await u.lstat(B(e,n)),!d)throw new Ve(`file at "${n}" on disk and "remove" not set`);if(d.isDirectory())throw new Fs("directory")}return await dt.acquire({fs:u,gitdir:f,cache:i},async function(h){if(!o
Line truncated
|
||||
|
||||
PROMPT="$1"
|
||||
TEMP_FILE="$OBSIDIAN_GIT_CREDENTIALS_INPUT"
|
||||
|
||||
cleanup() {
|
||||
rm -f "$TEMP_FILE" "$TEMP_FILE.response"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "$PROMPT" > "$TEMP_FILE"
|
||||
|
||||
while [ ! -e "$TEMP_FILE.response" ]; do
|
||||
if [ ! -e "$TEMP_FILE" ]; then
|
||||
echo "Trigger file got removed: Abort" >&2
|
||||
exit 1
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
|
||||
RESPONSE=$(cat "$TEMP_FILE.response")
|
||||
|
||||
echo "$RESPONSE"
|
||||
`,IS=["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"];m();m();m();var mu=class{diff(e,r,i={}){let n;typeof i=="function"?(n=i,i={}):"callback"in i&&(n=i.callback);let s=this.castInput(e,i),a=this.castInput(r,i),o=this.removeEmpty(this.tokenize(s,i)),l=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(o,l,i,n)}diffWithOptionsObj(e,r,i,n){var s;let a=_=>{if(_=this.postProcess(_,i),n){setTimeout(function(){n(_)},0);return}else return _},o=r.length,l=e.length,c=1,u=o+l;i.maxEditLength!=null&&(u=Math.min(u,i.maxEditLength));let f=(s=i.timeout)!==null&&s!==void 0?s:1/0,d=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(h[0],r,e,0,i);if(h[0].oldPos+1>=l&&p+1>=o)return a(this.buildValues(h[0].lastComponent,r,e));let g=-1/0,v=1/0,b=()=>{for(let _=Math.max(g,-c);_<=Math.min(v,c);_+=2){let C,x=h[_-1],S=h[_+1];x&&(h[_-1]=void 0);let A=!1;if(S){let E=S.oldPos-_;A=S&&0<=E&&E<o}let w=x&&x.oldPos+1<l;if(!A&&!w){h[_]=void 0;continue}if(!w||A&&x.oldPos<S.oldPos?C=this.addToPath(S,!0,!1,0,i):C=this.addToPath(x,!1,!0,1,i),p=this.extractCommon(C,r,e,_,i),C.oldPos+1>=l&&p+1>=o)return a(this.buildValues(C.lastComponent,r,e))||!0;h[_]=C,C.oldPos+1>=l&&(v=Math.min(v,_-1)),p+1>=o&&(g=Math.max(g,_+1))}c++};if(n)(function _(){setTimeout(function(){if(c>u||Date.now()>d)return n(void 0);b()||_()},0)})();else for(;c<=u&&Date.now()<=d;){let _=b();if(_)return _}}addToPath(e,r,i,n,s){let a=e.lastComponent;return a&&!s.oneChangePerToken&&a.added===r&&a.removed===i?{oldPos:e.oldPos+n,lastComponent:{count:a.count+1,added:r,removed:i,previousComponent:a.previousComponent}}:{oldPos:e.oldPos+n,lastComponent:{count:1,added:r,removed:i,previousComponent:a}}}extractCommon(e,r,i,n,s){let a=r.length,o=i.length,l=e.oldPos,c=l-n,u=0;for(;c+1<a&&l+1<o&&this.equals(i[l+1],r[c+1],s);)c++,l++,u++,s.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return u&&!s.oneChangePerToken&&(e.lastComponent={count:u,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=l,c}equals(e,r,i){return i.comparator?i.comparator(e,r):e===r||!!i.ignoreCase&&e.toLowerCase()===r.toLowerCase()}removeEmpty(e){let r=[];for(let i=0;i<e.length;i++)e[i]&&r.push(e[i]);return r}castInput(e,r){return e}tokenize(e,r){return Array.from(e)}join(e){return e.join("")}postProcess(e,r){return e}get useLongestToken(){return!1}buildValues(e,r,i){let n=[],s;for(;e;)n.push(e),s=e.previousComponent,delete e.previousComponent,e=s;n.reverse();let a=n.length,o=0,l=0,c=0;for(;o<a;o++){let u=n[o];if(u.removed)u.value=this.join(i.slice(c,c+u.count)),c+=u.count;else{if(!u.added&&this.useLongestToken){let f=r.slice(l,l+u.count);f=f.map(function(d,h){let p=i[c+h];return p.length>d.length?p:d}),u.value=this.join(f)}else u.value=this.join(r.slice(l,l+u.count));l+=u.count,u.added||(c+=u.count)}}return n}};m();var tv=class extends mu{constructor(){super(...arguments),this.tokenize=OB}equals(e,r,i){return i.ignoreWhitespace?((!i.newlineIsToken||!e.includes(`
|
||||
`))&&(e=e.trim()),(!i.newlineIsToken||!r.includes(`
|
||||
`))&&(r=r.trim())):i.ignoreNewlineAtEof&&!i.newlineIsToken&&(e.endsWith(`
|
||||
`)&&(e=e.slice(0,-1)),r.endsWith(`
|
||||
`)&&(r=r.slice(0,-1))),super.equals(e,r,i)}},DB=new tv;function rv(t,e,r){return DB.diff(t,e,r)}function OB(t,e){e.stripTrailingCr&&(t=t.replace(/\r\n/g,`
|
||||
`));let r=[],i=t.split(/(\n|\r\n)/);i[i.length-1]||i.pop();for(let n=0;n<i.length;n++){let s=i[n];n%2&&!e.newlineIsToken?r[r.length-1]+=s:r.push(s)}return r}m();function LB(t){for(let e=0;e<t.length;e++)if(t[e]<" "||t[e]>"~"||t[e]==='"'||t[e]==="\\")return!0;return!1}function Ns(t){if(!LB(t))return t;let e='"',r=new TextEncoder().encode(t),i=0;for(;i<r.length;){let n=r[i];n===7?e+="\\a":n===8?e+="\\b":n===9?e+="\\t":n===10?e+="\\n":n===11?e+="\\v":n===12?e+="\\f":n===13?e+="\\r":n===34?e+='\\"':n===92?e+="\\\\":n>=32&&n<=126?e+=String.fromCharCode(n):e+="\\"+n.toString(8).padStart(3,"0"),i++}return e+='"',e}var iv={includeIndex:!0,includeUnderline:!0,includeFileHeaders:!0};function nv(t,e,r,i,n,s,a){let o;a?typeof a=="function"?o={callback:a}:o=a:o={},typeof o.context=="undefined"&&(o.context=4);let l=o.context;if(o.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(o.callback){let{callback:u}=o;rv(r,i,Object.assign(Object.assign({},o),{callback:f=>{let d=c(f);u(d)}}))}else return c(rv(r,i,o));function c(u){if(!u)return;u.push({value:"",lines:[]});function f(_){return _.map(function(C){return" "+C})}let d=[],h=0,p=0,g=[],v=1,b=1;for(let _=0;_<u.length;_++){let C=u[_],x=C.lines||NB(C.value);if(C.lines=x,C.added||C.removed){if(!h){let S=u[_-1];h=v,p=b,S&&(g=l>0?f(S.lines.slice(-l)):[],h-=g.length,p-=g.length)}for(let S of x)g.push((C.added?"+":"-")+S);C.added?b+=x.length:v+=x.length}else{if(h)if(x.length<=l*2&&_<u.length-2)for(let S of f(x))g.push(S);else{let S=Math.min(x.length,l);for(let w of f(x.slice(0,S)))g.push(w);let A={oldStart:h,oldLines:v-h+S,newStart:p,newLines:b-p+S,lines:g};d.push(A),h=0,p=0,g=[]}v+=x.length,b+=x.length}}for(let _ of d)for(let C=0;C<_.lines.length;C++)_.lines[C].endsWith(`
|
||||
`)?_.lines[C]=_.lines[C].slice(0,-1):(_.lines.splice(C+1,0,"\\ No newline at end of file"),C++);return{oldFileName:t,newFileName:e,oldHeader:n,newHeader:s,hunks:d}}}function Od(t,e){var r,i,n,s,a,o;if(e||(e=iv),Array.isArray(t)){if(t.length>1&&!e.includeFileHeaders&&!t.every(u=>u.isGit))throw new Error("Cannot omit file headers on a multi-file patch. (The result would be unparseable; how would a tool trying to apply the patch know which changes are to which file?)");return t.map(u=>Od(u,e)).join(`
|
||||
`)}let l=[];if(t.isGit){if(e=iv,!t.oldFileName)throw new Error("oldFileName must be specified for Git patches");if(!t.newFileName)throw new Error("newFileName must be specified for Git patches");let u=t.oldFileName,f=t.newFileName;t.isCreate&&u==="/dev/null"?u=f.replace(/^b\//,"a/"):t.isDelete&&f==="/dev/null"&&(f=u.replace(/^a\//,"b/")),l.push("diff --git "+Ns(u)+" "+Ns(f)),t.isDelete&&l.push("deleted file mode "+((r=t.oldMode)!==null&&r!==void 0?r:"100644")),t.isCreate&&l.push("new file mode "+((i=t.newMode)!==null&&i!==void 0?i:"100644")),t.oldMode&&t.newMode&&!t.isDelete&&!t.isCreate&&(l.push("old mode "+t.oldMode),l.push("new mode "+t.newMode)),t.isRename&&(l.push("rename from "+Ns(((n=t.oldFileName)!==null&&n!==void 0?n:"").replace(/^a\//,""))),l.push("rename to "+Ns(((s=t.newFileName)!==null&&s!==void 0?s:"").replace(/^b\//,"")))),t.isCopy&&(l.push("copy from "+Ns(((a=t.oldFileName)!==null&&a!==void 0?a:"").replace(/^a\//,""))),l.push("copy to "+Ns(((o=t.newFileName)!==null&&o!==void 0?o:"").replace(/^b\//,""))))}else e.includeIndex&&t.oldFileName==t.newFileName&&t.oldFileName!==void 0&&l.push("Index: "+t.oldFileName),e.includeUnderline&&l.push("===================================================================");let c=t.hunks.length>0;e.includeFileHeaders&&t.oldFileName!==void 0&&t.newFileName!==void 0&&(!t.isGit||c)&&(l.push("--- "+Ns(t.oldFileName)+(t.oldHeader?" "+t.oldHeader:"")),l.push("+++ "+Ns(t.newFileName)+(t.newHeader?" "+t.newHeader:"")));for(let u=0;u<t.hunks.length;u++){let f=t.hunks[u],d=f.oldLines===0?f.oldStart-1:f.oldStart,h=f.newLines===0?f.newStart-1:f.newStart;l.push("@@ -"+d+","+f.oldLines+" +"+h+","+f.newLines+" @@");for(let p of f.lines)l.push(p)}return l.join(`
|
||||
`)+`
|
||||
`}function MS(t,e,r,i,n,s,a){if(typeof a=="function"&&(a={callback:a}),a!=null&&a.callback){let{callback:o}=a;nv(t,e,r,i,n,s,Object.assign(Object.assign({},a),{callback:l=>{o(l?Od(l,a.headerOptions):void 0)}}))}else{let o=nv(t,e,r,i,n,s,a);return o?Od(o,a==null?void 0:a.headerOptions):void 0}}function gu(t,e,r,i,n,s){return MS(t,t,e,r,i,n,s)}function NB(t){let e=t.endsWith(`
|
||||
`),r=t.split(`
|
||||
`).map(i=>i+`
|
||||
`);return e?r.pop():r.push(r.pop().slice(0,-1)),r}var En=require("obsidian");m();function DS(t,e){let r=Object.assign({},t.lineAuthor,e.lineAuthor);return Object.assign({},t,e,{lineAuthor:r})}var nl=class extends Error{constructor(r){super("No network connection available");this.originalError=r}};m();var OS=require("obsidian"),BB={options:[],placeholder:"",allowEmpty:!1,onlySelection:!1,initialValue:void 0,obscure:!1},rt=class extends OS.SuggestModal{constructor(e,r){if(super(e.app),this.config={...BB,...r},this.setPlaceholder(this.config.placeholder),this.config.obscure){this.inputEl.type="password";let i=this.containerEl.querySelector(".prompt-input-container");i.addClass("git-obscure-prompt"),i.setAttr("git-is-obscured","true");let n=i==null?void 0:i.createDiv({cls:"search-input-clear-button"});n.style.marginRight="32px",n.id="git-show-password",n.addEventListener("click",()=>{i.getAttr("git-is-obscured")==="true"?(this.inputEl.type="text",i.setAttr("git-is-obscured","false")):(this.inputEl.type="password",i.setAttr("git-is-obscured","true"))})}}openAndGetResult(){return new Promise(e=>{this.resolve=e,this.open(),this.config.initialValue!=null&&(this.inputEl.value=this.config.initialValue,this.inputEl.dispatchEvent(new Event("input")))})}onClose(){new Promise(e=>window.setTimeout(e,10)).then(()=>{this.resolve&&this.resolve(void 0)})}getSuggestions(e){return this.config.onlySelection?this.config.options:this.config.allowEmpty?[e.length>0?e:" ",...this.config.options]:[e.length>0?e:"...",...this.config.options]}renderSuggestion(e,r){this.config.obscure?r.hide():r.setText(e)}onChooseSuggestion(e,r){if(this.resolve){let i;this.config.allowEmpty&&e===" "?i="":e==="..."?i=void 0:i=e,this.resolve(i)}}};m();var tk=ft(ek(),1),rk=require("child_process"),Xn=require("obsidian");function Nd(t){throw new Error(`Unexpected object: ${t}`)}function wu(t,e,r){return t===1?`${t} ${e}`:`${t} ${r!=null?r:e+"s"}`}var ov=(t,e)=>t==="."||e==null||e.length===0||e==="."?!0:e.length>=t.length?e.startsWith(t):t.startsWith(e);function Vi(t,e){let r;if(e){if(e.button===0||e.button===1){let i=Xn.Keymap.isModEvent(e);r=t.workspace.getLeaf(i)}}else r=t.workspace.getLeaf(!1);return r}function _n(t,e,r,i,n){if(e.button==2){let s=t.vault.getAbstractFileByPath(r);if(s!=null){let a=new Xn.Menu;t.workspace.trigger("file-menu",a,s,n,i),a.showAtPosition({x:e.pageX,y:e.pageY})}else{let a=new Xn.Menu;t.workspace.trigger("obsidian-git:menu",a,r,n,i),a.showAtPosition({x:e.pageX,y:e.pageY})}}}function Bs(t){throw new Error("Impossible branch: "+t)}function lv(t){return`rgb(${t.r},${t.g},${t.b})`}function ik(t){var s;let e=(s=tk.fromString(t))==null?void 0:s.toRgbaArray();if(e===void 0)return;let[r,i,n]=e;return{r,g:i,b:n}}function nk(t){return t.diff(Xn.moment.unix(0),"seconds")}function sk(t){if(t.length!==0)return t.slice().sort()[Math.floor(t.length/2)]}function bu(t,e){return new Proxy(t,{get(r,i){return i==="length"?Math.min(e,r.length):r[i]}})}function ak(t,e,r){return t.length<=e?new Array(e-t.length).fill(r).join("")+t:t.substring(t.length-e)}function ok(t,e){if(e<=0)return t;let r=new Array(e).fill(" ").join(""),i=t.substring(e,t.length);return r+i}function cv(t,e,r){return t<=e&&e<=r}function yn(t){let[e,...r]=t.split("/");return[e!=null?e:"",r.length===0?void 0:r.join("/")]}function xn(t){return t.endsWith("/")?t:t.split("/").last().replace(/\.md$/,"")}function lk(t){return t===1?"1 minute":`${t} minutes`}function e3(t){let e=t.lastIndexOf(".");return t.substring(e+1)}function al(t){if(t.endsWith(".md"))return!1;let e=e3(t);return IS.includes(e)}function uv(t){return(t.startsWith("https://github.com/")||t.startsWith("https://gitlab.com/"))&&(t.endsWith(".git")||(t=t+".git")),t}function ol(t,e){let r=e.vault.getAbstractFileByPath(t);if(!(r instanceof Xn.TFile))return!1;try{return!!e.viewRegistry.getTypeByExtension(r.extension)}catch(i){return!0}}function ck({isFolder:t,gitRelativePath:e}){let r="/";return r+=e,t&&(r+="/"),r.replace(/([\\!#*?[\]])/g,String.raw`\$1`).replace(/\s(?=\s*$)/g,String.raw`\ `)}function ll(t,e,r,i){let n=e.target;t.workspace.trigger("hover-link",{event:e,source:r.getViewType(),hoverParent:r,targetEl:n,linktext:i})}function _u(t,e,r={}){return new Promise((i,n)=>{let s=(0,rk.spawn)(t,e,r),a="",o="";s.stdout.on("data",l=>{a+=l.toString()}),s.stderr.on("data",l=>{o+=l.toString()}),s.on("error",l=>{i({error:new Error(l.message),stdout:a,stderr:o,code:1})}),s.on("close",l=>{i({stdout:a,stderr:o,code:l!=null?l:1,error:void 0})})})}m();var uk=require("os"),Hd=require("obsidian");var cl=class{constructor(e){this.plugin=e,this.app=e.app}async withGitOperation(e,r){var i;this.plugin.setPluginState({operation:e});try{return await r()}finally{(i=this.plugin.statusBar)==null||i.clearProgress(!1),this.plugin.setPluginState({operation:0})}}getRelativeVaultPath(e){return this.plugin.settings.basePath?e===""||e==="."?this.plugin.settings.basePath:this.plugin.settings.basePath+"/"+e:e}getRelativeRepoPath(e,r=!0){if(r){let i=this.p
Line truncated
|
||||
`):n="Too many files to list",e=e+`
|
||||
|
||||
Affected files:
|
||||
`+n}return e}};m();var bi=require("obsidian"),Ud=class{constructor(e,r){this.plugin=r;this.promises={};this.adapter=e.adapter,this.vault=e,this.lastBasePath=this.plugin.settings.basePath,this.promises.readFile=this.readFile.bind(this),this.promises.writeFile=this.writeFile.bind(this),this.promises.readdir=this.readdir.bind(this),this.promises.mkdir=this.mkdir.bind(this),this.promises.rmdir=this.rmdir.bind(this),this.promises.stat=this.stat.bind(this),this.promises.unlink=this.unlink.bind(this),this.promises.lstat=this.lstat.bind(this),this.promises.readlink=this.readlink.bind(this),this.promises.symlink=this.symlink.bind(this)}async readFile(e,r){var n;if(this.maybeLog("Read: "+e+JSON.stringify(r)),(typeof r=="string"?r:r==null?void 0:r.encoding)==="utf8"){let s=this.vault.getAbstractFileByPath(e);return s instanceof bi.TFile?(this.maybeLog("Reuse"),this.vault.read(s)):this.adapter.read(e)}else{if(this.isIndexPath(e))return this.plugin.settings.basePath!=this.lastBasePath?(this.clearIndex(),this.lastBasePath=this.plugin.settings.basePath,this.adapter.readBinary(e)):(n=this.index)!=null?n:this.adapter.readBinary(e);let s=this.vault.getAbstractFileByPath(e);return s instanceof bi.TFile?(this.maybeLog("Reuse"),this.vault.readBinary(s)):this.adapter.readBinary(e)}}async writeFile(e,r){var i;if(this.maybeLog("Write: "+e),typeof r=="string"){let n=this.vault.getAbstractFileByPath(e);if(n instanceof bi.TFile)return this.vault.modify(n,r);if(!this.isHiddenPath(e))await this.vault.create(e,r);else return this.adapter.write(e,r)}else{let n=t3(r);if(this.isIndexPath(e)){this.index=n;let s=Date.now();(i=this.indexctime)!=null||(this.indexctime=s),this.indexmtime=s}else{let s=this.vault.getAbstractFileByPath(e);if(s instanceof bi.TFile)return this.vault.modifyBinary(s,n);if(!this.isHiddenPath(e))await this.vault.createBinary(e,n);else return this.adapter.writeBinary(e,n)}}}async readdir(e){e==="."&&(e="/");let r=await this.adapter.list(e),i=[...r.files,...r.folders],n;return e!=="/"?n=i.map(s=>(0,bi.normalizePath)(s.substring(e.length))):n=i,n}async mkdir(e){if(!(e==="."||e==="/")){if(!this.isHiddenPath(e)){if(this.vault.getFolderByPath(e))return;await this.vault.createFolder(e);return}return this.adapter.mkdir(e)}}async rmdir(e,r){var i,n;if(!this.isHiddenPath(e)){let s=this.vault.getAbstractFileByPath(e);if(s instanceof bi.TFolder){await this.vault.delete(s,(r==null?void 0:r.recursive)===!0||((i=r==null?void 0:r.options)==null?void 0:i.recursive)===!0);return}}return this.adapter.rmdir(e,(r==null?void 0:r.recursive)===!0||((n=r==null?void 0:r.options)==null?void 0:n.recursive)===!0)}async stat(e){if(this.isIndexPath(e)){if(this.index!==void 0&&this.indexctime!=null&&this.indexmtime!=null)return{isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1,size:this.index.byteLength,type:"file",ctimeMs:this.indexctime,mtimeMs:this.indexmtime};{let i=await this.adapter.stat(e);if(i==null)throw{code:"ENOENT"};return this.indexctime=i.ctime,this.indexmtime=i.mtime,{ctimeMs:i.ctime,mtimeMs:i.mtime,size:i.size,type:"file",isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1}}}e==="."&&(e="/");let r=this.vault.getAbstractFileByPath(e);if(this.maybeLog("Stat: "+e),r instanceof bi.TFile)return this.maybeLog("Reuse stat"),{ctimeMs:r.stat.ctime,mtimeMs:r.stat.mtime,size:r.stat.size,type:"file",isFile:()=>!0,isDirectory:()=>!1,isSymbolicLink:()=>!1};{let i=await this.adapter.stat(e);if(i)return{ctimeMs:i.ctime,mtimeMs:i.mtime,size:i.size,type:i.type==="folder"?"directory":i.type,isFile:()=>i.type==="file",isDirectory:()=>i.type==="folder",isSymbolicLink:()=>!1};throw{code:"ENOENT"}}}async unlink(e){if(!this.isHiddenPath(e)){let r=this.vault.getAbstractFileByPath(e);if(r instanceof bi.TFile)return this.vault.delete(r)}return this.adapter.remove(e)}async lstat(e){return this.stat(e)}async readlink(e){throw new Error(`readlink of (${e}) is not implemented.`)}async symlink(e){throw new Error(`symlink of (${e}) is not implemented.`)}async saveAndClear(){this.index!==void 0&&await this.adapter.writeBinary(this.getIndexPath(),this.index,{ctime:this.indexctime,mtime:this.indexmtime}),this.clearIndex()}clearIndex(){this.index=void 0,this.indexctime=void 0,this.indexmtime=void 0}get gitDir(){return this.plugin.settings.gitDir||".git"}getIndexPath(){return this.plugin.gitManager.getRelativeVaultPath(this.gitDir+"/index")}isIndexPath(e){return e===this.getIndexPath()}isHiddenPath(e){return e.startsWith(this.gitDir)?!0:(0,bi.normalizePath)(e).split("/").some(r=>r.startsWith(".")&&r!==".")}maybeLog(e){}};function t3(t){return t instanceof ArrayBuffer?t:t.buffer instanceof ArrayBuffer&&t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:new Uint8Array(t.buffer,t.byteOffset,t.byteLength).slice().buffer}var gk=ft(mk(),1),zi=class extends cl{constructor(r){super(r);this.FILE=0;this.HEAD=1;this.WORKDIR=2;this.STAGE=3;this.status_mapping={"000":" ","003":"AD","020":"??","022":"A ","023":"AM",100:"D ",101:" D",103:"MD",110:"DA",111:" ",113:"M
Line truncated
|
||||
|
||||
`);return{message:(c=l[0])!=null?c:"",author:{name:o.commit.author.name,email:o.commit.author.email},body:l.slice(1).join(`
|
||||
|
||||
`),date:new Date(o.commit.committer.timestamp).toDateString(),diff:{changed:0,files:(await this.getFileChangesCount(o.commit.parent.first(),o.oid)).map(u=>({path:u.path,status:u.type,vaultPath:this.getRelativeVaultPath(u.path),hash:o.oid}))},hash:o.oid,refs:[]}}))}updateBasePath(r){return this.getRepo().dir=r,Promise.resolve()}getGitDirPath(){return(0,En.normalizePath)(this.getRelativeVaultPath(this.plugin.settings.gitDir||".git"))}async updateUpstreamBranch(r){let[i,n]=yn(r),s=await this.branchInfo();await this.wrapFS(de.push({...this.getRepo(),remote:i,remoteRef:n})),await this.setConfig(`branch.${s.current}.merge`,`refs/heads/${n}`)}updateGitPath(r){return Promise.resolve()}async getFileChangesCount(r,i){return this.walkDifference({walkers:[de.TREE({ref:r}),de.TREE({ref:i})]})}async walkDifference({walkers:r,dir:i}){return await this.wrapFS(de.walk({...this.getRepo(),trees:r,map:async function(s,[a,o]){if(!ov(s,i))return null;if(await(a==null?void 0:a.type())==="tree"||await(o==null?void 0:o.type())==="tree")return;let l=await(a==null?void 0:a.oid()),c=await(o==null?void 0:o.oid()),u="equal";if(l!==c&&(u="M"),l===void 0&&(u="A"),c===void 0&&(u="D"),l===void 0&&c===void 0&&(console.log("Something weird happened:"),console.log(a),console.log(o)),u!=="equal")return{path:s,type:u}}}))}async getStagedFiles(r="."){return(await this.walkDifference({walkers:[de.TREE({ref:"HEAD"}),de.STAGE()],dir:r})).map(n=>({vaultPath:this.getRelativeVaultPath(n.path),path:n.path}))}async getUnstagedFiles(r="."){let i,n=window.setTimeout(()=>{i=new En.Notice("This takes longer: Getting status",this.noticeLength)},2e4);try{let s=this.getRepo(),a=await this.wrapFS(de.walk({...s,trees:[de.WORKDIR(),de.STAGE()],map:async function(o,[l,c]){if(!c&&l&&await de.isIgnored({...s,filepath:o})||!ov(o,r))return null;let[u,f]=await Promise.all([l&&l.type(),c&&c.type()]),d=[u,f].includes("blob");if((u==="tree"||u==="special")&&!d)return;if(f==="commit")return null;if((f==="tree"||f==="special")&&!d)return;let h=f==="blob"?await c.oid():void 0,p;return u==="blob"&&f!=="blob"?p="42":u==="blob"&&(p=await l.oid()),p?h?p!==h?{path:o,type:"M"}:null:{path:o,type:"A"}:{path:o,type:"D"}}}));return window.clearTimeout(n),i==null||i.hide(),a}catch(s){throw window.clearTimeout(n),i==null||i.hide(),this.plugin.displayError(s),s}}async getDiffString(r,i=!1,n){let s=this.getRelativeVaultPath(r),a=async(c,[u])=>{if(r==c){let f=await u.oid();return(await de.readBlob({...this.getRepo(),oid:f})).blob}};if(n){let c=await pu({...this.getRepo(),filepath:r,oid:n}).then(p=>new TextDecoder().decode(p.blob)).catch(p=>{if(!(p instanceof de.Errors.NotFoundError))throw p}),f=(await de.readCommit({...this.getRepo(),oid:n})).commit.parent.first(),d;return f&&(d=await pu({...this.getRepo(),filepath:r,oid:f}).then(p=>new TextDecoder().decode(p.blob)).catch(p=>{if(!(p instanceof de.Errors.NotFoundError))throw p})),gu(s,d!=null?d:"",c!=null?c:"")}let o=(await de.walk({...this.getRepo(),trees:[de.STAGE()],map:a})).first(),l=new TextDecoder().decode(o);if(i){let c=await this.resolveRef("HEAD").then(f=>pu({...this.getRepo(),filepath:r,oid:f})).then(f=>new TextDecoder().decode(f.blob)).catch(f=>{if(!(f instanceof de.Errors.NotFoundError))throw f});return gu(s,c!=null?c:"",l)}else{let c;return await this.app.vault.adapter.exists(s)?c=await this.app.vault.adapter.read(s):c="",gu(s,l,c)}}async getLastCommitTime(){let r=this.getRepo(),i=await this.resolveRef("HEAD"),s=(await de.readCommit({...r,oid:i})).commit.committer.timestamp;return new Date(s*1e3)}getFileStatusResult(r){var n,s;let i=this.status_mapping[`${r[this.HEAD]}${r[this.WORKDIR]}${r[this.STAGE]}`];return{index:i[0]=="?"?"U":(n=i[0])!=null?n:" ",workingDir:i[1]=="?"?"U":(s=i[1])!=null?s:" ",path:r[this.FILE],vaultPath:this.getRelativeVaultPath(r[this.FILE])}}async checkAuthorInfo(){let r=await this.getConfig("user.name"),i=await this.getConfig("user.email");if(!r||!i)throw Error("Git author name and email are not set. Please set both fields in the settings.")}showNotice(r,i=!0){if(!this.plugin.settings.disablePopups)return new En.Notice(r,i?this.noticeLength:void 0)}};async function*n3(t){yield new Uint8Array(t)}async function s3(t){let e=new ReadableStream({async start(i){for await(let n of t)i.enqueue(n);i.close()}});return await new Response(e).arrayBuffer()}async function a3(t){let e=new Uint8Array(t);if(e.length<2||e[0]!==31||e[1]!==139)return t;try{let r=new Blob([t]).stream().pipeThrough(new DecompressionStream("gzip"));return await new Response(r).arrayBuffer()}catch(r){return t}}m();var hT=ft(Vd(),1),ri=ft(require("fs/promises"),1),Qn=require("obsidian"),Le=ft(require("path"),1),Ru=require("path");m();var eh=ft(xk(),1);m();var fv=new WeakMap;function pl(...t){let e=new String(t);return fv.set(e,t),e}function _i(t){return t instanceof String&&fv.has(t)}function ml(t){var e;return(e=fv.get(t))!=null?e:[]}var Qd=ft(Vd(),1),QC=require("child_process");var OA=ft(hv(),1),qA=require("node:path");m();function*Ek(t,e){let
Line truncated
|
||||
`){return t.split(r).reduce((i,n)=>{let s=e?n.trim():n;return s&&i.push(s),i},[])}function Ov(t,e){return Cu(t,!0).map(r=>e(r))}function Lv(t){return(0,eh.exists)(t,eh.FOLDER)}function Ei(t,e){return Array.isArray(t)?t.includes(e)||t.push(e):t.add(e),e}function pC(t,e){return Array.isArray(t)&&!t.includes(e)&&t.push(e),t}function th(t,e){if(Array.isArray(t)){let r=t.indexOf(e);r>=0&&t.splice(r,1)}else t.delete(e);return e}function Sn(t){return Array.isArray(t)?t:[t]}function mC(t){return t.replace(/[\s-]+(.)/g,(e,r)=>r.toUpperCase())}function yl(t){return Sn(t).map(e=>e instanceof String?e:String(e))}function Qe(t,e=0){if(t==null)return e;let r=parseInt(t,10);return Number.isNaN(r)?e:r}function Eu(t,e){let r=[];for(let i=0,n=t.length;i<n;i++)r.push(e,t[i]);return r}function Su(t){return(Array.isArray(t)?k.concat(t):t).toString("utf-8")}function gC(t,e){let r={};return e.forEach(i=>{t[i]!==void 0&&(r[i]=t[i])}),r}function _v(t=0){return new Promise(e=>setTimeout(e,t))}function yv(t){if(t!==!1)return t}var wl,$a,Au,rh=Y({"src/lib/utils/util.ts"(){"use strict";Nv(),wl="\0",$a=()=>{},Au=Object.prototype.toString.call.bind(Object.prototype.toString)}});function ar(t,e,r){return e(t)?t:arguments.length>2?r:void 0}function xv(t,e){let r=_i(t)?"string":typeof t;return/number|string|boolean/.test(r)&&(!e||!e.includes(r))}function ih(t){return!!t&&Au(t)==="[object Object]"}function vC(t){return typeof t=="function"}var Tu,wC,mt,Kd,nh,Nv=Y({"src/lib/utils/argument-filters.ts"(){"use strict";rh(),Tu=t=>Array.isArray(t),wC=t=>typeof t=="number",mt=t=>typeof t=="string"||_i(t),Kd=t=>mt(t)||Array.isArray(t)&&t.every(mt),nh=t=>t==null||"number|boolean|function".includes(typeof t)?!1:typeof t.length=="number"}}),Ev,s8=Y({"src/lib/utils/exit-codes.ts"(){"use strict";Ev=(t=>(t[t.SUCCESS=0]="SUCCESS",t[t.ERROR=1]="ERROR",t[t.NOT_FOUND=-2]="NOT_FOUND",t[t.UNCLEAN=128]="UNCLEAN",t))(Ev||{})}}),Xd,a8=Y({"src/lib/utils/git-output-streams.ts"(){"use strict";Xd=class bC{constructor(e,r){this.stdOut=e,this.stdErr=r}asStrings(){return new bC(this.stdOut.toString("utf8"),this.stdErr.toString("utf8"))}}}});function o8(){throw new Error("LineParser:useMatches not implemented")}var be,Hs,l8=Y({"src/lib/utils/line-parser.ts"(){"use strict";be=class{constructor(t,e){this.matches=[],this.useMatches=o8,this.parse=(r,i)=>(this.resetMatches(),this._regExp.every((n,s)=>this.addMatch(n,s,r(s)))?this.useMatches(i,this.prepareMatches())!==!1:!1),this._regExp=Array.isArray(t)?t:[t],e&&(this.useMatches=e)}resetMatches(){this.matches.length=0}prepareMatches(){return this.matches}addMatch(t,e,r){let i=r&&t.exec(r);return i&&this.pushMatch(e,i),!!i}pushMatch(t,e){this.matches.push(...e.slice(1))}},Hs=class extends be{addMatch(t,e,r){return/^remote:\s/.test(String(r))&&super.addMatch(t,e,r)}pushMatch(t,e){(t>0||e.length>1)&&super.pushMatch(t,e)}}}});function _C(...t){let e=process.cwd(),r=Object.assign({baseDir:e,...yC},...t.filter(i=>typeof i=="object"&&i));return r.baseDir=r.baseDir||e,r.trimmed=r.trimmed===!0,r}var yC,c8=Y({"src/lib/utils/simple-git-options.ts"(){"use strict";yC={binary:"git",maxConcurrentProcesses:5,config:[],trimmed:!1}}});function Bv(t,e=[]){return ih(t)?Object.keys(t).reduce((r,i)=>{let n=t[i];if(_i(n))r.push(n);else if(xv(n,["boolean"]))r.push(i+"="+n);else if(Array.isArray(n))for(let s of n)xv(s,["string","number"])||r.push(i+"="+s);else r.push(i);return r},e):e}function yr(t,e=0,r=!1){let i=[];for(let n=0,s=e<0?t.length:e;n<s;n++)"string|number".includes(typeof t[n])&&i.push(String(t[n]));return Bv(Hv(t),i),r||i.push(...u8(t)),i}function u8(t){let e=typeof Ra(t)=="function";return yl(ar(Ra(t,e?1:0),Tu,[]))}function Hv(t){let e=vC(Ra(t));return ar(Ra(t,e?1:0),ih)}function nt(t,e=!0){let r=cC(Ra(t));return e||uC(r)?r:void 0}var f8=Y({"src/lib/utils/task-options.ts"(){"use strict";Nv(),rh()}});function Sv(t,e){return t(e.stdOut,e.stdErr)}function Hr(t,e,r,i=!0){return Sn(r).forEach(n=>{for(let s=Cu(n,i),a=0,o=s.length;a<o;a++){let l=(c=0)=>{if(!(a+c>=o))return s[a+c]};e.some(({parse:c})=>c(l,t))}}),t}var d8=Y({"src/lib/utils/task-parser.ts"(){"use strict";rh()}}),xC={};St(xC,{ExitCodes:()=>Ev,GitOutputStreams:()=>Xd,LineParser:()=>be,NOOP:()=>$a,NULL:()=>wl,RemoteLineParser:()=>Hs,append:()=>Ei,appendTaskOptions:()=>Bv,asArray:()=>Sn,asCamelCase:()=>mC,asFunction:()=>cC,asNumber:()=>Qe,asStringArray:()=>yl,bufferToString:()=>Su,callTaskParser:()=>Sv,createInstanceConfig:()=>_C,delay:()=>_v,filterArray:()=>Tu,filterFunction:()=>vC,filterHasLength:()=>nh,filterNumber:()=>wC,filterPlainObject:()=>ih,filterPrimitives:()=>xv,filterString:()=>mt,filterStringOrStringArray:()=>Kd,filterType:()=>ar,first:()=>dC,folderExists:()=>Lv,forEachLineWithContent:()=>Ov,getTrailingOptions:()=>yr,including:()=>pC,isUserFunction:()=>uC,last:()=>Ra,objectToString:()=>Au,orVoid:()=>yv,parseStringResponse:()=>Hr,pick:()=>gC,prefixedArray:()=>Eu,remove:()=>th,splitOn:()=>fC,toLinesWithContent:()=>Cu,trailingFunctionArgument:()=>nt,trailingOptionsArgument
Line truncated
|
||||
`)){let l=fC(a,`
|
||||
`);o=l[0],a=l[1]}yield{file:s,key:o,value:a}}}var BC,C8=Y({"src/lib/responses/ConfigList.ts"(){"use strict";ge(),BC=class{constructor(){this.files=[],this.values=Object.create(null)}get all(){return this._all||(this._all=this.files.reduce((t,e)=>Object.assign(t,this.values[e]),{})),this._all}addFile(t){if(!(t in this.values)){let e=Ra(this.files);this.values[t]=e?Object.create(this.values[e]):{},this.files.push(t)}return this.values[t]}addValue(t,e,r){let i=this.addFile(t);Object.hasOwn(i,e)?Array.isArray(i[e])?i[e].push(r):i[e]=[i[e],r]:i[e]=r,this._all=void 0}}}});function pv(t,e){return typeof t=="string"&&Object.hasOwn(Av,t)?t:e}function A8(t,e,r,i){let n=["config",`--${i}`];return r&&n.push("--add"),n.push(t,e),{commands:n,format:"utf-8",parser(s){return s}}}function T8(t,e){let r=["config","--null","--show-origin","--get-all",t];return e&&r.splice(1,0,`--${e}`),{commands:r,format:"utf-8",parser(i){return S8(i,t)}}}function P8(t){let e=["config","--list","--show-origin","--null"];return t&&e.push(`--${t}`),{commands:e,format:"utf-8",parser(r){return E8(r)}}}function R8(){return{addConfig(t,e,...r){return this._runTask(A8(t,e,r[0]===!0,pv(r[1],"local")),nt(arguments))},getConfig(t,e){return this._runTask(T8(t,pv(e,void 0)),nt(arguments))},listConfig(...t){return this._runTask(P8(pv(t[0],void 0)),nt(arguments))}}}var Av,HC=Y({"src/lib/tasks/config.ts"(){"use strict";C8(),ge(),Av=(t=>(t.system="system",t.global="global",t.local="local",t.worktree="worktree",t))(Av||{})}});function $8(t){return UC.has(t)}var mv,UC,GC=Y({"src/lib/tasks/diff-name-status.ts"(){"use strict";mv=(t=>(t.ADDED="A",t.COPIED="C",t.DELETED="D",t.MODIFIED="M",t.RENAMED="R",t.CHANGED="T",t.UNMERGED="U",t.UNKNOWN="X",t.BROKEN="B",t))(mv||{}),UC=new Set(Object.values(mv))}});function F8(...t){return new VC().param(...t)}function I8(t){let e=new Set,r={};return Ov(t,i=>{let[n,s,a]=i.split(wl);e.add(n),(r[n]=r[n]||[]).push({line:Qe(s),path:n,preview:a})}),{paths:e,results:r}}function M8(){return{grep(t){let e=nt(arguments),r=yr(arguments);for(let n of jC)if(r.includes(n))return this._runTask(Nr(`git.grep: use of "${n}" is not supported.`),e);typeof t=="string"&&(t=F8().param(t));let i=["grep","--null","-n","--full-name",...r,...t];return this._runTask({commands:i,format:"utf-8",parser(n){return I8(n)}},e)}}}var jC,xu,Rk,VC,zC=Y({"src/lib/tasks/grep.ts"(){"use strict";ge(),yt(),jC=["-h"],xu=Symbol("grepQuery"),VC=class{constructor(){this[Rk]=[]}*[(Rk=xu,Symbol.iterator)](){for(let t of this[xu])yield t}and(...t){return t.length&&this[xu].push("--and","(",...Eu(t,"-e"),")"),this}param(...t){return this[xu].push(...Eu(t,"-e")),this}}}}),WC={};St(WC,{ResetMode:()=>qd,getResetMode:()=>O8,resetTask:()=>D8});function D8(t,e){let r=["reset"];return qC(t)&&r.push(`--${t}`),r.push(...e),xr(r)}function O8(t){if(qC(t))return t;switch(typeof t){case"string":case"undefined":return"soft"}}function qC(t){return typeof t=="string"&&YC.includes(t)}var qd,YC,ZC=Y({"src/lib/tasks/reset.ts"(){"use strict";ge(),yt(),qd=(t=>(t.MIXED="mixed",t.SOFT="soft",t.HARD="hard",t.MERGE="merge",t.KEEP="keep",t))(qd||{}),YC=yl(Object.values(qd))}});function L8(){return(0,Qd.default)("simple-git")}function $k(t,e,r){return!e||!String(e).replace(/\s*/,"")?r?(i,...n)=>{t(i,...n),r(i,...n)}:t:(i,...n)=>{t(`%s ${i}`,e,...n),r&&r(i,...n)}}function N8(t,e,{namespace:r}){if(typeof t=="string")return t;let i=e&&e.namespace||"";return i.startsWith(r)?i.substr(r.length+1):i||r}function Wv(t,e,r,i=L8()){let n=t&&`[${t}]`||"",s=[],a=typeof e=="string"?i.extend(e):e,o=N8(ar(e,mt),a,i);return c(r);function l(u,f){return Ei(s,Wv(t,o.replace(/^[^:]+/,u),f,i))}function c(u){let f=u&&`[${u}]`||"",d=a&&$k(a,f)||$a,h=$k(i,`${n} ${f}`,d);return Object.assign(a?d:h,{label:t,sibling:l,info:h,step:c})}}var KC=Y({"src/lib/git-logger.ts"(){"use strict";ge(),Qd.default.formatters.L=t=>String(nh(t)?t.length:"-"),Qd.default.formatters.B=t=>k.isBuffer(t)?t.toString("utf8"):Au(t)}}),XC,B8=Y({"src/lib/runners/tasks-pending-queue.ts"(){"use strict";var t;Us(),KC(),XC=(t=class{constructor(r="GitExecutor"){this.logLabel=r,this._queue=new Map}withProgress(r){return this._queue.get(r)}createProgress(r){let i=t.getName(r.commands[0]),n=Wv(this.logLabel,i);return{task:r,logger:n,name:i}}push(r){let i=this.createProgress(r);return i.logger("Adding task to the queue, commands = %o",r.commands),this._queue.set(r,i),i}fatal(r){for(let[i,{logger:n}]of Array.from(this._queue.entries()))i===r.task?(n.info("Failed %o",r),n("Fatal exception, any as-yet un-started tasks run through this executor will not be attempted")):n.info("A fatal exception occurred in a previous task, the queue has been purged: %o",r.message),this.complete(i);if(this._queue.size!==0)throw new Error(`Queue size should be zero after fatal: ${this._queue.size}`)}complete(r){this.withProgress(r)&&this._queue.delete(r)}attempt(r){let i=this.withProgress(r);if(!i)throw new Br(void 0,"TasksPendingQueue: attempt called for an unknown task");return i.logger(
Line truncated
|
||||
`).map(M6).filter(Boolean);e||r.sort(function(n,s){let a=n.split("."),o=s.split(".");if(a.length===1||o.length===1)return I6(Wd(a[0]),Wd(o[0]));for(let l=0,c=Math.max(a.length,o.length);l<c;l++){let u=sT(Wd(a[l]),Wd(o[l]));if(u)return u}return 0});let i=e?r[0]:[...r].reverse().find(n=>n.indexOf(".")>=0);return new rC(r,i)}}}),oT={};St(oT,{addAnnotatedTagTask:()=>N6,addTagTask:()=>L6,tagListTask:()=>O6});function O6(t=[]){let e=t.some(r=>/^--sort=/.test(r));return{format:"utf-8",commands:["tag","-l",...t],parser(r){return aT(r,e)}}}function L6(t){return{format:"utf-8",commands:["tag",t],parser(){return{name:t}}}}function N6(t,e){return{format:"utf-8",commands:["tag","-a","-m",e,t],parser(){return{name:t}}}}var B6=Y({"src/lib/tasks/tag.ts"(){"use strict";D6()}}),H6=i8({"src/git.js"(t,e){"use strict";var{GitExecutor:r}=(G8(),_t(JC)),{SimpleGitApi:i}=(GH(),_t(MA)),{Scheduler:n}=(jH(),_t(DA)),{adhocExecTask:s,configurationErrorTask:a}=(yt(),_t(Cv)),{asArray:o,filterArray:l,filterPrimitives:c,filterString:u,filterStringOrStringArray:f,filterType:d,getTrailingOptions:h,trailingFunctionArgument:p,trailingOptionsArgument:g}=(ge(),_t(xC)),{applyPatchTask:v}=(zH(),_t(NA)),{branchTask:b,branchLocalTask:_,deleteBranchesTask:C,deleteBranchTask:x}=(r6(),_t(zA)),{checkIgnoreTask:S}=(a6(),_t(ZA)),{checkIsRepoTask:A}=(CC(),_t(EC)),{cleanWithOptionsTask:w,isCleanOptionsArray:E}=(LC(),_t(DC)),{diffSummaryTask:y}=(Jv(),_t(dA)),{fetchTask:P}=(f6(),_t(XA)),{moveTask:T}=(m6(),_t(JA)),{pullTask:I}=(v6(),_t(eT)),{pushTagsTask:L}=(AA(),_t(CA)),{addRemoteTask:H,getRemotesTask:te,listRemotesTask:xe,remoteTask:Z,removeRemoteTask:K}=(C6(),_t(rT)),{getResetMode:ce,resetTask:pe}=(ZC(),_t(WC)),{stashListTask:W}=(T6(),_t(iT)),{addSubModuleTask:X,initSubModuleTask:G,subModuleTask:Be,updateSubModuleTask:pr}=(F6(),_t(nT)),{addAnnotatedTagTask:Ut,addTagTask:Ie,tagListTask:Rt}=(B6(),_t(oT)),{straightThroughBufferTask:$t,straightThroughStringTask:Xe}=(yt(),_t(Cv));function ee(N,O){this._plugins=O,this._executor=new r(N.baseDir,new n(N.maxConcurrentProcesses),O),this._trimmed=N.trimmed}(ee.prototype=Object.create(i.prototype)).constructor=ee,ee.prototype.customBinary=function(N){return this._plugins.reconfigure("binary",N),this},ee.prototype.env=function(N,O){return arguments.length===1&&typeof N=="object"?this._executor.env=N:(this._executor.env=this._executor.env||{})[N]=O,this},ee.prototype.stashList=function(N){return this._runTask(W(g(arguments)||{},l(N)&&N||[]),p(arguments))},ee.prototype.mv=function(N,O){return this._runTask(T(N,O),p(arguments))},ee.prototype.checkoutLatestTag=function(N){var O=this;return this.pull(function(){O.tags(function(ue,$e){O.checkout($e.latest,N)})})},ee.prototype.pull=function(N,O,ue,$e){return this._runTask(I(d(N,u),d(O,u),h(arguments)),p(arguments))},ee.prototype.fetch=function(N,O){return this._runTask(P(d(N,u),d(O,u),h(arguments)),p(arguments))},ee.prototype.silent=function(N){return this._runTask(s(()=>console.warn("simple-git deprecation notice: git.silent: logging should be configured using the `debug` library / `DEBUG` environment variable, this method will be removed.")))},ee.prototype.tags=function(N,O){return this._runTask(Rt(h(arguments)),p(arguments))},ee.prototype.rebase=function(){return this._runTask(Xe(["rebase",...h(arguments)]),p(arguments))},ee.prototype.reset=function(N){return this._runTask(pe(ce(N),h(arguments)),p(arguments))},ee.prototype.revert=function(N){let O=p(arguments);return typeof N!="string"?this._runTask(a("Commit must be a string"),O):this._runTask(Xe(["revert",...h(arguments,0,!0),N]),O)},ee.prototype.addTag=function(N){let O=typeof N=="string"?Ie(N):a("Git.addTag requires a tag name");return this._runTask(O,p(arguments))},ee.prototype.addAnnotatedTag=function(N,O){return this._runTask(Ut(N,O),p(arguments))},ee.prototype.deleteLocalBranch=function(N,O,ue){return this._runTask(x(N,typeof O=="boolean"?O:!1),p(arguments))},ee.prototype.deleteLocalBranches=function(N,O,ue){return this._runTask(C(N,typeof O=="boolean"?O:!1),p(arguments))},ee.prototype.branch=function(N,O){return this._runTask(b(h(arguments)),p(arguments))},ee.prototype.branchLocal=function(N){return this._runTask(_(),p(arguments))},ee.prototype.raw=function(N){let O=!Array.isArray(N),ue=[].slice.call(O?arguments:N,0);for(let Gt=0;Gt<ue.length&&O;Gt++)if(!c(ue[Gt])){ue.splice(Gt,ue.length-Gt);break}ue.push(...h(arguments,0,!0));var $e=p(arguments);return ue.length?this._runTask(Xe(ue,this._trimmed),$e):this._runTask(a("Raw: must supply one or more command to execute"),$e)},ee.prototype.submoduleAdd=function(N,O,ue){return this._runTask(X(N,O),p(arguments))},ee.prototype.submoduleUpdate=function(N,O){return this._runTask(pr(h(arguments,!0)),p(arguments))},ee.prototype.submoduleInit=function(N,O){return this._runTask(G(h(arguments,!0)),p(arguments))},ee.prototype.subModule=function(N,O){return this._runTask(Be(h(arguments)),p(arguments))},ee.prototype.listRemote=function(){return this._runTask(xe(h(arguments)),p(argum
Line truncated
|
||||
`).some(l=>l.contains(n))||await ri.appendFile(r,n+`
|
||||
`)}catch(r){console.error("Error while adding askpass script to exclude file:",r)}}unload(){var r;(r=this.watchAbortController)==null||r.abort()}async status(r){let i=r==null?void 0:r.path,n=await this.git.status(i!=null?["--",i]:[]),s=n.files.map(a=>{let o=this.formatPath(a);return{path:o.path,from:o.from,index:a.index==="?"?"U":a.index,workingDir:a.working_dir==="?"?"U":a.working_dir,vaultPath:this.getRelativeVaultPath(o.path)}});return{all:s,changed:s.filter(a=>a.workingDir!==" "),staged:s.filter(a=>a.index!==" "&&a.index!="U"),conflicted:n.conflicted.map(a=>this.formatPath({path:a}).path)}}async submoduleAwareHeadRevisonInContainingDirectory(r){let i=this.getRelativeRepoPath(r),s=["-C",Le.dirname(i),"rev-parse","HEAD"],a=this.git.raw(s);return a.catch(o=>console.warn("obsidian-git: rev-parse error:",o)),(await a).trim()}async getSubmodulePaths(){return new Promise(r=>{this.git.outputHandler((i,n,s,a)=>{if(!(a.contains("submodule")&&a.contains("foreach")))return;let o="",l=this.app.vault.adapter.getBasePath()+(this.plugin.settings.basePath?"/"+this.plugin.settings.basePath:"");n.on("data",c=>{o+=c.toString("utf8")}),n.on("end",()=>{let u=o.split(`
|
||||
`).map(f=>{let d=f.match(/'([^']*)'/);if(d!=null)return l+"/"+d[1]+Ru.sep}).filter(f=>!!f);u.reverse(),r(u)})}),this.git.subModule(["foreach","--recursive",""]).then(()=>{this.git.outputHandler(()=>{})},i=>this.plugin.displayError(i))})}formatPath(r){function i(n){if(n!=null)return n.startsWith('"')&&n.endsWith('"')?n.substring(1,n.length-1):n}return r.from!=null?{from:i(r.from),path:i(r.path)}:{path:i(r.path)}}async blame(r,i,n){if(r=this.getRelativeRepoPath(r),!await this.isTracked(r))return"untracked";let s=await this.getSubmoduleOfFile(r),a=s?["-C",s.submodule]:[],o=s?s.relativeFilepath:r;a.push("blame","--porcelain"),n&&a.push("-w");let l=`-C${Id}`;switch(i){case"inactive":break;case"same-commit":a.push("-C",l);break;case"all-commits":a.push("-C","-C",l);break;default:Bs(i)}a.push("--",o);let c=await this.git.raw(a);return a4(c)}async isTracked(r){let i=await this.getSubmoduleOfFile(r),n=i?["-C",i.submodule]:[],s=i?i.relativeFilepath:r;return n.push("ls-files","--",s),this.git.raw(n).then(a=>a.trim()!=="")}async commitAll({message:r}){return this.withGitOperation(2,async()=>{if(this.plugin.settings.updateSubmodules){let n=await this.getSubmodulePaths();for(let s of n)await this.git.cwd({path:s,root:!1}).add("-A"),await this.git.cwd({path:s,root:!1}).commit(await this.formatCommitMessage(r))}await this.git.add("-A");let i=await this.git.commit(await this.formatCommitMessage(r));return this.app.workspace.trigger("obsidian-git:head-change"),i.summary.changes})}async commit({message:r,amend:i}){return this.withGitOperation(2,async()=>{let n=(await this.git.commit(await this.formatCommitMessage(r),i?["--amend"]:[])).summary.changes;return this.app.workspace.trigger("obsidian-git:head-change"),n})}async stage(r,i){r=this.getRelativeRepoPath(r,i),await this.git.add(["--",r])}async stageAll({dir:r}){await this.git.add(r!=null?r:"-A")}async unstageAll({dir:r}){await this.git.reset(r!=null?["--",r]:[])}async unstage(r,i){r=this.getRelativeRepoPath(r,i),await this.git.reset(["--",r])}async discard(r){await this.isTracked(r)&&await this.git.checkout(["--progress","--",r])}async applyPatch(r){let i=Le.join(this.relPluginConfigPath,"patch");await this.app.vault.adapter.write(i,r),await this.git.applyPatch(i,{"--cached":null,"--unidiff-zero":null,"--whitespace":"nowarn"}),await this.app.vault.adapter.remove(i)}async getUntrackedPaths(r){let i=r==null?void 0:r.path,n=[];return i!=null&&n.push("--",i),(await this.git.clean(Pa.RECURSIVE+Pa.DRY_RUN,n)).paths}async hashObject(r){r=this.getRelativeRepoPath(r);let i=await this.getSubmoduleOfFile(r),n=i?["-C",i.submodule]:[],s=i?i.relativeFilepath:r;return n.push("hash-object","--",s),this.git.raw(n)}async discardAll({dir:r}){return this.discard(r!=null?r:".")}async pull(){return this.withGitOperation(1,async()=>{try{this.plugin.settings.updateSubmodules&&await this.git.subModule(["update","--remote","--merge","--recursive"]);let r=await this.branchInfo();if(!r.current){this.plugin.displayError("No current branch found. Cannot pull.");return}let i=await this.git.revparse([r.current]);if(!r.tracking&&this.plugin.settings.updateSubmodules){this.plugin.log("No tracking branch found. Ignoring pull of main repo and updating submodules only.");return}await this.git.fetch();let n=await this.git.revparse([r.tracking]);if(i!==n){if(this.plugin.settings.syncMethod==="merge"||this.plugin.settings.syncMethod==="rebase")try{let o=[r.tracking];switch(this.plugin.settings.mergeStrategy!=="none"&&o.push(`--strategy-option=${this.plugin.settings.mergeStrategy}`),this.plugin.settings.syncMethod){case"merge":await this.git.merge(o);break;case"rebase":await this.git.rebase(o)}}catch(o){this.plugin.displayError(`Pull failed (${this.plugin.settings.syncMethod}): ${dT(o)}`);return}else if(this.plugin.settings.syncMethod==="reset")try{await this.git.raw(["update-ref",`refs/heads/${r.current}`,n]),await this.git.reset([])}catch(o){this.plugin.displayError(`Sync failed (${this.plugin.settings.syncMethod}): ${dT(o)}`)}this.app.workspace.trigger("obsidian-git:head-change");let s=await this.git.revparse([r.current]);return(await this.git.diff([`${i}..${s}`,"--name-only"])).split(/\r\n|\r|\n/).filter(o=>o.length>0).map(o=>({path:o,workingDir:"P",vaultPath:this.getRelativeVaultPath(o)}))}else return[]}catch(r){this.convertErrors(r)}})}async push(){return this.withGitOperation(3,async()=>{try{if(this.plugin.settings.updateSubmodules){let a=await this.git.subModule(["foreach","--recursive",`tracking=$(git for-each-ref --format='%(upstream:short)' "$(git symbolic-ref -q HEAD)"); echo $tracking; if [ ! -z "$(git diff --shortstat $tracking)" ]; then git push; fi`]);console.log(a)}let r=await this.git.status(),i=r.tracking,n=r.current;if(!n){this.plugin.displayError("No current branch found. Cannot push.");return}if(!i&&this.plugin.settings.updateSubmodules){this.plugin.log("No tracking branch found. Ignoring push of main repo and updating submodules only.");return}let s=null;return i&&(s=(await this.git.diffS
Line truncated
|
||||
`):[]}async removeRemote(r){await this.git.removeRemote(r)}async updateUpstreamBranch(r){try{await this.git.branch(["--set-upstream-to",r])}catch(i){try{await this.git.branch(["--set-upstream",r])}catch(n){let[s,a]=yn(r),o=await this.branchInfo();await this.git.push(["--set-upstream",s,`${o.current}:${a}`])}}}updateGitPath(r){return this.setGitInstance()}updateBasePath(r){return this.setGitInstance(!0)}async getDiffString(r,i=!1,n){return i?await this.git.diff(["--cached","--",r]):n?await this.git.show([`${n}`,"--",r]):await this.git.diff(["--",r])}async diff(r,i,n){return await this.git.diff([`${i}..${n}`,"--",r])}async rawCommand(r){let i=r.split(" "),n=i[0];return n===void 0?"":await this.git.raw(n,...i.slice(1))}async getSubmoduleOfFile(r){if(!await this.app.vault.adapter.exists(Le.dirname(r)))return;let i=await this.git.raw(["-C",Le.dirname(r),"rev-parse","--show-toplevel"],l=>l&&console.warn("get-submodule-of-file",l==null?void 0:l.message));if(i=i.trim(),(await this.git.raw(["-C",Le.dirname(r),"rev-parse","--show-superproject-working-tree"],l=>l&&console.warn("get-submodule-of-file",l==null?void 0:l.message))).trim()==="")return;let a=this.app.vault.adapter.getFullPath(Le.normalize(r)),o=Le.relative(i,a);return{submodule:i,relativeFilepath:o}}async getLastCommitTime(){try{let r=await this.git.log({n:1});if(r!=null&&r.latest!=null)return new Date(r.latest.date)}catch(r){if(r instanceof Br){if(r.message.contains("does not have any commits yet"))return}else throw r}}async isGitInstalled(){let r=this.plugin.localStorage.getGitPath(),i=await _u(r||"git",["--version"],{});if(i.error)if(Qn.Platform.isWin&&!r){this.plugin.log(`Git not found in PATH. Checking standard installation path(${Md}) of Git for Windows.`);let n=await _u(Md,["--version"]);if(n.error)return console.error(n.error),!1;this.useDefaultWindowsGitPath=!0}else return console.error(i.error),!1;else this.useDefaultWindowsGitPath=!1;return!0}convertErrors(r){if(r instanceof Br){let i=String(r.message);if(i.contains("Could not resolve host")||i.contains("Unable to resolve host")||i.contains("Unable to open connection")||i.match(/ssh: connect to host .*? port .*?: Operation timed out/)!=null||i.match(/ssh: connect to host .*? port .*?: Network is unreachable/)!=null||i.match(/ssh: connect to host .*? port .*?: Undefined error: 0/)!=null)throw new nl(i)}throw r}async isFileTrackedByLFS(r){try{return(await this.git.raw(["check-attr","filter",r])).includes("filter: lfs")}catch(i){let n=i instanceof Error?i.message:String(i);return this.plugin.displayError(`Error checking LFS status: ${n}`),!1}}},pT={hash:"000000",isZeroCommit:!0,summary:""};function a4(t){let r=t.replace(`\r
|
||||
`,`
|
||||
`).split(`
|
||||
`),i={commits:new Map,hashPerLine:[void 0],originalFileLineNrPerLine:[void 0],finalFileLineNrPerLine:[void 0],groupSizePerStartingLine:new Map},n=1;for(let s=0;s<r.length;){let a=r[s];if(uT(a)){let o=a.split(" "),l=o4(o,n,i);for(s++;uT(r[s]);s++){let c=r[s].split(" ");l4(c,i,n)}c4(i.commits.get(l)),n+=1}else if(!(a===""&&s===r.length-1))throw Error(`Expected non-whitespace line or EOF, but found: ${a}`);s++}return i}function o4(t,e,r){let i=t[0],n=t[1],s=t[2];if(i===void 0||n===void 0||s===void 0)throw Error(`Invalid git-blame line info: ${t.join(" ")}`);if(r.hashPerLine.push(i),r.originalFileLineNrPerLine.push(parseInt(n)),r.finalFileLineNrPerLine.push(parseInt(s)),t.length>=4&&r.groupSizePerStartingLine.set(e,parseInt(t[3])),parseInt(s)!==e)throw Error(`git-blame output is out of order: ${e} vs ${s}`);return i}function l4(t,e,r){let i=t[0],n=t.slice(1).join(" "),s=e.hashPerLine[r];if(s===void 0)throw Error(`No commit hash found for git-blame line ${r}`);let a=e.commits.get(s)||{hash:s,author:{},committer:{},previous:{}};switch(i){case"summary":a.summary=n;break;case"author":a.author.name=n;break;case"author-mail":a.author.email=fT(n);break;case"author-time":a.author.epochSeconds=parseInt(n);break;case"author-tz":a.author.tz=n;break;case"committer":a.committer.name=n;break;case"committer-mail":a.committer.email=fT(n);break;case"committer-time":a.committer.epochSeconds=parseInt(n);break;case"committer-tz":a.committer.tz=n;break;case"previous":a.previous.commitHash=n;break;case"filename":a.previous.filename=n;break}e.commits.set(s,a)}function c4(t){if(t.summary===void 0)throw Error(`Summary not provided for commit: ${t.hash}`);iw(t.author)&&(t.author=void 0),iw(t.committer)&&(t.committer=void 0),iw(t.previous)&&(t.previous=void 0),t.isZeroCommit=!!t.hash.match(/^0*$/)}function iw(t){return!t||Object.keys(t).length===0}function uT(t){return t===void 0?!1:t.length>0&&t[0].trim()===t[0]}function fT(t){let e=t.startsWith("<")?t.substring(1):t;return e.endsWith(">")?e.substring(0,e.length-1):e}function dT(t){return t instanceof Error?t.message:String(t)}m();var BT=require("@codemirror/state");m();var nw=class{constructor(){this.eventsPerFilepath=new Map;this.init()}ifFilepathDefinedTransformSubscribers(e,r){if(e)return this.ensureInitialized(e),r(this.eventsPerFilepath.get(e))}forEachSubscriber(e){this.eventsPerFilepath.forEach(r=>r.forEach(e))}ensureInitialized(e){this.eventsPerFilepath.get(e)||this.eventsPerFilepath.set(e,new Set)}init(){this.removeStalesSubscribersTimer===void 0&&this.startRemoveStalesSubscribersInterval()}startRemoveStalesSubscribersInterval(){this.removeStalesSubscribersTimer=window.setInterval(()=>this==null?void 0:this.forEachSubscriber(e=>e==null?void 0:e.removeIfStale()),6e4)}clear(){this.removeStalesSubscribersTimer!==void 0&&(window.clearInterval(this.removeStalesSubscribersTimer),this.removeStalesSubscribersTimer=void 0),this.eventsPerFilepath.clear()}},Si=new nw;m();var uh=require("@codemirror/state");m();function u4(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var mT={exports:{}};(function(t){(function(){var e="input is invalid type",r=typeof window=="object",i=r?window:{};i.JS_SHA256_NO_WINDOW&&(r=!1);var n=!r&&typeof self=="object";n&&(i=self);var s=!i.JS_SHA256_NO_COMMON_JS&&!0&&t.exports,a=!i.JS_SHA256_NO_ARRAY_BUFFER&&typeof ArrayBuffer!="undefined",o="0123456789abcdef".split(""),l=[-2147483648,8388608,32768,128],c=[24,16,8,0],u=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],f=["hex","array","digest","arrayBuffer"],d=[];(i.JS_SHA256_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}),a&&(i.JS_SHA256_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(x){return typeof x=="object"&&x.buffer&&x.buffer.constructor===ArrayBuffer});var h=function(x,S){return function(A){return new b(S,!0).update(A)[x]()}},p=function(x){var S=h("hex",x);S.create=function(){return new b(x)},S.update=function(E){return S.create().update(E)};for(var A=0;A<f.length;++A){var w=f[A];S[w]=h(w,x)}return S},g=function(x,S){return function(A,w){return new _(A,S,!0).update(w)[x]()}},v=function(x){var S=g("hex",x);S.create=function(E){return new _(E,x)},S.update=function(E,y){return S.create(E).update(y)};for(var A=0;A<f.length;++A){var w=f[A];S[w]=g
Line truncated
|
||||
If turned on, do auto ${n} every ${lk(i.settings.autoSaveInterval)} after stopping file edits.
|
||||
This also prevents auto ${n} while editing a file. If turned off, it's independent from the last file edit.`).addToggle(f=>f.setValue(i.settings.autoBackupAfterFileChange).onChange(async d=>{i.settings.autoBackupAfterFileChange=d,this.refreshDisplayWithDelay(),await i.saveSettings(),i.automaticsManager.reload("commit")})),this.mayDisableSetting(a,i.settings.setLastSaveToLastCommit),a=new j.Setting(r).setName(`Auto ${n} after latest commit`).setDesc(`If turned on, sets last auto ${n} timestamp to the latest commit timestamp. This reduces the frequency of auto ${n} when doing manual commits.`).addToggle(f=>f.setValue(i.settings.setLastSaveToLastCommit).onChange(async d=>{i.settings.setLastSaveToLastCommit=d,await i.saveSettings(),i.automaticsManager.reload("commit"),this.refreshDisplayWithDelay()})),this.mayDisableSetting(a,i.settings.autoBackupAfterFileChange),a=new j.Setting(r).setName("Auto push interval (minutes)").setDesc("Push commits every X minutes. Set to 0 (default) to disable.").addText(f=>{f.inputEl.type="number",this.setNonDefaultValue({text:f,settingsProperty:"autoPushInterval"}),f.setPlaceholder(String(pt.autoPushInterval)),f.onChange(async d=>{d!==""?i.settings.autoPushInterval=Number(d):i.settings.autoPushInterval=pt.autoPushInterval,await i.saveSettings(),i.automaticsManager.reload("push")})}),this.mayDisableSetting(a,!i.settings.differentIntervalCommitAndPush),new j.Setting(r).setName("Auto pull interval (minutes)").setDesc("Pull changes every X minutes. Set to 0 (default) to disable.").addText(f=>{f.inputEl.type="number",this.setNonDefaultValue({text:f,settingsProperty:"autoPullInterval"}),f.setPlaceholder(String(pt.autoPullInterval)),f.onChange(async d=>{d!==""?i.settings.autoPullInterval=Number(d):i.settings.autoPullInterval=pt.autoPullInterval,await i.saveSettings(),i.automaticsManager.reload("pull")})}),new j.Setting(r).setName(`Auto ${n} only staged files`).setDesc(`If turned on, only staged files are committed on ${n}. If turned off, all changed files are committed.`).addToggle(f=>f.setValue(i.settings.autoCommitOnlyStaged).onChange(async d=>{i.settings.autoCommitOnlyStaged=d,await i.saveSettings()})),new j.Setting(r).setName(`Specify custom commit message on auto ${n}`).setDesc("You will get a pop up to specify your message.").addToggle(f=>f.setValue(i.settings.customMessageOnAutoBackup).onChange(async d=>{i.settings.customMessageOnAutoBackup=d,await i.saveSettings(),this.refreshDisplayWithDelay()})),a=new j.Setting(r).setName(`Commit message on auto ${n}`).setDesc("Available placeholders: {{date}} (see below), {{hostname}} (see below), {{numFiles}} (number of changed files in the commit) and {{files}} (changed files in commit message).").addTextArea(f=>{f.setPlaceholder(pt.autoCommitMessage).onChange(async d=>{d===""?i.settings.autoCommitMessage=pt.autoCommitMessage:i.settings.autoCommitMessage=d,await i.saveSettings()}),this.setNonDefaultValue({text:f,settingsProperty:"autoCommitMessage"})}),this.mayDisableSetting(a,i.settings.customMessageOnAutoBackup),new j.Setting(r).setName("Commit message").setHeading();let c=new j.Setting(r).setName("Commit message on manual commit").setDesc("Available placeholders: {{date}} (see below), {{hostname}} (see below), {{numFiles}} (number of changed files in the commit) and {{files}} (changed files in commit message). Leave empty to require manual input on each commit.");c.addTextArea(f=>{c.addButton(d=>{d.setIcon("reset").setTooltip(`Set to default: "${pt.commitMessage}"`).onClick(()=>{f.setValue(pt.commitMessage),f.onChanged()})}),f.setValue(i.settings.commitMessage),f.onChange(async d=>{i.settings.commitMessage=d,await i.saveSettings()})}),j.Platform.isDesktopApp&&new j.Setting(r).setName("Commit message script").setDesc("A script that is run using 'sh -c' to generate the commit message. May be used to generate commit messages using AI tools. Available placeholders: {{hostname}}, {{date}}.").addText(f=>{f.onChange(async d=>{d===""?i.settings.commitMessageScript=pt.commitMessageScript:i.settings.commitMessageScript=d,await i.saveSettings()}),this.setNonDefaultValue({text:f,settingsProperty:"commitMessageScript"})});let u=new j.Setting(r).setName("{{date}} placeholder format").addMomentFormat(f=>f.setDefaultFormat(i.settings.commitDateFormat).setValue(i.settings.commitDateFormat).onChange(async d=>{i.settings.commitDateFormat=d,await i.saveSettings()}));u.descEl.createSpan({text:` Specify custom date format. E.g. "${ev}. See `}),u.descEl.createEl("a",{text:"Moment.js documentation",href:UT,attr:{target:"_blank"}}),u.descEl.createSpan({text:" for more formats."}),new j.Setting(r).setName("{{hostname}} placeholder replacement").setDesc("Specify custom hostname for every device. Defaults to the OS hostname if not set on desktop.").addText(f=>{var d;return f.setValue((d=i.localStorage.getHostname())!=null?d:"").onChange(h=>{i.localStorage.setHostname(h)})}),new j.Setting(r).setName("Preview commit message").addButton(f=>f.se
Line truncated
|
||||
`)),c.onChange(u=>{i.localStorage.setEnvVars(u.split(`
|
||||
`))})}),i.gitManager instanceof Se&&new j.Setting(r).setName("Additional PATH environment variable paths").setDesc("Use each line for one path").addTextArea(c=>{c.setValue(i.localStorage.getPATHPaths().join(`
|
||||
`)),c.onChange(u=>{i.localStorage.setPATHPaths(u.split(`
|
||||
`))})}),i.gitManager instanceof Se&&new j.Setting(r).setName("Reload with new environment variables").setDesc("Removing previously added environment variables will not take effect until Obsidian is restarted.").addButton(c=>{c.setButtonText("Reload"),c.setCta(),c.onClick(async()=>{await i.gitManager.setGitInstance()})}),new j.Setting(r).setName("Custom base path (Git repository path)").setDesc(`
|
||||
Sets the relative path to the vault from which the Git binary should be executed.
|
||||
Mostly used to set the path to the Git repository, which is only required if the Git repository is below the vault root directory. Use "\\" instead of "/" on Windows.
|
||||
`).addText(c=>{c.setValue(i.settings.basePath),c.setPlaceholder("directory/directory-with-git-repo"),c.onChange(async u=>{i.settings.basePath=u,await i.saveSettings(),i.gitManager.updateBasePath(u||"").catch(f=>i.displayError(f))})}),new j.Setting(r).setName("Custom Git directory path (Instead of '.git')").setDesc('Corresponds to the GIT_DIR environment variable. Relative paths are resolved from the custom base path, or the vault root when no base path is configured. Requires restart of Obsidian to take effect. Use "\\" instead of "/" on Windows.').addText(c=>{c.setValue(i.settings.gitDir),c.setPlaceholder(".git"),c.onChange(async u=>{i.settings.gitDir=u,await i.saveSettings()})}),new j.Setting(r).setName("Disable on this device").setDesc("Disables the plugin on this device. This setting is not synced.").addToggle(c=>c.setValue(i.localStorage.getPluginDisabled()).onChange(u=>{i.localStorage.setPluginDisabled(u),u?i.unloadPlugin():i.init({fromReload:!0}).catch(f=>i.displayError(f)),new j.Notice("Obsidian must be restarted for the changes to take affect.")})),new j.Setting(r).setName("Support").setHeading(),new j.Setting(r).setName("Donate").setDesc("If you like this Plugin, consider donating to support continued development.").addButton(c=>{var f;let u=(f=c.buttonEl.parentElement)==null?void 0:f.createEl("a",{href:"https://ko-fi.com/F1F195IQ5",attr:{target:"_blank"}});u&&(u.createEl("img",{attr:{height:"36",style:"border:0px;height:36px;",src:"https://cdn.ko-fi.com/cdn/kofi3.png?v=3",border:"0",alt:"Buy Me a Coffee at ko-fi.com"}}),c.buttonEl.remove())});let o=r.createDiv();o.setAttr("align","center"),o.setAttr("style","margin: var(--size-4-2)");let l=o.createEl("button");if(l.setText("Copy Debug Information"),l.onclick=async()=>{await window.navigator.clipboard.writeText(JSON.stringify({settings:this.plugin.settings,pluginVersion:this.plugin.manifest.version},null,4)),new j.Notice("Debug information copied to clipboard. May contain sensitive information!")},j.Platform.isDesktopApp){let c=r.createDiv();c.setAttr("align","center"),c.setText(`Debugging and logging:
|
||||
You can always see the logs of this and every other plugin by opening the console with`);let u=r.createDiv();u.setAttr("align","center"),u.addClass("obsidian-git-shortcuts"),j.Platform.isMacOS===!0?u.createEl("kbd",{text:"CMD (\u2318) + OPTION (\u2325) + I"}):u.createEl("kbd",{text:"CTRL + SHIFT + I"})}}mayDisableSetting(r,i){i&&(r.setDisabled(i),r.setClass("obsidian-git-disabled"))}configureLineAuthorShowStatus(r){this.settings.lineAuthor.show=r,this.plugin.saveSettings(),r?this.plugin.editorIntegration.activateLineAuthoring():this.plugin.editorIntegration.deactiveLineAuthoring()}async lineAuthorSettingHandler(r,i){this.settings.lineAuthor[r]=i,await this.plugin.saveSettings(),this.plugin.editorIntegration.lineAuthoringFeature.refreshLineAuthorViews()}beforeSaveSettings(){let r=this.settings.lineAuthor;r.authorDisplay!=="hide"&&(r.lastShownAuthorDisplay=r.authorDisplay),r.dateTimeFormatOptions!=="hide"&&(r.lastShownDateTimeFormatOptions=r.dateTimeFormatOptions)}addLineAuthorInfoSettings(){let r=new j.Setting(this.containerEl).setName("Show commit authoring information next to each line");if(this.plugin.editorIntegration.lineAuthoringFeature.isAvailableOnCurrentPlatform()||r.setDesc("Only available on desktop currently.").setDisabled(!0),r.descEl.createEl("a",{href:T4,text:"Feature guide and quick examples",attr:{target:"_blank"}}),r.descEl.createEl("br"),r.descEl.createSpan({text:" The commit hash, author name and authoring date can all be individually toggled."}),r.descEl.createEl("br"),r.descEl.createSpan({text:"Hide everything, to only show the age-colored sidebar."}),r.addToggle(i=>i.setValue(this.settings.lineAuthor.show).onChange(n=>{this.configureLineAuthorShowStatus(n),this.refreshDisplayWithDelay()})),this.settings.lineAuthor.show){let i=new j.Setting(this.containerEl).setName("Follow movement and copies across files and commits").addDropdown(l=>{l.addOptions({inactive:"Do not follow (default)","same-commit":"Follow within same commit","all-commits":"Follow within all commits (maybe slow)"}),l.setValue(this.settings.lineAuthor.followMovement),l.onChange(c=>this.lineAuthorSettingHandler("followMovement",c))});if(i.descEl.createSpan({text:"By default (deactivated), each line only shows the newest commit where it was changed."}),i.descEl.createEl("br"),i.descEl.createSpan({text:"With "}),i.descEl.createEl("i",{text:"same commit"}),i.descEl.createSpan({text:", cut-copy-paste-ing of text is followed within the same commit and the original commit of authoring will be shown."}),i.descEl.createEl("br"),i.descEl.createSpan({text:"With "}),i.descEl.createEl("i",{text:"all commits"}),i.descEl.createSpan({text:", cut-copy-paste-ing text inbetween multiple commits will be detected."}),i.descEl.createEl("br"),i.descEl.createSpan({text:"It uses "}),i.descEl.createEl("a",{href:"https://git-scm.com/docs/git-blame",text:"git-blame",attr:{target:"_blank"}}),i.descEl.createSpan({text:` and for matches (at least ${Id} characters) within the same (or all) commit(s), `}),i.descEl.createEl("em",{text:"the originating"}),i.descEl.createSpan({text:" commit's information is shown."}),new j.Setting(this.containerEl).setName("Show commit hash").addToggle(l=>{l.setValue(this.settings.lineAuthor.showCommitHash),l.onChange(c=>this.lineAuthorSettingHandler("showCommitHash",c))}),new j.Setting(this.containerEl).setName("Author name display").setDesc("If and how the author is displayed").addDropdown(l=>{let c={hide:"Hide",initials:"Initials (default)","first name":"First name","last name":"Last name",full:"Full name"};l.addOptions(c),l.setValue(this.settings.lineAuthor.authorDisplay),l.onChange(async u=>this.lineAuthorSettingHandler("authorDisplay",u))}),new j.Setting(this.containerEl).setName("Authoring date display").setDesc("If and how the date and time of authoring the line is displayed").addDropdown(l=>{let c={hide:"Hide",date:"Date (default)",datetime:"Date and time","natural language":"Natural language",custom:"Custom"};l.addOptions(c),l.setValue(this.settings.lineAuthor.dateTimeFormatOptions),l.onChange(async u=>{await this.lineAuthorSettingHandler("dateTimeFormatOptions",u),this.refreshDisplayWithDelay()})}),this.settings.lineAuthor.dateTimeFormatOptions==="custom"){let l=new j.Setting(this.containerEl);l.setName("Custom authoring date format").addText(c=>{c.setValue(this.settings.lineAuthor.dateTimeFormatCustomString),c.setPlaceholder("YYYY-MM-DD HH:mm"),c.onChange(async u=>{await this.lineAuthorSettingHandler("dateTimeFormatCustomString",u),this.setCustomDateTimeDescription(l.descEl,u)})}),this.setCustomDateTimeDescription(l.descEl,this.settings.lineAuthor.dateTimeFormatCustomString)}let n=new j.Setting(this.containerEl).setName("Authoring date display timezone").addDropdown(l=>{let c={"viewer-local":"My local (default)","author-local":"Author's local",utc0000:"UTC+0000/Z"};l.addOptions(c),l.setValue(this.settings.lineAuthor.dateTimeTimezone),l.onChange(async u=>this.lineAuthorSettingHandler("dateTimeTimezone",u))});n.d
Line truncated
|
||||
Either your local time-zone (default),
|
||||
the author's time-zone during commit creation or
|
||||
`}),n.descEl.createEl("a",{text:"UTC\xB100:00",href:"https://en.wikipedia.org/wiki/UTC%C2%B100:00"}),n.descEl.createSpan({text:"."});let s=new j.Setting(this.containerEl).setName("Oldest age in coloring");this.setOldestAgeDescription(s.descEl,this.settings.lineAuthor.coloringMaxAge),s.addText(l=>{l.setPlaceholder("1y"),l.setValue(this.settings.lineAuthor.coloringMaxAge),l.onChange(async c=>{let f=Iu(c)!==void 0;this.setOldestAgeDescription(s.descEl,c),f&&(await this.lineAuthorSettingHandler("coloringMaxAge",c),this.refreshColorSettingsName("oldest"))})}),this.createColorSetting("newest"),this.createColorSetting("oldest");let a=new j.Setting(this.containerEl).setName("Text color").addText(l=>{l.setValue(this.settings.lineAuthor.textColorCss),l.onChange(async c=>{await this.lineAuthorSettingHandler("textColorCss",c)})});a.descEl.empty(),a.descEl.createSpan({text:"The CSS color of the gutter text."}),a.descEl.createEl("br"),a.descEl.createEl("br"),a.descEl.createSpan({text:"It is highly recommended to use "}),a.descEl.createEl("a",{text:"CSS variables",href:"https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties"}),a.descEl.createSpan({text:" defined by themes (e.g. "}),a.descEl.createEl("pre",{text:"var(--text-muted)",attr:{style:"display:inline"}}),a.descEl.createSpan({text:" or "}),a.descEl.createEl("pre",{text:"var(--text-on-accent)",attr:{style:"display:inline"}}),a.descEl.createSpan({text:"), because they automatically adapt to theme changes."}),a.descEl.createEl("br"),a.descEl.createEl("br"),a.descEl.createSpan({text:"See: "}),a.descEl.createEl("a",{text:"List of available CSS variables in Obsidian",href:"https://github.com/obsidian-community/obsidian-theme-template/blob/main/obsidian.css"});let o=new j.Setting(this.containerEl).setName("Ignore whitespace and newlines in changes").addToggle(l=>{l.setValue(this.settings.lineAuthor.ignoreWhitespace),l.onChange(c=>this.lineAuthorSettingHandler("ignoreWhitespace",c))});o.descEl.empty(),o.descEl.createSpan({text:"Whitespace and newlines are interpreted as part of the document and in changes by default (hence not ignored). This makes the last line being shown as 'changed' when a new subsequent line is added, even if the previously last line's text is the same."}),o.descEl.createEl("br"),o.descEl.createSpan({text:"If you don't care about purely-whitespace changes (e.g. list nesting / quote indentation changes), then activating this will provide more meaningful change detection."})}}createColorSetting(r){let i=new j.Setting(this.containerEl).setName("").addText(n=>{let s=hw(r,this.settings.lineAuthor),a=hw(r,pt.lineAuthor);n.setPlaceholder(lv(a)),n.setValue(lv(s)),n.onChange(async o=>{let l=ik(o);if(l!==void 0){let c=r==="newest"?"colorNew":"colorOld";await this.lineAuthorSettingHandler(c,l)}this.refreshColorSettingsDesc(r,l)})});this.lineAuthorColorSettings.set(r,i),this.refreshColorSettingsName(r),this.refreshColorSettingsDesc(r,hw(r,this.settings.lineAuthor))}refreshColorSettingsName(r){let i=this.lineAuthorColorSettings.get(r);if(i){let n=r==="oldest"?`oldest (${this.settings.lineAuthor.coloringMaxAge} or older)`:"newest";i.nameEl.setText(`Color for ${n} commits`)}}refreshColorSettingsDesc(r,i){let n=this.lineAuthorColorSettings.get(r);n&&this.colorSettingPreviewDesc(n.descEl,r,this.settings.lineAuthor,i!==void 0)}colorSettingPreviewDesc(r,i,n,s){r.empty(),r.createSpan({text:"Supports 'rgb(r,g,b)', 'hsl(h,s,l)', hex (#) and named colors (e.g. 'black', 'purple'). Color preview: "});let a=s?bh(i,n):"rgba(127,127,127,0.3)",o=j.moment.unix(j.moment.now()/1e3).format("YYYY-MM-DD"),l=s?`abcdef Author Name ${o}`:"invalid color";r.createEl("div",{text:l,attr:{class:"line-author-settings-preview",style:`background-color: ${a}; width: 30ch;`}})}setCustomDateTimeDescription(r,i){r.empty(),r.createEl("a",{text:"Format string",href:UT}),r.createSpan({text:" to display the authoring date."}),r.createEl("br");let n=(0,j.moment)().format(i);r.createSpan({text:`Currently: ${n}`})}setOldestAgeDescription(r,i){let n=Iu(i),s=n!==void 0?`${n.asDays()} days`:"invalid!";r.empty(),r.createSpan({text:`The oldest age in the line author coloring. Everything older will have the same color.
|
||||
Smallest valid age is "1d". Currently: ${s}`})}setNonDefaultValue({settingsProperty:r,text:i}){let n=this.plugin.settings[r];pt[r]!==n&&(typeof n=="string"||typeof n=="number"||typeof n=="boolean"?i.setValue(String(n)):i.setValue(JSON.stringify(n)))}refreshDisplayWithDelay(r=80){window.setTimeout(()=>this.display(),r)}};function hw(t,e){return t==="oldest"?e.colorOld:e.colorNew}function Iu(t){let e=j.moment.duration("P"+t.toUpperCase());return e.isValid()&&e.asDays()&&e.asDays()>=1?e:void 0}m();var Ur=require("obsidian");var xh=class{constructor(e,r){this.statusBarEl=e;this.plugin=r;this.messages=[];this.currentMessage=null;this.lastMessageTimestamp=null;this.base="obsidian-git-statusbar-";this.statusBarEl.setAttribute("data-tooltip-position","top"),r.registerEvent(r.app.workspace.on("obsidian-git:refreshed",()=>{this.refreshCommitTimestamp().catch(console.error)}))}displayMessage(e,r){this.messages.push({message:`Git: ${e.slice(0,100)}`,timeout:r}),this.display()}displayProgress(e){this.progress=e,this.display()}clearProgress(e=!0){this.progress=void 0,e&&this.display()}display(){this.progress?this.displayState():this.messages.length>0&&!this.currentMessage?(this.currentMessage=this.messages.shift(),this.statusBarEl.addClass(this.base+"message"),this.statusBarEl.ariaLabel="",this.statusBarEl.setText(this.currentMessage.message),this.lastMessageTimestamp=Date.now()):this.currentMessage?Date.now()-this.lastMessageTimestamp>=this.currentMessage.timeout&&(this.currentMessage=null,this.lastMessageTimestamp=null):this.displayState()}displayState(){if((this.statusBarEl.getText().length>3||!this.statusBarEl.hasChildNodes())&&(this.statusBarEl.empty(),this.conflictEl=this.statusBarEl.createDiv(),this.conflictEl.setAttribute("data-tooltip-position","top"),this.conflictEl.style.float="left",this.pausedEl=this.statusBarEl.createDiv(),this.pausedEl.setAttribute("data-tooltip-position","top"),this.pausedEl.style.float="left",this.iconEl=this.statusBarEl.createDiv(),this.iconEl.style.float="left",this.textEl=this.statusBarEl.createDiv(),this.textEl.style.float="right",this.textEl.style.marginLeft="5px"),this.plugin.localStorage.getConflict()?((0,Ur.setIcon)(this.conflictEl,"alert-circle"),this.conflictEl.ariaLabel="You have merge conflicts. Resolve them and commit afterwards.",this.conflictEl.style.marginRight="5px",this.conflictEl.addClass(this.base+"conflict")):(this.conflictEl.empty(),this.conflictEl.style.marginRight=""),this.plugin.localStorage.getPausedAutomatics()?((0,Ur.setIcon)(this.pausedEl,"pause-circle"),this.pausedEl.ariaLabel="Automatic routines are currently paused.",this.pausedEl.style.marginRight="5px",this.pausedEl.addClass(this.base+"paused")):(this.pausedEl.empty(),this.pausedEl.style.marginRight=""),this.progress){this.statusBarEl.ariaLabel=this.getProgressTooltip("Git operation in progress..."),(0,Ur.setIcon)(this.iconEl,this.getProgressIcon()),this.displayProgressText(),this.statusBarEl.addClass(this.base+"progress");return}switch(this.plugin.state.operation){case 0:this.displayFromNow();break;case 2:this.statusBarEl.ariaLabel="Committing changes...",(0,Ur.setIcon)(this.iconEl,"git-commit"),this.textEl.empty(),this.statusBarEl.addClass(this.base+"commit");break;case 3:this.statusBarEl.ariaLabel=this.getProgressTooltip("Pushing changes..."),(0,Ur.setIcon)(this.iconEl,"upload"),this.displayProgressText(),this.statusBarEl.addClass(this.base+"push");break;case 1:this.statusBarEl.ariaLabel=this.getProgressTooltip("Pulling changes..."),(0,Ur.setIcon)(this.iconEl,"download"),this.displayProgressText(),this.statusBarEl.addClass(this.base+"pull");break;case 4:this.statusBarEl.ariaLabel=this.getProgressTooltip("Fetching from remote..."),(0,Ur.setIcon)(this.iconEl,"download"),this.displayProgressText(),this.statusBarEl.addClass(this.base+"fetch");break;case 5:this.statusBarEl.ariaLabel=this.getProgressTooltip("Checking out branch..."),(0,Ur.setIcon)(this.iconEl,"git-branch"),this.displayProgressText(),this.statusBarEl.addClass(this.base+"checkout");break;default:this.statusBarEl.ariaLabel="Failed on initialization!",(0,Ur.setIcon)(this.iconEl,"alert-triangle"),this.textEl.empty(),this.statusBarEl.addClass(this.base+"failed-init");break}}displayProgressText(){this.progress?this.textEl.setText(this.getCompactProgressText()):this.textEl.empty()}getProgressTooltip(e){if(!this.progress)return e;let r=this.progress.stage?`${this.progress.stage}: `:"";if(this.progress.progress===void 0)return this.progress.stage?`${this.progress.action}: ${this.progress.stage}...`:`${this.progress.action}...`;let i=this.progress.processed!==void 0&&this.progress.total!==void 0?` (${this.progress.processed}/${this.progress.total})`:"";return`${this.progress.action}: ${r}${Math.round(this.progress.progress)}%${i}`}getCompactProgressText(){return this.progress?this.progress.progress===void 0?`${this.progress.action}...`:`${this.progress.action} ${Math.round(this.progress.progress)}%`:""}getProgressIcon(){var e;switch((e=this.progress)
Line truncated
|
||||
(${this.unPushedCommits} unpushed commits)`)}else this.statusBarEl.ariaLabel=r?"Git is offline":"Git is ready";r?(0,Ur.setIcon)(this.iconEl,"globe"):(0,Ur.setIcon)(this.iconEl,"check"),this.plugin.settings.changedFilesInStatusBar&&this.plugin.cachedStatus?this.textEl.setText(this.plugin.cachedStatus.changed.length.toString()):this.textEl.empty(),this.statusBarEl.addClass(this.base+"idle")}async refreshCommitTimestamp(){this.lastCommitTimestamp=await this.plugin.gitManager.getLastCommitTime(),this.unPushedCommits=await this.plugin.gitManager.getUnpushedCommits()}remove(){this.statusBarEl.remove()}};m();var Sh=require("obsidian"),Eh=class extends Sh.SuggestModal{constructor(r){super(r.app);this.plugin=r;this.resolve=null;this.setPlaceholder("Type your message and select optional the version with the added date.")}openAndGetResult(){return new Promise(r=>{this.resolve=r,this.open()})}onClose(){new Promise(r=>window.setTimeout(r,10)).then(()=>{this.resolve&&this.resolve(void 0)})}getSuggestions(r){let i=(0,Sh.moment)().format(this.plugin.settings.commitDateFormat);return r==""&&(r="..."),[r,`${i}: ${r}`,`${r}: ${i}`]}renderSuggestion(r,i){i.innerText=r}onChooseSuggestion(r,i){this.resolve&&this.resolve(r)}};m();var GT=require("obsidian"),Mu=class{constructor(e){this.plugin=e}saveLastAuto(e,r){r==="backup"?this.plugin.localStorage.setLastAutoBackup(e.toString()):r==="pull"?this.plugin.localStorage.setLastAutoPull(e.toString()):r==="push"&&this.plugin.localStorage.setLastAutoPush(e.toString())}loadLastAuto(){var e,r,i;return{backup:new Date((e=this.plugin.localStorage.getLastAutoBackup())!=null?e:""),pull:new Date((r=this.plugin.localStorage.getLastAutoPull())!=null?r:""),push:new Date((i=this.plugin.localStorage.getLastAutoPush())!=null?i:"")}}async init(){await this.setUpAutoCommitAndSync();let e=this.loadLastAuto();if(this.plugin.settings.differentIntervalCommitAndPush&&this.plugin.settings.autoPushInterval>0){let r=this.diff(this.plugin.settings.autoPushInterval,e.push);this.startAutoPush(r)}if(this.plugin.settings.autoPullInterval>0){let r=this.diff(this.plugin.settings.autoPullInterval,e.pull);this.startAutoPull(r)}}unload(){this.clearAutoPull(),this.clearAutoPush(),this.clearAutoCommitAndSync()}reload(...e){this.plugin.localStorage.getPausedAutomatics()||(e.contains("commit")&&(this.clearAutoCommitAndSync(),this.plugin.settings.autoSaveInterval>0&&this.startAutoCommitAndSync(this.plugin.settings.autoSaveInterval)),e.contains("push")&&(this.clearAutoPush(),this.plugin.settings.differentIntervalCommitAndPush&&this.plugin.settings.autoPushInterval>0&&this.startAutoPush(this.plugin.settings.autoPushInterval)),e.contains("pull")&&(this.clearAutoPull(),this.plugin.settings.autoPullInterval>0&&this.startAutoPull(this.plugin.settings.autoPullInterval)))}async setUpAutoCommitAndSync(){if(this.plugin.settings.setLastSaveToLastCommit){this.clearAutoCommitAndSync();let e=await this.plugin.gitManager.getLastCommitTime();e&&this.saveLastAuto(e,"backup")}if(!this.timeoutIDCommitAndSync&&!this.plugin.autoCommitDebouncer){let e=this.loadLastAuto();if(this.plugin.settings.autoSaveInterval>0){let r=this.diff(this.plugin.settings.autoSaveInterval,e.backup);this.startAutoCommitAndSync(r)}}}get isAutomaticsDisabled(){return!this.plugin.gitReady||this.plugin.localStorage.getPausedAutomatics()}startAutoCommitAndSync(e){if(this.isAutomaticsDisabled)return;let r=(e!=null?e:this.plugin.settings.autoSaveInterval)*6e4;this.plugin.settings.autoBackupAfterFileChange?e===0?this.doAutoCommitAndSync():this.plugin.autoCommitDebouncer=(0,GT.debounce)(()=>this.doAutoCommitAndSync(),r,!0):(r>2147483647&&(r=2147483647),this.timeoutIDCommitAndSync=window.setTimeout(()=>this.doAutoCommitAndSync(),r))}doAutoCommitAndSync(){this.plugin.promiseQueue.addTask(async()=>{if(this.plugin.settings.setLastSaveToLastCommit){let r=await this.plugin.gitManager.getLastCommitTime();if(r){this.saveLastAuto(r,"backup");let i=this.diff(this.plugin.settings.autoSaveInterval,r);if(i>0)return this.startAutoCommitAndSync(i),!1}}let e=this.plugin.settings.autoCommitOnlyStaged;return this.plugin.settings.differentIntervalCommitAndPush?await this.plugin.commit({fromAuto:!0,onlyStaged:e}):await this.plugin.commitAndSync({fromAutoBackup:!0,onlyStaged:e}),!0},e=>{e!==!1&&(this.saveLastAuto(new Date,"backup"),this.startAutoCommitAndSync())})}startAutoPull(e){if(this.isAutomaticsDisabled)return;let r=(e!=null?e:this.plugin.settings.autoPullInterval)*6e4;r>2147483647&&(r=2147483647),this.timeoutIDPull=window.setTimeout(()=>this.doAutoPull(),r)}doAutoPull(){this.plugin.promiseQueue.addTask(()=>this.plugin.pullChangesFromRemote(),()=>{this.saveLastAuto(new Date,"pull"),this.startAutoPull()})}startAutoPush(e){if(this.isAutomaticsDisabled)return;let r=(e!=null?e:this.plugin.settings.autoPushInterval)*6e4;r>2147483647&&(r=2147483647),this.timeoutIDPush=window.setTimeout(()=>this.doAutoPush(),r)}doAutoPush(){this.plugin.promiseQueue.addTask(()=>this.plugin.push(),()=>{this.saveLastA
Line truncated
|
||||
`)}static newName(){let e=ZT[YT]||1;return ZT[YT]=e+1,"\u037C"+e.toString(36)}static mount(e,r,i){let n=e[pw],s=i&&i.nonce;n?s&&n.setNonce(s):n=new mw(e,s),n.mount(Array.isArray(r)?r:[r],e)}},KT=new Map,mw=class{constructor(e,r){let i=e.ownerDocument||e,n=i.defaultView;if(!e.head&&e.adoptedStyleSheets&&n.CSSStyleSheet){let s=KT.get(i);if(s)return e[pw]=s;this.sheet=new n.CSSStyleSheet,KT.set(i,this)}else this.styleTag=i.createElement("style"),r&&this.styleTag.setAttribute("nonce",r);this.modules=[],e[pw]=this}mount(e,r){let i=this.sheet,n=0,s=0;for(let a=0;a<e.length;a++){let o=e[a],l=this.modules.indexOf(o);if(l<s&&l>-1&&(this.modules.splice(l,1),s--,l=-1),l==-1){if(this.modules.splice(s++,0,o),i)for(let c=0;c<o.rules.length;c++)i.insertRule(o.rules[c],n++)}else{for(;s<l;)n+=this.modules[s++].rules.length;n+=o.rules.length,s++}}if(i)r.adoptedStyleSheets.indexOf(this.sheet)<0&&(r.adoptedStyleSheets=[this.sheet,...r.adoptedStyleSheets]);else{let a="";for(let l=0;l<this.modules.length;l++)a+=this.modules[l].getRules()+`
|
||||
`;this.styleTag.textContent=a;let o=r.head||r;this.styleTag.parentNode!=o&&o.insertBefore(this.styleTag,o.firstChild)}}setNonce(e){this.styleTag&&this.styleTag.getAttribute("nonce")!=e&&this.styleTag.setAttribute("nonce",e)}};var p2=require("@codemirror/language"),P4=require("@lezer/highlight"),kt=class t{constructor(e,r,i,n){this.fromA=e,this.toA=r,this.fromB=i,this.toB=n}offset(e,r=e){return new t(this.fromA+e,this.toA+e,this.fromB+r,this.toB+r)}};function Ma(t,e,r,i,n,s){if(t==i)return[];let a=Ew(t,e,r,i,n,s),o=Sw(t,e+a,r,i,n+a,s);e+=a,r-=o,n+=a,s-=o;let l=r-e,c=s-n;if(!l||!c)return[new kt(e,r,n,s)];if(l>c){let f=t.slice(e,r).indexOf(i.slice(n,s));if(f>-1)return[new kt(e,e+f,n,n),new kt(e+f+c,r,s,s)]}else if(c>l){let f=i.slice(n,s).indexOf(t.slice(e,r));if(f>-1)return[new kt(e,e,n,n+f),new kt(r,r,n+f+l,s)]}if(l==1||c==1)return[new kt(e,r,n,s)];let u=g2(t,e,r,i,n,s);if(u){let[f,d,h]=u;return Ma(t,e,f,i,n,d).concat(Ma(t,f+h,r,i,d+h,s))}return R4(t,e,r,i,n,s)}var Ou=1e9,Lu=0,xw=!1;function R4(t,e,r,i,n,s){let a=r-e,o=s-n;if(Ou<1e9&&Math.min(a,o)>Ou*16||Lu>0&&Date.now()>Lu)return Math.min(a,o)>Ou*64?[new kt(e,r,n,s)]:XT(t,e,r,i,n,s);let l=Math.ceil((a+o)/2);gw.reset(l),vw.reset(l);let c=(h,p)=>t.charCodeAt(e+h)==i.charCodeAt(n+p),u=(h,p)=>t.charCodeAt(r-h-1)==i.charCodeAt(s-p-1),f=(a-o)%2!=0?vw:null,d=f?null:gw;for(let h=0;h<l;h++){if(h>Ou||Lu>0&&!(h&63)&&Date.now()>Lu)return XT(t,e,r,i,n,s);let p=gw.advance(h,a,o,l,f,!1,c)||vw.advance(h,a,o,l,d,!0,u);if(p)return $4(t,e,r,e+p[0],i,n,s,n+p[1])}return[new kt(e,r,n,s)]}var Fh=class{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let r=0;r<this.len;r++)this.vec[r]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,r,i,n,s,a,o){for(let l=-e+this.start;l<=e-this.end;l+=2){let c=n+l,u=l==-e||l!=e&&this.vec[c-1]<this.vec[c+1]?this.vec[c+1]:this.vec[c-1]+1,f=u-l;for(;u<r&&f<i&&o(u,f);)u++,f++;if(this.vec[c]=u,u>r)this.end+=2;else if(f>i)this.start+=2;else if(s){let d=n+(r-i)-l;if(d>=0&&d<this.len&&s.vec[d]!=-1)if(a){let h=s.vec[d];if(h>=r-u)return[h,n+h-d]}else{let h=r-s.vec[d];if(u>=h)return[u,f]}}}return null}},gw=new Fh,vw=new Fh;function $4(t,e,r,i,n,s,a,o){let l=!1;return!Tl(t,i)&&++i==r&&(l=!0),!Tl(n,o)&&++o==a&&(l=!0),l?[new kt(e,r,s,a)]:Ma(t,e,i,n,s,o).concat(Ma(t,i,r,n,o,a))}function m2(t,e){let r=1,i=Math.min(t,e);for(;r<i;)r=r<<1;return r}function Ew(t,e,r,i,n,s){if(e==r||e==s||t.charCodeAt(e)!=i.charCodeAt(n))return 0;let a=m2(r-e,s-n);for(let o=e,l=n;;){let c=o+a,u=l+a;if(c>r||u>s||t.slice(o,c)!=i.slice(l,u)){if(a==1)return o-e-(Tl(t,o)?0:1);a=a>>1}else{if(c==r||u==s)return c-e;o=c,l=u}}}function Sw(t,e,r,i,n,s){if(e==r||n==s||t.charCodeAt(r-1)!=i.charCodeAt(s-1))return 0;let a=m2(r-e,s-n);for(let o=r,l=s;;){let c=o-a,u=l-a;if(c<e||u<n||t.slice(c,o)!=i.slice(u,l)){if(a==1)return r-o-(Tl(t,o)?0:1);a=a>>1}else{if(c==e||u==n)return r-c;o=c,l=u}}}function ww(t,e,r,i,n,s,a,o){let l=i.slice(n,s),c=null;for(;;){if(c||a<o)return c;for(let u=e+a;;){Tl(t,u)||u++;let f=u+a;if(Tl(t,f)||(f+=f==u+1?1:-1),f>=r)break;let d=t.slice(u,f),h=-1;for(;(h=l.indexOf(d,h+1))!=-1;){let p=Ew(t,f,r,i,n+h+d.length,s),g=Sw(t,e,u,i,n,n+h),v=d.length+p+g;(!c||c[2]<v)&&(c=[u-g,n+h-g,v])}u=f}if(o<0)return c;a=a>>1}}function g2(t,e,r,i,n,s){let a=r-e,o=s-n;if(a<o){let l=g2(i,n,s,t,e,r);return l&&[l[1],l[0],l[2]]}return a<4||o*2<a?null:ww(t,e,r,i,n,s,Math.floor(a/4),-1)}function XT(t,e,r,i,n,s){xw=!0;let a=r-e,o=s-n,l;if(a<o){let d=ww(i,n,s,t,e,r,Math.floor(a/6),50);l=d&&[d[1],d[0],d[2]]}else l=ww(t,e,r,i,n,s,Math.floor(o/6),50);if(!l)return[new kt(e,r,n,s)];let[c,u,f]=l;return Ma(t,e,c,i,n,u).concat(Ma(t,c+f,r,i,u+f,s))}function v2(t,e){for(let r=1;r<t.length;r++){let i=t[r-1],n=t[r];i.toA>n.fromA-e&&i.toB>n.fromB-e&&(t[r-1]=new kt(i.fromA,n.toA,i.fromB,n.toB),t.splice(r--,1))}}function F4(t,e,r){for(;;){v2(r,1);let i=!1;for(let n=0;n<r.length;n++){let s=r[n],a,o;(a=Ew(t,s.fromA,s.toA,e,s.fromB,s.toB))&&(s=r[n]=new kt(s.fromA+a,s.toA,s.fromB+a,s.toB)),(o=Sw(t,s.fromA,s.toA,e,s.fromB,s.toB))&&(s=r[n]=new kt(s.fromA,s.toA-o,s.fromB,s.toB-o));let l=s.toA-s.fromA,c=s.toB-s.fromB;if(l&&c)continue;let u=s.fromA-(n?r[n-1].toA:0),f=(n<r.length-1?r[n+1].fromA:t.length)-s.toA;if(!u||!f)continue;let d=l?t.slice(s.fromA,s.toA):e.slice(s.fromB,s.toB);u<=d.length&&t.slice(s.fromA-u,s.fromA)==d.slice(d.length-u)?(r[n]=new kt(s.fromA-u,s.toA-u,s.fromB-u,s.toB-u),i=!0):f<=d.length&&t.slice(s.toA,s.toA+f)==d.slice(0,f)&&(r[n]=new kt(s.fromA+f,s.toA+f,s.fromB+f,s.toB+f),i=!0)}if(!i)break}return r}function I4(t,e,r){for(let i=0,n=0;n<t.length;n++){let s=t[n],a=s.toA-s.fromA,o=s.toB-s.fromB;if(a&&o||a>3||o>3){let l=n==t.length-1?e.length:t[n+1].fromA,c=s.fromA-i,u=l-s.toA,f=JT(e,s.fromA,c),d=QT(e,s.toA,u),h=s.fromA-f,p=d-s.toA;if((!a||!o)&&h&&p){let g=Math.max(a,o),[v,b,_]=a?[e,s.fromA,s.toA]:[r,s.fromB,s.toB];g>h&&e.slice(f,s.fromA)==v.slice(_-h,_)?(s=t[n]=new kt(f,f+a,s.fromB-h,s.toB-h),f=s.fromA,d=QT(e,s.toA,l-s.toA)):g>p&&e.slice(s.toA,d)==v.slice(b,b+p)&&(s=t[n]=new kt(d-a,d,s.fromB+p,s.toB+p),d=s.
Line truncated
|
||||
`),s=e.split(`
|
||||
`);for(let a of r){let{oldStart:o,oldLines:l,newStart:c,newLines:u}=a,f=zt.createHunk(o,l,c,u);if(a.oldLines>0){for(let d=o;d<o+l;d++)f.removed.lines.push(n[d-1]);o+l>n.length&&n.last()!=""&&(f.removed.no_nl_at_eof=!0)}if(a.newLines>0){for(let d=c;d<c+u;d++)f.added.lines.push(s[d-1]);c+u>s.length&&s.last()!=""&&(f.added.no_nl_at_eof=!0)}i.push(f)}return i}function Tw(t,e,r){let i=e.lineAt(t.fromA).number,n=t.fromA==t.toA?0:Dh(e,t.endA)-i+1,s=r.lineAt(t.fromB).number,a=t.fromB==t.toB?0:Dh(r,t.endB)-s+1,o={oldStart:i,oldLines:n,newStart:s,newLines:a};return o.oldLines==0&&(o.oldStart-=1),o.newLines==0&&(o.newStart-=1),o}var T2={scanLimit:1e3,timeout:200};function Z4(t,e,r,i){let n=Cw.Text.of(t.split(`
|
||||
`)),s=Cw.Text.of(e.split(`
|
||||
`)),a=r&&i?Jn.updateB(r,n,s,i,T2):Jn.build(n,s,T2),o=[];for(let l=0;l<a.length;l++){let c=a[l],u=Tw(c,n,s);o.push(u)}return{hunks:Aw(t,e,o),chunks:a}}function P2(t,e,r,i){return Z4(t,e,r,i)}var es=require("obsidian"),Wi=class{static hasHunksData(e){let r=e.field(Gr,!1);return!!r&&!r.isDirty}static getHunks(e,r){let i=e.field(Gr);return i?r?i.stagedHunks:i.hunks:[]}static getHunkAtPos(e,r,i){if(!e.field(Gr))return;let s=e.doc.lineAt(r).number,a=this.getHunks(e,i);return zt.findHunk(s,a)[0]}static getCursorHunk(e,r){if(!e.field(Gr))return;let n=e.selection.main.head;return this.getHunkAtPos(e,n,r)}static getHunk(e,r,i){if(i!=null)return this.getHunkAtPos(e,i,r);if(e.selection.main.empty)return this.getCursorHunk(e,r);let n=e.selection.main.from,s=e.selection.main.to,a=e.doc.lineAt(n).number,o=Dh(e.doc,s),l=this.getHunks(e,r),c=zt.createPartialHunk(l,a,o);if(!c)return;let u=e.field(Gr);if(r){let f=a,d=o;for(let h of u.hunks)a>h.vend&&(f=f-(h.added.count-h.removed.count)),o>h.vend&&(d=d-(h.added.count-h.removed.count));c.added.lines=u.compareText.split(`
|
||||
`).slice(f-1,d),u.compareTextHead?c.removed.lines=u.compareTextHead.split(`
|
||||
`).slice(c.removed.start-1,c.removed.start-1+c.removed.count):c.removed.lines=[]}else c.added.lines=e.doc.toString().split(`
|
||||
`).slice(a-1,o),o===e.doc.lines&&!e.doc.toString().endsWith(`
|
||||
`)&&(c.added.no_nl_at_eof=!0),c.removed.lines=u.compareText.split(`
|
||||
`).slice(c.removed.start-1,c.removed.start-1+c.removed.count),c.removed.start+c.removed.count-1===u.compareText.split(`
|
||||
`).length&&!u.compareText.endsWith(`
|
||||
`)&&(c.removed.no_nl_at_eof=!0);return c}},Gr=Pl.StateField.define({create:t=>{},update:(t,e)=>{var n,s,a;let r=t?{...t}:{maxDiffTimeMs:0,hunks:[],stagedHunks:[],chunks:void 0,isDirty:!1},i=!1;for(let o of e.effects)if(o.is(Rl)&&(r.compareText=o.value.compareText,r.compareTextHead=o.value.compareTextHead,i=(t==null?void 0:t.compareText)!==o.value.compareText,i&&(r.chunks=void 0,r.changeDesc=void 0)),o.is(Oh)){let l=(n=e.startState.field(Bu,!1))==null?void 0:n.revision;if(o.value.revision!==l)continue;R2(r,o.value.result,e.state),r.changeDesc=void 0}if(e.docChanged){let o=!r.changeDesc||r.changeDesc.newLength===e.changes.length;console.assert(o,"Git: Hunk changes belong to different document histories."),o||(r.chunks=void 0),r.changeDesc=K4(r.changeDesc,e.changes)}if(r.compareText!==void 0){if(i||e.docChanged){r.isDirty=!0;let o=X4(e,r.compareText,r.chunks,r.changeDesc,r.maxDiffTimeMs);o&&(R2(r,o,e.state),r.changeDesc=void 0)}}else{r.compareText=void 0,r.compareTextHead=void 0,r.chunks=void 0,r.hunks=[],r.stagedHunks=[],r.isDirty=!1;let o=e.state.field(es.editorInfoField).file;(a=(s=It.plugin)==null?void 0:s.editorIntegration.signsFeature.changeStatusBar)==null||a.display(r.hunks,o)}return r}});function R2(t,e,r){var n,s;t.hunks=e.hunks,t.chunks=e.chunks,t.isDirty=!1,t.maxDiffTimeMs=Math.max(.95*t.maxDiffTimeMs,e.diffDuration);let i=r.field(es.editorInfoField).file;(s=(n=It.plugin)==null?void 0:n.editorIntegration.signsFeature.changeStatusBar)==null||s.display(t.hunks,i)}var Bu=Pl.StateField.define({create:t=>{var e,r;return{debouncer:(0,es.debounce)(i=>{let{state:n,compareText:s,previousChunks:a,changeDesc:o,revision:l}=i,c=n.field(es.editorEditorField,!1);if(!c)return;let u=c.state.field(Bu,!1);if((u==null?void 0:u.revision)!==l)return;let f=$2(n,s,a,o);c.dispatch({effects:Oh.of({result:f,revision:l})})},1e3,!0),revision:{},filePath:(r=(e=t.field(es.editorInfoField,!1))==null?void 0:e.file)==null?void 0:r.path}},update:(t,e)=>{var i,n;let r=(n=(i=e.state.field(es.editorInfoField,!1))==null?void 0:i.file)==null?void 0:n.path;return e.docChanged||r!==t.filePath?{...t,revision:{},filePath:r}:t}});function K4(t,e){return!t||t.newLength!==e.length?e:t.composeDesc(e)}function $2(t,e,r,i){let n=t.doc.toString(),s=performance.now(),{hunks:a,chunks:o}=P2(e,n,r,i),l=performance.now()-s;return{hunks:a,chunks:o,diffDuration:l}}function X4(t,e,r,i,n){let s=t.state,a=Math.abs(t.changes.length-t.changes.newLength),o=s.field(Bu);if(a>1e3||n>16){o.debouncer({state:s,compareText:e,previousChunks:r,changeDesc:i,revision:o.revision});return}else return $2(s,e,r,i)}var Rl=Pl.StateEffect.define(),Oh=Pl.StateEffect.define();function F2(t,e){return e.update({effects:Rl.of(t)})}m();m();m();var st;(function(t){t.INSERT="insert",t.DELETE="delete",t.CONTEXT="context"})(st||(st={}));var I2={LINE_BY_LINE:"line-by-line",SIDE_BY_SIDE:"side-by-side"},M2={LINES:"lines",WORDS:"words",NONE:"none"},D2={WORD:"word",CHAR:"char"},Da;(function(t){t.AUTO="auto",t.DARK="dark",t.LIGHT="light"})(Da||(Da={}));m();var Q4=["-","[","]","/","{","}","(",")","*","+","?",".","\\","^","$","|"],J4=RegExp("["+Q4.join("\\")+"]","g");function O2(t){return t.replace(J4,"\\$&")}function Pw(t){return t&&t.replace(/\\/g,"/")}function L2(t){let e,r,i,n=0;for(e=0,i=t.length;e<i;e++)r=t.charCodeAt(e),n=(n<<5)-n+r,n|=0;return n}function Lh(t){let e=t.length,r=-1/0;for(let i=0;i<e;i++)r=Math.max(r,t[i]);return r}function N2(t,e){let r=t.split(".");return r.length>1?r[r.length-1]:e}function B2(t,e){return e.reduce((r,i)=>r||t.startsWith(i),!1)}var H2=["a/","b/","i/","w/","c/","o/"];function Gs(t,e,r){let i=r!==void 0?[...H2,r]:H2,n=e?new RegExp(`^${O2(e)} "?(.+?)"?$`):new RegExp('^"?(.+?)"?$'),[,s=""]=n.exec(t)||[],a=i.find(l=>s.indexOf(l)===0);return(a?s.slice(a.length):s).replace(/\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [+-]\d{4}.*$/,"")}function e5(t,e){return Gs(t,"---",e)}function t5(t,e){return Gs(t,"+++",e)}function U2(t,e={}){let r=[],i=null,n=null,s=null,a=null,o=null,l=null,c=null,u="--- ",f="+++ ",d="@@",h=/^old mode (\d{6})/,p=/^new mode (\d{6})/,g=/^deleted file mode (\d{6})/,v=/^new file mode (\d{6})/,b=/^copy from "?(.+)"?/,_=/^copy to "?(.+)"?/,C=/^rename from "?(.+)"?/,x=/^rename to "?(.+)"?/,S=/^similarity index (\d+)%/,A=/^dissimilarity index (\d+)%/,w=/^index ([\da-z]+)\.\.([\da-z]+)\s*(\d{6})?/,E=/^Binary files (.*) and (.*) differ/,y=/^GIT binary patch/,P=/^index ([\da-z]+),([\da-z]+)\.\.([\da-z]+)/,T=/^mode (\d{6}),(\d{6})\.\.(\d{6})/,I=/^new file mode (\d{6})/,L=/^deleted file mode (\d{6}),(\d{6})/,H=t.replace(/\\ No newline at end of file/g,"").replace(/\r\n?/g,`
|
||||
`).split(`
|
||||
`);function te(){n!==null&&i!==null&&(i.blocks.push(n),n=null)}function xe(){i!==null&&(!i.oldName&&l!==null&&(i.oldName=l),!i.newName&&c!==null&&(i.newName=c),i.newName&&(r.push(i),i=null)),l=null,c=null}function Z(){te(),xe(),i={blocks:[],deletedLines:0,addedLines:0}}function K(W){te();let X;i!==null&&((X=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(W))?(i.isCombined=!1,s=parseInt(X[1],10),o=parseInt(X[2],10)):(X=/^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(W))?(i.isCombined=!0,s=parseInt(X[1],10),a=parseInt(X[2],10),o=parseInt(X[3],10)):(W.startsWith(d)&&console.error("Failed to parse lines, starting in 0!"),s=0,o=0,i.isCombined=!1)),n={lines:[],oldStartLine:s,oldStartLine2:a,newStartLine:o,header:W}}function ce(W){if(i===null||n===null||s===null||o===null)return;let X={content:W},G=i.isCombined?["+ "," +","++"]:["+"],Be=i.isCombined?["- "," -","--"]:["-"];B2(W,G)?(i.addedLines++,X.type=st.INSERT,X.oldNumber=void 0,X.newNumber=o++):B2(W,Be)?(i.deletedLines++,X.type=st.DELETE,X.oldNumber=s++,X.newNumber=void 0):(X.type=st.CONTEXT,X.oldNumber=s++,X.newNumber=o++),n.lines.push(X)}function pe(W,X){let G=X;for(;G<H.length-3;){if(W.startsWith("diff"))return!1;if(H[G].startsWith(u)&&H[G+1].startsWith(f)&&H[G+2].startsWith(d))return!0;G++}return!1}return H.forEach((W,X)=>{if(!W||W.startsWith("*"))return;let G,Be=H[X-1],pr=H[X+1],Ut=H[X+2];if(W.startsWith("diff --git")||W.startsWith("diff --combined")){if(Z(),(G=/^diff --git "?([a-ciow]\/.+)"? "?([a-ciow]\/.+)"?/.exec(W))&&(l=Gs(G[1],void 0,e.dstPrefix),c=Gs(G[2],void 0,e.srcPrefix)),i===null)throw new Error("Where is my file !!!");i.isGitDiff=!0;return}if(W.startsWith("Binary files")&&!(i!=null&&i.isGitDiff)){if(Z(),(G=/^Binary files "?([a-ciow]\/.+)"? and "?([a-ciow]\/.+)"? differ/.exec(W))&&(l=Gs(G[1],void 0,e.dstPrefix),c=Gs(G[2],void 0,e.srcPrefix)),i===null)throw new Error("Where is my file !!!");i.isBinary=!0;return}if((!i||!i.isGitDiff&&i&&W.startsWith(u)&&pr.startsWith(f)&&Ut.startsWith(d))&&Z(),i!=null&&i.isTooBig)return;if(i&&(typeof e.diffMaxChanges=="number"&&i.addedLines+i.deletedLines>e.diffMaxChanges||typeof e.diffMaxLineLength=="number"&&W.length>e.diffMaxLineLength)){i.isTooBig=!0,i.addedLines=0,i.deletedLines=0,i.blocks=[],n=null;let Rt=typeof e.diffTooBigMessage=="function"?e.diffTooBigMessage(r.length):"Diff too big to be displayed";K(Rt);return}if(W.startsWith(u)&&pr.startsWith(f)||W.startsWith(f)&&Be.startsWith(u)){if(i&&!i.oldName&&W.startsWith("--- ")&&(G=e5(W,e.srcPrefix))){i.oldName=G,i.language=N2(i.oldName,i.language);return}if(i&&!i.newName&&W.startsWith("+++ ")&&(G=t5(W,e.dstPrefix))){i.newName=G,i.language=N2(i.newName,i.language);return}}if(i&&(W.startsWith(d)||i.isGitDiff&&i.oldName&&i.newName&&!n)){K(W);return}if(n&&(W.startsWith("+")||W.startsWith("-")||W.startsWith(" "))){ce(W);return}let Ie=!pe(W,X);if(i===null)throw new Error("Where is my file !!!");(G=h.exec(W))?i.oldMode=G[1]:(G=p.exec(W))?i.newMode=G[1]:(G=g.exec(W))?(i.deletedFileMode=G[1],i.isDeleted=!0):(G=v.exec(W))?(i.newFileMode=G[1],i.isNew=!0):(G=b.exec(W))?(Ie&&(i.oldName=G[1]),i.isCopy=!0):(G=_.exec(W))?(Ie&&(i.newName=G[1]),i.isCopy=!0):(G=C.exec(W))?(Ie&&(i.oldName=G[1]),i.isRename=!0):(G=x.exec(W))?(Ie&&(i.newName=G[1]),i.isRename=!0):(G=E.exec(W))?(i.isBinary=!0,i.oldName=Gs(G[1],void 0,e.srcPrefix),i.newName=Gs(G[2],void 0,e.dstPrefix),K("Binary file")):y.test(W)?(i.isBinary=!0,K(W)):(G=S.exec(W))?i.unchangedPercentage=parseInt(G[1],10):(G=A.exec(W))?i.changedPercentage=parseInt(G[1],10):(G=w.exec(W))?(i.checksumBefore=G[1],i.checksumAfter=G[2],G[3]&&(i.mode=G[3])):(G=P.exec(W))?(i.checksumBefore=[G[2],G[3]],i.checksumAfter=G[1]):(G=T.exec(W))?(i.oldMode=[G[2],G[3]],i.newMode=G[1]):(G=I.exec(W))?(i.newFileMode=G[1],i.isNew=!0):(G=L.exec(W))&&(i.deletedFileMode=G[1],i.isDeleted=!0)}),te(),xe(),r}m();m();m();m();var js=class{diff(e,r,i={}){let n;typeof i=="function"?(n=i,i={}):"callback"in i&&(n=i.callback);let s=this.castInput(e,i),a=this.castInput(r,i),o=this.removeEmpty(this.tokenize(s,i)),l=this.removeEmpty(this.tokenize(a,i));return this.diffWithOptionsObj(o,l,i,n)}diffWithOptionsObj(e,r,i,n){var s;let a=_=>{if(_=this.postProcess(_,i),n){setTimeout(function(){n(_)},0);return}else return _},o=r.length,l=e.length,c=1,u=o+l;i.maxEditLength!=null&&(u=Math.min(u,i.maxEditLength));let f=(s=i.timeout)!==null&&s!==void 0?s:1/0,d=Date.now()+f,h=[{oldPos:-1,lastComponent:void 0}],p=this.extractCommon(h[0],r,e,0,i);if(h[0].oldPos+1>=l&&p+1>=o)return a(this.buildValues(h[0].lastComponent,r,e));let g=-1/0,v=1/0,b=()=>{for(let _=Math.max(g,-c);_<=Math.min(v,c);_+=2){let C,x=h[_-1],S=h[_+1];x&&(h[_-1]=void 0);let A=!1;if(S){let E=S.oldPos-_;A=S&&0<=E&&E<o}let w=x&&x.oldPos+1<l;if(!A&&!w){h[_]=void 0;continue}if(!w||A&&x.oldPos<S.oldPos?C=this.addToPath(S,!0,!1,0,i):C=this.addToPath(x,!1,!0,1,i),p=this.extractCommon(C,r,e,_,i),C.oldPos+1>=l&&p+1>=o)return a(this.buildValues(C.lastComponent,r,e))||!0;h[_]=C,C.oldPos+1>=l&&(v=Math.min(v,_-1)),p+
Line truncated
|
||||
`);return this.hoganUtils.render(W2,"wrapper",{colorScheme:Ol(this.config.colorScheme),filesNumber:e.length,files:r})}};m();var Gw=Object.assign(Object.assign({},La),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),Uu="generic",q2="line-by-line",p5="icon",m5="tag",Gu=class{constructor(e,r={}){this.hoganUtils=e,this.config=Object.assign(Object.assign({},Gw),r)}render(e){let r=e.map(i=>{let n;return i.blocks.length?n=this.generateFileHtml(i):n=this.generateEmptyDiff(),this.makeFileDiffHtml(i,n)}).join(`
|
||||
`);return this.hoganUtils.render(Uu,"wrapper",{colorScheme:Ol(this.config.colorScheme),content:r})}makeFileDiffHtml(e,r){if(this.config.renderNothingWhenEmpty&&Array.isArray(e.blocks)&&e.blocks.length===0)return"";let i=this.hoganUtils.template(q2,"file-diff"),n=this.hoganUtils.template(Uu,"file-path"),s=this.hoganUtils.template(p5,"file"),a=this.hoganUtils.template(m5,Nl(e));return i.render({file:e,fileHtmlId:Ll(e),diffs:r,filePath:n.render({fileDiffName:Na(e)},{fileIcon:s,fileTag:a})})}generateEmptyDiff(){return this.hoganUtils.render(Uu,"empty-diff",{contentClass:"d2h-code-line",CSSLineClass:Qt})}generateFileHtml(e){let r=Ml(Il(i=>Ci(i.content,e.isCombined).content));return e.blocks.map(i=>{let n=this.hoganUtils.render(Uu,"block-header",{CSSLineClass:Qt,blockHeader:e.isTooBig?i.header:Vs(i.header),lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line"});return this.applyLineGroupping(i).forEach(([s,a,o])=>{if(a.length&&o.length&&!s.length)this.applyRematchMatching(a,o,r).map(([l,c])=>{let{left:u,right:f}=this.processChangedLines(e,e.isCombined,l,c);n+=u,n+=f});else if(s.length)s.forEach(l=>{let{prefix:c,content:u}=Ci(l.content,e.isCombined);n+=this.generateSingleLineHtml(e,{type:Qt.CONTEXT,prefix:c,content:u,oldNumber:l.oldNumber,newNumber:l.newNumber})});else if(a.length||o.length){let{left:l,right:c}=this.processChangedLines(e,e.isCombined,a,o);n+=l,n+=c}else console.error("Unknown state reached while processing groups of lines",s,a,o)}),n}).join(`
|
||||
`)}applyLineGroupping(e){let r=[],i=[],n=[];for(let s=0;s<e.lines.length;s++){let a=e.lines[s];(a.type!==st.INSERT&&n.length||a.type===st.CONTEXT&&i.length>0)&&(r.push([[],i,n]),i=[],n=[]),a.type===st.CONTEXT?r.push([[a],[],[]]):a.type===st.INSERT&&i.length===0?r.push([[],[],[a]]):a.type===st.INSERT&&i.length>0?n.push(a):a.type===st.DELETE&&i.push(a)}return(i.length||n.length)&&(r.push([[],i,n]),i=[],n=[]),r}applyRematchMatching(e,r,i){let n=e.length*r.length,s=Lh(e.concat(r).map(o=>o.content.length));return n<this.config.matchingMaxComparisons&&s<this.config.maxLineSizeInBlockForComparison&&(this.config.matching==="lines"||this.config.matching==="words")?i(e,r):[[e,r]]}processChangedLines(e,r,i,n){let s={right:"",left:""},a=Math.max(i.length,n.length);for(let o=0;o<a;o++){let l=i[o],c=n[o],u=l!==void 0&&c!==void 0?Gh(l.content,c.content,r,this.config):void 0,f=l!==void 0&&l.oldNumber!==void 0?Object.assign(Object.assign({},u!==void 0?{prefix:u.oldLine.prefix,content:u.oldLine.content,type:Qt.DELETE_CHANGES}:Object.assign(Object.assign({},Ci(l.content,r)),{type:Dl(l.type)})),{oldNumber:l.oldNumber,newNumber:l.newNumber}):void 0,d=c!==void 0&&c.newNumber!==void 0?Object.assign(Object.assign({},u!==void 0?{prefix:u.newLine.prefix,content:u.newLine.content,type:Qt.INSERT_CHANGES}:Object.assign(Object.assign({},Ci(c.content,r)),{type:Dl(c.type)})),{oldNumber:c.oldNumber,newNumber:c.newNumber}):void 0,{left:h,right:p}=this.generateLineHtml(e,f,d);s.left+=h,s.right+=p}return s}generateLineHtml(e,r,i){return{left:this.generateSingleLineHtml(e,r),right:this.generateSingleLineHtml(e,i)}}generateSingleLineHtml(e,r){if(r===void 0)return"";let i=this.hoganUtils.render(q2,"numbers",{oldNumber:r.oldNumber||"",newNumber:r.newNumber||""});return this.hoganUtils.render(Uu,"line",{type:r.type,lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line",prefix:r.prefix===" "?" ":r.prefix,content:r.content,lineNumber:i,line:r,file:e})}};m();var jw=Object.assign(Object.assign({},La),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),ju="generic",g5="side-by-side",v5="icon",w5="tag",Vu=class{constructor(e,r={}){this.hoganUtils=e,this.config=Object.assign(Object.assign({},jw),r)}render(e){let r=e.map(i=>{let n;return i.blocks.length?n=this.generateFileHtml(i):n=this.generateEmptyDiff(),this.makeFileDiffHtml(i,n)}).join(`
|
||||
`);return this.hoganUtils.render(ju,"wrapper",{colorScheme:Ol(this.config.colorScheme),content:r})}makeFileDiffHtml(e,r){if(this.config.renderNothingWhenEmpty&&Array.isArray(e.blocks)&&e.blocks.length===0)return"";let i=this.hoganUtils.template(g5,"file-diff"),n=this.hoganUtils.template(ju,"file-path"),s=this.hoganUtils.template(v5,"file"),a=this.hoganUtils.template(w5,Nl(e));return i.render({file:e,fileHtmlId:Ll(e),diffs:r,filePath:n.render({fileDiffName:Na(e)},{fileIcon:s,fileTag:a})})}generateEmptyDiff(){return{right:"",left:this.hoganUtils.render(ju,"empty-diff",{contentClass:"d2h-code-side-line",CSSLineClass:Qt})}}generateFileHtml(e){let r=Ml(Il(i=>Ci(i.content,e.isCombined).content));return e.blocks.map(i=>{let n={left:this.makeHeaderHtml(i.header,e),right:this.makeHeaderHtml("")};return this.applyLineGroupping(i).forEach(([s,a,o])=>{if(a.length&&o.length&&!s.length)this.applyRematchMatching(a,o,r).map(([l,c])=>{let{left:u,right:f}=this.processChangedLines(e.isCombined,l,c);n.left+=u,n.right+=f});else if(s.length)s.forEach(l=>{let{prefix:c,content:u}=Ci(l.content,e.isCombined),{left:f,right:d}=this.generateLineHtml({type:Qt.CONTEXT,prefix:c,content:u,number:l.oldNumber},{type:Qt.CONTEXT,prefix:c,content:u,number:l.newNumber});n.left+=f,n.right+=d});else if(a.length||o.length){let{left:l,right:c}=this.processChangedLines(e.isCombined,a,o);n.left+=l,n.right+=c}else console.error("Unknown state reached while processing groups of lines",s,a,o)}),n}).reduce((i,n)=>({left:i.left+n.left,right:i.right+n.right}),{left:"",right:""})}applyLineGroupping(e){let r=[],i=[],n=[];for(let s=0;s<e.lines.length;s++){let a=e.lines[s];(a.type!==st.INSERT&&n.length||a.type===st.CONTEXT&&i.length>0)&&(r.push([[],i,n]),i=[],n=[]),a.type===st.CONTEXT?r.push([[a],[],[]]):a.type===st.INSERT&&i.length===0?r.push([[],[],[a]]):a.type===st.INSERT&&i.length>0?n.push(a):a.type===st.DELETE&&i.push(a)}return(i.length||n.length)&&(r.push([[],i,n]),i=[],n=[]),r}applyRematchMatching(e,r,i){let n=e.length*r.length,s=Lh(e.concat(r).map(o=>o.content.length));return n<this.config.matchingMaxComparisons&&s<this.config.maxLineSizeInBlockForComparison&&(this.config.matching==="lines"||this.config.matching==="words")?i(e,r):[[e,r]]}makeHeaderHtml(e,r){return this.hoganUtils.render(ju,"block-header",{CSSLineClass:Qt,blockHeader:r!=null&&r.isTooBig?e:Vs(e),lineClass:"d2h-code-side-linenumber",contentClass:"d2h-code-side-line"})}processChangedLines(e,r,i){let n={right:"",left:""},s=Math.max(r.length,i.length);for(let a=0;a<s;a++){let o=r[a],l=i[a],c=o!==void 0&&l!==void 0?Gh(o.content,l.content,e,this.config):void 0,u=o!==void 0&&o.oldNumber!==void 0?Object.assign(Object.assign({},c!==void 0?{prefix:c.oldLine.prefix,content:c.oldLine.content,type:Qt.DELETE_CHANGES}:Object.assign(Object.assign({},Ci(o.content,e)),{type:Dl(o.type)})),{number:o.oldNumber}):void 0,f=l!==void 0&&l.newNumber!==void 0?Object.assign(Object.assign({},c!==void 0?{prefix:c.newLine.prefix,content:c.newLine.content,type:Qt.INSERT_CHANGES}:Object.assign(Object.assign({},Ci(l.content,e)),{type:Dl(l.type)})),{number:l.newNumber}):void 0,{left:d,right:h}=this.generateLineHtml(u,f);n.left+=d,n.right+=h}return n}generateLineHtml(e,r){return{left:this.generateSingleHtml(e),right:this.generateSingleHtml(r)}}generateSingleHtml(e){let r="d2h-code-side-linenumber",i="d2h-code-side-line";return this.hoganUtils.render(ju,"line",{type:(e==null?void 0:e.type)||`${Qt.CONTEXT} d2h-emptyplaceholder`,lineClass:e!==void 0?r:`${r} d2h-code-side-emptyplaceholder`,contentClass:e!==void 0?i:`${i} d2h-code-side-emptyplaceholder`,prefix:(e==null?void 0:e.prefix)===" "?" ":e==null?void 0:e.prefix,content:e==null?void 0:e.content,lineNumber:e==null?void 0:e.number})}};m();var qw=ft(Ww());m();var Ct=ft(Ww()),xt={};xt["file-summary-line"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<li class="d2h-file-list-line">'),i.b(`
|
||||
`+r),i.b(' <span class="d2h-file-name-wrapper">'),i.b(`
|
||||
`+r),i.b(i.rp("<fileIcon0",t,e," ")),i.b(' <a href="#'),i.b(i.v(i.f("fileHtmlId",t,e,0))),i.b('" class="d2h-file-name">'),i.b(i.v(i.f("fileName",t,e,0))),i.b("</a>"),i.b(`
|
||||
`+r),i.b(' <span class="d2h-file-stats">'),i.b(`
|
||||
`+r),i.b(' <span class="d2h-lines-added">'),i.b(i.v(i.f("addedLines",t,e,0))),i.b("</span>"),i.b(`
|
||||
`+r),i.b(' <span class="d2h-lines-deleted">'),i.b(i.v(i.f("deletedLines",t,e,0))),i.b("</span>"),i.b(`
|
||||
`+r),i.b(" </span>"),i.b(`
|
||||
`+r),i.b(" </span>"),i.b(`
|
||||
`+r),i.b("</li>"),i.fl()},partials:{"<fileIcon0":{name:"fileIcon",partials:{},subs:{}}},subs:{}});xt["file-summary-wrapper"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<div class="d2h-file-list-wrapper '),i.b(i.v(i.f("colorScheme",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(' <div class="d2h-file-list-header">'),i.b(`
|
||||
`+r),i.b(' <span class="d2h-file-list-title">Files changed ('),i.b(i.v(i.f("filesNumber",t,e,0))),i.b(")</span>"),i.b(`
|
||||
`+r),i.b(' <a class="d2h-file-switch d2h-hide">hide</a>'),i.b(`
|
||||
`+r),i.b(' <a class="d2h-file-switch d2h-show">show</a>'),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(' <ol class="d2h-file-list">'),i.b(`
|
||||
`+r),i.b(" "),i.b(i.t(i.f("files",t,e,0))),i.b(`
|
||||
`+r),i.b(" </ol>"),i.b(`
|
||||
`+r),i.b("</div>"),i.fl()},partials:{},subs:{}});xt["generic-block-header"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b("<tr>"),i.b(`
|
||||
`+r),i.b(' <td class="'),i.b(i.v(i.f("lineClass",t,e,0))),i.b(" "),i.b(i.v(i.d("CSSLineClass.INFO",t,e,0))),i.b('"></td>'),i.b(`
|
||||
`+r),i.b(' <td class="'),i.b(i.v(i.d("CSSLineClass.INFO",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(' <div class="'),i.b(i.v(i.f("contentClass",t,e,0))),i.b('">'),i.s(i.f("blockHeader",t,e,1),t,e,0,156,173,"{{ }}")&&(i.rs(t,e,function(n,s,a){a.b(a.t(a.f("blockHeader",n,s,0)))}),t.pop()),i.s(i.f("blockHeader",t,e,1),t,e,1,0,0,"")||i.b(" "),i.b("</div>"),i.b(`
|
||||
`+r),i.b(" </td>"),i.b(`
|
||||
`+r),i.b("</tr>"),i.fl()},partials:{},subs:{}});xt["generic-empty-diff"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b("<tr>"),i.b(`
|
||||
`+r),i.b(' <td class="'),i.b(i.v(i.d("CSSLineClass.INFO",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(' <div class="'),i.b(i.v(i.f("contentClass",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(" File without changes"),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(" </td>"),i.b(`
|
||||
`+r),i.b("</tr>"),i.fl()},partials:{},subs:{}});xt["generic-file-path"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<span class="d2h-file-name-wrapper">'),i.b(`
|
||||
`+r),i.b(i.rp("<fileIcon0",t,e," ")),i.b(' <span class="d2h-file-name">'),i.b(i.v(i.f("fileDiffName",t,e,0))),i.b("</span>"),i.b(`
|
||||
`+r),i.b(i.rp("<fileTag1",t,e," ")),i.b("</span>"),i.b(`
|
||||
`+r),i.b('<label class="d2h-file-collapse">'),i.b(`
|
||||
`+r),i.b(' <input class="d2h-file-collapse-input" type="checkbox" name="viewed" value="viewed">'),i.b(`
|
||||
`+r),i.b(" Viewed"),i.b(`
|
||||
`+r),i.b("</label>"),i.fl()},partials:{"<fileIcon0":{name:"fileIcon",partials:{},subs:{}},"<fileTag1":{name:"fileTag",partials:{},subs:{}}},subs:{}});xt["generic-line"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b("<tr>"),i.b(`
|
||||
`+r),i.b(' <td class="'),i.b(i.v(i.f("lineClass",t,e,0))),i.b(" "),i.b(i.v(i.f("type",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(" "),i.b(i.t(i.f("lineNumber",t,e,0))),i.b(`
|
||||
`+r),i.b(" </td>"),i.b(`
|
||||
`+r),i.b(' <td class="'),i.b(i.v(i.f("type",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(' <div class="'),i.b(i.v(i.f("contentClass",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.s(i.f("prefix",t,e,1),t,e,0,162,238,"{{ }}")&&(i.rs(t,e,function(n,s,a){a.b(' <span class="d2h-code-line-prefix">'),a.b(a.t(a.f("prefix",n,s,0))),a.b("</span>"),a.b(`
|
||||
`+r)}),t.pop()),i.s(i.f("prefix",t,e,1),t,e,1,0,0,"")||(i.b(' <span class="d2h-code-line-prefix"> </span>'),i.b(`
|
||||
`+r)),i.s(i.f("content",t,e,1),t,e,0,371,445,"{{ }}")&&(i.rs(t,e,function(n,s,a){a.b(' <span class="d2h-code-line-ctn">'),a.b(a.t(a.f("content",n,s,0))),a.b("</span>"),a.b(`
|
||||
`+r)}),t.pop()),i.s(i.f("content",t,e,1),t,e,1,0,0,"")||(i.b(' <span class="d2h-code-line-ctn"><br></span>'),i.b(`
|
||||
`+r)),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(" </td>"),i.b(`
|
||||
`+r),i.b("</tr>"),i.fl()},partials:{},subs:{}});xt["generic-wrapper"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<div class="d2h-wrapper '),i.b(i.v(i.f("colorScheme",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(" "),i.b(i.t(i.f("content",t,e,0))),i.b(`
|
||||
`+r),i.b("</div>"),i.fl()},partials:{},subs:{}});xt["icon-file-added"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<svg aria-hidden="true" class="d2h-icon d2h-added" height="16" title="added" version="1.1" viewBox="0 0 14 16"'),i.b(`
|
||||
`+r),i.b(' width="14">'),i.b(`
|
||||
`+r),i.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z"></path>'),i.b(`
|
||||
`+r),i.b("</svg>"),i.fl()},partials:{},subs:{}});xt["icon-file-changed"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"'),i.b(`
|
||||
`+r),i.b(' viewBox="0 0 14 16" width="14">'),i.b(`
|
||||
`+r),i.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>'),i.b(`
|
||||
`+r),i.b("</svg>"),i.fl()},partials:{},subs:{}});xt["icon-file-deleted"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<svg aria-hidden="true" class="d2h-icon d2h-deleted" height="16" title="removed" version="1.1"'),i.b(`
|
||||
`+r),i.b(' viewBox="0 0 14 16" width="14">'),i.b(`
|
||||
`+r),i.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM11 9H3V7h8v2z"></path>'),i.b(`
|
||||
`+r),i.b("</svg>"),i.fl()},partials:{},subs:{}});xt["icon-file-renamed"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<svg aria-hidden="true" class="d2h-icon d2h-moved" height="16" title="renamed" version="1.1"'),i.b(`
|
||||
`+r),i.b(' viewBox="0 0 14 16" width="14">'),i.b(`
|
||||
`+r),i.b(' <path d="M6 9H3V7h3V4l5 4-5 4V9z m8-7v12c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h12c0.55 0 1 0.45 1 1z m-1 0H1v12h12V2z"></path>'),i.b(`
|
||||
`+r),i.b("</svg>"),i.fl()},partials:{},subs:{}});xt["icon-file"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">'),i.b(`
|
||||
`+r),i.b(' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>'),i.b(`
|
||||
`+r),i.b("</svg>"),i.fl()},partials:{},subs:{}});xt["line-by-line-file-diff"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<div id="'),i.b(i.v(i.f("fileHtmlId",t,e,0))),i.b('" class="d2h-file-wrapper" data-lang="'),i.b(i.v(i.d("file.language",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(' <div class="d2h-file-header">'),i.b(`
|
||||
`+r),i.b(" "),i.b(i.t(i.f("filePath",t,e,0))),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(' <div class="d2h-file-diff">'),i.b(`
|
||||
`+r),i.b(' <div class="d2h-code-wrapper">'),i.b(`
|
||||
`+r),i.b(' <table class="d2h-diff-table">'),i.b(`
|
||||
`+r),i.b(' <tbody class="d2h-diff-tbody">'),i.b(`
|
||||
`+r),i.b(" "),i.b(i.t(i.f("diffs",t,e,0))),i.b(`
|
||||
`+r),i.b(" </tbody>"),i.b(`
|
||||
`+r),i.b(" </table>"),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b("</div>"),i.fl()},partials:{},subs:{}});xt["line-by-line-numbers"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<div class="line-num1">'),i.b(i.v(i.f("oldNumber",t,e,0))),i.b("</div>"),i.b(`
|
||||
`+r),i.b('<div class="line-num2">'),i.b(i.v(i.f("newNumber",t,e,0))),i.b("</div>"),i.fl()},partials:{},subs:{}});xt["side-by-side-file-diff"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<div id="'),i.b(i.v(i.f("fileHtmlId",t,e,0))),i.b('" class="d2h-file-wrapper" data-lang="'),i.b(i.v(i.d("file.language",t,e,0))),i.b('">'),i.b(`
|
||||
`+r),i.b(' <div class="d2h-file-header">'),i.b(`
|
||||
`+r),i.b(" "),i.b(i.t(i.f("filePath",t,e,0))),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(' <div class="d2h-files-diff">'),i.b(`
|
||||
`+r),i.b(' <div class="d2h-file-side-diff">'),i.b(`
|
||||
`+r),i.b(' <div class="d2h-code-wrapper">'),i.b(`
|
||||
`+r),i.b(' <table class="d2h-diff-table">'),i.b(`
|
||||
`+r),i.b(' <tbody class="d2h-diff-tbody">'),i.b(`
|
||||
`+r),i.b(" "),i.b(i.t(i.d("diffs.left",t,e,0))),i.b(`
|
||||
`+r),i.b(" </tbody>"),i.b(`
|
||||
`+r),i.b(" </table>"),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(' <div class="d2h-file-side-diff">'),i.b(`
|
||||
`+r),i.b(' <div class="d2h-code-wrapper">'),i.b(`
|
||||
`+r),i.b(' <table class="d2h-diff-table">'),i.b(`
|
||||
`+r),i.b(' <tbody class="d2h-diff-tbody">'),i.b(`
|
||||
`+r),i.b(" "),i.b(i.t(i.d("diffs.right",t,e,0))),i.b(`
|
||||
`+r),i.b(" </tbody>"),i.b(`
|
||||
`+r),i.b(" </table>"),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b(" </div>"),i.b(`
|
||||
`+r),i.b("</div>"),i.fl()},partials:{},subs:{}});xt["tag-file-added"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<span class="d2h-tag d2h-added d2h-added-tag">ADDED</span>'),i.fl()},partials:{},subs:{}});xt["tag-file-changed"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span>'),i.fl()},partials:{},subs:{}});xt["tag-file-deleted"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<span class="d2h-tag d2h-deleted d2h-deleted-tag">DELETED</span>'),i.fl()},partials:{},subs:{}});xt["tag-file-renamed"]=new Ct.Template({code:function(t,e,r){var i=this;return i.b(r=r||""),i.b('<span class="d2h-tag d2h-moved d2h-moved-tag">RENAMED</span>'),i.fl()},partials:{},subs:{}});var zu=class{constructor({compiledTemplates:e={},rawTemplates:r={}}){let i=Object.entries(r).reduce((n,[s,a])=>{let o=qw.compile(a,{asString:!1});return Object.assign(Object.assign({},n),{[s]:o})},{});this.preCompiledTemplates=Object.assign(Object.assign(Object.assign({},xt),e),i)}static compile(e){return qw.compile(e,{asString:!1})}render(e,r,i,n,s){let a=this.templateKey(e,r);try{return this.preCompiledTemplates[a].render(i,n,s)}catch(o){throw new Error(`Could not find template to render '${a}'`)}}template(e,r){return this.preCompiledTemplates[this.templateKey(e,r)]}templateKey(e,r){return`${e}-${r}`}};var _5=Object.assign(Object.assign(Object.assign({},Gw),jw),{outputFormat:I2.LINE_BY_LINE,drawFileList:!0});function zh(t,e={}){let r=Object.assign(Object.assign({},_5),e),i=typeof t=="string"?U2(t,r):t,n=new zu(r),{colorScheme:s}=r,a={colorScheme:s},o=r.drawFileList?new jh(n,a).render(i):"",l=r.outputFormat==="side-by-side"?new Vu(n,r).render(i):new Gu(n,r).render(i);return o+l}var tP=ft(J2(),1);var Ba=require("obsidian"),Yw=Wu.StateEffect.define();function zs(t,e){let r=t.state,i=r.field(qh),n=r.field(Gr),s=r.doc.lineAt(e!=null?e:r.selection.main.head).number,a=zt.findHunk(s,n==null?void 0:n.hunks)[0];if(!a)return;let o=r.doc.line(Math.max(1,a.added.start)).from,l=i.has(o);return r.field(Ba.editorEditorField).dispatch({effects:Yw.of({pos:o,add:!l})})}var qh=Wu.StateField.define({create:()=>new Set,update(t,e){let r=new Set;for(let i of e.effects)i.is(Yw)&&(i.value.add?t.add(i.value.pos):t.delete(i.value.pos));for(let i of t)r.add(e.changes.mapPos(i));return r}}),rP=Wu.StateField.define({create:t=>eP(t),update(t,e){return e.docChanged||e.effects.some(r=>r.is(Rl)||r.is(Yw))?eP(e.state):t},provide:t=>Wh.showTooltip.computeN([t],e=>e.field(t))}),iP=Wh.EditorView.baseTheme({".cm-tooltip.git-diff-tooltip":{"z-index":"var(--layer-popover)",backgroundColor:"var(--background-primary-alt)",border:"var(--border-width) solid var(--background-primary-alt)",borderRadius:"var(--radius-s)"},".cm-tooltip.git-diff-tooltip .tooltip-toolbar":{display:"flex",padding:"var(--size-2-1)"}});function eP(t){let e=t.field(Gr);return e?[...t.field(qh)].map(i=>{let n=t.doc.lineAt(i),s=zt.findHunk(n.number,e.hunks)[0];if(s)return{pos:i,above:!1,arrow:!1,strictSide:!0,clip:!1,create:()=>y5(s,t,i)}}).filter(i=>i!==void 0):[]}function y5(t,e,r){var g,v;let i=zt.createPatch("file",[t],"10064",!1).join(`
|
||||
`)+`
|
||||
`,n=zh(i,{colorScheme:tP.ColorSchemeType.AUTO,diffStyle:"word",drawFileList:!1}),s=new DOMParser().parseFromString(n,"text/html").querySelector(".d2h-file-diff"),a=createDiv();a.addClass("tooltip-toolbar");let o=(b,_)=>{let C=createDiv();return(0,Ba.setIcon)(C,b),C.setAttr("aria-label",_),C.addClass("clickable-icon"),C},l=o("x","Close hunk"),c=o("plus","Stage hunk"),u=o("undo","Reset hunk");a.appendChild(l),a.appendChild(c),a.appendChild(u);let f=createDiv();f.appendChild(a),f.appendChild(s),f.addClass("git-diff-tooltip","git-diff");let d=e.field(Ba.editorEditorField);l.onclick=()=>{zs(d,r)},c.onclick=()=>{let b=It.plugin;b&&(b.promiseQueue.addTask(()=>b.hunkActions.stageHunk(r)),zs(d,r))},u.onclick=()=>{let b=It.plugin;b&&(b.hunkActions.resetHunk(r),zs(d,r))};let h=(v=(g=It.plugin)==null?void 0:g.app.workspace.getActiveViewOfType(Ba.MarkdownView))==null?void 0:v.scope,p=h==null?void 0:h.register(null,"Escape",(b,_)=>{zs(d,r)});return{dom:f,destroy:()=>{p&&(h==null||h.unregister(p))},update:b=>{r=b.changes.mapPos(r)}}}function nP(t){let e=t.app;t.addCommand({id:"edit-gitignore",name:"Edit .gitignore",callback:async()=>{let r=t.gitManager.getRelativeVaultPath(".gitignore");await e.vault.adapter.exists(r)||await e.vault.adapter.write(r,"");let i=await e.vault.adapter.read(r),s=await new Ch(e,i).openAndGetReslt();s!==void 0&&(await e.vault.adapter.write(r,s),await t.refresh())}}),t.addCommand({id:"open-git-view",name:"Open source control view",callback:async()=>{var n;let r=e.workspace.getLeavesOfType(Xt.type),i;r.length===0?(i=(n=e.workspace.getRightLeaf(!1))!=null?n:e.workspace.getLeaf(),await i.setViewState({type:Xt.type})):i=r.first(),await e.workspace.revealLeaf(i),e.workspace.trigger("obsidian-git:refresh")}}),t.addCommand({id:"open-history-view",name:"Open history view",callback:async()=>{var n;let r=e.workspace.getLeavesOfType(wi.type),i;r.length===0?(i=(n=e.workspace.getRightLeaf(!1))!=null?n:e.workspace.getLeaf(),await i.setViewState({type:wi.type})):i=r.first(),await e.workspace.revealLeaf(i),e.workspace.trigger("obsidian-git:refresh")}}),t.addCommand({id:"open-diff-view",name:"Open diff view",checkCallback:r=>{let i=e.workspace.getActiveFile();if(r)return i!==null;{let n=t.gitManager.getRelativeRepoPath(i.path,!0);return t.tools.openDiff({aFile:n,aRef:""}),!0}}}),t.addCommand({id:"view-file-on-github",name:"Open file on GitHub",editorCallback:(r,{file:i})=>{if(i)return jT(r,i,t.gitManager)}}),t.addCommand({id:"view-history-on-github",name:"Open file history on GitHub",editorCallback:(r,{file:i})=>{if(i)return VT(i,t.gitManager)}}),t.addCommand({id:"pull",name:"Pull",callback:()=>t.promiseQueue.addTask(()=>t.pullChangesFromRemote())}),t.addCommand({id:"fetch",name:"Fetch",callback:()=>t.promiseQueue.addTask(()=>t.fetch())}),t.addCommand({id:"switch-to-remote-branch",name:"Switch to remote branch",callback:()=>t.promiseQueue.addTask(()=>t.switchRemoteBranch())}),t.addCommand({id:"add-to-gitignore",name:"Add file to .gitignore",checkCallback:r=>{let i=e.workspace.getActiveFile();return r?i!==null:(t.addFileToGitignore(i.path,i instanceof qi.TFolder).catch(n=>t.displayError(n)),!0)}}),t.addCommand({id:"push",name:"Commit-and-sync",callback:()=>t.promiseQueue.addTask(()=>t.commitAndSync({fromAutoBackup:!1}))}),t.addCommand({id:"backup-and-close",name:"Commit-and-sync and then close Obsidian",callback:()=>t.promiseQueue.addTask(async()=>{await t.commitAndSync({fromAutoBackup:!1}),window.close()})}),t.addCommand({id:"commit-push-specified-message",name:"Commit-and-sync with specific message",callback:()=>t.promiseQueue.addTask(()=>t.commitAndSync({fromAutoBackup:!1,requestCustomMessage:!0}))}),t.addCommand({id:"commit",name:"Commit all changes",callback:()=>t.promiseQueue.addTask(()=>t.commit({fromAuto:!1}))}),t.addCommand({id:"commit-specified-message",name:"Commit all changes with specific message",callback:()=>t.promiseQueue.addTask(()=>t.commit({fromAuto:!1,requestCustomMessage:!0}))}),t.addCommand({id:"commit-smart",name:"Commit",callback:()=>t.promiseQueue.addTask(async()=>{let i=(await t.updateCachedStatus()).staged.length>0;return t.commit({fromAuto:!1,requestCustomMessage:!1,onlyStaged:i})})}),t.addCommand({id:"commit-staged",name:"Commit staged",checkCallback:function(r){return r?!1:(t.promiseQueue.addTask(async()=>t.commit({fromAuto:!1,requestCustomMessage:!1})),!0)}}),qi.Platform.isDesktopApp&&t.addCommand({id:"commit-amend-staged-specified-message",name:"Amend staged",callback:()=>t.promiseQueue.addTask(()=>t.commit({fromAuto:!1,requestCustomMessage:!0,onlyStaged:!0,amend:!0}))}),t.addCommand({id:"commit-smart-specified-message",name:"Commit with specific message",callback:()=>t.promiseQueue.addTask(async()=>{let i=(await t.updateCachedStatus()).staged.length>0;return t.commit({fromAuto:!1,requestCustomMessage:!0,onlyStaged:i})})}),t.addCommand({id:"commit-staged-specified-message",name:"Commit staged with specific message",checkCallback:function(r){return r?!1:t.promiseQueue.addTask(()=>t.c
Line truncated
|
||||
- ${s.map(o=>o.vaultPath).join(`
|
||||
- `)}
|
||||
Please remove them or add to .gitignore.`),!0}return!1}async writeAndOpenFile(e){e!==void 0&&await this.plugin.app.vault.adapter.write(il,e);let r=!1;this.plugin.app.workspace.iterateAllLeaves(i=>{i.getDisplayText()!=""&&il.startsWith(i.getDisplayText())&&(r=!0)}),r||await this.plugin.app.workspace.openLinkText(il,"/",!0)}openDiff({aFile:e,bFile:r,aRef:i,bRef:n,event:s}){var l,c;let a=this.plugin.settings.diffStyle;Bl.Platform.isMobileApp&&(a="git_unified");let o={aFile:e,bFile:r!=null?r:e,aRef:i,bRef:n};a=="split"?(l=Vi(this.plugin.app,s))==null||l.setViewState({type:Os.type,active:!0,state:o}):a=="git_unified"&&((c=Vi(this.plugin.app,s))==null||c.setViewState({type:Ls.type,active:!0,state:o}))}async runRawCommand(){let e=this.plugin.gitManager;if(!(e instanceof Se))return;let i=await new rt(this.plugin,{placeholder:"push origin master",allowEmpty:!1}).openAndGetResult();i!==void 0&&this.plugin.promiseQueue.addTask(async()=>{let n=new Bl.Notice(`Running '${i}'...`,999999);try{let s=await e.rawCommand(i);s?(n.setMessage(s),window.setTimeout(()=>n.hide(),5e3)):n.hide()}catch(s){throw n.hide(),s}})}};m();var Zh=require("obsidian");var Ha=class extends Zh.ItemView{constructor(r,i){super(r);this.plugin=i;this.gettingDiff=!1;this.parser=new DOMParser,this.navigation=!0,this.contentEl.addClass("git-diff"),this.gitRefreshRef=this.app.workspace.on("obsidian-git:status-changed",()=>{this.refresh().catch(console.error)})}getViewType(){return Ls.type}getDisplayText(){var r;if(((r=this.state)==null?void 0:r.bFile)!=null){let i=this.state.bFile.split("/").last();return i!=null&&i.endsWith(".md")&&(i=i.slice(0,-3)),`Diff: ${i}`}return Ls.name}getIcon(){return Ls.icon}async setState(r,i){this.state=r,Zh.Platform.isMobile&&(this.leaf.view.titleEl.textContent=this.getDisplayText()),await this.refresh()}getState(){return this.state}onClose(){return this.app.workspace.offref(this.gitRefreshRef),this.app.workspace.offref(this.gitViewRefreshRef),super.onClose()}async onOpen(){return await this.refresh(),super.onOpen()}async refresh(){var r;if((r=this.state)!=null&&r.bFile&&!this.gettingDiff&&this.plugin.gitManager){this.gettingDiff=!0;try{let i=await this.plugin.gitManager.getDiffString(this.state.bFile,this.state.aRef=="HEAD",this.state.bRef);this.contentEl.empty();let n=this.plugin.gitManager.getRelativeVaultPath(this.state.bFile);if(!i){if(this.plugin.gitManager instanceof Se&&await this.plugin.gitManager.isTracked(this.state.bFile))i=[`--- ${this.state.aFile}`,`+++ ${this.state.bFile}`,""].join(`
|
||||
`);else if(await this.app.vault.adapter.exists(n)){let s=await this.app.vault.adapter.read(n);i=[...`--- /dev/null
|
||||
+++ ${this.state.bFile}
|
||||
@@ -0,0 +1,${s.split(`
|
||||
`).length} @@`.split(`
|
||||
`),...s.split(`
|
||||
`).map(o=>`+${o}`)].join(`
|
||||
`)}}if(i){let s=this.parser.parseFromString(zh(i),"text/html").querySelector(".d2h-file-diff");this.contentEl.append(s)}else{let s=this.contentEl.createDiv({cls:"obsidian-git-center"});s.createSpan({text:"\u26A0\uFE0F",attr:{style:"font-size: 2em"}}),s.createEl("br"),s.createSpan({text:"File not found: "+this.state.bFile})}}finally{this.gettingDiff=!1}}}};m();var ts=require("obsidian");var Ul=require("@codemirror/commands");var Xh=require("@codemirror/search"),Hl=require("@codemirror/state"),Yi=require("@codemirror/view");m();var Kh=require("obsidian"),Zw=require("@codemirror/view");function x5(t){return t.selection.ranges.filter(e=>!e.empty).map(e=>t.sliceDoc(e.from,e.to)).join(t.lineBreak)}function E5(t){t.dispatch({...t.state.replaceSelection(""),userEvent:"delete.cut"})}function sP(t,e){t.dispatch({...t.state.replaceSelection(e),scrollIntoView:!0,userEvent:"input.paste"})}async function aP(t){if(!t&&navigator.clipboard.read){let e=await navigator.clipboard.read();for(let r of e)if(r.types.includes("text/html")){let i=await(await r.getType("text/html")).text();return(0,Kh.htmlToMarkdown)(i)}}return navigator.clipboard.readText()}var oP=Zw.EditorView.domEventHandlers({contextmenu(t,e){t.preventDefault();let r=x5(e.state),i=!e.state.readOnly&&e.state.facet(Zw.EditorView.editable),n=Kh.Menu.forEvent(t);return n.addItem(s=>s.setTitle("Cut").setIcon("scissors").setDisabled(!i||r.length===0).onClick(async()=>{await navigator.clipboard.writeText(r),E5(e)})),n.addItem(s=>s.setTitle("Copy").setIcon("copy").setDisabled(r.length===0).onClick(()=>navigator.clipboard.writeText(r))),n.addItem(s=>s.setTitle("Paste").setIcon("clipboard-paste").setDisabled(!i).onClick(async()=>sP(e,await aP(!1)))),n.addItem(s=>s.setTitle("Paste as plain text").setIcon("clipboard-type").setDisabled(!i).onClick(async()=>sP(e,await aP(!0)))),n.addItem(s=>s.setTitle("Select all").setIcon("scan").onClick(()=>e.dispatch({selection:{anchor:0,head:e.state.doc.length}}))),n.showAtMouseEvent(t),!0}});var lP=Yi.EditorView.theme({"& .cm-content":{caretColor:"transparent !important"},"&.cm-focused .cm-cursor, & .cm-dropCursor":{display:"none !important"}}),Ua=class extends ts.ItemView{constructor(r,i){super(r);this.plugin=i;this.refreshing=!1;this.ignoreNextModification=!1;this.navigation=!0,this.registerEvent(this.app.workspace.on("obsidian-git:status-changed",()=>{this.mergeView?this.updateRefEditors().catch(console.error):this.createMergeView().catch(console.error)})),this.intervalRef=window.setInterval(()=>{this.mergeView&&this.updateRefEditors().catch(console.error)},30*1e3),this.registerEvent(this.app.vault.on("modify",n=>{this.state.bRef==null&&n.path===this.state.bFile&&(this.ignoreNextModification?this.ignoreNextModification=!1:this.updateModifiableEditor().catch(console.error))})),this.registerEvent(this.app.vault.on("delete",n=>{this.state.bRef==null&&n.path===this.state.bFile&&this.createMergeView().catch(console.error)})),this.registerEvent(this.app.vault.on("create",n=>{this.state.bRef==null&&n.path===this.state.bFile&&this.createMergeView().catch(console.error)})),this.registerEvent(this.app.vault.on("rename",(n,s)=>{this.state.bRef==null&&(n.path===this.state.bFile||s===this.state.bFile)&&this.createMergeView().catch(console.error)})),this.fileSaveDebouncer=(0,ts.debounce)(n=>{let s=this.state.bFile;s&&(this.ignoreNextModification=!0,this.plugin.app.vault.adapter.write(this.plugin.gitManager.getRelativeVaultPath(s),n).catch(a=>this.plugin.displayError(a)))},1e3,!1)}getViewType(){return Os.type}getDisplayText(){var r;if(((r=this.state)==null?void 0:r.bFile)!=null){let i=this.state.bFile.split("/").last();i!=null&&i.endsWith(".md")&&(i=i.slice(0,-3));let n;return this.state.bRef==null?n=" (Working Tree)":this.state.bRef==""?n=" (Index)":n="("+this.state.bRef.substring(0,7)+")",`Diff: ${i} ${n}`}return Os.name}getIcon(){return Os.icon}async setState(r,i){this.state=r,ts.Platform.isMobile&&(this.leaf.view.titleEl.textContent=this.getDisplayText()),await super.setState(r,i),await this.createMergeView()}getState(){return this.state}onClose(){return window.clearInterval(this.intervalRef),super.onClose()}async onOpen(){return await this.createMergeView(),super.onOpen()}async gitShow(r,i){try{return await this.plugin.gitManager.show(r,i,!1)}catch(n){if(n instanceof Br&&(n.message.includes("does not exist")||n.message.includes("unknown revision or path")||n.message.includes("exists on disk, but not in")||n.message.includes("fatal: bad object")))return n.message.includes("fatal: bad object")&&this.plugin.displayError(n.message),"";throw n}}async bShouldBeEditable(){if(this.state.bRef!=null)return!1;let r=this.plugin.gitManager.getRelativeVaultPath(this.state.bFile);return await this.app.vault.adapter.exists(r)}async updateModifiableEditor(){if(!this.mergeView||this.refreshing)return;let r=this.mergeView.b;this.refreshing=!0;let i=await this.app.vault.adapter.read(this.state.bFile);if(i!=r.state.doc.toString()){let n=r.state.update({changes:{fro
Line truncated
|
||||
`)+`
|
||||
`;await this.plugin.gitManager.applyPatch(h),this.plugin.app.workspace.trigger("obsidian-git:refresh")},this.state.bRef==null){let s=i.createDiv();s.addClass("clickable-icon"),s.setAttr("aria-label","Reset hunk"),(0,ts.setIcon)(s,"undo"),s.onmousedown=a=>{var d;let o=this.mergeView.a,l=this.mergeView.b,c=kw(l.state),u=(d=i.parentElement)==null?void 0:d.indexOf(i),f=c.chunks[u];if(f){let h=f.fromA,p=f.toA,g=f.fromB,v=f.toB,b=o.state.sliceDoc(h,Math.max(h,p-1));h!=p&&v<=l.state.doc.length&&(b+=o.state.lineBreak),l.dispatch({changes:{from:g,to:Math.min(l.state.doc.length,v),insert:b},userEvent:"revert"})}}}return i.onmousedown=s=>{s.preventDefault(),s.stopPropagation()},i}async createMergeView(){var r,i,n;if((r=this.state)!=null&&r.aFile&&((i=this.state)!=null&&i.bFile)&&!this.refreshing&&this.plugin.gitManager){this.refreshing=!0,(n=this.mergeView)==null||n.destroy();let s=this.containerEl.children[1];s.empty(),this.contentEl.addClass("git-split-diff-view","git-diff"),this.bIsEditable=await this.bShouldBeEditable();let a=await this.gitShow(this.state.aRef,this.state.aFile),o;if(this.state.bRef!=null)o=await this.gitShow(this.state.bRef,this.state.bFile);else{let g=this.plugin.gitManager.getRelativeVaultPath(this.state.bFile);await this.app.vault.adapter.exists(g)?o=await this.app.vault.adapter.read(g):o=""}let l=[(0,Yi.lineNumbers)(),(0,Xh.highlightSelectionMatches)(),(0,Yi.drawSelection)(),Yi.keymap.of([...Ul.standardKeymap,Ul.indentWithTab]),(0,Ul.history)(),(0,Xh.search)(),Yi.EditorView.lineWrapping,oP],c=this,u=Yi.ViewPlugin.define(g=>({update(v){if(v.docChanged&&!v.transactions.some(b=>b.annotation(Hl.Transaction.remote))){let b=g.state.doc.toString();c.fileSaveDebouncer(b)}}})),f={doc:a,extensions:[...l,Hl.EditorState.readOnly.of(!0),lP]},d=[...l];this.bIsEditable?d.push(u):d.push(Hl.EditorState.readOnly.of(!0),lP);let h={doc:o,extensions:d};s.addClasses(["cm-s-obsidian","mod-cm6","markdown-source-view","cm-content"]);let p=this.plugin.gitManager instanceof Se&&(this.state.bRef===void 0||this.state.bRef==="");this.mergeView=new Mh({b:h,a:f,collapseUnchanged:{minSize:6,margin:4},renderRevertControl:p?()=>this.renderButtons(s):void 0,revertControls:p?"a-to-b":void 0,diffConfig:{scanLimit:this.bIsEditable?1e3:1e4},parent:s}),this.refreshing=!1}}};m();var QR=require("obsidian");m();m();m();var cP,uP,fP;typeof window!="undefined"&&((fP=(uP=(cP=window.__svelte)!=null?cP:window.__svelte={}).v)!=null?fP:uP.v=new Set).add("5");m();m();m();var rs={};var Ye=Symbol("uninitialized"),Ti=Symbol("filename");var Qh="http://www.w3.org/1999/xhtml";m();m();m();m();var Jh=!0;m();var D=!1;m();var is=Array.isArray,dP=Array.prototype.indexOf,Ws=Array.prototype.includes,Gl=Array.from,Kw=Object.keys,or=Object.defineProperty,jr=Object.getOwnPropertyDescriptor,Xw=Object.getOwnPropertyDescriptors,Qw=Object.prototype,hP=Array.prototype,jl=Object.getPrototypeOf,Jw=Object.isExtensible;function e0(t){return typeof t=="function"}var lr=()=>{};function ep(t){for(var e=0;e<t.length;e++)t[e]()}function tp(){var t,e,r=new Promise((i,n)=>{t=i,e=n});return{promise:r,resolve:t,reject:e}}m();m();var Jt=Symbol("$state"),Yu=Symbol("legacy props"),mP=Symbol(""),rp=Symbol("proxy path"),ip=Symbol("attributes"),Zu=Symbol("class"),t0=Symbol("style"),Ku=Symbol("text"),Ga=Symbol("form reset"),r0=Symbol("hmr anchor"),ns=new class extends Error{constructor(){super(...arguments);He(this,"name","StaleReactionError");He(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}},pP,i0=!!((pP=globalThis.document)!=null&&pP.contentType)&&globalThis.document.contentType.includes("xml");var Vl=3,Pi=8;m();m();function gP(t){if(D){let e=new Error(`invariant_violation
|
||||
An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app \u2014 please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${t}"
|
||||
https://svelte.dev/e/invariant_violation`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/invariant_violation")}function np(t){if(D){let e=new Error(`lifecycle_outside_component
|
||||
\`${t}(...)\` can only be used during component initialisation
|
||||
https://svelte.dev/e/lifecycle_outside_component`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function wP(){if(D){let t=new Error("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/async_derived_orphan")}function n0(){if(D){let t=new Error("bind_invalid_checkbox_value\nUsing `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead\nhttps://svelte.dev/e/bind_invalid_checkbox_value");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/bind_invalid_checkbox_value")}function bP(){if(D){let t=new Error(`derived_references_self
|
||||
A derived value cannot reference itself recursively
|
||||
https://svelte.dev/e/derived_references_self`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/derived_references_self")}function s0(t,e,r){if(D){let i=new Error(`each_key_duplicate
|
||||
${r?`Keyed each block has duplicate key \`${r}\` at indexes ${t} and ${e}`:`Keyed each block has duplicate key at indexes ${t} and ${e}`}
|
||||
https://svelte.dev/e/each_key_duplicate`);throw i.name="Svelte error",i}else throw new Error("https://svelte.dev/e/each_key_duplicate")}function _P(t,e,r){if(D){let i=new Error(`each_key_volatile
|
||||
Keyed each block has key that is not idempotent \u2014 the key for item at index ${t} was \`${e}\` but is now \`${r}\`. Keys must be the same each time for a given item
|
||||
https://svelte.dev/e/each_key_volatile`);throw i.name="Svelte error",i}else throw new Error("https://svelte.dev/e/each_key_volatile")}function yP(t){if(D){let e=new Error(`effect_in_teardown
|
||||
\`${t}\` cannot be used inside an effect cleanup function
|
||||
https://svelte.dev/e/effect_in_teardown`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_in_teardown")}function xP(){if(D){let t=new Error("effect_in_unowned_derived\nEffect cannot be created inside a `$derived` value that was not itself created inside an effect\nhttps://svelte.dev/e/effect_in_unowned_derived");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function EP(t){if(D){let e=new Error(`effect_orphan
|
||||
\`${t}\` can only be used inside an effect (e.g. during component initialisation)
|
||||
https://svelte.dev/e/effect_orphan`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_orphan")}function SP(){if(D){let t=new Error(`effect_update_depth_exceeded
|
||||
Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
|
||||
https://svelte.dev/e/effect_update_depth_exceeded`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function kP(){if(D){let t=new Error(`hydration_failed
|
||||
Failed to hydrate the application
|
||||
https://svelte.dev/e/hydration_failed`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/hydration_failed")}function CP(t){if(D){let e=new Error(`props_invalid_value
|
||||
Cannot do \`bind:${t}={undefined}\` when \`${t}\` has a fallback value
|
||||
https://svelte.dev/e/props_invalid_value`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/props_invalid_value")}function AP(t){if(D){let e=new Error(`rune_outside_svelte
|
||||
The \`${t}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files
|
||||
https://svelte.dev/e/rune_outside_svelte`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/rune_outside_svelte")}function TP(){if(D){let t=new Error("state_descriptors_fixed\nProperty descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.\nhttps://svelte.dev/e/state_descriptors_fixed");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function PP(){if(D){let t=new Error("state_prototype_fixed\nCannot set prototype of `$state` object\nhttps://svelte.dev/e/state_prototype_fixed");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/state_prototype_fixed")}function RP(){if(D){let t=new Error("state_unsafe_mutation\nUpdating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`\nhttps://svelte.dev/e/state_unsafe_mutation");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function $P(){if(D){let t=new Error("svelte_boundary_reset_onerror\nA `<svelte:boundary>` `reset` function cannot be called while an error is still being handled\nhttps://svelte.dev/e/svelte_boundary_reset_onerror");throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}m();m();m();var An="font-weight: bold",Tn="font-weight: normal";function FP(t){D?console.warn(`%c[svelte] await_reactivity_loss
|
||||
%cDetected reactivity loss when reading \`${t}\`. This happens when state is read in an async function after an earlier \`await\`
|
||||
https://svelte.dev/e/await_reactivity_loss`,An,Tn):console.warn("https://svelte.dev/e/await_reactivity_loss")}function IP(t,e){D?console.warn(`%c[svelte] await_waterfall
|
||||
%cAn async derived, \`${t}\` (${e}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
|
||||
https://svelte.dev/e/await_waterfall`,An,Tn):console.warn("https://svelte.dev/e/await_waterfall")}function MP(){D?console.warn(`%c[svelte] derived_inert
|
||||
%cReading a derived belonging to a now-destroyed effect may result in stale values
|
||||
https://svelte.dev/e/derived_inert`,An,Tn):console.warn("https://svelte.dev/e/derived_inert")}function DP(t,e,r){D?console.warn(`%c[svelte] hydration_attribute_changed
|
||||
%cThe \`${t}\` attribute on \`${e}\` changed its value between server and client renders. The client value, \`${r}\`, will be ignored in favour of the server value
|
||||
https://svelte.dev/e/hydration_attribute_changed`,An,Tn):console.warn("https://svelte.dev/e/hydration_attribute_changed")}function ja(t){D?console.warn(`%c[svelte] hydration_mismatch
|
||||
%c${t?`Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${t}`:"Hydration failed because the initial UI does not match what was rendered on the server"}
|
||||
https://svelte.dev/e/hydration_mismatch`,An,Tn):console.warn("https://svelte.dev/e/hydration_mismatch")}function OP(){D?console.warn(`%c[svelte] lifecycle_double_unmount
|
||||
%cTried to unmount a component that was not mounted
|
||||
https://svelte.dev/e/lifecycle_double_unmount`,An,Tn):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function sp(t){D?console.warn(`%c[svelte] state_proxy_equality_mismatch
|
||||
%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${t}\` will produce unexpected results
|
||||
https://svelte.dev/e/state_proxy_equality_mismatch`,An,Tn):console.warn("https://svelte.dev/e/state_proxy_equality_mismatch")}function LP(){D?console.warn(`%c[svelte] state_proxy_unmount
|
||||
%cTried to unmount a state proxy, rather than a component
|
||||
https://svelte.dev/e/state_proxy_unmount`,An,Tn):console.warn("https://svelte.dev/e/state_proxy_unmount")}function NP(){D?console.warn("%c[svelte] svelte_boundary_reset_noop\n%cA `<svelte:boundary>` `reset` function only resets the boundary the first time it is called\nhttps://svelte.dev/e/svelte_boundary_reset_noop",An,Tn):console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}function BP(t){D?console.warn(`%c[svelte] transition_slide_display
|
||||
%cThe \`slide\` transition does not work correctly for elements with \`display: ${t}\`
|
||||
https://svelte.dev/e/transition_slide_display`,An,Tn):console.warn("https://svelte.dev/e/transition_slide_display")}var ne=!1;function Mt(t){ne=t}var we;function ze(t){if(t===null)throw ja(),rs;return we=t}function cr(){return ze(tr(we))}function V(t){if(ne){if(tr(we)!==null)throw ja(),rs;we=t}}function Va(t=1){if(ne){for(var e=t,r=we;e--;)r=tr(r);we=r}}function Pn(t=!0){for(var e=0,r=we;;){if(r.nodeType===Pi){var i=r.data;if(i==="]"){if(e===0)return r;e-=1}else(i==="["||i==="[!"||i[0]==="["&&!isNaN(Number(i.slice(1))))&&(e+=1)}var n=tr(r);t&&r.remove(),r=n}}function Qu(t){if(!t||t.nodeType!==Pi)throw ja(),rs;return t.data}m();m();m();m();function ap(t){return t===this.v}function a0(t,e){return t!=t?e==e:t!==e||t!==null&&typeof t=="object"||typeof t=="function"}function op(t){return!a0(t,this.v)}m();var At=!1,ss=!1,Zi=!1;m();m();m();var Ju=null;function ur(t,e){return t.label=e,cp(t.v,e),t}function cp(t,e){var r;return(r=t==null?void 0:t[rp])==null||r.call(t,e),t}m();function Ki(t){let e=new Error,r=k5();return r.length===0?null:(r.unshift(`
|
||||
`),or(e,"stack",{value:r.join(`
|
||||
`)}),or(e,"name",{value:t}),e)}function k5(){let t=Error.stackTraceLimit;Error.stackTraceLimit=1/0;let e=new Error().stack;if(Error.stackTraceLimit=t,!e)return[];let r=e.split(`
|
||||
`),i=[];for(let n=0;n<r.length;n++){let s=r[n],a=s.replaceAll("\\","/");if(s.trim()!=="Error"){if(s.includes("validate_each_keys"))return[];a.includes("svelte/src/internal")||a.includes("node_modules/.vite")||i.push(s)}}return i}function UP(t,e){if(!D)throw new Error("invariant(...) was not guarded by if (DEV)");t||gP(e)}m();var ye=null;function as(t){ye=t}var Rn=null;function ql(t){Rn=t}var Xi=null;function up(t){Xi=t}function lt(t,e=!1,r){ye={p:ye,i:!1,c:null,e:null,s:t,x:null,r:Q,l:ss&&!e?{s:null,u:null,$:[]}:null},D&&(ye.function=r,Xi=r)}function ct(t){var n;var e=ye,r=e.e;if(r!==null){e.e=null;for(var i of r)o0(i)}return t!==void 0&&(e.x=t),e.i=!0,ye=e.p,D&&(Xi=(n=ye==null?void 0:ye.function)!=null?n:null),t!=null?t:{}}function $n(){return!ss||ye!==null&&ye.l===null}m();m();var za=[];function GP(){var t=za;za=[],ep(t)}function Et(t){if(za.length===0&&!Wa){var e=za;queueMicrotask(()=>{e===za&&GP()})}za.push(t)}function jP(){for(;za.length>0;)GP()}m();var l0=new WeakMap;function fp(t){var e=Q;if(e===null)return ae.f|=8388608,t;if(D&&t instanceof Error&&!l0.has(t)&&l0.set(t,C5(t,e)),(e.f&32768)===0&&(e.f&4)===0)throw D&&!e.parent&&t instanceof Error&&VP(t),t;Ji(t,e)}function Ji(t,e){if(!(e!==null&&(e.f&16384)!==0)){for(;e!==null;){if((e.f&128)!==0){if((e.f&32768)===0)throw t;try{e.b.error(t);return}catch(r){t=r}}e=e.parent}throw D&&t instanceof Error&&VP(t),t}}function C5(t,e){var a,o,l;let r=jr(t,"message");if(!(r&&!r.configurable)){for(var i=tf?" ":" ",n=`
|
||||
${i}in ${((a=e.fn)==null?void 0:a.name)||"<unknown>"}`,s=e.ctx;s!==null;)n+=`
|
||||
${i}in ${(o=s.function)==null?void 0:o[Ti].split("/").pop()}`,s=s.p;return{message:t.message+`
|
||||
${n}
|
||||
`,stack:(l=t.stack)==null?void 0:l.split(`
|
||||
`).filter(c=>!c.includes("svelte/src/internal")).join(`
|
||||
`)}}}function VP(t){let e=l0.get(t);e&&(or(t,"message",{value:e.message}),or(t,"stack",{value:e.stack}))}m();m();var A5=-7169;function Ue(t,e){t.f=t.f&A5|e}function Yl(t){(t.f&512)!==0||t.deps===null?Ue(t,1024):Ue(t,4096)}function zP(t){if(t!==null)for(let e of t)(e.f&2)===0||(e.f&65536)===0||(e.f^=65536,zP(e.deps))}function dp(t,e,r){(t.f&2048)!==0?e.add(t):(t.f&4096)!==0&&r.add(t),zP(t.deps),Ue(t,1024)}m();m();m();var WP=!1,hp=!1;function c0(t){var e=hp;try{return hp=!1,[t(),hp]}finally{hp=e}}m();m();m();m();function u0(t){ne&&nr(t)!==null&&Kl(t)}var qP=!1;function f0(){qP||(qP=!0,document.addEventListener("reset",t=>{Promise.resolve().then(()=>{var e;if(!t.defaultPrevented)for(let r of t.target.elements)(e=r[Ga])==null||e.call(r)})},{capture:!0}))}function zr(t){var e=ae,r=Q;Lt(null),Nt(null);try{return t()}finally{Lt(e),Nt(r)}}function d0(t,e,r,i=r){t.addEventListener(e,()=>zr(r));let n=t[Ga];n?t[Ga]=()=>{n(),i(!0)}:t[Ga]=()=>i(!0),f0()}m();m();m();function YP(t){let e=0,r=dr(0),i;return D&&ur(r,"createSubscriber version"),()=>{qs()&&(F(r),sr(()=>(e===0&&(i=Ze(()=>t(()=>Za(r)))),e+=1,()=>{Et(()=>{e-=1,e===0&&(i==null||i(),i=void 0,Za(r))})})))}}var P5=589824;function w0(t,e,r,i){new h0(t,e,r,i)}var ii,rf,Fi,Ka,Wr,Ii,Sr,ni,ls,Xa,Ys,Xl,nf,sf,Fn,gp,We,KP,XP,p0,QP,m0,pp,mp,g0,v0,h0=class{constructor(e,r,i,n){me(this,We);He(this,"parent");He(this,"is_pending",!1);He(this,"transform_error");me(this,ii);me(this,rf,ne?we:null);me(this,Fi);me(this,Ka);me(this,Wr);me(this,Ii,null);me(this,Sr,null);me(this,ni,null);me(this,ls,null);me(this,Xa,0);me(this,Ys,0);me(this,Xl,!1);me(this,nf,new Set);me(this,sf,new Set);me(this,Fn,null);me(this,gp,YP(()=>(fe(this,Fn,dr($(this,Xa))),D&&ur($(this,Fn),"$effect.pending()"),()=>{fe(this,Fn,null)})));var s,a;fe(this,ii,e),fe(this,Fi,r),fe(this,Ka,o=>{var l=Q;l.b=this,l.f|=128,i(o)}),this.parent=Q.b,this.transform_error=(a=n!=null?n:(s=this.parent)==null?void 0:s.transform_error)!=null?a:(o=>o),fe(this,Wr,ai(()=>{if(ne){let o=$(this,rf);cr();let l=o.data==="[!";if(o.data.startsWith("[?")){let u=JSON.parse(o.data.slice("[?".length));Ee(this,We,XP).call(this,u)}else l?Ee(this,We,QP).call(this):Ee(this,We,KP).call(this)}else Ee(this,We,m0).call(this)},P5)),ne&&fe(this,ii,we)}defer_effect(e){dp(e,$(this,nf),$(this,sf))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!$(this,Fi).pending}update_pending_count(e,r){Ee(this,We,g0).call(this,e,r),fe(this,Xa,$(this,Xa)+e),!(!$(this,Fn)||$(this,Xl))&&(fe(this,Xl,!0),Et(()=>{fe(this,Xl,!1),$(this,Fn)&&en($(this,Fn),$(this,Xa))}))}get_effect_pending(){return $(this,gp).call(this),F($(this,Fn))}error(e){var r;if(!$(this,Fi).onerror&&!$(this,Fi).failed)throw e;(r=oe)!=null&&r.is_fork?($(this,Ii)&&oe.skip_effect($(this,Ii)),$(this,Sr)&&oe.skip_effect($(this,Sr)),$(this,ni)&&oe.skip_effect($(this,ni)),oe.oncommit(()=>{Ee(this,We,v0).call(this,e)})):Ee(this,We,v0).call(this,e)}};ii=new WeakMap,rf=new WeakMap,Fi=new WeakMap,Ka=new WeakMap,Wr=new WeakMap,Ii=new WeakMap,Sr=new WeakMap,ni=new WeakMap,ls=new WeakMap,Xa=new WeakMap,Ys=new WeakMap,Xl=new WeakMap,nf=new WeakMap,sf=new WeakMap,Fn=new WeakMap,gp=new WeakMap,We=new WeakSet,KP=function(){try{fe(this,Ii,Bt(()=>$(this,Ka).call(this,$(this,ii))))}catch(e){this.error(e)}},XP=function(e){let r=$(this,Fi).failed,{reset:i,invoke_onerror:n}=Ee(this,We,p0).call(this,e);Et(n),r&&fe(this,ni,Bt(()=>{r($(this,ii),()=>e,()=>i)}))},p0=function(e){var r=!1,i=!1;let n=()=>{if(r){NP();return}r=!0,i&&$P(),$(this,ni)!==null&&In($(this,ni),()=>{fe(this,ni,null)}),Ee(this,We,mp).call(this,()=>{Ee(this,We,m0).call(this)})};return{reset:n,invoke_onerror:()=>{var a,o;try{i=!0,(o=(a=$(this,Fi)).onerror)==null||o.call(a,e,n),i=!1}catch(l){Ji(l,$(this,Wr)&&$(this,Wr).parent)}}}},QP=function(){let e=$(this,Fi).pending;e&&(this.is_pending=!0,fe(this,Sr,Bt(()=>e($(this,ii)))),Et(()=>{var r=fe(this,ls,document.createDocumentFragment()),i=Ht();r.append(i),fe(this,Ii,Ee(this,We,mp).call(this,()=>Bt(()=>$(this,Ka).call(this,i)))),$(this,Ys)===0&&($(this,ii).before(r),fe(this,ls,null),In($(this,Sr),()=>{fe(this,Sr,null)}),Ee(this,We,pp).call(this,oe))}))},m0=function(){try{if(this.is_pending=this.has_pending_snippet(),fe(this,Ys,0),fe(this,Xa,0),fe(this,Ii,Bt(()=>{$(this,Ka).call(this,$(this,ii))})),$(this,Ys)>0){var e=fe(this,ls,document.createDocumentFragment());Ql($(this,Ii),e);let r=$(this,Fi).pending;fe(this,Sr,Bt(()=>r($(this,ii))))}else Ee(this,We,pp).call(this,oe)}catch(r){this.error(r)}},pp=function(e){this.is_pending=!1,e.transfer_effects($(this,nf),$(this,sf))},mp=function(e){var r=Q,i=ae,n=ye;Nt($(this,Wr)),Lt($(this,Wr)),as($(this,Wr).ctx);try{return si.ensure(),e()}catch(s){return fp(s),null}finally{Nt(r),Lt(i),as(n)}},g0=function(e,r){var i;if(!this.has_pending_snippet()){this.parent&&Ee(i=this.parent,We,g0).call(i,e,r);return}fe(this,Ys,$(this,Ys)+e),$(this,Ys)===0&&(Ee(this,We,pp).call(this,r),$(this,Sr)&&In($(this,Sr),()=>{fe(this,Sr,null)}),$(this
Line truncated
|
||||
`).some(l=>l.startsWith("https://svelte.dev/e/")))throw o;return o!==rs&&console.warn("Failed to hydrate: ",o),e.recover===!1&&kP(),kp(),Kl(r),Mt(!1),Js(t,e)}finally{Mt(i),ze(n)}}var Fp=new Map;function OR(t,{target:e,anchor:r,props:i={},events:n,context:s,intro:a=!0,transformError:o}){kp();var l=void 0,c=yR(()=>{var u=r!=null?r:e.appendChild(Ht());w0(u,{pending:()=>{}},h=>{lt({});var p=ye;if(s&&(p.c=s),n&&(i.$$events=n),ne&&rn(h,null),Ip=a,l=t(h,i)||{},Ip=!0,ne&&(Q.nodes.end=we,we===null||we.nodeType!==Pi||we.data!=="]"))throw ja(),rs;ct()},o);var f=new Set,d=h=>{for(var p=0;p<h.length;p++){var g=h[p];if(!f.has(g)){f.add(g);var v=DR(g);for(let C of[e,document]){var b=Fp.get(C);b===void 0&&(b=new Map,Fp.set(C,b));var _=b.get(g);_===void 0?(C.addEventListener(g,$p,{passive:v}),b.set(g,1)):b.set(g,_+1)}}}};return d(Gl(N0)),Rp.add(d),()=>{var v;for(var h of f)for(let b of[e,document]){var p=Fp.get(b),g=p.get(h);--g==0?(b.removeEventListener(h,$p),p.delete(h),p.size===0&&Fp.delete(b)):p.set(h,g)}Rp.delete(d),u!==r&&((v=u.parentNode)==null||v.removeChild(u))}});return G0.set(l,c),l}var G0=new WeakMap;function gs(t,e){let r=G0.get(t);return r?(G0.delete(t),r(e)):(D&&(Jt in t?LP():OP()),Promise.resolve())}m();m();m();var nn,Nn,fi,lo,mf,gf,Mp,vs=class{constructor(e,r=!0){He(this,"anchor");me(this,nn,new Map);me(this,Nn,new Map);me(this,fi,new Map);me(this,lo,new Set);me(this,mf,!0);me(this,gf,e=>{if($(this,nn).has(e)){var r=$(this,nn).get(e),i=$(this,Nn).get(r);if(i)fc(i),$(this,lo).delete(r);else{var n=$(this,fi).get(r);n&&(fc(n.effect),$(this,Nn).set(r,n.effect),$(this,fi).delete(r),D&&(n.fragment.lastChild[r0]=this.anchor),n.fragment.lastChild.remove(),this.anchor.before(n.fragment),i=n.effect)}for(let[s,a]of $(this,nn)){if($(this,nn).delete(s),s===e)break;let o=$(this,fi).get(a);o&&(vt(o.effect),$(this,fi).delete(a))}for(let[s,a]of $(this,Nn)){if(s===r||$(this,lo).has(s))continue;let o=()=>{if(Array.from($(this,nn).values()).includes(s)){var c=document.createDocumentFragment();Ql(a,c),c.append(Ht()),$(this,fi).set(s,{effect:a,fragment:c})}else vt(a);$(this,lo).delete(s),$(this,Nn).delete(s)};$(this,mf)||!i?($(this,lo).add(s),In(a,o,!1)):o()}}});me(this,Mp,e=>{$(this,nn).delete(e);let r=Array.from($(this,nn).values());for(let[i,n]of $(this,fi))r.includes(i)||(vt(n.effect),$(this,fi).delete(i))});this.anchor=e,fe(this,mf,r)}ensure(e,r){var i=oe,n=Cp();if(r&&!$(this,Nn).has(e)&&!$(this,fi).has(e))if(n){var s=document.createDocumentFragment(),a=Ht();s.append(a),$(this,fi).set(e,{effect:Bt(()=>r(a)),fragment:s})}else $(this,Nn).set(e,Bt(()=>r(this.anchor)));if($(this,nn).set(i,e),n){for(let[o,l]of $(this,Nn))o===e?i.unskip_effect(l):i.skip_effect(l);for(let[o,l]of $(this,fi))o===e?i.unskip_effect(l.effect):i.skip_effect(l.effect);i.oncommit($(this,gf)),i.ondiscard($(this,Mp))}else ne&&(this.anchor=we),$(this,gf).call(this,i)}};nn=new WeakMap,Nn=new WeakMap,fi=new WeakMap,lo=new WeakMap,mf=new WeakMap,gf=new WeakMap,Mp=new WeakMap;if(D){let t=function(e){if(!(e in globalThis)){let r;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(r!==void 0)return r;AP(e)},set:i=>{r=i}})}};t("$state"),t("$effect"),t("$derived"),t("$inspect"),t("$props"),t("$bindable")}function co(t){ye===null&&np("onMount"),ss&&ye.l!==null?X5(ye).m.push(t):hr(()=>{let e=Ze(t);if(typeof e=="function")return e})}function X5(t){var r;var e=t.l;return(r=e.u)!=null?r:e.u={a:[],b:[],m:[]}}m();m();var BR=new Map;function HR(t,e){var r=BR.get(t);r||(r=new Set,BR.set(t,r)),r.add(e)}m();m();m();m();m();m();m();m();m();function Re(t,e,r=!1){var i;ne&&(i=we,cr());var n=new vs(t),s=r?65536:0;function a(o,l){if(ne){var c=Qu(i);if(o!==parseInt(c.substring(1))){var u=Pn();ze(u),n.anchor=u,Mt(!1),n.ensure(o,l),Mt(!0);return}}n.ensure(o,l)}ai(()=>{var o=!1;e((l,c=0)=>{o=!0,a(c,l)}),o||a(-1,null)},s)}m();m();m();function di(t,e){return e}function sU(t,e,r){var f;for(var i=[],n=e.length,s,a=e.length,o=0;o<n;o++){let d=e[o];In(d,()=>{if(s){if(s.pending.delete(d),s.done.add(d),s.pending.size===0){var h=t.outrogroups;V0(t,Gl(s.done)),h.delete(s),h.size===0&&(t.outrogroups=null)}}else a-=1},!1)}if(a===0){var l=i.length===0&&r!==null;if(l){var c=r,u=c.parentNode;Kl(u),u.append(c),t.items.clear()}V0(t,e,!l)}else s={pending:new Set(e),done:new Set},((f=t.outrogroups)!=null?f:t.outrogroups=new Set).add(s)}function V0(t,e,r=!0){var i;if(t.pending.size>0){i=new Set;for(let a of t.pending.values())for(let o of a)i.add(t.items.get(o).e)}for(var n=0;n<e.length;n++){var s=e[n];if(i!=null&&i.has(s)){s.f|=33554432;let a=document.createDocumentFragment();Ql(s,a)}else vt(e[n],r)}}var dc;function hi(t,e,r,i,n,s=null){var a=t,o=new Map,l=(e&4)!==0;if(l){var c=t;a=ne?ze(nr(c)):c.appendChild(Ht())}ne&&cr();var u=null,f=Qa(()=>{var C=r();return is(C)?C:C==null?[]:Gl(C)});D&&ur(f,"{#each ...}");var d,h=new Map,p=!0;function g(C){(_.effect.f&16384)===0&&(_.pending.delete(C),_.fallback=u,aU(_,d,a,e,i),u!==null&&(d.length===0?(u.f&33554432)===0?fc(u):(u.f^=33554432,wf(u,null,a)):
Line truncated
|
||||
\r\f\xA0\v\uFEFF`];function qR(t,e,r){var i=t==null?"":""+t;if(e&&(i=i?i+" "+e:e),r){for(var n of Object.keys(r))if(r[n])i=i?i+" "+n:n;else if(i.length)for(var s=n.length,a=0;(a=i.indexOf(n,a))>=0;){var o=a+s;(a===0||WR.includes(i[a-1]))&&(o===i.length||WR.includes(i[o]))?i=(a===0?"":i.substring(0,a))+i.substring(o+1):a=o}}return i===""?null:i}m();function wt(t,e,r,i,n,s){var a=t[Zu];if(ne||a!==r||a===void 0){var o=qR(r,i,s);(!ne||o!==t.getAttribute("class"))&&(o==null?t.removeAttribute("class"):e?t.className=o:t.setAttribute("class",o)),t[Zu]=r}else if(s&&n!==s)for(var l in s){var c=!!s[l];(n==null||c!==!!n[l])&&t.classList.toggle(l,c)}return s}m();m();var xU=Symbol("is custom element"),EU=Symbol("is html"),SU=i0?"link":"LINK";function Ce(t,e,r,i){var n=kU(t);if(ne&&(n[e]=t.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&t.nodeName===SU)){i||AU(t,e,r!=null?r:"");return}n[e]!==(n[e]=r)&&(e==="loading"&&(t[mP]=r),r==null?t.removeAttribute(e):typeof r!="string"&&CU(t).includes(e)?t[e]=r:t.setAttribute(e,r))}function kU(t){var e,r;return(r=t[e=ip])!=null?r:t[e]={[xU]:t.nodeName.includes("-"),[EU]:t.namespaceURI===Qh}}var YR=new Map;function CU(t){var e=t.getAttribute("is")||t.nodeName,r=YR.get(e);if(r)return r;YR.set(e,r=[]);for(var i,n=t,s=Element.prototype;s!==n;){i=Xw(n);for(var a in i)i[a].set&&a!=="innerHTML"&&a!=="textContent"&&a!=="innerText"&&r.push(a);n=jl(n)}return r}function AU(t,e,r){var i;D&&(e==="srcset"&&TU(t,r)||W0((i=t.getAttribute(e))!=null?i:"",r)||DP(e,t.outerHTML.replace(t.innerHTML,t.innerHTML&&"..."),String(r)))}function W0(t,e){return t===e?!0:new URL(t,document.baseURI).href===new URL(e,document.baseURI).href}function ZR(t){return t.split(",").map(e=>e.trim().split(" ").filter(Boolean))}function TU(t,e){var r=ZR(t.srcset),i=ZR(e);return i.length===r.length&&i.every(([n,s],a)=>s===r[a][1]&&(W0(r[a][0],n)||W0(n,r[a][0])))}m();m();m();function Z0(t,e,r=e){var i=new WeakSet;d0(t,"input",async n=>{D&&t.type==="checkbox"&&n0();var s=n?t.defaultValue:t.value;if(s=q0(t)?Y0(s):s,r(s),oe!==null&&i.add(oe),await Pp(),s!==(s=e())){var a=t.selectionStart,o=t.selectionEnd,l=t.value.length;if(t.value=s!=null?s:"",o!==null){var c=t.value.length;a===o&&o===l&&c>l?(t.selectionStart=c,t.selectionEnd=c):(t.selectionStart=a,t.selectionEnd=Math.min(o,c))}}}),(ne&&t.defaultValue!==t.value||Ze(e)==null&&t.value)&&(r(q0(t)?Y0(t.value):t.value),oe!==null&&i.add(oe)),sr(()=>{D&&t.type==="checkbox"&&n0();var n=e();if(t===document.activeElement){var s=At?us:oe;if(i.has(s))return}q0(t)&&n===Y0(t.value)||t.type==="date"&&!n&&!t.value||n!==t.value&&(t.value=n!=null?n:"")})}function q0(t){var e=t.type;return e==="number"||e==="range"}function Y0(t){return t===""?null:+t}m();m();m();m();m();function K0(t,e){return t===e||(t==null?void 0:t[Jt])===e}function at(t={},e,r,i){var n=ye.r,s=Q;return Kr(()=>{var a,o;return sr(()=>{a=o,o=(i==null?void 0:i())||[],Ze(()=>{K0(r(...o),t)||(e(t,...o),a&&K0(r(...a),t)&&e(null,...a))})}),()=>{let l=s;for(;l!==n&&l.parent!==null&&l.parent.f&33554432;)l=l.parent;let c=()=>{o&&K0(r(...o),t)&&e(null,...o)},u=l.teardown;l.teardown=()=>{c(),u==null||u()}}}),t}m();m();m();m();m();m();function Di(t,e,r,i){var x,S;var n=!ss||(r&2)!==0,s=(r&8)!==0,a=(r&16)!==0,o=i,l=!0,c=void 0,u=()=>a&&n?(c!=null||(c=Zs(i)),F(c)):(l&&(l=!1,o=a?Ze(i):i),o);let f;if(s){var d=Jt in t||Yu in t;f=(S=(x=jr(t,e))==null?void 0:x.set)!=null?S:d&&e in t?A=>t[e]=A:void 0}var h,p=!1;s?[h,p]=c0(()=>t[e]):h=t[e],h===void 0&&i!==void 0&&(h=u(),f&&(n&&CP(e),f(h)));var g;if(n?g=()=>{var A=t[e];return A===void 0?u():(l=!0,A)}:g=()=>{var A=t[e];return A!==void 0&&(o=void 0),A===void 0?o:A},n&&(r&4)===0)return g;if(f){var v=t.$$legacy;return(function(A,w){return arguments.length>0?((!n||!w||v||p)&&f(w?g():A),A):g()})}var b=!1,_=((r&1)!==0?Zs:Qa)(()=>(b=!1,g()));D&&(_.label=e),s&&F(_);var C=Q;return(function(A,w){if(arguments.length>0){let E=w?F(_):n&&s?et(A):A;return se(_,E),b=!0,o!==void 0&&(o=E),A}return oi&&b||(C.f&16384)!==0?_.v:F(_)})}m();m();m();function XR(t){return new Q0(t)}var ws,Oi,Q0=class{constructor(e){me(this,ws);me(this,Oi);var s,a;var r=new Map,i=(o,l)=>{var c=qa(l,!1,!1);return r.set(o,c),c};let n=new Proxy({...e.props||{},$$events:{}},{get(o,l){var c;return F((c=r.get(l))!=null?c:i(l,Reflect.get(o,l)))},has(o,l){var c;return l===Yu?!0:(F((c=r.get(l))!=null?c:i(l,Reflect.get(o,l))),Reflect.has(o,l))},set(o,l,c){var u;return se((u=r.get(l))!=null?u:i(l,c),c),Reflect.set(o,l,c)}});fe(this,Oi,(e.hydrate?j0:Js)(e.component,{target:e.target,anchor:e.anchor,props:n,context:e.context,intro:(s=e.intro)!=null?s:!1,recover:e.recover,transformError:e.transformError})),!At&&(!((a=e==null?void 0:e.props)!=null&&a.$$host)||e.sync===!1)&&io(),fe(this,ws,n.$$events);for(let o of Object.keys($(this,Oi)))o==="$set"||o==="$destroy"||o==="$on"||or(this,o,{get(){return $(this,Oi)[o]},set(l){$(this,Oi)[o]=l},enumerable:!0});$(this,Oi).$set=o=>{Object.assign(n,o)},$(this,Oi).$destroy=()=>{gs($(this,Oi))}}$set(e){$(this,Oi).$set(
Line truncated
|
||||
`:""}${(E=e.log.author)==null?void 0:E.name}
|
||||
${(0,tb.moment)(e.log.date).format(e.plugin.settings.commitDateFormat)}
|
||||
${e.log.message}`}]),ve("click",u,()=>se(n,!F(n))),le(t,o),ct()}Pt(["click"]);var nG=_e('<div class="tree-item nav-folder mod-root"></div>'),sG=_e('<main class="git-view"><div class="nav-header"><div class="nav-buttons-container"><div id="layoutChange" class="clickable-icon nav-action-button" aria-label="Change Layout"></div> <div id="refresh" data-icon="refresh-cw" aria-label="Refresh"></div></div></div> <div class="nav-files-container" style="position: relative;"><!> <div id="sentinel"></div> <div style="margin-bottom:40px"></div></div></main>'),aG={hash:"svelte-12n6twc",code:""};function nb(t,e){lt(e,!0),on(t,aG);let r=Di(e,"plugin",15),i=Oe(!1),n=et([]),s=Oe(void 0),a=Oe(et(r().settings.treeStructure)),o;hr(()=>{o&&o.empty()}),co(()=>{e.view.registerEvent(e.view.app.workspace.on("obsidian-git:head-change",()=>{c().catch(console.error)}))}),hr(()=>{n.forEach(x=>(0,ib.setIcon)(x,x.getAttr("data-icon")))}),co(()=>{let x=new IntersectionObserver(A=>{var w;(w=A[0])!=null&&w.isIntersecting&&!F(i)&&u().catch(console.error)}),S=activeDocument.querySelector("#sentinel");return S&&x.observe(S),()=>{x.disconnect()}}),c().catch(console.error);function l(){c().catch(console.error)}async function c(){var A,w;if(!r().gitReady){se(s,void 0);return}se(i,!0);let x=r().gitManager instanceof Se,S;((w=(A=F(s))==null?void 0:A.length)!=null?w:0)==0?S=x?50:10:S=F(s).length,se(s,await r().gitManager.log(void 0,!1,S),!0),se(i,!1)}async function u(){var w;if(!r().gitReady||F(s)===void 0)return;se(i,!0);let S=r().gitManager instanceof Se?50:10,A=await r().gitManager.log(void 0,!1,S,(w=F(s).last())==null?void 0:w.hash);F(s).push(...A.slice(1)),se(i,!1)}var f=sG(),d=z(f),h=z(d),p=z(h);at(p,x=>n[0]=x,()=>n==null?void 0:n[0]);var g=ie(p,2);let v;at(g,x=>n[1]=x,()=>n==null?void 0:n[1]),V(h),V(d);var b=ie(d,2),_=z(b);{var C=x=>{var S=nG();hi(S,21,()=>F(s),di,(A,w)=>{rb(A,{get view(){return e.view},get showTree(){return F(a)},get log(){return F(w)},get plugin(){return r()}})}),V(S),le(x,S)};Re(_,x=>{F(s)&&x(C)})}Va(4),V(b),V(f),je(()=>{Ce(p,"data-icon",F(a)?"list":"folder"),v=wt(g,1,"clickable-icon nav-action-button",null,v,{loading:F(i)})}),ve("click",p,()=>{se(a,!F(a)),(0,ib.setIcon)(n[0],F(a)?"list":"folder"),r(r().settings.treeStructure=F(a),!0),r().saveSettings()}),ve("click",g,l),le(t,f),ct()}Pt(["click"]);var yf=class extends QR.ItemView{constructor(e,r){super(e),this.plugin=r,this.hoverPopover=null}getViewType(){return wi.type}getDisplayText(){return wi.name}getIcon(){return wi.icon}onClose(){return this._view&&gs(this._view),super.onClose()}reload(){this._view&&gs(this._view),this._view=Js(nb,{target:this.contentEl,props:{plugin:this.plugin,view:this}})}onOpen(){return this.reload(),super.onOpen()}};m();var JR=require("obsidian"),Np=class extends JR.FuzzySuggestModal{constructor(r,i){super(r.app);this.branches=i;this.setPlaceholder("Select branch to checkout")}getItems(){return this.branches}getItemText(r){return r}onChooseItem(r,i){this.resolve(r)}openAndGetReslt(){return new Promise(r=>{this.resolve=r,this.open()})}onClose(){new Promise(r=>window.setTimeout(r,10)).then(()=>{this.resolve&&this.resolve(void 0)})}};m();var r$=require("obsidian");m();var ho=require("obsidian");m();var xf=require("obsidian");m();var e$=require("obsidian");var hc=class extends e$.Modal{constructor({app:r,path:i,filesToDeleteCount:n,filesToDiscardCount:s}){super(r);this.resolve=null;this.path=i,this.deleteCount=n,this.discardCount=s}openAndGetResult(){return this.open(),new Promise(r=>{this.resolve=r})}onOpen(){let r=this.deleteCount+this.discardCount,{contentEl:i,titleEl:n}=this,s="";this.path!=""&&(r>1?s=`files in "${this.path}"`:s=`"${this.path}"`),n.setText(`${this.discardCount==0?"Delete":"Discard"} ${s}`),this.deleteCount>0&&i.createEl("p").setText(`Are you sure you want to DELETE the ${wu(this.deleteCount,"untracked file")}? They are deleted according to your Obsidian trash settting.`),this.discardCount>0&&i.createEl("p").setText(`Are you sure you want to discard ALL changes in ${wu(this.discardCount,"tracked file")}?`);let a=i.createDiv({cls:"modal-button-container"});if(this.deleteCount>0){let l=a.createEl("button",{cls:"mod-warning",text:`${this.discardCount>0?"Discard":"Delete"} all ${wu(r,"file")}`});l.addEventListener("click",()=>{this.resolve&&this.resolve("delete"),this.close()}),l.addEventListener("keypress",()=>{this.resolve&&this.resolve("delete"),this.close()})}if(this.discardCount>0){let l=a.createEl("button",{cls:"mod-warning",text:`Discard all ${wu(this.discardCount,"tracked file")}`});l.addEventListener("click",()=>{this.resolve&&this.resolve("discard"),this.close()}),l.addEventListener("keypress",()=>{this.resolve&&this.resolve("discard"),this.close()})}let o=a.createEl("button",{text:"Cancel"});o.addEventListener("click",()=>(this.resolve&&this.resolve(!1),this.close())),o.addEventListener("keypress",()=>(this.resolve&&this.resolve(!1),this.close()))}onClose(){let{contentEl:r}=this;r.empty()}};var oG=_e('<div data-icon="go-t
Line truncated
|
||||
`);n.removed.lines.length>0&&!n.removed.no_nl_at_eof&&(c+=`
|
||||
`),i.replaceRange(c,i.offsetToPos(o),i.offsetToPos(l)),i.setSelection(i.offsetToPos(o))}}async stageHunk(e){if(!await this.plugin.isAllInitialized()||!this.editor)return;let{editor:r}=this.editor,i=Wi.getHunk(r.state,!1,e),n=!1;if(i||(i=Wi.getHunk(r.state,!0,e),n=!0),!i)return;let s=r.state.field(i$.editorInfoField).file.path,a=zt.createPatch(s,[i],"100644",n).join(`
|
||||
`)+`
|
||||
`;await this.gitManager.applyPatch(a),this.plugin.app.workspace.trigger("obsidian-git:refresh")}goToHunk(e){if(!this.editor)return;let{editor:r,obEditor:i}=this.editor,n=Wi.getHunks(r.state,!1),s=i.getCursor().line+1,a=zt.findNearestHunk(s,n,e,!0);if(a==null)return;let o=n[a];if(o){let l=o.added.start-1;i.setCursor(l,0),i.scrollIntoView({from:{line:l,ch:0},to:{line:l+1,ch:0}},!0)}}};m();m();var po=require("obsidian");var Gp=class{constructor(e){this.plg=e;this.codeMirrorExtensions=[];this.handleWorkspaceLeaf=e=>{if(!this.lineAuthorInfoProvider){console.warn("Git: undefined lineAuthorInfoProvider. Unexpected situation.");return}let r=e==null?void 0:e.view;!(r instanceof po.MarkdownView)||r.file==null||(r==null?void 0:r.allowNoFile)===!0||this.lineAuthorInfoProvider.trackChanged(r.file).catch(console.error)}}onLoadPlugin(){this.plg.registerEditorExtension(this.codeMirrorExtensions),bT(()=>this.plg.settings.lineAuthor,e=>{this.plg.settings.lineAuthor=e,this.plg.saveSettings()})}conditionallyActivateBySettings(){this.plg.settings.lineAuthor.show&&this.activateFeature()}activateFeature(){try{if(!this.isAvailableOnCurrentPlatform().available)return;PT(this.plg.settings.lineAuthor),this.lineAuthorInfoProvider=new _h(this.plg),this.createEventHandlers(),this.activateCodeMirrorExtensions(),console.log(this.plg.manifest.name+": Enabled line authoring.")}catch(e){console.warn("Git: Error while loading line authoring feature.",e),this.deactivateFeature()}}deactivateFeature(){var e;this.destroyEventHandlers(),this.deactivateCodeMirrorExtensions(),(e=this.lineAuthorInfoProvider)==null||e.destroy(),this.lineAuthorInfoProvider=void 0,console.log(this.plg.manifest.name+": Disabled line authoring.")}isAvailableOnCurrentPlatform(){return{available:this.plg.useSimpleGit&&po.Platform.isDesktopApp,gitManager:this.plg.gitManager instanceof Se?this.plg.gitManager:void 0}}refreshLineAuthorViews(){this.plg.settings.lineAuthor.show&&(this.deactivateFeature(),this.activateFeature())}activateCodeMirrorExtensions(){this.codeMirrorExtensions.push(HT),this.plg.app.workspace.updateOptions(),this.plg.app.workspace.iterateAllLeaves(this.handleWorkspaceLeaf)}deactivateCodeMirrorExtensions(){for(let e of this.codeMirrorExtensions)this.codeMirrorExtensions.remove(e);this.plg.app.workspace.updateOptions()}createEventHandlers(){this.gutterContextMenuEvent=this.createGutterContextMenuHandler(),this.fileOpenEvent=this.createFileOpenEvent(),this.workspaceLeafChangeEvent=this.createWorkspaceLeafChangeEvent(),this.fileModificationEvent=this.createVaultFileModificationHandler(),this.headChangeEvent=this.createHeadChangeEvent(),this.refreshOnCssChangeEvent=this.createCssRefreshHandler(),this.fileRenameEvent=this.createFileRenameEvent(),ST(),this.plg.registerEvent(this.gutterContextMenuEvent),this.plg.registerEvent(this.refreshOnCssChangeEvent),this.plg.registerEvent(this.fileOpenEvent),this.plg.registerEvent(this.workspaceLeafChangeEvent),this.plg.registerEvent(this.fileModificationEvent),this.plg.registerEvent(this.headChangeEvent),this.plg.registerEvent(this.fileRenameEvent)}destroyEventHandlers(){this.plg.app.workspace.offref(this.gutterContextMenuEvent),this.plg.app.workspace.offref(this.refreshOnCssChangeEvent),this.plg.app.workspace.offref(this.fileOpenEvent),this.plg.app.workspace.offref(this.workspaceLeafChangeEvent),this.plg.app.vault.offref(this.fileModificationEvent),this.plg.app.workspace.offref(this.headChangeEvent),this.plg.app.vault.offref(this.fileRenameEvent)}createFileOpenEvent(){return this.plg.app.workspace.on("file-open",e=>{var r;e&&((r=this.lineAuthorInfoProvider)==null||r.trackChanged(e).catch(console.error))})}createWorkspaceLeafChangeEvent(){return this.plg.app.workspace.on("active-leaf-change",this.handleWorkspaceLeaf)}createFileRenameEvent(){return this.plg.app.vault.on("rename",(e,r)=>{var i;return e instanceof po.TFile&&((i=this.lineAuthorInfoProvider)==null?void 0:i.trackChanged(e))})}createVaultFileModificationHandler(){return this.plg.app.vault.on("modify",e=>{var r;return e instanceof po.TFile&&((r=this.lineAuthorInfoProvider)==null?void 0:r.trackChanged(e))})}createHeadChangeEvent(){return this.plg.app.workspace.on("obsidian-git:head-change",()=>{this.refreshLineAuthorViews()})}createCssRefreshHandler(){return this.plg.app.workspace.on("css-change",()=>this.refreshLineAuthorViews())}createGutterContextMenuHandler(){return this.plg.app.workspace.on("editor-menu",AT)}};m();var pc=require("obsidian");m();m();var mo=require("@codemirror/state"),Vp=require("@codemirror/view");var jp=class extends Vp.GutterMarker{constructor(r,i){super();this.type=r;this.staged=i}toDOM(r){let i=createDiv();return i.className=`git-gutter-marker git-${this.type} ${this.staged?"staged":"unstaged"}`,this.type=="changedelete"&&i.setText("~"),i}},lb=mo.StateField.define({create:()=>mo.RangeSet.empty,update:(t,e)=>{let r=e.state.field(Gr,!1);if(!r)return mo.RangeSet.empty;let i=e.effects.some(s=>s.is(Oh)),n=e.effects.some(s=>s.is(Rl));if(i||n||(e.
Line truncated
|
||||
`+s),this.app.workspace.trigger("obsidian-git:refresh")}handleFileMenu(r,i,n,s){if(!this.gitReady||!this.settings.showFileMenu||!i)return;let a;if(typeof i=="string"?a=i:a=i.path,n=="file-explorer-context-menu"&&(r.addItem(o=>{o.setTitle("Git: Stage").setIcon("plus-circle").setSection("action").onClick(l=>{this.promiseQueue.addTask(async()=>{i instanceof ke.TFile?await this.stageFile(i):(await this.gitManager.stageAll({dir:this.gitManager.getRelativeRepoPath(a,!0)}),this.app.workspace.trigger("obsidian-git:refresh"))})})}),r.addItem(o=>{o.setTitle("Git: Unstage").setIcon("minus-circle").setSection("action").onClick(l=>{this.promiseQueue.addTask(async()=>{i instanceof ke.TFile?await this.unstageFile(i):(await this.gitManager.unstageAll({dir:this.gitManager.getRelativeRepoPath(a,!0)}),this.app.workspace.trigger("obsidian-git:refresh"))})})}),r.addItem(o=>{o.setTitle("Git: Add to .gitignore").setIcon("file-x").setSection("action").onClick(l=>{this.addFileToGitignore(a,i instanceof ke.TFolder).catch(c=>this.displayError(c))})})),n=="git-source-control"){r.addItem(l=>{l.setTitle("Git: Add to .gitignore").setIcon("file-x").setSection("action").onClick(c=>{this.addFileToGitignore(a,i instanceof ke.TFolder).catch(u=>this.displayError(u))})});let o=this.app.vault.adapter;s==="obsidian-git:menu"&&o instanceof ke.FileSystemAdapter&&(r.addItem(l=>{l.setTitle("Open in default app").setIcon("arrow-up-right").setSection("action").onClick(c=>{this.app.openWithDefaultApp(a)})}),r.addItem(l=>{l.setTitle("Show in system explorer").setIcon("arrow-up-right").setSection("action").onClick(c=>{window.electron.shell.showItemInFolder(c$.join(o.getBasePath(),a))})}))}}async migrateSettings(){this.settings.mergeOnPull!=null&&(this.settings.syncMethod=this.settings.mergeOnPull?"merge":"rebase",this.settings.mergeOnPull=void 0,await this.saveSettings()),this.settings.autoCommitMessage===void 0&&(this.settings.autoCommitMessage=this.settings.commitMessage,await this.saveSettings()),this.settings.gitPath!=null&&(this.localStorage.setGitPath(this.settings.gitPath),this.settings.gitPath=void 0,await this.saveSettings()),this.settings.username!=null&&(this.localStorage.setPassword(this.settings.username),this.settings.username=void 0,await this.saveSettings())}unloadPlugin(){var r,i;this.gitReady=!1,this.editorIntegration.onUnloadPlugin(),this.automaticsManager.unload(),(r=this.branchBar)==null||r.remove(),(i=this.statusBar)==null||i.remove(),this.statusBar=void 0,this.branchBar=void 0,this.gitManager.unload(),this.promiseQueue.clear();for(let n of this.intervalsToClear)window.clearInterval(n);this.intervalsToClear=[],this.debRefresh.cancel()}onunload(){this.unloadPlugin(),console.log("unloading "+this.manifest.name+" plugin")}async loadSettings(){let r=await this.loadData();r==null&&(r={showedMobileNotice:!0}),this.settings=DS(pt,r)}async saveSettings(){var r;(r=this.settingsTab)==null||r.beforeSaveSettings(),await this.saveData(this.settings)}get useSimpleGit(){return ke.Platform.isDesktopApp}async init({fromReload:r=!1}){var i;if(!this.localStorage.getPluginDisabled()){if(this.settings.showStatusBar&&!this.statusBar){let n=this.addStatusBarItem();this.statusBar=new xh(n,this),this.intervalsToClear.push(window.setInterval(()=>{var s;return(s=this.statusBar)==null?void 0:s.display()},1e3))}try{this.useSimpleGit?(this.gitManager=new Se(this),await this.gitManager.setGitInstance()):this.gitManager=new zi(this);let n=await this.gitManager.checkRequirements(),s=this.localStorage.getPausedAutomatics();switch(n){case"missing-git":this.displayError(`Cannot run git command. Trying to run: '${this.localStorage.getGitPath()||"git"}' .`);break;case"missing-repo":new ke.Notice("Can't find a valid git repository. Please create one via the given command or clone an existing repo.",1e4);break;case"valid":if(this.gitReady=!0,ke.Platform.isDesktop&&this.settings.showBranchStatusBar&&!this.branchBar){let a=this.addStatusBarItem();this.branchBar=new Hp(a,this),this.intervalsToClear.push(window.setInterval(()=>{var o;(o=this.branchBar)==null?void 0:o.display().catch(console.error)},6e4))}await((i=this.branchBar)==null?void 0:i.display()),this.editorIntegration.onReady(),this.app.workspace.trigger("obsidian-git:refresh"),this.app.workspace.trigger("obsidian-git:head-change"),!r&&this.settings.autoPullOnBoot&&!s&&this.promiseQueue.addTask(()=>this.pullChangesFromRemote()),s||await this.automaticsManager.init(),s&&new ke.Notice("Automatic routines are currently paused.");break;default:this.log("Something weird happened. The 'checkRequirements' result is "+n)}}catch(n){this.displayError(n),console.error(n)}}}async createNewRepo(){try{await this.gitManager.init(),new ke.Notice("Initialized new repo"),await this.init({fromReload:!0})}catch(r){this.displayError(r)}}async cloneNewRepo(){let i=await new rt(this,{placeholder:"Enter remote URL"}).openAndGetResult();if(i){let n="Vault Root",s=await new rt(this,{options:this.gitManager instanceof zi?[n]:[],placeholder:"En
Line truncated
|
||||
# Additional Instructions
|
||||
I strongly recommend to use "Source mode" for viewing the conflicted files. For simple conflicts, in each file listed above replace every occurrence of the following text blocks with the desired text.
|
||||
|
||||
\`\`\`diff
|
||||
<<<<<<< HEAD
|
||||
File changes in local repository
|
||||
=======
|
||||
File changes in remote repository
|
||||
>>>>>>> origin/main
|
||||
\`\`\``]),await this.tools.writeAndOpenFile(i==null?void 0:i.join(`
|
||||
`))}async editRemotes(){if(!await this.isAllInitialized())return;let r=await this.gitManager.getRemotes(),n=await new rt(this,{options:r,placeholder:"Select or create a new remote by typing its name and selecting it"}).openAndGetResult();if(n){let s=await this.gitManager.getRemoteUrl(n),o=await new rt(this,{initialValue:s,placeholder:"Enter remote URL"}).openAndGetResult();if(o)return await this.gitManager.setRemote(n,uv(o)),n}}async selectRemoteBranch(){let r=await this.gitManager.getRemotes(),i;r.length===0&&(i=await this.editRemotes(),i==null&&(r=await this.gitManager.getRemotes()));let n=new rt(this,{options:r,placeholder:"Select or create a new remote by typing its name and selecting it"}),s=i!=null?i:await n.openAndGetResult();if(s){this.displayMessage("Fetching remote branches"),await this.gitManager.fetch(s);let a=await this.gitManager.getRemoteBranches(s),l=await new rt(this,{options:a,placeholder:"Select or create a new remote branch by typing its name and selecting it"}).openAndGetResult();return l==null?void 0:l.startsWith(s+"/")?l:`${s}/${l}`}}async removeRemote(){if(!await this.isAllInitialized())return;let r=await this.gitManager.getRemotes(),n=await new rt(this,{options:r,placeholder:"Select a remote"}).openAndGetResult();n&&await this.gitManager.removeRemote(n)}onActiveLeafChange(r){var a,o;let i=r==null?void 0:r.view;if(!(i!=null&&i.getState().file)&&!(i instanceof Ha||i instanceof Ua))return;let n=this.app.workspace.getLeavesOfType(Xt.type).first(),s=this.app.workspace.getLeavesOfType(wi.type).first();if((a=n==null?void 0:n.view.containerEl.querySelector("div.tree-item-self.is-active"))==null||a.removeClass("is-active"),(o=s==null?void 0:s.view.containerEl.querySelector("div.tree-item-self.is-active"))==null||o.removeClass("is-active"),(r==null?void 0:r.view)instanceof Ha||(r==null?void 0:r.view)instanceof Ua){let c=r.view.state.bFile.replace(/["\\]/g,"\\$&");this.lastDiffViewState=r.view.getState();let u;n&&r.view.state.aRef=="HEAD"?u=n.view.containerEl.querySelector(`div.staged div.tree-item-self[data-path="${c}"]`):n&&r.view.state.aRef==""?u=n.view.containerEl.querySelector(`div.changes div.tree-item-self[data-path="${c}"]`):s&&(u=s.view.containerEl.querySelector(`div.tree-item-self[data-path='${c}']`)),u==null||u.addClass("is-active")}else this.lastDiffViewState=void 0}handleNoNetworkError(r){this.state.offlineMode?this.log("Encountered network error, but already in offline mode"):this.displayError("Git: Going into offline mode. Future network errors will no longer be displayed.",2e3),this.setPluginState({offlineMode:!0})}displayMessage(r,i=4*1e3){var n;(n=this.statusBar)==null||n.displayMessage(r.toLowerCase(),i),this.settings.disablePopups||(!this.settings.disablePopupsForNoChanges||!r.startsWith("No changes"))&&new ke.Notice(r,5*1e3),this.log(r)}displayError(r,i=10*1e3){var s;if(r instanceof lu.UserCanceledError){new ke.Notice("Aborted");return}let n;r instanceof Error?n=r:n=new Error(String(r)),this.settings.showErrorNotices&&new ke.Notice(n.message,i),console.error(`${this.manifest.id}:`,n.stack),(s=this.statusBar)==null||s.displayMessage(n.message.toLowerCase(),i)}log(...r){console.log(`${this.manifest.id}:`,...r)}};
|
||||
/*! Bundled license information:
|
||||
|
||||
ieee754/index.js:
|
||||
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
||||
|
||||
buffer/index.js:
|
||||
(*!
|
||||
* The buffer module from node.js, for the browser.
|
||||
*
|
||||
* @author Feross Aboukhadijeh <https://feross.org>
|
||||
* @license MIT
|
||||
*)
|
||||
|
||||
safe-buffer/index.js:
|
||||
(*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> *)
|
||||
|
||||
crc-32/crc32.js:
|
||||
(*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
|
||||
|
||||
isomorphic-git/index.js:
|
||||
(*!
|
||||
* This code for `path.join` is directly copied from @zenfs/core/path for bundle size improvements.
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
* Copyright (c) James Prevett and other ZenFS contributors.
|
||||
*
|
||||
* Windows support added:
|
||||
* - Backslashes are normalised to forward slashes before processing.
|
||||
* - Drive-letter prefixes (e.g. "C:") are detected and preserved through
|
||||
* normalisation, so absolute Windows paths are handled correctly.
|
||||
* - An absolute argument passed to join() resets the accumulated path,
|
||||
* matching Node behaviour and handling worktree gitdir paths properly.
|
||||
*
|
||||
* Limitation: UNC paths (e.g. \\server\share) are not supported. The leading
|
||||
* backslashes are normalised to forward slashes and then collapsed by
|
||||
* normalizeString, losing the UNC root. Git on Windows works with
|
||||
* drive-letter paths, so this is not expected to be a practical issue.
|
||||
*)
|
||||
|
||||
js-sha256/build/sha256.mjs:
|
||||
(**
|
||||
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
||||
*
|
||||
* @version 0.12.0
|
||||
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||
* @copyright Chen, Yi-Cyuan 2014-2026
|
||||
* @license MIT
|
||||
*)
|
||||
*/
|
||||
|
||||
/* nosourcemap */
|
||||
Reference in new issue
Block a user