@deephaven/code-studio 0.37.1-auth-plugins.2 → 0.37.1

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.
@@ -1,2 +0,0 @@
1
- import{A as o,C as t}from"./vendor-ef910ebc.js";import{L as m,B as h}from"./index-a15ad815.js";import{u as C,c as x,C as j,r as w,L as v,P as E,d as O,g as k,e as U,f as S,h as b,i as N}from"./useConnection-38d9ed2c.js";import{j as an,R as rn,o as un,p as ln,l as cn,m as dn,k as gn,n as pn,a as fn,b as hn}from"./useConnection-38d9ed2c.js";import"./helpers-042e6b4d.js";import"./monaco-a26f85af.js";const L=o.createContext(!1);function R({fontClassNames:n=["fira-sans-regular","fira-sans-bold","fira-mono"],children:e}){const[s,i]=o.useState(!1);return o.useEffect(function(){document.fonts.ready.then(()=>{i(!0)})},[]),t.jsxs(t.Fragment,{children:[t.jsx(L.Provider,{value:s,children:e}),t.jsx("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:n.map(a=>t.jsx("p",{className:a,children:"preload"},a))})]})}const _="io.deephaven.auth.AnonymousAuthenticationHandler",P=m.module("AuthPluginAnonymous");function A({children:n,getLoginOptions:e}){const s=C(),i=x(),[a,r]=o.useState(),[p,c]=o.useState(!1);return o.useEffect(()=>{let u=!1;function d(){if(u)throw new j("Login canceled.")}async function g(){try{const l=await e();d(),P.info("Logging in..."),await s.login(l),d(),c(!0)}catch(l){u||(P.error("Unable to login:",l),r(l),c(!1))}}return g(),()=>{u=!0}},[s,i,e]),p?t.jsx(t.Fragment,{children:n}):t.jsx(h,{"data-testid":"auth-base-loading",isLoading:a==null,isLoaded:!1,errorMessage:a!=null?`${a}`:null})}function B({children:n}){const e=x(),s=o.useCallback(async()=>({type:e.CoreClient.LOGIN_TYPE_ANONYMOUS}),[e]);return t.jsx(A,{getLoginOptions:s,children:n})}const F={Component:B,isAvailable:n=>n.includes(_)},M=F,$=m.module("AuthPluginParent");function I(){return $.info("Logging in by delegating to parent window..."),w(v)}function T(){return new URLSearchParams(window.location.search).get("authProvider")??""}function H({children:n}){return t.jsx(A,{getLoginOptions:I,children:n})}const V={Component:H,isAvailable:()=>window.opener!=null&&T()==="parent"},Y=V,y="io.deephaven.authentication.psk.PskAuthenticationHandler";async function G(){const n=new URLSearchParams(window.location.search).get("psk")??"";if(!n)throw new Error("No Pre-shared key token found. Add `psk=<token>` parameter to your URL");return{type:y,token:n}}function q({children:n}){return t.jsx(A,{getLoginOptions:G,children:n})}const D={Component:q,isAvailable:n=>n.includes(y)},J=D,Q=new Map([["@deephaven/auth-plugins.AuthPluginPsk",J],["@deephaven/auth-plugins.AuthPluginParent",Y],["@deephaven/auth-plugins.AuthPluginAnonymous",M]]);function W({children:n}){const e=C(),s=o.useContext(E),[i,a]=o.useState(),[r,p]=o.useState();o.useEffect(function(){let g=!1;async function l(){try{const f=await e.getAuthConfigValues();g||a(new Map(f))}catch(f){g||p(f)}}return l(),()=>{g=!0}},[e]);const c=o.useMemo(()=>{if(!(s==null||i==null))try{return O(s,i,Q)}catch(d){p(d)}},[i,s]),u=c==null||i==null;return u||r!=null?t.jsx(h,{isLoading:u,errorMessage:r!=null?`${r}`:void 0}):t.jsx(c,{authConfigValues:i,children:n})}function z({children:n}){return o.useContext(L)?t.jsx(t.Fragment,{children:n}):t.jsx(h,{"data-testid":"fonts-loaded-loading"})}function en({apiUrl:n,fontClassNames:e,pluginsUrl:s,children:i}){const a=k(n).origin,r=U();return t.jsx(R,{fontClassNames:e,children:t.jsx(S,{serverUrl:a,options:r,children:t.jsx(b,{pluginsUrl:s,children:t.jsx(W,{children:t.jsx(N,{children:t.jsx(z,{children:i})})})})})})}export{en as AppBootstrap,W as AuthBootstrap,N as ConnectionBootstrap,an as ConnectionContext,R as FontBootstrap,z as FontsLoaded,L as FontsLoadedContext,b as PluginsBootstrap,E as PluginsContext,rn as RemoteComponent,un as getAuthHandlers,O as getAuthPluginComponent,k as getBaseUrl,U as getConnectOptions,ln as getEnvoyPrefix,cn as loadComponentPlugin,dn as loadJson,gn as loadModulePlugin,pn as loadModulePlugins,fn as useConnection,hn as usePlugins};
2
- //# sourceMappingURL=index-33432f4c.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-33432f4c.js","sources":["../../../app-utils/src/components/FontBootstrap.tsx","../../../auth-plugins/src/AuthHandlerTypes.ts","../../../auth-plugins/src/AuthPluginBase.tsx","../../../auth-plugins/src/AuthPluginAnonymous.tsx","../../../auth-plugins/src/AuthPluginParent.tsx","../../../auth-plugins/src/AuthPluginPsk.tsx","../../../app-utils/src/components/AuthBootstrap.tsx","../../../app-utils/src/components/FontsLoaded.tsx","../../../app-utils/src/components/AppBootstrap.tsx"],"sourcesContent":["import React, { createContext, useEffect, useState } from 'react';\nimport 'fira';\n\nexport const FontsLoadedContext = createContext<boolean>(false);\n\nexport type FontBootstrapProps = {\n /**\n * Class names of the font elements to pre load\n */\n fontClassNames?: string[];\n\n /**\n * The children to render wrapped with the FontsLoadedContext.\n * Note that it renders the children even if the fonts aren't loaded yet.\n */\n children: React.ReactNode;\n};\n\n/**\n * FontBootstrap component. Handles preloading fonts.\n */\nexport function FontBootstrap({\n fontClassNames = ['fira-sans-regular', 'fira-sans-bold', 'fira-mono'],\n children,\n}: FontBootstrapProps) {\n const [isLoaded, setIsLoaded] = useState(false);\n useEffect(function initFonts() {\n document.fonts.ready.then(() => {\n setIsLoaded(true);\n });\n }, []);\n\n return (\n <>\n <FontsLoadedContext.Provider value={isLoaded}>\n {children}\n </FontsLoadedContext.Provider>\n {/*\n Need to preload any monaco and Deephaven grid fonts.\n We hide text with all the fonts we need on the root app.jsx page\n Load the Fira Mono font so that Monaco calculates word wrapping properly.\n This element doesn't need to be visible, just load the font and stay hidden.\n https://github.com/microsoft/vscode/issues/88689\n Can be replaced with a rel=\"preload\" when firefox adds support\n https://developer.mozilla.org/en-US/docs/Web/HTML/Preloading_content\n */}\n <div\n id=\"preload-fonts\"\n style={{ visibility: 'hidden', position: 'absolute', top: -10000 }}\n >\n {/* trigger loading of fonts needed by monaco and iris grid */}\n {fontClassNames.map(className => (\n <p key={className} className={className}>\n preload\n </p>\n ))}\n </div>\n </>\n );\n}\n\nexport default FontBootstrap;\n","export const AUTH_HANDLER_TYPE_ANONYMOUS =\n 'io.deephaven.auth.AnonymousAuthenticationHandler';\n\nexport const AUTH_HANDLER_TYPE_PSK =\n 'io.deephaven.authentication.psk.PskAuthenticationHandler';\n","import React, { useEffect, useState } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useApi, useClient } from '@deephaven/jsapi-bootstrap';\nimport Log from '@deephaven/log';\nimport { LoginOptions } from '@deephaven/jsapi-types';\nimport { CanceledPromiseError } from '@deephaven/utils';\n\nconst log = Log.module('AuthPluginAnonymous');\n\nexport type AuthPluginBaseProps = {\n /**\n * The children to render after authentication is completed.\n */\n children: React.ReactNode;\n\n /**\n * Retrieve the login options for logging in to the client\n * @returns A promise for the login options\n */\n getLoginOptions: () => Promise<LoginOptions>;\n};\n\n/**\n * Base AuthPlugin that gets passed a function for retrieving the login options, and then attempting to login with them.\n * @param getLoginOptions Function that returns a promise for the login options\n */\nfunction AuthPluginBase({\n children,\n getLoginOptions,\n}: AuthPluginBaseProps): JSX.Element {\n const client = useClient();\n const dh = useApi();\n const [error, setError] = useState<unknown>();\n const [isLoggedIn, setIsLoggedIn] = useState(false);\n\n useEffect(() => {\n let isCanceled = false;\n function verifyNotCanceled() {\n if (isCanceled) {\n throw new CanceledPromiseError('Login canceled.');\n }\n }\n async function login() {\n try {\n const loginOptions = await getLoginOptions();\n verifyNotCanceled();\n\n log.info('Logging in...');\n await client.login(loginOptions);\n verifyNotCanceled();\n\n setIsLoggedIn(true);\n } catch (e) {\n if (!isCanceled) {\n log.error('Unable to login:', e);\n setError(e);\n setIsLoggedIn(false);\n }\n }\n }\n login();\n return () => {\n isCanceled = true;\n };\n }, [client, dh, getLoginOptions]);\n\n if (!isLoggedIn) {\n return (\n <LoadingOverlay\n data-testid=\"auth-base-loading\"\n isLoading={error == null}\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n }\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{children}</>;\n}\n\nexport default AuthPluginBase;\n","import React, { useCallback } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { AUTH_HANDLER_TYPE_ANONYMOUS } from './AuthHandlerTypes';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\nimport AuthPluginBase from './AuthPluginBase';\n\n/**\n * AuthPlugin that tries to login anonymously. Fails if anonymous login fails\n */\nfunction Component({ children }: AuthPluginProps): JSX.Element {\n const dh = useApi();\n\n const getLoginOptions = useCallback(\n async () => ({ type: dh.CoreClient.LOGIN_TYPE_ANONYMOUS }),\n [dh]\n );\n\n return (\n <AuthPluginBase getLoginOptions={getLoginOptions}>\n {children}\n </AuthPluginBase>\n );\n}\n\nconst AuthPluginAnonymous: AuthPlugin = {\n Component,\n isAvailable: authHandlers =>\n authHandlers.includes(AUTH_HANDLER_TYPE_ANONYMOUS),\n};\n\nexport default AuthPluginAnonymous;\n","import React from 'react';\nimport { LoginOptions } from '@deephaven/jsapi-types';\nimport {\n LOGIN_OPTIONS_REQUEST,\n requestParentResponse,\n} from '@deephaven/jsapi-utils';\nimport Log from '@deephaven/log';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\nimport AuthPluginBase from './AuthPluginBase';\n\nconst log = Log.module('AuthPluginParent');\n\nfunction getLoginOptions(): Promise<LoginOptions> {\n log.info('Logging in by delegating to parent window...');\n return requestParentResponse<LoginOptions>(LOGIN_OPTIONS_REQUEST);\n}\n\nfunction getWindowAuthProvider(): string {\n return new URLSearchParams(window.location.search).get('authProvider') ?? '';\n}\n\n/**\n * AuthPlugin that tries to delegate to the parent window for authentication. Fails if there is no parent window.\n */\nfunction Component({ children }: AuthPluginProps): JSX.Element {\n return (\n <AuthPluginBase getLoginOptions={getLoginOptions}>\n {children}\n </AuthPluginBase>\n );\n}\n\nconst AuthPluginParent: AuthPlugin = {\n Component,\n isAvailable: () =>\n window.opener != null && getWindowAuthProvider() === 'parent',\n};\n\nexport default AuthPluginParent;\n","import React from 'react';\nimport { LoginOptions } from '@deephaven/jsapi-types';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\nimport AuthPluginBase from './AuthPluginBase';\n\nconst AUTH_TYPE = 'io.deephaven.authentication.psk.PskAuthenticationHandler';\n\nasync function getLoginOptions(): Promise<LoginOptions> {\n const token = new URLSearchParams(window.location.search).get('psk') ?? '';\n if (!token) {\n throw new Error(\n 'No Pre-shared key token found. Add `psk=<token>` parameter to your URL'\n );\n }\n return { type: AUTH_TYPE, token };\n}\n\n/**\n * AuthPlugin that tries to login using a pre-shared key.\n * Add the `psk=<token>` parameter to your URL string to set the token.\n */\nfunction Component({ children }: AuthPluginProps): JSX.Element {\n return (\n <AuthPluginBase getLoginOptions={getLoginOptions}>\n {children}\n </AuthPluginBase>\n );\n}\n\nconst AuthPluginPsk: AuthPlugin = {\n Component,\n isAvailable: authHandlers => authHandlers.includes(AUTH_TYPE),\n};\n\nexport default AuthPluginPsk;\n","import React, { useContext, useEffect, useMemo, useState } from 'react';\nimport {\n AuthConfigMap,\n AuthPluginAnonymous,\n AuthPluginParent,\n AuthPluginPsk,\n} from '@deephaven/auth-plugins';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useClient } from '@deephaven/jsapi-bootstrap';\nimport { PluginsContext } from './PluginsBootstrap';\nimport { getAuthPluginComponent } from '../plugins';\n\nexport type AuthBootstrapProps = {\n /**\n * The children to render after authentication is completed.\n */\n children: React.ReactNode;\n};\n\n/** Core auth plugins that are always loaded */\nconst CORE_AUTH_PLUGINS = new Map([\n ['@deephaven/auth-plugins.AuthPluginPsk', AuthPluginPsk],\n ['@deephaven/auth-plugins.AuthPluginParent', AuthPluginParent],\n ['@deephaven/auth-plugins.AuthPluginAnonymous', AuthPluginAnonymous],\n]);\n\n/**\n * AuthBootstrap component. Handles displaying the auth plugin and authenticating.\n */\nexport function AuthBootstrap({ children }: AuthBootstrapProps) {\n const client = useClient();\n // `useContext` instead of `usePlugins` so that we don't have to wait for the plugins to load\n // We want to load the auth config values in parallel with the plugins\n const plugins = useContext(PluginsContext);\n const [authConfig, setAuthConfig] = useState<AuthConfigMap>();\n const [error, setError] = useState<unknown>();\n\n useEffect(\n function initAuthConfigValues() {\n let isCanceled = false;\n async function loadAuthConfigValues() {\n try {\n const newAuthConfigValues = await client.getAuthConfigValues();\n if (!isCanceled) {\n setAuthConfig(new Map(newAuthConfigValues));\n }\n } catch (e) {\n if (!isCanceled) {\n setError(e);\n }\n }\n }\n loadAuthConfigValues();\n return () => {\n isCanceled = true;\n };\n },\n [client]\n );\n\n const AuthComponent = useMemo(() => {\n if (plugins == null || authConfig == null) {\n return undefined;\n }\n\n try {\n return getAuthPluginComponent(plugins, authConfig, CORE_AUTH_PLUGINS);\n } catch (e) {\n setError(e);\n }\n }, [authConfig, plugins]);\n\n const isLoading = AuthComponent == null || authConfig == null;\n\n if (isLoading || error != null) {\n return (\n <LoadingOverlay\n isLoading={isLoading}\n errorMessage={error != null ? `${error}` : undefined}\n />\n );\n }\n return (\n <AuthComponent authConfigValues={authConfig}>{children}</AuthComponent>\n );\n}\n\nexport default AuthBootstrap;\n","import React, { useContext } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { FontsLoadedContext } from './FontBootstrap';\n\nexport type FontsLoadedProps = {\n /** Children to show when the fonts have completed loading */\n children: React.ReactNode;\n};\n\nexport function FontsLoaded({ children }: FontsLoadedProps) {\n const isFontsLoaded = useContext(FontsLoadedContext);\n\n if (!isFontsLoaded) {\n return <LoadingOverlay data-testid=\"fonts-loaded-loading\" />;\n }\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{children}</>;\n}\n\nexport default FontsLoaded;\n","import React from 'react';\nimport '@deephaven/components/scss/BaseStyleSheet.scss';\nimport { ClientBootstrap } from '@deephaven/jsapi-bootstrap';\nimport FontBootstrap from './FontBootstrap';\nimport PluginsBootstrap from './PluginsBootstrap';\nimport AuthBootstrap from './AuthBootstrap';\nimport ConnectionBootstrap from './ConnectionBootstrap';\nimport { getBaseUrl, getConnectOptions } from '../utils';\nimport FontsLoaded from './FontsLoaded';\n\nexport type AppBootstrapProps = {\n /** URL of the API to load. */\n apiUrl: string;\n\n /** URL of the plugins to load. */\n pluginsUrl: string;\n\n /** Font class names to load. */\n fontClassNames?: string[];\n\n /**\n * The children to render wrapped when everything is loaded and authenticated.\n */\n children: React.ReactNode;\n};\n\n/**\n * AppBootstrap component. Handles loading the fonts, client, and authentication.\n * Will display the children when everything is loaded and authenticated.\n */\nexport function AppBootstrap({\n apiUrl,\n fontClassNames,\n pluginsUrl,\n children,\n}: AppBootstrapProps) {\n const serverUrl = getBaseUrl(apiUrl).origin;\n const clientOptions = getConnectOptions();\n return (\n <FontBootstrap fontClassNames={fontClassNames}>\n <ClientBootstrap serverUrl={serverUrl} options={clientOptions}>\n <PluginsBootstrap pluginsUrl={pluginsUrl}>\n <AuthBootstrap>\n <ConnectionBootstrap>\n <FontsLoaded>{children}</FontsLoaded>\n </ConnectionBootstrap>\n </AuthBootstrap>\n </PluginsBootstrap>\n </ClientBootstrap>\n </FontBootstrap>\n );\n}\n\nexport default AppBootstrap;\n"],"names":["FontsLoadedContext","createContext","FontBootstrap","fontClassNames","children","isLoaded","setIsLoaded","useState","useEffect","jsxs","Fragment","jsx","className","AUTH_HANDLER_TYPE_ANONYMOUS","log","Log","AuthPluginBase","getLoginOptions","client","useClient","dh","useApi","error","setError","isLoggedIn","setIsLoggedIn","isCanceled","verifyNotCanceled","CanceledPromiseError","login","loginOptions","e","LoadingOverlay","Component","useCallback","AuthPluginAnonymous","authHandlers","AuthPluginAnonymous$1","requestParentResponse","LOGIN_OPTIONS_REQUEST","getWindowAuthProvider","AuthPluginParent","AuthPluginParent$1","AUTH_TYPE","token","AuthPluginPsk","AuthPluginPsk$1","CORE_AUTH_PLUGINS","AuthBootstrap","plugins","useContext","PluginsContext","authConfig","setAuthConfig","loadAuthConfigValues","newAuthConfigValues","AuthComponent","useMemo","getAuthPluginComponent","isLoading","FontsLoaded","AppBootstrap","apiUrl","pluginsUrl","serverUrl","getBaseUrl","clientOptions","getConnectOptions","ClientBootstrap","PluginsBootstrap","ConnectionBootstrap"],"mappings":"gZAGa,MAAAA,EAAqBC,gBAAuB,EAAK,EAkBvD,SAASC,EAAc,CAC5B,eAAAC,EAAiB,CAAC,oBAAqB,iBAAkB,WAAW,EACpE,SAAAC,CACF,EAAuB,CACrB,KAAM,CAACC,EAAUC,CAAW,EAAIC,WAAS,EAAK,EAC9CC,OAAAA,EAAA,UAAU,UAAqB,CACpB,SAAA,MAAM,MAAM,KAAK,IAAM,CAC9BF,EAAY,EAAI,CAAA,CACjB,CACH,EAAG,CAAE,CAAA,EAIDG,EAAA,KAAAC,WAAA,CAAA,SAAA,CAAAC,EAAA,IAACX,EAAmB,SAAnB,CAA4B,MAAOK,EACjC,SAAAD,EACH,EAUAO,EAAA,IAAC,MAAA,CACC,GAAG,gBACH,MAAO,CAAE,WAAY,SAAU,SAAU,WAAY,IAAK,IAAO,EAGhE,SAAAR,EAAe,IACdS,GAAAD,EAAA,IAAC,KAAkB,UAAAC,EAAsB,SAAA,SAAA,EAAjCA,CAER,CACD,CAAA,CACH,CACF,CAAA,CAAA,CAEJ,CC3DO,MAAMC,EACX,mDCMIC,EAAMC,EAAI,OAAO,qBAAqB,EAmB5C,SAASC,EAAe,CACtB,SAAAZ,EACA,gBAAAa,CACF,EAAqC,CACnC,MAAMC,EAASC,IACTC,EAAKC,IACL,CAACC,EAAOC,CAAQ,EAAIhB,EAAkB,SAAA,EACtC,CAACiB,EAAYC,CAAa,EAAIlB,WAAS,EAAK,EAiClD,OA/BAC,EAAAA,UAAU,IAAM,CACd,IAAIkB,EAAa,GACjB,SAASC,GAAoB,CAC3B,GAAID,EACI,MAAA,IAAIE,EAAqB,iBAAiB,CAEpD,CACA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AO,CAAC,EAElBU,EAAYH,GAAiB,MAAQJ,GAAc,KAErD,OAAAO,GAAarC,GAAS,KAEtBX,EAAA,IAACqB,EAAA,CACC,UAAA2B,EACA,aAAcrC,GAAS,KAAO,GAAGA,IAAU,MAAA,CAAA,EAK9CX,EAAAA,IAAA6C,EAAA,CAAc,iBAAkBJ,EAAa,SAAAhD,CAAS,CAAA,CAE3D,CC5EgB,SAAAwD,EAAY,CAAE,SAAAxD,GAA8B,CAG1D,OAFsB8C,aAAWlD,CAAkB,oBAOzC,SAAAI,CAAS,CAAA,EAJVO,EAAA,IAACqB,EAAe,CAAA,cAAY,sBAAuB,CAAA,CAK9D,CCYO,SAAS6B,GAAa,CAC3B,OAAAC,EACA,eAAA3D,EACA,WAAA4D,EACA,SAAA3D,CACF,EAAsB,CACd,MAAA4D,EAAYC,EAAWH,CAAM,EAAE,OAC/BI,EAAgBC,IAEpB,OAAAxD,EAAAA,IAACT,GAAc,eAAAC,EACb,SAAAQ,EAAA,IAACyD,GAAgB,UAAAJ,EAAsB,QAASE,EAC9C,SAAAvD,EAAA,IAAC0D,EAAiB,CAAA,WAAAN,EAChB,eAACf,EACC,CAAA,SAAArC,EAAAA,IAAC2D,GACC,SAAC3D,MAAAiD,EAAA,CAAa,SAAAxD,EAAS,CACzB,CAAA,CAAA,CACF,CACF,CAAA,CAAA,CACF,CACF,CAAA,CAEJ"}
@@ -1,2 +0,0 @@
1
- import{A as l,C as d,I as h,H as P,R as $,aG as A,aH as M,aI as v,aJ as b,aK as L}from"./vendor-ef910ebc.js";import{aY as N,L as m,B as j}from"./index-a15ad815.js";class T extends Error{isCanceled=!0}const Z=T;class O extends Error{isTimeout=!0}const I=O;function p(e,n="No value available in context. Was code wrapped in a provider?"){const s=l.useContext(e);if(s==null)throw new Error(n);return s}function x(){return p(N,"No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?")}const E=l.createContext(null);function ee({serverUrl:e,options:n,children:s}){const r=x(),[a,t]=l.useState();return l.useEffect(function(){const u=new r.CoreClient(e,n);return t(u),()=>{u.disconnect()}},[r,n,e]),a==null?null:d.jsx(E.Provider,{value:a,children:s})}function U(){return p(E,"No Client available in useClient. Was code wrapped in ClientBootstrap or ClientContext.Provider?")}const C=m.module("MessageUtils"),ne="io.deephaven.message.LoginOptions.request",te="io.deephaven.message.SessionDetails.request";function q(e,n=h(),s){return{message:e,id:n,payload:s}}async function oe(e,n=3e4){if(window.opener==null)throw new Error("window.opener is null, unable to send request.");return new Promise((s,r)=>{let a;const t=h(),i=u=>{const{data:o}=u;if(C.debug("Received message",o),o?.id!==t){C.debug("Ignore message, id doesn't match",o);return}window.clearTimeout(a),window.removeEventListener("message",i),s(o.payload)};window.addEventListener("message",i),a=window.setTimeout(()=>{window.removeEventListener("message",i),r(new I("Request timed out"))},n),window.opener.postMessage(q(e,t),"*")})}function B(e){if(e==null)return!1;const n=e;return n.Component!==void 0&&typeof n.isAvailable=="function"}const y={react:P,"react-dom":$,redux:A,"react-redux":M},H=v.createRequires(()=>y),W=v.createRemoteComponent({requires:H}),J=W,_=b.createRequires(y),k=L({requires:_}),D=k,c=m.module("@deephaven/app-utils.PluginUtils");function se(e,n){const s=new URL(`${n}.js`,e),r=P.forwardRef((a,t)=>d.jsx(J,{url:s.href,render:({err:i,Component:u})=>{if(i!=null&&i!==""){const o=`Error loading plugin ${n} from ${s} due to ${i}`;return c.error(o),d.jsx("div",{className:"error-message",children:`${o}`})}return d.jsx(u,{ref:t,...a})}}));return r.pluginName=n,r.displayName="Plugin",r}async function F(e){return await D(e)}async function G(e){const n=await fetch(e);if(!n.ok)throw new Error(n.statusText);try{return await n.json()}catch{throw new Error("Could not be parsed as JSON")}}async function Q(e){c.debug("Loading plugins...");try{const n=await G(`${e}/manifest.json`);if(!Array.isArray(n.plugins))throw new Error("Plugin manifest JSON does not contain plugins array");c.debug("Plugin manifest loaded:",n);const s=[];for(let t=0;t<n.plugins.length;t+=1){const{name:i,main:u}=n.plugins[t],o=`${e}/${i}/${u}`;s.push(F(o))}const r=await Promise.allSettled(s),a=new Map;for(let t=0;t<r.length;t+=1){const i=r[t],{name:u}=n.plugins[t];i.status==="fulfilled"?a.set(u,i.value):c.error(`Unable to load plugin ${u}`,i.reason)}return c.info("Plugins loaded:",a),a}catch(n){return c.error("Unable to load plugins:",n),new Map}}function K(e){return e.get("AuthHandlers")?.split(",")??[]}function re(e,n,s){const r=K(n),a=[...e.entries()].filter(([,o])=>B(o.AuthPlugin)).map(([o,g])=>[o,g.AuthPlugin]);a.push(...s??[]);const t=a.filter(([o,g])=>g.isAvailable(r));if(t.length===0)throw new Error(`No login plugins found, please register a login plugin for auth handlers: ${r}`);t.length>1&&c.warn("More than one login plugin available, will use the first one: ",t.map(([o])=>o).join(", "));const[i,u]=t[0];return c.info("Using LoginPlugin",i),u.Component}const R=l.createContext(null);function ie({pluginsUrl:e,children:n}){const[s,r]=l.useState(null);return l.useEffect(function(){let t=!1;async function i(){const u=await Q(e);t||r(u)}return i(),()=>{t=!0}},[e]),d.jsx(R.Provider,{value:s,children:n})}const V=m.module("@deephaven/jsapi-components.ConnectionBootstrap"),S=l.createContext(null);function ae({children:e}){const n=x(),s=U(),[r,a]=l.useState(),[t,i]=l.useState();return l.useEffect(function(){let o=!1;async function g(){try{const f=await s.getAsIdeConnection();if(o)return;i(f)}catch(f){if(o)return;a(f)}}return g(),()=>{o=!0}},[n,s]),l.useEffect(function(){if(t==null)return;function o(f){const{detail:w}=f;V.info("Shutdown",`${JSON.stringify(w)}`),a(`Server shutdown: ${w??"Unknown reason"}`)}return t.addEventListener(n.IdeConnection.EVENT_SHUTDOWN,o)},[n,t]),t==null||r!=null?d.jsx(j,{"data-testid":"connection-bootstrap-loading",isLoading:t==null,errorMessage:r!=null?`${r}`:void 0}):d.jsx(S.Provider,{value:t,children:e})}function ue(e){return new URL(e,`${window.location}`)}function Y(){return new URLSearchParams(window.location.search).get("envoyPrefix")}function le(){const e=Y();return e!=null?{headers:{"envoy-prefix":e}}:{headers:{}}}function ce(){return p(R,"No Plugins available in usePlugins. Was code wrapped in PluginsBootstrap or PluginsContext.Provider?")}function de(){return p(S,"No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?")}export{Z as C,ne as L,R as P,J as R,te as S,I as T,de as a,ce as b,x as c,re as d,le as e,ee as f,ue as g,ie as h,ae as i,S as j,F as k,se as l,G as m,Q as n,K as o,Y as p,oe as r,U as u};
2
- //# sourceMappingURL=useConnection-38d9ed2c.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useConnection-38d9ed2c.js","sources":["../../../utils/src/CanceledPromiseError.ts","../../../utils/src/TimeoutError.ts","../../../react-hooks/src/useContextOrThrow.ts","../../../jsapi-bootstrap/src/useApi.ts","../../../jsapi-bootstrap/src/ClientBootstrap.tsx","../../../jsapi-bootstrap/src/useClient.ts","../../../jsapi-utils/src/MessageUtils.ts","../../../auth-plugins/src/AuthPlugin.ts","../../../app-utils/src/plugins/remote-component.config.ts","../../../app-utils/src/plugins/RemoteComponent.ts","../../../app-utils/src/plugins/loadRemoteModule.ts","../../../app-utils/src/plugins/PluginUtils.tsx","../../../app-utils/src/components/PluginsBootstrap.tsx","../../../app-utils/src/components/ConnectionBootstrap.tsx","../../../app-utils/src/utils/ConnectUtils.ts","../../../app-utils/src/components/usePlugins.ts","../../../app-utils/src/components/useConnection.ts"],"sourcesContent":["class CanceledPromiseError extends Error {\n isCanceled = true;\n}\n\nexport default CanceledPromiseError;\n","class TimeoutError extends Error {\n isTimeout = true;\n}\n\nexport default TimeoutError;\n","import React, { useContext } from 'react';\n\n/**\n * Fetch a given context or throw an error if it is null.\n * @param context Context to use\n * @param message Message to throw if context is null\n * @returns Context, or throws\n */\nexport function useContextOrThrow<T>(\n context: React.Context<T>,\n message = 'No value available in context. Was code wrapped in a provider?'\n): NonNullable<T> {\n const value = useContext(context);\n if (value == null) {\n throw new Error(message);\n }\n return value;\n}\n\nexport default useContextOrThrow;\n","import { useContextOrThrow } from '@deephaven/react-hooks';\nimport { ApiContext } from './ApiBootstrap';\n\nexport function useApi() {\n return useContextOrThrow(\n ApiContext,\n 'No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?'\n );\n}\n\nexport default useApi;\n","import React, { createContext, useEffect, useState } from 'react';\nimport { ConnectOptions, CoreClient } from '@deephaven/jsapi-types';\nimport useApi from './useApi';\n\nexport const ClientContext = createContext<CoreClient | null>(null);\n\nexport type ClientBootstrapProps = {\n /** URL of the server to connect to */\n serverUrl: string;\n\n /** Connection options to pass to CoreClient when connecting */\n options?: ConnectOptions;\n\n /**\n * The children to render wrapped with the ClientContext.\n * Will not render children until the client is created.\n */\n children: React.ReactNode;\n};\n\n/**\n * ClientBootstrap component. Handles creating the client.\n */\nexport function ClientBootstrap({\n serverUrl,\n options,\n children,\n}: ClientBootstrapProps) {\n const api = useApi();\n const [client, setClient] = useState<CoreClient>();\n useEffect(\n function initClient() {\n const newClient = new api.CoreClient(serverUrl, options);\n setClient(newClient);\n return () => {\n newClient.disconnect();\n };\n },\n [api, options, serverUrl]\n );\n\n if (client == null) {\n return null;\n }\n return (\n <ClientContext.Provider value={client}>{children}</ClientContext.Provider>\n );\n}\n\nexport default ClientBootstrap;\n","import { useContextOrThrow } from '@deephaven/react-hooks';\nimport { ClientContext } from './ClientBootstrap';\n\nexport function useClient() {\n return useContextOrThrow(\n ClientContext,\n 'No Client available in useClient. Was code wrapped in ClientBootstrap or ClientContext.Provider?'\n );\n}\n\nexport default useClient;\n","import shortid from 'shortid';\nimport Log from '@deephaven/log';\nimport { TimeoutError } from '@deephaven/utils';\n\nconst log = Log.module('MessageUtils');\n\nexport const LOGIN_OPTIONS_REQUEST =\n 'io.deephaven.message.LoginOptions.request';\n\nexport const SESSION_DETAILS_REQUEST =\n 'io.deephaven.message.SessionDetails.request';\n\nexport interface Message<T> {\n message: string;\n payload?: T;\n id: string;\n}\n\nexport interface Response<T> {\n id: string;\n payload: T;\n}\n\n/**\n * Make message object with optional payload\n * @param message Message string\n * @param id Unique message id\n * @param payload Payload to send\n * @returns Message\n */\nexport function makeMessage<T>(\n message: string,\n id = shortid(),\n payload?: T\n): Message<T> {\n return { message, id, payload };\n}\n\n/**\n * Make response object for given message id\n * @param messageId Id of the request message to respond to\n * @param payload Payload to respond with\n * @returns Response\n */\nexport function makeResponse<T>(messageId: string, payload: T): Response<T> {\n return { id: messageId, payload };\n}\n\n/**\n * Request data from the parent window and wait for response\n * @param request Request message to send to the parent window\n * @param timeout Timeout in ms\n * @returns Payload of the given type, or undefined\n */\nexport async function requestParentResponse<T>(\n request: string,\n timeout = 30000\n): Promise<T> {\n if (window.opener == null) {\n throw new Error('window.opener is null, unable to send request.');\n }\n return new Promise((resolve, reject) => {\n let timeoutId: number;\n const id = shortid();\n const listener = (event: MessageEvent<Response<T>>) => {\n const { data } = event;\n log.debug('Received message', data);\n if (data?.id !== id) {\n log.debug(\"Ignore message, id doesn't match\", data);\n return;\n }\n window.clearTimeout(timeoutId);\n window.removeEventListener('message', listener);\n resolve(data.payload);\n };\n window.addEventListener('message', listener);\n timeoutId = window.setTimeout(() => {\n window.removeEventListener('message', listener);\n reject(new TimeoutError('Request timed out'));\n }, timeout);\n window.opener.postMessage(makeMessage(request, id), '*');\n });\n}\n","import React from 'react';\n\n/**\n * Map from auth config keys to their values\n * E.g. Map { AuthHandlers → \"io.deephaven.auth.AnonymousAuthenticationHandler\" }\n */\nexport type AuthConfigMap = Map<string, string>;\n\n/**\n * Props for the auth plugin component to render\n */\nexport type AuthPluginProps = {\n /** Map from config keys to their values */\n authConfigValues: AuthConfigMap;\n\n /**\n * The children to render after authentication is completed.\n */\n children: React.ReactNode;\n};\n\nexport type AuthPluginComponent = React.FunctionComponent<AuthPluginProps>;\n\n/**\n * Whether the auth plugin is available given the current configuration\n */\nexport type AuthPluginIsAvailableFunction = (authHandlers: string[]) => boolean;\n\nexport type AuthPlugin = {\n Component: AuthPluginComponent;\n isAvailable: AuthPluginIsAvailableFunction;\n};\n\nexport function isAuthPlugin(plugin?: unknown): plugin is AuthPlugin {\n if (plugin == null) return false;\n const authPlugin = plugin as AuthPlugin;\n return (\n authPlugin.Component !== undefined &&\n typeof authPlugin.isAvailable === 'function'\n );\n}\n","/* eslint-disable global-require */\n/**\n * remote-component.config.js\n *\n * Dependencies for Remote Components\n */\nimport react from 'react';\nimport * as redux from 'redux';\nimport * as reactRedux from 'react-redux';\nimport ReactDOM from 'react-dom';\n\n// eslint-disable-next-line import/prefer-default-export\nexport const resolve = {\n react,\n 'react-dom': ReactDOM,\n redux,\n 'react-redux': reactRedux,\n};\n","import {\n createRemoteComponent,\n createRequires,\n} from '@paciolan/remote-component';\nimport { resolve } from './remote-component.config';\n\nconst requires = createRequires(() => resolve);\n\nexport const RemoteComponent = createRemoteComponent({ requires });\nexport default RemoteComponent;\n","import createLoadRemoteModule, {\n createRequires,\n} from '@paciolan/remote-module-loader';\nimport { resolve } from './remote-component.config';\n\nconst requires = createRequires(resolve);\n\nexport const loadRemoteModule: {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (url: string): Promise<any>;\n} = createLoadRemoteModule({\n requires,\n});\n\nexport default loadRemoteModule;\n","import React, { ForwardRefExoticComponent } from 'react';\nimport {\n AuthPlugin,\n AuthPluginComponent,\n isAuthPlugin,\n} from '@deephaven/auth-plugins';\nimport Log from '@deephaven/log';\nimport RemoteComponent from './RemoteComponent';\nimport loadRemoteModule from './loadRemoteModule';\n\nconst log = Log.module('@deephaven/app-utils.PluginUtils');\n\n// A PluginModule. This interface should have new fields added to it from different levels of plugins.\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface PluginModule {}\n\nexport type PluginModuleMap = Map<string, PluginModule>;\n\n/**\n * Load a component plugin from the server.\n * @param baseURL Base URL of the plugin server\n * @param pluginName Name of the component plugin to load\n * @returns A lazily loaded JSX.Element from the plugin\n */\nexport function loadComponentPlugin(\n baseURL: URL,\n pluginName: string\n): ForwardRefExoticComponent<React.RefAttributes<unknown>> {\n const pluginUrl = new URL(`${pluginName}.js`, baseURL);\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Plugin: any = React.forwardRef((props, ref) => (\n <RemoteComponent\n url={pluginUrl.href}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n render={({ err, Component }: { err: unknown; Component: any }) => {\n if (err != null && err !== '') {\n const errorMessage = `Error loading plugin ${pluginName} from ${pluginUrl} due to ${err}`;\n log.error(errorMessage);\n return <div className=\"error-message\">{`${errorMessage}`}</div>;\n }\n // eslint-disable-next-line react/jsx-props-no-spreading\n return <Component ref={ref} {...props} />;\n }}\n />\n ));\n Plugin.pluginName = pluginName;\n Plugin.displayName = 'Plugin';\n return Plugin;\n}\n\n/**\n * Imports a commonjs plugin module from the provided URL\n * @param pluginUrl The URL of the plugin to load\n * @returns The loaded module\n */\nexport async function loadModulePlugin(pluginUrl: string): Promise<unknown> {\n const myModule = await loadRemoteModule(pluginUrl);\n return myModule;\n}\n\n/**\n * Loads a JSON file and returns the JSON object\n * @param jsonUrl The URL of the JSON file to load\n * @returns The JSON object of the manifest file\n */\nexport async function loadJson(\n jsonUrl: string\n): Promise<{ plugins: { name: string; main: string }[] }> {\n const res = await fetch(jsonUrl);\n if (!res.ok) {\n throw new Error(res.statusText);\n }\n try {\n return await res.json();\n } catch {\n throw new Error('Could not be parsed as JSON');\n }\n}\n\n/**\n * Load all plugin modules available.\n * @param modulePluginsUrl The base URL of the module plugins to load\n * @returns A map from the name of the plugin to the plugin module that was loaded\n */\nexport async function loadModulePlugins(\n modulePluginsUrl: string\n): Promise<PluginModuleMap> {\n log.debug('Loading plugins...');\n try {\n const manifest = await loadJson(`${modulePluginsUrl}/manifest.json`);\n\n if (!Array.isArray(manifest.plugins)) {\n throw new Error('Plugin manifest JSON does not contain plugins array');\n }\n\n log.debug('Plugin manifest loaded:', manifest);\n const pluginPromises: Promise<unknown>[] = [];\n for (let i = 0; i < manifest.plugins.length; i += 1) {\n const { name, main } = manifest.plugins[i];\n const pluginMainUrl = `${modulePluginsUrl}/${name}/${main}`;\n pluginPromises.push(loadModulePlugin(pluginMainUrl));\n }\n const pluginModules = await Promise.allSettled(pluginPromises);\n\n const pluginMap: PluginModuleMap = new Map();\n for (let i = 0; i < pluginModules.length; i += 1) {\n const module = pluginModules[i];\n const { name } = manifest.plugins[i];\n if (module.status === 'fulfilled') {\n pluginMap.set(name, module.value as PluginModule);\n } else {\n log.error(`Unable to load plugin ${name}`, module.reason);\n }\n }\n log.info('Plugins loaded:', pluginMap);\n\n return pluginMap;\n } catch (e) {\n log.error('Unable to load plugins:', e);\n return new Map();\n }\n}\n\nexport function getAuthHandlers(\n authConfigValues: Map<string, string>\n): string[] {\n return authConfigValues.get('AuthHandlers')?.split(',') ?? [];\n}\n\n/**\n * Get the auth plugin component from the plugin map and current configuration\n * Throws if no auth plugin is available\n *\n * @param pluginMap Map of plugins loaded from the server\n * @param authConfigValues Auth config values from the server\n * @param corePlugins Map of core auth plugins to include in the list. They are added after the loaded plugins\n * @returns The auth plugin component to render\n */\nexport function getAuthPluginComponent(\n pluginMap: PluginModuleMap,\n authConfigValues: Map<string, string>,\n corePlugins?: Map<string, AuthPlugin>\n): AuthPluginComponent {\n const authHandlers = getAuthHandlers(authConfigValues);\n // Filter out all the plugins that are auth plugins, and then map them to [pluginName, AuthPlugin] pairs\n // Uses some pretty disgusting casting, because TypeScript wants to treat it as an (string | AuthPlugin)[] array instead\n const authPlugins = ([\n ...pluginMap.entries(),\n ].filter(([, plugin]: [string, { AuthPlugin?: AuthPlugin }]) =>\n isAuthPlugin(plugin.AuthPlugin)\n ) as [string, { AuthPlugin: AuthPlugin }][]).map(([name, plugin]) => [\n name,\n plugin.AuthPlugin,\n ]) as [string, AuthPlugin][];\n\n // Add all the core plugins in priority\n authPlugins.push(...(corePlugins ?? []));\n\n // Filter the available auth plugins\n\n const availableAuthPlugins = authPlugins.filter(([name, authPlugin]) =>\n authPlugin.isAvailable(authHandlers)\n );\n\n if (availableAuthPlugins.length === 0) {\n throw new Error(\n `No login plugins found, please register a login plugin for auth handlers: ${authHandlers}`\n );\n } else if (availableAuthPlugins.length > 1) {\n log.warn(\n 'More than one login plugin available, will use the first one: ',\n availableAuthPlugins.map(([name]) => name).join(', ')\n );\n }\n\n const [loginPluginName, NewLoginPlugin] = availableAuthPlugins[0];\n log.info('Using LoginPlugin', loginPluginName);\n\n return NewLoginPlugin.Component;\n}\n","import React, { createContext, useEffect, useState } from 'react';\nimport { PluginModuleMap, loadModulePlugins } from '../plugins';\n\nexport const PluginsContext = createContext<PluginModuleMap | null>(null);\n\nexport type PluginsBootstrapProps = {\n /**\n * Base URL of the plugins to load.\n */\n pluginsUrl: string;\n\n /**\n * The children to render wrapped with the PluginsContext.\n * Note that it renders the children even if the plugins aren't loaded yet.\n */\n children: React.ReactNode;\n};\n\n/**\n * PluginsBootstrap component. Handles loading the plugins.\n */\nexport function PluginsBootstrap({\n pluginsUrl,\n children,\n}: PluginsBootstrapProps) {\n const [plugins, setPlugins] = useState<PluginModuleMap | null>(null);\n useEffect(\n function initPlugins() {\n let isCancelled = false;\n async function loadPlugins() {\n const pluginModules = await loadModulePlugins(pluginsUrl);\n if (!isCancelled) {\n setPlugins(pluginModules);\n }\n }\n loadPlugins();\n return () => {\n isCancelled = true;\n };\n },\n [pluginsUrl]\n );\n\n return (\n <PluginsContext.Provider value={plugins}>\n {children}\n </PluginsContext.Provider>\n );\n}\n\nexport default PluginsBootstrap;\n","import React, { createContext, useEffect, useState } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useApi, useClient } from '@deephaven/jsapi-bootstrap';\nimport { IdeConnection } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\n\nconst log = Log.module('@deephaven/jsapi-components.ConnectionBootstrap');\n\nexport const ConnectionContext = createContext<IdeConnection | null>(null);\n\nexport type ConnectionBootstrapProps = {\n /**\n * The children to render wrapped with the ConnectionContext.\n * Will not render children until the connection is created.\n */\n children: React.ReactNode;\n};\n\n/**\n * ConnectionBootstrap component. Handles initializing the connection.\n */\nexport function ConnectionBootstrap({ children }: ConnectionBootstrapProps) {\n const api = useApi();\n const client = useClient();\n const [error, setError] = useState<unknown>();\n const [connection, setConnection] = useState<IdeConnection>();\n useEffect(\n function initConnection() {\n let isCancelled = false;\n async function loadConnection() {\n try {\n const newConnection = await client.getAsIdeConnection();\n if (isCancelled) {\n return;\n }\n setConnection(newConnection);\n } catch (e) {\n if (isCancelled) {\n return;\n }\n setError(e);\n }\n }\n loadConnection();\n return () => {\n isCancelled = true;\n };\n },\n [api, client]\n );\n\n useEffect(\n function listenForShutdown() {\n if (connection == null) return;\n\n function handleShutdown(event: CustomEvent) {\n const { detail } = event;\n log.info('Shutdown', `${JSON.stringify(detail)}`);\n setError(`Server shutdown: ${detail ?? 'Unknown reason'}`);\n }\n\n const removerFn = connection.addEventListener(\n api.IdeConnection.EVENT_SHUTDOWN,\n handleShutdown\n );\n return removerFn;\n },\n [api, connection]\n );\n\n if (connection == null || error != null) {\n return (\n <LoadingOverlay\n data-testid=\"connection-bootstrap-loading\"\n isLoading={connection == null}\n errorMessage={error != null ? `${error}` : undefined}\n />\n );\n }\n\n return (\n <ConnectionContext.Provider value={connection}>\n {children}\n </ConnectionContext.Provider>\n );\n}\n\nexport default ConnectionBootstrap;\n","import { ConnectOptions } from '@deephaven/jsapi-types';\n\n/**\n * Get the base URL of the API\n * @param apiUrl API URL\n * @returns URL for the base of the API\n */\nexport function getBaseUrl(apiUrl: string): URL {\n return new URL(apiUrl, `${window.location}`);\n}\n\n/**\n * Get the Envoy prefix header value\n * @returns Envoy prefix header value\n */\nexport function getEnvoyPrefix(): string | null {\n const searchParams = new URLSearchParams(window.location.search);\n return searchParams.get('envoyPrefix');\n}\n\nexport function getConnectOptions(): ConnectOptions {\n const envoyPrefix = getEnvoyPrefix();\n return envoyPrefix != null\n ? { headers: { 'envoy-prefix': envoyPrefix } }\n : { headers: {} };\n}\n","import { useContextOrThrow } from '@deephaven/react-hooks';\nimport { PluginsContext } from './PluginsBootstrap';\n\nexport function usePlugins() {\n return useContextOrThrow(\n PluginsContext,\n 'No Plugins available in usePlugins. Was code wrapped in PluginsBootstrap or PluginsContext.Provider?'\n );\n}\n\nexport default usePlugins;\n","import { useContextOrThrow } from '@deephaven/react-hooks';\nimport { ConnectionContext } from './ConnectionBootstrap';\n\nexport function useConnection() {\n return useContextOrThrow(\n ConnectionContext,\n 'No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?'\n );\n}\n\nexport default useConnection;\n"],"names":["CanceledPromiseError","CanceledPromiseError$1","TimeoutError","TimeoutError$1","useContextOrThrow","context","message","value","useContext","useApi","ApiContext","ClientContext","createContext","ClientBootstrap","serverUrl","options","children","api","client","setClient","useState","useEffect","newClient","useClient","log","Log","LOGIN_OPTIONS_REQUEST","SESSION_DETAILS_REQUEST","makeMessage","id","shortid","payload","requestParentResponse","request","timeout","resolve","reject","timeoutId","listener","event","data","isAuthPlugin","plugin","authPlugin","react","ReactDOM","redux","reactRedux","requires","createRequires","RemoteComponent","createRemoteComponent","RemoteComponent$1","loadRemoteModule","createLoadRemoteModule","loadRemoteModule$1","loadComponentPlugin","baseURL","pluginName","pluginUrl","Plugin","React","props","ref","jsx","err","Component","errorMessage","loadModulePlugin","loadJson","jsonUrl","res","loadModulePlugins","modulePluginsUrl","manifest","pluginPromises","i","name","main","pluginMainUrl","pluginModules","pluginMap","module","e","getAuthHandlers","authConfigValues","getAuthPluginComponent","corePlugins","authHandlers","authPlugins","availableAuthPlugins","loginPluginName","NewLoginPlugin","PluginsContext","PluginsBootstrap","pluginsUrl","plugins","setPlugins","isCancelled","loadPlugins","ConnectionContext","ConnectionBootstrap","error","setError","connection","setConnection","loadConnection","newConnection","handleShutdown","detail","LoadingOverlay","getBaseUrl","apiUrl","getEnvoyPrefix","getConnectOptions","envoyPrefix","usePlugins","useConnection"],"mappings":"oKAAA,MAAMA,UAA6B,KAAM,CACvC,WAAa,EACf,CAEA,MAAAC,EAAeD,ECJf,MAAME,U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