@adland/embed 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/CHANGELOG.md +21 -0
- package/dist/adland-farcaster.js +1 -1
- package/dist/adland-farcaster.js.map +1 -1
- package/dist/adland.js +1 -1
- package/dist/adland.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/adland.js
CHANGED
|
@@ -130,7 +130,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
130
130
|
color: var(--adland-label, #9ca3af);
|
|
131
131
|
}
|
|
132
132
|
.adland-empty { justify-content: center; color: var(--adland-muted, #6b7280); }
|
|
133
|
-
`;function vw(e){let t=mw(e),n=Ag(e),o=dw(e),r=pw(e),i=r?BS[r]??r:"";return `<div part="card" class="adland-card">${t?`<img part="media" class="adland-media" src="${Ug(t)}" alt="" loading="lazy" />`:""}<div part="body" class="adland-body">${n?`<p part="title" class="adland-title">${jg(n)}</p>`:""}${o?`<p part="description" class="adland-description">${jg(o)}</p>`:""}</div>${i?`<span part="badge" class="adland-badge">${jg(i)}</span>`:""}<span part="label" class="adland-label">Ad</span></div>`}function ww(){return '<div part="card" class="adland-card adland-empty"><span part="description" class="adland-description">Your ad here</span><span part="label" class="adland-label">Ad</span></div>'}function $w(e){if(e.type==="link"||e.type==="miniapp"){let t=e.data.url;return typeof t=="string"?t:null}return null}var jS=["--adland-bg","--adland-fg","--adland-muted","--adland-label","--adland-border","--adland-border-hover","--adland-border-width","--adland-radius","--adland-padding","--adland-gap","--adland-font","--adland-shadow-hover","--adland-media-size","--adland-media-radius","--adland-media-bg","--adland-title-size","--adland-title-weight","--adland-description-size","--adland-badge-radius","--adland-accent-bg","--adland-accent-fg"];function _w(e){let t=getComputedStyle(e),n="";for(let o of jS){let r=t.getPropertyValue(o).trim();r&&(n+=`${o}:${r};`);}return n}var kw=8453,US="https://
|
|
133
|
+
`;function vw(e){let t=mw(e),n=Ag(e),o=dw(e),r=pw(e),i=r?BS[r]??r:"";return `<div part="card" class="adland-card">${t?`<img part="media" class="adland-media" src="${Ug(t)}" alt="" loading="lazy" />`:""}<div part="body" class="adland-body">${n?`<p part="title" class="adland-title">${jg(n)}</p>`:""}${o?`<p part="description" class="adland-description">${jg(o)}</p>`:""}</div>${i?`<span part="badge" class="adland-badge">${jg(i)}</span>`:""}<span part="label" class="adland-label">Ad</span></div>`}function ww(){return '<div part="card" class="adland-card adland-empty"><span part="description" class="adland-description">Your ad here</span><span part="label" class="adland-label">Ad</span></div>'}function $w(e){if(e.type==="link"||e.type==="miniapp"){let t=e.data.url;return typeof t=="string"?t:null}return null}var jS=["--adland-bg","--adland-fg","--adland-muted","--adland-label","--adland-border","--adland-border-hover","--adland-border-width","--adland-radius","--adland-padding","--adland-gap","--adland-font","--adland-shadow-hover","--adland-media-size","--adland-media-radius","--adland-media-bg","--adland-title-size","--adland-title-weight","--adland-description-size","--adland-badge-radius","--adland-accent-bg","--adland-accent-fg"];function _w(e){let t=getComputedStyle(e),n="";for(let o of jS){let r=t.getPropertyValue(o).trim();r&&(n+=`${o}:${r};`);}return n}var kw=8453,US="https://0xslots.org/app",OS="68px";function Iw(e){return class extends HTMLElement{static observedAttributes=["slot","chain","placement","render-mode","gateway","endpoint","rpc-url","consent","verified","base-link-url","data-ad"];shadowInited=false;cleanupImpression;messageHandler;renderToken=0;connectedCallback(){this.render();}disconnectedCallback(){this.teardown();}attributeChangedCallback(){this.isConnected&&this.render();}attr(n){return this.getAttribute(n)??void 0}chainId(){return Number(this.attr("chain")??kw)||kw}teardown(){this.cleanupImpression?.(),this.cleanupImpression=void 0,this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=void 0);}async loadAd(){let n=this.attr("data-ad");if(n)try{return {data:JSON.parse(n),cid:null}}catch{return {data:null,cid:null}}let o=this.attr("slot");if(!o)return {data:null,cid:null};let r=uw(this.chainId(),this.attr("rpc-url")),i=await lw(r,o);return i?fw(i,this.attr("gateway")):{data:null,cid:null}}async render(){let n=++this.renderToken;this.teardown(),this.style.minHeight||(this.style.minHeight=OS);let o;try{o=await this.loadAd();}catch{o={data:null,cid:null};}if(n!==this.renderToken||!this.isConnected)return;let r=o.data?vw(o.data):ww();(this.attr("render-mode")==="inline"?"inline":"isolated")==="inline"?this.renderInline(r,o.data):this.renderIsolated(r,o.data);let a=this.attr("slot");if(a){let s=this.attr("verified")!=null?yw:xw;this.cleanupImpression=s(this,{slot:a,chainId:this.chainId(),placement:this.attr("placement"),cid:o.cid,empty:!o.data,endpoint:this.attr("endpoint"),consent:this.attr("consent")});}}renderInline(n,o){let r=this.shadowRoot??(this.shadowInited?null:this.attachShadow({mode:"open"}));if(!r)return;this.shadowInited=true,r.innerHTML=`<style>${Og}</style>${n}`,r.querySelector(".adland-card")?.addEventListener("click",()=>this.handleClick(o,false));}renderIsolated(n,o){this.replaceChildren();let r=o?$w(o):this.emptyUrl(),i=r?`<a href="${Ug(r)}" target="_blank" rel="noopener noreferrer" style="display:block;text-decoration:none;color:inherit">${n}</a>`:n,a=_w(this),s=document.createElement("iframe");s.setAttribute("sandbox","allow-popups allow-popups-to-escape-sandbox allow-scripts"),s.setAttribute("title","Advertisement"),s.setAttribute("scrolling","no"),s.style.cssText="width:100%;border:0;display:block;height:100%",s.srcdoc=`<!doctype html><html><head><meta charset="utf-8"><style>:root{${a}}html,body{margin:0;padding:0}${Og}</style></head><body>${i}<script>(function(){function send(t,x){parent.postMessage(Object.assign({__adland:t},x||{}),'*')}addEventListener('click',function(){send('click')});function size(){send('size',{height:document.documentElement.scrollHeight})}new ResizeObserver(size).observe(document.documentElement);size()})()<\/script></body></html>`;let c=u=>{if(u.source!==s.contentWindow)return;let f=u.data;f?.__adland==="size"&&typeof f.height=="number"?(s.style.height=`${f.height}px`,this.style.minHeight=""):f?.__adland==="click"&&this.handleClick(o,true);};this.messageHandler=c,window.addEventListener("message",c),this.appendChild(s);}baseLink(){return this.attr("base-link-url")??US}emptyUrl(){let n=this.attr("slot");return n?`${this.baseLink()}/slots/${n}?chain=${this.chainId()}`:null}handleClick(n,o){let r=this.attr("slot"),i={chainId:this.chainId(),placement:this.attr("placement"),endpoint:this.attr("endpoint"),consent:this.attr("consent")};n?(r&&Bg("click",{slot:r,cid:null,...i}),o||e.performAdAction(n)):r&&(Bg("click-empty",{slot:r,...i}),o||e.performEmptyAdAction(r,this.chainId(),this.baseLink()));}}}function Ew(e,t="adland-slot"){typeof customElements>"u"||customElements.get(t)||customElements.define(t,Iw(e));}Ew(cw);
|
|
134
134
|
/*! Bundled license information:
|
|
135
135
|
|
|
136
136
|
@noble/hashes/esm/utils.js:
|