@o3r/configuration 15.3.0-prerelease.8 → 15.3.0-rc.1

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.
@@ -1,831 +1,767 @@
1
- import { deepFill, computeItemIdentifier, sendOtterMessage, filterMessageContent, otterComponentInfoPropertyName } from '@o3r/core';
2
- import { map, distinctUntilChanged, shareReplay, filter, take, switchMap } from 'rxjs/operators';
3
- import * as i0 from '@angular/core';
4
- import { InjectionToken, NgModule, makeEnvironmentProviders, inject, ApplicationRef, Injectable, DestroyRef } from '@angular/core';
5
- import { firstValueFrom, fromEvent, of, combineLatest, BehaviorSubject, shareReplay as shareReplay$1 } from 'rxjs';
6
- import * as i1 from '@ngrx/store';
7
- import { createAction, props, on, createReducer, StoreModule, provideState, createFeatureSelector, createSelector, Store, select } from '@ngrx/store';
8
- import { createEntityAdapter } from '@ngrx/entity';
9
- import { takeUntilDestroyed, toSignal, toObservable } from '@angular/core/rxjs-interop';
10
- import { LoggerService } from '@o3r/logger';
11
-
12
- /**
13
- * Get the component and library's names based on the configuration name
14
- * @param configurationName Name of the component as found in the store
15
- * @returns Object containing library and component name.
16
- */
1
+ import { computeItemIdentifier, deepFill, filterMessageContent, otterComponentInfoPropertyName, sendOtterMessage } from "@o3r/core";
2
+ import { distinctUntilChanged, filter, map, shareReplay, switchMap, take } from "rxjs/operators";
3
+ import * as i0 from "@angular/core";
4
+ import { ApplicationRef, DestroyRef, Injectable, InjectionToken, NgModule, inject, makeEnvironmentProviders } from "@angular/core";
5
+ import { BehaviorSubject, combineLatest, firstValueFrom, fromEvent, of, shareReplay as shareReplay$1 } from "rxjs";
6
+ import * as i1 from "@ngrx/store";
7
+ import { Store, StoreModule, createAction, createFeatureSelector, createReducer, createSelector, on, props, provideState, select } from "@ngrx/store";
8
+ import { createEntityAdapter } from "@ngrx/entity";
9
+ import { takeUntilDestroyed, toObservable, toSignal } from "@angular/core/rxjs-interop";
10
+ import { LoggerService } from "@o3r/logger";
17
11
  function parseConfigurationName(configurationName) {
18
- const parsedConfigurationName = configurationName.match(/^([^#]*)#(.*)$/i);
19
- if (parsedConfigurationName) {
20
- return {
21
- library: parsedConfigurationName.length > 2 ? parsedConfigurationName[1] : undefined,
22
- componentName: parsedConfigurationName.length > 2 ? parsedConfigurationName[2] : parsedConfigurationName[0]
23
- };
24
- }
12
+ const parsedConfigurationName = configurationName.match(/^([^#]*)#(.*)$/i);
13
+ if (parsedConfigurationName) return {
14
+ library: parsedConfigurationName.length > 2 ? parsedConfigurationName[1] : void 0,
15
+ componentName: parsedConfigurationName.length > 2 ? parsedConfigurationName[2] : parsedConfigurationName[0]
16
+ };
25
17
  }
26
- /**
27
- * Operator to get the configuration from store for a given component and merge it with the global config
28
- * @param defaultValue Default value of the configuration
29
- */
30
18
  function getConfiguration(defaultValue) {
31
- return (source) => source.pipe(map((configOverride) => {
32
- return deepFill(defaultValue, configOverride);
33
- }), distinctUntilChanged((prev, current) => JSON.stringify(prev) === JSON.stringify(current)), shareReplay({ refCount: true, bufferSize: 1 }));
19
+ return (source) => source.pipe(map((configOverride) => {
20
+ return deepFill(defaultValue, configOverride);
21
+ }), distinctUntilChanged((prev, current) => JSON.stringify(prev) === JSON.stringify(current)), shareReplay({
22
+ refCount: true,
23
+ bufferSize: 1
24
+ }));
34
25
  }
35
-
36
- /** Actions */
37
- const ACTION_SET = '[ConfigOverride] set';
38
- /**
39
- * Clear all overrides and fill the store with the payload
40
- */
41
- const setConfigOverride = createAction(ACTION_SET, props());
42
-
43
- /**
44
- * ConfigOverride Store initial value
45
- */
26
+ const setConfigOverride = createAction("[ConfigOverride] set", props());
46
27
  const configOverrideInitialState = { configOverrides: {} };
47
- /**
48
- * List of basic actions for ConfigOverride Store
49
- */
50
- const configOverrideReducerFeatures = [
51
- on(setConfigOverride, (_state, payload) => ({ ...payload.state }))
52
- ];
53
- /**
54
- * ConfigOverride Store reducer
55
- */
28
+ const configOverrideReducerFeatures = [on(setConfigOverride, (_state, payload) => ({ ...payload.state }))];
56
29
  const configOverrideReducer = createReducer(configOverrideInitialState, ...configOverrideReducerFeatures);
57
-
58
- /**
59
- * Name of the ConfigOverride Store
60
- */
61
- const CONFIG_OVERRIDE_STORE_NAME = 'configOverride';
62
-
63
- /** Token of the ConfigOverride reducer */
64
- const CONFIG_OVERRIDE_REDUCER_TOKEN = new InjectionToken('Feature ConfigOverride Reducer');
65
- /** Provide default reducer for ConfigOverride store */
30
+ const CONFIG_OVERRIDE_STORE_NAME = "configOverride";
31
+ const CONFIG_OVERRIDE_REDUCER_TOKEN = new InjectionToken("Feature ConfigOverride Reducer");
66
32
  function getDefaultConfigOverrideReducer() {
67
- return configOverrideReducer;
33
+ return configOverrideReducer;
68
34
  }
69
- /**
70
- * @deprecated Will be removed in v16. Use {@link provideConfigOverrideStore} instead.
71
- */
72
- class ConfigOverrideStoreModule {
73
- static forRoot(reducerFactory) {
74
- return {
75
- ngModule: ConfigOverrideStoreModule,
76
- providers: [
77
- { provide: CONFIG_OVERRIDE_REDUCER_TOKEN, useFactory: reducerFactory }
78
- ]
79
- };
80
- }
81
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigOverrideStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
82
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: ConfigOverrideStoreModule, imports: [i1.StoreFeatureModule] }); }
83
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigOverrideStoreModule, providers: [
84
- { provide: CONFIG_OVERRIDE_REDUCER_TOKEN, useFactory: getDefaultConfigOverrideReducer }
85
- ], imports: [StoreModule.forFeature(CONFIG_OVERRIDE_STORE_NAME, CONFIG_OVERRIDE_REDUCER_TOKEN)] }); }
86
- }
87
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigOverrideStoreModule, decorators: [{
88
- type: NgModule,
89
- args: [{
90
- imports: [
91
- StoreModule.forFeature(CONFIG_OVERRIDE_STORE_NAME, CONFIG_OVERRIDE_REDUCER_TOKEN)
92
- ],
93
- providers: [
94
- { provide: CONFIG_OVERRIDE_REDUCER_TOKEN, useFactory: getDefaultConfigOverrideReducer }
95
- ]
96
- }]
97
- }] });
98
- /**
99
- * Provide ConfigOverride feature store.
100
- * @param reducerFactory Optional factory to override the default reducer.
101
- */
35
+ var ConfigOverrideStoreModule = class ConfigOverrideStoreModule {
36
+ static forRoot(reducerFactory) {
37
+ return {
38
+ ngModule: ConfigOverrideStoreModule,
39
+ providers: [{
40
+ provide: CONFIG_OVERRIDE_REDUCER_TOKEN,
41
+ useFactory: reducerFactory
42
+ }]
43
+ };
44
+ }
45
+ static {
46
+ this.ɵfac = i0.ɵɵngDeclareFactory({
47
+ minVersion: "12.0.0",
48
+ version: "22.2.3",
49
+ ngImport: i0,
50
+ type: ConfigOverrideStoreModule,
51
+ deps: [],
52
+ target: i0.ɵɵFactoryTarget.NgModule
53
+ });
54
+ }
55
+ static {
56
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
57
+ minVersion: "14.0.0",
58
+ version: "22.2.3",
59
+ ngImport: i0,
60
+ type: ConfigOverrideStoreModule,
61
+ imports: [i1.StoreFeatureModule]
62
+ });
63
+ }
64
+ static {
65
+ this.ɵinj = i0.ɵɵngDeclareInjector({
66
+ minVersion: "12.0.0",
67
+ version: "22.2.3",
68
+ ngImport: i0,
69
+ type: ConfigOverrideStoreModule,
70
+ providers: [{
71
+ provide: CONFIG_OVERRIDE_REDUCER_TOKEN,
72
+ useFactory: getDefaultConfigOverrideReducer
73
+ }],
74
+ imports: [StoreModule.forFeature(CONFIG_OVERRIDE_STORE_NAME, CONFIG_OVERRIDE_REDUCER_TOKEN)]
75
+ });
76
+ }
77
+ };
78
+ i0.ɵɵngDeclareClassMetadata({
79
+ minVersion: "12.0.0",
80
+ version: "22.2.3",
81
+ ngImport: i0,
82
+ type: ConfigOverrideStoreModule,
83
+ decorators: [{
84
+ type: NgModule,
85
+ args: [{
86
+ imports: [StoreModule.forFeature(CONFIG_OVERRIDE_STORE_NAME, CONFIG_OVERRIDE_REDUCER_TOKEN)],
87
+ providers: [{
88
+ provide: CONFIG_OVERRIDE_REDUCER_TOKEN,
89
+ useFactory: getDefaultConfigOverrideReducer
90
+ }]
91
+ }]
92
+ }]
93
+ });
102
94
  function provideConfigOverrideStore(reducerFactory) {
103
- return makeEnvironmentProviders([
104
- provideState(CONFIG_OVERRIDE_STORE_NAME, reducerFactory ? reducerFactory() : configOverrideReducer)
105
- ]);
95
+ return makeEnvironmentProviders([provideState(CONFIG_OVERRIDE_STORE_NAME, reducerFactory ? reducerFactory() : configOverrideReducer)]);
106
96
  }
