@bodhiapp/bodhi-js-react-core 0.0.23 → 0.0.25
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/bodhi-react-core.cjs.js +2 -2
- package/dist/bodhi-react-core.esm.js +196 -180
- package/dist/index.d.ts +1 -1
- package/package.json +5 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react/jsx-runtime"),s=require("@bodhiapp/bodhi-js-core"),r=require("react"),O=require("@bodhiapp/setup-modal-types");function W(e){const
|
|
2
|
-
`,JSON.stringify(n,null,2)),i.current?.updateState(C()),{setupState:n}},[O.MSG.MODAL_LNA_CONNECT]:async t=>{const n=t.payload.serverUrl;console.log("[SetupModalProcessor] LNA connect:",n);const c=await e.testDirectConnectivity(n);if(c.server.status!=="not-connected"){const p=c.server.status;if(p==="ready"||p==="setup"||p==="resource-admin"){f.setDirectStatus("granted"),e.getConnectionMode()===null&&await e.setConnectionMode("direct");const _=await h();return E.current=_,i.current?.updateState(C()),{success:!0}}}const d=await h();return E.current=d,i.current?.updateState(C()),{success:!1}},[O.MSG.MODAL_LNA_SKIP]:async()=>{f.setDirectStatus("skipped");const t=await h();return E.current=t,i.current?.updateState(C()),{success:!0}},[O.MSG.MODAL_CLOSE]:()=>{g()},[O.MSG.MODAL_COMPLETE]:()=>{g()},[O.MSG.MODAL_CONFIRM_SERVER_INSTALL]:t=>(f.setServerInstallConfirmed(t.payload.confirmed),i.current?.updateState(C()),{success:!0}),[O.MSG.MODAL_SELECT_CONNECTION]:async t=>{const c=t.payload.connection==="lna"?"direct":"extension";return await e.setConnectionMode(c),i.current?.updateState(C()),{success:!0}}}),[I,e,f,h,C,x,g]);return r.useEffect(()=>(i.current=new s.OnboardingModal({modalHtmlPath:a,handlers:k}),()=>{i.current?.destroy(),i.current=null}),[a,k]),r.useEffect(()=>{R&&i.current?(i.current.showLoading(),h(!0).then(t=>{E.current=t,i.current?.updateState(t),y?.()}).catch(t=>{console.error("[SetupModalProcessor] buildSetupState failed:",t)})):!R&&i.current&&i.current.destroy()},[R,h,y]),null}const j={status:"not-initialized",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null},U={status:"initializing",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null};function G(e){return e.status==="not-initialized"}function F(e){return e.status==="initializing"}function q(e){return e.status!=="not-initialized"&&e.status!=="initializing"}function P(e){return e.status==="ready"}function H(e){return P(e)&&e.server.status==="ready"}function V(e){return s.isExtensionState(e)?{status:e.extension==="not-initialized"?"initializing":e.extension==="not-found"?"extension-not-found":"ready",mode:"extension",extensionId:e.extensionId,url:null,server:e.server,error:e.server.error}:{status:e.url===null?"direct-not-connected":"ready",mode:"direct",extensionId:null,url:e.url,server:e.server,error:e.server.error}}const X={isNotInitialized:G,isInitializing:F,isInitialized:q,isReady:P,isOverallReady:H},z=r.createContext(null);z.displayName="BodhiContext";function Z({children:e,client:a,modalHtmlPath:g,handleCallback:y=!0,callbackPath:M,basePath:b="/",logLevel:S="warn"}){const R=b==="/"?"":b.replace(/\/$/,""),I=M??`${R}/callback`,i=r.useMemo(()=>new s.Logger("BodhiProvider",S),[S]),f=r.useRef(!1),E=r.useRef(!1),[m,L]=r.useState(j),[w,x]=r.useState(s.INITIAL_AUTH_STATE),[T,A]=r.useState(!1),[h,C]=r.useState("ready");r.useEffect(()=>{const u=o=>{switch(o.type){case"client-state":L(V(o.state));break;case"auth-state":x(o.state),A(!1);break}};return a.setStateCallback(u),()=>{a.setStateCallback(s.NOOP_STATE_CALLBACK)}},[a]);const k=r.useCallback(async()=>{C("loading")},[]),t=r.useCallback(()=>{C("ready")},[]),n=r.useCallback(()=>{C("loaded")},[]),c=r.useCallback(async u=>{L(U);try{await a.init(u||{})}catch(o){i.error("Init failed:",o)}},[a,i]);r.useEffect(()=>{if(E.current)return;E.current=!0,(async()=>{if(await c(),!y)return;const o=new URL(window.location.href);if(o.pathname!==I)return;const v=o.searchParams.get("code"),B=o.searchParams.get("state");!v||!B||f.current||(f.current=!0,s.isWebUIClient(a)&&(A(!0),a.handleOAuthCallback(v,B).then(()=>{window.history.replaceState({},"",b)}).catch(D=>{i.error("OAuth callback failed:",D),x({status:"error",user:null,accessToken:null,error:{message:D instanceof Error?D.message:"OAuth callback failed",code:"OAUTH_CALLBACK_FAILED"}}),A(!1),window.history.replaceState({},"",b)})))})()},[c,a,y,I,b]);const d=r.useCallback(async u=>{A(!0);try{const o=u?{...u.toolsetScopeIds&&{toolsetScopeIds:u.toolsetScopeIds},...u.version&&{version:u.version}}:void 0,v=o&&Object.keys(o).length>0?o:void 0;await a.login(v)}catch(o){const v={status:"error",user:null,accessToken:null,error:{message:o instanceof Error?o.message:"Login failed",code:"LOGIN_FAILED"}};return x(v),A(!1),v}},[a]),p=r.useCallback(async()=>{try{await a.logout()}catch(u){x({status:"error",user:null,accessToken:null,error:{message:u instanceof Error?u.message:"Logout failed",code:"LOGOUT_FAILED"}})}},[a]),_=r.useMemo(()=>{const u=m.status==="ready",o=m.server.status==="ready";return{client:a,clientState:m,auth:w,isAuthLoading:T,login:d,logout:p,showSetup:k,hideSetup:t,setupState:h,isAuthenticated:w.status==="authenticated",canLogin:u&&!T,isReady:u,isServerReady:o,isOverallReady:u&&o,isInitializing:m.status==="initializing",isExtension:m.mode==="extension",isDirect:m.mode==="direct"}},[a,m,w,T,h,d,p,k,t]);return N.jsxs(z.Provider,{value:_,children:[N.jsx(K,{client:a,modalHtmlPath:g,hideSetup:t,onSetupReady:n,setupState:h,basePath:b,logLevel:S}),e]})}function J(){const e=r.useContext(z);if(!e)throw new Error("useBodhi must be used within BodhiProvider");return e}const Y=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 479.995 479.995",width:"480px",height:"480px",...e},l.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.56l-0.01-0.01c0-0.01,0.01-0.01,0.01-0.02c-4.64-8.78-65.7-144.8-212.22-85.2 c-14.36,5.85-19.78,23.45-11.19,36.36c11.11,16.69,22.86,30.01,34.91,40.53c-27.85,7.89-45.6,33.8-43.3,61.55 c0.96,11.6,13.29,18.52,23.71,13.35c33.99-16.84,60.03-2.51,80.35,2.14c56.68,12.99,113.71,4.53,125.52-46.29 c0.52-2.22,0.95-4.51,1.28-6.89c0.01-0.04,0.01-0.08,0.02-0.12c0.066-0.492,0.126-0.978,0.181-1.458 c0.455-3.631,0.712-7.438,0.739-11.452c-0.02-1.44-0.02-2.01,0-2.25v-0.09c0-0.02,0-0.04,0.01-0.05c0-0.02,0.01-0.03,0.02-0.06 c0-0.01,0.01-0.01,0.01-0.02C240.018,374.569,240.008,374.56,239.998,374.56z"}),l.createElement("path",{fill:"#ffa4b8",d:"M471.798,427.769c-0.96,11.6-13.29,18.52-23.71,13.35c-33.99-16.84-60.03-2.51-80.35,2.14 c-63.41,14.53-127.25,2.22-127.74-66.21c0.033-2.642-0.044-2.302,0.04-2.47c-0.02-0.01-0.03-0.02-0.04-0.02l0.01-0.01 c0-0.01-0.01-0.01-0.01-0.02c4.64-8.78,65.7-144.8,212.22-85.2c14.36,5.85,19.78,23.45,11.19,36.36 c-11.11,16.69-22.86,30.01-34.91,40.53C456.348,374.109,474.098,400.019,471.798,427.769z"}),l.createElement("path",{fill:"#befa91",d:"M428.498,366.219c27.85,7.89,45.6,33.8,43.3,61.55c-0.96,11.6-13.29,18.52-23.71,13.35 c-33.99-16.84-60.03-2.51-80.35,2.14c-63.41,14.53-127.928,2.222-127.74-66.21c0.007-2.683-0.02-2.351,0.04-2.47 C248.598,379.129,345.858,438.329,428.498,366.219z"}),l.createElement("path",{fill:"#befa91",d:"M51.498,366.219c82.76,72.22,180.18,12.74,188.5,8.34c0.01,0,0.02,0.01,0.04,0.02 c-0.058,0.116-0.047-0.169-0.04,2.47c0.188,68.432-64.33,80.74-127.74,66.21c-20.32-4.65-46.36-18.98-80.35-2.14 c-10.42,5.17-22.75-1.75-23.71-13.35C5.898,400.019,23.648,374.109,51.498,366.219z"}),l.createElement("path",{fill:"#ffbfcb",d:"M235.228,365.299c-32.29-36.09-89.98-73-179.74-36.49c-1.979,0.805-3.787,1.834-5.413,3.042 c-10.569,7.856-25.473,5.765-32.82-5.164c-0.223-0.331-0.445-0.664-0.667-0.997c-8.59-12.91-3.17-30.51,11.19-36.36 C155.168,237.509,217.948,333.56,235.228,365.299z"}),l.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.549c-12.85-2.2-214.54-23.33-193.03-240.71c1.49-14.99,15.86-25.15,30.48-21.55 c108.49,26.72,149.07,91.39,162.55,149.92C252.768,317.699,241.178,367.679,239.998,374.549z"}),l.createElement("path",{fill:"#ffbfcb",d:"M193.698,174.638c11.866,12.406-3.013,31.792-18.056,23.52 c-21.875-12.028-50.044-10.573-70.207,3.701c-24.832,17.579-59.398-0.365-60.013-30.784c-0.237-11.724,0.248-24.123,1.545-37.237 c1.49-14.99,15.86-25.15,30.48-21.55C131.23,125.537,168.324,148.11,193.698,174.638z"}),l.createElement("path",{fill:"#ffa4b8",d:"M221.538,39.599c9.78-11.13,27.15-11.12,36.93,0.01c157.02,178.77-7.48,323.95-18.47,334.94 C229.988,364.549,63.948,218.989,221.538,39.599z"}),l.createElement("path",{fill:"#ffbfcb",d:"M261.523,43.131c9.452,11.033,8.166,27.623-2.74,37.221c-0.784,0.69-1.535,1.439-2.245,2.247 c-35.942,40.915-55.05,80.07-63.012,116.258c-5.176,23.523-39.936,19.717-39.551-4.366c0.741-46.282,18.411-98.941,67.563-154.892 c9.78-11.13,27.15-11.12,36.93,0.01C259.5,40.785,260.518,41.959,261.523,43.131z"}),l.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.549c-1.18-6.87-12.77-56.85,0-112.34c13.48-58.53,54.06-123.2,162.55-149.92 c14.62-3.6,28.99,6.56,30.48,21.55C454.538,351.219,252.848,372.349,239.998,374.549z"}),l.createElement("path",{fill:"#ff8ca5",d:"M239.998,374.549c-3.115-0.536-17.362-2.183-36.835-7.483c-3.181-0.866-6.028-2.682-8.145-5.209 c-49.098-58.608-75.675-130.75-61.047-205.793c2.165-11.107,14.881-16.444,24.408-10.337c0.756,0.485,1.506,0.972,2.249,1.462 C126.798,274.139,232.088,366.649,239.998,374.549z"}),l.createElement("path",{fill:"#ff8ca5",d:"M281.608,365.729c-21.9,6.37-38.24,8.25-41.61,8.82c8.67-8.67,112.98-100.94,79.35-227.34v-0.01 c0.742-0.489,1.49-0.975,2.244-1.459c9.551-6.123,22.265-0.733,24.422,10.406C369.565,277.734,281.608,363.204,281.608,365.729z"}),l.createElement("path",{fill:"#ff8ca5",d:"M417.451,302.932c-32.211,44.193-80.706,72.823-134.571,87.345c-3.396,0.916-6.999,0.754-10.3-0.463 c-20.772-7.664-31.911-15.254-32.583-15.254c0.826-0.825,112.667-9.463,166.4-98.31C419.37,278.279,424.743,292.927,417.451,302.932 z"}),l.createElement("path",{fill:"#ff8ca5",d:"M62.565,302.932c32.211,44.193,80.705,72.823,134.571,87.345c3.396,0.916,6.999,0.754,10.3-0.463 c20.772-7.664,31.911-15.254,32.583-15.254c-0.828-0.828-112.665-9.458-166.4-98.31C60.646,278.279,55.273,292.927,62.565,302.932z"}),l.createElement("path",{fill:"#9ceb63",d:"M433.464,393.091c-52.749,39.415-118.979,42.09-182.861,13.657 c-4.441-1.977-7.606-6.011-8.633-10.763c-1.552-7.18-1.884-14.238-1.973-21.326c0.172-0.345,9.566,5.934,26.76,12.89 c36.31,14.71,102.75,30.15,161.74-21.33C440.977,369.752,443.403,385.664,433.464,393.091z"}),l.createElement("path",{fill:"#9ceb63",d:"M240.038,374.579c0,0.01-0.01,0.01-0.01,0.02s-0.01,0.03-0.01,0.05c0,0,0,0,0,0.01 c-0.01,0.03-0.01,0.06-0.02,0.1v0.04c-0.13,1.3,0.09,7.59-0.92,15.16c-0.01,0.04-0.01,0.08-0.02,0.12 c-0.26,1.91-0.59,3.91-1.03,5.92c-0.07,0.33-0.15,0.65-0.25,0.97c-1.23,4.33-4.28,7.95-8.41,9.79 c-63.06,28.05-129.47,26.21-182.79-13.63c-9.94-7.43-7.63-23.36,4.92-26.91c13.1,11.46,28.11,20.79,44.16,26.79 c19.78,7.48,34.99,8.98,53.83,8.68c34.33-0.55,60.1-11.03,90.51-27.13C240.008,374.56,240.018,374.569,240.038,374.579z"}),l.createElement("path",{d:"M443.143,363.426c9.579-9.648,18.604-20.804,26.926-33.305c11.399-17.132,4.201-40.447-14.837-48.202 c-12.321-5.012-24.515-8.844-36.391-11.454c17.945-34.197,27.974-78.94,22.188-137.413c-1.925-19.503-20.802-33.354-40.394-28.53 c-17.952,4.421-34.806,10.063-50.093,16.768c-4.046,1.775-5.888,6.494-4.113,10.54c1.774,4.046,6.493,5.887,10.54,4.113 c14.45-6.338,30.429-11.682,47.492-15.885c9.885-2.435,19.599,4.434,20.607,14.573c9.088,90.121-21.147,164.341-99.823,205.213 c-3.921,2.037-5.448,6.866-3.411,10.787c2.043,3.933,6.879,5.442,10.787,3.411c27.191-14.125,56.267-35.849,77.701-68.994 c12.564,2.375,25.617,6.296,38.878,11.69c9.68,3.943,13.334,15.824,7.549,24.518c-10.205,15.33-21.482,28.43-33.516,38.936 c-49.396,43.107-111.979,41.39-169.834,12.419c56.638-56.971,92.247-132.34,77.074-212.524 c-8.101-42.81-30.305-85.119-65.997-125.754c-12.964-14.759-36.003-14.748-48.946-0.016 c-28.645,32.607-48.657,66.371-59.602,100.512c-21.999-13.018-47.7-23.197-76.569-30.307c-19.338-4.763-38.383,8.699-40.354,28.53 C26.197,262.501,90.89,324.677,147.416,354.042c3.92,2.036,8.75,0.51,10.787-3.411c2.037-3.921,0.51-8.75-3.411-10.787 c-52.141-27.086-111.791-84.677-99.863-205.213c1.007-10.132,10.713-17.01,20.606-14.574c31.115,7.663,58.223,19.013,80.571,33.735 c4.863,3.204,10.891,0.586,12.257-4.539c9.392-35.245,29.306-70.362,59.188-104.378c6.581-7.492,18.316-7.487,24.904,0.014 c128.735,146.565,37.449,269.122-12.476,318.519c-30.274-29.828-76.759-87.727-78.002-162.831 c-0.073-4.417-3.698-7.933-8.131-7.867c-4.417,0.073-7.939,3.714-7.867,8.131c1.382,83.483,54.096,146.516,85.999,177.099 c-0.353,20.737-7.099,36.575-20.104,47.086c-20.129,16.267-55.786,20.072-97.831,10.438c-19.181-4.396-48.632-19.874-85.688-1.511 c-5.361,2.657-11.689-0.859-12.186-6.844c-1.888-22.74,12.042-43.926,33.548-51.893c13.4,11.096,27.797,19.551,43.11,25.275 c20.238,7.653,36.036,9.525,56.788,9.196c15.85-0.254,30.814-2.572,45.747-7.085c4.229-1.278,6.622-5.743,5.343-9.972 c-1.278-4.229-5.744-6.622-9.972-5.344c-13.494,4.078-27.027,6.173-41.373,6.403c-17.347,0.275-31.911-0.993-50.901-8.174 c-31.69-11.847-56.387-35.98-75.211-64.258c-5.791-8.704-2.122-20.58,7.548-24.52c4.092-1.667,6.058-6.335,4.391-10.427 c-1.667-4.092-6.334-6.058-10.427-4.391c-19.062,7.765-26.214,31.095-14.832,48.202c8.365,12.566,17.352,23.674,26.917,33.31 C12.89,375.664-2.037,401.187,0.226,428.434c1.427,17.192,19.743,27.533,35.235,19.857c30.84-15.283,54.311-1.971,75.01,2.771 c36.708,8.411,82.166,10.086,111.461-13.59c14.777-11.943,23.305-28.715,25.489-49.937 c61.607,30.736,128.694,32.482,182.835-12.326c21.516,7.959,35.456,29.153,33.567,51.902c-0.493,5.939-6.786,9.519-12.186,6.844 c-30.339-15.034-55.535-7.379-73.932-1.791c-31.306,9.51-74.736,14.144-102.884-2.498c-3.803-2.248-8.709-0.989-10.958,2.815 c-2.249,3.803-0.989,8.709,2.815,10.958c29.214,17.272,69.817,15.19,102.844,7.622c20.72-4.747,44.177-18.05,75.01-2.771 c15.523,7.691,33.811-2.693,35.235-19.856C482.032,401.183,467.102,375.655,443.143,363.426z"})),$={sm:32,md:48,lg:64};function Q({size:e="md",variant:a="light",className:g="",style:y={}}){const M=$[e],b={display:"inline-block",cursor:"pointer",transition:"all 250ms ease",borderRadius:"50%",...a==="dark"&&{backgroundColor:"rgba(255, 255, 255, 0.05)",padding:"8px"},...y};return N.jsx("a",{href:"https://getbodhi.app",target:"_blank",rel:"noopener noreferrer",title:"Powered by Bodhi","aria-label":"Powered by Bodhi - Visit getbodhi.app",className:g,style:b,onMouseEnter:S=>{S.currentTarget.style.transform="scale(1.1)",S.currentTarget.style.boxShadow="0 0 20px rgba(255, 164, 184, 0.6)"},onMouseLeave:S=>{S.currentTarget.style.transform="scale(1)",S.currentTarget.style.boxShadow="none"},children:N.jsx(Y,{width:M,height:M,style:{display:"block"}})})}const ee="production";Object.defineProperty(exports,"createApiError",{enumerable:!0,get:()=>s.createApiError});Object.defineProperty(exports,"createOperationError",{enumerable:!0,get:()=>s.createOperationError});Object.defineProperty(exports,"isApiResultError",{enumerable:!0,get:()=>s.isApiResultError});Object.defineProperty(exports,"isApiResultOperationError",{enumerable:!0,get:()=>s.isApiResultOperationError});Object.defineProperty(exports,"isApiResultSuccess",{enumerable:!0,get:()=>s.isApiResultSuccess});Object.defineProperty(exports,"isAuthError",{enumerable:!0,get:()=>s.isAuthError});Object.defineProperty(exports,"isAuthLoading",{enumerable:!0,get:()=>s.isAuthLoading});Object.defineProperty(exports,"isAuthenticated",{enumerable:!0,get:()=>s.isAuthenticated});Object.defineProperty(exports,"isClientReady",{enumerable:!0,get:()=>s.isClientReady});Object.defineProperty(exports,"isDirectState",{enumerable:!0,get:()=>s.isDirectState});Object.defineProperty(exports,"isExtensionState",{enumerable:!0,get:()=>s.isExtensionState});Object.defineProperty(exports,"isOperationError",{enumerable:!0,get:()=>s.isOperationError});Object.defineProperty(exports,"isWebUIClient",{enumerable:!0,get:()=>s.isWebUIClient});exports.BodhiBadge=Q;exports.BodhiProvider=Z;exports.BodhiReactContext=z;exports.ClientCtxState=X;exports.INITIALIZING_CLIENT_CONTEXT_STATE=U;exports.INITIAL_CLIENT_CONTEXT_STATE=j;exports.REACT_CORE_BUILD_MODE=ee;exports.clientStateToContextState=V;exports.isClientCtxInitialized=q;exports.isClientCtxInitializing=F;exports.isClientCtxNotInitialized=G;exports.isClientCtxReady=P;exports.isOverallReady=H;exports.useBodhi=J;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const N=require("react/jsx-runtime"),s=require("@bodhiapp/bodhi-js-core"),r=require("react"),O=require("@bodhiapp/setup-modal-types");function W(e){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const p in e)if(p!=="default"){const y=Object.getOwnPropertyDescriptor(e,p);Object.defineProperty(c,p,y.get?y:{enumerable:!0,get:()=>e[p]})}}return c.default=e,Object.freeze(c)}const l=W(r);function K({client:e,modalHtmlPath:c,hideSetup:p,onSetupReady:y,setupState:w,basePath:b="/",logLevel:S="warn"}){const R=w!=="ready",_=r.useMemo(()=>new s.Logger("SetupModalProcessor",S),[S]),u=r.useRef(null),C=r.useMemo(()=>new s.BodhiClientUserPrefsManager(s.createStoragePrefixWithBasePath(b,"bodhijs:")),[b]),E=r.useRef(null),m=r.useCallback(t=>t==="direct"?"lna":t==="extension"?"extension":null,[]),L=r.useCallback(t=>t.extension==="ready"?{status:"ready",version:"unknown",id:t.extensionId}:t.extension==="not-found"?{status:"not-installed",error:{message:"Extension not found",code:"ext-not-installed"}}:{status:"unreachable",error:{message:"Client not initialized",code:"ext-connection-failed"}},[]),A=r.useCallback(t=>{if(t.server.status==="pending-extension-ready")return{status:"pending-extension-ready",error:{message:"Extension not ready",code:"server-pending-ext-ready"}};const n=t.server;switch(n.status){case"ready":return{status:"ready",version:n.version||"unknown"};case"setup":return{status:"setup",version:n.version||"unknown",error:{message:n.error?.message||"Setup required",code:"server-in-setup-status"}};case"resource_admin":return{status:"resource_admin",version:n.version||"unknown",error:{message:n.error?.message||"Resource admin required",code:"server-in-admin-status"}};case"tenant_selection":return{status:"tenant_selection",version:n.version||"unknown",error:{message:"Tenant selection required",code:"server-in-tenant-selection-status"}};case"error":return{status:"error",error:{message:n.error?.message||"Unknown error",code:"server-unexpected-error"}};case"not-reachable":return{status:"unreachable",error:{message:n.error?.message||"Server not reachable",code:"server-conn-refused"}};default:return{status:"unreachable",error:{message:"Unknown server status",code:"server-unexpected-error"}}}},[]),M=r.useCallback(t=>{if(t.server.status==="not-connected")return{status:"pending-lna-ready"};const n=t.server;switch(n.status){case"ready":return{status:"ready",version:n.version||"unknown"};case"setup":return{status:"setup",version:n.version||"unknown"};case"resource_admin":return{status:"resource_admin",version:n.version||"unknown"};case"tenant_selection":return{status:"tenant_selection",version:n.version||"unknown"};case"error":case"not-reachable":return{status:"error",error:{message:n.error?.message||"Connection error"}};default:return{status:"error",error:{message:"Unknown server status"}}}},[]),I=r.useCallback((t,n)=>{if(t.server.status!=="pending-extension-ready"){const o=t.server.status;if(o==="ready"||o==="setup"||o==="resource_admin"||o==="tenant_selection")return!0}if(n.server.status!=="not-connected"){const o=n.server.status;if(o==="ready"||o==="setup"||o==="resource_admin"||o==="tenant_selection")return!0}return!1},[]),x=r.useCallback((t,n,o)=>{if(n==="skipped")return{status:"skipped",serverUrl:o};if(t.server.status!=="not-connected"){const d=t.server;return d.status==="ready"||d.status==="setup"||d.status==="resource_admin"||d.status==="tenant_selection"?{status:"granted",serverUrl:o}:{status:"unreachable",serverUrl:o,error:{message:d.error?.message||"Server unreachable",code:"lna-unreachable"}}}return n==="granted"?{status:"granted",serverUrl:o}:{status:"prompt",serverUrl:o}},[]),h=r.useCallback(async(t=!1)=>{const n=s.detectBrowser().type,o=s.detectOS().type;let d=await e.getExtensionState();(d.extension==="not-initialized"||t)&&(d=await e.testExtensionConnectivity());let f=await e.getDirectState();const T=C.getDirectStatus();T==="granted"&&(f.server.status==="not-connected"||t)&&(f=await e.testDirectConnectivity());const i=s.getServerUrl(f)||"http://localhost:1135",v=x(f,T,i);return e.getConnectionMode()===null&&(s.isDirectServerReady(f)?await e.setConnectionMode("direct"):s.isExtensionServerReady(d)&&await e.setConnectionMode("extension")),C.isServerInstallConfirmed()||I(d,f)&&C.setServerInstallConfirmed(!0),{extension:L(d),server:A(d),lna:v,lnaServer:M(f),env:{browser:n,os:o},browsers:s.BROWSER_CONFIGS,os:s.OS_CONFIGS,userConfirmations:{serverInstall:C.isServerInstallConfirmed()},selectedConnection:m(e.getConnectionMode())}},[e,C,L,A,M,m,x,I]),g=r.useCallback(()=>{if(!E.current)throw new Error("Cannot get state: currentStateRef is null");return{...E.current,userConfirmations:{serverInstall:C.isServerInstallConfirmed()},selectedConnection:m(e.getConnectionMode())}},[C,e,m]),k=r.useMemo(()=>({[O.MSG.MODAL_READY]:async()=>(_.info("MODAL_READY: returning current state or default"),E.current?{setupState:g()}:{setupState:O.DEFAULT_SETUP_STATE}),[O.MSG.MODAL_REFRESH]:async()=>{_.info("MODAL_REFRESH: refreshing state");const t=await h(!0);E.current=t;const n=g();return _.info(`MODAL_REFRESH: state refreshed
|
|
2
|
+
`,JSON.stringify(n,null,2)),u.current?.updateState(g()),{setupState:n}},[O.MSG.MODAL_LNA_CONNECT]:async t=>{const n=t.payload.serverUrl;console.log("[SetupModalProcessor] LNA connect:",n);const o=await e.testDirectConnectivity(n);if(o.server.status!=="not-connected"){const f=o.server.status;if(f==="ready"||f==="setup"||f==="resource_admin"||f==="tenant_selection"){C.setDirectStatus("granted"),e.getConnectionMode()===null&&await e.setConnectionMode("direct");const T=await h();return E.current=T,u.current?.updateState(g()),{success:!0}}}const d=await h();return E.current=d,u.current?.updateState(g()),{success:!1}},[O.MSG.MODAL_LNA_SKIP]:async()=>{C.setDirectStatus("skipped");const t=await h();return E.current=t,u.current?.updateState(g()),{success:!0}},[O.MSG.MODAL_CLOSE]:()=>{p()},[O.MSG.MODAL_COMPLETE]:()=>{p()},[O.MSG.MODAL_CONFIRM_SERVER_INSTALL]:t=>(C.setServerInstallConfirmed(t.payload.confirmed),u.current?.updateState(g()),{success:!0}),[O.MSG.MODAL_SELECT_CONNECTION]:async t=>{const o=t.payload.connection==="lna"?"direct":"extension";return await e.setConnectionMode(o),u.current?.updateState(g()),{success:!0}}}),[_,e,C,h,g,M,p]);return r.useEffect(()=>(u.current=new s.OnboardingModal({modalHtmlPath:c,handlers:k}),()=>{u.current?.destroy(),u.current=null}),[c,k]),r.useEffect(()=>{R&&u.current?(u.current.showLoading(),h(!0).then(t=>{E.current=t,u.current?.updateState(t),y?.()}).catch(t=>{console.error("[SetupModalProcessor] buildSetupState failed:",t)})):!R&&u.current&&u.current.destroy()},[R,h,y]),null}const j={status:"not-initialized",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null},U={status:"initializing",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null};function G(e){return e.status==="not-initialized"}function q(e){return e.status==="initializing"}function F(e){return e.status!=="not-initialized"&&e.status!=="initializing"}function P(e){return e.status==="ready"}function H(e){return P(e)&&e.server.status==="ready"}function V(e){return s.isExtensionState(e)?{status:e.extension==="not-initialized"?"initializing":e.extension==="not-found"?"extension-not-found":"ready",mode:"extension",extensionId:e.extensionId,url:null,server:e.server,error:e.server.error}:{status:e.url===null?"direct-not-connected":"ready",mode:"direct",extensionId:null,url:e.url,server:e.server,error:e.server.error}}const X={isNotInitialized:G,isInitializing:q,isInitialized:F,isReady:P,isOverallReady:H},z=r.createContext(null);z.displayName="BodhiContext";function Z({children:e,client:c,modalHtmlPath:p,handleCallback:y=!0,callbackPath:w,basePath:b="/",logLevel:S="warn"}){const R=b==="/"?"":b.replace(/\/$/,""),_=w??`${R}/callback`,u=r.useMemo(()=>new s.Logger("BodhiProvider",S),[S]),C=r.useRef(!1),E=r.useRef(!1),[m,L]=r.useState(j),[A,M]=r.useState(s.INITIAL_AUTH_STATE),[I,x]=r.useState(!1),[h,g]=r.useState("ready");r.useEffect(()=>{const a=i=>{switch(i.type){case"client-state":L(V(i.state));break;case"auth-state":M(i.state),x(!1);break}};return c.setStateCallback(a),()=>{c.setStateCallback(s.NOOP_STATE_CALLBACK)}},[c]);const k=r.useCallback(async()=>{g("loading")},[]),t=r.useCallback(()=>{g("ready")},[]),n=r.useCallback(()=>{g("loaded")},[]),o=r.useCallback(async a=>{L(U);try{await c.init(a||{})}catch(i){u.error("Init failed:",i)}},[c,u]);r.useEffect(()=>{if(E.current)return;E.current=!0,(async()=>{if(await o(),!y)return;const i=new URL(window.location.href);if(i.pathname!==_)return;const v=i.searchParams.get("code"),B=i.searchParams.get("state");!v||!B||C.current||(C.current=!0,s.isWebUIClient(c)&&(x(!0),c.handleOAuthCallback(v,B).then(()=>{window.history.replaceState({},"",b)}).catch(D=>{u.error("OAuth callback failed:",D),M({status:"error",user:null,accessToken:null,error:{message:D instanceof Error?D.message:"OAuth callback failed",code:"OAUTH_CALLBACK_FAILED"}}),x(!1),window.history.replaceState({},"",b)})))})()},[o,c,y,_,b]);const d=r.useCallback(async a=>{x(!0);try{const i=a?{...a.userRole&&{userRole:a.userRole},...a.requested&&{requested:a.requested},...a.flowType&&{flowType:a.flowType},...a.redirectUrl&&{redirectUrl:a.redirectUrl},...a.onProgress&&{onProgress:a.onProgress},...a.pollIntervalMs&&{pollIntervalMs:a.pollIntervalMs},...a.pollTimeoutMs&&{pollTimeoutMs:a.pollTimeoutMs}}:void 0,v=i&&Object.keys(i).length>0?i:void 0;await c.login(v)}catch(i){const v={status:"error",user:null,accessToken:null,error:{message:i instanceof Error?i.message:"Login failed",code:"LOGIN_FAILED"}};return M(v),x(!1),v}},[c]),f=r.useCallback(async()=>{try{await c.logout()}catch(a){M({status:"error",user:null,accessToken:null,error:{message:a instanceof Error?a.message:"Logout failed",code:"LOGOUT_FAILED"}})}},[c]),T=r.useMemo(()=>{const a=m.status==="ready",i=m.server.status==="ready";return{client:c,clientState:m,auth:A,isAuthLoading:I,login:d,logout:f,showSetup:k,hideSetup:t,setupState:h,isAuthenticated:A.status==="authenticated",canLogin:a&&!I,isReady:a,isServerReady:i,isOverallReady:a&&i,isInitializing:m.status==="initializing",isExtension:m.mode==="extension",isDirect:m.mode==="direct"}},[c,m,A,I,h,d,f,k,t]);return N.jsxs(z.Provider,{value:T,children:[N.jsx(K,{client:c,modalHtmlPath:p,hideSetup:t,onSetupReady:n,setupState:h,basePath:b,logLevel:S}),e]})}function J(){const e=r.useContext(z);if(!e)throw new Error("useBodhi must be used within BodhiProvider");return e}const Y=e=>l.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 479.995 479.995",width:"480px",height:"480px",...e},l.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.56l-0.01-0.01c0-0.01,0.01-0.01,0.01-0.02c-4.64-8.78-65.7-144.8-212.22-85.2 c-14.36,5.85-19.78,23.45-11.19,36.36c11.11,16.69,22.86,30.01,34.91,40.53c-27.85,7.89-45.6,33.8-43.3,61.55 c0.96,11.6,13.29,18.52,23.71,13.35c33.99-16.84,60.03-2.51,80.35,2.14c56.68,12.99,113.71,4.53,125.52-46.29 c0.52-2.22,0.95-4.51,1.28-6.89c0.01-0.04,0.01-0.08,0.02-0.12c0.066-0.492,0.126-0.978,0.181-1.458 c0.455-3.631,0.712-7.438,0.739-11.452c-0.02-1.44-0.02-2.01,0-2.25v-0.09c0-0.02,0-0.04,0.01-0.05c0-0.02,0.01-0.03,0.02-0.06 c0-0.01,0.01-0.01,0.01-0.02C240.018,374.569,240.008,374.56,239.998,374.56z"}),l.createElement("path",{fill:"#ffa4b8",d:"M471.798,427.769c-0.96,11.6-13.29,18.52-23.71,13.35c-33.99-16.84-60.03-2.51-80.35,2.14 c-63.41,14.53-127.25,2.22-127.74-66.21c0.033-2.642-0.044-2.302,0.04-2.47c-0.02-0.01-0.03-0.02-0.04-0.02l0.01-0.01 c0-0.01-0.01-0.01-0.01-0.02c4.64-8.78,65.7-144.8,212.22-85.2c14.36,5.85,19.78,23.45,11.19,36.36 c-11.11,16.69-22.86,30.01-34.91,40.53C456.348,374.109,474.098,400.019,471.798,427.769z"}),l.createElement("path",{fill:"#befa91",d:"M428.498,366.219c27.85,7.89,45.6,33.8,43.3,61.55c-0.96,11.6-13.29,18.52-23.71,13.35 c-33.99-16.84-60.03-2.51-80.35,2.14c-63.41,14.53-127.928,2.222-127.74-66.21c0.007-2.683-0.02-2.351,0.04-2.47 C248.598,379.129,345.858,438.329,428.498,366.219z"}),l.createElement("path",{fill:"#befa91",d:"M51.498,366.219c82.76,72.22,180.18,12.74,188.5,8.34c0.01,0,0.02,0.01,0.04,0.02 c-0.058,0.116-0.047-0.169-0.04,2.47c0.188,68.432-64.33,80.74-127.74,66.21c-20.32-4.65-46.36-18.98-80.35-2.14 c-10.42,5.17-22.75-1.75-23.71-13.35C5.898,400.019,23.648,374.109,51.498,366.219z"}),l.createElement("path",{fill:"#ffbfcb",d:"M235.228,365.299c-32.29-36.09-89.98-73-179.74-36.49c-1.979,0.805-3.787,1.834-5.413,3.042 c-10.569,7.856-25.473,5.765-32.82-5.164c-0.223-0.331-0.445-0.664-0.667-0.997c-8.59-12.91-3.17-30.51,11.19-36.36 C155.168,237.509,217.948,333.56,235.228,365.299z"}),l.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.549c-12.85-2.2-214.54-23.33-193.03-240.71c1.49-14.99,15.86-25.15,30.48-21.55 c108.49,26.72,149.07,91.39,162.55,149.92C252.768,317.699,241.178,367.679,239.998,374.549z"}),l.createElement("path",{fill:"#ffbfcb",d:"M193.698,174.638c11.866,12.406-3.013,31.792-18.056,23.52 c-21.875-12.028-50.044-10.573-70.207,3.701c-24.832,17.579-59.398-0.365-60.013-30.784c-0.237-11.724,0.248-24.123,1.545-37.237 c1.49-14.99,15.86-25.15,30.48-21.55C131.23,125.537,168.324,148.11,193.698,174.638z"}),l.createElement("path",{fill:"#ffa4b8",d:"M221.538,39.599c9.78-11.13,27.15-11.12,36.93,0.01c157.02,178.77-7.48,323.95-18.47,334.94 C229.988,364.549,63.948,218.989,221.538,39.599z"}),l.createElement("path",{fill:"#ffbfcb",d:"M261.523,43.131c9.452,11.033,8.166,27.623-2.74,37.221c-0.784,0.69-1.535,1.439-2.245,2.247 c-35.942,40.915-55.05,80.07-63.012,116.258c-5.176,23.523-39.936,19.717-39.551-4.366c0.741-46.282,18.411-98.941,67.563-154.892 c9.78-11.13,27.15-11.12,36.93,0.01C259.5,40.785,260.518,41.959,261.523,43.131z"}),l.createElement("path",{fill:"#ffa4b8",d:"M239.998,374.549c-1.18-6.87-12.77-56.85,0-112.34c13.48-58.53,54.06-123.2,162.55-149.92 c14.62-3.6,28.99,6.56,30.48,21.55C454.538,351.219,252.848,372.349,239.998,374.549z"}),l.createElement("path",{fill:"#ff8ca5",d:"M239.998,374.549c-3.115-0.536-17.362-2.183-36.835-7.483c-3.181-0.866-6.028-2.682-8.145-5.209 c-49.098-58.608-75.675-130.75-61.047-205.793c2.165-11.107,14.881-16.444,24.408-10.337c0.756,0.485,1.506,0.972,2.249,1.462 C126.798,274.139,232.088,366.649,239.998,374.549z"}),l.createElement("path",{fill:"#ff8ca5",d:"M281.608,365.729c-21.9,6.37-38.24,8.25-41.61,8.82c8.67-8.67,112.98-100.94,79.35-227.34v-0.01 c0.742-0.489,1.49-0.975,2.244-1.459c9.551-6.123,22.265-0.733,24.422,10.406C369.565,277.734,281.608,363.204,281.608,365.729z"}),l.createElement("path",{fill:"#ff8ca5",d:"M417.451,302.932c-32.211,44.193-80.706,72.823-134.571,87.345c-3.396,0.916-6.999,0.754-10.3-0.463 c-20.772-7.664-31.911-15.254-32.583-15.254c0.826-0.825,112.667-9.463,166.4-98.31C419.37,278.279,424.743,292.927,417.451,302.932 z"}),l.createElement("path",{fill:"#ff8ca5",d:"M62.565,302.932c32.211,44.193,80.705,72.823,134.571,87.345c3.396,0.916,6.999,0.754,10.3-0.463 c20.772-7.664,31.911-15.254,32.583-15.254c-0.828-0.828-112.665-9.458-166.4-98.31C60.646,278.279,55.273,292.927,62.565,302.932z"}),l.createElement("path",{fill:"#9ceb63",d:"M433.464,393.091c-52.749,39.415-118.979,42.09-182.861,13.657 c-4.441-1.977-7.606-6.011-8.633-10.763c-1.552-7.18-1.884-14.238-1.973-21.326c0.172-0.345,9.566,5.934,26.76,12.89 c36.31,14.71,102.75,30.15,161.74-21.33C440.977,369.752,443.403,385.664,433.464,393.091z"}),l.createElement("path",{fill:"#9ceb63",d:"M240.038,374.579c0,0.01-0.01,0.01-0.01,0.02s-0.01,0.03-0.01,0.05c0,0,0,0,0,0.01 c-0.01,0.03-0.01,0.06-0.02,0.1v0.04c-0.13,1.3,0.09,7.59-0.92,15.16c-0.01,0.04-0.01,0.08-0.02,0.12 c-0.26,1.91-0.59,3.91-1.03,5.92c-0.07,0.33-0.15,0.65-0.25,0.97c-1.23,4.33-4.28,7.95-8.41,9.79 c-63.06,28.05-129.47,26.21-182.79-13.63c-9.94-7.43-7.63-23.36,4.92-26.91c13.1,11.46,28.11,20.79,44.16,26.79 c19.78,7.48,34.99,8.98,53.83,8.68c34.33-0.55,60.1-11.03,90.51-27.13C240.008,374.56,240.018,374.569,240.038,374.579z"}),l.createElement("path",{d:"M443.143,363.426c9.579-9.648,18.604-20.804,26.926-33.305c11.399-17.132,4.201-40.447-14.837-48.202 c-12.321-5.012-24.515-8.844-36.391-11.454c17.945-34.197,27.974-78.94,22.188-137.413c-1.925-19.503-20.802-33.354-40.394-28.53 c-17.952,4.421-34.806,10.063-50.093,16.768c-4.046,1.775-5.888,6.494-4.113,10.54c1.774,4.046,6.493,5.887,10.54,4.113 c14.45-6.338,30.429-11.682,47.492-15.885c9.885-2.435,19.599,4.434,20.607,14.573c9.088,90.121-21.147,164.341-99.823,205.213 c-3.921,2.037-5.448,6.866-3.411,10.787c2.043,3.933,6.879,5.442,10.787,3.411c27.191-14.125,56.267-35.849,77.701-68.994 c12.564,2.375,25.617,6.296,38.878,11.69c9.68,3.943,13.334,15.824,7.549,24.518c-10.205,15.33-21.482,28.43-33.516,38.936 c-49.396,43.107-111.979,41.39-169.834,12.419c56.638-56.971,92.247-132.34,77.074-212.524 c-8.101-42.81-30.305-85.119-65.997-125.754c-12.964-14.759-36.003-14.748-48.946-0.016 c-28.645,32.607-48.657,66.371-59.602,100.512c-21.999-13.018-47.7-23.197-76.569-30.307c-19.338-4.763-38.383,8.699-40.354,28.53 C26.197,262.501,90.89,324.677,147.416,354.042c3.92,2.036,8.75,0.51,10.787-3.411c2.037-3.921,0.51-8.75-3.411-10.787 c-52.141-27.086-111.791-84.677-99.863-205.213c1.007-10.132,10.713-17.01,20.606-14.574c31.115,7.663,58.223,19.013,80.571,33.735 c4.863,3.204,10.891,0.586,12.257-4.539c9.392-35.245,29.306-70.362,59.188-104.378c6.581-7.492,18.316-7.487,24.904,0.014 c128.735,146.565,37.449,269.122-12.476,318.519c-30.274-29.828-76.759-87.727-78.002-162.831 c-0.073-4.417-3.698-7.933-8.131-7.867c-4.417,0.073-7.939,3.714-7.867,8.131c1.382,83.483,54.096,146.516,85.999,177.099 c-0.353,20.737-7.099,36.575-20.104,47.086c-20.129,16.267-55.786,20.072-97.831,10.438c-19.181-4.396-48.632-19.874-85.688-1.511 c-5.361,2.657-11.689-0.859-12.186-6.844c-1.888-22.74,12.042-43.926,33.548-51.893c13.4,11.096,27.797,19.551,43.11,25.275 c20.238,7.653,36.036,9.525,56.788,9.196c15.85-0.254,30.814-2.572,45.747-7.085c4.229-1.278,6.622-5.743,5.343-9.972 c-1.278-4.229-5.744-6.622-9.972-5.344c-13.494,4.078-27.027,6.173-41.373,6.403c-17.347,0.275-31.911-0.993-50.901-8.174 c-31.69-11.847-56.387-35.98-75.211-64.258c-5.791-8.704-2.122-20.58,7.548-24.52c4.092-1.667,6.058-6.335,4.391-10.427 c-1.667-4.092-6.334-6.058-10.427-4.391c-19.062,7.765-26.214,31.095-14.832,48.202c8.365,12.566,17.352,23.674,26.917,33.31 C12.89,375.664-2.037,401.187,0.226,428.434c1.427,17.192,19.743,27.533,35.235,19.857c30.84-15.283,54.311-1.971,75.01,2.771 c36.708,8.411,82.166,10.086,111.461-13.59c14.777-11.943,23.305-28.715,25.489-49.937 c61.607,30.736,128.694,32.482,182.835-12.326c21.516,7.959,35.456,29.153,33.567,51.902c-0.493,5.939-6.786,9.519-12.186,6.844 c-30.339-15.034-55.535-7.379-73.932-1.791c-31.306,9.51-74.736,14.144-102.884-2.498c-3.803-2.248-8.709-0.989-10.958,2.815 c-2.249,3.803-0.989,8.709,2.815,10.958c29.214,17.272,69.817,15.19,102.844,7.622c20.72-4.747,44.177-18.05,75.01-2.771 c15.523,7.691,33.811-2.693,35.235-19.856C482.032,401.183,467.102,375.655,443.143,363.426z"})),$={sm:32,md:48,lg:64};function Q({size:e="md",variant:c="light",className:p="",style:y={}}){const w=$[e],b={display:"inline-block",cursor:"pointer",transition:"all 250ms ease",borderRadius:"50%",...c==="dark"&&{backgroundColor:"rgba(255, 255, 255, 0.05)",padding:"8px"},...y};return N.jsx("a",{href:"https://getbodhi.app",target:"_blank",rel:"noopener noreferrer",title:"Powered by Bodhi","aria-label":"Powered by Bodhi - Visit getbodhi.app",className:p,style:b,onMouseEnter:S=>{S.currentTarget.style.transform="scale(1.1)",S.currentTarget.style.boxShadow="0 0 20px rgba(255, 164, 184, 0.6)"},onMouseLeave:S=>{S.currentTarget.style.transform="scale(1)",S.currentTarget.style.boxShadow="none"},children:N.jsx(Y,{width:w,height:w,style:{display:"block"}})})}const ee="production";Object.defineProperty(exports,"createApiError",{enumerable:!0,get:()=>s.createApiError});Object.defineProperty(exports,"createOperationError",{enumerable:!0,get:()=>s.createOperationError});Object.defineProperty(exports,"isApiResultError",{enumerable:!0,get:()=>s.isApiResultError});Object.defineProperty(exports,"isApiResultOperationError",{enumerable:!0,get:()=>s.isApiResultOperationError});Object.defineProperty(exports,"isApiResultSuccess",{enumerable:!0,get:()=>s.isApiResultSuccess});Object.defineProperty(exports,"isAuthError",{enumerable:!0,get:()=>s.isAuthError});Object.defineProperty(exports,"isAuthLoading",{enumerable:!0,get:()=>s.isAuthLoading});Object.defineProperty(exports,"isAuthenticated",{enumerable:!0,get:()=>s.isAuthenticated});Object.defineProperty(exports,"isClientReady",{enumerable:!0,get:()=>s.isClientReady});Object.defineProperty(exports,"isDirectState",{enumerable:!0,get:()=>s.isDirectState});Object.defineProperty(exports,"isExtensionState",{enumerable:!0,get:()=>s.isExtensionState});Object.defineProperty(exports,"isOperationError",{enumerable:!0,get:()=>s.isOperationError});Object.defineProperty(exports,"isWebUIClient",{enumerable:!0,get:()=>s.isWebUIClient});exports.BodhiBadge=Q;exports.BodhiProvider=Z;exports.BodhiReactContext=z;exports.ClientCtxState=X;exports.INITIALIZING_CLIENT_CONTEXT_STATE=U;exports.INITIAL_CLIENT_CONTEXT_STATE=j;exports.REACT_CORE_BUILD_MODE=ee;exports.clientStateToContextState=V;exports.isClientCtxInitialized=F;exports.isClientCtxInitializing=q;exports.isClientCtxNotInitialized=G;exports.isClientCtxReady=P;exports.isOverallReady=H;exports.useBodhi=J;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Logger as
|
|
3
|
-
import { createApiError as
|
|
1
|
+
import { jsxs as V, jsx as P } from "react/jsx-runtime";
|
|
2
|
+
import { Logger as q, BodhiClientUserPrefsManager as W, createStoragePrefixWithBasePath as j, detectBrowser as K, detectOS as X, getServerUrl as Y, isDirectServerReady as Z, isExtensionServerReady as $, OS_CONFIGS as J, BROWSER_CONFIGS as Q, OnboardingModal as ee, BACKEND_SERVER_NOT_CONNECTED as G, isExtensionState as te, INITIAL_AUTH_STATE as re, NOOP_STATE_CALLBACK as ne, isWebUIClient as se } from "@bodhiapp/bodhi-js-core";
|
|
3
|
+
import { createApiError as Te, createOperationError as Oe, isApiResultError as Le, isApiResultOperationError as Re, isApiResultSuccess as ke, isAuthError as ze, isAuthLoading as De, isAuthenticated as Ne, isClientReady as Be, isDirectState as Pe, isExtensionState as Ue, isOperationError as Fe, isWebUIClient as qe } from "@bodhiapp/bodhi-js-core";
|
|
4
4
|
import * as i from "react";
|
|
5
|
-
import { useMemo as
|
|
5
|
+
import { useMemo as k, useRef as D, useCallback as f, useEffect as N, createContext as ae, useState as z, useContext as ce } from "react";
|
|
6
6
|
import { MSG as w, DEFAULT_SETUP_STATE as oe } from "@bodhiapp/setup-modal-types";
|
|
7
7
|
function ie({
|
|
8
8
|
client: e,
|
|
9
|
-
modalHtmlPath:
|
|
9
|
+
modalHtmlPath: a,
|
|
10
10
|
hideSetup: x,
|
|
11
|
-
onSetupReady:
|
|
12
|
-
setupState:
|
|
13
|
-
basePath:
|
|
14
|
-
logLevel:
|
|
11
|
+
onSetupReady: _,
|
|
12
|
+
setupState: M,
|
|
13
|
+
basePath: S = "/",
|
|
14
|
+
logLevel: g = "warn"
|
|
15
15
|
}) {
|
|
16
|
-
const
|
|
17
|
-
() => new j(
|
|
18
|
-
[
|
|
19
|
-
), h = D(null),
|
|
16
|
+
const O = M !== "ready", b = k(() => new q("SetupModalProcessor", g), [g]), o = D(null), d = k(
|
|
17
|
+
() => new W(j(S, "bodhijs:")),
|
|
18
|
+
[S]
|
|
19
|
+
), h = D(null), m = f(
|
|
20
20
|
(t) => t === "direct" ? "lna" : t === "extension" ? "extension" : null,
|
|
21
21
|
[]
|
|
22
|
-
),
|
|
22
|
+
), L = f((t) => t.extension === "ready" ? {
|
|
23
23
|
status: "ready",
|
|
24
24
|
version: "unknown",
|
|
25
25
|
// TODO: have ExtensionState also get extension version
|
|
@@ -30,7 +30,7 @@ function ie({
|
|
|
30
30
|
} : {
|
|
31
31
|
status: "unreachable",
|
|
32
32
|
error: { message: "Client not initialized", code: "ext-connection-failed" }
|
|
33
|
-
}, []),
|
|
33
|
+
}, []), A = f((t) => {
|
|
34
34
|
if (t.server.status === "pending-extension-ready")
|
|
35
35
|
return {
|
|
36
36
|
status: "pending-extension-ready",
|
|
@@ -49,15 +49,24 @@ function ie({
|
|
|
49
49
|
code: "server-in-setup-status"
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
case "
|
|
52
|
+
case "resource_admin":
|
|
53
53
|
return {
|
|
54
|
-
status: "
|
|
54
|
+
status: "resource_admin",
|
|
55
55
|
version: r.version || "unknown",
|
|
56
56
|
error: {
|
|
57
57
|
message: r.error?.message || "Resource admin required",
|
|
58
58
|
code: "server-in-admin-status"
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
+
case "tenant_selection":
|
|
62
|
+
return {
|
|
63
|
+
status: "tenant_selection",
|
|
64
|
+
version: r.version || "unknown",
|
|
65
|
+
error: {
|
|
66
|
+
message: "Tenant selection required",
|
|
67
|
+
code: "server-in-tenant-selection-status"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
61
70
|
case "error":
|
|
62
71
|
return {
|
|
63
72
|
status: "error",
|
|
@@ -92,8 +101,10 @@ function ie({
|
|
|
92
101
|
return { status: "ready", version: r.version || "unknown" };
|
|
93
102
|
case "setup":
|
|
94
103
|
return { status: "setup", version: r.version || "unknown" };
|
|
95
|
-
case "
|
|
96
|
-
return { status: "
|
|
104
|
+
case "resource_admin":
|
|
105
|
+
return { status: "resource_admin", version: r.version || "unknown" };
|
|
106
|
+
case "tenant_selection":
|
|
107
|
+
return { status: "tenant_selection", version: r.version || "unknown" };
|
|
97
108
|
case "error":
|
|
98
109
|
case "not-reachable":
|
|
99
110
|
return {
|
|
@@ -106,69 +117,69 @@ function ie({
|
|
|
106
117
|
error: { message: "Unknown server status" }
|
|
107
118
|
};
|
|
108
119
|
}
|
|
109
|
-
}, []),
|
|
120
|
+
}, []), I = f(
|
|
110
121
|
(t, r) => {
|
|
111
122
|
if (t.server.status !== "pending-extension-ready") {
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
123
|
+
const s = t.server.status;
|
|
124
|
+
if (s === "ready" || s === "setup" || s === "resource_admin" || s === "tenant_selection")
|
|
114
125
|
return !0;
|
|
115
126
|
}
|
|
116
127
|
if (r.server.status !== "not-connected") {
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
128
|
+
const s = r.server.status;
|
|
129
|
+
if (s === "ready" || s === "setup" || s === "resource_admin" || s === "tenant_selection")
|
|
119
130
|
return !0;
|
|
120
131
|
}
|
|
121
132
|
return !1;
|
|
122
133
|
},
|
|
123
134
|
[]
|
|
124
135
|
), y = f(
|
|
125
|
-
(t, r,
|
|
136
|
+
(t, r, s) => {
|
|
126
137
|
if (r === "skipped")
|
|
127
|
-
return { status: "skipped", serverUrl:
|
|
138
|
+
return { status: "skipped", serverUrl: s };
|
|
128
139
|
if (t.server.status !== "not-connected") {
|
|
129
140
|
const u = t.server;
|
|
130
|
-
return u.status === "ready" || u.status === "setup" || u.status === "
|
|
141
|
+
return u.status === "ready" || u.status === "setup" || u.status === "resource_admin" || u.status === "tenant_selection" ? { status: "granted", serverUrl: s } : {
|
|
131
142
|
status: "unreachable",
|
|
132
|
-
serverUrl:
|
|
143
|
+
serverUrl: s,
|
|
133
144
|
error: {
|
|
134
145
|
message: u.error?.message || "Server unreachable",
|
|
135
146
|
code: "lna-unreachable"
|
|
136
147
|
}
|
|
137
148
|
};
|
|
138
149
|
}
|
|
139
|
-
return r === "granted" ? { status: "granted", serverUrl:
|
|
150
|
+
return r === "granted" ? { status: "granted", serverUrl: s } : { status: "prompt", serverUrl: s };
|
|
140
151
|
},
|
|
141
152
|
[]
|
|
142
|
-
),
|
|
153
|
+
), v = f(
|
|
143
154
|
async (t = !1) => {
|
|
144
|
-
const r =
|
|
155
|
+
const r = K().type, s = X().type;
|
|
145
156
|
let u = await e.getExtensionState();
|
|
146
157
|
(u.extension === "not-initialized" || t) && (u = await e.testExtensionConnectivity());
|
|
147
|
-
let
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
return e.getConnectionMode() === null && (Z(
|
|
152
|
-
extension:
|
|
153
|
-
server:
|
|
154
|
-
lna:
|
|
155
|
-
lnaServer: E(
|
|
156
|
-
env: { browser: r, os:
|
|
158
|
+
let l = await e.getDirectState();
|
|
159
|
+
const T = d.getDirectStatus();
|
|
160
|
+
T === "granted" && (l.server.status === "not-connected" || t) && (l = await e.testDirectConnectivity());
|
|
161
|
+
const c = Y(l) || "http://localhost:1135", C = y(l, T, c);
|
|
162
|
+
return e.getConnectionMode() === null && (Z(l) ? await e.setConnectionMode("direct") : $(u) && await e.setConnectionMode("extension")), d.isServerInstallConfirmed() || I(u, l) && d.setServerInstallConfirmed(!0), {
|
|
163
|
+
extension: L(u),
|
|
164
|
+
server: A(u),
|
|
165
|
+
lna: C,
|
|
166
|
+
lnaServer: E(l),
|
|
167
|
+
env: { browser: r, os: s },
|
|
157
168
|
browsers: Q,
|
|
158
169
|
os: J,
|
|
159
|
-
userConfirmations: { serverInstall:
|
|
160
|
-
selectedConnection:
|
|
170
|
+
userConfirmations: { serverInstall: d.isServerInstallConfirmed() },
|
|
171
|
+
selectedConnection: m(e.getConnectionMode())
|
|
161
172
|
};
|
|
162
173
|
},
|
|
163
174
|
[
|
|
164
175
|
e,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
176
|
+
d,
|
|
177
|
+
L,
|
|
178
|
+
A,
|
|
168
179
|
E,
|
|
169
|
-
|
|
180
|
+
m,
|
|
170
181
|
y,
|
|
171
|
-
|
|
182
|
+
I
|
|
172
183
|
]
|
|
173
184
|
), p = f(() => {
|
|
174
185
|
if (!h.current)
|
|
@@ -177,41 +188,41 @@ function ie({
|
|
|
177
188
|
...h.current,
|
|
178
189
|
// Override userConfirmations from storage (in case updated outside buildSetupState)
|
|
179
190
|
userConfirmations: {
|
|
180
|
-
serverInstall:
|
|
191
|
+
serverInstall: d.isServerInstallConfirmed()
|
|
181
192
|
},
|
|
182
193
|
// Override selectedConnection from client (in case changed via handler)
|
|
183
|
-
selectedConnection:
|
|
194
|
+
selectedConnection: m(e.getConnectionMode())
|
|
184
195
|
};
|
|
185
|
-
}, [
|
|
196
|
+
}, [d, e, m]), R = k(
|
|
186
197
|
() => ({
|
|
187
|
-
[w.MODAL_READY]: async () => (
|
|
198
|
+
[w.MODAL_READY]: async () => (b.info("MODAL_READY: returning current state or default"), h.current ? { setupState: p() } : { setupState: oe }),
|
|
188
199
|
[w.MODAL_REFRESH]: async () => {
|
|
189
|
-
|
|
190
|
-
const t = await
|
|
200
|
+
b.info("MODAL_REFRESH: refreshing state");
|
|
201
|
+
const t = await v(!0);
|
|
191
202
|
h.current = t;
|
|
192
203
|
const r = p();
|
|
193
|
-
return
|
|
194
|
-
`, JSON.stringify(r, null, 2)),
|
|
204
|
+
return b.info(`MODAL_REFRESH: state refreshed
|
|
205
|
+
`, JSON.stringify(r, null, 2)), o.current?.updateState(p()), { setupState: r };
|
|
195
206
|
},
|
|
196
207
|
[w.MODAL_LNA_CONNECT]: async (t) => {
|
|
197
208
|
const r = t.payload.serverUrl;
|
|
198
209
|
console.log("[SetupModalProcessor] LNA connect:", r);
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
return h.current =
|
|
210
|
+
const s = await e.testDirectConnectivity(r);
|
|
211
|
+
if (s.server.status !== "not-connected") {
|
|
212
|
+
const l = s.server.status;
|
|
213
|
+
if (l === "ready" || l === "setup" || l === "resource_admin" || l === "tenant_selection") {
|
|
214
|
+
d.setDirectStatus("granted"), e.getConnectionMode() === null && await e.setConnectionMode("direct");
|
|
215
|
+
const T = await v();
|
|
216
|
+
return h.current = T, o.current?.updateState(p()), { success: !0 };
|
|
206
217
|
}
|
|
207
218
|
}
|
|
208
|
-
const u = await
|
|
209
|
-
return h.current = u,
|
|
219
|
+
const u = await v();
|
|
220
|
+
return h.current = u, o.current?.updateState(p()), { success: !1 };
|
|
210
221
|
},
|
|
211
222
|
[w.MODAL_LNA_SKIP]: async () => {
|
|
212
|
-
|
|
213
|
-
const t = await
|
|
214
|
-
return h.current = t,
|
|
223
|
+
d.setDirectStatus("skipped");
|
|
224
|
+
const t = await v();
|
|
225
|
+
return h.current = t, o.current?.updateState(p()), { success: !0 };
|
|
215
226
|
},
|
|
216
227
|
[w.MODAL_CLOSE]: () => {
|
|
217
228
|
x();
|
|
@@ -219,37 +230,37 @@ function ie({
|
|
|
219
230
|
[w.MODAL_COMPLETE]: () => {
|
|
220
231
|
x();
|
|
221
232
|
},
|
|
222
|
-
[w.MODAL_CONFIRM_SERVER_INSTALL]: (t) => (
|
|
233
|
+
[w.MODAL_CONFIRM_SERVER_INSTALL]: (t) => (d.setServerInstallConfirmed(t.payload.confirmed), o.current?.updateState(p()), { success: !0 }),
|
|
223
234
|
[w.MODAL_SELECT_CONNECTION]: async (t) => {
|
|
224
|
-
const
|
|
225
|
-
return await e.setConnectionMode(
|
|
235
|
+
const s = t.payload.connection === "lna" ? "direct" : "extension";
|
|
236
|
+
return await e.setConnectionMode(s), o.current?.updateState(p()), { success: !0 };
|
|
226
237
|
}
|
|
227
238
|
}),
|
|
228
|
-
[
|
|
239
|
+
[b, e, d, v, p, E, x]
|
|
229
240
|
);
|
|
230
|
-
return N(() => (
|
|
231
|
-
|
|
232
|
-
}), [
|
|
233
|
-
|
|
234
|
-
h.current = t,
|
|
241
|
+
return N(() => (o.current = new ee({ modalHtmlPath: a, handlers: R }), () => {
|
|
242
|
+
o.current?.destroy(), o.current = null;
|
|
243
|
+
}), [a, R]), N(() => {
|
|
244
|
+
O && o.current ? (o.current.showLoading(), v(!0).then((t) => {
|
|
245
|
+
h.current = t, o.current?.updateState(t), _?.();
|
|
235
246
|
}).catch((t) => {
|
|
236
247
|
console.error("[SetupModalProcessor] buildSetupState failed:", t);
|
|
237
|
-
})) : !
|
|
238
|
-
}, [
|
|
248
|
+
})) : !O && o.current && o.current.destroy();
|
|
249
|
+
}, [O, v, _]), null;
|
|
239
250
|
}
|
|
240
251
|
const ue = {
|
|
241
252
|
status: "not-initialized",
|
|
242
253
|
mode: null,
|
|
243
254
|
extensionId: null,
|
|
244
255
|
url: null,
|
|
245
|
-
server:
|
|
256
|
+
server: G,
|
|
246
257
|
error: null
|
|
247
258
|
}, le = {
|
|
248
259
|
status: "initializing",
|
|
249
260
|
mode: null,
|
|
250
261
|
extensionId: null,
|
|
251
262
|
url: null,
|
|
252
|
-
server:
|
|
263
|
+
server: G,
|
|
253
264
|
error: null
|
|
254
265
|
};
|
|
255
266
|
function de(e) {
|
|
@@ -261,13 +272,13 @@ function fe(e) {
|
|
|
261
272
|
function pe(e) {
|
|
262
273
|
return e.status !== "not-initialized" && e.status !== "initializing";
|
|
263
274
|
}
|
|
264
|
-
function
|
|
275
|
+
function H(e) {
|
|
265
276
|
return e.status === "ready";
|
|
266
277
|
}
|
|
267
|
-
function Se(e) {
|
|
268
|
-
return V(e) && e.server.status === "ready";
|
|
269
|
-
}
|
|
270
278
|
function ge(e) {
|
|
279
|
+
return H(e) && e.server.status === "ready";
|
|
280
|
+
}
|
|
281
|
+
function me(e) {
|
|
271
282
|
return te(e) ? {
|
|
272
283
|
status: e.extension === "not-initialized" ? "initializing" : e.extension === "not-found" ? "extension-not-found" : "ready",
|
|
273
284
|
mode: "extension",
|
|
@@ -288,63 +299,63 @@ const we = {
|
|
|
288
299
|
isNotInitialized: de,
|
|
289
300
|
isInitializing: fe,
|
|
290
301
|
isInitialized: pe,
|
|
291
|
-
isReady:
|
|
292
|
-
isOverallReady:
|
|
302
|
+
isReady: H,
|
|
303
|
+
isOverallReady: ge
|
|
293
304
|
}, U = ae(null);
|
|
294
305
|
U.displayName = "BodhiContext";
|
|
295
306
|
function xe({
|
|
296
307
|
children: e,
|
|
297
|
-
client:
|
|
308
|
+
client: a,
|
|
298
309
|
modalHtmlPath: x,
|
|
299
|
-
handleCallback:
|
|
300
|
-
callbackPath:
|
|
301
|
-
basePath:
|
|
302
|
-
logLevel:
|
|
310
|
+
handleCallback: _ = !0,
|
|
311
|
+
callbackPath: M,
|
|
312
|
+
basePath: S = "/",
|
|
313
|
+
logLevel: g = "warn"
|
|
303
314
|
}) {
|
|
304
|
-
const
|
|
315
|
+
const O = S === "/" ? "" : S.replace(/\/$/, ""), b = M ?? `${O}/callback`, o = k(() => new q("BodhiProvider", g), [g]), d = D(!1), h = D(!1), [m, L] = z(ue), [A, E] = z(re), [I, y] = z(!1), [v, p] = z("ready");
|
|
305
316
|
N(() => {
|
|
306
|
-
const
|
|
307
|
-
switch (
|
|
317
|
+
const n = (c) => {
|
|
318
|
+
switch (c.type) {
|
|
308
319
|
case "client-state":
|
|
309
|
-
|
|
320
|
+
L(me(c.state));
|
|
310
321
|
break;
|
|
311
322
|
case "auth-state":
|
|
312
|
-
E(
|
|
323
|
+
E(c.state), y(!1);
|
|
313
324
|
break;
|
|
314
325
|
}
|
|
315
326
|
};
|
|
316
|
-
return
|
|
317
|
-
|
|
327
|
+
return a.setStateCallback(n), () => {
|
|
328
|
+
a.setStateCallback(ne);
|
|
318
329
|
};
|
|
319
|
-
}, [
|
|
330
|
+
}, [a]);
|
|
320
331
|
const R = f(async () => {
|
|
321
332
|
p("loading");
|
|
322
333
|
}, []), t = f(() => {
|
|
323
334
|
p("ready");
|
|
324
335
|
}, []), r = f(() => {
|
|
325
336
|
p("loaded");
|
|
326
|
-
}, []),
|
|
327
|
-
async (
|
|
328
|
-
|
|
337
|
+
}, []), s = f(
|
|
338
|
+
async (n) => {
|
|
339
|
+
L(le);
|
|
329
340
|
try {
|
|
330
|
-
await
|
|
331
|
-
} catch (
|
|
332
|
-
|
|
341
|
+
await a.init(n || {});
|
|
342
|
+
} catch (c) {
|
|
343
|
+
o.error("Init failed:", c);
|
|
333
344
|
}
|
|
334
345
|
},
|
|
335
|
-
[
|
|
346
|
+
[a, o]
|
|
336
347
|
);
|
|
337
348
|
N(() => {
|
|
338
349
|
if (h.current) return;
|
|
339
350
|
h.current = !0, (async () => {
|
|
340
|
-
if (await
|
|
341
|
-
const
|
|
342
|
-
if (
|
|
343
|
-
const
|
|
344
|
-
!
|
|
345
|
-
window.history.replaceState({}, "",
|
|
351
|
+
if (await s(), !_) return;
|
|
352
|
+
const c = new URL(window.location.href);
|
|
353
|
+
if (c.pathname !== b) return;
|
|
354
|
+
const C = c.searchParams.get("code"), F = c.searchParams.get("state");
|
|
355
|
+
!C || !F || d.current || (d.current = !0, se(a) && (y(!0), a.handleOAuthCallback(C, F).then(() => {
|
|
356
|
+
window.history.replaceState({}, "", S);
|
|
346
357
|
}).catch((B) => {
|
|
347
|
-
|
|
358
|
+
o.error("OAuth callback failed:", B), E({
|
|
348
359
|
status: "error",
|
|
349
360
|
user: null,
|
|
350
361
|
accessToken: null,
|
|
@@ -352,113 +363,118 @@ function xe({
|
|
|
352
363
|
message: B instanceof Error ? B.message : "OAuth callback failed",
|
|
353
364
|
code: "OAUTH_CALLBACK_FAILED"
|
|
354
365
|
}
|
|
355
|
-
}), y(!1), window.history.replaceState({}, "",
|
|
366
|
+
}), y(!1), window.history.replaceState({}, "", S);
|
|
356
367
|
})));
|
|
357
368
|
})();
|
|
358
|
-
}, [
|
|
369
|
+
}, [s, a, _, b, S]);
|
|
359
370
|
const u = f(
|
|
360
|
-
async (
|
|
371
|
+
async (n) => {
|
|
361
372
|
y(!0);
|
|
362
373
|
try {
|
|
363
|
-
const
|
|
364
|
-
...
|
|
365
|
-
...
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
374
|
+
const c = n ? {
|
|
375
|
+
...n.userRole && { userRole: n.userRole },
|
|
376
|
+
...n.requested && { requested: n.requested },
|
|
377
|
+
...n.flowType && { flowType: n.flowType },
|
|
378
|
+
...n.redirectUrl && { redirectUrl: n.redirectUrl },
|
|
379
|
+
...n.onProgress && { onProgress: n.onProgress },
|
|
380
|
+
...n.pollIntervalMs && { pollIntervalMs: n.pollIntervalMs },
|
|
381
|
+
...n.pollTimeoutMs && { pollTimeoutMs: n.pollTimeoutMs }
|
|
382
|
+
} : void 0, C = c && Object.keys(c).length > 0 ? c : void 0;
|
|
383
|
+
await a.login(C);
|
|
384
|
+
} catch (c) {
|
|
385
|
+
const C = {
|
|
370
386
|
status: "error",
|
|
371
387
|
user: null,
|
|
372
388
|
accessToken: null,
|
|
373
389
|
error: {
|
|
374
|
-
message:
|
|
390
|
+
message: c instanceof Error ? c.message : "Login failed",
|
|
375
391
|
code: "LOGIN_FAILED"
|
|
376
392
|
}
|
|
377
393
|
};
|
|
378
|
-
return E(
|
|
394
|
+
return E(C), y(!1), C;
|
|
379
395
|
}
|
|
380
396
|
},
|
|
381
|
-
[
|
|
382
|
-
),
|
|
397
|
+
[a]
|
|
398
|
+
), l = f(async () => {
|
|
383
399
|
try {
|
|
384
|
-
await
|
|
385
|
-
} catch (
|
|
400
|
+
await a.logout();
|
|
401
|
+
} catch (n) {
|
|
386
402
|
E({
|
|
387
403
|
status: "error",
|
|
388
404
|
user: null,
|
|
389
405
|
accessToken: null,
|
|
390
406
|
error: {
|
|
391
|
-
message:
|
|
407
|
+
message: n instanceof Error ? n.message : "Logout failed",
|
|
392
408
|
code: "LOGOUT_FAILED"
|
|
393
409
|
}
|
|
394
410
|
});
|
|
395
411
|
}
|
|
396
|
-
}, [
|
|
397
|
-
const
|
|
412
|
+
}, [a]), T = k(() => {
|
|
413
|
+
const n = m.status === "ready", c = m.server.status === "ready";
|
|
398
414
|
return {
|
|
399
|
-
client:
|
|
400
|
-
clientState:
|
|
401
|
-
auth:
|
|
402
|
-
isAuthLoading:
|
|
415
|
+
client: a,
|
|
416
|
+
clientState: m,
|
|
417
|
+
auth: A,
|
|
418
|
+
isAuthLoading: I,
|
|
403
419
|
login: u,
|
|
404
|
-
logout:
|
|
420
|
+
logout: l,
|
|
405
421
|
showSetup: R,
|
|
406
422
|
hideSetup: t,
|
|
407
|
-
setupState:
|
|
423
|
+
setupState: v,
|
|
408
424
|
// Computed auth properties
|
|
409
|
-
isAuthenticated:
|
|
410
|
-
canLogin:
|
|
425
|
+
isAuthenticated: A.status === "authenticated",
|
|
426
|
+
canLogin: n && !I,
|
|
411
427
|
// Computed connection properties
|
|
412
|
-
isReady:
|
|
413
|
-
isServerReady:
|
|
414
|
-
isOverallReady:
|
|
415
|
-
isInitializing:
|
|
416
|
-
isExtension:
|
|
417
|
-
isDirect:
|
|
428
|
+
isReady: n,
|
|
429
|
+
isServerReady: c,
|
|
430
|
+
isOverallReady: n && c,
|
|
431
|
+
isInitializing: m.status === "initializing",
|
|
432
|
+
isExtension: m.mode === "extension",
|
|
433
|
+
isDirect: m.mode === "direct"
|
|
418
434
|
};
|
|
419
|
-
}, [
|
|
420
|
-
return /* @__PURE__ */
|
|
435
|
+
}, [a, m, A, I, v, u, l, R, t]);
|
|
436
|
+
return /* @__PURE__ */ V(U.Provider, { value: T, children: [
|
|
421
437
|
/* @__PURE__ */ P(
|
|
422
438
|
ie,
|
|
423
439
|
{
|
|
424
|
-
client:
|
|
440
|
+
client: a,
|
|
425
441
|
modalHtmlPath: x,
|
|
426
442
|
hideSetup: t,
|
|
427
443
|
onSetupReady: r,
|
|
428
|
-
setupState:
|
|
429
|
-
basePath:
|
|
430
|
-
logLevel:
|
|
444
|
+
setupState: v,
|
|
445
|
+
basePath: S,
|
|
446
|
+
logLevel: g
|
|
431
447
|
}
|
|
432
448
|
),
|
|
433
449
|
e
|
|
434
450
|
] });
|
|
435
451
|
}
|
|
436
|
-
function
|
|
452
|
+
function _e() {
|
|
437
453
|
const e = ce(U);
|
|
438
454
|
if (!e) throw new Error("useBodhi must be used within BodhiProvider");
|
|
439
455
|
return e;
|
|
440
456
|
}
|
|
441
|
-
const
|
|
457
|
+
const Se = (e) => /* @__PURE__ */ i.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 479.995 479.995", width: "480px", height: "480px", ...e }, /* @__PURE__ */ i.createElement("path", { fill: "#ffa4b8", d: "M239.998,374.56l-0.01-0.01c0-0.01,0.01-0.01,0.01-0.02c-4.64-8.78-65.7-144.8-212.22-85.2 c-14.36,5.85-19.78,23.45-11.19,36.36c11.11,16.69,22.86,30.01,34.91,40.53c-27.85,7.89-45.6,33.8-43.3,61.55 c0.96,11.6,13.29,18.52,23.71,13.35c33.99-16.84,60.03-2.51,80.35,2.14c56.68,12.99,113.71,4.53,125.52-46.29 c0.52-2.22,0.95-4.51,1.28-6.89c0.01-0.04,0.01-0.08,0.02-0.12c0.066-0.492,0.126-0.978,0.181-1.458 c0.455-3.631,0.712-7.438,0.739-11.452c-0.02-1.44-0.02-2.01,0-2.25v-0.09c0-0.02,0-0.04,0.01-0.05c0-0.02,0.01-0.03,0.02-0.06 c0-0.01,0.01-0.01,0.01-0.02C240.018,374.569,240.008,374.56,239.998,374.56z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ffa4b8", d: "M471.798,427.769c-0.96,11.6-13.29,18.52-23.71,13.35c-33.99-16.84-60.03-2.51-80.35,2.14 c-63.41,14.53-127.25,2.22-127.74-66.21c0.033-2.642-0.044-2.302,0.04-2.47c-0.02-0.01-0.03-0.02-0.04-0.02l0.01-0.01 c0-0.01-0.01-0.01-0.01-0.02c4.64-8.78,65.7-144.8,212.22-85.2c14.36,5.85,19.78,23.45,11.19,36.36 c-11.11,16.69-22.86,30.01-34.91,40.53C456.348,374.109,474.098,400.019,471.798,427.769z" }), /* @__PURE__ */ i.createElement("path", { fill: "#befa91", d: "M428.498,366.219c27.85,7.89,45.6,33.8,43.3,61.55c-0.96,11.6-13.29,18.52-23.71,13.35 c-33.99-16.84-60.03-2.51-80.35,2.14c-63.41,14.53-127.928,2.222-127.74-66.21c0.007-2.683-0.02-2.351,0.04-2.47 C248.598,379.129,345.858,438.329,428.498,366.219z" }), /* @__PURE__ */ i.createElement("path", { fill: "#befa91", d: "M51.498,366.219c82.76,72.22,180.18,12.74,188.5,8.34c0.01,0,0.02,0.01,0.04,0.02 c-0.058,0.116-0.047-0.169-0.04,2.47c0.188,68.432-64.33,80.74-127.74,66.21c-20.32-4.65-46.36-18.98-80.35-2.14 c-10.42,5.17-22.75-1.75-23.71-13.35C5.898,400.019,23.648,374.109,51.498,366.219z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ffbfcb", d: "M235.228,365.299c-32.29-36.09-89.98-73-179.74-36.49c-1.979,0.805-3.787,1.834-5.413,3.042 c-10.569,7.856-25.473,5.765-32.82-5.164c-0.223-0.331-0.445-0.664-0.667-0.997c-8.59-12.91-3.17-30.51,11.19-36.36 C155.168,237.509,217.948,333.56,235.228,365.299z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ffa4b8", d: "M239.998,374.549c-12.85-2.2-214.54-23.33-193.03-240.71c1.49-14.99,15.86-25.15,30.48-21.55 c108.49,26.72,149.07,91.39,162.55,149.92C252.768,317.699,241.178,367.679,239.998,374.549z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ffbfcb", d: "M193.698,174.638c11.866,12.406-3.013,31.792-18.056,23.52 c-21.875-12.028-50.044-10.573-70.207,3.701c-24.832,17.579-59.398-0.365-60.013-30.784c-0.237-11.724,0.248-24.123,1.545-37.237 c1.49-14.99,15.86-25.15,30.48-21.55C131.23,125.537,168.324,148.11,193.698,174.638z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ffa4b8", d: "M221.538,39.599c9.78-11.13,27.15-11.12,36.93,0.01c157.02,178.77-7.48,323.95-18.47,334.94 C229.988,364.549,63.948,218.989,221.538,39.599z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ffbfcb", d: "M261.523,43.131c9.452,11.033,8.166,27.623-2.74,37.221c-0.784,0.69-1.535,1.439-2.245,2.247 c-35.942,40.915-55.05,80.07-63.012,116.258c-5.176,23.523-39.936,19.717-39.551-4.366c0.741-46.282,18.411-98.941,67.563-154.892 c9.78-11.13,27.15-11.12,36.93,0.01C259.5,40.785,260.518,41.959,261.523,43.131z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ffa4b8", d: "M239.998,374.549c-1.18-6.87-12.77-56.85,0-112.34c13.48-58.53,54.06-123.2,162.55-149.92 c14.62-3.6,28.99,6.56,30.48,21.55C454.538,351.219,252.848,372.349,239.998,374.549z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ff8ca5", d: "M239.998,374.549c-3.115-0.536-17.362-2.183-36.835-7.483c-3.181-0.866-6.028-2.682-8.145-5.209 c-49.098-58.608-75.675-130.75-61.047-205.793c2.165-11.107,14.881-16.444,24.408-10.337c0.756,0.485,1.506,0.972,2.249,1.462 C126.798,274.139,232.088,366.649,239.998,374.549z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ff8ca5", d: "M281.608,365.729c-21.9,6.37-38.24,8.25-41.61,8.82c8.67-8.67,112.98-100.94,79.35-227.34v-0.01 c0.742-0.489,1.49-0.975,2.244-1.459c9.551-6.123,22.265-0.733,24.422,10.406C369.565,277.734,281.608,363.204,281.608,365.729z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ff8ca5", d: "M417.451,302.932c-32.211,44.193-80.706,72.823-134.571,87.345c-3.396,0.916-6.999,0.754-10.3-0.463 c-20.772-7.664-31.911-15.254-32.583-15.254c0.826-0.825,112.667-9.463,166.4-98.31C419.37,278.279,424.743,292.927,417.451,302.932 z" }), /* @__PURE__ */ i.createElement("path", { fill: "#ff8ca5", d: "M62.565,302.932c32.211,44.193,80.705,72.823,134.571,87.345c3.396,0.916,6.999,0.754,10.3-0.463 c20.772-7.664,31.911-15.254,32.583-15.254c-0.828-0.828-112.665-9.458-166.4-98.31C60.646,278.279,55.273,292.927,62.565,302.932z" }), /* @__PURE__ */ i.createElement("path", { fill: "#9ceb63", d: "M433.464,393.091c-52.749,39.415-118.979,42.09-182.861,13.657 c-4.441-1.977-7.606-6.011-8.633-10.763c-1.552-7.18-1.884-14.238-1.973-21.326c0.172-0.345,9.566,5.934,26.76,12.89 c36.31,14.71,102.75,30.15,161.74-21.33C440.977,369.752,443.403,385.664,433.464,393.091z" }), /* @__PURE__ */ i.createElement("path", { fill: "#9ceb63", d: "M240.038,374.579c0,0.01-0.01,0.01-0.01,0.02s-0.01,0.03-0.01,0.05c0,0,0,0,0,0.01 c-0.01,0.03-0.01,0.06-0.02,0.1v0.04c-0.13,1.3,0.09,7.59-0.92,15.16c-0.01,0.04-0.01,0.08-0.02,0.12 c-0.26,1.91-0.59,3.91-1.03,5.92c-0.07,0.33-0.15,0.65-0.25,0.97c-1.23,4.33-4.28,7.95-8.41,9.79 c-63.06,28.05-129.47,26.21-182.79-13.63c-9.94-7.43-7.63-23.36,4.92-26.91c13.1,11.46,28.11,20.79,44.16,26.79 c19.78,7.48,34.99,8.98,53.83,8.68c34.33-0.55,60.1-11.03,90.51-27.13C240.008,374.56,240.018,374.569,240.038,374.579z" }), /* @__PURE__ */ i.createElement("path", { d: "M443.143,363.426c9.579-9.648,18.604-20.804,26.926-33.305c11.399-17.132,4.201-40.447-14.837-48.202 c-12.321-5.012-24.515-8.844-36.391-11.454c17.945-34.197,27.974-78.94,22.188-137.413c-1.925-19.503-20.802-33.354-40.394-28.53 c-17.952,4.421-34.806,10.063-50.093,16.768c-4.046,1.775-5.888,6.494-4.113,10.54c1.774,4.046,6.493,5.887,10.54,4.113 c14.45-6.338,30.429-11.682,47.492-15.885c9.885-2.435,19.599,4.434,20.607,14.573c9.088,90.121-21.147,164.341-99.823,205.213 c-3.921,2.037-5.448,6.866-3.411,10.787c2.043,3.933,6.879,5.442,10.787,3.411c27.191-14.125,56.267-35.849,77.701-68.994 c12.564,2.375,25.617,6.296,38.878,11.69c9.68,3.943,13.334,15.824,7.549,24.518c-10.205,15.33-21.482,28.43-33.516,38.936 c-49.396,43.107-111.979,41.39-169.834,12.419c56.638-56.971,92.247-132.34,77.074-212.524 c-8.101-42.81-30.305-85.119-65.997-125.754c-12.964-14.759-36.003-14.748-48.946-0.016 c-28.645,32.607-48.657,66.371-59.602,100.512c-21.999-13.018-47.7-23.197-76.569-30.307c-19.338-4.763-38.383,8.699-40.354,28.53 C26.197,262.501,90.89,324.677,147.416,354.042c3.92,2.036,8.75,0.51,10.787-3.411c2.037-3.921,0.51-8.75-3.411-10.787 c-52.141-27.086-111.791-84.677-99.863-205.213c1.007-10.132,10.713-17.01,20.606-14.574c31.115,7.663,58.223,19.013,80.571,33.735 c4.863,3.204,10.891,0.586,12.257-4.539c9.392-35.245,29.306-70.362,59.188-104.378c6.581-7.492,18.316-7.487,24.904,0.014 c128.735,146.565,37.449,269.122-12.476,318.519c-30.274-29.828-76.759-87.727-78.002-162.831 c-0.073-4.417-3.698-7.933-8.131-7.867c-4.417,0.073-7.939,3.714-7.867,8.131c1.382,83.483,54.096,146.516,85.999,177.099 c-0.353,20.737-7.099,36.575-20.104,47.086c-20.129,16.267-55.786,20.072-97.831,10.438c-19.181-4.396-48.632-19.874-85.688-1.511 c-5.361,2.657-11.689-0.859-12.186-6.844c-1.888-22.74,12.042-43.926,33.548-51.893c13.4,11.096,27.797,19.551,43.11,25.275 c20.238,7.653,36.036,9.525,56.788,9.196c15.85-0.254,30.814-2.572,45.747-7.085c4.229-1.278,6.622-5.743,5.343-9.972 c-1.278-4.229-5.744-6.622-9.972-5.344c-13.494,4.078-27.027,6.173-41.373,6.403c-17.347,0.275-31.911-0.993-50.901-8.174 c-31.69-11.847-56.387-35.98-75.211-64.258c-5.791-8.704-2.122-20.58,7.548-24.52c4.092-1.667,6.058-6.335,4.391-10.427 c-1.667-4.092-6.334-6.058-10.427-4.391c-19.062,7.765-26.214,31.095-14.832,48.202c8.365,12.566,17.352,23.674,26.917,33.31 C12.89,375.664-2.037,401.187,0.226,428.434c1.427,17.192,19.743,27.533,35.235,19.857c30.84-15.283,54.311-1.971,75.01,2.771 c36.708,8.411,82.166,10.086,111.461-13.59c14.777-11.943,23.305-28.715,25.489-49.937 c61.607,30.736,128.694,32.482,182.835-12.326c21.516,7.959,35.456,29.153,33.567,51.902c-0.493,5.939-6.786,9.519-12.186,6.844 c-30.339-15.034-55.535-7.379-73.932-1.791c-31.306,9.51-74.736,14.144-102.884-2.498c-3.803-2.248-8.709-0.989-10.958,2.815 c-2.249,3.803-0.989,8.709,2.815,10.958c29.214,17.272,69.817,15.19,102.844,7.622c20.72-4.747,44.177-18.05,75.01-2.771 c15.523,7.691,33.811-2.693,35.235-19.856C482.032,401.183,467.102,375.655,443.143,363.426z" })), he = {
|
|
442
458
|
sm: 32,
|
|
443
459
|
md: 48,
|
|
444
460
|
lg: 64
|
|
445
461
|
};
|
|
446
|
-
function
|
|
462
|
+
function be({
|
|
447
463
|
size: e = "md",
|
|
448
|
-
variant:
|
|
464
|
+
variant: a = "light",
|
|
449
465
|
className: x = "",
|
|
450
|
-
style:
|
|
466
|
+
style: _ = {}
|
|
451
467
|
}) {
|
|
452
|
-
const
|
|
468
|
+
const M = he[e], S = {
|
|
453
469
|
display: "inline-block",
|
|
454
470
|
cursor: "pointer",
|
|
455
471
|
transition: "all 250ms ease",
|
|
456
472
|
borderRadius: "50%",
|
|
457
|
-
...
|
|
473
|
+
...a === "dark" && {
|
|
458
474
|
backgroundColor: "rgba(255, 255, 255, 0.05)",
|
|
459
475
|
padding: "8px"
|
|
460
476
|
},
|
|
461
|
-
...
|
|
477
|
+
..._
|
|
462
478
|
};
|
|
463
479
|
return /* @__PURE__ */ P(
|
|
464
480
|
"a",
|
|
@@ -469,44 +485,44 @@ function Ae({
|
|
|
469
485
|
title: "Powered by Bodhi",
|
|
470
486
|
"aria-label": "Powered by Bodhi - Visit getbodhi.app",
|
|
471
487
|
className: x,
|
|
472
|
-
style:
|
|
473
|
-
onMouseEnter: (
|
|
474
|
-
|
|
488
|
+
style: S,
|
|
489
|
+
onMouseEnter: (g) => {
|
|
490
|
+
g.currentTarget.style.transform = "scale(1.1)", g.currentTarget.style.boxShadow = "0 0 20px rgba(255, 164, 184, 0.6)";
|
|
475
491
|
},
|
|
476
|
-
onMouseLeave: (
|
|
477
|
-
|
|
492
|
+
onMouseLeave: (g) => {
|
|
493
|
+
g.currentTarget.style.transform = "scale(1)", g.currentTarget.style.boxShadow = "none";
|
|
478
494
|
},
|
|
479
|
-
children: /* @__PURE__ */ P(
|
|
495
|
+
children: /* @__PURE__ */ P(Se, { width: M, height: M, style: { display: "block" } })
|
|
480
496
|
}
|
|
481
497
|
);
|
|
482
498
|
}
|
|
483
|
-
const
|
|
499
|
+
const Me = "production";
|
|
484
500
|
export {
|
|
485
|
-
|
|
501
|
+
be as BodhiBadge,
|
|
486
502
|
xe as BodhiProvider,
|
|
487
503
|
U as BodhiReactContext,
|
|
488
504
|
we as ClientCtxState,
|
|
489
505
|
le as INITIALIZING_CLIENT_CONTEXT_STATE,
|
|
490
506
|
ue as INITIAL_CLIENT_CONTEXT_STATE,
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
507
|
+
Me as REACT_CORE_BUILD_MODE,
|
|
508
|
+
me as clientStateToContextState,
|
|
509
|
+
Te as createApiError,
|
|
510
|
+
Oe as createOperationError,
|
|
511
|
+
Le as isApiResultError,
|
|
496
512
|
Re as isApiResultOperationError,
|
|
497
|
-
|
|
498
|
-
|
|
513
|
+
ke as isApiResultSuccess,
|
|
514
|
+
ze as isAuthError,
|
|
499
515
|
De as isAuthLoading,
|
|
500
516
|
Ne as isAuthenticated,
|
|
501
517
|
pe as isClientCtxInitialized,
|
|
502
518
|
fe as isClientCtxInitializing,
|
|
503
519
|
de as isClientCtxNotInitialized,
|
|
504
|
-
|
|
520
|
+
H as isClientCtxReady,
|
|
505
521
|
Be as isClientReady,
|
|
506
522
|
Pe as isDirectState,
|
|
507
523
|
Ue as isExtensionState,
|
|
508
524
|
Fe as isOperationError,
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
525
|
+
ge as isOverallReady,
|
|
526
|
+
qe as isWebUIClient,
|
|
527
|
+
_e as useBodhi
|
|
512
528
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { ClientCtxState, clientStateToContextState, isClientCtxInitialized, isCl
|
|
|
11
11
|
export type { ApiResponseResult, ClientState, LogLevel } from '@bodhiapp/bodhi-js-core';
|
|
12
12
|
export { isApiResultError, isApiResultOperationError, isApiResultSuccess, isDirectState, isExtensionState, isWebUIClient, } from '@bodhiapp/bodhi-js-core';
|
|
13
13
|
export { createApiError, createOperationError } from '@bodhiapp/bodhi-js-core';
|
|
14
|
-
export type { AuthState, UIClient } from '@bodhiapp/bodhi-js-core';
|
|
14
|
+
export type { AuthState, UIClient, LoginOptions, UserScope } from '@bodhiapp/bodhi-js-core';
|
|
15
15
|
export { isAuthError, isAuthLoading, isAuthenticated, isClientReady, } from '@bodhiapp/bodhi-js-core';
|
|
16
16
|
export { isOperationError, type OperationError } from '@bodhiapp/bodhi-js-core';
|
|
17
17
|
export { BUILD_MODE as REACT_CORE_BUILD_MODE } from './build-info';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bodhiapp/bodhi-js-react-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.25",
|
|
4
4
|
"description": "Core React bindings for Bodhi Browser SDK (dependency injection)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/bodhi-react-core.cjs.js",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"typecheck": "tsc --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@bodhiapp/bodhi-browser-types": "0.0.
|
|
46
|
-
"@bodhiapp/setup-modal-types": "0.0.
|
|
47
|
-
"@bodhiapp/bodhi-js-core": "0.0.
|
|
48
|
-
"@bodhiapp/ts-client": "0.1.
|
|
45
|
+
"@bodhiapp/bodhi-browser-types": "0.0.25",
|
|
46
|
+
"@bodhiapp/setup-modal-types": "0.0.25",
|
|
47
|
+
"@bodhiapp/bodhi-js-core": "0.0.25",
|
|
48
|
+
"@bodhiapp/ts-client": "0.1.19"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "^18.3.0 || ^19.0.0"
|