@occluze/tether 0.6.8 → 0.7.1
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/README.md +28 -28
- package/dist/esm/astro.js +2 -2
- package/dist/esm/chunks/account-CXMA5RPZ.js +1 -0
- package/dist/esm/chunks/account-pages-IZO7FEOZ.js +1 -0
- package/dist/esm/chunks/analytics-PG5FPRDN.js +1 -0
- package/dist/esm/chunks/chunk-4HD4J5JC.js +1 -0
- package/dist/esm/chunks/chunk-6TFMLT4A.js +4 -0
- package/dist/esm/chunks/chunk-BBVUVPMO.js +1 -0
- package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
- package/dist/esm/chunks/chunk-EW5SYO6L.js +1 -0
- package/dist/esm/chunks/chunk-HJY2JSNB.js +1 -0
- package/dist/esm/chunks/chunk-MQYB6BH4.js +1 -0
- package/dist/esm/chunks/chunk-N3V45JPS.js +1 -0
- package/dist/esm/chunks/chunk-RPMBCAGS.js +1 -0
- package/dist/esm/chunks/chunk-VFNHIGCS.js +1 -0
- package/dist/esm/chunks/chunk-WT7RGGJU.js +1 -0
- package/dist/esm/chunks/chunk-YN6LEBEN.js +1 -0
- package/dist/esm/chunks/chunk-Z6HS3H7K.js +1 -0
- package/dist/esm/chunks/diagnose-XCEBQKBO.js +14 -0
- package/dist/esm/chunks/extras-4HU3VSBQ.js +1 -0
- package/dist/esm/chunks/markets-ui-M4IQ62CT.js +1 -0
- package/dist/esm/chunks/search-A5DS2IOS.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +2 -2
- package/dist/presets/barba.esm.js +19 -23
- package/dist/tether.account-pages.js +332 -367
- package/dist/tether.account-pages.min.js +1 -1
- package/dist/tether.account.js +253 -492
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.analytics.js +82 -89
- package/dist/tether.analytics.min.js +1 -1
- package/dist/tether.diagnose.js +52 -34
- package/dist/tether.diagnose.min.js +2 -2
- package/dist/tether.extras.js +42 -37
- package/dist/tether.extras.min.js +1 -1
- package/dist/tether.js +1361 -935
- package/dist/tether.markets.js +89 -91
- package/dist/tether.markets.min.js +1 -1
- package/dist/tether.min.js +0 -0
- package/dist/tether.min.js.map +4 -4
- package/dist/tether.search.js +60 -69
- package/dist/tether.search.min.js +1 -1
- package/dist/types/server/src/shared/account-orders.d.ts +44 -0
- package/dist/types/server/src/shared/account-routes.d.ts +153 -0
- package/dist/types/server/src/shared/api-versions.d.ts +13 -0
- package/dist/types/server/src/shared/cart-id.d.ts +2 -0
- package/dist/types/server/src/shared/error-message.d.ts +2 -0
- package/dist/types/server/src/shared/json.d.ts +25 -0
- package/dist/types/server/src/shared/market-codes.d.ts +16 -0
- package/dist/types/src/account/addresses-view.d.ts +5 -0
- package/dist/types/src/account/answers.d.ts +40 -0
- package/dist/types/src/account/markup.d.ts +19 -0
- package/dist/types/src/account/operations.d.ts +41 -0
- package/dist/types/src/account/order-lines.d.ts +13 -0
- package/dist/types/src/account/order-list.d.ts +12 -0
- package/dist/types/src/account/order-page.d.ts +6 -0
- package/dist/types/src/account/page-answers.d.ts +182 -0
- package/dist/types/src/account/page-events.d.ts +2 -0
- package/dist/types/src/account/server-client.d.ts +60 -0
- package/dist/types/src/account/subscriptions-view.d.ts +2 -0
- package/dist/types/src/account-api.d.ts +18 -0
- package/dist/types/src/account-marks.d.ts +15 -0
- package/dist/types/src/account-pages.d.ts +8 -0
- package/dist/types/src/account.d.ts +64 -0
- package/dist/types/src/amounts.d.ts +12 -0
- package/dist/types/src/analytics-shopify.d.ts +41 -0
- package/dist/types/src/analytics.d.ts +2 -0
- package/dist/types/src/api-version.d.ts +28 -0
- package/dist/types/src/astro.d.ts +42 -0
- package/dist/types/src/cart/cart-shape.d.ts +43 -0
- package/dist/types/src/cart/checkout.d.ts +16 -0
- package/dist/types/src/cart/drawer.d.ts +18 -0
- package/dist/types/src/cart/mutations.d.ts +85 -0
- package/dist/types/src/cart/render.d.ts +17 -0
- package/dist/types/src/cart/store.d.ts +185 -0
- package/dist/types/src/cart.d.ts +106 -0
- package/dist/types/src/client.d.ts +134 -0
- package/dist/types/src/collection.d.ts +25 -0
- package/dist/types/src/config-sections.d.ts +40 -0
- package/dist/types/src/config.d.ts +190 -0
- package/dist/types/src/controls/cart-controls.d.ts +2 -0
- package/dist/types/src/controls/discount.d.ts +2 -0
- package/dist/types/src/controls/extras.d.ts +5 -0
- package/dist/types/src/controls/navigation.d.ts +12 -0
- package/dist/types/src/diagnose-markup.d.ts +19 -0
- package/dist/types/src/diagnose.d.ts +60 -0
- package/dist/types/src/dom.d.ts +75 -0
- package/dist/types/src/extras.d.ts +21 -0
- package/dist/types/src/fragments.d.ts +158 -0
- package/dist/types/src/globals.d.ts +15 -0
- package/dist/types/src/images.d.ts +20 -0
- package/dist/types/src/index.d.ts +167 -0
- package/dist/types/src/initial.d.ts +56 -0
- package/dist/types/src/lazy.d.ts +28 -0
- package/dist/types/src/loader.d.ts +84 -0
- package/dist/types/src/market-codes.d.ts +6 -0
- package/dist/types/src/markets-ui.d.ts +32 -0
- package/dist/types/src/markets.d.ts +72 -0
- package/dist/types/src/markup.d.ts +131 -0
- package/dist/types/src/mounting.d.ts +46 -0
- package/dist/types/src/page-market.d.ts +27 -0
- package/dist/types/src/presets/barba.d.ts +56 -0
- package/dist/types/src/product-events.d.ts +2 -0
- package/dist/types/src/product-render.d.ts +17 -0
- package/dist/types/src/product-shape.d.ts +90 -0
- package/dist/types/src/product-state.d.ts +110 -0
- package/dist/types/src/product.d.ts +66 -0
- package/dist/types/src/repeaters.d.ts +16 -0
- package/dist/types/src/search.d.ts +33 -0
- package/dist/types/src/selling-plans.d.ts +64 -0
- package/dist/types/src/server.d.ts +88 -0
- package/dist/types/src/shopify-values.d.ts +46 -0
- package/dist/types/src/status.d.ts +33 -0
- package/dist/types/src/storage.d.ts +12 -0
- package/dist/types/src/store-html.d.ts +39 -0
- package/dist/types/src/storefront/catalog.d.ts +38 -0
- package/dist/types/src/storefront/json-ld.d.ts +20 -0
- package/dist/types/src/variant-render.d.ts +14 -0
- package/package.json +24 -24
- package/dist/esm/chunks/account-C3NP6HFB.js +0 -1
- package/dist/esm/chunks/account-pages-WLK374FO.js +0 -1
- package/dist/esm/chunks/analytics-G3SAWMNL.js +0 -1
- package/dist/esm/chunks/chunk-27PJJZGC.js +0 -1
- package/dist/esm/chunks/chunk-2FSXS55U.js +0 -1
- package/dist/esm/chunks/chunk-FCSWQDVV.js +0 -1
- package/dist/esm/chunks/chunk-FOMSMIAM.js +0 -1
- package/dist/esm/chunks/chunk-GZJTCLLW.js +0 -1
- package/dist/esm/chunks/chunk-HEQILZVR.js +0 -1
- package/dist/esm/chunks/chunk-JOOEXYF3.js +0 -4
- package/dist/esm/chunks/chunk-MPTQYLSM.js +0 -1
- package/dist/esm/chunks/chunk-NEHZ37TU.js +0 -3
- package/dist/esm/chunks/chunk-V74KGEJF.js +0 -1
- package/dist/esm/chunks/chunk-VT4CDUJJ.js +0 -1
- package/dist/esm/chunks/chunk-YJLWX2HK.js +0 -1
- package/dist/esm/chunks/diagnose-6VVGZNTY.js +0 -14
- package/dist/esm/chunks/extras-GJVRDFM3.js +0 -1
- package/dist/esm/chunks/markets-ui-UNB4PTA7.js +0 -1
- package/dist/esm/chunks/search-OU75RNQL.js +0 -1
- package/src/account/addresses-view.js +0 -92
- package/src/account/browser-session.js +0 -359
- package/src/account/markup.js +0 -48
- package/src/account/operations.js +0 -180
- package/src/account/order-lines.js +0 -96
- package/src/account/order-list.js +0 -91
- package/src/account/order-page.js +0 -192
- package/src/account/page-events.js +0 -288
- package/src/account/server-client.js +0 -172
- package/src/account/shared.js +0 -111
- package/src/account/shopify-auth.js +0 -150
- package/src/account/subscriptions-view.js +0 -158
- package/src/account-api.js +0 -118
- package/src/account-links.js +0 -35
- package/src/account-pages.js +0 -89
- package/src/account.js +0 -342
- package/src/amounts.js +0 -36
- package/src/analytics-shopify.js +0 -241
- package/src/analytics.js +0 -352
- package/src/api-version.js +0 -85
- package/src/astro.js +0 -266
- package/src/cart/checkout.js +0 -97
- package/src/cart/drawer.js +0 -138
- package/src/cart/mutations.js +0 -234
- package/src/cart/render.js +0 -294
- package/src/cart/store.js +0 -326
- package/src/cart.js +0 -391
- package/src/client.js +0 -267
- package/src/collection.js +0 -183
- package/src/config.js +0 -349
- package/src/controls/cart-controls.js +0 -155
- package/src/controls/discount.js +0 -96
- package/src/controls/extras.js +0 -63
- package/src/controls/navigation.js +0 -83
- package/src/diagnose-markup.js +0 -333
- package/src/diagnose.js +0 -295
- package/src/dom.js +0 -287
- package/src/extras.js +0 -145
- package/src/fragments.js +0 -237
- package/src/images.js +0 -104
- package/src/index.js +0 -353
- package/src/initial.js +0 -87
- package/src/lazy-iife.js +0 -116
- package/src/lazy.js +0 -39
- package/src/loader.js +0 -337
- package/src/market-codes.js +0 -35
- package/src/markets-ui.js +0 -204
- package/src/markets.js +0 -334
- package/src/markup.js +0 -64
- package/src/mounting.js +0 -277
- package/src/page-market.js +0 -116
- package/src/parts/account-pages.js +0 -6
- package/src/parts/account.js +0 -6
- package/src/parts/analytics.js +0 -6
- package/src/parts/diagnose.js +0 -6
- package/src/parts/extras.js +0 -6
- package/src/parts/markets.js +0 -6
- package/src/parts/search.js +0 -6
- package/src/presets/barba.js +0 -190
- package/src/product-events.js +0 -130
- package/src/product-render.js +0 -257
- package/src/product-state.js +0 -318
- package/src/product.js +0 -344
- package/src/repeaters.js +0 -173
- package/src/search.js +0 -323
- package/src/selling-plans.js +0 -154
- package/src/server.js +0 -215
- package/src/shopify-values.js +0 -89
- package/src/status.js +0 -126
- package/src/store-html.js +0 -0
- package/src/storefront/catalog.js +0 -199
- package/src/storefront/json-ld.js +0 -167
- package/src/variant-render.js +0 -165
- package/types/astro.d.ts +0 -28
- package/types/barba.d.ts +0 -16
- package/types/index.d.ts +0 -577
- package/types/server.d.ts +0 -182
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as k}from"./chunks/chunk-27PJJZGC.js";import{a as J,b as X,d as C,f as b,g as Z,h as p,i as tt,j as et,k as nt,l as rt,m as ot}from"./chunks/chunk-V74KGEJF.js";import{a as Y}from"./chunks/chunk-2FSXS55U.js";import"./chunks/chunk-HEQILZVR.js";import{a as W}from"./chunks/chunk-FCSWQDVV.js";import{a as l,b as it}from"./chunks/chunk-VT4CDUJJ.js";import{a as G,b as c}from"./chunks/chunk-MPTQYLSM.js";import{a as B,b as V,c as K,d as z,h as Q,i as j}from"./chunks/chunk-NEHZ37TU.js";import{l as F}from"./chunks/chunk-JOOEXYF3.js";import{G as U,P as m,b as r,e as D,f as L,g as E,h as O,i as a,j as N,k as _,l as v,n as H,p as R,r as d,s as i,x as g,y as q}from"./chunks/chunk-YJLWX2HK.js";import"./chunks/chunk-FOMSMIAM.js";var at={country:void 0,language:void 0,locale:void 0},x=!1;function ut(){let t=n=>document.querySelector(`meta[name="${r.prefix}-page-${n}"]`)?.getAttribute("content")||void 0,e=N(t("country"));return e?{country:e,language:_(t("language"))??void 0,locale:t("locale")}:null}async function Mt(){let t=r.markets??{};if(t.detect===!1)return null;if(!t.detect)return t.remember===!1?null:k();try{return(await l("markets")).detectMarket(t)}catch(e){return a(e,"markets"),null}}async function st(t){at={country:r.country,language:r.language,locale:r.locale};let e=ut();if(x=e!==null,e){r.country=e.country,r.language=e.language,e.locale&&(r.locale=e.locale);return}let n=await Mt();n&&(n.country&&(r.country=n.country),n.language&&(r.language=n.language),n.locale&&!t.locale&&(r.locale=n.locale),E("market",n))}var ct=(t,e)=>(t??"").toUpperCase()===(e??"").toUpperCase();function lt(){let t=ut(),e=t===null&&x;x=t!==null;let n=t??(e?k()??at:null);return!n?.country||ct(n.country,r.country)&&ct(n.language,r.language)?null:{country:n.country,language:n.language,locale:n.locale}}function y(t,e){return l("markets").then(n=>n.setCountry(t,e))}var Pt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],$t=()=>[...Pt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Dt(){let t=`${r.prefix}:account:${r.domain}`,e=`${r.prefix}:account-hint:${r.domain}`;try{return!!(sessionStorage.getItem(t)||localStorage.getItem(t)||localStorage.getItem(e))}catch{return!1}}function dt(t){!r.account?.clientId&&!r.account?.server||!(p(t,$t()).length>0||/[?&]code=/.test(window.location.search)||Dt())||l("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function s(t){return(...e)=>l("account").then(n=>{let o=n[t];return o(...e)})}var ft={login:s("login"),logout:s("logout"),handleCallback:s("handleCallback"),getToken:s("getToken"),isLoggedIn:s("isLoggedIn"),query:s("query"),customer:s("customer"),orders:s("orders"),order:s("order"),updateProfile:s("updateProfile"),addresses:s("addresses"),saveAddress:s("saveAddress"),deleteAddress:s("deleteAddress"),subscriptions:s("subscriptions"),subscriptionAction:s("subscriptionAction"),requestReturn:s("requestReturn"),render:s("render"),mountAccount:s("mountAccount")};var mt=()=>`data-${r.prefix}-key`,gt=t=>t instanceof window.Element;function yt(t){let e=t.closest(`[${mt()}]`),n=e?.getAttribute(mt());return e&&n?{line:e,id:n}:null}function w(t,e){t.catch(n=>{a(n,e)})}function Ot(t,e){let n=yt(e);if(!n?.line.closest(i("cart-lines")))return;let{line:o,id:u}=n;if(e.closest(i("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),w(c.removeLine(u),"cart line");return}let $=Nt(e);!$||!c.lines.some(It=>It.id===u)||(t.preventDefault(),w(c.changeQuantity(u,$),"cart line"))}function Nt(t){return t.closest(i("line-plus"))?1:t.closest(i("line-minus"))?-1:0}function _t(t){let{target:e}=t;if(!gt(e))return;if(e.closest(i("cart-open"))){t.preventDefault(),c.toggle();return}if(e.closest(i("cart-close"))){t.preventDefault(),c.close();return}let n=e.closest(i("cart-clear"));if(n){t.preventDefault(),m(n,()=>c.clear().catch(u=>{a(u,"cart clear")}));return}let o=e.closest(i("checkout"));if(o){t.preventDefault(),m(o,()=>c.checkout());return}Ot(t,e)}function pt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),w(e,n)}function Ht(t){let{target:e}=t;if(!gt(e))return;let n=yt(e);n&&e instanceof window.HTMLInputElement&&e.matches(i("line","quantity"))?pt(n.line,c.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(i("line-plan"))?pt(n.line,c.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Rt(e)&&e.matches(i("cart-note"))&&w(c.setNote(e.value),"cart note")}var Rt=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function qt(t){if(c.isOpen()){if(t.key==="Escape"){c.close();return}G(t)}}function ht(){document.addEventListener("click",_t),document.addEventListener("change",Ht),document.addEventListener("keydown",qt)}var A=t=>t instanceof window.Element;function Ut(t){let e=t.querySelector(i("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Et(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Ft(t,e,n){try{await c.applyDiscount(n),Et(t,e,!1),g("discount-applied",{code:n},t),e&&(e.value="")}catch(o){Et(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?g("discount-invalid",{code:n},t):a(o,"discount")}}function Gt(t){let{target:e}=t,n=A(e)?e.closest(i("discount-form")):null;if(!n)return;t.preventDefault();let o=Ut(n),u=o?.value.trim();u&&m(n,()=>Ft(n,o,u))}function Bt(t){let{target:e}=t;if(!A(e))return;let n=e.closest(i("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function Vt(t){let{target:e}=t,n=A(e)?e.closest(i("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(i("discount-code"))?.getAttribute(d("discount-code"));o&&c.removeDiscount(o).catch(u=>{a(u,"discount")})}function vt(){document.addEventListener("submit",Gt,!0),document.addEventListener("input",Bt),document.addEventListener("click",Vt)}var T=t=>l("extras").then(e=>e.addGroup(t)),S=t=>{a(t,"extras")};function Kt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(i("group-add")):null;n&&(t.preventDefault(),m(n,()=>T(n)).catch(S))}function zt(t){!r.domain||!t.key?.startsWith(`${r.prefix}:`)||l("extras").then(e=>{e.onStorage(t)}).catch(S)}function Qt(t){let{target:e}=t;e instanceof window.Element&&(!r.variantUrl&&!e.hasAttribute(d("variant-url"))||l("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(S))}function bt(){document.addEventListener("click",Kt),window.addEventListener("storage",zt),document.addEventListener(`${r.prefix}:variant-changed`,Qt)}var I=null;function wt(){I=document.body}async function jt(t){await t.ready();let e=lt();if(!e){I!==document.body&&t.mount(document);return}try{await y(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Wt(t){document.addEventListener("astro:page-load",()=>{jt(t)}),document.addEventListener("astro:before-swap",()=>{I=null,t.unmount()})}function Yt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(i("country-select"))||e.value&&y(e.value).catch(n=>{a(n,"country")})}function Jt(){et(),b.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Lt(t){r.astro&&Wt(t),document.addEventListener("change",Yt),window.addEventListener("online",Jt)}var kt="0.6.8",Xt=["product-ready","list-ready","cart-updated","cart-toggled","checkout","search"],Zt=50,xt=()=>window,f=null,M=null,At=null,Ct=!1;function te(t){let e=0;return p(t,J()).forEach(n=>{if(C.has(n))return;C.add(n),e++;let o=new X(n);b.add(o),n.addEventListener(`${r.prefix}:list-rendered`,u=>{h(u.detail.container)}),nt(o.load())}),e}function ee(t){p(t,`${i("country-select")},${i("country-bind")}`).length&&l("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),dt(t),p(t,i("search")).length&&l("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function h(t=document){if(!L())return 0;t===document&&wt(),Z(),ot(t.ownerDocument??document);let e=te(t);return p(t,i("product")).forEach(n=>{tt(n)&&e++}),ee(t),rt(),c.render(),E(`mounted ${e} scope(s)`,t),e}function Tt(){c.close()}function ne(t){let e=t?.closest(i("product"));return e?Y.get(e)??null:null}function re(){Ct||(Ct=!0,ht(),vt(),bt(),Lt({ready:()=>f??Promise.resolve(null),mount:h,unmount:Tt}))}function oe(){let t=[];At=t,Xt.forEach(e=>{document.addEventListener(`${r.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",()=>t.push(new CustomEvent(`${r.prefix}:page`))),l("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ie(t){let e=r.country?.toUpperCase(),n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await c.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function St(t={}){return f&&!Object.keys(t).length?f:(D({...xt().TETHER_CONFIG,...t}),L()?(re(),r.observe&&ce(),r.analytics&&!At&&oe(),f=st(t).then(()=>c.init()).then(ie).then(e=>(g("ready",{cart:e}),P)),f):(O("TETHER_CONFIG is missing domain or token. Tether is idle."),f=Promise.resolve(null),f))}function ce(){if(M||typeof MutationObserver>"u")return;let t,e=new Set;M=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(u=>{u instanceof window.Element&&e.add(u)})}),clearTimeout(t),t=setTimeout(()=>{e.forEach(o=>{o.isConnected&&h(o)}),e.clear()},Zt)}),M.observe(document.body,{childList:!0,subtree:!0})}var ae=t=>l("markets").then(e=>e.detectMarket(t??r.markets)),ue=()=>l("markets").then(t=>t.getLocalization()),se=t=>l("diagnose").then(e=>e.diagnose({...t,version:kt}));function le(t,e){let n=o=>{let u=o;e(u.detail,u)};return document.addEventListener(`${r.prefix}:${t}`,n),()=>{document.removeEventListener(`${r.prefix}:${t}`,n)}}var P={VERSION:kt,init:St,mount:h,unmount:Tt,get config(){return r},get ready(){return f??Promise.resolve(null)},query:R,withContext:H,cart:c,getProduct:K,getProducts:Q,getRecommendations:j,getScope:ne,addGroup:T,account:ft,primeProduct:V,normalizeProductKey:B,clearProductCache:z,formatMoney:U,imageUrl:q,plans:F,TetherError:v,resolveProductKey:W,setCountry:y,detectMarket:ae,getLocalization:ue,diagnose:se,__core:it,__parts:{},on:le},nn=P;function de(){let t=xt();if(t.Tether=P,!t.TETHER_CONFIG||t.TETHER_CONFIG.autoMount===!1||t.TETHER_INTEGRATION)return;let e=()=>{St().then(()=>h(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&de();export{kt as VERSION,T as addGroup,P as api,nn as default,ne as getScope,St as init,h as mount,y as setCountry,Tt as unmount};
|
|
1
|
+
import{a as nt,b as ot,d as T,f as w,g as C,h as p,i as rt,j as it,k as st,l as k,m as S}from"./chunks/chunk-4HD4J5JC.js";import{a as at,b as ct,c as h}from"./chunks/chunk-EW5SYO6L.js";import"./chunks/chunk-RPMBCAGS.js";import{a as et}from"./chunks/chunk-YN6LEBEN.js";import"./chunks/chunk-BBVUVPMO.js";import{a as tt}from"./chunks/chunk-VFNHIGCS.js";import{a as ut,b as lt,c as dt}from"./chunks/chunk-WT7RGGJU.js";import{a as l,b as mt}from"./chunks/chunk-Z6HS3H7K.js";import{a as z,b as Z,e as s}from"./chunks/chunk-HJY2JSNB.js";import{D as J,E as X,o as q,t as K,u as Q,v as W,w as Y}from"./chunks/chunk-6TFMLT4A.js";import{D as j,K as P,N as f,a as v,g as _,k as G,m as d,n as r,s as U,t as g,u as y,v as B}from"./chunks/chunk-MQYB6BH4.js";import{e as H,r as c,s as $,v as V,w as E,x as L,y as F,z as a}from"./chunks/chunk-E5YO6274.js";var Nt=["account-login","account-bind","account-link","orders","order","addresses","subscriptions","profile-form","address-form"],Ot=()=>[...Nt.map(t=>`[${d(t)}]`),`[${d("show")}^="logged-"]`].join(",");function Dt(){return!!Z(ut())}function ft(t){!c.account||!(p(t,Ot()).length>0||dt(new URLSearchParams(window.location.search).get("account"))||Dt())||l("account").then(n=>n.mountAccount(t)).catch(n=>{a(n,"account")})}function u(t){return(...e)=>l("account").then(n=>{let o=n[t];return o(...e)})}var pt={login:u("login"),logout:u("logout"),isLoggedIn:u("isLoggedIn"),customer:u("customer"),orders:u("orders"),order:u("order"),updateProfile:u("updateProfile"),addresses:u("addresses"),saveAddress:u("saveAddress"),deleteAddress:u("deleteAddress"),subscriptions:u("subscriptions"),subscriptionAction:u("subscriptionAction"),requestReturn:u("requestReturn"),render:u("render"),mountAccount:u("mountAccount")};var gt=()=>`data-${c.prefix}-key`,ht=t=>t instanceof window.Element;function Et(t){let e=t.closest(`[${gt()}]`),n=e?.getAttribute(gt());return e&&n?{line:e,id:n}:null}function A(t,e){t.catch(n=>{a(n,e)})}function Rt(t,e){let n=Et(e);if(!n?.line.closest(r("cart-lines")))return;let{line:o,id:i}=n;if(e.closest(r("line-remove"))){t.preventDefault(),o.classList.add("is-busy"),A(s.removeLine(i),"cart line");return}let R=Ht(e);!R||!s.lines.some(It=>It.id===i)||(t.preventDefault(),A(s.changeQuantity(i,R),"cart line"))}function Ht(t){return t.closest(r("line-plus"))?1:t.closest(r("line-minus"))?-1:0}function $t(t){let{target:e}=t;if(!ht(e))return;if(e.closest(r("cart-open"))){t.preventDefault(),s.toggle();return}if(e.closest(r("cart-close"))){t.preventDefault(),s.close();return}let n=e.closest(r("cart-clear"));if(n){t.preventDefault(),f(n,()=>s.clear().catch(i=>{a(i,"cart clear")}));return}let o=e.closest(r("checkout"));if(o){t.preventDefault(),f(o,()=>s.checkout());return}Rt(t,e)}function yt(t,e,n){t.classList.add("is-busy"),t.setAttribute("aria-busy","true"),A(e,n)}function Vt(t){let{target:e}=t;if(!ht(e))return;let n=Et(e);n&&e instanceof window.HTMLInputElement&&e.matches(r("line","quantity"))?yt(n.line,s.updateLine(n.id,parseInt(e.value,10)||0),"cart line"):n&&e instanceof window.HTMLSelectElement&&e.matches(r("line-plan"))?yt(n.line,s.updateLine(n.id,{sellingPlanId:e.value||null}),"cart line plan"):Ft(e)&&e.matches(r("cart-note"))&&A(s.setNote(e.value),"cart note")}var Ft=t=>t instanceof window.HTMLInputElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLSelectElement;function _t(t){if(s.isOpen()){if(t.key==="Escape"){s.close();return}z(t)}}function vt(){document.addEventListener("click",$t),document.addEventListener("change",Vt),document.addEventListener("keydown",_t)}var x=t=>t instanceof window.Element;function Gt(t){let e=t.querySelector(r("discount-input"))??t.querySelector("input");return e instanceof window.HTMLInputElement?e:null}function Pt(t,e,n){t.classList.toggle("is-invalid",n),n?e?.setAttribute("aria-invalid","true"):e?.removeAttribute("aria-invalid")}async function Ut(t,e,n){try{await s.applyDiscount(n),Pt(t,e,!1),y("discount-applied",{code:n},t),e&&(e.value="")}catch(o){Pt(t,e,!0),o instanceof v&&o.code==="INVALID_DISCOUNT"?y("discount-invalid",{code:n},t):a(o,"discount")}}function Bt(t){let{target:e}=t,n=x(e)?e.closest(r("discount-form")):null;if(!n)return;t.preventDefault();let o=Gt(n),i=o?.value.trim();i&&f(n,()=>Ut(n,o,i))}function jt(t){let{target:e}=t;if(!x(e))return;let n=e.closest(r("discount-form"));n&&(n.classList.remove("is-invalid"),e.removeAttribute("aria-invalid"))}function qt(t){let{target:e}=t,n=x(e)?e.closest(r("discount-remove")):null;if(!n)return;t.preventDefault();let o=n.closest(r("discount-code"))?.getAttribute(d("discount-code"));o&&s.removeDiscount(o).catch(i=>{a(i,"discount")})}function wt(){document.addEventListener("submit",Bt,!0),document.addEventListener("input",jt),document.addEventListener("click",qt)}var M=t=>l("extras").then(e=>e.addGroup(t)),I=t=>{a(t,"extras")};function zt(t){let{target:e}=t,n=e instanceof window.Element?e.closest(r("group-add")):null;n&&(t.preventDefault(),f(n,()=>M(n)).catch(I))}function Kt(t){!c.domain||!t.key?.startsWith(`${c.prefix}:`)||l("extras").then(e=>{e.onStorage(t)}).catch(I)}function Qt(t){if(!g(t,"variant-changed"))return;let{target:e}=t;e instanceof window.Element&&(!c.variantUrl&&!e.hasAttribute(d("variant-url"))||l("extras").then(n=>{n.writeVariantUrl(e,t.detail)}).catch(I))}function At(){document.addEventListener("click",zt),window.addEventListener("storage",Kt),document.addEventListener(`${c.prefix}:variant-changed`,Qt)}var N=null;function bt(){N=document.body}async function Wt(t){await t.ready();let e=ct();if(!e){N!==document.body&&t.mount(document);return}try{await h(e.country,{language:e.language??null,locale:e.locale,remember:!1})}catch(n){a(n,"country")}t.mount(document)}function Yt(t){document.addEventListener("astro:page-load",()=>{Wt(t).catch(e=>{a(e,"page mount")})}),document.addEventListener("astro:before-swap",()=>{N=null,t.unmount()})}function Jt(t){let{target:e}=t;!(e instanceof window.HTMLSelectElement)||!e.matches(r("country-select"))||e.value&&h(e.value).catch(n=>{a(n,"country")})}function Xt(){it(),w.forEach(t=>{t.root.getAttribute(d("state"))==="error"&&t.load()})}function Lt(t){c.astro&&Yt(t),document.addEventListener("change",Jt),window.addEventListener("online",Xt)}var Ct="0.7.1",Zt=50;function te(){let t=P("TETHER_CONFIG");return typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t)):{}}var m=null,O=null,kt=null,Tt=!1;function ee(t){let e=0;return p(t,nt()).forEach(n=>{if(T.has(n))return;T.add(n),e++;let o=new ot(n);w.add(o),n.addEventListener(`${c.prefix}:list-rendered`,i=>{g(i,"list-rendered")&&b(i.detail.container)}),st(o.load())}),e}function ne(t){p(t,`${r("country-select")},${r("country-bind")}`).length&&l("markets").then(e=>e.renderCountrySelects(t)).catch(e=>{a(e,"markets")}),ft(t),p(t,r("search")).length&&l("search").then(e=>{e.mountSearch(t)}).catch(e=>{a(e,"search")})}function St(t){let e=ee(t);return p(t,r("product")).forEach(n=>{rt(n)&&e++}),ne(t),e}function b(t=document){if(!E())return 0;t===document&&bt(),C(),S(t.ownerDocument??document);let e=St(t);return k(),s.render(),L(`mounted ${e} scope(s)`,t),e}function oe(t){let e=t.filter(o=>o.isConnected&&!t.some(i=>i!==o&&i.contains(o)));if(!e.length||!E())return;C(),e.forEach(o=>{S(o)});let n=e.reduce((o,i)=>o+St(i),0);k(),s.render(),L(`mounted ${n} scope(s) in ${e.length} added element(s)`)}function xt(){s.close()}function re(t){let e=t?.closest(r("product"));return e?et.get(e)??null:null}function ie(){Tt||(Tt=!0,vt(),wt(),At(),Lt({ready:()=>m??Promise.resolve(null),mount:b,unmount:xt}))}function se(){let t=[];kt=t,U.forEach(e=>{document.addEventListener(`${c.prefix}:${e}`,n=>t.push(n))}),document.addEventListener("astro:page-load",e=>t.push(e)),l("analytics").then(e=>e.startAnalytics(t)).catch(e=>{a(e,"analytics")})}async function ae(t){let e=c.country,n=t?.buyerIdentity.countryCode;if(!t||!e||!n||n===e)return t;try{return await s.setBuyerIdentity({countryCode:e},{create:!1})}catch(o){return a(o,"cart country"),t}}function Mt(t={}){return m&&!Object.keys(t).length?m:(V({...te(),...t}),E()?(lt(),ie(),c.observe&&ce(),c.analytics&&!kt&&se(),m=at(t).then(()=>s.init()).then(ae).then(e=>(y("ready",{cart:e}),D)),m):(F("TETHER_CONFIG is missing domain or token. Tether is idle."),m=Promise.resolve(null),m))}function ce(){if(O||typeof MutationObserver>"u")return;let t,e=new Set;O=new MutationObserver(n=>{n.forEach(o=>{o.addedNodes.forEach(i=>{i instanceof window.Element&&e.add(i)})}),clearTimeout(t),t=setTimeout(()=>{let o=[...e];e.clear(),oe(o)},Zt)}),O.observe(document.body,{childList:!0,subtree:!0})}var ue=t=>l("markets").then(e=>e.detectMarket(t??c.markets)),le=()=>l("markets").then(t=>t.getLocalization()),de=t=>l("diagnose").then(e=>e.diagnose({...t,version:Ct}));function me(t,e){let n=`${c.prefix}:${t}`,o=i=>{g(i,t)&&e(i.detail,i)};return document.addEventListener(n,o),()=>{document.removeEventListener(n,o)}}var fe={VERSION:Ct,init:Mt,mount:b,unmount:xt,get config(){return $},get ready(){return m??Promise.resolve(null)},query:G,withContext:_,cart:s,getProduct:W,getProducts:J,getRecommendations:X,getScope:re,addGroup:M,account:pt,primeProduct:Q,normalizeProductKey:K,clearProductCache:Y,formatMoney:j,imageUrl:B,plans:q,TetherError:v,resolveProductKey:tt,setCountry:h,detectMarket:ue,getLocalization:le,diagnose:de,on:me},pe={__core:mt,__parts:{}},D=Object.assign(fe,pe),sn=D;function ge(){Reflect.set(window,"Tether",D);let t=P("TETHER_CONFIG");if(!t||H(t,"autoMount")===!1||P("TETHER_INTEGRATION"))return;let e=()=>{Mt().then(()=>b(document)).catch(n=>{a(n,"init")})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",e,{once:!0}):e()}typeof window<"u"&&typeof document<"u"&&ge();export{Ct as VERSION,M as addGroup,D as api,sn as default,re as getScope,Mt as init,b as mount,h as setCountry,xt as unmount};
|
package/dist/esm/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as
|
|
2
|
-
${
|
|
1
|
+
import{b as G,f as H,g as Q}from"./chunks/chunk-BBVUVPMO.js";import{A as J,B as K,C as j,a as M,c as T,h as v,i as b,j as $,l as F,o as q,q as V,s as B}from"./chunks/chunk-6TFMLT4A.js";import{C as _,a as S,c as k,d as C,f as L,g as rt,h as P,j as N,v as D}from"./chunks/chunk-MQYB6BH4.js";import{B as E,E as U,F as I,G as O,q as g,t as A}from"./chunks/chunk-E5YO6274.js";function Y(t,e={}){if(!t)return null;let{variant:r,sellingPlan:a,defaultPurchase:c=g.defaultPurchase,lowStock:u=g.lowStock}=e,d=H(t,{variant:r,sellingPlan:a,defaultPurchase:c}),n=Q(t,{...d,quantity:1},u);if(!n)throw new S(`Product ${t.handle} has no variants`);let{selected:l,line:p}=n,i=(o,s)=>!G(t,l,o,s);return{variant:n.variant,selected:l,purchase:n.purchase.kind,plan:p.kind==="subscription"?n.plan:null,plans:v(t).map(o=>({id:o.id,name:o.name,price:$(n.variant,o.id),savings:F(n.variant,o.id).percentage,selected:p.kind==="subscription"&&o.id===p.planId,available:!!b(n.variant,o.id)})),savings:n.savings.percentage,price:n.price,compareAtPrice:n.compareAtPrice,available:n.variant.availableForSale,show:n.show,unavailable:Object.fromEntries(t.options.map(o=>[o.name,o.optionValues.map(s=>s.name).filter(s=>i(o.name,s))])),isUnavailable:i}}var ot=500,it=100,at=100,st="query TetherServerProductById($id:ID!){node(id:$id){... on Product{...TetherProduct}}}",lt="query TetherServerProduct($handle:String!){product(handle:$handle){...TetherProduct}}",ct=()=>`query TetherServerCollection($handle:String!,$first:Int!,$after:String,$sortKey:ProductCollectionSortKeys,$reverse:Boolean,$filters:[ProductFilter!]){collection(handle:$handle){${T()} products(first:$first,after:$after,sortKey:$sortKey,reverse:$reverse,filters:$filters){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}}`,ut="query TetherServerProducts($first:Int!,$after:String,$query:String,$sortKey:ProductSortKeys,$reverse:Boolean){products(first:$first,after:$after,query:$query,sortKey:$sortKey,reverse:$reverse){nodes{...TetherProduct}pageInfo{hasNextPage endCursor}}}",dt=()=>`query TetherServerCollections($first:Int!,$after:String){collections(first:$first,after:$after){nodes{${T()}}pageInfo{hasNextPage endCursor}}}`,ft=t=>`query TetherServerRecs(${t?"$id: ID!":"$handle: String!"},$intent:ProductRecommendationIntent){productRecommendations(${t?"productId: $id":"productHandle: $handle"},intent:$intent){...TetherProduct}}`,pt=C({product:k(V)}),mt=C({node:k(B)}),gt=C({collections:{nodes:[{handle:"string"}],pageInfo:{hasNextPage:"boolean"}}});async function yt(t){let e=[],r=null;for(let a=0;a<at;a++){let c=await P(t,dt(),{first:it,after:r},gt);if(e.push(...c.collections.nodes),!c.collections.pageInfo.hasNextPage)break;r=c.collections.pageInfo.endCursor}return e}function z(t,e){let r=(i,o,s)=>P(t,f=>`${i}
|
|
2
|
+
${M(t,f)}`,o,s);async function a(i){let o=O(i);if(!o)return null;if(o.startsWith("gid://")){let{node:f}=await r(st,{id:o},mt);return f?.id?f:null}return(await r(lt,{handle:o},pt)).product}async function c(i,{first:o=e,after:s=null,sortKey:f,reverse:m=!1,filters:w}){let h=await r(ct(),{handle:i,first:o,after:s,sortKey:f||void 0,reverse:m,filters:w??void 0},J);if(!h.collection)return{collection:null,products:[],pageInfo:{hasNextPage:!1,endCursor:null}};let{products:y,...nt}=h.collection;return{collection:nt,products:y.nodes,pageInfo:y.pageInfo}}async function u(i={}){let{collection:o,query:s,first:f=e,after:m=null,sortKey:w,reverse:h=!1}=i;if(o)return c(o,i);let y=await r(ut,{first:f,after:m,query:s||void 0,sortKey:w||void 0,reverse:h},K);return{collection:null,products:y.products.nodes,pageInfo:y.products.pageInfo}}async function d(i={}){let o=[],s=null;for(let f=0;f<ot;f++){let m=await u({...i,first:e,after:s});if(o.push(...m.products),!m.pageInfo.hasNextPage)break;s=m.pageInfo.endCursor}return o}async function n(i,o={}){let s=await u({...o,collection:i});return s.collection?{...s.collection,products:s.products,pageInfo:s.pageInfo}:null}async function l(i,o="RELATED"){let s=O(typeof i=="object"?i?.id:i),f=s?.startsWith("gid://")??!1;return(await r(ft(f),f?{id:s,intent:o}:{handle:s,intent:o},j)).productRecommendations??[]}return{getProduct:a,getProducts:u,allProducts:d,getCollection:n,allCollections:()=>yt(t),getRecommendations:l}}var X={size:"https://schema.org/size",color:"https://schema.org/color",colour:"https://schema.org/color",material:"https://schema.org/material"},R=t=>JSON.stringify(t).replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");function W(t){return JSON.parse(JSON.stringify(t))}var Z=t=>t.split("/").pop()??t;function Pt(t){return t.availableForSale?t.currentlyNotInStock?"https://schema.org/BackOrder":"https://schema.org/InStock":"https://schema.org/OutOfStock"}function ht(t,e){if(!t.requiresSellingPlan)return e.price;let r=v(t).find(a=>b(e,a.id));return(r&&$(e,r.id))??e.price}function tt(t,e,r){let a=ht(t,e),c=r?.includes("?")?"&":"?";return{"@type":"Offer",price:a.amount,priceCurrency:a.currencyCode,availability:Pt(e),url:r?`${r}${c}variant=${Z(e.id)}`:void 0}}function St(t,e,r,a){let c=e.selectedOptions.flatMap(u=>{let d=X[u.name.toLowerCase()];return d?[[d.split("/").pop()??d,u.value]]:[]});return{"@type":"Product",name:`${t.title} - ${e.title}`,sku:e.sku||void 0,image:e.image?.url||a[0],...Object.fromEntries(c),offers:tt(t,e,r)}}function Ct(t,{url:e},r){if(e)return e;let a=I(r.productPath,t.handle,t.id);if(!(!r.siteUrl||!a))return new URL(a,r.siteUrl).toString()}function x(t,e,r){if(!t)return null;let a=Ct(t,e,r),c=t.images.nodes.map(i=>i.url).filter(Boolean),u=e.brand||t.vendor,d=u?{"@type":"Brand",name:u}:void 0,n=t.description.trim()||void 0,l=t.variants.nodes;if(l.length<=1){let[i]=l;return W({"@context":"https://schema.org","@type":"Product",name:t.title,description:n,url:a,image:c,sku:i?.sku||void 0,brand:d,offers:i?tt(t,i,a):void 0})}let p=t.options.map(i=>X[i.name.toLowerCase()]).filter(Boolean);return W({"@context":"https://schema.org","@type":"ProductGroup",name:t.title,description:n,url:a,productGroupID:Z(t.id),image:c,brand:d,variesBy:[...new Set(p)],hasVariant:l.map(i=>St(t,i,a,c))})}var It=25,Ot=2,vt=1;function bt(t,{productPath:e=g.productPath,id:r}={}){return I(e,t,r)}function et(t,e){for(let r of e){let a=t[r];if(typeof a=="string"&&a)return a}return""}function $t(t){let e={};for(let[u,d]of Object.entries(t))u in g&&(e[u]=d);let r=typeof t.domain=="string"&&t.domain?t.domain:"",a=typeof t.token=="string"&&t.token?t.token:"",c=A({...e,domain:r||et(t,E.domain),token:a||et(t,E.token)});return t.fetch&&(c.fetch=t.fetch),t.pageSize!==void 0&&(c.pageSize=t.pageSize),t.siteUrl!==void 0&&(c.siteUrl=t.siteUrl),c}var wt=t=>typeof t=="number"&&Number.isInteger(t)&&t>0?t:It;function kt(t,e){return{...t,description:"",descriptionHtml:"",images:{nodes:t.images.nodes.slice(0,Math.max(1,e))},variants:{nodes:t.variants.nodes.map(r=>({...r,image:null}))}}}function Yt(t={}){let e=$t(t);if(!e.domain||!e.token)throw new S("createStorefront needs domain and token: pass them, or import.meta.env with PUBLIC_SHOPIFY_DOMAIN and PUBLIC_SHOPIFY_STOREFRONT_TOKEN",{code:"NOT_CONFIGURED"});let r=z(e,wt(e.pageSize)),a={productPath:e.productPath,siteUrl:e.siteUrl};function c(n,{card:l=!1,images:p=Ot}={}){let i=(Array.isArray(n)?n:[n]).filter(s=>s!=null),o={v:vt,at:new Date().toISOString(),country:e.country||null,language:e.language||null,products:l?i.map(s=>kt(s,p)):i};return`<script type="application/json" data-tether-hydrate>${R(o)}<\/script>`}function u(n,l={}){return n?`<script type="application/ld+json">${R(x(n,l,a))}<\/script>`:""}function d(n,l={}){return Y(n,{defaultPurchase:e.defaultPurchase,lowStock:e.lowStock,...l})}return{config:e,query:(n,l,p)=>P(e,n,l??{},N,{...p,operation:L(n)}),...r,hydrate:c,formatMoney:(n,l=e.locale)=>U(n,l),formatPercent:(n,l=e.locale)=>_(n,l),imageUrl:D,jsonLd:u,jsonLdData:(n,l={})=>x(n,l,a),initialState:d,productUrl:(n,l={})=>bt(n,{productPath:e.productPath,...l}),plans:q}}export{S as TetherError,Yt as createStorefront,U as formatMoney,_ as formatPercent,D as imageUrl,Y as initialState,q as plans,O as productKey,bt as productUrl,rt as withContext};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/presets/barba.
|
|
1
|
+
// src/presets/barba.ts
|
|
2
2
|
var LINE_DURATION_SECONDS = 0.3;
|
|
3
3
|
var collapsed = () => ({
|
|
4
4
|
height: 0,
|
|
@@ -10,31 +10,27 @@ var collapsed = () => ({
|
|
|
10
10
|
});
|
|
11
11
|
var ANIMATED_PROPS = "height,paddingTop,paddingBottom,borderBottomWidth,opacity,overflow";
|
|
12
12
|
var reducedMotion = () => typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
option
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
var GETTER_OPTIONS = ["gsap", "lenis", "scrollTrigger"];
|
|
14
|
+
function checkGetters(options) {
|
|
15
|
+
for (const name of GETTER_OPTIONS) {
|
|
16
|
+
const option = options[name];
|
|
17
|
+
if (option !== void 0 && option !== null && typeof option !== "function") {
|
|
18
|
+
throw new TypeError(`barbaPreset: ${name} must be a function that returns it, such as () => ${name}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
20
21
|
}
|
|
21
22
|
function callIfPresent(target, method) {
|
|
22
|
-
if (typeof target !== "object" || target === null) return;
|
|
23
|
+
if (typeof target !== "object" && typeof target !== "function" || target === null) return;
|
|
23
24
|
const fn = Reflect.get(target, method);
|
|
24
25
|
if (typeof fn === "function") fn.call(target);
|
|
25
26
|
}
|
|
26
27
|
var isGsap = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "fromTo") === "function" && typeof Reflect.get(value, "to") === "function";
|
|
27
28
|
function barbaPreset(options = {}) {
|
|
29
|
+
checkGetters(options);
|
|
28
30
|
const {
|
|
29
|
-
gsap = () => (
|
|
30
|
-
/** @type {unknown} */
|
|
31
|
-
Reflect.get(window, "gsap")
|
|
32
|
-
),
|
|
31
|
+
gsap = () => Reflect.get(window, "gsap"),
|
|
33
32
|
lenis = null,
|
|
34
|
-
scrollTrigger = () => (
|
|
35
|
-
/** @type {unknown} */
|
|
36
|
-
Reflect.get(window, "ScrollTrigger")
|
|
37
|
-
),
|
|
33
|
+
scrollTrigger = () => Reflect.get(window, "ScrollTrigger"),
|
|
38
34
|
lockScroll = null,
|
|
39
35
|
unlockScroll = null,
|
|
40
36
|
onResize = null,
|
|
@@ -45,23 +41,23 @@ function barbaPreset(options = {}) {
|
|
|
45
41
|
let locked = false;
|
|
46
42
|
const animator = (node) => {
|
|
47
43
|
if (!animateLines || reducedMotion() || node.offsetHeight <= 0) return null;
|
|
48
|
-
const animation =
|
|
44
|
+
const animation = gsap();
|
|
49
45
|
return isGsap(animation) ? animation : null;
|
|
50
46
|
};
|
|
51
47
|
return {
|
|
52
48
|
autoMount: false,
|
|
53
49
|
onLayoutChange() {
|
|
54
|
-
callIfPresent(
|
|
55
|
-
callIfPresent(
|
|
50
|
+
callIfPresent(lenis?.(), "resize");
|
|
51
|
+
callIfPresent(scrollTrigger(), "refresh");
|
|
56
52
|
},
|
|
57
53
|
onCartOpen(drawers) {
|
|
58
54
|
const drawer = drawers[0];
|
|
59
|
-
if (locked ||
|
|
55
|
+
if (locked || !lockScroll || !drawer) return;
|
|
60
56
|
lockScroll(drawer);
|
|
61
57
|
locked = true;
|
|
62
58
|
},
|
|
63
59
|
onCartClose() {
|
|
64
|
-
if (locked &&
|
|
60
|
+
if (locked && unlockScroll) unlockScroll();
|
|
65
61
|
locked = false;
|
|
66
62
|
},
|
|
67
63
|
onLineEnter(node) {
|
|
@@ -94,7 +90,7 @@ function barbaPreset(options = {}) {
|
|
|
94
90
|
}
|
|
95
91
|
});
|
|
96
92
|
},
|
|
97
|
-
onValueChange
|
|
93
|
+
onValueChange
|
|
98
94
|
};
|
|
99
95
|
}
|
|
100
96
|
var barba_default = barbaPreset;
|