107
-
108
- /** Select ConfigOverride State */
109
97
  const selectConfigOverrideState = createFeatureSelector(CONFIG_OVERRIDE_STORE_NAME);
110
- /** Select the array of ConfigOverride */
111
98
  const selectConfigOverride = createSelector(selectConfigOverrideState, (state) => state?.configOverrides || {});
112
- /**
113
- * Get the override for given component identifier
114
- * @param componentId
115
- */
116
99
  const selectComponentOverrideConfig = (componentId) => createSelector(selectConfigOverride, (configOverrides) => configOverrides[componentId] || {});
117
-
118
- /**
119
- * Deserializer
120
- * @param rawObject
121
- */
122
100
  const configOverrideStorageDeserializer = (rawObject) => {
123
- if (!rawObject) {
124
- return configOverrideInitialState;
125
- }
126
- return rawObject;
127
- };
128
- const configOverrideStorageSync = {
129
- deserialize: configOverrideStorageDeserializer
101
+ if (!rawObject) return configOverrideInitialState;
102
+ return rawObject;
130
103
  };
131
-
132
- /** Entity Actions */
133
- const ACTION_CLEAR_ENTITIES = '[Configuration] clear entities';
134
- const ACTION_UPDATE_ENTITIES = '[Configuration] update entities';
135
- const ACTION_UPSERT_ENTITIES = '[Configuration] upsert entities';
136
- const ACTION_SET_ENTITIES = '[Configuration] set entities';
137
- const ACTION_UPDATE_CONFIGURATION_ENTITY = '[Configuration] update configuration entity';
138
- const ACTION_UPSERT_CONFIGURATION_ENTITY = '[Configuration] set configuration entity';
139
- /**
140
- * Upsert one configuration entity
141
- */
142
- const upsertConfigurationEntity = createAction(ACTION_UPSERT_CONFIGURATION_ENTITY, props());
143
- /**
144
- * Update one configuration entity
145
- */
104
+ const configOverrideStorageSync = { deserialize: configOverrideStorageDeserializer };
105
+ const ACTION_CLEAR_ENTITIES = "[Configuration] clear entities";
106
+ const ACTION_UPDATE_ENTITIES = "[Configuration] update entities";
107
+ const ACTION_UPSERT_ENTITIES = "[Configuration] upsert entities";
108
+ const ACTION_SET_ENTITIES = "[Configuration] set entities";
109
+ const ACTION_UPDATE_CONFIGURATION_ENTITY = "[Configuration] update configuration entity";
110
+ const upsertConfigurationEntity = createAction("[Configuration] set configuration entity", props());
146
111
  const updateConfigurationEntity = createAction(ACTION_UPDATE_CONFIGURATION_ENTITY, props());
147
- /**
148
- * Clear all configuration and fill the store with the payload
149
- */
150
112
  const setConfigurationEntities = createAction(ACTION_SET_ENTITIES, props());
151
- /**
152
- * Update configuration with known IDs, ignore the new ones
153
- */
154
113
  const updateConfigurationEntities = createAction(ACTION_UPDATE_ENTITIES, props());
155
- /**
156
- * Update configuration with known IDs, insert the new ones
157
- */
158
114
  const upsertConfigurationEntities = createAction(ACTION_UPSERT_ENTITIES, props());
159
- /**
160
- * Clear only the entities, keeps the other attributes in the state
161
- */
162
115
  const clearConfigurationEntities = createAction(ACTION_CLEAR_ENTITIES);
163
-
164
- /**
165
- * compute the configuration into SetEntitiesPayload
166
- * @param customConfigObject array of configurations
167
- */
168
116
  function computeConfiguration(customConfigObject) {
169
- const entities = customConfigObject.reduce((acc, conf) => {
170
- const id = computeItemIdentifier(conf.name, conf.library);
171
- acc[id] = { ...conf.config, id };
172
- return acc;
173
- }, {});
174
- return { entities };
117
+ return { entities: customConfigObject.reduce((acc, conf) => {
118
+ const id = computeItemIdentifier(conf.name, conf.library);
119
+ acc[id] = {
120
+ ...conf.config,
121
+ id
122
+ };
123
+ return acc;
124
+ }, {}) };
175
125
  }
176
-
177
- /**
178
- * Configuration Store adapter
179
- */
180
- const configurationAdapter = createEntityAdapter({
181
- selectId: (model) => model.id
182
- });
183
- /**
184
- * Configuration Store initial value
185
- */
126
+ const configurationAdapter = createEntityAdapter({ selectId: (model) => model.id });
186
127
  const configurationInitialState = configurationAdapter.getInitialState({});
187
- /**
188
- * List of basic actions for Configuration Store
189
- */
190
128
  const configurationReducerFeatures = [
191
- on(setConfigurationEntities, (state, payload) => configurationAdapter.addMany(Object.keys(payload).map((id) => ({ ...payload[id], id })), configurationAdapter.removeAll(state))),
192
- on(updateConfigurationEntities, (state, payload) => configurationAdapter.updateMany(Object.keys(payload.entities).map((id) => ({ id: id, changes: payload.entities[id] })), state)),
193
- on(upsertConfigurationEntities, (state, payload) => configurationAdapter.upsertMany(Object.keys(payload.entities).map((id) => ({ ...payload.entities[id], id })), state)),
194
- on(clearConfigurationEntities, (state) => configurationAdapter.removeAll(state)),
195
- on(updateConfigurationEntity, (state, payload) => configurationAdapter.updateOne({ id: payload.id, changes: payload.configuration }, state)),
196
- on(upsertConfigurationEntity, (state, payload) => configurationAdapter.upsertOne({ id: payload.id, ...payload.configuration }, state))
129
+ on(setConfigurationEntities, (state, payload) => configurationAdapter.addMany(Object.keys(payload).map((id) => ({
130
+ ...payload[id],
131
+ id
132
+ })), configurationAdapter.removeAll(state))),
133
+ on(updateConfigurationEntities, (state, payload) => configurationAdapter.updateMany(Object.keys(payload.entities).map((id) => ({
134
+ id,
135
+ changes: payload.entities[id]
136
+ })), state)),
137
+ on(upsertConfigurationEntities, (state, payload) => configurationAdapter.upsertMany(Object.keys(payload.entities).map((id) => ({
138
+ ...payload.entities[id],
139
+ id
140
+ })), state)),
141
+ on(clearConfigurationEntities, (state) => configurationAdapter.removeAll(state)),
142
+ on(updateConfigurationEntity, (state, payload) => configurationAdapter.updateOne({
143
+ id: payload.id,
144
+ changes: payload.configuration
145
+ }, state)),
146
+ on(upsertConfigurationEntity, (state, payload) => configurationAdapter.upsertOne({
147
+ id: payload.id,
148
+ ...payload.configuration
149
+ }, state))
197
150
  ];
198
- /**
199
- * Configuration Store reducer
200
- */
201
151
  const configurationReducer = createReducer(configurationInitialState, ...configurationReducerFeatures);
