-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathindex.tsx
72 lines (64 loc) · 2.1 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React, { Suspense } from 'react';
import ReactDOM from 'react-dom';
import '@deephaven/components/scss/BaseStyleSheet.scss'; // Do NOT move any lower. This needs to be imported before any other styles
import { LoadingOverlay, preloadTheme } from '@deephaven/components';
import { ApiBootstrap } from '@deephaven/jsapi-bootstrap';
import { logInit } from '@deephaven/log';
import './index.scss';
logInit(
parseInt(import.meta.env.VITE_LOG_LEVEL ?? '2', 10),
import.meta.env.VITE_ENABLE_LOG_PROXY === 'true'
);
preloadTheme();
// Lazy load components for code splitting and also to avoid importing the jsapi-shim before API is bootstrapped.
// eslint-disable-next-line react-refresh/only-export-components
const App = React.lazy(() => import('./App'));
// eslint-disable-next-line react-refresh/only-export-components
const AppBootstrap = React.lazy(async () => {
const module = await import('@deephaven/app-utils');
return { default: module.AppBootstrap };
});
const apiURL = new URL(
`${import.meta.env.VITE_CORE_API_URL}/${import.meta.env.VITE_CORE_API_NAME}`,
document.baseURI
);
const pluginsURL = new URL(
import.meta.env.VITE_MODULE_PLUGINS_URL,
document.baseURI
);
const logMetadata: Record<string, unknown> = {
uiVersion: import.meta.env.npm_package_version,
};
// Lazy load the configs because it breaks initial page loads otherwise
async function getCorePlugins() {
const dashboardCorePlugins = await import(
'@deephaven/dashboard-core-plugins'
);
const {
GridPluginConfig,
PandasPluginConfig,
ChartPluginConfig,
WidgetLoaderPluginConfig,
} = dashboardCorePlugins;
return [
GridPluginConfig,
PandasPluginConfig,
ChartPluginConfig,
WidgetLoaderPluginConfig,
];
}
ReactDOM.render(
<ApiBootstrap apiUrl={apiURL.href} setGlobally>
<Suspense fallback={<LoadingOverlay />}>
<AppBootstrap
getCorePlugins={getCorePlugins}
serverUrl={apiURL.origin}
pluginsUrl={pluginsURL.href}
logMetadata={logMetadata}
>
<App />
</AppBootstrap>
</Suspense>
</ApiBootstrap>,
document.getElementById('root')
);