@deephaven/app-utils 0.49.2-beta.5 → 0.49.2-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AppBootstrap.d.ts.map +1 -1
- package/dist/components/AppBootstrap.js +15 -12
- package/dist/components/AppBootstrap.js.map +1 -1
- package/dist/components/ThemeBootstrap.d.ts +7 -0
- package/dist/components/ThemeBootstrap.d.ts.map +1 -0
- package/dist/components/ThemeBootstrap.js +21 -0
- package/dist/components/ThemeBootstrap.js.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/usePlugins.js +1 -1
- package/dist/components/usePlugins.js.map +1 -1
- package/dist/plugins/PluginUtils.d.ts +6 -0
- package/dist/plugins/PluginUtils.d.ts.map +1 -1
- package/dist/plugins/PluginUtils.js +42 -3
- package/dist/plugins/PluginUtils.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppBootstrap.d.ts","sourceRoot":"","sources":["../../src/components/AppBootstrap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,gDAAgD,CAAC;AAMxD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"AppBootstrap.d.ts","sourceRoot":"","sources":["../../src/components/AppBootstrap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAC9D,OAAO,gDAAgD,CAAC;AAMxD,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAWzD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAElB,kCAAkC;IAClC,UAAU,EAAE,MAAM,CAAC;IAEnB,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAElD,gCAAgC;IAChC,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAE1B;;OAEG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,EAC3B,cAAc,EACd,UAAU,EACV,cAAc,EACd,SAAS,EACT,QAAQ,GACT,EAAE,iBAAiB,GAAG,GAAG,CAAC,OAAO,CAmCjC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -10,6 +10,7 @@ import { getConnectOptions } from "../utils/index.js";
|
|
|
10
10
|
import FontsLoaded from "./FontsLoaded.js";
|
|
11
11
|
import UserBootstrap from "./UserBootstrap.js";
|
|
12
12
|
import ServerConfigBootstrap from "./ServerConfigBootstrap.js";
|
|
13
|
+
import ThemeBootstrap from "./ThemeBootstrap.js";
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
/**
|
|
15
16
|
* AppBootstrap component. Handles loading the fonts, client, and authentication.
|
|
@@ -37,23 +38,25 @@ export function AppBootstrap(_ref) {
|
|
|
37
38
|
children: /*#__PURE__*/_jsx(PluginsBootstrap, {
|
|
38
39
|
getCorePlugins: getCorePlugins,
|
|
39
40
|
pluginsUrl: pluginsUrl,
|
|
40
|
-
children: /*#__PURE__*/_jsx(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
children: /*#__PURE__*/_jsx(
|
|
45
|
-
children: /*#__PURE__*/_jsx(
|
|
46
|
-
children: /*#__PURE__*/_jsx(
|
|
47
|
-
children: /*#__PURE__*/_jsx(
|
|
48
|
-
children: /*#__PURE__*/_jsx(
|
|
49
|
-
children:
|
|
41
|
+
children: /*#__PURE__*/_jsx(ThemeBootstrap, {
|
|
42
|
+
children: /*#__PURE__*/_jsx(ClientBootstrap, {
|
|
43
|
+
serverUrl: serverUrl,
|
|
44
|
+
options: clientOptions,
|
|
45
|
+
children: /*#__PURE__*/_jsx(RefreshTokenBootstrap, {
|
|
46
|
+
children: /*#__PURE__*/_jsx(AuthBootstrap, {
|
|
47
|
+
children: /*#__PURE__*/_jsx(ServerConfigBootstrap, {
|
|
48
|
+
children: /*#__PURE__*/_jsx(UserBootstrap, {
|
|
49
|
+
children: /*#__PURE__*/_jsx(ConnectionBootstrap, {
|
|
50
|
+
children: /*#__PURE__*/_jsx(FontsLoaded, {
|
|
51
|
+
children: children
|
|
52
|
+
})
|
|
50
53
|
})
|
|
51
54
|
})
|
|
52
55
|
})
|
|
53
56
|
})
|
|
54
57
|
})
|
|
55
|
-
})
|
|
56
|
-
}
|
|
58
|
+
}, logoutCount)
|
|
59
|
+
})
|
|
57
60
|
})
|
|
58
61
|
});
|
|
59
62
|
}
|
|
@@ -1 +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","getCorePlugins","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 { type DashboardPlugin } from '@deephaven/plugin';\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 /** The core plugins to load. */\n getCorePlugins?: () => Promise<DashboardPlugin[]>;\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 getCorePlugins,\n serverUrl,\n children,\n}: AppBootstrapProps): JSX.Element {\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 getCorePlugins={getCorePlugins} pluginsUrl={pluginsUrl}>\n <ClientBootstrap\n
|
|
1
|
+
{"version":3,"file":"AppBootstrap.js","names":["React","useCallback","useMemo","useState","ClientBootstrap","RefreshTokenBootstrap","useBroadcastLoginListener","FontBootstrap","PluginsBootstrap","AuthBootstrap","ConnectionBootstrap","getConnectOptions","FontsLoaded","UserBootstrap","ServerConfigBootstrap","ThemeBootstrap","AppBootstrap","fontClassNames","pluginsUrl","getCorePlugins","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 { type DashboardPlugin } from '@deephaven/plugin';\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';\nimport ThemeBootstrap from './ThemeBootstrap';\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 /** The core plugins to load. */\n getCorePlugins?: () => Promise<DashboardPlugin[]>;\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 getCorePlugins,\n serverUrl,\n children,\n}: AppBootstrapProps): JSX.Element {\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 getCorePlugins={getCorePlugins} pluginsUrl={pluginsUrl}>\n <ThemeBootstrap>\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 </ThemeBootstrap>\n </PluginsBootstrap>\n </F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,KAAC,aAAa;cAAA,uBACZ,KAAC,qBAAqB;gBAAA,uBACpB,KAAC,aAAa;kBAAA,uBACZ,KAAC,mBAAmB;oBAAA,uBAClB,KAAC,WAAW;sBAAA,UAAED;oBAAQ;kBAAe;gBACjB;cACR;YACM;UACV;QACM,GAZnBE,WAAW;MAaA;IACH;EACA,EACL;AAEpB;AAEA,eAAeP,YAAY"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ThemeBootstrapProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
export declare function ThemeBootstrap({ children }: ThemeBootstrapProps): JSX.Element;
|
|
6
|
+
export default ThemeBootstrap;
|
|
7
|
+
//# sourceMappingURL=ThemeBootstrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeBootstrap.d.ts","sourceRoot":"","sources":["../../src/components/ThemeBootstrap.tsx"],"names":[],"mappings":";AAKA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,EAAE,mBAAmB,GAAG,GAAG,CAAC,OAAO,CAa7E;AAED,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ThemeProvider } from '@deephaven/components';
|
|
2
|
+
import { useContext, useMemo } from 'react';
|
|
3
|
+
import { getThemeDataFromPlugins } from "../plugins/index.js";
|
|
4
|
+
import { PluginsContext } from "./PluginsBootstrap.js";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export function ThemeBootstrap(_ref) {
|
|
7
|
+
var {
|
|
8
|
+
children
|
|
9
|
+
} = _ref;
|
|
10
|
+
// The `usePlugins` hook throws if the context value is null. Since this is
|
|
11
|
+
// the state while plugins load asynchronously, we are using `useContext`
|
|
12
|
+
// directly to avoid the exception.
|
|
13
|
+
var pluginModules = useContext(PluginsContext);
|
|
14
|
+
var themes = useMemo(() => pluginModules == null ? null : getThemeDataFromPlugins(pluginModules), [pluginModules]);
|
|
15
|
+
return /*#__PURE__*/_jsx(ThemeProvider, {
|
|
16
|
+
themes: themes,
|
|
17
|
+
children: children
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export default ThemeBootstrap;
|
|
21
|
+
//# sourceMappingURL=ThemeBootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeBootstrap.js","names":["ThemeProvider","useContext","useMemo","getThemeDataFromPlugins","PluginsContext","ThemeBootstrap","children","pluginModules","themes"],"sources":["../../src/components/ThemeBootstrap.tsx"],"sourcesContent":["import { ThemeProvider } from '@deephaven/components';\nimport { useContext, useMemo } from 'react';\nimport { getThemeDataFromPlugins } from '../plugins';\nimport { PluginsContext } from './PluginsBootstrap';\n\nexport interface ThemeBootstrapProps {\n children: React.ReactNode;\n}\n\nexport function ThemeBootstrap({ children }: ThemeBootstrapProps): JSX.Element {\n // The `usePlugins` hook throws if the context value is null. Since this is\n // the state while plugins load asynchronously, we are using `useContext`\n // directly to avoid the exception.\n const pluginModules = useContext(PluginsContext);\n\n const themes = useMemo(\n () =>\n pluginModules == null ? null : getThemeDataFromPlugins(pluginModules),\n [pluginModules]\n );\n\n return <ThemeProvider themes={themes}>{children}</ThemeProvider>;\n}\n\nexport default ThemeBootstrap;\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAAC,SACnCC,uBAAuB;AAAA,SACvBC,cAAc;AAAA;AAMvB,OAAO,SAASC,cAAc,OAAiD;EAAA,IAAhD;IAAEC;EAA8B,CAAC;EAC9D;EACA;EACA;EACA,IAAMC,aAAa,GAAGN,UAAU,CAACG,cAAc,CAAC;EAEhD,IAAMI,MAAM,GAAGN,OAAO,CACpB,MACEK,aAAa,IAAI,IAAI,GAAG,IAAI,GAAGJ,uBAAuB,CAACI,aAAa,CAAC,EACvE,CAACA,aAAa,CAAC,CAChB;EAED,oBAAO,KAAC,aAAa;IAAC,MAAM,EAAEC,MAAO;IAAA,UAAEF;EAAQ,EAAiB;AAClE;AAEA,eAAeD,cAAc"}
|
|
@@ -4,6 +4,7 @@ export * from './ConnectionBootstrap';
|
|
|
4
4
|
export * from './FontBootstrap';
|
|
5
5
|
export * from './FontsLoaded';
|
|
6
6
|
export * from './PluginsBootstrap';
|
|
7
|
+
export * from './ThemeBootstrap';
|
|
7
8
|
export * from './usePlugins';
|
|
8
9
|
export * from './useConnection';
|
|
9
10
|
export * from './useServerConfig';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC;AAC1B,cAAc,sBAAsB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./ConnectionBootstrap.js";
|
|
|
4
4
|
export * from "./FontBootstrap.js";
|
|
5
5
|
export * from "./FontsLoaded.js";
|
|
6
6
|
export * from "./PluginsBootstrap.js";
|
|
7
|
+
export * from "./ThemeBootstrap.js";
|
|
7
8
|
export * from "./usePlugins.js";
|
|
8
9
|
export * from "./useConnection.js";
|
|
9
10
|
export * from "./useServerConfig.js";
|
|
@@ -1 +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';\nexport * from './useLoadTablePlugin';\n"],"mappings":""}
|
|
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 './ThemeBootstrap';\nexport * from './usePlugins';\nexport * from './useConnection';\nexport * from './useServerConfig';\nexport * from './useUser';\nexport * from './useLoadTablePlugin';\n"],"mappings":""}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextOrThrow } from '@deephaven/react-hooks';
|
|
2
2
|
import { PluginsContext } from "./PluginsBootstrap.js";
|
|
3
3
|
export function usePlugins() {
|
|
4
|
-
return useContextOrThrow(PluginsContext, 'No Plugins available in usePlugins.
|
|
4
|
+
return useContextOrThrow(PluginsContext, 'No Plugins available in usePlugins. This can happen when plugins have not finished loading or if code is not wrapped in PluginsBootstrap or PluginsContext.Provider.');
|
|
5
5
|
}
|
|
6
6
|
export default usePlugins;
|
|
7
7
|
//# sourceMappingURL=usePlugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePlugins.js","names":["useContextOrThrow","PluginsContext","usePlugins"],"sources":["../../src/components/usePlugins.ts"],"sourcesContent":["import { useContextOrThrow } from '@deephaven/react-hooks';\nimport type { PluginModuleMap } from '../plugins';\nimport { PluginsContext } from './PluginsBootstrap';\n\nexport function usePlugins(): PluginModuleMap {\n return useContextOrThrow(\n PluginsContext,\n 'No Plugins available in usePlugins.
|
|
1
|
+
{"version":3,"file":"usePlugins.js","names":["useContextOrThrow","PluginsContext","usePlugins"],"sources":["../../src/components/usePlugins.ts"],"sourcesContent":["import { useContextOrThrow } from '@deephaven/react-hooks';\nimport type { PluginModuleMap } from '../plugins';\nimport { PluginsContext } from './PluginsBootstrap';\n\nexport function usePlugins(): PluginModuleMap {\n return useContextOrThrow(\n PluginsContext,\n 'No Plugins available in usePlugins. This can happen when plugins have not finished loading or if code is not wrapped in PluginsBootstrap or PluginsContext.Provider.'\n );\n}\n\nexport default usePlugins;\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,wBAAwB;AAAC,SAElDC,cAAc;AAEvB,OAAO,SAASC,UAAU,GAAoB;EAC5C,OAAOF,iBAAiB,CACtBC,cAAc,EACd,sKAAsK,CACvK;AACH;AAEA,eAAeC,UAAU"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ThemeData } from '@deephaven/components';
|
|
1
2
|
import { type PluginModule, type AuthPlugin, type AuthPluginComponent, LegacyAuthPlugin, LegacyPlugin, Plugin } from '@deephaven/plugin';
|
|
2
3
|
export type PluginModuleMap = Map<string, PluginModule>;
|
|
3
4
|
export type PluginManifestPluginInfo = {
|
|
@@ -39,4 +40,9 @@ export declare function getAuthHandlers(authConfigValues: Map<string, string>):
|
|
|
39
40
|
* @returns The auth plugin component to render
|
|
40
41
|
*/
|
|
41
42
|
export declare function getAuthPluginComponent(pluginMap: PluginModuleMap, authConfigValues: Map<string, string>, corePlugins?: Map<string, LegacyAuthPlugin | AuthPlugin>): AuthPluginComponent;
|
|
43
|
+
/**
|
|
44
|
+
* Extract theme data from theme plugins in the given plugin map.
|
|
45
|
+
* @param pluginMap
|
|
46
|
+
*/
|
|
47
|
+
export declare function getThemeDataFromPlugins(pluginMap: PluginModuleMap): ThemeData[];
|
|
42
48
|
//# sourceMappingURL=PluginUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginUtils.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginUtils.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PluginUtils.d.ts","sourceRoot":"","sources":["../../src/plugins/PluginUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAe,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,mBAAmB,EAExB,gBAAgB,EAChB,YAAY,EACZ,MAAM,EAMP,MAAM,mBAAmB,CAAC;AAK3B,MAAM,MAAM,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAExD,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,wBAAwB,EAAE,CAAA;CAAE,CAAC;AAErE;;;;GAIG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,YAAY,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAG7C;AAED;;;;GAIG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAUvE;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,gBAAgB,EAAE,MAAM,GACvB,OAAO,CAAC,eAAe,CAAC,CAgD1B;AAED,wBAAgB,eAAe,CAC7B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GACpC,MAAM,EAAE,CAEV;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,eAAe,EAC1B,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACrC,WAAW,6CAAmD,GAC7D,mBAAmB,CAwCrB;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,eAAe,GACzB,SAAS,EAAE,CA0Bb"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
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
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 { getThemeKey } from '@deephaven/components';
|
|
3
4
|
import Log from '@deephaven/log';
|
|
4
|
-
import { isAuthPlugin, PluginType, isLegacyAuthPlugin, isLegacyPlugin } from '@deephaven/plugin';
|
|
5
|
+
import { isAuthPlugin, PluginType, isLegacyAuthPlugin, isLegacyPlugin, isThemePlugin } from '@deephaven/plugin';
|
|
5
6
|
import loadRemoteModule from "./loadRemoteModule.js";
|
|
6
7
|
var log = Log.module('@deephaven/app-utils.PluginUtils');
|
|
7
8
|
/**
|
|
@@ -77,9 +78,19 @@ function _loadModulePlugins() {
|
|
|
77
78
|
name: _name
|
|
78
79
|
} = manifest.plugins[_i];
|
|
79
80
|
if (module.status === 'fulfilled') {
|
|
80
|
-
|
|
81
|
+
var _module$value$default;
|
|
82
|
+
var moduleValue = isLegacyPlugin(module.value) ? module.value : // TypeScript builds CJS default exports differently depending on
|
|
83
|
+
// whether there are also named exports. If the default is the only
|
|
84
|
+
// export, it will be the value. If there are also named exports,
|
|
85
|
+
// it will be assigned to the `default` property on the value.
|
|
86
|
+
(_module$value$default = module.value.default) !== null && _module$value$default !== void 0 ? _module$value$default : module.value;
|
|
87
|
+
if (moduleValue == null) {
|
|
88
|
+
log.error("Plugin '".concat(_name, "' is missing an exported value."));
|
|
89
|
+
} else {
|
|
90
|
+
pluginMap.set(_name, moduleValue);
|
|
91
|
+
}
|
|
81
92
|
} else {
|
|
82
|
-
log.error("Unable to load plugin ".concat(_name), module.reason);
|
|
93
|
+
log.error("Unable to load plugin '".concat(_name, "'"), module.reason);
|
|
83
94
|
}
|
|
84
95
|
}
|
|
85
96
|
log.info('Plugins loaded:', pluginMap);
|
|
@@ -149,4 +160,32 @@ export function getAuthPluginComponent(pluginMap, authConfigValues) {
|
|
|
149
160
|
log.info('Using LoginPlugin', name);
|
|
150
161
|
return component;
|
|
151
162
|
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Extract theme data from theme plugins in the given plugin map.
|
|
166
|
+
* @param pluginMap
|
|
167
|
+
*/
|
|
168
|
+
export function getThemeDataFromPlugins(pluginMap) {
|
|
169
|
+
var themePluginEntries = [...pluginMap.entries()].filter(entry => isThemePlugin(entry[1]));
|
|
170
|
+
log.debug('Getting theme data from plugins', themePluginEntries);
|
|
171
|
+
return themePluginEntries.map(_ref5 => {
|
|
172
|
+
var [pluginName, plugin] = _ref5;
|
|
173
|
+
// Normalize to an array since config can be an array of configs or a
|
|
174
|
+
// single config
|
|
175
|
+
var configs = Array.isArray(plugin.themes) ? plugin.themes : [plugin.themes];
|
|
176
|
+
return configs.map(_ref6 => {
|
|
177
|
+
var {
|
|
178
|
+
name,
|
|
179
|
+
baseTheme,
|
|
180
|
+
styleContent
|
|
181
|
+
} = _ref6;
|
|
182
|
+
return {
|
|
183
|
+
baseThemeKey: "default-".concat(baseTheme !== null && baseTheme !== void 0 ? baseTheme : 'dark'),
|
|
184
|
+
themeKey: getThemeKey(pluginName, name),
|
|
185
|
+
name,
|
|
186
|
+
styleContent
|
|
187
|
+
};
|
|
188
|
+
});
|
|
189
|
+
}).flat();
|
|
190
|
+
}
|
|
152
191
|
//# sourceMappingURL=PluginUtils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PluginUtils.js","names":["Log","isAuthPlugin","PluginType","isLegacyAuthPlugin","isLegacyPlugin","loadRemoteModule","log","module","loadModulePlugin","pluginUrl","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","default","error","reason","info","e","getAuthHandlers","authConfigValues","get","split","getAuthPluginComponent","corePlugins","authHandlers","authPlugins","entries","filter","plugin","map","type","AUTH_PLUGIN","component","AuthPlugin","Component","isAvailable","availableAuthPlugins","warn","join"],"sources":["../../src/plugins/PluginUtils.tsx"],"sourcesContent":["import Log from '@deephaven/log';\nimport {\n type PluginModule,\n type AuthPlugin,\n type AuthPluginComponent,\n isAuthPlugin,\n LegacyAuthPlugin,\n LegacyPlugin,\n Plugin,\n PluginType,\n isLegacyAuthPlugin,\n isLegacyPlugin,\n} from '@deephaven/plugin';\nimport loadRemoteModule from './loadRemoteModule';\n\nconst log = Log.module('@deephaven/app-utils.PluginUtils');\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 * 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<LegacyPlugin | { default: Plugin }> {\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 based on the manifest file at the provided base URL\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<LegacyPlugin | { default: Plugin }>[] = [];\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(\n name,\n isLegacyPlugin(module.value) ? module.value : module.value.default\n );\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 = new Map<string, AuthPlugin | LegacyAuthPlugin>()\n): AuthPluginComponent {\n const authHandlers = getAuthHandlers(authConfigValues);\n // User plugins take priority over core plugins\n const authPlugins = (\n [...pluginMap.entries(), ...corePlugins.entries()].filter(\n ([, plugin]) => isAuthPlugin(plugin) || isLegacyAuthPlugin(plugin)\n ) as [string, AuthPlugin | LegacyAuthPlugin][]\n ).map(([name, plugin]) => {\n if (isLegacyAuthPlugin(plugin)) {\n return {\n type: PluginType.AUTH_PLUGIN,\n name,\n component: plugin.AuthPlugin.Component,\n isAvailable: plugin.AuthPlugin.isAvailable,\n };\n }\n\n return plugin;\n });\n\n // Filter the available auth plugins\n const availableAuthPlugins = authPlugins.filter(({ isAvailable }) =>\n 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 { name, component } = availableAuthPlugins[0];\n log.info('Using LoginPlugin', name);\n\n return component;\n}\n"],"mappings":";;AAAA,OAAOA,GAAG,MAAM,gBAAgB;AAChC,SAIEC,YAAY,EAIZC,UAAU,EACVC,kBAAkB,EAClBC,cAAc,QACT,mBAAmB;AAAC,OACpBC,gBAAgB;AAEvB,IAAMC,GAAG,GAAGN,GAAG,CAACO,MAAM,CAAC,kCAAkC,CAAC;AAY1D;AACA;AACA;AACA;AACA;AACA,gBAAsBC,gBAAgB;EAAA;AAAA;;AAOtC;AACA;AACA;AACA;AACA;AAJA;EAAA,sCAPO,WACLC,SAAiB,EAC4B;IAC7C,IAAMC,QAAQ,SAASL,gBAAgB,CAACI,SAAS,CA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AAI,CAAC,mBAAmB,EAAEf,IAAI,CAAC;EAEnC,OAAO+B,SAAS;AAClB"}
|
|
1
|
+
{"version":3,"file":"PluginUtils.js","names":["getThemeKey","Log","isAuthPlugin","PluginType","isLegacyAuthPlugin","isLegacyPlugin","isThemePlugin","loadRemoteModule","log","module","loadModulePlugin","pluginUrl","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","moduleValue","value","default","error","set","reason","info","e","getAuthHandlers","authConfigValues","get","split","getAuthPluginComponent","corePlugins","authHandlers","authPlugins","entries","filter","plugin","map","type","AUTH_PLUGIN","component","AuthPlugin","Component","isAvailable","availableAuthPlugins","warn","join","getThemeDataFromPlugins","themePluginEntries","entry","pluginName","configs","themes","baseTheme","styleContent","baseThemeKey","themeKey","flat"],"sources":["../../src/plugins/PluginUtils.tsx"],"sourcesContent":["import { getThemeKey, ThemeData } from '@deephaven/components';\nimport Log from '@deephaven/log';\nimport {\n type PluginModule,\n type AuthPlugin,\n type AuthPluginComponent,\n isAuthPlugin,\n LegacyAuthPlugin,\n LegacyPlugin,\n Plugin,\n PluginType,\n isLegacyAuthPlugin,\n isLegacyPlugin,\n isThemePlugin,\n ThemePlugin,\n} from '@deephaven/plugin';\nimport loadRemoteModule from './loadRemoteModule';\n\nconst log = Log.module('@deephaven/app-utils.PluginUtils');\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 * 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<LegacyPlugin | { default: Plugin }> {\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 based on the manifest file at the provided base URL\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<LegacyPlugin | { default: Plugin }>[] = [];\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\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 const moduleValue = isLegacyPlugin(module.value)\n ? module.value\n : // TypeScript builds CJS default exports differently depending on\n // whether there are also named exports. If the default is the only\n // export, it will be the value. If there are also named exports,\n // it will be assigned to the `default` property on the value.\n module.value.default ?? module.value;\n\n if (moduleValue == null) {\n log.error(`Plugin '${name}' is missing an exported value.`);\n } else {\n pluginMap.set(name, moduleValue);\n }\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 = new Map<string, AuthPlugin | LegacyAuthPlugin>()\n): AuthPluginComponent {\n const authHandlers = getAuthHandlers(authConfigValues);\n // User plugins take priority over core plugins\n const authPlugins = (\n [...pluginMap.entries(), ...corePlugins.entries()].filter(\n ([, plugin]) => isAuthPlugin(plugin) || isLegacyAuthPlugin(plugin)\n ) as [string, AuthPlugin | LegacyAuthPlugin][]\n ).map(([name, plugin]) => {\n if (isLegacyAuthPlugin(plugin)) {\n return {\n type: PluginType.AUTH_PLUGIN,\n name,\n component: plugin.AuthPlugin.Component,\n isAvailable: plugin.AuthPlugin.isAvailable,\n };\n }\n\n return plugin;\n });\n\n // Filter the available auth plugins\n const availableAuthPlugins = authPlugins.filter(({ isAvailable }) =>\n 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 { name, component } = availableAuthPlugins[0];\n log.info('Using LoginPlugin', name);\n\n return component;\n}\n\n/**\n * Extract theme data from theme plugins in the given plugin map.\n * @param pluginMap\n */\nexport function getThemeDataFromPlugins(\n pluginMap: PluginModuleMap\n): ThemeData[] {\n const themePluginEntries = [...pluginMap.entries()].filter(\n (entry): entry is [string, ThemePlugin] => isThemePlugin(entry[1])\n );\n\n log.debug('Getting theme data from plugins', themePluginEntries);\n\n return themePluginEntries\n .map(([pluginName, plugin]) => {\n // Normalize to an array since config can be an array of configs or a\n // single config\n const configs = Array.isArray(plugin.themes)\n ? plugin.themes\n : [plugin.themes];\n\n return configs.map(\n ({ name, baseTheme, styleContent }) =>\n ({\n baseThemeKey: `default-${baseTheme ?? 'dark'}`,\n themeKey: getThemeKey(pluginName, name),\n name,\n styleContent,\n }) as const\n );\n })\n .flat();\n}\n"],"mappings":";;AAAA,SAASA,WAAW,QAAmB,uBAAuB;AAC9D,OAAOC,GAAG,MAAM,gBAAgB;AAChC,SAIEC,YAAY,EAIZC,UAAU,EACVC,kBAAkB,EAClBC,cAAc,EACdC,aAAa,QAER,mBAAmB;AAAC,OACpBC,gBAAgB;AAEvB,IAAMC,GAAG,GAAGP,GAAG,CAACQ,MAAM,CAAC,kCAAkC,CAAC;AAY1D;AACA;AACA;AACA;AACA;AACA,gBAAsBC,gBAAgB;EAAA;AAAA;;AAOtC;AACA;AACA;AACA;AACA;AAJA;EAAA,sCAPO,WACLC,SAAiB,EAC4B;IAC7C,IAAMC,QAAQ,SAASL,gBAAgB,CAACI,SAAS,CAAC;IAClD,OAAOC,QAAQ;EACjB,CAAC;EAAA;AAAA;AAOD,gBAAsBC,QAAQ;EAAA;AAAA;;AAY9B;AACA;AACA;AACA;AACA;AAJA;EAAA,8BAZO,WAAwBC,OAAe,EAA2B;IACvE,IAAMC,GAAG,SAASC,KAAK,CAACF,OAAO,CAAC;IAChC,IAAI,CAACC,GAAG,CAACE,EAAE,EAAE;MACX,MAAM,IAAIC,KAAK,CAACH,GAAG,CAACI,UAAU,CAAC;IACjC;IACA,IAAI;MACF,aAAaJ,GAAG,CAACK,IAAI,EAAE;IACzB,CAAC,CAAC,gBAAM;MACN,MAAM,IAAIF,KAAK,CAAC,6BAA6B,CAAC;IAChD;EACF,CAAC;EAAA;AAAA;AAOD,gBAAsBG,iBAAiB;EAAA;AAAA;AAkDtC;EAAA,uCAlDM,WACLC,gB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G,CAACe,KAAK,CAAC,iCAAiC,EAAEgD,kBAAkB,CAAC;EAEhE,OAAOA,kBAAkB,CACtBX,GAAG,CAAC,SAA0B;IAAA,IAAzB,CAACa,UAAU,EAAEd,MAAM,CAAC;IACxB;IACA;IACA,IAAMe,OAAO,GAAGjD,KAAK,CAACC,OAAO,CAACiC,MAAM,CAACgB,MAAM,CAAC,GACxChB,MAAM,CAACgB,MAAM,GACb,CAAChB,MAAM,CAACgB,MAAM,CAAC;IAEnB,OAAOD,OAAO,CAACd,GAAG,CAChB;MAAA,IAAC;QAAE7B,IAAI;QAAE6C,SAAS;QAAEC;MAAa,CAAC;MAAA,OAC/B;QACCC,YAAY,oBAAaF,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,MAAM,CAAE;QAC9CG,QAAQ,EAAE/E,WAAW,CAACyE,UAAU,EAAE1C,IAAI,CAAC;QACvCA,IAAI;QACJ8C;MACF,CAAC;IAAA,CAAU,CACd;EACH,CAAC,CAAC,CACDG,IAAI,EAAE;AACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deephaven/app-utils",
|
|
3
|
-
"version": "0.49.2-beta.
|
|
3
|
+
"version": "0.49.2-beta.6+a9541b10",
|
|
4
4
|
"description": "Deephaven App Utils",
|
|
5
5
|
"author": "Deephaven Data Labs LLC",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"redux": "^4.x"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@deephaven/auth-plugins": "^0.49.2-beta.
|
|
32
|
-
"@deephaven/components": "^0.49.2-beta.
|
|
33
|
-
"@deephaven/jsapi-bootstrap": "^0.49.2-beta.
|
|
34
|
-
"@deephaven/jsapi-components": "^0.49.2-beta.
|
|
35
|
-
"@deephaven/jsapi-types": "^0.49.2-beta.
|
|
36
|
-
"@deephaven/jsapi-utils": "^0.49.2-beta.
|
|
37
|
-
"@deephaven/log": "^0.49.2-beta.
|
|
38
|
-
"@deephaven/plugin": "^0.49.2-beta.
|
|
39
|
-
"@deephaven/react-hooks": "^0.49.2-beta.
|
|
40
|
-
"@deephaven/redux": "^0.49.2-beta.
|
|
41
|
-
"@deephaven/utils": "^0.49.2-beta.
|
|
31
|
+
"@deephaven/auth-plugins": "^0.49.2-beta.6+a9541b10",
|
|
32
|
+
"@deephaven/components": "^0.49.2-beta.6+a9541b10",
|
|
33
|
+
"@deephaven/jsapi-bootstrap": "^0.49.2-beta.6+a9541b10",
|
|
34
|
+
"@deephaven/jsapi-components": "^0.49.2-beta.6+a9541b10",
|
|
35
|
+
"@deephaven/jsapi-types": "^0.49.2-beta.6+a9541b10",
|
|
36
|
+
"@deephaven/jsapi-utils": "^0.49.2-beta.6+a9541b10",
|
|
37
|
+
"@deephaven/log": "^0.49.2-beta.6+a9541b10",
|
|
38
|
+
"@deephaven/plugin": "^0.49.2-beta.6+a9541b10",
|
|
39
|
+
"@deephaven/react-hooks": "^0.49.2-beta.6+a9541b10",
|
|
40
|
+
"@deephaven/redux": "^0.49.2-beta.6+a9541b10",
|
|
41
|
+
"@deephaven/utils": "^0.49.2-beta.6+a9541b10",
|
|
42
42
|
"@paciolan/remote-component": "2.13.0",
|
|
43
43
|
"@paciolan/remote-module-loader": "^3.0.2",
|
|
44
44
|
"fira": "mozilla/fira#4.202"
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"publishConfig": {
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "a9541b108f1d998bb2713e70642f5a54aaf8bd97"
|
|
62
62
|
}
|