@deephaven/app-utils 0.43.0 → 0.44.0

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.
Files changed (45) hide show
  1. package/dist/components/AppBootstrap.js +44 -0
  2. package/dist/components/AppBootstrap.js.map +1 -0
  3. package/dist/components/AuthBootstrap.js +74 -0
  4. package/dist/components/AuthBootstrap.js.map +1 -0
  5. package/dist/components/ConnectionBootstrap.js +71 -0
  6. package/dist/components/ConnectionBootstrap.js.map +1 -0
  7. package/dist/components/FontBootstrap.js +33 -0
  8. package/dist/components/FontBootstrap.js.map +1 -0
  9. package/dist/components/FontsLoaded.js +19 -0
  10. package/dist/components/FontsLoaded.js.map +1 -0
  11. package/dist/components/LoginNotifier.js +16 -0
  12. package/dist/components/LoginNotifier.js.map +1 -0
  13. package/dist/components/PluginsBootstrap.js +39 -0
  14. package/dist/components/PluginsBootstrap.js.map +1 -0
  15. package/dist/components/ServerConfigBootstrap.js +55 -0
  16. package/dist/components/ServerConfigBootstrap.js.map +1 -0
  17. package/dist/components/UserBootstrap.js +20 -0
  18. package/dist/components/UserBootstrap.js.map +1 -0
  19. package/dist/components/index.js +11 -0
  20. package/dist/components/index.js.map +1 -0
  21. package/dist/components/useConnection.js +7 -0
  22. package/dist/components/useConnection.js.map +1 -0
  23. package/dist/components/usePlugins.js +7 -0
  24. package/dist/components/usePlugins.js.map +1 -0
  25. package/dist/components/useServerConfig.js +7 -0
  26. package/dist/components/useServerConfig.js.map +1 -0
  27. package/dist/components/useUser.js +7 -0
  28. package/dist/components/useUser.js.map +1 -0
  29. package/dist/index.js +4 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/plugins/PluginUtils.js +184 -0
  32. package/dist/plugins/PluginUtils.js.map +1 -0
  33. package/dist/plugins/RemoteComponent.js +8 -0
  34. package/dist/plugins/RemoteComponent.js.map +1 -0
  35. package/dist/plugins/index.js +3 -0
  36. package/dist/plugins/index.js.map +1 -0
  37. package/dist/plugins/loadRemoteModule.js +8 -0
  38. package/dist/plugins/loadRemoteModule.js.map +1 -0
  39. package/dist/plugins/remote-component.config.js +33 -0
  40. package/dist/plugins/remote-component.config.js.map +1 -0
  41. package/dist/utils/ConnectUtils.js +28 -0
  42. package/dist/utils/ConnectUtils.js.map +1 -0
  43. package/dist/utils/index.js +2 -0
  44. package/dist/utils/index.js.map +1 -0
  45. package/package.json +11 -11
@@ -0,0 +1,44 @@
1
+ import React, { useCallback, useMemo, useState } from 'react';
2
+ import '@deephaven/components/scss/BaseStyleSheet.scss';
3
+ import { ClientBootstrap } from '@deephaven/jsapi-bootstrap';
4
+ import { RefreshTokenBootstrap, useBroadcastLoginListener } from '@deephaven/jsapi-components';
5
+ import FontBootstrap from "./FontBootstrap.js";
6
+ import PluginsBootstrap from "./PluginsBootstrap.js";
7
+ import AuthBootstrap from "./AuthBootstrap.js";
8
+ import ConnectionBootstrap from "./ConnectionBootstrap.js";
9
+ import { getConnectOptions } from "../utils/index.js";
10
+ import FontsLoaded from "./FontsLoaded.js";
11
+ import UserBootstrap from "./UserBootstrap.js";
12
+ import ServerConfigBootstrap from "./ServerConfigBootstrap.js";
13
+ /**
14
+ * AppBootstrap component. Handles loading the fonts, client, and authentication.
15
+ * Will display the children when everything is loaded and authenticated.
16
+ */
17
+ export function AppBootstrap(_ref) {
18
+ var {
19
+ fontClassNames,
20
+ pluginsUrl,
21
+ serverUrl,
22
+ children
23
+ } = _ref;
24
+ var clientOptions = useMemo(() => getConnectOptions(), []);
25
+
26
+ // On logout, we reset the client and have user login again
27
+ var [logoutCount, setLogoutCount] = useState(0);
28
+ var onLogin = useCallback(() => undefined, []);
29
+ var onLogout = useCallback(() => {
30
+ setLogoutCount(value => value + 1);
31
+ }, []);
32
+ useBroadcastLoginListener(onLogin, onLogout);
33
+ return /*#__PURE__*/React.createElement(FontBootstrap, {
34
+ fontClassNames: fontClassNames
35
+ }, /*#__PURE__*/React.createElement(PluginsBootstrap, {
36
+ pluginsUrl: pluginsUrl
37
+ }, /*#__PURE__*/React.createElement(ClientBootstrap, {
38
+ serverUrl: serverUrl,
39
+ options: clientOptions,
40
+ key: logoutCount
41
+ }, /*#__PURE__*/React.createElement(RefreshTokenBootstrap, null, /*#__PURE__*/React.createElement(AuthBootstrap, null, /*#__PURE__*/React.createElement(ServerConfigBootstrap, null, /*#__PURE__*/React.createElement(UserBootstrap, null, /*#__PURE__*/React.createElement(ConnectionBootstrap, null, /*#__PURE__*/React.createElement(FontsLoaded, null, children)))))))));
42
+ }
43
+ export default AppBootstrap;
44
+ //# sourceMappingURL=AppBootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppBootstrap.js","names":["React","useCallback","useMemo","useState","ClientBootstrap","RefreshTokenBootstrap","useBroadcastLoginListener","FontBootstrap","PluginsBootstrap","AuthBootstrap","ConnectionBootstrap","getConnectOptions","FontsLoaded","UserBootstrap","ServerConfigBootstrap","AppBootstrap","fontClassNames","pluginsUrl","serverUrl","children","clientOptions","logoutCount","setLogoutCount","onLogin","undefined","onLogout","value"],"sources":["../../src/components/AppBootstrap.tsx"],"sourcesContent":["import React, { useCallback, useMemo, useState } from 'react';\nimport '@deephaven/components/scss/BaseStyleSheet.scss';\nimport { ClientBootstrap } from '@deephaven/jsapi-bootstrap';\nimport {\n RefreshTokenBootstrap,\n useBroadcastLoginListener,\n} from '@deephaven/jsapi-components';\nimport FontBootstrap from './FontBootstrap';\nimport PluginsBootstrap from './PluginsBootstrap';\nimport AuthBootstrap from './AuthBootstrap';\nimport ConnectionBootstrap from './ConnectionBootstrap';\nimport { getConnectOptions } from '../utils';\nimport FontsLoaded from './FontsLoaded';\nimport UserBootstrap from './UserBootstrap';\nimport ServerConfigBootstrap from './ServerConfigBootstrap';\n\nexport type AppBootstrapProps = {\n /** URL of the server. */\n serverUrl: 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 fontClassNames,\n pluginsUrl,\n serverUrl,\n children,\n}: AppBootstrapProps) {\n const clientOptions = useMemo(() => getConnectOptions(), []);\n\n // On logout, we reset the client and have user login again\n const [logoutCount, setLogoutCount] = useState(0);\n const onLogin = useCallback(() => undefined, []);\n const onLogout = useCallback(() => {\n setLogoutCount(value => value + 1);\n }, []);\n useBroadcastLoginListener(onLogin, onLogout);\n return (\n <FontBootstrap fontClassNames={fontClassNames}>\n <PluginsBootstrap pluginsUrl={pluginsUrl}>\n <ClientBootstrap\n serverUrl={serverUrl}\n options={clientOptions}\n key={logoutCount}\n >\n <RefreshTokenBootstrap>\n <AuthBootstrap>\n <ServerConfigBootstrap>\n <UserBootstrap>\n <ConnectionBootstrap>\n <FontsLoaded>{children}</FontsLoaded>\n </ConnectionBootstrap>\n </UserBootstrap>\n </ServerConfigBootstrap>\n </AuthBootstrap>\n </RefreshTokenBootstrap>\n </ClientBootstrap>\n </PluginsBootstrap>\n </FontBootstrap>\n );\n}\n\nexport default AppBootstrap;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AAC7D,OAAO,gDAAgD;AACvD,SAASC,eAAe,QAAQ,4BAA4B;AAC5D,SACEC,qBAAqB,EACrBC,yBAAyB,QACpB,6BAA6B;AAAC,OAC9BC,aAAa;AAAA,OACbC,gBAAgB;AAAA,OAChBC,aAAa;AAAA,OACbC,mBAAmB;AAAA,SACjBC,iBAAiB;AAAA,OACnBC,WAAW;AAAA,OACXC,aAAa;AAAA,OACbC,qBAAqB;AAkB5B;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAY,OAKN;EAAA,IALO;IAC3BC,cAAc;IACdC,UAAU;IACVC,SAAS;IACTC;EACiB,CAAC;EAClB,IAAMC,aAAa,GAAGlB,OAAO,CAAC,MAAMS,iBAAiB,EAAE,EAAE,EAAE,CAAC;;EAE5D;EACA,IAAM,CAACU,WAAW,EAAEC,cAAc,CAAC,GAAGnB,QAAQ,CAAC,CAAC,CAAC;EACjD,IAAMoB,OAAO,GAAGtB,WAAW,CAAC,MAAMuB,SAAS,EAAE,EAAE,CAAC;EAChD,IAAMC,QAAQ,GAAGxB,WAAW,CAAC,MAAM;IACjCqB,cAAc,CAACI,KAAK,IAAIA,KAAK,GAAG,CAAC,CAAC;EACpC,CAAC,EAAE,EAAE,CAAC;EACNpB,yBAAyB,CAACiB,OAAO,EAAEE,QAAQ,CAAC;EAC5C,oBACE,oBAAC,aAAa;IAAC,cAAc,EAAET;EAAe,gBAC5C,oBAAC,gBAAgB;IAAC,UAAU,EAAEC;EAAW,gBACvC,oBAAC,eAAe;IACd,SAAS,EAAEC,SAAU;IACrB,OAAO,EAAEE,aAAc;IACvB,GAAG,EAAEC;EAAY,gBAEjB,oBAAC,qBAAqB,qBACpB,oBAAC,aAAa,qBACZ,oBAAC,qBAAqB,qBACpB,oBAAC,aAAa,qBACZ,oBAAC,mBAAmB,qBAClB,oBAAC,WAAW,QAAEF,QAAQ,CAAe,CACjB,CACR,CACM,CACV,CACM,CACR,CACD,CACL;AAEpB;AAEA,eAAeJ,YAAY"}
@@ -0,0 +1,74 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ import React, { useContext, useEffect, useMemo, useState } from 'react';
4
+ import { AuthPluginAnonymous, AuthPluginParent, AuthPluginPsk } from '@deephaven/auth-plugins';
5
+ import { LoadingOverlay } from '@deephaven/components';
6
+ import { useClient } from '@deephaven/jsapi-bootstrap';
7
+ import { getErrorMessage } from '@deephaven/utils';
8
+ import { PluginsContext } from "./PluginsBootstrap.js";
9
+ import { getAuthPluginComponent } from "../plugins/index.js";
10
+ import LoginNotifier from "./LoginNotifier.js";
11
+ /** Core auth plugins that are always loaded */
12
+ var CORE_AUTH_PLUGINS = new Map([['@deephaven/auth-plugins.AuthPluginParent', AuthPluginParent], ['@deephaven/auth-plugins.AuthPluginPsk', AuthPluginPsk], ['@deephaven/auth-plugins.AuthPluginAnonymous', AuthPluginAnonymous]]);
13
+
14
+ /**
15
+ * AuthBootstrap component. Handles displaying the auth plugin and authenticating.
16
+ */
17
+ export function AuthBootstrap(_ref) {
18
+ var {
19
+ children
20
+ } = _ref;
21
+ var client = useClient();
22
+ // `useContext` instead of `usePlugins` so that we don't have to wait for the plugins to load
23
+ // We want to load the auth config values in parallel with the plugins
24
+ var plugins = useContext(PluginsContext);
25
+ var [authConfig, setAuthConfig] = useState();
26
+ var [error, setError] = useState();
27
+ useEffect(function initAuthConfigValues() {
28
+ var isCanceled = false;
29
+ function loadAuthConfigValues() {
30
+ return _loadAuthConfigValues.apply(this, arguments);
31
+ }
32
+ function _loadAuthConfigValues() {
33
+ _loadAuthConfigValues = _asyncToGenerator(function* () {
34
+ try {
35
+ var newAuthConfigValues = yield client.getAuthConfigValues();
36
+ if (!isCanceled) {
37
+ setAuthConfig(new Map(newAuthConfigValues));
38
+ }
39
+ } catch (e) {
40
+ if (!isCanceled) {
41
+ setError(e);
42
+ }
43
+ }
44
+ });
45
+ return _loadAuthConfigValues.apply(this, arguments);
46
+ }
47
+ loadAuthConfigValues();
48
+ return () => {
49
+ isCanceled = true;
50
+ };
51
+ }, [client]);
52
+ var AuthComponent = useMemo(() => {
53
+ if (plugins == null || authConfig == null) {
54
+ return undefined;
55
+ }
56
+ try {
57
+ return getAuthPluginComponent(plugins, authConfig, CORE_AUTH_PLUGINS);
58
+ } catch (e) {
59
+ setError(e);
60
+ }
61
+ }, [authConfig, plugins]);
62
+ var isLoading = AuthComponent == null || authConfig == null;
63
+ if (isLoading || error != null) {
64
+ return /*#__PURE__*/React.createElement(LoadingOverlay, {
65
+ isLoading: isLoading && error == null,
66
+ errorMessage: getErrorMessage(error)
67
+ });
68
+ }
69
+ return /*#__PURE__*/React.createElement(AuthComponent, {
70
+ authConfigValues: authConfig
71
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LoginNotifier, null), children));
72
+ }
73
+ export default AuthBootstrap;
74
+ //# sourceMappingURL=AuthBootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AuthBootstrap.js","names":["React","useContext","useEffect","useMemo","useState","AuthPluginAnonymous","AuthPluginParent","AuthPluginPsk","LoadingOverlay","useClient","getErrorMessage","PluginsContext","getAuthPluginComponent","LoginNotifier","CORE_AUTH_PLUGINS","Map","AuthBootstrap","children","client","plugins","authConfig","setAuthConfig","error","setError","initAuthConfigValues","isCanceled","loadAuthConfigValues","newAuthConfigValues","getAuthConfigValues","e","AuthComponent","undefined","isLoading"],"sources":["../../src/components/AuthBootstrap.tsx"],"sourcesContent":["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 { getErrorMessage } from '@deephaven/utils';\nimport { PluginsContext } from './PluginsBootstrap';\nimport { getAuthPluginComponent } from '../plugins';\nimport LoginNotifier from './LoginNotifier';\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.AuthPluginParent', AuthPluginParent],\n ['@deephaven/auth-plugins.AuthPluginPsk', AuthPluginPsk],\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 && error == null}\n errorMessage={getErrorMessage(error)}\n />\n );\n }\n return (\n <AuthComponent authConfigValues={authConfig}>\n <>\n <LoginNotifier />\n {children}\n </>\n </AuthComponent>\n );\n}\n\nexport default AuthBootstrap;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,OAAO;AACvE,SAEEC,mBAAmB,EACnBC,gBAAgB,EAChBC,aAAa,QACR,yBAAyB;AAChC,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,4BAA4B;AACtD,SAASC,eAAe,QAAQ,kBAAkB;AAAC,SAC1CC,cAAc;AAA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OAAOnB,sBAAsB,CAACO,OAAO,EAAEC,UAAU,EAAEN,iBAAiB,CAAC;IACvE,CAAC,CAAC,OAAOe,CAAC,EAAE;MACVN,QAAQ,CAACM,CAAC,CAAC;IACb;EACF,CAAC,EAAE,CAACT,UAAU,EAAED,OAAO,CAAC,CAAC;EAEzB,IAAMa,SAAS,GAAGF,aAAa,IAAI,IAAI,IAAIV,UAAU,IAAI,IAAI;EAE7D,IAAIY,SAAS,IAAIV,KAAK,IAAI,IAAI,EAAE;IAC9B,oBACE,oBAAC,cAAc;MACb,SAAS,EAAEU,SAAS,IAAIV,KAAK,IAAI,IAAK;MACtC,YAAY,EAAEZ,eAAe,CAACY,KAAK;IAAE,EACrC;EAEN;EACA,oBACE,oBAAC,aAAa;IAAC,gBAAgB,EAAEF;EAAW,gBAC1C,uDACE,oBAAC,aAAa,OAAG,EAChBH,QAAQ,CACR,CACW;AAEpB;AAEA,eAAeD,aAAa"}
@@ -0,0 +1,71 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ import React, { createContext, useEffect, useState } from 'react';
4
+ import { LoadingOverlay } from '@deephaven/components';
5
+ import { useApi, useClient } from '@deephaven/jsapi-bootstrap';
6
+ import Log from '@deephaven/log';
7
+ var log = Log.module('@deephaven/jsapi-components.ConnectionBootstrap');
8
+ export var ConnectionContext = /*#__PURE__*/createContext(null);
9
+ /**
10
+ * ConnectionBootstrap component. Handles initializing the connection.
11
+ */
12
+ export function ConnectionBootstrap(_ref) {
13
+ var {
14
+ children
15
+ } = _ref;
16
+ var api = useApi();
17
+ var client = useClient();
18
+ var [error, setError] = useState();
19
+ var [connection, setConnection] = useState();
20
+ useEffect(function initConnection() {
21
+ var isCanceled = false;
22
+ function loadConnection() {
23
+ return _loadConnection.apply(this, arguments);
24
+ }
25
+ function _loadConnection() {
26
+ _loadConnection = _asyncToGenerator(function* () {
27
+ try {
28
+ var newConnection = yield client.getAsIdeConnection();
29
+ if (isCanceled) {
30
+ return;
31
+ }
32
+ setConnection(newConnection);
33
+ } catch (e) {
34
+ if (isCanceled) {
35
+ return;
36
+ }
37
+ setError(e);
38
+ }
39
+ });
40
+ return _loadConnection.apply(this, arguments);
41
+ }
42
+ loadConnection();
43
+ return () => {
44
+ isCanceled = true;
45
+ };
46
+ }, [api, client]);
47
+ useEffect(function listenForShutdown() {
48
+ if (connection == null) return;
49
+ function handleShutdown(event) {
50
+ var {
51
+ detail
52
+ } = event;
53
+ log.info('Shutdown', "".concat(JSON.stringify(detail)));
54
+ setError("Server shutdown: ".concat(detail !== null && detail !== void 0 ? detail : 'Unknown reason'));
55
+ }
56
+ var removerFn = connection.addEventListener(api.IdeConnection.EVENT_SHUTDOWN, handleShutdown);
57
+ return removerFn;
58
+ }, [api, connection]);
59
+ if (connection == null || error != null) {
60
+ return /*#__PURE__*/React.createElement(LoadingOverlay, {
61
+ "data-testid": "connection-bootstrap-loading",
62
+ isLoading: connection == null,
63
+ errorMessage: error != null ? "".concat(error) : undefined
64
+ });
65
+ }
66
+ return /*#__PURE__*/React.createElement(ConnectionContext.Provider, {
67
+ value: connection
68
+ }, children);
69
+ }
70
+ export default ConnectionBootstrap;
71
+ //# sourceMappingURL=ConnectionBootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectionBootstrap.js","names":["React","createContext","useEffect","useState","LoadingOverlay","useApi","useClient","Log","log","module","ConnectionContext","ConnectionBootstrap","children","api","client","error","setError","connection","setConnection","initConnection","isCanceled","loadConnection","newConnection","getAsIdeConnection","e","listenForShutdown","handleShutdown","event","detail","info","JSON","stringify","removerFn","addEventListener","IdeConnection","EVENT_SHUTDOWN","undefined"],"sources":["../../src/components/ConnectionBootstrap.tsx"],"sourcesContent":["import React, { createContext, useEffect, useState } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useApi, useClient } from '@deephaven/jsapi-bootstrap';\nimport type { 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 isCanceled = false;\n async function loadConnection() {\n try {\n const newConnection = await client.getAsIdeConnection();\n if (isCanceled) {\n return;\n }\n setConnection(newConnection);\n } catch (e) {\n if (isCanceled) {\n return;\n }\n setError(e);\n }\n }\n loadConnection();\n return () => {\n isCanceled = 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\n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E;IAExB,SAASS,cAAc,CAACC,KAAkB,EAAE;MAC1C,IAAM;QAAEC;MAAO,CAAC,GAAGD,KAAK;MACxBnB,GAAG,CAACqB,IAAI,CAAC,UAAU,YAAKC,IAAI,CAACC,SAAS,CAACH,MAAM,CAAC,EAAG;MACjDZ,QAAQ,4BAAqBY,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI,gBAAgB,EAAG;IAC5D;IAEA,IAAMI,SAAS,GAAGf,UAAU,CAACgB,gBAAgB,CAC3CpB,GAAG,CAACqB,aAAa,CAACC,cAAc,EAChCT,cAAc,CACf;IACD,OAAOM,SAAS;EAClB,CAAC,EACD,CAACnB,GAAG,EAAEI,UAAU,CAAC,CAClB;EAED,IAAIA,UAAU,IAAI,IAAI,IAAIF,KAAK,IAAI,IAAI,EAAE;IACvC,oBACE,oBAAC,cAAc;MACb,eAAY,8BAA8B;MAC1C,SAAS,EAAEE,UAAU,IAAI,IAAK;MAC9B,YAAY,EAAEF,KAAK,IAAI,IAAI,aAAMA,KAAK,IAAKqB;IAAU,EACrD;EAEN;EAEA,oBACE,oBAAC,iBAAiB,CAAC,QAAQ;IAAC,KAAK,EAAEnB;EAAW,GAC3CL,QAAQ,CACkB;AAEjC;AAEA,eAAeD,mBAAmB"}
@@ -0,0 +1,33 @@
1
+ import React, { createContext, useEffect, useState } from 'react';
2
+ import 'fira';
3
+ export var FontsLoadedContext = /*#__PURE__*/createContext(false);
4
+ /**
5
+ * FontBootstrap component. Handles preloading fonts.
6
+ */
7
+ export function FontBootstrap(_ref) {
8
+ var {
9
+ fontClassNames = ['fira-sans-regular', 'fira-sans-semibold', 'fira-mono'],
10
+ children
11
+ } = _ref;
12
+ var [isLoaded, setIsLoaded] = useState(false);
13
+ useEffect(function initFonts() {
14
+ document.fonts.ready.then(() => {
15
+ setIsLoaded(true);
16
+ });
17
+ }, []);
18
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FontsLoadedContext.Provider, {
19
+ value: isLoaded
20
+ }, children), /*#__PURE__*/React.createElement("div", {
21
+ id: "preload-fonts",
22
+ style: {
23
+ visibility: 'hidden',
24
+ position: 'absolute',
25
+ top: -10000
26
+ }
27
+ }, fontClassNames.map(className => /*#__PURE__*/React.createElement("p", {
28
+ key: className,
29
+ className: className
30
+ }, "preload"))));
31
+ }
32
+ export default FontBootstrap;
33
+ //# sourceMappingURL=FontBootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontBootstrap.js","names":["React","createContext","useEffect","useState","FontsLoadedContext","FontBootstrap","fontClassNames","children","isLoaded","setIsLoaded","initFonts","document","fonts","ready","then","visibility","position","top","map","className"],"sources":["../../src/components/FontBootstrap.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-semibold', '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"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACjE,OAAO,MAAM;AAEb,OAAO,IAAMC,kBAAkB,gBAAGH,aAAa,CAAU,KAAK,CAAC;AAe/D;AACA;AACA;AACA,OAAO,SAASI,aAAa,OAGN;EAAA,IAHO;IAC5BC,cAAc,GAAG,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,WAAW,CAAC;IACzEC;EACkB,CAAC;EACnB,IAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGN,QAAQ,CAAC,KAAK,CAAC;EAC/CD,SAAS,CAAC,SAASQ,SAAS,GAAG;IAC7BC,QAAQ,CAACC,KAAK,CAACC,KAAK,CAACC,IAAI,CAAC,MAAM;MAC9BL,WAAW,CAAC,IAAI,CAAC;IACnB,CAAC,CAAC;EACJ,CAAC,EAAE,EAAE,CAAC;EAEN,oBACE,uDACE,oBAAC,kBAAkB,CAAC,QAAQ;IAAC,KAAK,EAAED;EAAS,GAC1CD,QAAQ,CACmB,eAU9B;IACE,EAAE,EAAC,eAAe;IAClB,KAAK,EAAE;MAAEQ,UAAU,EAAE,QAAQ;MAAEC,QAAQ,EAAE,UAAU;MAAEC,GAAG,EAAE,CAAC;IAAM;EAAE,GAGlEX,cAAc,CAACY,GAAG,CAACC,SAAS,iBAC3B;IAAG,GAAG,EAAEA,SAAU;IAAC,SAAS,EAAEA;EAAU,GAAC,SAEzC,CACD,CAAC,CACE,CACL;AAEP;AAEA,eAAed,aAAa"}
@@ -0,0 +1,19 @@
1
+ import React, { useContext } from 'react';
2
+ import { LoadingOverlay } from '@deephaven/components';
3
+ import { FontsLoadedContext } from "./FontBootstrap.js";
4
+ export function FontsLoaded(_ref) {
5
+ var {
6
+ children
7
+ } = _ref;
8
+ var isFontsLoaded = useContext(FontsLoadedContext);
9
+ if (!isFontsLoaded) {
10
+ return /*#__PURE__*/React.createElement(LoadingOverlay, {
11
+ "data-testid": "fonts-loaded-loading"
12
+ });
13
+ }
14
+
15
+ // eslint-disable-next-line react/jsx-no-useless-fragment
16
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children);
17
+ }
18
+ export default FontsLoaded;
19
+ //# sourceMappingURL=FontsLoaded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FontsLoaded.js","names":["React","useContext","LoadingOverlay","FontsLoadedContext","FontsLoaded","children","isFontsLoaded"],"sources":["../../src/components/FontsLoaded.tsx"],"sourcesContent":["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"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,cAAc,QAAQ,uBAAuB;AAAC,SAC9CC,kBAAkB;AAO3B,OAAO,SAASC,WAAW,OAAiC;EAAA,IAAhC;IAAEC;EAA2B,CAAC;EACxD,IAAMC,aAAa,GAAGL,UAAU,CAACE,kBAAkB,CAAC;EAEpD,IAAI,CAACG,aAAa,EAAE;IAClB,oBAAO,oBAAC,cAAc;MAAC,eAAY;IAAsB,EAAG;EAC9D;;EAEA;EACA,oBAAO,0CAAGD,QAAQ,CAAI;AACxB;AAEA,eAAeD,WAAW"}
@@ -0,0 +1,16 @@
1
+ import { useBroadcastChannel } from '@deephaven/jsapi-components';
2
+ import { BROADCAST_LOGIN_MESSAGE, makeMessage } from '@deephaven/jsapi-utils';
3
+ import { useEffect } from 'react';
4
+
5
+ /**
6
+ * Component that broadcasts a message when mounted. Should be mounted after the user has logged in.
7
+ */
8
+ export function LoginNotifier() {
9
+ var channel = useBroadcastChannel();
10
+ useEffect(function notifyLogin() {
11
+ channel.postMessage(makeMessage(BROADCAST_LOGIN_MESSAGE));
12
+ }, [channel]);
13
+ return null;
14
+ }
15
+ export default LoginNotifier;
16
+ //# sourceMappingURL=LoginNotifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoginNotifier.js","names":["useBroadcastChannel","BROADCAST_LOGIN_MESSAGE","makeMessage","useEffect","LoginNotifier","channel","notifyLogin","postMessage"],"sources":["../../src/components/LoginNotifier.tsx"],"sourcesContent":["import { useBroadcastChannel } from '@deephaven/jsapi-components';\nimport { BROADCAST_LOGIN_MESSAGE, makeMessage } from '@deephaven/jsapi-utils';\nimport { useEffect } from 'react';\n\n/**\n * Component that broadcasts a message when mounted. Should be mounted after the user has logged in.\n */\nexport function LoginNotifier() {\n const channel = useBroadcastChannel();\n useEffect(\n function notifyLogin() {\n channel.postMessage(makeMessage(BROADCAST_LOGIN_MESSAGE));\n },\n [channel]\n );\n return null;\n}\n\nexport default LoginNotifier;\n"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,6BAA6B;AACjE,SAASC,uBAAuB,EAAEC,WAAW,QAAQ,wBAAwB;AAC7E,SAASC,SAAS,QAAQ,OAAO;;AAEjC;AACA;AACA;AACA,OAAO,SAASC,aAAa,GAAG;EAC9B,IAAMC,OAAO,GAAGL,mBAAmB,EAAE;EACrCG,SAAS,CACP,SAASG,WAAW,GAAG;IACrBD,OAAO,CAACE,WAAW,CAACL,WAAW,CAACD,uBAAuB,CAAC,CAAC;EAC3D,CAAC,EACD,CAACI,OAAO,CAAC,CACV;EACD,OAAO,IAAI;AACb;AAEA,eAAeD,aAAa"}
@@ -0,0 +1,39 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ import React, { createContext, useEffect, useState } from 'react';
4
+ import { loadModulePlugins } from "../plugins/index.js";
5
+ export var PluginsContext = /*#__PURE__*/createContext(null);
6
+ /**
7
+ * PluginsBootstrap component. Handles loading the plugins.
8
+ */
9
+ export function PluginsBootstrap(_ref) {
10
+ var {
11
+ pluginsUrl,
12
+ children
13
+ } = _ref;
14
+ var [plugins, setPlugins] = useState(null);
15
+ useEffect(function initPlugins() {
16
+ var isCanceled = false;
17
+ function loadPlugins() {
18
+ return _loadPlugins.apply(this, arguments);
19
+ }
20
+ function _loadPlugins() {
21
+ _loadPlugins = _asyncToGenerator(function* () {
22
+ var pluginModules = yield loadModulePlugins(pluginsUrl);
23
+ if (!isCanceled) {
24
+ setPlugins(pluginModules);
25
+ }
26
+ });
27
+ return _loadPlugins.apply(this, arguments);
28
+ }
29
+ loadPlugins();
30
+ return () => {
31
+ isCanceled = true;
32
+ };
33
+ }, [pluginsUrl]);
34
+ return /*#__PURE__*/React.createElement(PluginsContext.Provider, {
35
+ value: plugins
36
+ }, children);
37
+ }
38
+ export default PluginsBootstrap;
39
+ //# sourceMappingURL=PluginsBootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginsBootstrap.js","names":["React","createContext","useEffect","useState","loadModulePlugins","PluginsContext","PluginsBootstrap","pluginsUrl","children","plugins","setPlugins","initPlugins","isCanceled","loadPlugins","pluginModules"],"sources":["../../src/components/PluginsBootstrap.tsx"],"sourcesContent":["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 isCanceled = false;\n async function loadPlugins() {\n const pluginModules = await loadModulePlugins(pluginsUrl);\n if (!isCanceled) {\n setPlugins(pluginModules);\n }\n }\n loadPlugins();\n return () => {\n isCanceled = 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"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAAC,SACxCC,iBAAiB;AAE3C,OAAO,IAAMC,cAAc,gBAAGJ,aAAa,CAAyB,IAAI,CAAC;AAezE;AACA;AACA;AACA,OAAO,SAASK,gBAAgB,OAGN;EAAA,IAHO;IAC/BC,UAAU;IACVC;EACqB,CAAC;EACtB,IAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGP,QAAQ,CAAyB,IAAI,CAAC;EACpED,SAAS,CACP,SAASS,WAAW,GAAG;IACrB,IAAIC,UAAU,GAAG,KAAK;IAAC,SACRC,WAAW;MAAA;IAAA;IAAA;MAAA,iCAA1B,aAA6B;QAC3B,IAAMC,aAAa,SAASV,iBAAiB,CAACG,UAAU,CAAC;QACzD,IAAI,CAACK,UAAU,EAAE;UACfF,UAAU,CAACI,aAAa,CAAC;QAC3B;MACF,CAAC;MAAA;IAAA;IACDD,WAAW,EAAE;IACb,OAAO,MAAM;MACXD,UAAU,GAAG,IAAI;IACnB,CAAC;EACH,CAAC,EACD,CAACL,UAAU,CAAC,CACb;EAED,oBACE,oBAAC,cAAc,CAAC,QAAQ;IAAC,KAAK,EAAEE;EAAQ,GACrCD,QAAQ,CACe;AAE9B;AAEA,eAAeF,gBAAgB"}
@@ -0,0 +1,55 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ import React, { createContext, useEffect, useState } from 'react';
4
+ import { LoadingOverlay } from '@deephaven/components';
5
+ import { useClient } from '@deephaven/jsapi-bootstrap';
6
+ import { getErrorMessage } from '@deephaven/utils';
7
+ export var ServerConfigContext = /*#__PURE__*/createContext(null);
8
+ /**
9
+ * ServerConfigBootstrap component. Handles loading the server config.
10
+ */
11
+ export function ServerConfigBootstrap(_ref) {
12
+ var {
13
+ children
14
+ } = _ref;
15
+ var client = useClient();
16
+ var [serverConfig, setServerConfig] = useState();
17
+ var [error, setError] = useState();
18
+ useEffect(function initServerConfigValues() {
19
+ var isCanceled = false;
20
+ function loadServerConfigValues() {
21
+ return _loadServerConfigValues.apply(this, arguments);
22
+ }
23
+ function _loadServerConfigValues() {
24
+ _loadServerConfigValues = _asyncToGenerator(function* () {
25
+ try {
26
+ var newServerConfigValues = yield client.getServerConfigValues();
27
+ if (!isCanceled) {
28
+ setServerConfig(new Map(newServerConfigValues));
29
+ }
30
+ } catch (e) {
31
+ if (!isCanceled) {
32
+ setError(e);
33
+ }
34
+ }
35
+ });
36
+ return _loadServerConfigValues.apply(this, arguments);
37
+ }
38
+ loadServerConfigValues();
39
+ return () => {
40
+ isCanceled = true;
41
+ };
42
+ }, [client]);
43
+ var isLoading = serverConfig == null;
44
+ if (isLoading || error != null) {
45
+ return /*#__PURE__*/React.createElement(LoadingOverlay, {
46
+ isLoading: isLoading && error == null,
47
+ errorMessage: getErrorMessage(error)
48
+ });
49
+ }
50
+ return /*#__PURE__*/React.createElement(ServerConfigContext.Provider, {
51
+ value: serverConfig
52
+ }, children);
53
+ }
54
+ export default ServerConfigBootstrap;
55
+ //# sourceMappingURL=ServerConfigBootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ServerConfigBootstrap.js","names":["React","createContext","useEffect","useState","LoadingOverlay","useClient","getErrorMessage","ServerConfigContext","ServerConfigBootstrap","children","client","serverConfig","setServerConfig","error","setError","initServerConfigValues","isCanceled","loadServerConfigValues","newServerConfigValues","getServerConfigValues","Map","e","isLoading"],"sources":["../../src/components/ServerConfigBootstrap.tsx"],"sourcesContent":["import React, { createContext, useEffect, useState } from 'react';\nimport { LoadingOverlay } from '@deephaven/components';\nimport { useClient } from '@deephaven/jsapi-bootstrap';\nimport { getErrorMessage } from '@deephaven/utils';\n\nexport const ServerConfigContext = createContext<Map<string, string> | null>(\n null\n);\n\nexport type ServerConfigBootstrapProps = {\n /**\n * The children to render after server config is loaded.\n */\n children: React.ReactNode;\n};\n\n/**\n * ServerConfigBootstrap component. Handles loading the server config.\n */\nexport function ServerConfigBootstrap({\n children,\n}: ServerConfigBootstrapProps) {\n const client = useClient();\n const [serverConfig, setServerConfig] = useState<Map<string, string>>();\n const [error, setError] = useState<unknown>();\n\n useEffect(\n function initServerConfigValues() {\n let isCanceled = false;\n async function loadServerConfigValues() {\n try {\n const newServerConfigValues = await client.getServerConfigValues();\n if (!isCanceled) {\n setServerConfig(new Map(newServerConfigValues));\n }\n } catch (e) {\n if (!isCanceled) {\n setError(e);\n }\n }\n }\n loadServerConfigValues();\n return () => {\n isCanceled = true;\n };\n },\n [client]\n );\n\n const isLoading = serverConfig == null;\n\n if (isLoading || error != null) {\n return (\n <LoadingOverlay\n isLoading={isLoading && error == null}\n errorMessage={getErrorMessage(error)}\n />\n );\n }\n\n return (\n <ServerConfigContext.Provider value={serverConfig}>\n {children}\n </ServerConfigContext.Provider>\n );\n}\n\nexport default ServerConfigBootstrap;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,aAAa,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACjE,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,SAAS,QAAQ,4BAA4B;AACtD,SAASC,eAAe,QAAQ,kBAAkB;AAElD,OAAO,IAAMC,mBAAmB,gBAAGN,aAAa,CAC9C,IAAI,CACL;AASD;AACA;AACA;AACA,OAAO,SAASO,qBAAqB,OAEN;EAAA,IAFO;IACpCC;EAC0B,CAAC;EAC3B,IAAMC,MAAM,GAAGL,SAAS,EAAE;EAC1B,IAAM,CAACM,YAAY,EAAEC,eAAe,CAAC,GAAGT,QAAQ,EAAuB;EACvE,IAAM,CAACU,KAAK,EAAEC,QAAQ,CAAC,GAAGX,QAAQ,EAAW;EAE7CD,SAAS,CACP,SAASa,sBAAsB,GAAG;IAChC,IAAIC,UAAU,GAAG,KAAK;IAAC,SACRC,sBAAsB;MAAA;IAAA;IAAA;MAAA,4CAArC,aAAwC;QACtC,IAAI;UACF,IAAMC,qBAAqB,SAASR,MAAM,CAACS,qBAAqB,EAAE;UAClE,IAAI,CAACH,UAAU,EAAE;YACfJ,eAAe,CAAC,IAAIQ,GAAG,CAACF,qBAAqB,CAAC,CAAC;UACjD;QACF,CAAC,CAAC,OAAOG,CAAC,EAAE;UACV,IAAI,CAACL,UAAU,EAAE;YACfF,QAAQ,CAACO,CAAC,CAAC;UACb;QACF;MACF,CAAC;MAAA;IAAA;IACDJ,sBAAsB,EAAE;IACxB,OAAO,MAAM;MACXD,UAAU,GAAG,IAAI;IACnB,CAAC;EACH,CAAC,EACD,CAACN,MAAM,CAAC,CACT;EAED,IAAMY,SAAS,GAAGX,YAAY,IAAI,IAAI;EAEtC,IAAIW,SAAS,IAAIT,KAAK,IAAI,IAAI,EAAE;IAC9B,oBACE,oBAAC,cAAc;MACb,SAAS,EAAES,SAAS,IAAIT,KAAK,IAAI,IAAK;MACtC,YAAY,EAAEP,eAAe,CAACO,KAAK;IAAE,EACrC;EAEN;EAEA,oBACE,oBAAC,mBAAmB,CAAC,QAAQ;IAAC,KAAK,EAAEF;EAAa,GAC/CF,QAAQ,CACoB;AAEnC;AAEA,eAAeD,qBAAqB"}
@@ -0,0 +1,20 @@
1
+ import React, { useContext } from 'react';
2
+ import { UserContext, UserOverrideContext, UserPermissionsOverrideContext, getUserFromConfig } from '@deephaven/auth-plugins';
3
+ import useServerConfig from "./useServerConfig.js";
4
+ /**
5
+ * UserBootstrap component. Derives the UserContext from the ServerConfigContext, UserOverrideContext, and UserPermissionsOverrideContext.
6
+ */
7
+ export function UserBootstrap(_ref) {
8
+ var {
9
+ children
10
+ } = _ref;
11
+ var serverConfig = useServerConfig();
12
+ var overrides = useContext(UserOverrideContext);
13
+ var permissionsOverrides = useContext(UserPermissionsOverrideContext);
14
+ var user = getUserFromConfig(serverConfig, overrides, permissionsOverrides);
15
+ return /*#__PURE__*/React.createElement(UserContext.Provider, {
16
+ value: user
17
+ }, children);
18
+ }
19
+ export default UserBootstrap;
20
+ //# sourceMappingURL=UserBootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UserBootstrap.js","names":["React","useContext","UserContext","UserOverrideContext","UserPermissionsOverrideContext","getUserFromConfig","useServerConfig","UserBootstrap","children","serverConfig","overrides","permissionsOverrides","user"],"sources":["../../src/components/UserBootstrap.tsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport {\n UserContext,\n UserOverrideContext,\n UserPermissionsOverrideContext,\n getUserFromConfig,\n} from '@deephaven/auth-plugins';\nimport useServerConfig from './useServerConfig';\n\nexport type UserBootstrapProps = {\n /** The children to render */\n children: React.ReactNode;\n};\n\n/**\n * UserBootstrap component. Derives the UserContext from the ServerConfigContext, UserOverrideContext, and UserPermissionsOverrideContext.\n */\nexport function UserBootstrap({ children }: UserBootstrapProps) {\n const serverConfig = useServerConfig();\n const overrides = useContext(UserOverrideContext);\n const permissionsOverrides = useContext(UserPermissionsOverrideContext);\n const user = getUserFromConfig(serverConfig, overrides, permissionsOverrides);\n return <UserContext.Provider value={user}>{children}</UserContext.Provider>;\n}\n\nexport default UserBootstrap;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SACEC,WAAW,EACXC,mBAAmB,EACnBC,8BAA8B,EAC9BC,iBAAiB,QACZ,yBAAyB;AAAC,OAC1BC,eAAe;AAOtB;AACA;AACA;AACA,OAAO,SAASC,aAAa,OAAmC;EAAA,IAAlC;IAAEC;EAA6B,CAAC;EAC5D,IAAMC,YAAY,GAAGH,eAAe,EAAE;EACtC,IAAMI,SAAS,GAAGT,UAAU,CAACE,mBAAmB,CAAC;EACjD,IAAMQ,oBAAoB,GAAGV,UAAU,CAACG,8BAA8B,CAAC;EACvE,IAAMQ,IAAI,GAAGP,iBAAiB,CAACI,YAAY,EAAEC,SAAS,EAAEC,oBAAoB,CAAC;EAC7E,oBAAO,oBAAC,WAAW,CAAC,QAAQ;IAAC,KAAK,EAAEC;EAAK,GAAEJ,QAAQ,CAAwB;AAC7E;AAEA,eAAeD,aAAa"}
@@ -0,0 +1,11 @@
1
+ export * from "./AppBootstrap.js";
2
+ export * from "./AuthBootstrap.js";
3
+ export * from "./ConnectionBootstrap.js";
4
+ export * from "./FontBootstrap.js";
5
+ export * from "./FontsLoaded.js";
6
+ export * from "./PluginsBootstrap.js";
7
+ export * from "./usePlugins.js";
8
+ export * from "./useConnection.js";
9
+ export * from "./useServerConfig.js";
10
+ export * from "./useUser.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/components/index.ts"],"sourcesContent":["export * from './AppBootstrap';\nexport * from './AuthBootstrap';\nexport * from './ConnectionBootstrap';\nexport * from './FontBootstrap';\nexport * from './FontsLoaded';\nexport * from './PluginsBootstrap';\nexport * from './usePlugins';\nexport * from './useConnection';\nexport * from './useServerConfig';\nexport * from './useUser';\n"],"mappings":""}
@@ -0,0 +1,7 @@
1
+ import { useContextOrThrow } from '@deephaven/react-hooks';
2
+ import { ConnectionContext } from "./ConnectionBootstrap.js";
3
+ export function useConnection() {
4
+ return useContextOrThrow(ConnectionContext, 'No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?');
5
+ }
6
+ export default useConnection;
7
+ //# sourceMappingURL=useConnection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useConnection.js","names":["useContextOrThrow","ConnectionContext","useConnection"],"sources":["../../src/components/useConnection.ts"],"sourcesContent":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wBAAwB;AAAC,SAClDC,iBAAiB;AAE1B,OAAO,SAASC,aAAa,GAAG;EAC9B,OAAOF,iBAAiB,CACtBC,iBAAiB,EACjB,qHAAqH,CACtH;AACH;AAEA,eAAeC,aAAa"}
@@ -0,0 +1,7 @@
1
+ import { useContextOrThrow } from '@deephaven/react-hooks';
2
+ import { PluginsContext } from "./PluginsBootstrap.js";
3
+ export function usePlugins() {
4
+ return useContextOrThrow(PluginsContext, 'No Plugins available in usePlugins. Was code wrapped in PluginsBootstrap or PluginsContext.Provider?');
5
+ }
6
+ export default usePlugins;
7
+ //# sourceMappingURL=usePlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePlugins.js","names":["useContextOrThrow","PluginsContext","usePlugins"],"sources":["../../src/components/usePlugins.ts"],"sourcesContent":["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"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wBAAwB;AAAC,SAClDC,cAAc;AAEvB,OAAO,SAASC,UAAU,GAAG;EAC3B,OAAOF,iBAAiB,CACtBC,cAAc,EACd,sGAAsG,CACvG;AACH;AAEA,eAAeC,UAAU"}
@@ -0,0 +1,7 @@
1
+ import { useContextOrThrow } from '@deephaven/react-hooks';
2
+ import { ServerConfigContext } from "./ServerConfigBootstrap.js";
3
+ export function useServerConfig() {
4
+ return useContextOrThrow(ServerConfigContext, 'No server config available in useServerConfig. Was code wrapped in ServerConfigBootstrap or ServerConfigContext.Provider?');
5
+ }
6
+ export default useServerConfig;
7
+ //# sourceMappingURL=useServerConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useServerConfig.js","names":["useContextOrThrow","ServerConfigContext","useServerConfig"],"sources":["../../src/components/useServerConfig.ts"],"sourcesContent":["import { useContextOrThrow } from '@deephaven/react-hooks';\nimport { ServerConfigContext } from './ServerConfigBootstrap';\n\nexport function useServerConfig() {\n return useContextOrThrow(\n ServerConfigContext,\n 'No server config available in useServerConfig. Was code wrapped in ServerConfigBootstrap or ServerConfigContext.Provider?'\n );\n}\n\nexport default useServerConfig;\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wBAAwB;AAAC,SAClDC,mBAAmB;AAE5B,OAAO,SAASC,eAAe,GAAG;EAChC,OAAOF,iBAAiB,CACtBC,mBAAmB,EACnB,2HAA2H,CAC5H;AACH;AAEA,eAAeC,eAAe"}
@@ -0,0 +1,7 @@
1
+ import { useContextOrThrow } from '@deephaven/react-hooks';
2
+ import { UserContext } from '@deephaven/auth-plugins';
3
+ export function useUser() {
4
+ return useContextOrThrow(UserContext, 'No user available in useUser. Was code wrapped in UserBootstrap or UserContext.Provider?');
5
+ }
6
+ export default useUser;
7
+ //# sourceMappingURL=useUser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUser.js","names":["useContextOrThrow","UserContext","useUser"],"sources":["../../src/components/useUser.ts"],"sourcesContent":["import { useContextOrThrow } from '@deephaven/react-hooks';\nimport { UserContext } from '@deephaven/auth-plugins';\n\nexport function useUser() {\n return useContextOrThrow(\n UserContext,\n 'No user available in useUser. Was code wrapped in UserBootstrap or UserContext.Provider?'\n );\n}\n\nexport default useUser;\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wBAAwB;AAC1D,SAASC,WAAW,QAAQ,yBAAyB;AAErD,OAAO,SAASC,OAAO,GAAG;EACxB,OAAOF,iBAAiB,CACtBC,WAAW,EACX,0FAA0F,CAC3F;AACH;AAEA,eAAeC,OAAO"}
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./components/index.js";
2
+ export * from "./plugins/index.js";
3
+ export * from "./utils/index.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["export * from './components';\nexport * from './plugins';\nexport * from './utils';\n"],"mappings":""}
@@ -0,0 +1,184 @@
1
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
2
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
4
+ import React from 'react';
5
+ import { isAuthPlugin } from '@deephaven/auth-plugins';
6
+ import Log from '@deephaven/log';
7
+ import RemoteComponent from "./RemoteComponent.js";
8
+ import loadRemoteModule from "./loadRemoteModule.js";
9
+ var log = Log.module('@deephaven/app-utils.PluginUtils');
10
+
11
+ // A PluginModule. This interface should have new fields added to it from different levels of plugins.
12
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
13
+
14
+ /**
15
+ * Load a component plugin from the server.
16
+ * @param baseURL Base URL of the plugin server
17
+ * @param pluginName Name of the component plugin to load
18
+ * @returns A lazily loaded JSX.Element from the plugin
19
+ */
20
+ export function loadComponentPlugin(baseURL, pluginName) {
21
+ var pluginUrl = new URL("".concat(pluginName, ".js"), baseURL);
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ var Plugin = /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/React.createElement(RemoteComponent, {
24
+ url: pluginUrl.href
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ ,
27
+ render: _ref => {
28
+ var {
29
+ err,
30
+ Component
31
+ } = _ref;
32
+ if (err != null && err !== '') {
33
+ var errorMessage = "Error loading plugin ".concat(pluginName, " from ").concat(pluginUrl, " due to ").concat(err);
34
+ log.error(errorMessage);
35
+ return /*#__PURE__*/React.createElement("div", {
36
+ className: "error-message"
37
+ }, "".concat(errorMessage));
38
+ }
39
+ // eslint-disable-next-line react/jsx-props-no-spreading
40
+ return /*#__PURE__*/React.createElement(Component, _extends({
41
+ ref: ref
42
+ }, props));
43
+ }
44
+ }));
45
+ Plugin.pluginName = pluginName;
46
+ Plugin.displayName = 'Plugin';
47
+ return Plugin;
48
+ }
49
+
50
+ /**
51
+ * Imports a commonjs plugin module from the provided URL
52
+ * @param pluginUrl The URL of the plugin to load
53
+ * @returns The loaded module
54
+ */
55
+ export function loadModulePlugin(_x) {
56
+ return _loadModulePlugin.apply(this, arguments);
57
+ }
58
+
59
+ /**
60
+ * Loads a JSON file and returns the JSON object
61
+ * @param jsonUrl The URL of the JSON file to load
62
+ * @returns The JSON object of the manifest file
63
+ */
64
+ function _loadModulePlugin() {
65
+ _loadModulePlugin = _asyncToGenerator(function* (pluginUrl) {
66
+ var myModule = yield loadRemoteModule(pluginUrl);
67
+ return myModule;
68
+ });
69
+ return _loadModulePlugin.apply(this, arguments);
70
+ }
71
+ export function loadJson(_x2) {
72
+ return _loadJson.apply(this, arguments);
73
+ }
74
+
75
+ /**
76
+ * Load all plugin modules available.
77
+ * @param modulePluginsUrl The base URL of the module plugins to load
78
+ * @returns A map from the name of the plugin to the plugin module that was loaded
79
+ */
80
+ function _loadJson() {
81
+ _loadJson = _asyncToGenerator(function* (jsonUrl) {
82
+ var res = yield fetch(jsonUrl);
83
+ if (!res.ok) {
84
+ throw new Error(res.statusText);
85
+ }
86
+ try {
87
+ return yield res.json();
88
+ } catch (_unused) {
89
+ throw new Error('Could not be parsed as JSON');
90
+ }
91
+ });
92
+ return _loadJson.apply(this, arguments);
93
+ }
94
+ export function loadModulePlugins(_x3) {
95
+ return _loadModulePlugins.apply(this, arguments);
96
+ }
97
+ function _loadModulePlugins() {
98
+ _loadModulePlugins = _asyncToGenerator(function* (modulePluginsUrl) {
99
+ log.debug('Loading plugins...');
100
+ try {
101
+ var manifest = yield loadJson("".concat(modulePluginsUrl, "/manifest.json"));
102
+ if (!Array.isArray(manifest.plugins)) {
103
+ throw new Error('Plugin manifest JSON does not contain plugins array');
104
+ }
105
+ log.debug('Plugin manifest loaded:', manifest);
106
+ var pluginPromises = [];
107
+ for (var i = 0; i < manifest.plugins.length; i += 1) {
108
+ var {
109
+ name,
110
+ main
111
+ } = manifest.plugins[i];
112
+ var pluginMainUrl = "".concat(modulePluginsUrl, "/").concat(name, "/").concat(main);
113
+ pluginPromises.push(loadModulePlugin(pluginMainUrl));
114
+ }
115
+ var pluginModules = yield Promise.allSettled(pluginPromises);
116
+ var pluginMap = new Map();
117
+ for (var _i = 0; _i < pluginModules.length; _i += 1) {
118
+ var module = pluginModules[_i];
119
+ var {
120
+ name: _name
121
+ } = manifest.plugins[_i];
122
+ if (module.status === 'fulfilled') {
123
+ pluginMap.set(_name, module.value);
124
+ } else {
125
+ log.error("Unable to load plugin ".concat(_name), module.reason);
126
+ }
127
+ }
128
+ log.info('Plugins loaded:', pluginMap);
129
+ return pluginMap;
130
+ } catch (e) {
131
+ log.error('Unable to load plugins:', e);
132
+ return new Map();
133
+ }
134
+ });
135
+ return _loadModulePlugins.apply(this, arguments);
136
+ }
137
+ export function getAuthHandlers(authConfigValues) {
138
+ var _authConfigValues$get, _authConfigValues$get2;
139
+ return (_authConfigValues$get = (_authConfigValues$get2 = authConfigValues.get('AuthHandlers')) === null || _authConfigValues$get2 === void 0 ? void 0 : _authConfigValues$get2.split(',')) !== null && _authConfigValues$get !== void 0 ? _authConfigValues$get : [];
140
+ }
141
+
142
+ /**
143
+ * Get the auth plugin component from the plugin map and current configuration
144
+ * Throws if no auth plugin is available
145
+ *
146
+ * @param pluginMap Map of plugins loaded from the server
147
+ * @param authConfigValues Auth config values from the server
148
+ * @param corePlugins Map of core auth plugins to include in the list. They are added after the loaded plugins
149
+ * @returns The auth plugin component to render
150
+ */
151
+ export function getAuthPluginComponent(pluginMap, authConfigValues, corePlugins) {
152
+ var authHandlers = getAuthHandlers(authConfigValues);
153
+ // Filter out all the plugins that are auth plugins, and then map them to [pluginName, AuthPlugin] pairs
154
+ // Uses some pretty disgusting casting, because TypeScript wants to treat it as an (string | AuthPlugin)[] array instead
155
+ var authPlugins = [...pluginMap.entries()].filter(_ref2 => {
156
+ var [, plugin] = _ref2;
157
+ return isAuthPlugin(plugin.AuthPlugin);
158
+ }).map(_ref3 => {
159
+ var [name, plugin] = _ref3;
160
+ return [name, plugin.AuthPlugin];
161
+ });
162
+
163
+ // Add all the core plugins in priority
164
+ authPlugins.push(...(corePlugins !== null && corePlugins !== void 0 ? corePlugins : []));
165
+
166
+ // Filter the available auth plugins
167
+
168
+ var availableAuthPlugins = authPlugins.filter(_ref4 => {
169
+ var [name, authPlugin] = _ref4;
170
+ return authPlugin.isAvailable(authHandlers, authConfigValues);
171
+ });
172
+ if (availableAuthPlugins.length === 0) {
173
+ throw new Error("No login plugins found, please register a login plugin for auth handlers: ".concat(authHandlers));
174
+ } else if (availableAuthPlugins.length > 1) {
175
+ log.warn('More than one login plugin available, will use the first one: ', availableAuthPlugins.map(_ref5 => {
176
+ var [name] = _ref5;
177
+ return name;
178
+ }).join(', '));
179
+ }
180
+ var [loginPluginName, NewLoginPlugin] = availableAuthPlugins[0];
181
+ log.info('Using LoginPlugin', loginPluginName);
182
+ return NewLoginPlugin.Component;
183
+ }
184
+ //# sourceMappingURL=PluginUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PluginUtils.js","names":["React","isAuthPlugin","Log","RemoteComponent","loadRemoteModule","log","module","loadComponentPlugin","baseURL","pluginName","pluginUrl","URL","Plugin","forwardRef","props","ref","href","err","Component","errorMessage","error","displayName","loadModulePlugin","myModule","loadJson","jsonUrl","res","fetch","ok","Error","statusText","json","loadModulePlugins","modulePluginsUrl","debug","manifest","Array","isArray","plugins","pluginPromises","i","length","name","main","pluginMainUrl","push","pluginModules","Promise","allSettled","pluginMap","Map","status","set","value","reason","info","e","getAuthHandlers","authConfigValues","get","split","getAuthPluginComponent","corePlugins","authHandlers","authPlugins","entries","filter","plugin","AuthPlugin","map","availableAuthPlugins","authPlugin","isAvailable","warn","join","loginPluginName","NewLoginPlugin"],"sources":["../../src/plugins/PluginUtils.tsx"],"sourcesContent":["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\nexport type PluginManifestPluginInfo = {\n name: string;\n main: string;\n version: string;\n};\n\nexport type PluginManifest = { plugins: PluginManifestPluginInfo[] };\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(\n pluginUrl: string\n): Promise<PluginModule> {\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(jsonUrl: string): Promise<PluginManifest> {\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<PluginModule>[] = [];\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);\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, authConfigValues)\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"],"mappings":";;;AAAA,OAAOA,KAAK,MAAqC,OAAO;AACxD,SAGEC,YAAY,QACP,yBAAyB;AAChC,OAAOC,GAAG,MAAM,gBAAgB;AAAC,OAC1BC,eAAe;AAAA,OACfC,gBAAgB;AAEvB,IAAMC,GAAG,GAAGH,GAAG,CAACI,MAAM,CAAC,kCAAkC,CAAC;;AAE1D;AACA;;AAaA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,mBAAmB,CACjCC,OAAY,EACZC,UAAkB,EACuC;EACzD,IAAMC,SAAS,GAAG,IAAIC,GAAG,WAAIF,UAAU,UAAOD,OAAO,CAAC;EACtD;EACA,IAAMI,MAAW,gBAAGZ,KAAK,CAACa,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,kBAC9C,oBAAC,eAAe;IACd,GAAG,EAAEL,SAAS,CAACM;I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CAAC;EAAA,EACvD;EAED,IAAIY,oBAAoB,CAAC7B,MAAM,KAAK,CAAC,EAAE;IACrC,MAAM,IAAIZ,KAAK,qFACgEkC,YAAY,EAC1F;EACH,CAAC,MAAM,IAAIO,oBAAoB,CAAC7B,MAAM,GAAG,CAAC,EAAE;IAC1CpC,GAAG,CAACoE,IAAI,CACN,gEAAgE,EAChEH,oBAAoB,CAACD,GAAG,CAAC;MAAA,IAAC,CAAC3B,IAAI,CAAC;MAAA,OAAKA,IAAI;IAAA,EAAC,CAACgC,IAAI,CAAC,IAAI,CAAC,CACtD;EACH;EAEA,IAAM,CAACC,eAAe,EAAEC,cAAc,CAAC,GAAGN,oBAAoB,CAAC,CAAC,CAAC;EACjEjE,GAAG,CAACkD,IAAI,CAAC,mBAAmB,EAAEoB,eAAe,CAAC;EAE9C,OAAOC,cAAc,CAAC1D,SAAS;AACjC"}
@@ -0,0 +1,8 @@
1
+ import { createRemoteComponent, createRequires } from '@paciolan/remote-component';
2
+ import { resolve } from "./remote-component.config.js";
3
+ var requires = createRequires(() => resolve);
4
+ export var RemoteComponent = createRemoteComponent({
5
+ requires
6
+ });
7
+ export default RemoteComponent;
8
+ //# sourceMappingURL=RemoteComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteComponent.js","names":["createRemoteComponent","createRequires","resolve","requires","RemoteComponent"],"sources":["../../src/plugins/RemoteComponent.ts"],"sourcesContent":["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"],"mappings":"AAAA,SACEA,qBAAqB,EACrBC,cAAc,QACT,4BAA4B;AAAC,SAC3BC,OAAO;AAEhB,IAAMC,QAAQ,GAAGF,cAAc,CAAC,MAAMC,OAAO,CAAC;AAE9C,OAAO,IAAME,eAAe,GAAGJ,qBAAqB,CAAC;EAAEG;AAAS,CAAC,CAAC;AAClE,eAAeC,eAAe"}
@@ -0,0 +1,3 @@
1
+ export * from "./PluginUtils.js";
2
+ export { default as RemoteComponent } from "./RemoteComponent.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["default","RemoteComponent"],"sources":["../../src/plugins/index.ts"],"sourcesContent":["export * from './PluginUtils';\nexport { default as RemoteComponent } from './RemoteComponent';\n"],"mappings":";SACSA,OAAO,IAAIC,eAAe"}
@@ -0,0 +1,8 @@
1
+ import createLoadRemoteModule, { createRequires } from '@paciolan/remote-module-loader';
2
+ import { resolve } from "./remote-component.config.js";
3
+ var requires = createRequires(resolve);
4
+ export var loadRemoteModule = createLoadRemoteModule({
5
+ requires
6
+ });
7
+ export default loadRemoteModule;
8
+ //# sourceMappingURL=loadRemoteModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadRemoteModule.js","names":["createLoadRemoteModule","createRequires","resolve","requires","loadRemoteModule"],"sources":["../../src/plugins/loadRemoteModule.ts"],"sourcesContent":["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"],"mappings":"AAAA,OAAOA,sBAAsB,IAC3BC,cAAc,QACT,gCAAgC;AAAC,SAC/BC,OAAO;AAEhB,IAAMC,QAAQ,GAAGF,cAAc,CAACC,OAAO,CAAC;AAExC,OAAO,IAAME,gBAGZ,GAAGJ,sBAAsB,CAAC;EACzBG;AACF,CAAC,CAAC;AAEF,eAAeC,gBAAgB"}
@@ -0,0 +1,33 @@
1
+ /* eslint-disable global-require */
2
+ /**
3
+ * remote-component.config.js
4
+ *
5
+ * Dependencies for Remote Components
6
+ */
7
+ import react from 'react';
8
+ import * as redux from 'redux';
9
+ import * as reactRedux from 'react-redux';
10
+ import ReactDOM from 'react-dom';
11
+ import * as DeephavenAuthPlugins from '@deephaven/auth-plugins';
12
+ import * as DeephavenComponents from '@deephaven/components';
13
+ import * as DeephavenJsapiBootstrap from '@deephaven/jsapi-bootstrap';
14
+ import * as DeephavenJsapiComponents from '@deephaven/jsapi-components';
15
+ import * as DeephavenJsapiUtils from '@deephaven/jsapi-utils';
16
+ import * as DeephavenLog from '@deephaven/log';
17
+ import * as DeephavenReactHooks from '@deephaven/react-hooks';
18
+
19
+ // eslint-disable-next-line import/prefer-default-export
20
+ export var resolve = {
21
+ react,
22
+ 'react-dom': ReactDOM,
23
+ redux,
24
+ 'react-redux': reactRedux,
25
+ '@deephaven/auth-plugins': DeephavenAuthPlugins,
26
+ '@deephaven/components': DeephavenComponents,
27
+ '@deephaven/jsapi-bootstrap': DeephavenJsapiBootstrap,
28
+ '@deephaven/jsapi-components': DeephavenJsapiComponents,
29
+ '@deephaven/jsapi-utils': DeephavenJsapiUtils,
30
+ '@deephaven/log': DeephavenLog,
31
+ '@deephaven/react-hooks': DeephavenReactHooks
32
+ };
33
+ //# sourceMappingURL=remote-component.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-component.config.js","names":["react","redux","reactRedux","ReactDOM","DeephavenAuthPlugins","DeephavenComponents","DeephavenJsapiBootstrap","DeephavenJsapiComponents","DeephavenJsapiUtils","DeephavenLog","DeephavenReactHooks","resolve"],"sources":["../../src/plugins/remote-component.config.ts"],"sourcesContent":["/* 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';\nimport * as DeephavenAuthPlugins from '@deephaven/auth-plugins';\nimport * as DeephavenComponents from '@deephaven/components';\nimport * as DeephavenJsapiBootstrap from '@deephaven/jsapi-bootstrap';\nimport * as DeephavenJsapiComponents from '@deephaven/jsapi-components';\nimport * as DeephavenJsapiUtils from '@deephaven/jsapi-utils';\nimport * as DeephavenLog from '@deephaven/log';\nimport * as DeephavenReactHooks from '@deephaven/react-hooks';\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 '@deephaven/auth-plugins': DeephavenAuthPlugins,\n '@deephaven/components': DeephavenComponents,\n '@deephaven/jsapi-bootstrap': DeephavenJsapiBootstrap,\n '@deephaven/jsapi-components': DeephavenJsapiComponents,\n '@deephaven/jsapi-utils': DeephavenJsapiUtils,\n '@deephaven/log': DeephavenLog,\n '@deephaven/react-hooks': DeephavenReactHooks,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAO,KAAKC,KAAK,MAAM,OAAO;AAC9B,OAAO,KAAKC,UAAU,MAAM,aAAa;AACzC,OAAOC,QAAQ,MAAM,WAAW;AAChC,OAAO,KAAKC,oBAAoB,MAAM,yBAAyB;AAC/D,OAAO,KAAKC,mBAAmB,MAAM,uBAAuB;AAC5D,OAAO,KAAKC,uBAAuB,MAAM,4BAA4B;AACrE,OAAO,KAAKC,wBAAwB,MAAM,6BAA6B;AACvE,OAAO,KAAKC,mBAAmB,MAAM,wBAAwB;AAC7D,OAAO,KAAKC,YAAY,MAAM,gBAAgB;AAC9C,OAAO,KAAKC,mBAAmB,MAAM,wBAAwB;;AAE7D;AACA,OAAO,IAAMC,OAAO,GAAG;EACrBX,KAAK;EACL,WAAW,EAAEG,QAAQ;EACrBF,KAAK;EACL,aAAa,EAAEC,UAAU;EACzB,yBAAyB,EAAEE,oBAAoB;EAC/C,uBAAuB,EAAEC,mBAAmB;EAC5C,4BAA4B,EAAEC,uBAAuB;EACrD,6BAA6B,EAAEC,wBAAwB;EACvD,wBAAwB,EAAEC,mBAAmB;EAC7C,gBAAgB,EAAEC,YAAY;EAC9B,wBAAwB,EAAEC;AAC5B,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Get the base URL of the API
3
+ * @param apiUrl API URL
4
+ * @returns URL for the base of the API
5
+ */
6
+ export function getBaseUrl(apiUrl) {
7
+ return new URL(apiUrl, "".concat(window.location));
8
+ }
9
+
10
+ /**
11
+ * Get the Envoy prefix header value
12
+ * @returns Envoy prefix header value
13
+ */
14
+ export function getEnvoyPrefix() {
15
+ var searchParams = new URLSearchParams(window.location.search);
16
+ return searchParams.get('envoyPrefix');
17
+ }
18
+ export function getConnectOptions() {
19
+ var envoyPrefix = getEnvoyPrefix();
20
+ return envoyPrefix != null ? {
21
+ headers: {
22
+ 'envoy-prefix': envoyPrefix
23
+ }
24
+ } : {
25
+ headers: {}
26
+ };
27
+ }
28
+ //# sourceMappingURL=ConnectUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ConnectUtils.js","names":["getBaseUrl","apiUrl","URL","window","location","getEnvoyPrefix","searchParams","URLSearchParams","search","get","getConnectOptions","envoyPrefix","headers"],"sources":["../../src/utils/ConnectUtils.ts"],"sourcesContent":["import type { 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"],"mappings":"AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,UAAU,CAACC,MAAc,EAAO;EAC9C,OAAO,IAAIC,GAAG,CAACD,MAAM,YAAKE,MAAM,CAACC,QAAQ,EAAG;AAC9C;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAc,GAAkB;EAC9C,IAAMC,YAAY,GAAG,IAAIC,eAAe,CAACJ,MAAM,CAACC,QAAQ,CAACI,MAAM,CAAC;EAChE,OAAOF,YAAY,CAACG,GAAG,CAAC,aAAa,CAAC;AACxC;AAEA,OAAO,SAASC,iBAAiB,GAAmB;EAClD,IAAMC,WAAW,GAAGN,cAAc,EAAE;EACpC,OAAOM,WAAW,IAAI,IAAI,GACtB;IAAEC,OAAO,EAAE;MAAE,cAAc,EAAED;IAAY;EAAE,CAAC,GAC5C;IAAEC,OAAO,EAAE,CAAC;EAAE,CAAC;AACrB"}
@@ -0,0 +1,2 @@
1
+ export * from "./ConnectUtils.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './ConnectUtils';\n"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/app-utils",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "Deephaven App Utils",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -28,15 +28,15 @@
28
28
  "redux": "^4.x"
29
29
  },
30
30
  "dependencies": {
31
- "@deephaven/auth-plugins": "^0.43.0",
32
- "@deephaven/components": "^0.43.0",
33
- "@deephaven/jsapi-bootstrap": "^0.43.0",
34
- "@deephaven/jsapi-components": "^0.43.0",
35
- "@deephaven/jsapi-types": "^0.43.0",
36
- "@deephaven/jsapi-utils": "^0.43.0",
37
- "@deephaven/log": "^0.43.0",
38
- "@deephaven/react-hooks": "^0.43.0",
39
- "@deephaven/utils": "^0.43.0",
31
+ "@deephaven/auth-plugins": "^0.44.0",
32
+ "@deephaven/components": "^0.44.0",
33
+ "@deephaven/jsapi-bootstrap": "^0.44.0",
34
+ "@deephaven/jsapi-components": "^0.44.0",
35
+ "@deephaven/jsapi-types": "^0.44.0",
36
+ "@deephaven/jsapi-utils": "^0.44.0",
37
+ "@deephaven/log": "^0.44.0",
38
+ "@deephaven/react-hooks": "^0.44.0",
39
+ "@deephaven/utils": "^0.44.0",
40
40
  "@paciolan/remote-component": "2.13.0",
41
41
  "@paciolan/remote-module-loader": "^3.0.2",
42
42
  "fira": "mozilla/fira#4.202"
@@ -56,5 +56,5 @@
56
56
  "publishConfig": {
57
57
  "access": "public"
58
58
  },
59
- "gitHead": "b16776b5bdc15a02cd2897cd79d562ea38c60ed8"
59
+ "gitHead": "ba13c9139b3b7a5f5d64d79069f1de9d4727eeb6"
60
60
  }