PageSourceSearch

https://cdnjs.com/islands/libraries-CnFRHMET.js

js cdnjs.com collected 2026-09-24 06:57:47 UTC 13,602 bytes, 272 lines download raw bytes

1import{i as e,l as t,n,r,t as i}from"./chunks/theme-z3Jnh76u.js";import{i as a,r as o,t as s}from"./chunks/hydration-runtime-7OK5mKrL.js";import{t as c}from"./chunks/copy-DjZE_PQo.js";import{t as l}from"./chunks/esm-C0_xodi_.js";import{a as u,o as d,r as f,t as p}from"./chunks/schemas-DW0xURyX.js";import{t as m}from"./chunks/search-DwafNmcg.js";var h=t(a(),1),g=o(),_=75,v=16,y=9,b=(e,t)=>{let n=Math.sin((e+t)*12.9898)*43758.5453123;return n-Math.floor(n)},x=(e,t,n,r)=>n+b(e,t)*(r-n),S=(e,t)=>Math.round((e+2**-52)*10**t)/10**t,C=e=>`M ${e.map(e=>{let t=e%v,n=Math.floor(e/v);return`${t*_} ${n*_}`}).join(` L `)}`,w=e=>{let t=Array.from({length:v*y},(t,n)=>{let r=n%v,i=Math.floor(n/v),a=r===0||r===v-1||i===0||i===y-1;return b(e,1e3+n)<(a?.3:.5)}),n=t.reduce((n,r,i)=>{if(!r)return n;let a=i%v,o=Math.floor(i/v);return a<v-1&&t[i+1]&&n.push([i,i+1]),o<y-1&&t[i+v]&&n.push([i,i+v]),b(e,2e3+i)<.5&&o<y-1&&!t[i+v]&&(a<v-1&&t[i+v+1]&&n.push([i,i+v,i+v+1]),a>0&&t[i+v-1]&&n.push([i,i+v,i+v-1])),n},[]);return{connections:n,requests:n.reduce((t,n,r)=>{if(b(e,3e3+r)<.5){let i=S(x(e,4e3+r,2,5),2)*(n.length-1),a=S(x(e,5e3+r,-i,0),2);if(t.push([n,i,a]),b(e,6e3+r)<.3){let i=S(x(e,7e3+r,2,5),2)*(n.length-1),a=S(x(e,8e3+r,-i,0),2);t.push([[...n].reverse(),i,a])}}return t},[]),vias:n.reduce((e,t)=>{let n=t[0];if(n===void 0)return e;e[n]=(e[n]??0)+1;let r=t[t.length-1];return r===void 0||(e[r]=(e[r]??0)+1),e},Array.from({length:v*y},()=>0))}},T={hub:e`
2        0% {
3            transform: scale(1);
4            opacity: 0.7;
5        }
6
7        50%, 100% {
8            transform: scale(4);
9            opacity: 0;
10        }
11    `,dot:e`
12        0% {
13            opacity: 0.35;
14        }
15
16        50% {
17            opacity: 0.7;
18        }
19
20        100% {
21            opacity: 0.35;
22        }
23    `,request:e`
24        0% {
25            offset-distance: 0%;
26            opacity: 0;
27        }
28
29        5%, 95% {
30            opacity: 1;
31        }
32
33        100% {
34            offset-distance: 100%;
35            opacity: 0;
36        }
37    `},E={grid:n`
38        fill: currentColor;
39        opacity: 0.2;
40    `,connection:n`
41        fill: none;
42        stroke: currentColor;
43        stroke-width: 1;
44        opacity: 0.1;
45    `,hub:n`
46        fill: color-mix(in oklab, currentColor, transparent 80%);
47        transform-box: fill-box;
48        transform-origin: center;
49        animation: ${T.hub} linear infinite;
50        will-change: transform, opacity;
51    `,dot:n`
52        animation: ${T.dot} linear infinite;
53        will-change: opacity;
54
55        &:nth-child(1) {
56            fill: currentColor;
57        }
58
59        &:nth-child(2) {
60            fill: color-mix(in oklab, currentColor, white 35%);
61        }
62    `,request:n`
63        animation: ${T.request} linear infinite;
64        will-change: offset-distance, opacity;
65
66        &:nth-child(1) {
67            fill: color-mix(in oklab, currentColor, transparent 65%);
68            filter: blur(2.5px);
69        }
70
71        &:nth-child(2) {
72            fill: color-mix(in oklab, currentColor, white 55%);
73        }
74    `},D=({width:e=v,height:t=y,className:n})=>{let r=`grid-${(0,h.useId)()}`,[i]=(0,h.useState)(()=>{let e=typeof document<`u`?document.getElementById(r)?.getAttribute(`data-seed`):null,t=Number.parseInt(e??``,10);return Number.isInteger(t)?t:Math.floor(Math.random()*2**31-1)}),{connections:a,requests:o,vias:s}=(0,h.useMemo)(()=>w(i),[i]);return(0,g.jsxs)(`svg`,{id:r,xmlns:`http://www.w3.org/2000/svg`,"data-seed":i,viewBox:`${(v*_-e*_)/2} ${(y*_-t*_)/2} ${e*_} ${t*_}`,preserveAspectRatio:`xMidYMid slice`,"aria-hidden":`true`,className:n,children:[(0,g.jsx)(`g`,{children:Array.from({length:v*y},(e,t)=>{let n=t%v,r=Math.floor(t/v);return(0,g.jsx)(`circle`,{cx:n*_,cy:r*_,r:1,className:E.grid},t)})}),(0,g.jsx)(`g`,{children:a.map((e,t)=>(0,g.jsx)(`path`,{d:C(e),className:E.connection},t))}),(0,g.jsx)(`g`,{children:s.map((e,t)=>{if(!e)return null;let n=t%v,r=Math.floor(t/v),i=e>2,a=i?2:4,o=-S(t*.4%a,2);return(0,g.jsxs)(`g`,{children:[i&&(0,g.jsx)(`circle`,{cx:n*_,cy:r*_,r:8,className:E.hub,style:{animationDuration:`3.5s`,animationDelay:`${o}s`}}),(0,g.jsx)(`circle`,{cx:n*_,cy:r*_,r:i?4:2,className:E.dot,style:{animationDuration:`${a}s`,animationDelay:`${o}s`}})]},t)})}),(0,g.jsx)(`g`,{children:o.map(([e,t,n],r)=>
74(0,g.jsxs)(`g`,{children:[(0,g.jsx)(`circle`,{cx:0,cy:0,r:5,className:E.request,style:{offsetPath:`path('${C(e)}')`,animationDuration:`${t}s`,animationDelay:`${n}s`}}),(0,g.jsx)(`circle`,{cx:0,cy:0,r:2,className:E.request,style:{offsetPath:`path('${C(e)}')`,animationDuration:`${t}s`,animationDelay:`${n}s`}})]},r))})]})},O={header:n`
75        position: relative;
76        isolation: isolate;
77        display: flex;
78        flex-direction: column;
79    `,fill:n`
80        flex-grow: 1;
81    `,background:n`
82        color: ${i.background.brand};
83        position: absolute;
84        width: 100vw;
85        height: calc(100% + ${i.spacing(4)});
86        left: 50%;
87        transform: translateX(-50%);
88        top: ${i.spacing(-2)};
89        bottom: ${i.spacing(-2)};
90        z-index: -1;
91        pointer-events: none;
92    `,content:n`
93        display: flex;
94        flex-direction: column;
95        align-items: center;
96        justify-content: center;
97        text-align: center;
98        gap: ${i.spacing(4)};
99        margin: auto;
100        max-width: 100%;
101        background: radial-gradient(
102            ellipse at center,
103            rgb(from ${i.background.primary} r g b / 0.9) 0%,
104            rgb(from ${i.background.primary} r g b / 0) 100%
105        );
106        padding: ${i.spacing(4,2)};
107    `,badge:n`
108        display: flex;
109        align-items: center;
110        gap: ${i.spacing(1.5)};
111        background: rgb(from ${i.background.brand} r g b / 0.125);
112        border: ${i.spacing(.125)} solid
113            rgb(from ${i.background.brand} r g b / 0.75);
114        border-radius: ${i.spacing(4)};
115        color: ${i.text.brand};
116        font-family: ${i.font.families.mono};
117        font-size: ${i.font.tiny.size};
118        font-weight: ${i.font.tiny.weight};
119        line-height: 1;
120        text-transform: uppercase;
121        padding: ${i.spacing(1,1.75)};
122        margin: 0;
123        opacity: 0.875;
124
125        &::before {
126            content: ' ';
127            display: block;
128            width: ${i.spacing(.75)};
129            height: ${i.spacing(.75)};
130            margin: 0 ${i.spacing(-.25)};
131            border-radius: 50%;
132            background: ${i.text.brand};
133            box-shadow: 0 0 ${i.spacing(.75)} ${i.text.brand};
134        }
135    `,title:n`
136        font-family: ${i.font.families.home};
137        line-height: 1.125;
138        margin: 0;
139
140        &,
141        strong {
142            font-size: ${i.font.heading.size};
143            font-weight: ${i.font.heading.weight};
144        }
145
146        strong {
147            color: ${i.text.brand};
148        }
149
150        small {
151            color: ${i.text.secondary};
152            font-family: ${i.font.families.mono};
153            font-size: ${i.font.body.size};
154            font-weight: ${i.font.body.weight};
155        }
156    `,prose:n`
157        color: ${i.text.secondary};
158        line-height: 1.5;
159        margin: 0;
160
161        &,
162        strong {
163            font-size: ${i.font.small.size};
164            font-weight: ${i.font.small.weight};
165        }
166
167        strong {
168            color: ${i.text.primary};
169        }
170    `,after:n`
171        position: relative;
172        isolation: isolate;
173        padding: ${i.spacing(2,0)};
174
175        &::before {
176            content: '';
177            position: absolute;
178            width: 100vw;
179            left: 50%;
180            transform: translateX(-50%);
181            background: ${i.background.elevated};
182            top: 0;
183            bottom: 0;
184            z-index: -1;
185        }
186    `},k=({title:e,prose:t=`A free, open-source CDN for the web's most popular JavaScript, CSS, and font resources.`,fill:n,extra:i,children:a})=>(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(`div`,{className:r(O.header,n&&O.fill),children:[(0,g.jsx)(D,{className:O.background,height:n?void 0:3}),(0,g.jsxs)(`div`,{className:O.content,children:[(0,g.jsx)(`p`,{className:O.badge,children:`Powered by Cloudflare`}),(0,g.jsx)(`h1`,{className:O.title,children:e}),(0,g.jsx)(`p`,{className:O.prose,children:t}),i]})]}),a&&(0,g.jsx)(`div`,{className:O.after,children:a})]}),A=u({name:d(),version:d(),description:d(),latest:f(d()),sri:d()}),j=async(e,t)=>{let n=await fetch(`https://api.cdnjs.com/libraries?search=${encodeURIComponent(e)}&fields=name,latest,version,description,sri`,{signal:t});if(!n.ok)throw Error(`Failed to fetch status: ${n.status} ${n.statusText}`,{cause:await n.text()});let r=await n.json();return u({results:p(A)}).parse(r).results},M={header:n`
187        display: flex;
188        flex-direction: column;
189        gap: ${i.spacing(2)};
190        padding: ${i.spacing(2,0)};
191    `,found:n`
192        color: ${i.text.secondary};
193        margin: 0;
194
195        &,
196        strong {
197            font-size: ${i.font.small.size};
198            font-weight: ${i.font.small.weight};
199        }
200
201        strong {
202            color: ${i.text.brand};
203        }
204    `,results:n`
205        display: grid;
206        grid-template-columns: repeat(2, minmax(0, 1fr));
207        gap: ${i.spacing(2)};
208        padding: 0;
209        margin: ${i.spacing(2,0,0)};
210        list-style: none;
211        transition: opacity ${i.transition};
212
213        ${i.breakpoints.medium} {
214            grid-template-columns: 1fr;
215        }
216
217        @starting-style {
218            opacity: 0;
219        }
220    `,card:n`
221        display: flex;
222        flex-direction: column;
223        gap: ${i.spacing(1)};
224        padding: ${i.spacing(2)};
225        background: ${i.background.elevated};
226        border-radius: ${i.radius};
227        position: relative;
228        isolation: isolate;
229        transition: background ${i.transition};
230
231        &:has(a:hover, a:focus) {
232            background: rgb(from ${i.background.elevated} r g b / 0.75);
233        }
234    `,name:n`
235        display: flex;
236        flex-wrap: wrap;
237        gap: ${i.spacing(1)};
238
239        a {
240            color: ${i.text.brand};
241            font-size: ${i.font.large.size};
242            font-weight: ${i.font.large.weight};
243            text-decoration: underline;
244
245            &:hover {
246                text-decoration: none;
247            }
248
249            &::before {
250                content: '';
251                position: absolute;
252                width: 100%;
253                height: 100%;
254                top: 0;
255                left: 0;
256            }
257
258            small {
259                font-size: ${i.font.small.size};
260                font-weight: ${i.font.small.weight};
261            }
262        }
263
264        button {
265            z-index: 1;
266        }
267    `,description:n`
268        font-size: ${i.font.body.size};
269        font-weight: ${i.font.body.weight};
270        margin: 0;
271    `},N=({name:e,version:t,description:n,latest:r,sri:i,index:a,ref:o})=>(0,g.jsxs)(`li`,{className:M.card,"data-index":a,ref:o,children:[(0,g.jsxs)(`div`,{className:M.name,children:[(0,g.jsxs)(`a`,{href:`/libraries/${encodeURIComponent(e)}`,children:[e,(0,g.jsxs)(`small`,{children:[` @ `,t]})]}),r&&(0,g.jsx)(c,{name:e,version:t,file:r.replace(/https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/[^/]+\/[^/]+\//,``),sri:i})]}),(0,g.jsx)(`p`,{className:M.description,children:n})]});s(`libraries`,({initial:e})=>{let[t,n]=(0,h.useState)(`loading`),[r,a]=(0,h.useState)(e.results),[o,s]=(0,h.useState)(e.search),c=(0,h.useRef)(null);(0,h.useEffect)(()=>{let e=setTimeout(async()=>{let e=new AbortController;c.current?.abort(),c.current=e;try{n(`loading`),a(await j(o,e.signal)),n(`idle`);let t=new URL(window.location.href);o===``?t.searchParams.delete(`search`):t.searchParams.set(`search`,o),window.history.replaceState({},``,t.toString())}catch(t){e.signal.aborted||(console.error(t),n(`failed`))}},c.current?300:0);return()=>clearTimeout(e)},[o,e.search,e.results]);let[u,d]=(0,h.useState)(e.total.toLocaleString(`en-US`));(0,h.useEffect)(()=>{d((r===e.results?e.total:r.length).toLocaleString())},[r]);let[f,p]=(0,h.useState)(2),_=(0,h.useRef)(null),v=(0,h.useRef)(0);(0,h.useLayoutEffect)(()=>{v.current=_.current?.offsetTop??0},[]),(0,h.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(i.breakpoints.medium.replace(`@media `,``)),t=()=>p(e.matches?1:2);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let y=(0,h.useMemo)(()=>{let e=Math.ceil(r.length/f);return Array.from({length:e},(e,t)=>{let n=r.slice(t*f,t*f+f);return{key:n.map(e=>JSON.stringify([e.name,e.version,e.description,e.latest,e.sri])).join(`|`),values:n}})},[f,r]),b=l({count:y.length,estimateSize:()=>Number(i.spacing(12).replace(`px`,``)),gap:Number(i.spacing(2).replace(`px`,``)),overscan:5,scrollMargin:v.current,getItemKey:e=>y[e]?.key??e,initialRect:{width:0,height:1e3}}),x=b.getVirtualItems(),S=x.at(0),C=S?Math.max(0,S.start-b.options.scrollMargin):0,w=x.at(-1),T=w?Math.max(0,b.getTotalSize()-w.end):0;return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(k,{title:(0,g.jsxs)(g.Fragment,{children:[`Browse `,(0,g.jsx)(`strong`,{children:`cdnjs`})]}),children:(0,g.jsxs)(`div`,{className:M.header,children:[(0,g.jsx)(m,{value:o,onChange:s,state:t}),(0,g.jsxs)(`p`,{className:M.found,children:[`Found `,(0,g.jsx)(`strong`,{children:u}),` libraries available on cdnjs.`]})]})}),(0,g.jsx)(`ul`,{ref:_,style:{paddingTop:C,paddingBottom:T},className:M.results,children:x.map(e=>{let t=y[e.index];return t?t.values.map((t,n)=>(0,g.jsx)(N,{...t,index:e.index,ref:n===0?b.measureElement:void 0},`${t.name}:${t.version}`)):null})})]})});
272//# sourceMappingURL=libraries-CnFRHMET.js.map

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.