@occluze/tether 0.6.1 → 0.6.3

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.
Files changed (43) hide show
  1. package/README.md +15 -1
  2. package/dist/esm/astro.js +2 -2
  3. package/dist/esm/chunks/account-NVHPA7AX.js +1 -0
  4. package/dist/esm/chunks/{analytics-22NMIVBV.js → analytics-SLATWPLC.js} +1 -1
  5. package/dist/esm/chunks/{chunk-YZMBXS6Y.js → chunk-64TUD3QR.js} +1 -1
  6. package/dist/esm/chunks/{chunk-YXCXIPQV.js → chunk-AJLPU2JC.js} +1 -1
  7. package/dist/esm/chunks/{chunk-ZVUPVSLF.js → chunk-FIOZPPC5.js} +1 -1
  8. package/dist/esm/chunks/chunk-K2YEQAIH.js +1 -0
  9. package/dist/esm/chunks/chunk-L2TRRKYV.js +1 -0
  10. package/dist/esm/chunks/{chunk-4UR45XTC.js → chunk-RREHGH4A.js} +1 -1
  11. package/dist/esm/chunks/chunk-VCPI7MJ2.js +1 -0
  12. package/dist/esm/chunks/{chunk-6R752OYZ.js → chunk-ZIUIWEON.js} +1 -1
  13. package/dist/esm/chunks/diagnose-4JHU6RTC.js +11 -0
  14. package/dist/esm/chunks/{extras-QDCSW6VU.js → extras-R4X34VQL.js} +1 -1
  15. package/dist/esm/chunks/{markets-ui-HJCVLCKJ.js → markets-ui-F3R5T5EL.js} +1 -1
  16. package/dist/esm/chunks/{search-LN2H6SXS.js → search-NILMGYXG.js} +1 -1
  17. package/dist/esm/index.js +1 -1
  18. package/dist/esm/server.js +1 -1
  19. package/dist/tether.account.js +28 -2
  20. package/dist/tether.account.min.js +1 -1
  21. package/dist/tether.diagnose.js +139 -40
  22. package/dist/tether.diagnose.min.js +11 -1
  23. package/dist/tether.js +31 -9
  24. package/dist/tether.min.js +2 -2
  25. package/dist/tether.min.js.map +3 -3
  26. package/package.json +1 -1
  27. package/src/account.js +25 -4
  28. package/src/astro.js +29 -4
  29. package/src/cart.js +15 -2
  30. package/src/client.js +12 -3
  31. package/src/collection.js +5 -1
  32. package/src/config.js +1 -1
  33. package/src/diagnose.js +79 -20
  34. package/src/dom.js +2 -1
  35. package/src/index.js +1 -1
  36. package/src/server.js +7 -6
  37. package/types/astro.d.ts +2 -0
  38. package/types/server.d.ts +16 -8
  39. package/dist/esm/chunks/account-JBZJN7X7.js +0 -1
  40. package/dist/esm/chunks/chunk-BGIKQY6H.js +0 -1
  41. package/dist/esm/chunks/chunk-CISGFYOF.js +0 -1
  42. package/dist/esm/chunks/chunk-KARKXC6G.js +0 -1
  43. package/dist/esm/chunks/diagnose-6ZSK5DGE.js +0 -1
