@xoocity/wallet-sdk 1.0.2 → 1.0.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.
- package/dist/iframe-manager.d.ts +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/xoowallet-sdk.es.js +9 -5
- package/dist/xoowallet-sdk.umd.js +1 -1
- package/package.json +1 -1
package/dist/iframe-manager.d.ts
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export interface XooWalletConfig {
|
|
|
19
19
|
lang?: 'en' | 'zh' | 'ms';
|
|
20
20
|
/** z-index,默认 99999 */
|
|
21
21
|
zIndex?: number;
|
|
22
|
+
/** 邀请码,传递给钱包 iframe 用于注册时绑定邀请关系 */
|
|
23
|
+
ref?: string;
|
|
22
24
|
}
|
|
23
25
|
/** 用户信息 */
|
|
24
26
|
export interface UserInfo {
|
|
@@ -26,6 +28,12 @@ export interface UserInfo {
|
|
|
26
28
|
address: string;
|
|
27
29
|
email?: string;
|
|
28
30
|
loginType?: string;
|
|
31
|
+
/** 用户昵称 */
|
|
32
|
+
nickname?: string | null;
|
|
33
|
+
/** 头像 URL */
|
|
34
|
+
avatar?: string | null;
|
|
35
|
+
/** 用户邀请码 */
|
|
36
|
+
inviteCode?: string | null;
|
|
29
37
|
}
|
|
30
38
|
/** 支付参数 */
|
|
31
39
|
export interface PayOptions {
|
|
@@ -35,6 +43,8 @@ export interface PayOptions {
|
|
|
35
43
|
amount: string;
|
|
36
44
|
/** 代币符号(可选,默认原生代币) */
|
|
37
45
|
token?: string;
|
|
46
|
+
/** 网络ID(可选,如 'polygon-mainnet', 'eth-mainnet') */
|
|
47
|
+
network?: string;
|
|
38
48
|
}
|
|
39
49
|
/** 事件映射 */
|
|
40
50
|
export interface XooWalletEvents {
|
|
@@ -82,4 +92,5 @@ export type SdkCommand = {
|
|
|
82
92
|
to: string;
|
|
83
93
|
amount: string;
|
|
84
94
|
token?: string;
|
|
95
|
+
network?: string;
|
|
85
96
|
};
|
package/dist/xoowallet-sdk.es.js
CHANGED
|
@@ -33,6 +33,7 @@ class IframeManager {
|
|
|
33
33
|
url.searchParams.set("partnerKey", partnerKey);
|
|
34
34
|
if (params == null ? void 0 : params.lang) url.searchParams.set("lang", params.lang);
|
|
35
35
|
if (params == null ? void 0 : params.theme) url.searchParams.set("theme", params.theme);
|
|
36
|
+
if (params == null ? void 0 : params.ref) url.searchParams.set("ref", params.ref);
|
|
36
37
|
if (this.popupPosition === "center") {
|
|
37
38
|
this.overlay = document.createElement("div");
|
|
38
39
|
this.overlay.className = "xoo-widget-overlay xoo-widget-overlay--hidden";
|
|
@@ -121,8 +122,8 @@ class IframeManager {
|
|
|
121
122
|
this.visible = false;
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
|
-
const WALLET_ICON = `<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="
|
|
125
|
-
const CLOSE_ICON = `<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="
|
|
125
|
+
const WALLET_ICON = `<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.8703 16.2806C11.6385 16.0995 11.3551 15.996 11.0718 15.996C10.8914 15.996 10.7111 16.0219 10.5308 16.0995C10.3763 16.1771 10.2217 16.2806 10.0929 16.4358C10.0672 16.4617 10.0414 16.4876 10.0156 16.5134C9.88684 16.6687 9.80957 16.8239 9.75805 17.005C9.70653 17.1861 9.68077 17.3672 9.70653 17.5483C9.73229 17.7294 9.78381 17.9104 9.86109 18.0915C9.93836 18.2468 10.0672 18.402 10.2217 18.5313C10.4535 18.7383 10.7626 18.8418 11.046 18.8418C11.2263 18.8418 11.4066 18.8159 11.5869 18.7383C11.7672 18.6607 11.896 18.5572 12.0248 18.402C12.2567 18.1433 12.4112 17.7811 12.4112 17.4189C12.4112 17.0567 12.2824 16.6945 12.0506 16.41C11.9733 16.3841 11.9218 16.3323 11.8703 16.2806ZM17.9752 16.2806C17.7176 16.0736 17.3827 15.9701 17.0478 15.996C16.713 16.0219 16.4039 16.1771 16.1978 16.4358C15.966 16.6945 15.8114 17.0567 15.8114 17.4189C15.7856 17.7811 15.9144 18.1433 16.172 18.402C16.3008 18.5313 16.4296 18.6348 16.5842 18.7124C16.7387 18.7901 16.919 18.8159 17.0994 18.8159H17.1509C17.3312 18.8159 17.5115 18.7901 17.6661 18.7124C17.8206 18.6348 17.9752 18.5313 18.104 18.402C18.3358 18.1433 18.4903 17.7811 18.4903 17.4189C18.4903 17.0567 18.3615 16.6945 18.1297 16.4358C18.0782 16.3841 18.0267 16.3323 17.9752 16.2806ZM27.8924 15.1682H23.5906C22.9724 15.1682 22.483 15.6597 22.483 16.2806V18.5831C22.483 19.204 22.9724 19.6955 23.5906 19.6955H27.8924C28.5106 19.6955 29 19.204 29 18.5831V16.2806C29 15.6856 28.5106 15.1682 27.8924 15.1682ZM25.4453 18.402C24.9043 18.402 24.4922 17.9622 24.4922 17.4448C24.4922 16.9015 24.9301 16.4876 25.4453 16.4876C25.9604 16.4876 26.3983 16.9274 26.3983 17.4448C26.4241 17.9622 25.9862 18.402 25.4453 18.402ZM21.5814 18.7124V16.1512C21.5814 15.1682 22.3799 14.3662 23.3588 14.3662H27.506V11.1582C27.506 8.82985 25.7029 6.88955 23.3845 6.73433V5.23383C23.3845 3.44876 21.9163 2 20.1389 2H4.24563C2.4425 2 1 3.44876 1 5.2597C1 5.36318 1 5.46667 1.02576 5.54428H1V11.1582V23.5761C1 26.0338 2.98344 28 5.40478 28H23.0754C25.5225 28 27.4802 26.008 27.4802 23.5761V20.4975H23.3588C22.3799 20.4975 21.5814 19.6955 21.5814 18.7124ZM4.24563 3.78507H20.1389C20.9632 3.78507 21.6072 4.45771 21.6072 5.2597V6.73433H4.24563C3.42134 6.73433 2.77737 6.06169 2.77737 5.2597C2.77737 4.45771 3.42134 3.78507 4.24563 3.78507ZM8.05796 15.7114L6.4609 17.4448L8.05796 19.1781V20.3164H7.00184L5.40478 18.5831L3.80773 20.3164H2.77737V19.1522L4.37443 17.4189L2.77737 15.7114V14.5731H3.83349L5.43054 16.3065L7.0276 14.5731H8.08372V15.7114H8.05796ZM13.7249 18.5313C13.5961 18.8935 13.3901 19.204 13.1325 19.4627C12.8749 19.7214 12.5658 19.9542 12.2309 20.0836C11.896 20.2388 11.5354 20.3164 11.149 20.2905H10.9945C10.6339 20.2905 10.2475 20.2129 9.9126 20.0836C9.57774 19.9284 9.26863 19.7214 9.01104 19.4627C8.75345 19.204 8.54738 18.8677 8.41858 18.5313C8.28979 18.195 8.21251 17.807 8.21251 17.4189C8.21251 17.0308 8.26403 16.6687 8.39282 16.3065C8.52162 15.9443 8.72769 15.6338 8.98528 15.3751C9.24287 15.1164 9.55198 14.8836 9.88684 14.7542C10.2217 14.6249 10.5823 14.5214 10.9687 14.5473H11.0975C11.4581 14.5473 11.8445 14.6249 12.1794 14.7801C12.5143 14.9353 12.8234 15.1423 13.081 15.401C13.3385 15.6597 13.5446 15.996 13.6992 16.3323C13.828 16.6945 13.9052 17.0567 13.9052 17.4448C13.9052 17.807 13.8537 18.195 13.7249 18.5313ZM19.8298 18.5313C19.701 18.8935 19.4949 19.204 19.2374 19.4627L19.2116 19.4886C18.6707 20.006 17.9236 20.2905 17.1766 20.2905C16.4296 20.2905 15.6826 19.9801 15.1417 19.4368C14.8841 19.1781 14.678 18.8418 14.5492 18.5055C14.4204 18.1433 14.3431 17.7811 14.3431 17.393C14.3431 17.005 14.3947 16.6428 14.5235 16.2806C14.6523 15.9184 14.8583 15.608 15.1159 15.3493C15.1417 15.3234 15.1674 15.2975 15.1674 15.2975C15.7084 14.7801 16.4296 14.4955 17.1509 14.5214C17.5373 14.5214 17.8979 14.599 18.2585 14.7284C18.6191 14.8836 18.9282 15.0905 19.1858 15.3493C19.4434 15.608 19.6495 15.9443 19.804 16.2806C19.9328 16.6428 20.0101 17.005 20.0101 17.393C20.0101 17.807 19.9586 18.195 19.8298 18.5313Z" fill="#1D2088"/></svg>`;
|
|
126
|
+
const CLOSE_ICON = `<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21.5739 18.6984V16.1404C21.5739 15.1586 22.3731 14.3576 23.3529 14.3576H27.4006V11.4638C27.4006 9.62926 25.931 8.1565 24.1005 8.1565H3.47506V7.89812C3.47506 7.12299 4.04226 6.47704 4.81571 6.37369L20.7231 4.15163C21.4966 4.04828 22.1927 4.64255 22.1927 5.41769V7.35553H24.1005V4.87509C24.1005 3.06644 22.631 1.77454 20.8262 2.03292L4.27429 4.38417C2.46956 4.64255 1 6.34785 1 8.1565V24.6928C1 26.5272 2.46956 28 4.30008 28H24.1005C25.931 28 27.4006 26.5272 27.4006 24.6928V20.4812H23.3529C22.3731 20.4812 21.5739 19.6802 21.5739 18.6984ZM8.06422 15.7012L6.46575 17.4323L8.06422 19.1634V20.3003H7.00717L5.40869 18.5692L3.81022 20.3003H2.75316V19.1376L4.35164 17.4065L2.75316 15.6753V14.5385H3.81022L5.40869 16.2696L7.00717 14.5385H8.06422V15.7012ZM13.7104 18.5175C13.5815 18.8792 13.3753 19.1893 13.1175 19.4477C12.8596 19.706 12.5503 19.9386 12.2151 20.0678C11.8799 20.2228 11.519 20.3003 11.1323 20.2745H10.9776C10.6166 20.2745 10.2299 20.197 9.89473 20.0678C9.55957 19.9127 9.25019 19.706 8.99237 19.4477C8.73455 19.1893 8.5283 18.8534 8.39939 18.5175C8.27048 18.1816 8.19313 17.794 8.19313 17.4065C8.19313 17.0189 8.2447 16.6572 8.37361 16.2954C8.50251 15.9337 8.70877 15.6237 8.96659 15.3653C9.22441 15.1069 9.53379 14.8744 9.86895 14.7452C10.2041 14.616 10.5651 14.5126 10.9518 14.5385H11.0807C11.4416 14.5385 11.8284 14.616 12.1635 14.771C12.4987 14.926 12.8081 15.1327 13.0659 15.3911C13.3237 15.6495 13.53 15.9854 13.6847 16.3213C13.8136 16.683 13.8909 17.0447 13.8909 17.4323C13.9167 17.794 13.8394 18.1558 13.7104 18.5175ZM19.8207 18.5175C19.6918 18.8792 19.4856 19.1893 19.2278 19.4477L19.202 19.4735C18.6606 19.9903 17.9129 20.2745 17.1652 20.2745C16.4175 20.2745 15.6699 19.9644 15.1284 19.4218C14.8706 19.1634 14.6644 18.8276 14.5355 18.4917C14.4066 18.1299 14.3292 17.7682 14.3292 17.3806C14.3292 16.9931 14.3808 16.6313 14.5097 16.2696C14.6386 15.9079 14.8448 15.5978 15.1027 15.3394C15.1284 15.3136 15.1542 15.2878 15.1542 15.2878C15.6956 14.771 16.4175 14.4868 17.1394 14.5126C17.5262 14.5126 17.8871 14.5901 18.248 14.7193C18.609 14.8744 18.9184 15.0811 19.1762 15.3394C19.434 15.5978 19.6403 15.9337 19.795 16.2696C19.9239 16.6313 20.0012 16.9931 20.0012 17.3806C20.027 17.794 19.9497 18.1558 19.8207 18.5175ZM17.9644 16.2696C17.7066 16.0629 17.3715 15.9595 17.0363 15.9854C16.7269 16.0112 16.4175 16.1921 16.2113 16.4246C15.9792 16.683 15.8246 17.0447 15.8246 17.4065C15.7988 17.7682 15.9277 18.1299 16.1855 18.3883C16.3144 18.5175 16.4433 18.6208 16.598 18.6984C16.7527 18.7759 16.9332 18.8017 17.1136 18.8017H17.1652C17.3457 18.8017 17.5262 18.7759 17.6808 18.6984C17.8355 18.6208 17.9902 18.5175 18.1191 18.3883C18.3512 18.1299 18.5059 17.7682 18.5059 17.4065C18.5059 17.0447 18.377 16.683 18.1449 16.4246C18.0934 16.373 18.0418 16.3213 17.9644 16.2696ZM11.8542 16.2696C11.6221 16.0887 11.3385 15.9854 11.0549 15.9854C10.8744 15.9854 10.694 16.0112 10.5135 16.0887C10.3588 16.1662 10.2041 16.2696 10.0752 16.4246C10.0494 16.4505 10.0236 16.4763 9.99786 16.5021C9.86895 16.6572 9.79161 16.8122 9.74004 16.9931C9.68848 17.1739 9.6627 17.3548 9.68848 17.5357C9.71426 17.7165 9.76582 17.8974 9.84317 18.0783C9.92052 18.2333 10.0494 18.3883 10.2041 18.5175C10.4362 18.7242 10.7455 18.8275 11.0291 18.8275C11.2096 18.8275 11.3901 18.8017 11.5706 18.7242C11.751 18.6467 11.8799 18.5433 12.0088 18.3883C12.2409 18.1299 12.3956 17.7682 12.3956 17.4065C12.3956 17.0447 12.2667 16.683 12.0346 16.3988C11.9573 16.373 11.9057 16.3213 11.8542 16.2696ZM27.8905 15.1586H23.5849C22.9661 15.1586 22.4763 15.6495 22.4763 16.2696V18.5692C22.4763 19.1893 22.9661 19.6802 23.5849 19.6802H27.8905C28.5092 19.6802 28.9991 19.1893 28.9991 18.5692V16.2696C29.0249 15.6495 28.5092 15.1586 27.8905 15.1586ZM25.4412 18.3883C24.8998 18.3883 24.4873 17.9491 24.4873 17.4323C24.4873 16.8897 24.9255 16.4763 25.4412 16.4763C25.9826 16.4763 26.3951 16.9155 26.3951 17.4323C26.4209 17.9491 25.9826 18.3883 25.4412 18.3883Z" fill="#1D2088"/></svg>`;
|
|
126
127
|
class FabButton {
|
|
127
128
|
constructor(position, onClick) {
|
|
128
129
|
this.button = null;
|
|
@@ -351,7 +352,8 @@ class XooWallet {
|
|
|
351
352
|
autoShow: config.autoShow !== false,
|
|
352
353
|
zIndex: config.zIndex || DEFAULT_Z_INDEX,
|
|
353
354
|
theme: config.theme,
|
|
354
|
-
lang: config.lang
|
|
355
|
+
lang: config.lang,
|
|
356
|
+
ref: config.ref
|
|
355
357
|
};
|
|
356
358
|
injectStyles(this.config.zIndex);
|
|
357
359
|
this.fab = new FabButton(this.config.position, () => this.toggle());
|
|
@@ -365,7 +367,8 @@ class XooWallet {
|
|
|
365
367
|
this.iframe.create(this.config.walletUrl, this.config.apiKey, this.config.position, {
|
|
366
368
|
lang: this.config.lang,
|
|
367
369
|
theme: this.config.theme,
|
|
368
|
-
popupPosition: this.config.popupPosition
|
|
370
|
+
popupPosition: this.config.popupPosition,
|
|
371
|
+
ref: this.config.ref
|
|
369
372
|
});
|
|
370
373
|
}
|
|
371
374
|
/**
|
|
@@ -418,7 +421,8 @@ class XooWallet {
|
|
|
418
421
|
type: "xoo-cmd-pay",
|
|
419
422
|
to: options.to,
|
|
420
423
|
amount: options.amount,
|
|
421
|
-
token: options.token
|
|
424
|
+
token: options.token,
|
|
425
|
+
network: options.network
|
|
422
426
|
});
|
|
423
427
|
}
|
|
424
428
|
// ==================== 状态查询 ====================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XooWallet={})}(this,function(t){"use strict";class e{constructor(){this.container=null,this.iframe=null,this.closeBtn=null,this.overlay=null,this.visible=!1,this.popupPosition="center",this.walletOrigin="",this.onMessage=null,this.onCloseClick=null,this.handleMessage=t=>{var e;if(t.origin!==this.walletOrigin)return;const i=t.data;i&&"string"==typeof i.type&&i.type.startsWith("xoo-")&&(i.type.startsWith("xoo-cmd-")||null==(e=this.onMessage)||e.call(this,i))},this.handleCloseClick=()=>{var t;null==(t=this.onCloseClick)||t.call(this)}}create(t,e,i,n){if(this.container)return;this.popupPosition=(null==n?void 0:n.popupPosition)||"center";const o=new URL(t);this.walletOrigin=o.origin,o.searchParams.set("embed","true"),o.searchParams.set("partnerKey",e),(null==n?void 0:n.lang)&&o.searchParams.set("lang",n.lang),(null==n?void 0:n.theme)&&o.searchParams.set("theme",n.theme),"center"===this.popupPosition&&(this.overlay=document.createElement("div"),this.overlay.className="xoo-widget-overlay xoo-widget-overlay--hidden",document.body.appendChild(this.overlay));const s="center"===this.popupPosition?"center":i;this.container=document.createElement("div"),this.container.className=`xoo-widget-container xoo-widget-container--${s} xoo-widget-container--hidden`,this.iframe=document.createElement("iframe"),this.iframe.src=o.toString(),this.iframe.className="xoo-widget-iframe",this.iframe.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"),this.iframe.setAttribute("allow","clipboard-write"),this.iframe.setAttribute("title","XOO Wallet"),this.container.appendChild(this.iframe),this.closeBtn=document.createElement("button"),this.closeBtn.className="xoo-widget-close",this.closeBtn.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.closeBtn.setAttribute("aria-label","Close"),this.closeBtn.addEventListener("click",this.handleCloseClick),this.container.appendChild(this.closeBtn),document.body.appendChild(this.container),window.addEventListener("message",this.handleMessage)}setMessageHandler(t){this.onMessage=t}setCloseClickHandler(t){this.onCloseClick=t}show(){this.container&&(this.visible=!0,this.container.classList.remove("xoo-widget-container--hidden"),this.container.classList.add("xoo-widget-container--visible"),this.overlay&&(this.overlay.classList.remove("xoo-widget-overlay--hidden"),this.overlay.classList.add("xoo-widget-overlay--visible")))}hide(){this.container&&(this.visible=!1,this.container.classList.remove("xoo-widget-container--visible"),this.container.classList.add("xoo-widget-container--hidden"),this.overlay&&(this.overlay.classList.remove("xoo-widget-overlay--visible"),this.overlay.classList.add("xoo-widget-overlay--hidden")))}isVisible(){return this.visible}postCommand(t){var e;(null==(e=this.iframe)?void 0:e.contentWindow)&&this.iframe.contentWindow.postMessage(t,this.walletOrigin)}destroy(){window.removeEventListener("message",this.handleMessage),this.closeBtn&&this.closeBtn.removeEventListener("click",this.handleCloseClick),this.overlay&&(this.overlay.remove(),this.overlay=null),this.container&&(this.container.remove(),this.container=null),this.iframe=null,this.closeBtn=null,this.onMessage=null,this.onCloseClick=null,this.visible=!1}}const i='<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21.5739 18.6984V16.1404C21.5739 15.1586 22.3731 14.3576 23.3529 14.3576H27.4006V11.4638C27.4006 9.62926 25.931 8.1565 24.1005 8.1565H3.47506V7.89812C3.47506 7.12299 4.04226 6.47704 4.81571 6.37369L20.7231 4.15163C21.4966 4.04828 22.1927 4.64255 22.1927 5.41769V7.35553H24.1005V4.87509C24.1005 3.06644 22.631 1.77454 20.8262 2.03292L4.27429 4.38417C2.46956 4.64255 1 6.34785 1 8.1565V24.6928C1 26.5272 2.46956 28 4.30008 28H24.1005C25.931 28 27.4006 26.5272 27.4006 24.6928V20.4812H23.3529C22.3731 20.4812 21.5739 19.6802 21.5739 18.6984ZM8.06422 15.7012L6.46575 17.4323L8.06422 19.1634V20.3003H7.00717L5.40869 18.5692L3.81022 20.3003H2.75316V19.1376L4.35164 17.4065L2.75316 15.6753V14.5385H3.81022L5.40869 16.2696L7.00717 14.5385H8.06422V15.7012ZM13.7104 18.5175C13.5815 18.8792 13.3753 19.1893 13.1175 19.4477C12.8596 19.706 12.5503 19.9386 12.2151 20.0678C11.8799 20.2228 11.519 20.3003 11.1323 20.2745H10.9776C10.6166 20.2745 10.2299 20.197 9.89473 20.0678C9.55957 19.9127 9.25019 19.706 8.99237 19.4477C8.73455 19.1893 8.5283 18.8534 8.39939 18.5175C8.27048 18.1816 8.19313 17.794 8.19313 17.4065C8.19313 17.0189 8.2447 16.6572 8.37361 16.2954C8.50251 15.9337 8.70877 15.6237 8.96659 15.3653C9.22441 15.1069 9.53379 14.8744 9.86895 14.7452C10.2041 14.616 10.5651 14.5126 10.9518 14.5385H11.0807C11.4416 14.5385 11.8284 14.616 12.1635 14.771C12.4987 14.926 12.8081 15.1327 13.0659 15.3911C13.3237 15.6495 13.53 15.9854 13.6847 16.3213C13.8136 16.683 13.8909 17.0447 13.8909 17.4323C13.9167 17.794 13.8394 18.1558 13.7104 18.5175ZM19.8207 18.5175C19.6918 18.8792 19.4856 19.1893 19.2278 19.4477L19.202 19.4735C18.6606 19.9903 17.9129 20.2745 17.1652 20.2745C16.4175 20.2745 15.6699 19.9644 15.1284 19.4218C14.8706 19.1634 14.6644 18.8276 14.5355 18.4917C14.4066 18.1299 14.3292 17.7682 14.3292 17.3806C14.3292 16.9931 14.3808 16.6313 14.5097 16.2696C14.6386 15.9079 14.8448 15.5978 15.1027 15.3394C15.1284 15.3136 15.1542 15.2878 15.1542 15.2878C15.6956 14.771 16.4175 14.4868 17.1394 14.5126C17.5262 14.5126 17.8871 14.5901 18.248 14.7193C18.609 14.8744 18.9184 15.0811 19.1762 15.3394C19.434 15.5978 19.6403 15.9337 19.795 16.2696C19.9239 16.6313 20.0012 16.9931 20.0012 17.3806C20.027 17.794 19.9497 18.1558 19.8207 18.5175ZM17.9644 16.2696C17.7066 16.0629 17.3715 15.9595 17.0363 15.9854C16.7269 16.0112 16.4175 16.1921 16.2113 16.4246C15.9792 16.683 15.8246 17.0447 15.8246 17.4065C15.7988 17.7682 15.9277 18.1299 16.1855 18.3883C16.3144 18.5175 16.4433 18.6208 16.598 18.6984C16.7527 18.7759 16.9332 18.8017 17.1136 18.8017H17.1652C17.3457 18.8017 17.5262 18.7759 17.6808 18.6984C17.8355 18.6208 17.9902 18.5175 18.1191 18.3883C18.3512 18.1299 18.5059 17.7682 18.5059 17.4065C18.5059 17.0447 18.377 16.683 18.1449 16.4246C18.0934 16.373 18.0418 16.3213 17.9644 16.2696ZM11.8542 16.2696C11.6221 16.0887 11.3385 15.9854 11.0549 15.9854C10.8744 15.9854 10.694 16.0112 10.5135 16.0887C10.3588 16.1662 10.2041 16.2696 10.0752 16.4246C10.0494 16.4505 10.0236 16.4763 9.99786 16.5021C9.86895 16.6572 9.79161 16.8122 9.74004 16.9931C9.68848 17.1739 9.6627 17.3548 9.68848 17.5357C9.71426 17.7165 9.76582 17.8974 9.84317 18.0783C9.92052 18.2333 10.0494 18.3883 10.2041 18.5175C10.4362 18.7242 10.7455 18.8275 11.0291 18.8275C11.2096 18.8275 11.3901 18.8017 11.5706 18.7242C11.751 18.6467 11.8799 18.5433 12.0088 18.3883C12.2409 18.1299 12.3956 17.7682 12.3956 17.4065C12.3956 17.0447 12.2667 16.683 12.0346 16.3988C11.9573 16.373 11.9057 16.3213 11.8542 16.2696ZM27.8905 15.1586H23.5849C22.9661 15.1586 22.4763 15.6495 22.4763 16.2696V18.5692C22.4763 19.1893 22.9661 19.6802 23.5849 19.6802H27.8905C28.5092 19.6802 28.9991 19.1893 28.9991 18.5692V16.2696C29.0249 15.6495 28.5092 15.1586 27.8905 15.1586ZM25.4412 18.3883C24.8998 18.3883 24.4873 17.9491 24.4873 17.4323C24.4873 16.8897 24.9255 16.4763 25.4412 16.4763C25.9826 16.4763 26.3951 16.9155 26.3951 17.4323C26.4209 17.9491 25.9826 18.3883 25.4412 18.3883Z" fill="#1D2088"/></svg>';class n{constructor(t,e){this.button=null,this.isOpen=!1,this.handleClick=()=>{this.onClick()},this.position=t,this.onClick=e}create(){this.button||(this.button=document.createElement("button"),this.button.className=`xoo-widget-fab xoo-widget-fab--${this.position}`,this.button.innerHTML=i,this.button.setAttribute("aria-label","Open XOO Wallet"),this.button.addEventListener("click",this.handleClick),document.body.appendChild(this.button))}setOpen(t){this.isOpen=t,this.button&&(t?(this.button.innerHTML='<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.8703 16.2806C11.6385 16.0995 11.3551 15.996 11.0718 15.996C10.8914 15.996 10.7111 16.0219 10.5308 16.0995C10.3763 16.1771 10.2217 16.2806 10.0929 16.4358C10.0672 16.4617 10.0414 16.4876 10.0156 16.5134C9.88684 16.6687 9.80957 16.8239 9.75805 17.005C9.70653 17.1861 9.68077 17.3672 9.70653 17.5483C9.73229 17.7294 9.78381 17.9104 9.86109 18.0915C9.93836 18.2468 10.0672 18.402 10.2217 18.5313C10.4535 18.7383 10.7626 18.8418 11.046 18.8418C11.2263 18.8418 11.4066 18.8159 11.5869 18.7383C11.7672 18.6607 11.896 18.5572 12.0248 18.402C12.2567 18.1433 12.4112 17.7811 12.4112 17.4189C12.4112 17.0567 12.2824 16.6945 12.0506 16.41C11.9733 16.3841 11.9218 16.3323 11.8703 16.2806ZM17.9752 16.2806C17.7176 16.0736 17.3827 15.9701 17.0478 15.996C16.713 16.0219 16.4039 16.1771 16.1978 16.4358C15.966 16.6945 15.8114 17.0567 15.8114 17.4189C15.7856 17.7811 15.9144 18.1433 16.172 18.402C16.3008 18.5313 16.4296 18.6348 16.5842 18.7124C16.7387 18.7901 16.919 18.8159 17.0994 18.8159H17.1509C17.3312 18.8159 17.5115 18.7901 17.6661 18.7124C17.8206 18.6348 17.9752 18.5313 18.104 18.402C18.3358 18.1433 18.4903 17.7811 18.4903 17.4189C18.4903 17.0567 18.3615 16.6945 18.1297 16.4358C18.0782 16.3841 18.0267 16.3323 17.9752 16.2806ZM27.8924 15.1682H23.5906C22.9724 15.1682 22.483 15.6597 22.483 16.2806V18.5831C22.483 19.204 22.9724 19.6955 23.5906 19.6955H27.8924C28.5106 19.6955 29 19.204 29 18.5831V16.2806C29 15.6856 28.5106 15.1682 27.8924 15.1682ZM25.4453 18.402C24.9043 18.402 24.4922 17.9622 24.4922 17.4448C24.4922 16.9015 24.9301 16.4876 25.4453 16.4876C25.9604 16.4876 26.3983 16.9274 26.3983 17.4448C26.4241 17.9622 25.9862 18.402 25.4453 18.402ZM21.5814 18.7124V16.1512C21.5814 15.1682 22.3799 14.3662 23.3588 14.3662H27.506V11.1582C27.506 8.82985 25.7029 6.88955 23.3845 6.73433V5.23383C23.3845 3.44876 21.9163 2 20.1389 2H4.24563C2.4425 2 1 3.44876 1 5.2597C1 5.36318 1 5.46667 1.02576 5.54428H1V11.1582V23.5761C1 26.0338 2.98344 28 5.40478 28H23.0754C25.5225 28 27.4802 26.008 27.4802 23.5761V20.4975H23.3588C22.3799 20.4975 21.5814 19.6955 21.5814 18.7124ZM4.24563 3.78507H20.1389C20.9632 3.78507 21.6072 4.45771 21.6072 5.2597V6.73433H4.24563C3.42134 6.73433 2.77737 6.06169 2.77737 5.2597C2.77737 4.45771 3.42134 3.78507 4.24563 3.78507ZM8.05796 15.7114L6.4609 17.4448L8.05796 19.1781V20.3164H7.00184L5.40478 18.5831L3.80773 20.3164H2.77737V19.1522L4.37443 17.4189L2.77737 15.7114V14.5731H3.83349L5.43054 16.3065L7.0276 14.5731H8.08372V15.7114H8.05796ZM13.7249 18.5313C13.5961 18.8935 13.3901 19.204 13.1325 19.4627C12.8749 19.7214 12.5658 19.9542 12.2309 20.0836C11.896 20.2388 11.5354 20.3164 11.149 20.2905H10.9945C10.6339 20.2905 10.2475 20.2129 9.9126 20.0836C9.57774 19.9284 9.26863 19.7214 9.01104 19.4627C8.75345 19.204 8.54738 18.8677 8.41858 18.5313C8.28979 18.195 8.21251 17.807 8.21251 17.4189C8.21251 17.0308 8.26403 16.6687 8.39282 16.3065C8.52162 15.9443 8.72769 15.6338 8.98528 15.3751C9.24287 15.1164 9.55198 14.8836 9.88684 14.7542C10.2217 14.6249 10.5823 14.5214 10.9687 14.5473H11.0975C11.4581 14.5473 11.8445 14.6249 12.1794 14.7801C12.5143 14.9353 12.8234 15.1423 13.081 15.401C13.3385 15.6597 13.5446 15.996 13.6992 16.3323C13.828 16.6945 13.9052 17.0567 13.9052 17.4448C13.9052 17.807 13.8537 18.195 13.7249 18.5313ZM19.8298 18.5313C19.701 18.8935 19.4949 19.204 19.2374 19.4627L19.2116 19.4886C18.6707 20.006 17.9236 20.2905 17.1766 20.2905C16.4296 20.2905 15.6826 19.9801 15.1417 19.4368C14.8841 19.1781 14.678 18.8418 14.5492 18.5055C14.4204 18.1433 14.3431 17.7811 14.3431 17.393C14.3431 17.005 14.3947 16.6428 14.5235 16.2806C14.6523 15.9184 14.8583 15.608 15.1159 15.3493C15.1417 15.3234 15.1674 15.2975 15.1674 15.2975C15.7084 14.7801 16.4296 14.4955 17.1509 14.5214C17.5373 14.5214 17.8979 14.599 18.2585 14.7284C18.6191 14.8836 18.9282 15.0905 19.1858 15.3493C19.4434 15.608 19.6495 15.9443 19.804 16.2806C19.9328 16.6428 20.0101 17.005 20.0101 17.393C20.0101 17.807 19.9586 18.195 19.8298 18.5313Z" fill="#1D2088"/></svg>',this.button.classList.add("xoo-widget-fab--open"),this.button.setAttribute("aria-label","Close XOO Wallet")):(this.button.innerHTML=i,this.button.classList.remove("xoo-widget-fab--open"),this.button.setAttribute("aria-label","Open XOO Wallet")))}show(){this.button&&(this.button.style.display="flex")}hide(){this.button&&(this.button.style.display="none")}destroy(){this.button&&(this.button.removeEventListener("click",this.handleClick),this.button.remove(),this.button=null)}}class o{constructor(t){this.eventListeners=new Map,this._isOpen=!1,this._isLoggedIn=!1,this._user=null,this._ready=!1,this.config={apiKey:t.apiKey,walletUrl:t.walletUrl||"https://web.xoowallet.com",position:t.position||"bottom-right",popupPosition:t.popupPosition||"center",autoShow:!1!==t.autoShow,zIndex:t.zIndex||99999,theme:t.theme,lang:t.lang},function(t){if(document.getElementById("xoo-widget-styles"))return;const e=document.createElement("style");e.id="xoo-widget-styles",e.textContent=`\n .xoo-widget-fab {\n position: fixed;\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n z-index: ${t+1};\n background: #f0f0f0;\n padding: 0;\n outline: none;\n }\n .xoo-widget-fab:hover {\n transform: scale(1.05);\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);\n background: #e5e5e5;\n }\n .xoo-widget-fab:active {\n transform: scale(0.95);\n }\n .xoo-widget-fab svg {\n width: 30px;\n height: 30px;\n transition: transform 0.3s ease;\n }\n .xoo-widget-fab--bottom-right {\n bottom: 20px;\n right: 20px;\n }\n .xoo-widget-fab--bottom-left {\n bottom: 20px;\n left: 20px;\n }\n\n /* ---- 弹窗容器(包裹 iframe + 关闭按钮) ---- */\n .xoo-widget-container {\n position: fixed;\n width: 375px;\n height: 640px;\n max-height: 80vh;\n border-radius: 16px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n z-index: ${t};\n overflow: hidden;\n transition: opacity 0.2s ease, transform 0.2s ease;\n }\n .xoo-widget-container--center {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n margin: auto;\n }\n .xoo-widget-container--bottom-right {\n bottom: 88px;\n right: 20px;\n }\n .xoo-widget-container--bottom-left {\n bottom: 88px;\n left: 20px;\n }\n .xoo-widget-container--hidden {\n opacity: 0;\n transform: translateY(10px) scale(0.95);\n pointer-events: none;\n }\n .xoo-widget-container--visible {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n\n /* ---- iframe 填充容器 ---- */\n .xoo-widget-iframe {\n width: 100%;\n height: 100%;\n border: none;\n background: #ffffff;\n }\n\n /* ---- 关闭按钮(容器内,iframe 上层) ---- */\n .xoo-widget-close {\n position: absolute;\n top: 3px;\n right: 3px;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n border: none;\n background: rgba(0, 0, 0, 0.06);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 2;\n color: #999;\n padding: 0;\n outline: none;\n transition: background 0.15s ease, color 0.15s ease;\n }\n .xoo-widget-close:hover {\n background: rgba(0, 0, 0, 0.12);\n color: #333;\n }\n .xoo-widget-close svg {\n width: 14px;\n height: 14px;\n }\n\n /* ---- 遮罩层(仅视觉,不拦截点击) ---- */\n .xoo-widget-overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.4);\n z-index: ${t-1};\n transition: opacity 0.2s ease;\n }\n .xoo-widget-overlay--hidden {\n opacity: 0;\n pointer-events: none;\n }\n .xoo-widget-overlay--visible {\n opacity: 1;\n pointer-events: none;\n }\n\n @media (max-width: 420px) {\n .xoo-widget-container {\n width: calc(100vw - 16px);\n height: calc(100vh - 100px);\n max-height: none;\n left: 8px !important;\n right: 8px !important;\n border-radius: 12px;\n }\n .xoo-widget-container--center {\n top: 0;\n bottom: 0;\n margin: auto;\n }\n }\n `,document.head.appendChild(e)}(this.config.zIndex),this.fab=new n(this.config.position,()=>this.toggle()),this.fab.create(),this.config.autoShow||this.fab.hide(),this.iframe=new e,this.iframe.setMessageHandler(t=>this.handleIframeMessage(t)),this.iframe.setCloseClickHandler(()=>this.close()),this.iframe.create(this.config.walletUrl,this.config.apiKey,this.config.position,{lang:this.config.lang,theme:this.config.theme,popupPosition:this.config.popupPosition})}static init(t){if(!t.apiKey)throw new Error("[XooWallet] apiKey is required");return new o(t)}open(){this._isOpen||(this._isOpen=!0,this.iframe.show(),this.fab.setOpen(!0),this.iframe.postCommand({type:"xoo-cmd-open"}))}close(){this._isOpen&&(this._isOpen=!1,this.iframe.hide(),this.fab.setOpen(!1),this.iframe.postCommand({type:"xoo-cmd-close"}))}toggle(){this._isOpen?this.close():this.open()}login(){this.open(),this.iframe.postCommand({type:"xoo-cmd-login"})}logout(){this.iframe.postCommand({type:"xoo-cmd-logout"})}pay(t){this.open(),this.iframe.postCommand({type:"xoo-cmd-pay",to:t.to,amount:t.amount,token:t.token})}isOpen(){return this._isOpen}isLoggedIn(){return this._isLoggedIn}getUser(){return this._user}isReady(){return this._ready}show(){this.fab.show()}hide(){this.fab.hide(),this._isOpen&&this.close()}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t).add(e)}off(t,e){var i;null==(i=this.eventListeners.get(t))||i.delete(e)}destroy(){this.iframe.destroy(),this.fab.destroy(),function(){const t=document.getElementById("xoo-widget-styles");t&&t.remove()}(),this.eventListeners.clear(),this._isOpen=!1,this._isLoggedIn=!1,this._user=null,this._ready=!1}emit(t,...e){const i=this.eventListeners.get(t);if(i)for(const o of i)try{o(...e)}catch(n){console.error(`[XooWallet] Event handler error (${t}):`,n)}}handleIframeMessage(t){switch(t.type){case"xoo-ready":this._ready=!0,this.emit("ready");break;case"xoo-auth-success":this._isLoggedIn=!0,this._user=t.user,this.emit("auth:success",t.user);break;case"xoo-auth-logout":this._isLoggedIn=!1,this._user=null,this.emit("auth:logout");break;case"xoo-tx-success":this.emit("tx:success",{txHash:t.txHash});break;case"xoo-tx-failed":this.emit("tx:failed",{error:t.error});break;case"xoo-close":this._isOpen=!1,this.iframe.hide(),this.fab.setOpen(!1)}}}t.XooWallet=o,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}),"undefined"!=typeof globalThis&&globalThis.XooWallet&&globalThis.XooWallet.XooWallet&&(globalThis.XooWallet=globalThis.XooWallet.XooWallet);
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XooWallet={})}(this,function(t){"use strict";class e{constructor(){this.container=null,this.iframe=null,this.closeBtn=null,this.overlay=null,this.visible=!1,this.popupPosition="center",this.walletOrigin="",this.onMessage=null,this.onCloseClick=null,this.handleMessage=t=>{var e;if(t.origin!==this.walletOrigin)return;const i=t.data;i&&"string"==typeof i.type&&i.type.startsWith("xoo-")&&(i.type.startsWith("xoo-cmd-")||null==(e=this.onMessage)||e.call(this,i))},this.handleCloseClick=()=>{var t;null==(t=this.onCloseClick)||t.call(this)}}create(t,e,i,n){if(this.container)return;this.popupPosition=(null==n?void 0:n.popupPosition)||"center";const o=new URL(t);this.walletOrigin=o.origin,o.searchParams.set("embed","true"),o.searchParams.set("partnerKey",e),(null==n?void 0:n.lang)&&o.searchParams.set("lang",n.lang),(null==n?void 0:n.theme)&&o.searchParams.set("theme",n.theme),(null==n?void 0:n.ref)&&o.searchParams.set("ref",n.ref),"center"===this.popupPosition&&(this.overlay=document.createElement("div"),this.overlay.className="xoo-widget-overlay xoo-widget-overlay--hidden",document.body.appendChild(this.overlay));const s="center"===this.popupPosition?"center":i;this.container=document.createElement("div"),this.container.className=`xoo-widget-container xoo-widget-container--${s} xoo-widget-container--hidden`,this.iframe=document.createElement("iframe"),this.iframe.src=o.toString(),this.iframe.className="xoo-widget-iframe",this.iframe.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"),this.iframe.setAttribute("allow","clipboard-write"),this.iframe.setAttribute("title","XOO Wallet"),this.container.appendChild(this.iframe),this.closeBtn=document.createElement("button"),this.closeBtn.className="xoo-widget-close",this.closeBtn.innerHTML='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>',this.closeBtn.setAttribute("aria-label","Close"),this.closeBtn.addEventListener("click",this.handleCloseClick),this.container.appendChild(this.closeBtn),document.body.appendChild(this.container),window.addEventListener("message",this.handleMessage)}setMessageHandler(t){this.onMessage=t}setCloseClickHandler(t){this.onCloseClick=t}show(){this.container&&(this.visible=!0,this.container.classList.remove("xoo-widget-container--hidden"),this.container.classList.add("xoo-widget-container--visible"),this.overlay&&(this.overlay.classList.remove("xoo-widget-overlay--hidden"),this.overlay.classList.add("xoo-widget-overlay--visible")))}hide(){this.container&&(this.visible=!1,this.container.classList.remove("xoo-widget-container--visible"),this.container.classList.add("xoo-widget-container--hidden"),this.overlay&&(this.overlay.classList.remove("xoo-widget-overlay--visible"),this.overlay.classList.add("xoo-widget-overlay--hidden")))}isVisible(){return this.visible}postCommand(t){var e;(null==(e=this.iframe)?void 0:e.contentWindow)&&this.iframe.contentWindow.postMessage(t,this.walletOrigin)}destroy(){window.removeEventListener("message",this.handleMessage),this.closeBtn&&this.closeBtn.removeEventListener("click",this.handleCloseClick),this.overlay&&(this.overlay.remove(),this.overlay=null),this.container&&(this.container.remove(),this.container=null),this.iframe=null,this.closeBtn=null,this.onMessage=null,this.onCloseClick=null,this.visible=!1}}const i='<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.8703 16.2806C11.6385 16.0995 11.3551 15.996 11.0718 15.996C10.8914 15.996 10.7111 16.0219 10.5308 16.0995C10.3763 16.1771 10.2217 16.2806 10.0929 16.4358C10.0672 16.4617 10.0414 16.4876 10.0156 16.5134C9.88684 16.6687 9.80957 16.8239 9.75805 17.005C9.70653 17.1861 9.68077 17.3672 9.70653 17.5483C9.73229 17.7294 9.78381 17.9104 9.86109 18.0915C9.93836 18.2468 10.0672 18.402 10.2217 18.5313C10.4535 18.7383 10.7626 18.8418 11.046 18.8418C11.2263 18.8418 11.4066 18.8159 11.5869 18.7383C11.7672 18.6607 11.896 18.5572 12.0248 18.402C12.2567 18.1433 12.4112 17.7811 12.4112 17.4189C12.4112 17.0567 12.2824 16.6945 12.0506 16.41C11.9733 16.3841 11.9218 16.3323 11.8703 16.2806ZM17.9752 16.2806C17.7176 16.0736 17.3827 15.9701 17.0478 15.996C16.713 16.0219 16.4039 16.1771 16.1978 16.4358C15.966 16.6945 15.8114 17.0567 15.8114 17.4189C15.7856 17.7811 15.9144 18.1433 16.172 18.402C16.3008 18.5313 16.4296 18.6348 16.5842 18.7124C16.7387 18.7901 16.919 18.8159 17.0994 18.8159H17.1509C17.3312 18.8159 17.5115 18.7901 17.6661 18.7124C17.8206 18.6348 17.9752 18.5313 18.104 18.402C18.3358 18.1433 18.4903 17.7811 18.4903 17.4189C18.4903 17.0567 18.3615 16.6945 18.1297 16.4358C18.0782 16.3841 18.0267 16.3323 17.9752 16.2806ZM27.8924 15.1682H23.5906C22.9724 15.1682 22.483 15.6597 22.483 16.2806V18.5831C22.483 19.204 22.9724 19.6955 23.5906 19.6955H27.8924C28.5106 19.6955 29 19.204 29 18.5831V16.2806C29 15.6856 28.5106 15.1682 27.8924 15.1682ZM25.4453 18.402C24.9043 18.402 24.4922 17.9622 24.4922 17.4448C24.4922 16.9015 24.9301 16.4876 25.4453 16.4876C25.9604 16.4876 26.3983 16.9274 26.3983 17.4448C26.4241 17.9622 25.9862 18.402 25.4453 18.402ZM21.5814 18.7124V16.1512C21.5814 15.1682 22.3799 14.3662 23.3588 14.3662H27.506V11.1582C27.506 8.82985 25.7029 6.88955 23.3845 6.73433V5.23383C23.3845 3.44876 21.9163 2 20.1389 2H4.24563C2.4425 2 1 3.44876 1 5.2597C1 5.36318 1 5.46667 1.02576 5.54428H1V11.1582V23.5761C1 26.0338 2.98344 28 5.40478 28H23.0754C25.5225 28 27.4802 26.008 27.4802 23.5761V20.4975H23.3588C22.3799 20.4975 21.5814 19.6955 21.5814 18.7124ZM4.24563 3.78507H20.1389C20.9632 3.78507 21.6072 4.45771 21.6072 5.2597V6.73433H4.24563C3.42134 6.73433 2.77737 6.06169 2.77737 5.2597C2.77737 4.45771 3.42134 3.78507 4.24563 3.78507ZM8.05796 15.7114L6.4609 17.4448L8.05796 19.1781V20.3164H7.00184L5.40478 18.5831L3.80773 20.3164H2.77737V19.1522L4.37443 17.4189L2.77737 15.7114V14.5731H3.83349L5.43054 16.3065L7.0276 14.5731H8.08372V15.7114H8.05796ZM13.7249 18.5313C13.5961 18.8935 13.3901 19.204 13.1325 19.4627C12.8749 19.7214 12.5658 19.9542 12.2309 20.0836C11.896 20.2388 11.5354 20.3164 11.149 20.2905H10.9945C10.6339 20.2905 10.2475 20.2129 9.9126 20.0836C9.57774 19.9284 9.26863 19.7214 9.01104 19.4627C8.75345 19.204 8.54738 18.8677 8.41858 18.5313C8.28979 18.195 8.21251 17.807 8.21251 17.4189C8.21251 17.0308 8.26403 16.6687 8.39282 16.3065C8.52162 15.9443 8.72769 15.6338 8.98528 15.3751C9.24287 15.1164 9.55198 14.8836 9.88684 14.7542C10.2217 14.6249 10.5823 14.5214 10.9687 14.5473H11.0975C11.4581 14.5473 11.8445 14.6249 12.1794 14.7801C12.5143 14.9353 12.8234 15.1423 13.081 15.401C13.3385 15.6597 13.5446 15.996 13.6992 16.3323C13.828 16.6945 13.9052 17.0567 13.9052 17.4448C13.9052 17.807 13.8537 18.195 13.7249 18.5313ZM19.8298 18.5313C19.701 18.8935 19.4949 19.204 19.2374 19.4627L19.2116 19.4886C18.6707 20.006 17.9236 20.2905 17.1766 20.2905C16.4296 20.2905 15.6826 19.9801 15.1417 19.4368C14.8841 19.1781 14.678 18.8418 14.5492 18.5055C14.4204 18.1433 14.3431 17.7811 14.3431 17.393C14.3431 17.005 14.3947 16.6428 14.5235 16.2806C14.6523 15.9184 14.8583 15.608 15.1159 15.3493C15.1417 15.3234 15.1674 15.2975 15.1674 15.2975C15.7084 14.7801 16.4296 14.4955 17.1509 14.5214C17.5373 14.5214 17.8979 14.599 18.2585 14.7284C18.6191 14.8836 18.9282 15.0905 19.1858 15.3493C19.4434 15.608 19.6495 15.9443 19.804 16.2806C19.9328 16.6428 20.0101 17.005 20.0101 17.393C20.0101 17.807 19.9586 18.195 19.8298 18.5313Z" fill="#1D2088"/></svg>';class n{constructor(t,e){this.button=null,this.isOpen=!1,this.handleClick=()=>{this.onClick()},this.position=t,this.onClick=e}create(){this.button||(this.button=document.createElement("button"),this.button.className=`xoo-widget-fab xoo-widget-fab--${this.position}`,this.button.innerHTML=i,this.button.setAttribute("aria-label","Open XOO Wallet"),this.button.addEventListener("click",this.handleClick),document.body.appendChild(this.button))}setOpen(t){this.isOpen=t,this.button&&(t?(this.button.innerHTML='<svg width="30" height="30" viewBox="0 0 30 30" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M21.5739 18.6984V16.1404C21.5739 15.1586 22.3731 14.3576 23.3529 14.3576H27.4006V11.4638C27.4006 9.62926 25.931 8.1565 24.1005 8.1565H3.47506V7.89812C3.47506 7.12299 4.04226 6.47704 4.81571 6.37369L20.7231 4.15163C21.4966 4.04828 22.1927 4.64255 22.1927 5.41769V7.35553H24.1005V4.87509C24.1005 3.06644 22.631 1.77454 20.8262 2.03292L4.27429 4.38417C2.46956 4.64255 1 6.34785 1 8.1565V24.6928C1 26.5272 2.46956 28 4.30008 28H24.1005C25.931 28 27.4006 26.5272 27.4006 24.6928V20.4812H23.3529C22.3731 20.4812 21.5739 19.6802 21.5739 18.6984ZM8.06422 15.7012L6.46575 17.4323L8.06422 19.1634V20.3003H7.00717L5.40869 18.5692L3.81022 20.3003H2.75316V19.1376L4.35164 17.4065L2.75316 15.6753V14.5385H3.81022L5.40869 16.2696L7.00717 14.5385H8.06422V15.7012ZM13.7104 18.5175C13.5815 18.8792 13.3753 19.1893 13.1175 19.4477C12.8596 19.706 12.5503 19.9386 12.2151 20.0678C11.8799 20.2228 11.519 20.3003 11.1323 20.2745H10.9776C10.6166 20.2745 10.2299 20.197 9.89473 20.0678C9.55957 19.9127 9.25019 19.706 8.99237 19.4477C8.73455 19.1893 8.5283 18.8534 8.39939 18.5175C8.27048 18.1816 8.19313 17.794 8.19313 17.4065C8.19313 17.0189 8.2447 16.6572 8.37361 16.2954C8.50251 15.9337 8.70877 15.6237 8.96659 15.3653C9.22441 15.1069 9.53379 14.8744 9.86895 14.7452C10.2041 14.616 10.5651 14.5126 10.9518 14.5385H11.0807C11.4416 14.5385 11.8284 14.616 12.1635 14.771C12.4987 14.926 12.8081 15.1327 13.0659 15.3911C13.3237 15.6495 13.53 15.9854 13.6847 16.3213C13.8136 16.683 13.8909 17.0447 13.8909 17.4323C13.9167 17.794 13.8394 18.1558 13.7104 18.5175ZM19.8207 18.5175C19.6918 18.8792 19.4856 19.1893 19.2278 19.4477L19.202 19.4735C18.6606 19.9903 17.9129 20.2745 17.1652 20.2745C16.4175 20.2745 15.6699 19.9644 15.1284 19.4218C14.8706 19.1634 14.6644 18.8276 14.5355 18.4917C14.4066 18.1299 14.3292 17.7682 14.3292 17.3806C14.3292 16.9931 14.3808 16.6313 14.5097 16.2696C14.6386 15.9079 14.8448 15.5978 15.1027 15.3394C15.1284 15.3136 15.1542 15.2878 15.1542 15.2878C15.6956 14.771 16.4175 14.4868 17.1394 14.5126C17.5262 14.5126 17.8871 14.5901 18.248 14.7193C18.609 14.8744 18.9184 15.0811 19.1762 15.3394C19.434 15.5978 19.6403 15.9337 19.795 16.2696C19.9239 16.6313 20.0012 16.9931 20.0012 17.3806C20.027 17.794 19.9497 18.1558 19.8207 18.5175ZM17.9644 16.2696C17.7066 16.0629 17.3715 15.9595 17.0363 15.9854C16.7269 16.0112 16.4175 16.1921 16.2113 16.4246C15.9792 16.683 15.8246 17.0447 15.8246 17.4065C15.7988 17.7682 15.9277 18.1299 16.1855 18.3883C16.3144 18.5175 16.4433 18.6208 16.598 18.6984C16.7527 18.7759 16.9332 18.8017 17.1136 18.8017H17.1652C17.3457 18.8017 17.5262 18.7759 17.6808 18.6984C17.8355 18.6208 17.9902 18.5175 18.1191 18.3883C18.3512 18.1299 18.5059 17.7682 18.5059 17.4065C18.5059 17.0447 18.377 16.683 18.1449 16.4246C18.0934 16.373 18.0418 16.3213 17.9644 16.2696ZM11.8542 16.2696C11.6221 16.0887 11.3385 15.9854 11.0549 15.9854C10.8744 15.9854 10.694 16.0112 10.5135 16.0887C10.3588 16.1662 10.2041 16.2696 10.0752 16.4246C10.0494 16.4505 10.0236 16.4763 9.99786 16.5021C9.86895 16.6572 9.79161 16.8122 9.74004 16.9931C9.68848 17.1739 9.6627 17.3548 9.68848 17.5357C9.71426 17.7165 9.76582 17.8974 9.84317 18.0783C9.92052 18.2333 10.0494 18.3883 10.2041 18.5175C10.4362 18.7242 10.7455 18.8275 11.0291 18.8275C11.2096 18.8275 11.3901 18.8017 11.5706 18.7242C11.751 18.6467 11.8799 18.5433 12.0088 18.3883C12.2409 18.1299 12.3956 17.7682 12.3956 17.4065C12.3956 17.0447 12.2667 16.683 12.0346 16.3988C11.9573 16.373 11.9057 16.3213 11.8542 16.2696ZM27.8905 15.1586H23.5849C22.9661 15.1586 22.4763 15.6495 22.4763 16.2696V18.5692C22.4763 19.1893 22.9661 19.6802 23.5849 19.6802H27.8905C28.5092 19.6802 28.9991 19.1893 28.9991 18.5692V16.2696C29.0249 15.6495 28.5092 15.1586 27.8905 15.1586ZM25.4412 18.3883C24.8998 18.3883 24.4873 17.9491 24.4873 17.4323C24.4873 16.8897 24.9255 16.4763 25.4412 16.4763C25.9826 16.4763 26.3951 16.9155 26.3951 17.4323C26.4209 17.9491 25.9826 18.3883 25.4412 18.3883Z" fill="#1D2088"/></svg>',this.button.classList.add("xoo-widget-fab--open"),this.button.setAttribute("aria-label","Close XOO Wallet")):(this.button.innerHTML=i,this.button.classList.remove("xoo-widget-fab--open"),this.button.setAttribute("aria-label","Open XOO Wallet")))}show(){this.button&&(this.button.style.display="flex")}hide(){this.button&&(this.button.style.display="none")}destroy(){this.button&&(this.button.removeEventListener("click",this.handleClick),this.button.remove(),this.button=null)}}class o{constructor(t){this.eventListeners=new Map,this._isOpen=!1,this._isLoggedIn=!1,this._user=null,this._ready=!1,this.config={apiKey:t.apiKey,walletUrl:t.walletUrl||"https://web.xoowallet.com",position:t.position||"bottom-right",popupPosition:t.popupPosition||"center",autoShow:!1!==t.autoShow,zIndex:t.zIndex||99999,theme:t.theme,lang:t.lang,ref:t.ref},function(t){if(document.getElementById("xoo-widget-styles"))return;const e=document.createElement("style");e.id="xoo-widget-styles",e.textContent=`\n .xoo-widget-fab {\n position: fixed;\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n z-index: ${t+1};\n background: #f0f0f0;\n padding: 0;\n outline: none;\n }\n .xoo-widget-fab:hover {\n transform: scale(1.05);\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);\n background: #e5e5e5;\n }\n .xoo-widget-fab:active {\n transform: scale(0.95);\n }\n .xoo-widget-fab svg {\n width: 30px;\n height: 30px;\n transition: transform 0.3s ease;\n }\n .xoo-widget-fab--bottom-right {\n bottom: 20px;\n right: 20px;\n }\n .xoo-widget-fab--bottom-left {\n bottom: 20px;\n left: 20px;\n }\n\n /* ---- 弹窗容器(包裹 iframe + 关闭按钮) ---- */\n .xoo-widget-container {\n position: fixed;\n width: 375px;\n height: 640px;\n max-height: 80vh;\n border-radius: 16px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);\n z-index: ${t};\n overflow: hidden;\n transition: opacity 0.2s ease, transform 0.2s ease;\n }\n .xoo-widget-container--center {\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n margin: auto;\n }\n .xoo-widget-container--bottom-right {\n bottom: 88px;\n right: 20px;\n }\n .xoo-widget-container--bottom-left {\n bottom: 88px;\n left: 20px;\n }\n .xoo-widget-container--hidden {\n opacity: 0;\n transform: translateY(10px) scale(0.95);\n pointer-events: none;\n }\n .xoo-widget-container--visible {\n opacity: 1;\n transform: translateY(0) scale(1);\n }\n\n /* ---- iframe 填充容器 ---- */\n .xoo-widget-iframe {\n width: 100%;\n height: 100%;\n border: none;\n background: #ffffff;\n }\n\n /* ---- 关闭按钮(容器内,iframe 上层) ---- */\n .xoo-widget-close {\n position: absolute;\n top: 3px;\n right: 3px;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n border: none;\n background: rgba(0, 0, 0, 0.06);\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 2;\n color: #999;\n padding: 0;\n outline: none;\n transition: background 0.15s ease, color 0.15s ease;\n }\n .xoo-widget-close:hover {\n background: rgba(0, 0, 0, 0.12);\n color: #333;\n }\n .xoo-widget-close svg {\n width: 14px;\n height: 14px;\n }\n\n /* ---- 遮罩层(仅视觉,不拦截点击) ---- */\n .xoo-widget-overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.4);\n z-index: ${t-1};\n transition: opacity 0.2s ease;\n }\n .xoo-widget-overlay--hidden {\n opacity: 0;\n pointer-events: none;\n }\n .xoo-widget-overlay--visible {\n opacity: 1;\n pointer-events: none;\n }\n\n @media (max-width: 420px) {\n .xoo-widget-container {\n width: calc(100vw - 16px);\n height: calc(100vh - 100px);\n max-height: none;\n left: 8px !important;\n right: 8px !important;\n border-radius: 12px;\n }\n .xoo-widget-container--center {\n top: 0;\n bottom: 0;\n margin: auto;\n }\n }\n `,document.head.appendChild(e)}(this.config.zIndex),this.fab=new n(this.config.position,()=>this.toggle()),this.fab.create(),this.config.autoShow||this.fab.hide(),this.iframe=new e,this.iframe.setMessageHandler(t=>this.handleIframeMessage(t)),this.iframe.setCloseClickHandler(()=>this.close()),this.iframe.create(this.config.walletUrl,this.config.apiKey,this.config.position,{lang:this.config.lang,theme:this.config.theme,popupPosition:this.config.popupPosition,ref:this.config.ref})}static init(t){if(!t.apiKey)throw new Error("[XooWallet] apiKey is required");return new o(t)}open(){this._isOpen||(this._isOpen=!0,this.iframe.show(),this.fab.setOpen(!0),this.iframe.postCommand({type:"xoo-cmd-open"}))}close(){this._isOpen&&(this._isOpen=!1,this.iframe.hide(),this.fab.setOpen(!1),this.iframe.postCommand({type:"xoo-cmd-close"}))}toggle(){this._isOpen?this.close():this.open()}login(){this.open(),this.iframe.postCommand({type:"xoo-cmd-login"})}logout(){this.iframe.postCommand({type:"xoo-cmd-logout"})}pay(t){this.open(),this.iframe.postCommand({type:"xoo-cmd-pay",to:t.to,amount:t.amount,token:t.token,network:t.network})}isOpen(){return this._isOpen}isLoggedIn(){return this._isLoggedIn}getUser(){return this._user}isReady(){return this._ready}show(){this.fab.show()}hide(){this.fab.hide(),this._isOpen&&this.close()}on(t,e){this.eventListeners.has(t)||this.eventListeners.set(t,new Set),this.eventListeners.get(t).add(e)}off(t,e){var i;null==(i=this.eventListeners.get(t))||i.delete(e)}destroy(){this.iframe.destroy(),this.fab.destroy(),function(){const t=document.getElementById("xoo-widget-styles");t&&t.remove()}(),this.eventListeners.clear(),this._isOpen=!1,this._isLoggedIn=!1,this._user=null,this._ready=!1}emit(t,...e){const i=this.eventListeners.get(t);if(i)for(const o of i)try{o(...e)}catch(n){console.error(`[XooWallet] Event handler error (${t}):`,n)}}handleIframeMessage(t){switch(t.type){case"xoo-ready":this._ready=!0,this.emit("ready");break;case"xoo-auth-success":this._isLoggedIn=!0,this._user=t.user,this.emit("auth:success",t.user);break;case"xoo-auth-logout":this._isLoggedIn=!1,this._user=null,this.emit("auth:logout");break;case"xoo-tx-success":this.emit("tx:success",{txHash:t.txHash});break;case"xoo-tx-failed":this.emit("tx:failed",{error:t.error});break;case"xoo-close":this._isOpen=!1,this.iframe.hide(),this.fab.setOpen(!1)}}}t.XooWallet=o,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}),"undefined"!=typeof globalThis&&globalThis.XooWallet&&globalThis.XooWallet.XooWallet&&(globalThis.XooWallet=globalThis.XooWallet.XooWallet);
|