nostr-components 0.2.3 → 0.2.5
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/dist/assets/{dialog-component-Dqg0QU9I.js → dialog-component-Da1ZIYh9.js} +7 -2
- package/dist/assets/dialog-component-Da1ZIYh9.js.map +1 -0
- package/dist/assets/{dialog-likers-BzTesCZa.js → dialog-likers-BjiCHFan.js} +2 -2
- package/dist/assets/{dialog-likers-BzTesCZa.js.map → dialog-likers-BjiCHFan.js.map} +1 -1
- package/dist/assets/nostr-user-component-BOdux8_6.js +2 -0
- package/dist/assets/nostr-user-component-BOdux8_6.js.map +1 -0
- package/dist/components/nostr-follow-button.es.js +1 -1
- package/dist/components/nostr-like.es.js +3 -3
- package/dist/components/nostr-like.es.js.map +1 -1
- package/dist/components/nostr-profile-badge.es.js +1 -1
- package/dist/components/nostr-profile.es.js +1 -1
- package/dist/components/nostr-zap.es.js +2 -2
- package/dist/components/nostr-zap.es.js.map +1 -1
- package/dist/nostr-components.es.js +1 -1
- package/dist/nostr-components.umd.js +9 -4
- package/dist/nostr-components.umd.js.map +1 -1
- package/package.json +1 -1
- package/dist/assets/dialog-component-Dqg0QU9I.js.map +0 -1
- package/dist/assets/nostr-user-component-Q7GeeFyu.js +0 -2
- package/dist/assets/nostr-user-component-Q7GeeFyu.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/zap-utils-B1sz0Abx.js","assets/nostr-service-pr_crY62.js","assets/utils--bxLbhGF.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
var Yt=Object.defineProperty;var Jt=(e,t,n)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t,n)=>Jt(e,typeof t!="symbol"?t+"":t,n);import{N as Gt}from"../assets/nostr-user-component-
|
|
2
|
+
var Yt=Object.defineProperty;var Jt=(e,t,n)=>t in e?Yt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var _=(e,t,n)=>Jt(e,typeof t!="symbol"?t+"":t,n);import{N as Gt}from"../assets/nostr-user-component-BOdux8_6.js";import{n as Qt,g as St,h as G,e as X,f as kt,c as At,a as N}from"../assets/base-styles-CBypR3FR.js";import"../assets/dialog-component-Da1ZIYh9.js";import{getProfileMetadata as Wt,getZapEndpoint as Xt,fetchInvoice as te,listenForZapReceipt as ee,getBatchedProfileMetadata as ne,extractProfileMetadataContent as Nt,fetchTotalZapAmount as oe}from"../assets/zap-utils-B1sz0Abx.js";import{_ as re}from"../assets/preload-helper-D7HrI6pR.js";import{i as ae}from"../assets/utils--bxLbhGF.js";import"../assets/user-resolver-C-E6KdwY.js";import"../assets/nostr-service-pr_crY62.js";const ie=(e="light")=>{const t=e==="dark";return`
|
|
3
3
|
/* === ZAP DIALOG CONTENT STYLES === */
|
|
4
4
|
.zap-dialog-content {
|
|
5
5
|
text-align: center;
|
|
@@ -687,7 +687,7 @@ Minimum version required to store current data is: `+a+`.
|
|
|
687
687
|
max-width: 250px;
|
|
688
688
|
white-space: pre-line;
|
|
689
689
|
}
|
|
690
|
-
`)}class hn extends Gt{constructor(){super();_(this,"zapActionStatus",this.channel("zapAction"));_(this,"zapListStatus",this.channel("zapList"));_(this,"totalZapAmount",null);_(this,"cachedZapDetails",[]);_(this,"cachedAmountDialog",null)}connectedCallback(){var n;(n=super.connectedCallback)==null||n.call(this),this.zapListStatus.get()==N.Idle&&this.
|
|
690
|
+
`)}class hn extends Gt{constructor(){super();_(this,"zapActionStatus",this.channel("zapAction"));_(this,"zapListStatus",this.channel("zapList"));_(this,"totalZapAmount",null);_(this,"cachedZapDetails",[]);_(this,"cachedAmountDialog",null)}connectedCallback(){var n;(n=super.connectedCallback)==null||n.call(this),this.zapListStatus.get()==N.Idle&&this.initChannelStatus("zapList",N.Loading,{reflectOverall:!1}),this.attachDelegatedListeners(),this.render()}static get observedAttributes(){return[...super.observedAttributes,"text","amount","default-amount","url"]}attributeChangedCallback(n,o,r){o!==r&&(super.attributeChangedCallback(n,o,r),this.render())}disconnectedCallback(){this.cachedAmountDialog&&typeof this.cachedAmountDialog.close=="function"&&this.cachedAmountDialog.close()}onStatusChange(n){this.render()}onUserReady(n,o){this.render(),this.updateZapCount()}validateInputs(){if(!super.validateInputs())return this.zapActionStatus.set(N.Idle),this.zapListStatus.set(N.Idle),!1;const n=this.getAttribute("text"),o=this.getAttribute("amount"),r=this.getAttribute("default-amount"),a=this.getAttribute("url"),s=this.tagName.toLowerCase();let i=null;if(n&&n.length>128)i="Max text length: 128 characters";else if(o){const c=Number(o);isNaN(c)||c<=0?i="Invalid amount":c>21e4&&(i="Amount too high (max 210,000 sats)")}else if(r){const c=Number(r);isNaN(c)||c<=0?i="Invalid default-amount":c>21e4&&(i="Default-amount too high (max 210,000 sats)")}else a&&(At(a)||(i="Invalid URL format"));return i?(this.zapActionStatus.set(N.Error,i),this.zapListStatus.set(N.Error,i),this.userStatus.set(N.Idle),console.error(`Nostr-Components: ${s}: ${i}`),!1):!0}async handleZapClick(){if(this.userStatus.get()===N.Ready){this.zapActionStatus.set(N.Loading),this.render();try{if(!this.user){this.zapActionStatus.set(N.Error,"Could not resolve user to zap."),this.render();return}const n=this.getRelays().join(","),o=this.user.npub;this.cachedAmountDialog=await Ge({npub:o,relays:n,cachedDialogComponent:this.cachedAmountDialog,theme:this.theme==="dark"?"dark":"light",fixedAmount:(()=>{const r=this.getAttribute("amount");if(!r)return;const a=Number(r);if(isNaN(a)||a<=0||a>21e4){console.error("Nostr-Components: Zap button: Max zap amount: 210,000 sats");return}return a})(),defaultAmount:(()=>{const r=this.getAttribute("default-amount");if(!r)return 21;const a=Number(r);return isNaN(a)||a<=0||a>21e4?(console.error("Nostr-Components: Zap button: Max zap amount: 210,000 sats"),21):a})(),url:this.getAttribute("url")||void 0,anon:!1}),this.zapActionStatus.set(N.Ready)}catch(n){this.zapActionStatus.set(N.Error,(n==null?void 0:n.message)||"Unable to zap")}finally{this.render()}}}async handleHelpClick(){try{await en(this.theme==="dark"?"dark":"light")}catch(n){console.error("Error showing help dialog:",n)}}async handleZappersClick(){if(this.cachedZapDetails.length!==0)try{await an({zapDetails:this.cachedZapDetails,theme:this.theme==="dark"?"dark":"light"})}catch(n){console.error("Nostr-Components: Zap button: Error opening zappers dialog",n)}}attachDelegatedListeners(){this.delegateEvent("click",".nostr-zap-button",n=>{var o,r;(o=n.preventDefault)==null||o.call(n),(r=n.stopPropagation)==null||r.call(n),this.handleZapClick()}),this.delegateEvent("click",".help-icon",n=>{var o,r;(o=n.preventDefault)==null||o.call(n),(r=n.stopPropagation)==null||r.call(n),this.handleHelpClick()}),this.delegateEvent("click",".total-zap-amount",n=>{var o,r;(o=n.preventDefault)==null||o.call(n),(r=n.stopPropagation)==null||r.call(n),this.handleZappersClick()})}async updateZapCount(){if(this.user)try{this.zapListStatus.set(N.Loading),this.render(),await this.ensureNostrConnected();const n=await oe({pubkey:this.user.pubkey,relays:this.getRelays(),url:this.getAttribute("url")||void 0});this.totalZapAmount=n.totalAmount,this.cachedZapDetails=n.zapDetails,this.zapListStatus.set(N.Ready)}catch(n){console.error("Nostr-Components: Zap button: Failed to fetch zap count",n),this.totalZapAmount=null,this.zapListStatus.set(N.Error)}finally{this.render()}}renderContent(){const n=this.userStatus.get()==N.Loading,o=this.zapListStatus.get()==N.Loading,r=this.computeOverall()===N.Error,a=this.errorMessage,s=this.getAttribute("text")||"Zap",i={isLoading:n,isAmountLoading:o,isError:r,isSuccess:!1,errorMessage:a,buttonText:s,totalZapAmount:this.totalZapAmount,hasZaps:this.cachedZapDetails.length>0};this.shadowRoot.innerHTML=`
|
|
691
691
|
${gn()}
|
|
692
692
|
${un(i)}
|
|
693
693
|
`}}customElements.define("nostr-zap",hn);
|