just-git 1.3.1 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{hooks-BtbyLyYE.d.ts → hooks-t3k-y0u_.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/repo/index.d.ts +200 -270
- package/dist/repo/index.js +13 -18
- package/dist/server/index.d.ts +203 -59
- package/dist/server/index.js +37 -36
- package/package.json +1 -1
package/dist/server/index.js
CHANGED
|
@@ -1,40 +1,41 @@
|
|
|
1
|
-
var ue=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});function T(r){return r!=null&&typeof r=="object"&&"reject"in r&&r.reject===!0}var ke="0000000000000000000000000000000000000000",st=(()=>{let r=new Array(256);for(let e=0;e<256;e++)r[e]=(e>>4).toString(16)+(e&15).toString(16);return r})();function he(r){let e="";for(let t=0;t<20;t++)e+=st[r[t]];return e}function Z(r,e){let t="";for(let n=0;n<20;n++)t+=st[r[e+n]];return t}function ye(r){let e=new Uint8Array(20);for(let t=0;t<20;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}var or=new TextEncoder;function ve(r){return typeof r=="string"?or.encode(r):r}function ir(){if(typeof globalThis.Bun<"u")return()=>{let r=new Bun.CryptoHasher("sha1"),e={update(t){return r.update(ve(t)),e},hex:()=>Promise.resolve(r.digest("hex"))};return e};try{let r=ue(["node","crypto"].join(":"));if(typeof r.createHash=="function")return()=>{let e=r.createHash("sha1"),t={update(n){return e.update(ve(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let r=[],e={update(t){return r.push(ve(t)),e},async hex(){let t=0;for(let i of r)t+=i.byteLength;let n=new Uint8Array(t),s=0;for(let i of r)n.set(i,s),s+=i.byteLength;let a=await crypto.subtle.digest("SHA-1",n);return he(new Uint8Array(a))}};return e};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}var at=ir(),G=at;async function ot(r){return at().update(r).hex()}var cr=new Set(["tree","commit","tag"]),be=class{map=new Map;currentBytes=0;maxBytes;constructor(e=16*1024*1024){this.maxBytes=e}get(e){return this.map.get(e)}set(e,t){if(!cr.has(t.type))return;let n=t.content.byteLength;if(!(n>this.maxBytes/2)&&!this.map.has(e)){for(;this.currentBytes+n>this.maxBytes&&this.map.size>0;){let s=this.map.keys().next().value;this.currentBytes-=this.map.get(s).content.byteLength,this.map.delete(s)}this.map.set(e,t),this.currentBytes+=n}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}};var L=Uint8Array,F=Uint16Array,fr=Int32Array,it=new L([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ct=new L([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),lr=new L([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ft=(r,e)=>{let t=new F(31);for(let s=0;s<31;++s)t[s]=e+=1<<r[s-1];let n=new fr(t[30]);for(let s=1;s<30;++s)for(let a=t[s];a<t[s+1];++a)n[a]=a-t[s]<<5|s;return{b:t,r:n}},{b:lt}=ft(it,2);lt[28]=258;var{b:dr}=ft(ct,0),Ae=new F(32768);for(let r=0;r<32768;++r){let e=(r&43690)>>1|(r&21845)<<1;e=(e&52428)>>2|(e&13107)<<2,e=(e&61680)>>4|(e&3855)<<4,Ae[r]=((e&65280)>>8|(e&255)<<8)>>1}var J=(r,e,t)=>{let n=r.length,s=0,a=new F(e);for(;s<n;++s)r[s]&&++a[r[s]-1];let i=new F(e);for(s=1;s<e;++s)i[s]=i[s-1]+a[s-1]<<1;let o;if(t){o=new F(1<<e);let f=15-e;for(s=0;s<n;++s)if(r[s]){let c=s<<4|r[s],l=e-r[s],d=i[r[s]-1]++<<l;for(let p=d|(1<<l)-1;d<=p;++d)o[Ae[d]>>f]=c}}else for(o=new F(n),s=0;s<n;++s)r[s]&&(o[s]=Ae[i[r[s]-1]++]>>15-r[s]);return o},Q=new L(288);for(let r=0;r<144;++r)Q[r]=8;for(let r=144;r<256;++r)Q[r]=9;for(let r=256;r<280;++r)Q[r]=7;for(let r=280;r<288;++r)Q[r]=8;var dt=new L(32);for(let r=0;r<32;++r)dt[r]=5;var pr=J(Q,9,1),ur=J(dt,5,1),Se=r=>{let e=r[0];for(let t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},U=(r,e,t)=>{let n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},je=(r,e)=>{let t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},pt=r=>(r+7)/8|0,hr=(r,e,t)=>((e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new L(r.subarray(e,t))),H=(r,e)=>{let t=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||t[r]||"unknown inflate error")},ut=(r,e,t,n)=>{let s=r.length,a=n?n.length:0;if(!s||e.f&&!e.l)return t||new L(0);let i=!t,o=i||e.i!=2,f=e.i;i&&(t=new L(s*3));let c=y=>{let R=t.length;if(y>R){let w=new L(Math.max(R*2,y));w.set(t),t=w}},l=e.f||0,d=e.p||0,p=e.b||0,u=e.l,h=e.d,m=e.m,g=e.n,b=s*8;do{if(!u){l=U(r,d,1);let P=U(r,d+1,3);if(d+=3,P)if(P==1)u=pr,h=ur,m=9,g=5;else if(P==2){let x=U(r,d,31)+257,O=U(r,d+10,15)+4,S=x+U(r,d+5,31)+1;d+=14;let E=new L(S),j=new L(19);for(let N=0;N<O;++N)j[lr[N]]=U(r,d+N*3,7);d+=O*3;let M=Se(j),I=(1<<M)-1,C=J(j,M,1);for(let N=0;N<S;){let rt=C[U(r,d,I)];d+=rt&15;let V=rt>>4;if(V<16)E[N++]=V;else{let nt=0,pe=0;for(V==16?(pe=3+U(r,d,3),d+=2,nt=E[N-1]):V==17?(pe=3+U(r,d,7),d+=3):V==18&&(pe=11+U(r,d,127),d+=7);pe--;)E[N++]=nt}}let $=E.subarray(0,x),tt=E.subarray(x);m=Se($),g=Se(tt),u=J($,m,1),h=J(tt,g,1)}else H(1);else{let x=pt(d)+4,O=r[x-4]|r[x-3]<<8,S=x+O;if(S>s){f&&H(0);break}o&&c(p+O),t.set(r.subarray(x,S),p),e.b=p+=O,e.p=d=S*8,e.f=l;continue}if(d>b){f&&H(0);break}}o&&c(p+131072);let y=(1<<m)-1,R=(1<<g)-1,w=d;for(;;w=d){let P=u[je(r,d)&y],x=P>>4;if(d+=P&15,d>b){f&&H(0);break}if(P||H(2),x<256)t[p++]=x;else if(x==256){w=d,u=null;break}else{let O=x-254;if(x>264){let I=x-257,C=it[I];O=U(r,d,(1<<C)-1)+lt[I],d+=C}let S=h[je(r,d)&R],E=S>>4;S||H(3),d+=S&15;let j=dr[E];if(E>3){let I=ct[E];j+=je(r,d)&(1<<I)-1,d+=I}if(d>b){f&&H(0);break}o&&c(p+131072);let M=p+O;if(p<j){let I=a-j,C=Math.min(j,M);for(I+p<0&&H(3);p<C;++p)t[p]=n[I+p]}for(;p<M;++p)t[p]=t[p-j]}}e.l=u,e.p=w,e.b=p,e.f=l,u&&(l=1,e.m=m,e.d=h,e.n=g)}while(!l);return p!=t.length&&i?hr(t,0,p):t.subarray(0,p)},ht=r=>(((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&H(0,"invalid zlib data"),r[1]&32&&H(0,"zlib dictionaries are not supported"),2);function yt(r){let e=ht(r);return ut(r.subarray(e,-4),{i:2})}function Ie(r){let e=ht(r),t={i:2},n=ut(r.subarray(e),t),s=pt(t.p);return{result:n,bytesConsumed:e+s+4}}async function yr(){let r;if(!(typeof document<"u"))try{r=ue(["node","zlib"].join(":"))}catch{try{r=await import(["node","zlib"].join(":"))}catch{}}if(r&&typeof r.deflateSync=="function"&&typeof r.inflateSync=="function"){let n=null;try{let s=r.inflateSync(r.deflateSync(Buffer.from("x")),{info:!0});s?.engine&&typeof s.engine.bytesWritten=="number"&&(n=a=>{let i=r.inflateSync(a,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:s=>new Uint8Array(r.deflateSync(s)),inflateSync:s=>new Uint8Array(r.inflateSync(s)),inflateWithConsumed:n??Ie}}let t;return typeof globalThis.CompressionStream=="function"?t=async n=>{let s=new CompressionStream("deflate"),a=s.writable.getWriter();return a.write(n),a.close(),new Uint8Array(await new Response(s.readable).arrayBuffer())}:t=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:t,inflateSync:yt,inflateWithConsumed:Ie}}var br=null;function bt(){return br??=yr()}async function me(r){return await(await bt()).deflateSync(r)}async function Te(r,e){let t=await bt(),{result:n,bytesConsumed:s}=t.inflateWithConsumed(r);if(n.byteLength!==e)throw new Error(`Inflate size mismatch: got ${n.byteLength}, expected ${e}`);return{result:n,bytesConsumed:s}}var z=1346454347,xe=2,xt=1,Rt=2,wt=3,Pt=4,W=6,ee=7,Ot={[xt]:"commit",[Rt]:"tree",[wt]:"blob",[Pt]:"tag"},Et={commit:xt,tree:Rt,blob:wt,tag:Pt};async function kt(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.getUint32(0);if(n!==z)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${z.toString(16)})`);let s=t.getUint32(4);if(s!==xe)throw new Error(`Unsupported pack version: ${s}`);if(r.byteLength>=32){let c=Z(r,r.byteLength-20),l=G();l.update(r.subarray(0,r.byteLength-20));let d=await l.hex();if(d!==c)throw new Error(`pack checksum mismatch: expected ${c}, computed ${d}`)}let a=t.getUint32(8),i=[],o=12;for(let c=0;c<a;c++){let l=await mr(r,o);i.push(l),o=l.nextOffset}return(await gr(i,e)).map((c,l)=>({...c,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function mr(r,e){let t=e,n=r[e++],s=n>>4&7,a=n&15,i=4;for(;n&128;)n=r[e++],a|=(n&127)<<i,i+=7;let o,f;if(s===W){let d=r[e++];for(o=d&127;d&128;)o+=1,d=r[e++],o=(o<<7)+(d&127);o=t-o}else s===ee&&(f=Z(r,e),e+=20);let{result:c,bytesConsumed:l}=await Te(r.subarray(e),a);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:o,baseHash:f,nextOffset:e+l}}var mt=50;async function gr(r,e){let t=new Map;for(let a=0;a<r.length;a++)t.set(r[a].headerOffset,a);let n=new Array(r.length).fill(null);async function s(a,i=0){if(i>mt)throw new Error(`delta chain depth ${i} exceeds limit of ${mt}`);let o=n[a];if(o)return o;let f=r[a];if(f.typeNum!==W&&f.typeNum!==ee){let u=Ot[f.typeNum];if(!u)throw new Error(`Unknown object type: ${f.typeNum}`);let h={type:u,content:f.inflated,hash:await q(u,f.inflated)};return n[a]=h,h}if(f.typeNum===W){let u=t.get(f.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${f.baseOffset}`);let h=await s(u,i+1),m=ge(h.content,f.inflated),g={type:h.type,content:m,hash:await q(h.type,m)};return n[a]=g,g}let c=await xr(r,n,f.baseHash,s),l;if(c!==void 0)l=await s(c,i+1);else if(e){let u=await e(f.baseHash);u&&(l=u)}if(!l)throw new Error(`REF_DELTA base not found for hash ${f.baseHash}`);let d=ge(l.content,f.inflated),p={type:l.type,content:d,hash:await q(l.type,d)};return n[a]=p,p}for(let a=0;a<r.length;a++)await s(a);return n}async function xr(r,e,t,n){for(let s=0;s<e.length;s++)if(e[s]?.hash===t)return s;for(let s=0;s<r.length;s++){let a=r[s];if(a.typeNum!==W&&a.typeNum!==ee&&(await n(s)).hash===t)return s}}var Ue=class{buf=new Uint8Array(0);iter;eof=!1;_bytesRead=0;hasher;constructor(e,t=!1){this.iter=e[Symbol.asyncIterator](),this.hasher=t?G():null}get bytesRead(){return this._bytesRead}async pullMore(){if(this.eof)return!1;let{value:e,done:t}=await this.iter.next();if(t||!e)return this.eof=!0,!1;if(this.buf.byteLength===0)this.buf=new Uint8Array(e);else{let n=new Uint8Array(this.buf.byteLength+e.byteLength);n.set(this.buf),n.set(e,this.buf.byteLength),this.buf=n}return!0}async ensure(e){for(;this.buf.byteLength<e;)if(!await this.pullMore())throw new Error(`Unexpected end of pack data: needed ${e} bytes, have ${this.buf.byteLength}`)}consume(e){let t=new Uint8Array(this.buf.subarray(0,e));return this.hasher?.update(t),this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async readByte(){return await this.ensure(1),this.consume(1)[0]}async readExact(e){return await this.ensure(e),this.consume(e)}async readRaw(e){await this.ensure(e);let t=new Uint8Array(this.buf.subarray(0,e));return this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async inflateNext(e){for(this.buf.byteLength===0&&!this.eof&&await this.pullMore();;)try{let{result:t,bytesConsumed:n}=await Te(this.buf,e);return this.consume(n),t}catch{if(!this.eof&&await this.pullMore())continue;throw new Error(`Failed to inflate pack entry at byte ${this._bytesRead} (expected ${e} bytes)`)}}async hashHex(){if(!this.hasher)throw new Error("Hashing not enabled");return this.hasher.hex()}};async function*vt(r,e){let t=new Ue(r,!0),n=await t.readExact(12),s=new DataView(n.buffer,n.byteOffset,n.byteLength),a=s.getUint32(0);if(a!==z)throw new Error(`Invalid pack signature: 0x${a.toString(16)} (expected 0x${z.toString(16)})`);let i=s.getUint32(4);if(i!==xe)throw new Error(`Unsupported pack version: ${i}`);let o=s.getUint32(8),f=new Map,c=new Map;for(let p=0;p<o;p++){let u=t.bytesRead,h=await t.readByte(),m=h>>4&7,g=h&15,b=4;for(;h&128;)h=await t.readByte(),g|=(h&127)<<b,b+=7;let y,R;if(m===W){let x=await t.readByte();for(y=x&127;x&128;)y+=1,x=await t.readByte(),y=(y<<7)+(x&127);y=u-y}else if(m===ee){let x=await t.readExact(20);R=Z(x,0)}let w=await t.inflateNext(g),P;if(m!==W&&m!==ee){let x=Ot[m];if(!x)throw new Error(`Unknown object type: ${m}`);P={type:x,content:w,hash:await q(x,w)}}else if(m===W){let x=f.get(y);if(!x)throw new Error(`OFS_DELTA base not found at offset ${y}`);let O=ge(x.content,w);P={type:x.type,content:O,hash:await q(x.type,O)}}else{let x=c.get(R);if(!x&&e&&(x=await e(R)??void 0),!x)throw new Error(`REF_DELTA base not found for hash ${R}`);let O=ge(x.content,w);P={type:x.type,content:O,hash:await q(x.type,O)}}f.set(u,P),c.set(P.hash,P),yield P}let l=Z(await t.readRaw(20),0),d=await t.hashHex();if(d!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${d}`)}function ge(r,e){let t=0,{value:n,newPos:s}=gt(e,t);if(t=s,n!==r.byteLength)throw new Error(`Delta base size mismatch: expected ${n}, got ${r.byteLength}`);let{value:a,newPos:i}=gt(e,t);t=i;let o=new Uint8Array(a),f=0;for(;t<e.byteLength;){let c=e[t++];if(c&128){let l=0,d=0;c&1&&(l=e[t++]),c&2&&(l|=e[t++]<<8),c&4&&(l|=e[t++]<<16),c&8&&(l|=e[t++]<<24),c&16&&(d=e[t++]),c&32&&(d|=e[t++]<<8),c&64&&(d|=e[t++]<<16),d===0&&(d=65536),o.set(r.subarray(l,l+d),f),f+=d}else if(c>0)o.set(e.subarray(t,t+c),f),f+=c,t+=c;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(f!==a)throw new Error(`Delta produced ${f} bytes, expected ${a}`);return o}async function Re(r){let e=[],t=new Map,n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,xe),s.setUint32(8,r.length),e.push(n);let a=12,i=[];for(let o of r){let f=a;t.set(o.hash,a);let c=o.delta&&o.deltaBaseHash?t.get(o.deltaBaseHash):void 0;if(o.delta&&c!==void 0){let l=Le(W,o.delta.byteLength),d=wr(a-c),p=await me(o.delta);e.push(l,d,p),a+=l.byteLength+d.byteLength+p.byteLength}else{let l=Et[o.type],d=Le(l,o.content.byteLength),p=await me(o.content);e.push(d,p),a+=d.byteLength+p.byteLength}i.push({hash:o.hash,offset:f,nextOffset:a})}return{data:await Rr(e),entries:i}}async function*St(r,e){let t=G(),n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,xe),s.setUint32(8,r),t.update(n),yield n;for await(let a of e){let i=Et[a.type],o=Le(i,a.content.byteLength),f=await me(a.content);t.update(o),t.update(f),yield Pr(o,f)}yield ye(await t.hex())}async function Rr(r){let e=0;for(let i of r)e+=i.byteLength;e+=20;let t=new Uint8Array(e),n=0;for(let i of r)t.set(i,n),n+=i.byteLength;let s=G();s.update(t.subarray(0,n));let a=await s.hex();return t.set(ye(a),n),t}function wr(r){let e=[];e.push(r&127);let t=r>>>7;for(;t>0;)e.unshift(128|--t&127),t>>>=7;return new Uint8Array(e)}function Le(r,e){let t=[],n=r<<4|e&15;for(e>>=4;e>0;)t.push(n|128),n=e&127,e>>=7;return t.push(n),new Uint8Array(t)}function gt(r,e){let t=0,n=0,s;do s=r[e++],t|=(s&127)<<n,n+=7;while(s&128);return{value:t,newPos:e}}function Pr(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var Or=new TextEncoder;async function q(r,e){let t=Or.encode(`${r} ${e.byteLength}\0`),n=G();return n.update(t),n.update(e),n.hex()}var Er=new TextEncoder,Sn=new TextDecoder;function jt(r,e){let t=Er.encode(`${r} ${e.byteLength}\0`),n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t),n.set(e,t.byteLength),n}function te(r){let e=r.indexOf("<"),t=r.indexOf(">");if(e===-1||t===-1)throw new Error(`Malformed identity line: "${r}"`);let n=r.slice(0,e).trimEnd(),s=r.slice(e+1,t),a=r.slice(t+2),[i="0",o="+0000"]=a.split(" "),f=parseInt(i,10);return{name:n,email:s,timestamp:f,timezone:o}}var Tn=new TextEncoder,vr=new TextDecoder;function re(r){let e=vr.decode(r),t=e.indexOf(`
|
|
1
|
+
var he=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});function T(r){return r!=null&&typeof r=="object"&&"reject"in r&&r.reject===!0}var ye="0000000000000000000000000000000000000000",ot=(()=>{let r=new Array(256);for(let e=0;e<256;e++)r[e]=(e>>4).toString(16)+(e&15).toString(16);return r})();function be(r){let e="";for(let t=0;t<20;t++)e+=ot[r[t]];return e}function J(r,e){let t="";for(let n=0;n<20;n++)t+=ot[r[e+n]];return t}function me(r){let e=new Uint8Array(20);for(let t=0;t<20;t++)e[t]=parseInt(r.slice(t*2,t*2+2),16);return e}var lr=new TextEncoder;function je(r){return typeof r=="string"?lr.encode(r):r}function dr(){if(typeof globalThis.Bun<"u")return()=>{let r=new Bun.CryptoHasher("sha1"),e={update(t){return r.update(je(t)),e},hex:()=>Promise.resolve(r.digest("hex"))};return e};try{let r=he(["node","crypto"].join(":"));if(typeof r.createHash=="function")return()=>{let e=r.createHash("sha1"),t={update(n){return e.update(je(n)),t},hex:()=>Promise.resolve(e.digest("hex"))};return t}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let r=[],e={update(t){return r.push(je(t)),e},async hex(){let t=0;for(let i of r)t+=i.byteLength;let n=new Uint8Array(t),s=0;for(let i of r)n.set(i,s),s+=i.byteLength;let a=await crypto.subtle.digest("SHA-1",n);return be(new Uint8Array(a))}};return e};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}var it=dr(),G=it;async function ct(r){return it().update(r).hex()}var pr=new Set(["tree","commit","tag"]),ge=class{map=new Map;currentBytes=0;maxBytes;constructor(e=16*1024*1024){this.maxBytes=e}get(e){return this.map.get(e)}set(e,t){if(!pr.has(t.type))return;let n=t.content.byteLength;if(!(n>this.maxBytes/2)&&!this.map.has(e)){for(;this.currentBytes+n>this.maxBytes&&this.map.size>0;){let s=this.map.keys().next().value;this.currentBytes-=this.map.get(s).content.byteLength,this.map.delete(s)}this.map.set(e,t),this.currentBytes+=n}}get size(){return this.map.size}get bytes(){return this.currentBytes}clear(){this.map.clear(),this.currentBytes=0}};var L=Uint8Array,F=Uint16Array,ur=Int32Array,ft=new L([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),lt=new L([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hr=new L([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dt=(r,e)=>{let t=new F(31);for(let s=0;s<31;++s)t[s]=e+=1<<r[s-1];let n=new ur(t[30]);for(let s=1;s<30;++s)for(let a=t[s];a<t[s+1];++a)n[a]=a-t[s]<<5|s;return{b:t,r:n}},{b:pt}=dt(ft,2);pt[28]=258;var{b:yr}=dt(lt,0),Ie=new F(32768);for(let r=0;r<32768;++r){let e=(r&43690)>>1|(r&21845)<<1;e=(e&52428)>>2|(e&13107)<<2,e=(e&61680)>>4|(e&3855)<<4,Ie[r]=((e&65280)>>8|(e&255)<<8)>>1}var Q=(r,e,t)=>{let n=r.length,s=0,a=new F(e);for(;s<n;++s)r[s]&&++a[r[s]-1];let i=new F(e);for(s=1;s<e;++s)i[s]=i[s-1]+a[s-1]<<1;let o;if(t){o=new F(1<<e);let f=15-e;for(s=0;s<n;++s)if(r[s]){let c=s<<4|r[s],l=e-r[s],d=i[r[s]-1]++<<l;for(let p=d|(1<<l)-1;d<=p;++d)o[Ie[d]>>f]=c}}else for(o=new F(n),s=0;s<n;++s)r[s]&&(o[s]=Ie[i[r[s]-1]++]>>15-r[s]);return o},ee=new L(288);for(let r=0;r<144;++r)ee[r]=8;for(let r=144;r<256;++r)ee[r]=9;for(let r=256;r<280;++r)ee[r]=7;for(let r=280;r<288;++r)ee[r]=8;var ut=new L(32);for(let r=0;r<32;++r)ut[r]=5;var br=Q(ee,9,1),mr=Q(ut,5,1),Se=r=>{let e=r[0];for(let t=1;t<r.length;++t)r[t]>e&&(e=r[t]);return e},U=(r,e,t)=>{let n=e/8|0;return(r[n]|r[n+1]<<8)>>(e&7)&t},Ae=(r,e)=>{let t=e/8|0;return(r[t]|r[t+1]<<8|r[t+2]<<16)>>(e&7)},ht=r=>(r+7)/8|0,gr=(r,e,t)=>((e==null||e<0)&&(e=0),(t==null||t>r.length)&&(t=r.length),new L(r.subarray(e,t))),H=(r,e)=>{let t=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||t[r]||"unknown inflate error")},yt=(r,e,t,n)=>{let s=r.length,a=n?n.length:0;if(!s||e.f&&!e.l)return t||new L(0);let i=!t,o=i||e.i!=2,f=e.i;i&&(t=new L(s*3));let c=y=>{let g=t.length;if(y>g){let w=new L(Math.max(g*2,y));w.set(t),t=w}},l=e.f||0,d=e.p||0,p=e.b||0,u=e.l,h=e.d,m=e.m,R=e.n,b=s*8;do{if(!u){l=U(r,d,1);let E=U(r,d+1,3);if(d+=3,E)if(E==1)u=br,h=mr,m=9,R=5;else if(E==2){let x=U(r,d,31)+257,O=U(r,d+10,15)+4,j=x+U(r,d+5,31)+1;d+=14;let P=new L(j),A=new L(19);for(let N=0;N<O;++N)A[hr[N]]=U(r,d+N*3,7);d+=O*3;let B=Se(A),I=(1<<B)-1,C=Q(A,B,1);for(let N=0;N<j;){let st=C[U(r,d,I)];d+=st&15;let Z=st>>4;if(Z<16)P[N++]=Z;else{let at=0,ue=0;for(Z==16?(ue=3+U(r,d,3),d+=2,at=P[N-1]):Z==17?(ue=3+U(r,d,7),d+=3):Z==18&&(ue=11+U(r,d,127),d+=7);ue--;)P[N++]=at}}let $=P.subarray(0,x),nt=P.subarray(x);m=Se($),R=Se(nt),u=Q($,m,1),h=Q(nt,R,1)}else H(1);else{let x=ht(d)+4,O=r[x-4]|r[x-3]<<8,j=x+O;if(j>s){f&&H(0);break}o&&c(p+O),t.set(r.subarray(x,j),p),e.b=p+=O,e.p=d=j*8,e.f=l;continue}if(d>b){f&&H(0);break}}o&&c(p+131072);let y=(1<<m)-1,g=(1<<R)-1,w=d;for(;;w=d){let E=u[Ae(r,d)&y],x=E>>4;if(d+=E&15,d>b){f&&H(0);break}if(E||H(2),x<256)t[p++]=x;else if(x==256){w=d,u=null;break}else{let O=x-254;if(x>264){let I=x-257,C=ft[I];O=U(r,d,(1<<C)-1)+pt[I],d+=C}let j=h[Ae(r,d)&g],P=j>>4;j||H(3),d+=j&15;let A=yr[P];if(P>3){let I=lt[P];A+=Ae(r,d)&(1<<I)-1,d+=I}if(d>b){f&&H(0);break}o&&c(p+131072);let B=p+O;if(p<A){let I=a-A,C=Math.min(A,B);for(I+p<0&&H(3);p<C;++p)t[p]=n[I+p]}for(;p<B;++p)t[p]=t[p-A]}}e.l=u,e.p=w,e.b=p,e.f=l,u&&(l=1,e.m=m,e.d=h,e.n=R)}while(!l);return p!=t.length&&i?gr(t,0,p):t.subarray(0,p)},bt=r=>(((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&H(0,"invalid zlib data"),r[1]&32&&H(0,"zlib dictionaries are not supported"),2);function mt(r){let e=bt(r);return yt(r.subarray(e,-4),{i:2})}function Te(r){let e=bt(r),t={i:2},n=yt(r.subarray(e),t),s=ht(t.p);return{result:n,bytesConsumed:e+s+4}}async function Rr(){let r;if(!(typeof document<"u"))try{r=he(["node","zlib"].join(":"))}catch{try{r=await import(["node","zlib"].join(":"))}catch{}}if(r&&typeof r.deflateSync=="function"&&typeof r.inflateSync=="function"){let n=null;try{let s=r.inflateSync(r.deflateSync(Buffer.from("x")),{info:!0});s?.engine&&typeof s.engine.bytesWritten=="number"&&(n=a=>{let i=r.inflateSync(a,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:s=>new Uint8Array(r.deflateSync(s)),inflateSync:s=>new Uint8Array(r.inflateSync(s)),inflateWithConsumed:n??Te}}let t;return typeof globalThis.CompressionStream=="function"?t=async n=>{let s=new CompressionStream("deflate"),a=s.writable.getWriter();return a.write(n),a.close(),new Uint8Array(await new Response(s.readable).arrayBuffer())}:t=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:t,inflateSync:mt,inflateWithConsumed:Te}}var xr=null;function gt(){return xr??=Rr()}async function Re(r){return await(await gt()).deflateSync(r)}async function Ue(r,e){let t=await gt(),{result:n,bytesConsumed:s}=t.inflateWithConsumed(r);if(n.byteLength!==e)throw new Error(`Inflate size mismatch: got ${n.byteLength}, expected ${e}`);return{result:n,bytesConsumed:s}}var z=1346454347,we=2,wt=1,Et=2,Ot=3,Pt=4,_=6,te=7,vt={[wt]:"commit",[Et]:"tree",[Ot]:"blob",[Pt]:"tag"},kt={commit:wt,tree:Et,blob:Ot,tag:Pt};async function jt(r,e){let t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=t.getUint32(0);if(n!==z)throw new Error(`Invalid pack signature: 0x${n.toString(16)} (expected 0x${z.toString(16)})`);let s=t.getUint32(4);if(s!==we)throw new Error(`Unsupported pack version: ${s}`);if(r.byteLength>=32){let c=J(r,r.byteLength-20),l=G();l.update(r.subarray(0,r.byteLength-20));let d=await l.hex();if(d!==c)throw new Error(`pack checksum mismatch: expected ${c}, computed ${d}`)}let a=t.getUint32(8),i=[],o=12;for(let c=0;c<a;c++){let l=await wr(r,o);i.push(l),o=l.nextOffset}return(await Er(i,e)).map((c,l)=>({...c,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function wr(r,e){let t=e,n=r[e++],s=n>>4&7,a=n&15,i=4;for(;n&128;)n=r[e++],a|=(n&127)<<i,i+=7;let o,f;if(s===_){let d=r[e++];for(o=d&127;d&128;)o+=1,d=r[e++],o=(o<<7)+(d&127);o=t-o}else s===te&&(f=J(r,e),e+=20);let{result:c,bytesConsumed:l}=await Ue(r.subarray(e),a);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:o,baseHash:f,nextOffset:e+l}}var Rt=50;async function Er(r,e){let t=new Map;for(let a=0;a<r.length;a++)t.set(r[a].headerOffset,a);let n=new Array(r.length).fill(null);async function s(a,i=0){if(i>Rt)throw new Error(`delta chain depth ${i} exceeds limit of ${Rt}`);let o=n[a];if(o)return o;let f=r[a];if(f.typeNum!==_&&f.typeNum!==te){let u=vt[f.typeNum];if(!u)throw new Error(`Unknown object type: ${f.typeNum}`);let h={type:u,content:f.inflated,hash:await q(u,f.inflated)};return n[a]=h,h}if(f.typeNum===_){let u=t.get(f.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${f.baseOffset}`);let h=await s(u,i+1),m=xe(h.content,f.inflated),R={type:h.type,content:m,hash:await q(h.type,m)};return n[a]=R,R}let c=await Or(r,n,f.baseHash,s),l;if(c!==void 0)l=await s(c,i+1);else if(e){let u=await e(f.baseHash);u&&(l=u)}if(!l)throw new Error(`REF_DELTA base not found for hash ${f.baseHash}`);let d=xe(l.content,f.inflated),p={type:l.type,content:d,hash:await q(l.type,d)};return n[a]=p,p}for(let a=0;a<r.length;a++)await s(a);return n}async function Or(r,e,t,n){for(let s=0;s<e.length;s++)if(e[s]?.hash===t)return s;for(let s=0;s<r.length;s++){let a=r[s];if(a.typeNum!==_&&a.typeNum!==te&&(await n(s)).hash===t)return s}}var Le=class{buf=new Uint8Array(0);iter;eof=!1;_bytesRead=0;hasher;constructor(e,t=!1){this.iter=e[Symbol.asyncIterator](),this.hasher=t?G():null}get bytesRead(){return this._bytesRead}async pullMore(){if(this.eof)return!1;let{value:e,done:t}=await this.iter.next();if(t||!e)return this.eof=!0,!1;if(this.buf.byteLength===0)this.buf=new Uint8Array(e);else{let n=new Uint8Array(this.buf.byteLength+e.byteLength);n.set(this.buf),n.set(e,this.buf.byteLength),this.buf=n}return!0}async ensure(e){for(;this.buf.byteLength<e;)if(!await this.pullMore())throw new Error(`Unexpected end of pack data: needed ${e} bytes, have ${this.buf.byteLength}`)}consume(e){let t=new Uint8Array(this.buf.subarray(0,e));return this.hasher?.update(t),this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async readByte(){return await this.ensure(1),this.consume(1)[0]}async readExact(e){return await this.ensure(e),this.consume(e)}async readRaw(e){await this.ensure(e);let t=new Uint8Array(this.buf.subarray(0,e));return this.buf=this.buf.subarray(e),this._bytesRead+=e,t}async inflateNext(e){for(this.buf.byteLength===0&&!this.eof&&await this.pullMore();;)try{let{result:t,bytesConsumed:n}=await Ue(this.buf,e);return this.consume(n),t}catch{if(!this.eof&&await this.pullMore())continue;throw new Error(`Failed to inflate pack entry at byte ${this._bytesRead} (expected ${e} bytes)`)}}async hashHex(){if(!this.hasher)throw new Error("Hashing not enabled");return this.hasher.hex()}};async function*St(r,e){let t=new Le(r,!0),n=await t.readExact(12),s=new DataView(n.buffer,n.byteOffset,n.byteLength),a=s.getUint32(0);if(a!==z)throw new Error(`Invalid pack signature: 0x${a.toString(16)} (expected 0x${z.toString(16)})`);let i=s.getUint32(4);if(i!==we)throw new Error(`Unsupported pack version: ${i}`);let o=s.getUint32(8),f=new Map,c=new Map;for(let p=0;p<o;p++){let u=t.bytesRead,h=await t.readByte(),m=h>>4&7,R=h&15,b=4;for(;h&128;)h=await t.readByte(),R|=(h&127)<<b,b+=7;let y,g;if(m===_){let x=await t.readByte();for(y=x&127;x&128;)y+=1,x=await t.readByte(),y=(y<<7)+(x&127);y=u-y}else if(m===te){let x=await t.readExact(20);g=J(x,0)}let w=await t.inflateNext(R),E;if(m!==_&&m!==te){let x=vt[m];if(!x)throw new Error(`Unknown object type: ${m}`);E={type:x,content:w,hash:await q(x,w)}}else if(m===_){let x=f.get(y);if(!x)throw new Error(`OFS_DELTA base not found at offset ${y}`);let O=xe(x.content,w);E={type:x.type,content:O,hash:await q(x.type,O)}}else{let x=c.get(g);if(!x&&e&&(x=await e(g)??void 0),!x)throw new Error(`REF_DELTA base not found for hash ${g}`);let O=xe(x.content,w);E={type:x.type,content:O,hash:await q(x.type,O)}}f.set(u,E),c.set(E.hash,E),yield E}let l=J(await t.readRaw(20),0),d=await t.hashHex();if(d!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${d}`)}function xe(r,e){let t=0,{value:n,newPos:s}=xt(e,t);if(t=s,n!==r.byteLength)throw new Error(`Delta base size mismatch: expected ${n}, got ${r.byteLength}`);let{value:a,newPos:i}=xt(e,t);t=i;let o=new Uint8Array(a),f=0;for(;t<e.byteLength;){let c=e[t++];if(c&128){let l=0,d=0;c&1&&(l=e[t++]),c&2&&(l|=e[t++]<<8),c&4&&(l|=e[t++]<<16),c&8&&(l|=e[t++]<<24),c&16&&(d=e[t++]),c&32&&(d|=e[t++]<<8),c&64&&(d|=e[t++]<<16),d===0&&(d=65536),o.set(r.subarray(l,l+d),f),f+=d}else if(c>0)o.set(e.subarray(t,t+c),f),f+=c,t+=c;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(f!==a)throw new Error(`Delta produced ${f} bytes, expected ${a}`);return o}async function Ee(r){let e=[],t=new Map,n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,we),s.setUint32(8,r.length),e.push(n);let a=12,i=[];for(let o of r){let f=a;t.set(o.hash,a);let c=o.delta&&o.deltaBaseHash?t.get(o.deltaBaseHash):void 0;if(o.delta&&c!==void 0){let l=Ce(_,o.delta.byteLength),d=vr(a-c),p=await Re(o.delta);e.push(l,d,p),a+=l.byteLength+d.byteLength+p.byteLength}else{let l=kt[o.type],d=Ce(l,o.content.byteLength),p=await Re(o.content);e.push(d,p),a+=d.byteLength+p.byteLength}i.push({hash:o.hash,offset:f,nextOffset:a})}return{data:await Pr(e),entries:i}}async function*At(r,e){let t=G(),n=new Uint8Array(12),s=new DataView(n.buffer);s.setUint32(0,z),s.setUint32(4,we),s.setUint32(8,r),t.update(n),yield n;for await(let a of e){let i=kt[a.type],o=Ce(i,a.content.byteLength),f=await Re(a.content);t.update(o),t.update(f),yield kr(o,f)}yield me(await t.hex())}async function Pr(r){let e=0;for(let i of r)e+=i.byteLength;e+=20;let t=new Uint8Array(e),n=0;for(let i of r)t.set(i,n),n+=i.byteLength;let s=G();s.update(t.subarray(0,n));let a=await s.hex();return t.set(me(a),n),t}function vr(r){let e=[];e.push(r&127);let t=r>>>7;for(;t>0;)e.unshift(128|--t&127),t>>>=7;return new Uint8Array(e)}function Ce(r,e){let t=[],n=r<<4|e&15;for(e>>=4;e>0;)t.push(n|128),n=e&127,e>>=7;return t.push(n),new Uint8Array(t)}function xt(r,e){let t=0,n=0,s;do s=r[e++],t|=(s&127)<<n,n+=7;while(s&128);return{value:t,newPos:e}}function kr(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var jr=new TextEncoder;async function q(r,e){let t=jr.encode(`${r} ${e.byteLength}\0`),n=G();return n.update(t),n.update(e),n.hex()}var Sr=new TextEncoder,Dn=new TextDecoder;function It(r,e){let t=Sr.encode(`${r} ${e.byteLength}\0`),n=new Uint8Array(t.byteLength+e.byteLength);return n.set(t),n.set(e,t.byteLength),n}function re(r){let e=r.indexOf("<"),t=r.indexOf(">");if(e===-1||t===-1)throw new Error(`Malformed identity line: "${r}"`);let n=r.slice(0,e).trimEnd(),s=r.slice(e+1,t),a=r.slice(t+2),[i="0",o="+0000"]=a.split(" "),f=parseInt(i,10);return{name:n,email:s,timestamp:f,timezone:o}}var $n=new TextEncoder,Ir=new TextDecoder;function ne(r){let e=Ir.decode(r),t=e.indexOf(`
|
|
2
2
|
|
|
3
3
|
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),a="",i=[],o,f;for(let c of n.split(`
|
|
4
|
-
`)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"tree":a=p;break;case"parent":i.push(p);break;case"author":o=
|
|
4
|
+
`)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"tree":a=p;break;case"parent":i.push(p);break;case"author":o=re(p);break;case"committer":f=re(p);break}}if(!a)throw new Error("Commit missing tree field");if(!o)throw new Error("Commit missing author field");if(!f)throw new Error("Commit missing committer field");return{type:"commit",tree:a,parents:i,author:o,committer:f,message:s}}var Gn=new TextEncoder,Tr=new TextDecoder;function W(r){let e=Tr.decode(r),t=e.indexOf(`
|
|
5
5
|
|
|
6
6
|
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),a="",i="commit",o="",f;for(let c of n.split(`
|
|
7
|
-
`)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"object":a=p;break;case"type":i=p;break;case"tag":o=p;break;case"tagger":f=te(p);break}}if(!a)throw new Error("Tag missing object field");if(!o)throw new Error("Tag missing tag name field");if(!f)throw new Error("Tag missing tagger field");return{type:"tag",object:a,objectType:i,name:o,tagger:f,message:s}}async function ne(r,e){return r.objectStore.read(e)}async function se(r,e){return r.objectStore.exists(e)}var Nn=new TextDecoder;async function X(r,e){let t=await ne(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return re(t.content)}function At(r){return typeof r=="string"?{type:"direct",hash:r}:r}var Ce=".lock";var jr=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];function Ar(r,e,t){let n=0,s=!1,a=e;for(;a<r.length;a++){let o=r.charCodeAt(a);switch(o<128?jr[o]:0){case 1:break;case 2:if(n===46)return{len:-1,starConsumed:s};n=o;continue;case 3:if(n===64)return{len:-1,starConsumed:s};n=o;continue;case 4:return{len:-1,starConsumed:s};case 5:if(!t)return{len:-1,starConsumed:s};s=!0,n=o;continue;default:n=o;continue}break}let i=a-e;return i===0?{len:0,starConsumed:s}:r.charCodeAt(e)===46?{len:-1,starConsumed:s}:i>=Ce.length&&r.slice(a-Ce.length,a)===Ce?{len:-1,starConsumed:s}:{len:i,starConsumed:s}}function It(r,e=0){if(r==="@"||r.length===0)return!1;let t=0,n=0,s=!!(e&2);for(;t<=r.length;){let{len:a,starConsumed:i}=Ar(r,t,s);if(a<0||a===0)return!1;i&&(s=!1),n++,t+=a+1}return!(r.charCodeAt(r.length-1)===46||!(e&1)&&n<2)}var _n=new TextEncoder,Tt=new TextDecoder,Ir=new Set(["100644","100755","040000","120000","160000"]);function Tr(r){return r.length===4&&r.toLowerCase()===".git"}function Ur(r,e){if(r.length===0)throw new Error("invalid tree entry: empty name");if(r.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${r}'`);if(r.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(r==="."||r==="..")throw new Error(`invalid tree entry: '${r}'`);if(Tr(r))throw new Error(`invalid tree entry: '${r}'`);if(!Ir.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${r}'`)}function He(r){let e=[],t=0;for(;t<r.byteLength;){let n=r.indexOf(32,t);if(n===-1)break;let s=Tt.decode(r.subarray(t,n)),a=r.indexOf(0,n+1);if(a===-1)break;let i=Tt.decode(r.subarray(n+1,a)),o=r.subarray(a+1,a+21),f=he(o),c=s.padStart(6,"0");Ur(i,c),e.push({mode:c,name:i,hash:f}),t=a+21}return{type:"tree",entries:e}}async function Ut(r,e,t){if(e===t)return!0;let n=new Set,s=[t],a=0;for(;a<s.length;){let i=s[a++];if(i===e)return!0;if(n.has(i))continue;n.add(i);let o;try{o=await X(r,i)}catch{continue}for(let f of o.parents)n.has(f)||s.push(f)}return!1}var Pe=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),Lr=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),we=64,Cr=4,De=4096,Lt=65536,Hr=127;function Dr(r){let e=r.byteLength;if(e===0)return null;let t=(e-1)/16|0;if(t===0)return null;let n=t>>>2;n<16&&(n=16),n=Br(n);let s=n-1,a=new Uint32Array(n),i=[],o=-1>>>0;for(let p=t*16-16;p>=0;p-=16){let u=0;for(let h=1;h<=16;h++)u=(u<<8|r[p+h])^Pe[u>>>23];if(u=u>>>0,u===o)i[i.length-1].ptr=p+16;else{o=u;let h=u&s;i.push({ptr:p+16,val:u}),a[h]++}}let f=new Map;for(let p of i){let u=p.val&s,h=f.get(u);h||(h=[],f.set(u,h)),h.push(p)}for(let[p,u]of f){if(u.length<=we)continue;let h=[],m=u.length/we;for(let g=0;g<we;g++)h.push(u[Math.floor(g*m)]);f.set(p,h),a[p]=we}let c=new Uint32Array(n+1),l=[],d=0;for(let p=0;p<n;p++){c[p]=d;let u=f.get(p);if(u){for(let h of u)l.push(h);d+=u.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:l}}function Nr(r,e,t){if(!r||e.byteLength===0)return null;let n=r.src.byteLength,s=e.byteLength,a=r.src,i=new Uint8Array(Math.max(s,1024)),o=0;function f(m){for(;o+m>i.length;){let g=new Uint8Array(i.length*2);g.set(i),i=g}}o=Ht(i,o,n),o=Ht(i,o,s),f(18),o++;let c=0,l=0,d=Math.min(16,s);for(let m=0;m<d;m++)i[o++]=e[m],c=(c<<8|e[m])^Pe[c>>>23],l++;c=c>>>0;let p=d,u=0,h=0;for(;p<s;){if(h<De){c^=Lr[e[p-16]],c=((c<<8|e[p])^Pe[c>>>23])>>>0;let m=c&r.hashMask,g=r.buckets[m],b=r.buckets[m+1];for(let y=g;y<b;y++){let R=r.entries[y];if(R.val!==c)continue;let w=R.ptr,P=a.byteLength-w,x=s-p;if(P>x&&(P=x),P<=h)break;let O=0;for(;O<P&&a[w+O]===e[p+O];)O++;if(O>h&&(h=O,u=w,h>=De))break}}if(h<Cr)f(2),l===0&&o++,i[o++]=e[p++],l++,l===Hr&&(i[o-l-1]=l,l=0),h=0;else{if(l>0){for(;u>0&&a[u-1]===e[p-1];)if(h++,u--,p--,o--,!(--l>0)){o--,l=-1;break}l>0&&(i[o-l-1]=l),l=0}let m=h>Lt?h-Lt:0;h-=m,f(8);let g=o++,b=128;if(u&255&&(i[o++]=u&255,b|=1),u&65280&&(i[o++]=u>>>8&255,b|=2),u&16711680&&(i[o++]=u>>>16&255,b|=4),u&4278190080&&(i[o++]=u>>>24&255,b|=8),h&255&&(i[o++]=h&255,b|=16),h&65280&&(i[o++]=h>>>8&255,b|=32),i[g]=b,p+=h,u+=h,h=m,u>4294967295&&(h=0),h<De){c=0;for(let y=-16;y<0;y++)c=(c<<8|e[p+y])^Pe[c>>>23];c=c>>>0}}if(t&&o>t)return null}return l>0&&(i[o-l-1]=l),t&&o>t?null:i.subarray(0,o)}var Ct={blob:0,tree:1,commit:2,tag:3};function Dt(r,e){let t=e?.window??10,n=e?.depth??50,s=r.slice().sort((c,l)=>{let d=Ct[c.type]??99,p=Ct[l.type]??99;return d!==p?d-p:l.content.byteLength-c.content.byteLength}),a=new Map,i=[],o=[],f=[];for(let c=0;c<s.length;c++){let l=s[c],d={hash:l.hash,type:l.type,content:l.content,depth:0},p=null,u=null,h=Math.max(0,c-t);for(let m=c-1;m>=h;m--){let g=s[m];if(g.type!==l.type||(a.get(g.hash)?.depth??0)>=n||l.content.byteLength<g.content.byteLength>>>5)continue;let R=o[m-h]??null;if(!R)continue;let w=p?p.byteLength:l.content.byteLength/2|0;if(w<16)continue;let P=Nr(R,l.content,w);P&&(!p||P.byteLength<p.byteLength)&&(p=P,u=g.hash)}if(p&&u){d.delta=p,d.deltaBase=u;let m=a.get(u);d.depth=(m?.depth??0)+1}a.set(l.hash,d),i.push(d),o.length>=t&&(o.shift(),f.shift()),o.push(Dr(l.content)),f.push(l.hash)}return i}function Br(r){let e=r;return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e<16?16:e}function Ht(r,e,t){let n=t;do{let s=n&127;n>>>=7,n>0&&(s|=128),r[e++]=s}while(n>0);return e}var Mr=2147483647;async function Nt(r,e,t,n){if(t>=Mr)return{shallow:[],unshallow:[...n]};let s=new Map,a=[];for(let c of e)!s.has(c)&&await se(r,c)&&(s.set(c,1),a.push({hash:c,level:1}));let i=new Set,o=0;for(;o<a.length;){let{hash:c,level:l}=a[o++];if(l>=t){i.add(c);continue}let d;try{d=await X(r,c)}catch{continue}for(let p of d.parents)!s.has(p)&&await se(r,p)&&(s.set(p,l+1),a.push({hash:p,level:l+1}))}let f=[];for(let c of n){let l=s.get(c);l!==void 0&&l<t&&f.push(c)}return{shallow:[...i],unshallow:f}}async function Ne(r,e,t,n,s){let a=s??n,i=new Set;for(let l of t)await ae(r,l,i,a);let o=[...e];if(s&&n)for(let l of s)try{let d=await X(r,l);for(let p of d.parents)i.has(p)||o.push(p)}catch{}let f=[],c=new Set;for(let l of o)await oe(r,l,i,c,f,n);return{count:f.length,objects:$r(f)}}async function Bt(r,e,t,n,s){let{count:a,objects:i}=await Ne(r,e,t,n,s);return{count:a,objects:Wr(r,i)}}async function*$r(r){for(let e of r)yield e}async function*Wr(r,e){for await(let t of e){let n=await ne(r,t.hash);yield{hash:t.hash,type:t.type,content:n.content}}}async function Mt(r){let e=[];for await(let t of r.objects)e.push(t);return e}async function ae(r,e,t,n){if(t.has(e)||(t.add(e),!await se(r,e)))return;let s=await ne(r,e);switch(s.type){case"commit":{let a=re(s.content);if(await ae(r,a.tree,t,n),!n?.has(e))for(let i of a.parents)await ae(r,i,t,n);break}case"tree":{let a=He(s.content);for(let i of a.entries)await ae(r,i.hash,t,n);break}case"tag":{let a=_(s.content);await ae(r,a.object,t,n);break}case"blob":break}}async function oe(r,e,t,n,s,a){if(n.has(e)||t.has(e))return;n.add(e);let i=await ne(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let o=re(i.content);if(await oe(r,o.tree,t,n,s,a),!a?.has(e))for(let f of o.parents)await oe(r,f,t,n,s,a);break}case"tree":{let o=He(i.content);for(let f of o.entries)await oe(r,f.hash,t,n,s,a);break}case"tag":{let o=_(i.content);await oe(r,o.object,t,n,s,a);break}case"blob":break}}var _r=new TextEncoder,Wt=new TextDecoder,$t=65520,Gr=new Uint8Array([48,48,48,48]);function k(r){let e=typeof r=="string"?_r.encode(r):r,t=4+e.byteLength;if(t>$t)throw new Error(`pkt-line too long: ${t} bytes (max ${$t})`);let n=t.toString(16).padStart(4,"0"),s=new Uint8Array(t);return s[0]=n.charCodeAt(0),s[1]=n.charCodeAt(1),s[2]=n.charCodeAt(2),s[3]=n.charCodeAt(3),s.set(e,4),s}function D(){return Gr.slice()}function B(...r){let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function _t(r){let e=[],t=0;for(;t<r.byteLength;){if(t+4>r.byteLength)throw new Error("Truncated pkt-line header");let n=Wt.decode(r.subarray(t,t+4)),s=parseInt(n,16);if(Number.isNaN(s))throw new Error(`Invalid pkt-line length: ${n}`);if(s===0){e.push({type:"flush"}),t+=4;continue}if(s<4)throw new Error(`Invalid pkt-line length: ${s}`);if(t+s>r.byteLength)throw new Error(`Truncated pkt-line: need ${s} bytes at offset ${t}, have ${r.byteLength-t}`);e.push({type:"data",data:r.subarray(t+4,t+s)}),t+=s}return e}function Gt(r){if(r.type==="flush")return"";let e=Wt.decode(r.data);return e.endsWith(`
|
|
8
|
-
`)?e.slice(0,-1):e}var
|
|
9
|
-
`));else for(let i=0;i<r.length;i++){let o=r[i];i===0?n.push(
|
|
10
|
-
`)):n.push(
|
|
11
|
-
`))}return n.push(D()),
|
|
12
|
-
`),D()),a=
|
|
13
|
-
`));for(let a of n.unshallow)s.push(
|
|
14
|
-
`));s.push(D())}if(t&&t.length>0){for(let i of t)s.push(
|
|
15
|
-
`));let a=t[t.length-1];s.push(
|
|
16
|
-
`)),s.push(
|
|
17
|
-
`))}else s.push(
|
|
18
|
-
`));if(e){let a=0;for(;a<r.byteLength;){let i=Math.min(
|
|
19
|
-
`));for(let t of r.unshallow)e.push(
|
|
20
|
-
`));return e.push(D()),
|
|
21
|
-
`));for(let i of n.unshallow)a.push(
|
|
22
|
-
`));a.push(D()),yield
|
|
23
|
-
`));let a=t[t.length-1];s.push(
|
|
24
|
-
`)),s.push(
|
|
25
|
-
`))}else s.push(
|
|
26
|
-
`));if(yield
|
|
27
|
-
`)?u.slice(0,-1):u}let p=d.split(" ");p.length>=3&&t.push({oldHash:p[0],newHash:p[1],refName:p[2]})}let i=s<r.byteLength?r.subarray(s):new Uint8Array(0);return{commands:t,packData:i,capabilities:n,sawFlush:a}}function Y(r,e,t){let n=[];n.push(
|
|
7
|
+
`)){let l=c.indexOf(" ");if(l===-1)continue;let d=c.slice(0,l),p=c.slice(l+1);switch(d){case"object":a=p;break;case"type":i=p;break;case"tag":o=p;break;case"tagger":f=re(p);break}}if(!a)throw new Error("Tag missing object field");if(!o)throw new Error("Tag missing tag name field");if(!f)throw new Error("Tag missing tagger field");return{type:"tag",object:a,objectType:i,name:o,tagger:f,message:s}}async function se(r,e){return r.objectStore.read(e)}async function ae(r,e){return r.objectStore.exists(e)}var zn=new TextDecoder;async function X(r,e){let t=await se(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return ne(t.content)}function Tt(r){return typeof r=="string"?{type:"direct",hash:r}:r}var He=".lock";var Ur=[1,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,0,0,0,0,0,0,0,0,0,5,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,4,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,4,4];function Lr(r,e,t){let n=0,s=!1,a=e;for(;a<r.length;a++){let o=r.charCodeAt(a);switch(o<128?Ur[o]:0){case 1:break;case 2:if(n===46)return{len:-1,starConsumed:s};n=o;continue;case 3:if(n===64)return{len:-1,starConsumed:s};n=o;continue;case 4:return{len:-1,starConsumed:s};case 5:if(!t)return{len:-1,starConsumed:s};s=!0,n=o;continue;default:n=o;continue}break}let i=a-e;return i===0?{len:0,starConsumed:s}:r.charCodeAt(e)===46?{len:-1,starConsumed:s}:i>=He.length&&r.slice(a-He.length,a)===He?{len:-1,starConsumed:s}:{len:i,starConsumed:s}}function Ut(r,e=0){if(r==="@"||r.length===0)return!1;let t=0,n=0,s=!!(e&2);for(;t<=r.length;){let{len:a,starConsumed:i}=Lr(r,t,s);if(a<0||a===0)return!1;i&&(s=!1),n++,t+=a+1}return!(r.charCodeAt(r.length-1)===46||!(e&1)&&n<2)}var Cr=10;async function Hr(r,e){return r.refStore.readRef(e)}async function Lt(r,e){let t=e;for(let n=0;n<Cr;n++){let s=await Hr(r,t);if(!s)return null;if(s.type==="direct")return s.hash;t=s.target}throw new Error(`Symbolic ref loop detected resolving "${e}"`)}var Zn=new TextEncoder,Ct=new TextDecoder,Dr=new Set(["100644","100755","040000","120000","160000"]);function Nr(r){return r.length===4&&r.toLowerCase()===".git"}function Mr(r,e){if(r.length===0)throw new Error("invalid tree entry: empty name");if(r.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${r}'`);if(r.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(r==="."||r==="..")throw new Error(`invalid tree entry: '${r}'`);if(Nr(r))throw new Error(`invalid tree entry: '${r}'`);if(!Dr.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${r}'`)}function De(r){let e=[],t=0;for(;t<r.byteLength;){let n=r.indexOf(32,t);if(n===-1)break;let s=Ct.decode(r.subarray(t,n)),a=r.indexOf(0,n+1);if(a===-1)break;let i=Ct.decode(r.subarray(n+1,a)),o=r.subarray(a+1,a+21),f=be(o),c=s.padStart(6,"0");Mr(i,c),e.push({mode:c,name:i,hash:f}),t=a+21}return{type:"tree",entries:e}}async function Ne(r,e,t){if(e===t)return!0;let n=new Set,s=[t],a=0;for(;a<s.length;){let i=s[a++];if(i===e)return!0;if(n.has(i))continue;n.add(i);let o;try{o=await X(r,i)}catch{continue}for(let f of o.parents)n.has(f)||s.push(f)}return!1}var Pe=new Uint32Array([0,2874782929,1454598562,4260027763,104818581,2909197124,1351355959,4225088230,209637162,2804382715,1523426952,4053013081,172075199,2702711918,1559413021,4155209164,419274324,3013880453,1313798134,3843506983,516094401,3046853904,1215402083,3811058866,344150398,3218793903,1110456540,3916008461,314324715,3118826042,1141858121,4015451032,838548648,2594343033,1732793610,3423723995,935615293,2627596268,1635201695,3392046670,1032188802,2531018579,1798740512,3228511985,1002083351,2430804166,1829371317,3327150436,688300796,2187269677,2142620510,3572268943,792315241,2220913080,2039131339,3537049626,628649430,2384582919,1942684788,3633492133,591858243,2283716242,1978950625,3735934768,1677097296,3366964609,893718770,2652677155,1707679429,3465587220,863663975,2552480694,1871230586,3302032043,960225240,2455923465,1773654511,3270403390,1057273933,2489126044,2064377604,3495056341,767069862,2262907511,2100592785,3597481024,730327347,2162056674,2004166702,3693911295,566641036,2325738845,1900695483,3658742634,670639641,2359333576,1376601592,4183093545,79572058,2951190667,1412571757,4285241020,42027983,2849570590,1584630482,4113186307,146858864,2744735649,1481436487,4078262678,251626725,2779131956,1257298860,3785977725,474198542,3071936223,1288682553,3885369576,444388763,2972016970,1183716486,3990331479,272465188,3143944693,1085371155,3957901250,369236657,3176902240,1823819377,3354194592,973483987,2438961922,1787437540,3251868981,1010387014,2539715735,1623951707,3415358858,913891577,2636207144,1727327950,3450690079,809994092,2602447805,1950930981,3742461172,586920327,2309096790,1920450480,3643673441,616879634,2409456323,2016810767,3547309022,780500653,2245839484,2114547866,3578840139,683284792,2212736489,1565424345,4128755208,201134971,2695145386,1534139724,4029196701,230847726,2795225151,1362146803,4201185570,126082129,2899994752,1460654694,4233520823,29146052,2867138325,1169417357,4008333404,318803247,3092855294,1133282072,3906287561,356510394,3194379883,1238182823,3801390966,528368133,3022517972,1341279282,3836475619,423699856,2987954497,256065313,2753203184,1508923011,4071219794,159144116,2720394341,1607414038,4103505351,54390795,2825143514,1435408809,4275514744,84055966,2925208399,1404173884,4175973101,398369141,3169260964,1091422423,3931405318,293717728,3134747185,1194504002,3966442387,465595999,2962872974,1299384317,3861558060,503253450,3064380699,1263296616,3759527097,1052246921,2514597720,1745578539,3276988154,948397084,2480853197,1848905150,3312302447,851889315,2577365106,1685431553,3475771856,888777526,2678071271,1649066644,3373495877,642096605,2367432972,1895232639,3685695662,544930376,2334346905,1992922090,3717211963,708530935,2170742310,2089302869,3620835204,738473314,2271052211,2058837184,3522095121]),Br=new Uint32Array([0,2125799437,1446245579,679924934,121527623,2039184714,1359849868,800622977,243055246,1892260483,1481592389,653946440,155379657,2012727236,1601245954,566506255,486110492,1649169681,1254785495,880779738,466036827,1701972054,1307892880,859962525,310759314,1815146399,1152793433,973282132,364614357,1796125400,1133012510,1027425811,972220984,1195887157,1874927347,292830974,1053603711,1081710450,1761559476,373973945,932073654,1228632251,1639818365,520651888,816844273,1308962300,1719925050,406247735,621518628,1539227433,1933077487,227363810,573948515,1551950446,1946564264,179508901,729228714,1438778791,2101662049,66187628,743012589,1392269536,2054851622,80718891,1944441968,223409277,634790075,1533214902,1960544567,175024442,585661948,1549622769,2107207422,53235443,732600885,1428142648,2057778105,68293556,747947890,1377953663,1864147308,296321377,959403431,1201305002,1747123243,379051046,1041303776,1084500205,1633688546,534068207,928247593,1239863076,1717454501,418080424,812495470,1322816099,1243037256,883039813,472173187,1653729934,1294557967,865878786,454727620,1706014665,1147897030,987669707,307785741,1827491840,1129699713,1038154124,359017802,1808993607,1458457428,677079897,14532511,2120785810,1372591635,795162142,132375256,2035729109,1486025178,640143831,245433617,1880368412,1605151901,555322512,161437782,1999272027,1284643889,841432124,446818554,1679083767,1269580150,890855803,497006013,1663735216,1122936511,1012631218,350048884,1785229945,1171323896,996531189,333647667,1834364734,1349216557,786319648,106470886,2028846571,1465201770,702551143,23511201,2144592044,1578619811,547550126,136587112,1989216101,1495895780,664579817,253393455,1907317282,1969288713,198563332,592642754,1575363279,1918806862,216763203,611147653,1524137864,2065452167,94989450,758102092,1402640449,2082607552,43463117,705815819,1420084486,1771668245,388801304,1068136414,1092573139,1856495186,269680223,949234329,1176570516,1743075739,424679830,836160848,1331948893,1624990940,510543057,921210903,1214099482,1064814657,1103292492,1766079626,401677447,944346374,1190966539,1853514189,282018240,822833871,1337873090,1731757572,428713481,909455240,1216352133,1611062083,515111758,596557149,1564187984,1975339414,185100699,615571482,1510326295,1921193169,204879068,770836435,1397172190,2076308248,91542293,718035604,1417247385,2097131103,38440530,109388409,2016412276,1354159794,772011711,29065022,2131648307,1468566517,691907576,150575351,1984739578,1590324284,545213489,264750512,1903355325,1509175675,658575734,444356453,1690924904,1280287662,855278499,490867234,1677142575,1265762025,902094564,335605227,1790299622,1110645024,1015429421,322875564,1837863073,1158497383,1001940074]),Oe=64,$r=4,Me=4096,Ht=65536,_r=127;function Wr(r){let e=r.byteLength;if(e===0)return null;let t=(e-1)/16|0;if(t===0)return null;let n=t>>>2;n<16&&(n=16),n=Fr(n);let s=n-1,a=new Uint32Array(n),i=[],o=-1>>>0;for(let p=t*16-16;p>=0;p-=16){let u=0;for(let h=1;h<=16;h++)u=(u<<8|r[p+h])^Pe[u>>>23];if(u=u>>>0,u===o)i[i.length-1].ptr=p+16;else{o=u;let h=u&s;i.push({ptr:p+16,val:u}),a[h]++}}let f=new Map;for(let p of i){let u=p.val&s,h=f.get(u);h||(h=[],f.set(u,h)),h.push(p)}for(let[p,u]of f){if(u.length<=Oe)continue;let h=[],m=u.length/Oe;for(let R=0;R<Oe;R++)h.push(u[Math.floor(R*m)]);f.set(p,h),a[p]=Oe}let c=new Uint32Array(n+1),l=[],d=0;for(let p=0;p<n;p++){c[p]=d;let u=f.get(p);if(u){for(let h of u)l.push(h);d+=u.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:l}}function Gr(r,e,t){if(!r||e.byteLength===0)return null;let n=r.src.byteLength,s=e.byteLength,a=r.src,i=new Uint8Array(Math.max(s,1024)),o=0;function f(m){for(;o+m>i.length;){let R=new Uint8Array(i.length*2);R.set(i),i=R}}o=Nt(i,o,n),o=Nt(i,o,s),f(18),o++;let c=0,l=0,d=Math.min(16,s);for(let m=0;m<d;m++)i[o++]=e[m],c=(c<<8|e[m])^Pe[c>>>23],l++;c=c>>>0;let p=d,u=0,h=0;for(;p<s;){if(h<Me){c^=Br[e[p-16]],c=((c<<8|e[p])^Pe[c>>>23])>>>0;let m=c&r.hashMask,R=r.buckets[m],b=r.buckets[m+1];for(let y=R;y<b;y++){let g=r.entries[y];if(g.val!==c)continue;let w=g.ptr,E=a.byteLength-w,x=s-p;if(E>x&&(E=x),E<=h)break;let O=0;for(;O<E&&a[w+O]===e[p+O];)O++;if(O>h&&(h=O,u=w,h>=Me))break}}if(h<$r)f(2),l===0&&o++,i[o++]=e[p++],l++,l===_r&&(i[o-l-1]=l,l=0),h=0;else{if(l>0){for(;u>0&&a[u-1]===e[p-1];)if(h++,u--,p--,o--,!(--l>0)){o--,l=-1;break}l>0&&(i[o-l-1]=l),l=0}let m=h>Ht?h-Ht:0;h-=m,f(8);let R=o++,b=128;if(u&255&&(i[o++]=u&255,b|=1),u&65280&&(i[o++]=u>>>8&255,b|=2),u&16711680&&(i[o++]=u>>>16&255,b|=4),u&4278190080&&(i[o++]=u>>>24&255,b|=8),h&255&&(i[o++]=h&255,b|=16),h&65280&&(i[o++]=h>>>8&255,b|=32),i[R]=b,p+=h,u+=h,h=m,u>4294967295&&(h=0),h<Me){c=0;for(let y=-16;y<0;y++)c=(c<<8|e[p+y])^Pe[c>>>23];c=c>>>0}}if(t&&o>t)return null}return l>0&&(i[o-l-1]=l),t&&o>t?null:i.subarray(0,o)}var Dt={blob:0,tree:1,commit:2,tag:3};function Mt(r,e){let t=e?.window??10,n=e?.depth??50,s=r.slice().sort((c,l)=>{let d=Dt[c.type]??99,p=Dt[l.type]??99;return d!==p?d-p:l.content.byteLength-c.content.byteLength}),a=new Map,i=[],o=[],f=[];for(let c=0;c<s.length;c++){let l=s[c],d={hash:l.hash,type:l.type,content:l.content,depth:0},p=null,u=null,h=Math.max(0,c-t);for(let m=c-1;m>=h;m--){let R=s[m];if(R.type!==l.type||(a.get(R.hash)?.depth??0)>=n||l.content.byteLength<R.content.byteLength>>>5)continue;let g=o[m-h]??null;if(!g)continue;let w=p?p.byteLength:l.content.byteLength/2|0;if(w<16)continue;let E=Gr(g,l.content,w);E&&(!p||E.byteLength<p.byteLength)&&(p=E,u=R.hash)}if(p&&u){d.delta=p,d.deltaBase=u;let m=a.get(u);d.depth=(m?.depth??0)+1}a.set(l.hash,d),i.push(d),o.length>=t&&(o.shift(),f.shift()),o.push(Wr(l.content)),f.push(l.hash)}return i}function Fr(r){let e=r;return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e<16?16:e}function Nt(r,e,t){let n=t;do{let s=n&127;n>>>=7,n>0&&(s|=128),r[e++]=s}while(n>0);return e}var qr=2147483647;async function Bt(r,e,t,n){if(t>=qr)return{shallow:[],unshallow:[...n]};let s=new Map,a=[];for(let c of e)!s.has(c)&&await ae(r,c)&&(s.set(c,1),a.push({hash:c,level:1}));let i=new Set,o=0;for(;o<a.length;){let{hash:c,level:l}=a[o++];if(l>=t){i.add(c);continue}let d;try{d=await X(r,c)}catch{continue}for(let p of d.parents)!s.has(p)&&await ae(r,p)&&(s.set(p,l+1),a.push({hash:p,level:l+1}))}let f=[];for(let c of n){let l=s.get(c);l!==void 0&&l<t&&f.push(c)}return{shallow:[...i],unshallow:f}}async function ce(r,e,t,n,s){let a=s??n,i=new Set;for(let l of t)await oe(r,l,i,a);let o=[...e];if(s&&n)for(let l of s)try{let d=await X(r,l);for(let p of d.parents)i.has(p)||o.push(p)}catch{}let f=[],c=new Set;for(let l of o)await ie(r,l,i,c,f,n);return{count:f.length,objects:zr(f)}}async function $t(r,e,t,n,s){let{count:a,objects:i}=await ce(r,e,t,n,s);return{count:a,objects:Xr(r,i)}}async function*zr(r){for(let e of r)yield e}async function*Xr(r,e){for await(let t of e){let n=await se(r,t.hash);yield{hash:t.hash,type:t.type,content:n.content}}}async function _t(r){let e=[];for await(let t of r.objects)e.push(t);return e}async function oe(r,e,t,n){if(t.has(e)||(t.add(e),!await ae(r,e)))return;let s=await se(r,e);switch(s.type){case"commit":{let a=ne(s.content);if(await oe(r,a.tree,t,n),!n?.has(e))for(let i of a.parents)await oe(r,i,t,n);break}case"tree":{let a=De(s.content);for(let i of a.entries)await oe(r,i.hash,t,n);break}case"tag":{let a=W(s.content);await oe(r,a.object,t,n);break}case"blob":break}}async function ie(r,e,t,n,s,a){if(n.has(e)||t.has(e))return;n.add(e);let i=await se(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let o=ne(i.content);if(await ie(r,o.tree,t,n,s,a),!a?.has(e))for(let f of o.parents)await ie(r,f,t,n,s,a);break}case"tree":{let o=De(i.content);for(let f of o.entries)await ie(r,f.hash,t,n,s,a);break}case"tag":{let o=W(i.content);await ie(r,o.object,t,n,s,a);break}case"blob":break}}var Kr=new TextEncoder,Gt=new TextDecoder,Wt=65520,Yr=new Uint8Array([48,48,48,48]);function v(r){let e=typeof r=="string"?Kr.encode(r):r,t=4+e.byteLength;if(t>Wt)throw new Error(`pkt-line too long: ${t} bytes (max ${Wt})`);let n=t.toString(16).padStart(4,"0"),s=new Uint8Array(t);return s[0]=n.charCodeAt(0),s[1]=n.charCodeAt(1),s[2]=n.charCodeAt(2),s[3]=n.charCodeAt(3),s.set(e,4),s}function D(){return Yr.slice()}function M(...r){let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}function Ft(r){let e=[],t=0;for(;t<r.byteLength;){if(t+4>r.byteLength)throw new Error("Truncated pkt-line header");let n=Gt.decode(r.subarray(t,t+4)),s=parseInt(n,16);if(Number.isNaN(s))throw new Error(`Invalid pkt-line length: ${n}`);if(s===0){e.push({type:"flush"}),t+=4;continue}if(s<4)throw new Error(`Invalid pkt-line length: ${s}`);if(t+s>r.byteLength)throw new Error(`Truncated pkt-line: need ${s} bytes at offset ${t}, have ${r.byteLength-t}`);e.push({type:"data",data:r.subarray(t+4,t+s)}),t+=s}return e}function qt(r){if(r.type==="flush")return"";let e=Gt.decode(r.data);return e.endsWith(`
|
|
8
|
+
`)?e.slice(0,-1):e}var zt=65515;function ve(r,e,t){let n=[],s=[...e];t&&s.push(`symref=HEAD:${t}`),s.push("agent=just-git/1.0");let a=s.join(" ");if(r.length===0)n.push(v(`0000000000000000000000000000000000000000 capabilities^{}\0${a}
|
|
9
|
+
`));else for(let i=0;i<r.length;i++){let o=r[i];i===0?n.push(v(`${o.hash} ${o.name}\0${a}
|
|
10
|
+
`)):n.push(v(`${o.hash} ${o.name}
|
|
11
|
+
`))}return n.push(D()),M(...n)}function Xt(r,e,t,n){let s=M(v(`# service=${e}
|
|
12
|
+
`),D()),a=ve(r,t,n),i=new Uint8Array(s.byteLength+a.byteLength);return i.set(s,0),i.set(a,s.byteLength),i}function Kt(r){let e=Ft(r),t=[],n=[],s=[],a=[],i,o=!1;for(let f of e){if(f.type==="flush")continue;let c=qt(f);if(c.startsWith("want ")){let l=c.slice(5);if(t.length===0){let d=l.indexOf(" ");d!==-1?(t.push(l.slice(0,d)),a=l.slice(d+1).split(" ").filter(Boolean)):t.push(l)}else t.push(l)}else c.startsWith("have ")?n.push(c.slice(5)):c.startsWith("shallow ")?s.push(c.slice(8)):c.startsWith("deepen ")?(i=parseInt(c.slice(7),10),Number.isNaN(i)&&(i=void 0)):c==="done"&&(o=!0)}return{wants:t,haves:n,capabilities:a,clientShallows:s,depth:i,done:o}}function K(r,e,t,n){let s=[];if(n){for(let a of n.shallow)s.push(v(`shallow ${a}
|
|
13
|
+
`));for(let a of n.unshallow)s.push(v(`unshallow ${a}
|
|
14
|
+
`));s.push(D())}if(t&&t.length>0){for(let i of t)s.push(v(`ACK ${i} common
|
|
15
|
+
`));let a=t[t.length-1];s.push(v(`ACK ${a} ready
|
|
16
|
+
`)),s.push(v(`ACK ${a}
|
|
17
|
+
`))}else s.push(v(`NAK
|
|
18
|
+
`));if(e){let a=0;for(;a<r.byteLength;){let i=Math.min(zt,r.byteLength-a);s.push(Be(1,r.subarray(a,a+i))),a+=i}s.push(D())}else{let a=new Uint8Array(r.byteLength);a.set(r),s.push(a)}return M(...s)}function Yt(r){let e=[];for(let t of r.shallow)e.push(v(`shallow ${t}
|
|
19
|
+
`));for(let t of r.unshallow)e.push(v(`unshallow ${t}
|
|
20
|
+
`));return e.push(D()),M(...e)}async function*Vt(r,e,t,n){if(n){let a=[];for(let i of n.shallow)a.push(v(`shallow ${i}
|
|
21
|
+
`));for(let i of n.unshallow)a.push(v(`unshallow ${i}
|
|
22
|
+
`));a.push(D()),yield M(...a)}let s=[];if(t&&t.length>0){for(let i of t)s.push(v(`ACK ${i} common
|
|
23
|
+
`));let a=t[t.length-1];s.push(v(`ACK ${a} ready
|
|
24
|
+
`)),s.push(v(`ACK ${a}
|
|
25
|
+
`))}else s.push(v(`NAK
|
|
26
|
+
`));if(yield M(...s),e){for await(let a of r){let i=0;for(;i<a.byteLength;){let o=Math.min(zt,a.byteLength-i);yield Be(1,a.subarray(i,i+o)),i+=o}}yield D()}else for await(let a of r)yield a}function Zt(r){let e=new TextDecoder,t=[],n=[],s=0,a=!1;for(;s<r.byteLength&&!(s+4>r.byteLength);){let o=e.decode(r.subarray(s,s+4)),f=parseInt(o,16);if(Number.isNaN(f))break;if(f===0){a=!0,s+=4;break}if(f<4||s+f>r.byteLength)break;let c=r.subarray(s+4,s+f);s+=f;let l=c.indexOf(0),d;if(l!==-1)d=e.decode(c.subarray(0,l)),n=e.decode(c.subarray(l+1)).replace(/\n$/,"").split(" ").filter(Boolean);else{let u=e.decode(c);d=u.endsWith(`
|
|
27
|
+
`)?u.slice(0,-1):u}let p=d.split(" ");p.length>=3&&t.push({oldHash:p[0],newHash:p[1],refName:p[2]})}let i=s<r.byteLength?r.subarray(s):new Uint8Array(0);return{commands:t,packData:i,capabilities:n,sawFlush:a}}function Y(r,e,t){let n=[];n.push(v(r?`unpack ok
|
|
28
28
|
`:`unpack error
|
|
29
|
-
`));for(let a of e)a.ok?n.push(
|
|
30
|
-
`)):n.push(
|
|
31
|
-
`));n.push(D());let s=
|
|
32
|
-
`),128;let{service:l,repoPath:d}=c,p=await n(d);if(!p)return
|
|
33
|
-
`),128;let{repo:u,repoId:h}=p,m=await
|
|
34
|
-
`),128;await f.write(
|
|
35
|
-
`),128}finally{try{await f.close()}catch{}}}async function
|
|
36
|
-
`)&&(a=a.slice(0,-1)),n){let o=a.indexOf("\0");o!==-1&&(t=a.slice(o+1).split(" ").filter(Boolean),a=a.slice(0,o)),n=!1}let i=a.split(" ");i.length>=3&&e.push({oldHash:i[0],newHash:i[1],refName:i[2]})}return{commands:e,capabilities:t}}function
|
|
37
|
-
`)),128;try{
|
|
29
|
+
`));for(let a of e)a.ok?n.push(v(`ok ${a.name}
|
|
30
|
+
`)):n.push(v(`ng ${a.name} ${a.error??"failed"}
|
|
31
|
+
`));n.push(D());let s=M(...n);if(t){let a=[];return a.push(Be(1,s)),a.push(D()),M(...a)}return s}function Be(r,e){let t=new Uint8Array(1+e.byteLength);return t[0]=r,t.set(e,1),v(t)}var fe=class{entries=new Map;currentBytes=0;maxBytes;hits=0;misses=0;constructor(e=256*1024*1024){this.maxBytes=e}static key(e,t,n){if(n.length>0)return null;let s=t.slice().sort();return`${e}\0${s.join(",")}`}get(e){let t=this.entries.get(e);return t?this.hits++:this.misses++,t}set(e,t){if(this.entries.has(e))return;let n=t.packData.byteLength;if(!(n>this.maxBytes)){for(;this.currentBytes+n>this.maxBytes&&this.entries.size>0;){let s=this.entries.keys().next().value;this.currentBytes-=this.entries.get(s).packData.byteLength,this.entries.delete(s)}this.entries.set(e,t),this.currentBytes+=n}}clear(){this.entries.clear(),this.currentBytes=0}get stats(){return{entries:this.entries.size,bytes:this.currentBytes,hits:this.hits,misses:this.misses}}},Jt=["multi_ack_detailed","no-done","side-band-64k","ofs-delta","include-tag","allow-reachable-sha1-in-want","shallow"],Qt=["report-status","side-band-64k","ofs-delta","delete-refs"];async function er(r){let e=await r.refStore.listRefs("refs"),t=await r.refStore.readRef("HEAD"),n=[],s=null,a;if(t)if(t.type==="symbolic"){a=t.target;let o=await r.refStore.readRef(t.target);o?.type==="direct"&&(s=o.hash)}else s=t.hash;let i=e.slice().sort((o,f)=>o.name<f.name?-1:o.name>f.name?1:0);if(!s&&i.length>0){let o=Zr(i);o&&(s=o.hash,a=o.name)}s&&n.push({name:"HEAD",hash:s});for(let o of i)if(n.push({name:o.name,hash:o.hash}),o.name.startsWith("refs/tags/"))try{let f=await r.objectStore.read(o.hash);if(f.type==="tag"){let c=W(f.content);n.push({name:`${o.name}^{}`,hash:c.object})}}catch{}return{refs:n,headTarget:a}}var Vr=["refs/heads/main","refs/heads/master"];function Zr(r){for(let t of Vr){let n=r.find(s=>s.name===t);if(n)return n}return r.find(t=>t.name.startsWith("refs/heads/"))??null}function $e(r,e,t){return Xt(r,e,e==="git-upload-pack"?Jt:Qt,t)}function _e(r,e,t){return ve(r,e==="git-upload-pack"?Jt:Qt,t)}async function le(r,e,t,n,s){let{refs:a,headTarget:i}=await er(r),o=a;if(n?.advertiseRefs){let f=await n.advertiseRefs({repo:r,repoId:e,refs:a,service:t,session:s});if(T(f))return f;f&&(o=f)}return{refs:o,headTarget:i}}async function de(r,e,t){let{wants:n,haves:s,capabilities:a,clientShallows:i,depth:o,done:f}=Kt(e);if(n.length===0)return K(new Uint8Array(0),!1);let c=a.includes("multi_ack_detailed"),l=a.includes("side-band-64k"),d,p,u;if(i.length>0&&(u=new Set(i)),o!==void 0){let R=await Bt(r,n,o,u??new Set);d=R,p=new Set(R.shallow)}if(d&&!f)return Yt(d);let h;if(c&&s.length>0){h=[];for(let R of s)await r.objectStore.exists(R)&&h.push(R);h.length===0&&(h=void 0)}let m=!p&&t?.cache&&t.cacheKey?fe.key(t.cacheKey,n,s):null;if(m&&t?.cache){let R=t.cache.get(m);if(R)return K(R.packData,l,h)}return t?.noDelta?Jr(r,n,s,a,l,h,d,p,u):Qr(r,n,s,a,l,h,t,m,d,p,u)}async function Jr(r,e,t,n,s,a,i,o,f){let{count:c,objects:l}=await ce(r,e,t,o,f);if(c===0){let{data:y}=await Ee([]),g=K(y,s,a,i);return new ReadableStream({start(w){w.enqueue(g),w.close()}})}let d=[];for await(let y of l)d.push(y);let p=new Set(d.map(y=>y.hash)),u=[];if(n.includes("include-tag")){let y=await r.refStore.listRefs("refs/tags");for(let g of y)if(!p.has(g.hash))try{let w=await r.objectStore.read(g.hash);if(w.type==="tag"){let E=W(w.content);p.has(E.object)&&u.push({hash:g.hash,type:"tag",content:w.content})}}catch{}}let h=d.length+u.length;async function*m(){for(let y of d){let g=await r.objectStore.read(y.hash);yield{type:g.type,content:g.content}}for(let y of u)yield{type:y.type,content:y.content}}let R=At(h,m()),b=Vt(R,s,a,i);return new ReadableStream({async pull(y){let{value:g,done:w}=await b.next();w?y.close():y.enqueue(g)}})}async function Qr(r,e,t,n,s,a,i,o,f,c,l){let d=await $t(r,e,t,c,l);if(d.count===0){let{data:y}=await Ee([]);return K(y,s,a,f)}let p=await _t(d),u=new Set(p.map(y=>y.hash));if(n.includes("include-tag")){let y=await r.refStore.listRefs("refs/tags");for(let g of y)if(!u.has(g.hash))try{let w=await r.objectStore.read(g.hash);if(w.type==="tag"){let E=W(w.content);u.has(E.object)&&(p.push({hash:g.hash,type:"tag",content:w.content}),u.add(g.hash))}}catch{}}let h=i?.deltaWindow?{window:i.deltaWindow}:void 0,m=Mt(p,h),R=m.map(y=>({hash:y.hash,type:y.type,content:y.content,delta:y.delta,deltaBaseHash:y.deltaBase})),{data:b}=await Ee(R);if(o&&i?.cache){let y=m.filter(g=>g.delta).length;i.cache.set(o,{packData:b,objectCount:p.length,deltaCount:y})}return K(b,s,a,f)}async function We(r,e){let{commands:t,packData:n,capabilities:s,sawFlush:a}=Zt(e),i=!0;if(n.byteLength>0)try{await r.objectStore.ingestPack(n)}catch{i=!1}return{updates:await tr(r,t,i),unpackOk:i,capabilities:s,sawFlush:a}}async function Ge(r,e,t,n,s=!0){let a=!0;try{let f=St(n,async c=>{try{return await r.objectStore.read(c)}catch{return null}});await r.objectStore.ingestPackStream(f)}catch{a=!1}return{updates:await tr(r,e,a),unpackOk:a,capabilities:t,sawFlush:s}}async function tr(r,e,t){let n=[];for(let s of e){let a=s.oldHash===ye,i=s.newHash===ye,o=!1;if(!a&&!i&&t)try{o=await Ne(r,s.oldHash,s.newHash)}catch{}n.push({ref:s.refName,oldHash:a?null:s.oldHash,newHash:s.newHash,isFF:o,isCreate:a,isDelete:i})}return n}async function V(r){let{repo:e,repoId:t,ingestResult:n,hooks:s,session:a}=r,{updates:i}=n;if(s?.preReceive){let c=await s.preReceive({repo:e,repoId:t,updates:i,session:a});if(T(c)){let l=c.message??"pre-receive hook declined";return{refResults:i.map(d=>({ref:d.ref,ok:!1,error:l})),applied:[]}}}let o=[],f=[];for(let c of i){if(c.ref==="HEAD"){o.push({ref:c.ref,ok:!1,error:"HEAD cannot be updated via push"});continue}if(!c.isDelete&&!Ut(c.ref)){o.push({ref:c.ref,ok:!1,error:"invalid refname"});continue}if(s?.update){let l=await s.update({repo:e,repoId:t,update:c,session:a});if(T(l)){o.push({ref:c.ref,ok:!1,error:l.message??"update hook declined"});continue}}if(!c.isDelete&&!await e.objectStore.exists(c.newHash)){o.push({ref:c.ref,ok:!1,error:"missing objects"});continue}try{let l=c.isCreate?null:c.oldHash,d=c.isDelete?null:{type:"direct",hash:c.newHash};if(!await e.refStore.compareAndSwapRef(c.ref,l,d)){o.push({ref:c.ref,ok:!1,error:"failed to lock"});continue}o.push({ref:c.ref,ok:!0}),f.push(c)}catch(l){o.push({ref:c.ref,ok:!1,error:l instanceof Error?l.message:String(l)})}}if(s?.postReceive&&f.length>0)try{await s.postReceive({repo:e,repoId:t,updates:f,session:a})}catch{}return{refResults:o,applied:f}}async function Fe(r,e){let t=[];for(let n of e){let s;n.oldHash!==void 0?s=n.oldHash:s=await Lt(r,n.ref);let a=s===null,i=n.newHash===null,o=n.newHash??ye,f=!1;if(!a&&!i)try{f=await Ne(r,s,o)}catch{}t.push({ref:n.ref,oldHash:s,newHash:o,isFF:f,isCreate:a,isDelete:i})}return t}function en(r){let e=r.match(/^git[\s-](upload-pack|receive-pack)\s+'?([^']+?)'?\s*$/);if(!e)return null;let t=`git-${e[1]}`,n=e[2];return n.startsWith("/")&&(n=n.slice(1)),{service:t,repoPath:n}}var tn=new TextEncoder;async function nr(r,e,t){let{resolveRepo:n,hooks:s,packCache:a,packOptions:i,session:o}=t,f=e.writable.getWriter();try{let c=en(r);if(!c)return ke(e,`fatal: unrecognized command '${r}'
|
|
32
|
+
`),128;let{service:l,repoPath:d}=c,p=await n(d);if(!p)return ke(e,`fatal: '${d}' does not appear to be a git repository
|
|
33
|
+
`),128;let{repo:u,repoId:h}=p,m=await le(u,h,l,s,o);if(T(m))return ke(e,`fatal: ${m.message??"access denied"}
|
|
34
|
+
`),128;await f.write(_e(m.refs,l,m.headTarget));let R=new qe(e.readable);try{if(l==="git-upload-pack"){let b=await nn(R),y=await de(u,b,{cache:a,cacheKey:h,noDelta:i?.noDelta,deltaWindow:i?.deltaWindow});await on(f,y)}else{let{commands:b,capabilities:y}=await sn(R),g=R.streamRemaining();await rn({writer:f,repo:u,repoId:h,commands:b,capabilities:y,packStream:g,hooks:s,session:o})}}finally{R.release()}return 0}catch(c){return t.onError?.(c),ke(e,`fatal: internal error
|
|
35
|
+
`),128}finally{try{await f.close()}catch{}}}async function rn(r){let{writer:e,repo:t,repoId:n,commands:s,capabilities:a,packStream:i,hooks:o,session:f}=r,c=await Ge(t,s,a,i);if(c.updates.length===0)return;let l=c.capabilities.includes("side-band-64k"),d=c.capabilities.includes("report-status");if(!c.unpackOk){if(d){let u=c.updates.map(h=>({name:h.ref,ok:!1,error:"unpack failed"}));await e.write(Y(!1,u,l))}return}let{refResults:p}=await V({repo:t,repoId:n,ingestResult:c,hooks:o,session:f});if(d){let u=p.map(h=>({name:h.ref,ok:h.ok,error:h.error}));await e.write(Y(!0,u,l))}}function ke(r,e){r.writeStderr?.(tn.encode(e))}var rr=new TextDecoder,qe=class{buf=new Uint8Array(0);byteReader;eof=!1;constructor(e){this.byteReader=e.getReader()}async fill(e){for(;this.buf.byteLength<e&&!this.eof;){let t=await this.byteReader.read();if(t.done||!t.value){this.eof=!0;break}let n=t.value,s=new Uint8Array(this.buf.byteLength+n.byteLength);s.set(this.buf),s.set(n,this.buf.byteLength),this.buf=s}return this.buf.byteLength>=e}consume(e){let t=this.buf.subarray(0,e);return this.buf=this.buf.subarray(e),t}async readPktLine(){if(!await this.fill(4))return null;let e=rr.decode(this.buf.subarray(0,4)),t=parseInt(e,16);if(t===0)return{type:"flush",raw:this.consume(4)};if(t<4||!await this.fill(t))return null;let n=new Uint8Array(this.consume(t));return{type:"data",raw:n,text:rr.decode(n.subarray(4))}}async*streamRemaining(){for(this.buf.byteLength>0&&(yield this.consume(this.buf.byteLength));!this.eof;){let e=await this.byteReader.read();if(e.done||!e.value){this.eof=!0;break}yield e.value}}release(){this.byteReader.releaseLock()}};async function nn(r){let e=[];for(;;){let t=await r.readPktLine();if(!t||(e.push(t.raw),t.type==="data"&&t.text.trimEnd()==="done"))break}return an(e)}async function sn(r){let e=[],t=[],n=!0;for(;;){let s=await r.readPktLine();if(!s||s.type==="flush")break;let a=s.text;if(a.endsWith(`
|
|
36
|
+
`)&&(a=a.slice(0,-1)),n){let o=a.indexOf("\0");o!==-1&&(t=a.slice(o+1).split(" ").filter(Boolean),a=a.slice(0,o)),n=!1}let i=a.split(" ");i.length>=3&&e.push({oldHash:i[0],newHash:i[1],refName:i[2]})}return{commands:e,capabilities:t}}function an(r){if(r.length===0)return new Uint8Array(0);if(r.length===1)return r[0];let e=0;for(let s of r)e+=s.byteLength;let t=new Uint8Array(e),n=0;for(let s of r)t.set(s,n),n+=s.byteLength;return t}async function on(r,e){if(e instanceof ReadableStream){let t=e.getReader();try{for(;;){let{value:n,done:s}=await t.read();if(s)break;await r.write(n)}}finally{t.releaseLock()}}else await r.write(e)}async function ar(r,e,t,n){let s=n?.dryRun??!1,a=await sr(r),i=cn(a);if(i.length===0)return{deleted:0,retained:0};let o=await ce(r,i,[]),f=new Set;for await(let u of o.objects)f.add(u.hash);let c=await e.listObjectHashes(t),l=[];for(let u of c)f.has(u)||l.push(u);let d=await sr(r);return fn(a,d)?s||l.length===0?{deleted:l.length,retained:f.size}:{deleted:await e.deleteObjects(t,l),retained:f.size}:{deleted:0,retained:f.size,aborted:!0}}async function sr(r){return r.refStore.listRefs()}function cn(r){let e=new Set;for(let t of r)e.add(t.hash);return Array.from(e)}function fn(r,e){if(r.length!==e.length)return!1;let t=new Map;for(let n of r)t.set(n.name,n.hash);for(let n of e)if(t.get(n.name)!==n.hash)return!1;return!0}function or(r){function e(t){return{objectStore:new ze(r,t),refStore:new Xe(r,t)}}return{async createRepo(t,n){if(await r.hasRepo(t))throw new Error(`repo '${t}' already exists`);let a=n?.defaultBranch??"main";return await r.insertRepo(t),await r.putRef(t,"HEAD",{type:"symbolic",target:`refs/heads/${a}`}),e(t)},async repo(t){return await r.hasRepo(t)?e(t):null},async deleteRepo(t){await r.deleteRepo(t)}}}var ze=class{constructor(e,t){this.driver=e;this.repoId=t}cache=new ge;async write(e,t){let n=It(e,t),s=await ct(n);return await this.driver.putObject(this.repoId,s,e,t),s}async read(e){let t=this.cache.get(e);if(t)return t;let n=await this.driver.getObject(this.repoId,e);if(!n)throw new Error(`object ${e} not found`);return this.cache.set(e,n),n}async exists(e){return!!await this.driver.hasObject(this.repoId,e)}async ingestPack(e){if(e.byteLength<32)return 0;let t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=t.getUint32(0);if(n!==1346454347)throw new Error(`invalid pack signature: 0x${n.toString(16)} (expected 0x5041434b)`);let s=t.getUint32(4);if(s!==2)throw new Error(`unsupported pack version: ${s}`);if(t.getUint32(8)===0)return 0;let i=this.driver,o=this.repoId,f=await jt(e,async c=>{let l=await i.getObject(o,c);return l?{type:l.type,content:new Uint8Array(l.content)}:null});return await i.putObjects(o,f.map(c=>({hash:c.hash,type:c.type,content:c.content}))),f.length}async ingestPackStream(e){let t=[];for await(let n of e)t.push({hash:n.hash,type:n.type,content:n.content});return t.length===0?0:(await this.driver.putObjects(this.repoId,t),t.length)}async findByPrefix(e){return e.length<4?[]:Array.from(await this.driver.findObjectsByPrefix(this.repoId,e))}},Xe=class{constructor(e,t){this.driver=e;this.repoId=t}async readRef(e){return await this.driver.getRef(this.repoId,e)??null}async writeRef(e,t){await this.driver.putRef(this.repoId,e,Tt(t))}async deleteRef(e){await this.driver.removeRef(this.repoId,e)}async listRefs(e){let t=await this.driver.listRefs(this.repoId,e),n=[];for(let s of t)if(s.ref.type==="direct")n.push({name:s.name,hash:s.ref.hash});else if(s.ref.type==="symbolic"){let a=await Ke(i=>this.driver.getRef(this.repoId,i),s.ref.target);a&&n.push({name:s.name,hash:a})}return n}async compareAndSwapRef(e,t,n){return!!await this.driver.atomicRefUpdate(this.repoId,s=>pe(s.getRef(e),a=>{let i=a?a.type==="direct"?a.hash:Ke(o=>s.getRef(o),a.target):null;return pe(i,o=>{if(t===null){if(a!==null)return!1}else if(o!==t)return!1;return n===null?pe(s.removeRef(e),()=>!0):pe(s.putRef(e,n),()=>!0)})}))}};function pe(r,e){return r instanceof Promise?r.then(e):e(r)}function Ke(r,e,t=0){return t>10?null:pe(r(e),n=>n?n.type==="direct"?n.hash:n.type==="symbolic"?Ke(r,n.target,t+1):null:null)}var ln={http:r=>({transport:"http",request:r}),ssh:r=>({transport:"ssh",username:r.username})};function ir(r){if(r.length===0)return!1;for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(n===0||n<32||n===127||n===92)return!1}let e=r.split("/");for(let t of e)if(t.length===0||t.charCodeAt(0)===46)return!1;return!0}function dn(r){if(!r||!r.storage)throw new TypeError("createServer: config.storage is required. Example: createServer({ storage: new MemoryStorage() })");let e=or(r.storage),t=r.resolve??(b=>b),n=r.autoCreate,{basePath:s}=r;async function a(b){if(!ir(b))return null;let y=await t(b);if(y==null||y!==b&&!ir(y))return null;let g=await e.repo(y);if(g)return{repo:g,repoId:y};if(!n)return null;let w=typeof n=="object"?{defaultBranch:n.defaultBranch}:void 0;return{repo:await e.createRepo(y,w),repoId:y}}let i=hn(r.policy,r.hooks),o=r.session??ln,f=r.packCache===!1?void 0:new fe(r.packCache?.maxBytes),c=r.onError===!1?void 0:r.onError??(b=>{let y=b instanceof Error?b.message:String(b);console.error(`[server] Internal error: ${y}`)}),l=!1,d=0,p=null,u=null;function h(){return l?!1:(d++,!0)}function m(){d--,l&&d===0&&p?.()}let R={async fetch(b){if(!h())return new Response("Service Unavailable",{status:503});let y;try{if(!o.http)return new Response("HTTP session builder not configured",{status:501});let g=await o.http(b);if(g instanceof Response)return g;y=g;let w=new URL(b.url),E=decodeURIComponent(w.pathname);if(s){let x=s.replace(/\/+$/,"");if(!E.startsWith(x))return new Response("Not Found",{status:404});E=E.slice(x.length)}if(E.startsWith("/")||(E=`/${E}`),E.endsWith("/info/refs")&&b.method==="GET"){let x=w.searchParams.get("service");if(x!=="git-upload-pack"&&x!=="git-receive-pack")return new Response("Unsupported service",{status:403});let O=Ye(E,"/info/refs"),j=await a(O);if(!j)return new Response("Not Found",{status:404});let P=await le(j.repo,j.repoId,x,i,y);if(T(P))return new Response(P.message??"Forbidden",{status:403});let A=$e(P.refs,x,P.headTarget);return new Response(A,{headers:{"Content-Type":`application/x-${x}-advertisement`,"Cache-Control":"no-cache"}})}if(E.endsWith("/git-upload-pack")&&b.method==="POST"){let x=Ye(E,"/git-upload-pack"),O=await a(x);if(!O)return new Response("Not Found",{status:404});let j=await cr(b),P=await de(O.repo,j,{cache:f,cacheKey:O.repoId,noDelta:r.packOptions?.noDelta,deltaWindow:r.packOptions?.deltaWindow});return new Response(P,{headers:{"Content-Type":"application/x-git-upload-pack-result"}})}if(E.endsWith("/git-receive-pack")&&b.method==="POST"){let x=Ye(E,"/git-receive-pack"),O=await a(x);if(!O)return new Response("Not Found",{status:404});let j=await cr(b),P=await We(O.repo,j);if(!P.sawFlush&&P.updates.length===0)return new Response("Bad Request",{status:400});let A=P.capabilities.includes("side-band-64k"),B=P.capabilities.includes("report-status");if(!P.unpackOk){if(B){let C=P.updates.map($=>({name:$.ref,ok:!1,error:"unpack failed"}));return new Response(Y(!1,C,A),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response(new Uint8Array(0),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}let{refResults:I}=await V({repo:O.repo,repoId:O.repoId,ingestResult:P,hooks:i,session:y});if(B){let C=I.map($=>({name:$.ref,ok:$.ok,error:$.error}));return new Response(Y(!0,C,A),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response(new Uint8Array(0),{headers:{"Content-Type":"application/x-git-receive-pack-result"}})}return new Response("Not Found",{status:404})}catch(g){return c?.(g,y),new Response("Internal Server Error",{status:500})}finally{m()}},async handleSession(b,y,g){if(!h())return y.writeStderr?.(new TextEncoder().encode(`fatal: server shutting down
|
|
37
|
+
`)),128;try{if(!o.ssh)return y.writeStderr?.(new TextEncoder().encode(`fatal: SSH session builder not configured
|
|
38
|
+
`)),128;let w=await o.ssh(g??{});return await nr(b,y,{resolveRepo:a,hooks:i,packCache:f,packOptions:r.packOptions,session:w,onError:c?E=>c(E,w):void 0})}finally{m()}},async updateRefs(b,y,g){if(!h())throw new Error("Server is shutting down");try{let w=await e.repo(b);if(!w)throw new Error(`Repository "${b}" not found`);let E=await Fe(w,y);return V({repo:w,repoId:b,ingestResult:{updates:E,unpackOk:!0,capabilities:[],sawFlush:!0},hooks:i,session:g})}finally{m()}},nodeHandler(b,y){let g=[];b.on("data",w=>g.push(new Uint8Array(w))),b.on("error",()=>{y.writeHead(500),y.end("Internal Server Error")}),b.on("end",()=>{pn(R,b,g,y).catch(()=>{try{y.writeHead(500),y.end("Internal Server Error")}catch{}})})},createRepo:(b,y)=>e.createRepo(b,y),repo:b=>e.repo(b),deleteRepo:b=>e.deleteRepo(b),async gc(b,y){if(!h())throw new Error("Server is shutting down");try{let g=await e.repo(b);if(!g)throw new Error(`Repository "${b}" not found`);return ar(g,r.storage,b,y)}finally{m()}},get closed(){return l},asNetwork(b="http://git"){return{allowed:[b.endsWith("/")?b:`${b}/`],fetch:(g,w)=>R.fetch(new Request(g,w))}},async close(b){if(l)return u??Promise.resolve();if(l=!0,f?.clear(),d!==0){if(u=new Promise(y=>{p=y}),b?.signal){if(b.signal.aborted){p();return}let y=()=>p?.();b.signal.addEventListener("abort",y,{once:!0}),u.then(()=>b.signal.removeEventListener("abort",y))}return u}}};return R}function Ye(r,e){let t=r.slice(0,-e.length);return t.startsWith("/")&&(t=t.slice(1)),t}async function cr(r){let e=new Uint8Array(await r.arrayBuffer()),t=r.headers.get("content-encoding");if(t==="gzip"||t==="x-gzip"){let n=new DecompressionStream("gzip"),s=n.writable.getWriter();return s.write(e),s.close(),new Uint8Array(await new Response(n.readable).arrayBuffer())}return e}async function pn(r,e,t,n){let s=typeof e.headers.host=="string"?e.headers.host:"localhost",a=new URL(e.url??"/",`http://${s}`),i=new Headers;for(let[u,h]of Object.entries(e.headers))if(h!==void 0)if(Array.isArray(h))for(let m of h)i.append(u,m);else i.set(u,h);let o=e.method??"GET",f;if(o!=="GET"&&o!=="HEAD"){let u=0;for(let R of t)u+=R.byteLength;let h=new Uint8Array(u),m=0;for(let R of t)h.set(R,m),m+=R.byteLength;f=h}let c=new Request(a.href,{method:o,headers:i,body:f}),l=await r.fetch(c),d={};l.headers.forEach((u,h)=>{d[h]=u}),n.writeHead(l.status,d);let p=new Uint8Array(await l.arrayBuffer());p.byteLength>0&&n.write(p),n.end()}function un(r){let{protectedBranches:e=[],denyNonFastForward:t=!1,denyDeletes:n=!1,immutableTags:s=!1}=r,a=new Set(e.map(o=>o.startsWith("refs/")?o:`refs/heads/${o}`)),i={};return a.size>0&&(i.preReceive=async o=>{for(let f of o.updates)if(a.has(f.ref)){if(f.isDelete)return{reject:!0,message:`cannot delete protected branch ${f.ref}`};if(!f.isCreate&&!f.isFF)return{reject:!0,message:`non-fast-forward push to protected branch ${f.ref}`}}}),(t||n||s)&&(i.update=async o=>{if(n&&o.update.isDelete)return{reject:!0,message:"ref deletion denied"};if(s&&o.update.ref.startsWith("refs/tags/")){if(o.update.isDelete)return{reject:!0,message:"tag deletion denied"};if(!o.update.isCreate)return{reject:!0,message:"tag overwrite denied"}}if(t&&!o.update.isCreate&&!o.update.isDelete&&!o.update.isFF)return{reject:!0,message:"non-fast-forward"}}),i}function hn(r,e){let t=r?un(r):void 0;return t&&e?fr(t,e):t??e}function fr(...r){let e=r.filter(o=>o!=null);if(e.length===0)return{};if(e.length===1)return e[0];let t={},n=e.filter(o=>o.preReceive).map(o=>o.preReceive);n.length>0&&(t.preReceive=async o=>{for(let f of n){let c=await f(o);if(T(c))return c}});let s=e.filter(o=>o.update).map(o=>o.update);s.length>0&&(t.update=async o=>{for(let f of s){let c=await f(o);if(T(c))return c}});let a=e.filter(o=>o.postReceive).map(o=>o.postReceive);a.length>0&&(t.postReceive=async o=>{for(let f of a)try{await f(o)}catch{}});let i=e.filter(o=>o.advertiseRefs).map(o=>o.advertiseRefs);return i.length>0&&(t.advertiseRefs=async o=>{let f=o.refs;for(let c of i){let l=await c({...o,refs:f});if(T(l))return l;l&&(f=l)}return f}),t}var Ve=class{repos=new Set;objects=new Map;refs=new Map;hasRepo(e){return this.repos.has(e)}insertRepo(e){this.repos.add(e)}deleteRepo(e){this.repos.delete(e),this.objects.get(e)?.clear(),this.objects.delete(e),this.refs.get(e)?.clear(),this.refs.delete(e)}getObject(e,t){let n=this.getObjMap(e).get(t);return n?{type:n.type,content:new Uint8Array(n.content)}:null}putObject(e,t,n,s){let a=this.getObjMap(e);a.has(t)||a.set(t,{type:n,content:new Uint8Array(s)})}putObjects(e,t){let n=this.getObjMap(e);for(let s of t)n.has(s.hash)||n.set(s.hash,{type:s.type,content:new Uint8Array(s.content)})}hasObject(e,t){return this.getObjMap(e).has(t)}findObjectsByPrefix(e,t){let n=[];for(let s of this.getObjMap(e).keys())s.startsWith(t)&&n.push(s);return n}listObjectHashes(e){return Array.from(this.getObjMap(e).keys())}deleteObjects(e,t){let n=this.getObjMap(e),s=0;for(let a of t)n.delete(a)&&s++;return s}getRef(e,t){return this.getRefMap(e).get(t)??null}putRef(e,t,n){this.getRefMap(e).set(t,n)}removeRef(e,t){this.getRefMap(e).delete(t)}listRefs(e,t){let n=[];for(let[s,a]of this.getRefMap(e))t&&!s.startsWith(t)||n.push({name:s,ref:a});return n}atomicRefUpdate(e,t){let n=this.getRefMap(e);return t({getRef:s=>n.get(s)??null,putRef:(s,a)=>{n.set(s,a)},removeRef:s=>{n.delete(s)}})}repoIds(){return Array.from(this.repos)}getObjMap(e){let t=this.objects.get(e);return t||(t=new Map,this.objects.set(e,t)),t}getRefMap(e){let t=this.refs.get(e);return t||(t=new Map,this.refs.set(e,t)),t}};var yn=`
|
|
38
39
|
CREATE TABLE IF NOT EXISTS repos (
|
|
39
40
|
id TEXT PRIMARY KEY
|
|
40
41
|
);
|
|
@@ -55,7 +56,7 @@ CREATE TABLE IF NOT EXISTS git_refs (
|
|
|
55
56
|
target TEXT,
|
|
56
57
|
PRIMARY KEY (repo_id, name)
|
|
57
58
|
) WITHOUT ROWID;
|
|
58
|
-
`;function
|
|
59
|
+
`;function bn(r){return{repoInsert:r.prepare("INSERT INTO repos (id) VALUES (?)"),repoExists:r.prepare("SELECT 1 FROM repos WHERE id = ? LIMIT 1"),repoDelete:r.prepare("DELETE FROM repos WHERE id = ?"),objInsert:r.prepare("INSERT OR IGNORE INTO git_objects (repo_id, hash, type, content) VALUES (?, ?, ?, ?)"),objRead:r.prepare("SELECT type, content FROM git_objects WHERE repo_id = ? AND hash = ?"),objExists:r.prepare("SELECT 1 FROM git_objects WHERE repo_id = ? AND hash = ? LIMIT 1"),objPrefix:r.prepare("SELECT hash FROM git_objects WHERE repo_id = ? AND hash GLOB ?"),objDeleteAll:r.prepare("DELETE FROM git_objects WHERE repo_id = ?"),objListHashes:r.prepare("SELECT hash FROM git_objects WHERE repo_id = ?"),objDelete:r.prepare("DELETE FROM git_objects WHERE repo_id = ? AND hash = ?"),refRead:r.prepare("SELECT type, hash, target FROM git_refs WHERE repo_id = ? AND name = ?"),refWrite:r.prepare("INSERT OR REPLACE INTO git_refs (repo_id, name, type, hash, target) VALUES (?, ?, ?, ?, ?)"),refDelete:r.prepare("DELETE FROM git_refs WHERE repo_id = ? AND name = ?"),refList:r.prepare("SELECT name, type, hash, target FROM git_refs WHERE repo_id = ? AND name GLOB ?"),refListAll:r.prepare("SELECT name, type, hash, target FROM git_refs WHERE repo_id = ?"),refDeleteAll:r.prepare("DELETE FROM git_refs WHERE repo_id = ?")}}var Je=class{constructor(e){this.db=e;e.run(yn),this.stmts=bn(e),this.batchInsertTx=e.transaction(t=>{for(let n of t)this.stmts.objInsert.run(n.repoId,n.hash,n.type,n.content)}),this.batchDeleteTx=e.transaction((t,n,s)=>{let a=0;for(let i of n)this.stmts.objDelete.run(t,i),a++;s(a)})}stmts;batchInsertTx;batchDeleteTx;hasRepo(e){return this.stmts.repoExists.get(e)!==null}insertRepo(e){this.stmts.repoInsert.run(e)}deleteRepo(e){this.stmts.repoDelete.run(e),this.stmts.objDeleteAll.run(e),this.stmts.refDeleteAll.run(e)}getObject(e,t){let n=this.stmts.objRead.get(e,t);return n?{type:n.type,content:new Uint8Array(n.content)}:null}putObject(e,t,n,s){this.stmts.objInsert.run(e,t,n,s)}putObjects(e,t){this.batchInsertTx(t.map(n=>({repoId:e,...n})))}hasObject(e,t){return this.stmts.objExists.get(e,t)!==null}findObjectsByPrefix(e,t){return this.stmts.objPrefix.all(e,`${t}*`).map(s=>s.hash)}listObjectHashes(e){return this.stmts.objListHashes.all(e).map(n=>n.hash)}deleteObjects(e,t){if(t.length===0)return 0;let n=0;return this.batchDeleteTx(e,t,s=>{n+=s}),n}getRef(e,t){let n=this.stmts.refRead.get(e,t);return Ze(n)}putRef(e,t,n){n.type==="symbolic"?this.stmts.refWrite.run(e,t,"symbolic",null,n.target):this.stmts.refWrite.run(e,t,"direct",n.hash,null)}removeRef(e,t){this.stmts.refDelete.run(e,t)}listRefs(e,t){return(t?this.stmts.refList.all(e,`${t}*`):this.stmts.refListAll.all(e)).flatMap(s=>{let a=Ze(s);return a?[{name:s.name,ref:a}]:[]})}atomicRefUpdate(e,t){let n=this.stmts;return this.db.transaction(()=>t({getRef:a=>Ze(n.refRead.get(e,a)),putRef:(a,i)=>{i.type==="symbolic"?n.refWrite.run(e,a,"symbolic",null,i.target):n.refWrite.run(e,a,"direct",i.hash,null)},removeRef:a=>{n.refDelete.run(e,a)}}))()}};function Ze(r){return r?r.type==="symbolic"&&r.target?{type:"symbolic",target:r.target}:r.type==="direct"&&r.hash?{type:"direct",hash:r.hash}:null:null}var mn=`
|
|
59
60
|
CREATE TABLE IF NOT EXISTS repos (
|
|
60
61
|
id TEXT PRIMARY KEY
|
|
61
62
|
);
|
|
@@ -76,7 +77,7 @@ CREATE TABLE IF NOT EXISTS git_refs (
|
|
|
76
77
|
target TEXT,
|
|
77
78
|
PRIMARY KEY (repo_id, name)
|
|
78
79
|
) WITHOUT ROWID;
|
|
79
|
-
`;function
|
|
80
|
+
`;function S(r){return{run:(...e)=>{r.run(...e)},get:(...e)=>r.get(...e)??null,all:(...e)=>r.all(...e)}}function gn(r){return{repoInsert:S(r.prepare("INSERT INTO repos (id) VALUES (?)")),repoExists:S(r.prepare("SELECT 1 FROM repos WHERE id = ? LIMIT 1")),repoDelete:S(r.prepare("DELETE FROM repos WHERE id = ?")),objInsert:S(r.prepare("INSERT OR IGNORE INTO git_objects (repo_id, hash, type, content) VALUES (?, ?, ?, ?)")),objRead:S(r.prepare("SELECT type, content FROM git_objects WHERE repo_id = ? AND hash = ?")),objExists:S(r.prepare("SELECT 1 FROM git_objects WHERE repo_id = ? AND hash = ? LIMIT 1")),objPrefix:S(r.prepare("SELECT hash FROM git_objects WHERE repo_id = ? AND hash GLOB ?")),objDeleteAll:S(r.prepare("DELETE FROM git_objects WHERE repo_id = ?")),objListHashes:S(r.prepare("SELECT hash FROM git_objects WHERE repo_id = ?")),objDelete:S(r.prepare("DELETE FROM git_objects WHERE repo_id = ? AND hash = ?")),refRead:S(r.prepare("SELECT type, hash, target FROM git_refs WHERE repo_id = ? AND name = ?")),refWrite:S(r.prepare("INSERT OR REPLACE INTO git_refs (repo_id, name, type, hash, target) VALUES (?, ?, ?, ?, ?)")),refDelete:S(r.prepare("DELETE FROM git_refs WHERE repo_id = ? AND name = ?")),refList:S(r.prepare("SELECT name, type, hash, target FROM git_refs WHERE repo_id = ? AND name GLOB ?")),refListAll:S(r.prepare("SELECT name, type, hash, target FROM git_refs WHERE repo_id = ?")),refDeleteAll:S(r.prepare("DELETE FROM git_refs WHERE repo_id = ?"))}}var et=class{constructor(e){this.db=e;e.exec(mn),this.stmts=gn(e),this.batchInsertTx=e.transaction(t=>{for(let n of t)this.stmts.objInsert.run(n.repoId,n.hash,n.type,n.content)}),this.batchDeleteTx=e.transaction((t,n,s)=>{let a=0;for(let i of n)this.stmts.objDelete.run(t,i),a++;s(a)})}stmts;batchInsertTx;batchDeleteTx;hasRepo(e){return this.stmts.repoExists.get(e)!==null}insertRepo(e){this.stmts.repoInsert.run(e)}deleteRepo(e){this.stmts.repoDelete.run(e),this.stmts.objDeleteAll.run(e),this.stmts.refDeleteAll.run(e)}getObject(e,t){let n=this.stmts.objRead.get(e,t);return n?{type:n.type,content:new Uint8Array(n.content)}:null}putObject(e,t,n,s){this.stmts.objInsert.run(e,t,n,s)}putObjects(e,t){this.batchInsertTx(t.map(n=>({repoId:e,...n})))}hasObject(e,t){return this.stmts.objExists.get(e,t)!==null}findObjectsByPrefix(e,t){return this.stmts.objPrefix.all(e,`${t}*`).map(s=>s.hash)}listObjectHashes(e){return this.stmts.objListHashes.all(e).map(n=>n.hash)}deleteObjects(e,t){if(t.length===0)return 0;let n=0;return this.batchDeleteTx(e,t,s=>{n+=s}),n}getRef(e,t){let n=this.stmts.refRead.get(e,t);return Qe(n)}putRef(e,t,n){n.type==="symbolic"?this.stmts.refWrite.run(e,t,"symbolic",null,n.target):this.stmts.refWrite.run(e,t,"direct",n.hash,null)}removeRef(e,t){this.stmts.refDelete.run(e,t)}listRefs(e,t){return(t?this.stmts.refList.all(e,`${t}*`):this.stmts.refListAll.all(e)).flatMap(s=>{let a=Qe(s);return a?[{name:s.name,ref:a}]:[]})}atomicRefUpdate(e,t){let n=this.stmts;return this.db.transaction(()=>t({getRef:a=>Qe(n.refRead.get(e,a)),putRef:(a,i)=>{i.type==="symbolic"?n.refWrite.run(e,a,"symbolic",null,i.target):n.refWrite.run(e,a,"direct",i.hash,null)},removeRef:a=>{n.refDelete.run(e,a)}}))()}};function Qe(r){return r?r.type==="symbolic"&&r.target?{type:"symbolic",target:r.target}:r.type==="direct"&&r.hash?{type:"direct",hash:r.hash}:null:null}function Rn(r){return{query:(e,t)=>r.query(e,t),async transaction(e){let t=await r.connect();try{await t.query("BEGIN");let s=await e({query:(a,i)=>t.query(a,i),transaction:()=>{throw new Error("nested transactions not supported")}});return await t.query("COMMIT"),s}catch(n){throw await t.query("ROLLBACK"),n}finally{t.release()}}}}var xn=`
|
|
80
81
|
CREATE TABLE IF NOT EXISTS repos (
|
|
81
82
|
id TEXT PRIMARY KEY
|
|
82
83
|
);
|
|
@@ -97,5 +98,5 @@ CREATE TABLE IF NOT EXISTS git_refs (
|
|
|
97
98
|
target TEXT,
|
|
98
99
|
PRIMARY KEY (repo_id, name)
|
|
99
100
|
);
|
|
100
|
-
`,
|
|
101
|
-
ON CONFLICT (repo_id, name) DO UPDATE SET type = EXCLUDED.type, hash = EXCLUDED.hash, target = EXCLUDED.target`,refDelete:"DELETE FROM git_refs WHERE repo_id = $1 AND name = $2",refList:"SELECT name, type, hash, target FROM git_refs WHERE repo_id = $1 AND name LIKE $2",refListAll:"SELECT name, type, hash, target FROM git_refs WHERE repo_id = $1",refDeleteAll:"DELETE FROM git_refs WHERE repo_id = $1"},
|
|
101
|
+
`,k={repoInsert:"INSERT INTO repos (id) VALUES ($1)",repoExists:"SELECT 1 FROM repos WHERE id = $1 LIMIT 1",repoDelete:"DELETE FROM repos WHERE id = $1",objInsert:"INSERT INTO git_objects (repo_id, hash, type, content) VALUES ($1, $2, $3, $4) ON CONFLICT DO NOTHING",objRead:"SELECT type, content FROM git_objects WHERE repo_id = $1 AND hash = $2",objExists:"SELECT 1 FROM git_objects WHERE repo_id = $1 AND hash = $2 LIMIT 1",objPrefix:"SELECT hash FROM git_objects WHERE repo_id = $1 AND hash LIKE $2",objDeleteAll:"DELETE FROM git_objects WHERE repo_id = $1",objListHashes:"SELECT hash FROM git_objects WHERE repo_id = $1",refRead:"SELECT type, hash, target FROM git_refs WHERE repo_id = $1 AND name = $2",refReadForUpdate:"SELECT type, hash, target FROM git_refs WHERE repo_id = $1 AND name = $2 FOR UPDATE",refWrite:`INSERT INTO git_refs (repo_id, name, type, hash, target) VALUES ($1, $2, $3, $4, $5)
|
|
102
|
+
ON CONFLICT (repo_id, name) DO UPDATE SET type = EXCLUDED.type, hash = EXCLUDED.hash, target = EXCLUDED.target`,refDelete:"DELETE FROM git_refs WHERE repo_id = $1 AND name = $2",refList:"SELECT name, type, hash, target FROM git_refs WHERE repo_id = $1 AND name LIKE $2",refListAll:"SELECT name, type, hash, target FROM git_refs WHERE repo_id = $1",refDeleteAll:"DELETE FROM git_refs WHERE repo_id = $1"},rt=class r{constructor(e){this.db=e}static async create(e){return await e.query(xn),new r(e)}async hasRepo(e){let{rows:t}=await this.db.query(k.repoExists,[e]);return t.length>0}async insertRepo(e){await this.db.query(k.repoInsert,[e])}async deleteRepo(e){await this.db.query(k.repoDelete,[e]),await this.db.query(k.objDeleteAll,[e]),await this.db.query(k.refDeleteAll,[e])}async getObject(e,t){let{rows:n}=await this.db.query(k.objRead,[e,t]),s=n[0];return s?{type:s.type,content:new Uint8Array(s.content)}:null}async putObject(e,t,n,s){await this.db.query(k.objInsert,[e,t,n,s])}async putObjects(e,t){await this.db.transaction(async n=>{for(let s of t)await n.query(k.objInsert,[e,s.hash,s.type,s.content])})}async hasObject(e,t){let{rows:n}=await this.db.query(k.objExists,[e,t]);return n.length>0}async findObjectsByPrefix(e,t){let{rows:n}=await this.db.query(k.objPrefix,[e,`${t}%`]);return n.map(s=>s.hash)}async listObjectHashes(e){let{rows:t}=await this.db.query(k.objListHashes,[e]);return t.map(n=>n.hash)}async deleteObjects(e,t){if(t.length===0)return 0;let{rows:n}=await this.db.query("DELETE FROM git_objects WHERE repo_id = $1 AND hash = ANY($2::text[]) RETURNING hash",[e,Array.from(t)]);return n.length}async getRef(e,t){let{rows:n}=await this.db.query(k.refRead,[e,t]);return tt(n[0]??null)}async putRef(e,t,n){n.type==="symbolic"?await this.db.query(k.refWrite,[e,t,"symbolic",null,n.target]):await this.db.query(k.refWrite,[e,t,"direct",n.hash,null])}async removeRef(e,t){await this.db.query(k.refDelete,[e,t])}async listRefs(e,t){let n;return t?{rows:n}=await this.db.query(k.refList,[e,`${t}%`]):{rows:n}=await this.db.query(k.refListAll,[e]),n.flatMap(s=>{let a=tt(s);return a?[{name:s.name,ref:a}]:[]})}async atomicRefUpdate(e,t){return this.db.transaction(async n=>t({getRef:async s=>{let{rows:a}=await n.query(k.refReadForUpdate,[e,s]);return tt(a[0]??null)},putRef:async(s,a)=>{a.type==="symbolic"?await n.query(k.refWrite,[e,s,"symbolic",null,a.target]):await n.query(k.refWrite,[e,s,"direct",a.hash,null])},removeRef:async s=>{await n.query(k.refDelete,[e,s])}}))}};function tt(r){return r?r.type==="symbolic"&&r.target?{type:"symbolic",target:r.target}:r.type==="direct"&&r.hash?{type:"direct",hash:r.hash}:null:null}export{et as BetterSqlite3Storage,Je as BunSqliteStorage,Ve as MemoryStorage,rt as PgStorage,le as advertiseRefsWithHooks,V as applyReceivePack,$e as buildRefAdvertisementBytes,_e as buildRefListBytes,ve as buildRefListPktLines,er as collectRefs,fr as composeHooks,dn as createServer,de as handleUploadPack,We as ingestReceivePack,Ge as ingestReceivePackFromStream,Fe as resolveRefUpdates,Rn as wrapPgPool};
|