PageSourceSearch

https://northspore.com/cdn/shop/t/221/assets/cart-market-resync-DRN5S86A.js

js northspore.com collected 2026-09-25 18:20:40 UTC 2,504 bytes, 15 lines download raw bytes

1import{C as i}from"./events-Dm1k7AS7.js";const l="2025-07",y="ns_cart_resync_reloaded";let s=!1;function t(e,...r){e?.debug&&console.info("[ns-cart-resync]",...r)}function C(e){try{return window.sessionStorage.getItem(y)===e}catch{return!0}}function p(e){try{window.sessionStorage.setItem(y,e)}catch{}}async function f(){const e=window.Shopify?.routes?.root||"/",r=await fetch(`${e}cart.js`,{credentials:"include"});return r.ok?r.json():null}async function h(e,r){const n=`/api/${e.apiVersion||l}/graphql.json`,o=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","X-Shopify-Storefront-Access-Token":e.token},body:JSON.stringify({query:`
2        mutation SetCartCountry($cartId: ID!, $countryCode: CountryCode!) {
3          cartBuyerIdentityUpdate(
4            cartId: $cartId
5            buyerIdentity: { countryCode: $countryCode }
6          ) {
7            cart {
8              id
9              cost { totalAmount { currencyCode } }
10              buyerIdentity { countryCode }
11            }
12            userErrors { field message }
13          }
14        }
15      `,variables:{cartId:r,countryCode:e.countryCode}})});return o.ok?o.json():null}async function u(e,r){if(s){t(e,"resync already in flight — skipping");return}s=!0;try{await m(e,r)}finally{s=!1}}async function m(e,r){const n=await f();if(!n||!n.token||n.item_count===0){t(e,"no cart to correct");return}if(n.currency===e.expectedCurrency){t(e,"cart already in the expected market — page HTML was stale");return}const o=`gid://shopify/Cart/${n.token}`;t(e,`resyncing ${n.currency} -> ${e.expectedCurrency}`,{countryCode:e.countryCode});const a=await h(e,o),c=a?.data?.cartBuyerIdentityUpdate;if(a?.errors?.length){t(e,"GraphQL errors — cart left unchanged",a.errors);return}if(c?.userErrors?.length){t(e,"mutation userErrors — cart left unchanged",c.userErrors);return}const d=c?.cart?.cost?.totalAmount?.currencyCode;if(d!==e.expectedCurrency){t(e,`resync did not take (got ${d})`);return}if(t(e,"resync succeeded"),r==="refresh"){t(e,"refreshing cart drawer"),document.dispatchEvent(new CustomEvent(i.UPDATE));return}if(C(e.expectedCurrency)){t(e,"reload already used for this currency — not reloading again");return}p(e.expectedCurrency),window.location.reload()}function E(){const e=window.nsCartResync;!e||!e.token||!e.countryCode||(e.mismatch&&u(e,"reload").catch(r=>t(e,"resync failed",r)),document.addEventListener(i.ADDED,()=>{u(e,"refresh").catch(r=>t(e,"resync after add failed",r))}))}export{E as i};

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.