202
-
203
- /**
204
- * Name of the Configuration Store
205
- */
206
- const CONFIGURATION_STORE_NAME = 'configuration';
207
- /**
208
- * ID of the global configuration
209
- */
210
- const globalConfigurationId = 'global';
211
-
212
- /** Token of the Configuration reducer */
213
- const CONFIGURATION_REDUCER_TOKEN = new InjectionToken('Feature Configuration Reducer');
214
- /** Provide default reducer for Configuration store */
152
+ const CONFIGURATION_STORE_NAME = "configuration";
153
+ const globalConfigurationId = "global";
154
+ const CONFIGURATION_REDUCER_TOKEN = new InjectionToken("Feature Configuration Reducer");
215
155
  function getDefaultConfigurationReducer() {
216
- return configurationReducer;
217
- }
218
- /**
219
- * @deprecated Will be removed in v16. Use {@link provideConfigurationStore} instead.
220
- */
221
- class ConfigurationStoreModule {
222
- static forRoot(reducerFactory) {
223
- return {
224
- ngModule: ConfigurationStoreModule,
225
- providers: [
226
- { provide: CONFIGURATION_REDUCER_TOKEN, useFactory: reducerFactory }
227
- ]
228
- };
229
- }
230
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
231
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationStoreModule, imports: [i1.StoreFeatureModule] }); }
232
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationStoreModule, providers: [
233
- { provide: CONFIGURATION_REDUCER_TOKEN, useFactory: getDefaultConfigurationReducer }
234
- ], imports: [StoreModule.forFeature(CONFIGURATION_STORE_NAME, CONFIGURATION_REDUCER_TOKEN)] }); }
156
+ return configurationReducer;
235
157
  }
236
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationStoreModule, decorators: [{
237
- type: NgModule,
238
- args: [{
239
- imports: [
240
- StoreModule.forFeature(CONFIGURATION_STORE_NAME, CONFIGURATION_REDUCER_TOKEN)
241
- ],
242
- providers: [
243
- { provide: CONFIGURATION_REDUCER_TOKEN, useFactory: getDefaultConfigurationReducer }
244
- ]
245
- }]
246
- }] });
247
- /**
248
- * Provide Configuration feature store.
249
- * @param reducerFactory Optional factory to override the default reducer.
250
- */
158
+ var ConfigurationStoreModule = class ConfigurationStoreModule {
159
+ static forRoot(reducerFactory) {
160
+ return {
161
+ ngModule: ConfigurationStoreModule,
162
+ providers: [{
163
+ provide: CONFIGURATION_REDUCER_TOKEN,
164
+ useFactory: reducerFactory
165
+ }]
166
+ };
167
+ }
168
+ static {
169
+ this.ɵfac = i0.ɵɵngDeclareFactory({
170
+ minVersion: "12.0.0",
171
+ version: "22.2.3",
172
+ ngImport: i0,
173
+ type: ConfigurationStoreModule,
174
+ deps: [],
175
+ target: i0.ɵɵFactoryTarget.NgModule
176
+ });
177
+ }
178
+ static {
179
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
180
+ minVersion: "14.0.0",
181
+ version: "22.2.3",
182
+ ngImport: i0,
183
+ type: ConfigurationStoreModule,
184
+ imports: [i1.StoreFeatureModule]
185
+ });
186
+ }
187
+ static {
188
+ this.ɵinj = i0.ɵɵngDeclareInjector({
189
+ minVersion: "12.0.0",
190
+ version: "22.2.3",
191
+ ngImport: i0,
192
+ type: ConfigurationStoreModule,
193
+ providers: [{
194
+ provide: CONFIGURATION_REDUCER_TOKEN,
195
+ useFactory: getDefaultConfigurationReducer
196
+ }],
197
+ imports: [StoreModule.forFeature(CONFIGURATION_STORE_NAME, CONFIGURATION_REDUCER_TOKEN)]
198
+ });
199
+ }
200
+ };
201
+ i0.ɵɵngDeclareClassMetadata({
202
+ minVersion: "12.0.0",
203
+ version: "22.2.3",
204
+ ngImport: i0,
205
+ type: ConfigurationStoreModule,
206
+ decorators: [{
207
+ type: NgModule,
208
+ args: [{
209
+ imports: [StoreModule.forFeature(CONFIGURATION_STORE_NAME, CONFIGURATION_REDUCER_TOKEN)],
210
+ providers: [{
211
+ provide: CONFIGURATION_REDUCER_TOKEN,
212
+ useFactory: getDefaultConfigurationReducer
213
+ }]
214
+ }]
215
+ }]
216
+ });
251
217
  function provideConfigurationStore(reducerFactory) {
252
- return makeEnvironmentProviders([
253
- provideState(CONFIGURATION_STORE_NAME, reducerFactory ? reducerFactory() : configurationReducer)
254
- ]);
218
+ return makeEnvironmentProviders([provideState(CONFIGURATION_STORE_NAME, reducerFactory ? reducerFactory() : configurationReducer)]);
255
219
  }
256
-
257
220
  const { selectIds, selectEntities, selectAll, selectTotal } = configurationAdapter.getSelectors();
258
- /**
259
- * Select Configuration State
260
- * Note: the usage of createSelector is to avoid warning printing because of potentially undefined feature store
261
- */
262
221
  const selectConfigurationState = createSelector((state) => state[CONFIGURATION_STORE_NAME], (state) => state);
263
- /** Select the array of Configuration ids */
264
222
  const selectConfigurationIds = createSelector(selectConfigurationState, (state) => state ? selectIds(state) : []);
265
- /** Select the array of Configuration */
266
223
  const selectAllConfiguration = createSelector(selectConfigurationState, (state) => state ? selectAll(state) : []);
267
- /** Select the dictionary of Configuration entities */
268
224
  const selectConfigurationEntities = createSelector(selectConfigurationState, (state) => state ? selectEntities(state) : {});
269
- /** Select the total Configuration count */
270
225
  const selectConfigurationTotal = createSelector(selectConfigurationState, (state) => state ? selectTotal(state) : 0);
271
- /**
272
- * Select the configuration for component with id
273
- * @param props property of the selector
274
- * @param props.id id of the component
275
- */
276
- const selectConfigurationForComponent = (props) => createSelector(selectConfigurationEntities, (entities) => (entities?.[props.id] || {}));
277
- /**
278
- * Select the global configuration
279
- */
226
+ const selectConfigurationForComponent = (props) => createSelector(selectConfigurationEntities, (entities) => entities?.[props.id] || {});
280
227
  const selectGlobalConfiguration = createSelector(selectConfigurationForComponent({ id: globalConfigurationId }), (config) => config);
281
-
282
- const configurationStorageSync = {
283
- deserialize: (rawObject) => {
284
- if (!rawObject || !rawObject.ids) {
285
- return configurationInitialState;
286
- }
287
- return configurationAdapter.getInitialState(rawObject);
288
- }
289
- };
290
-
228
+ const configurationStorageSync = { deserialize: (rawObject) => {
229
+ if (!rawObject || !rawObject.ids) return configurationInitialState;
230
+ return configurationAdapter.getInitialState(rawObject);
231
+ } };
291
232
  const OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS = {
292
- defaultLibraryName: '@o3r/components',
293
- defaultJsonFilename: 'partial-static-config.json',
294
- isActivatedOnBootstrap: false,
295
- isActivatedOnBootstrapWhenCMSContext: true
233
+ defaultLibraryName: "@o3r/components",
234
+ defaultJsonFilename: "partial-static-config.json",
235
+ isActivatedOnBootstrap: false,
236
+ isActivatedOnBootstrapWhenCMSContext: true
296
237
  };
