@helia/routers 3.1.0 → 3.1.1-e3522f5

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.min.js CHANGED
@@ -11,7 +11,7 @@
11
11
  (?:${ut}:){1}(?:(?::${ut}){0,4}:${te}|(?::${ut}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
12
12
  (?::(?:(?::${ut}){0,5}:${te}|(?::${ut}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
13
13
  )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
14
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),kp=new RegExp(`(?:^${te}$)|(?:^${vo}$)`),Kp=new RegExp(`^${te}$`),Op=new RegExp(`^${vo}$`),Ns=e=>e&&e.exact?kp:new RegExp(`(?:${Le(e)}${te}${Le(e)})|(?:${Le(e)}${vo}${Le(e)})`,"g");Ns.v4=e=>e&&e.exact?Kp:new RegExp(`${Le(e)}${te}${Le(e)}`,"g");Ns.v6=e=>e&&e.exact?Op:new RegExp(`${Le(e)}${vo}${Le(e)}`,"g");var Rs=Ns;function Ls(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Ef(){return!1}var{toString:Fp}=Object.prototype;function Ds(e){return Fp.call(e)==="[object RegExp]"}var Sf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function ks(e,t={}){if(!Ds(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(Sf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?Sf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Ks(e,t,{timeout:r}={}){try{return Ls(()=>ks(e).test(t),{timeout:r})()}catch(n){if(Ef(n))return!1;throw n}}var Mp=15,Vp=45,vf={timeout:400};function Os(e){return e.length>Vp?!1:Ks(Rs.v6({exact:!0}),e,vf)}function Af(e){return e.length>Mp?!1:Ks(Rs.v4({exact:!0}),e,vf)}var If={http:"80",https:"443",ws:"80",wss:"443"},qp=["http","https","ws","wss"];function Tf(e,t){t=t??{};let r=t.defaultDnsType??"dns4",{scheme:n,hostname:o,port:i,path:s}=$p(e),a=[Hp(o,r),zp(i,n),jp(n)];s!=null&&a.push(Gp(s));let c="/"+a.filter(l=>!!l).reduce((l,u)=>l.concat(u),[]).join("/");return Ze(c)}function $p(e){let[t]=e.split(":");qp.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let c=Zp(t);c!=null&&(o=c),c==null&&r==="http:"&&(o="80")}let a;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),a=i),s!=null&&s!==""&&(a=a??"",a+=s),{scheme:t,hostname:n,port:o,path:a}}function Hp(e,t){if(!(e==null||e==="")){if(Af(e))return["ip4",e];if(Os(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(Os(r))return["ip6",r]}return[t,e]}}function zp(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function jp(e){if(e.match(/^tcp$|^udp$/)==null)return[e]}function Gp(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function Zp(e){if(!(e==null||e===""||If[e]==null))return If[e]}var Wp=["https://trustless-gateway.link","https://4everland.io"],Yp=2336;function Xp(e){return e=e.toString(),{id:rs(G.createV1(Yp,Lt.digest(H(e)))),multiaddrs:[Tf(e)]}}var Fs=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??Wp).map(r=>Xp(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function Cf(e={}){return new Fs(e)}var Ms=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}};function Bf(e){return new Ms(e)}return Of(Jp);})();
14
+ `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),kp=new RegExp(`(?:^${te}$)|(?:^${vo}$)`),Kp=new RegExp(`^${te}$`),Op=new RegExp(`^${vo}$`),Ns=e=>e&&e.exact?kp:new RegExp(`(?:${Le(e)}${te}${Le(e)})|(?:${Le(e)}${vo}${Le(e)})`,"g");Ns.v4=e=>e&&e.exact?Kp:new RegExp(`${Le(e)}${te}${Le(e)}`,"g");Ns.v6=e=>e&&e.exact?Op:new RegExp(`${Le(e)}${vo}${Le(e)}`,"g");var Rs=Ns;function Ls(e){let t=(...r)=>e(...r);return Object.defineProperty(t,"name",{value:`functionTimeout(${e.name||"<anonymous>"})`,configurable:!0}),t}function Ef(){return!1}var{toString:Fp}=Object.prototype;function Ds(e){return Fp.call(e)==="[object RegExp]"}var Sf={global:"g",ignoreCase:"i",multiline:"m",dotAll:"s",sticky:"y",unicode:"u"};function ks(e,t={}){if(!Ds(e))throw new TypeError("Expected a RegExp instance");let r=Object.keys(Sf).map(o=>(typeof t[o]=="boolean"?t[o]:e[o])?Sf[o]:"").join(""),n=new RegExp(t.source||e.source,r);return n.lastIndex=typeof t.lastIndex=="number"?t.lastIndex:e.lastIndex,n}function Ks(e,t,{timeout:r}={}){try{return Ls(()=>ks(e).test(t),{timeout:r})()}catch(n){if(Ef(n))return!1;throw n}}var Mp=15,Vp=45,vf={timeout:400};function Os(e){return e.length>Vp?!1:Ks(Rs.v6({exact:!0}),e,vf)}function Af(e){return e.length>Mp?!1:Ks(Rs.v4({exact:!0}),e,vf)}var If={http:"80",https:"443",ws:"80",wss:"443"},qp=["http","https","ws","wss"];function Tf(e,t){t=t??{};let r=t.defaultDnsType??"dns",{scheme:n,hostname:o,port:i,path:s}=$p(e),a=[Hp(o,r),zp(i,n),jp(n)];s!=null&&a.push(Gp(s));let c="/"+a.filter(l=>!!l).reduce((l,u)=>l.concat(u),[]).join("/");return Ze(c)}function $p(e){let[t]=e.split(":");qp.includes(t)||(e="http"+e.substring(t.length));let{protocol:r,hostname:n,port:o,pathname:i,search:s}=new URL(e);if(o==null||o===""){let c=Zp(t);c!=null&&(o=c),c==null&&r==="http:"&&(o="80")}let a;return i!=null&&i!==""&&i!=="/"&&(i.startsWith("/")&&(i=i.substring(1)),a=i),s!=null&&s!==""&&(a=a??"",a+=s),{scheme:t,hostname:n,port:o,path:a}}function Hp(e,t){if(!(e==null||e==="")){if(Af(e))return["ip4",e];if(Os(e))return["ip6",e];if(e[0]==="["){let r=e.substring(1,e.length-1);if(Os(r))return["ip6",r]}return[t,e]}}function zp(e,t){if(!(e==null||e===""))return t==="udp"?["udp",e]:["tcp",e]}function jp(e){if(e.match(/^tcp$|^udp$/)==null)return e==="https"?["/tls/http"]:e==="wss"?["/tls/ws"]:[e]}function Gp(e){if(!(e==null||e===""))return["http-path",encodeURIComponent(e)]}function Zp(e){if(!(e==null||e===""||If[e]==null))return If[e]}var Wp=["https://trustless-gateway.link","https://4everland.io"],Yp=2336;function Xp(e){return e=e.toString(),{id:rs(G.createV1(Yp,Lt.digest(H(e)))),multiaddrs:[Tf(e)]}}var Fs=class{gateways;shuffle;constructor(t={}){this.gateways=(t.gateways??Wp).map(r=>Xp(r)),this.shuffle=t.shuffle??!0}async*findProviders(t,r){yield*(this.shuffle?this.gateways.toSorted(()=>Math.random()>.5?1:-1):this.gateways).map(n=>({...n,protocols:["transport-ipfs-gateway-http"]}))}};function Cf(e={}){return new Fs(e)}var Ms=class{libp2p;constructor(t){this.libp2p=t}async provide(t,r){await this.libp2p.contentRouting.provide(t,r)}async cancelReprovide(t,r){await this.libp2p.contentRouting.cancelReprovide(t,r)}async*findProviders(t,r){yield*this.libp2p.contentRouting.findProviders(t,r)}async put(t,r,n){await this.libp2p.contentRouting.put(t,r,n)}async get(t,r){return this.libp2p.contentRouting.get(t,r)}async findPeer(t,r){return this.libp2p.peerRouting.findPeer(t,r)}async*getClosestPeers(t,r){yield*this.libp2p.peerRouting.getClosestPeers(t,r)}};function Bf(e){return new Ms(e)}return Of(Jp);})();
15
15
  /*! Bundled license information:
16
16
 
17
17
  @noble/hashes/esm/utils.js: