@geogirafe/lib-geoportal 1.2.0-dev.2873796427 → 1.2.0-dev.2889263072

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.
Files changed (94) hide show
  1. package/api/apicontext.d.ts +12 -1
  2. package/api/apicontext.js +19 -111
  3. package/api/apisessionmanager.d.ts +1 -1
  4. package/api/apisessionmanager.js +1 -1
  5. package/base/GirafeSingleton.d.ts +1 -1
  6. package/base/GirafeSingleton.js +1 -1
  7. package/components/navigation/component.d.ts +2 -2
  8. package/components/navigation/component.js +6 -6
  9. package/components/news/news-button/component.d.ts +0 -1
  10. package/components/news/news-button/component.js +0 -6
  11. package/components/news/news-panel/component.d.ts +2 -2
  12. package/components/news/news-panel/component.js +5 -5
  13. package/components/themes/component.d.ts +1 -1
  14. package/components/themes/component.js +4 -4
  15. package/components/userpreferences/component.d.ts +1 -1
  16. package/components/userpreferences/component.js +7 -7
  17. package/package.json +1 -1
  18. package/templates/public/about.json +1 -1
  19. package/tools/app/lifecyclemanager.d.ts +1 -1
  20. package/tools/app/lifecyclemanager.js +1 -1
  21. package/tools/auth/abstractconnectmanager.js +2 -2
  22. package/tools/auth/authmanager.d.ts +1 -1
  23. package/tools/auth/authmanager.js +1 -1
  24. package/tools/auth/pluginmanager.d.ts +1 -1
  25. package/tools/auth/pluginmanager.js +1 -1
  26. package/tools/configuration/configmanager.d.ts +3 -2
  27. package/tools/configuration/configmanager.js +9 -5
  28. package/tools/configuration/girafeconfig.d.ts +6 -5
  29. package/tools/configuration/girafeconfig.js +3 -0
  30. package/tools/context/context.d.ts +1 -0
  31. package/tools/context/context.js +4 -112
  32. package/tools/context/contexthelper.d.ts +6 -0
  33. package/tools/context/contexthelper.js +102 -0
  34. package/tools/error/errormanager.d.ts +1 -1
  35. package/tools/error/errormanager.js +1 -1
  36. package/tools/feedback/feedbackmanager.d.ts +1 -2
  37. package/tools/feedback/feedbackmanager.js +6 -8
  38. package/tools/i18n/i18nmanager.d.ts +1 -1
  39. package/tools/i18n/i18nmanager.js +22 -20
  40. package/tools/layers/layermanager.d.ts +1 -1
  41. package/tools/layers/layermanager.js +1 -1
  42. package/tools/layers/snapmanager.d.ts +1 -1
  43. package/tools/layers/snapmanager.js +1 -1
  44. package/tools/localfile/localfilemanager.d.ts +1 -1
  45. package/tools/localfile/localfilemanager.js +1 -1
  46. package/tools/logging/defaultconsole.d.ts +8 -0
  47. package/tools/logging/defaultconsole.js +9 -0
  48. package/tools/logging/logmanager.d.ts +1 -7
  49. package/tools/logging/logmanager.js +8 -13
  50. package/tools/main.d.ts +3 -1
  51. package/tools/main.js +2 -0
  52. package/tools/offline/offlinemanager.d.ts +3 -3
  53. package/tools/offline/offlinemanager.js +6 -6
  54. package/tools/ogcapi/ogcapifeaturesmanager.d.ts +1 -1
  55. package/tools/ogcapi/ogcapifeaturesmanager.js +1 -1
  56. package/tools/onboarding/onboardingmanager.js +4 -4
  57. package/tools/ordering/orderingmanager.d.ts +1 -1
  58. package/tools/ordering/orderingmanager.js +1 -1
  59. package/tools/search/abstractsearchclient.d.ts +1 -1
  60. package/tools/search/abstractsearchclient.js +2 -2
  61. package/tools/search/searchmanager.d.ts +1 -1
  62. package/tools/search/searchmanager.js +2 -2
  63. package/tools/selection/selectionmanager.d.ts +1 -1
  64. package/tools/selection/selectionmanager.js +1 -1
  65. package/tools/share/sessionmanager.d.ts +1 -1
  66. package/tools/share/sessionmanager.js +1 -1
  67. package/tools/share/sharemanager.d.ts +1 -1
  68. package/tools/share/sharemanager.js +1 -1
  69. package/tools/share/stateserializer.d.ts +1 -1
  70. package/tools/share/stateserializer.js +1 -1
  71. package/tools/state/statemanager.d.ts +1 -1
  72. package/tools/state/statemanager.js +1 -1
  73. package/tools/tests/mockconfig.d.ts +2 -3
  74. package/tools/tests/mockconfig.js +0 -1
  75. package/tools/tests/mockcontext.d.ts +13 -1
  76. package/tools/tests/mockcontext.js +27 -112
  77. package/tools/tests/mockhelper.d.ts +2 -2
  78. package/tools/tests/mockhelper.js +4 -5
  79. package/tools/themes/customthemesmanager.d.ts +3 -3
  80. package/tools/themes/customthemesmanager.js +9 -9
  81. package/tools/themes/themefavoritesmanager.d.ts +5 -5
  82. package/tools/themes/themefavoritesmanager.js +16 -16
  83. package/tools/themes/themeshelper.d.ts +1 -1
  84. package/tools/themes/themeshelper.js +1 -1
  85. package/tools/themes/themesmanager.d.ts +1 -1
  86. package/tools/themes/themesmanager.js +2 -2
  87. package/tools/url/permalinkmanager.d.ts +1 -1
  88. package/tools/url/permalinkmanager.js +1 -1
  89. package/tools/userdata/userdatamanager.d.ts +18 -39
  90. package/tools/userdata/userdatamanager.js +111 -75
  91. package/tools/wfs/wfsmanager.d.ts +1 -1
  92. package/tools/wfs/wfsmanager.js +1 -1
  93. package/tools/wms/wmsmanager.d.ts +1 -1
  94. package/tools/wms/wmsmanager.js +1 -1
