@finos/legend-studio
Version:
60 lines • 3.22 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
/**
* Copyright (c) 2020-present, Goldman Sachs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createRoot } from 'react-dom/client';
import { BrowserRouter } from 'react-router-dom';
import { configure as configureReactHotkeys } from 'react-hotkeys';
import { LegendStudioApplication } from '../components/LegendStudioApplication.js';
import { LegendStudioPluginManager } from './LegendStudioPluginManager.js';
import { ApplicationStoreProvider, LegendApplication, setupLegendApplicationUILibrary, WebApplicationNavigatorProvider, } from '@finos/legend-application';
import { CorePureGraphManagerPlugin } from '@finos/legend-graph';
import { getRootElement } from '@finos/legend-art';
import { LegendStudioApplicationConfig, } from './LegendStudioApplicationConfig.js';
import { Core_LegendStudioApplicationPlugin } from '../components/Core_LegendStudioApplicationPlugin.js';
const setupLegendStudioUILibrary = async (pluginManager, logger) => {
await setupLegendApplicationUILibrary(pluginManager, logger);
configureReactHotkeys({
// By default, `react-hotkeys` will avoid capturing keys from input tags like <input>, <textarea>, <select>
// We want to listen to hotkey from every where in the app so we disable that
// See https://github.com/greena13/react-hotkeys#ignoring-events
ignoreTags: [],
});
};
export class LegendStudio extends LegendApplication {
static create() {
const application = new LegendStudio(LegendStudioPluginManager.create());
application.withBasePlugins([
new CorePureGraphManagerPlugin(),
new Core_LegendStudioApplicationPlugin(),
]);
return application;
}
async configureApplication(input) {
return new LegendStudioApplicationConfig(input);
}
async loadApplication() {
// Setup React application libraries
await setupLegendStudioUILibrary(this.pluginManager, this.logger);
// Render React application
const rootElement = createRoot(getRootElement());
rootElement.render(
// TODO: would be great if we can have <React.StrictMode> here but since Mobx React is not ready for
// concurrency yet, we would have to wait
// See https://github.com/mobxjs/mobx/issues/2526
_jsx(BrowserRouter, { basename: this.baseUrl, children: _jsx(WebApplicationNavigatorProvider, { children: _jsx(ApplicationStoreProvider, { config: this.config, pluginManager: this.pluginManager, children: _jsx(LegendStudioApplication, { config: this.config, pluginManager: this.pluginManager }) }) }) }));
}
}
//# sourceMappingURL=LegendStudio.js.map