PageSourceSearch

https://octocounts.com/assets/RepoHistoryChart-CXrKYW0O.js

js octocounts.com collected 2026-09-24 13:59:41 UTC 8,287 bytes, 1 lines download raw bytes

1import{u as pe,L as C,f as L,D as me,_ as ee,b as ye,t as ge,A as je,c as be}from"./index-DanONFSR.js";import{r as c,j as e}from"./vendor-react-QBdHTLhB.js";import{u as ve}from"./vendor-query-DvxQDmy6.js";import{u as Le}from"./vendor-i18n-D25i1uPq.js";const Ne={matrix:{bg:"#101713",line:"#55d37a",lineFill:"rgba(85, 211, 122, 0.15)",axis:"#7d9186",count:"#cfead9"},paper:{bg:"#ffffff",line:"#167a3b",lineFill:"rgba(22, 122, 59, 0.15)",axis:"#63706a",count:"#183326"}},m=640,u=220,a={left:48,right:16,top:30,bottom:26},G=m-a.left-a.right,se=u-a.top-a.bottom,I=a.top+se,we=3e3,S=18,Te=5e3;function Ee(i,n,o){const r=Math.max(o-n,1),x=Math.max(...i.map(j=>j.totalLines),1);return i.map(j=>{const y=new Date(j.date+"T00:00:00Z").getTime();return{x:a.left+(y-n)/r*G,y:I-j.totalLines/x*se,point:j}})}function O(i){return i.map((n,o)=>`${o===0?"M":"L"}${n.x.toFixed(1)},${n.y.toFixed(1)}`).join(" ")}function te(i){if(i.length===0)return"";const n=i[0],o=i[i.length-1];return`${O(i)} L${o.x.toFixed(1)},${I} L${n.x.toFixed(1)},${I} Z`}function He(i){if(i.length<2)return null;const n=i.map(o=>new Date(o.date+"T00:00:00Z").getTime()).sort((o,r)=>o-r);return[n[0],n[n.length-1]]}function _e({provider:i,owner:n,repo:o}){const{t:r,i18n:x}=Le(),j=pe(),y=Ne[j],B=i==="github",_=ve({queryKey:["repo-history",i,n,o],queryFn:()=>be(i,n,o),enabled:B,staleTime:60*1e3,retry:!1,refetchInterval:t=>{var l;return(l=t.state.data)!=null&&l.slocBackfillInProgress?Te:!1}}),{data:g,isLoading:ie}=_,T=c.useMemo(()=>g?He(g.slocPoints):null,[g]),s=c.useMemo(()=>g&&T?Ee(g.slocPoints,T[0],T[1]):null,[g,T]),[re,D]=c.useState(0),[ne,F]=c.useState(0),[E,H]=c.useState(null),[U,q]=c.useState(!1),[z,W]=c.useState(null),oe=c.useRef(null),P=c.useRef(null),Z=c.useRef(null),$=c.useRef(null),ae=c.useRef(typeof window<"u"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches),N=s?s[s.length-1].point.totalLines:0;c.useEffect(()=>{if(!s)return;if(ae.current){D(1),F(N);return}D(0),F(0);const t=performance.now();let l=0;const f=p=>{const d=Math.max(0,Math.min((p-t)/1400,1));D(d),F(Math.round(N*d)),d<1&&(l=requestAnimationFrame(f))};return l=requestAnimationFrame(f),()=>cancelAnimationFrame(l)},[s,N]);const le=async()=>{var t;if(!(!s||!P.current)){q(!0),W(null);try{const[{toCanvas:l},{GIFEncoder:f,quantize:p,applyPalette:d}]=await Promise.all([ee(()=>import("./index-CgJtiJsK.js"),[]),ee(()=>import("./gifenc.esm-sOOlYEo8.js"),[])]),b=f(),w=we/S;for(let R=0;R<=S;R+=1){const X=R/S;(t=Z.current)==null||t.setAttribute("width",String(a.left+G*X)),$.current&&($.current.textContent=L(Math.round(N*X))),await new Promise(fe=>requestAnimationFrame(()=>requestAnimationFrame(()=>fe())));const k=await l(P.current,{pixelRatio:1,backgroundColor:y.bg,style:{position:"static",left:"0",top:"0",transform:"none"}}),Q=k.getContext("2d");if(!Q)continue;const{data:Y,width:de,height:ue}=Q.getImageData(0,0,k.width,k.height),J=p(Y,256),xe=d(Y,J);b.writeFrame(xe,de,ue,{palette:J,delay:w,first:R===0})}b.finish();const M=new Blob([new Uint8Array(b.bytes())],{type:"image/gif"}),K=URL.createObjectURL(M);ye(K,`octocounts-${n}-${o}-history.gif`),setTimeout(()=>URL.revokeObjectURL(K),5e3),ge(je.gifExported,{provider:i,owner:n,repo:o})}catch{W(r("codeHistory.gifExportFailed"))}finally{q(!1)}}};if(!B)return null;if(ie)return e.jsx("div",{className:"repo-history repo-history-loading","aria-hidden":"true",children:e.jsx(C,{className:"spin",size:16})});if(_.isError)return e.jsxs("section",{className:"repo-history repo-history-loading",role:"status",children:[r("codeHistory.unavailable")," ",e.jsx("button",{className:"copybtn",type:"button",onClick:()=>void _.refetch(),children:r("codeHistory.retry")})]});if(!g||!s)return e.jsx("section",{className:"repo-history repo-history-loading",role:"status",children:r("codeHistory.empty")});const ce=a.left+G*re,h=E!==null?s[E]:null,he=t=>{const l=t.currentTarget.getBoundingClientRect(),f=(t.clientX-l.left)/l.width*m;let p=0,d=1/0;s.forEach((b,w)=>{const M=Math.abs(b.x-f);M<d&&(d=M,p=w)}),H(p)},V=t=>{const l=t.touches[0];if(!l)return;const f=t.currentTarget.getBoundingClientRect(),p=(l.clientX-f.left)/f.width*m;let d=0;
1s.forEach((b,w)=>{Math.abs(b.x-p)<Math.abs(s[d].x-p)&&(d=w)}),H(d)},A=t=>H(Math.max(0,Math.min(s.length-1,t)));return e.jsxs("section",{className:"repo-history","aria-label":r("codeHistory.title"),children:[e.jsxs("div",{className:"repo-history-head",children:[e.jsx("h2",{children:r("codeHistory.title")}),e.jsxs("span",{className:"repo-history-count",children:[L(ne)," ",r("codeHistory.locAbbrev")]})]}),e.jsxs("div",{className:"repo-history-chart",ref:oe,children:[e.jsxs("svg",{viewBox:`0 0 ${m} ${u}`,width:"100%",role:"img","aria-label":r("codeHistory.chartAriaLabel",{count:L(N)}),onMouseMove:he,onMouseLeave:()=>H(null),onTouchStart:V,onTouchMove:V,tabIndex:0,onKeyDown:t=>{t.key==="ArrowRight"&&(t.preventDefault(),A((E??-1)+1)),t.key==="ArrowLeft"&&(t.preventDefault(),A((E??s.length)-1)),t.key==="Home"&&(t.preventDefault(),A(0)),t.key==="End"&&(t.preventDefault(),A(s.length-1))},children:[e.jsx("defs",{children:e.jsx("clipPath",{id:"repo-history-reveal",children:e.jsx("rect",{x:0,y:0,width:ce,height:u})})}),e.jsxs("g",{clipPath:"url(#repo-history-reveal)",children:[e.jsx("path",{d:te(s),className:"repo-history-sloc-area",fill:"#55c878",fillOpacity:"0.15"}),e.jsx("path",{d:O(s),className:"repo-history-sloc-line",stroke:"#55d37a",fill:"none",strokeWidth:"2"})]}),h?e.jsxs(e.Fragment,{children:[e.jsx("line",{x1:h.x,x2:h.x,y1:a.top,y2:I,className:"repo-history-hover-line"}),e.jsx("circle",{cx:h.x,cy:h.y,r:4,className:"repo-history-hover-dot"})]}):null,e.jsx("text",{x:a.left,y:u-6,className:"repo-history-axis-label",children:v(s[0].point.date,x.language)}),e.jsx("text",{x:m-a.right,y:u-6,textAnchor:"end",className:"repo-history-axis-label",children:v(s[s.length-1].point.date,x.language)})]}),h?e.jsxs("div",{className:"repo-history-tooltip",style:{left:`${Math.min(54,Math.max(24,h.x/m*100))}%`},children:[e.jsx("strong",{children:L(h.point.totalLines)})," ",r("codeHistory.locAbbrev")," · ",v(h.point.date,x.language)]}):null]}),g.slocBackfillInProgress?e.jsxs("div",{className:"repo-history-progress",children:[e.jsx(C,{className:"spin",size:13})," ",r("codeHistory.gatheringSloc")]}):null,e.jsx("span",{className:"visually-hidden","aria-live":"polite",children:h?`${v(h.point.date,x.language)}: ${L(h.point.totalLines)} ${r("codeHistory.locAbbrev")}`:""}),e.jsxs("details",{className:"repo-history-data",children:[e.jsx("summary",{children:r("codeHistory.dataTable")}),e.jsx("div",{className:"repo-history-data-wrap",children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:r("codeHistory.date")}),e.jsx("th",{children:r("codeHistory.lines")})]})}),e.jsx("tbody",{children:s.map(t=>e.jsxs("tr",{children:[e.jsx("td",{children:v(t.point.date,x.language)}),e.jsx("td",{children:L(t.point.totalLines)})]},t.point.date))})]})})]}),e.jsx("div",{className:"repo-history-export",ref:P,"aria-hidden":"true",children:e.jsxs("svg",{viewBox:`0 0 ${m} ${u}`,width:m,height:u,children:[e.jsx("defs",{children:e.jsx("clipPath",{id:"repo-history-export-reveal",children:e.jsx("rect",{ref:Z,x:0,y:0,width:a.left,height:u})})}),e.jsxs("g",{clipPath:"url(#repo-history-export-reveal)",children:[e.jsx("path",{d:te(s),fill:y.line,fillOpacity:"0.15"}),e.jsx("path",{d:O(s),stroke:y.line,fill:"none",strokeWidth:"2",strokeLinejoin:"round",strokeLinecap:"round"})]}),e.jsx("text",{x:a.left,y:u-6,fill:y.axis,fontSize:"10",children:v(s[0].point.date,x.language)}),e.jsx("text",{x:m-a.right,y:u-6,textAnchor:"end",fill:y.axis,fontSize:"10",children:v(s[s.length-1].point.date,x.language)}),e.jsx("text",{ref:$,x:a.left,y:20,fill:y.count,fontSize:"14",fontWeight:"700",children:"0"})]})}),e.jsxs("div",{className:"repo-history-actions",children:[e.jsxs("button",{className:"copybtn",disabled:U,onClick:()=>void le(),children:[U?e.jsx(C,{className:"spin",size:13}):e.jsx(me,{size:13})," ",r("codeHistory.exportGif")]}),z?e.jsx("span",{className:"repo-history-error",children:z}):null]})]})}function v(i,n){const o=new Date(`${i}T00:00:00Z`);return Number.isNaN(o.getTime())?i:new Intl.DateTimeFormat(n,{year:"numeric",month:"short",day:"numeric",timeZone:"UTC"}
1).format(o)}export{_e as RepoHistoryChart};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.