297
- const OTTER_CONFIGURATION_DEVTOOLS_OPTIONS = new InjectionToken('Otter Configuration Devtools options');
298
-
299
- class OtterConfigurationDevtools {
300
- constructor() {
301
- this.store = inject(Store);
302
- this.appRef = inject(ApplicationRef);
303
- this.options = inject(OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, { optional: true }) ?? OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS;
304
- const options = this.options;
305
- this.options = { ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, ...options };
306
- /** Full configuration store */
307
- this.configurationEntities$ = this.store.pipe(select(selectConfigurationEntities), map((entities) => Object.values(entities)
308
- .filter((entity) => !!entity)
309
- .map((entity) => {
310
- const { id, ...config } = entity;
311
- const { library = this.options.defaultLibraryName, componentName: name = id } = parseConfigurationName(id) || {};
312
- return { name, config, library };
313
- })), shareReplay(1));
314
- }
315
- /**
316
- * Get configuration name based on input information
317
- * @param selector Selector for a component configuration. It can be a string in the form library#componentName (i.e: `@my-lib/shared-components#HeaderContComponent`)
318
- * or an object with the component and library names (i.e: `{library:"@my-lib/shared-components", componentName:'HeaderContComponent'}`)
319
- * @param isFallbackName Determine if the name requested is a fallback name
320
- * @returns string in the format library#componentName (i.e: `"@my-lib/shared-components#HeaderContComponent"`)
321
- */
322
- getComponentConfigName(selector, isFallbackName = false) {
323
- if (!isFallbackName) {
324
- return typeof selector === 'string' ? selector : computeItemIdentifier(selector.componentName, selector.library || this.options.defaultLibraryName);
325
- }
326
- return typeof selector === 'string'
327
- ? computeItemIdentifier(selector, this.options.defaultLibraryName || 'global')
328
- : computeItemIdentifier(selector.componentName, this.options.defaultLibraryName || 'global');
329
- }
330
- /**
331
- * Get the list of components which have a configuration loaded in the store
332
- */
333
- getComponentsWithConfiguration() {
334
- return firstValueFrom(this.store
335
- .pipe(select(selectConfigurationIds), map((ids) => ids
336
- .map((configName) => parseConfigurationName(configName.toString()))
337
- .filter((parsedName) => !!parsedName)
338
- .map((parsedName) => parsedName.componentName + (parsedName.library ? ' from ' + parsedName.library : '')))));
339
- }
340
- /**
341
- * Set a specified value of a component configuration
342
- * @param selector Selector for a component configuration
343
- * @param configProperty Name of the configuration property to set
344
- * @param configValue Value of the configuration property to set
345
- */
346
- setDynamicConfig(selector, configProperty, configValue) {
347
- this.store.dispatch(upsertConfigurationEntity({
348
- id: this.getComponentConfigName(selector),
349
- configuration: { [configProperty]: configValue }
350
- }));
351
- this.appRef.tick();
352
- }
353
- /**
354
- * Get the configuration for a specific component
355
- * @param selector Selector for a component configuration. It can be a string in the form library#configurationName (i.e: `@my-lib/shared-components#HeaderPresConfig`)
356
- * or an object with the configuration and library names (i.e: `{library:"@my-lib/shared-components", componentName:'HeaderPresConfig'}`)
357
- */
358
- getCurrentConfigurationFor(selector) {
359
- return firstValueFrom(this.store.pipe(select(selectConfigurationEntities), map((entities) => entities[this.getComponentConfigName(selector)] || entities[this.getComponentConfigName(selector, true)]), filter((entity) => !!entity), map((entity) => {
360
- const { id, ...configuration } = entity;
361
- return configuration;
362
- })));
363
- }
364
- /**
365
- * Get the whole configuration of the application
366
- */
367
- getConfiguration() {
368
- return firstValueFrom(this.configurationEntities$);
369
- }
370
- /**
371
- * Load a json configuration
372
- * @param configurations configurations to load
373
- */
374
- loadConfiguration(configurations) {
375
- this.store.dispatch(upsertConfigurationEntities(computeConfiguration(typeof configurations === 'string' ? JSON.parse(configurations) : configurations)));
376
- this.appRef.tick();
377
- }
378
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: OtterConfigurationDevtools, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
379
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: OtterConfigurationDevtools, providedIn: 'root' }); }
380
- }
381
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: OtterConfigurationDevtools, decorators: [{
382
- type: Injectable,
383
- args: [{ providedIn: 'root' }]
384
- }], ctorParameters: () => [] });
385
-
386
- /* eslint-disable no-console -- service to log message in the console */
387
- class ConfigurationDevtoolsConsoleService {
388
- /** Name of the Window property to access to the devtools */
389
- static { this.windowModuleName = 'configuration'; }
390
- constructor() {
391
- this.configurationDevtools = inject(OtterConfigurationDevtools);
392
- this.options = inject(OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, { optional: true }) ?? OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS;
393
- const options = this.options;
394
- this.options = { ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, ...options };
395
- if (this.options.isActivatedOnBootstrap
396
- || (this.options.isActivatedOnBootstrapWhenCMSContext
397
- && document.body.dataset.cmscontext === 'true')) {
398
- this.activate();
399
- }
400
- }
401
- downloadJSON(content, fileName = this.options.defaultJsonFilename) {
402
- const a = document.createElement('a');
403
- const file = new Blob([content], { type: 'text/plain' });
404
- a.href = URL.createObjectURL(file);
405
- a.download = fileName;
406
- a.click();
407
- }
408
- copyElementToClipboard(content) {
409
- const input = document.createElement('textarea');
410
- input.value = content;
411
- document.body.append(input);
412
- input.select();
413
- document.execCommand('copy');
414
- input.remove();
415
- }
416
- /**
417
- * Set a specified value of a component configuration
418
- * @param selector Selector for a component configuration
419
- * @param configProperty Name of the configuration property to set
420
- * @param configValue Value of the configuration property to set
421
- */
422
- setDynamicConfig(selector, configProperty, configValue) {
423
- this.configurationDevtools.setDynamicConfig(selector, configProperty, configValue);
424
- }
425
- /** @inheritDoc */
426
- activate() {
427
- const windowWithDevtools = window;
428
- windowWithDevtools._OTTER_DEVTOOLS_ ||= {};
429
- windowWithDevtools._OTTER_DEVTOOLS_[ConfigurationDevtoolsConsoleService.windowModuleName] = this;
430
- console.info(`Otter Configuration Devtools is now accessible via the _OTTER_DEVTOOLS_.${ConfigurationDevtoolsConsoleService.windowModuleName} variable`);
431
- }
432
- /**
433
- * Display the list of configurations loaded in the store and the library they originate from
434
- * @returns array with the configurations and libraries for example: `["LibComponentsCommonRuntimeConfig from \@my-lib/shared-common"]`
435
- */
436
- async displayComponentsWithConfiguration() {
437
- const selectors = await this.configurationDevtools.getComponentsWithConfiguration();
438
- console.log(selectors);
439
- }
440
- /**
441
- * Display the configuration for a specific component
442
- * @param selector Selector for a component configuration. It can be a string in the form library#configurationName (i.e: '@my-lib/shared-components#HeaderContConfig')
443
- * or an object with the configuration and library names (i.e: `{library:"@my-lib/shared-components", componentName:'HeaderContConfig'}`).
444
- * Note the object input componentName expects a configuration name not a component name.
445
- * @returns Configuration object (i.e: {airlineLogoPath: "img/airlines/icon-BH.svg", displayLanguageSelector: false})
446
- */
447
- async displayCurrentConfigurationFor(selector) {
448
- const configuration = await this.configurationDevtools.getCurrentConfigurationFor(selector);
449
- console.log(configuration);
450
- }
451
- /**
452
- * Download the JSON file of the whole configuration
453
- * @param fileName Name of the file to download
454
- */
455
- async saveConfiguration(fileName = this.options.defaultJsonFilename) {
456
- const configs = await firstValueFrom(this.configurationDevtools.configurationEntities$);
457
- this.downloadJSON(JSON.stringify(configs), fileName);
458
- }
459
- /**
460
- * Display the whole configuration of the application
461
- */
462
- async displayConfiguration() {
463
- const configs = await this.configurationDevtools.getConfiguration();
464
- console.log(configs);
465
- }
466
- /**
467
- * Display a bookmark to generate the current configuration
468
- */
469
- async displayConfigurationBookmark() {
470
- const content = await this.configurationDevtools.getConfiguration();
471
- console.log('BOOKMARK');
472
- console.log(`javascript:window._OTTER_DEVTOOLS_.updateConfigurations('${JSON.stringify(content).replace(/'/g, '\\\'')}')`);
473
- }
474
- /**
475
- * Copy the whole configuration to the clipboard
476
- */
477
- async copyConfigurationToClipboard() {
478
- const configs = await firstValueFrom(this.configurationDevtools.configurationEntities$);
479
- this.copyElementToClipboard(JSON.stringify(configs));
480
- }
481
- /**
482
- * Replace N configurations in one shot
483
- * @param configurations array of configurations to update
484
- */
485
- updateConfigurations(configurations) {
486
- this.configurationDevtools.loadConfiguration(configurations);
487
- }
488
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsConsoleService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
489
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsConsoleService, providedIn: 'root' }); }
490
- }
491
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsConsoleService, decorators: [{
492
- type: Injectable,
493
- args: [{
494
- providedIn: 'root'
495
- }]
496
- }], ctorParameters: () => [] });
497
-
498
- /**
499
- * Determine if the given message is a Configuration message
500
- * @param message message to check
501
- */
238
+ const OTTER_CONFIGURATION_DEVTOOLS_OPTIONS = new InjectionToken("Otter Configuration Devtools options");
239
+ var OtterConfigurationDevtools = class OtterConfigurationDevtools {
240
+ constructor() {
241
+ this.store = inject(Store);
242
+ this.appRef = inject(ApplicationRef);
243
+ this.options = inject(OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, { optional: true }) ?? OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS;
244
+ const options = this.options;
245
+ this.options = {
246
+ ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS,
247
+ ...options
248
+ };
249
+ this.configurationEntities$ = this.store.pipe(select(selectConfigurationEntities), map((entities) => Object.values(entities).filter((entity) => !!entity).map((entity) => {
250
+ const { id, ...config } = entity;
251
+ const { library = this.options.defaultLibraryName, componentName: name = id } = parseConfigurationName(id) || {};
252
+ return {
253
+ name,
254
+ config,
255
+ library
256
+ };
257
+ })), shareReplay(1));
258
+ }
259
+ getComponentConfigName(selector, isFallbackName = false) {
260
+ if (!isFallbackName) return typeof selector === "string" ? selector : computeItemIdentifier(selector.componentName, selector.library || this.options.defaultLibraryName);
261
+ return typeof selector === "string" ? computeItemIdentifier(selector, this.options.defaultLibraryName || "global") : computeItemIdentifier(selector.componentName, this.options.defaultLibraryName || "global");
262
+ }
263
+ getComponentsWithConfiguration() {
264
+ return firstValueFrom(this.store.pipe(select(selectConfigurationIds), map((ids) => ids.map((configName) => parseConfigurationName(configName.toString())).filter((parsedName) => !!parsedName).map((parsedName) => parsedName.componentName + (parsedName.library ? " from " + parsedName.library : "")))));
265
+ }
266
+ setDynamicConfig(selector, configProperty, configValue) {
267
+ this.store.dispatch(upsertConfigurationEntity({
268
+ id: this.getComponentConfigName(selector),
269
+ configuration: { [configProperty]: configValue }
270
+ }));
271
+ this.appRef.tick();
272
+ }
273
+ getCurrentConfigurationFor(selector) {
274
+ return firstValueFrom(this.store.pipe(select(selectConfigurationEntities), map((entities) => entities[this.getComponentConfigName(selector)] || entities[this.getComponentConfigName(selector, true)]), filter((entity) => !!entity), map((entity) => {
275
+ const { id, ...configuration } = entity;
276
+ return configuration;
277
+ })));
278
+ }
279
+ getConfiguration() {
280
+ return firstValueFrom(this.configurationEntities$);
281
+ }
282
+ loadConfiguration(configurations) {
283
+ this.store.dispatch(upsertConfigurationEntities(computeConfiguration(typeof configurations === "string" ? JSON.parse(configurations) : configurations)));
284
+ this.appRef.tick();
285
+ }
286
+ static {
287
+ this.ɵfac = i0.ɵɵngDeclareFactory({
288
+ minVersion: "12.0.0",
289
+ version: "22.2.3",
290
+ ngImport: i0,
291
+ type: OtterConfigurationDevtools,
292
+ deps: [],
293
+ target: i0.ɵɵFactoryTarget.Injectable
294
+ });
295
+ }
296
+ static {
297
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
298
+ minVersion: "12.0.0",
299
+ version: "22.2.3",
300
+ ngImport: i0,
301
+ type: OtterConfigurationDevtools,
302
+ providedIn: "root"
303
+ });
304
+ }
305
+ };
306
+ i0.ɵɵngDeclareClassMetadata({
307
+ minVersion: "12.0.0",
308
+ version: "22.2.3",
309
+ ngImport: i0,
310
+ type: OtterConfigurationDevtools,
311
+ decorators: [{
312
+ type: Injectable,
313
+ args: [{ providedIn: "root" }]
314
+ }],
315
+ ctorParameters: () => []
316
+ });
317
+ var ConfigurationDevtoolsConsoleService = class ConfigurationDevtoolsConsoleService {
318
+ static {
319
+ this.windowModuleName = "configuration";
320
+ }
321
+ constructor() {
322
+ this.configurationDevtools = inject(OtterConfigurationDevtools);
323
+ this.options = inject(OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, { optional: true }) ?? OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS;
324
+ const options = this.options;
325
+ this.options = {
326
+ ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS,
327
+ ...options
328
+ };
329
+ if (this.options.isActivatedOnBootstrap || this.options.isActivatedOnBootstrapWhenCMSContext && document.body.dataset.cmscontext === "true") this.activate();
330
+ }
331
+ downloadJSON(content, fileName = this.options.defaultJsonFilename) {
332
+ const a = document.createElement("a");
333
+ const file = new Blob([content], { type: "text/plain" });
334
+ a.href = URL.createObjectURL(file);
335
+ a.download = fileName;
336
+ a.click();
337
+ }
338
+ copyElementToClipboard(content) {
339
+ const input = document.createElement("textarea");
340
+ input.value = content;
341
+ document.body.append(input);
342
+ input.select();
343
+ document.execCommand("copy");
344
+ input.remove();
345
+ }
346
+ setDynamicConfig(selector, configProperty, configValue) {
347
+ this.configurationDevtools.setDynamicConfig(selector, configProperty, configValue);
348
+ }
349
+ activate() {
350
+ const windowWithDevtools = window;
351
+ windowWithDevtools._OTTER_DEVTOOLS_ ||= {};
352
+ windowWithDevtools._OTTER_DEVTOOLS_[ConfigurationDevtoolsConsoleService.windowModuleName] = this;
353
+ console.info(`Otter Configuration Devtools is now accessible via the _OTTER_DEVTOOLS_.${ConfigurationDevtoolsConsoleService.windowModuleName} variable`);
354
+ }
355
+ async displayComponentsWithConfiguration() {
356
+ const selectors = await this.configurationDevtools.getComponentsWithConfiguration();
357
+ console.log(selectors);
358
+ }
359
+ async displayCurrentConfigurationFor(selector) {
360
+ const configuration = await this.configurationDevtools.getCurrentConfigurationFor(selector);
361
+ console.log(configuration);
362
+ }
363
+ async saveConfiguration(fileName = this.options.defaultJsonFilename) {
364
+ const configs = await firstValueFrom(this.configurationDevtools.configurationEntities$);
365
+ this.downloadJSON(JSON.stringify(configs), fileName);
366
+ }
367
+ async displayConfiguration() {
368
+ const configs = await this.configurationDevtools.getConfiguration();
369
+ console.log(configs);
370
+ }
371
+ async displayConfigurationBookmark() {
372
+ const content = await this.configurationDevtools.getConfiguration();
373
+ console.log("BOOKMARK");
374
+ console.log(`javascript:window._OTTER_DEVTOOLS_.updateConfigurations('${JSON.stringify(content).replace(/'/g, "\\'")}')`);
375
+ }
376
+ async copyConfigurationToClipboard() {
377
+ const configs = await firstValueFrom(this.configurationDevtools.configurationEntities$);
378
+ this.copyElementToClipboard(JSON.stringify(configs));
379
+ }
380
+ updateConfigurations(configurations) {
381
+ this.configurationDevtools.loadConfiguration(configurations);
382
+ }
383
+ static {
384
+ this.ɵfac = i0.ɵɵngDeclareFactory({
385
+ minVersion: "12.0.0",
386
+ version: "22.2.3",
387
+ ngImport: i0,
388
+ type: ConfigurationDevtoolsConsoleService,
389
+ deps: [],
390
+ target: i0.ɵɵFactoryTarget.Injectable
391
+ });
392
+ }
393
+ static {
394
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
395
+ minVersion: "12.0.0",
396
+ version: "22.2.3",
397
+ ngImport: i0,
398
+ type: ConfigurationDevtoolsConsoleService,
399
+ providedIn: "root"
400
+ });
401
+ }
402
+ };
403
+ i0.ɵɵngDeclareClassMetadata({
404
+ minVersion: "12.0.0",
405
+ version: "22.2.3",
406
+ ngImport: i0,
407
+ type: ConfigurationDevtoolsConsoleService,
408
+ decorators: [{
409
+ type: Injectable,
410
+ args: [{ providedIn: "root" }]
411
+ }],
412
+ ctorParameters: () => []
413
+ });
502
414
  const isConfigurationMessage = (message) => {
503
- return message && (message.dataType === 'configurations'
504
- || message.dataType === 'updateConfig'
505
- || message.dataType === 'requestMessages'
506
- || message.dataType === 'connect');
415
+ return message && (message.dataType === "configurations" || message.dataType === "updateConfig" || message.dataType === "requestMessages" || message.dataType === "connect");
507
416
  };
508
-
509
- class ConfigurationDevtoolsMessageService {
510
- constructor() {
511
- this.store = inject(Store);
512
- this.logger = inject(LoggerService);
513
- this.configurationDevtools = inject(OtterConfigurationDevtools);
514
- this.options = inject(OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, { optional: true });
515
- this.sendMessage = (sendOtterMessage);
516
- this.destroyRef = inject(DestroyRef);
517
- const options = this.options;
518
- this.options = { ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, ...options };
519
- if (this.options.isActivatedOnBootstrap) {
520
- this.activate();
521
- }
522
- }
523
- async sendCurrentConfigurationState() {
524
- const configurations = await firstValueFrom(this.store.pipe(select(selectConfigurationEntities)));
525
- this.sendMessage('configurations', { configurations });
526
- }
527
- /**
528
- * Function to trigger a re-send a requested messages to the Otter Chrome DevTools extension
529
- * @param only restricted list of messages to re-send
530
- */
531
- handleReEmitRequest(only) {
532
- if (!only || only.includes('configurations')) {
533
- return this.sendCurrentConfigurationState();
534
- }
535
- }
536
- /**
537
- * Function to handle the incoming messages from Otter Chrome DevTools extension
538
- * @param message message coming from the Otter Chrome DevTools extension
539
- */
540
- async handleEvents(message) {
541
- this.logger.debug('Message handling by the configuration service', message);
542
- switch (message.dataType) {
543
- case 'connect': {
544
- await this.connectPlugin();
545
- break;
546
- }
547
- case 'requestMessages': {
548
- await this.handleReEmitRequest(message.only);
549
- break;
550
- }
551
- case 'updateConfig': {
552
- this.configurationDevtools.loadConfiguration([{
553
- name: message.id,
554
- config: message.configValue
555
- }]);
556
- break;
557
- }
558
- default: {
559
- this.logger.warn('Message ignored by the configuration service', message);
560
- }
561
- }
562
- }
563
- /**
564
- * Function to connect the plugin to the Otter DevTools extension
565
- */
566
- connectPlugin() {
567
- this.logger.debug('Otter DevTools is plugged to configuration service of the application');
568
- return this.sendCurrentConfigurationState();
569
- }
570
- /** @inheritDoc */
571
- activate() {
572
- fromEvent(window, 'message').pipe(takeUntilDestroyed(this.destroyRef), filterMessageContent(isConfigurationMessage)).subscribe((e) => this.handleEvents(e));
573
- this.store.pipe(select(selectConfigurationEntities), takeUntilDestroyed(this.destroyRef)).subscribe((configurations) => this.sendMessage('configurations', { configurations }));
574
- }
575
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsMessageService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
576
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsMessageService, providedIn: 'root' }); }
577
- }
578
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsMessageService, decorators: [{
579
- type: Injectable,
580
- args: [{
581
- providedIn: 'root'
582
- }]
583
- }], ctorParameters: () => [] });
584
-
585
- /**
586
- * @deprecated Will be removed in v16. Use {@link provideConfigurationDevtools} instead.
587
- */
588
- class ConfigurationDevtoolsModule {
589
- /**
590
- * Initialize Otter Devtools
591
- * @param options
592
- */
593
- static instrument(options) {
594
- return {
595
- ngModule: ConfigurationDevtoolsModule,
596
- providers: [
597
- { provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, useValue: { ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, ...options }, multi: false },
598
- ConfigurationDevtoolsMessageService,
599
- ConfigurationDevtoolsConsoleService,
600
- OtterConfigurationDevtools
601
- ]
602
- };
603
- }
604
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
605
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsModule, imports: [StoreModule,
606
- ConfigurationStoreModule] }); }
607
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsModule, providers: [
608
- { provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, useValue: OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS },
609
- ConfigurationDevtoolsMessageService,
610
- ConfigurationDevtoolsConsoleService,
611
- OtterConfigurationDevtools
612
- ], imports: [StoreModule,
613
- ConfigurationStoreModule] }); }
614
- }
615
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationDevtoolsModule, decorators: [{
616
- type: NgModule,
617
- args: [{
618
- imports: [
619
- StoreModule,
620
- ConfigurationStoreModule
621
- ],
622
- providers: [
623
- { provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, useValue: OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS },
624
- ConfigurationDevtoolsMessageService,
625
- ConfigurationDevtoolsConsoleService,
626
- OtterConfigurationDevtools
627
- ]
628
- }]
629
- }] });
630
- /**
631
- * Provide configuration devtools functionality.
632
- * @param options Configuration devtools options
633
- */
417
+ var ConfigurationDevtoolsMessageService = class ConfigurationDevtoolsMessageService {
418
+ constructor() {
419
+ this.store = inject(Store);
420
+ this.logger = inject(LoggerService);
421
+ this.configurationDevtools = inject(OtterConfigurationDevtools);
422
+ this.options = inject(OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, { optional: true });
423
+ this.sendMessage = sendOtterMessage;
424
+ this.destroyRef = inject(DestroyRef);
425
+ const options = this.options;
426
+ this.options = {
427
+ ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS,
428
+ ...options
429
+ };
430
+ if (this.options.isActivatedOnBootstrap) this.activate();
431
+ }
432
+ async sendCurrentConfigurationState() {
433
+ const configurations = await firstValueFrom(this.store.pipe(select(selectConfigurationEntities)));
434
+ this.sendMessage("configurations", { configurations });
435
+ }
436
+ handleReEmitRequest(only) {
437
+ if (!only || only.includes("configurations")) return this.sendCurrentConfigurationState();
438
+ }
439
+ async handleEvents(message) {
440
+ this.logger.debug("Message handling by the configuration service", message);
441
+ switch (message.dataType) {
442
+ case "connect":
443
+ await this.connectPlugin();
444
+ break;
445
+ case "requestMessages":
446
+ await this.handleReEmitRequest(message.only);
447
+ break;
448
+ case "updateConfig":
449
+ this.configurationDevtools.loadConfiguration([{
450
+ name: message.id,
451
+ config: message.configValue
452
+ }]);
453
+ break;
454
+ default: this.logger.warn("Message ignored by the configuration service", message);
455
+ }
456
+ }
457
+ connectPlugin() {
458
+ this.logger.debug("Otter DevTools is plugged to configuration service of the application");
459
+ return this.sendCurrentConfigurationState();
460
+ }
461
+ activate() {
462
+ fromEvent(window, "message").pipe(takeUntilDestroyed(this.destroyRef), filterMessageContent(isConfigurationMessage)).subscribe((e) => this.handleEvents(e));
463
+ this.store.pipe(select(selectConfigurationEntities), takeUntilDestroyed(this.destroyRef)).subscribe((configurations) => this.sendMessage("configurations", { configurations }));
464
+ }
465
+ static {
466
+ this.ɵfac = i0.ɵɵngDeclareFactory({
467
+ minVersion: "12.0.0",
468
+ version: "22.2.3",
469
+ ngImport: i0,
470
+ type: ConfigurationDevtoolsMessageService,
471
+ deps: [],
472
+ target: i0.ɵɵFactoryTarget.Injectable
473
+ });
474
+ }
475
+ static {
476
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
477
+ minVersion: "12.0.0",
478
+ version: "22.2.3",
479
+ ngImport: i0,
480
+ type: ConfigurationDevtoolsMessageService,
481
+ providedIn: "root"
482
+ });
483
+ }
484
+ };
485
+ i0.ɵɵngDeclareClassMetadata({
486
+ minVersion: "12.0.0",
487
+ version: "22.2.3",
488
+ ngImport: i0,
489
+ type: ConfigurationDevtoolsMessageService,
490
+ decorators: [{
491
+ type: Injectable,
492
+ args: [{ providedIn: "root" }]
493
+ }],
494
+ ctorParameters: () => []
495
+ });
496
+ var ConfigurationDevtoolsModule = class ConfigurationDevtoolsModule {
497
+ static instrument(options) {
498
+ return {
499
+ ngModule: ConfigurationDevtoolsModule,
500
+ providers: [
501
+ {
502
+ provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS,
503
+ useValue: {
504
+ ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS,
505
+ ...options
506
+ },
507
+ multi: false
508
+ },
509
+ ConfigurationDevtoolsMessageService,
510
+ ConfigurationDevtoolsConsoleService,
511
+ OtterConfigurationDevtools
512
+ ]
513
+ };
514
+ }
515
+ static {
516
+ this.ɵfac = i0.ɵɵngDeclareFactory({
517
+ minVersion: "12.0.0",
518
+ version: "22.2.3",
519
+ ngImport: i0,
520
+ type: ConfigurationDevtoolsModule,
521
+ deps: [],
522
+ target: i0.ɵɵFactoryTarget.NgModule
523
+ });
524
+ }
525
+ static {
526
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
527
+ minVersion: "14.0.0",
528
+ version: "22.2.3",
529
+ ngImport: i0,
530
+ type: ConfigurationDevtoolsModule,
531
+ imports: [StoreModule, ConfigurationStoreModule]
532
+ });
533
+ }
534
+ static {
535
+ this.ɵinj = i0.ɵɵngDeclareInjector({
536
+ minVersion: "12.0.0",
537
+ version: "22.2.3",
538
+ ngImport: i0,
539
+ type: ConfigurationDevtoolsModule,
540
+ providers: [
541
+ {
542
+ provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS,
543
+ useValue: OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS
544
+ },
545
+ ConfigurationDevtoolsMessageService,
546
+ ConfigurationDevtoolsConsoleService,
547
+ OtterConfigurationDevtools
548
+ ],
549
+ imports: [StoreModule, ConfigurationStoreModule]
550
+ });
551
+ }
552
+ };
553
+ i0.ɵɵngDeclareClassMetadata({
554
+ minVersion: "12.0.0",
555
+ version: "22.2.3",
556
+ ngImport: i0,
557
+ type: ConfigurationDevtoolsModule,
558
+ decorators: [{
559
+ type: NgModule,
560
+ args: [{
561
+ imports: [StoreModule, ConfigurationStoreModule],
562
+ providers: [
563
+ {
564
+ provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS,
565
+ useValue: OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS
566
+ },
567
+ ConfigurationDevtoolsMessageService,
568
+ ConfigurationDevtoolsConsoleService,
569
+ OtterConfigurationDevtools
570
+ ]
571
+ }]
572
+ }]
573
+ });
634
574
  function provideConfigurationDevtools(options) {
635
- return makeEnvironmentProviders([
636
- provideConfigurationStore(),
637
- { provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, useValue: { ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, ...options } },
638
- ConfigurationDevtoolsMessageService,
639
- ConfigurationDevtoolsConsoleService,
640
- OtterConfigurationDevtools
641
- ]);
642
- }
643
-
644
- /**
645
- * @deprecated Will be removed in v16. Use {@link import('@o3r/configuration').provideConfigurationStore} instead.
646
- */
647
- class ConfigurationBaseServiceModule {
648
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationBaseServiceModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
649
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationBaseServiceModule, imports: [ConfigurationStoreModule] }); }
650
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationBaseServiceModule, imports: [ConfigurationStoreModule] }); }
575
+ return makeEnvironmentProviders([
576
+ provideConfigurationStore(),
577
+ {
578
+ provide: OTTER_CONFIGURATION_DEVTOOLS_OPTIONS,
579
+ useValue: {
580
+ ...OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS,
581
+ ...options
582
+ }
583
+ },
584
+ ConfigurationDevtoolsMessageService,
585
+ ConfigurationDevtoolsConsoleService,
586
+ OtterConfigurationDevtools
587
+ ]);
651
588
  }
