@deephaven/embed-chart 0.37.4-beta.0 → 0.37.4-beta.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
- var S=Object.defineProperty;var B=(r,e,s)=>e in r?S(r,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[e]=s;var u=(r,e,s)=>(B(r,typeof e!="symbol"?e+"":e,s),s);import{A as d,R,C as n,D as L,E as x,F as j,G as _}from"./vendor-73e67738.js";import"./helpers-042e6b4d.js";(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const t of document.querySelectorAll('link[rel="modulepreload"]'))a(t);new MutationObserver(t=>{for(const o of t)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&a(l)}).observe(document,{childList:!0,subtree:!0});function s(t){const o={};return t.integrity&&(o.integrity=t.integrity),t.referrerPolicy&&(o.referrerPolicy=t.referrerPolicy),t.crossOrigin==="use-credentials"?o.credentials="include":t.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function a(t){if(t.ep)return;t.ep=!0;const o=s(t);fetch(t.href,o)}})();const C="modulepreload",O=function(r,e){return new URL(r,e).href},k={},w=function(e,s,a){if(!s||s.length===0)return e();const t=document.getElementsByTagName("link");return Promise.all(s.map(o=>{if(o=O(o,a),o in k)return;k[o]=!0;const l=o.endsWith(".css"),h=l?'[rel="stylesheet"]':"";if(!!a)for(let p=t.length-1;p>=0;p--){const c=t[p];if(c.href===o&&(!l||c.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${o}"]${h}`))return;const i=document.createElement("link");if(i.rel=l?"stylesheet":C,l||(i.as="script",i.crossOrigin=""),i.href=o,document.head.appendChild(i),l)return new Promise((p,c)=>{i.addEventListener("load",p),i.addEventListener("error",()=>c(new Error(`Unable to preload CSS for ${o}`)))})})).then(()=>e())};const $="#1a171a",D="#f0f0ee",H="#fcd65b",T="#9edc6f",F="#76d9e4",U="#aa9af4",V="#f37e3f",G="#f95d84",W="#4878ea",K="#5b5a5c",q="#9edc6f",J="#fcd65b",Q="#f37e3f",X="#f95d84",Y="#fcfcfa",Z="#929192",ee="#373438",te="#1a171a",se="#f0f0ee",ne="0.15s",re={"gray-100":"#fcfcfa","gray-200":"#f0f0ee","gray-300":"#c0bfbf","gray-400":"#929192","gray-500":"#5b5a5c","gray-600":"#555356","gray-700":"#403e41","gray-800":"#373438","gray-850":"#322f33","gray-900":"#211f22",black:$,white:D,yellow:H,green:T,blue:F,purple:U,orange:V,red:G,primary:W,"primary-hover":"#235de6","primary-dark":"#343e5d",secondary:K,success:q,info:J,warning:Q,danger:X,light:Y,mid:Z,dark:ee,"text-muted":"#929192","content-bg":"#2d2a2e",background:te,foreground:se,transition:ne},oe={transitionMs:150,transitionMidMs:200,transitionLongMs:300,transitionSlowMs:1e3},E=Object.freeze({...oe,...re}),ae=0,ie=1,z=2,le=3,ce=4,f=()=>{};class de{constructor(e,s){u(this,"name");u(this,"prefix");u(this,"level");u(this,"error");u(this,"warn");u(this,"log");u(this,"info");u(this,"debug");u(this,"debug2");this.name=e,this.prefix=e!=null?`[${e}]`:"",this.error=f,this.warn=f,this.log=f,this.info=f,this.debug=f,this.debug2=f,this.level=s,this.setLogLevel(s)}setLogLevel(e){if(!Number.isFinite(e)){console.warn(`Expected a number for log level. Received: ${e}. Ignoring`);return}this.level=e,this.error=e>=ae?console.error.bind(console,this.prefix):f,this.warn=e>=ie?console.warn.bind(console,this.prefix):f,this.log=e>=z?console.log.bind(console,this.prefix):f,this.info=this.log,this.debug=e>=le?console.debug.bind(console,this.prefix):f,this.debug2=e>=ce?console.debug.bind(console,this.prefix):f}}const M=de;class ue extends M{constructor(s=z){super(null,s);u(this,"modules");this.modules={}}module(s){return this.modules[s]==null&&(this.modules[s]=new M(s,this.level)),this.modules[s]}setLogLevel(s){if(super.setLogLevel(s),this.modules==null)return;const a=Object.keys(this.modules);for(let t=0;t<a.length;t+=1)this.modules[a[t]].setLogLevel(s)}}const fe=ue,me=new fe,he=me;function pe({className:r="theme-bg-light",children:e,role:s="role",keyboard:a=!0,isOpen:t=!1,centered:o=!1,size:l,onOpened:h,onClosed:g,toggle:i,"data-testid":p}){const c=d.useRef(),v=d.useRef(null),[P,N]=d.useState(!1),b=d.useCallback(m=>{switch(m.key){case"Escape":i==null||i();break}},[i]);d.useEffect(function(){if(t&&a)return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[b,t,a]),d.useEffect(function(){t&&h&&h()},[h,t]),d.useEffect(function(){!t&&g&&g()},[g,t]),t&&!c.current&&(c.current=document.createElement("div"),c.current.setAttribute("style","padding-right: 15px; display: block"),c.current.setAttribute("role","presentation"),document.body.appendChild(c.current));const A=()=>{c.current&&(document.body.removeChild(c.current),c.current=void 0)};return c.current?R.createPortal(n.jsxs(n.Fragment,{children:[n.jsx(L,{appear:!0,mountOnEnter:!0,unmountOnExit:!0,in:t,classNames:{appearActive:"show",appearDone:"show"},timeout:E.transitionMs,onExited:A,children:n.jsx("div",{className:x("modal-backdrop fade"),style:{zIndex:1050}})}),n.jsx(L,{appear:!0,mountOnEnter:!0,unmountOnExit:!0,in:t,classNames:{appearDone:"show"},timeout:E.transitionMs,onExited:A,children:n.jsx("div",{ref:v,className:"modal fade",onMouseDown:m=>{m.target===v.current?N(!0):N(!1)},onMouseUp:m=>{P&&m.target===v.current&&i!==void 0&&i()},role:"dialog",style:{display:"block"},children:n.jsx("div",{className:x(`modal-dialog ${r}`,{"modal-lg":l==="lg","modal-sm":l==="sm","modal-xl":l==="xl","modal-dialog-centered":o}),style:{zIndex:1040},children:n.jsx("div",{className:"modal-content",role:"presentation","data-testid":p,children:e})})})})]}),c.current):null}function ge({className:r="modal-body",style:e,children:s,"data-testid":a}){return n.jsx("div",{className:r,"data-testid":a,style:e,children:s})}function xe({className:r,children:e,closeButton:s=!0,style:a,toggle:t,"data-testid":o}){return n.jsxs("div",{className:`modal-header ${r}`,style:a,children:[n.jsx("h5",{className:"modal-title",children:e}),s&&n.jsx("button",{type:"button",className:"close","data-dismiss":"modal","aria-label":"Close",onClick:t,children:n.jsx("span",{"aria-hidden":"true",children:"×"})})]})}var Re={prefix:"vs",iconName:"chevron-right",icon:[512,512,[],"f000","M322.304 256.768 182.88 117.344l19.776 -19.84L352 246.912v19.776L202.656 416l-19.776 -19.808 139.424 -139.424z"]},ve={prefix:"vs",iconName:"circle-large-outline",icon:[512,512,[],"f000","M306.816 70.88A185.856 185.856 0 0 0 256 64c-17.728 0 -34.624 2.336 -50.816 6.88l-0.192 0.064c-16.448 4.512 -31.68 10.944 -45.824 19.232A196.992 196.992 0 0 0 90.24 159.36l-0.064 0.128A190.944 190.944 0 0 0 70.72 205.12 191.552 191.552 0 0 0 64 256c0 17.76 2.24 34.72 6.72 50.912a193.6 193.6 0 0 0 49.536 84.832c11.84 11.68 24.768 21.664 38.912 30.08a195.2 195.2 0 0 0 45.92 19.488A192.64 192.64 0 0 0 256 448c17.76 0 34.72 -2.24 50.912 -6.72 16.48 -4.64 31.68 -11.136 45.632 -19.424l0.128 -0.064a197.12 197.12 0 0 0 69.152 -68.96 187.2 187.2 0 0 0 19.2 -45.824l0.096 -0.192A185.824 185.824 0 0 0 448 256c0 -17.728 -2.304 -34.624 -6.88 -50.816l-0.064 -0.192a184.704 184.704 0 0 0 -19.2 -45.536l-0.064 -0.128a188.8 188.8 0 0 0 -30.144 -38.72l-0.256 -0.256a188.864 188.864 0 0 0 -38.72 -30.144l-0.128 -0.064a184.704 184.704 0 0 0 -45.536 -19.2l-0.192 -0.064zm142.56 298.24a229.024 229.024 0 0 1 -80.512 80.256 222.912 222.912 0 0 1 -53.376 22.72A223.488 223.488 0 0 1 256 480a223.488 223.488 0 0 1 -59.52 -7.872 227.136 227.136 0 0 1 -53.568 -22.752 233.6 233.6 0 0 1 -45.28 -35.008 233.44 233.44 0 0 1 -35.008 -45.28 227.136 227.136 0 0 1 -22.72 -53.6A223.52 223.52 0 0 1 32 256c0 -20.576 2.624 -40.384 7.872 -59.52a222.976 222.976 0 0 1 22.752 -53.344 228.992 228.992 0 0 1 80.288 -80.512 220.64 220.64 0 0 1 53.6 -22.528A217.856 217.856 0 0 1 256 32a217.6 217.6 0 0 1 59.52 8.096 220.768 220.768 0 0 1 98.656 57.76 220.896 220.896 0 0 1 57.728 98.656C477.312 215.616 480 235.424 480 256s-2.688 40.384 -8.096 59.52a220.8 220.8 0 0 1 -22.528 53.568z"]},be={prefix:"vs",iconName:"loading",icon:[512,512,[],"f000","M445.344 224A192.064 192.064 0 0 0 66.656 224H34.272a224.064 224.064 0 0 1 443.456 0h-32.384z"]},ye={prefix:"vs",iconName:"warning",icon:[512,512,[],"f000","M241.92 32h28.16l209.28 392.32 -14.08 23.68H46.08L32 424.32 241.92 32zM256 72.96 72.96 416H438.4L256 72.96zM276 384v-32h-40v32h40zm-40 -64V192h40v128h-40z"]},_e={prefix:"dh",iconName:"graph-line-down",icon:[512,512,[],"f000","M64 416V0H32v432l16 16H480v-32zm67.2 -291.2 -22.4 22.4 108.8 112 70.4 -64 108.8 124.8H320v32h112l16 -16V224h-32v70.4L288 150.4l-70.4 64z"]},ze={prefix:"dh",iconName:"warning-filled",icon:[512,512,[],"f000","M268.8 32h-25.6L32 425.6l12.8 22.4h419.2l12.8 -22.4L268.8 32zm6.4 352H236.8v-32h38.4v32zm0 -64H236.8V192h38.4v128z"]};function Le({className:r="","data-testid":e}){return n.jsxs("div",{className:x("loading-spinner fa-layers",r),"data-testid":e,children:[n.jsx(j,{icon:ve,className:"text-white-50"}),n.jsx(j,{icon:be,className:"text-primary",spin:!0})]})}function I({isLoaded:r=!1,isLoading:e=!0,errorMessage:s=null,"data-testid":a}){return n.jsx(L,{in:Boolean(s)||!r||e,timeout:E.transitionMs,classNames:r?"fade":"",mountOnEnter:!0,unmountOnExit:!0,children:n.jsx("div",{className:"fill-parent-absolute","data-testid":a,children:n.jsx("div",{className:x("iris-panel-message-overlay","fill-parent-absolute",{"iris-panel-scrim-background":r}),children:n.jsxs("div",{className:"message-content",children:[n.jsxs("div",{className:"message-icon",children:[e&&n.jsx(Le,{}),!e&&s!=null&&n.jsx(j,{icon:ye})]}),n.jsx("div",{className:"message-text",children:s})]})})})})}const y=he.module("@deephaven/jsapi-bootstrap.ApiBootstrap"),je=d.createContext(null);function Ee({apiUrl:r,children:e,failureElement:s,setGlobally:a=!1}){const[t,o]=d.useState(!0),[l,h]=d.useState();return d.useEffect(()=>{async function g(){try{const i=(await w(()=>import(r),[],import.meta.url)).default;y.info("API bootstrapped from",r),h(i),a&&(y.debug("API set globally"),globalThis.dh=i)}catch(i){y.error("Unable to bootstrap API",i)}o(!1)}g()},[r,a]),t?n.jsx(I,{}):l==null?s??n.jsxs(pe,{isOpen:!0,className:"modal-dialog-centered theme-bg-light",children:[n.jsx(xe,{closeButton:!1,children:"Error: Unable to load API"}),n.jsx(ge,{children:n.jsxs("p",{className:"text-break",children:["Ensure the server is running and you are able to reach ",r,", then refresh the page."]})})]}):n.jsx(je.Provider,{value:l,children:e})}const we=_.lazy(()=>w(()=>import("./App-97a93d70.js"),["./App-97a93d70.js","./vendor-73e67738.js","./helpers-042e6b4d.js","./vendor-458ea229.css","./useConnection-e7328bfb.js","./plotly-b2b7fdc4.js","./App-a2eeb683.css"],import.meta.url)),Ne=_.lazy(async()=>({default:(await w(()=>import("./index-b88ed4a8.js"),["./index-b88ed4a8.js","./vendor-73e67738.js","./helpers-042e6b4d.js","./vendor-458ea229.css","./useConnection-e7328bfb.js"],import.meta.url)).AppBootstrap}));R.render(n.jsx(Ee,{apiUrl:"/jsapi/dh-core.js",setGlobally:!0,children:n.jsx(d.Suspense,{fallback:n.jsx(I,{}),children:n.jsx(Ne,{apiUrl:"/jsapi",pluginsUrl:"/js-plugins",children:n.jsx(we,{})})})}),document.getElementById("root"));export{je as A,he as L,Le as a,be as b,_e as c,ze as d,I as e,Re as v};
2
- //# sourceMappingURL=index-7bce681d.js.map
@@ -1,2 +0,0 @@
1
- import{M as L,A as l,C as u,G as E,R as k,N as O,O as N,P as M,Q as T,S as I}from"./vendor-73e67738.js";import{L as h,e as m}from"./index-7bce681d.js";import{T as _,a as q,b as H,C as B,c as F}from"./useConnection-e7328bfb.js";import{d as ke,e as Oe,u as Ne}from"./useConnection-e7328bfb.js";import"./helpers-042e6b4d.js";const x=h.module("MessageUtils"),V="io.deephaven.message.LoginOptions.request";function Y(e,n=L(),i){return{message:e,id:n,payload:i}}async function G(e,n=3e4){if(window.opener==null)throw new Error("window.opener is null, unable to send request.");return new Promise((i,s)=>{let a;const t=L(),o=c=>{const{data:r}=c;if(x.debug("Received message",r),(r==null?void 0:r.id)!==t){x.debug("Ignore message, id doesn't match",r);return}window.clearTimeout(a),window.removeEventListener("message",o),i(r.payload)};window.addEventListener("message",o),a=window.setTimeout(()=>{window.removeEventListener("message",o),s(new _("Request timed out"))},n),window.opener.postMessage(Y(e,t),"*")})}const $=l.createContext(!1);function J({fontClassNames:e=["fira-sans-regular","fira-sans-bold","fira-mono"],children:n}){const[i,s]=l.useState(!1);return l.useEffect(function(){document.fonts.ready.then(()=>{s(!0)})},[]),u.jsxs(u.Fragment,{children:[u.jsx($.Provider,{value:i,children:n}),u.jsx("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:e.map(a=>u.jsx("p",{className:a,children:"preload"},a))})]})}function W(e){if(e==null)return!1;const n=e;return n.Component!==void 0&&typeof n.isAvailable=="function"}const D="io.deephaven.auth.AnonymousAuthenticationHandler",f=h.module("AuthPluginAnonymous");function Q({client:e,onSuccess:n,onFailure:i}){const[s,a]=l.useState(),t=q();return l.useEffect(()=>{let o=!1;async function c(){try{if(f.info("Logging in..."),await e.login({type:t.CoreClient.LOGIN_TYPE_ANONYMOUS}),o){f.info("Previous login result canceled");return}f.info("Logged in successfully."),n()}catch(r){if(o){f.info("Previous login failure canceled");return}f.error("Unable to login:",r),a(r),i(r)}}return c(),()=>{o=!0}},[e,t,i,n]),u.jsx(m,{"data-testid":"auth-anonymous-loading",isLoading:!0,isLoaded:!1,errorMessage:s!=null?`${s}`:null})}const z={Component:Q,isAvailable:e=>e.includes(D)},K=z,C=h.module("AuthPluginParent");function X(){return new URLSearchParams(window.location.search).get("authProvider")??""}function Z({client:e,onSuccess:n,onFailure:i}){const[s,a]=l.useState();return l.useEffect(()=>{async function t(){try{C.info("Logging in by delegating to parent window...");const o=await G(V);await e.login(o),C.info("Logged in successfully."),n()}catch(o){C.error("Unable to login:",o),a(o),i(o)}}t()},[e,i,n]),u.jsx(m,{"data-testid":"auth-parent-loading",isLoading:!0,isLoaded:!1,errorMessage:s!=null?`${s}`:null})}const ee={Component:Z,isAvailable:()=>window.opener!=null&&X()==="parent"},ne=ee,p=h.module("AuthPluginPsk"),j="io.deephaven.authentication.psk.PskAuthenticationHandler";function te(){return new URLSearchParams(window.location.search).get("psk")??""}function oe({client:e,onSuccess:n,onFailure:i}){const[s,a]=l.useState(),[t]=l.useState(()=>te());return l.useEffect(()=>{let o=!1;async function c(){try{if(!t)throw new Error("No Pre-shared key token found. Add `psk=<token>` parameter to your URL");if(p.info("Logging in with found token..."),await e.login({type:j,token:t}),o){p.info("Previous login result canceled");return}p.info("Logged in successfully."),n()}catch(r){if(o){p.info("Previous login failure canceled");return}p.error("Unable to login:",r),a(r),i(r)}}return c(),()=>{o=!0}},[e,i,n,t]),u.jsx(m,{"data-testid":"auth-psk-loading",isLoading:!0,isLoaded:!1,errorMessage:s!=null?`${s}`:null})}const se={Component:oe,isAvailable:e=>e.includes(j)},ie=se,R={react:E,"react-dom":k,redux:O,"react-redux":N},re=M.createRequires(()=>R),ae=M.createRemoteComponent({requires:re}),ue=ae,le=T.createRequires(R),ce=I({requires:le}),de=ce,d=h.module("@deephaven/app-utils.PluginUtils");function je(e,n){const i=new URL(`${n}.js`,e),s=E.forwardRef((a,t)=>u.jsx(ue,{url:i.href,render:({err:o,Component:c})=>{if(o!=null&&o!==""){const r=`Error loading plugin ${n} from ${i} due to ${o}`;return d.error(r),u.jsx("div",{className:"error-message",children:`${r}`})}return u.jsx(c,{ref:t,...a})}}));return s.pluginName=n,s.displayName="Plugin",s}async function ge(e){return await de(e)}async function fe(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 pe(e){d.debug("Loading plugins...");try{const n=await fe(`${e}/manifest.json`);if(!Array.isArray(n.plugins))throw new Error("Plugin manifest JSON does not contain plugins array");d.debug("Plugin manifest loaded:",n);const i=[];for(let t=0;t<n.plugins.length;t+=1){const{name:o,main:c}=n.plugins[t],r=`${e}/${o}/${c}`;i.push(ge(r))}const s=await Promise.allSettled(i),a=new Map;for(let t=0;t<s.length;t+=1){const o=s[t],{name:c}=n.plugins[t];o.status==="fulfilled"?a.set(c,o.value):d.error(`Unable to load plugin ${c}`,o.reason)}return d.info("Plugins loaded:",a),a}catch(n){return d.error("Unable to load plugins:",n),new Map}}function he(e){var n;return((n=e.get("AuthHandlers"))==null?void 0:n.split(","))??[]}function me(e,n,i){const s=he(n),a=[...e.entries()].filter(([,r])=>W(r.AuthPlugin)).map(([r,g])=>[r,g.AuthPlugin]);a.push(...i??[]);const t=a.filter(([r,g])=>g.isAvailable(s));if(t.length===0)throw new Error(`No login plugins found, please register a login plugin for auth handlers: ${s}`);t.length>1&&d.warn("More than one login plugin available, will use the first one: ",t.map(([r])=>r).join(", "));const[o,c]=t[0];return d.info("Using LoginPlugin",o),c.Component}const v=l.createContext(null);function Pe({pluginsUrl:e,children:n}){const[i,s]=l.useState(null);return l.useEffect(function(){let t=!1;async function o(){const c=await pe(e);t||s(c)}return o(),()=>{t=!0}},[e]),u.jsx(v.Provider,{value:i,children:n})}const we=new Map([["@deephaven/auth-plugins.AuthPluginPsk",ie],["@deephaven/auth-plugins.AuthPluginParent",ne],["@deephaven/auth-plugins.AuthPluginAnonymous",K]]);function Ae({children:e}){const n=H(),i=l.useContext(v),[s,a]=l.useState(),[t,o]=l.useState(!1),[c,r]=l.useState();l.useEffect(function(){let w=!1;async function S(){try{const A=await n.getAuthConfigValues();w||a(new Map(A))}catch(A){w||r(A)}}return S(),()=>{w=!0}},[n]);const g=l.useMemo(()=>{if(!(i==null||s==null))try{return me(i,s,we)}catch(P){r(P)}},[s,i]),b=l.useCallback(()=>{o(!0)},[]),U=l.useCallback(P=>{o(!1),r(P)},[]),y=g==null||s==null;return y||c!=null?u.jsx(m,{isLoading:y,errorMessage:c!=null?`${c}`:void 0}):t?u.jsx(u.Fragment,{children:e}):u.jsx(g,{authConfigValues:s,client:n,onSuccess:b,onFailure:U})}function Ce(e){return new URL(e,`${window.location}`)}function ve(){return new URLSearchParams(window.location.search).get("envoyPrefix")}function ye(){const e=ve();return e!=null?{headers:{"envoy-prefix":e}}:{headers:{}}}function xe({children:e}){return l.useContext($)?u.jsx(u.Fragment,{children:e}):u.jsx(m,{"data-testid":"fonts-loaded-loading"})}function Re({apiUrl:e,fontClassNames:n,pluginsUrl:i,children:s}){const a=Ce(e).origin,t=ye();return u.jsx(J,{fontClassNames:n,children:u.jsx(B,{serverUrl:a,options:t,children:u.jsx(Pe,{pluginsUrl:i,children:u.jsx(Ae,{children:u.jsx(F,{children:u.jsx(xe,{children:s})})})})})})}function be(){const e=l.useContext(v);if(e==null)throw new Error("No Plugins available in usePlugins. Was code wrapped in PluginsBootstrap or PluginsContext.Provider?");return e}export{Re as AppBootstrap,Ae as AuthBootstrap,B as ClientBootstrap,ke as ClientContext,F as ConnectionBootstrap,Oe as ConnectionContext,J as FontBootstrap,xe as FontsLoaded,$ as FontsLoadedContext,Pe as PluginsBootstrap,v as PluginsContext,ue as RemoteComponent,he as getAuthHandlers,me as getAuthPluginComponent,Ce as getBaseUrl,ye as getConnectOptions,ve as getEnvoyPrefix,je as loadComponentPlugin,fe as loadJson,ge as loadModulePlugin,pe as loadModulePlugins,H as useClient,Ne as useConnection,be as usePlugins};
2
- //# sourceMappingURL=index-b88ed4a8.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-b88ed4a8.js","sources":["../../../jsapi-utils/src/MessageUtils.ts","../../../app-utils/src/components/FontBootstrap.tsx","../../../auth-plugins/src/AuthPlugin.ts","../../../auth-plugins/src/AuthHandlerTypes.ts","../../../auth-plugins/src/AuthPluginAnonymous.tsx","../../../auth-plugins/src/AuthPluginParent.tsx","../../../auth-plugins/src/AuthPluginPsk.tsx","../../../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/AuthBootstrap.tsx","../../../app-utils/src/utils/ConnectUtils.ts","../../../app-utils/src/components/FontsLoaded.tsx","../../../app-utils/src/components/AppBootstrap.tsx","../../../app-utils/src/components/usePlugins.ts"],"sourcesContent":["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, { 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","import React from 'react';\nimport { CoreClient } from '@deephaven/jsapi-types';\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 /** Client to check auth configuration on */\n client: CoreClient;\n\n /** Called when authentication is sucessful */\n onSuccess(): void;\n\n /** Called when authentication fails */\n onFailure(error: unknown): void;\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","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 { useApi } from '@deephaven/jsapi-bootstrap';\nimport Log from '@deephaven/log';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { AUTH_HANDLER_TYPE_ANONYMOUS } from './AuthHandlerTypes';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginAnonymous');\n\n/**\n * AuthPlugin that tries to login anonymously. Fails if anonymous login fails\n */\nfunction Component({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n const dh = useApi();\n\n useEffect(() => {\n let isCanceled = false;\n async function login() {\n try {\n log.info('Logging in...');\n await client.login({ type: dh.CoreClient.LOGIN_TYPE_ANONYMOUS });\n if (isCanceled) {\n log.info('Previous login result canceled');\n return;\n }\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n if (isCanceled) {\n log.info('Previous login failure canceled');\n return;\n }\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n return () => {\n isCanceled = true;\n };\n }, [client, dh, onFailure, onSuccess]);\n return (\n <LoadingOverlay\n data-testid=\"auth-anonymous-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\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, { useEffect, useState } 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 { LoadingOverlay } from '@deephaven/components';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginParent');\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({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n useEffect(() => {\n async function login() {\n try {\n log.info('Logging in by delegating to parent window...');\n const loginOptions = await requestParentResponse<LoginOptions>(\n LOGIN_OPTIONS_REQUEST\n );\n\n await client.login(loginOptions);\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n }, [client, onFailure, onSuccess]);\n return (\n <LoadingOverlay\n data-testid=\"auth-parent-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n}\n\nconst AuthPluginParent: AuthPlugin = {\n Component,\n isAvailable: () =>\n window.opener != null && getWindowAuthProvider() === 'parent',\n};\n\nexport default AuthPluginParent;\n","import React, { useEffect, useState } from 'react';\nimport Log from '@deephaven/log';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { AuthPlugin, AuthPluginProps } from './AuthPlugin';\n\nconst log = Log.module('AuthPluginPsk');\n\nconst AUTH_TYPE = 'io.deephaven.authentication.psk.PskAuthenticationHandler';\n\nfunction getWindowToken(): string {\n return new URLSearchParams(window.location.search).get('psk') ?? '';\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({\n client,\n onSuccess,\n onFailure,\n}: AuthPluginProps): JSX.Element {\n const [error, setError] = useState<unknown>();\n const [token] = useState(() => getWindowToken());\n useEffect(() => {\n let isCanceled = false;\n async function login() {\n try {\n if (!token) {\n throw new Error(\n 'No Pre-shared key token found. Add `psk=<token>` parameter to your URL'\n );\n }\n log.info('Logging in with found token...');\n await client.login({ type: AUTH_TYPE, token });\n if (isCanceled) {\n log.info('Previous login result canceled');\n return;\n }\n log.info('Logged in successfully.');\n onSuccess();\n } catch (e) {\n if (isCanceled) {\n log.info('Previous login failure canceled');\n return;\n }\n log.error('Unable to login:', e);\n setError(e);\n onFailure(e);\n }\n }\n login();\n return () => {\n isCanceled = true;\n };\n }, [client, onFailure, onSuccess, token]);\n return (\n <LoadingOverlay\n data-testid=\"auth-psk-loading\"\n isLoading\n isLoaded={false}\n errorMessage={error != null ? `${error}` : null}\n />\n );\n}\n\nconst AuthPluginPsk: AuthPlugin = {\n Component,\n isAvailable: authHandlers => authHandlers.includes(AUTH_TYPE),\n};\n\nexport default AuthPluginPsk;\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, {\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport {\n AuthConfigMap,\n AuthPluginAnonymous,\n AuthPluginParent,\n AuthPluginPsk,\n} from '@deephaven/auth-plugins';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { PluginsContext } from './PluginsBootstrap';\nimport { getAuthPluginComponent } from '../plugins';\nimport useClient from './useClient';\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 [isLoggedIn, setIsLoggedIn] = useState(false);\n const [error, setError] = useState<unknown>();\n\n useEffect(\n function initAuthConfigValues() {\n let isCancelled = false;\n async function loadAuthConfigValues() {\n try {\n const newAuthConfigValues = await client.getAuthConfigValues();\n if (!isCancelled) {\n setAuthConfig(new Map(newAuthConfigValues));\n }\n } catch (e) {\n if (!isCancelled) {\n setError(e);\n }\n }\n }\n loadAuthConfigValues();\n return () => {\n isCancelled = 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 handleLoginSuccess = useCallback(() => {\n setIsLoggedIn(true);\n }, []);\n\n const handleLoginFailure = useCallback((e: unknown) => {\n setIsLoggedIn(false);\n setError(e);\n }, []);\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 if (!isLoggedIn) {\n return (\n <AuthComponent\n authConfigValues={authConfig}\n client={client}\n onSuccess={handleLoginSuccess}\n onFailure={handleLoginFailure}\n />\n );\n }\n\n // eslint-disable-next-line react/jsx-no-useless-fragment\n return <>{children}</>;\n}\n\nexport default AuthBootstrap;\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 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 FontBootstrap from './FontBootstrap';\nimport ClientBootstrap from './ClientBootstrap';\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","import { useContext } from 'react';\nimport { PluginsContext } from './PluginsBootstrap';\n\nexport function usePlugins() {\n const plugins = useContext(PluginsContext);\n if (plugins == null) {\n throw new Error(\n 'No Plugins available in usePlugins. Was code wrapped in PluginsBootstrap or PluginsContext.Provider?'\n );\n }\n return plugins;\n}\n\nexport default usePlugins;\n"],"names":["log","Log","LOGIN_OPTIONS_REQUEST","makeMessage","message","id","shortid","payload","requestParentResponse","request","timeout","resolve","reject","timeoutId","listener","event","data","TimeoutError","FontsLoadedContext","createContext","FontBootstrap","fontClassNames","children","isLoaded","setIsLoaded","useState","useEffect","jsxs","Fragment","jsx","className","isAuthPlugin","plugin","authPlugin","AUTH_HANDLER_TYPE_ANONYMOUS","Component","client","onSuccess","onFailure","error","setError","dh","useApi","isCanceled","login","e","LoadingOverlay","AuthPluginAnonymous","authHandlers","AuthPluginAnonymous$1","getWindowAuthProvider","loginOptions","AuthPluginParent","AuthPluginParent$1","AUTH_TYPE","getWindowToken","token","AuthPluginPsk","AuthPluginPsk$1","react","ReactDOM","redux","reactRedux","requires","createRequires","RemoteComponent","createRemoteComponent","RemoteComponent$1","loadRemoteModule","createLoadRemoteModule","loadRemoteModule$1","loadComponentPlugin","baseURL","pluginName","pluginUrl","Plugin","React","props","ref","err","errorMessage","loadModulePlugin","loadJson","jsonUrl","res","loadModulePlugins","modulePluginsUrl","manifest","pluginPromises","i","name","main","pluginMainUrl","pluginModules","pluginMap","module","getAuthHandlers","authConfigValues","_a","getAuthPluginComponent","corePlugins","authPlugins","availableAuthPlugins","loginPluginName","NewLoginPlugin","PluginsContext","PluginsBootstrap","pluginsUrl","plugins","setPlugins","isCancelled","loadPlugins","CORE_AUTH_PLUGINS","AuthBootstrap","useClient","useContext","authConfig","setAuthConfig","isLoggedIn","setIsLoggedIn","loadAuthConfigValues","newAuthConfigValues","AuthComponent","useMemo","handleLoginSuccess","useCallback","handleLoginFailure","isLoading","getBaseUrl","apiUrl","getEnvoyPrefix","getConnectOptions","envoyPrefix","FontsLoaded","AppBootstrap","serverUrl","clientOptions","ClientBootstrap","ConnectionBootstrap","usePlugins"],"mappings":"kUAIA,MAAMA,EAAMC,EAAI,OAAO,cAAc,EAExBC,EACX,4CAuBK,SAASC,EACdC,EACAC,EAAKC,EAAA,EACLC,EACY,CACL,MAAA,CAAE,QAAAH,EAAS,GAAAC,EAAI,QAAAE,EACxB,CAkBsB,eAAAC,EACpBC,EACAC,EAAU,IACE,CACR,GAAA,OAAO,QAAU,KACb,MAAA,IAAI,MAAM,gDAAgD,EAElE,OAAO,IAAI,QAAQ,CAACC,EAASC,IAAW,CAClC,IAAAC,EACJ,MAAMR,EAAKC,IACLQ,EAAYC,GAAqC,CAC/C,KAAA,CAAE,KAAAC,CAAS,EAAAD,EAEb,GADAf,EAAA,MAAM,mBAAoBgB,CAAI,GAC9BA,GAAA,YAAAA,EAAM,MAAOX,EAAI,CACfL,EAAA,MAAM,mCAAoCgB,CAAI,EAClD,MACF,CACA,OAAO,aAAaH,CAAS,EACtB,OAAA,oBAAoB,UAAWC,CAAQ,EAC9CH,EAAQK,EAAK,OAAO,CAAA,EAEf,OAAA,iBAAiB,UAAWF,CAAQ,EAC/BD,EAAA,OAAO,WAAW,IAAM,CAC3B,OAAA,oBAAoB,UAAWC,CAAQ,EACvCF,EAAA,IAAIK,EAAa,mBAAmB,CAAC,GAC3CP,CAAO,EACV,OAAO,OAAO,YAAYP,EAAYM,EAASJ,CAAE,EAAG,GAAG,CAAA,CACxD,CACH,CC/Ea,MAAAa,EAAqBC,gBAAuB,EAAK,EAkBvD,SAASC,EAAc,CAC5B,eAAAC,EAAiB,CAAC,o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A,EAJVO,EAAA,IAACiB,EAAe,CAAA,cAAY,sBAAuB,CAAA,CAK9D,CCYO,SAASwF,GAAa,CAC3B,OAAAL,EACA,eAAA5G,EACA,WAAAsF,EACA,SAAArF,CACF,EAAsB,CACd,MAAAiH,EAAYP,GAAWC,CAAM,EAAE,OAC/BO,EAAgBL,KAEpB,OAAAtG,EAAAA,IAACT,GAAc,eAAAC,EACb,SAAAQ,EAAA,IAAC4G,GAAgB,UAAAF,EAAsB,QAASC,EAC9C,SAAA3G,EAAA,IAAC6E,GAAiB,CAAA,WAAAC,EAChB,eAACM,GACC,CAAA,SAAApF,EAAAA,IAAC6G,GACC,SAAC7G,MAAAwG,GAAA,CAAa,SAAA/G,EAAS,CACzB,CAAA,CAAA,CACF,CACF,CAAA,CAAA,CACF,CACF,CAAA,CAEJ,CChDO,SAASqH,IAAa,CACrB,MAAA/B,EAAUO,aAAWV,CAAc,EACzC,GAAIG,GAAW,KACb,MAAM,IAAI,MACR,sGAAA,EAGG,OAAAA,CACT"}
@@ -1,2 +0,0 @@
1
- var E=Object.defineProperty;var m=(n,t,o)=>t in n?E(n,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[t]=o;var p=(n,t,o)=>(m(n,typeof t!="symbol"?t+"":t,o),o);import{A as e,C as l}from"./vendor-73e67738.js";import{A as h,L as A,e as S}from"./index-7bce681d.js";class g extends Error{constructor(){super(...arguments);p(this,"isTimeout",!0)}}const j=g,x=()=>{const n=e.useContext(h);if(n==null)throw new Error("No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?");return n},w=e.createContext(null);function L({serverUrl:n,options:t,children:o}){const i=x(),[s,r]=e.useState();return e.useEffect(function(){const u=new i.CoreClient(n,t);return r(u),()=>{u.disconnect()}},[i,t,n]),s==null?null:l.jsx(w.Provider,{value:s,children:o})}function B(){const n=e.useContext(w);if(n==null)throw new Error("No Client available in useClient. Was code wrapped in ClientBootstrap or ClientContext.Provider?");return n}const N=A.module("@deephaven/jsapi-components.ConnectionBootstrap"),v=e.createContext(null);function y({children:n}){const t=x(),o=B(),[i,s]=e.useState(),[r,C]=e.useState();return e.useEffect(function(){let c=!1;async function d(){try{const a=await o.getAsIdeConnection();if(c)return;C(a)}catch(a){if(c)return;s(a)}}return d(),()=>{c=!0}},[t,o]),e.useEffect(function(){if(r==null)return;function c(a){const{detail:f}=a;N.info("Shutdown",`${JSON.stringify(f)}`),s(`Server shutdown: ${f??"Unknown reason"}`)}return r.addEventListener(t.IdeConnection.EVENT_SHUTDOWN,c)},[t,r]),r==null||i!=null?l.jsx(S,{"data-testid":"connection-bootstrap-loading",isLoading:r==null,errorMessage:`${i}`}):l.jsx(v.Provider,{value:r,children:n})}function I(){const n=e.useContext(v);if(n==null)throw new Error("No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?");return n}export{L as C,j as T,x as a,B as b,y as c,w as d,v as e,I as u};
2
- //# sourceMappingURL=useConnection-e7328bfb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useConnection-e7328bfb.js","sources":["../../../utils/src/TimeoutError.ts","../../../jsapi-bootstrap/src/useApi.ts","../../../app-utils/src/components/ClientBootstrap.tsx","../../../app-utils/src/components/useClient.ts","../../../app-utils/src/components/ConnectionBootstrap.tsx","../../../app-utils/src/components/useConnection.ts"],"sourcesContent":["class TimeoutError extends Error {\n isTimeout = true;\n}\n\nexport default TimeoutError;\n","import { useContext } from 'react';\nimport { ApiContext } from './ApiBootstrap';\n\nexport const useApi = () => {\n const dh = useContext(ApiContext);\n if (dh == null) {\n throw new Error(\n 'No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?'\n );\n }\n return dh;\n};\n\nexport default useApi;\n","import React, { createContext, useEffect, useState } from 'react';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { ConnectOptions, CoreClient } from '@deephaven/jsapi-types';\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 { useContext } from 'react';\nimport { ClientContext } from './ClientBootstrap';\n\nexport function useClient() {\n const client = useContext(ClientContext);\n if (client == null) {\n throw new Error(\n 'No Client available in useClient. Was code wrapped in ClientBootstrap or ClientContext.Provider?'\n );\n }\n return client;\n}\n\nexport default useClient;\n","import React, { createContext, useEffect, useState } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useApi } from '@deephaven/jsapi-bootstrap';\nimport { IdeConnection } from '@deephaven/jsapi-types';\nimport Log from '@deephaven/log';\nimport useClient from './useClient';\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}`}\n />\n );\n }\n\n return (\n <ConnectionContext.Provider value={connection}>\n {children}\n </ConnectionContext.Provider>\n );\n}\n\nexport default ConnectionBootstrap;\n","import { useContext } from 'react';\nimport { ConnectionContext } from './ConnectionBootstrap';\n\nexport function useConnection() {\n const connection = useContext(ConnectionContext);\n if (connection == null) {\n throw new Error(\n 'No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?'\n );\n }\n return connection;\n}\n\nexport default useConnection;\n"],"names":["TimeoutError","__publicField","TimeoutError$1","useApi","dh","useContext","ApiContext","ClientContext","createContext","ClientBootstrap","serverUrl","options","children","api","client","setClient","useState","useEffect","newClient","useClient","log","Log","ConnectionContext","ConnectionBootstrap","error","setError","connection","setConnection","isCancelled","loadConnection","newConnection","e","handleShutdown","event","detail","jsx","LoadingOverlay","useConnection"],"mappings":"8QAAA,MAAMA,UAAqB,KAAM,CAAjC,kCACEC,EAAA,iBAAY,IACd,CAEA,MAAAC,EAAeF,ECDFG,EAAS,IAAM,CACpB,MAAAC,EAAKC,aAAWC,CAAU,EAChC,GAAIF,GAAM,KACR,MAAM,IAAI,MACR,sFAAA,EAGG,OAAAA,CACT,ECPaG,EAAgBC,gBAAiC,IAAI,EAmB3D,SAASC,EAAgB,CAC9B,UAAAC,EACA,QAAAC,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