@latchprotocol/widgets 0.1.1 → 0.1.2
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 +2 -2
- package/dist/chunks/{SwapWidget-CwkRtOfn.js → SwapWidget-B0oDyBNK.js} +2 -2
- package/dist/chunks/{SwapWidget-CwkRtOfn.js.map → SwapWidget-B0oDyBNK.js.map} +1 -1
- package/dist/chunks/{scan-Dhu7f4Nl.js → scan-Cdm3p_wF.js} +2 -2
- package/dist/chunks/scan-Cdm3p_wF.js.map +1 -0
- package/dist/chunks/{useLocker-CGpgCh75.js → useLocker-m3WH-bQm.js} +2 -2
- package/dist/chunks/{useLocker-CGpgCh75.js.map → useLocker-m3WH-bQm.js.map} +1 -1
- package/dist/embed/lockBadge.d.ts +1 -1
- package/dist/embed.js +6 -6
- package/dist/embed.js.map +1 -1
- package/dist/headless.js +2 -2
- package/dist/index.js +9 -9
- package/dist/index.js.map +1 -1
- package/dist/latch-embed.js +1 -1
- package/dist/latch-embed.js.map +1 -1
- package/dist/latch-embed.mjs +1 -1
- package/dist/latch-embed.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/scan-Dhu7f4Nl.js.map +0 -1
package/dist/latch-embed.js
CHANGED
|
@@ -946,5 +946,5 @@ ${ks(p)}`),super(t.shortMessage,{cause:t,docsPath:a,metaMessages:[...t.metaMessa
|
|
|
946
946
|
.latch-embed-badge { gap: 4px; }
|
|
947
947
|
.latch-embed-badge__retry { font: inherit; font-size: 11px; background: none; border: 0; padding: 0; color: var(--latch-accent); cursor: pointer; text-decoration: underline; }
|
|
948
948
|
`,rl=typeof HTMLElement>"u"?class{}:HTMLElement,Dn=new Map;function Wr(e){const t=Number(e("chain")??"");if(!Number.isInteger(t)||t<=0)return{ok:!1,message:'Set the chain attribute to a chain id, e.g. chain="4663".'};const n=e("pool"),a=e("token");if(n!==null&&n!==""){if(!/^0x[0-9a-fA-F]{64}$/.test(n))return{ok:!1,message:"The pool attribute is not a 32-byte pool id."};const r=(e("pool-type")??"cl").toLowerCase();return{ok:!0,chainId:t,target:{kind:"pool",poolId:n,poolType:r==="bin"?"bin":"cl"}}}return a!==null&&a!==""?X(a,{strict:!1})?{ok:!0,chainId:t,target:{kind:"token",token:a}}:{ok:!1,message:"The token attribute is not an address."}:{ok:!1,message:"Set a pool or a token attribute."}}class Vr extends rl{constructor(){super(...arguments);se(this,M);se(this,le,null);se(this,Re,null);se(this,re,{k:"loading"});se(this,ze,0);se(this,ve,null);se(this,ke,null);se(this,je,null)}static get observedAttributes(){return["chain","pool","token","pool-type","rpc","site","theme","refresh"]}connectedCallback(){if(_(this,le)===null){H(this,le,this.attachShadow({mode:"open"}));const n=document.createElement("style");n.textContent=`${nl}
|
|
949
|
-
${al}`,_(this,le).appendChild(n),H(this,Re,document.createElement("div")),_(this,le).appendChild(_(this,Re))}$(this,M,jt).call(this)}disconnectedCallback(){$(this,M,qn).call(this),H(this,ze,_(this,ze)+1)}attributeChangedCallback(){_(this,le)!==null&&this.isConnected&&$(this,M,jt).call(this)}}le=new WeakMap,Re=new WeakMap,re=new WeakMap,ze=new WeakMap,ve=new WeakMap,ke=new WeakMap,je=new WeakMap,M=new WeakSet,qn=function(){_(this,ve)!==null&&clearInterval(_(this,ve)),_(this,ke)!==null&&clearInterval(_(this,ke)),H(this,ve,null),H(this,ke,null)},jt=function(){$(this,M,qn).call(this),H(this,re,{k:"loading"}),$(this,M,Ut).call(this),$(this,M,Gn).call(this);const n=Number(this.getAttribute("refresh")??"60");Number.isFinite(n)&&n>0&&H(this,ve,setInterval(()=>void $(this,M,Gn).call(this),Math.max(15,n)*1e3)),H(this,ke,setInterval(()=>{_(this,re).k==="ready"&&_(this,re).view.countdownTo!==null&&$(this,M,Ut).call(this)},1e3))},Jr=function(n){const a=this.getAttribute("rpc"),r=`${n}|${a??""}`;if(_(this,je)?.key===r)return _(this,je).client;const i=a!==null&&a.trim()!==""?_r(a.trim()):Hu(n),o=Ic({transport:i}),s={...o,readContract:c=>xc(o,c),getBlock:c=>Vs(o,c),getBlockNumber:c=>Ac(o,c),getLogs:c=>Ys(o,c)};return H(this,je,{key:r,client:s}),s},Gn=async function(){const n=++Yr(this,ze)._,a=Wr(u=>this.getAttribute(u));if(!a.ok)return $(this,M,Ue).call(this,n,{k:"message",tone:"error",text:a.message,retry:!1});const r=tu(a.chainId);if(r===void 0)return $(this,M,Ue).call(this,n,{k:"message",tone:"none",text:`Latch does not support chain ${a.chainId}.`,retry:!1});const i={symbol:r.nativeCurrency.symbol,decimals:r.nativeCurrency.decimals},o=r.launchpadV2.clLPLocker,s=r.launchpadV2.binLPLocker,c=a.target;if(!(c.kind==="pool"?c.poolType==="bin"?s!==null:r.positionLock!==null||o!==null:r.tokenLock!==null||o!==null||s!==null))return $(this,M,Ue).call(this,n,{k:"message",tone:"none",text:`Latch locks are coming soon on ${r.name}.`,retry:!1});try{const u=$(this,M,Jr).call(this,a.chainId);let d=[];if(o!==null&&!(c.kind==="pool"&&c.poolType==="bin")){const g=`${a.chainId}|${o.toLowerCase()}|${this.getAttribute("rpc")??""}`;let x=Dn.get(g);x===void 0&&(x=tl(u,o,{fromBlock:r.deployedAtBlock}),Dn.set(g,x),x.catch(()=>Dn.delete(g))),d=await x}const f={...o!==null?{lpLocker:o,lpLockerTokenIds:d}:{},...s!==null?{binLpLocker:s}:{}};let p,m;if(c.kind==="pool"){const g=await Gu(u,r.positionLock,c.poolId,{native:i,lp:{...f,poolType:c.poolType}});p=g,m=Ju(g)}else{const g=await Wu(u,r.tokenLock,c.token,{native:i,lp:f});p=g,m=Qu(g)}const y=this.getAttribute("site"),h=y===null||y.trim()===""?null:Vu(y.trim(),c.kind==="pool"?{kind:"pool",poolId:c.poolId}:{kind:"token",token:c.token},{pathBase:"/locks",query:`net=${r.key}`});$(this,M,Ue).call(this,n,{k:"ready",view:m,chainNow:p.chainNow,readAtMs:p.readAtMs,href:h})}catch{if(_(this,re).k==="ready")return;$(this,M,Ue).call(this,n,{k:"message",tone:"error",text:"Couldn't load locks. Try again.",retry:!0})}},Ue=function(n,a){n===_(this,ze)&&(H(this,re,a),$(this,M,Ut).call(this))},Ut=function(){const n=_(this,Re);if(n===null)return;const a=this.getAttribute("theme"),r=_(this,re),i=document.createElement("div");i.className="latch-widget latch-locks latch-locks--badge latch-embed-badge",i.dataset.latchTheme=a==="light"||a==="
|
|
949
|
+
${al}`,_(this,le).appendChild(n),H(this,Re,document.createElement("div")),_(this,le).appendChild(_(this,Re))}$(this,M,jt).call(this)}disconnectedCallback(){$(this,M,qn).call(this),H(this,ze,_(this,ze)+1)}attributeChangedCallback(){_(this,le)!==null&&this.isConnected&&$(this,M,jt).call(this)}}le=new WeakMap,Re=new WeakMap,re=new WeakMap,ze=new WeakMap,ve=new WeakMap,ke=new WeakMap,je=new WeakMap,M=new WeakSet,qn=function(){_(this,ve)!==null&&clearInterval(_(this,ve)),_(this,ke)!==null&&clearInterval(_(this,ke)),H(this,ve,null),H(this,ke,null)},jt=function(){$(this,M,qn).call(this),H(this,re,{k:"loading"}),$(this,M,Ut).call(this),$(this,M,Gn).call(this);const n=Number(this.getAttribute("refresh")??"60");Number.isFinite(n)&&n>0&&H(this,ve,setInterval(()=>void $(this,M,Gn).call(this),Math.max(15,n)*1e3)),H(this,ke,setInterval(()=>{_(this,re).k==="ready"&&_(this,re).view.countdownTo!==null&&$(this,M,Ut).call(this)},1e3))},Jr=function(n){const a=this.getAttribute("rpc"),r=`${n}|${a??""}`;if(_(this,je)?.key===r)return _(this,je).client;const i=a!==null&&a.trim()!==""?_r(a.trim()):Hu(n),o=Ic({transport:i}),s={...o,readContract:c=>xc(o,c),getBlock:c=>Vs(o,c),getBlockNumber:c=>Ac(o,c),getLogs:c=>Ys(o,c)};return H(this,je,{key:r,client:s}),s},Gn=async function(){const n=++Yr(this,ze)._,a=Wr(u=>this.getAttribute(u));if(!a.ok)return $(this,M,Ue).call(this,n,{k:"message",tone:"error",text:a.message,retry:!1});const r=tu(a.chainId);if(r===void 0)return $(this,M,Ue).call(this,n,{k:"message",tone:"none",text:`Latch does not support chain ${a.chainId}.`,retry:!1});const i={symbol:r.nativeCurrency.symbol,decimals:r.nativeCurrency.decimals},o=r.launchpadV2.clLPLocker,s=r.launchpadV2.binLPLocker,c=a.target;if(!(c.kind==="pool"?c.poolType==="bin"?s!==null:r.positionLock!==null||o!==null:r.tokenLock!==null||o!==null||s!==null))return $(this,M,Ue).call(this,n,{k:"message",tone:"none",text:`Latch locks are coming soon on ${r.name}.`,retry:!1});try{const u=$(this,M,Jr).call(this,a.chainId);let d=[];if(o!==null&&!(c.kind==="pool"&&c.poolType==="bin")){const g=`${a.chainId}|${o.toLowerCase()}|${this.getAttribute("rpc")??""}`;let x=Dn.get(g);x===void 0&&(x=tl(u,o,{fromBlock:r.deployedAtBlock}),Dn.set(g,x),x.catch(()=>Dn.delete(g))),d=await x}const f={...o!==null?{lpLocker:o,lpLockerTokenIds:d}:{},...s!==null?{binLpLocker:s}:{}};let p,m;if(c.kind==="pool"){const g=await Gu(u,r.positionLock,c.poolId,{native:i,lp:{...f,poolType:c.poolType}});p=g,m=Ju(g)}else{const g=await Wu(u,r.tokenLock,c.token,{native:i,lp:f});p=g,m=Qu(g)}const y=this.getAttribute("site"),h=y===null||y.trim()===""?null:Vu(y.trim(),c.kind==="pool"?{kind:"pool",poolId:c.poolId}:{kind:"token",token:c.token},{pathBase:"/locks",query:`net=${r.key}`});$(this,M,Ue).call(this,n,{k:"ready",view:m,chainNow:p.chainNow,readAtMs:p.readAtMs,href:h})}catch{if(_(this,re).k==="ready")return;$(this,M,Ue).call(this,n,{k:"message",tone:"error",text:"Couldn't load locks. Try again.",retry:!0})}},Ue=function(n,a){n===_(this,ze)&&(H(this,re,a),$(this,M,Ut).call(this))},Ut=function(){const n=_(this,Re);if(n===null)return;const a=this.getAttribute("theme"),r=_(this,re),i=document.createElement("div");i.className="latch-widget latch-locks latch-locks--badge latch-embed-badge",i.dataset.latchTheme=a==="light"||a==="system"?a:"dark";const o=(d,f,p)=>{const m=document.createElement("p");if(m.className=d,p!==void 0){const h=document.createElement("span");h.className=`latch-locks__dot latch-locks__dot--${p}`,h.setAttribute("aria-hidden","true"),m.appendChild(h)}const y=document.createElement("span");return y.textContent=f,m.appendChild(y),m};if(r.k==="loading")i.appendChild(o("latch-locks__headline latch-locks__headline--muted","Loading locks…")),i.setAttribute("role","status");else if(r.k==="message"){const d=o(`latch-locks__headline${r.tone==="error"?" latch-locks__headline--error":""}`,r.text,r.tone==="none"?"none":void 0);if(i.appendChild(d),r.retry){const f=document.createElement("button");f.type="button",f.className="latch-embed-badge__retry",f.textContent="Retry",f.addEventListener("click",()=>$(this,M,jt).call(this)),i.appendChild(f)}}else{const d=o("latch-locks__headline",r.view.headline,r.view.tone);if(d.title=r.view.detail??"",i.dataset.tone=r.view.tone,i.appendChild(d),r.view.countdownTo!==null){const f=Yu(r.chainNow,r.readAtMs,Date.now()),p=document.createElement("p");p.className="latch-locks__countdown";const m=document.createElement("span");m.className="latch-locks__timer",m.textContent=Ku(r.view.countdownTo-f),p.append(m,` to ${r.view.countdownLabel??"the next unlock"}`),i.appendChild(p)}}const s=document.createElement("p");s.className="latch-brand";const c=this.getAttribute("site");if(c!==null&&c.trim()!==""){const d=document.createElement("img");d.className="latch-brand__mark";const f=i.dataset.latchTheme,m=f==="light"||f==="system"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-color-scheme: light)").matches?"-onlight":"";d.src=`${c.trim().replace(/\/+$/,"")}/brand/masters/latch-mark${m}.svg`,d.width=665,d.height=765,d.alt="Latch",s.appendChild(d)}const l=document.createElement("span");l.textContent="Live from the chain",s.appendChild(l);const u=document.createElement("span");if(u.className="latch-brand__spacer",s.appendChild(u),r.k==="ready"&&r.href!==null){const d=document.createElement("a");d.className="latch-locks__link",d.href=r.href,d.target="_blank",d.rel="noopener",d.textContent="Lock details →",s.appendChild(d)}i.appendChild(s),n.replaceChildren(i)};function Kr(){typeof customElements>"u"||customElements.get(Nn)===void 0&&customElements.define(Nn,Vr)}return Kr(),v.LOCK_BADGE_TAG=Nn,v.LatchLockBadgeElement=Vr,v.defineLatchLockBadge=Kr,v.parseLockBadgeAttributes=Wr,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),v}({});
|
|
950
950
|
//# sourceMappingURL=latch-embed.js.map
|