652
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationBaseServiceModule, decorators: [{
653
- type: NgModule,
654
- args: [{
655
- imports: [ConfigurationStoreModule]
656
- }]
657
- }] });
658
-
589
+ var ConfigurationBaseServiceModule = class ConfigurationBaseServiceModule {
590
+ static {
591
+ this.ɵfac = i0.ɵɵngDeclareFactory({
592
+ minVersion: "12.0.0",
593
+ version: "22.2.3",
594
+ ngImport: i0,
595
+ type: ConfigurationBaseServiceModule,
596
+ deps: [],
597
+ target: i0.ɵɵFactoryTarget.NgModule
598
+ });
599
+ }
600
+ static {
601
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
602
+ minVersion: "14.0.0",
603
+ version: "22.2.3",
604
+ ngImport: i0,
605
+ type: ConfigurationBaseServiceModule,
606
+ imports: [ConfigurationStoreModule]
607
+ });
608
+ }
609
+ static {
610
+ this.ɵinj = i0.ɵɵngDeclareInjector({
611
+ minVersion: "12.0.0",
612
+ version: "22.2.3",
613
+ ngImport: i0,
614
+ type: ConfigurationBaseServiceModule,
615
+ imports: [ConfigurationStoreModule]
616
+ });
617
+ }
618
+ };
619
+ i0.ɵɵngDeclareClassMetadata({
620
+ minVersion: "12.0.0",
621
+ version: "22.2.3",
622
+ ngImport: i0,
623
+ type: ConfigurationBaseServiceModule,
624
+ decorators: [{
625
+ type: NgModule,
626
+ args: [{ imports: [ConfigurationStoreModule] }]
627
+ }]
628
+ });
659
629
  const jsonStringifyDiff = (obj1, obj2) => JSON.stringify(obj1) === JSON.stringify(obj2);