@@ -1 +0,0 @@
1
- import{c as D}from"./chunk-YZMBXS6Y.js";import{a as b,d as x}from"./chunk-4UR45XTC.js";import{c as E}from"./chunk-ZVUPVSLF.js";import{e as P}from"./chunk-YXCXIPQV.js";import{F as V,b as a,d as w,i as S,l as v,n as u,o as r,p as y,s as c}from"./chunk-KARKXC6G.js";import"./chunk-VC46IEJQ.js";var q=e=>{let o=/^(\d{4})-(01|04|07|10)$/.exec(String(e||""));return o?{y:+o[1],m:+o[2]}:null},C=(e,o)=>`${e}-${String(o).padStart(2,"0")}`;function M(e,o=1){let n=q(e);if(!n)throw new Error(`not a quarterly Shopify API version: ${e}`);let p=n.y*4+(n.m-1)/3+o;return C(Math.floor(p/4),p%4*3+1)}function A(e,o=new Date){if(e==="unstable")return{version:e,ok:!1,note:'"unstable" changes without notice: pin a dated version such as 2026-07'};let n=q(e);if(!n)return{version:e,ok:!1,note:"not a quarterly version (YYYY-01, -04, -07 or -10)"};let p=new Date(Date.UTC(n.y,n.m-1,1)),s=new Date(Date.UTC(n.y+1,n.m-1,1)),g=(s-o)/(30.44*24*3600*1e3),l=`supported until about ${s.toISOString().slice(0,7)}`;return p>o?l="not released yet (release candidate at best)":g<=0?l="no longer supported: Shopify falls back to the oldest supported version. Upgrade (see README)":g<3&&(l=`${l}: plan the upgrade to ${M(e)} or later (see README)`),{version:e,ok:p<=o&&g>0,monthsLeft:Math.round(g),next:M(e),note:l}}var I=e=>e?`${String(e).slice(0,4)}\u2026${String(e).slice(-4)} (${String(e).length} chars)`:"(missing)";function T(e){let o=e.id?`#${e.id}`:"",n=e.className&&typeof e.className=="string"?`.${e.className.trim().split(/\s+/).slice(0,2).join(".")}`:"";return`<${e.tagName.toLowerCase()}${o}${n}>`}function N(e=document){let o=[],n=(t,i,d)=>o.push({level:t,message:i,element:d?T(d):void 0,el:d}),p=t=>!!t.closest(r("product")),s=`${r("collection")},${r("products")},${r("recommendations")}`;c(e,r("product")).forEach(t=>{if(t.closest(s)&&t.closest(r("list")))return;let{key:i,fromUrl:d,raw:h}=b(t);h?d&&!i&&n("warn",`${u("product")}="${h}" but this URL has no value for it (e.g. ?handle=my-product).`,t):n("error",`${u("product")} has no value. Bind it to the Shopify handle (CMS field), or use "url:handle".`,t)}),["bind","option-list","option","variant-select","add-to-cart","purchase","plan-list","plan","qty","line-attribute"].forEach(t=>{c(e,r(t)).forEach(i=>{p(i)||t==="line-attribute"&&i.closest(r("group"))||n("warn",`${u(t)} outside any ${u("product")}: it does nothing here.`,i)})}),c(e,r("group-add")).forEach(t=>{t.closest(r("group"))||n("warn",`${u("group-add")} outside a ${u("group")}.`,t)}),[...c(e,r("option-list")),...c(e,r("plan-list")),...c(e,r("cart-lines")),...c(e,r("list"))].forEach(t=>{!t.firstElementChild&&!V(t)&&n("warn","Repeater without a template child: put one example element inside it.",t)}),c(e,s).forEach(t=>{c(t,r("list")).length||n("error",`List without a ${u("list")} child: products have nowhere to render.`,t)});let l=new Set(["in-stock","out-of-stock","backorder","low-stock","plenty-in-stock","on-sale","not-on-sale","has-variants","single-variant","subscription-available","subscription-unavailable","subscription-only","one-time-available","subscription-selected","one-time-selected","has-savings","loading","ready","error","not-found","cart-empty","cart-filled","cart-has-subscription","cart-no-subscription","cart-has-discount","cart-error","cart-warning","list-empty","list-filled"]);return c(e,r("show")).forEach(t=>{let i=y(t,"show");l.has(i)||n("warn",`Unknown ${u("show")}="${i}".`,t)}),c(e,r("bind")).forEach(t=>{let i=y(t,"bind")||"";if(!i.startsWith("metafield:"))return;let d=i.slice(10);(a.metafields||[]).some($=>(typeof $=="string"?$:`${$.namespace}.${$.key}`)===d)||n("error",`${u("bind")}="${i}" but "${d}" is not in config.metafields, so it stays empty.`,t)}),c(e,r("cart-open")).length&&!c(e,r("cart-drawer")).length&&n("warn",`${u("cart-open")} exists but there is no ${u("cart-drawer")} on this page.`),c(e,r("cart-drawer")).length>1&&n("warn",`More than one ${u("cart-drawer")}.`),c(e,`[${u("state")}="error"]`).forEach(t=>{t.matches(x())&&n("error",`Scope failed to load (${y(t,"error")||"error"}).`,t)}),o}async function G({root:e=document,silent:o=!1,version:n,now:p=new Date}={}){let s={version:n,config:{domain:a.domain||"(missing)",token:I(a.token),apiVersion:a.apiVersion,endpoint:a.domain?S():null,country:a.country,language:a.language,locale:a.locale,markets:a.markets||null,prefix:a.prefix,productPath:a.productPath,metafields:a.metafields,autoMount:a.autoMount,observe:a.observe,onError:typeof a.onError=="function"},apiVersion:A(a.apiVersion,p),market:{country:a.country||null,language:a.language||null,locale:a.locale||null,detected:a.markets?.detect?D(a.markets):null},reachable:!1,shop:null,latencyMs:null,products:[],sellingPlans:[],problems:[]};if(!w())s.problems.push({level:"error",message:"TETHER_CONFIG needs domain and token."});else{let g=Date.now();try{let l=await v("query TetherDiagnose { shop { name primaryDomain { url } paymentSettings { currencyCode } } }",{},{context:!1});s.reachable=!0,s.shop={name:l.shop?.name,url:l.shop?.primaryDomain?.url,currency:l.shop?.paymentSettings?.currencyCode}}catch(l){let t=l.status===401||l.status===403?"Token rejected: use the public Storefront token from the Headless channel, not an Admin token.":l.status===404?"Store or API version not found: check domain (x.myshopify.com) and apiVersion.":"";s.problems.push({level:"error",message:`Storefront API not reachable: ${l.message}${t?`. ${t}`:""}`})}if(s.latencyMs=Date.now()-g,s.reachable){let l=[...new Set(c(e,r("product")).map(i=>b(i).key).filter(Boolean))].slice(0,20);(await Promise.allSettled(l.map(i=>E(i)))).forEach((i,d)=>{if(i.status==="fulfilled"){let h=i.value,$=P(h);s.products.push({key:l[d],handle:h.handle,title:h.title,plans:$.length,requiresSellingPlan:h.requiresSellingPlan}),$.forEach(f=>s.sellingPlans.push({product:h.handle,group:f.group?.name,plan:f.name,id:f.id})),c(e,r("product")).filter(f=>b(f).key===l[d]&&f.querySelector(r("add-to-cart"))).forEach(f=>{let k=new Set(c(f,`${r("option-list")},select${r("option")}`).map(m=>y(m,"option-list")||y(m,"option")));!k.size&&c(f,`select${r("variant-select")}`).length||(h.options||[]).filter(m=>m.optionValues.length>1&&!k.has(m.name)).forEach(m=>{s.problems.push({level:"warn",message:`Product "${h.handle}": option "${m.name}" (${m.optionValues.length} values) has no tether-option-list, so visitors can't choose it.`})})})}else s.products.push({key:l[d],error:i.reason?.message}),s.problems.push({level:"error",message:`Product "${l[d]}": ${i.reason?.message}. Is it published to the Headless channel?`})})}}return(!s.apiVersion.ok||(s.apiVersion.monthsLeft??99)<3)&&s.problems.push({level:s.apiVersion.ok?"warn":"error",message:`apiVersion ${a.apiVersion}: ${s.apiVersion.note}`}),typeof document<"u"&&s.problems.push(...N(e)),o||U(s),s}function U(e){let o=console,n=e.problems.filter(p=>p.level==="error").length;o.group?.(`[${a.prefix}] diagnose: ${n?`${n} error(s)`:"no errors"}, ${e.problems.length-n} warning(s)`),o.log("version",e.version,"| API",e.apiVersion.version,`(${e.apiVersion.note})`),o.log("config",e.config),e.market&&o.log("market detected",e.market,"(in use:",e.config.country,e.config.language,")"),o.log(e.reachable?`Storefront API reachable: ${e.shop?.name} (${e.latencyMs} ms)`:"Storefront API NOT reachable"),e.products.length&&(o.table||o.log)(e.products),e.sellingPlans.length?(o.table||o.log)(e.sellingPlans):e.reachable&&o.log("No selling plans on the products of this page."),e.problems.forEach(p=>(p.level==="error"?o.error:o.warn)(p.message,p.el||"")),o.groupEnd?.()}export{A as apiVersionStatus,N as checkMarkup,G as diagnose};