@@ -13,7 +13,7 @@ import { OgcApiClientOptions } from './ogcapiclient.js';
13
13
  export default class OgcApiFeaturesManager extends VendorSpecificOgcServerManager<OgcApiFeaturesClient, OgcApiClientOptions> {
14
14
  protected get state(): import("../main.js").State;
15
15
  getClientId(ogcServer: ServerOgc): string;
16
- initializeSingleton(): void;
16
+ initializeSingleton(): Promise<void>;
17
17
  getSchema(layer: OapifLayer): Promise<OgcApiFeaturesSchema>;
18
18
  getItems(layer: OapifLayer, crs?: string, bbox?: number[], limit?: number): Promise<Feature<Geometry>[]>;
19
19
  getItem(layer: OapifLayer, featureId: string): Promise<Feature<Geometry> | undefined>;
@@ -14,7 +14,7 @@ export default class OgcApiFeaturesManager extends VendorSpecificOgcServerManage
14
14
  getClientId(ogcServer) {
15
15
  return ogcServer.urlOapif ?? '';
16
16
  }
17
- initializeSingleton() {
17
+ async initializeSingleton() {
18
18
  // Register the clients
19
19
  this.registerClientClass('default', OgcApiFeaturesClient);
20
20
  this.registerClientClass('georama', OgcApiFeaturesClientGeorama);
@@ -8,7 +8,7 @@ export default class OnBoardingManager extends GirafeSingleton {
8
8
  }
9
9
  STORAGE_PATH = 'onboardingTourAlreadyDone';
10
10
  async restart() {
11
- this.context.userDataManager.saveUserData(this.STORAGE_PATH, 'false');
11
+ await this.context.userDataManager.saveUserData(this.STORAGE_PATH, 'false');
12
12
  return this.start();
13
13
  }
14
14
  async start() {
@@ -17,13 +17,13 @@ export default class OnBoardingManager extends GirafeSingleton {
17
17
  return;
18
18
  }
19
19
  await this.context.i18nManager.ensureTranslationLoaded();
20
- const tourAlreadyDone = this.context.userDataManager.getUserData(this.STORAGE_PATH) || 'false';
20
+ const tourAlreadyDone = (await this.context.userDataManager.getUserData(this.STORAGE_PATH)) || 'false';
21
21
  if (tourAlreadyDone !== 'true') {
22
22
  const onboardingDriver = driver({
23
23
  popoverClass: 'girafe-onboarding-theme',
24
24
  showProgress: true,
25
- onDestroyed: (_element, _step, _options) => {
26
- this.context.userDataManager.saveUserData(this.STORAGE_PATH, 'true');
25
+ onDestroyed: async (_element, _step, _options) => {
26
+ await this.context.userDataManager.saveUserData(this.STORAGE_PATH, 'true');
27
27
  },
28
28
  nextBtnText: this.context.i18nManager.getTranslation('onboarding-next-button-text'),
29
29
  prevBtnText: this.context.i18nManager.getTranslation('onboarding-previous-button-text'),
@@ -4,7 +4,7 @@ export default class OrderingManager extends GirafeSingleton {
4
4
  private timeoutId?;
5
5
  private isReordering;
6
6
  private get state();
7
- initializeSingleton(): void;
7
+ initializeSingleton(): Promise<void>;
8
8
  private registerEvents;
9
9
  private onLayerListChanged;
10
10
  /**
@@ -9,7 +9,7 @@ export default class OrderingManager extends GirafeSingleton {
9
9
  get state() {
10
10
  return this.context.stateManager.state;
11
11
  }
12
- initializeSingleton() {
12
+ async initializeSingleton() {
13
13
  this.registerEvents();
14
14
  }
15
15
  registerEvents() {
@@ -26,7 +26,7 @@ declare abstract class AbstractSearchClient extends GirafeSingleton {
26
26
  [x: string]: any;
27
27
  }>>;
28
28
  protected constructor(context: IGirafeContext, config: BaseSearchClientConfig);
29
- initializeSingleton(): void;
29
+ initializeSingleton(): Promise<void>;
30
30
  protected get mapProjection(): import("ol/proj.js").Projection;
31
31
  /**
32
32
  * Sanitize the url by removing placeholders that are wrongfully interpreted as URL fragments by the URL parser.
@@ -25,8 +25,8 @@ class AbstractSearchClient extends GirafeSingleton {
25
25
  this.url = this.sanitizeUrl(config.url);
26
26
  this.resultSrid = config.resultSrid;
27
27
  }
28
- initializeSingleton() {
29
- super.initializeSingleton();
28
+ async initializeSingleton() {
29
+ await super.initializeSingleton();
30
30
  }
31
31
  get mapProjection() {
32
32
  return this.context.mapManager.getMap().getView().getProjection();
@@ -18,7 +18,7 @@ declare class SearchManager extends GirafeSingleton {
18
18
  private defaultMaxExtent?;
19
19
  readonly minSearchTermLength = 3;
20
20
  constructor(context: IGirafeContext);
21
- initializeSingleton(): void;
21
+ initializeSingleton(): Promise<void>;
22
22
  protected createClient(providerConfig: SearchProviderConfig): void;
23
23
  /**
24
24
  * Returns available search categories per provider.
@@ -16,8 +16,8 @@ class SearchManager extends GirafeSingleton {
16
16
  constructor(context) {
17
17
  super(context);
18
18
  }
19
- initializeSingleton() {
20
- super.initializeSingleton();
19
+ async initializeSingleton() {
20
+ await super.initializeSingleton();
21
21
  for (const providerConfig of this.context.configManager.Config.search?.providers ?? []) {
22
22
  this.createClient(providerConfig);
23
23
  }
@@ -8,7 +8,7 @@ import GirafeSingleton from '../../base/GirafeSingleton.js';
8
8
  */
9
9
  export default class SelectionManager extends GirafeSingleton {
10
10
  private get state();
11
- initializeSingleton(): void;
11
+ initializeSingleton(): Promise<void>;
12
12
  /**
13
13
  * Selects all the features of the queryable layers that are inside the given extent.
14
14
  * Layers selectable today are WMS, WMTS (with wms layer) and Local files.
@@ -13,7 +13,7 @@ export default class SelectionManager extends GirafeSingleton {
13
13
  get state() {
14
14
  return this.context.stateManager.state;
15
15
  }
16
- initializeSingleton() {
16
+ async initializeSingleton() {
17
17
  this.context.stateManager.subscribe('selection.selectionParameters', (_, newParams) => {
18
18
  // The querying is asynchronous and nobody awaits it here,
19
19
  // so a failing request must not end up in an unhandled rejection.
@@ -2,7 +2,7 @@ import GirafeSingleton from '../../base/GirafeSingleton.js';
2
2
  import ISessionManager from './isessionmanager.js';
3
3
  declare class SessionManager extends GirafeSingleton implements ISessionManager {
4
4
  private readonly sessionHash;
5
- initializeSingleton(): void;
5
+ initializeSingleton(): Promise<void>;
6
6
  beginSession(): void;
7
7
  saveStateToSession(): void;
8
8
  hasState(): boolean;
@@ -2,7 +2,7 @@
2
2
  import GirafeSingleton from '../../base/GirafeSingleton.js';
3
3
  class SessionManager extends GirafeSingleton {
4
4
  sessionHash = 'session';
5
- initializeSingleton() {
5
+ async initializeSingleton() {
6
6
  window.addEventListener('pagehide', () => this.saveStateToSession());
7
7
  }
8
8
  beginSession() {
@@ -3,7 +3,7 @@ import { IUrlShortener } from './iurlshortener.js';
3
3
  declare class ShareManager extends GirafeSingleton {
4
4
  private urlShortener?;
5
5
  get UrlShortener(): IUrlShortener | undefined;
6
- initializeSingleton(): void;
6
+ initializeSingleton(): Promise<void>;
7
7
  getStateToShare(): string;
8
8
  hasSharedState(): boolean;
9
9
  private getStateFromUrl;
@@ -7,7 +7,7 @@ class ShareManager extends GirafeSingleton {
7
7
  get UrlShortener() {
8
8
  return this.urlShortener;
9
9
  }
10
- initializeSingleton() {
10
+ async initializeSingleton() {
11
11
  const share = this.context.configManager.Config.share;
12
12
  if (share) {
13
13
  switch (share.service) {
@@ -2,7 +2,7 @@ import GirafeSingleton from '../../base/GirafeSingleton.js';
2
2
  import { Constructor, IBrainSerializer } from '../state/brain/serialize.js';
3
3
  declare class StateSerializer extends GirafeSingleton {
4
4
  private readonly brainSerializer;
5
- initializeSingleton(): void;
5
+ initializeSingleton(): Promise<void>;
6
6
  addSerializer(type: Constructor<object>, serializerData: IBrainSerializer<object>): void;
7
7
  getSerializedState(): string;
8
8
  deserializeAndSetState(compressedState: string): boolean;
@@ -17,7 +17,7 @@ import LayoutState from '../state/layout.js';
17
17
  import LayoutSerializer from './serializers/layoutserializer.js';
18
18
  class StateSerializer extends GirafeSingleton {
19
19
  brainSerializer = new BrainSerializer();
20
- initializeSingleton() {
20
+ async initializeSingleton() {
21
21
  this.addSerializer((Array), new ActiveBasemapsSerializer(this.context));
22
22
  this.addSerializer(MapPosition, new MapPositionSerializer(this.context));
23
23
  this.addSerializer(LayersConfig, new LayersConfigSerializer(this.context));
@@ -8,7 +8,7 @@ declare class StateManager extends GirafeSingleton {
8
8
  get state(): State;
9
9
  private readonly callbacks;
10
10
  constructor(context: IGirafeContext);
11
- initializeSingleton(): void;
11
+ initializeSingleton(): Promise<void>;
12
12
  private setDefaultValues;
13
13
  private setDefaultLayout;
14
14
  /**
@@ -18,7 +18,7 @@ class StateManager extends GirafeSingleton {
18
18
  this.onChange(path, oldValue, newValue, parents);
19
19
  });
20
20
  }
21
- initializeSingleton() {
21
+ async initializeSingleton() {
22
22
  this.setDefaultValues();
23
23
  }
24
24
  setDefaultValues() {
@@ -1,3 +1,4 @@
1
+ import { UserDataConfig } from '../configuration/girafeconfig';
1
2
  export declare const MockConfig: {
2
3
  general: {
3
4
  locale: string;
@@ -58,9 +59,7 @@ export declare const MockConfig: {
58
59
  lidar: {
59
60
  url: string;
60
61
  };
61
- userdata: {
62
- source: string;
63
- };
62
+ userdata: UserDataConfig;
64
63
  crs: {
65
64
  code: string;
66
65
  definition: string;
@@ -1,4 +1,3 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
1
  export const MockConfig = {
3
2
  general: {
4
3
  locale: 'en-US',
@@ -46,8 +46,8 @@ export default class MockGirafeContext implements IGirafeContext {
46
46
  readonly themesManager: ThemesManager;
47
47
  readonly themesHelper: ThemesHelper;
48
48
  readonly permalinkManager: PermalinkManager;
49
- readonly urlManager: UrlManager;
50
49
  readonly dragManager: DragManager;
50
+ readonly urlManager: UrlManager;
51
51
  readonly layerManager: LayerManager;
52
52
  readonly sessionManager: SessionManager;
53
53
  readonly stateSerializer: StateSerializer;
@@ -72,6 +72,18 @@ export default class MockGirafeContext implements IGirafeContext {
72
72
  readonly themeFavoritesManager: ThemeFavoritesManager;
73
73
  readonly searchManager: SearchManager;
74
74
  readonly feedbackManager: FeedbackManager;
75
+ private readonly contextHelper;
75
76
  constructor();
76
77
  initialize(): Promise<void>;
78
+ /** The context can contains hook methods that will be called after each manager initialization.
79
+ * The hook method must be named with the property name + the "Hook" suffix.
80
+ * The hook method must be async and will be awaited
81
+ * For example, the methods themesManagerHook() will be called immediately after
82
+ * the call of themesManager.initializeSingleton().
83
+ * This allows specific initialization methods when defining custom contexts
84
+ * (for example for the apiContext, the mockContext, or any customContext)
85
+ */
86
+ protected userDataManagerHook(): Promise<void>;
87
+ protected configManagerHook(): Promise<void>;
88
+ protected i18nManagerHook(): Promise<void>;
77
89
  }
@@ -1,42 +1,6 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- import ApplicationLifeCycleManager from '../app/lifecyclemanager';
3
- import AuthManager from '../auth/authmanager';
4
- import DragManager from '../../components/treeview/tools/dragmanager';
5
- import PluginManager from '../auth/pluginmanager';
6
- import ConfigManager from '../configuration/configmanager';
7
1
  import GirafeConfig from '../configuration/girafeconfig';
8
- import ErrorManager from '../error/errormanager';
9
- import I18nManager from '../i18n/i18nmanager';
10
- import LayerManager from '../layers/layermanager';
11
- import SnapManager from '../layers/snapmanager';
12
- import LocalFileManager from '../localfile/localfilemanager';
13
- import LogManager from '../logging/logmanager';
14
- import OfflineManager from '../offline/offlinemanager';
15
- import OgcApiFeaturesManager from '../ogcapi/ogcapifeaturesmanager';
16
- import OrderingManager from '../ordering/orderingmanager';
17
- import SessionManager from '../share/sessionmanager';
18
- import ShareManager from '../share/sharemanager';
19
- import StateSerializer from '../share/stateserializer';
20
- import ComponentManager from '../state/componentManager';
21
- import MapManager from '../state/mapManager';
22
- import StateManager from '../state/statemanager';
23
- import UserInteractionManager from '../state/userInteractionManager';
24
- import CustomThemesManager from '../themes/customthemesmanager';
25
- import ThemesHelper from '../themes/themeshelper';
26
- import ThemesManager from '../themes/themesmanager';
27
- import UserLayerManager from '../themes/userlayermanager';
28
- import PermalinkManager from '../url/permalinkmanager';
29
- import UrlManager from '../url/urlmanager';
30
- import UserDataManager from '../userdata/userdatamanager';
31
- import WfsManager from '../wfs/wfsmanager';
32
- import WmsManager from '../wms/wmsmanager';
33
- import WmtsManager from '../wmts/wmtsmanager';
34
- import SelectionManager from '../selection/selectionmanager';
35
2
  import { MockConfig } from './mockconfig';
36
- import OnBoardingManager from '../onboarding/onboardingmanager';
37
- import ThemeFavoritesManager from '../themes/themefavoritesmanager';
38
- import SearchManager from '../search/searchmanager';
39
- import FeedbackManager from '../feedback/feedbackmanager';
3
+ import ContextInitializationHelper from '../context/contexthelper';
40
4
  export default class MockGirafeContext {
41
5
  userDataManager;
42
6
  configManager;
@@ -48,8 +12,8 @@ export default class MockGirafeContext {
48
12
  themesManager;
49
13
  themesHelper;
50
14
  permalinkManager;
51
- urlManager;
52
15
  dragManager;
16
+ urlManager;
53
17
  layerManager;
54
18
  sessionManager;
55
19
  stateSerializer;
@@ -74,88 +38,39 @@ export default class MockGirafeContext {
74
38
  themeFavoritesManager;
75
39
  searchManager;
76
40
  feedbackManager;
41
+ contextHelper = new ContextInitializationHelper();
77
42
  constructor() {
78
- this.componentManager = new ComponentManager(this);
79
- this.userDataManager = new UserDataManager(this);
80
- this.configManager = new ConfigManager(this);
81
- this.logManager = new LogManager(this);
82
- this.stateManager = new StateManager(this);
83
- this.orderingManager = new OrderingManager(this);
84
- this.applicationLifeCycleManager = new ApplicationLifeCycleManager(this);
85
- this.mapManager = new MapManager(this);
86
- this.offlineManager = new OfflineManager(this);
87
- this.snapManager = new SnapManager(this);
88
- this.authManager = new AuthManager(this);
89
- this.pluginManager = new PluginManager(this);
90
- this.i18nManager = new I18nManager(this);
91
- this.userInteractionManager = new UserInteractionManager(this);
92
- this.dragManager = new DragManager(this);
93
- this.urlManager = new UrlManager(this);
94
- this.permalinkManager = new PermalinkManager(this);
95
- this.layerManager = new LayerManager(this);
96
- this.userLayerManager = new UserLayerManager(this);
97
- this.themesHelper = new ThemesHelper(this);
98
- this.stateSerializer = new StateSerializer(this);
99
- this.sessionManager = new SessionManager(this);
100
- this.shareManager = new ShareManager(this);
101
- this.wfsManager = new WfsManager(this);
102
- this.errorManager = new ErrorManager(this);
103
- this.customThemesManager = new CustomThemesManager(this);
104
- this.themesManager = new ThemesManager(this);
105
- this.wmsManager = new WmsManager(this);
106
- this.wmtsManager = new WmtsManager(this);
107
- this.selectionManager = new SelectionManager(this);
108
- this.localFileManager = new LocalFileManager(this);
109
- this.ogcApiFeaturesManager = new OgcApiFeaturesManager(this);
110
- this.onBoardingManager = new OnBoardingManager(this);
111
- this.themeFavoritesManager = new ThemeFavoritesManager(this);
112
- this.searchManager = new SearchManager(this);
113
- this.feedbackManager = new FeedbackManager(this);
43
+ this.contextHelper.constructContext(this);
114
44
  }
115
45
  async initialize() {
116
- // NOTE: This initialization order is important, because some singleton will need other ones!
117
- this.componentManager.initializeSingleton();
118
- this.userDataManager.initializeSingleton();
119
- this.userDataManager.setSource(MockConfig.userdata.source);
120
- this.userDataManager.deleteAllUserData();
46
+ await this.contextHelper.initializeContext(this);
47
+ }
48
+ /** The context can contains hook methods that will be called after each manager initialization.
49
+ * The hook method must be named with the property name + the "Hook" suffix.
50
+ * The hook method must be async and will be awaited
51
+ * For example, the methods themesManagerHook() will be called immediately after
52
+ * the call of themesManager.initializeSingleton().
53
+ * This allows specific initialization methods when defining custom contexts
54
+ * (for example for the apiContext, the mockContext, or any customContext)
55
+ */
56
+ async userDataManagerHook() {
57
+ await this.userDataManager.initializeSingleton();
58
+ this.userDataManager.initializeFromConfig(MockConfig.userdata);
59
+ await this.userDataManager.deleteAllUserData();
60
+ }
61
+ async configManagerHook() {
62
+ // Do not call the initializeSingleton methode
63
+ // But set hardcoded mock config
121
64
  // @ts-ignore
122
65
  this.configManager['config'] = new GirafeConfig(MockConfig);
123
66
  // @ts-ignore
124
67
  this.configManager['defaultConfig'] = new GirafeConfig(MockConfig);
125
- this.logManager.initializeSingleton();
126
- this.stateManager.initializeSingleton();
127
- this.orderingManager.initializeSingleton();
128
- this.applicationLifeCycleManager.initializeSingleton();
129
- this.mapManager.initializeSingleton();
130
- this.offlineManager.initializeSingleton();
131
- this.snapManager.initializeSingleton();
132
- this.authManager.initializeSingleton();
133
- this.pluginManager.initializeSingleton();
134
- this.i18nManager.initializeSingleton();
68
+ }
69
+ async i18nManagerHook() {
70
+ // Do not load translation files
71
+ // Bu set hardcoded mock translations
72
+ await this.i18nManager.initializeSingleton();
135
73
  // @ts-expect-error: private property
136
74
  this.i18nManager.translations = { fr: { a: 'translated_a', b: 'translated_b' } };
137
- this.userInteractionManager.initializeSingleton();
138
- this.dragManager.initializeSingleton();
139
- this.urlManager.initializeSingleton();
140
- this.permalinkManager.initializeSingleton();
141
- this.layerManager.initializeSingleton();
142
- this.userLayerManager.initializeSingleton();
143
- this.themesHelper.initializeSingleton();
144
- this.stateSerializer.initializeSingleton();
145
- this.sessionManager.initializeSingleton();
146
- this.shareManager.initializeSingleton();
147
- this.wfsManager.initializeSingleton();
148
- this.errorManager.initializeSingleton();
149
- this.customThemesManager.initializeSingleton();
150
- this.themesManager.initializeSingleton();
151
- this.wmsManager.initializeSingleton();
152
- this.wmtsManager.initializeSingleton();
153
- this.localFileManager.initializeSingleton();
154
- this.selectionManager.initializeSingleton();
155
- this.ogcApiFeaturesManager.initializeSingleton();
156
- this.onBoardingManager.initializeSingleton();
157
- this.themeFavoritesManager.initializeSingleton();
158
- this.searchManager.initializeSingleton();
159
- this.feedbackManager.initializeSingleton();
160
75
  }
161
76
  }
@@ -1,6 +1,6 @@
1
1
  import IGirafeContext from '../context/icontext';
2
2
  declare class MockHelper {
3
- static startMocking(): IGirafeContext;
4
- static stopMocking(context: IGirafeContext): void;
3
+ static startMocking(): Promise<IGirafeContext>;
4
+ static stopMocking(context: IGirafeContext): Promise<void>;
5
5
  }
6
6
  export default MockHelper;
@@ -3,21 +3,20 @@ import proj4 from 'proj4';
3
3
  import { register } from 'ol/proj/proj4';
4
4
  import MockGirafeContext from './mockcontext';
5
5
  import { MockConfig } from './mockconfig';
6
- import { noop } from '../utils/async';
7
6
  class MockHelper {
8
- static startMocking() {
7
+ static async startMocking() {
9
8
  const context = new MockGirafeContext();
10
- context.initialize().then(noop);
9
+ await context.initialize();
11
10
  for (const crs of MockConfig.crs) {
12
11
  proj4.defs(crs.code, crs.definition);
13
12
  }
14
13
  register(proj4);
15
14
  return context;
16
15
  }
17
- static stopMocking(context) {
16
+ static async stopMocking(context) {
17
+ await context.userDataManager.deleteAllUserData();
18
18
  // @ts-ignore
19
19
  context.configManager.config = null;
20
- context.userDataManager.deleteAllUserData();
21
20
  }
22
21
  }
23
22
  export default MockHelper;
@@ -5,10 +5,10 @@ declare class CustomThemesManager extends GirafeSingleton {
5
5
  customThemes: CustomTheme[];
6
6
  private readonly storagePath;
7
7
  private readonly serializer;
8
- addTheme(themeName: string, layersList: BaseLayer[]): void;
8
+ addTheme(themeName: string, layersList: BaseLayer[]): Promise<void>;
9
9
  private manageActiveStateForClonedObject;
10
- deleteTheme(theme: CustomTheme): void;
10
+ deleteTheme(theme: CustomTheme): Promise<void>;
11
11
  private saveCustomThemes;
12
- loadCustomThemes(): void;
12
+ loadCustomThemes(): Promise<void>;
13
13
  }
14
14
  export default CustomThemesManager;
@@ -9,7 +9,7 @@ class CustomThemesManager extends GirafeSingleton {
9
9
  customThemes = [];
10
10
  storagePath = 'customThemes';
11
11
  serializer = new CustomLayersSerializer(this.context);
12
- addTheme(themeName, layersList) {
12
+ async addTheme(themeName, layersList) {
13
13
  const theme = new CustomTheme(themeName);
14
14
  for (const layerBase of layersList) {
15
15
  const layer = layerBase.clone();
@@ -17,7 +17,7 @@ class CustomThemesManager extends GirafeSingleton {
17
17
  theme.layers.push(layer);
18
18
  }
19
19
  this.customThemes.push(theme);
20
- this.saveCustomThemes();
20
+ await this.saveCustomThemes();
21
21
  }
22
22
  manageActiveStateForClonedObject(layer) {
23
23
  /** Manage the current active state and default active state
@@ -35,25 +35,25 @@ class CustomThemesManager extends GirafeSingleton {
35
35
  }
36
36
  }
37
37
  }
38
- deleteTheme(theme) {
39
- const index = this.customThemes.findIndex((item) => item === theme);
38
+ async deleteTheme(theme) {
39
+ const index = this.customThemes.indexOf(theme);
40
40
  if (index >= 0) {
41
41
  this.customThemes.splice(index, 1);
42
- this.saveCustomThemes();
42
+ await this.saveCustomThemes();
43
43
  }
44
44
  else {
45
45
  throw new Error('The custom theme to be removed cannot be found in the list of custom themes');
46
46
  }
47
47
  }
48
- saveCustomThemes() {
48
+ async saveCustomThemes() {
49
49
  const serializedObject = {};
50
50
  for (const customTheme of this.customThemes) {
51
51
  serializedObject[customTheme.name] = this.serializer.customThemeSerialize(customTheme);
52
52
  }
53
- this.context.userDataManager.saveUserData(this.storagePath, serializedObject);
53
+ await this.context.userDataManager.saveUserData(this.storagePath, serializedObject);
54
54
  }
55
- loadCustomThemes() {
56
- const customThemes = this.context.userDataManager.getUserData(this.storagePath);
55
+ async loadCustomThemes() {
56
+ const customThemes = (await this.context.userDataManager.getUserData(this.storagePath));
57
57
  if (customThemes) {
58
58
  for (const customThemeName of Object.keys(customThemes)) {
59
59
  try {
@@ -4,13 +4,13 @@ import ThemeLayer from '../../models/layers/themelayer.js';
4
4
  declare class ThemeFavoritesManager extends GirafeSingleton {
5
5
  private themeFavorites;
6
6
  private readonly storagePath;
7
- initializeSingleton(): void;
7
+ initializeSingleton(): Promise<void>;
8
8
  private saveThemeFavorites;
9
9
  private loadThemeFavorites;
10
- addThemeToFavorites(theme: ThemeLayer | CustomTheme): void;
11
- removeThemeFromFavorites(theme: ThemeLayer | CustomTheme): void;
12
- addOrRemoveThemeFromFavorites(theme: ThemeLayer | CustomTheme): void;
13
- clearThemeFavorites(): void;
10
+ addThemeToFavorites(theme: ThemeLayer | CustomTheme): Promise<void>;
11
+ removeThemeFromFavorites(theme: ThemeLayer | CustomTheme): Promise<void>;
12
+ addOrRemoveThemeFromFavorites(theme: ThemeLayer | CustomTheme): Promise<void>;
13
+ clearThemeFavorites(): Promise<void>;
14
14
  isThemeInFavorites(theme: ThemeLayer | CustomTheme): boolean;
15
15
  getThemeFavorites(): Array<number | string>;
16
16
  }
@@ -4,45 +4,45 @@ import ThemeLayer from '../../models/layers/themelayer.js';
4
4
  class ThemeFavoritesManager extends GirafeSingleton {
5
5
  themeFavorites = [];
6
6
  storagePath = 'themeFavorites';
7
- initializeSingleton() {
8
- super.initializeSingleton();
9
- this.loadThemeFavorites();
7
+ async initializeSingleton() {
8
+ await super.initializeSingleton();
9
+ await this.loadThemeFavorites();
10
10
  }
11
- saveThemeFavorites() {
11
+ async saveThemeFavorites() {
12
12
  const serializedThemeFavorites = JSON.stringify(this.themeFavorites);
13
- this.context.userDataManager.saveUserData(this.storagePath, serializedThemeFavorites);
13
+ await this.context.userDataManager.saveUserData(this.storagePath, serializedThemeFavorites);
14
14
  }
15
- loadThemeFavorites() {
16
- const serializedThemeFavorites = this.context.userDataManager.getUserData(this.storagePath);
15
+ async loadThemeFavorites() {
16
+ const serializedThemeFavorites = (await this.context.userDataManager.getUserData(this.storagePath));
17
17
  if (serializedThemeFavorites) {
18
18
  this.themeFavorites = JSON.parse(serializedThemeFavorites);
19
19
  }
20
20
  }
21
- addThemeToFavorites(theme) {
21
+ async addThemeToFavorites(theme) {
22
22
  this.themeFavorites.push(theme instanceof ThemeLayer ? theme.id : theme.name);
23
- this.saveThemeFavorites();
23
+ await this.saveThemeFavorites();
24
24
  }
25
- removeThemeFromFavorites(theme) {
25
+ async removeThemeFromFavorites(theme) {
26
26
  const index = this.themeFavorites.findIndex((themeIdOrName) => theme instanceof ThemeLayer ? themeIdOrName === theme.id : themeIdOrName === theme.name);
27
27
  if (index >= 0) {
28
28
  this.themeFavorites.splice(index, 1);
29
- this.saveThemeFavorites();
29
+ await this.saveThemeFavorites();
30
30
  }
31
31
  else {
32
32
  throw new Error('The theme to be removed cannot be found in the list of favorites');
33
33
  }
34
34
  }
35
- addOrRemoveThemeFromFavorites(theme) {
35
+ async addOrRemoveThemeFromFavorites(theme) {
36
36
  if (this.isThemeInFavorites(theme)) {
37
- this.removeThemeFromFavorites(theme);
37
+ await this.removeThemeFromFavorites(theme);
38
38
  }
39
39
  else {
40
- this.addThemeToFavorites(theme);
40
+ await this.addThemeToFavorites(theme);
41
41
  }
42
42
  }
43
- clearThemeFavorites() {
43
+ async clearThemeFavorites() {
44
44
  this.themeFavorites = [];
45
- this.saveThemeFavorites();
45
+ await this.saveThemeFavorites();
46
46
  }
47
47
  isThemeInFavorites(theme) {
48
48
  return this.themeFavorites.includes(theme instanceof ThemeLayer ? theme.id : theme.name);
@@ -9,7 +9,7 @@ export type LayerTreeChanges = {
9
9
  activatedLayers: BaseLayer[];
10
10
  };
11
11
  export default class ThemesHelper extends GirafeSingleton {
12
- initializeSingleton(): void;
12
+ initializeSingleton(): Promise<void>;
13
13
  private get state();
14
14
  findBaseLayerById(layerId: LayerId): BaseLayer;
15
15
  findBaseLayerRecursiveById(layers: BaseLayer[], layerId: LayerId): BaseLayer | null;
@@ -10,7 +10,7 @@ import WfsFilterCondition, { isWfsOperator } from '../wfs/wfsfiltercondition.js'
10
10
  import { KNOWN_FUNCTIONALITIES } from '../functionalities.js';
11
11
  import WfsFilter from '../wfs/wfsfilter.js';
12
12
  export default class ThemesHelper extends GirafeSingleton {
13
- initializeSingleton() {
13
+ async initializeSingleton() {
14
14
  this.context.stateManager.subscribe('themes.lastSelectedTheme', (_oldTheme, newTheme) => this.onSelectedThemeChanged(newTheme));
15
15
  }
16
16
  get state() {