660
- /**
661
- * Configuration service
662
- */
663
- class ConfigurationBaseService {
664
- constructor() {
665
- this.store = inject(Store);
666
- this.extendedConfiguration = {};
667
- }
668
- /**
669
- * Update a specific component config or add it to the store if does not exist
670
- * @param configuration to edit/add
671
- * @param configurationId Configuration ID
672
- */
673
- upsertConfiguration(configuration, configurationId = globalConfigurationId) {
674
- this.store.dispatch(upsertConfigurationEntity({ id: configurationId, configuration }));
675
- }
676
- /**
677
- * Update a specific component config
678
- * @param configuration Partial config to edit
679
- * @param configurationId Configuration ID
680
- */
681
- updateConfiguration(configuration, configurationId = globalConfigurationId) {
682
- this.store.dispatch(updateConfigurationEntity({ id: configurationId, configuration }));
683
- }
684
- /**
685
- * This function will get the configuration stored in the data attribute of the html's body tag
686
- * @param configTagName Value used to identify the data attribute where the config is pushed in the index.html
687
- */
688
- getConfigFromBodyTag(configTagName = 'staticconfig') {
689
- const bootstrapConfigString = document.body.dataset[configTagName];
690
- const customConfigObject = bootstrapConfigString ? JSON.parse(bootstrapConfigString) : [];
691
- if (customConfigObject.length > 0) {
692
- this.computeConfiguration(customConfigObject);
693
- }
694
- }
695
- /**
696
- * Transform the custom configuration in store configuration model
697
- * @param customConfigObject Configuration object (extracted from body tag for static config or downloaded in case of dynamic config)
698
- */
699
- computeConfiguration(customConfigObject) {
700
- this.store.dispatch(upsertConfigurationEntities(computeConfiguration(customConfigObject)));
701
- }
702
- /**
703
- * Complete a stored configuration by adding the missing fields
704
- * @param extension Configuration extension to be included in the store
705
- * @param configurationId Configuration ID to extend
706
- * @param forceUpdate Force update the configuration in the store
707
- */
708
- extendConfiguration(extension, configurationId = globalConfigurationId, forceUpdate = false) {
709
- if (this.extendedConfiguration[configurationId] && !forceUpdate) {
710
- return;
711
- }
712
- this.extendedConfiguration[configurationId] = true;
713
- this.store.pipe(select(selectConfigurationEntities), take(1), map((storedConfigs) => configurationId in storedConfigs ? deepFill(extension, storedConfigs[configurationId]) : extension)).subscribe((extendedConfig) => this.upsertConfiguration(extendedConfig, configurationId));
714
- }
715
- /**
716
- * Operator to get the configuration from store for a given component and merge it with the global config
717
- * @param id Id of the component
718
- * @param defaultValue Default value of the configuration
719
- */
720
- getComponentConfig(id, defaultValue) {
721
- return (source) => {
722
- const componentConfigurationFromStore$ = this.getConfig(id);
723
- return source.pipe(switchMap((overrideConfig) => componentConfigurationFromStore$.pipe(map((componentConfigurationFromStore) => {
724
- const config = componentConfigurationFromStore ? deepFill(defaultValue, componentConfigurationFromStore) : defaultValue;
725
- return overrideConfig ? deepFill(config, overrideConfig) : config;
726
- }))));
727
- };
728
- }
729
- /**
730
- * Get an observable of the configuration from store for a given component and merge it with the global config + the config overrides from the rules engine
731
- * @param id Id of the component
732
- */
733
- getConfig(id) {
734
- const globalConfig$ = this.store.pipe(select(selectGlobalConfiguration));
735
- const componentConfig$ = id === globalConfigurationId ? of({}) : this.store.pipe(select(selectConfigurationForComponent({ id })));
736
- const overrideConfig$ = this.store.pipe(select(selectComponentOverrideConfig(id)));
737
- return combineLatest([globalConfig$, componentConfig$, overrideConfig$]).pipe(map(([globalConfig, componentConfig, overrideConfig]) => ({ ...globalConfig, ...componentConfig, ...overrideConfig })), distinctUntilChanged(jsonStringifyDiff));
738
- }
739
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationBaseService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
740
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationBaseService, providedIn: ConfigurationBaseServiceModule }); }
741
- }
742
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ConfigurationBaseService, decorators: [{
743
- type: Injectable,
744
- args: [{
745
- providedIn: ConfigurationBaseServiceModule
746
- }]
747
- }] });
748
-
630
+ var ConfigurationBaseService = class ConfigurationBaseService {
631
+ constructor() {
632
+ this.store = inject(Store);
633
+ this.extendedConfiguration = {};
634
+ }
635
+ upsertConfiguration(configuration, configurationId = globalConfigurationId) {
636
+ this.store.dispatch(upsertConfigurationEntity({
637
+ id: configurationId,
638
+ configuration
639
+ }));
640
+ }
641
+ updateConfiguration(configuration, configurationId = globalConfigurationId) {
642
+ this.store.dispatch(updateConfigurationEntity({
643
+ id: configurationId,
644
+ configuration
645
+ }));
646
+ }
647
+ getConfigFromBodyTag(configTagName = "staticconfig") {
648
+ const bootstrapConfigString = document.body.dataset[configTagName];
649
+ const customConfigObject = bootstrapConfigString ? JSON.parse(bootstrapConfigString) : [];
650
+ if (customConfigObject.length > 0) this.computeConfiguration(customConfigObject);
651
+ }
652
+ computeConfiguration(customConfigObject) {
653
+ this.store.dispatch(upsertConfigurationEntities(computeConfiguration(customConfigObject)));
654
+ }
655
+ extendConfiguration(extension, configurationId = globalConfigurationId, forceUpdate = false) {
656
+ if (this.extendedConfiguration[configurationId] && !forceUpdate) return;
657
+ this.extendedConfiguration[configurationId] = true;
658
+ this.store.pipe(select(selectConfigurationEntities), take(1), map((storedConfigs) => configurationId in storedConfigs ? deepFill(extension, storedConfigs[configurationId]) : extension)).subscribe((extendedConfig) => this.upsertConfiguration(extendedConfig, configurationId));
659
+ }
660
+ getComponentConfig(id, defaultValue) {
661
+ return (source) => {
662
+ const componentConfigurationFromStore$ = this.getConfig(id);
663
+ return source.pipe(switchMap((overrideConfig) => componentConfigurationFromStore$.pipe(map((componentConfigurationFromStore) => {
664
+ const config = componentConfigurationFromStore ? deepFill(defaultValue, componentConfigurationFromStore) : defaultValue;
665
+ return overrideConfig ? deepFill(config, overrideConfig) : config;
666
+ }))));
667
+ };
668
+ }
669
+ getConfig(id) {
670
+ const globalConfig$ = this.store.pipe(select(selectGlobalConfiguration));
671
+ const componentConfig$ = id === "global" ? of({}) : this.store.pipe(select(selectConfigurationForComponent({ id })));
672
+ const overrideConfig$ = this.store.pipe(select(selectComponentOverrideConfig(id)));
673
+ return combineLatest([
674
+ globalConfig$,
675
+ componentConfig$,
676
+ overrideConfig$
677
+ ]).pipe(map(([globalConfig, componentConfig, overrideConfig]) => ({
678
+ ...globalConfig,
679
+ ...componentConfig,
680
+ ...overrideConfig
681
+ })), distinctUntilChanged(jsonStringifyDiff));
682
+ }
683
+ static {
684
+ this.ɵfac = i0.ɵɵngDeclareFactory({
685
+ minVersion: "12.0.0",
686
+ version: "22.2.3",
687
+ ngImport: i0,
688
+ type: ConfigurationBaseService,
689
+ deps: [],
690
+ target: i0.ɵɵFactoryTarget.Injectable
691
+ });
692
+ }
693
+ static {
694
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
695
+ minVersion: "12.0.0",
696
+ version: "22.2.3",
697
+ ngImport: i0,
698
+ type: ConfigurationBaseService,
699
+ providedIn: ConfigurationBaseServiceModule
700
+ });
701
+ }
702
+ };
703
+ i0.ɵɵngDeclareClassMetadata({
704
+ minVersion: "12.0.0",
705
+ version: "22.2.3",
706
+ ngImport: i0,
707
+ type: ConfigurationBaseService,
708
+ decorators: [{
709
+ type: Injectable,
710
+ args: [{ providedIn: ConfigurationBaseServiceModule }]
711
+ }]
712
+ });
749
713
  const decorator = (target, key) => {
750
- const privateField = `_${key}`;
751
- if (delete target[key]) {
752
- Object.defineProperty(target, key, {
753
- get: function () {
754
- return this[privateField];
755
- },
756
- set: function (value) {
757
- this[privateField] = value;
758
- if (this[otterComponentInfoPropertyName]) {
759
- this[otterComponentInfoPropertyName].configId = this[privateField].configId;
760
- }
761
- },
762
- enumerable: true,
763
- configurable: true
764
- });
765
- }
714
+ const privateField = `_${key}`;
715
+ if (delete target[key]) Object.defineProperty(target, key, {
716
+ get: function() {
717
+ return this[privateField];
718
+ },
719
+ set: function(value) {
720
+ this[privateField] = value;
721
+ if (this[otterComponentInfoPropertyName]) this[otterComponentInfoPropertyName].configId = this[privateField].configId;
722
+ },
723
+ enumerable: true,
724
+ configurable: true
725
+ });
766
726
  };
