just-git 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/repo/index.js +7 -7
- package/dist/server/index.d.ts +145 -54
- package/dist/server/index.js +39 -38
- package/package.json +7 -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 ar=new TextEncoder;function ve(r){return typeof r=="string"?ar.encode(r):r}function or(){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=or(),G=at;async function ot(r){return at().update(r).hex()}var ir=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(!ir.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,cr=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]),fr=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 cr(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:lr}=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 dr=J(Q,9,1),pr=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,ur=(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=dr,h=pr,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[fr[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=lr[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?ur(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 hr(){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 yr=null;function bt(){return yr??=hr()}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 br(r,o);i.push(l),o=l.nextOffset}return(await mr(i,e)).map((c,l)=>({...c,offset:i[l].headerOffset,nextOffset:i[l].nextOffset}))}async function br(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 mr(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 gr(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 gr(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=Rr(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 xr(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 wr(o,f)}yield ye(await t.hex())}async function xr(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 Rr(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 wr(r,e){let t=new Uint8Array(r.byteLength+e.byteLength);return t.set(r,0),t.set(e,r.byteLength),t}var Pr=new TextEncoder;async function q(r,e){let t=Pr.encode(`${r} ${e.byteLength}\0`),n=G();return n.update(t),n.update(e),n.hex()}var Or=new TextEncoder,Sn=new TextDecoder;function jt(r,e){let t=Or.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,kr=new TextDecoder;function re(r){let e=kr.decode(r),t=e.indexOf(`
|
|
1
|
+
var ye=(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 J="0000000000000000000000000000000000000000",at=(()=>{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+=at[r[t]];return e}function Q(r,e){let t="";for(let n=0;n<20;n++)t+=at[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=ye(["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 o=await crypto.subtle.digest("SHA-1",n);return be(new Uint8Array(o))}};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 o=t[s];o<t[s+1];++o)n[o]=o-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 ee=(r,e,t)=>{let n=r.length,s=0,o=new F(e);for(;s<n;++s)r[s]&&++o[r[s]-1];let i=new F(e);for(s=1;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;let a;if(t){a=new F(1<<e);let l=15-e;for(s=0;s<n;++s)if(r[s]){let c=s<<4|r[s],f=e-r[s],d=i[r[s]-1]++<<f;for(let p=d|(1<<f)-1;d<=p;++d)a[Ie[d]>>l]=c}}else for(a=new F(n),s=0;s<n;++s)r[s]&&(a[s]=Ie[i[r[s]-1]++]>>15-r[s]);return a},te=new L(288);for(let r=0;r<144;++r)te[r]=8;for(let r=144;r<256;++r)te[r]=9;for(let r=256;r<280;++r)te[r]=7;for(let r=280;r<288;++r)te[r]=8;var ut=new L(32);for(let r=0;r<32;++r)ut[r]=5;var br=ee(te,9,1),mr=ee(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,o=n?n.length:0;if(!s||e.f&&!e.l)return t||new L(0);let i=!t,a=i||e.i!=2,l=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}},f=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){f=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=ee(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 ot=0,he=0;for(Z==16?(he=3+U(r,d,3),d+=2,ot=P[N-1]):Z==17?(he=3+U(r,d,7),d+=3):Z==18&&(he=11+U(r,d,127),d+=7);he--;)P[N++]=ot}}let $=P.subarray(0,x),nt=P.subarray(x);m=Se($),R=Se(nt),u=ee($,m,1),h=ee(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){l&&H(0);break}a&&c(p+O),t.set(r.subarray(x,j),p),e.b=p+=O,e.p=d=j*8,e.f=f;continue}if(d>b){l&&H(0);break}}a&&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){l&&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){l&&H(0);break}a&&c(p+131072);let B=p+O;if(p<A){let I=o-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=f,u&&(f=1,e.m=m,e.d=h,e.n=R)}while(!f);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=ye(["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=o=>{let i=r.inflateSync(o,{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"),o=s.writable.getWriter();return o.write(n),o.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,re=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=Q(r,r.byteLength-20),f=G();f.update(r.subarray(0,r.byteLength-20));let d=await f.hex();if(d!==c)throw new Error(`pack checksum mismatch: expected ${c}, computed ${d}`)}let o=t.getUint32(8),i=[],a=12;for(let c=0;c<o;c++){let f=await wr(r,a);i.push(f),a=f.nextOffset}return(await Er(i,e)).map((c,f)=>({...c,offset:i[f].headerOffset,nextOffset:i[f].nextOffset}))}async function wr(r,e){let t=e,n=r[e++],s=n>>4&7,o=n&15,i=4;for(;n&128;)n=r[e++],o|=(n&127)<<i,i+=7;let a,l;if(s===_){let d=r[e++];for(a=d&127;d&128;)a+=1,d=r[e++],a=(a<<7)+(d&127);a=t-a}else s===re&&(l=Q(r,e),e+=20);let{result:c,bytesConsumed:f}=await Ue(r.subarray(e),o);return{headerOffset:t,typeNum:s,inflated:c,baseOffset:a,baseHash:l,nextOffset:e+f}}var Rt=50;async function Er(r,e){let t=new Map;for(let o=0;o<r.length;o++)t.set(r[o].headerOffset,o);let n=new Array(r.length).fill(null);async function s(o,i=0){if(i>Rt)throw new Error(`delta chain depth ${i} exceeds limit of ${Rt}`);let a=n[o];if(a)return a;let l=r[o];if(l.typeNum!==_&&l.typeNum!==re){let u=vt[l.typeNum];if(!u)throw new Error(`Unknown object type: ${l.typeNum}`);let h={type:u,content:l.inflated,hash:await q(u,l.inflated)};return n[o]=h,h}if(l.typeNum===_){let u=t.get(l.baseOffset);if(u===void 0)throw new Error(`OFS_DELTA base not found at offset ${l.baseOffset}`);let h=await s(u,i+1),m=xe(h.content,l.inflated),R={type:h.type,content:m,hash:await q(h.type,m)};return n[o]=R,R}let c=await Or(r,n,l.baseHash,s),f;if(c!==void 0)f=await s(c,i+1);else if(e){let u=await e(l.baseHash);u&&(f=u)}if(!f)throw new Error(`REF_DELTA base not found for hash ${l.baseHash}`);let d=xe(f.content,l.inflated),p={type:f.type,content:d,hash:await q(f.type,d)};return n[o]=p,p}for(let o=0;o<r.length;o++)await s(o);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 o=r[s];if(o.typeNum!==_&&o.typeNum!==re&&(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),o=s.getUint32(0);if(o!==z)throw new Error(`Invalid pack signature: 0x${o.toString(16)} (expected 0x${z.toString(16)})`);let i=s.getUint32(4);if(i!==we)throw new Error(`Unsupported pack version: ${i}`);let a=s.getUint32(8),l=new Map,c=new Map;for(let p=0;p<a;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===re){let x=await t.readExact(20);g=Q(x,0)}let w=await t.inflateNext(R),E;if(m!==_&&m!==re){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=l.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)}}l.set(u,E),c.set(E.hash,E),yield E}let f=Q(await t.readRaw(20),0),d=await t.hashHex();if(d!==f)throw new Error(`pack checksum mismatch: expected ${f}, 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:o,newPos:i}=xt(e,t);t=i;let a=new Uint8Array(o),l=0;for(;t<e.byteLength;){let c=e[t++];if(c&128){let f=0,d=0;c&1&&(f=e[t++]),c&2&&(f|=e[t++]<<8),c&4&&(f|=e[t++]<<16),c&8&&(f|=e[t++]<<24),c&16&&(d=e[t++]),c&32&&(d|=e[t++]<<8),c&64&&(d|=e[t++]<<16),d===0&&(d=65536),a.set(r.subarray(f,f+d),l),l+=d}else if(c>0)a.set(e.subarray(t,t+c),l),l+=c,t+=c;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(l!==o)throw new Error(`Delta produced ${l} bytes, expected ${o}`);return a}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 o=12,i=[];for(let a of r){let l=o;t.set(a.hash,o);let c=a.delta&&a.deltaBaseHash?t.get(a.deltaBaseHash):void 0;if(a.delta&&c!==void 0){let f=Ce(_,a.delta.byteLength),d=vr(o-c),p=await Re(a.delta);e.push(f,d,p),o+=f.byteLength+d.byteLength+p.byteLength}else{let f=kt[a.type],d=Ce(f,a.content.byteLength),p=await Re(a.content);e.push(d,p),o+=d.byteLength+p.byteLength}i.push({hash:a.hash,offset:l,nextOffset:o})}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 o of e){let i=kt[o.type],a=Ce(i,o.content.byteLength),l=await Re(o.content);t.update(a),t.update(l),yield kr(a,l)}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 o=await s.hex();return t.set(me(o),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,Hn=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 ne(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),o=r.slice(t+2),[i="0",a="+0000"]=o.split(" "),l=parseInt(i,10);return{name:n,email:s,timestamp:l,timezone:a}}var Bn=new TextEncoder,Ir=new TextDecoder;function se(r){let e=Ir.decode(r),t=e.indexOf(`
|
|
2
2
|
|
|
3
|
-
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),
|
|
4
|
-
`)){let
|
|
3
|
+
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),o="",i=[],a,l;for(let c of n.split(`
|
|
4
|
+
`)){let f=c.indexOf(" ");if(f===-1)continue;let d=c.slice(0,f),p=c.slice(f+1);switch(d){case"tree":o=p;break;case"parent":i.push(p);break;case"author":a=ne(p);break;case"committer":l=ne(p);break}}if(!o)throw new Error("Commit missing tree field");if(!a)throw new Error("Commit missing author field");if(!l)throw new Error("Commit missing committer field");return{type:"commit",tree:o,parents:i,author:a,committer:l,message:s}}var Wn=new TextEncoder,Tr=new TextDecoder;function W(r){let e=Tr.decode(r),t=e.indexOf(`
|
|
5
5
|
|
|
6
|
-
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),
|
|
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 Sr=[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 jr(r,e,t){let n=0,s=!1,a=e;for(;a<r.length;a++){let o=r.charCodeAt(a);switch(o<128?Sr[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}=jr(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,Ar=new Set(["100644","100755","040000","120000","160000"]);function Ir(r){return r.length===4&&r.toLowerCase()===".git"}function Tr(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(Ir(r))throw new Error(`invalid tree entry: '${r}'`);if(!Ar.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");Tr(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]),Ur=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,Lr=4,De=4096,Lt=65536,Cr=127;function Hr(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=Nr(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 Dr(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^=Ur[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<Lr)f(2),l===0&&o++,i[o++]=e[p++],l++,l===Cr&&(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=Dr(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(Hr(l.content)),f.push(l.hash)}return i}function Nr(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 Br=2147483647;async function Nt(r,e,t,n){if(t>=Br)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:Mr(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:$r(r,i)}}async function*Mr(r){for(let e of r)yield e}async function*$r(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 Wr=new TextEncoder,Wt=new TextDecoder,$t=65520,_r=new Uint8Array([48,48,48,48]);function k(r){let e=typeof r=="string"?Wr.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 _r.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
|
|
10
|
-
`)):n.push(
|
|
11
|
-
`))}return n.push(D()),
|
|
12
|
-
`),D()),
|
|
13
|
-
`));for(let
|
|
14
|
-
`));s.push(D())}if(t&&t.length>0){for(let i of t)s.push(
|
|
15
|
-
`));let
|
|
16
|
-
`)),s.push(
|
|
17
|
-
`))}else s.push(
|
|
18
|
-
`));if(e){let
|
|
19
|
-
`));for(let t of r.unshallow)e.push(
|
|
20
|
-
`));return e.push(D()),
|
|
21
|
-
`));for(let i of n.unshallow)
|
|
22
|
-
`));
|
|
23
|
-
`));let
|
|
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:
|
|
6
|
+
`),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+2),o="",i="commit",a="",l;for(let c of n.split(`
|
|
7
|
+
`)){let f=c.indexOf(" ");if(f===-1)continue;let d=c.slice(0,f),p=c.slice(f+1);switch(d){case"object":o=p;break;case"type":i=p;break;case"tag":a=p;break;case"tagger":l=ne(p);break}}if(!o)throw new Error("Tag missing object field");if(!a)throw new Error("Tag missing tag name field");if(!l)throw new Error("Tag missing tagger field");return{type:"tag",object:o,objectType:i,name:a,tagger:l,message:s}}async function oe(r,e){return r.objectStore.read(e)}async function ae(r,e){return r.objectStore.exists(e)}var qn=new TextDecoder;async function X(r,e){let t=await oe(r,e);if(t.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${t.type}`);return se(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,o=e;for(;o<r.length;o++){let a=r.charCodeAt(o);switch(a<128?Ur[a]:0){case 1:break;case 2:if(n===46)return{len:-1,starConsumed:s};n=a;continue;case 3:if(n===64)return{len:-1,starConsumed:s};n=a;continue;case 4:return{len:-1,starConsumed:s};case 5:if(!t)return{len:-1,starConsumed:s};s=!0,n=a;continue;default:n=a;continue}break}let i=o-e;return i===0?{len:0,starConsumed:s}:r.charCodeAt(e)===46?{len:-1,starConsumed:s}:i>=He.length&&r.slice(o-He.length,o)===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:o,starConsumed:i}=Lr(r,t,s);if(o<0||o===0)return!1;i&&(s=!1),n++,t+=o+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 Vn=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)),o=r.indexOf(0,n+1);if(o===-1)break;let i=Ct.decode(r.subarray(n+1,o)),a=r.subarray(o+1,o+21),l=be(a),c=s.padStart(6,"0");Mr(i,c),e.push({mode:c,name:i,hash:l}),t=o+21}return{type:"tree",entries:e}}async function Ne(r,e,t){if(e===t)return!0;let n=new Set,s=[t],o=0;for(;o<s.length;){let i=s[o++];if(i===e)return!0;if(n.has(i))continue;n.add(i);let a;try{a=await X(r,i)}catch{continue}for(let l of a.parents)n.has(l)||s.push(l)}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,o=new Uint32Array(n),i=[],a=-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===a)i[i.length-1].ptr=p+16;else{a=u;let h=u&s;i.push({ptr:p+16,val:u}),o[h]++}}let l=new Map;for(let p of i){let u=p.val&s,h=l.get(u);h||(h=[],l.set(u,h)),h.push(p)}for(let[p,u]of l){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)]);l.set(p,h),o[p]=Oe}let c=new Uint32Array(n+1),f=[],d=0;for(let p=0;p<n;p++){c[p]=d;let u=l.get(p);if(u){for(let h of u)f.push(h);d+=u.length}}return c[n]=d,{src:r,hashMask:s,buckets:c,entries:f}}function Gr(r,e,t){if(!r||e.byteLength===0)return null;let n=r.src.byteLength,s=e.byteLength,o=r.src,i=new Uint8Array(Math.max(s,1024)),a=0;function l(m){for(;a+m>i.length;){let R=new Uint8Array(i.length*2);R.set(i),i=R}}a=Nt(i,a,n),a=Nt(i,a,s),l(18),a++;let c=0,f=0,d=Math.min(16,s);for(let m=0;m<d;m++)i[a++]=e[m],c=(c<<8|e[m])^Pe[c>>>23],f++;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=o.byteLength-w,x=s-p;if(E>x&&(E=x),E<=h)break;let O=0;for(;O<E&&o[w+O]===e[p+O];)O++;if(O>h&&(h=O,u=w,h>=Me))break}}if(h<$r)l(2),f===0&&a++,i[a++]=e[p++],f++,f===_r&&(i[a-f-1]=f,f=0),h=0;else{if(f>0){for(;u>0&&o[u-1]===e[p-1];)if(h++,u--,p--,a--,!(--f>0)){a--,f=-1;break}f>0&&(i[a-f-1]=f),f=0}let m=h>Ht?h-Ht:0;h-=m,l(8);let R=a++,b=128;if(u&255&&(i[a++]=u&255,b|=1),u&65280&&(i[a++]=u>>>8&255,b|=2),u&16711680&&(i[a++]=u>>>16&255,b|=4),u&4278190080&&(i[a++]=u>>>24&255,b|=8),h&255&&(i[a++]=h&255,b|=16),h&65280&&(i[a++]=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&&a>t)return null}return f>0&&(i[a-f-1]=f),t&&a>t?null:i.subarray(0,a)}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,f)=>{let d=Dt[c.type]??99,p=Dt[f.type]??99;return d!==p?d-p:f.content.byteLength-c.content.byteLength}),o=new Map,i=[],a=[],l=[];for(let c=0;c<s.length;c++){let f=s[c],d={hash:f.hash,type:f.type,content:f.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!==f.type||(o.get(R.hash)?.depth??0)>=n||f.content.byteLength<R.content.byteLength>>>5)continue;let g=a[m-h]??null;if(!g)continue;let w=p?p.byteLength:f.content.byteLength/2|0;if(w<16)continue;let E=Gr(g,f.content,w);E&&(!p||E.byteLength<p.byteLength)&&(p=E,u=R.hash)}if(p&&u){d.delta=p,d.deltaBase=u;let m=o.get(u);d.depth=(m?.depth??0)+1}o.set(f.hash,d),i.push(d),a.length>=t&&(a.shift(),l.shift()),a.push(Wr(f.content)),l.push(f.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,o=[];for(let c of e)!s.has(c)&&await ae(r,c)&&(s.set(c,1),o.push({hash:c,level:1}));let i=new Set,a=0;for(;a<o.length;){let{hash:c,level:f}=o[a++];if(f>=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,f+1),o.push({hash:p,level:f+1}))}let l=[];for(let c of n){let f=s.get(c);f!==void 0&&f<t&&l.push(c)}return{shallow:[...i],unshallow:l}}async function fe(r,e,t,n,s){let o=s??n,i=new Set;for(let f of t)await ie(r,f,i,o);let a=[...e];if(s&&n)for(let f of s)try{let d=await X(r,f);for(let p of d.parents)i.has(p)||a.push(p)}catch{}let l=[],c=new Set;for(let f of a)await ce(r,f,i,c,l,n);return{count:l.length,objects:zr(l)}}async function $t(r,e,t,n,s){let{count:o,objects:i}=await fe(r,e,t,n,s);return{count:o,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 oe(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 ie(r,e,t,n){if(t.has(e)||(t.add(e),!await ae(r,e)))return;let s=await oe(r,e);switch(s.type){case"commit":{let o=se(s.content);if(await ie(r,o.tree,t,n),!n?.has(e))for(let i of o.parents)await ie(r,i,t,n);break}case"tree":{let o=De(s.content);for(let i of o.entries)await ie(r,i.hash,t,n);break}case"tag":{let o=W(s.content);await ie(r,o.object,t,n);break}case"blob":break}}async function ce(r,e,t,n,s,o){if(n.has(e)||t.has(e))return;n.add(e);let i=await oe(r,e);switch(s.push({hash:e,type:i.type}),i.type){case"commit":{let a=se(i.content);if(await ce(r,a.tree,t,n,s,o),!o?.has(e))for(let l of a.parents)await ce(r,l,t,n,s,o);break}case"tree":{let a=De(i.content);for(let l of a.entries)await ce(r,l.hash,t,n,s,o);break}case"tag":{let a=W(i.content);await ce(r,a.object,t,n,s,o);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 o=s.join(" ");if(r.length===0)n.push(v(`0000000000000000000000000000000000000000 capabilities^{}\0${o}
|
|
9
|
+
`));else for(let i=0;i<r.length;i++){let a=r[i];i===0?n.push(v(`${a.hash} ${a.name}\0${o}
|
|
10
|
+
`)):n.push(v(`${a.hash} ${a.name}
|
|
11
|
+
`))}return n.push(D()),M(...n)}function Xt(r,e,t,n){let s=M(v(`# service=${e}
|
|
12
|
+
`),D()),o=ve(r,t,n),i=new Uint8Array(s.byteLength+o.byteLength);return i.set(s,0),i.set(o,s.byteLength),i}function Kt(r){let e=Ft(r),t=[],n=[],s=[],o=[],i,a=!1;for(let l of e){if(l.type==="flush")continue;let c=qt(l);if(c.startsWith("want ")){let f=c.slice(5);if(t.length===0){let d=f.indexOf(" ");d!==-1?(t.push(f.slice(0,d)),o=f.slice(d+1).split(" ").filter(Boolean)):t.push(f)}else t.push(f)}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"&&(a=!0)}return{wants:t,haves:n,capabilities:o,clientShallows:s,depth:i,done:a}}function K(r,e,t,n){let s=[];if(n){for(let o of n.shallow)s.push(v(`shallow ${o}
|
|
13
|
+
`));for(let o of n.unshallow)s.push(v(`unshallow ${o}
|
|
14
|
+
`));s.push(D())}if(t&&t.length>0){for(let i of t)s.push(v(`ACK ${i} common
|
|
15
|
+
`));let o=t[t.length-1];s.push(v(`ACK ${o} ready
|
|
16
|
+
`)),s.push(v(`ACK ${o}
|
|
17
|
+
`))}else s.push(v(`NAK
|
|
18
|
+
`));if(e){let o=0;for(;o<r.byteLength;){let i=Math.min(zt,r.byteLength-o);s.push(Be(1,r.subarray(o,o+i))),o+=i}s.push(D())}else{let o=new Uint8Array(r.byteLength);o.set(r),s.push(o)}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 o=[];for(let i of n.shallow)o.push(v(`shallow ${i}
|
|
21
|
+
`));for(let i of n.unshallow)o.push(v(`unshallow ${i}
|
|
22
|
+
`));o.push(D()),yield M(...o)}let s=[];if(t&&t.length>0){for(let i of t)s.push(v(`ACK ${i} common
|
|
23
|
+
`));let o=t[t.length-1];s.push(v(`ACK ${o} ready
|
|
24
|
+
`)),s.push(v(`ACK ${o}
|
|
25
|
+
`))}else s.push(v(`NAK
|
|
26
|
+
`));if(yield M(...s),e){for await(let o of r){let i=0;for(;i<o.byteLength;){let a=Math.min(zt,o.byteLength-i);yield Be(1,o.subarray(i,i+a)),i+=a}}yield D()}else for await(let o of r)yield o}function Zt(r){let e=new TextDecoder,t=[],n=[],s=0,o=!1;for(;s<r.byteLength&&!(s+4>r.byteLength);){let a=e.decode(r.subarray(s,s+4)),l=parseInt(a,16);if(Number.isNaN(l))break;if(l===0){o=!0,s+=4;break}if(l<4||s+l>r.byteLength)break;let c=r.subarray(s+4,s+l);s+=l;let f=c.indexOf(0),d;if(f!==-1)d=e.decode(c.subarray(0,f)),n=e.decode(c.subarray(f+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:o}}function Y(r,e,t){let n=[];n.push(v(r?`unpack ok
|
|
28
28
|
`:`unpack error
|
|
29
|
-
`));for(let
|
|
30
|
-
`)):n.push(
|
|
31
|
-
`));n.push(D());let s=
|
|
32
|
-
`),128;let{service:
|
|
33
|
-
`),128;let{repo:u,repoId:h}=p,m=await
|
|
34
|
-
`),128;await
|
|
35
|
-
`),128}finally{try{await
|
|
36
|
-
`)&&(
|
|
37
|
-
`)),128;try{
|
|
29
|
+
`));for(let o of e)o.ok?n.push(v(`ok ${o.name}
|
|
30
|
+
`)):n.push(v(`ng ${o.name} ${o.error??"failed"}
|
|
31
|
+
`));n.push(D());let s=M(...n);if(t){let o=[];return o.push(Be(1,s)),o.push(D()),M(...o)}return s}function Be(r,e){let t=new Uint8Array(1+e.byteLength);return t[0]=r,t.set(e,1),v(t)}var le=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,o;if(t)if(t.type==="symbolic"){o=t.target;let a=await r.refStore.readRef(t.target);a?.type==="direct"&&(s=a.hash)}else s=t.hash;let i=e.slice().sort((a,l)=>a.name<l.name?-1:a.name>l.name?1:0);if(!s&&i.length>0){let a=Zr(i);a&&(s=a.hash,o=a.name)}s&&n.push({name:"HEAD",hash:s});for(let a of i)if(n.push({name:a.name,hash:a.hash}),a.name.startsWith("refs/tags/"))try{let l=await r.objectStore.read(a.hash);if(l.type==="tag"){let c=W(l.content);n.push({name:`${a.name}^{}`,hash:c.object})}}catch{}return{refs:n,headTarget:o}}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 de(r,e,t,n,s){let{refs:o,headTarget:i}=await er(r),a=o;if(n?.advertiseRefs){let l=await n.advertiseRefs({repo:r,repoId:e,refs:o,service:t,session:s});if(T(l))return l;l&&(a=l)}return{refs:a,headTarget:i}}async function pe(r,e,t){let{wants:n,haves:s,capabilities:o,clientShallows:i,depth:a,done:l}=Kt(e);if(n.length===0)return K(new Uint8Array(0),!1);let c=o.includes("multi_ack_detailed"),f=o.includes("side-band-64k"),d,p,u;if(i.length>0&&(u=new Set(i)),a!==void 0){let R=await Bt(r,n,a,u??new Set);d=R,p=new Set(R.shallow)}if(d&&!l)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?le.key(t.cacheKey,n,s):null;if(m&&t?.cache){let R=t.cache.get(m);if(R)return K(R.packData,f,h)}return t?.noDelta?Jr(r,n,s,o,f,h,d,p,u):Qr(r,n,s,o,f,h,t,m,d,p,u)}async function Jr(r,e,t,n,s,o,i,a,l){let{count:c,objects:f}=await fe(r,e,t,a,l);if(c===0){let{data:y}=await Ee([]),g=K(y,s,o,i);return new ReadableStream({start(w){w.enqueue(g),w.close()}})}let d=[];for await(let y of f)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,o,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,o,i,a,l,c,f){let d=await $t(r,e,t,c,f);if(d.count===0){let{data:y}=await Ee([]);return K(y,s,o,l)}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(a&&i?.cache){let y=m.filter(g=>g.delta).length;i.cache.set(a,{packData:b,objectCount:p.length,deltaCount:y})}return K(b,s,o,l)}async function We(r,e){let{commands:t,packData:n,capabilities:s,sawFlush:o}=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:o}}async function Ge(r,e,t,n,s=!0){let o=!0;if(e.some(l=>l.newHash!==J))try{let c=St(n,async f=>{try{return await r.objectStore.read(f)}catch{return null}});await r.objectStore.ingestPackStream(c)}catch{o=!1}return{updates:await tr(r,e,o),unpackOk:o,capabilities:t,sawFlush:s}}async function tr(r,e,t){let n=[];for(let s of e){let o=s.oldHash===J,i=s.newHash===J,a=!1;if(!o&&!i&&t)try{a=await Ne(r,s.oldHash,s.newHash)}catch{}n.push({ref:s.refName,oldHash:o?null:s.oldHash,newHash:s.newHash,isFF:a,isCreate:o,isDelete:i})}return n}async function V(r){let{repo:e,repoId:t,ingestResult:n,hooks:s,session:o}=r,{updates:i}=n;if(s?.preReceive){let c=await s.preReceive({repo:e,repoId:t,updates:i,session:o});if(T(c)){let f=c.message??"pre-receive hook declined";return{refResults:i.map(d=>({ref:d.ref,ok:!1,error:f})),applied:[]}}}let a=[],l=[];for(let c of i){if(c.ref==="HEAD"){a.push({ref:c.ref,ok:!1,error:"HEAD cannot be updated via push"});continue}if(!c.isDelete&&!Ut(c.ref)){a.push({ref:c.ref,ok:!1,error:"invalid refname"});continue}if(s?.update){let f=await s.update({repo:e,repoId:t,update:c,session:o});if(T(f)){a.push({ref:c.ref,ok:!1,error:f.message??"update hook declined"});continue}}if(!c.isDelete&&!await e.objectStore.exists(c.newHash)){a.push({ref:c.ref,ok:!1,error:"missing objects"});continue}try{let f=c.isCreate?null:c.oldHash,d=c.isDelete?null:{type:"direct",hash:c.newHash};if(!await e.refStore.compareAndSwapRef(c.ref,f,d)){a.push({ref:c.ref,ok:!1,error:"failed to lock"});continue}a.push({ref:c.ref,ok:!0}),l.push(c)}catch(f){a.push({ref:c.ref,ok:!1,error:f instanceof Error?f.message:String(f)})}}if(s?.postReceive&&l.length>0)try{await s.postReceive({repo:e,repoId:t,updates:l,session:o})}catch{}return{refResults:a,applied:l}}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 o=s===null,i=n.newHash===null,a=n.newHash??J,l=!1;if(!o&&!i)try{l=await Ne(r,s,a)}catch{}t.push({ref:n.ref,oldHash:s,newHash:a,isFF:l,isCreate:o,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:o,packOptions:i,session:a}=t,l=e.writable.getWriter();try{let c=en(r);if(!c)return ke(e,`fatal: unrecognized command '${r}'
|
|
32
|
+
`),128;let{service:f,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 de(u,h,f,s,a);if(T(m))return ke(e,`fatal: ${m.message??"access denied"}
|
|
34
|
+
`),128;await l.write(_e(m.refs,f,m.headTarget));let R=new qe(e.readable);try{if(f==="git-upload-pack"){let b=await nn(R),y=await pe(u,b,{cache:o,cacheKey:h,noDelta:i?.noDelta,deltaWindow:i?.deltaWindow});await an(l,y)}else{let{commands:b,capabilities:y}=await sn(R),g=R.streamRemaining();await rn({writer:l,repo:u,repoId:h,commands:b,capabilities:y,packStream:g,hooks:s,session:a})}}finally{R.release()}return 0}catch(c){return t.onError?.(c),ke(e,`fatal: internal error
|
|
35
|
+
`),128}finally{try{await l.close()}catch{}}}async function rn(r){let{writer:e,repo:t,repoId:n,commands:s,capabilities:o,packStream:i,hooks:a,session:l}=r,c=await Ge(t,s,o,i);if(c.updates.length===0)return;let f=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,f))}return}let{refResults:p}=await V({repo:t,repoId:n,ingestResult:c,hooks:a,session:l});if(d){let u=p.map(h=>({name:h.ref,ok:h.ok,error:h.error}));await e.write(Y(!0,u,f))}}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 on(e)}async function sn(r){let e=[],t=[],n=!0;for(;;){let s=await r.readPktLine();if(!s||s.type==="flush")break;let o=s.text;if(o.endsWith(`
|
|
36
|
+
`)&&(o=o.slice(0,-1)),n){let a=o.indexOf("\0");a!==-1&&(t=o.slice(a+1).split(" ").filter(Boolean),o=o.slice(0,a)),n=!1}let i=o.split(" ");i.length>=3&&e.push({oldHash:i[0],newHash:i[1],refName:i[2]})}return{commands:e,capabilities:t}}function on(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 an(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 or(r,e,t,n){let s=n?.dryRun??!1,o=await sr(r),i=cn(o);if(i.length===0)return{deleted:0,retained:0};let a=await fe(r,i,[]),l=new Set;for await(let u of a.objects)l.add(u.hash);let c=await e.listObjectHashes(t),f=[];for(let u of c)l.has(u)||f.push(u);let d=await sr(r);return fn(o,d)?s||f.length===0?{deleted:f.length,retained:l.size}:{deleted:await e.deleteObjects(t,f),retained:l.size}:{deleted:0,retained:l.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 ar(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 o=n?.defaultBranch??"main";return await r.insertRepo(t),await r.putRef(t,"HEAD",{type:"symbolic",target:`refs/heads/${o}`}),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,a=this.repoId,l=await jt(e,async c=>{let f=await i.getObject(a,c);return f?{type:f.type,content:new Uint8Array(f.content)}:null});return await i.putObjects(a,l.map(c=>({hash:c.hash,type:c.type,content:c.content}))),l.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 o=await Ke(i=>this.driver.getRef(this.repoId,i),s.ref.target);o&&n.push({name:s.name,hash:o})}return n}async compareAndSwapRef(e,t,n){return!!await this.driver.atomicRefUpdate(this.repoId,s=>ue(s.getRef(e),o=>{let i=o?o.type==="direct"?o.hash:Ke(a=>s.getRef(a),o.target):null;return ue(i,a=>{if(t===null){if(o!==null)return!1}else if(a!==t)return!1;return n===null?ue(s.removeRef(e),()=>!0):ue(s.putRef(e,n),()=>!0)})}))}};function ue(r,e){return r instanceof Promise?r.then(e):e(r)}function Ke(r,e,t=0){return t>10?null:ue(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=ar(r.storage),t=r.resolve??(b=>b),n=r.autoCreate,{basePath:s}=r;async function o(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),a=r.session??ln,l=r.packCache===!1?void 0:new le(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}`)}),f=!1,d=0,p=null,u=null;function h(){return f?!1:(d++,!0)}function m(){d--,f&&d===0&&p?.()}let R={async fetch(b){if(!h())return new Response("Service Unavailable",{status:503});let y;try{if(!a.http)return new Response("HTTP session builder not configured",{status:501});let g=await a.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 o(O);if(!j)return new Response("Not Found",{status:404});let P=await de(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 o(x);if(!O)return new Response("Not Found",{status:404});let j=await cr(b),P=await pe(O.repo,j,{cache:l,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 o(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(!a.ssh)return y.writeStderr?.(new TextEncoder().encode(`fatal: SSH session builder not configured
|
|
38
|
+
`)),128;let w=await a.ssh(g??{});return await nr(b,y,{resolveRepo:o,hooks:i,packCache:l,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 or(g,r.storage,b,y)}finally{m()}},get closed(){return f},asNetwork(b="http://git"){return{allowed:[b.endsWith("/")?b:`${b}/`],fetch:(g,w)=>R.fetch(new Request(g,w))}},async close(b){if(f)return u??Promise.resolve();if(f=!0,l?.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",o=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 a=e.method??"GET",l;if(a!=="GET"&&a!=="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;l=h}let c=new Request(o.href,{method:a,headers:i,body:l}),f=await r.fetch(c),d={};f.headers.forEach((u,h)=>{d[h]=u}),n.writeHead(f.status,d);let p=new Uint8Array(await f.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,o=new Set(e.map(a=>a.startsWith("refs/")?a:`refs/heads/${a}`)),i={};return o.size>0&&(i.preReceive=async a=>{for(let l of a.updates)if(o.has(l.ref)){if(l.isDelete)return{reject:!0,message:`cannot delete protected branch ${l.ref}`};if(!l.isCreate&&!l.isFF)return{reject:!0,message:`non-fast-forward push to protected branch ${l.ref}`}}}),(t||n||s)&&(i.update=async a=>{if(n&&a.update.isDelete)return{reject:!0,message:"ref deletion denied"};if(s&&a.update.ref.startsWith("refs/tags/")){if(a.update.isDelete)return{reject:!0,message:"tag deletion denied"};if(!a.update.isCreate)return{reject:!0,message:"tag overwrite denied"}}if(t&&!a.update.isCreate&&!a.update.isDelete&&!a.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(a=>a!=null);if(e.length===0)return{};if(e.length===1)return e[0];let t={},n=e.filter(a=>a.preReceive).map(a=>a.preReceive);n.length>0&&(t.preReceive=async a=>{for(let l of n){let c=await l(a);if(T(c))return c}});let s=e.filter(a=>a.update).map(a=>a.update);s.length>0&&(t.update=async a=>{for(let l of s){let c=await l(a);if(T(c))return c}});let o=e.filter(a=>a.postReceive).map(a=>a.postReceive);o.length>0&&(t.postReceive=async a=>{for(let l of o)try{await l(a)}catch{}});let i=e.filter(a=>a.advertiseRefs).map(a=>a.advertiseRefs);return i.length>0&&(t.advertiseRefs=async a=>{let l=a.refs;for(let c of i){let f=await c({...a,refs:l});if(T(f))return f;f&&(l=f)}return l}),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 o=this.getObjMap(e);o.has(t)||o.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 o of t)n.delete(o)&&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,o]of this.getRefMap(e))t&&!s.startsWith(t)||n.push({name:s,ref:o});return n}atomicRefUpdate(e,t){let n=this.getRefMap(e);return t({getRef:s=>n.get(s)??null,putRef:(s,o)=>{n.set(s,o)},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 o=0;for(let i of n)this.stmts.objDelete.run(t,i),o++;s(o)})}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 o=Ze(s);return o?[{name:s.name,ref:o}]:[]})}atomicRefUpdate(e,t){let n=this.stmts;return this.db.transaction(()=>t({getRef:o=>Ze(n.refRead.get(e,o)),putRef:(o,i)=>{i.type==="symbolic"?n.refWrite.run(e,o,"symbolic",null,i.target):n.refWrite.run(e,o,"direct",i.hash,null)},removeRef:o=>{n.refDelete.run(e,o)}}))()}};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 o=0;for(let i of n)this.stmts.objDelete.run(t,i),o++;s(o)})}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 o=Qe(s);return o?[{name:s.name,ref:o}]:[]})}atomicRefUpdate(e,t){let n=this.stmts;return this.db.transaction(()=>t({getRef:o=>Qe(n.refRead.get(e,o)),putRef:(o,i)=>{i.type==="symbolic"?n.refWrite.run(e,o,"symbolic",null,i.target):n.refWrite.run(e,o,"direct",i.hash,null)},removeRef:o=>{n.refDelete.run(e,o)}}))()}};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}var Rn=`
|
|
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.pool=e}static async create(e){return await e.query(Rn),new r(e)}async transaction(e){let t=await this.pool.connect();try{await t.query("BEGIN");let n=await e((s,o)=>t.query(s,o));return await t.query("COMMIT"),n}catch(n){throw await t.query("ROLLBACK"),n}finally{t.release()}}async hasRepo(e){let{rows:t}=await this.pool.query(k.repoExists,[e]);return t.length>0}async insertRepo(e){await this.pool.query(k.repoInsert,[e])}async deleteRepo(e){await this.pool.query(k.repoDelete,[e]),await this.pool.query(k.objDeleteAll,[e]),await this.pool.query(k.refDeleteAll,[e])}async getObject(e,t){let{rows:n}=await this.pool.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.pool.query(k.objInsert,[e,t,n,s])}async putObjects(e,t){await this.transaction(async n=>{for(let s of t)await n(k.objInsert,[e,s.hash,s.type,s.content])})}async hasObject(e,t){let{rows:n}=await this.pool.query(k.objExists,[e,t]);return n.length>0}async findObjectsByPrefix(e,t){let{rows:n}=await this.pool.query(k.objPrefix,[e,`${t}%`]);return n.map(s=>s.hash)}async listObjectHashes(e){let{rows:t}=await this.pool.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.pool.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.pool.query(k.refRead,[e,t]);return tt(n[0]??null)}async putRef(e,t,n){n.type==="symbolic"?await this.pool.query(k.refWrite,[e,t,"symbolic",null,n.target]):await this.pool.query(k.refWrite,[e,t,"direct",n.hash,null])}async removeRef(e,t){await this.pool.query(k.refDelete,[e,t])}async listRefs(e,t){let n;return t?{rows:n}=await this.pool.query(k.refList,[e,`${t}%`]):{rows:n}=await this.pool.query(k.refListAll,[e]),n.flatMap(s=>{let o=tt(s);return o?[{name:s.name,ref:o}]:[]})}async atomicRefUpdate(e,t){return this.transaction(async n=>t({getRef:async s=>{let{rows:o}=await n(k.refReadForUpdate,[e,s]);return tt(o[0]??null)},putRef:async(s,o)=>{o.type==="symbolic"?await n(k.refWrite,[e,s,"symbolic",null,o.target]):await n(k.refWrite,[e,s,"direct",o.hash,null])},removeRef:async s=>{await n(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,de as advertiseRefsWithHooks,V as applyReceivePack,$e as buildRefAdvertisementBytes,_e as buildRefListBytes,ve as buildRefListPktLines,er as collectRefs,fr as composeHooks,dn as createServer,pe as handleUploadPack,We as ingestReceivePack,Ge as ingestReceivePackFromStream,Fe as resolveRefUpdates};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "just-git",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "Pure TypeScript git implementation: virtual filesystem client and embeddable server.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"type": "git",
|
|
24
24
|
"url": "git+https://github.com/blindmansion/just-git.git"
|
|
25
25
|
},
|
|
26
|
+
"workspaces": [
|
|
27
|
+
"packages/*"
|
|
28
|
+
],
|
|
26
29
|
"files": [
|
|
27
30
|
"dist"
|
|
28
31
|
],
|
|
@@ -32,14 +35,17 @@
|
|
|
32
35
|
"types": "./dist/index.d.ts",
|
|
33
36
|
"exports": {
|
|
34
37
|
".": {
|
|
38
|
+
"bun": "./src/index.ts",
|
|
35
39
|
"types": "./dist/index.d.ts",
|
|
36
40
|
"import": "./dist/index.js"
|
|
37
41
|
},
|
|
38
42
|
"./server": {
|
|
43
|
+
"bun": "./src/server/index.ts",
|
|
39
44
|
"types": "./dist/server/index.d.ts",
|
|
40
45
|
"import": "./dist/server/index.js"
|
|
41
46
|
},
|
|
42
47
|
"./repo": {
|
|
48
|
+
"bun": "./src/repo/index.ts",
|
|
43
49
|
"types": "./dist/repo/index.d.ts",
|
|
44
50
|
"import": "./dist/repo/index.js"
|
|
45
51
|
}
|