PageSourceSearch

https://shop.newbelgium.com/cdn/shopifycloud/checkout-web/assets/c1/extensibility-browser-engine.BTJCdlU6.js

js newbelgium.com collected 2026-09-24 08:50:47 UTC 15,706 bytes, 5 lines download raw bytes

1import{r as ce,s as de,c as V,i as D,a as le}from"./hooks-useReplaceShopPayInHistory.Cz4PqGkk.js";import{dR as he,a7 as fe,dS as pe,bT as W,dT as H,dU as G,dV as ue,dW as ye,dX as xe}from"./addresses-is-address-empty.-MuOhIyI.js";import{E as be}from"./utilities-extension-execution-errors.C94S0eIO.js";import{e as g,S as Z,m as J}from"./performance-index.mu6MOGR9.js";import{E as te,c as we,a as me,r as ge}from"./extensions-rpc.a_fI7Gy6.js";import{r as ke,a2 as Y,a3 as Se,R as Ae,a4 as ee,a5 as Ee}from"./esnext-vendor.D7ldIee_.js";import{s as Pe}from"./context-browser.CzQjCL-z.js";import"./app.A60-IfPs.js";import"./constants.DowbVE6J.js";import"./shop-pay-ProgressIntercepts.wTCQvlrM.js";import"./checkout-updaters-helpers.DKDxNKY0.js";import"./shared-shop-theme.BJKdwdMa.js";import"./consent-manager-shared.B29itG0S.js";import"./mobile-checkout-sdk-MobileCheckoutSdkClient.CVSnUTrf.js";import"./apple-pay-errors.CcNuwNMC.js";import"./receipt-mapper-load-recovery.CtThaHn4.js";import"./receipt-eager-mappers.C1dYRU4X.js";import"./shared-report-graphql-error.CaKFFhiw.js";import"./shop-pay-normalizeBuyerDetails.BcEhgoK7.js";import"./context-CheckoutSheetProtocolClient.CNLSBD5p.js";import"./utilities-shopCashMoney.B9eyOzz9.js";import"./graphql-PaymentSessionMutation.CK_JkOwG.js";async function Te(r){const{scriptUrl:e}=r;try{g.markStarted("partner-js-fetch",{extension:r,instanceId:null,type:"extension"});const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch extension asset, received http status ${t.status}`);const i=await t.text();return g.markFinished("partner-js-fetch",{extension:r,instanceId:null,type:"extension",transferredBundleSize:Number(t.headers.get("content-length")),bundleSize:i.length}),{scriptBody:i,scriptUrl:e,extensionId:r.id}}catch(t){const i=t instanceof Error&&typeof t.message=="string"&&t.message.length>0?t.message:"Failed to fetch extension asset";throw new he(i,{cause:t})}}function se(r){if(typeof r=="function"||r instanceof AbortSignal)return;if(typeof r!="object"||r==null)return r;const e={};for(const t in r)e[t]=se(r[t]);return e}const _e=/^\/api\/.+\/graphql\.json$/,Ie=/^(\/\/)?(\/)?storefront\/api\/(.+\/)?graphql\.json$/;function Re(r,e,t){const i=new URL(r),h=new URL(e),c=new URL(`https://${t}`),n=_e.test(i.pathname)&&(i.host===h.host||i.host===c.host);return Ie.test(i.pathname)||n}async function Fe(){throw new te(`permission to access the storefront API must be specified under [capabilities] with flag "api_access = true"; this can be done within your extension's configuration. View the docs for more information:
2
3https://shopify.dev/docs/api/checkout-ui-extensions/configuration#api-access`)}async function Ue(){throw new te(`invalid request URL for storefront API. View the docs for more information:
4
5https://shopify.dev/docs/api/storefront#endpoints`)}function ve({appId:r,extensionType:e,storefrontTokens:t,storefrontUrl:i,myshopifyDomain:h,allowApiAccess:c,apiVersion:n}){async function f(y){const m=ce(y.url,{storefront:de(i,n)});let T;try{T=new Request(m,y)}catch(A){throw new fe(`Invalid API request: ${A}`)}if(!Re(T.url,i,h))return Ue();if(c){const A=await t.get(r,e,"apiFetch");A&&T.headers.set("Shopify-Storefront-Extension-Token",A);let E;try{E=await fetch(T)}catch(v){throw v instanceof TypeError&&v.message.includes("Failed to fetch")?new pe("Failed to query Storefront API",{cause:v}):v}const M=await E.text();return{...se(E),headers:E.headers?Array.from(E.headers.entries()):[],body:M}}return Fe()}return f}const Me=2,Ce=.5;async function Le(r,e){const{observability:t}=e;let i="",h=0;g.markStarted(Z,{type:"sandbox-fetch"});try{const{response:c,text:n}=await ke(async()=>{const f=h>0?{cache:"reload"}:{},y=await fetch(r,f);if(!y.ok)throw new W(`Failed to fetch sandbox polyfills: ${y.status}`);const m=await y.text();if(i=m,!m.slice(-256).includes("SANDBOX_EOF"))throw h++,t.leaveErrorBreadcrumb("truncated_sandbox_polyfill_fetch",{scriptUrl:r,httpStatus:y.status,contentLengthHeader:y.headers.get("content-length"),scriptBodyLength:m.length,scriptEnd:m.slice(-50)},"error"),new H("Polyfill script does not have expected end of file marker, likely truncated");return h>0&&t.log("successful_retry_truncated_sandbox_polyfill_fetch","Successful retry of truncated sandbox polyfill fetch",{scriptUrl:r,truncatedPolyfillCounter:h}),{response:y,text:m}},{maxAttempts:Me,initialRetryDelay:Ce});return g.markFinished(Z,{type:"sandbox-fetch",transferredBundleSize:Number(c.headers.get("content-length")),bundleSize:n.length}),n}catch(c){if(c instanceof H&&i.length>0)return i;throw c instanceof W?c:new W(c instanceof Error&&c.message.length>0?c.message:"Failed to fetch sandbox polyfills",{cause:c})}}const Ne="/cdn/shopifycloud/checkout-web/assets/c1/polyfills-entry-legacy.D3EVUnMj.worker.js",Be="/cdn/shopifycloud/checkout-web/assets/c1/polyfills-entry-modern.DCV3miiE.worker.js",Oe="/cdn/shopifycloud/checkout-web/assets/c1/sandbox.CphAGbZv.worker.js",je="/cdn/shopifycloud/checkout-web/assets/c1/sandbox-2023-04.ZwRa-_pA.worker.js",De="/cdn/shopifycloud/checkout-web/assets/c1/sandbox-2025-07.D1aPqhNY.worker.js";new Proxy({},{get(r,e){return Promise.reject(new Error(`Called ${String(e)} on dummyWorker. Methods are not executable in dummyWorker.`))}});const $e=Y(Oe),qe=Y(De),Ke=Y(je),ze=Ne,Qe=Be;function Ve(r){"signal"in r&&Object.assign(r,{signal:We(r.signal)}
5)}function We(r){const e=new Set;return r.aborted?{aborted:!0}:(r.addEventListener("abort",()=>{for(const t of e)t(r.aborted),Se(t);e.clear()},{once:!0}),{aborted:!1,start(t){r.aborted?t(!0):(Ae(t),e.add(t))}})}const Ye=200;function Xe(r,e){const i=!r.assets.isBaselineBrowser?Qe:ze,h=we({extensionsPublicPath:r.assets.extensionsBase,isPostPurchase:!1,observability:e.observability,getPolyfills:()=>Le(ge(i,r.assets.extensionsBase),{observability:e.observability}),appSandboxPermissions:e.appSandboxPermissions}),c=new Map,n=new Map,f=new Set,y=[],m=[];let T=!1;function O(){T=!0;const o=m.splice(0);for(const l of o)requestIdleCallback(()=>$(l))}const A=ye(O,500);function E(o){Ee(o.worker),o.worker=null,o.extensionPreloads.clear(),o.loadedExtensions.clear()}return{get(o){return c.get(o)},on(o,l){f.add(l);for(const k of y.splice(0))l(k);return()=>{f.delete(l)}},getOrCreate({extension:o,storefrontUrl:l,myshopifyDomain:k}){const F=$({extension:o,storefrontUrl:l,myshopifyDomain:k,appSandboxPermissions:e.appSandboxPermissions}),_=n.get(F);return _.userCount+=1,F},release(o){const l=n.get(o);return l==null?Promise.reject(new G("Could not release the provided sandbox, which usually means the sandbox has already been destroyed.")):(l.userCount-=1,l.userCount>0||(l.listeners.clear(),E(l),n.delete(o),c.delete(l.id)),Promise.resolve())},preload({extensions:o,storefrontUrl:l,myshopifyDomain:k}){const F=_=>e.deferThankYouPreloads&&!ue(_.extensionPoint.target)&&!T;for(const _ of o)F(_)?m.push({extension:_,storefrontUrl:l,myshopifyDomain:k,appSandboxPermissions:e.appSandboxPermissions}):$({extension:_,storefrontUrl:l,myshopifyDomain:k,appSandboxPermissions:e.appSandboxPermissions});o.length>0&&o.every(F)&&A()}};function v(o){if(f.size>0){for(const l of f)l(o);return}y.push(o),y.length>Ye&&y.shift()}function $({extension:o,storefrontUrl:l,myshopifyDomain:k,appSandboxPermissions:F}){const{capabilities:_,scriptUrl:re,id:oe,extensionPoint:ne,apiVersion:U}=o,S=me({extension:o,appSandboxPermissions:F,observability:e.observability}),C=He({target:ne.target,publicId:oe,apiVersion:U,sandboxConfig:S});if(c.has(C)){const s=c.get(C);return S.isShared&&(s.loadExtension(o),e.observability.log("extension_loaded_in_shared_sandbox","Extension loaded into shared sandbox",{appId:o.appId,extensionId:o.id,sandboxCacheKey:C})),s}const I=new Map,p={id:C,userCount:0,scriptUrl:re,extensionPreloads:new Map,loadedExtensions:new Map,listeners:I,worker:null,workerReady:void 0},j={allowNetworkAccess:S.isShared?S.hasSharedNetworkAccess:V(o)};p.workerReady=X();async function q(s){const u=p.loadedExtensions.get(s.id);if(u&&u.scriptUrl===s.scriptUrl)return;g.markStarted("js-loading",{extension:s,instanceId:null,type:"extension"}),p.loadedExtensions.set(s.id,s);const a=Te(s),d=(async()=>{await p.workerReady;let b;try{b=await a}catch(P){throw p.loadedExtensions.delete(s.id),p.extensionPreloads.delete(s.id),g.markFinished("js-loading",{extension:s,instanceId:null,type:"extension"}),P}if(p.worker==null){g.markFinished("js-loading",{extension:s,instanceId:null,type:"extension"});return}await p.worker.load(b),g.markFinished("js-loading",{extension:s,instanceId:null,type:"extension"})})();p.extensionPreloads.set(s.id,d)}q(o);async function X(){let s=null;U==="2023-04"?s=Ke({createMessenger:h(a=>{I.get("error")?.forEach(d=>d(a))},j,o)}):D(U)?s=$e({createMessenger:h(a=>{I.get("error")?.forEach(d=>d(a))},j,o)}):s=qe({createMessenger:h(a=>{I.get("error")?.forEach(d=>d(a))},j,o)}),p.worker=s,ee(s,{reload:()=>{},extensionPerformanceMarkStarted:(a,d)=>{a in J&&g.markStarted(a,{type:"extension",extension:L(d.extensionId),...d})},extensionPerformanceMarkFinished:(a,d)=>{a in J&&g.markFinished(a,{type:"extension",extension:L(d.extensionId),...d})},reportSandboxError:(a,d)=>{const b=new be(`${a?.name??"Error"}: ${a?.message??"Unknown sandbox error"}`);a?.stack&&(b.stack=a.stack),e.observability.error(b,{severity:"error",metadata:{sandbox:ie(d?.scriptUrl)}})},reportApiRead:(a,d)=>{if(!Array.isArray(a))return;const b=typeof d?.extensionId=="string"?d.extensionId:void 0,P=b==null?o:L(b);if(P.type==="local")return;const x=[];for(const R of a)typeof R!="string"||R===""||x.push(R);x.length>0&&v({apiPropertyNames:x,extension:P,initialLoad:g.initialLoad,timestamp:new Date})}}),D(U)||await s.sandbox({allowNetworkAccess:j.allowNetworkAccess,allowApiAccess:_.apiAccess,storefrontUrl:l,myshopifyDomain:k})}function L(s){return p.loadedExtensions.get(s)??o}function ie(s){const{appId:u,appName:a}=o,d=s==null?!S.isShared&&o||void 0:[...p.loadedExtensions.values()].find(b=>b.scriptUrl===s);return{appId:u,appName:a,extensionId:d?.extensionId,extensionName:d?.name}}function N(){const s=p.worker;if(s==null)throw new G("You attempted to call a function on a terminated web worker after its extension sandbox was released.");return s}const K={async render(s,u,a,d,b,P,x,R,B,ae){const w=L(x);return ee(N(),{apiFetch:ve({appId:S.isShared?S.appId:w.appId,storefrontTokens:b,storefrontUrl:l,myshopifyDomain:k,extensionType:S.isShared?S.extensionType:w.type,allowApiAccess:S.isShared?S.hasSharedApiAccess:w.capabilities.apiAccess,apiVersion:U})}),await p.extensionPreloads.get(w.id),A(),g.markStarted("execution",{extension:w,instanceId:P,type:"extension"}),D(U)?N().render({connection:u,target:w.extensionPoint.target,translations:w.translations,extensionType:w.type,scriptUrl:w.scriptUrl,api:d,instanceId:P,extensionId:w.id,allowNetworkAccess:V(w),allowApiAccess:w.capabilities.apiAccess,storefrontUrl:l,myshopifyDomain:k,initialValues:B,relayApi:ae}).then(({output:z,teardown:Q})=>({output:z,teardown:Q})):N().render(s,u,a,d,w.translations,w.type,P,R).then(({output:z,teardown:Q})=>({output:z,teardown:Q}))},async run(s,u,a,d,b,P){const x=L(d);return Ve(u),await p.extensionPreloads.get(x.id),A(),D(U)?N().run({target:x.extensionPoint.target,translations:x.translations,extensionType:x.type,scriptUrl:
5x.scriptUrl,api:u,instanceId:a,extensionId:x.id,allowNetworkAccess:V(x),allowApiAccess:x.capabilities.apiAccess,storefrontUrl:l,myshopifyDomain:k,initialValues:P}).then(({output:R,teardown:B})=>({output:R,teardown:B})):N().run(s,u,x.translations,x.type,a,b).then(({output:R,teardown:B})=>({output:R,teardown:B}))},async restart(){const s=[...p.loadedExtensions.values()];E(p),p.workerReady=X();for(const u of s)q(u);I.get("restart")?.forEach(u=>u())},on(s,u){return I.has(s)?I.get(s)?.add(u):I.set(s,new Set([u])),()=>{I.get(s)?.delete(u)}},getUserCount(){return p.userCount},isWorkerAvailable(){return p.worker!==null},loadExtension(s){q(s)}};return c.set(C,K),n.set(K,p),K}}function He({target:r,publicId:e,apiVersion:t,sandboxConfig:i}){return i.isShared?i.cacheKey():`${e}:${r}:${t}`}const Ge={id:"19a6a28598862a756fd845752b04b4eed5d189eed0b08c3a5033847732004301",type:"query",name:"ExtensionTokens",source:""},Ze=60*1e3;class St{#e;#r;#s;#t;#n;#o;#i;#a;#c;constructor({options:e,activatedExtensions:t,isCheckoutEditor:i,extensions:h,metafields:c,afterHydrate:n}){const{client:f,shop:y,observability:m,persistence:T,proposal:O,serializedReceipt:A,graphql:E,source:M}=e;this.#r=h,this.#s=c,this.#t=y,this.#n=T,this.#o=O,this.#i=A,this.#a=M,this.#e=new le,this.syncPermissions(h.value),this.sandboxCache=Xe(f,{observability:m,appSandboxPermissions:this.#e,deferThankYouPreloads:!i}),this.storefrontTokens=new Je({activatedExtensions:t,globalExtensions:y.globalUIExtensions,graphql:E,observability:m,source:M}),n.then(()=>this.#d()).catch(()=>{})}registerExtensionsManager(e){this.#c=e}syncPermissions(e){for(const t of e)t.appId&&this.#e.app(t.appId).syncExtension(t)}removePermissions(e){for(const t of e)t.appId&&this.#e.app(t.appId).removeExtension(t.id)}destroyExtensions(e,t){e.forEach(i=>{this.#c?.findAll({id:i.id,target:i.extensionPoint.target}).forEach(h=>{h.destroy({reason:t})})})}refreshStorefrontTokens(e){e.forEach(t=>{t.apiTokens?.storefrontApi&&this.storefrontTokens.cache.set(this.storefrontTokens.cacheKey(t.extension.appId,"persisted"),t.apiTokens.storefrontApi)})}#d(){Pe({metafields:this.#s,persistence:this.#n,proposal:this.#o,serializedReceipt:this.#i,source:this.#a}),this.#r.subscribe(e=>{this.sandboxCache.preload({extensions:e,storefrontUrl:this.#t.storefrontUrl??"",myshopifyDomain:this.#t.myshopifyDomain})})}}class Je{#e;#r;#s;#t;constructor({activatedExtensions:e,globalExtensions:t=[],graphql:i,observability:h,source:c}){this.#r=i,this.#s=h,this.#t=c,this.#e=new Map;for(const n of e){const f=this.cacheKey(n.extension.appId,"persisted");n.apiTokens?.storefrontApi&&this.#e.set(f,n.apiTokens.storefrontApi)}for(const n of t){const f=this.cacheKey(n.extension.appId,"global");n.apiTokens?.storefrontApi&&this.#e.set(f,n.apiTokens.storefrontApi)}}async get(e,t,i){const h=this.cacheKey(e,t),c=this.#e.get(h);if(c){if(!this.#n(c.expiresAt))return this.#o(t),c.token;this.#e.delete(h)}try{const{data:n}=await this.#r.staticQuery(Ge,{cache:!1,variables:{appId:e,extensionType:t}}),f=n?.extensionApiTokens?.storefrontApi;return f?(this.#e.set(h,f),this.#o(t),f.token):(this.#s.log("use_ensure_storefront_token_not_found_in_response","Extension storefront token not found in API response",{appId:e,extensionType:t,sourceType:this.#t.type,reason:i}),null)}catch(n){const f=n instanceof Error?n:new xe(`Failed to fetch extension storefront token for app ${e}: ${String(n)}`);return this.#s.error(f,{severity:"error",metadata:{graphQL:{name:"ExtensionTokensQuery",appId:e,extensionType:t},source:{type:this.#t.type}}}),this.#s.log("use_ensure_storefront_token_fetch_failed","Failed to fetch extension storefront token",{appId:e,extensionType:t,sourceType:this.#t.type,error:n instanceof Error?n.message:String(n),errorType:n instanceof Error?n.constructor.name:typeof n}),null}}get cache(){return this.#e}cacheKey(e,t){return`${e}-${t}`}#n(e){return Date.now()>new Date(e).getTime()-Ze}#o(e){e==="local"&&this.#t.type==="draftOrder"&&console.warn("Queries to the storefront API might not return data for certain products. The extension is currently using the online store channel for product availability. This is because the extension is in development mode, the extension is not published to the checkout configuration, and the current checkout is a draft order invoice. Install the app and add the extension in order to use draft order product availability.")}}export{Je as StorefrontTokensForBrowser,St as UIExtensibilityBrowserEngine};

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.