@bodhiapp/bodhi-js-react-core 0.0.34 → 0.0.36
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/BodhiProvider.d.ts
CHANGED
|
@@ -2,6 +2,13 @@ import { AuthState, LoginOptions, LogLevel, UIClient } from '@bodhiapp/bodhi-js-
|
|
|
2
2
|
import { ReactNode, Context } from 'react';
|
|
3
3
|
import { ClientContextState } from './client-ctx';
|
|
4
4
|
export type SetupState = 'ready' | 'loading' | 'loaded';
|
|
5
|
+
/**
|
|
6
|
+
* Which setup-modal variant to mount.
|
|
7
|
+
* - 'setup-modal-v2' (default): eager LNA-first flow with cloud signup fallback.
|
|
8
|
+
* - 'setup-modal': legacy multi-step wizard retained for opt-out and extension-
|
|
9
|
+
* heavy flows.
|
|
10
|
+
*/
|
|
11
|
+
export type SetupModalVariant = 'setup-modal' | 'setup-modal-v2';
|
|
5
12
|
export interface BodhiProviderProps {
|
|
6
13
|
children: ReactNode;
|
|
7
14
|
client: UIClient;
|
|
@@ -10,6 +17,8 @@ export interface BodhiProviderProps {
|
|
|
10
17
|
callbackPath?: string;
|
|
11
18
|
basePath?: string;
|
|
12
19
|
logLevel?: LogLevel;
|
|
20
|
+
setupModal?: SetupModalVariant;
|
|
21
|
+
autoProbe?: boolean;
|
|
13
22
|
}
|
|
14
23
|
export interface BodhiContext {
|
|
15
24
|
client: UIClient;
|
|
@@ -31,5 +40,5 @@ export interface BodhiContext {
|
|
|
31
40
|
isDirect: boolean;
|
|
32
41
|
}
|
|
33
42
|
export declare const BodhiReactContext: Context<BodhiContext | null>;
|
|
34
|
-
export declare function BodhiProvider({ children, client, modalHtmlPath, handleCallback, callbackPath: userCallbackPath, basePath, logLevel, }: BodhiProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
export declare function BodhiProvider({ children, client, modalHtmlPath, handleCallback, callbackPath: userCallbackPath, basePath, logLevel, setupModal, autoProbe, }: BodhiProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
35
44
|
export declare function useBodhi(): BodhiContext;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { UIClient, LogLevel } from '@bodhiapp/bodhi-js-core';
|
|
2
|
+
import { SetupState } from './BodhiProvider';
|
|
3
|
+
interface SetupModalV2ProcessorProps {
|
|
4
|
+
client: UIClient;
|
|
5
|
+
modalHtmlPath?: string;
|
|
6
|
+
hideSetup: () => void;
|
|
7
|
+
onSetupReady?: () => void;
|
|
8
|
+
setupState: SetupState;
|
|
9
|
+
basePath?: string;
|
|
10
|
+
logLevel?: LogLevel;
|
|
11
|
+
autoProbe?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function SetupModalV2Processor({ client, modalHtmlPath, hideSetup, onSetupReady, setupState, basePath, logLevel, autoProbe, }: SetupModalV2ProcessorProps): null;
|
|
14
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`,JSON.stringify(s,null,2)),u.current?.updateState(C()),{setupState:s}},[v.MSG.MODAL_LNA_CONNECT]:async t=>{const s=t.payload.serverUrl;console.log("[SetupModalProcessor] LNA connect:",s);const i=await e.testDirectConnectivity(s);if(i.server.status!=="not-connected"){const h=i.server.status;if(h==="ready"||h==="setup"||h==="resource_admin"){f.setDirectStatus("granted"),e.getConnectionMode()===null&&await e.setConnectionMode("direct");const _=await g();return m.current=_,u.current?.updateState(C()),{success:!0}}}const d=await g();return m.current=d,u.current?.updateState(C()),{success:!1}},[v.MSG.MODAL_LNA_SKIP]:async()=>{f.setDirectStatus("skipped");const t=await g();return m.current=t,u.current?.updateState(C()),{success:!0}},[v.MSG.MODAL_CLOSE]:()=>{b()},[v.MSG.MODAL_COMPLETE]:()=>{b()},[v.MSG.MODAL_CONFIRM_SERVER_INSTALL]:t=>(f.setServerInstallConfirmed(t.payload.confirmed),u.current?.updateState(C()),{success:!0}),[v.MSG.MODAL_SELECT_CONNECTION]:async t=>{const i=t.payload.connection==="lna"?"direct":"extension";return await e.setConnectionMode(i),u.current?.updateState(C()),{success:!0}}}),[M,e,f,g,C,O,b]);return r.useEffect(()=>(u.current=new n.OnboardingModal({modalHtmlPath:c,handlers:R}),()=>{u.current?.destroy(),u.current=null}),[c,R]),r.useEffect(()=>{L&&u.current?(u.current.showLoading(),g(!0).then(t=>{m.current=t,u.current?.updateState(t),E?.()}).catch(t=>{console.error("[SetupModalProcessor] buildSetupState failed:",t)})):!L&&u.current&&u.current.destroy()},[L,g,E]),null}const V={status:"not-initialized",mode:null,extensionId:null,url:null,server:n.BACKEND_SERVER_NOT_CONNECTED,error:null},W={status:"initializing",mode:null,extensionId:null,url:null,server:n.BACKEND_SERVER_NOT_CONNECTED,error:null};function H(e){return e.status==="not-initialized"}function K(e){return e.status==="initializing"}function X(e){return e.status!=="not-initialized"&&e.status!=="initializing"}function G(e){return e.status==="ready"}function Z(e){return G(e)&&e.server.status==="ready"}function J(e){return n.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 ee={isNotInitialized:H,isInitializing:K,isInitialized:X,isReady:G,isOverallReady:Z},j=r.createContext(null);j.displayName="BodhiContext";function te({children:e,client:c,modalHtmlPath:b,handleCallback:E=!0,callbackPath:I,basePath:p="/",logLevel:S="warn"}){const L=p==="/"?"":p.replace(/\/$/,""),M=I??`${L}/callback`,u=r.useMemo(()=>new n.Logger("BodhiProvider",S),[S]),f=r.useRef(!1),m=r.useRef(!1),x=r.useRef(!1),[y,N]=r.useState(V),[O,A]=r.useState(n.INITIAL_AUTH_STATE),[k,g]=r.useState(!1),[C,R]=r.useState("ready"),t=r.useCallback((a,o)=>{m.current=!0,A({status:"error",user:null,accessToken:null,error:{code:a,message:o},refreshToken:null,expiresAt:null,isTokenRefresh:!1}),g(!1)},[]),s=r.useCallback(()=>{m.current=!1},[]);r.useEffect(()=>{const a=o=>{switch(o.type){case"client-state":N(J(o.state));break;case"auth-state":m.current||(A(o.state),g(!1));break}};return c.setStateCallback(a),()=>{c.setStateCallback(n.NOOP_STATE_CALLBACK)}},[c]);const i=r.useCallback(async()=>{R("loading")},[]),d=r.useCallback(()=>{R("ready")},[]),h=r.useCallback(()=>{R("loaded")},[]),_=r.useCallback(async a=>{N(W);try{await c.init(a||{})}catch(o){u.error("Init failed:",o)}},[c,u]);r.useEffect(()=>{if(x.current)return;x.current=!0,(async()=>{if(await _(),!E)return;const o=new URL(window.location.href);if(o.pathname!==M||f.current||!n.isWebUIClient(c))return;if(o.searchParams.get("bodhi_flow")==="access_request"){const w=o.searchParams.get("id");if(!w){u.warn("Access request callback marker present but no id parameter"),window.history.replaceState({},"",p);return}f.current=!0,g(!0);try{await c.handleAccessRequestCallback(w)}catch(T){u.error("Access request callback failed:",T);const Y=T instanceof n.BodhiError?T:null;t(Y?.code??"access_request_callback_failed",T instanceof Error?T.message:"Access request callback failed"),window.history.replaceState({},"",p)}return}const z=o.searchParams.get("code"),F=o.searchParams.get("state");if(!(!z||!F)){f.current=!0,g(!0);try{await c.handleOAuthCallback(z,F),window.history.replaceState({},"",p)}catch(w){u.error("OAuth callback failed:",w);const T=w instanceof n.BodhiError?w:null;t(T?.code??"oauth_callback_failed",w instanceof Error?w.message:"OAuth callback failed"),window.history.replaceState({},"",p)}}})()},[_,c,E,M,p]);const q=r.useCallback(async a=>{s(),g(!0);try{const o=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,B=o&&Object.keys(o).length>0?o:void 0;await c.login(B)}catch(o){const B=o instanceof n.BodhiError?o:null,z={status:"error",user:null,accessToken:null,error:{message:o instanceof Error?o.message:"Login failed",code:B?.code??"login_failed"},refreshToken:null,expiresAt:null,isTokenRefresh:!1};return A(z),g(!1),z}},[c,s]),P=r.useCallback(async()=>{s();try{await c.logout()}catch(a){t("logout_failed",a instanceof Error?a.message:"Logout failed")}},[c,t,s]),U=r.useMemo(()=>{const a=y.status==="ready",o=y.server.status==="ready";return{client:c,clientState:y,auth:O,isAuthLoading:k,login:q,logout:P,showSetup:i,hideSetup:d,setupState:C,isAuthenticated:O.status==="authenticated",canLogin:a&&!k,isReady:a,isServerReady:o,isOverallReady:a&&o,isInitializing:y.status==="initializing",isExtension:y.mode==="extension",isDirect:y.mode==="direct"}},[c,y,O,k,C,q,P,i,d]);return D.jsxs(j.Provider,{value:U,children:[D.jsx(Q,{client:c,modalHtmlPath:b,hideSetup:d,onSetupReady:h,setupState:C,basePath:p,logLevel:S}),e]})}function re(){const e=r.useContext(j);if(!e)throw new Error("useBodhi must be used within BodhiProvider");return e}const ne=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"})),se={sm:32,md:48,lg:64};function ae({size:e="md",variant:c="light",className:b="",style:E={}}){const I=se[e],p={display:"inline-block",cursor:"pointer",transition:"all 250ms ease",borderRadius:"50%",...c==="dark"&&{backgroundColor:"rgba(255, 255, 255, 0.05)",padding:"8px"},...E};return D.jsx("a",{href:"https://getbodhi.app",target:"_blank",rel:"noopener noreferrer",title:"Powered by Bodhi","aria-label":"Powered by Bodhi - Visit getbodhi.app",className:b,style:p,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:D.jsx(ne,{width:I,height:I,style:{display:"block"}})})}const ce="production";Object.defineProperty(exports,"BodhiApiError",{enumerable:!0,get:()=>n.BodhiApiError});Object.defineProperty(exports,"BodhiError",{enumerable:!0,get:()=>n.BodhiError});Object.defineProperty(exports,"InMemoryStorage",{enumerable:!0,get:()=>n.InMemoryStorage});Object.defineProperty(exports,"LoginOptionsBuilder",{enumerable:!0,get:()=>n.LoginOptionsBuilder});Object.defineProperty(exports,"createApiError",{enumerable:!0,get:()=>n.createApiError});Object.defineProperty(exports,"createOperationError",{enumerable:!0,get:()=>n.createOperationError});Object.defineProperty(exports,"isAuthError",{enumerable:!0,get:()=>n.isAuthError});Object.defineProperty(exports,"isAuthLoading",{enumerable:!0,get:()=>n.isAuthLoading});Object.defineProperty(exports,"isAuthenticated",{enumerable:!0,get:()=>n.isAuthenticated});Object.defineProperty(exports,"isClientReady",{enumerable:!0,get:()=>n.isClientReady});Object.defineProperty(exports,"isDirectState",{enumerable:!0,get:()=>n.isDirectState});Object.defineProperty(exports,"isExtensionState",{enumerable:!0,get:()=>n.isExtensionState});Object.defineProperty(exports,"isWebUIClient",{enumerable:!0,get:()=>n.isWebUIClient});Object.defineProperty(exports,"unwrapResponse",{enumerable:!0,get:()=>n.unwrapResponse});exports.BodhiBadge=ae;exports.BodhiProvider=te;exports.BodhiReactContext=j;exports.ClientCtxState=ee;exports.INITIALIZING_CLIENT_CONTEXT_STATE=W;exports.INITIAL_CLIENT_CONTEXT_STATE=V;exports.REACT_CORE_BUILD_MODE=ce;exports.clientStateToContextState=J;exports.isClientCtxInitialized=X;exports.isClientCtxInitializing=K;exports.isClientCtxNotInitialized=H;exports.isClientCtxReady=G;exports.isOverallReady=Z;exports.useBodhi=re;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const U=require("react/jsx-runtime"),s=require("@bodhiapp/bodhi-js-core"),t=require("react"),I=require("@bodhiapp/setup-modal-types");function re(e){const c=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const S in e)if(S!=="default"){const b=Object.getOwnPropertyDescriptor(e,S);Object.defineProperty(c,S,b.get?b:{enumerable:!0,get:()=>e[S]})}}return c.default=e,Object.freeze(c)}const C=re(t);function ne({client:e,modalHtmlPath:c,hideSetup:S,onSetupReady:b,setupState:w,basePath:g="/",logLevel:h="warn"}){const T=w!=="ready",A=t.useMemo(()=>new s.Logger("SetupModalProcessor",h),[h]),p=t.useRef(null),u=t.useMemo(()=>new s.BodhiClientUserPrefsManager(s.createStoragePrefixWithBasePath(g,"bodhijs:")),[g]),f=t.useRef(null),O=t.useCallback(r=>r==="direct"?"lna":r==="extension"?"extension":null,[]),_=t.useCallback(r=>r.extension==="ready"?{status:"ready",version:"unknown",id:r.extensionId}:r.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"}},[]),k=t.useCallback(r=>{if(r.server.status==="pending-extension-ready")return{status:"pending-extension-ready",error:{message:"Extension not ready",code:"server-pending-ext-ready"}};const a=r.server;switch(a.status){case"ready":return{status:"ready",version:a.version||"unknown"};case"setup":return{status:"setup",version:a.version||"unknown",error:{message:a.error?.message||"Setup required",code:"server-in-setup-status"}};case"resource_admin":return{status:"resource_admin",version:a.version||"unknown",error:{message:a.error?.message||"Resource admin required",code:"server-in-admin-status"}};case"error":return{status:"error",error:{message:a.error?.message||"Unknown error",code:"server-unexpected-error"}};case"not-reachable":return{status:"unreachable",error:{message:a.error?.message||"Server not reachable",code:"server-conn-refused"}};default:return{status:"unreachable",error:{message:"Unknown server status",code:"server-unexpected-error"}}}},[]),E=t.useCallback(r=>{if(r.server.status==="not-connected")return{status:"pending-lna-ready"};const a=r.server;switch(a.status){case"ready":return{status:"ready",version:a.version||"unknown"};case"setup":return{status:"setup",version:a.version||"unknown"};case"resource_admin":return{status:"resource_admin",version:a.version||"unknown"};case"error":case"not-reachable":return{status:"error",error:{message:a.error?.message||"Connection error"}};default:return{status:"error",error:{message:"Unknown server status"}}}},[]),x=t.useCallback((r,a)=>{if(r.server.status!=="pending-extension-ready"){const l=r.server.status;if(l==="ready"||l==="setup"||l==="resource_admin")return!0}if(a.server.status!=="not-connected"){const l=a.server.status;if(l==="ready"||l==="setup"||l==="resource_admin")return!0}return!1},[]),M=t.useCallback((r,a,l)=>{if(a==="skipped")return{status:"skipped",serverUrl:l};if(r.server.status!=="not-connected"){const m=r.server;return m.status==="ready"||m.status==="setup"||m.status==="resource_admin"?{status:"granted",serverUrl:l}:{status:"unreachable",serverUrl:l,error:{message:m.error?.message||"Server unreachable",code:"lna-unreachable"}}}return a==="granted"?{status:"granted",serverUrl:l}:{status:"prompt",serverUrl:l}},[]),y=t.useCallback(async(r=!1)=>{const a=s.detectBrowser().type,l=s.detectOS().type;let m=await e.getExtensionState();(m.extension==="not-initialized"||r)&&(m=await e.testExtensionConnectivity());let v=await e.getDirectState();const L=u.getDirectStatus();L==="granted"&&(v.server.status==="not-connected"||r)&&(v=await e.testDirectConnectivity());const P=s.getServerUrl(v)||"http://localhost:1135",B=M(v,L,P);return e.getConnectionMode()===null&&(s.isDirectServerReady(v)?await e.setConnectionMode("direct"):s.isExtensionServerReady(m)&&await e.setConnectionMode("extension")),u.isServerInstallConfirmed()||x(m,v)&&u.setServerInstallConfirmed(!0),{extension:_(m),server:k(m),lna:B,lnaServer:E(v),env:{browser:a,os:l},browsers:s.BROWSER_CONFIGS,os:s.OS_CONFIGS,userConfirmations:{serverInstall:u.isServerInstallConfirmed()},selectedConnection:O(e.getConnectionMode())}},[e,u,_,k,E,O,M,x]),n=t.useCallback(()=>{if(!f.current)throw new Error("Cannot get state: currentStateRef is null");return{...f.current,userConfirmations:{serverInstall:u.isServerInstallConfirmed()},selectedConnection:O(e.getConnectionMode())}},[u,e,O]),i=t.useMemo(()=>({[I.MSG.MODAL_READY]:async()=>(A.info("MODAL_READY: returning current state or default"),f.current?{setupState:n()}:{setupState:I.DEFAULT_SETUP_STATE}),[I.MSG.MODAL_REFRESH]:async()=>{A.info("MODAL_REFRESH: refreshing state");const r=await y(!0);f.current=r;const a=n();return A.info(`MODAL_REFRESH: state refreshed
|
|
2
|
+
`,JSON.stringify(a,null,2)),p.current?.updateState(n()),{setupState:a}},[I.MSG.MODAL_LNA_CONNECT]:async r=>{const a=r.payload.serverUrl;console.log("[SetupModalProcessor] LNA connect:",a);const l=await e.testDirectConnectivity(a);if(l.server.status!=="not-connected"){const v=l.server.status;if(v==="ready"||v==="setup"||v==="resource_admin"){u.setDirectStatus("granted"),e.getConnectionMode()===null&&await e.setConnectionMode("direct");const L=await y();return f.current=L,p.current?.updateState(n()),{success:!0}}}const m=await y();return f.current=m,p.current?.updateState(n()),{success:!1}},[I.MSG.MODAL_LNA_SKIP]:async()=>{u.setDirectStatus("skipped");const r=await y();return f.current=r,p.current?.updateState(n()),{success:!0}},[I.MSG.MODAL_CLOSE]:()=>{S()},[I.MSG.MODAL_COMPLETE]:()=>{S()},[I.MSG.MODAL_CONFIRM_SERVER_INSTALL]:r=>(u.setServerInstallConfirmed(r.payload.confirmed),p.current?.updateState(n()),{success:!0}),[I.MSG.MODAL_SELECT_CONNECTION]:async r=>{const l=r.payload.connection==="lna"?"direct":"extension";return await e.setConnectionMode(l),p.current?.updateState(n()),{success:!0}}}),[A,e,u,y,n,E,S]);return t.useEffect(()=>(p.current=new s.OnboardingModal({modalHtmlPath:c,handlers:i}),()=>{p.current?.destroy(),p.current=null}),[c,i]),t.useEffect(()=>{T&&p.current?(p.current.showLoading(),y(!0).then(r=>{f.current=r,p.current?.updateState(r),b?.()}).catch(r=>{console.error("[SetupModalProcessor] buildSetupState failed:",r)})):!T&&p.current&&p.current.destroy()},[T,y,b]),null}const se="http://localhost:1135",j={MODAL_READY:"modal:ready",MODAL_PROBE:"modal:probe",MODAL_COMPLETE:"modal:complete",MODAL_CLOSE:"modal:close"},ae=130,ce=143;function oe(e=navigator.userAgent){const c=e.toLowerCase(),S=c.match(/edg\/(\d+)/);if(S){const h=parseInt(S[1],10);return{name:"edge",version:h,supported:h>=ce}}const b=c.match(/chrome\/(\d+)/);if(b&&!c.includes("edg/")){const h=parseInt(b[1],10);return{name:"chrome",version:h,supported:h>=ae}}const w=c.match(/firefox\/(\d+)/);if(w)return{name:"firefox",version:parseInt(w[1],10),supported:!1};const g=c.match(/version\/(\d+).*safari/);return g&&!c.includes("chrome/")?{name:"safari",version:parseInt(g[1],10),supported:!1}:{name:"unknown",version:0,supported:!1}}function ie({client:e,modalHtmlPath:c,hideSetup:S,onSetupReady:b,setupState:w,basePath:g="/",logLevel:h="warn",autoProbe:T=!0}){const A=w!=="ready",p=t.useMemo(()=>new s.Logger("SetupModalV2Processor",h),[h]),u=t.useRef(null),f=t.useRef(null),O=t.useMemo(()=>new s.BodhiClientUserPrefsManager(s.createStoragePrefixWithBasePath(g,"bodhijs:")),[g]),_=t.useMemo(()=>`${s.createStoragePrefixWithBasePath(g,"bodhijs:")}setup-v2.connection`,[g]),k=t.useCallback(()=>{try{const n=localStorage.getItem(_);if(!n)return null;const i=JSON.parse(n);return typeof i?.serverUrl=="string"?i:null}catch{return null}},[_]),E=t.useCallback(n=>{try{localStorage.setItem(_,JSON.stringify({serverUrl:n,lastProbedAt:Date.now()}))}catch{}},[_]),x=t.useCallback(async n=>{const i=oe(),r=await e.testDirectConnectivity(n),a=r.server.status;return a==="ready"?(E(n),O.setDirectStatus("granted"),e.getConnectionMode()===null&&await e.setConnectionMode("direct"),{serverUrl:n,browser:i,probeStatus:"connected",serverStatus:"ready"}):a==="setup"||a==="resource_admin"?{serverUrl:n,browser:i,probeStatus:"not-ready",serverStatus:a}:a==="error"?{serverUrl:n,browser:i,probeStatus:"error",serverStatus:"error",error:r.server.error?{code:"server-error",message:r.server.error.message}:void 0}:{serverUrl:n,browser:i,probeStatus:"network-error",serverStatus:"unreachable",error:r.server.error?{code:"network-error",message:r.server.error.message}:void 0}},[e,O,E]),M=t.useCallback(async()=>{const i=k()?.serverUrl??se;return x(i)},[x,k]),y=t.useMemo(()=>({[j.MODAL_READY]:async()=>{if(f.current)return{setupState:f.current};const n=await M();return f.current=n,{setupState:n}},[j.MODAL_PROBE]:async n=>{const i=await x(n.payload.serverUrl);return f.current=i,u.current?.updateState(i),{setupState:i}},[j.MODAL_COMPLETE]:()=>{S()},[j.MODAL_CLOSE]:()=>{S()}}),[M,x,S]);return t.useEffect(()=>(u.current=new s.OnboardingModalV2({modalHtmlPath:c,handlers:y}),()=>{u.current?.destroy(),u.current=null}),[c,y]),t.useEffect(()=>{T&&M().then(n=>{f.current=n,p.info("Auto-probe complete:",n.probeStatus)}).catch(n=>{p.error("Auto-probe failed:",n)})},[T,M,p]),t.useEffect(()=>{let n=!1;return A&&u.current?(u.current.showLoading(),f.current?(u.current.updateState(f.current),b?.()):M().then(i=>{n||(f.current=i,u.current?.updateState(i),b?.())}).catch(i=>{n||p.error("buildInitialState failed:",i)})):!A&&u.current&&u.current.destroy(),()=>{n=!0}},[A,M,b,p]),null}const H={status:"not-initialized",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null},K={status:"initializing",mode:null,extensionId:null,url:null,server:s.BACKEND_SERVER_NOT_CONNECTED,error:null};function J(e){return e.status==="not-initialized"}function X(e){return e.status==="initializing"}function Y(e){return e.status!=="not-initialized"&&e.status!=="initializing"}function G(e){return e.status==="ready"}function Z(e){return G(e)&&e.server.status==="ready"}function $(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 ue={isNotInitialized:J,isInitializing:X,isInitialized:Y,isReady:G,isOverallReady:Z},q=t.createContext(null);q.displayName="BodhiContext";function le({children:e,client:c,modalHtmlPath:S,handleCallback:b=!0,callbackPath:w,basePath:g="/",logLevel:h="warn",setupModal:T="setup-modal-v2",autoProbe:A=!0}){const p=g==="/"?"":g.replace(/\/$/,""),u=w??`${p}/callback`,f=t.useMemo(()=>new s.Logger("BodhiProvider",h),[h]),O=t.useRef(!1),_=t.useRef(!1),k=t.useRef(!1),[E,x]=t.useState(H),[M,y]=t.useState(s.INITIAL_AUTH_STATE),[n,i]=t.useState(!1),[r,a]=t.useState("ready"),l=t.useCallback((o,d)=>{_.current=!0,y({status:"error",user:null,accessToken:null,error:{code:o,message:d},refreshToken:null,expiresAt:null,isTokenRefresh:!1}),i(!1)},[]),m=t.useCallback(()=>{_.current=!1},[]);t.useEffect(()=>{const o=d=>{switch(d.type){case"client-state":x($(d.state));break;case"auth-state":_.current||(y(d.state),i(!1));break}};return c.setStateCallback(o),()=>{c.setStateCallback(s.NOOP_STATE_CALLBACK)}},[c]);const v=t.useCallback(async()=>{a("loading")},[]),L=t.useCallback(()=>{a("ready")},[]),V=t.useCallback(()=>{a("loaded")},[]),P=t.useCallback(async o=>{x(K);try{await c.init(o||{})}catch(d){f.error("Init failed:",d)}},[c,f]);t.useEffect(()=>{if(k.current)return;k.current=!0,(async()=>{if(await P(),!b)return;const d=new URL(window.location.href);if(d.pathname!==u||O.current||!s.isWebUIClient(c))return;if(d.searchParams.get("bodhi_flow")==="access_request"){const R=d.searchParams.get("id");if(!R){f.warn("Access request callback marker present but no id parameter"),window.history.replaceState({},"",g);return}O.current=!0,i(!0);try{await c.handleAccessRequestCallback(R)}catch(D){f.error("Access request callback failed:",D);const te=D instanceof s.BodhiError?D:null;l(te?.code??"access_request_callback_failed",D instanceof Error?D.message:"Access request callback failed"),window.history.replaceState({},"",g)}return}const N=d.searchParams.get("code"),W=d.searchParams.get("state");if(!(!N||!W)){O.current=!0,i(!0);try{await c.handleOAuthCallback(N,W),window.history.replaceState({},"",g)}catch(R){f.error("OAuth callback failed:",R);const D=R instanceof s.BodhiError?R:null;l(D?.code??"oauth_callback_failed",R instanceof Error?R.message:"OAuth callback failed"),window.history.replaceState({},"",g)}}})()},[P,c,b,u,g]);const B=t.useCallback(async o=>{m(),i(!0);try{const d=o?{...o.userRole&&{userRole:o.userRole},...o.requested&&{requested:o.requested},...o.flowType&&{flowType:o.flowType},...o.redirectUrl&&{redirectUrl:o.redirectUrl},...o.onProgress&&{onProgress:o.onProgress},...o.pollIntervalMs&&{pollIntervalMs:o.pollIntervalMs},...o.pollTimeoutMs&&{pollTimeoutMs:o.pollTimeoutMs}}:void 0,z=d&&Object.keys(d).length>0?d:void 0;await c.login(z)}catch(d){const z=d instanceof s.BodhiError?d:null,N={status:"error",user:null,accessToken:null,error:{message:d instanceof Error?d.message:"Login failed",code:z?.code??"login_failed"},refreshToken:null,expiresAt:null,isTokenRefresh:!1};return y(N),i(!1),N}},[c,m]),F=t.useCallback(async()=>{m();try{await c.logout()}catch(o){l("logout_failed",o instanceof Error?o.message:"Logout failed")}},[c,l,m]),Q=t.useMemo(()=>{const o=E.status==="ready",d=E.server.status==="ready";return{client:c,clientState:E,auth:M,isAuthLoading:n,login:B,logout:F,showSetup:v,hideSetup:L,setupState:r,isAuthenticated:M.status==="authenticated",canLogin:o&&!n,isReady:o,isServerReady:d,isOverallReady:o&&d,isInitializing:E.status==="initializing",isExtension:E.mode==="extension",isDirect:E.mode==="direct"}},[c,E,M,n,r,B,F,v,L]),ee=T==="setup-modal"?ne:ie;return U.jsxs(q.Provider,{value:Q,children:[U.jsx(ee,{client:c,modalHtmlPath:S,hideSetup:L,onSetupReady:V,setupState:r,basePath:g,logLevel:h,autoProbe:A}),e]})}function de(){const e=t.useContext(q);if(!e)throw new Error("useBodhi must be used within BodhiProvider");return e}const fe=e=>C.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 479.995 479.995",width:"480px",height:"480px",...e},C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"}),C.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"})),pe={sm:32,md:48,lg:64};function ge({size:e="md",variant:c="light",className:S="",style:b={}}){const w=pe[e],g={display:"inline-block",cursor:"pointer",transition:"all 250ms ease",borderRadius:"50%",...c==="dark"&&{backgroundColor:"rgba(255, 255, 255, 0.05)",padding:"8px"},...b};return U.jsx("a",{href:"https://getbodhi.app",target:"_blank",rel:"noopener noreferrer",title:"Powered by Bodhi","aria-label":"Powered by Bodhi - Visit getbodhi.app",className:S,style:g,onMouseEnter:h=>{h.currentTarget.style.transform="scale(1.1)",h.currentTarget.style.boxShadow="0 0 20px rgba(255, 164, 184, 0.6)"},onMouseLeave:h=>{h.currentTarget.style.transform="scale(1)",h.currentTarget.style.boxShadow="none"},children:U.jsx(fe,{width:w,height:w,style:{display:"block"}})})}const he="production";Object.defineProperty(exports,"BodhiApiError",{enumerable:!0,get:()=>s.BodhiApiError});Object.defineProperty(exports,"BodhiError",{enumerable:!0,get:()=>s.BodhiError});Object.defineProperty(exports,"InMemoryStorage",{enumerable:!0,get:()=>s.InMemoryStorage});Object.defineProperty(exports,"LoginOptionsBuilder",{enumerable:!0,get:()=>s.LoginOptionsBuilder});Object.defineProperty(exports,"createApiError",{enumerable:!0,get:()=>s.createApiError});Object.defineProperty(exports,"createOperationError",{enumerable:!0,get:()=>s.createOperationError});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,"isWebUIClient",{enumerable:!0,get:()=>s.isWebUIClient});Object.defineProperty(exports,"unwrapResponse",{enumerable:!0,get:()=>s.unwrapResponse});exports.BodhiBadge=ge;exports.BodhiProvider=le;exports.BodhiReactContext=q;exports.ClientCtxState=ue;exports.INITIALIZING_CLIENT_CONTEXT_STATE=K;exports.INITIAL_CLIENT_CONTEXT_STATE=H;exports.REACT_CORE_BUILD_MODE=he;exports.clientStateToContextState=$;exports.isClientCtxInitialized=Y;exports.isClientCtxInitializing=X;exports.isClientCtxNotInitialized=J;exports.isClientCtxReady=G;exports.isOverallReady=Z;exports.useBodhi=de;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { Logger as
|
|
3
|
-
import { BodhiApiError as
|
|
4
|
-
import * as
|
|
5
|
-
import { useMemo as
|
|
6
|
-
import { MSG as
|
|
7
|
-
function
|
|
1
|
+
import { jsxs as ne, jsx as G } from "react/jsx-runtime";
|
|
2
|
+
import { Logger as W, BodhiClientUserPrefsManager as X, createStoragePrefixWithBasePath as H, detectBrowser as se, detectOS as ae, getServerUrl as oe, isDirectServerReady as ce, isExtensionServerReady as ie, OS_CONFIGS as ue, BROWSER_CONFIGS as le, OnboardingModal as de, OnboardingModalV2 as fe, BACKEND_SERVER_NOT_CONNECTED as Z, isExtensionState as pe, INITIAL_AUTH_STATE as he, NOOP_STATE_CALLBACK as me, isWebUIClient as ge, BodhiError as j } from "@bodhiapp/bodhi-js-core";
|
|
3
|
+
import { BodhiApiError as We, BodhiError as Ke, InMemoryStorage as Ye, LoginOptionsBuilder as Je, createApiError as $e, createOperationError as Xe, isAuthError as Ze, isAuthLoading as Qe, isAuthenticated as et, isClientReady as tt, isDirectState as rt, isExtensionState as nt, isWebUIClient as st, unwrapResponse as at } from "@bodhiapp/bodhi-js-core";
|
|
4
|
+
import * as g from "react";
|
|
5
|
+
import { useMemo as O, useRef as z, useCallback as h, useEffect as N, createContext as Se, useState as V, useContext as ve } from "react";
|
|
6
|
+
import { MSG as k, DEFAULT_SETUP_STATE as Ce } from "@bodhiapp/setup-modal-types";
|
|
7
|
+
function Ee({
|
|
8
8
|
client: e,
|
|
9
|
-
modalHtmlPath:
|
|
10
|
-
hideSetup:
|
|
11
|
-
onSetupReady:
|
|
12
|
-
setupState:
|
|
13
|
-
basePath:
|
|
14
|
-
logLevel:
|
|
9
|
+
modalHtmlPath: s,
|
|
10
|
+
hideSetup: S,
|
|
11
|
+
onSetupReady: v,
|
|
12
|
+
setupState: b,
|
|
13
|
+
basePath: f = "/",
|
|
14
|
+
logLevel: p = "warn"
|
|
15
15
|
}) {
|
|
16
|
-
const
|
|
17
|
-
() => new
|
|
18
|
-
[
|
|
19
|
-
),
|
|
16
|
+
const I = b !== "ready", _ = O(() => new W("SetupModalProcessor", p), [p]), d = z(null), c = O(
|
|
17
|
+
() => new X(H(f, "bodhijs:")),
|
|
18
|
+
[f]
|
|
19
|
+
), l = z(null), M = h(
|
|
20
20
|
(t) => t === "direct" ? "lna" : t === "extension" ? "extension" : null,
|
|
21
21
|
[]
|
|
22
|
-
),
|
|
22
|
+
), A = h((t) => t.extension === "ready" ? {
|
|
23
23
|
status: "ready",
|
|
24
24
|
version: "unknown",
|
|
25
25
|
// TODO: have ExtensionState also get extension version
|
|
@@ -30,31 +30,31 @@ function ge({
|
|
|
30
30
|
} : {
|
|
31
31
|
status: "unreachable",
|
|
32
32
|
error: { message: "Client not initialized", code: "ext-connection-failed" }
|
|
33
|
-
}, []), L =
|
|
33
|
+
}, []), L = h((t) => {
|
|
34
34
|
if (t.server.status === "pending-extension-ready")
|
|
35
35
|
return {
|
|
36
36
|
status: "pending-extension-ready",
|
|
37
37
|
error: { message: "Extension not ready", code: "server-pending-ext-ready" }
|
|
38
38
|
};
|
|
39
|
-
const
|
|
40
|
-
switch (
|
|
39
|
+
const n = t.server;
|
|
40
|
+
switch (n.status) {
|
|
41
41
|
case "ready":
|
|
42
|
-
return { status: "ready", version:
|
|
42
|
+
return { status: "ready", version: n.version || "unknown" };
|
|
43
43
|
case "setup":
|
|
44
44
|
return {
|
|
45
45
|
status: "setup",
|
|
46
|
-
version:
|
|
46
|
+
version: n.version || "unknown",
|
|
47
47
|
error: {
|
|
48
|
-
message:
|
|
48
|
+
message: n.error?.message || "Setup required",
|
|
49
49
|
code: "server-in-setup-status"
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
case "resource_admin":
|
|
53
53
|
return {
|
|
54
54
|
status: "resource_admin",
|
|
55
|
-
version:
|
|
55
|
+
version: n.version || "unknown",
|
|
56
56
|
error: {
|
|
57
|
-
message:
|
|
57
|
+
message: n.error?.message || "Resource admin required",
|
|
58
58
|
code: "server-in-admin-status"
|
|
59
59
|
}
|
|
60
60
|
};
|
|
@@ -62,7 +62,7 @@ function ge({
|
|
|
62
62
|
return {
|
|
63
63
|
status: "error",
|
|
64
64
|
error: {
|
|
65
|
-
message:
|
|
65
|
+
message: n.error?.message || "Unknown error",
|
|
66
66
|
code: "server-unexpected-error"
|
|
67
67
|
}
|
|
68
68
|
};
|
|
@@ -70,7 +70,7 @@ function ge({
|
|
|
70
70
|
return {
|
|
71
71
|
status: "unreachable",
|
|
72
72
|
error: {
|
|
73
|
-
message:
|
|
73
|
+
message: n.error?.message || "Server not reachable",
|
|
74
74
|
code: "server-conn-refused"
|
|
75
75
|
}
|
|
76
76
|
};
|
|
@@ -83,22 +83,22 @@ function ge({
|
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
|
-
}, []),
|
|
86
|
+
}, []), C = h((t) => {
|
|
87
87
|
if (t.server.status === "not-connected")
|
|
88
88
|
return { status: "pending-lna-ready" };
|
|
89
|
-
const
|
|
90
|
-
switch (
|
|
89
|
+
const n = t.server;
|
|
90
|
+
switch (n.status) {
|
|
91
91
|
case "ready":
|
|
92
|
-
return { status: "ready", version:
|
|
92
|
+
return { status: "ready", version: n.version || "unknown" };
|
|
93
93
|
case "setup":
|
|
94
|
-
return { status: "setup", version:
|
|
94
|
+
return { status: "setup", version: n.version || "unknown" };
|
|
95
95
|
case "resource_admin":
|
|
96
|
-
return { status: "resource_admin", version:
|
|
96
|
+
return { status: "resource_admin", version: n.version || "unknown" };
|
|
97
97
|
case "error":
|
|
98
98
|
case "not-reachable":
|
|
99
99
|
return {
|
|
100
100
|
status: "error",
|
|
101
|
-
error: { message:
|
|
101
|
+
error: { message: n.error?.message || "Connection error" }
|
|
102
102
|
};
|
|
103
103
|
default:
|
|
104
104
|
return {
|
|
@@ -106,169 +106,289 @@ function ge({
|
|
|
106
106
|
error: { message: "Unknown server status" }
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
}, []),
|
|
110
|
-
(t,
|
|
109
|
+
}, []), x = h(
|
|
110
|
+
(t, n) => {
|
|
111
111
|
if (t.server.status !== "pending-extension-ready") {
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
112
|
+
const i = t.server.status;
|
|
113
|
+
if (i === "ready" || i === "setup" || i === "resource_admin")
|
|
114
114
|
return !0;
|
|
115
115
|
}
|
|
116
|
-
if (
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
116
|
+
if (n.server.status !== "not-connected") {
|
|
117
|
+
const i = n.server.status;
|
|
118
|
+
if (i === "ready" || i === "setup" || i === "resource_admin")
|
|
119
119
|
return !0;
|
|
120
120
|
}
|
|
121
121
|
return !1;
|
|
122
122
|
},
|
|
123
123
|
[]
|
|
124
|
-
),
|
|
125
|
-
(t,
|
|
126
|
-
if (
|
|
127
|
-
return { status: "skipped", serverUrl:
|
|
124
|
+
), w = h(
|
|
125
|
+
(t, n, i) => {
|
|
126
|
+
if (n === "skipped")
|
|
127
|
+
return { status: "skipped", serverUrl: i };
|
|
128
128
|
if (t.server.status !== "not-connected") {
|
|
129
|
-
const
|
|
130
|
-
return
|
|
129
|
+
const m = t.server;
|
|
130
|
+
return m.status === "ready" || m.status === "setup" || m.status === "resource_admin" ? { status: "granted", serverUrl: i } : {
|
|
131
131
|
status: "unreachable",
|
|
132
|
-
serverUrl:
|
|
132
|
+
serverUrl: i,
|
|
133
133
|
error: {
|
|
134
|
-
message:
|
|
134
|
+
message: m.error?.message || "Server unreachable",
|
|
135
135
|
code: "lna-unreachable"
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
|
-
return
|
|
139
|
+
return n === "granted" ? { status: "granted", serverUrl: i } : { status: "prompt", serverUrl: i };
|
|
140
140
|
},
|
|
141
141
|
[]
|
|
142
|
-
),
|
|
142
|
+
), E = h(
|
|
143
143
|
async (t = !1) => {
|
|
144
|
-
const
|
|
145
|
-
let
|
|
146
|
-
(
|
|
147
|
-
let
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
return e.getConnectionMode() === null && (
|
|
152
|
-
extension:
|
|
153
|
-
server: L(
|
|
154
|
-
lna:
|
|
155
|
-
lnaServer:
|
|
156
|
-
env: { browser:
|
|
157
|
-
browsers:
|
|
158
|
-
os:
|
|
159
|
-
userConfirmations: { serverInstall:
|
|
160
|
-
selectedConnection:
|
|
144
|
+
const n = se().type, i = ae().type;
|
|
145
|
+
let m = await e.getExtensionState();
|
|
146
|
+
(m.extension === "not-initialized" || t) && (m = await e.testExtensionConnectivity());
|
|
147
|
+
let y = await e.getDirectState();
|
|
148
|
+
const T = c.getDirectStatus();
|
|
149
|
+
T === "granted" && (y.server.status === "not-connected" || t) && (y = await e.testDirectConnectivity());
|
|
150
|
+
const P = oe(y) || "http://localhost:1135", U = w(y, T, P);
|
|
151
|
+
return e.getConnectionMode() === null && (ce(y) ? await e.setConnectionMode("direct") : ie(m) && await e.setConnectionMode("extension")), c.isServerInstallConfirmed() || x(m, y) && c.setServerInstallConfirmed(!0), {
|
|
152
|
+
extension: A(m),
|
|
153
|
+
server: L(m),
|
|
154
|
+
lna: U,
|
|
155
|
+
lnaServer: C(y),
|
|
156
|
+
env: { browser: n, os: i },
|
|
157
|
+
browsers: le,
|
|
158
|
+
os: ue,
|
|
159
|
+
userConfirmations: { serverInstall: c.isServerInstallConfirmed() },
|
|
160
|
+
selectedConnection: M(e.getConnectionMode())
|
|
161
161
|
};
|
|
162
162
|
},
|
|
163
163
|
[
|
|
164
164
|
e,
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
c,
|
|
166
|
+
A,
|
|
167
167
|
L,
|
|
168
|
+
C,
|
|
168
169
|
M,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
T
|
|
170
|
+
w,
|
|
171
|
+
x
|
|
172
172
|
]
|
|
173
|
-
),
|
|
174
|
-
if (!
|
|
173
|
+
), r = h(() => {
|
|
174
|
+
if (!l.current)
|
|
175
175
|
throw new Error("Cannot get state: currentStateRef is null");
|
|
176
176
|
return {
|
|
177
|
-
...
|
|
177
|
+
...l.current,
|
|
178
178
|
// Override userConfirmations from storage (in case updated outside buildSetupState)
|
|
179
179
|
userConfirmations: {
|
|
180
|
-
serverInstall:
|
|
180
|
+
serverInstall: c.isServerInstallConfirmed()
|
|
181
181
|
},
|
|
182
182
|
// Override selectedConnection from client (in case changed via handler)
|
|
183
|
-
selectedConnection:
|
|
183
|
+
selectedConnection: M(e.getConnectionMode())
|
|
184
184
|
};
|
|
185
|
-
}, [
|
|
185
|
+
}, [c, e, M]), o = O(
|
|
186
186
|
() => ({
|
|
187
|
-
[
|
|
188
|
-
[
|
|
189
|
-
|
|
190
|
-
const t = await
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
return
|
|
194
|
-
`, JSON.stringify(
|
|
187
|
+
[k.MODAL_READY]: async () => (_.info("MODAL_READY: returning current state or default"), l.current ? { setupState: r() } : { setupState: Ce }),
|
|
188
|
+
[k.MODAL_REFRESH]: async () => {
|
|
189
|
+
_.info("MODAL_REFRESH: refreshing state");
|
|
190
|
+
const t = await E(!0);
|
|
191
|
+
l.current = t;
|
|
192
|
+
const n = r();
|
|
193
|
+
return _.info(`MODAL_REFRESH: state refreshed
|
|
194
|
+
`, JSON.stringify(n, null, 2)), d.current?.updateState(r()), { setupState: n };
|
|
195
195
|
},
|
|
196
|
-
[
|
|
197
|
-
const
|
|
198
|
-
console.log("[SetupModalProcessor] LNA connect:",
|
|
199
|
-
const
|
|
200
|
-
if (
|
|
201
|
-
const
|
|
202
|
-
if (
|
|
203
|
-
|
|
204
|
-
const
|
|
205
|
-
return
|
|
196
|
+
[k.MODAL_LNA_CONNECT]: async (t) => {
|
|
197
|
+
const n = t.payload.serverUrl;
|
|
198
|
+
console.log("[SetupModalProcessor] LNA connect:", n);
|
|
199
|
+
const i = await e.testDirectConnectivity(n);
|
|
200
|
+
if (i.server.status !== "not-connected") {
|
|
201
|
+
const y = i.server.status;
|
|
202
|
+
if (y === "ready" || y === "setup" || y === "resource_admin") {
|
|
203
|
+
c.setDirectStatus("granted"), e.getConnectionMode() === null && await e.setConnectionMode("direct");
|
|
204
|
+
const T = await E();
|
|
205
|
+
return l.current = T, d.current?.updateState(r()), { success: !0 };
|
|
206
206
|
}
|
|
207
207
|
}
|
|
208
|
-
const
|
|
209
|
-
return
|
|
208
|
+
const m = await E();
|
|
209
|
+
return l.current = m, d.current?.updateState(r()), { success: !1 };
|
|
210
210
|
},
|
|
211
|
-
[
|
|
212
|
-
|
|
213
|
-
const t = await
|
|
214
|
-
return
|
|
211
|
+
[k.MODAL_LNA_SKIP]: async () => {
|
|
212
|
+
c.setDirectStatus("skipped");
|
|
213
|
+
const t = await E();
|
|
214
|
+
return l.current = t, d.current?.updateState(r()), { success: !0 };
|
|
215
215
|
},
|
|
216
|
-
[
|
|
217
|
-
|
|
216
|
+
[k.MODAL_CLOSE]: () => {
|
|
217
|
+
S();
|
|
218
218
|
},
|
|
219
|
-
[
|
|
220
|
-
|
|
219
|
+
[k.MODAL_COMPLETE]: () => {
|
|
220
|
+
S();
|
|
221
221
|
},
|
|
222
|
-
[
|
|
223
|
-
[
|
|
224
|
-
const
|
|
225
|
-
return await e.setConnectionMode(
|
|
222
|
+
[k.MODAL_CONFIRM_SERVER_INSTALL]: (t) => (c.setServerInstallConfirmed(t.payload.confirmed), d.current?.updateState(r()), { success: !0 }),
|
|
223
|
+
[k.MODAL_SELECT_CONNECTION]: async (t) => {
|
|
224
|
+
const i = t.payload.connection === "lna" ? "direct" : "extension";
|
|
225
|
+
return await e.setConnectionMode(i), d.current?.updateState(r()), { success: !0 };
|
|
226
226
|
}
|
|
227
227
|
}),
|
|
228
|
-
[
|
|
228
|
+
[_, e, c, E, r, C, S]
|
|
229
229
|
);
|
|
230
|
-
return
|
|
231
|
-
|
|
232
|
-
}), [
|
|
233
|
-
|
|
234
|
-
|
|
230
|
+
return N(() => (d.current = new de({ modalHtmlPath: s, handlers: o }), () => {
|
|
231
|
+
d.current?.destroy(), d.current = null;
|
|
232
|
+
}), [s, o]), N(() => {
|
|
233
|
+
I && d.current ? (d.current.showLoading(), E(!0).then((t) => {
|
|
234
|
+
l.current = t, d.current?.updateState(t), v?.();
|
|
235
235
|
}).catch((t) => {
|
|
236
236
|
console.error("[SetupModalProcessor] buildSetupState failed:", t);
|
|
237
|
-
})) : !
|
|
238
|
-
}, [
|
|
237
|
+
})) : !I && d.current && d.current.destroy();
|
|
238
|
+
}, [I, E, v]), null;
|
|
239
|
+
}
|
|
240
|
+
const ye = "http://localhost:1135", F = {
|
|
241
|
+
MODAL_READY: "modal:ready",
|
|
242
|
+
MODAL_PROBE: "modal:probe",
|
|
243
|
+
MODAL_COMPLETE: "modal:complete",
|
|
244
|
+
MODAL_CLOSE: "modal:close"
|
|
245
|
+
}, we = 130, be = 143;
|
|
246
|
+
function Me(e = navigator.userAgent) {
|
|
247
|
+
const s = e.toLowerCase(), S = s.match(/edg\/(\d+)/);
|
|
248
|
+
if (S) {
|
|
249
|
+
const p = parseInt(S[1], 10);
|
|
250
|
+
return { name: "edge", version: p, supported: p >= be };
|
|
251
|
+
}
|
|
252
|
+
const v = s.match(/chrome\/(\d+)/);
|
|
253
|
+
if (v && !s.includes("edg/")) {
|
|
254
|
+
const p = parseInt(v[1], 10);
|
|
255
|
+
return { name: "chrome", version: p, supported: p >= we };
|
|
256
|
+
}
|
|
257
|
+
const b = s.match(/firefox\/(\d+)/);
|
|
258
|
+
if (b)
|
|
259
|
+
return { name: "firefox", version: parseInt(b[1], 10), supported: !1 };
|
|
260
|
+
const f = s.match(/version\/(\d+).*safari/);
|
|
261
|
+
return f && !s.includes("chrome/") ? { name: "safari", version: parseInt(f[1], 10), supported: !1 } : { name: "unknown", version: 0, supported: !1 };
|
|
262
|
+
}
|
|
263
|
+
function Ae({
|
|
264
|
+
client: e,
|
|
265
|
+
modalHtmlPath: s,
|
|
266
|
+
hideSetup: S,
|
|
267
|
+
onSetupReady: v,
|
|
268
|
+
setupState: b,
|
|
269
|
+
basePath: f = "/",
|
|
270
|
+
logLevel: p = "warn",
|
|
271
|
+
autoProbe: I = !0
|
|
272
|
+
}) {
|
|
273
|
+
const _ = b !== "ready", d = O(() => new W("SetupModalV2Processor", p), [p]), c = z(null), l = z(null), M = O(
|
|
274
|
+
() => new X(H(f, "bodhijs:")),
|
|
275
|
+
[f]
|
|
276
|
+
), A = O(
|
|
277
|
+
() => `${H(f, "bodhijs:")}setup-v2.connection`,
|
|
278
|
+
[f]
|
|
279
|
+
), L = h(() => {
|
|
280
|
+
try {
|
|
281
|
+
const r = localStorage.getItem(A);
|
|
282
|
+
if (!r) return null;
|
|
283
|
+
const o = JSON.parse(r);
|
|
284
|
+
return typeof o?.serverUrl == "string" ? o : null;
|
|
285
|
+
} catch {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
}, [A]), C = h(
|
|
289
|
+
(r) => {
|
|
290
|
+
try {
|
|
291
|
+
localStorage.setItem(
|
|
292
|
+
A,
|
|
293
|
+
JSON.stringify({ serverUrl: r, lastProbedAt: Date.now() })
|
|
294
|
+
);
|
|
295
|
+
} catch {
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
[A]
|
|
299
|
+
), x = h(
|
|
300
|
+
async (r) => {
|
|
301
|
+
const o = Me(), t = await e.testDirectConnectivity(r), n = t.server.status;
|
|
302
|
+
return n === "ready" ? (C(r), M.setDirectStatus("granted"), e.getConnectionMode() === null && await e.setConnectionMode("direct"), { serverUrl: r, browser: o, probeStatus: "connected", serverStatus: "ready" }) : n === "setup" || n === "resource_admin" ? { serverUrl: r, browser: o, probeStatus: "not-ready", serverStatus: n } : n === "error" ? {
|
|
303
|
+
serverUrl: r,
|
|
304
|
+
browser: o,
|
|
305
|
+
probeStatus: "error",
|
|
306
|
+
serverStatus: "error",
|
|
307
|
+
error: t.server.error ? { code: "server-error", message: t.server.error.message } : void 0
|
|
308
|
+
} : {
|
|
309
|
+
serverUrl: r,
|
|
310
|
+
browser: o,
|
|
311
|
+
probeStatus: "network-error",
|
|
312
|
+
serverStatus: "unreachable",
|
|
313
|
+
error: t.server.error ? { code: "network-error", message: t.server.error.message } : void 0
|
|
314
|
+
};
|
|
315
|
+
},
|
|
316
|
+
[e, M, C]
|
|
317
|
+
), w = h(async () => {
|
|
318
|
+
const o = L()?.serverUrl ?? ye;
|
|
319
|
+
return x(o);
|
|
320
|
+
}, [x, L]), E = O(
|
|
321
|
+
() => ({
|
|
322
|
+
[F.MODAL_READY]: async () => {
|
|
323
|
+
if (l.current)
|
|
324
|
+
return { setupState: l.current };
|
|
325
|
+
const r = await w();
|
|
326
|
+
return l.current = r, { setupState: r };
|
|
327
|
+
},
|
|
328
|
+
[F.MODAL_PROBE]: async (r) => {
|
|
329
|
+
const o = await x(r.payload.serverUrl);
|
|
330
|
+
return l.current = o, c.current?.updateState(o), { setupState: o };
|
|
331
|
+
},
|
|
332
|
+
[F.MODAL_COMPLETE]: () => {
|
|
333
|
+
S();
|
|
334
|
+
},
|
|
335
|
+
[F.MODAL_CLOSE]: () => {
|
|
336
|
+
S();
|
|
337
|
+
}
|
|
338
|
+
}),
|
|
339
|
+
[w, x, S]
|
|
340
|
+
);
|
|
341
|
+
return N(() => (c.current = new fe({ modalHtmlPath: s, handlers: E }), () => {
|
|
342
|
+
c.current?.destroy(), c.current = null;
|
|
343
|
+
}), [s, E]), N(() => {
|
|
344
|
+
I && w().then((r) => {
|
|
345
|
+
l.current = r, d.info("Auto-probe complete:", r.probeStatus);
|
|
346
|
+
}).catch((r) => {
|
|
347
|
+
d.error("Auto-probe failed:", r);
|
|
348
|
+
});
|
|
349
|
+
}, [I, w, d]), N(() => {
|
|
350
|
+
let r = !1;
|
|
351
|
+
return _ && c.current ? (c.current.showLoading(), l.current ? (c.current.updateState(l.current), v?.()) : w().then((o) => {
|
|
352
|
+
r || (l.current = o, c.current?.updateState(o), v?.());
|
|
353
|
+
}).catch((o) => {
|
|
354
|
+
r || d.error("buildInitialState failed:", o);
|
|
355
|
+
})) : !_ && c.current && c.current.destroy(), () => {
|
|
356
|
+
r = !0;
|
|
357
|
+
};
|
|
358
|
+
}, [_, w, v, d]), null;
|
|
239
359
|
}
|
|
240
|
-
const
|
|
360
|
+
const _e = {
|
|
241
361
|
status: "not-initialized",
|
|
242
362
|
mode: null,
|
|
243
363
|
extensionId: null,
|
|
244
364
|
url: null,
|
|
245
|
-
server:
|
|
365
|
+
server: Z,
|
|
246
366
|
error: null
|
|
247
|
-
},
|
|
367
|
+
}, xe = {
|
|
248
368
|
status: "initializing",
|
|
249
369
|
mode: null,
|
|
250
370
|
extensionId: null,
|
|
251
371
|
url: null,
|
|
252
|
-
server:
|
|
372
|
+
server: Z,
|
|
253
373
|
error: null
|
|
254
374
|
};
|
|
255
|
-
function
|
|
375
|
+
function Oe(e) {
|
|
256
376
|
return e.status === "not-initialized";
|
|
257
377
|
}
|
|
258
|
-
function
|
|
378
|
+
function Ie(e) {
|
|
259
379
|
return e.status === "initializing";
|
|
260
380
|
}
|
|
261
|
-
function
|
|
381
|
+
function Le(e) {
|
|
262
382
|
return e.status !== "not-initialized" && e.status !== "initializing";
|
|
263
383
|
}
|
|
264
|
-
function
|
|
384
|
+
function Q(e) {
|
|
265
385
|
return e.status === "ready";
|
|
266
386
|
}
|
|
267
|
-
function
|
|
268
|
-
return
|
|
387
|
+
function Te(e) {
|
|
388
|
+
return Q(e) && e.server.status === "ready";
|
|
269
389
|
}
|
|
270
|
-
function
|
|
271
|
-
return
|
|
390
|
+
function Re(e) {
|
|
391
|
+
return pe(e) ? {
|
|
272
392
|
status: e.extension === "not-initialized" ? "initializing" : e.extension === "not-found" ? "extension-not-found" : "ready",
|
|
273
393
|
mode: "extension",
|
|
274
394
|
extensionId: e.extensionId,
|
|
@@ -284,215 +404,218 @@ function we(e) {
|
|
|
284
404
|
error: e.server.error
|
|
285
405
|
};
|
|
286
406
|
}
|
|
287
|
-
const
|
|
288
|
-
isNotInitialized:
|
|
289
|
-
isInitializing:
|
|
290
|
-
isInitialized:
|
|
291
|
-
isReady:
|
|
292
|
-
isOverallReady:
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
function
|
|
407
|
+
const Ue = {
|
|
408
|
+
isNotInitialized: Oe,
|
|
409
|
+
isInitializing: Ie,
|
|
410
|
+
isInitialized: Le,
|
|
411
|
+
isReady: Q,
|
|
412
|
+
isOverallReady: Te
|
|
413
|
+
}, K = Se(null);
|
|
414
|
+
K.displayName = "BodhiContext";
|
|
415
|
+
function qe({
|
|
296
416
|
children: e,
|
|
297
|
-
client:
|
|
298
|
-
modalHtmlPath:
|
|
299
|
-
handleCallback:
|
|
300
|
-
callbackPath:
|
|
301
|
-
basePath:
|
|
302
|
-
logLevel:
|
|
417
|
+
client: s,
|
|
418
|
+
modalHtmlPath: S,
|
|
419
|
+
handleCallback: v = !0,
|
|
420
|
+
callbackPath: b,
|
|
421
|
+
basePath: f = "/",
|
|
422
|
+
logLevel: p = "warn",
|
|
423
|
+
setupModal: I = "setup-modal-v2",
|
|
424
|
+
autoProbe: _ = !0
|
|
303
425
|
}) {
|
|
304
|
-
const
|
|
305
|
-
|
|
426
|
+
const d = f === "/" ? "" : f.replace(/\/$/, ""), c = b ?? `${d}/callback`, l = O(() => new W("BodhiProvider", p), [p]), M = z(!1), A = z(!1), L = z(!1), [C, x] = V(_e), [w, E] = V(he), [r, o] = V(!1), [t, n] = V("ready"), i = h((a, u) => {
|
|
427
|
+
A.current = !0, E({
|
|
306
428
|
status: "error",
|
|
307
429
|
user: null,
|
|
308
430
|
accessToken: null,
|
|
309
|
-
error: { code:
|
|
431
|
+
error: { code: a, message: u },
|
|
310
432
|
refreshToken: null,
|
|
311
433
|
expiresAt: null,
|
|
312
434
|
isTokenRefresh: !1
|
|
313
|
-
}),
|
|
314
|
-
}, []),
|
|
315
|
-
|
|
435
|
+
}), o(!1);
|
|
436
|
+
}, []), m = h(() => {
|
|
437
|
+
A.current = !1;
|
|
316
438
|
}, []);
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
switch (
|
|
439
|
+
N(() => {
|
|
440
|
+
const a = (u) => {
|
|
441
|
+
switch (u.type) {
|
|
320
442
|
case "client-state":
|
|
321
|
-
|
|
443
|
+
x(Re(u.state));
|
|
322
444
|
break;
|
|
323
445
|
case "auth-state":
|
|
324
|
-
|
|
446
|
+
A.current || (E(u.state), o(!1));
|
|
325
447
|
break;
|
|
326
448
|
}
|
|
327
449
|
};
|
|
328
|
-
return
|
|
329
|
-
|
|
450
|
+
return s.setStateCallback(a), () => {
|
|
451
|
+
s.setStateCallback(me);
|
|
330
452
|
};
|
|
331
|
-
}, [
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
}, []),
|
|
335
|
-
|
|
336
|
-
}, []),
|
|
337
|
-
|
|
338
|
-
}, []),
|
|
339
|
-
async (
|
|
340
|
-
|
|
453
|
+
}, [s]);
|
|
454
|
+
const y = h(async () => {
|
|
455
|
+
n("loading");
|
|
456
|
+
}, []), T = h(() => {
|
|
457
|
+
n("ready");
|
|
458
|
+
}, []), Y = h(() => {
|
|
459
|
+
n("loaded");
|
|
460
|
+
}, []), P = h(
|
|
461
|
+
async (a) => {
|
|
462
|
+
x(xe);
|
|
341
463
|
try {
|
|
342
|
-
await
|
|
343
|
-
} catch (
|
|
344
|
-
|
|
464
|
+
await s.init(a || {});
|
|
465
|
+
} catch (u) {
|
|
466
|
+
l.error("Init failed:", u);
|
|
345
467
|
}
|
|
346
468
|
},
|
|
347
|
-
[
|
|
469
|
+
[s, l]
|
|
348
470
|
);
|
|
349
|
-
|
|
350
|
-
if (
|
|
351
|
-
|
|
352
|
-
if (await
|
|
353
|
-
const
|
|
354
|
-
if (
|
|
355
|
-
if (
|
|
356
|
-
const
|
|
357
|
-
if (!
|
|
358
|
-
|
|
471
|
+
N(() => {
|
|
472
|
+
if (L.current) return;
|
|
473
|
+
L.current = !0, (async () => {
|
|
474
|
+
if (await P(), !v) return;
|
|
475
|
+
const u = new URL(window.location.href);
|
|
476
|
+
if (u.pathname !== c || M.current || !ge(s)) return;
|
|
477
|
+
if (u.searchParams.get("bodhi_flow") === "access_request") {
|
|
478
|
+
const R = u.searchParams.get("id");
|
|
479
|
+
if (!R) {
|
|
480
|
+
l.warn("Access request callback marker present but no id parameter"), window.history.replaceState({}, "", f);
|
|
359
481
|
return;
|
|
360
482
|
}
|
|
361
|
-
|
|
483
|
+
M.current = !0, o(!0);
|
|
362
484
|
try {
|
|
363
|
-
await
|
|
364
|
-
} catch (
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
), window.history.replaceState({}, "",
|
|
485
|
+
await s.handleAccessRequestCallback(R);
|
|
486
|
+
} catch (D) {
|
|
487
|
+
l.error("Access request callback failed:", D);
|
|
488
|
+
const re = D instanceof j ? D : null;
|
|
489
|
+
i(
|
|
490
|
+
re?.code ?? "access_request_callback_failed",
|
|
491
|
+
D instanceof Error ? D.message : "Access request callback failed"
|
|
492
|
+
), window.history.replaceState({}, "", f);
|
|
371
493
|
}
|
|
372
494
|
return;
|
|
373
495
|
}
|
|
374
|
-
const
|
|
375
|
-
if (!(!
|
|
376
|
-
|
|
496
|
+
const B = u.searchParams.get("code"), $ = u.searchParams.get("state");
|
|
497
|
+
if (!(!B || !$)) {
|
|
498
|
+
M.current = !0, o(!0);
|
|
377
499
|
try {
|
|
378
|
-
await
|
|
379
|
-
} catch (
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
), window.history.replaceState({}, "",
|
|
500
|
+
await s.handleOAuthCallback(B, $), window.history.replaceState({}, "", f);
|
|
501
|
+
} catch (R) {
|
|
502
|
+
l.error("OAuth callback failed:", R);
|
|
503
|
+
const D = R instanceof j ? R : null;
|
|
504
|
+
i(
|
|
505
|
+
D?.code ?? "oauth_callback_failed",
|
|
506
|
+
R instanceof Error ? R.message : "OAuth callback failed"
|
|
507
|
+
), window.history.replaceState({}, "", f);
|
|
386
508
|
}
|
|
387
509
|
}
|
|
388
510
|
})();
|
|
389
|
-
}, [
|
|
390
|
-
const
|
|
391
|
-
async (
|
|
392
|
-
|
|
511
|
+
}, [P, s, v, c, f]);
|
|
512
|
+
const U = h(
|
|
513
|
+
async (a) => {
|
|
514
|
+
m(), o(!0);
|
|
393
515
|
try {
|
|
394
|
-
const
|
|
395
|
-
...
|
|
396
|
-
...
|
|
397
|
-
...
|
|
398
|
-
...
|
|
399
|
-
...
|
|
400
|
-
...
|
|
401
|
-
...
|
|
402
|
-
} : void 0,
|
|
403
|
-
await
|
|
404
|
-
} catch (
|
|
405
|
-
const
|
|
516
|
+
const u = a ? {
|
|
517
|
+
...a.userRole && { userRole: a.userRole },
|
|
518
|
+
...a.requested && { requested: a.requested },
|
|
519
|
+
...a.flowType && { flowType: a.flowType },
|
|
520
|
+
...a.redirectUrl && { redirectUrl: a.redirectUrl },
|
|
521
|
+
...a.onProgress && { onProgress: a.onProgress },
|
|
522
|
+
...a.pollIntervalMs && { pollIntervalMs: a.pollIntervalMs },
|
|
523
|
+
...a.pollTimeoutMs && { pollTimeoutMs: a.pollTimeoutMs }
|
|
524
|
+
} : void 0, q = u && Object.keys(u).length > 0 ? u : void 0;
|
|
525
|
+
await s.login(q);
|
|
526
|
+
} catch (u) {
|
|
527
|
+
const q = u instanceof j ? u : null, B = {
|
|
406
528
|
status: "error",
|
|
407
529
|
user: null,
|
|
408
530
|
accessToken: null,
|
|
409
531
|
error: {
|
|
410
|
-
message:
|
|
411
|
-
code:
|
|
532
|
+
message: u instanceof Error ? u.message : "Login failed",
|
|
533
|
+
code: q?.code ?? "login_failed"
|
|
412
534
|
},
|
|
413
535
|
refreshToken: null,
|
|
414
536
|
expiresAt: null,
|
|
415
537
|
isTokenRefresh: !1
|
|
416
538
|
};
|
|
417
|
-
return
|
|
539
|
+
return E(B), o(!1), B;
|
|
418
540
|
}
|
|
419
541
|
},
|
|
420
|
-
[
|
|
421
|
-
),
|
|
422
|
-
|
|
542
|
+
[s, m]
|
|
543
|
+
), J = h(async () => {
|
|
544
|
+
m();
|
|
423
545
|
try {
|
|
424
|
-
await
|
|
425
|
-
} catch (
|
|
426
|
-
|
|
546
|
+
await s.logout();
|
|
547
|
+
} catch (a) {
|
|
548
|
+
i("logout_failed", a instanceof Error ? a.message : "Logout failed");
|
|
427
549
|
}
|
|
428
|
-
}, [
|
|
429
|
-
const
|
|
550
|
+
}, [s, i, m]), ee = O(() => {
|
|
551
|
+
const a = C.status === "ready", u = C.server.status === "ready";
|
|
430
552
|
return {
|
|
431
|
-
client:
|
|
553
|
+
client: s,
|
|
432
554
|
clientState: C,
|
|
433
|
-
auth:
|
|
434
|
-
isAuthLoading:
|
|
435
|
-
login:
|
|
436
|
-
logout:
|
|
437
|
-
showSetup:
|
|
438
|
-
hideSetup:
|
|
439
|
-
setupState:
|
|
555
|
+
auth: w,
|
|
556
|
+
isAuthLoading: r,
|
|
557
|
+
login: U,
|
|
558
|
+
logout: J,
|
|
559
|
+
showSetup: y,
|
|
560
|
+
hideSetup: T,
|
|
561
|
+
setupState: t,
|
|
440
562
|
// Computed auth properties
|
|
441
|
-
isAuthenticated:
|
|
442
|
-
canLogin:
|
|
563
|
+
isAuthenticated: w.status === "authenticated",
|
|
564
|
+
canLogin: a && !r,
|
|
443
565
|
// Computed connection properties
|
|
444
|
-
isReady:
|
|
445
|
-
isServerReady:
|
|
446
|
-
isOverallReady:
|
|
566
|
+
isReady: a,
|
|
567
|
+
isServerReady: u,
|
|
568
|
+
isOverallReady: a && u,
|
|
447
569
|
isInitializing: C.status === "initializing",
|
|
448
570
|
isExtension: C.mode === "extension",
|
|
449
571
|
isDirect: C.mode === "direct"
|
|
450
572
|
};
|
|
451
|
-
}, [
|
|
452
|
-
return /* @__PURE__ */
|
|
453
|
-
/* @__PURE__ */
|
|
454
|
-
|
|
573
|
+
}, [s, C, w, r, t, U, J, y, T]), te = I === "setup-modal" ? Ee : Ae;
|
|
574
|
+
return /* @__PURE__ */ ne(K.Provider, { value: ee, children: [
|
|
575
|
+
/* @__PURE__ */ G(
|
|
576
|
+
te,
|
|
455
577
|
{
|
|
456
|
-
client:
|
|
457
|
-
modalHtmlPath:
|
|
458
|
-
hideSetup:
|
|
459
|
-
onSetupReady:
|
|
460
|
-
setupState:
|
|
461
|
-
basePath:
|
|
462
|
-
logLevel:
|
|
578
|
+
client: s,
|
|
579
|
+
modalHtmlPath: S,
|
|
580
|
+
hideSetup: T,
|
|
581
|
+
onSetupReady: Y,
|
|
582
|
+
setupState: t,
|
|
583
|
+
basePath: f,
|
|
584
|
+
logLevel: p,
|
|
585
|
+
autoProbe: _
|
|
463
586
|
}
|
|
464
587
|
),
|
|
465
588
|
e
|
|
466
589
|
] });
|
|
467
590
|
}
|
|
468
|
-
function
|
|
469
|
-
const e =
|
|
591
|
+
function Ve() {
|
|
592
|
+
const e = ve(K);
|
|
470
593
|
if (!e) throw new Error("useBodhi must be used within BodhiProvider");
|
|
471
594
|
return e;
|
|
472
595
|
}
|
|
473
|
-
const
|
|
596
|
+
const ke = (e) => /* @__PURE__ */ g.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 479.995 479.995", width: "480px", height: "480px", ...e }, /* @__PURE__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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__ */ g.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" })), De = {
|
|
474
597
|
sm: 32,
|
|
475
598
|
md: 48,
|
|
476
599
|
lg: 64
|
|
477
600
|
};
|
|
478
|
-
function
|
|
601
|
+
function Fe({
|
|
479
602
|
size: e = "md",
|
|
480
|
-
variant:
|
|
481
|
-
className:
|
|
482
|
-
style:
|
|
603
|
+
variant: s = "light",
|
|
604
|
+
className: S = "",
|
|
605
|
+
style: v = {}
|
|
483
606
|
}) {
|
|
484
|
-
const
|
|
607
|
+
const b = De[e], f = {
|
|
485
608
|
display: "inline-block",
|
|
486
609
|
cursor: "pointer",
|
|
487
610
|
transition: "all 250ms ease",
|
|
488
611
|
borderRadius: "50%",
|
|
489
|
-
...
|
|
612
|
+
...s === "dark" && {
|
|
490
613
|
backgroundColor: "rgba(255, 255, 255, 0.05)",
|
|
491
614
|
padding: "8px"
|
|
492
615
|
},
|
|
493
|
-
...
|
|
616
|
+
...v
|
|
494
617
|
};
|
|
495
|
-
return /* @__PURE__ */
|
|
618
|
+
return /* @__PURE__ */ G(
|
|
496
619
|
"a",
|
|
497
620
|
{
|
|
498
621
|
href: "https://getbodhi.app",
|
|
@@ -500,46 +623,46 @@ function Oe({
|
|
|
500
623
|
rel: "noopener noreferrer",
|
|
501
624
|
title: "Powered by Bodhi",
|
|
502
625
|
"aria-label": "Powered by Bodhi - Visit getbodhi.app",
|
|
503
|
-
className:
|
|
504
|
-
style:
|
|
505
|
-
onMouseEnter: (
|
|
506
|
-
|
|
626
|
+
className: S,
|
|
627
|
+
style: f,
|
|
628
|
+
onMouseEnter: (p) => {
|
|
629
|
+
p.currentTarget.style.transform = "scale(1.1)", p.currentTarget.style.boxShadow = "0 0 20px rgba(255, 164, 184, 0.6)";
|
|
507
630
|
},
|
|
508
|
-
onMouseLeave: (
|
|
509
|
-
|
|
631
|
+
onMouseLeave: (p) => {
|
|
632
|
+
p.currentTarget.style.transform = "scale(1)", p.currentTarget.style.boxShadow = "none";
|
|
510
633
|
},
|
|
511
|
-
children: /* @__PURE__ */
|
|
634
|
+
children: /* @__PURE__ */ G(ke, { width: b, height: b, style: { display: "block" } })
|
|
512
635
|
}
|
|
513
636
|
);
|
|
514
637
|
}
|
|
515
|
-
const
|
|
638
|
+
const je = "production";
|
|
516
639
|
export {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
640
|
+
We as BodhiApiError,
|
|
641
|
+
Fe as BodhiBadge,
|
|
642
|
+
Ke as BodhiError,
|
|
643
|
+
qe as BodhiProvider,
|
|
644
|
+
K as BodhiReactContext,
|
|
645
|
+
Ue as ClientCtxState,
|
|
646
|
+
xe as INITIALIZING_CLIENT_CONTEXT_STATE,
|
|
647
|
+
_e as INITIAL_CLIENT_CONTEXT_STATE,
|
|
648
|
+
Ye as InMemoryStorage,
|
|
649
|
+
Je as LoginOptionsBuilder,
|
|
650
|
+
je as REACT_CORE_BUILD_MODE,
|
|
651
|
+
Re as clientStateToContextState,
|
|
652
|
+
$e as createApiError,
|
|
653
|
+
Xe as createOperationError,
|
|
654
|
+
Ze as isAuthError,
|
|
655
|
+
Qe as isAuthLoading,
|
|
656
|
+
et as isAuthenticated,
|
|
657
|
+
Le as isClientCtxInitialized,
|
|
658
|
+
Ie as isClientCtxInitializing,
|
|
659
|
+
Oe as isClientCtxNotInitialized,
|
|
660
|
+
Q as isClientCtxReady,
|
|
661
|
+
tt as isClientReady,
|
|
662
|
+
rt as isDirectState,
|
|
663
|
+
nt as isExtensionState,
|
|
664
|
+
Te as isOverallReady,
|
|
665
|
+
st as isWebUIClient,
|
|
666
|
+
at as unwrapResponse,
|
|
667
|
+
Ve as useBodhi
|
|
545
668
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Public API exports - minimal surface area following industry best practices
|
|
5
5
|
*/
|
|
6
|
-
export { BodhiProvider, BodhiReactContext, useBodhi, type BodhiContext, type BodhiProviderProps, type SetupState, } from './BodhiProvider';
|
|
6
|
+
export { BodhiProvider, BodhiReactContext, useBodhi, type BodhiContext, type BodhiProviderProps, type SetupState, type SetupModalVariant, } from './BodhiProvider';
|
|
7
7
|
export { BodhiBadge, type BodhiBadgeProps, type BodhiBadgeSize, type BodhiBadgeVariant, } from './BodhiBadge';
|
|
8
8
|
export type { ClientContextState, ClientContextStatus } from './client-ctx';
|
|
9
9
|
export { INITIAL_CLIENT_CONTEXT_STATE, INITIALIZING_CLIENT_CONTEXT_STATE } from './client-ctx';
|
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.36",
|
|
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",
|
|
@@ -57,9 +57,10 @@
|
|
|
57
57
|
"typecheck": "tsc --noEmit"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@bodhiapp/bodhi-browser-types": "0.0.
|
|
61
|
-
"@bodhiapp/setup-modal-types": "0.0.
|
|
62
|
-
"@bodhiapp/
|
|
60
|
+
"@bodhiapp/bodhi-browser-types": "0.0.36",
|
|
61
|
+
"@bodhiapp/setup-modal-types": "0.0.36",
|
|
62
|
+
"@bodhiapp/setup-modal-v2-types": "0.0.36",
|
|
63
|
+
"@bodhiapp/bodhi-js-core": "0.0.36",
|
|
63
64
|
"@bodhiapp/ts-client": "0.1.31"
|
|
64
65
|
},
|
|
65
66
|
"peerDependencies": {
|