@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
@@ -46,8 +46,8 @@ export default class GirafeApiContext 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: ApiSessionManager;
53
53
  readonly stateSerializer: StateSerializer;
@@ -72,6 +72,17 @@ export default class GirafeApiContext 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 configManagerHook(): Promise<void>;
87
+ protected stateManagerHook(): Promise<void>;
77
88
  }
package/api/apicontext.js CHANGED
@@ -1,41 +1,6 @@
1
- // SPDX-License-Identifier: Apache-2.0
2
- import ApplicationLifeCycleManager from '../tools/app/lifecyclemanager.js';
3
- import AuthManager from '../tools/auth/authmanager.js';
4
- import DragManager from '../components/treeview/tools/dragmanager.js';
5
- import PluginManager from '../tools/auth/pluginmanager.js';
6
- import ConfigManager from '../tools/configuration/configmanager.js';
7
- import ErrorManager from '../tools/error/errormanager.js';
8
- import I18nManager from '../tools/i18n/i18nmanager.js';
9
- import LayerManager from '../tools/layers/layermanager.js';
10
- import SnapManager from '../tools/layers/snapmanager.js';
11
- import LocalFileManager from '../tools/localfile/localfilemanager.js';
12
- import LogManager from '../tools/logging/logmanager.js';
13
- import OfflineManager from '../tools/offline/offlinemanager.js';
14
- import OgcApiFeaturesManager from '../tools/ogcapi/ogcapifeaturesmanager.js';
15
- import OrderingManager from '../tools/ordering/orderingmanager.js';
16
- import ShareManager from '../tools/share/sharemanager.js';
17
- import StateSerializer from '../tools/share/stateserializer.js';
18
- import ComponentManager from '../tools/state/componentManager.js';
19
- import MapManager from '../tools/state/mapManager.js';
20
- import StateManager from '../tools/state/statemanager.js';
21
- import UserInteractionManager from '../tools/state/userInteractionManager.js';
22
- import CustomThemesManager from '../tools/themes/customthemesmanager.js';
23
- import ThemesHelper from '../tools/themes/themeshelper.js';
24
- import ThemesManager from '../tools/themes/themesmanager.js';
25
- import UserLayerManager from '../tools/themes/userlayermanager.js';
26
- import PermalinkManager from '../tools/url/permalinkmanager.js';
27
- import UrlManager from '../tools/url/urlmanager.js';
28
- import UserDataManager from '../tools/userdata/userdatamanager.js';
29
- import WfsManager from '../tools/wfs/wfsmanager.js';
30
- import WmsManager from '../tools/wms/wmsmanager.js';
31
- import WmtsManager from '../tools/wmts/wmtsmanager.js';
32
- import SelectionManager from '../tools/selection/selectionmanager.js';
33
1
  import ApiSessionManager from './apisessionmanager.js';
34
- import OnBoardingManager from '../tools/onboarding/onboardingmanager.js';
35
- import ThemeFavoritesManager from '../tools/themes/themefavoritesmanager.js';
36
- import SearchManager from '../tools/search/searchmanager.js';
37
- import FeedbackManager from '../tools/feedback/feedbackmanager.js';
38
2
  import { updateConfigPaths } from './apiutils.js';
