diff --git a/src/components/App.tsx b/src/components/App.tsx index f0bc2d16..726e2092 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -29,7 +29,6 @@ import { ModalOpen } from "./modals/ModalOpen"; import { ModalShortcuts } from "./modals/ModalShortcuts"; import { ModalDebug } from "./modals/ModalDebug"; import { ModalGlobalState } from "./modals/ModalGlobalState"; -import { ModalAgentWorkspace } from "./modals/ModalAgentWorkspace"; import {downloadGlyphsMetadata, downloadSpriteMetadata} from "../libs/metadata"; import { emptyStyle, replaceAccessTokenInUrl, replaceAccessTokens } from "../libs/style"; @@ -44,6 +43,26 @@ import { type MappedError, type OnStyleChangedOpts, type StyleSpecificationWithI import { DatasetStore } from "../libs/dataset-store"; import type { MapOpenLayers } from "./MapOpenLayers"; +// Keep the agent workspace out of the initial bundle, while still loading it +// by default because the lazy component is rendered with the other modals. +const LazyModalAgentWorkspace = React.lazy(() => + import("./modals/ModalAgentWorkspace").then(({ModalAgentWorkspace}) => ({ + default: ModalAgentWorkspace, + })) +); + +const AgentWorkspaceLoading = () =>
+ + {i18next.t("Loading")} +
; + // Buffer must be defined globally for @maplibre/maplibre-gl-style-spec validate() function to succeed. window.Buffer = buffer.Buffer; @@ -1036,16 +1055,18 @@ export class App extends React.Component { isOpen={this.state.isOpen.globalState} onOpenToggle={() => this.toggleModal("globalState")} /> - this.toggleModal("agentConsole")} - getMap={this.getAgentMap} - getMaputnikStyle={this.getAgentMaputnikStyle} - updateMaputnikStyle={this.updateAgentMaputnikStyle} - datasetStore={this.datasetStore} - onDatasetsChange={this.onDatasetsChange} - renderer={this._getRenderer()} - /> + : null}> + this.toggleModal("agentConsole")} + getMap={this.getAgentMap} + getMaputnikStyle={this.getAgentMaputnikStyle} + updateMaputnikStyle={this.updateAgentMaputnikStyle} + datasetStore={this.datasetStore} + onDatasetsChange={this.onDatasetsChange} + renderer={this._getRenderer()} + /> + ; return