767
- /**
768
- * Decorator to identify the component's configuration
769
- */
770
- // eslint-disable-next-line @typescript-eslint/naming-convention -- decorator should be PascalCase
771
727
  function O3rConfig() {
772
- return decorator;
728
+ return decorator;
773
729
  }
774
-
775
- class ConfigurationObserver {
776
- constructor(
777
- /** Configuration ID */
778
- configId, defaultConfig, configurationService) {
779
- this.configId = configId;
780
- /** Inner subscriber */
781
- this.subscriber = new BehaviorSubject({});
782
- if (configurationService) {
783
- configurationService.extendConfiguration(defaultConfig, configId);
784
- }
785
- this.observable = this.subscriber
786
- .pipe(configurationService ? configurationService.getComponentConfig(configId, defaultConfig) : getConfiguration(defaultConfig), shareReplay({ refCount: true, bufferSize: 1 }));
787
- }
788
- /** @inheritdoc */
789
- next(value) {
790
- this.subscriber.next(value || {});
791
- }
792
- /** @inheritdoc */
793
- error(err) {
794
- this.subscriber.error(err);
795
- this.closed = true;
796
- }
797
- /** @inheritdoc */
798
- complete() {
799
- this.subscriber.complete();
800
- this.closed = true;
801
- }
802
- /**
803
- * @inheritdoc
804
- */
805
- asObservable() {
806
- return this.observable;
807
- }
808
- }
809
-
810
- /**
811
- * Get a configuration signal
812
- * @param configInput
813
- * @param configId
814
- * @param defaultConfig
815
- */
730
+ var ConfigurationObserver = class {
731
+ constructor(configId, defaultConfig, configurationService) {
732
+ this.configId = configId;
733
+ this.subscriber = new BehaviorSubject({});
734
+ if (configurationService) configurationService.extendConfiguration(defaultConfig, configId);
735
+ this.observable = this.subscriber.pipe(configurationService ? configurationService.getComponentConfig(configId, defaultConfig) : getConfiguration(defaultConfig), shareReplay({
736
+ refCount: true,
737
+ bufferSize: 1
738
+ }));
739
+ }
740
+ next(value) {
741
+ this.subscriber.next(value || {});
742
+ }
743
+ error(err) {
744
+ this.subscriber.error(err);
745
+ this.closed = true;
746
+ }
747
+ complete() {
748
+ this.subscriber.complete();
749
+ this.closed = true;
750
+ }
751
+ asObservable() {
752
+ return this.observable;
753
+ }
754
+ };
816
755
  function configSignal(configInput, configId, defaultConfig) {
817
- const configurationService = inject(ConfigurationBaseService, { optional: true });
818
- if (configurationService) {
819
- configurationService.extendConfiguration(defaultConfig, configId);
820
- }
821
- const signal = toSignal(toObservable(configInput).pipe(configurationService ? configurationService.getComponentConfig(configId, defaultConfig) : getConfiguration(defaultConfig), shareReplay$1({ bufferSize: 1, refCount: true })), { initialValue: defaultConfig });
822
- signal.configId = configId;
823
- return signal;
756
+ const configurationService = inject(ConfigurationBaseService, { optional: true });
757
+ if (configurationService) configurationService.extendConfiguration(defaultConfig, configId);
758
+ const signal = toSignal(toObservable(configInput).pipe(configurationService ? configurationService.getComponentConfig(configId, defaultConfig) : getConfiguration(defaultConfig), shareReplay$1({
759
+ bufferSize: 1,
760
+ refCount: true
761
+ })), { initialValue: defaultConfig });
762
+ signal.configId = configId;
763
+ return signal;
824
764
  }
825
-
826
- /**
827
- * Generated bundle index. Do not edit.
828
- */
829
-
830
765
  export { CONFIGURATION_REDUCER_TOKEN, CONFIGURATION_STORE_NAME, CONFIG_OVERRIDE_REDUCER_TOKEN, CONFIG_OVERRIDE_STORE_NAME, ConfigOverrideStoreModule, ConfigurationBaseService, ConfigurationBaseServiceModule, ConfigurationDevtoolsConsoleService, ConfigurationDevtoolsMessageService, ConfigurationDevtoolsModule, ConfigurationObserver, ConfigurationStoreModule, O3rConfig, OTTER_CONFIGURATION_DEVTOOLS_DEFAULT_OPTIONS, OTTER_CONFIGURATION_DEVTOOLS_OPTIONS, OtterConfigurationDevtools, clearConfigurationEntities, computeConfiguration, configOverrideInitialState, configOverrideReducer, configOverrideReducerFeatures, configOverrideStorageDeserializer, configOverrideStorageSync, configSignal, configurationAdapter, configurationInitialState, configurationReducer, configurationReducerFeatures, configurationStorageSync, getConfiguration, getDefaultConfigOverrideReducer, getDefaultConfigurationReducer, globalConfigurationId, isConfigurationMessage, parseConfigurationName, provideConfigOverrideStore, provideConfigurationDevtools, provideConfigurationStore, selectAllConfiguration, selectComponentOverrideConfig, selectConfigOverride, selectConfigOverrideState, selectConfigurationEntities, selectConfigurationForComponent, selectConfigurationIds, selectConfigurationState, selectConfigurationTotal, selectGlobalConfiguration, setConfigOverride, setConfigurationEntities, updateConfigurationEntities, updateConfigurationEntity, upsertConfigurationEntities, upsertConfigurationEntity };
831
- //# sourceMappingURL=o3r-configuration.mjs.map
766
+
767
+ //# sourceMappingURL=o3r-configuration.mjs.map