PageSourceSearch

https://hyperice.com/cdn/shop/t/117/assets/WithApiClient.DyDsqC0I.min.js

js hyperice.com collected 2026-10-01 11:44:51 UTC 4,964 bytes, 1 lines download raw bytes

1import{d as U}from"./index.CKJCYK2x.min.js";async function K(e,s={},t=[],r=1*60*1e3){try{const a=q(e,t),o=Date.now();if((s.method??"GET").toUpperCase()==="GET")try{const l=localStorage.getItem(a);if(l){const{timestamp:c,body:d,headers:n}=JSON.parse(l);if(o-c<r)return new Response(d,{headers:n});localStorage.removeItem(a)}}catch(l){console.warn("Error reading from fetch cache",l)}const h=await fetch(e,s),u=h.clone();try{const l=await u.text(),c={};u.headers.forEach((d,n)=>{c[n]=d}),localStorage.setItem(a,JSON.stringify({timestamp:o,body:l,headers:c}))}catch{}return h}catch(a){return console.error("Error in fetchWithCache",a),fetch(e,s)}}function R(e){let s=0,t,r;for(t=0;t<e.length;t++)r=e.charCodeAt(t),s=(s<<5)-s+r,s|=0;return(s>>>0).toString(16).padStart(8,"0")}const q=(e,s=[])=>{var h;const t=typeof window<"u"&&((h=window.location)!=null&&h.origin)?window.location.origin:"http://localhost",r=new URL(e,t);r.hash="",s.forEach(u=>r.searchParams.delete(u));const a=r.pathname+(r.search?r.search:"");return`fetch-cache:${R(a)}`},E={},b={},A=async(e,s)=>{try{const t=e.headers.get("content-type");return t&&(t.includes("application/json")||t.includes("json")||t.includes("application/graphql")||t.includes("text/javascript"))||s!=null&&s.forceJSON?await e.json():await e.text()}catch(t){return console.error("Error in formattedResponse",t),await e.text()}},M=e=>{const s=new URLSearchParams;for(const t in e){const r=e[t];if(Array.isArray(r))for(const a of r)s.append(t,a);else s.set(t,r)}return s},I=e=>{const s={};for(const[t,r]of e.entries())s[t]?Array.isArray(s[t])?s[t].push(r):s[t]=[s[t],r]:s[t]=r;return s},T=async(e,s,t,r,a)=>{var o,h,u,l;try{const c={...e.headers,...(r==null?void 0:r.headers)||{}},d=a!=null&&a.params?M(a.params):null;(o=e==null?void 0:e.onRequestStart)==null||o.call(e);const n={...c,...(r==null?void 0:r.headers)||{}};a!=null&&a.removeContentType&&delete n["Content-Type"];const f=(r==null?void 0:r.method)||e.defaultMethod||"GET",i=(a==null?void 0:a.withCache)&&f==="GET",O=(a==null?void 0:a.persistCache)&&f==="GET"?(y,x)=>K(y,x,a==null?void 0:a.persistCacheParamsToIgnore,a==null?void 0:a.persistCacheExpiryMs):fetch,w=`${e.baseUrl}${t}${d?"?"+d.toString():""}`;if(i){const y=s.get(w);if(y)return y}const C=await O(w,{signal:e.signal,method:f,...r,headers:n,...(r==null?void 0:r.body)&&(a==null?void 0:a.rawBody)&&{body:r.body},...(r==null?void 0:r.body)&&!(a!=null&&a.rawBody)&&{body:JSON.stringify(r.body)}});if(!C.ok||C.status>=400)throw await A(C,a);if((u=(h=r==null?void 0:r.headers)==null?void 0:h["Content-Type"])!=null&&u.includes("text/")){const y=await C.text();return i&&s.set(w,y),y}const p=await A(C,a);return i&&s.set(w,p),p}catch(c){const d=String(c).toLowerCase(),n=c instanceof Error?c.message:d,f=c instanceof Error&&c.name||typeof DOMException<"u"&&c instanceof DOMException&&c.name||"";throw typeof DOMException<"u"&&c instanceof DOMException&&c.name==="AbortError"||c instanceof Error&&c.name==="AbortError"||(n==null?void 0:n.toLowerCase().includes("aborted"))||d.includes("aborted")||f==="AbortError"||console.error("Error in createApiClient",c),c}finally{(l=e==null?void 0:e.onRequestEnd)==null||l.call(e)}},j=async(e,s,t)=>{if(b[t])return;b[t]=!0;const r=E[t];for(;r.length>0;){const{requestArguments:a,deferred:o}=r.shift();try{const h=await T(e,s,a.endpoint,a.init,a.options);o.resolve(h)}catch(h){o.reject(h)}}b[t]=!1},S=(e,s)=>{const t=new P(s);return e.withQueue&&e.queueKey&&(E[e.queueKey]||(E[e.queueKey]=[])),(r,a,o)=>{if(r==="FLUSH_CACHE")return t.clear(),Promise.resolve({});if(e.withQueue&&e.queueKey){const h=U();return E[e.queueKey].push({requestArguments:{endpoint:r,init:a,options:o},deferred:h}),j(e,t,e.queueKey),h.promise}return T(e,t,r,a,o)}},$=e=>{class s extends e{constructor(){super(...arguments),this.$api=new L(this)}}return s};class L{constructor(s){this.abortController=new AbortController,this.fetchClient=S({baseUrl:"",signal:this.abortController.signal}),this.storefrontClient=S({baseUrl:`${window.Shopify.routes.root==="/"?"":window.Shopify.routes.root}/api/2024-07/graphql.json`,headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":`${window.__STOREFRONT_ACCESS_TOKEN__}`},defaultMethod:"POST",signal:this.abortController.signal}),this.shopifyClient=S({baseUrl:`${window.Shopify.routes.root}`,headers:{"Content-Type":"application/json"},signal:this.abortController.signal}),(this.host=s).addController(this)}hostDisconnected(){this.abortController.abort()}get client(){return{fetchClient:this.fetchClient,storefront:s=>this.storefrontClient("",s),shopify:this.shopifyClient}}}const m=new Map;class P{constructor(s){if(this.cache=new Map,this.get=t=>this.cache.get(t),this.set=(t,r)=>this.cache.set(t,r),this.clear=()=>this.cache.clear(),this.cacheKey=s,this.cacheKey&&(m.has(this.cacheKey)||m.set(this.cacheKey,this)),this.cacheKey&&m.has(this.cacheKey)){const t=m.get(this.cacheKey);t&&(this.cache=t.cache)}}}export{$ as W,S as c,I as f};

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.