@frak-labs/components 1.0.5 → 1.0.6-beta.dc7ed9db
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/cdn/Banner.L6HcKGUv.js +178 -0
- package/cdn/ButtonShare.O2wAgNZa.js +1 -0
- package/cdn/ButtonWallet.Cm8Qzz45.js +40 -0
- package/cdn/{GiftIcon.eRNTGQ_r.js → GiftIcon.DnSW4dJQ.js} +1 -1
- package/cdn/{OpenInAppButton.Dgb-qhM8.js → OpenInAppButton.CTBE114K.js} +1 -1
- package/cdn/PostPurchase.fx6VasmG.js +89 -0
- package/cdn/components.js +1 -1
- package/cdn/embeddedWallet.CDUxjdX2.js +1 -0
- package/cdn/{formatReward.B1ZyoceC.js → formatReward.Cmg_Q___.js} +1 -1
- package/cdn/loader.js +1 -1
- package/cdn/replay-V6FXES7X.CNozpSRg.js +1 -0
- package/cdn/{useGlobalComponents.TG9kIYSc.js → useGlobalComponents.pjgSwLk9.js} +1 -1
- package/cdn/{useLightDomStyles.tjNBKcOr.js → useLightDomStyles.2RQE6Iby.js} +1 -1
- package/cdn/usePlacement.CRfzWKVY.js +58 -0
- package/cdn/useReward.cZ7bx5ND.js +1 -0
- package/dist/{GiftIcon-BIp9FTJs.js → GiftIcon-WEWSJ8kV.js} +1 -1
- package/dist/banner.d.ts +1 -2
- package/dist/banner.js +3 -3
- package/dist/buttonShare.d.ts +1 -2
- package/dist/buttonShare.js +3 -3
- package/dist/buttonWallet.d.ts +1 -2
- package/dist/buttonWallet.js +17 -1
- package/dist/embeddedWallet-By3_p5Xc.js +18 -0
- package/dist/openInApp.d.ts +1 -3
- package/dist/openInApp.js +2 -2
- package/dist/postPurchase.d.ts +1 -2
- package/dist/postPurchase.js +4 -75
- package/dist/{useLightDomStyles-DVe5UDg6.js → useLightDomStyles-Xi52h2yV.js} +1 -1
- package/dist/usePlacement-SHVjZ5IW.js +404 -0
- package/package.json +3 -3
- package/cdn/Banner.CIxY6tCU.js +0 -178
- package/cdn/ButtonShare.elMtdxF3.js +0 -1
- package/cdn/ButtonWallet.BUUPX0gO.js +0 -40
- package/cdn/PostPurchase.Cy7-FrRh.js +0 -89
- package/cdn/replay-V6FXES7X.BoL9fAjx.js +0 -1
- package/cdn/sharingPage.BYsqcN9O.js +0 -1
- package/cdn/usePlacement.BgMXY5CX.js +0 -58
- package/cdn/useReward.B530suzR.js +0 -1
- package/dist/sharingPage-D6fQEXV9.js +0 -15
- package/dist/usePlacement-DzEuVg_u.js +0 -253
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import{S as e,T as t,a as n,b as r,l as i,s as a,x as o}from"./loader.js";import{a as s,c,d as l,i as ee,l as u,o as d,s as f,t as p,u as m}from"./usePlacement.BgMXY5CX.js";import{r as h,t as g}from"./GiftIcon.eRNTGQ_r.js";import{t as _}from"./useGlobalComponents.TG9kIYSc.js";import{t as v}from"./useLightDomStyles.tjNBKcOr.js";import{n as te,t as y}from"./formatReward.B1ZyoceC.js";import{t as b}from"./sharingPage.BYsqcN9O.js";var ne=`PostPurchase_card__5fv5lh0`,re=`PostPurchase_cardLayout__5fv5lh1`,ie=`PostPurchase_cardLeft__5fv5lh2`,ae=`PostPurchase_cardRight__5fv5lh3`,oe=`PostPurchase_cta__5fv5lh6 sharedBaseCss_buttonReset__7cswil0`,se=`PostPurchase_customImage__5fv5lha`,ce=`PostPurchase_frakLogo__5fv5lhb`,le=`PostPurchase_giftIcon__5fv5lh8`,ue=`PostPurchase_icon__5fv5lh7`,de=`PostPurchase_imageWrapper__5fv5lh9`,fe=`PostPurchase_message__5fv5lh5`;function x(e){try{let t=new URL(e);return t.protocol===`http:`||t.protocol===`https:`}catch{return!1}}function pe(e){if(!e)return null;if(Array.isArray(e))return e;if(typeof e!=`string`)return null;try{let t=JSON.parse(e);return Array.isArray(t)?t:null}catch{return null}}function S(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.title==`string`?t.title.trim():``;if(n===``)return null;let r={title:n};return typeof t.imageUrl==`string`&&x(t.imageUrl)&&(r.imageUrl=t.imageUrl),typeof t.link==`string`&&x(t.link)&&(r.link=t.link),typeof t.utmContent==`string`&&t.utmContent!==``&&(r.utmContent=t.utmContent),r}function C(e,t){let n=t.rewards.find(e=>e.interactionTypeKey===`purchase`&&(e.referrer||e.referee));if(!n)return null;let r=e?.isReferred&&n.referee?`referee`:`referrer`;return{variant:r,reward:r===`referee`?n.referee:n.referrer,merchantDomain:t.onChainMetadata.domain}}function w({customerId:l,orderId:x,token:w,sharingUrl:T,merchantId:E,placement:D,classname:O=``,variant:k,badgeText:A,referrerText:j,refereeText:M,ctaText:N,preview:P,previewVariant:F,products:I,imageUrl:L}){let R=!!P,{shouldRender:z,isHidden:B,isClientReady:V}=ee(),H=p(D);v(`frak-post-purchase`,D,H?.components?.postPurchase?.css,`.PostPurchase_card__5fv5lh0 {
|
|
2
|
-
padding: 16px;
|
|
3
|
-
border-radius: 12px;
|
|
4
|
-
background-color: var(--surface-background__pbq4akc);
|
|
5
|
-
border: 1px solid var(--border-default__pbq4akv);
|
|
6
|
-
}
|
|
7
|
-
.PostPurchase_cardLayout__5fv5lh1 {
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: row;
|
|
10
|
-
align-items: center;
|
|
11
|
-
gap: 32px;
|
|
12
|
-
}
|
|
13
|
-
.PostPurchase_cardLeft__5fv5lh2 {
|
|
14
|
-
flex-grow: 1;
|
|
15
|
-
min-width: 0;
|
|
16
|
-
display: flex;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
gap: 8px;
|
|
19
|
-
}
|
|
20
|
-
.PostPurchase_cardRight__5fv5lh3 {
|
|
21
|
-
flex-shrink: 0;
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
align-items: flex-end;
|
|
25
|
-
gap: 8px;
|
|
26
|
-
text-align: right;
|
|
27
|
-
}
|
|
28
|
-
.PostPurchase_badge__5fv5lh4 {
|
|
29
|
-
align-self: flex-start;
|
|
30
|
-
background-color: #FFF534;
|
|
31
|
-
border-radius: 4px;
|
|
32
|
-
padding: 4px 8px;
|
|
33
|
-
font-size: 12px;
|
|
34
|
-
font-weight: 600;
|
|
35
|
-
line-height: 12px;
|
|
36
|
-
color: var(--text-primary__pbq4ak0);
|
|
37
|
-
}
|
|
38
|
-
.PostPurchase_message__5fv5lh5 {
|
|
39
|
-
margin: 0;
|
|
40
|
-
font-size: 16px;
|
|
41
|
-
line-height: 22px;
|
|
42
|
-
color: var(--text-primary__pbq4ak0);
|
|
43
|
-
font-weight: 600;
|
|
44
|
-
}
|
|
45
|
-
.PostPurchase_cta__5fv5lh6 {
|
|
46
|
-
display: inline-flex;
|
|
47
|
-
align-items: center;
|
|
48
|
-
justify-content: center;
|
|
49
|
-
gap: 4px;
|
|
50
|
-
padding: 12px 16px;
|
|
51
|
-
border-radius: 9999px;
|
|
52
|
-
background-color: var(--text-primary__pbq4ak0);
|
|
53
|
-
color: var(--text-onAction__pbq4ak6);
|
|
54
|
-
font-size: 12px;
|
|
55
|
-
font-weight: bold;
|
|
56
|
-
text-transform: uppercase;
|
|
57
|
-
}
|
|
58
|
-
.PostPurchase_cta__5fv5lh6:disabled {
|
|
59
|
-
opacity: 0.7;
|
|
60
|
-
cursor: default;
|
|
61
|
-
}
|
|
62
|
-
.PostPurchase_icon__5fv5lh7 {
|
|
63
|
-
margin: -2px 0;
|
|
64
|
-
}
|
|
65
|
-
.PostPurchase_giftIcon__5fv5lh8 {
|
|
66
|
-
display: block;
|
|
67
|
-
flex-shrink: 0;
|
|
68
|
-
}
|
|
69
|
-
.PostPurchase_imageWrapper__5fv5lh9 {
|
|
70
|
-
flex-shrink: 0;
|
|
71
|
-
display: flex;
|
|
72
|
-
align-items: center;
|
|
73
|
-
justify-content: center;
|
|
74
|
-
width: 80px;
|
|
75
|
-
height: 80px;
|
|
76
|
-
overflow: hidden;
|
|
77
|
-
}
|
|
78
|
-
.PostPurchase_customImage__5fv5lha {
|
|
79
|
-
max-width: 100%;
|
|
80
|
-
max-height: 100%;
|
|
81
|
-
width: auto;
|
|
82
|
-
height: auto;
|
|
83
|
-
object-fit: contain;
|
|
84
|
-
display: block;
|
|
85
|
-
}
|
|
86
|
-
.PostPurchase_frakLogo__5fv5lhb {
|
|
87
|
-
display: block;
|
|
88
|
-
margin-left: auto;
|
|
89
|
-
}`,t);let[U,me]=f(null),[W,G]=f(!1);u(()=>{R||!V||!l||!x||!w||n({customerId:l,orderId:x,token:w,merchantId:E}).catch(()=>{})},[R,V,l,x,w,E]),u(()=>{if(R||!V||W)return;let t=window.FrakSetup?.client;t&&Promise.all([a(t),i(t)]).then(([e,t])=>{G(!0),me(C(e,t))}).catch(t=>{if(t instanceof e&&t.code===o.configError){G(!0);return}})},[R,V,W]);let K=s(null),q=k??U?.variant??(R?F??`referrer`:void 0),J=T??U?.merchantDomain,Y=d(()=>{if(!U?.reward)return;let e=window.FrakSetup?.client?.config?.metadata?.currency;return te(U.reward,e)},[U?.reward]),he=_(),X=H?.components?.postPurchase??he?.postPurchase,Z=A??X?.badgeText,Q=d(()=>({message:q===`referee`?Y?y(M??X?.refereeText??`You just earned {REWARD}! Share with friends to earn even more.`,Y):M??X?.refereeNoRewardText??`You just earned a reward! Share with friends to earn even more.`:Y?y(j??X?.referrerText??`Earn {REWARD} by sharing this with your friends!`,Y):j??X?.referrerNoRewardText??`Share this with your friends and earn rewards!`,cta:Y?y(N??X?.ctaText??`Share & earn {REWARD}`,Y):N??X?.ctaNoRewardText??`Share & earn`}),[q,Y,X,j,M,N]);u(()=>{q&&K.current!==q&&(!R&&(!z||B||!V)||(r(window.FrakSetup?.client,`post_purchase_impression`,{placement:D,variant:q,has_reward:!!U?.reward}),K.current=q))},[q,z,B,V,R,D,U?.reward]);let $=d(()=>{let e=pe(I);if(!e)return;let t=[];for(let n of e){let e=S(n);e&&t.push(e)}return t.length>0?t:void 0},[I]),ge=c(()=>{q&&(r(window.FrakSetup?.client,`post_purchase_clicked`,{placement:D,variant:q}),b(void 0,D,{link:J,products:$}))},[q,D,J,$]);return!q||!R&&(!z||B||!U)?null:m(`div`,{className:[ne,O].filter(Boolean).join(` `),children:m(`div`,{class:re,children:[m(`div`,{class:ie,children:[Z&&m(`span`,{class:`PostPurchase_badge__5fv5lh4`,children:Z}),m(`p`,{class:fe,children:Q.message}),m(`button`,{type:`button`,className:`${oe} button`,disabled:!R&&!V,onClick:R?void 0:ge,children:[Q.cta,m(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`${ue} button`,children:m(`path`,{d:`M13.8984 11.144C13.9864 11.052 14.1543 11.1114 14.1543 11.2388V11.644C14.1543 13.0509 12.6288 14.1918 10.7471 14.1919C8.86523 14.1919 7.33984 13.051 7.33984 11.644V11.2388C7.33984 11.1114 7.50675 11.052 7.59473 11.144C8.3452 11.9295 9.47906 12.4292 10.7471 12.4292C12.0149 12.4291 13.148 11.9293 13.8984 11.144ZM1.8457 9.64795C1.8457 9.51169 2.01094 9.44452 2.10254 9.54053C2.85304 10.3238 3.98586 10.8247 5.25293 10.8247C5.52246 10.8247 5.78608 10.8026 6.04102 10.7593C6.25744 10.7225 6.46582 10.8816 6.46582 11.1011V12.1704C6.46564 12.319 6.36769 12.4507 6.22266 12.4829C5.91535 12.5512 5.58981 12.5874 5.25293 12.5874C3.3711 12.5874 1.8457 11.4469 1.8457 10.0396V9.64795ZM10.7471 6.20654C12.6288 6.20666 14.1543 7.3475 14.1543 8.75439C14.1541 10.1612 12.6287 11.3012 10.7471 11.3013C8.86535 11.3013 7.34004 10.1612 7.33984 8.75439C7.33984 7.34743 8.86523 6.20654 10.7471 6.20654ZM1.8457 6.8501C1.84597 6.71385 2.01208 6.64848 2.10352 6.74365C2.85393 7.52827 3.98602 8.0278 5.25293 8.02783C5.52282 8.02783 5.78667 8.00448 6.04199 7.96143C6.258 7.92499 6.46582 8.08514 6.46582 8.3042V9.37256C6.46582 9.52127 6.36783 9.65378 6.22266 9.68604C5.91537 9.75429 5.58979 9.79053 5.25293 9.79053C3.3711 9.79048 1.8457 8.64863 1.8457 7.24268V6.8501ZM5.25293 1.80811C7.13481 1.80811 8.66016 2.94856 8.66016 4.35596C8.66008 5.76331 7.13476 6.90381 5.25293 6.90381C3.37115 6.90376 1.84578 5.76328 1.8457 4.35596C1.8457 2.94858 3.3711 1.80815 5.25293 1.80811Z`,fill:`currentColor`})})]})]}),m(`div`,{class:ae,children:[L?m(`span`,{class:de,children:m(`img`,{src:L,alt:``,class:se})}):m(g,{className:le,width:80,height:80}),m(h,{className:ce,width:42,height:24})]})]})})}l(w,`frak-post-purchase`,[`customerId`,`orderId`,`token`,`sharingUrl`,`merchantId`,`placement`,`classname`,`variant`,`badgeText`,`referrerText`,`refereeText`,`ctaText`,`products`,`preview`,`previewVariant`,`imageUrl`],{shadow:!1});export{w as PostPurchase};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function e(){return()=>{}}var t=null;function n(n,r){if(typeof document>`u`||typeof window>`u`)return;t&&t();let i=n.maxEventsPerChunk??200,a=n.flushIntervalMs??1e4,o=n.maxPayloadBytes??1048576,s=[],c=0,l=null;function u(e){if(s.length===0)return;let t=JSON.stringify(s);if(new TextEncoder().encode(t).length>o){if(s.length>1){let t=Math.floor(s.length/2),n=s.slice(0,t),r=s.slice(t),i=e&&n.some(e=>e.type===2);s=n,u(i),s=r,u(!1);return}s=[];return}let n=s[0].timestamp,i=s[s.length-1].timestamp;try{r({chunk_index:c,events_count:s.length,is_full_snapshot:e,started_at:new Date(n).toISOString(),ended_at:new Date(i).toISOString(),payload:t}),c+=1,s=[]}catch(e){throw e}}function d(e){let t=e||s.some(e=>e.type===2);s.length>=i?u(t):e&&s.length>0&&u(!0)}let f=n.maskAllText!==!1,p=n.unmaskTextSelector,m=e({emit(e,t){s.push(e),d(!!t)},checkoutEveryNms:a,maskAllInputs:n.maskAllInputs??!0,maskTextSelector:f?`*`:`[data-openpanel-replay-mask]`,maskTextFn:f&&p?(e,t)=>t?.closest(p)?e:e.replace(/\S/g,`*`):void 0,blockSelector:n.blockSelector??`[data-openpanel-replay-block]`,blockClass:n.blockClass,ignoreSelector:n.ignoreSelector});l=setInterval(()=>{s.length>0&&u(s.some(e=>e.type===2))},a);function h(){document.visibilityState===`hidden`&&s.length>0&&u(s.some(e=>e.type===2))}function g(){s.length>0&&u(s.some(e=>e.type===2))}document.addEventListener(`visibilitychange`,h),window.addEventListener(`pagehide`,g),t=()=>{s.length>0&&u(s.some(e=>e.type===2)),l&&=(clearInterval(l),null),document.removeEventListener(`visibilitychange`,h),window.removeEventListener(`pagehide`,g),m?.(),t=null}}function r(){t&&t()}export{n as startReplayRecorder,r as stopReplayRecorder};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./loader.js";async function t(t,n,r){window.FrakSetup?.client&&await e(window.FrakSetup.client,{...r?.link&&{link:r.link},...r?.products?.length&&{products:r.products},...t&&{metadata:{targetInteraction:t}}},n)}export{t};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import{C as e,n as t,t as n,y as r}from"./loader.js";var i,a,o,s,c,l,u,d,f,p,m,h={},g=[],_=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,v=Array.isArray;function y(e,t){for(var n in t)e[n]=t[n];return e}function b(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function x(e,t,n){var r,a,o,s={};for(o in t)o==`key`?r=t[o]:o==`ref`?a=t[o]:s[o]=t[o];if(arguments.length>2&&(s.children=arguments.length>3?i.call(arguments,2):n),typeof e==`function`&&e.defaultProps!=null)for(o in e.defaultProps)s[o]===void 0&&(s[o]=e.defaultProps[o]);return S(e,s,r,a,null)}function S(e,t,n,r,i){var s={type:e,props:t,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++o,__i:-1,__u:0};return i==null&&a.vnode!=null&&a.vnode(s),s}function C(e){return e.children}function w(e,t){this.props=e,this.context=t}function T(e,t){if(t==null)return e.__?T(e.__,e.__i+1):null;for(var n;t<e.__k.length;t++)if((n=e.__k[t])!=null&&n.__e!=null)return n.__e;return typeof e.type==`function`?T(e):null}function E(e){if(e.__P&&e.__d){var t=e.__v,n=t.__e,r=[],i=[],o=y({},t);o.__v=t.__v+1,a.vnode&&a.vnode(o),F(e.__P,o,t,e.__n,e.__P.namespaceURI,32&t.__u?[n]:null,r,n??T(t),!!(32&t.__u),i),o.__v=t.__v,o.__.__k[o.__i]=o,re(r,o,i),t.__e=t.__=null,o.__e!=n&&D(o)}}function D(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(t){if(t!=null&&t.__e!=null)return e.__e=e.__c.base=t.__e}),D(e)}function O(e){(!e.__d&&(e.__d=!0)&&s.push(e)&&!k.__r++||c!=a.debounceRendering)&&((c=a.debounceRendering)||l)(k)}function k(){try{for(var e,t=1;s.length;)s.length>t&&s.sort(u),e=s.shift(),t=s.length,E(e)}finally{s.length=k.__r=0}}function ee(e,t,n,r,i,a,o,s,c,l,u){var d,f,p,m,_,v,y,b=r&&r.__k||g,x=t.length;for(c=A(n,t,b,c,x),d=0;d<x;d++)(p=n.__k[d])!=null&&(f=p.__i!=-1&&b[p.__i]||h,p.__i=d,v=F(e,p,f,i,a,o,s,c,l,u),m=p.__e,p.ref&&f.ref!=p.ref&&(f.ref&&L(f.ref,null,p),u.push(p.ref,p.__c||m,p)),_==null&&m!=null&&(_=m),(y=!!(4&p.__u))||f.__k===p.__k?c=j(p,c,e,y):typeof p.type==`function`&&v!==void 0?c=v:m&&(c=m.nextSibling),p.__u&=-7);return n.__e=_,c}function A(e,t,n,r,i){var a,o,s,c,l,u=n.length,d=u,f=0;for(e.__k=Array(i),a=0;a<i;a++)(o=t[a])!=null&&typeof o!=`boolean`&&typeof o!=`function`?(typeof o==`string`||typeof o==`number`||typeof o==`bigint`||o.constructor==String?o=e.__k[a]=S(null,o,null,null,null):v(o)?o=e.__k[a]=S(C,{children:o},null,null,null):o.constructor===void 0&&o.__b>0?o=e.__k[a]=S(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):e.__k[a]=o,c=a+f,o.__=e,o.__b=e.__b+1,s=null,(l=o.__i=te(o,n,c,d))!=-1&&(d--,(s=n[l])&&(s.__u|=2)),s==null||s.__v==null?(l==-1&&(i>u?f--:i<u&&f++),typeof o.type!=`function`&&(o.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,o.__u|=4))):e.__k[a]=null;if(d)for(a=0;a<u;a++)(s=n[a])!=null&&!(2&s.__u)&&(s.__e==r&&(r=T(s)),oe(s,s));return r}function j(e,t,n,r){var i,a;if(typeof e.type==`function`){for(i=e.__k,a=0;i&&a<i.length;a++)i[a]&&(i[a].__=e,t=j(i[a],t,n,r));return t}e.__e!=t&&(r&&(t&&e.type&&!t.parentNode&&(t=T(e)),n.insertBefore(e.__e,t||null)),t=e.__e);do t&&=t.nextSibling;while(t!=null&&t.nodeType==8);return t}function M(e,t){return t||=[],e==null||typeof e==`boolean`||(v(e)?e.some(function(e){M(e,t)}):t.push(e)),t}function te(e,t,n,r){var i,a,o,s=e.key,c=e.type,l=t[n],u=l!=null&&(2&l.__u)==0;if(l===null&&s==null||u&&s==l.key&&c==l.type)return n;if(r>+!!u){for(i=n-1,a=n+1;i>=0||a<t.length;)if((l=t[o=i>=0?i--:a++])!=null&&!(2&l.__u)&&s==l.key&&c==l.type)return o}return-1}function ne(e,t,n){t[0]==`-`?e.setProperty(t,n??``):e[t]=n==null?``:typeof n!=`number`||_.test(t)?n:n+`px`}function N(e,t,n,r,i){var a,o;n:if(t==`style`)if(typeof n==`string`)e.style.cssText=n;else{if(typeof r==`string`&&(e.style.cssText=r=``),r)for(t in r)n&&t in n||ne(e.style,t,``);if(n)for(t in n)r&&n[t]==r[t]||ne(e.style,t,n[t])}else if(t[0]==`o`&&t[1]==`n`)a=t!=(t=t.replace(d,`$1`)),o=t.toLowerCase(),t=o in e||t==`onFocusOut`||t==`onFocusIn`?o.slice(2):t.slice(2),e.l||={},e.l[t+a]=n,n?r?n.u=r.u:(n.u=f,e.addEventListener(t,a?m:p,a)):e.removeEventListener(t,a?m:p,a);else{if(i==`http://www.w3.org/2000/svg`)t=t.replace(/xlink(H|:h)/,`h`).replace(/sName$/,`s`);else if(t!=`width`&&t!=`height`&&t!=`href`&&t!=`list`&&t!=`form`&&t!=`tabIndex`&&t!=`download`&&t!=`rowSpan`&&t!=`colSpan`&&t!=`role`&&t!=`popover`&&t in e)try{e[t]=n??``;break n}catch{}typeof n==`function`||(n==null||!1===n&&t[4]!=`-`?e.removeAttribute(t):e.setAttribute(t,t==`popover`&&n==1?``:n))}}function P(e){return function(t){if(this.l){var n=this.l[t.type+e];if(t.t==null)t.t=f++;else if(t.t<n.u)return;return n(a.event?a.event(t):t)}}}function F(e,t,n,r,i,o,s,c,l,u){var d,f,p,m,h,_,x,S,T,E,D,O,k,A,j,M=t.type;if(t.constructor!==void 0)return null;128&n.__u&&(l=!!(32&n.__u),o=[c=t.__e=n.__e]),(d=a.__b)&&d(t);n:if(typeof M==`function`)try{if(S=t.props,T=M.prototype&&M.prototype.render,E=(d=M.contextType)&&r[d.__c],D=d?E?E.props.value:d.__:r,n.__c?x=(f=t.__c=n.__c).__=f.__E:(T?t.__c=f=new M(S,D):(t.__c=f=new w(S,D),f.constructor=M,f.render=se),E&&E.sub(f),f.state||={},f.__n=r,p=f.__d=!0,f.__h=[],f._sb=[]),T&&f.__s==null&&(f.__s=f.state),T&&M.getDerivedStateFromProps!=null&&(f.__s==f.state&&(f.__s=y({},f.__s)),y(f.__s,M.getDerivedStateFromProps(S,f.__s))),m=f.props,h=f.state,f.__v=t,p)T&&M.getDerivedStateFromProps==null&&f.componentWillMount!=null&&f.componentWillMount(),T&&f.componentDidMount!=null&&f.__h.push(f.componentDidMount);else{if(T&&M.getDerivedStateFromProps==null&&S!==m&&f.componentWillReceiveProps!=null&&f.componentWillReceiveProps(S,D),t.__v==n.__v||!f.__e&&f.shouldComponentUpdate!=null&&!1===f.shouldComponentUpdate(S,f.__s,D)){t.__v!=n.__v&&(f.props=S,f.state=f.__s,f.__d=!1),t.__e=n.__e,t.__k=n.__k,t.__k.some(function(e){e&&(e.__=t)}),g.push.apply(f.__h,f._sb),f._sb=[],f.__h.length&&s.push(f);break n}f.componentWillUpdate!=null&&f.componentWillUpdate(S,f.__s,D),T&&f.componentDidUpdate!=null&&f.__h.push(function(){f.componentDidUpdate(m,h,_)})}if(f.context=D,f.props=S,f.__P=e,f.__e=!1,O=a.__r,k=0,T)f.state=f.__s,f.__d=!1,O&&O(t),d=f.render(f.props,f.state,f.context),g.push.apply(f.__h,f._sb),f._sb=[];else do f.__d=!1,O&&O(t),d=f.render(f.props,f.state,f.context),f.state=f.__s;while(f.__d&&++k<25);f.state=f.__s,f.getChildContext!=null&&(r=y(y({},r),f.getChildContext())),T&&!p&&f.getSnapshotBeforeUpdate!=null&&(_=f.getSnapshotBeforeUpdate(m,h)),A=d!=null&&d.type===C&&d.key==null?ie(d.props.children):d,c=ee(e,v(A)?A:[A],t,n,r,i,o,s,c,l,u),f.base=t.__e,t.__u&=-161,f.__h.length&&s.push(f),x&&(f.__E=f.__=null)}catch(e){if(t.__v=null,l||o!=null)if(e.then){for(t.__u|=l?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,t.__e=c}else{for(j=o.length;j--;)b(o[j]);I(t)}else t.__e=n.__e,t.__k=n.__k,e.then||I(t);a.__e(e,t,n)}else o==null&&t.__v==n.__v?(t.__k=n.__k,t.__e=n.__e):c=t.__e=ae(n.__e,t,n,r,i,o,s,l,u);return(d=a.diffed)&&d(t),128&t.__u?void 0:c}function I(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(I))}function re(e,t,n){for(var r=0;r<n.length;r++)L(n[r],n[++r],n[++r]);a.__c&&a.__c(t,e),e.some(function(t){try{e=t.__h,t.__h=[],e.some(function(e){e.call(t)})}catch(e){a.__e(e,t.__v)}})}function ie(e){return typeof e!=`object`||!e||e.__b>0?e:v(e)?e.map(ie):y({},e)}function ae(e,t,n,r,o,s,c,l,u){var d,f,p,m,g,_,y,x=n.props||h,S=t.props,C=t.type;if(C==`svg`?o=`http://www.w3.org/2000/svg`:C==`math`?o=`http://www.w3.org/1998/Math/MathML`:o||=`http://www.w3.org/1999/xhtml`,s!=null){for(d=0;d<s.length;d++)if((g=s[d])&&`setAttribute`in g==!!C&&(C?g.localName==C:g.nodeType==3)){e=g,s[d]=null;break}}if(e==null){if(C==null)return document.createTextNode(S);e=document.createElementNS(o,C,S.is&&S),l&&=(a.__m&&a.__m(t,s),!1),s=null}if(C==null)x===S||l&&e.data==S||(e.data=S);else{if(s&&=i.call(e.childNodes),!l&&s!=null)for(x={},d=0;d<e.attributes.length;d++)x[(g=e.attributes[d]).name]=g.value;for(d in x)g=x[d],d==`dangerouslySetInnerHTML`?p=g:d==`children`||d in S||d==`value`&&`defaultValue`in S||d==`checked`&&`defaultChecked`in S||N(e,d,null,g,o);for(d in S)g=S[d],d==`children`?m=g:d==`dangerouslySetInnerHTML`?f=g:d==`value`?_=g:d==`checked`?y=g:l&&typeof g!=`function`||x[d]===g||N(e,d,g,x[d],o);if(f)l||p&&(f.__html==p.__html||f.__html==e.innerHTML)||(e.innerHTML=f.__html),t.__k=[];else if(p&&(e.innerHTML=``),ee(t.type==`template`?e.content:e,v(m)?m:[m],t,n,r,C==`foreignObject`?`http://www.w3.org/1999/xhtml`:o,s,c,s?s[0]:n.__k&&T(n,0),l,u),s!=null)for(d=s.length;d--;)b(s[d]);l||(d=`value`,C==`progress`&&_==null?e.removeAttribute(`value`):_!=null&&(_!==e[d]||C==`progress`&&!_||C==`option`&&_!=x[d])&&N(e,d,_,x[d],o),d=`checked`,y!=null&&y!=e[d]&&N(e,d,y,x[d],o))}return e}function L(e,t,n){try{if(typeof e==`function`){var r=typeof e.__u==`function`;r&&e.__u(),r&&t==null||(e.__u=e(t))}else e.current=t}catch(e){a.__e(e,n)}}function oe(e,t,n){var r,i;if(a.unmount&&a.unmount(e),(r=e.ref)&&(r.current&&r.current!=e.__e||L(r,null,t)),(r=e.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(e){a.__e(e,t)}r.base=r.__P=null}if(r=e.__k)for(i=0;i<r.length;i++)r[i]&&oe(r[i],t,n||typeof e.type!=`function`);n||b(e.__e),e.__c=e.__=e.__e=void 0}function se(e,t,n){return this.constructor(e,n)}function R(e,t,n){var r,o,s,c;t==document&&(t=document.documentElement),a.__&&a.__(e,t),o=(r=typeof n==`function`)?null:n&&n.__k||t.__k,s=[],c=[],F(t,e=(!r&&n||t).__k=x(C,null,[e]),o||h,h,t.namespaceURI,!r&&n?[n]:o?null:t.firstChild?i.call(t.childNodes):null,s,!r&&n?n:o?o.__e:t.firstChild,r,c),re(s,e,c)}function ce(e,t){R(e,t,ce)}function z(e,t,n){var r,a,o,s,c=y({},e.props);for(o in e.type&&e.type.defaultProps&&(s=e.type.defaultProps),t)o==`key`?r=t[o]:o==`ref`?a=t[o]:c[o]=t[o]===void 0&&s!=null?s[o]:t[o];return arguments.length>2&&(c.children=arguments.length>3?i.call(arguments,2):n),S(e.type,c,r||e.key,a||e.ref,null)}i=g.slice,a={__e:function(e,t,n,r){for(var i,a,o;t=t.__;)if((i=t.__c)&&!i.__)try{if((a=i.constructor)&&a.getDerivedStateFromError!=null&&(i.setState(a.getDerivedStateFromError(e)),o=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(e,r||{}),o=i.__d),o)return i.__E=i}catch(t){e=t}throw e}},o=0,w.prototype.setState=function(e,t){var n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=y({},this.state);typeof e==`function`&&(e=e(y({},n),this.props)),e&&y(n,e),e!=null&&this.__v&&(t&&this._sb.push(t),O(this))},w.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),O(this))},w.prototype.render=C,s=[],l=typeof Promise==`function`?Promise.prototype.then.bind(Promise.resolve()):setTimeout,u=function(e,t){return e.__v.__b-t.__v.__b},k.__r=0,d=/(PointerCapture)$|Capture$/i,f=0,p=P(!1),m=P(!0);function B(){return B=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},B.apply(this,arguments)}function V(e,t){if(e==null)return{};var n,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)t.indexOf(n=a[r])>=0||(i[n]=e[n]);return i}var le=[`context`,`children`],ue=[`useFragment`];function de(e,t,n,r){function i(){var t,n=Reflect.construct(HTMLElement,[],i);return n._vdomComponent=e,r&&r.shadow?(n._root=n.attachShadow({mode:r.mode||`open`,serializable:(t=r.serializable)!=null&&t}),r.adoptedStyleSheets&&(n._root.adoptedStyleSheets=r.adoptedStyleSheets)):n._root=n,n}return(i.prototype=Object.create(HTMLElement.prototype)).constructor=i,i.prototype.connectedCallback=function(){pe.call(this,r)},i.prototype.attributeChangedCallback=me,i.prototype.disconnectedCallback=he,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),i.observedAttributes=n,e.formAssociated&&(i.formAssociated=!0),n.forEach(function(e){Object.defineProperty(i.prototype,e,{get:function(){return this._vdom?this._vdom.props[e]:this._props[e]},set:function(t){this._vdom?this.attributeChangedCallback(e,null,t):(this._props||={},this._props[e]=t);var n=typeof t;t!=null&&n!==`string`&&n!==`boolean`&&n!==`number`||this.setAttribute(e,t)}})}),customElements.define(t||e.tagName||e.displayName||e.name,i),i}function fe(e){this.getChildContext=function(){return e.context};var t=e.children;return z(t,V(e,le))}function pe(e){var t=new CustomEvent(`_preact`,{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(t),this._vdom=x(fe,B({},this._props,{context:t.detail.context}),_e(this,this._vdomComponent,e)),(this.hasAttribute(`hydrate`)?ce:R)(this._vdom,this._root)}function H(e){return e.replace(/-(\w)/g,function(e,t){return t?t.toUpperCase():``})}function me(e,t,n){if(this._vdom){var r={};r[e]=n??=void 0,r[H(e)]=n,this._vdom=z(this._vdom,r),R(this._vdom,this._root)}}function he(){R(this._vdom=null,this._root)}function ge(e,t){var n=this,r=e.useFragment,i=V(e,ue);return x(r?C:`slot`,B({},i,{ref:function(e){e?(n.ref=e,n._listener||(n._listener=function(e){e.stopPropagation(),e.detail.context=t},e.addEventListener(`_preact`,n._listener))):n.ref.removeEventListener(`_preact`,n._listener)}}))}function _e(e,t,n){if(e.nodeType===3)return e.data;if(e.nodeType!==1)return null;var r=[],i={},a=0,o=e.attributes,s=e.childNodes;for(a=o.length;a--;)o[a].name!==`slot`&&(i[o[a].name]=o[a].value,i[H(o[a].name)]=o[a].value);for(a=s.length;a--;){var c=_e(s[a],null,n),l=s[a].slot;l?i[l]=x(ge,{name:l},c):r[a]=c}var u=!(!n||!n.shadow),d=t?x(ge,{useFragment:!u},r):r;return!u&&t&&(e.innerHTML=``),x(t||e.nodeName.toLowerCase(),i,d)}function ve(t,r,i=[],a={shadow:!0}){typeof window<`u`&&(e(n),customElements.get(r)||de(t,r,i,a))}var ye=0;Array.isArray;function be(e,t,n,r,i,o){t||={};var s,c,l=t;if(`ref`in l)for(c in l={},t)c==`ref`?s=t[c]:l[c]=t[c];var u={type:e,props:l,key:n,ref:s,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--ye,__i:-1,__u:0,__source:i,__self:o};if(typeof e==`function`&&(s=e.defaultProps))for(c in s)l[c]===void 0&&(l[c]=s[c]);return a.vnode&&a.vnode(u),u}var U,W,G,xe,K=0,Se=[],q=a,Ce=q.__b,we=q.__r,Te=q.diffed,Ee=q.__c,De=q.unmount,Oe=q.__;function J(e,t){q.__h&&q.__h(W,e,K||t),K=0;var n=W.__H||={__:[],__h:[]};return e>=n.__.length&&n.__.push({}),n.__[e]}function Y(e){return K=1,ke(Ie,e)}function ke(e,t,n){var r=J(U++,2);if(r.t=e,!r.__c&&(r.__=[n?n(t):Ie(void 0,t),function(e){var t=r.__N?r.__N[0]:r.__[0],n=r.t(t,e);t!==n&&(r.__N=[n,r.__[1]],r.__c.setState({}))}],r.__c=W,!W.__f)){var i=function(e,t,n){if(!r.__c.__H)return!0;var i=r.__c.__H.__.filter(function(e){return e.__c});if(i.every(function(e){return!e.__N}))return!a||a.call(this,e,t,n);var o=r.__c.props!==e;return i.some(function(e){if(e.__N){var t=e.__[0];e.__=e.__N,e.__N=void 0,t!==e.__[0]&&(o=!0)}}),a&&a.call(this,e,t,n)||o};W.__f=!0;var a=W.shouldComponentUpdate,o=W.componentWillUpdate;W.componentWillUpdate=function(e,t,n){if(this.__e){var r=a;a=void 0,i(e,t,n),a=r}o&&o.call(this,e,t,n)},W.shouldComponentUpdate=i}return r.__N||r.__}function X(e,t){var n=J(U++,3);!q.__s&&Fe(n.__H,t)&&(n.__=e,n.u=t,W.__H.__h.push(n))}function Ae(e){return K=5,Z(function(){return{current:e}},[])}function Z(e,t){var n=J(U++,7);return Fe(n.__H,t)&&(n.__=e(),n.__H=t,n.__h=e),n.__}function je(e,t){return K=8,Z(function(){return e},t)}function Me(){for(var e;e=Se.shift();){var t=e.__H;if(e.__P&&t)try{t.__h.some(Q),t.__h.some($),t.__h=[]}catch(n){t.__h=[],q.__e(n,e.__v)}}}q.__b=function(e){W=null,Ce&&Ce(e)},q.__=function(e,t){e&&t.__k&&t.__k.__m&&(e.__m=t.__k.__m),Oe&&Oe(e,t)},q.__r=function(e){we&&we(e),U=0;var t=(W=e.__c).__H;t&&(G===W?(t.__h=[],W.__h=[],t.__.some(function(e){e.__N&&(e.__=e.__N),e.u=e.__N=void 0})):(t.__h.some(Q),t.__h.some($),t.__h=[],U=0)),G=W},q.diffed=function(e){Te&&Te(e);var t=e.__c;t&&t.__H&&(t.__H.__h.length&&(Se.push(t)!==1&&xe===q.requestAnimationFrame||((xe=q.requestAnimationFrame)||Pe)(Me)),t.__H.__.some(function(e){e.u&&(e.__H=e.u),e.u=void 0})),G=W=null},q.__c=function(e,t){t.some(function(e){try{e.__h.some(Q),e.__h=e.__h.filter(function(e){return!e.__||$(e)})}catch(n){t.some(function(e){e.__h&&=[]}),t=[],q.__e(n,e.__v)}}),Ee&&Ee(e,t)},q.unmount=function(e){De&&De(e);var t,n=e.__c;n&&n.__H&&(n.__H.__.some(function(e){try{Q(e)}catch(e){t=e}}),n.__H=void 0,t&&q.__e(t,n.__v))};var Ne=typeof requestAnimationFrame==`function`;function Pe(e){var t,n=function(){clearTimeout(r),Ne&&cancelAnimationFrame(t),setTimeout(e)},r=setTimeout(n,35);Ne&&(t=requestAnimationFrame(n))}function Q(e){var t=W,n=e.__c;typeof n==`function`&&(e.__c=void 0,n()),W=t}function $(e){var t=W;e.__c=e.__(),W=t}function Fe(e,t){return!e||e.length!==t.length||t.some(function(t,n){return t!==e[n]})}function Ie(e,t){return typeof t==`function`?t(e):t}function Le(){let[e,n]=Y(()=>window.FrakSetup?.config?.waitForBackendConfig===!1?!0:r.isResolved),[i,a]=Y(()=>r.getConfig().hidden??!1),[o,s]=Y(()=>!!window.FrakSetup?.client);return X(()=>{let e=r.getConfig();e.isResolved&&(n(!0),a(e.hidden??!1)),window.FrakSetup?.client&&s(!0);let i=e=>{let t=e.detail;t.isResolved&&n(!0),a(t.hidden??!1)};window.addEventListener(`frak:config`,i);let o=()=>s(!0);return t(`add`,o),()=>{window.removeEventListener(`frak:config`,i),t(`remove`,o)}},[]),{shouldRender:e,isHidden:i,isClientReady:o}}const Re=`
|
|
2
|
-
:host {
|
|
3
|
-
display: contents;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
:host([hidden]) {
|
|
7
|
-
display: none;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.button:disabled {
|
|
11
|
-
opacity: 0.7;
|
|
12
|
-
cursor: default;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.button__fadeIn {
|
|
16
|
-
animation: frak-fadeIn 300ms ease-in;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
@keyframes frak-fadeIn {
|
|
20
|
-
from {
|
|
21
|
-
opacity: 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
to {
|
|
25
|
-
opacity: 1;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
`;function ze(e,t){return t?`${Re}\n${e}\n${t}`:`${Re}\n${e}`}const Be=`
|
|
29
|
-
:where(frak-button-share, frak-open-in-app) {
|
|
30
|
-
display: contents;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
:where(frak-button-share .button, frak-open-in-app .button) {
|
|
34
|
-
display: flex;
|
|
35
|
-
align-items: center;
|
|
36
|
-
justify-content: center;
|
|
37
|
-
gap: 10px;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
:where(frak-button-share .button:disabled, frak-open-in-app .button:disabled) {
|
|
41
|
-
opacity: 0.7;
|
|
42
|
-
cursor: default;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
:where(frak-button-share .button__fadeIn, frak-open-in-app .button__fadeIn) {
|
|
46
|
-
animation: frak-fadeIn 300ms ease-in;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@keyframes frak-fadeIn {
|
|
50
|
-
from {
|
|
51
|
-
opacity: 0;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
to {
|
|
55
|
-
opacity: 1;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
`;function Ve(e){return r.getConfig().placements?.[e]}function He(e){let[t,n]=Y(0);return X(()=>{let e=e=>{n(e=>e+1)};return window.addEventListener(`frak:config`,e),n(e=>e+1),()=>window.removeEventListener(`frak:config`,e)},[]),Z(()=>e?Ve(e):void 0,[e,t])}export{Ae as a,je as c,ve as d,M as f,w as g,a as h,Le as i,X as l,C as m,ze as n,Z as o,x as p,Be as r,Y as s,He as t,be as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{h as e,l as t,p as n}from"./loader.js";import{l as r,s as i}from"./usePlacement.BgMXY5CX.js";import{n as a}from"./formatReward.B1ZyoceC.js";function o(e,t){switch(e.payoutType){case`fixed`:return e.amount[t];case`tiered`:return e.tiers.reduce((e,n)=>Math.max(e,n.amount[t]),0);case`percentage`:return 0}}function s({rewards:t},r,i){let s=(i?t.filter(e=>e.interactionTypeKey===i):t).map(e=>e.referrer).filter(e=>e!==void 0);if(s.length===0)return;let c=n(e(r)),l=s[0],u=o(l,c);for(let e=1;e<s.length;e++){let t=o(s[e],c);t>u&&(l=s[e],u=t)}if(u<=0){let e=s.find(e=>e.payoutType===`percentage`);if(!e)return;l=e}return a(l,r)}function c(e,n){let[a,o]=i(void 0);return r(()=>{if(!e)return;let r=window.FrakSetup?.client;r&&t(r).then(e=>{let t=r.config.metadata?.currency,i=s(e,t,n);i&&o(i)}).catch(()=>{})},[e,n]),{reward:a}}export{c as t};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { displaySharingPage } from "@frak-labs/core-sdk/actions";
|
|
2
|
-
//#region src/actions/sharingPage.ts
|
|
3
|
-
async function openSharingPage(targetInteraction, placement, options) {
|
|
4
|
-
if (!window.FrakSetup?.client) {
|
|
5
|
-
console.error("Frak client not found");
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
await displaySharingPage(window.FrakSetup.client, {
|
|
9
|
-
...options?.link && { link: options.link },
|
|
10
|
-
...options?.products?.length && { products: options.products },
|
|
11
|
-
...targetInteraction && { metadata: { targetInteraction } }
|
|
12
|
-
}, placement);
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
export { openSharingPage as t };
|
|
@@ -1,253 +0,0 @@
|
|
|
1
|
-
import register from "preact-custom-element";
|
|
2
|
-
import * as coreSdkIndex from "@frak-labs/core-sdk";
|
|
3
|
-
import { sdkConfigStore, setupClient, trackEvent, withCache } from "@frak-labs/core-sdk";
|
|
4
|
-
import * as coreSdkActions from "@frak-labs/core-sdk/actions";
|
|
5
|
-
import { displayEmbeddedWallet } from "@frak-labs/core-sdk/actions";
|
|
6
|
-
import { useEffect, useMemo, useState } from "preact/hooks";
|
|
7
|
-
//#region src/actions/embeddedWallet.ts
|
|
8
|
-
async function openEmbeddedWallet(targetInteraction, placement) {
|
|
9
|
-
if (!window.FrakSetup?.client) {
|
|
10
|
-
console.error("Frak client not found");
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const modalWalletConfig = window.FrakSetup?.modalWalletConfig ?? {};
|
|
14
|
-
await displayEmbeddedWallet(window.FrakSetup.client, targetInteraction ? {
|
|
15
|
-
...modalWalletConfig,
|
|
16
|
-
metadata: {
|
|
17
|
-
...modalWalletConfig.metadata,
|
|
18
|
-
targetInteraction
|
|
19
|
-
}
|
|
20
|
-
} : modalWalletConfig, placement);
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/utils/browser/safeVibrate.ts
|
|
24
|
-
/**
|
|
25
|
-
* Attempt to vibrate the device
|
|
26
|
-
*/
|
|
27
|
-
function safeVibrate() {
|
|
28
|
-
if ("vibrate" in navigator) navigator.vibrate(10);
|
|
29
|
-
else console.log("Vibration not supported");
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/components/ButtonWallet/utils.ts
|
|
33
|
-
function openWalletModal(targetInteraction, placement) {
|
|
34
|
-
safeVibrate();
|
|
35
|
-
openEmbeddedWallet(targetInteraction, placement);
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/bootstrap/clientReady.ts
|
|
39
|
-
const CUSTOM_EVENT_NAME = "frak:client";
|
|
40
|
-
/**
|
|
41
|
-
* Dispatch a custom event when the Frak client is ready
|
|
42
|
-
*/
|
|
43
|
-
function dispatchClientReadyEvent() {
|
|
44
|
-
const event = new CustomEvent(CUSTOM_EVENT_NAME);
|
|
45
|
-
window.dispatchEvent(event);
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Add or remove an event listener for when the Frak client is ready
|
|
49
|
-
* @param action
|
|
50
|
-
* @param callback
|
|
51
|
-
*/
|
|
52
|
-
function onClientReady(action, callback) {
|
|
53
|
-
if (window.FrakSetup?.client && action === "add") {
|
|
54
|
-
callback();
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
(action === "add" ? window.addEventListener : window.removeEventListener)(CUSTOM_EVENT_NAME, callback, false);
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/bootstrap/initFrakSdk.ts
|
|
61
|
-
/**
|
|
62
|
-
* Initializes the Frak SDK client and sets up necessary configurations.
|
|
63
|
-
* Uses withCache for inflight dedup — concurrent callers share the same promise.
|
|
64
|
-
* Failures are not cached, allowing retry on next call.
|
|
65
|
-
*
|
|
66
|
-
* @returns {Promise<void>}
|
|
67
|
-
*/
|
|
68
|
-
function initFrakSdk() {
|
|
69
|
-
window.FrakSetup.core = {
|
|
70
|
-
...coreSdkIndex,
|
|
71
|
-
...coreSdkActions
|
|
72
|
-
};
|
|
73
|
-
if (window.FrakSetup?.client) return Promise.resolve();
|
|
74
|
-
return withCache(() => doInit(), {
|
|
75
|
-
cacheKey: "frak-sdk-init",
|
|
76
|
-
cacheTime: Number.POSITIVE_INFINITY
|
|
77
|
-
}).catch((err) => {
|
|
78
|
-
trackEvent(window.FrakSetup?.client, "sdk_init_failed", {
|
|
79
|
-
reason: err instanceof Error ? err.message : typeof err === "string" ? err : "unknown",
|
|
80
|
-
config_missing: !window.FrakSetup?.config
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Performs the actual SDK initialization.
|
|
86
|
-
* Throws on failure so withCache doesn't cache failed attempts.
|
|
87
|
-
*/
|
|
88
|
-
async function doInit() {
|
|
89
|
-
if (!window.FrakSetup?.config) throw new Error("[Frak SDK] Configuration not found. Please ensure window.FrakSetup.config is set.");
|
|
90
|
-
console.log("[Frak SDK] Starting initialization");
|
|
91
|
-
const client = await setupClient({ config: window.FrakSetup.config });
|
|
92
|
-
if (!client) throw new Error("[Frak SDK] Failed to create client");
|
|
93
|
-
window.FrakSetup.client = client;
|
|
94
|
-
console.log("[Frak SDK] Client initialized successfully");
|
|
95
|
-
dispatchClientReadyEvent();
|
|
96
|
-
coreSdkActions.setupReferral(client);
|
|
97
|
-
handleActionQueryParam();
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Check the query param contain params for an auto opening of the frak modal
|
|
101
|
-
*/
|
|
102
|
-
function handleActionQueryParam() {
|
|
103
|
-
const frakAction = new URLSearchParams(window.location.search).get("frakAction");
|
|
104
|
-
if (!frakAction) return;
|
|
105
|
-
if (frakAction === "share") {
|
|
106
|
-
console.log("[Frak SDK] Auto open query param found");
|
|
107
|
-
openWalletModal();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/utils/browser/onDocumentReady.ts
|
|
112
|
-
/**
|
|
113
|
-
* When the document is ready, run the callback
|
|
114
|
-
* @param callback
|
|
115
|
-
*/
|
|
116
|
-
function onDocumentReady(callback) {
|
|
117
|
-
if (document.readyState === "complete" || document.readyState === "interactive") setTimeout(callback, 1);
|
|
118
|
-
else document.addEventListener("DOMContentLoaded", callback);
|
|
119
|
-
}
|
|
120
|
-
//#endregion
|
|
121
|
-
//#region src/webcomponent/registerWebComponent.ts
|
|
122
|
-
/**
|
|
123
|
-
* Registers a Preact component as a custom web component
|
|
124
|
-
*
|
|
125
|
-
* @param component - The Preact component to register
|
|
126
|
-
* @param tagName - The custom element tag name (e.g., "frak-button-wallet")
|
|
127
|
-
* @param observedAttributes - Array of attribute names to observe for changes
|
|
128
|
-
* @param options - Registration options (e.g., { shadow: true })
|
|
129
|
-
*/
|
|
130
|
-
function registerWebComponent(component, tagName, observedAttributes = [], options = { shadow: true }) {
|
|
131
|
-
if (typeof window !== "undefined") {
|
|
132
|
-
onDocumentReady(initFrakSdk);
|
|
133
|
-
if (!customElements.get(tagName)) register(component, tagName, observedAttributes, options);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
//#endregion
|
|
137
|
-
//#region src/hooks/useClientReady.ts
|
|
138
|
-
function useClientReady() {
|
|
139
|
-
const [shouldRender, setShouldRender] = useState(() => {
|
|
140
|
-
if (!(window.FrakSetup?.config?.waitForBackendConfig !== false)) return true;
|
|
141
|
-
return sdkConfigStore.isResolved;
|
|
142
|
-
});
|
|
143
|
-
const [isHidden, setIsHidden] = useState(() => sdkConfigStore.getConfig().hidden ?? false);
|
|
144
|
-
const [isClientReady, setIsClientReady] = useState(() => !!window.FrakSetup?.client);
|
|
145
|
-
useEffect(() => {
|
|
146
|
-
const currentConfig = sdkConfigStore.getConfig();
|
|
147
|
-
if (currentConfig.isResolved) {
|
|
148
|
-
setShouldRender(true);
|
|
149
|
-
setIsHidden(currentConfig.hidden ?? false);
|
|
150
|
-
}
|
|
151
|
-
if (window.FrakSetup?.client) setIsClientReady(true);
|
|
152
|
-
const onConfig = (e) => {
|
|
153
|
-
const config = e.detail;
|
|
154
|
-
if (config.isResolved) setShouldRender(true);
|
|
155
|
-
setIsHidden(config.hidden ?? false);
|
|
156
|
-
};
|
|
157
|
-
window.addEventListener("frak:config", onConfig);
|
|
158
|
-
const handleReady = () => setIsClientReady(true);
|
|
159
|
-
onClientReady("add", handleReady);
|
|
160
|
-
return () => {
|
|
161
|
-
window.removeEventListener("frak:config", onConfig);
|
|
162
|
-
onClientReady("remove", handleReady);
|
|
163
|
-
};
|
|
164
|
-
}, []);
|
|
165
|
-
return {
|
|
166
|
-
shouldRender,
|
|
167
|
-
isHidden,
|
|
168
|
-
isClientReady
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
//#endregion
|
|
172
|
-
//#region src/styles/sharedCss.ts
|
|
173
|
-
const sharedCss = `
|
|
174
|
-
:host {
|
|
175
|
-
display: contents;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
:host([hidden]) {
|
|
179
|
-
display: none;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.button:disabled {
|
|
183
|
-
opacity: 0.7;
|
|
184
|
-
cursor: default;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
.button__fadeIn {
|
|
188
|
-
animation: frak-fadeIn 300ms ease-in;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
@keyframes frak-fadeIn {
|
|
192
|
-
from {
|
|
193
|
-
opacity: 0;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
to {
|
|
197
|
-
opacity: 1;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
`;
|
|
201
|
-
function buildStyleContent(componentCss, placementCss) {
|
|
202
|
-
return placementCss ? `${sharedCss}\n${componentCss}\n${placementCss}` : `${sharedCss}\n${componentCss}`;
|
|
203
|
-
}
|
|
204
|
-
const lightDomBaseCss = `
|
|
205
|
-
:where(frak-button-share, frak-open-in-app) {
|
|
206
|
-
display: contents;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
:where(frak-button-share .button, frak-open-in-app .button) {
|
|
210
|
-
display: flex;
|
|
211
|
-
align-items: center;
|
|
212
|
-
justify-content: center;
|
|
213
|
-
gap: 10px;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
:where(frak-button-share .button:disabled, frak-open-in-app .button:disabled) {
|
|
217
|
-
opacity: 0.7;
|
|
218
|
-
cursor: default;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
:where(frak-button-share .button__fadeIn, frak-open-in-app .button__fadeIn) {
|
|
222
|
-
animation: frak-fadeIn 300ms ease-in;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
@keyframes frak-fadeIn {
|
|
226
|
-
from {
|
|
227
|
-
opacity: 0;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
to {
|
|
231
|
-
opacity: 1;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
`;
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/hooks/usePlacement.ts
|
|
237
|
-
function getPlacement(id) {
|
|
238
|
-
return sdkConfigStore.getConfig().placements?.[id];
|
|
239
|
-
}
|
|
240
|
-
function usePlacement(placementId) {
|
|
241
|
-
const [configVersion, setConfigVersion] = useState(0);
|
|
242
|
-
useEffect(() => {
|
|
243
|
-
const onConfig = (_e) => {
|
|
244
|
-
setConfigVersion((v) => v + 1);
|
|
245
|
-
};
|
|
246
|
-
window.addEventListener("frak:config", onConfig);
|
|
247
|
-
setConfigVersion((v) => v + 1);
|
|
248
|
-
return () => window.removeEventListener("frak:config", onConfig);
|
|
249
|
-
}, []);
|
|
250
|
-
return useMemo(() => placementId ? getPlacement(placementId) : void 0, [placementId, configVersion]);
|
|
251
|
-
}
|
|
252
|
-
//#endregion
|
|
253
|
-
export { registerWebComponent as a, useClientReady as i, buildStyleContent as n, openWalletModal as o, lightDomBaseCss as r, openEmbeddedWallet as s, usePlacement as t };
|