@wellesley/host-remote 1.0.184 → 1.0.185
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/index.mjs +10 -1
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import{logErrorToSentry as rt}from"https://cdn.jsdelivr.net/npm/@wellesley/sentry@next";import{subscribeAfter as V}from"https://cdn.jsdelivr.net/npm/@wellesley/redux-subscribe-action@next";import{useRef as g,useCallback as w,useEffect as p,memo as $,useState as q}from"https://cdn.jsdelivr.net/npm/react@18.2.0/+esm";import{getStore as h,createStore as at}from"https://cdn.jsdelivr.net/npm/@wellesley/store@next";import{api as ct,handleBasicResponse as i}from"https://cdn.jsdelivr.net/npm/@wellesley/openapi@next";import{createSlice as it,createAction as H}from"https://cdn.jsdelivr.net/npm/@reduxjs/toolkit@2.2.1/+esm";import{toast as B}from"https://cdn.jsdelivr.net/npm/react-toastify@10.0.5/+esm";import{getErrorMsg as lt}from"https://cdn.jsdelivr.net/npm/@wellesley/error-kit@next";import{useDispatch as b,useSelector as u}from"https://cdn.jsdelivr.net/npm/react-redux@9.1.0/+esm";import{routerSlice as d}from"https://cdn.jsdelivr.net/npm/@wellesley/router@next";import{useLocation as W,useBlocker as ut,useNavigate as j}from"https://cdn.jsdelivr.net/npm/react-router-dom@6.22.2/+esm";import{handleLogin as dt,handleLogout as pt}from"https://cdn.jsdelivr.net/npm/@wellesley/auth@next";const gt=()=>"object"!=typeof window,Q=["debug","info","warn","error"],ht=(e,t)=>{const s=Q.indexOf(e);return Q.indexOf(t)>=s},y=(e,t,s,...r)=>{ht(t,e)&&console.log(`[${e}] ${s}`,...r)},ft=()=>null==window?void 0:window.localStorage.getItem("logger_lvl"),yt=(e=!gt()&&ft()||"warn")=>{let t=e;return{debug:(e,...s)=>y("debug",t,e,...s),info:(e,...s)=>y("info",t,e,...s),warn:(e,...s)=>y("warn",t,e,...s),error:(e,...s)=>(rt(e,...s),y("error",t,e,...s)),setLevel:e=>{t=e},getLevel:()=>t}},v=yt(),C="staticState",m={path:"",baseUrl:"",search:""},mt=e=>{if(!e)return m;try{return JSON.parse(decodeURIComponent(e))||m}catch(e){return v.error("Error parsing static state",e),m}},x=()=>new URLSearchParams(window.location.search).get(C),wt=({path:e,baseUrl:t,search:s}={})=>{const{pathname:r,origin:n,search:o}=window.location;return`${C}=${encodeURIComponent(JSON.stringify({path:e||r,baseUrl:t||n,search:s||o}))}`},St=()=>{const e=x();return e&&localStorage.setItem(C,e),G()},G=()=>{try{const e=localStorage.getItem(C)||x();return mt(e)}catch(e){return v.error("Error parsing static state",e),m}},Pt={create:wt,init:St,get:G},k=({onMessage:e,whitelist:t})=>{const s=s=>{const r=s.origin!==window.location.origin,n=s.data&&"object"==typeof s.data&&"type"in s.data,o=t.some((({type:e})=>e===s.data.type||"*"===e));r&&n&&o&&e(s.data)};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},At=e=>{try{const{type:t,payload:s}=e,r={type:t};return void 0!==s&&(r.payload=JSON.parse(JSON.stringify(s))),r}catch(t){return v.warn(`Could not serialize action type: ${e.type}`,t),{type:e.type,payload:`[Non-serializable payload for action: ${e.type}]`}}},E=({action:e,windowElement:t,whitelist:s})=>{if(t)try{const{type:r}=e;if(!s.some((({type:e})=>e===r||"*"===e)))return;const n=At(e);t.postMessage(n,"*")}catch(e){v.error("Failed to process or send message:",e)}},F="auth_token",z=()=>localStorage.getItem(F)||void 0,bt=e=>localStorage.setItem(F,e),vt=()=>localStorage.removeItem(F),Ct=()=>!!z(),S={getToken:z,setToken:bt,removeToken:vt,hasToken:Ct},M={forgotPasswordStep:"request",forgotPasswordFields:null,signupStep:"rules",signupFields:null,token:null,newEmail:null,isPending:!!S.getToken(),isAuthenticated:!1},D=it({name:"auth",initialState:M,reducers:{login:(e,t)=>{e.isAuthenticated=!0,e.token=t.payload||null,e.isPending=!1},logout:()=>({...M,isPending:!1}),setNewEmail:(e,t)=>{e.newEmail=t.payload},setForgotPasswordStep:(e,t)=>{e.forgotPasswordStep=t.payload},updateForgotPasswordFields:(e,t)=>{e.forgotPasswordFields={...e.forgotPasswordFields,...t.payload}},resetForgotPasswordFields:e=>{e.forgotPasswordFields=null},setSignupStep:(e,t)=>{e.signupStep=t.payload},updateSignupFields:(e,t)=>{e.signupFields={...e.signupFields,...t.payload}},resetSignupFields:e=>{e.signupFields=null},setPending:(e,t)=>{e.isPending=t.payload}},selectors:{selectToken:e=>e.token,selectNewEmail:e=>e.newEmail,selectForgotPasswordStep:e=>e.forgotPasswordStep,selectForgotPasswordFields:e=>e.forgotPasswordFields,selectSignupStep:e=>e.signupStep,selectSignupFields:e=>e.signupFields,selectPending:e=>e.isPending,selectIsAuthenticated:e=>e.isAuthenticated}}),Lt=e=>{if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)},Nt=e=>Lt(e)&&"type"in e&&"string"==typeof e.type,r=e=>{const t=t=>({type:e,payload:t});return t.toString=()=>`${e}`,t.type=e,t.match=t=>Nt(t)&&t.type===e,t},P=r("remoteReady"),J=r("reselectUser"),U=r("requestLogin"),K=r("requestLogout"),X=r("setConfirmLeavePage"),I=r("requestChangePath"),Rt=r("wsSubscribe"),kt=r("wsUnSubscribe"),A=r("hostStoreConnect"),Y=r("remoteLogin"),Z=r("remoteLogout"),Et=r("wsOnMessage"),tt=r("setRouterPath"),Ft=r("setDeviceType"),Ut=r("setUserError"),It=r("setUserIsError"),Ot=r("setUserPending"),Tt=r("setUserSuccess"),_t=r("setUserData"),et=r("updateAccountData"),Vt=r("updateUser"),Qt=r("addNotification"),Mt=r("markNotification"),Dt=r("setNotificationsError"),$t=r("setNotificationsList"),qt=r("setNotificationsPending"),Ht=r("setNotificationsTotalCount"),Bt=r("setNotificationsUnreadCount"),Wt=r("resetNotificationsState"),jt=r("undoNotification"),xt=r("setInstanceInfo"),Gt=r("setInstanceInfoPending"),zt=r("setInstanceInfoError"),Jt=r("setPlatformSettings"),Kt=r("setProfileSettings"),Xt=r("setGroupData"),Yt=r("setGroupLoading"),Zt=r("showGroupBasicInfo");H("requestMicroFrontendFetch"),H("sendMicroFrontendFetchResponse");const L=async(e,t,s)=>{try{e(D.actions.setPending(!0));const{data:r}=await t,n="sessionKey"in r?r.sessionKey:r.token.sessionKey;return S.setToken(n),e(U(n)),null==s||s(),t}catch(t){e(D.actions.setPending(!1)),B.error(lt(t))}},te=ct.enhanceEndpoints({endpoints:{getApiV1Rules:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsPasswordRecover:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsPasswordRecoverCheckCode:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsPasswordRecoverChange:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsPasswordChangeConfirm:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},putApiV1AccountsPasswordChangeResendCode:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsPasswordChangeRequest:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},putApiV1AccountsEmailChangeResendCode:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},putApiV1AccountsResendEmailByHash:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsEmailChangeRequest:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsEmailChangeConfirm:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsConfirmEmail:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsCheckCaptcha:{async onQueryStarted(e,{queryFulfilled:t}){await i(t)}},postApiV1AccountsFinishCreating:{async onQueryStarted(e,{dispatch:t,queryFulfilled:s}){await L(t,s,(()=>{B.success("User registered successfully")}))}},postApiV1AccountsAuthenticateEmail:{invalidatesTags:["Secure"],async onQueryStarted(e,{dispatch:t,queryFulfilled:s}){await L(t,s)}},postApiV1AccountsSignup:{invalidatesTags:["Secure"]},postApiV1AccountsUserReselectUser:{async onQueryStarted({userId:e},{dispatch:t,queryFulfilled:s}){await L(t,s),e&&t(et({selectedUserId:e}))}}}}),st={[J.type]:e=>h().dispatch(te.endpoints.postApiV1AccountsUserReselectUser.initiate(e)),[U.type]:e=>S.setToken(e),[K.type]:()=>S.removeToken()},ee=e=>Object.keys(st).includes(e.type),ot=e=>ee(e)?st[e.type](e.payload):null,nt=({sendWhitelist:e,receiveWhitelist:t,onMessage:s})=>{const r=g((()=>{})),n=g((()=>{}));return w((o=>{o&&(r.current(),n.current(),r.current=V((t=>{ot(t),E({action:t,windowElement:o,whitelist:e})})),n.current=k({onMessage:e=>{s?s(e):h().dispatch(e)},whitelist:t}))}),[e,t,s,V])},O=[I,Rt,kt,P,J,U,K,X],T=[Y,Z,A,Et,tt,Ft,Ut,It,Ot,Tt,_t,et,Vt,Qt,Mt,Dt,$t,qt,Ht,Bt,Wt,jt,xt,Gt,zt,Jt,Kt,Xt,Yt,Zt];if(T.some((e=>O.some((t=>(null==t?void 0:t.toString())===(null==e?void 0:e.toString()))))))throw new Error("Output action is duplicated with input action");const se=()=>{const e=structuredClone(h().getState());return e.openapi&&(e.openapi=void 0),e.auth&&(e.auth={...e.auth,token:null}),e},Ne=e=>{const t=nt({sendWhitelist:T,receiveWhitelist:O,onMessage:e=>{ot(e)||h().dispatch(e)}}),s=w((()=>{var t;const s=A(se());E({action:s,windowElement:(null==(t=e.current)?void 0:t.contentWindow)??null,whitelist:[s]})}),[e]),r=w((()=>{var r;t((null==(r=e.current)?void 0:r.contentWindow)??null),s()}),[t,e,s]);p((()=>{const e=k({onMessage:e=>{e.type===P.type&&r()},whitelist:[P]});return()=>e()}),[r])},_=()=>{const e=W();return e.pathname+e.search},oe=({lastLocationPathRef:e})=>{const t=b(),s=_(),r=u(d.selectors.selectPath),n=u(d.selectors.selectTransitionPath);p((()=>{s!==e.current&&(e.current=s,s!==r&&s!==n&&t(I(s)))}),[r,n,s])},ne=({canShowMessage:e,message:t="Are you sure you want to leave?"})=>{const s=b(),r=u(d.selectors.selectPath),n=e=>(e.preventDefault(),e.returnValue=t,t);p((()=>(window.onbeforeunload=e?n:null,()=>{window.onbeforeunload=null})),[e,t]);const o=ut(e),a="blocked"===o.state;p((()=>{a&&(confirm(t)?(o.proceed(),s(X(null))):(o.reset(),s(I(r))))}),[a])},re=()=>{const e=b(),t=u(d.selectors.selectPath),s=_();return{setPath:({transitionPath:r})=>{r&&s===r&&t!==r&&e(tt(r))}}},ae=()=>{const e=j(),t=W(),s=b(),r=g(""),n=u(d.selectors.selectPath),o=u(d.selectors.selectTransitionPath),{setPath:a}=re(),{shouldBlock:i,message:l}=u(d.selectors.selectConfirmLeavePage)||{};ne({canShowMessage:!!i,message:l}),oe({lastLocationPathRef:r}),p((()=>{a({transitionPath:o})}),[t,n,o,s]),p((()=>{o&&o!==r.current&&(r.current=o,e(o,{replace:!1}))}),[o,e])},ce=$((()=>(ae(),null)));ce.displayName="HostRouteObserver";const ie=e=>{const t=g(e),[s,r]=q(null);return p((()=>{const e=k({onMessage:e=>{var s;if(e.type===A.type){const n=at(e.payload);r(n),null==(s=t.current)||s.call(t,n)}},whitelist:[A]}),s=P();return E({action:s,windowElement:window.parent,whitelist:[s]}),()=>e()}),[]),{store:s}},N={[Y.type]:()=>dt(),[Z.type]:()=>pt()},le=e=>Object.keys(N).includes(e.type),ue=e=>le(e)&&e.type in N?N[e.type]():null,{path:R,search:de}=Pt.init();R&&window.history.replaceState({},"",`${R}${de||""}`);const Re=()=>{const[e,t]=q(null),s=nt({sendWhitelist:O,receiveWhitelist:T,onMessage:e=>{ue(e)||h().dispatch(e)}}),r=w((e=>{t(e),s(window.parent)}),[s]);return ie(r),{store:e,path:R}},pe=()=>{const e=j(),t=g(""),s=_(),r=u(d.selectors.selectPath);p((()=>{r&&r!==t.current&&(t.current=r,s!==r&&e(r,{replace:!0}))}),[r,e,s])},ge=$((()=>(pe(),null)));ge.displayName="RemoteRouteObserver";export{ce as HostRouteObserver,ge as RemoteRouteObserver,ot as callHostApiAction,ue as callRemoteApiAction,k as listenMessage,se as prepareState,E as sendMessage,Pt as staticState,Ne as useHostStoreConnect,ie as usePreloadedStore,Re as useRemoteStoreConnect};
|
|
1
|
+
import{logErrorToSentry as he}from"https://cdn.jsdelivr.net/npm/@wellesley/sentry@next";import{subscribeAfter as J}from"https://cdn.jsdelivr.net/npm/@wellesley/redux-subscribe-action@next";import ye,{useRef as A,useCallback as w,useEffect as h,useState as I,memo as X}from"https://cdn.jsdelivr.net/npm/react@18.2.0/+esm";import{getStore as C,createStore as we}from"https://cdn.jsdelivr.net/npm/@wellesley/store@next";import{api as Se,handleBasicResponse as u}from"https://cdn.jsdelivr.net/npm/@wellesley/openapi@next";import{createSlice as Pe,createAction as Z}from"https://cdn.jsdelivr.net/npm/@reduxjs/toolkit@2.2.1/+esm";import{toast as ee}from"https://cdn.jsdelivr.net/npm/react-toastify@10.0.5/+esm";import{getErrorMsg as ve}from"https://cdn.jsdelivr.net/npm/@wellesley/error-kit@next";import{useDispatch as E,useSelector as m}from"https://cdn.jsdelivr.net/npm/react-redux@9.1.0/+esm";import{routerSlice as f}from"https://cdn.jsdelivr.net/npm/@wellesley/router@next";import{useLocation as te,useBlocker as Ae,useNavigate as se}from"https://cdn.jsdelivr.net/npm/react-router-dom@6.22.2/+esm";import{Dialog as Ce,DialogContent as xe,cn as Re,ButtonLoader as z}from"https://cdn.jsdelivr.net/npm/@wellesley/ui@next";import{handleLogin as be,handleLogout as Ne}from"https://cdn.jsdelivr.net/npm/@wellesley/auth@next";const _e=()=>"object"!=typeof window,B=["debug","info","warn","error"],Ee=(e,t)=>{const s=B.indexOf(e);return B.indexOf(t)>=s},x=(e,t,s,...n)=>{Ee(t,e)&&console.log(`[${e}] ${s}`,...n)},Le=()=>null==window?void 0:window.localStorage.getItem("logger_lvl"),Oe=(e=!_e()&&Le()||"warn")=>{let t=e;return{debug:(e,...s)=>x("debug",t,e,...s),info:(e,...s)=>x("info",t,e,...s),warn:(e,...s)=>x("warn",t,e,...s),error:(e,...s)=>(he(e,...s),x("error",t,e,...s)),setLevel:e=>{t=e},getLevel:()=>t}},L=Oe(),O="staticState",R={path:"",baseUrl:"",search:""},ke=e=>{if(!e)return R;try{return JSON.parse(decodeURIComponent(e))||R}catch(e){return L.error("Error parsing static state",e),R}},oe=()=>new URLSearchParams(window.location.search).get(O),Fe=({path:e,baseUrl:t,search:s}={})=>{const{pathname:n,origin:o,search:a}=window.location;return`${O}=${encodeURIComponent(JSON.stringify({path:e||n,baseUrl:t||o,search:s||a}))}`},Te=()=>{const e=oe();return e&&localStorage.setItem(O,e),ne()},ne=()=>{try{const e=localStorage.getItem(O)||oe();return ke(e)}catch(e){return L.error("Error parsing static state",e),R}},Ue={create:Fe,init:Te,get:ne},j=({onMessage:e,whitelist:t})=>{const s=s=>{const n=s.origin!==window.location.origin,o=s.data&&"object"==typeof s.data&&"type"in s.data,a=t.some((({type:e})=>e===s.data.type||"*"===e));n&&o&&a&&e(s.data)};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},Ie=e=>{try{const{type:t,payload:s}=e,n={type:t};return void 0!==s&&(n.payload=JSON.parse(JSON.stringify(s))),n}catch(t){return L.warn(`Could not serialize action type: ${e.type}`,t),{type:e.type,payload:`[Non-serializable payload for action: ${e.type}]`}}},V=({action:e,windowElement:t,whitelist:s})=>{if(t)try{const{type:n}=e;if(!s.some((({type:e})=>e===n||"*"===e)))return;const o=Ie(e);t.postMessage(o,"*")}catch(e){L.error("Failed to process or send message:",e)}},D="auth_token",re=()=>localStorage.getItem(D)||void 0,je=e=>localStorage.setItem(D,e),Ve=()=>localStorage.removeItem(D),De=()=>!!re(),b={getToken:re,setToken:je,removeToken:Ve,hasToken:De},W={forgotPasswordStep:"request",forgotPasswordFields:null,signupStep:"rules",signupFields:null,token:null,newEmail:null,isPending:!!b.getToken(),isAuthenticated:!1},G=Pe({name:"auth",initialState:W,reducers:{login:(e,t)=>{e.isAuthenticated=!0,e.token=t.payload||null,e.isPending=!1},logout:()=>({...W,isPending:!1}),setNewEmail:(e,t)=>{e.newEmail=t.payload},setForgotPasswordStep:(e,t)=>{e.forgotPasswordStep=t.payload},updateForgotPasswordFields:(e,t)=>{e.forgotPasswordFields={...e.forgotPasswordFields,...t.payload}},resetForgotPasswordFields:e=>{e.forgotPasswordFields=null},setSignupStep:(e,t)=>{e.signupStep=t.payload},updateSignupFields:(e,t)=>{e.signupFields={...e.signupFields,...t.payload}},resetSignupFields:e=>{e.signupFields=null},setPending:(e,t)=>{e.isPending=t.payload}},selectors:{selectToken:e=>e.token,selectNewEmail:e=>e.newEmail,selectForgotPasswordStep:e=>e.forgotPasswordStep,selectForgotPasswordFields:e=>e.forgotPasswordFields,selectSignupStep:e=>e.signupStep,selectSignupFields:e=>e.signupFields,selectPending:e=>e.isPending,selectIsAuthenticated:e=>e.isAuthenticated}}),Me=e=>{if("object"!=typeof e||null===e)return!1;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||null===Object.getPrototypeOf(e)},Qe=e=>Me(e)&&"type"in e&&"string"==typeof e.type,a=e=>{const t=t=>({type:e,payload:t});return t.toString=()=>`${e}`,t.type=e,t.match=t=>Qe(t)&&t.type===e,t},N=a("remoteReady"),ae=a("reselectUser"),M=a("requestLogin"),ie=a("requestLogout"),ce=a("setConfirmLeavePage"),Q=a("requestChangePath"),qe=a("wsSubscribe"),$e=a("wsUnSubscribe"),_=a("hostStoreConnect"),le=a("remoteLogin"),ue=a("remoteLogout"),He=a("wsOnMessage"),de=a("setRouterPath"),Je=a("setDeviceType"),ze=a("setUserError"),Be=a("setUserIsError"),We=a("setUserPending"),Ge=a("setUserSuccess"),Ke=a("setUserData"),pe=a("updateAccountData"),Ye=a("updateUser"),Xe=a("addNotification"),Ze=a("markNotification"),et=a("setNotificationsError"),tt=a("setNotificationsList"),st=a("setNotificationsPending"),ot=a("setNotificationsTotalCount"),nt=a("setNotificationsUnreadCount"),rt=a("resetNotificationsState"),at=a("undoNotification"),it=a("setInstanceInfo"),ct=a("setInstanceInfoPending"),lt=a("setInstanceInfoError"),ut=a("setPlatformSettings"),dt=a("setProfileSettings"),pt=a("setGroupData"),gt=a("setGroupLoading"),mt=a("showGroupBasicInfo");Z("requestMicroFrontendFetch"),Z("sendMicroFrontendFetchResponse");const k=async(e,t,s)=>{try{e(G.actions.setPending(!0));const{data:n}=await t,o="sessionKey"in n?n.sessionKey:n.token.sessionKey;return b.setToken(o),e(M(o)),null==s||s(),t}catch(t){e(G.actions.setPending(!1)),ee.error(ve(t))}},ft=Se.enhanceEndpoints({endpoints:{getApiV1Rules:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsPasswordRecover:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsPasswordRecoverCheckCode:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsPasswordRecoverChange:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsPasswordChangeConfirm:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},putApiV1AccountsPasswordChangeResendCode:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsPasswordChangeRequest:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},putApiV1AccountsEmailChangeResendCode:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},putApiV1AccountsResendEmailByHash:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsEmailChangeRequest:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsEmailChangeConfirm:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsConfirmEmail:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsCheckCaptcha:{async onQueryStarted(e,{queryFulfilled:t}){await u(t)}},postApiV1AccountsFinishCreating:{async onQueryStarted(e,{dispatch:t,queryFulfilled:s}){await k(t,s,(()=>{ee.success("User registered successfully")}))}},postApiV1AccountsAuthenticateEmail:{invalidatesTags:["Secure"],async onQueryStarted(e,{dispatch:t,queryFulfilled:s}){await k(t,s)}},postApiV1AccountsSignup:{invalidatesTags:["Secure"]},postApiV1AccountsUserReselectUser:{async onQueryStarted({userId:e},{dispatch:t,queryFulfilled:s}){await k(t,s),e&&t(pe({selectedUserId:e}))}}}}),ge={[ae.type]:e=>C().dispatch(ft.endpoints.postApiV1AccountsUserReselectUser.initiate(e)),[M.type]:e=>b.setToken(e),[ie.type]:()=>b.removeToken()},ht=e=>Object.keys(ge).includes(e.type),me=e=>ht(e)?ge[e.type](e.payload):null,fe=({sendWhitelist:e,receiveWhitelist:t,onMessage:s})=>{const n=A((()=>{})),o=A((()=>{}));return w((a=>{a&&(n.current(),o.current(),n.current=J((t=>{me(t),V({action:t,windowElement:a,whitelist:e})})),o.current=j({onMessage:e=>{s?s(e):C().dispatch(e)},whitelist:t}))}),[e,t,s,J])},q=[Q,qe,$e,N,ae,M,ie,ce],$=[le,ue,_,He,de,Je,ze,Be,We,Ge,Ke,pe,Ye,Xe,Ze,et,tt,st,ot,nt,rt,at,it,ct,lt,ut,dt,pt,gt,mt];if($.some((e=>q.some((t=>(null==t?void 0:t.toString())===(null==e?void 0:e.toString()))))))throw new Error("Output action is duplicated with input action");const yt=()=>{const e=structuredClone(C().getState());return e.openapi&&(e.openapi=void 0),e.auth&&(e.auth={...e.auth,token:null}),e},Gt=e=>{const t=fe({sendWhitelist:$,receiveWhitelist:q,onMessage:e=>{me(e)||C().dispatch(e)}}),s=w((()=>{var t;const s=_(yt());V({action:s,windowElement:(null==(t=e.current)?void 0:t.contentWindow)??null,whitelist:[s]})}),[e]),n=w((()=>{var n;t((null==(n=e.current)?void 0:n.contentWindow)??null),s()}),[t,e,s]);h((()=>{const e=j({onMessage:e=>{e.type===N.type&&n()},whitelist:[N]});return()=>e()}),[n])};var K,Y,F={exports:{}},v={};
|
|
2
|
+
/**
|
|
3
|
+
* @license React
|
|
4
|
+
* react-jsx-runtime.production.min.js
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/function wt(){if(K)return v;K=1;var e=ye,t=Symbol.for("react.element"),s=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,o=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function r(e,s,r){var i,l={},c=null,d=null;for(i in void 0!==r&&(c=""+r),void 0!==s.key&&(c=""+s.key),void 0!==s.ref&&(d=s.ref),s)n.call(s,i)&&!a.hasOwnProperty(i)&&(l[i]=s[i]);if(e&&e.defaultProps)for(i in s=e.defaultProps)void 0===l[i]&&(l[i]=s[i]);return{$$typeof:t,type:e,key:c,ref:d,props:l,_owner:o.current}}return v.Fragment=s,v.jsx=r,v.jsxs=r,v}function St(){return Y||(Y=1,F.exports=wt()),F.exports}var d=St();const H=()=>{const e=te();return e.pathname+e.search},Pt=({lastLocationPathRef:e})=>{const t=E(),s=H(),n=m(f.selectors.selectPath),o=m(f.selectors.selectTransitionPath);h((()=>{s!==e.current&&(e.current=s,s!==n&&s!==o&&t(Q(s)))}),[n,o,s])},vt=(e=!1)=>{const[t,s]=I(e);return[t,w((()=>s(!0)),[]),w((()=>s(!1)),[]),w((()=>s((e=>!e))),[]),s]},At=({open:e,modal:t,children:s,onCloseModal:n,className:o,...a})=>d.jsx(Ce,{open:e,modal:t,onOpenChange:e=>{e||null==n||n()},children:d.jsx(xe,{className:Re("max-w-[600px] rounded-lg",o),closeSize:"small",closeVariant:"insideCard",onCloseModal:n,...a,children:s})}),Ct=({open:e,title:t,children:s,leftButton:n,rightButton:o,onClose:a,...r})=>d.jsxs(At,{open:e,onCloseModal:a,className:"gap-none max-w-[400px] rounded-lg",...r,children:[d.jsx("h3",{className:"p-none mb-xxs text-center text-lg font-semibold text-slate-700",children:t}),s&&d.jsx("div",{className:"text-center text-base text-slate-500",children:s}),d.jsxs("div",{className:"mt-m max-md:gap-s md:gap-m flex justify-center",children:[d.jsx(z,{size:"m",variant:"secondary",className:"w-[157px] max-md:flex-1",...n,title:void 0,children:n.title}),o&&d.jsx(z,{size:"m",className:"w-[157px] max-md:flex-1",...o,title:void 0,children:o.title})]})]}),xt=({isOpen:e,onCancel:t,onDiscard:s})=>d.jsx(Ct,{open:e,onClose:t,title:"Discard unsaved changes?",leftButton:{title:"Cancel",variant:"secondary",onClick:t},rightButton:{title:"Discard",variant:"red_primary",onClick:s},children:"You have unsaved changes. Closing now will discard them. Do you want to continue?"}),Rt=()=>vt(),bt=({canShowMessage:e,message:t="You have unsaved changes. Are you sure you want to leave?"})=>{const s=E(),n=m(f.selectors.selectPath),o=e=>(e.preventDefault(),e.returnValue=t,t);h((()=>(window.onbeforeunload=e?o:null,()=>{window.onbeforeunload=null})),[e,t]);const a=Ae(e),r="blocked"===a.state,[i,l,c]=Rt(),u=()=>{var e;null==(e=a.proceed)||e.call(a),c(),s(ce(null))},p=()=>{var e;null==(e=a.reset)||e.call(a),c(),s(Q(n))};return h((()=>{r&&l()}),[r]),()=>d.jsx(xt,{isOpen:i,onCancel:p,onDiscard:u})},Nt=()=>{const e=E(),t=m(f.selectors.selectPath),s=H();return{setPath:({transitionPath:n})=>{n&&s===n&&t!==n&&e(de(n))}}},_t=()=>{const e=se(),t=te(),s=E(),n=A(""),o=m(f.selectors.selectPath),a=m(f.selectors.selectTransitionPath),{setPath:r}=Nt(),{shouldBlock:i,message:l}=m(f.selectors.selectConfirmLeavePage)||{},c=bt({canShowMessage:!!i,message:l});return Pt({lastLocationPathRef:n}),h((()=>{r({transitionPath:a})}),[t,o,a,s]),h((()=>{a&&a!==n.current&&(n.current=a,e(a,{replace:!1}))}),[a,e]),c},Et=X((()=>{const e=_t();return d.jsx(d.Fragment,{children:null==e?void 0:e()})}));Et.displayName="HostRouteObserver";const Lt=e=>{const t=A(e),[s,n]=I(null);return h((()=>{const e=j({onMessage:e=>{var s;if(e.type===_.type){const o=we(e.payload);n(o),null==(s=t.current)||s.call(t,o)}},whitelist:[_]}),s=N();return V({action:s,windowElement:window.parent,whitelist:[s]}),()=>e()}),[]),{store:s}},T={[le.type]:()=>be(),[ue.type]:()=>Ne()},Ot=e=>Object.keys(T).includes(e.type),kt=e=>Ot(e)&&e.type in T?T[e.type]():null,{path:U,search:Ft}=Ue.init();U&&window.history.replaceState({},"",`${U}${Ft||""}`);const Kt=()=>{const[e,t]=I(null),s=fe({sendWhitelist:q,receiveWhitelist:$,onMessage:e=>{kt(e)||C().dispatch(e)}}),n=w((e=>{t(e),s(window.parent)}),[s]);return Lt(n),{store:e,path:U}},Tt=()=>{const e=se(),t=A(""),s=H(),n=m(f.selectors.selectPath);h((()=>{n&&n!==t.current&&(t.current=n,s!==n&&e(n,{replace:!0}))}),[n,e,s])},Ut=X((()=>(Tt(),null)));Ut.displayName="RemoteRouteObserver";export{Et as HostRouteObserver,Ut as RemoteRouteObserver,me as callHostApiAction,kt as callRemoteApiAction,j as listenMessage,yt as prepareState,V as sendMessage,Ue as staticState,Gt as useHostStoreConnect,Lt as usePreloadedStore,Kt as useRemoteStoreConnect};
|