zh-web-sdk 2.1.2 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
- package/src/iframe-container/AppContainer.tsx +3 -1
- package/src/styles.ts +5 -4
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ Error generating stack: `+i.message+`
|
|
|
9
9
|
The error may be correlated with this previous error:
|
|
10
10
|
${Bi.current.stack}
|
|
11
11
|
|
|
12
|
-
`),Be}Dn(()=>{Bi.current=void 0,jn.current=void 0,Ui.current=Wr});let Qi=(0,D.useMemo)(()=>D.default.createElement(O,at({},Wr,{ref:H})),[H,O,Wr]);return(0,D.useMemo)(()=>w?D.default.createElement(pe.Provider,{value:Fs},Qi):Qi,[pe,Qi,Fs])}let k=D.default.memo(y);if(k.WrappedComponent=O,k.displayName=y.displayName=a,s){let C=D.default.forwardRef(function(P,pe){return D.default.createElement(k,at({},P,{reactReduxForwardedRef:pe}))});return C.displayName=a,C.WrappedComponent=O,(0,As.default)(C,O)}return(0,As.default)(k,O)}}var Is=xv;var Dr=b(Oe());function _v({store:e,context:t,children:n,serverState:r,stabilityCheck:o="once",noopCheck:i="once"}){let l=(0,Dr.useMemo)(()=>{let c=Di(e);return{store:e,subscription:c,getServerState:r?()=>r:void 0,stabilityCheck:o,noopCheck:i}},[e,r,o,i]),u=(0,Dr.useMemo)(()=>e.getState(),[e]);Dn(()=>{let{subscription:c}=l;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),u!==e.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[l,u]);let s=t||st;return Dr.default.createElement(s.Provider,{value:l},n)}var Mi=_v;Gd(wp.useSyncExternalStoreWithSelector);gp(Sp.useSyncExternalStore);Bd(Ss.unstable_batchedUpdates);var Ov=540,Lr=[{id:"MTE_SM",size:Ov}],Ep=()=>{for(let e=0;e<Lr.length;e++){let{id:t,size:n}=Lr[e];if(window.matchMedia(`(min-width: ${n}px`).matches)return t}return"ANY"},Rs={paddingRight:0,paddingLeft:0,marginRight:"auto",marginLeft:"auto",maxHeight:882},xp={MTE_SM:{width:540},ANY:{width:"100%",height:"100%",maxWidth:"100%",borderRadius:0,maxHeight:"100%"}},_p={position:"absolute",zIndex:999999,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",width:"100vw",height:"
|
|
12
|
+
`),Be}Dn(()=>{Bi.current=void 0,jn.current=void 0,Ui.current=Wr});let Qi=(0,D.useMemo)(()=>D.default.createElement(O,at({},Wr,{ref:H})),[H,O,Wr]);return(0,D.useMemo)(()=>w?D.default.createElement(pe.Provider,{value:Fs},Qi):Qi,[pe,Qi,Fs])}let k=D.default.memo(y);if(k.WrappedComponent=O,k.displayName=y.displayName=a,s){let C=D.default.forwardRef(function(P,pe){return D.default.createElement(k,at({},P,{reactReduxForwardedRef:pe}))});return C.displayName=a,C.WrappedComponent=O,(0,As.default)(C,O)}return(0,As.default)(k,O)}}var Is=xv;var Dr=b(Oe());function _v({store:e,context:t,children:n,serverState:r,stabilityCheck:o="once",noopCheck:i="once"}){let l=(0,Dr.useMemo)(()=>{let c=Di(e);return{store:e,subscription:c,getServerState:r?()=>r:void 0,stabilityCheck:o,noopCheck:i}},[e,r,o,i]),u=(0,Dr.useMemo)(()=>e.getState(),[e]);Dn(()=>{let{subscription:c}=l;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),u!==e.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[l,u]);let s=t||st;return Dr.default.createElement(s.Provider,{value:l},n)}var Mi=_v;Gd(wp.useSyncExternalStoreWithSelector);gp(Sp.useSyncExternalStore);Bd(Ss.unstable_batchedUpdates);var Ov=540,Lr=[{id:"MTE_SM",size:Ov}],Ep=()=>{for(let e=0;e<Lr.length;e++){let{id:t,size:n}=Lr[e];if(window.matchMedia(`(min-width: ${n}px`).matches)return t}return"ANY"},Rs={paddingRight:0,paddingLeft:0,marginRight:"auto",marginLeft:"auto",maxHeight:882},xp={MTE_SM:{width:540},ANY:{width:"100%",height:"100%",maxWidth:"100%",borderRadius:0,maxHeight:"100%"}},_p={position:"absolute",zIndex:999999,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",width:"100vw",height:CSS.supports("height: 100dvh")?"100dvh":window.innerHeight+"px",maxHeight:window.innerHeight+"px",background:"rgba(0,0,0,0.5)",cursor:"pointer"},kp={display:"none",width:0,height:0},Cp={padding:0,borderRadius:5,backgroundColor:"#FFF",height:"calc(100% - 100px)",maxWidth:"calc(100% - 30px)"},Op={width:"100%",height:"100%",border:"none",overflow:"hidden"},Pp={width:"100%",height:"100%",border:"none",margin:0,padding:0,overflow:"hidden",borderRadius:"0 0 15px 15px"};var Pv=Z.get("onboarding"),Nv=Z.get("crypto-withdrawals"),Tv=Z.get("ach-deposits"),Ds="SEND_JWT_TOKEN",Np=Pv+Ds,Tp=Nv+Ds,Ap=Tv+Ds;var Ls=e=>{An(e,ut,{isAppActive:!0})},Lt=e=>{An(e,ut,{isAppActive:!1})},zi=e=>{An(e,Dt,{isAppLoaded:!0})};var zr=b(Mr()),zv=Date.now(),jv={onboarding:"Onboarding","crypto-withdrawals":"Crypto Withdrawals","ach-deposits":"ACH Deposits"},Wv=({isAppActive:e,isAppLoaded:t,jwt:n,zeroHashAppURL:r,appIdentifier:o})=>{let i=jv[o],l=!!n,[u,s]=(0,qt.useState)(Rs),c=()=>{let m=Ep(),v=xp[m];s({...Rs,...v})},p=(0,qt.useRef)(null);(0,qt.useEffect)(()=>{if(r&&t&&l&&p.current?.contentWindow)switch(o){case"crypto-withdrawals":p.current.contentWindow.postMessage({type:Tp,cryptoWithdrawalsJWT:n},r);break;case"onboarding":p.current.contentWindow.postMessage({type:Np,userOnboardingJWT:n},r);break;case"ach-deposits":p.current.contentWindow.postMessage({type:Ap,achDepositsJWT:n},r);break;default:break}},[o,l,t,n,r]),(0,qt.useEffect)(()=>{if(c(),window)return Lr.forEach(({size:m})=>{window.matchMedia(`(min-width: ${m}px)`).addEventListener("change",c)}),()=>Lr.forEach(({size:m})=>{window.matchMedia(`(min-width: ${m}px)`).removeEventListener("change",c)})},[]);let h=new URL(r);return h.searchParams.set("name",zv.toString()),window&&h.searchParams.set("origin",window.location.origin),(0,zr.jsx)("div",{style:e?{..._p}:kp,onClick:()=>Lt(o),children:(0,zr.jsx)("div",{style:{...Cp,...u},children:(0,zr.jsx)("div",{style:{...Op},children:(0,zr.jsx)("iframe",{ref:p,title:i,src:h.toString(),allow:"camera *; fullscreen *; accelerometer *; gyroscope *; magnetometer *;",sandbox:"allow-downloads allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-top-navigation",style:Pp})})})})},Fv=(e,t)=>({isAppActive:e[t.appIdentifier].isAppActive,isAppLoaded:e[t.appIdentifier].isAppLoaded,jwt:e[t.appIdentifier].jwt}),Ms=Is(Fv)(Wv);var jr=b(Mr()),Wi=ps,Mp="",Lp={ONBOARDING_APP_LOADED:()=>{zi("onboarding")},ONBOARDING_CLOSE_BUTTON_CLICKED:()=>{Lt("onboarding")},CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED:()=>{Lt("crypto-withdrawals")},CRYPTO_WITHDRAWALS_APP_LOADED:()=>{zi("crypto-withdrawals")},ACH_DEPOSITS_CLOSE_BUTTON_CLICKED:()=>{Lt("ach-deposits")},ACH_DEPOSITS_APP_LOADED:()=>{zi("ach-deposits")}},$v=e=>{if(e.origin===Mp){let t=e.data;if(t&&t.type&&Lp[t.type])try{Lp[t.type](t.payload)}catch(n){console.error(n)}}},Fi=class{rootQuerySelector="";onboardingInitialized=!1;initializedApps=new Map([["crypto-withdrawals",!1],["onboarding",!1],["ach-deposits",!1]]);constructor({zeroHashOnboardingURL:t=ps,rootQuerySelector:n,userOnboardingJWT:r,cryptoWithdrawalsJWT:o,achDepositsJWT:i,zeroHashAppsURL:l}){Wi=l||t,Mp=new URL(Wi).origin,n&&(this.rootQuerySelector=n),window.addEventListener("message",$v,!1),r&&this.setJWT({jwt:r,appIdentifier:"onboarding"}),o&&this.setJWT({jwt:o,appIdentifier:"crypto-withdrawals"}),i&&this.setJWT({jwt:i,appIdentifier:"ach-deposits"})}setJWT({jwt:t,appIdentifier:n}){An(n,Rt,{jwt:t})}setUserOnboardingJWT(t){this.setJWT({jwt:t.userOnboardingJWT,appIdentifier:"onboarding"})}isOnboardingModalOpen(){return Zt.getState().onboarding.isAppActive}isModalOpen(t){return Zt.getState()[t].isAppActive}closeModal(t){Lt(t)}openModal({jwt:t,appIdentifier:n}){if(t&&this.setJWT({jwt:t,appIdentifier:n}),Ls(n),this.initializedApps.get(n))return;let r=null;if(this.rootQuerySelector&&(r=document.querySelector(this.rootQuerySelector)),!this.initializedApps.get(n)){r=document.createElement("div");let o=ys(n);r.id=o,r.style.position="absolute",r.style.top="0",r.style.left="0",this.rootQuerySelector=`#${o}`,document.querySelector("body").appendChild(r)}if(r){let o=r.attachShadow({mode:"closed"});zs.default.createRoot(o).render((0,jr.jsx)(Mi,{store:Zt,children:(0,jr.jsx)(Ms,{appIdentifier:n,zeroHashAppURL:`${Wi}/${n}`})})),this.initializedApps.set(n,!0)}else{let o="failed to append ZeroHash root to the page: root not found";throw console.error(o),new Error(o)}}openOnboardingModal(t){if(t.userOnboardingJWT&&this.setUserOnboardingJWT({userOnboardingJWT:t.userOnboardingJWT}),Ls("onboarding"),this.onboardingInitialized)return;let n=null;if(this.rootQuerySelector&&(n=document.querySelector(this.rootQuerySelector)),!n){n=document.createElement("div");let r=ys();n.id=r,n.style.position="absolute",n.style.top="0",n.style.left="0",this.rootQuerySelector=`#${r}`,document.querySelector("body").appendChild(n)}if(n){let r=n.attachShadow({mode:"closed"});zs.default.createRoot(r).render((0,jr.jsx)(Mi,{store:Zt,children:(0,jr.jsx)(Ms,{appIdentifier:"onboarding",zeroHashAppURL:Wi})})),this.onboardingInitialized=!0}else{let r="failed to append ZeroHash root to the page: root not found";throw console.error(r),new Error(r)}}closeOnboardingModal(){Lt("onboarding")}};window&&(window.zerohash=Fi);var dS=Fi;export{Xt as AppIdentifier,kd as IncomingMessageType,Fi as ZeroHashSDK,Z as appIdentifierToActionPrefixMap,dS as default};
|
|
13
13
|
/*! Bundled license information:
|
|
14
14
|
|
|
15
15
|
react/cjs/react.production.min.js:
|