@o3r/components 10.3.0-prerelease.39 → 10.3.0-prerelease.40
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.
- package/devkit/components-devkit.interface.d.ts +9 -1
- package/devkit/components-devkit.interface.d.ts.map +1 -1
- package/devkit/components-devtools.message.service.d.ts +5 -2
- package/devkit/components-devtools.message.service.d.ts.map +1 -1
- package/devkit/components-devtools.module.d.ts +2 -1
- package/devkit/components-devtools.module.d.ts.map +1 -1
- package/esm2022/devkit/components-devkit.interface.mjs +2 -1
- package/esm2022/devkit/components-devtools.message.service.mjs +12 -4
- package/esm2022/devkit/components-devtools.module.mjs +8 -4
- package/esm2022/rules-engine/placeholder.action-handler.mjs +1 -1
- package/esm2022/stores/placeholder-template/placeholder-template.actions.mjs +3 -1
- package/esm2022/stores/placeholder-template/placeholder-template.reducer.mjs +10 -2
- package/esm2022/stores/placeholder-template/placeholder-template.selectors.mjs +2 -1
- package/esm2022/stores/placeholder-template/placeholder-template.state.mjs +1 -1
- package/esm2022/tools/placeholder/placeholder.component.mjs +9 -11
- package/esm2022/tools/placeholder/placeholder.module.mjs +1 -1
- package/fesm2022/o3r-components-rules-engine.mjs.map +1 -1
- package/fesm2022/o3r-components.mjs +369 -351
- package/fesm2022/o3r-components.mjs.map +1 -1
- package/package.json +11 -11
- package/rules-engine/placeholder.action-handler.d.ts.map +1 -1
- package/stores/placeholder-template/placeholder-template.actions.d.ts +6 -1
- package/stores/placeholder-template/placeholder-template.actions.d.ts.map +1 -1
- package/stores/placeholder-template/placeholder-template.reducer.d.ts.map +1 -1
- package/stores/placeholder-template/placeholder-template.selectors.d.ts +1 -0
- package/stores/placeholder-template/placeholder-template.selectors.d.ts.map +1 -1
- package/stores/placeholder-template/placeholder-template.state.d.ts +3 -0
- package/stores/placeholder-template/placeholder-template.state.d.ts.map +1 -1
- package/tools/placeholder/placeholder.component.d.ts +5 -3
- package/tools/placeholder/placeholder.component.d.ts.map +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { of, from, observeOn, animationFrameScheduler, BehaviorSubject, Subscription, firstValueFrom, fromEvent, Subject, ReplaySubject, sample } from 'rxjs';
|
|
2
2
|
import { mergeMap, bufferCount, concatMap, delay, scan, tap, filter, distinctUntilChanged, map, mapTo, switchMap } from 'rxjs/operators';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { InjectionToken, Injectable, Optional, Inject,
|
|
5
|
-
import {
|
|
6
|
-
import * as i1 from '@o3r/logger';
|
|
7
|
-
import * as i1
|
|
8
|
-
import {
|
|
4
|
+
import { InjectionToken, NgModule, Injectable, Optional, Inject, SimpleChange, forwardRef, Directive, Input, Pipe, Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core';
|
|
5
|
+
import { asyncProps, createEntityAsyncRequestAdapter, asyncStoreItemAdapter, asyncEntitySerializer, otterComponentInfoPropertyName, sendOtterMessage, filterMessageContent } from '@o3r/core';
|
|
6
|
+
import * as i1$1 from '@o3r/logger';
|
|
7
|
+
import * as i1 from '@ngrx/store';
|
|
8
|
+
import { createAction, props, on, createReducer, StoreModule, createFeatureSelector, createSelector } from '@ngrx/store';
|
|
9
9
|
import { createEntityAdapter } from '@ngrx/entity';
|
|
10
10
|
import { NgControl, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
|
|
11
11
|
import * as i2 from '@angular/common';
|
|
@@ -50,9 +50,322 @@ const isComponentsMessage = (message) => {
|
|
|
50
50
|
message.dataType === 'connect' ||
|
|
51
51
|
message.dataType === 'selectedComponentInfo' ||
|
|
52
52
|
message.dataType === 'isComponentSelectionAvailable' ||
|
|
53
|
+
message.dataType === 'placeholderMode' ||
|
|
53
54
|
message.dataType === 'toggleInspector');
|
|
54
55
|
};
|
|
55
56
|
|
|
57
|
+
const ACTION_DELETE_ENTITY = '[PlaceholderTemplate] delete entity';
|
|
58
|
+
const ACTION_SET_ENTITY = '[PlaceholderTemplate] set entity';
|
|
59
|
+
const ACTION_TOGGLE_MODE = '[PlaceholderTemplate] toggle mode';
|
|
60
|
+
/** Action to delete a specific entity */
|
|
61
|
+
const deletePlaceholderTemplateEntity = createAction(ACTION_DELETE_ENTITY, props());
|
|
62
|
+
/** Action to clear all placeholderTemplate and fill the store with the payload */
|
|
63
|
+
const setPlaceholderTemplateEntity = createAction(ACTION_SET_ENTITY, props());
|
|
64
|
+
const togglePlaceholderModeTemplate = createAction(ACTION_TOGGLE_MODE, props());
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* PlaceholderTemplate Store adapter
|
|
68
|
+
*/
|
|
69
|
+
const placeholderTemplateAdapter = createEntityAdapter({
|
|
70
|
+
selectId: (model) => model.id
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* PlaceholderTemplate Store initial value
|
|
74
|
+
*/
|
|
75
|
+
const placeholderTemplateInitialState = placeholderTemplateAdapter.getInitialState({
|
|
76
|
+
mode: 'normal'
|
|
77
|
+
});
|
|
78
|
+
/**
|
|
79
|
+
* List of basic actions for PlaceholderTemplate Store
|
|
80
|
+
*/
|
|
81
|
+
const placeholderTemplateReducerFeatures = [
|
|
82
|
+
on(setPlaceholderTemplateEntity, (state, payload) => placeholderTemplateAdapter.addOne(payload.entity, placeholderTemplateAdapter.removeOne(payload.entity.id, state))),
|
|
83
|
+
on(deletePlaceholderTemplateEntity, (state, payload) => {
|
|
84
|
+
const id = payload.id;
|
|
85
|
+
if (!id || !state.entities[id]) {
|
|
86
|
+
return state;
|
|
87
|
+
}
|
|
88
|
+
return placeholderTemplateAdapter.removeOne(id, state);
|
|
89
|
+
}),
|
|
90
|
+
on(togglePlaceholderModeTemplate, (state, payload) => {
|
|
91
|
+
return {
|
|
92
|
+
...state,
|
|
93
|
+
mode: payload.mode
|
|
94
|
+
};
|
|
95
|
+
})
|
|
96
|
+
];
|
|
97
|
+
/**
|
|
98
|
+
* PlaceholderTemplate Store reducer
|
|
99
|
+
*/
|
|
100
|
+
const placeholderTemplateReducer = createReducer(placeholderTemplateInitialState, ...placeholderTemplateReducerFeatures);
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Name of the PlaceholderTemplate Store
|
|
104
|
+
*/
|
|
105
|
+
const PLACEHOLDER_TEMPLATE_STORE_NAME = 'placeholderTemplate';
|
|
106
|
+
|
|
107
|
+
/** Token of the PlaceholderTemplate reducer */
|
|
108
|
+
const PLACEHOLDER_TEMPLATE_REDUCER_TOKEN = new InjectionToken('Feature PlaceholderTemplate Reducer');
|
|
109
|
+
/** Provide default reducer for PlaceholderTemplate store */
|
|
110
|
+
function getDefaultPlaceholderTemplateReducer() {
|
|
111
|
+
return placeholderTemplateReducer;
|
|
112
|
+
}
|
|
113
|
+
class PlaceholderTemplateStoreModule {
|
|
114
|
+
static forRoot(reducerFactory) {
|
|
115
|
+
return {
|
|
116
|
+
ngModule: PlaceholderTemplateStoreModule,
|
|
117
|
+
providers: [
|
|
118
|
+
{ provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN, useFactory: reducerFactory }
|
|
119
|
+
]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderTemplateStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
123
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderTemplateStoreModule, imports: [i1.StoreFeatureModule] }); }
|
|
124
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderTemplateStoreModule, providers: [
|
|
125
|
+
{ provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN, useFactory: getDefaultPlaceholderTemplateReducer }
|
|
126
|
+
], imports: [StoreModule.forFeature(PLACEHOLDER_TEMPLATE_STORE_NAME, PLACEHOLDER_TEMPLATE_REDUCER_TOKEN)] }); }
|
|
127
|
+
}
|
|
128
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderTemplateStoreModule, decorators: [{
|
|
129
|
+
type: NgModule,
|
|
130
|
+
args: [{
|
|
131
|
+
imports: [
|
|
132
|
+
StoreModule.forFeature(PLACEHOLDER_TEMPLATE_STORE_NAME, PLACEHOLDER_TEMPLATE_REDUCER_TOKEN)
|
|
133
|
+
],
|
|
134
|
+
providers: [
|
|
135
|
+
{ provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN, useFactory: getDefaultPlaceholderTemplateReducer }
|
|
136
|
+
]
|
|
137
|
+
}]
|
|
138
|
+
}] });
|
|
139
|
+
|
|
140
|
+
const ACTION_FAIL_ENTITIES = '[PlaceholderRequest] fail entities';
|
|
141
|
+
const ACTION_SET_ENTITY_FROM_URL = '[PlaceholderRequest] set entity from url';
|
|
142
|
+
const ACTION_CANCEL_REQUEST = '[PlaceholderRequest] cancel request';
|
|
143
|
+
const ACTION_UPDATE_ENTITY = '[PlaceholderRequest] update entity';
|
|
144
|
+
const ACTION_UPDATE_ENTITY_SYNC = '[PlaceholderRequest] update entity sync';
|
|
145
|
+
/** Action to cancel a Request ID registered in the store. Can happen from effect based on a switchMap for instance */
|
|
146
|
+
const cancelPlaceholderRequest = createAction(ACTION_CANCEL_REQUEST, props());
|
|
147
|
+
/** Action to update failureStatus for PlaceholderRequestModels */
|
|
148
|
+
const failPlaceholderRequestEntity = createAction(ACTION_FAIL_ENTITIES, props());
|
|
149
|
+
/** Action to update an entity */
|
|
150
|
+
const updatePlaceholderRequestEntity = createAction(ACTION_UPDATE_ENTITY, props());
|
|
151
|
+
/** Action to update an entity without impact on request id */
|
|
152
|
+
const updatePlaceholderRequestEntitySync = createAction(ACTION_UPDATE_ENTITY_SYNC, props());
|
|
153
|
+
/** Action to update PlaceholderRequest with known IDs, will create the entity with only the url, the call will be created in the effect */
|
|
154
|
+
const setPlaceholderRequestEntityFromUrl = createAction(ACTION_SET_ENTITY_FROM_URL, asyncProps());
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* PlaceholderRequest Store adapter
|
|
158
|
+
*/
|
|
159
|
+
const placeholderRequestAdapter = createEntityAsyncRequestAdapter(createEntityAdapter({
|
|
160
|
+
selectId: (model) => model.id
|
|
161
|
+
}));
|
|
162
|
+
/**
|
|
163
|
+
* PlaceholderRequest Store initial value
|
|
164
|
+
*/
|
|
165
|
+
const placeholderRequestInitialState = placeholderRequestAdapter.getInitialState({
|
|
166
|
+
requestIds: []
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* Reducers of Placeholder request store that handles the call to the placeholder template URL
|
|
170
|
+
*/
|
|
171
|
+
const placeholderRequestReducerFeatures = [
|
|
172
|
+
on(cancelPlaceholderRequest, (state, action) => {
|
|
173
|
+
const id = action.id;
|
|
174
|
+
if (!id || !state.entities[id]) {
|
|
175
|
+
return state;
|
|
176
|
+
}
|
|
177
|
+
return placeholderRequestAdapter.updateOne({
|
|
178
|
+
id: action.id,
|
|
179
|
+
changes: asyncStoreItemAdapter.resolveRequest(state.entities[id], action.requestId)
|
|
180
|
+
}, asyncStoreItemAdapter.resolveRequest(state, action.requestId));
|
|
181
|
+
}),
|
|
182
|
+
on(updatePlaceholderRequestEntity, (state, action) => {
|
|
183
|
+
const currentEntity = state.entities[action.entity.id];
|
|
184
|
+
const newEntity = asyncStoreItemAdapter.resolveRequest({ ...action.entity, ...asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity) }, action.requestId);
|
|
185
|
+
return placeholderRequestAdapter.updateOne({
|
|
186
|
+
id: newEntity.id,
|
|
187
|
+
changes: newEntity
|
|
188
|
+
}, asyncStoreItemAdapter.resolveRequest(state, action.requestId));
|
|
189
|
+
}),
|
|
190
|
+
on(updatePlaceholderRequestEntitySync, (state, action) => {
|
|
191
|
+
return placeholderRequestAdapter.updateOne({
|
|
192
|
+
id: action.entity.id,
|
|
193
|
+
changes: {
|
|
194
|
+
...action.entity
|
|
195
|
+
}
|
|
196
|
+
}, state);
|
|
197
|
+
}),
|
|
198
|
+
on(setPlaceholderRequestEntityFromUrl, (state, payload) => {
|
|
199
|
+
const currentEntity = state.entities[payload.id];
|
|
200
|
+
// Nothing to update if resolved URLs already match
|
|
201
|
+
if (currentEntity && currentEntity.resolvedUrl === payload.resolvedUrl) {
|
|
202
|
+
return state;
|
|
203
|
+
}
|
|
204
|
+
let newEntity = {
|
|
205
|
+
id: payload.id,
|
|
206
|
+
resolvedUrl: payload.resolvedUrl,
|
|
207
|
+
used: true
|
|
208
|
+
};
|
|
209
|
+
if (currentEntity) {
|
|
210
|
+
newEntity = { ...asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity), ...newEntity };
|
|
211
|
+
}
|
|
212
|
+
return placeholderRequestAdapter.addOne(asyncStoreItemAdapter.addRequest(asyncStoreItemAdapter.initialize(newEntity), payload.requestId), asyncStoreItemAdapter.addRequest(state, payload.requestId));
|
|
213
|
+
}),
|
|
214
|
+
on(failPlaceholderRequestEntity, (state, payload) => {
|
|
215
|
+
return placeholderRequestAdapter.failRequestMany(asyncStoreItemAdapter.resolveRequest(state, payload.requestId), payload && payload.ids, payload.requestId);
|
|
216
|
+
})
|
|
217
|
+
];
|
|
218
|
+
/**
|
|
219
|
+
* PlaceholderRequest Store reducer
|
|
220
|
+
*/
|
|
221
|
+
const placeholderRequestReducer = createReducer(placeholderRequestInitialState, ...placeholderRequestReducerFeatures);
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Name of the PlaceholderRequest Store
|
|
225
|
+
*/
|
|
226
|
+
const PLACEHOLDER_REQUEST_STORE_NAME = 'placeholderRequest';
|
|
227
|
+
|
|
228
|
+
/** Token of the PlaceholderRequest reducer */
|
|
229
|
+
const PLACEHOLDER_REQUEST_REDUCER_TOKEN = new InjectionToken('Feature PlaceholderRequest Reducer');
|
|
230
|
+
/** Provide default reducer for PlaceholderRequest store */
|
|
231
|
+
function getDefaultplaceholderRequestReducer() {
|
|
232
|
+
return placeholderRequestReducer;
|
|
233
|
+
}
|
|
234
|
+
class PlaceholderRequestStoreModule {
|
|
235
|
+
static forRoot(reducerFactory) {
|
|
236
|
+
return {
|
|
237
|
+
ngModule: PlaceholderRequestStoreModule,
|
|
238
|
+
providers: [
|
|
239
|
+
{ provide: PLACEHOLDER_REQUEST_REDUCER_TOKEN, useFactory: reducerFactory }
|
|
240
|
+
]
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderRequestStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
244
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderRequestStoreModule, imports: [i1.StoreFeatureModule] }); }
|
|
245
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderRequestStoreModule, providers: [
|
|
246
|
+
{ provide: PLACEHOLDER_REQUEST_REDUCER_TOKEN, useFactory: getDefaultplaceholderRequestReducer }
|
|
247
|
+
], imports: [StoreModule.forFeature(PLACEHOLDER_REQUEST_STORE_NAME, PLACEHOLDER_REQUEST_REDUCER_TOKEN)] }); }
|
|
248
|
+
}
|
|
249
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderRequestStoreModule, decorators: [{
|
|
250
|
+
type: NgModule,
|
|
251
|
+
args: [{
|
|
252
|
+
imports: [
|
|
253
|
+
StoreModule.forFeature(PLACEHOLDER_REQUEST_STORE_NAME, PLACEHOLDER_REQUEST_REDUCER_TOKEN)
|
|
254
|
+
],
|
|
255
|
+
providers: [
|
|
256
|
+
{ provide: PLACEHOLDER_REQUEST_REDUCER_TOKEN, useFactory: getDefaultplaceholderRequestReducer }
|
|
257
|
+
]
|
|
258
|
+
}]
|
|
259
|
+
}] });
|
|
260
|
+
|
|
261
|
+
const selectPlaceholderRequestState = createFeatureSelector(PLACEHOLDER_REQUEST_STORE_NAME);
|
|
262
|
+
const { selectEntities: selectEntities$1 } = placeholderRequestAdapter.getSelectors();
|
|
263
|
+
/** Select the dictionary of PlaceholderRequest entities */
|
|
264
|
+
const selectPlaceholderRequestEntities = createSelector(selectPlaceholderRequestState, (state) => state && selectEntities$1(state));
|
|
265
|
+
/**
|
|
266
|
+
* Select a specific PlaceholderRequest entity using a raw url as id
|
|
267
|
+
* @param rawUrl
|
|
268
|
+
*/
|
|
269
|
+
const selectPlaceholderRequestEntityUsage = (rawUrl) => createSelector(selectPlaceholderRequestState, (state) => {
|
|
270
|
+
return state?.entities[rawUrl] ? state?.entities[rawUrl].used : undefined;
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
const placeholderRequestStorageSerializer = asyncEntitySerializer;
|
|
274
|
+
const placeholderRequestStorageDeserializer = (rawObject) => {
|
|
275
|
+
if (!rawObject || !rawObject.ids) {
|
|
276
|
+
return placeholderRequestInitialState;
|
|
277
|
+
}
|
|
278
|
+
const storeObject = placeholderRequestAdapter.getInitialState(rawObject);
|
|
279
|
+
for (const id of rawObject.ids) {
|
|
280
|
+
storeObject.entities[id] = rawObject.entities[id];
|
|
281
|
+
}
|
|
282
|
+
return storeObject;
|
|
283
|
+
};
|
|
284
|
+
const placeholderRequestStorageSync = {
|
|
285
|
+
serialize: placeholderRequestStorageSerializer,
|
|
286
|
+
deserialize: placeholderRequestStorageDeserializer
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const { selectEntities } = placeholderTemplateAdapter.getSelectors();
|
|
290
|
+
const selectPlaceholderTemplateState = createFeatureSelector(PLACEHOLDER_TEMPLATE_STORE_NAME);
|
|
291
|
+
/** Select the dictionary of PlaceholderTemplate entities */
|
|
292
|
+
const selectPlaceholderTemplateEntities = createSelector(selectPlaceholderTemplateState, (state) => state && selectEntities(state));
|
|
293
|
+
/**
|
|
294
|
+
* Select a specific PlaceholderTemplate
|
|
295
|
+
* @param placeholderId
|
|
296
|
+
*/
|
|
297
|
+
const selectPlaceholderTemplateEntity = (placeholderId) => createSelector(selectPlaceholderTemplateState, (state) => state?.entities[placeholderId]);
|
|
298
|
+
/**
|
|
299
|
+
* Select the ordered rendered placeholder template full data (url, priority etc.) for a given placeholderId
|
|
300
|
+
* Return undefined if the placeholder is not found
|
|
301
|
+
* Returns {orderedRenderedTemplates: undefined, isPending: true} if any of the request is still pending
|
|
302
|
+
* @param placeholderId
|
|
303
|
+
*/
|
|
304
|
+
const selectSortedTemplates = (placeholderId) => createSelector(selectPlaceholderTemplateEntity(placeholderId), selectPlaceholderRequestState, (placeholderTemplate, placeholderRequestState) => {
|
|
305
|
+
if (!placeholderTemplate || !placeholderRequestState) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
// The isPending will be considered true if any of the Url is still pending
|
|
309
|
+
let isPending = false;
|
|
310
|
+
const templates = [];
|
|
311
|
+
placeholderTemplate.urlsWithPriority.forEach(urlWithPriority => {
|
|
312
|
+
const placeholderRequest = placeholderRequestState.entities[urlWithPriority.rawUrl];
|
|
313
|
+
if (placeholderRequest) {
|
|
314
|
+
// If one of the items is pending, we will wait to display all contents at the same time
|
|
315
|
+
isPending = isPending || placeholderRequest.isPending;
|
|
316
|
+
// Templates in failure will be ignored from the list
|
|
317
|
+
if (!placeholderRequest.isFailure) {
|
|
318
|
+
templates.push({
|
|
319
|
+
rawUrl: urlWithPriority.rawUrl,
|
|
320
|
+
resolvedUrl: placeholderRequest.resolvedUrl,
|
|
321
|
+
priority: urlWithPriority.priority,
|
|
322
|
+
renderedTemplate: placeholderRequest.renderedTemplate
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
// No need to perform sorting if still pending
|
|
328
|
+
if (isPending) {
|
|
329
|
+
return { orderedTemplates: undefined, isPending };
|
|
330
|
+
}
|
|
331
|
+
// Sort templates by priority
|
|
332
|
+
const orderedTemplates = templates.sort((template1, template2) => {
|
|
333
|
+
return (template2.priority - template1.priority) || 1;
|
|
334
|
+
}).filter(templateData => !!templateData.renderedTemplate);
|
|
335
|
+
return { orderedTemplates, isPending };
|
|
336
|
+
});
|
|
337
|
+
/**
|
|
338
|
+
* Select the ordered rendered templates for a given placeholderId
|
|
339
|
+
* Return undefined if the placeholder is not found
|
|
340
|
+
* Returns {orderedRenderedTemplates: undefined, isPending: true} if any of the request is still pending
|
|
341
|
+
* @param placeholderId
|
|
342
|
+
* @deprecated Please use {@link selectSortedTemplates} instead
|
|
343
|
+
*/
|
|
344
|
+
const selectPlaceholderRenderedTemplates = (placeholderId) => createSelector(selectSortedTemplates(placeholderId), (placeholderData) => {
|
|
345
|
+
if (!placeholderData) {
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
orderedRenderedTemplates: placeholderData.orderedTemplates?.map(placeholder => placeholder.renderedTemplate),
|
|
350
|
+
isPending: placeholderData.isPending
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
const selectPlaceholderTemplateMode = createSelector(selectPlaceholderTemplateState, (state) => state.mode);
|
|
354
|
+
|
|
355
|
+
const placeholderTemplateStorageDeserializer = (rawObject) => {
|
|
356
|
+
if (!rawObject || !rawObject.ids) {
|
|
357
|
+
return placeholderTemplateInitialState;
|
|
358
|
+
}
|
|
359
|
+
const storeObject = placeholderTemplateAdapter.getInitialState(rawObject);
|
|
360
|
+
for (const id of rawObject.ids) {
|
|
361
|
+
storeObject.entities[id] = rawObject.entities[id];
|
|
362
|
+
}
|
|
363
|
+
return storeObject;
|
|
364
|
+
};
|
|
365
|
+
const placeholderTemplateStorageSync = {
|
|
366
|
+
deserialize: placeholderTemplateStorageDeserializer
|
|
367
|
+
};
|
|
368
|
+
|
|
56
369
|
const OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS = {
|
|
57
370
|
isActivatedOnBootstrap: false
|
|
58
371
|
};
|
|
@@ -336,8 +649,9 @@ class OtterInspectorService {
|
|
|
336
649
|
}
|
|
337
650
|
|
|
338
651
|
class ComponentsDevtoolsMessageService {
|
|
339
|
-
constructor(logger, options) {
|
|
652
|
+
constructor(logger, store, options) {
|
|
340
653
|
this.logger = logger;
|
|
654
|
+
this.store = store;
|
|
341
655
|
this.subscriptions = new Subscription();
|
|
342
656
|
this.sendMessage = (sendOtterMessage);
|
|
343
657
|
this.options = {
|
|
@@ -405,6 +719,10 @@ class ComponentsDevtoolsMessageService {
|
|
|
405
719
|
this.inspectorService.toggleInspector(message.isRunning);
|
|
406
720
|
break;
|
|
407
721
|
}
|
|
722
|
+
case 'placeholderMode': {
|
|
723
|
+
this.store.dispatch(togglePlaceholderModeTemplate({ mode: message.mode }));
|
|
724
|
+
break;
|
|
725
|
+
}
|
|
408
726
|
default: {
|
|
409
727
|
this.logger.warn('Message ignored by the components service', message);
|
|
410
728
|
}
|
|
@@ -417,360 +735,62 @@ class ComponentsDevtoolsMessageService {
|
|
|
417
735
|
this.subscriptions.add(this.inspectorService.otterLikeComponentInfoToBeSent$
|
|
418
736
|
.pipe(filter((info) => !!info)).subscribe((info) => this.sendMessage('selectedComponentInfo', info)));
|
|
419
737
|
}
|
|
420
|
-
/** @inheritDoc */
|
|
421
|
-
ngOnDestroy() {
|
|
422
|
-
this.subscriptions.unsubscribe();
|
|
423
|
-
}
|
|
424
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsMessageService, deps: [{ token: i1.LoggerService }, { token: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
425
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsMessageService, providedIn: 'root' }); }
|
|
426
|
-
}
|
|
427
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsMessageService, decorators: [{
|
|
428
|
-
type: Injectable,
|
|
429
|
-
args: [{
|
|
430
|
-
providedIn: 'root'
|
|
431
|
-
}]
|
|
432
|
-
}], ctorParameters: () => [{ type: i1.LoggerService }, { type: undefined, decorators: [{
|
|
433
|
-
type: Optional
|
|
434
|
-
}, {
|
|
435
|
-
type: Inject,
|
|
436
|
-
args: [OTTER_COMPONENTS_DEVTOOLS_OPTIONS]
|
|
437
|
-
}] }] });
|
|
438
|
-
|
|
439
|
-
class ComponentsDevtoolsModule {
|
|
440
|
-
/**
|
|
441
|
-
* Initialize Otter Devtools
|
|
442
|
-
* @param options
|
|
443
|
-
*/
|
|
444
|
-
static instrument(options) {
|
|
445
|
-
return {
|
|
446
|
-
ngModule: ComponentsDevtoolsModule,
|
|
447
|
-
providers: [
|
|
448
|
-
{ provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, useValue: { ...OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS, ...options }, multi: false },
|
|
449
|
-
ComponentsDevtoolsMessageService
|
|
450
|
-
]
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
454
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsModule, imports: [StoreModule] }); }
|
|
455
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsModule, providers: [
|
|
456
|
-
{ provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, useValue: OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS },
|
|
457
|
-
ComponentsDevtoolsMessageService
|
|
458
|
-
], imports: [StoreModule] }); }
|
|
459
|
-
}
|
|
460
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsModule, decorators: [{
|
|
461
|
-
type: NgModule,
|
|
462
|
-
args: [{
|
|
463
|
-
imports: [
|
|
464
|
-
StoreModule
|
|
465
|
-
],
|
|
466
|
-
providers: [
|
|
467
|
-
{ provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, useValue: OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS },
|
|
468
|
-
ComponentsDevtoolsMessageService
|
|
469
|
-
]
|
|
470
|
-
}]
|
|
471
|
-
}] });
|
|
472
|
-
|
|
473
|
-
const ACTION_DELETE_ENTITY = '[PlaceholderTemplate] delete entity';
|
|
474
|
-
const ACTION_SET_ENTITY = '[PlaceholderTemplate] set entity';
|
|
475
|
-
/** Action to delete a specific entity */
|
|
476
|
-
const deletePlaceholderTemplateEntity = createAction(ACTION_DELETE_ENTITY, props());
|
|
477
|
-
/** Action to clear all placeholderTemplate and fill the store with the payload */
|
|
478
|
-
const setPlaceholderTemplateEntity = createAction(ACTION_SET_ENTITY, props());
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* PlaceholderTemplate Store adapter
|
|
482
|
-
*/
|
|
483
|
-
const placeholderTemplateAdapter = createEntityAdapter({
|
|
484
|
-
selectId: (model) => model.id
|
|
485
|
-
});
|
|
486
|
-
/**
|
|
487
|
-
* PlaceholderTemplate Store initial value
|
|
488
|
-
*/
|
|
489
|
-
const placeholderTemplateInitialState = placeholderTemplateAdapter.getInitialState();
|
|
490
|
-
/**
|
|
491
|
-
* List of basic actions for PlaceholderTemplate Store
|
|
492
|
-
*/
|
|
493
|
-
const placeholderTemplateReducerFeatures = [
|
|
494
|
-
on(setPlaceholderTemplateEntity, (state, payload) => placeholderTemplateAdapter.addOne(payload.entity, placeholderTemplateAdapter.removeOne(payload.entity.id, state))),
|
|
495
|
-
on(deletePlaceholderTemplateEntity, (state, payload) => {
|
|
496
|
-
const id = payload.id;
|
|
497
|
-
if (!id || !state.entities[id]) {
|
|
498
|
-
return state;
|
|
499
|
-
}
|
|
500
|
-
return placeholderTemplateAdapter.removeOne(id, state);
|
|
501
|
-
})
|
|
502
|
-
];
|
|
503
|
-
/**
|
|
504
|
-
* PlaceholderTemplate Store reducer
|
|
505
|
-
*/
|
|
506
|
-
const placeholderTemplateReducer = createReducer(placeholderTemplateInitialState, ...placeholderTemplateReducerFeatures);
|
|
507
|
-
|
|
508
|
-
/**
|
|
509
|
-
* Name of the PlaceholderTemplate Store
|
|
510
|
-
*/
|
|
511
|
-
const PLACEHOLDER_TEMPLATE_STORE_NAME = 'placeholderTemplate';
|
|
512
|
-
|
|
513
|
-
/** Token of the PlaceholderTemplate reducer */
|
|
514
|
-
const PLACEHOLDER_TEMPLATE_REDUCER_TOKEN = new InjectionToken('Feature PlaceholderTemplate Reducer');
|
|
515
|
-
/** Provide default reducer for PlaceholderTemplate store */
|
|
516
|
-
function getDefaultPlaceholderTemplateReducer() {
|
|
517
|
-
return placeholderTemplateReducer;
|
|
518
|
-
}
|
|
519
|
-
class PlaceholderTemplateStoreModule {
|
|
520
|
-
static forRoot(reducerFactory) {
|
|
521
|
-
return {
|
|
522
|
-
ngModule: PlaceholderTemplateStoreModule,
|
|
523
|
-
providers: [
|
|
524
|
-
{ provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN, useFactory: reducerFactory }
|
|
525
|
-
]
|
|
526
|
-
};
|
|
738
|
+
/** @inheritDoc */
|
|
739
|
+
ngOnDestroy() {
|
|
740
|
+
this.subscriptions.unsubscribe();
|
|
527
741
|
}
|
|
528
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type:
|
|
529
|
-
/** @nocollapse */ static { this.ɵ
|
|
530
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderTemplateStoreModule, providers: [
|
|
531
|
-
{ provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN, useFactory: getDefaultPlaceholderTemplateReducer }
|
|
532
|
-
], imports: [StoreModule.forFeature(PLACEHOLDER_TEMPLATE_STORE_NAME, PLACEHOLDER_TEMPLATE_REDUCER_TOKEN)] }); }
|
|
742
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsMessageService, deps: [{ token: i1$1.LoggerService }, { token: i1.Store }, { token: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
743
|
+
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsMessageService, providedIn: 'root' }); }
|
|
533
744
|
}
|
|
534
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type:
|
|
535
|
-
type:
|
|
745
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsMessageService, decorators: [{
|
|
746
|
+
type: Injectable,
|
|
536
747
|
args: [{
|
|
537
|
-
|
|
538
|
-
StoreModule.forFeature(PLACEHOLDER_TEMPLATE_STORE_NAME, PLACEHOLDER_TEMPLATE_REDUCER_TOKEN)
|
|
539
|
-
],
|
|
540
|
-
providers: [
|
|
541
|
-
{ provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN, useFactory: getDefaultPlaceholderTemplateReducer }
|
|
542
|
-
]
|
|
748
|
+
providedIn: 'root'
|
|
543
749
|
}]
|
|
544
|
-
}] }
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const ACTION_UPDATE_ENTITY_SYNC = '[PlaceholderRequest] update entity sync';
|
|
551
|
-
/** Action to cancel a Request ID registered in the store. Can happen from effect based on a switchMap for instance */
|
|
552
|
-
const cancelPlaceholderRequest = createAction(ACTION_CANCEL_REQUEST, props());
|
|
553
|
-
/** Action to update failureStatus for PlaceholderRequestModels */
|
|
554
|
-
const failPlaceholderRequestEntity = createAction(ACTION_FAIL_ENTITIES, props());
|
|
555
|
-
/** Action to update an entity */
|
|
556
|
-
const updatePlaceholderRequestEntity = createAction(ACTION_UPDATE_ENTITY, props());
|
|
557
|
-
/** Action to update an entity without impact on request id */
|
|
558
|
-
const updatePlaceholderRequestEntitySync = createAction(ACTION_UPDATE_ENTITY_SYNC, props());
|
|
559
|
-
/** Action to update PlaceholderRequest with known IDs, will create the entity with only the url, the call will be created in the effect */
|
|
560
|
-
const setPlaceholderRequestEntityFromUrl = createAction(ACTION_SET_ENTITY_FROM_URL, asyncProps());
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* PlaceholderRequest Store adapter
|
|
564
|
-
*/
|
|
565
|
-
const placeholderRequestAdapter = createEntityAsyncRequestAdapter(createEntityAdapter({
|
|
566
|
-
selectId: (model) => model.id
|
|
567
|
-
}));
|
|
568
|
-
/**
|
|
569
|
-
* PlaceholderRequest Store initial value
|
|
570
|
-
*/
|
|
571
|
-
const placeholderRequestInitialState = placeholderRequestAdapter.getInitialState({
|
|
572
|
-
requestIds: []
|
|
573
|
-
});
|
|
574
|
-
/**
|
|
575
|
-
* Reducers of Placeholder request store that handles the call to the placeholder template URL
|
|
576
|
-
*/
|
|
577
|
-
const placeholderRequestReducerFeatures = [
|
|
578
|
-
on(cancelPlaceholderRequest, (state, action) => {
|
|
579
|
-
const id = action.id;
|
|
580
|
-
if (!id || !state.entities[id]) {
|
|
581
|
-
return state;
|
|
582
|
-
}
|
|
583
|
-
return placeholderRequestAdapter.updateOne({
|
|
584
|
-
id: action.id,
|
|
585
|
-
changes: asyncStoreItemAdapter.resolveRequest(state.entities[id], action.requestId)
|
|
586
|
-
}, asyncStoreItemAdapter.resolveRequest(state, action.requestId));
|
|
587
|
-
}),
|
|
588
|
-
on(updatePlaceholderRequestEntity, (state, action) => {
|
|
589
|
-
const currentEntity = state.entities[action.entity.id];
|
|
590
|
-
const newEntity = asyncStoreItemAdapter.resolveRequest({ ...action.entity, ...asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity) }, action.requestId);
|
|
591
|
-
return placeholderRequestAdapter.updateOne({
|
|
592
|
-
id: newEntity.id,
|
|
593
|
-
changes: newEntity
|
|
594
|
-
}, asyncStoreItemAdapter.resolveRequest(state, action.requestId));
|
|
595
|
-
}),
|
|
596
|
-
on(updatePlaceholderRequestEntitySync, (state, action) => {
|
|
597
|
-
return placeholderRequestAdapter.updateOne({
|
|
598
|
-
id: action.entity.id,
|
|
599
|
-
changes: {
|
|
600
|
-
...action.entity
|
|
601
|
-
}
|
|
602
|
-
}, state);
|
|
603
|
-
}),
|
|
604
|
-
on(setPlaceholderRequestEntityFromUrl, (state, payload) => {
|
|
605
|
-
const currentEntity = state.entities[payload.id];
|
|
606
|
-
// Nothing to update if resolved URLs already match
|
|
607
|
-
if (currentEntity && currentEntity.resolvedUrl === payload.resolvedUrl) {
|
|
608
|
-
return state;
|
|
609
|
-
}
|
|
610
|
-
let newEntity = {
|
|
611
|
-
id: payload.id,
|
|
612
|
-
resolvedUrl: payload.resolvedUrl,
|
|
613
|
-
used: true
|
|
614
|
-
};
|
|
615
|
-
if (currentEntity) {
|
|
616
|
-
newEntity = { ...asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity), ...newEntity };
|
|
617
|
-
}
|
|
618
|
-
return placeholderRequestAdapter.addOne(asyncStoreItemAdapter.addRequest(asyncStoreItemAdapter.initialize(newEntity), payload.requestId), asyncStoreItemAdapter.addRequest(state, payload.requestId));
|
|
619
|
-
}),
|
|
620
|
-
on(failPlaceholderRequestEntity, (state, payload) => {
|
|
621
|
-
return placeholderRequestAdapter.failRequestMany(asyncStoreItemAdapter.resolveRequest(state, payload.requestId), payload && payload.ids, payload.requestId);
|
|
622
|
-
})
|
|
623
|
-
];
|
|
624
|
-
/**
|
|
625
|
-
* PlaceholderRequest Store reducer
|
|
626
|
-
*/
|
|
627
|
-
const placeholderRequestReducer = createReducer(placeholderRequestInitialState, ...placeholderRequestReducerFeatures);
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Name of the PlaceholderRequest Store
|
|
631
|
-
*/
|
|
632
|
-
const PLACEHOLDER_REQUEST_STORE_NAME = 'placeholderRequest';
|
|
750
|
+
}], ctorParameters: () => [{ type: i1$1.LoggerService }, { type: i1.Store }, { type: undefined, decorators: [{
|
|
751
|
+
type: Optional
|
|
752
|
+
}, {
|
|
753
|
+
type: Inject,
|
|
754
|
+
args: [OTTER_COMPONENTS_DEVTOOLS_OPTIONS]
|
|
755
|
+
}] }] });
|
|
633
756
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
class PlaceholderRequestStoreModule {
|
|
641
|
-
static forRoot(reducerFactory) {
|
|
757
|
+
class ComponentsDevtoolsModule {
|
|
758
|
+
/**
|
|
759
|
+
* Initialize Otter Devtools
|
|
760
|
+
* @param options
|
|
761
|
+
*/
|
|
762
|
+
static instrument(options) {
|
|
642
763
|
return {
|
|
643
|
-
ngModule:
|
|
764
|
+
ngModule: ComponentsDevtoolsModule,
|
|
644
765
|
providers: [
|
|
645
|
-
{ provide:
|
|
766
|
+
{ provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, useValue: { ...OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS, ...options }, multi: false },
|
|
767
|
+
ComponentsDevtoolsMessageService
|
|
646
768
|
]
|
|
647
769
|
};
|
|
648
770
|
}
|
|
649
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type:
|
|
650
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type:
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
771
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
772
|
+
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsModule, imports: [StoreModule,
|
|
773
|
+
PlaceholderTemplateStoreModule] }); }
|
|
774
|
+
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsModule, providers: [
|
|
775
|
+
{ provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, useValue: OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS },
|
|
776
|
+
ComponentsDevtoolsMessageService
|
|
777
|
+
], imports: [StoreModule,
|
|
778
|
+
PlaceholderTemplateStoreModule] }); }
|
|
654
779
|
}
|
|
655
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type:
|
|
780
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: ComponentsDevtoolsModule, decorators: [{
|
|
656
781
|
type: NgModule,
|
|
657
782
|
args: [{
|
|
658
783
|
imports: [
|
|
659
|
-
StoreModule
|
|
784
|
+
StoreModule,
|
|
785
|
+
PlaceholderTemplateStoreModule
|
|
660
786
|
],
|
|
661
787
|
providers: [
|
|
662
|
-
{ provide:
|
|
788
|
+
{ provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, useValue: OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS },
|
|
789
|
+
ComponentsDevtoolsMessageService
|
|
663
790
|
]
|
|
664
791
|
}]
|
|
665
792
|
}] });
|
|
666
793
|
|
|
667
|
-
const selectPlaceholderRequestState = createFeatureSelector(PLACEHOLDER_REQUEST_STORE_NAME);
|
|
668
|
-
const { selectEntities: selectEntities$1 } = placeholderRequestAdapter.getSelectors();
|
|
669
|
-
/** Select the dictionary of PlaceholderRequest entities */
|
|
670
|
-
const selectPlaceholderRequestEntities = createSelector(selectPlaceholderRequestState, (state) => state && selectEntities$1(state));
|
|
671
|
-
/**
|
|
672
|
-
* Select a specific PlaceholderRequest entity using a raw url as id
|
|
673
|
-
* @param rawUrl
|
|
674
|
-
*/
|
|
675
|
-
const selectPlaceholderRequestEntityUsage = (rawUrl) => createSelector(selectPlaceholderRequestState, (state) => {
|
|
676
|
-
return state?.entities[rawUrl] ? state?.entities[rawUrl].used : undefined;
|
|
677
|
-
});
|
|
678
|
-
|
|
679
|
-
const placeholderRequestStorageSerializer = asyncEntitySerializer;
|
|
680
|
-
const placeholderRequestStorageDeserializer = (rawObject) => {
|
|
681
|
-
if (!rawObject || !rawObject.ids) {
|
|
682
|
-
return placeholderRequestInitialState;
|
|
683
|
-
}
|
|
684
|
-
const storeObject = placeholderRequestAdapter.getInitialState(rawObject);
|
|
685
|
-
for (const id of rawObject.ids) {
|
|
686
|
-
storeObject.entities[id] = rawObject.entities[id];
|
|
687
|
-
}
|
|
688
|
-
return storeObject;
|
|
689
|
-
};
|
|
690
|
-
const placeholderRequestStorageSync = {
|
|
691
|
-
serialize: placeholderRequestStorageSerializer,
|
|
692
|
-
deserialize: placeholderRequestStorageDeserializer
|
|
693
|
-
};
|
|
694
|
-
|
|
695
|
-
const { selectEntities } = placeholderTemplateAdapter.getSelectors();
|
|
696
|
-
const selectPlaceholderTemplateState = createFeatureSelector(PLACEHOLDER_TEMPLATE_STORE_NAME);
|
|
697
|
-
/** Select the dictionary of PlaceholderTemplate entities */
|
|
698
|
-
const selectPlaceholderTemplateEntities = createSelector(selectPlaceholderTemplateState, (state) => state && selectEntities(state));
|
|
699
|
-
/**
|
|
700
|
-
* Select a specific PlaceholderTemplate
|
|
701
|
-
* @param placeholderId
|
|
702
|
-
*/
|
|
703
|
-
const selectPlaceholderTemplateEntity = (placeholderId) => createSelector(selectPlaceholderTemplateState, (state) => state?.entities[placeholderId]);
|
|
704
|
-
/**
|
|
705
|
-
* Select the ordered rendered placeholder template full data (url, priority etc.) for a given placeholderId
|
|
706
|
-
* Return undefined if the placeholder is not found
|
|
707
|
-
* Returns {orderedRenderedTemplates: undefined, isPending: true} if any of the request is still pending
|
|
708
|
-
* @param placeholderId
|
|
709
|
-
*/
|
|
710
|
-
const selectSortedTemplates = (placeholderId) => createSelector(selectPlaceholderTemplateEntity(placeholderId), selectPlaceholderRequestState, (placeholderTemplate, placeholderRequestState) => {
|
|
711
|
-
if (!placeholderTemplate || !placeholderRequestState) {
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
// The isPending will be considered true if any of the Url is still pending
|
|
715
|
-
let isPending = false;
|
|
716
|
-
const templates = [];
|
|
717
|
-
placeholderTemplate.urlsWithPriority.forEach(urlWithPriority => {
|
|
718
|
-
const placeholderRequest = placeholderRequestState.entities[urlWithPriority.rawUrl];
|
|
719
|
-
if (placeholderRequest) {
|
|
720
|
-
// If one of the items is pending, we will wait to display all contents at the same time
|
|
721
|
-
isPending = isPending || placeholderRequest.isPending;
|
|
722
|
-
// Templates in failure will be ignored from the list
|
|
723
|
-
if (!placeholderRequest.isFailure) {
|
|
724
|
-
templates.push({
|
|
725
|
-
rawUrl: urlWithPriority.rawUrl,
|
|
726
|
-
resolvedUrl: placeholderRequest.resolvedUrl,
|
|
727
|
-
priority: urlWithPriority.priority,
|
|
728
|
-
renderedTemplate: placeholderRequest.renderedTemplate
|
|
729
|
-
});
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
});
|
|
733
|
-
// No need to perform sorting if still pending
|
|
734
|
-
if (isPending) {
|
|
735
|
-
return { orderedTemplates: undefined, isPending };
|
|
736
|
-
}
|
|
737
|
-
// Sort templates by priority
|
|
738
|
-
const orderedTemplates = templates.sort((template1, template2) => {
|
|
739
|
-
return (template2.priority - template1.priority) || 1;
|
|
740
|
-
}).filter(templateData => !!templateData.renderedTemplate);
|
|
741
|
-
return { orderedTemplates, isPending };
|
|
742
|
-
});
|
|
743
|
-
/**
|
|
744
|
-
* Select the ordered rendered templates for a given placeholderId
|
|
745
|
-
* Return undefined if the placeholder is not found
|
|
746
|
-
* Returns {orderedRenderedTemplates: undefined, isPending: true} if any of the request is still pending
|
|
747
|
-
* @param placeholderId
|
|
748
|
-
* @deprecated Please use {@link selectSortedTemplates} instead
|
|
749
|
-
*/
|
|
750
|
-
const selectPlaceholderRenderedTemplates = (placeholderId) => createSelector(selectSortedTemplates(placeholderId), (placeholderData) => {
|
|
751
|
-
if (!placeholderData) {
|
|
752
|
-
return;
|
|
753
|
-
}
|
|
754
|
-
return {
|
|
755
|
-
orderedRenderedTemplates: placeholderData.orderedTemplates?.map(placeholder => placeholder.renderedTemplate),
|
|
756
|
-
isPending: placeholderData.isPending
|
|
757
|
-
};
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
const placeholderTemplateStorageDeserializer = (rawObject) => {
|
|
761
|
-
if (!rawObject || !rawObject.ids) {
|
|
762
|
-
return placeholderTemplateInitialState;
|
|
763
|
-
}
|
|
764
|
-
const storeObject = placeholderTemplateAdapter.getInitialState(rawObject);
|
|
765
|
-
for (const id of rawObject.ids) {
|
|
766
|
-
storeObject.entities[id] = rawObject.entities[id];
|
|
767
|
-
}
|
|
768
|
-
return storeObject;
|
|
769
|
-
};
|
|
770
|
-
const placeholderTemplateStorageSync = {
|
|
771
|
-
deserialize: placeholderTemplateStorageDeserializer
|
|
772
|
-
};
|
|
773
|
-
|
|
774
794
|
class C11nDirective {
|
|
775
795
|
/** The input setter */
|
|
776
796
|
set inputs(value) {
|
|
@@ -1324,6 +1344,7 @@ class PlaceholderComponent {
|
|
|
1324
1344
|
this.id$ = new BehaviorSubject(undefined);
|
|
1325
1345
|
this.afterViewInit$ = new Subject();
|
|
1326
1346
|
this.messages$ = new ReplaySubject(1);
|
|
1347
|
+
this.mode = this.store.selectSignal(selectPlaceholderTemplateMode);
|
|
1327
1348
|
}
|
|
1328
1349
|
/** @inheritdoc */
|
|
1329
1350
|
ngOnInit() {
|
|
@@ -1369,19 +1390,16 @@ class PlaceholderComponent {
|
|
|
1369
1390
|
this.afterViewInit$.complete();
|
|
1370
1391
|
this.subscription.unsubscribe();
|
|
1371
1392
|
}
|
|
1372
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderComponent, deps: [{ token: i1
|
|
1373
|
-
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
1393
|
+
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderComponent, deps: [{ token: i1.Store }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
1394
|
+
/** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "17.3.3", type: PlaceholderComponent, selector: "o3r-placeholder", inputs: { id: "id" }, host: { properties: { "class.debug": "mode() === 'debug'" } }, ngImport: i0, template: "<ng-template #projection>\n <ng-content></ng-content>\n</ng-template>\n@switch (mode()) {\n @case ('debug') {\n <span class=\"placehoder-id\">{{ id$ | async }}</span>\n }\n @case ('pending') {\n <ng-container *ngTemplateOutlet=\"projection\" />\n }\n @case ('normal') {\n @if (isPending) {\n <ng-container *ngTemplateOutlet=\"projection\" />\n } @else {\n <div [innerHTML]=\"template\"></div>\n }\n }\n}\n", styles: [".debug{padding:15px;text-align:center;border:2px dashed var(--o3r-placeholder-debug-color, #a65c27);border-radius:10px;width:100%;background:var(--o3r-placeholder-background, #fff2ea);border-style:dashed;color:var(--o3r-placeholder-debug-color, #a65c27);font-size:larger}\n"], dependencies: [{ kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
|
|
1374
1395
|
}
|
|
1375
1396
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PlaceholderComponent, decorators: [{
|
|
1376
1397
|
type: Component,
|
|
1377
|
-
args: [{
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
encapsulation: ViewEncapsulation.None
|
|
1383
|
-
}]
|
|
1384
|
-
}], ctorParameters: () => [{ type: i1$1.Store }, { type: i0.ChangeDetectorRef }], propDecorators: { id: [{
|
|
1398
|
+
args: [{ selector: 'o3r-placeholder', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
|
|
1399
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
1400
|
+
'[class.debug]': `mode() === 'debug'`
|
|
1401
|
+
}, template: "<ng-template #projection>\n <ng-content></ng-content>\n</ng-template>\n@switch (mode()) {\n @case ('debug') {\n <span class=\"placehoder-id\">{{ id$ | async }}</span>\n }\n @case ('pending') {\n <ng-container *ngTemplateOutlet=\"projection\" />\n }\n @case ('normal') {\n @if (isPending) {\n <ng-container *ngTemplateOutlet=\"projection\" />\n } @else {\n <div [innerHTML]=\"template\"></div>\n }\n }\n}\n", styles: [".debug{padding:15px;text-align:center;border:2px dashed var(--o3r-placeholder-debug-color, #a65c27);border-radius:10px;width:100%;background:var(--o3r-placeholder-background, #fff2ea);border-style:dashed;color:var(--o3r-placeholder-debug-color, #a65c27);font-size:larger}\n"] }]
|
|
1402
|
+
}], ctorParameters: () => [{ type: i1.Store }, { type: i0.ChangeDetectorRef }], propDecorators: { id: [{
|
|
1385
1403
|
type: Input
|
|
1386
1404
|
}] } });
|
|
1387
1405
|
|
|
@@ -1414,5 +1432,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
1414
1432
|
* Generated bundle index. Do not edit.
|
|
1415
1433
|
*/
|
|
1416
1434
|
|
|
1417
|
-
export { C11N_PRESENTERS_MAP_TOKEN, C11N_REGISTER_FUNC_TOKEN, C11nDirective, C11nMockModule, C11nMockService, C11nModule, C11nService, CapitalizePipe, CapitalizePipeModule, ComponentsDevtoolsMessageService, ComponentsDevtoolsModule, DurationPipe, DurationPipeModule, INSPECTOR_CLASS, KeepWhiteSpacePipe, KeepWhiteSpacePipeModule, MockC11nDirective, O3rCapitalizePipe, O3rDurationPipe, O3rKeepWhiteSpacePipe, O3rReplaceWithBoldPipe, OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS, OTTER_COMPONENTS_DEVTOOLS_OPTIONS, OtterInspectorService, PLACEHOLDER_REQUEST_REDUCER_TOKEN, PLACEHOLDER_REQUEST_STORE_NAME, PLACEHOLDER_TEMPLATE_REDUCER_TOKEN, PLACEHOLDER_TEMPLATE_STORE_NAME, PlaceholderComponent, PlaceholderModule, PlaceholderRequestStoreModule, PlaceholderTemplateStoreModule, ReplaceWithBoldPipe, ReplaceWithBoldPipeModule, cancelPlaceholderRequest, createC11nService, deletePlaceholderTemplateEntity, failPlaceholderRequestEntity, getAnalyticEvents, getAnalyticEventsRec, getConfigId, getDefaultPlaceholderTemplateReducer, getDefaultplaceholderRequestReducer, getOtterLikeComponentInfo, getTranslations, getTranslationsRec, isComponentsMessage, isContainer, lazyArray, placeholderRequestAdapter, placeholderRequestInitialState, placeholderRequestReducer, placeholderRequestReducerFeatures, placeholderRequestStorageDeserializer, placeholderRequestStorageSerializer, placeholderRequestStorageSync, placeholderTemplateAdapter, placeholderTemplateInitialState, placeholderTemplateReducer, placeholderTemplateReducerFeatures, placeholderTemplateStorageDeserializer, placeholderTemplateStorageSync, registerCustomComponent, selectPlaceholderRenderedTemplates, selectPlaceholderRequestEntities, selectPlaceholderRequestEntityUsage, selectPlaceholderRequestState, selectPlaceholderTemplateEntities, selectPlaceholderTemplateEntity, selectPlaceholderTemplateState, selectSortedTemplates, setPlaceholderRequestEntityFromUrl, setPlaceholderTemplateEntity, updatePlaceholderRequestEntity, updatePlaceholderRequestEntitySync };
|
|
1435
|
+
export { C11N_PRESENTERS_MAP_TOKEN, C11N_REGISTER_FUNC_TOKEN, C11nDirective, C11nMockModule, C11nMockService, C11nModule, C11nService, CapitalizePipe, CapitalizePipeModule, ComponentsDevtoolsMessageService, ComponentsDevtoolsModule, DurationPipe, DurationPipeModule, INSPECTOR_CLASS, KeepWhiteSpacePipe, KeepWhiteSpacePipeModule, MockC11nDirective, O3rCapitalizePipe, O3rDurationPipe, O3rKeepWhiteSpacePipe, O3rReplaceWithBoldPipe, OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS, OTTER_COMPONENTS_DEVTOOLS_OPTIONS, OtterInspectorService, PLACEHOLDER_REQUEST_REDUCER_TOKEN, PLACEHOLDER_REQUEST_STORE_NAME, PLACEHOLDER_TEMPLATE_REDUCER_TOKEN, PLACEHOLDER_TEMPLATE_STORE_NAME, PlaceholderComponent, PlaceholderModule, PlaceholderRequestStoreModule, PlaceholderTemplateStoreModule, ReplaceWithBoldPipe, ReplaceWithBoldPipeModule, cancelPlaceholderRequest, createC11nService, deletePlaceholderTemplateEntity, failPlaceholderRequestEntity, getAnalyticEvents, getAnalyticEventsRec, getConfigId, getDefaultPlaceholderTemplateReducer, getDefaultplaceholderRequestReducer, getOtterLikeComponentInfo, getTranslations, getTranslationsRec, isComponentsMessage, isContainer, lazyArray, placeholderRequestAdapter, placeholderRequestInitialState, placeholderRequestReducer, placeholderRequestReducerFeatures, placeholderRequestStorageDeserializer, placeholderRequestStorageSerializer, placeholderRequestStorageSync, placeholderTemplateAdapter, placeholderTemplateInitialState, placeholderTemplateReducer, placeholderTemplateReducerFeatures, placeholderTemplateStorageDeserializer, placeholderTemplateStorageSync, registerCustomComponent, selectPlaceholderRenderedTemplates, selectPlaceholderRequestEntities, selectPlaceholderRequestEntityUsage, selectPlaceholderRequestState, selectPlaceholderTemplateEntities, selectPlaceholderTemplateEntity, selectPlaceholderTemplateMode, selectPlaceholderTemplateState, selectSortedTemplates, setPlaceholderRequestEntityFromUrl, setPlaceholderTemplateEntity, togglePlaceholderModeTemplate, updatePlaceholderRequestEntity, updatePlaceholderRequestEntitySync };
|
|
1418
1436
|
//# sourceMappingURL=o3r-components.mjs.map
|