3
+ import ContextInitializationHelper from '../tools/context/contexthelper.js';
39
4
  export default class GirafeApiContext {
40
5
  userDataManager;
41
6
  configManager;
@@ -47,8 +12,8 @@ export default class GirafeApiContext {
47
12
  themesManager;
48
13
  themesHelper;
49
14
  permalinkManager;
50
- urlManager;
51
15
  dragManager;
16
+ urlManager;
52
17
  layerManager;
53
18
  sessionManager;
54
19
  stateSerializer;
@@ -73,87 +38,30 @@ export default class GirafeApiContext {
73
38
  themeFavoritesManager;
74
39
  searchManager;
75
40
  feedbackManager;
41
+ contextHelper = new ContextInitializationHelper();
76
42
  constructor() {
77
- this.componentManager = new ComponentManager(this);
78
- this.userDataManager = new UserDataManager(this);
79
- this.configManager = new ConfigManager(this);
80
- this.logManager = new LogManager(this);
81
- this.stateManager = new StateManager(this);
82
- this.orderingManager = new OrderingManager(this);
83
- this.applicationLifeCycleManager = new ApplicationLifeCycleManager(this);
84
- this.mapManager = new MapManager(this);
85
- this.offlineManager = new OfflineManager(this);
86
- this.snapManager = new SnapManager(this);
87
- this.authManager = new AuthManager(this);
88
- this.pluginManager = new PluginManager(this);
89
- this.i18nManager = new I18nManager(this);
90
- this.userInteractionManager = new UserInteractionManager(this);
91
- this.dragManager = new DragManager(this);
92
- this.urlManager = new UrlManager(this);
93
- this.permalinkManager = new PermalinkManager(this);
94
- this.layerManager = new LayerManager(this);
95
- this.userLayerManager = new UserLayerManager(this);
96
- this.themesHelper = new ThemesHelper(this);
97
- this.stateSerializer = new StateSerializer(this);
43
+ this.contextHelper.constructContext(this, ['sessionManager']);
98
44
  this.sessionManager = new ApiSessionManager(this);
99
- this.shareManager = new ShareManager(this);
100
- this.wfsManager = new WfsManager(this);
101
- this.errorManager = new ErrorManager(this);
102
- this.customThemesManager = new CustomThemesManager(this);
103
- this.themesManager = new ThemesManager(this);
104
- this.wmsManager = new WmsManager(this);
105
- this.wmtsManager = new WmtsManager(this);
106
- this.selectionManager = new SelectionManager(this);
107
- this.localFileManager = new LocalFileManager(this);
108
- this.ogcApiFeaturesManager = new OgcApiFeaturesManager(this);
109
- this.onBoardingManager = new OnBoardingManager(this);
110
- this.themeFavoritesManager = new ThemeFavoritesManager(this);
111
- this.searchManager = new SearchManager(this);
112
- this.feedbackManager = new FeedbackManager(this);
113
45
  }
114
46
  async initialize() {
115
- // NOTE : This initialization order is important, because some singleton will need other ones !
116
- this.componentManager.initializeSingleton();
117
- this.userDataManager.initializeSingleton();
118
- this.configManager.initializeSingleton();
119
- await this.configManager.loadConfig();
47
+ await this.contextHelper.initializeContext(this);
48
+ }
49
+ /** The context can contains hook methods that will be called after each manager initialization.
50
+ * The hook method must be named with the property name + the "Hook" suffix.
51
+ * The hook method must be async and will be awaited
52
+ * For example, the methods themesManagerHook() will be called immediately after
53
+ * the call of themesManager.initializeSingleton().
54
+ * This allows specific initialization methods when defining custom contexts
55
+ * (for example for the apiContext, the mockContext, or any customContext)
56
+ */
57
+ async configManagerHook() {
58
+ await this.configManager.initializeSingleton();
120
59
  // For the API context, some configuraton options in the config file can be relative.
121
60
  // We have to convert them to absolute paths.
122
61
  updateConfigPaths(this.configManager.Config);
123
- this.logManager.initializeSingleton();
124
- this.logManager.initLogging();
125
- this.stateManager.initializeSingleton();
62
+ }
63
+ async stateManagerHook() {
64
+ await this.stateManager.initializeSingleton();
126
65
  this.stateManager.state.interface.isApi = true;
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();
135
- this.userInteractionManager.initializeSingleton();
136
- this.dragManager.initializeSingleton();
137
- this.urlManager.initializeSingleton();
138
- this.permalinkManager.initializeSingleton();
139
- this.layerManager.initializeSingleton();
140
- this.userLayerManager.initializeSingleton();
141
- this.themesHelper.initializeSingleton();
142
- this.stateSerializer.initializeSingleton();
143
- this.sessionManager.initializeSingleton();
144
- this.shareManager.initializeSingleton();
145
- this.wfsManager.initializeSingleton();
146
- this.errorManager.initializeSingleton();
147
- this.customThemesManager.initializeSingleton();
148
- this.themesManager.initializeSingleton();
149
- this.wmsManager.initializeSingleton();
150
- this.wmtsManager.initializeSingleton();
151
- this.localFileManager.initializeSingleton();
152
- this.selectionManager.initializeSingleton();
153
- this.ogcApiFeaturesManager.initializeSingleton();
154
- this.onBoardingManager.initializeSingleton();
155
- this.themeFavoritesManager.initializeSingleton();
156
- this.searchManager.initializeSingleton();
157
- this.feedbackManager.initializeSingleton();
158
66
  }
159
67
  }
@@ -1,7 +1,7 @@
1
1
  import GirafeSingleton from '../base/GirafeSingleton.js';
2
2
  import ISessionManager from '../tools/share/isessionmanager.js';
3
3
  declare class ApiSessionManager extends GirafeSingleton implements ISessionManager {
4
- initializeSingleton(): void;
4
+ initializeSingleton(): Promise<void>;
5
5
  beginSession(): void;
6
6
  saveStateToSession(): void;
7
7
  hasState(): boolean;
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  import GirafeSingleton from '../base/GirafeSingleton.js';
3
3
  class ApiSessionManager extends GirafeSingleton {
4
- initializeSingleton() {
4
+ async initializeSingleton() {
5
5
  /* For the API: Do Nothing */
6
6
  }
7
7
  beginSession() {
@@ -2,7 +2,7 @@ import IGirafeContext from '../tools/context/icontext.js';
2
2
  declare class GirafeSingleton {
3
3
  protected readonly context: IGirafeContext;
4
4
  constructor(context: IGirafeContext);
5
- initializeSingleton(): void;
5
+ initializeSingleton(): Promise<void>;
6
6
  protected isNullOrUndefinedOrBlank(val: unknown): val is "" | null | undefined;
7
7
  }
8
8
  export default GirafeSingleton;
@@ -4,7 +4,7 @@ class GirafeSingleton {
4
4
  constructor(context) {
5
5
  this.context = context;
6
6
  }
7
- initializeSingleton() {
7
+ async initializeSingleton() {
8
8
  /*
9
9
  * This method does nothing by default, but will be called by the context when creating the singleton
10
10
  * (This prevent overriding the constructor in every songleton and creating a strong dependency to the context object)
@@ -15,8 +15,8 @@ declare class NavigationComponent extends GirafeHTMLElement {
15
15
  render(): void;
16
16
  addBookmark(): Promise<void>;
17
17
  removeBookmark(bookmark: Bookmark): Promise<void>;
18
- saveBookmarks(): void;
19
- loadBookmarks(): void;
18
+ private saveBookmarks;
19
+ private loadBookmarks;
20
20
  registerEvents(): void;
21
21
  onPositionChanged(position: MapPosition): void;
22
22
  navigateBack(): void;
@@ -36,7 +36,7 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
36
36
  if (name) {
37
37
  const bookmark = new Bookmark(name, this.state.position);
38
38
  this.bookmarks.push(bookmark);
39
- this.saveBookmarks();
39
+ await this.saveBookmarks();
40
40
  super.render();
41
41
  super.girafeTranslate();
42
42
  }
@@ -48,17 +48,17 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
48
48
  if (index >= 0) {
49
49
  this.bookmarks.splice(index, 1);
50
50
  }
51
- this.saveBookmarks();
51
+ await this.saveBookmarks();
52
52
  super.render();
53
53
  super.girafeTranslate();
54
54
  }
55
55
  }
56
- saveBookmarks() {
57
- this.context.userDataManager.saveUserData(this.storagePath, this.bookmarks);
56
+ async saveBookmarks() {
57
+ await this.context.userDataManager.saveUserData(this.storagePath, this.bookmarks);
58
58
  }
59
- loadBookmarks() {
59
+ async loadBookmarks() {
60
60
  this.bookmarks = [];
61
- const storedBookmarks = this.context.userDataManager.getUserData(this.storagePath);
61
+ const storedBookmarks = (await this.context.userDataManager.getUserData(this.storagePath));
62
62
  if (storedBookmarks) {
63
63
  for (const bookmark of storedBookmarks) {
64
64
  try {
@@ -7,7 +7,6 @@ declare class NewsButtonComponent extends GirafeHTMLElement {
7
7
  warn: boolean;
8
8
  constructor();
9
9
  setWarn(): void;
10
- loadLastViewDate(): void;
11
10
  getIcon(): "icons/bell-warn.svg" | "icons/bell.svg";
12
11
  connectedCallback(): void;
13
12
  }
@@ -26,12 +26,6 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
26
26
  }
27
27
  super.render();
28
28
  }
29
- loadLastViewDate() {
30
- const lastViewDate = this.context.userDataManager.getUserData('lastViewDate');
31
- if (lastViewDate) {
32
- this.context.stateManager.state.news.lastViewDate = lastViewDate;
33
- }
34
- }
35
29
  getIcon() {
36
30
  const icon = this.warn ? 'icons/bell-warn.svg' : 'icons/bell.svg';
37
31
  return icon;
@@ -10,8 +10,8 @@ declare class NewsPanelComponent extends GirafeHTMLElement implements IGirafePan
10
10
  panelTogglePath: string;
11
11
  entries: FeedEntry[];
12
12
  constructor();
13
- saveLastViewDate(): void;
14
- loadLastViewDate(): void;
13
+ saveLastViewDate(): Promise<void>;
14
+ private loadLastViewDate;
15
15
  togglePanel(visible: boolean): void;
16
16
  render(): void;
17
17
  private initializeNewsState;
@@ -22,13 +22,13 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
22
22
  constructor() {
23
23
  super('news-panel');
24
24
  }
25
- saveLastViewDate() {
25
+ async saveLastViewDate() {
26
26
  const currentTimestamp = Date.now();
27
- this.context.userDataManager.saveUserData('lastViewDate', currentTimestamp);
27
+ await this.context.userDataManager.saveUserData('lastViewDate', currentTimestamp);
28
28
  this.context.stateManager.state.news.lastViewDate = currentTimestamp;
29
29
  }
30
- loadLastViewDate() {
31
- const raw = this.context.userDataManager.getUserData('lastViewDate');
30
+ async loadLastViewDate() {
31
+ const raw = await this.context.userDataManager.getUserData('lastViewDate');
32
32
  const lastViewDate = Number(raw);
33
33
  this.context.stateManager.state.news.lastViewDate = Number.isFinite(lastViewDate) ? lastViewDate : 0;
34
34
  }
@@ -52,7 +52,7 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
52
52
  if (!this.context.configManager.Config.news) {
53
53
  return;
54
54
  }
55
- this.loadLastViewDate();
55
+ await this.loadLastViewDate();
56
56
  const urls = this.context.configManager.Config.news.urls;
57
57
  this.entries = await loadFeeds(urls);
58
58
  // Update state manager
@@ -25,7 +25,7 @@ declare class ThemeComponent extends GirafeHTMLElement {
25
25
  onThemeChanged(theme: ThemeLayer | CustomTheme): void;
26
26
  isThemeActive(theme: ThemeLayer | CustomTheme): boolean;
27
27
  isThemeFavorite(theme: ThemeLayer | CustomTheme): boolean;
28
- onThemeFavoriteChanged(theme: ThemeLayer | CustomTheme, e: Event): void;
28
+ onThemeFavoriteChanged(theme: ThemeLayer | CustomTheme, e: Event): Promise<void>;
29
29
  isThemeTypeActive(themeType: ThemeType): boolean;
30
30
  isCustomTheme(theme: ThemeLayer | CustomTheme): theme is CustomTheme;
31
31
  onCustomThemeChanged(customTheme: CustomTheme): void;
@@ -117,10 +117,10 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
117
117
  isThemeFavorite(theme) {
118
118
  return this.context.themeFavoritesManager.isThemeInFavorites(theme);
119
119
  }
120
- onThemeFavoriteChanged(theme, e) {
120
+ async onThemeFavoriteChanged(theme, e) {
121
121
  e.preventDefault();
122
122
  e.stopPropagation();
123
- this.context.themeFavoritesManager.addOrRemoveThemeFromFavorites(theme);
123
+ await this.context.themeFavoritesManager.addOrRemoveThemeFromFavorites(theme);
124
124
  this.render();
125
125
  }
126
126
  isThemeTypeActive(themeType) {
@@ -136,7 +136,7 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
136
136
  async onAddCustomTheme() {
137
137
  const themeName = await window.gPrompt('Enter a name for your custom theme', 'Create custom theme', 'Enter a name...');
138
138
  if (themeName !== false && themeName.trim().length > 0) {
139
- this.context.customThemesManager.addTheme(themeName, this.state.layers.layersList);
139
+ await this.context.customThemesManager.addTheme(themeName, this.state.layers.layersList);
140
140
  this.render();
141
141
  }
142
142
  }
@@ -144,7 +144,7 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
144
144
  e.stopPropagation();
145
145
  const confirm = await window.gConfirm('Do you want to delete this theme?', 'Delete Theme');
146
146
  if (confirm) {
147
- this.context.customThemesManager.deleteTheme(customTheme);
147
+ await this.context.customThemesManager.deleteTheme(customTheme);
148
148
  this.render();
149
149
  }
150
150
  }
@@ -59,7 +59,7 @@ export default class UserPreferencesComponent extends GirafeHTMLElement implemen
59
59
  /**
60
60
  Update state and local storage with new value
61
61
  */
62
- changePreference(preferenceKey: string, newValue: unknown): void;
62
+ changePreference(preferenceKey: string, newValue: unknown): Promise<void>;
63
63
  /**
64
64
  Update the config object with the new value
65
65
  */
@@ -272,12 +272,12 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
272
272
  /**
273
273
  Update state and local storage with new value
274
274
  */
275
- changePreference(preferenceKey, newValue) {
275
+ async changePreference(preferenceKey, newValue) {
276
276
  if (this.preferences[preferenceKey]) {
277
277
  this.preferences[preferenceKey].currentValue = newValue;
278
278
  this.updatePreferenceInConfig(preferenceKey);
279
279
  this.updatePreferenceInState(preferenceKey);
280
- this.updatePreferenceInStorage(preferenceKey);
280
+ await this.updatePreferenceInStorage(preferenceKey);
281
281
  this.refreshRender();
282
282
  }
283
283
  }
@@ -300,10 +300,10 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
300
300
  /**
301
301
  Save the user preference as a config override in user data storage
302
302
  */
303
- updatePreferenceInStorage(preferenceKey) {
303
+ async updatePreferenceInStorage(preferenceKey) {
304
304
  const preference = this.preferences[preferenceKey];
305
305
  // Values are saved under 'configOverrides' in the same structure as in the config
306
- this.context.userDataManager.saveUserData(`${this.storagePath}.${preference.configPath}`, preference.currentValue);
306
+ await this.context.userDataManager.saveUserData(`${this.storagePath}.${preference.configPath}`, preference.currentValue);
307
307
  }
308
308
  /**
309
309
  * Reset user preferences back to defaults. This will delete the configOverrides object in storage and set the
@@ -312,11 +312,11 @@ ${this.htmlUnsafe(this.feedbackTemplateHtml ?? '')}`;
312
312
  async onResetAll() {
313
313
  const confirm = await window.gConfirm('Reset user preferences back to default values?', 'Reset preferences');
314
314
  if (confirm) {
315
- this.resetAll();
315
+ await this.resetAll();
316
316
  }
317
317
  }
318
- resetAll() {
319
- this.context.userDataManager.deleteUserData(this.storagePath);
318
+ async resetAll() {
319
+ await this.context.userDataManager.deleteUserData(this.storagePath);
320
320
  for (const preferenceKey in this.preferences) {
321
321
  this.preferences[preferenceKey].currentValue = this.context.configManager.getDefaultConfigValue(this.preferences[preferenceKey].configPath);
322
322
  this.updatePreferenceInState(preferenceKey);
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "name": "GeoGirafe PSC",
6
6
  "url": "https://doc.geogirafe.org"
7
7
  },
8
- "version": "1.2.0-dev.2873796427",
8
+ "version": "1.2.0-dev.2889263072",
9
9
  "type": "module",
10
10
  "engines": {
11
11
  "node": ">=20.19.0"
@@ -1 +1 @@
1
- {"version":"1.2.0-dev.2873796427", "build":"2873796427", "date":"23/09/2026"}
1
+ {"version":"1.2.0-dev.2889263072", "build":"2889263072", "date":"28/09/2026"}
@@ -1,7 +1,7 @@
1
1
  import GirafeSingleton from '../../base/GirafeSingleton.js';
2
2
  export default class ApplicationLifeCycleManager extends GirafeSingleton {
3
3
  private get state();
4
- initializeSingleton(): void;
4
+ initializeSingleton(): Promise<void>;
5
5
  private log;
6
6
  /**
7
7
  * For the application to be ready to load the themes and to deserialize the shared state or the session,
@@ -4,7 +4,7 @@ export default class ApplicationLifeCycleManager extends GirafeSingleton {
4
4
  get state() {
5
5
  return this.context.stateManager.state;
6
6
  }
7
- initializeSingleton() {
7
+ async initializeSingleton() {
8
8
  this.context.stateManager.subscribe('themes.isLoaded', (_, isThemesLoaded) => {
9
9
  this.log(isThemesLoaded, 'Themes are loaded');
10
10
  this.checkApplicationReady();
@@ -60,10 +60,10 @@ export default class AbstractConnectManager {
60
60
  return url.toString();
61
61
  }
62
62
  loadFromLocalStorage(path) {
63
- return this.context.userDataManager.getUserData(`${this.storagePath}.${path}`, true) ?? '';
63
+ return this.context.userDataManager.getFromLocalStorage(`${this.storagePath}.${path}`) ?? '';
64
64
  }
65
65
  saveToLocalStorage(path, value) {
66
- return this.context.userDataManager.saveUserData(`${this.storagePath}.${path}`, value, true);
66
+ this.context.userDataManager.saveToLocalStorage(`${this.storagePath}.${path}`, value);
67
67
  }
68
68
  resetUrl() {
69
69
  const url = new URL(this.context.urlManager.getBaseUrlPath());
@@ -6,7 +6,7 @@ export default class AuthManager extends GirafeSingleton {
6
6
  private readonly gmfManager;
7
7
  private get state();
8
8
  constructor(context: IGirafeContext);
9
- initializeSingleton(): void;
9
+ initializeSingleton(): Promise<void>;
10
10
  initialize(sw: ServiceWorker | null): Promise<void>;
11
11
  private initializeOAuth;
12
12
  private initializeGmfAuth;
@@ -15,7 +15,7 @@ export default class AuthManager extends GirafeSingleton {
15
15
  super(context);
16
16
  this.gmfManager = new GMFManager(this.context);
17
17
  }
18
- initializeSingleton() {
18
+ async initializeSingleton() {
19
19
  this.context.stateManager.subscribe('oauth.status', () => this.loginStateChanged());
20
20
  this.context.stateManager.subscribe('oauth.tokens', () => this.tokensChanged());
21
21
  }
@@ -1,6 +1,6 @@
1
1
  import GirafeSingleton from '../../base/GirafeSingleton.js';
2
2
  declare class PluginManager extends GirafeSingleton {
3
- initializeSingleton(): void;
3
+ initializeSingleton(): Promise<void>;
4
4
  filterPlugins(dom: DocumentFragment | Document): void;
5
5
  private filterPluginFromConfig;
6
6
  private filterPlugin;
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
2
  import GirafeSingleton from '../../base/GirafeSingleton.js';
3
3
  class PluginManager extends GirafeSingleton {
4
- initializeSingleton() {
4
+ async initializeSingleton() {
5
5
  this.context.stateManager.subscribe('oauth.userInfo', () => this.filterPlugins(document));
6
6
  this.filterPlugins(document);
7
7
  }
@@ -10,7 +10,8 @@ declare class ConfigManager extends GirafeSingleton {
10
10
  constructor(context: IGirafeContext);
11
11
  get Config(): GirafeConfig;
12
12
  private getConfigUrls;
13
- loadConfig(): Promise<GirafeConfig>;
13
+ initializeSingleton(): Promise<void>;
14
+ private loadConfig;
14
15
  private doLoadConfig;
15
16
  /**
16
17
  * Merges two configuration objects recursively.
@@ -20,7 +21,7 @@ declare class ConfigManager extends GirafeSingleton {
20
21
  * Retrieves saved configuration overrides based on the user data source.
21
22
  * @param userDataSource The source of user data.
22
23
  */
23
- private getConfigOverrides;
24
+ private loadConfigOverrides;
24
25
  /**
25
26
  * Retrieves the original (default) configuration value before applying overrides.
26
27
  * @param path The path to the configuration property.
@@ -42,6 +42,9 @@ class ConfigManager extends GirafeSingleton {
42
42
  }
43
43
  return configUrls;
44
44
  }
45
+ async initializeSingleton() {
46
+ await this.loadConfig();
47
+ }
45
48
  async loadConfig() {
46
49
  if (this.loadingPromise) {
47
50
  // There's already a promise for loading the configuration
@@ -50,7 +53,7 @@ class ConfigManager extends GirafeSingleton {
50
53
  }
51
54
  if (this.config) {
52
55
  // Config was already loaded.
53
- return Promise.resolve(this.config);
56
+ return this.config;
54
57
  }
55
58
  this.loadingPromise = this.doLoadConfig();
56
59
  return this.loadingPromise;
@@ -77,7 +80,7 @@ class ConfigManager extends GirafeSingleton {
77
80
  // Create a backup of the default config before applying overrides
78
81
  this.defaultConfig = new GirafeConfig(structuredClone(jsonConfig));
79
82
  // Load config overrides and merge them with the default config
80
- const configOverrides = this.getConfigOverrides(this.defaultConfig.userdata.source);
83
+ const configOverrides = await this.loadConfigOverrides(this.defaultConfig);
81
84
  jsonConfig = this.mergeConfigs(jsonConfig, configOverrides);
82
85
  this.config = new GirafeConfig(jsonConfig);
83
86
  console.log('Application Configuration loaded.');
@@ -93,10 +96,11 @@ class ConfigManager extends GirafeSingleton {
93
96
  * Retrieves saved configuration overrides based on the user data source.
94
97
  * @param userDataSource The source of user data.
95
98
  */
96
- getConfigOverrides(userDataSource) {
99
+ async loadConfigOverrides(config) {
97
100
  // Set the user data source first before requesting config overrides from the userDataManager
98
- this.context.userDataManager.setSource(userDataSource);
99
- return this.context.userDataManager.getUserData(this.storagePathForOverrides) || {};
101
+ this.context.userDataManager.initializeFromConfig(config.userdata);
102
+ const configOverrides = await this.context.userDataManager.getUserData(this.storagePathForOverrides);
103
+ return configOverrides;
100
104
  }
101
105
  /**
102
106
  * Retrieves the original (default) configuration value before applying overrides.
@@ -2,6 +2,11 @@ export declare enum HighlightMode {
2
2
  HighlightAll = "highlight-all",
3
3
  HighlightPerLayer = "highlight-per-layer"
4
4
  }
5
+ export type UserDataConfig = {
6
+ source: 'localStorage' | 'server';
7
+ getUrl?: string;
8
+ postUrl?: string;
9
+ };
5
10
  import { Config as SanitizeConfig } from 'dompurify';
6
11
  import { LayoutType } from '../state/layout.js';
7
12
  declare class GirafeConfig {
@@ -243,11 +248,7 @@ declare class GirafeConfig {
243
248
  refererPolicy: ReferrerPolicy;
244
249
  };
245
250
  };
246
- userdata: {
247
- source: 'localStorage' | 'server';
248
- getUrl: string | undefined;
249
- postUrl: string | undefined;
250
- };
251
+ userdata: UserDataConfig;
251
252
  contact?: {
252
253
  url: string;
253
254
  reasons: string[];
@@ -466,6 +466,9 @@ class GirafeConfig {
466
466
  const defaultConfig = {
467
467
  source: 'localStorage'
468
468
  };
469
+ if (config.userdata?.source === 'server' && (!config.userdata?.getUrl || !config.userdata?.postUrl)) {
470
+ throw new Error(`Configuration userdata.getUrl or userdata.postUrl is missing. See https://doc.geogirafe.org/docs/configuration.`);
471
+ }
469
472
  return {
470
473
  ...defaultConfig,
471
474
  ...config.userdata
@@ -72,6 +72,7 @@ export default class GirafeContext 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>;
77
78
  }