import MapPosition from './mapposition.js'; import GlobeState from './globe.js'; import type Basemap from '../../models/basemaps/basemap.js'; import type ThemeLayer from '../../models/layers/themelayer.js'; import type OlGeomLineString from 'ol/geom/LineString.js'; import type ServerOgc from '../../models/serverogc.js'; import LayersConfig from './layersConfig.js'; import type { TokenEndpointResponse } from 'oauth4webapi'; import type { GgUserInteractionListener } from './userInteractionManager.js'; import type CustomTheme from '../../models/customtheme.js'; import ObjectSelection from './objectselection.js'; import type Theme from '../../models/theme.js'; import GraphicalInterface from './graphicalInterface.js'; import { GMFThemeFunctionalities, GMFThemeFunctionality } from '../../models/gmf.js'; export type ThemesConfig = { _allThemes: Record; _allFunctionalities: Record; isLoaded: boolean; lastSelectedTheme: ThemeLayer | CustomTheme | null; }; type TreeviewConfig = { renderEnabled: boolean; }; type PrintConfig = { maskVisible: boolean; pageSize: [number, number] | null; format: string | null; scale: number | null; dpi: number | null; }; export type InfoBoxContent = { id: string; text: string; type: 'info' | 'warning' | 'error'; duration?: number; }; export type Lidar = { line: OlGeomLineString | null; drawActive: boolean; }; export type News = { urls: string[] | null; lastViewDate: number; lastPublishDate: number; }; type Functionalities = { authorized_plugins?: string[]; }; type UserInfo = { username: string; display_name: string; email: string; family_name: string; given_name: string; is_intranet: boolean; two_factor_enable: boolean; roles: unknown[]; functionalities?: Functionalities; }; /** * Login states : * 1. issuer.loggedIn : Logged in to identity provider * 2. loggedIn : Fully logged in (to both identity provider and backend) * 3. loginFailed : Login failed * 4. backend.loggedOut : Logout from backend * 5. loggedOut : Fully Logged out (from both identity provider and backend) * 5. logoutFailed : Logout failed */ type LoginState = { status: 'not-initialized' | 'issuer.loggedIn' | 'loggedIn' | 'loginFailed' | 'backend.loggedOut' | 'loggedOut' | 'logoutFailed'; tokens?: TokenEndpointResponse; userInfo?: UserInfo; audience: string[]; error?: string; somethingChanged: boolean; }; export type InfoWindow = { title: string | null; url: string | null; width: string | number | null; height: string | number | null; top: string | number | null; left: string | number | null; }; export type ExtendedState = Record; export default class State { /** * This class is a used as the state of the application, which will be accessed behind a javascript proxy. * This means that each modification made to its properties must come from outside, * because they have to be made through the proxy, so that the modification can be listen. * Therefore, this class must not contain any method which is updating a value directly * For example, any method doing is forbidden here, because the modification be known from the proxy */ themes: ThemesConfig; functionalities: Record; basemaps: Record; ogcServers: Record; activeBasemaps: Basemap[]; projection: string; mouseCoordinates: number[]; interface: GraphicalInterface; userInteractionListeners: GgUserInteractionListener[]; language: string | null; lidar: Lidar; news: News; loading: boolean; application: { isConfigurationLoaded: boolean; isAuthInitialized: boolean; isStateInitialized: boolean; isCustomSerializerInitialized: boolean; isReadyToLoadThemes: boolean; isReady: boolean; }; position: MapPosition; layers: LayersConfig; treeview: TreeviewConfig; print: PrintConfig; globe: GlobeState; theme: Theme | null; selection: ObjectSelection; infobox: { elements: InfoBoxContent[]; }; infoWindow: InfoWindow; isOffline: boolean; oauth: LoginState; extendedState: ExtendedState; } export {};