@o3r/components 15.3.0-prerelease.9 → 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.
- package/fesm2022/o3r-components-rules-engine.mjs +321 -334
- package/fesm2022/o3r-components-rules-engine.mjs.map +1 -1
- package/fesm2022/o3r-components.mjs +1495 -1638
- package/fesm2022/o3r-components.mjs.map +1 -1
- package/package.json +12 -12
- package/schematics/ng-add/schema.json +0 -3
- package/types/o3r-components-rules-engine.d.ts +60 -66
- package/types/o3r-components-rules-engine.d.ts.map +1 -1
- package/types/o3r-components.d.ts +635 -641
- package/types/o3r-components.d.ts.map +1 -1
|
@@ -1,969 +1,697 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import * as i0 from
|
|
4
|
-
import {
|
|
5
|
-
import { takeUntilDestroyed } from
|
|
6
|
-
import * as i1 from
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { LoggerService } from
|
|
10
|
-
import { createEntityAdapter } from
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Buffers and emits data for lazy/progressive rendering of big lists
|
|
16
|
-
* That could solve issues with long-running tasks when trying to render an array
|
|
17
|
-
* of similar components.
|
|
18
|
-
* @param delayMs Delay between data emits
|
|
19
|
-
* @param concurrency Amount of elements that should be emitted at once
|
|
20
|
-
*/
|
|
1
|
+
import { BehaviorSubject, ReplaySubject, Subject, animationFrameScheduler, firstValueFrom, from, fromEvent, observeOn, of, sample } from "rxjs";
|
|
2
|
+
import { bufferCount, concatMap, delay, distinctUntilChanged, filter, map, mapTo, mergeMap, scan, switchMap, tap } from "rxjs/operators";
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, DestroyRef, Directive, Injectable, InjectionToken, Injector, Input, KeyValueDiffers, NgModule, Pipe, SimpleChange, ViewContainerRef, ViewEncapsulation, forwardRef, inject, makeEnvironmentProviders } from "@angular/core";
|
|
5
|
+
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
6
|
+
import * as i1 from "@ngrx/store";
|
|
7
|
+
import { Store, StoreModule, createAction, createFeatureSelector, createReducer, createSelector, on, props, provideState } from "@ngrx/store";
|
|
8
|
+
import { asyncEntitySerializer, asyncProps, asyncStoreItemAdapter, createEntityAsyncRequestAdapter, filterMessageContent, otterComponentInfoPropertyName, sendOtterMessage } from "@o3r/core";
|
|
9
|
+
import { LoggerService } from "@o3r/logger";
|
|
10
|
+
import { createEntityAdapter } from "@ngrx/entity";
|
|
11
|
+
import { AsyncPipe, CommonModule, DOCUMENT, NgTemplateOutlet } from "@angular/common";
|
|
12
|
+
import { NG_VALIDATORS, NG_VALUE_ACCESSOR, NgControl } from "@angular/forms";
|
|
21
13
|
function lazyArray(delayMs = 0, concurrency = 2) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (scanDidComplete) {
|
|
36
|
-
isFirstEmission = false;
|
|
37
|
-
}
|
|
38
|
-
}));
|
|
39
|
-
}));
|
|
40
|
-
};
|
|
14
|
+
let isFirstEmission = true;
|
|
15
|
+
return (source$) => {
|
|
16
|
+
return source$.pipe(mergeMap((items) => {
|
|
17
|
+
if (!isFirstEmission) return of(items);
|
|
18
|
+
return from(items).pipe(bufferCount(concurrency), concatMap((value, index) => {
|
|
19
|
+
return of(value).pipe(observeOn(animationFrameScheduler), delay(index * delayMs));
|
|
20
|
+
}), scan((acc, steps) => {
|
|
21
|
+
return [...acc, ...steps];
|
|
22
|
+
}, []), tap((scannedItems) => {
|
|
23
|
+
if (scannedItems.length === items.length) isFirstEmission = false;
|
|
24
|
+
}));
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
41
27
|
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Determine if the given message is a Components message
|
|
45
|
-
* @param message message to check
|
|
46
|
-
*/
|
|
47
28
|
const isComponentsMessage = (message) => {
|
|
48
|
-
|
|
49
|
-
|| message.dataType === 'connect'
|
|
50
|
-
|| message.dataType === 'selectedComponentInfo'
|
|
51
|
-
|| message.dataType === 'isComponentSelectionAvailable'
|
|
52
|
-
|| message.dataType === 'placeholderMode'
|
|
53
|
-
|| message.dataType === 'toggleInspector'
|
|
54
|
-
|| message.dataType === 'toggleHighlight'
|
|
55
|
-
|| message.dataType === 'changeHighlightConfiguration');
|
|
29
|
+
return message && (message.dataType === "requestMessages" || message.dataType === "connect" || message.dataType === "selectedComponentInfo" || message.dataType === "isComponentSelectionAvailable" || message.dataType === "placeholderMode" || message.dataType === "toggleInspector" || message.dataType === "toggleHighlight" || message.dataType === "changeHighlightConfiguration");
|
|
56
30
|
};
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
const ACTION_UPDATE_ENTITY_SYNC = '[PlaceholderRequest] update entity sync';
|
|
63
|
-
/** Action to cancel a Request ID registered in the store. Can happen from effect based on a switchMap for instance */
|
|
31
|
+
const ACTION_FAIL_ENTITIES = "[PlaceholderRequest] fail entities";
|
|
32
|
+
const ACTION_SET_ENTITY_FROM_URL = "[PlaceholderRequest] set entity from url";
|
|
33
|
+
const ACTION_CANCEL_REQUEST = "[PlaceholderRequest] cancel request";
|
|
34
|
+
const ACTION_UPDATE_ENTITY = "[PlaceholderRequest] update entity";
|
|
35
|
+
const ACTION_UPDATE_ENTITY_SYNC = "[PlaceholderRequest] update entity sync";
|
|
64
36
|
const cancelPlaceholderRequest = createAction(ACTION_CANCEL_REQUEST, props());
|
|
65
|
-
/** Action to update failureStatus for PlaceholderRequestModels */
|
|
66
37
|
const failPlaceholderRequestEntity = createAction(ACTION_FAIL_ENTITIES, props());
|
|
67
|
-
/** Action to update an entity */
|
|
68
38
|
const updatePlaceholderRequestEntity = createAction(ACTION_UPDATE_ENTITY, props());
|
|
69
|
-
/** Action to update an entity without impact on request id */
|
|
70
39
|
const updatePlaceholderRequestEntitySync = createAction(ACTION_UPDATE_ENTITY_SYNC, props());
|
|
71
|
-
/** Action to update PlaceholderRequest with known IDs, will create the entity with only the url, the call will be created in the effect */
|
|
72
40
|
const setPlaceholderRequestEntityFromUrl = createAction(ACTION_SET_ENTITY_FROM_URL, asyncProps());
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* PlaceholderRequest Store adapter
|
|
76
|
-
*/
|
|
77
|
-
const placeholderRequestAdapter = createEntityAsyncRequestAdapter(createEntityAdapter({
|
|
78
|
-
selectId: (model) => model.id
|
|
79
|
-
}));
|
|
80
|
-
/**
|
|
81
|
-
* PlaceholderRequest Store initial value
|
|
82
|
-
*/
|
|
83
|
-
const placeholderRequestInitialState = placeholderRequestAdapter.getInitialState({
|
|
84
|
-
requestIds: []
|
|
85
|
-
});
|
|
86
|
-
/**
|
|
87
|
-
* Reducers of Placeholder request store that handles the call to the placeholder template URL
|
|
88
|
-
*/
|
|
41
|
+
const placeholderRequestAdapter = createEntityAsyncRequestAdapter(createEntityAdapter({ selectId: (model) => model.id }));
|
|
42
|
+
const placeholderRequestInitialState = placeholderRequestAdapter.getInitialState({ requestIds: [] });
|
|
89
43
|
const placeholderRequestReducerFeatures = [
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
on(failPlaceholderRequestEntity, (state, payload) => {
|
|
133
|
-
return placeholderRequestAdapter.failRequestMany(asyncStoreItemAdapter.resolveRequest(state, payload.requestId), payload && payload.ids, payload.requestId);
|
|
134
|
-
})
|
|
44
|
+
on(cancelPlaceholderRequest, (state, action) => {
|
|
45
|
+
const id = action.id;
|
|
46
|
+
if (!id || !state.entities[id]) return state;
|
|
47
|
+
return placeholderRequestAdapter.updateOne({
|
|
48
|
+
id: action.id,
|
|
49
|
+
changes: asyncStoreItemAdapter.resolveRequest(state.entities[id], action.requestId)
|
|
50
|
+
}, asyncStoreItemAdapter.resolveRequest(state, action.requestId));
|
|
51
|
+
}),
|
|
52
|
+
on(updatePlaceholderRequestEntity, (state, action) => {
|
|
53
|
+
const currentEntity = state.entities[action.entity.id];
|
|
54
|
+
const newEntity = asyncStoreItemAdapter.resolveRequest({
|
|
55
|
+
...action.entity,
|
|
56
|
+
...asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity)
|
|
57
|
+
}, action.requestId);
|
|
58
|
+
return placeholderRequestAdapter.updateOne({
|
|
59
|
+
id: newEntity.id,
|
|
60
|
+
changes: newEntity
|
|
61
|
+
}, asyncStoreItemAdapter.resolveRequest(state, action.requestId));
|
|
62
|
+
}),
|
|
63
|
+
on(updatePlaceholderRequestEntitySync, (state, action) => {
|
|
64
|
+
return placeholderRequestAdapter.updateOne({
|
|
65
|
+
id: action.entity.id,
|
|
66
|
+
changes: { ...action.entity }
|
|
67
|
+
}, state);
|
|
68
|
+
}),
|
|
69
|
+
on(setPlaceholderRequestEntityFromUrl, (state, payload) => {
|
|
70
|
+
const currentEntity = state.entities[payload.id];
|
|
71
|
+
if (currentEntity && currentEntity.resolvedUrl === payload.resolvedUrl) return state;
|
|
72
|
+
let newEntity = {
|
|
73
|
+
id: payload.id,
|
|
74
|
+
resolvedUrl: payload.resolvedUrl,
|
|
75
|
+
used: true
|
|
76
|
+
};
|
|
77
|
+
if (currentEntity) newEntity = {
|
|
78
|
+
...asyncStoreItemAdapter.extractAsyncStoreItem(currentEntity),
|
|
79
|
+
...newEntity
|
|
80
|
+
};
|
|
81
|
+
return placeholderRequestAdapter.addOne(asyncStoreItemAdapter.addRequest(asyncStoreItemAdapter.initialize(newEntity), payload.requestId), asyncStoreItemAdapter.addRequest(state, payload.requestId));
|
|
82
|
+
}),
|
|
83
|
+
on(failPlaceholderRequestEntity, (state, payload) => {
|
|
84
|
+
return placeholderRequestAdapter.failRequestMany(asyncStoreItemAdapter.resolveRequest(state, payload.requestId), payload && payload.ids, payload.requestId);
|
|
85
|
+
})
|
|
135
86
|
];
|
|
136
|
-
/**
|
|
137
|
-
* PlaceholderRequest Store reducer
|
|
138
|
-
*/
|
|
139
87
|
const placeholderRequestReducer = createReducer(placeholderRequestInitialState, ...placeholderRequestReducerFeatures);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
* Name of the PlaceholderRequest Store
|
|
143
|
-
*/
|
|
144
|
-
const PLACEHOLDER_REQUEST_STORE_NAME = 'placeholderRequest';
|
|
145
|
-
|
|
146
|
-
/** Token of the PlaceholderRequest reducer */
|
|
147
|
-
const PLACEHOLDER_REQUEST_REDUCER_TOKEN = new InjectionToken('Feature PlaceholderRequest Reducer');
|
|
148
|
-
/** Provide default reducer for PlaceholderRequest store */
|
|
88
|
+
const PLACEHOLDER_REQUEST_STORE_NAME = "placeholderRequest";
|
|
89
|
+
const PLACEHOLDER_REQUEST_REDUCER_TOKEN = new InjectionToken("Feature PlaceholderRequest Reducer");
|
|
149
90
|
function getDefaultplaceholderRequestReducer() {
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* @deprecated Will be removed in v16. Use {@link providePlaceholderRequestStore} instead.
|
|
154
|
-
*/
|
|
155
|
-
class PlaceholderRequestStoreModule {
|
|
156
|
-
static forRoot(reducerFactory) {
|
|
157
|
-
return {
|
|
158
|
-
ngModule: PlaceholderRequestStoreModule,
|
|
159
|
-
providers: [
|
|
160
|
-
{ provide: PLACEHOLDER_REQUEST_REDUCER_TOKEN, useFactory: reducerFactory }
|
|
161
|
-
]
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PlaceholderRequestStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
165
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: PlaceholderRequestStoreModule, imports: [i1.StoreFeatureModule] }); }
|
|
166
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: PlaceholderRequestStoreModule, providers: [
|
|
167
|
-
{ provide: PLACEHOLDER_REQUEST_REDUCER_TOKEN, useFactory: getDefaultplaceholderRequestReducer }
|
|
168
|
-
], imports: [StoreModule.forFeature(PLACEHOLDER_REQUEST_STORE_NAME, PLACEHOLDER_REQUEST_REDUCER_TOKEN)] }); }
|
|
91
|
+
return placeholderRequestReducer;
|
|
169
92
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
93
|
+
var PlaceholderRequestStoreModule = class PlaceholderRequestStoreModule {
|
|
94
|
+
static forRoot(reducerFactory) {
|
|
95
|
+
return {
|
|
96
|
+
ngModule: PlaceholderRequestStoreModule,
|
|
97
|
+
providers: [{
|
|
98
|
+
provide: PLACEHOLDER_REQUEST_REDUCER_TOKEN,
|
|
99
|
+
useFactory: reducerFactory
|
|
100
|
+
}]
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
static {
|
|
104
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
105
|
+
minVersion: "12.0.0",
|
|
106
|
+
version: "22.2.3",
|
|
107
|
+
ngImport: i0,
|
|
108
|
+
type: PlaceholderRequestStoreModule,
|
|
109
|
+
deps: [],
|
|
110
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
static {
|
|
114
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
115
|
+
minVersion: "14.0.0",
|
|
116
|
+
version: "22.2.3",
|
|
117
|
+
ngImport: i0,
|
|
118
|
+
type: PlaceholderRequestStoreModule,
|
|
119
|
+
imports: [i1.StoreFeatureModule]
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
static {
|
|
123
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
124
|
+
minVersion: "12.0.0",
|
|
125
|
+
version: "22.2.3",
|
|
126
|
+
ngImport: i0,
|
|
127
|
+
type: PlaceholderRequestStoreModule,
|
|
128
|
+
providers: [{
|
|
129
|
+
provide: PLACEHOLDER_REQUEST_REDUCER_TOKEN,
|
|
130
|
+
useFactory: getDefaultplaceholderRequestReducer
|
|
131
|
+
}],
|
|
132
|
+
imports: [StoreModule.forFeature(PLACEHOLDER_REQUEST_STORE_NAME, PLACEHOLDER_REQUEST_REDUCER_TOKEN)]
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
137
|
+
minVersion: "12.0.0",
|
|
138
|
+
version: "22.2.3",
|
|
139
|
+
ngImport: i0,
|
|
140
|
+
type: PlaceholderRequestStoreModule,
|
|
141
|
+
decorators: [{
|
|
142
|
+
type: NgModule,
|
|
143
|
+
args: [{
|
|
144
|
+
imports: [StoreModule.forFeature(PLACEHOLDER_REQUEST_STORE_NAME, PLACEHOLDER_REQUEST_REDUCER_TOKEN)],
|
|
145
|
+
providers: [{
|
|
146
|
+
provide: PLACEHOLDER_REQUEST_REDUCER_TOKEN,
|
|
147
|
+
useFactory: getDefaultplaceholderRequestReducer
|
|
148
|
+
}]
|
|
149
|
+
}]
|
|
150
|
+
}]
|
|
151
|
+
});
|
|
185
152
|
function providePlaceholderRequestStore(reducerFactory) {
|
|
186
|
-
|
|
187
|
-
provideState(PLACEHOLDER_REQUEST_STORE_NAME, reducerFactory ? reducerFactory() : placeholderRequestReducer)
|
|
188
|
-
]);
|
|
153
|
+
return makeEnvironmentProviders([provideState(PLACEHOLDER_REQUEST_STORE_NAME, reducerFactory ? reducerFactory() : placeholderRequestReducer)]);
|
|
189
154
|
}
|
|
190
|
-
|
|
191
155
|
const selectPlaceholderRequestState = createFeatureSelector(PLACEHOLDER_REQUEST_STORE_NAME);
|
|
192
156
|
const { selectEntities: selectEntities$1 } = placeholderRequestAdapter.getSelectors();
|
|
193
|
-
/** Select the dictionary of PlaceholderRequest entities */
|
|
194
157
|
const selectPlaceholderRequestEntities = createSelector(selectPlaceholderRequestState, (state) => state && selectEntities$1(state));
|
|
195
|
-
/**
|
|
196
|
-
* Select a specific PlaceholderRequest entity using a raw url as id
|
|
197
|
-
* @param rawUrl
|
|
198
|
-
*/
|
|
199
158
|
const selectPlaceholderRequestEntityUsage = (rawUrl) => createSelector(selectPlaceholderRequestState, (state) => {
|
|
200
|
-
|
|
159
|
+
return state?.entities[rawUrl] ? state.entities[rawUrl].used : void 0;
|
|
201
160
|
});
|
|
202
|
-
|
|
203
161
|
const placeholderRequestStorageSerializer = asyncEntitySerializer;
|
|
204
162
|
const placeholderRequestStorageDeserializer = (rawObject) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
for (const id of rawObject.ids) {
|
|
210
|
-
storeObject.entities[id] = rawObject.entities[id];
|
|
211
|
-
}
|
|
212
|
-
return storeObject;
|
|
163
|
+
if (!rawObject || !rawObject.ids) return placeholderRequestInitialState;
|
|
164
|
+
const storeObject = placeholderRequestAdapter.getInitialState(rawObject);
|
|
165
|
+
for (const id of rawObject.ids) storeObject.entities[id] = rawObject.entities[id];
|
|
166
|
+
return storeObject;
|
|
213
167
|
};
|
|
214
168
|
const placeholderRequestStorageSync = {
|
|
215
|
-
|
|
216
|
-
|
|
169
|
+
serialize: placeholderRequestStorageSerializer,
|
|
170
|
+
deserialize: placeholderRequestStorageDeserializer
|
|
217
171
|
};
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
const
|
|
221
|
-
const ACTION_TOGGLE_MODE = '[PlaceholderTemplate] toggle mode';
|
|
222
|
-
/** Action to delete a specific entity */
|
|
172
|
+
const ACTION_DELETE_ENTITY = "[PlaceholderTemplate] delete entity";
|
|
173
|
+
const ACTION_SET_ENTITY = "[PlaceholderTemplate] set entity";
|
|
174
|
+
const ACTION_TOGGLE_MODE = "[PlaceholderTemplate] toggle mode";
|
|
223
175
|
const deletePlaceholderTemplateEntity = createAction(ACTION_DELETE_ENTITY, props());
|
|
224
|
-
/** Action to clear all placeholderTemplate and fill the store with the payload */
|
|
225
176
|
const setPlaceholderTemplateEntity = createAction(ACTION_SET_ENTITY, props());
|
|
226
177
|
const togglePlaceholderModeTemplate = createAction(ACTION_TOGGLE_MODE, props());
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
* PlaceholderTemplate Store adapter
|
|
230
|
-
*/
|
|
231
|
-
const placeholderTemplateAdapter = createEntityAdapter({
|
|
232
|
-
selectId: (model) => model.id
|
|
233
|
-
});
|
|
234
|
-
/**
|
|
235
|
-
* PlaceholderTemplate Store initial value
|
|
236
|
-
*/
|
|
237
|
-
const placeholderTemplateInitialState = placeholderTemplateAdapter.getInitialState({
|
|
238
|
-
mode: 'normal'
|
|
239
|
-
});
|
|
240
|
-
/**
|
|
241
|
-
* List of basic actions for PlaceholderTemplate Store
|
|
242
|
-
*/
|
|
178
|
+
const placeholderTemplateAdapter = createEntityAdapter({ selectId: (model) => model.id });
|
|
179
|
+
const placeholderTemplateInitialState = placeholderTemplateAdapter.getInitialState({ mode: "normal" });
|
|
243
180
|
const placeholderTemplateReducerFeatures = [
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
};
|
|
257
|
-
})
|
|
181
|
+
on(setPlaceholderTemplateEntity, (state, payload) => placeholderTemplateAdapter.addOne(payload.entity, placeholderTemplateAdapter.removeOne(payload.entity.id, state))),
|
|
182
|
+
on(deletePlaceholderTemplateEntity, (state, payload) => {
|
|
183
|
+
const id = payload.id;
|
|
184
|
+
if (!id || !state.entities[id]) return state;
|
|
185
|
+
return placeholderTemplateAdapter.removeOne(id, state);
|
|
186
|
+
}),
|
|
187
|
+
on(togglePlaceholderModeTemplate, (state, payload) => {
|
|
188
|
+
return {
|
|
189
|
+
...state,
|
|
190
|
+
mode: payload.mode
|
|
191
|
+
};
|
|
192
|
+
})
|
|
258
193
|
];
|
|
259
|
-
/**
|
|
260
|
-
* PlaceholderTemplate Store reducer
|
|
261
|
-
*/
|
|
262
194
|
const placeholderTemplateReducer = createReducer(placeholderTemplateInitialState, ...placeholderTemplateReducerFeatures);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
* Name of the PlaceholderTemplate Store
|
|
266
|
-
*/
|
|
267
|
-
const PLACEHOLDER_TEMPLATE_STORE_NAME = 'placeholderTemplate';
|
|
268
|
-
|
|
269
|
-
/** Token of the PlaceholderTemplate reducer */
|
|
270
|
-
const PLACEHOLDER_TEMPLATE_REDUCER_TOKEN = new InjectionToken('Feature PlaceholderTemplate Reducer');
|
|
271
|
-
/** Provide default reducer for PlaceholderTemplate store */
|
|
195
|
+
const PLACEHOLDER_TEMPLATE_STORE_NAME = "placeholderTemplate";
|
|
196
|
+
const PLACEHOLDER_TEMPLATE_REDUCER_TOKEN = new InjectionToken("Feature PlaceholderTemplate Reducer");
|
|
272
197
|
function getDefaultPlaceholderTemplateReducer() {
|
|
273
|
-
|
|
198
|
+
return placeholderTemplateReducer;
|
|
274
199
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
200
|
+
var PlaceholderTemplateStoreModule = class PlaceholderTemplateStoreModule {
|
|
201
|
+
static forRoot(reducerFactory) {
|
|
202
|
+
return {
|
|
203
|
+
ngModule: PlaceholderTemplateStoreModule,
|
|
204
|
+
providers: [{
|
|
205
|
+
provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN,
|
|
206
|
+
useFactory: reducerFactory
|
|
207
|
+
}]
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
static {
|
|
211
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
212
|
+
minVersion: "12.0.0",
|
|
213
|
+
version: "22.2.3",
|
|
214
|
+
ngImport: i0,
|
|
215
|
+
type: PlaceholderTemplateStoreModule,
|
|
216
|
+
deps: [],
|
|
217
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
static {
|
|
221
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
222
|
+
minVersion: "14.0.0",
|
|
223
|
+
version: "22.2.3",
|
|
224
|
+
ngImport: i0,
|
|
225
|
+
type: PlaceholderTemplateStoreModule,
|
|
226
|
+
imports: [i1.StoreFeatureModule]
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
static {
|
|
230
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
231
|
+
minVersion: "12.0.0",
|
|
232
|
+
version: "22.2.3",
|
|
233
|
+
ngImport: i0,
|
|
234
|
+
type: PlaceholderTemplateStoreModule,
|
|
235
|
+
providers: [{
|
|
236
|
+
provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN,
|
|
237
|
+
useFactory: getDefaultPlaceholderTemplateReducer
|
|
238
|
+
}],
|
|
239
|
+
imports: [StoreModule.forFeature(PLACEHOLDER_TEMPLATE_STORE_NAME, PLACEHOLDER_TEMPLATE_REDUCER_TOKEN)]
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
244
|
+
minVersion: "12.0.0",
|
|
245
|
+
version: "22.2.3",
|
|
246
|
+
ngImport: i0,
|
|
247
|
+
type: PlaceholderTemplateStoreModule,
|
|
248
|
+
decorators: [{
|
|
249
|
+
type: NgModule,
|
|
250
|
+
args: [{
|
|
251
|
+
imports: [StoreModule.forFeature(PLACEHOLDER_TEMPLATE_STORE_NAME, PLACEHOLDER_TEMPLATE_REDUCER_TOKEN)],
|
|
252
|
+
providers: [{
|
|
253
|
+
provide: PLACEHOLDER_TEMPLATE_REDUCER_TOKEN,
|
|
254
|
+
useFactory: getDefaultPlaceholderTemplateReducer
|
|
255
|
+
}]
|
|
256
|
+
}]
|
|
257
|
+
}]
|
|
258
|
+
});
|
|
308
259
|
function providePlaceholderTemplateStore(reducerFactory) {
|
|
309
|
-
|
|
310
|
-
provideState(PLACEHOLDER_TEMPLATE_STORE_NAME, reducerFactory ? reducerFactory() : placeholderTemplateReducer)
|
|
311
|
-
]);
|
|
260
|
+
return makeEnvironmentProviders([provideState(PLACEHOLDER_TEMPLATE_STORE_NAME, reducerFactory ? reducerFactory() : placeholderTemplateReducer)]);
|
|
312
261
|
}
|
|
313
|
-
|
|
314
262
|
const { selectEntities } = placeholderTemplateAdapter.getSelectors();
|
|
315
263
|
const selectPlaceholderTemplateState = createFeatureSelector(PLACEHOLDER_TEMPLATE_STORE_NAME);
|
|
316
|
-
/** Select the dictionary of PlaceholderTemplate entities */
|
|
317
264
|
const selectPlaceholderTemplateEntities = createSelector(selectPlaceholderTemplateState, (state) => state && selectEntities(state));
|
|
318
|
-
/**
|
|
319
|
-
* Select a specific PlaceholderTemplate
|
|
320
|
-
* @param placeholderId
|
|
321
|
-
*/
|
|
322
265
|
const selectPlaceholderTemplateEntity = (placeholderId) => createSelector(selectPlaceholderTemplateState, (state) => state?.entities[placeholderId]);
|
|
323
|
-
/**
|
|
324
|
-
* Select the ordered rendered placeholder template full data (url, priority etc.) for a given placeholderId
|
|
325
|
-
* Return undefined if the placeholder is not found
|
|
326
|
-
* Returns {orderedRenderedTemplates: undefined, isPending: true} if any of the request is still pending
|
|
327
|
-
* @param placeholderId
|
|
328
|
-
*/
|
|
329
266
|
const selectSortedTemplates = (placeholderId) => createSelector(selectPlaceholderTemplateEntity(placeholderId), selectPlaceholderRequestState, (placeholderTemplate, placeholderRequestState) => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
}
|
|
356
|
-
// Sort templates by priority
|
|
357
|
-
const orderedTemplates = templates.toSorted((template1, template2) => {
|
|
358
|
-
return (template2.priority - template1.priority) || 1;
|
|
359
|
-
}).filter((templateData) => !!templateData.renderedTemplate);
|
|
360
|
-
return { orderedTemplates, isPending };
|
|
267
|
+
if (!placeholderTemplate || !placeholderRequestState) return;
|
|
268
|
+
let isPending = false;
|
|
269
|
+
const templates = [];
|
|
270
|
+
placeholderTemplate.urlsWithPriority.forEach((urlWithPriority) => {
|
|
271
|
+
const placeholderRequest = placeholderRequestState.entities[urlWithPriority.rawUrl];
|
|
272
|
+
if (placeholderRequest) {
|
|
273
|
+
isPending = isPending || placeholderRequest.isPending;
|
|
274
|
+
if (!placeholderRequest.isFailure) templates.push({
|
|
275
|
+
rawUrl: urlWithPriority.rawUrl,
|
|
276
|
+
resolvedUrl: placeholderRequest.resolvedUrl,
|
|
277
|
+
priority: urlWithPriority.priority,
|
|
278
|
+
renderedTemplate: placeholderRequest.renderedTemplate
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
if (isPending) return {
|
|
283
|
+
orderedTemplates: void 0,
|
|
284
|
+
isPending
|
|
285
|
+
};
|
|
286
|
+
return {
|
|
287
|
+
orderedTemplates: templates.toSorted((template1, template2) => {
|
|
288
|
+
return template2.priority - template1.priority || 1;
|
|
289
|
+
}).filter((templateData) => !!templateData.renderedTemplate),
|
|
290
|
+
isPending
|
|
291
|
+
};
|
|
361
292
|
});
|
|
362
293
|
const selectPlaceholderTemplateMode = createSelector(selectPlaceholderTemplateState, (state) => state.mode);
|
|
363
|
-
|
|
364
294
|
const placeholderTemplateStorageDeserializer = (rawObject) => {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
for (const id of rawObject.ids) {
|
|
370
|
-
storeObject.entities[id] = rawObject.entities[id];
|
|
371
|
-
}
|
|
372
|
-
return storeObject;
|
|
373
|
-
};
|
|
374
|
-
const placeholderTemplateStorageSync = {
|
|
375
|
-
deserialize: placeholderTemplateStorageDeserializer
|
|
295
|
+
if (!rawObject || !rawObject.ids) return placeholderTemplateInitialState;
|
|
296
|
+
const storeObject = placeholderTemplateAdapter.getInitialState(rawObject);
|
|
297
|
+
for (const id of rawObject.ids) storeObject.entities[id] = rawObject.entities[id];
|
|
298
|
+
return storeObject;
|
|
376
299
|
};
|
|
377
|
-
|
|
378
|
-
const OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS = {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
|
|
383
|
-
/**
|
|
384
|
-
* Class applied on the wrapper of highlight elements
|
|
385
|
-
*/
|
|
386
|
-
const HIGHLIGHT_WRAPPER_CLASS = 'highlight-wrapper';
|
|
387
|
-
/**
|
|
388
|
-
* Class applied on the overlay elements
|
|
389
|
-
*/
|
|
390
|
-
const HIGHLIGHT_OVERLAY_CLASS = 'highlight-overlay';
|
|
391
|
-
/**
|
|
392
|
-
* Class applied on the chip elements
|
|
393
|
-
*/
|
|
394
|
-
const HIGHLIGHT_CHIP_CLASS = 'highlight-chip';
|
|
395
|
-
/**
|
|
396
|
-
* Default value for maximum number of ancestors
|
|
397
|
-
*/
|
|
398
|
-
const DEFAULT_MAX_DEPTH = 10;
|
|
399
|
-
/**
|
|
400
|
-
* Default value for element min height
|
|
401
|
-
*/
|
|
402
|
-
const DEFAULT_ELEMENT_MIN_HEIGHT = 30;
|
|
403
|
-
/**
|
|
404
|
-
* Default value for element min width
|
|
405
|
-
*/
|
|
406
|
-
const DEFAULT_ELEMENT_MIN_WIDTH = 60;
|
|
407
|
-
/**
|
|
408
|
-
* Default value for throttle interval
|
|
409
|
-
*/
|
|
410
|
-
const DEFAULT_THROTTLE_INTERVAL = 500;
|
|
411
|
-
/**
|
|
412
|
-
* Default value for chips opacity
|
|
413
|
-
*/
|
|
414
|
-
const DEFAULT_CHIPS_OPACITY = 1;
|
|
415
|
-
/**
|
|
416
|
-
* Default value for auto refresh activation
|
|
417
|
-
*/
|
|
418
|
-
const DEFAULT_AUTO_REFRESH = true;
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Retrieve the identifier of the element
|
|
422
|
-
* @param element
|
|
423
|
-
*/
|
|
300
|
+
const placeholderTemplateStorageSync = { deserialize: placeholderTemplateStorageDeserializer };
|
|
301
|
+
const OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS = { isActivatedOnBootstrap: false };
|
|
302
|
+
const OTTER_COMPONENTS_DEVTOOLS_OPTIONS = new InjectionToken("Otter Components Devtools options");
|
|
303
|
+
const HIGHLIGHT_WRAPPER_CLASS = "highlight-wrapper";
|
|
304
|
+
const HIGHLIGHT_OVERLAY_CLASS = "highlight-overlay";
|
|
305
|
+
const HIGHLIGHT_CHIP_CLASS = "highlight-chip";
|
|
424
306
|
function getIdentifier(element) {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
return className;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
return tagName;
|
|
307
|
+
const { tagName, attributes, classList } = element.htmlElement;
|
|
308
|
+
const regexp = new RegExp(element.regexp, "i");
|
|
309
|
+
if (!regexp.test(tagName)) {
|
|
310
|
+
const attribute = Array.from(attributes).find((attr) => regexp.test(attr.name));
|
|
311
|
+
if (attribute) return `${attribute.name}${attribute.value ? `="${attribute.value}"` : ""}`;
|
|
312
|
+
const className = Array.from(classList).find((cName) => regexp.test(cName));
|
|
313
|
+
if (className) return className;
|
|
314
|
+
}
|
|
315
|
+
return tagName;
|
|
438
316
|
}
|
|
439
|
-
/**
|
|
440
|
-
* Filters a list of HTML elements and returns those that match specific group information.
|
|
441
|
-
*
|
|
442
|
-
* Each element is checked against a set of criteria:
|
|
443
|
-
* - The element's dimensions must meet the minimum height and width requirements.
|
|
444
|
-
* - The element's tag name, attributes, or class names must match a regular expression defined in the group information.
|
|
445
|
-
* @param elements An array of HTML elements to filter.
|
|
446
|
-
* @param elementMinHeight The min height required for each element to be considered in the computation
|
|
447
|
-
* @param elementMinWidth The min width required for each element to be considered in the computation
|
|
448
|
-
* @param groupsInfo The config that describes the HTML tags to check
|
|
449
|
-
* @returns An array of objects containing the matching elements and their associated group information
|
|
450
|
-
*/
|
|
451
317
|
function filterElementsWithInfo(elements, elementMinHeight, elementMinWidth, groupsInfo) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
return acc;
|
|
467
|
-
}, []);
|
|
318
|
+
return elements.reduce((acc, element) => {
|
|
319
|
+
const { height, width } = element.getBoundingClientRect();
|
|
320
|
+
if (height < elementMinHeight || width < elementMinWidth) return acc;
|
|
321
|
+
const elementInfo = Object.values(groupsInfo).find((info) => {
|
|
322
|
+
const regexp = new RegExp(info.regexp, "i");
|
|
323
|
+
return regexp.test(element.tagName) || Array.from(element.attributes).some((attr) => regexp.test(attr.name)) || Array.from(element.classList).some((cName) => regexp.test(cName));
|
|
324
|
+
});
|
|
325
|
+
if (elementInfo) return acc.concat({
|
|
326
|
+
...elementInfo,
|
|
327
|
+
htmlElement: element
|
|
328
|
+
});
|
|
329
|
+
return acc;
|
|
330
|
+
}, []);
|
|
468
331
|
}
|
|
469
|
-
/**
|
|
470
|
-
* Compute the number of ancestors of a given element based on a list of elements
|
|
471
|
-
* @param element
|
|
472
|
-
* @param elementList
|
|
473
|
-
*/
|
|
474
332
|
function computeNumberOfAncestors(element, elementList) {
|
|
475
|
-
|
|
333
|
+
return elementList.filter((el) => el.contains(element)).length;
|
|
476
334
|
}
|
|
477
|
-
/**
|
|
478
|
-
* Throttle {@link fn} with a {@link delay}
|
|
479
|
-
* @param fn method to run
|
|
480
|
-
* @param delay given in ms
|
|
481
|
-
*/
|
|
482
335
|
function throttle(fn, delay) {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
336
|
+
let timerFlag = null;
|
|
337
|
+
const throttleFn = (...args) => {
|
|
338
|
+
if (timerFlag === null) {
|
|
339
|
+
fn(...args);
|
|
340
|
+
timerFlag = setTimeout(() => {
|
|
341
|
+
timerFlag = null;
|
|
342
|
+
}, delay);
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
return throttleFn;
|
|
493
346
|
}
|
|
494
|
-
/**
|
|
495
|
-
* Run {@link refreshFn} if {@link mutations} implies to refresh elements inside {@link highlightWrapper}
|
|
496
|
-
* @param mutations
|
|
497
|
-
* @param highlightWrapper
|
|
498
|
-
* @param refreshFn
|
|
499
|
-
*/
|
|
500
347
|
function runRefreshIfNeeded(mutations, highlightWrapper, refreshFn) {
|
|
501
|
-
|
|
502
|
-
|| (mutation.target === document.body
|
|
503
|
-
&& Array.from(mutation.addedNodes.values())
|
|
504
|
-
.concat(...mutation.removedNodes.values())
|
|
505
|
-
.some((node) => !node.classList.contains(HIGHLIGHT_WRAPPER_CLASS))))) {
|
|
506
|
-
refreshFn();
|
|
507
|
-
}
|
|
348
|
+
if (mutations.some((mutation) => mutation.target !== highlightWrapper || mutation.target === document.body && Array.from(mutation.addedNodes.values()).concat(...mutation.removedNodes.values()).some((node) => !node.classList.contains("highlight-wrapper")))) refreshFn();
|
|
508
349
|
}
|
|
509
|
-
/**
|
|
510
|
-
* Create an overlay element
|
|
511
|
-
* @param doc HTML Document
|
|
512
|
-
* @param opts
|
|
513
|
-
* @param depth
|
|
514
|
-
*/
|
|
515
350
|
function createOverlay(doc, opts, depth) {
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
return overlay;
|
|
351
|
+
const overlay = doc.createElement("div");
|
|
352
|
+
overlay.classList.add(HIGHLIGHT_OVERLAY_CLASS);
|
|
353
|
+
overlay.style.top = opts.top;
|
|
354
|
+
overlay.style.left = opts.left;
|
|
355
|
+
overlay.style.width = opts.width;
|
|
356
|
+
overlay.style.height = opts.height;
|
|
357
|
+
overlay.style.border = `2px ${depth % 2 === 0 ? "solid" : "dotted"} ${opts.backgroundColor}`;
|
|
358
|
+
overlay.style.zIndex = "10000";
|
|
359
|
+
overlay.style.position = opts.position;
|
|
360
|
+
overlay.style.pointerEvents = "none";
|
|
361
|
+
return overlay;
|
|
528
362
|
}
|
|
529
|
-
/**
|
|
530
|
-
* Create a chip element
|
|
531
|
-
* @param doc HTML Document
|
|
532
|
-
* @param opts
|
|
533
|
-
* @param overlay
|
|
534
|
-
*/
|
|
535
363
|
function createChip(doc, opts, overlay) {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
overlay.style.transition = 'box-shadow 0.3s ease-in-out';
|
|
566
|
-
return chip;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
class HighlightService {
|
|
570
|
-
constructor() {
|
|
571
|
-
/**
|
|
572
|
-
* Group information
|
|
573
|
-
* Value could be changed through chrome extension options
|
|
574
|
-
*/
|
|
575
|
-
this.groupsInfo = {};
|
|
576
|
-
/**
|
|
577
|
-
* Maximum number of components ancestor
|
|
578
|
-
* Value could be changed through chrome extension view
|
|
579
|
-
*/
|
|
580
|
-
this.maxDepth = DEFAULT_MAX_DEPTH;
|
|
581
|
-
/**
|
|
582
|
-
* Element min height to be considered
|
|
583
|
-
* Value could be changed through chrome extension options
|
|
584
|
-
*/
|
|
585
|
-
this.elementMinHeight = DEFAULT_ELEMENT_MIN_HEIGHT;
|
|
586
|
-
/**
|
|
587
|
-
* Element min width to be considered
|
|
588
|
-
* Value could be changed through chrome extension options
|
|
589
|
-
*/
|
|
590
|
-
this.elementMinWidth = DEFAULT_ELEMENT_MIN_WIDTH;
|
|
591
|
-
/**
|
|
592
|
-
* Throttle interval to refresh the highlight elements
|
|
593
|
-
* Value could be changed through chrome extension options
|
|
594
|
-
*/
|
|
595
|
-
this.throttleInterval = DEFAULT_THROTTLE_INTERVAL;
|
|
596
|
-
/**
|
|
597
|
-
* Opacity of the chips
|
|
598
|
-
* Value could be changed through chrome extension options
|
|
599
|
-
*/
|
|
600
|
-
this.chipsOpacity = DEFAULT_CHIPS_OPACITY;
|
|
601
|
-
/**
|
|
602
|
-
* Whether to activate the auto refresh of the highlight
|
|
603
|
-
* Value could be changed through chrome extension view
|
|
604
|
-
*/
|
|
605
|
-
this.autoRefresh = DEFAULT_AUTO_REFRESH;
|
|
606
|
-
this.singleRun = false;
|
|
607
|
-
this.document = inject(DOCUMENT);
|
|
608
|
-
this.mutationObserver = new MutationObserver((mutations) => runRefreshIfNeeded(mutations, this.getHighlightWrapper(), () => this.throttleRun?.()));
|
|
609
|
-
this.resizeObserver = new ResizeObserver(() => this.throttleRun?.());
|
|
610
|
-
inject(DestroyRef).onDestroy(() => this.stop());
|
|
611
|
-
}
|
|
612
|
-
getHighlightWrapper() {
|
|
613
|
-
return this.document.body.querySelector(`.${HIGHLIGHT_WRAPPER_CLASS}`);
|
|
614
|
-
}
|
|
615
|
-
cleanHighlightWrapper() {
|
|
616
|
-
this.getHighlightWrapper()?.querySelectorAll('*').forEach((node) => node.remove());
|
|
617
|
-
}
|
|
618
|
-
initializeHighlightWrapper() {
|
|
619
|
-
let wrapper = this.getHighlightWrapper();
|
|
620
|
-
if (!wrapper) {
|
|
621
|
-
wrapper = this.document.createElement('div');
|
|
622
|
-
wrapper.classList.add(HIGHLIGHT_WRAPPER_CLASS);
|
|
623
|
-
this.document.body.append(wrapper);
|
|
624
|
-
}
|
|
625
|
-
this.cleanHighlightWrapper();
|
|
626
|
-
}
|
|
627
|
-
run() {
|
|
628
|
-
this.initializeHighlightWrapper();
|
|
629
|
-
const wrapper = this.getHighlightWrapper();
|
|
630
|
-
// We have to select all elements from document because
|
|
631
|
-
// with CSS Selector it's impossible to select element
|
|
632
|
-
// by regex on their `tagName`, attribute name or attribute value.
|
|
633
|
-
const allHTMLElements = Array.from(this.document.body.querySelectorAll('*'));
|
|
634
|
-
const elementsWithInfo = filterElementsWithInfo(allHTMLElements, this.elementMinHeight, this.elementMinWidth, this.groupsInfo);
|
|
635
|
-
const elementsWithInfoAndDepth = elementsWithInfo
|
|
636
|
-
.reduce((acc, elementWithInfo, _, array) => {
|
|
637
|
-
const depth = computeNumberOfAncestors(elementWithInfo.htmlElement, array.map((e) => e.htmlElement));
|
|
638
|
-
if (depth <= this.maxDepth) {
|
|
639
|
-
return acc.concat({
|
|
640
|
-
...elementWithInfo,
|
|
641
|
-
depth
|
|
642
|
-
});
|
|
643
|
-
}
|
|
644
|
-
return acc;
|
|
645
|
-
}, []);
|
|
646
|
-
const overlayData = {};
|
|
647
|
-
elementsWithInfoAndDepth.forEach((item) => {
|
|
648
|
-
const { htmlElement: element, backgroundColor, color, displayName, depth } = item;
|
|
649
|
-
const rect = element.getBoundingClientRect();
|
|
650
|
-
const position = element.computedStyleMap().get('position')?.toString() === 'fixed' ? 'fixed' : 'absolute';
|
|
651
|
-
const top = `${position === 'fixed' ? rect.top : (rect.top + window.scrollY)}px`;
|
|
652
|
-
const left = `${position === 'fixed' ? rect.left : (rect.left + window.scrollX)}px`;
|
|
653
|
-
const overlay = createOverlay(this.document, {
|
|
654
|
-
top, left, width: `${rect.width}px`, height: `${rect.height}px`, position, backgroundColor
|
|
655
|
-
}, depth);
|
|
656
|
-
const chip = createChip(this.document, {
|
|
657
|
-
displayName,
|
|
658
|
-
depth,
|
|
659
|
-
top,
|
|
660
|
-
left,
|
|
661
|
-
backgroundColor,
|
|
662
|
-
color,
|
|
663
|
-
position,
|
|
664
|
-
name: getIdentifier(item),
|
|
665
|
-
opacity: this.chipsOpacity
|
|
666
|
-
}, overlay);
|
|
667
|
-
wrapper.append(overlay);
|
|
668
|
-
wrapper.append(chip);
|
|
669
|
-
const positionKey = `${top};${left}`;
|
|
670
|
-
if (!overlayData[positionKey]) {
|
|
671
|
-
overlayData[positionKey] = [];
|
|
672
|
-
}
|
|
673
|
-
overlayData[positionKey].push({ chip, overlay, depth });
|
|
674
|
-
});
|
|
675
|
-
Object.values(overlayData).forEach((chips) => {
|
|
676
|
-
chips
|
|
677
|
-
.toSorted(({ depth: depthA }, { depth: depthB }) => depthA - depthB)
|
|
678
|
-
.forEach(({ chip, overlay }, index, array) => {
|
|
679
|
-
if (index !== 0) {
|
|
680
|
-
// In case of overlap,
|
|
681
|
-
// we should translate the chip to have it visible
|
|
682
|
-
// and reduce the size of the overlay.
|
|
683
|
-
const translateX = array.slice(0, index).reduce((sum, e) => sum + e.chip.getBoundingClientRect().width, 0);
|
|
684
|
-
chip.style.transform = `translateX(${translateX}px)`;
|
|
685
|
-
overlay.style.margin = `${index}px 0 0 ${index}px`;
|
|
686
|
-
overlay.style.width = `${+overlay.style.width.replace('px', '') - 2 * index}px`;
|
|
687
|
-
overlay.style.height = `${+overlay.style.height.replace('px', '') - 2 * index}px`;
|
|
688
|
-
overlay.style.zIndex = `${+overlay.style.zIndex - index}`;
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
});
|
|
692
|
-
}
|
|
693
|
-
/**
|
|
694
|
-
* Returns true if the highlight is displayed
|
|
695
|
-
*/
|
|
696
|
-
isRunning() {
|
|
697
|
-
return !!this.throttleRun || this.singleRun;
|
|
698
|
-
}
|
|
699
|
-
/**
|
|
700
|
-
* Start the highlight of elements
|
|
701
|
-
*/
|
|
702
|
-
start() {
|
|
703
|
-
this.stop();
|
|
704
|
-
if (!this.autoRefresh) {
|
|
705
|
-
this.run();
|
|
706
|
-
this.singleRun = true;
|
|
707
|
-
return;
|
|
708
|
-
}
|
|
709
|
-
this.throttleRun = throttle(() => this.run(), this.throttleInterval);
|
|
710
|
-
this.throttleRun();
|
|
711
|
-
this.document.addEventListener('scroll', this.throttleRun, true);
|
|
712
|
-
this.resizeObserver.observe(this.document.body);
|
|
713
|
-
this.mutationObserver.observe(this.document.body, { childList: true, subtree: true });
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* Stop the highlight of elements
|
|
717
|
-
*/
|
|
718
|
-
stop() {
|
|
719
|
-
this.cleanHighlightWrapper();
|
|
720
|
-
if (this.throttleRun) {
|
|
721
|
-
this.document.removeEventListener('scroll', this.throttleRun, true);
|
|
722
|
-
this.resizeObserver.disconnect();
|
|
723
|
-
this.mutationObserver.disconnect();
|
|
724
|
-
this.throttleRun = undefined;
|
|
725
|
-
this.singleRun = false;
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: HighlightService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
729
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: HighlightService, providedIn: 'root' }); }
|
|
364
|
+
const chip = doc.createElement("div");
|
|
365
|
+
chip.classList.add(HIGHLIGHT_CHIP_CLASS);
|
|
366
|
+
chip.textContent = `${opts.displayName} ${opts.depth}`;
|
|
367
|
+
chip.style.top = opts.top;
|
|
368
|
+
chip.style.left = opts.left;
|
|
369
|
+
chip.style.backgroundColor = opts.backgroundColor;
|
|
370
|
+
chip.style.color = opts.color ?? "#FFF";
|
|
371
|
+
chip.style.position = opts.position;
|
|
372
|
+
chip.style.display = "inline-block";
|
|
373
|
+
chip.style.padding = "2px 4px";
|
|
374
|
+
chip.style.borderRadius = "0 0 4px";
|
|
375
|
+
chip.style.cursor = "pointer";
|
|
376
|
+
chip.style.zIndex = "10000";
|
|
377
|
+
chip.style.textWrap = "no-wrap";
|
|
378
|
+
chip.style.opacity = opts.opacity?.toString() ?? "1";
|
|
379
|
+
chip.title = opts.name;
|
|
380
|
+
chip.addEventListener("click", () => {
|
|
381
|
+
navigator.clipboard.writeText(opts.name);
|
|
382
|
+
});
|
|
383
|
+
chip.addEventListener("mouseover", () => {
|
|
384
|
+
chip.style.opacity = "1";
|
|
385
|
+
overlay.style.boxShadow = `0 0 10px 3px ${opts.backgroundColor}`;
|
|
386
|
+
});
|
|
387
|
+
chip.addEventListener("mouseout", () => {
|
|
388
|
+
chip.style.opacity = opts.opacity?.toString() ?? "1";
|
|
389
|
+
overlay.style.boxShadow = "none";
|
|
390
|
+
});
|
|
391
|
+
overlay.style.transition = "box-shadow 0.3s ease-in-out";
|
|
392
|
+
return chip;
|
|
730
393
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
394
|
+
var HighlightService = class HighlightService {
|
|
395
|
+
constructor() {
|
|
396
|
+
this.groupsInfo = {};
|
|
397
|
+
this.maxDepth = 10;
|
|
398
|
+
this.elementMinHeight = 30;
|
|
399
|
+
this.elementMinWidth = 60;
|
|
400
|
+
this.throttleInterval = 500;
|
|
401
|
+
this.chipsOpacity = 1;
|
|
402
|
+
this.autoRefresh = true;
|
|
403
|
+
this.singleRun = false;
|
|
404
|
+
this.document = inject(DOCUMENT);
|
|
405
|
+
this.mutationObserver = new MutationObserver((mutations) => runRefreshIfNeeded(mutations, this.getHighlightWrapper(), () => this.throttleRun?.()));
|
|
406
|
+
this.resizeObserver = new ResizeObserver(() => this.throttleRun?.());
|
|
407
|
+
inject(DestroyRef).onDestroy(() => this.stop());
|
|
408
|
+
}
|
|
409
|
+
getHighlightWrapper() {
|
|
410
|
+
return this.document.body.querySelector(`.${HIGHLIGHT_WRAPPER_CLASS}`);
|
|
411
|
+
}
|
|
412
|
+
cleanHighlightWrapper() {
|
|
413
|
+
this.getHighlightWrapper()?.querySelectorAll("*").forEach((node) => node.remove());
|
|
414
|
+
}
|
|
415
|
+
initializeHighlightWrapper() {
|
|
416
|
+
let wrapper = this.getHighlightWrapper();
|
|
417
|
+
if (!wrapper) {
|
|
418
|
+
wrapper = this.document.createElement("div");
|
|
419
|
+
wrapper.classList.add(HIGHLIGHT_WRAPPER_CLASS);
|
|
420
|
+
this.document.body.append(wrapper);
|
|
421
|
+
}
|
|
422
|
+
this.cleanHighlightWrapper();
|
|
423
|
+
}
|
|
424
|
+
run() {
|
|
425
|
+
this.initializeHighlightWrapper();
|
|
426
|
+
const wrapper = this.getHighlightWrapper();
|
|
427
|
+
const elementsWithInfoAndDepth = filterElementsWithInfo(Array.from(this.document.body.querySelectorAll("*")), this.elementMinHeight, this.elementMinWidth, this.groupsInfo).reduce((acc, elementWithInfo, _, array) => {
|
|
428
|
+
const depth = computeNumberOfAncestors(elementWithInfo.htmlElement, array.map((e) => e.htmlElement));
|
|
429
|
+
if (depth <= this.maxDepth) return acc.concat({
|
|
430
|
+
...elementWithInfo,
|
|
431
|
+
depth
|
|
432
|
+
});
|
|
433
|
+
return acc;
|
|
434
|
+
}, []);
|
|
435
|
+
const overlayData = {};
|
|
436
|
+
elementsWithInfoAndDepth.forEach((item) => {
|
|
437
|
+
const { htmlElement: element, backgroundColor, color, displayName, depth } = item;
|
|
438
|
+
const rect = element.getBoundingClientRect();
|
|
439
|
+
const position = element.computedStyleMap().get("position")?.toString() === "fixed" ? "fixed" : "absolute";
|
|
440
|
+
const top = `${position === "fixed" ? rect.top : rect.top + window.scrollY}px`;
|
|
441
|
+
const left = `${position === "fixed" ? rect.left : rect.left + window.scrollX}px`;
|
|
442
|
+
const overlay = createOverlay(this.document, {
|
|
443
|
+
top,
|
|
444
|
+
left,
|
|
445
|
+
width: `${rect.width}px`,
|
|
446
|
+
height: `${rect.height}px`,
|
|
447
|
+
position,
|
|
448
|
+
backgroundColor
|
|
449
|
+
}, depth);
|
|
450
|
+
const chip = createChip(this.document, {
|
|
451
|
+
displayName,
|
|
452
|
+
depth,
|
|
453
|
+
top,
|
|
454
|
+
left,
|
|
455
|
+
backgroundColor,
|
|
456
|
+
color,
|
|
457
|
+
position,
|
|
458
|
+
name: getIdentifier(item),
|
|
459
|
+
opacity: this.chipsOpacity
|
|
460
|
+
}, overlay);
|
|
461
|
+
wrapper.append(overlay);
|
|
462
|
+
wrapper.append(chip);
|
|
463
|
+
const positionKey = `${top};${left}`;
|
|
464
|
+
if (!overlayData[positionKey]) overlayData[positionKey] = [];
|
|
465
|
+
overlayData[positionKey].push({
|
|
466
|
+
chip,
|
|
467
|
+
overlay,
|
|
468
|
+
depth
|
|
469
|
+
});
|
|
470
|
+
});
|
|
471
|
+
Object.values(overlayData).forEach((chips) => {
|
|
472
|
+
chips.toSorted(({ depth: depthA }, { depth: depthB }) => depthA - depthB).forEach(({ chip, overlay }, index, array) => {
|
|
473
|
+
if (index !== 0) {
|
|
474
|
+
const translateX = array.slice(0, index).reduce((sum, e) => sum + e.chip.getBoundingClientRect().width, 0);
|
|
475
|
+
chip.style.transform = `translateX(${translateX}px)`;
|
|
476
|
+
overlay.style.margin = `${index}px 0 0 ${index}px`;
|
|
477
|
+
overlay.style.width = `${+overlay.style.width.replace("px", "") - 2 * index}px`;
|
|
478
|
+
overlay.style.height = `${+overlay.style.height.replace("px", "") - 2 * index}px`;
|
|
479
|
+
overlay.style.zIndex = `${+overlay.style.zIndex - index}`;
|
|
480
|
+
}
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
isRunning() {
|
|
485
|
+
return !!this.throttleRun || this.singleRun;
|
|
486
|
+
}
|
|
487
|
+
start() {
|
|
488
|
+
this.stop();
|
|
489
|
+
if (!this.autoRefresh) {
|
|
490
|
+
this.run();
|
|
491
|
+
this.singleRun = true;
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
this.throttleRun = throttle(() => this.run(), this.throttleInterval);
|
|
495
|
+
this.throttleRun();
|
|
496
|
+
this.document.addEventListener("scroll", this.throttleRun, true);
|
|
497
|
+
this.resizeObserver.observe(this.document.body);
|
|
498
|
+
this.mutationObserver.observe(this.document.body, {
|
|
499
|
+
childList: true,
|
|
500
|
+
subtree: true
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
stop() {
|
|
504
|
+
this.cleanHighlightWrapper();
|
|
505
|
+
if (this.throttleRun) {
|
|
506
|
+
this.document.removeEventListener("scroll", this.throttleRun, true);
|
|
507
|
+
this.resizeObserver.disconnect();
|
|
508
|
+
this.mutationObserver.disconnect();
|
|
509
|
+
this.throttleRun = void 0;
|
|
510
|
+
this.singleRun = false;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
static {
|
|
514
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
515
|
+
minVersion: "12.0.0",
|
|
516
|
+
version: "22.2.3",
|
|
517
|
+
ngImport: i0,
|
|
518
|
+
type: HighlightService,
|
|
519
|
+
deps: [],
|
|
520
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
static {
|
|
524
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
525
|
+
minVersion: "12.0.0",
|
|
526
|
+
version: "22.2.3",
|
|
527
|
+
ngImport: i0,
|
|
528
|
+
type: HighlightService,
|
|
529
|
+
providedIn: "root"
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
};
|
|
533
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
534
|
+
minVersion: "12.0.0",
|
|
535
|
+
version: "22.2.3",
|
|
536
|
+
ngImport: i0,
|
|
537
|
+
type: HighlightService,
|
|
538
|
+
decorators: [{
|
|
539
|
+
type: Injectable,
|
|
540
|
+
args: [{ providedIn: "root" }]
|
|
541
|
+
}],
|
|
542
|
+
ctorParameters: () => []
|
|
543
|
+
});
|
|
544
|
+
const INSPECTOR_CLASS = "otter-devtools-inspector";
|
|
747
545
|
const isContainer = (node) => {
|
|
748
|
-
|
|
546
|
+
return !!node?.tagName.toLowerCase().endsWith("cont");
|
|
749
547
|
};
|
|
750
|
-
/**
|
|
751
|
-
* Determine the config id of a component instance
|
|
752
|
-
* @param instance component instance
|
|
753
|
-
* @returns the config id of the component instance
|
|
754
|
-
*/
|
|
755
548
|
const getConfigId = (instance) => {
|
|
756
|
-
|
|
549
|
+
return instance[otterComponentInfoPropertyName]?.configId;
|
|
757
550
|
};
|
|
758
|
-
/**
|
|
759
|
-
* Recursive method to determin the translations of a node
|
|
760
|
-
* @param node HTMLElement to check
|
|
761
|
-
* @param rec recursive method
|
|
762
|
-
* @returns the trasnslations associated to their component name
|
|
763
|
-
*/
|
|
764
551
|
function getTranslationsRec(node, rec) {
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
const componentTranslations = Object.values(component[o3rInfoProperty]?.translations || {}).filter((t) => typeof t === 'string');
|
|
783
|
-
if (componentTranslations.length > 0) {
|
|
784
|
-
translations[componentName] = componentTranslations;
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
return Object.keys(translations).length > 0 ? translations : undefined;
|
|
552
|
+
const angularDevTools = window.ng;
|
|
553
|
+
const o3rInfoProperty = "__otter-info__";
|
|
554
|
+
if (!node || !angularDevTools) return;
|
|
555
|
+
const component = angularDevTools.getComponent(node);
|
|
556
|
+
const subTranslations = Array.from(node.children).map((child) => rec(child, rec));
|
|
557
|
+
const translations = {};
|
|
558
|
+
subTranslations.forEach((s) => {
|
|
559
|
+
Object.entries(s || {}).forEach(([k, v]) => {
|
|
560
|
+
if (v.length > 0) translations[k] = v;
|
|
561
|
+
});
|
|
562
|
+
});
|
|
563
|
+
if (component) {
|
|
564
|
+
const componentName = component.constructor.name;
|
|
565
|
+
const componentTranslations = Object.values(component[o3rInfoProperty]?.translations || {}).filter((t) => typeof t === "string");
|
|
566
|
+
if (componentTranslations.length > 0) translations[componentName] = componentTranslations;
|
|
567
|
+
}
|
|
568
|
+
return Object.keys(translations).length > 0 ? translations : void 0;
|
|
788
569
|
}
|
|
789
|
-
/**
|
|
790
|
-
* Determine the translations of a node
|
|
791
|
-
* @param node HTMLElement to check
|
|
792
|
-
* @returns the translations associated to their component name
|
|
793
|
-
*/
|
|
794
570
|
const getTranslations = (node) => getTranslationsRec(node, getTranslations);
|
|
795
|
-
/**
|
|
796
|
-
* Recursive method to determine the analytics of a node
|
|
797
|
-
* @param node Element to check
|
|
798
|
-
* @param rec recursive method
|
|
799
|
-
* @returns the analytics associated to their component name
|
|
800
|
-
*/
|
|
801
571
|
function getAnalyticEventsRec(node, rec) {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
const componentEvents = Object.values(component.analyticsEvents || {}).map((eventConstructor) => eventConstructor.name);
|
|
820
|
-
if (componentEvents.length > 0) {
|
|
821
|
-
events[componentName] = componentEvents;
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
return Object.keys(events).length > 0 ? events : undefined;
|
|
572
|
+
const angularDevTools = window.ng;
|
|
573
|
+
const o3rInfoProperty = "__otter-info__";
|
|
574
|
+
if (!node || !angularDevTools) return;
|
|
575
|
+
const component = angularDevTools.getComponent(node);
|
|
576
|
+
const subEvents = Array.from(node.children).map((child) => rec(child, rec));
|
|
577
|
+
const events = {};
|
|
578
|
+
subEvents.forEach((s) => {
|
|
579
|
+
Object.entries(s || {}).forEach(([k, v]) => {
|
|
580
|
+
if (v.length > 0) events[k] = v;
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
if (component && component[o3rInfoProperty]) {
|
|
584
|
+
const componentName = component.constructor.name;
|
|
585
|
+
const componentEvents = Object.values(component.analyticsEvents || {}).map((eventConstructor) => eventConstructor.name);
|
|
586
|
+
if (componentEvents.length > 0) events[componentName] = componentEvents;
|
|
587
|
+
}
|
|
588
|
+
return Object.keys(events).length > 0 ? events : void 0;
|
|
825
589
|
}
|
|
826
|
-
/**
|
|
827
|
-
* Determine the analytics of a node
|
|
828
|
-
* @param node Element to check
|
|
829
|
-
* @returns the analytics associated to their component name
|
|
830
|
-
*/
|
|
831
590
|
const getAnalyticEvents = (node) => getAnalyticEventsRec(node, getAnalyticEvents);
|
|
832
|
-
/**
|
|
833
|
-
* Determine all info from an Otter component
|
|
834
|
-
* @param componentClassInstance component instance
|
|
835
|
-
* @param host HTML element hosting the component
|
|
836
|
-
* @returns all info from an Otter component
|
|
837
|
-
*/
|
|
838
591
|
const getOtterLikeComponentInfo = (componentClassInstance, host) => {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
};
|
|
592
|
+
const configId = getConfigId(componentClassInstance);
|
|
593
|
+
const translations = getTranslations(host);
|
|
594
|
+
const analytics = getAnalyticEvents(host);
|
|
595
|
+
return {
|
|
596
|
+
componentName: componentClassInstance.constructor.ɵcmp?.debugInfo?.className || componentClassInstance.constructor.name,
|
|
597
|
+
configId,
|
|
598
|
+
translations,
|
|
599
|
+
analytics
|
|
600
|
+
};
|
|
849
601
|
};
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}
|
|
944
|
-
unHighlight() {
|
|
945
|
-
if (this.selectedComponent?.host && this.inspectorDiv) {
|
|
946
|
-
this.inspectorDiv.style.width = '0';
|
|
947
|
-
this.inspectorDiv.style.height = '0';
|
|
948
|
-
this.inspectorDiv.style.top = '0';
|
|
949
|
-
this.inspectorDiv.style.left = '0';
|
|
950
|
-
}
|
|
951
|
-
this.selectedComponent = undefined;
|
|
952
|
-
}
|
|
953
|
-
cancelEvent(e) {
|
|
954
|
-
e.stopPropagation();
|
|
955
|
-
e.stopImmediatePropagation();
|
|
956
|
-
e.preventDefault();
|
|
957
|
-
}
|
|
958
|
-
/**
|
|
959
|
-
* Prepare the inspector div and add it to the DOM.
|
|
960
|
-
*/
|
|
961
|
-
prepareInspector() {
|
|
962
|
-
if (this.inspectorDiv) {
|
|
963
|
-
return;
|
|
964
|
-
}
|
|
965
|
-
const inspectorCss = document.createElement('style');
|
|
966
|
-
inspectorCss.textContent = `
|
|
602
|
+
var OtterInspectorService = class {
|
|
603
|
+
constructor() {
|
|
604
|
+
this.elementMouseOverCallback = this.elementMouseOver.bind(this);
|
|
605
|
+
this.elementClickCallback = this.elementClick.bind(this);
|
|
606
|
+
this.cancelEventCallback = this.cancelEvent.bind(this);
|
|
607
|
+
this.inspectorDiv = null;
|
|
608
|
+
this.otterLikeComponentInfoToBeSent = new BehaviorSubject(void 0);
|
|
609
|
+
this.otterLikeComponentInfoToBeSent$ = this.otterLikeComponentInfoToBeSent.asObservable();
|
|
610
|
+
this.angularDevTools = window.ng;
|
|
611
|
+
}
|
|
612
|
+
startInspecting() {
|
|
613
|
+
window.addEventListener("mouseover", this.elementMouseOverCallback, true);
|
|
614
|
+
window.addEventListener("click", this.elementClickCallback, true);
|
|
615
|
+
window.addEventListener("mouseout", this.cancelEventCallback, true);
|
|
616
|
+
}
|
|
617
|
+
elementClick(e) {
|
|
618
|
+
e.stopImmediatePropagation();
|
|
619
|
+
e.stopPropagation();
|
|
620
|
+
e.preventDefault();
|
|
621
|
+
if (!this.selectedComponent || !this.angularDevTools) return;
|
|
622
|
+
const parentElement = this.selectedComponent.host.parentElement;
|
|
623
|
+
const parent = parentElement && (this.angularDevTools.getComponent(parentElement) || this.angularDevTools.getOwningComponent(parentElement));
|
|
624
|
+
const parentHost = parent && this.angularDevTools.getHostElement(parent);
|
|
625
|
+
const container = isContainer(parentHost) ? getOtterLikeComponentInfo(parent, parentHost) : void 0;
|
|
626
|
+
const { component, host, ...infoToBeSent } = this.selectedComponent;
|
|
627
|
+
this.otterLikeComponentInfoToBeSent.next({
|
|
628
|
+
...infoToBeSent,
|
|
629
|
+
container
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
isOtterLikeComponent(info) {
|
|
633
|
+
const hasConfigId = !!info.configId;
|
|
634
|
+
const hasTranslations = !!info.translations?.length;
|
|
635
|
+
const hasAnalytics = Object.keys(info.analytics || {}).length > 0;
|
|
636
|
+
return hasConfigId || hasTranslations || hasAnalytics;
|
|
637
|
+
}
|
|
638
|
+
findComponentInfo(node) {
|
|
639
|
+
if (!this.angularDevTools) return;
|
|
640
|
+
let componentClassInstance = this.angularDevTools.getComponent(node) || this.angularDevTools.getOwningComponent(node);
|
|
641
|
+
let o3rLikeComponentInfo;
|
|
642
|
+
let isO3rLike;
|
|
643
|
+
if (!componentClassInstance) return;
|
|
644
|
+
do {
|
|
645
|
+
o3rLikeComponentInfo = getOtterLikeComponentInfo(componentClassInstance, this.angularDevTools.getHostElement(componentClassInstance));
|
|
646
|
+
isO3rLike = this.isOtterLikeComponent(o3rLikeComponentInfo);
|
|
647
|
+
if (!isO3rLike) componentClassInstance = this.angularDevTools.getOwningComponent(componentClassInstance);
|
|
648
|
+
} while (!isO3rLike && componentClassInstance);
|
|
649
|
+
if (isO3rLike) return {
|
|
650
|
+
component: componentClassInstance,
|
|
651
|
+
host: this.angularDevTools.getHostElement(componentClassInstance),
|
|
652
|
+
...o3rLikeComponentInfo
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
elementMouseOver(e) {
|
|
656
|
+
this.cancelEvent(e);
|
|
657
|
+
const el = e.target;
|
|
658
|
+
if (el) {
|
|
659
|
+
const selectedComponent = this.findComponentInfo(el);
|
|
660
|
+
if (selectedComponent?.host !== this.selectedComponent?.host) {
|
|
661
|
+
this.unHighlight();
|
|
662
|
+
this.highlight(selectedComponent);
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
highlight(selectedComponent) {
|
|
667
|
+
this.selectedComponent = selectedComponent;
|
|
668
|
+
if (this.selectedComponent?.host && this.inspectorDiv) {
|
|
669
|
+
const rect = this.selectedComponent.host.getBoundingClientRect();
|
|
670
|
+
this.inspectorDiv.style.width = `${rect.width}px`;
|
|
671
|
+
this.inspectorDiv.style.height = `${rect.height}px`;
|
|
672
|
+
this.inspectorDiv.style.top = `${rect.top}px`;
|
|
673
|
+
this.inspectorDiv.style.left = `${rect.left}px`;
|
|
674
|
+
this.inspectorDiv.firstChild.textContent = `<${this.selectedComponent.componentName}>`;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
unHighlight() {
|
|
678
|
+
if (this.selectedComponent?.host && this.inspectorDiv) {
|
|
679
|
+
this.inspectorDiv.style.width = "0";
|
|
680
|
+
this.inspectorDiv.style.height = "0";
|
|
681
|
+
this.inspectorDiv.style.top = "0";
|
|
682
|
+
this.inspectorDiv.style.left = "0";
|
|
683
|
+
}
|
|
684
|
+
this.selectedComponent = void 0;
|
|
685
|
+
}
|
|
686
|
+
cancelEvent(e) {
|
|
687
|
+
e.stopPropagation();
|
|
688
|
+
e.stopImmediatePropagation();
|
|
689
|
+
e.preventDefault();
|
|
690
|
+
}
|
|
691
|
+
prepareInspector() {
|
|
692
|
+
if (this.inspectorDiv) return;
|
|
693
|
+
const inspectorCss = document.createElement("style");
|
|
694
|
+
inspectorCss.textContent = `
|
|
967
695
|
.${INSPECTOR_CLASS} {
|
|
968
696
|
z-index: 9999999;
|
|
969
697
|
width: 0;
|
|
@@ -984,764 +712,893 @@ class OtterInspectorService {
|
|
|
984
712
|
border-radius: 5px;
|
|
985
713
|
color: white;
|
|
986
714
|
}`;
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
i0.ɵɵ
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
ComponentsDevtoolsMessageService
|
|
1173
|
-
], imports: [StoreModule,
|
|
1174
|
-
PlaceholderTemplateStoreModule] }); }
|
|
1175
|
-
}
|
|
1176
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: ComponentsDevtoolsModule, decorators: [{
|
|
1177
|
-
type: NgModule,
|
|
1178
|
-
args: [{
|
|
1179
|
-
imports: [
|
|
1180
|
-
StoreModule,
|
|
1181
|
-
PlaceholderTemplateStoreModule
|
|
1182
|
-
],
|
|
1183
|
-
providers: [
|
|
1184
|
-
{ provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS, useValue: OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS },
|
|
1185
|
-
ComponentsDevtoolsMessageService
|
|
1186
|
-
]
|
|
1187
|
-
}]
|
|
1188
|
-
}] });
|
|
1189
|
-
/**
|
|
1190
|
-
* Provide components devtools functionality.
|
|
1191
|
-
* @param options Components devtools options
|
|
1192
|
-
*/
|
|
715
|
+
const inspectorDiv = document.createElement("div");
|
|
716
|
+
const inspectorSpan = document.createElement("span");
|
|
717
|
+
inspectorDiv.append(inspectorSpan);
|
|
718
|
+
inspectorDiv.classList.add(INSPECTOR_CLASS);
|
|
719
|
+
document.head.append(inspectorCss);
|
|
720
|
+
document.body.append(inspectorDiv);
|
|
721
|
+
this.inspectorDiv = inspectorDiv;
|
|
722
|
+
}
|
|
723
|
+
toggleInspector(isRunning) {
|
|
724
|
+
if (isRunning) this.startInspecting();
|
|
725
|
+
else this.stopInspecting();
|
|
726
|
+
}
|
|
727
|
+
stopInspecting() {
|
|
728
|
+
this.unHighlight();
|
|
729
|
+
window.removeEventListener("mouseover", this.elementMouseOverCallback, true);
|
|
730
|
+
window.removeEventListener("click", this.elementClickCallback, true);
|
|
731
|
+
window.removeEventListener("mouseout", this.cancelEventCallback, true);
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
var ComponentsDevtoolsMessageService = class ComponentsDevtoolsMessageService {
|
|
735
|
+
constructor() {
|
|
736
|
+
this.logger = inject(LoggerService);
|
|
737
|
+
this.store = inject(Store);
|
|
738
|
+
this.sendMessage = sendOtterMessage;
|
|
739
|
+
this.destroyRef = inject(DestroyRef);
|
|
740
|
+
this.highlightService = inject(HighlightService);
|
|
741
|
+
const options = inject(OTTER_COMPONENTS_DEVTOOLS_OPTIONS, { optional: true });
|
|
742
|
+
this.options = {
|
|
743
|
+
...OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS,
|
|
744
|
+
...options
|
|
745
|
+
};
|
|
746
|
+
this.inspectorService = new OtterInspectorService();
|
|
747
|
+
if (this.options.isActivatedOnBootstrap) this.activate();
|
|
748
|
+
}
|
|
749
|
+
async connectPlugin() {
|
|
750
|
+
this.logger.debug("Otter DevTools is plugged to components service of the application");
|
|
751
|
+
if (await firstValueFrom(this.inspectorService.otterLikeComponentInfoToBeSent$)) await this.sendCurrentSelectedComponent();
|
|
752
|
+
}
|
|
753
|
+
async sendCurrentSelectedComponent() {
|
|
754
|
+
const selectComponentInfo = await firstValueFrom(this.inspectorService.otterLikeComponentInfoToBeSent$);
|
|
755
|
+
if (selectComponentInfo) this.sendMessage("selectedComponentInfo", selectComponentInfo);
|
|
756
|
+
}
|
|
757
|
+
sendIsComponentSelectionAvailable() {
|
|
758
|
+
this.sendMessage("isComponentSelectionAvailable", { available: !!window.ng });
|
|
759
|
+
}
|
|
760
|
+
handleReEmitRequest(only) {
|
|
761
|
+
if (!only) {
|
|
762
|
+
this.sendCurrentSelectedComponent();
|
|
763
|
+
this.sendIsComponentSelectionAvailable();
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
if (only.includes("selectedComponentInfo")) this.sendCurrentSelectedComponent();
|
|
767
|
+
if (only.includes("isComponentSelectionAvailable")) this.sendIsComponentSelectionAvailable();
|
|
768
|
+
}
|
|
769
|
+
async handleEvents(message) {
|
|
770
|
+
this.logger.debug("Message handling by the components service", message);
|
|
771
|
+
switch (message.dataType) {
|
|
772
|
+
case "connect":
|
|
773
|
+
await this.connectPlugin();
|
|
774
|
+
break;
|
|
775
|
+
case "requestMessages":
|
|
776
|
+
this.handleReEmitRequest(message.only);
|
|
777
|
+
break;
|
|
778
|
+
case "toggleInspector":
|
|
779
|
+
this.inspectorService.toggleInspector(message.isRunning);
|
|
780
|
+
break;
|
|
781
|
+
case "toggleHighlight":
|
|
782
|
+
if (message.isRunning) this.highlightService.start();
|
|
783
|
+
else this.highlightService.stop();
|
|
784
|
+
break;
|
|
785
|
+
case "changeHighlightConfiguration":
|
|
786
|
+
if (message.elementMinWidth) this.highlightService.elementMinWidth = message.elementMinWidth;
|
|
787
|
+
if (message.elementMinHeight) this.highlightService.elementMinHeight = message.elementMinHeight;
|
|
788
|
+
if (message.throttleInterval) this.highlightService.throttleInterval = message.throttleInterval;
|
|
789
|
+
if (message.groupsInfo) this.highlightService.groupsInfo = message.groupsInfo;
|
|
790
|
+
if (message.maxDepth) this.highlightService.maxDepth = message.maxDepth;
|
|
791
|
+
if (message.chipsOpacity) this.highlightService.chipsOpacity = message.chipsOpacity;
|
|
792
|
+
if (message.autoRefresh !== void 0) this.highlightService.autoRefresh = message.autoRefresh;
|
|
793
|
+
if (this.highlightService.isRunning()) this.highlightService.start();
|
|
794
|
+
break;
|
|
795
|
+
case "placeholderMode":
|
|
796
|
+
this.store.dispatch(togglePlaceholderModeTemplate({ mode: message.mode }));
|
|
797
|
+
break;
|
|
798
|
+
default: this.logger.warn("Message ignored by the components service", message);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
activate() {
|
|
802
|
+
fromEvent(window, "message").pipe(takeUntilDestroyed(this.destroyRef), filterMessageContent(isComponentsMessage)).subscribe((e) => this.handleEvents(e));
|
|
803
|
+
this.inspectorService.prepareInspector();
|
|
804
|
+
this.inspectorService.otterLikeComponentInfoToBeSent$.pipe(takeUntilDestroyed(this.destroyRef), filter((info) => !!info)).subscribe((info) => this.sendMessage("selectedComponentInfo", info));
|
|
805
|
+
}
|
|
806
|
+
static {
|
|
807
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
808
|
+
minVersion: "12.0.0",
|
|
809
|
+
version: "22.2.3",
|
|
810
|
+
ngImport: i0,
|
|
811
|
+
type: ComponentsDevtoolsMessageService,
|
|
812
|
+
deps: [],
|
|
813
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
static {
|
|
817
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
818
|
+
minVersion: "12.0.0",
|
|
819
|
+
version: "22.2.3",
|
|
820
|
+
ngImport: i0,
|
|
821
|
+
type: ComponentsDevtoolsMessageService,
|
|
822
|
+
providedIn: "root"
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
};
|
|
826
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
827
|
+
minVersion: "12.0.0",
|
|
828
|
+
version: "22.2.3",
|
|
829
|
+
ngImport: i0,
|
|
830
|
+
type: ComponentsDevtoolsMessageService,
|
|
831
|
+
decorators: [{
|
|
832
|
+
type: Injectable,
|
|
833
|
+
args: [{ providedIn: "root" }]
|
|
834
|
+
}],
|
|
835
|
+
ctorParameters: () => []
|
|
836
|
+
});
|
|
837
|
+
var ComponentsDevtoolsModule = class ComponentsDevtoolsModule {
|
|
838
|
+
static instrument(options) {
|
|
839
|
+
return {
|
|
840
|
+
ngModule: ComponentsDevtoolsModule,
|
|
841
|
+
providers: [{
|
|
842
|
+
provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS,
|
|
843
|
+
useValue: {
|
|
844
|
+
...OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS,
|
|
845
|
+
...options
|
|
846
|
+
},
|
|
847
|
+
multi: false
|
|
848
|
+
}, ComponentsDevtoolsMessageService]
|
|
849
|
+
};
|
|
850
|
+
}
|
|
851
|
+
static {
|
|
852
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
853
|
+
minVersion: "12.0.0",
|
|
854
|
+
version: "22.2.3",
|
|
855
|
+
ngImport: i0,
|
|
856
|
+
type: ComponentsDevtoolsModule,
|
|
857
|
+
deps: [],
|
|
858
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
859
|
+
});
|
|
860
|
+
}
|
|
861
|
+
static {
|
|
862
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
863
|
+
minVersion: "14.0.0",
|
|
864
|
+
version: "22.2.3",
|
|
865
|
+
ngImport: i0,
|
|
866
|
+
type: ComponentsDevtoolsModule,
|
|
867
|
+
imports: [StoreModule, PlaceholderTemplateStoreModule]
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
static {
|
|
871
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
872
|
+
minVersion: "12.0.0",
|
|
873
|
+
version: "22.2.3",
|
|
874
|
+
ngImport: i0,
|
|
875
|
+
type: ComponentsDevtoolsModule,
|
|
876
|
+
providers: [{
|
|
877
|
+
provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS,
|
|
878
|
+
useValue: OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS
|
|
879
|
+
}, ComponentsDevtoolsMessageService],
|
|
880
|
+
imports: [StoreModule, PlaceholderTemplateStoreModule]
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
};
|
|
884
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
885
|
+
minVersion: "12.0.0",
|
|
886
|
+
version: "22.2.3",
|
|
887
|
+
ngImport: i0,
|
|
888
|
+
type: ComponentsDevtoolsModule,
|
|
889
|
+
decorators: [{
|
|
890
|
+
type: NgModule,
|
|
891
|
+
args: [{
|
|
892
|
+
imports: [StoreModule, PlaceholderTemplateStoreModule],
|
|
893
|
+
providers: [{
|
|
894
|
+
provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS,
|
|
895
|
+
useValue: OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS
|
|
896
|
+
}, ComponentsDevtoolsMessageService]
|
|
897
|
+
}]
|
|
898
|
+
}]
|
|
899
|
+
});
|
|
1193
900
|
function provideComponentsDevtools(options) {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
901
|
+
return makeEnvironmentProviders([
|
|
902
|
+
providePlaceholderTemplateStore(),
|
|
903
|
+
{
|
|
904
|
+
provide: OTTER_COMPONENTS_DEVTOOLS_OPTIONS,
|
|
905
|
+
useValue: {
|
|
906
|
+
...OTTER_COMPONENTS_DEVTOOLS_DEFAULT_OPTIONS,
|
|
907
|
+
...options
|
|
908
|
+
}
|
|
909
|
+
},
|
|
910
|
+
ComponentsDevtoolsMessageService
|
|
911
|
+
]);
|
|
1199
912
|
}
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
}
|
|
1344
|
-
]
|
|
1345
|
-
}]
|
|
1346
|
-
}], propDecorators: { component: [{
|
|
1347
|
-
type: Input
|
|
1348
|
-
}], config: [{
|
|
1349
|
-
type: Input
|
|
1350
|
-
}], formControl: [{
|
|
1351
|
-
type: Input
|
|
1352
|
-
}], inputs: [{
|
|
1353
|
-
type: Input
|
|
1354
|
-
}], outputs: [{
|
|
1355
|
-
type: Input
|
|
1356
|
-
}] } });
|
|
1357
|
-
|
|
1358
|
-
/**
|
|
1359
|
-
* Register a custom component
|
|
1360
|
-
* @param customComponentsMap an object containing the already registered custom component
|
|
1361
|
-
* @param customComponentKey
|
|
1362
|
-
* @param customComponent
|
|
1363
|
-
*/
|
|
913
|
+
var C11nDirective = class C11nDirective {
|
|
914
|
+
constructor() {
|
|
915
|
+
this.viewContainerRef = inject(ViewContainerRef);
|
|
916
|
+
this.differsService = inject(KeyValueDiffers);
|
|
917
|
+
this.injector = inject(Injector);
|
|
918
|
+
this.componentSubscriptions = [];
|
|
919
|
+
this.uninitializedInputs = /* @__PURE__ */ new Set();
|
|
920
|
+
}
|
|
921
|
+
set inputs(value) {
|
|
922
|
+
this._inputs = value;
|
|
923
|
+
if (!this.differInputs && value) this.differInputs = this.differsService.find(value).create();
|
|
924
|
+
}
|
|
925
|
+
get inputs() {
|
|
926
|
+
return this._inputs;
|
|
927
|
+
}
|
|
928
|
+
componentImplementsCva(_cmp) {
|
|
929
|
+
return !!this.formControl;
|
|
930
|
+
}
|
|
931
|
+
updateInputs(record, inputChanges) {
|
|
932
|
+
const recordKey = record.key;
|
|
933
|
+
const isFirstChange = this.uninitializedInputs.has(recordKey);
|
|
934
|
+
this.uninitializedInputs.delete(recordKey);
|
|
935
|
+
inputChanges[recordKey] = new SimpleChange(record.previousValue, record.currentValue, isFirstChange);
|
|
936
|
+
}
|
|
937
|
+
ngOnChanges(changes) {
|
|
938
|
+
const inputChanges = {};
|
|
939
|
+
if (changes.component && changes.component.currentValue) {
|
|
940
|
+
if (this.componentRef) {
|
|
941
|
+
this.componentSubscriptions.forEach((s) => s.unsubscribe());
|
|
942
|
+
this.componentSubscriptions = [];
|
|
943
|
+
this.componentRef.destroy();
|
|
944
|
+
}
|
|
945
|
+
const ngControl = !!this.formControl && this.injector.get(NgControl);
|
|
946
|
+
this.viewContainerRef.clear();
|
|
947
|
+
this.componentRef = this.viewContainerRef.createComponent(changes.component.currentValue);
|
|
948
|
+
Object.keys(this.componentRef.instance).filter((prop) => !(this.outputs && Object.keys(this.outputs).includes(prop))).forEach((prop) => {
|
|
949
|
+
this.uninitializedInputs.add(prop);
|
|
950
|
+
});
|
|
951
|
+
if (ngControl && this.componentImplementsCva(this.componentRef.instance)) ngControl.valueAccessor = this.componentRef.instance;
|
|
952
|
+
if (this.outputs) {
|
|
953
|
+
const subscriptions = Object.keys(this.outputs).map((outputName) => this.componentRef.instance[outputName].subscribe((val) => this.outputs[outputName](val)));
|
|
954
|
+
this.componentSubscriptions.push(...subscriptions);
|
|
955
|
+
}
|
|
956
|
+
if (!changes.inputs && this.inputs) Object.keys(this.inputs).forEach((inputName) => {
|
|
957
|
+
const currentInputValue = this.inputs[inputName];
|
|
958
|
+
inputChanges[inputName] = new SimpleChange(void 0, currentInputValue, true);
|
|
959
|
+
this.uninitializedInputs.delete(inputName);
|
|
960
|
+
});
|
|
961
|
+
if (!changes.config && this.config) {
|
|
962
|
+
inputChanges.config = new SimpleChange(this.componentRef.instance.config, this.config, true);
|
|
963
|
+
this.uninitializedInputs.delete("config");
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
if (this.componentRef && this.differInputs) {
|
|
967
|
+
const changesInInputs = this.differInputs.diff(this.inputs);
|
|
968
|
+
if (changesInInputs) {
|
|
969
|
+
changesInInputs.forEachAddedItem((record) => this.updateInputs(record, inputChanges));
|
|
970
|
+
changesInInputs.forEachChangedItem((record) => this.updateInputs(record, inputChanges));
|
|
971
|
+
changesInInputs.forEachRemovedItem((record) => this.updateInputs(record, inputChanges));
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
if (this.componentRef && changes.config) {
|
|
975
|
+
inputChanges.config = new SimpleChange(this.componentRef.instance.config, changes.config.currentValue, this.uninitializedInputs.has("config"));
|
|
976
|
+
this.uninitializedInputs.delete("config");
|
|
977
|
+
}
|
|
978
|
+
if (this.componentRef && Object.keys(inputChanges).length > 0) Object.entries(inputChanges).forEach(([inputName, value]) => {
|
|
979
|
+
this.componentRef.setInput(inputName, value.currentValue);
|
|
980
|
+
});
|
|
981
|
+
}
|
|
982
|
+
validate(control) {
|
|
983
|
+
if (!this.componentRef?.instance.validate) return null;
|
|
984
|
+
return this.componentRef.instance.validate(control);
|
|
985
|
+
}
|
|
986
|
+
ngOnDestroy() {
|
|
987
|
+
this.componentSubscriptions.forEach((s) => s.unsubscribe());
|
|
988
|
+
if (this.componentRef) this.componentRef.destroy();
|
|
989
|
+
}
|
|
990
|
+
static {
|
|
991
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
992
|
+
minVersion: "12.0.0",
|
|
993
|
+
version: "22.2.3",
|
|
994
|
+
ngImport: i0,
|
|
995
|
+
type: C11nDirective,
|
|
996
|
+
deps: [],
|
|
997
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
998
|
+
});
|
|
999
|
+
}
|
|
1000
|
+
static {
|
|
1001
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
1002
|
+
minVersion: "14.0.0",
|
|
1003
|
+
version: "22.2.3",
|
|
1004
|
+
type: C11nDirective,
|
|
1005
|
+
isStandalone: true,
|
|
1006
|
+
selector: "[c11n]",
|
|
1007
|
+
inputs: {
|
|
1008
|
+
component: "component",
|
|
1009
|
+
config: "config",
|
|
1010
|
+
formControl: "formControl",
|
|
1011
|
+
inputs: "inputs",
|
|
1012
|
+
outputs: "outputs"
|
|
1013
|
+
},
|
|
1014
|
+
providers: [{
|
|
1015
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1016
|
+
useExisting: forwardRef((() => C11nDirective)),
|
|
1017
|
+
multi: true
|
|
1018
|
+
}, {
|
|
1019
|
+
provide: NG_VALIDATORS,
|
|
1020
|
+
useExisting: forwardRef((() => C11nDirective)),
|
|
1021
|
+
multi: true
|
|
1022
|
+
}],
|
|
1023
|
+
usesOnChanges: true,
|
|
1024
|
+
ngImport: i0
|
|
1025
|
+
});
|
|
1026
|
+
}
|
|
1027
|
+
};
|
|
1028
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1029
|
+
minVersion: "12.0.0",
|
|
1030
|
+
version: "22.2.3",
|
|
1031
|
+
ngImport: i0,
|
|
1032
|
+
type: C11nDirective,
|
|
1033
|
+
decorators: [{
|
|
1034
|
+
type: Directive,
|
|
1035
|
+
args: [{
|
|
1036
|
+
selector: "[c11n]",
|
|
1037
|
+
providers: [{
|
|
1038
|
+
provide: NG_VALUE_ACCESSOR,
|
|
1039
|
+
useExisting: forwardRef((() => C11nDirective)),
|
|
1040
|
+
multi: true
|
|
1041
|
+
}, {
|
|
1042
|
+
provide: NG_VALIDATORS,
|
|
1043
|
+
useExisting: forwardRef((() => C11nDirective)),
|
|
1044
|
+
multi: true
|
|
1045
|
+
}]
|
|
1046
|
+
}]
|
|
1047
|
+
}],
|
|
1048
|
+
propDecorators: {
|
|
1049
|
+
component: [{ type: Input }],
|
|
1050
|
+
config: [{ type: Input }],
|
|
1051
|
+
formControl: [{ type: Input }],
|
|
1052
|
+
inputs: [{ type: Input }],
|
|
1053
|
+
outputs: [{ type: Input }]
|
|
1054
|
+
}
|
|
1055
|
+
});
|
|
1364
1056
|
function registerCustomComponent(customComponentsMap, customComponentKey, customComponent) {
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
/** The C11n injection token */
|
|
1370
|
-
const C11N_PRESENTERS_MAP_TOKEN = new InjectionToken('C11n injection token');
|
|
1371
|
-
/** Function used to register custom components */
|
|
1372
|
-
const C11N_REGISTER_FUNC_TOKEN = new InjectionToken('C11n register presenters token');
|
|
1373
|
-
|
|
1374
|
-
class C11nService {
|
|
1375
|
-
constructor() {
|
|
1376
|
-
this.presentersMap = inject(C11N_PRESENTERS_MAP_TOKEN);
|
|
1377
|
-
}
|
|
1378
|
-
/**
|
|
1379
|
-
* Add a presenter
|
|
1380
|
-
* @param presKey The presenter key to set
|
|
1381
|
-
* @param presenter The new presenter
|
|
1382
|
-
*/
|
|
1383
|
-
addPresenter(presKey, presenter) {
|
|
1384
|
-
this.presentersMap.set(presKey, presenter);
|
|
1385
|
-
}
|
|
1386
|
-
/**
|
|
1387
|
-
* Operator to retrieve the presenter based on a given presKey
|
|
1388
|
-
* @param defaultPres The default presenter
|
|
1389
|
-
* @param presKey The presenter key to retrieve
|
|
1390
|
-
*/
|
|
1391
|
-
getPresenter(defaultPres, presKey = 'customPresKey') {
|
|
1392
|
-
return (source) => source.pipe(distinctUntilChanged((p, q) => p[presKey] === q[presKey]), map((config) => {
|
|
1393
|
-
const presenterConfig = config[presKey];
|
|
1394
|
-
return typeof presenterConfig === 'string' && presenterConfig !== '' ? (this.presentersMap.get(presenterConfig) || defaultPres) : defaultPres;
|
|
1395
|
-
}));
|
|
1396
|
-
}
|
|
1397
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: C11nService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1398
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: C11nService }); }
|
|
1399
|
-
}
|
|
1400
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: C11nService, decorators: [{
|
|
1401
|
-
type: Injectable
|
|
1402
|
-
}] });
|
|
1403
|
-
|
|
1404
|
-
/** C11n directive mock */
|
|
1405
|
-
class MockC11nDirective {
|
|
1406
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MockC11nDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1407
|
-
/** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.2.0", type: MockC11nDirective, isStandalone: true, selector: "[c11n]", inputs: { config: "config", component: "component", inputs: "inputs", outputs: "outputs" }, ngImport: i0 }); }
|
|
1408
|
-
}
|
|
1409
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: MockC11nDirective, decorators: [{
|
|
1410
|
-
type: Directive,
|
|
1411
|
-
args: [{
|
|
1412
|
-
selector: '[c11n]',
|
|
1413
|
-
// eslint-disable-next-line @angular-eslint/no-inputs-metadata-property -- mocked directive
|
|
1414
|
-
inputs: ['config', 'component', 'inputs', 'outputs']
|
|
1415
|
-
}]
|
|
1416
|
-
}] });
|
|
1417
|
-
/** C11n service mock */
|
|
1418
|
-
class C11nMockService {
|
|
1419
|
-
addPresenter(_presKey, _presType) { }
|
|
1420
|
-
getPresenter(_defaultPres, _presKey) {
|
|
1421
|
-
return (source) => source.pipe(mapTo(null));
|
|
1422
|
-
}
|
|
1423
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: C11nMockService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1424
|
-
/** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: C11nMockService }); }
|
|
1425
|
-
}
|
|
1426
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: C11nMockService, decorators: [{
|
|
1427
|
-
type: Injectable
|
|
1428
|
-
}] });
|
|
1429
|
-
/**
|
|
1430
|
-
* The purpose of this module is to be imported in the unit tests of the components which are using c11n directive
|
|
1431
|
-
* @deprecated Will be removed in v16. Use {@link provideC11nMock} and import `MockC11nDirective` directly instead.
|
|
1432
|
-
*/
|
|
1433
|
-
class C11nMockModule {
|
|
1434
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: C11nMockModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1435
|
-
/** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: C11nMockModule, imports: [MockC11nDirective] }); }
|
|
1436
|
-
/** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: C11nMockModule, providers: [{ provide: C11nService, useClass: C11nMockService }] }); }
|
|
1057
|
+
customComponentsMap.set(customComponentKey, customComponent);
|
|
1058
|
+
return customComponentsMap;
|
|
1437
1059
|
}
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1060
|
+
const C11N_PRESENTERS_MAP_TOKEN = new InjectionToken("C11n injection token");
|
|
1061
|
+
const C11N_REGISTER_FUNC_TOKEN = new InjectionToken("C11n register presenters token");
|
|
1062
|
+
var C11nService = class C11nService {
|
|
1063
|
+
constructor() {
|
|
1064
|
+
this.presentersMap = inject(C11N_PRESENTERS_MAP_TOKEN);
|
|
1065
|
+
}
|
|
1066
|
+
addPresenter(presKey, presenter) {
|
|
1067
|
+
this.presentersMap.set(presKey, presenter);
|
|
1068
|
+
}
|
|
1069
|
+
getPresenter(defaultPres, presKey = "customPresKey") {
|
|
1070
|
+
return (source) => source.pipe(distinctUntilChanged((p, q) => p[presKey] === q[presKey]), map((config) => {
|
|
1071
|
+
const presenterConfig = config[presKey];
|
|
1072
|
+
return typeof presenterConfig === "string" && presenterConfig !== "" ? this.presentersMap.get(presenterConfig) || defaultPres : defaultPres;
|
|
1073
|
+
}));
|
|
1074
|
+
}
|
|
1075
|
+
static {
|
|
1076
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1077
|
+
minVersion: "12.0.0",
|
|
1078
|
+
version: "22.2.3",
|
|
1079
|
+
ngImport: i0,
|
|
1080
|
+
type: C11nService,
|
|
1081
|
+
deps: [],
|
|
1082
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
static {
|
|
1086
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1087
|
+
minVersion: "12.0.0",
|
|
1088
|
+
version: "22.2.3",
|
|
1089
|
+
ngImport: i0,
|
|
1090
|
+
type: C11nService
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
};
|
|
1094
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1095
|
+
minVersion: "12.0.0",
|
|
1096
|
+
version: "22.2.3",
|
|
1097
|
+
ngImport: i0,
|
|
1098
|
+
type: C11nService,
|
|
1099
|
+
decorators: [{ type: Injectable }]
|
|
1100
|
+
});
|
|
1101
|
+
var MockC11nDirective = class MockC11nDirective {
|
|
1102
|
+
static {
|
|
1103
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1104
|
+
minVersion: "12.0.0",
|
|
1105
|
+
version: "22.2.3",
|
|
1106
|
+
ngImport: i0,
|
|
1107
|
+
type: MockC11nDirective,
|
|
1108
|
+
deps: [],
|
|
1109
|
+
target: i0.ɵɵFactoryTarget.Directive
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
static {
|
|
1113
|
+
this.ɵdir = i0.ɵɵngDeclareDirective({
|
|
1114
|
+
minVersion: "14.0.0",
|
|
1115
|
+
version: "22.2.3",
|
|
1116
|
+
type: MockC11nDirective,
|
|
1117
|
+
isStandalone: true,
|
|
1118
|
+
selector: "[c11n]",
|
|
1119
|
+
inputs: {
|
|
1120
|
+
config: "config",
|
|
1121
|
+
component: "component",
|
|
1122
|
+
inputs: "inputs",
|
|
1123
|
+
outputs: "outputs"
|
|
1124
|
+
},
|
|
1125
|
+
ngImport: i0
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
};
|
|
1129
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1130
|
+
minVersion: "12.0.0",
|
|
1131
|
+
version: "22.2.3",
|
|
1132
|
+
ngImport: i0,
|
|
1133
|
+
type: MockC11nDirective,
|
|
1134
|
+
decorators: [{
|
|
1135
|
+
type: Directive,
|
|
1136
|
+
args: [{
|
|
1137
|
+
selector: "[c11n]",
|
|
1138
|
+
inputs: [
|
|
1139
|
+
"config",
|
|
1140
|
+
"component",
|
|
1141
|
+
"inputs",
|
|
1142
|
+
"outputs"
|
|
1143
|
+
]
|
|
1144
|
+
}]
|
|
1145
|
+
}]
|
|
1146
|
+
});
|
|
1147
|
+
var C11nMockService = class C11nMockService {
|
|
1148
|
+
addPresenter(_presKey, _presType) {}
|
|
1149
|
+
getPresenter(_defaultPres, _presKey) {
|
|
1150
|
+
return (source) => source.pipe(mapTo(null));
|
|
1151
|
+
}
|
|
1152
|
+
static {
|
|
1153
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1154
|
+
minVersion: "12.0.0",
|
|
1155
|
+
version: "22.2.3",
|
|
1156
|
+
ngImport: i0,
|
|
1157
|
+
type: C11nMockService,
|
|
1158
|
+
deps: [],
|
|
1159
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
static {
|
|
1163
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
1164
|
+
minVersion: "12.0.0",
|
|
1165
|
+
version: "22.2.3",
|
|
1166
|
+
ngImport: i0,
|
|
1167
|
+
type: C11nMockService
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1172
|
+
minVersion: "12.0.0",
|
|
1173
|
+
version: "22.2.3",
|
|
1174
|
+
ngImport: i0,
|
|
1175
|
+
type: C11nMockService,
|
|
1176
|
+
decorators: [{ type: Injectable }]
|
|
1177
|
+
});
|
|
1178
|
+
var C11nMockModule = class C11nMockModule {
|
|
1179
|
+
static {
|
|
1180
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1181
|
+
minVersion: "12.0.0",
|
|
1182
|
+
version: "22.2.3",
|
|
1183
|
+
ngImport: i0,
|
|
1184
|
+
type: C11nMockModule,
|
|
1185
|
+
deps: [],
|
|
1186
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
static {
|
|
1190
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
1191
|
+
minVersion: "14.0.0",
|
|
1192
|
+
version: "22.2.3",
|
|
1193
|
+
ngImport: i0,
|
|
1194
|
+
type: C11nMockModule,
|
|
1195
|
+
imports: [MockC11nDirective]
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
static {
|
|
1199
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
1200
|
+
minVersion: "12.0.0",
|
|
1201
|
+
version: "22.2.3",
|
|
1202
|
+
ngImport: i0,
|
|
1203
|
+
type: C11nMockModule,
|
|
1204
|
+
providers: [{
|
|
1205
|
+
provide: C11nService,
|
|
1206
|
+
useClass: C11nMockService
|
|
1207
|
+
}]
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1212
|
+
minVersion: "12.0.0",
|
|
1213
|
+
version: "22.2.3",
|
|
1214
|
+
ngImport: i0,
|
|
1215
|
+
type: C11nMockModule,
|
|
1216
|
+
decorators: [{
|
|
1217
|
+
type: NgModule,
|
|
1218
|
+
args: [{
|
|
1219
|
+
imports: [MockC11nDirective],
|
|
1220
|
+
providers: [{
|
|
1221
|
+
provide: C11nService,
|
|
1222
|
+
useClass: C11nMockService
|
|
1223
|
+
}]
|
|
1224
|
+
}]
|
|
1225
|
+
}]
|
|
1226
|
+
});
|
|
1448
1227
|
function provideC11nMock() {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1228
|
+
return makeEnvironmentProviders([{
|
|
1229
|
+
provide: C11nService,
|
|
1230
|
+
useClass: C11nMockService
|
|
1231
|
+
}]);
|
|
1452
1232
|
}
|
|
1453
|
-
|
|
1454
|
-
/**
|
|
1455
|
-
* Customization service factory
|
|
1456
|
-
* @param config -> registerCompFunc - a function which returns the map of custom components which will be injected in c11n service
|
|
1457
|
-
* @param config.registerCompFunc
|
|
1458
|
-
*/
|
|
1459
1233
|
function createC11nService(config) {
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1234
|
+
return Injector.create({ providers: [{
|
|
1235
|
+
provide: C11N_PRESENTERS_MAP_TOKEN,
|
|
1236
|
+
useValue: config ? config.registerCompFunc() : /* @__PURE__ */ new Map()
|
|
1237
|
+
}, {
|
|
1238
|
+
provide: C11nService,
|
|
1239
|
+
deps: [C11N_PRESENTERS_MAP_TOKEN]
|
|
1240
|
+
}] }).get(C11nService);
|
|
1467
1241
|
}
|
|
1468
|
-
/**
|
|
1469
|
-
* Returns a tuple of the key and the component
|
|
1470
|
-
* @note should be used with {@link provideCustomComponents}
|
|
1471
|
-
* @example
|
|
1472
|
-
* ```typescript
|
|
1473
|
-
* provideCustomComponents(
|
|
1474
|
-
* new Map(),
|
|
1475
|
-
* withComponent('example1', MyFirstComponent),
|
|
1476
|
-
* withComponent('example2', MySecondComponent),
|
|
1477
|
-
* )
|
|
1478
|
-
* ```
|
|
1479
|
-
* @param customComponentKey
|
|
1480
|
-
* @param customComponent
|
|
1481
|
-
*/
|
|
1482
1242
|
function withComponent(customComponentKey, customComponent) {
|
|
1483
|
-
|
|
1243
|
+
return [customComponentKey, customComponent];
|
|
1484
1244
|
}
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
additionalComponents.forEach(([customComponentKey, customComponent]) => customComponents.set(customComponentKey, customComponent));
|
|
1492
|
-
return makeEnvironmentProviders([
|
|
1493
|
-
C11nService,
|
|
1494
|
-
{
|
|
1495
|
-
provide: C11N_PRESENTERS_MAP_TOKEN,
|
|
1496
|
-
useValue: customComponents
|
|
1497
|
-
}
|
|
1498
|
-
]);
|
|
1245
|
+
function provideCustomComponents(customComponents = /* @__PURE__ */ new Map(), ...additionalComponents) {
|
|
1246
|
+
additionalComponents.forEach(([customComponentKey, customComponent]) => customComponents.set(customComponentKey, customComponent));
|
|
1247
|
+
return makeEnvironmentProviders([C11nService, {
|
|
1248
|
+
provide: C11N_PRESENTERS_MAP_TOKEN,
|
|
1249
|
+
useValue: customComponents
|
|
1250
|
+
}]);
|
|
1499
1251
|
}
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1252
|
+
var O3rCapitalizePipe = class O3rCapitalizePipe {
|
|
1253
|
+
transform(value) {
|
|
1254
|
+
const val = value && value.toString && value.toString();
|
|
1255
|
+
const firstLetter = val && val.charAt(0);
|
|
1256
|
+
return firstLetter ? firstLetter.toUpperCase() + val.slice(1) : value;
|
|
1257
|
+
}
|
|
1258
|
+
static {
|
|
1259
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1260
|
+
minVersion: "12.0.0",
|
|
1261
|
+
version: "22.2.3",
|
|
1262
|
+
ngImport: i0,
|
|
1263
|
+
type: O3rCapitalizePipe,
|
|
1264
|
+
deps: [],
|
|
1265
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
static {
|
|
1269
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
1270
|
+
minVersion: "14.0.0",
|
|
1271
|
+
version: "22.2.3",
|
|
1272
|
+
ngImport: i0,
|
|
1273
|
+
type: O3rCapitalizePipe,
|
|
1274
|
+
isStandalone: true,
|
|
1275
|
+
name: "o3rCapitalize"
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
};
|
|
1279
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1280
|
+
minVersion: "12.0.0",
|
|
1281
|
+
version: "22.2.3",
|
|
1282
|
+
ngImport: i0,
|
|
1283
|
+
type: O3rCapitalizePipe,
|
|
1284
|
+
decorators: [{
|
|
1285
|
+
type: Pipe,
|
|
1286
|
+
args: [{ name: "o3rCapitalize" }]
|
|
1287
|
+
}]
|
|
1288
|
+
});
|
|
1516
1289
|
const defaultTimeUnits = [
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1290
|
+
{
|
|
1291
|
+
formatCharacter: "d",
|
|
1292
|
+
divider: 86400
|
|
1293
|
+
},
|
|
1294
|
+
{
|
|
1295
|
+
formatCharacter: "h",
|
|
1296
|
+
divider: 3600
|
|
1297
|
+
},
|
|
1298
|
+
{
|
|
1299
|
+
formatCharacter: "m",
|
|
1300
|
+
divider: 60
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
formatCharacter: "s",
|
|
1304
|
+
divider: 1
|
|
1305
|
+
}
|
|
1533
1306
|
];
|
|
1534
|
-
|
|
1535
|
-
/**
|
|
1536
|
-
* Pad a number with zeroes
|
|
1537
|
-
* @param num
|
|
1538
|
-
* @param digits
|
|
1539
|
-
*/
|
|
1540
1307
|
function padNum(num, digits) {
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
}
|
|
1545
|
-
return strNum;
|
|
1546
|
-
}
|
|
1547
|
-
/**
|
|
1548
|
-
* Converts a duration in seconds into the HH:mm format
|
|
1549
|
-
*/
|
|
1550
|
-
class O3rDurationPipe {
|
|
1551
|
-
/**
|
|
1552
|
-
* Converts a duration in seconds into the HH:mm format
|
|
1553
|
-
* @param value the value in seconds
|
|
1554
|
-
* @param pattern the desired output format.
|
|
1555
|
-
* The pattern takes into account static format characters surrounded by braces
|
|
1556
|
-
* {d} for days, {h} for hours, {m} for minutes and {s} for seconds.
|
|
1557
|
-
* It accepts a double unit time in case a padding is wanted {dd} outputs 05 for instance
|
|
1558
|
-
* Should respect the following pattern `/(\{h+\})|(\{m+\})/` (ex: `'{h}h{m}m'` outputs `0h2m`, `'{h}H{mm}'` `0H02` etc.)
|
|
1559
|
-
* @param timeUnits the units time to be used in this transformation. This can be used for custom units in the pattern like
|
|
1560
|
-
* {
|
|
1561
|
-
* formatCharacter: 'w',
|
|
1562
|
-
* divider: 3600 * 24 * 7
|
|
1563
|
-
* }
|
|
1564
|
-
* The above defines a week for {w}
|
|
1565
|
-
*/
|
|
1566
|
-
transform(value, pattern = '{h}:{mm}', timeUnits = defaultTimeUnits) {
|
|
1567
|
-
const val = value || 0;
|
|
1568
|
-
let modulo = Number.MAX_SAFE_INTEGER;
|
|
1569
|
-
const matches = timeUnits.reduce((result, unit) => {
|
|
1570
|
-
const regexp = new RegExp('({' + unit.formatCharacter + '+})', 'g');
|
|
1571
|
-
const match = regexp.exec(pattern);
|
|
1572
|
-
if (!match) {
|
|
1573
|
-
return result;
|
|
1574
|
-
}
|
|
1575
|
-
return result.concat({
|
|
1576
|
-
textMatch: match[0],
|
|
1577
|
-
timeUnit: unit
|
|
1578
|
-
});
|
|
1579
|
-
}, []);
|
|
1580
|
-
return matches.reduce((result, match) => {
|
|
1581
|
-
const matchedPatternToReplace = match.textMatch;
|
|
1582
|
-
const unit = match.timeUnit;
|
|
1583
|
-
const unitTimeValue = Math.floor(val % (unit.modulo || modulo) / unit.divider);
|
|
1584
|
-
const unitMatchLength = (matchedPatternToReplace.match(new RegExp(unit.formatCharacter, 'g')) || []).length;
|
|
1585
|
-
const padded = padNum(unitTimeValue, unitMatchLength);
|
|
1586
|
-
modulo = unitTimeValue > 0 ? unit.divider : modulo;
|
|
1587
|
-
return result.replace(matchedPatternToReplace, padded);
|
|
1588
|
-
}, pattern);
|
|
1589
|
-
}
|
|
1590
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: O3rDurationPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1591
|
-
/** @nocollapse */ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: O3rDurationPipe, isStandalone: true, name: "o3rDuration" }); }
|
|
1592
|
-
}
|
|
1593
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: O3rDurationPipe, decorators: [{
|
|
1594
|
-
type: Pipe,
|
|
1595
|
-
args: [{ name: 'o3rDuration' }]
|
|
1596
|
-
}] });
|
|
1597
|
-
|
|
1598
|
-
class O3rKeepWhiteSpacePipe {
|
|
1599
|
-
transform(value) {
|
|
1600
|
-
return value.replace(/\s/g, ' ');
|
|
1601
|
-
}
|
|
1602
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: O3rKeepWhiteSpacePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1603
|
-
/** @nocollapse */ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: O3rKeepWhiteSpacePipe, isStandalone: true, name: "o3rKeepWhiteSpace" }); }
|
|
1604
|
-
}
|
|
1605
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: O3rKeepWhiteSpacePipe, decorators: [{
|
|
1606
|
-
type: Pipe,
|
|
1607
|
-
args: [{ name: 'o3rKeepWhiteSpace' }]
|
|
1608
|
-
}] });
|
|
1609
|
-
|
|
1610
|
-
const escapeRegExp = (str) => str.replace(/[$()*+./?[\\\]^{|}-]/g, '\\$&');
|
|
1611
|
-
class O3rReplaceWithBoldPipe {
|
|
1612
|
-
transform(value, inputText) {
|
|
1613
|
-
if (inputText) {
|
|
1614
|
-
const regexp = new RegExp(escapeRegExp(inputText.trim()), 'gi');
|
|
1615
|
-
return value.replace(regexp, (match) => `<strong>${match}</strong>`);
|
|
1616
|
-
}
|
|
1617
|
-
else {
|
|
1618
|
-
return value;
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
/** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: O3rReplaceWithBoldPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
1622
|
-
/** @nocollapse */ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: O3rReplaceWithBoldPipe, isStandalone: true, name: "o3rReplaceWithBold" }); }
|
|
1308
|
+
let strNum = String(num);
|
|
1309
|
+
while (strNum.length < digits) strNum = "0" + strNum;
|
|
1310
|
+
return strNum;
|
|
1623
1311
|
}
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
i0.ɵɵ
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1312
|
+
var O3rDurationPipe = class O3rDurationPipe {
|
|
1313
|
+
transform(value, pattern = "{h}:{mm}", timeUnits = defaultTimeUnits) {
|
|
1314
|
+
const val = value || 0;
|
|
1315
|
+
let modulo = Number.MAX_SAFE_INTEGER;
|
|
1316
|
+
return timeUnits.reduce((result, unit) => {
|
|
1317
|
+
const match = new RegExp("({" + unit.formatCharacter + "+})", "g").exec(pattern);
|
|
1318
|
+
if (!match) return result;
|
|
1319
|
+
return result.concat({
|
|
1320
|
+
textMatch: match[0],
|
|
1321
|
+
timeUnit: unit
|
|
1322
|
+
});
|
|
1323
|
+
}, []).reduce((result, match) => {
|
|
1324
|
+
const matchedPatternToReplace = match.textMatch;
|
|
1325
|
+
const unit = match.timeUnit;
|
|
1326
|
+
const unitTimeValue = Math.floor(val % (unit.modulo || modulo) / unit.divider);
|
|
1327
|
+
const unitMatchLength = (matchedPatternToReplace.match(new RegExp(unit.formatCharacter, "g")) || []).length;
|
|
1328
|
+
const padded = padNum(unitTimeValue, unitMatchLength);
|
|
1329
|
+
modulo = unitTimeValue > 0 ? unit.divider : modulo;
|
|
1330
|
+
return result.replace(matchedPatternToReplace, padded);
|
|
1331
|
+
}, pattern);
|
|
1332
|
+
}
|
|
1333
|
+
static {
|
|
1334
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1335
|
+
minVersion: "12.0.0",
|
|
1336
|
+
version: "22.2.3",
|
|
1337
|
+
ngImport: i0,
|
|
1338
|
+
type: O3rDurationPipe,
|
|
1339
|
+
deps: [],
|
|
1340
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
static {
|
|
1344
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
1345
|
+
minVersion: "14.0.0",
|
|
1346
|
+
version: "22.2.3",
|
|
1347
|
+
ngImport: i0,
|
|
1348
|
+
type: O3rDurationPipe,
|
|
1349
|
+
isStandalone: true,
|
|
1350
|
+
name: "o3rDuration"
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
};
|
|
1354
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1355
|
+
minVersion: "12.0.0",
|
|
1356
|
+
version: "22.2.3",
|
|
1357
|
+
ngImport: i0,
|
|
1358
|
+
type: O3rDurationPipe,
|
|
1359
|
+
decorators: [{
|
|
1360
|
+
type: Pipe,
|
|
1361
|
+
args: [{ name: "o3rDuration" }]
|
|
1362
|
+
}]
|
|
1363
|
+
});
|
|
1364
|
+
var O3rKeepWhiteSpacePipe = class O3rKeepWhiteSpacePipe {
|
|
1365
|
+
transform(value) {
|
|
1366
|
+
return value.replace(/\s/g, " ");
|
|
1367
|
+
}
|
|
1368
|
+
static {
|
|
1369
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1370
|
+
minVersion: "12.0.0",
|
|
1371
|
+
version: "22.2.3",
|
|
1372
|
+
ngImport: i0,
|
|
1373
|
+
type: O3rKeepWhiteSpacePipe,
|
|
1374
|
+
deps: [],
|
|
1375
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
static {
|
|
1379
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
1380
|
+
minVersion: "14.0.0",
|
|
1381
|
+
version: "22.2.3",
|
|
1382
|
+
ngImport: i0,
|
|
1383
|
+
type: O3rKeepWhiteSpacePipe,
|
|
1384
|
+
isStandalone: true,
|
|
1385
|
+
name: "o3rKeepWhiteSpace"
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
};
|
|
1389
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1390
|
+
minVersion: "12.0.0",
|
|
1391
|
+
version: "22.2.3",
|
|
1392
|
+
ngImport: i0,
|
|
1393
|
+
type: O3rKeepWhiteSpacePipe,
|
|
1394
|
+
decorators: [{
|
|
1395
|
+
type: Pipe,
|
|
1396
|
+
args: [{ name: "o3rKeepWhiteSpace" }]
|
|
1397
|
+
}]
|
|
1398
|
+
});
|
|
1399
|
+
const escapeRegExp = (str) => str.replace(/[$()*+./?[\\\]^{|}-]/g, "\\$&");
|
|
1400
|
+
var O3rReplaceWithBoldPipe = class O3rReplaceWithBoldPipe {
|
|
1401
|
+
transform(value, inputText) {
|
|
1402
|
+
if (inputText) {
|
|
1403
|
+
const regexp = new RegExp(escapeRegExp(inputText.trim()), "gi");
|
|
1404
|
+
return value.replace(regexp, (match) => `<strong>${match}</strong>`);
|
|
1405
|
+
} else return value;
|
|
1406
|
+
}
|
|
1407
|
+
static {
|
|
1408
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1409
|
+
minVersion: "12.0.0",
|
|
1410
|
+
version: "22.2.3",
|
|
1411
|
+
ngImport: i0,
|
|
1412
|
+
type: O3rReplaceWithBoldPipe,
|
|
1413
|
+
deps: [],
|
|
1414
|
+
target: i0.ɵɵFactoryTarget.Pipe
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
static {
|
|
1418
|
+
this.ɵpipe = i0.ɵɵngDeclarePipe({
|
|
1419
|
+
minVersion: "14.0.0",
|
|
1420
|
+
version: "22.2.3",
|
|
1421
|
+
ngImport: i0,
|
|
1422
|
+
type: O3rReplaceWithBoldPipe,
|
|
1423
|
+
isStandalone: true,
|
|
1424
|
+
name: "o3rReplaceWithBold"
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
};
|
|
1428
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1429
|
+
minVersion: "12.0.0",
|
|
1430
|
+
version: "22.2.3",
|
|
1431
|
+
ngImport: i0,
|
|
1432
|
+
type: O3rReplaceWithBoldPipe,
|
|
1433
|
+
decorators: [{
|
|
1434
|
+
type: Pipe,
|
|
1435
|
+
args: [{ name: "o3rReplaceWithBold" }]
|
|
1436
|
+
}]
|
|
1437
|
+
});
|
|
1438
|
+
var PlaceholderComponent = class PlaceholderComponent {
|
|
1439
|
+
set id(value) {
|
|
1440
|
+
this.id$.next(value);
|
|
1441
|
+
}
|
|
1442
|
+
constructor() {
|
|
1443
|
+
this.store = inject(Store);
|
|
1444
|
+
this.cd = inject(ChangeDetectorRef);
|
|
1445
|
+
this.id$ = new BehaviorSubject(void 0);
|
|
1446
|
+
this.afterViewInit$ = new Subject();
|
|
1447
|
+
this.messages$ = new ReplaySubject(1);
|
|
1448
|
+
this.destroyRef = inject(DestroyRef);
|
|
1449
|
+
this.mode = this.store.selectSignal(selectPlaceholderTemplateMode);
|
|
1450
|
+
}
|
|
1451
|
+
ngOnInit() {
|
|
1452
|
+
this.id$.pipe(filter((id) => !!id), distinctUntilChanged(), switchMap((id) => this.store.select(selectSortedTemplates(id)).pipe(takeUntilDestroyed(this.destroyRef), map((placeholders) => ({
|
|
1453
|
+
id,
|
|
1454
|
+
orderedTemplates: placeholders?.orderedTemplates,
|
|
1455
|
+
isPending: placeholders?.isPending
|
|
1456
|
+
})), distinctUntilChanged((previous, current) => previous.id === current.id && previous.isPending === current.isPending && previous.orderedTemplates?.map((placeholder) => placeholder.renderedTemplate).join("") === current.orderedTemplates?.map((placeholder) => placeholder.renderedTemplate).join(""))))).subscribe(({ id, orderedTemplates, isPending }) => {
|
|
1457
|
+
this.isPending = isPending;
|
|
1458
|
+
this.template = orderedTemplates?.length ? orderedTemplates.map((placeholder) => placeholder.renderedTemplate).join("") : void 0;
|
|
1459
|
+
if (this.isPending === false) this.messages$.next({
|
|
1460
|
+
templateIds: this.isPending ? [] : (orderedTemplates || []).map((placeholder) => placeholder.resolvedUrl),
|
|
1461
|
+
placeholderId: id
|
|
1462
|
+
});
|
|
1463
|
+
this.cd.markForCheck();
|
|
1464
|
+
});
|
|
1465
|
+
this.messages$.pipe(takeUntilDestroyed(this.destroyRef), sample(this.afterViewInit$), distinctUntilChanged((previous, current) => JSON.stringify(current) === JSON.stringify(previous))).subscribe({
|
|
1466
|
+
next: (data) => sendOtterMessage("placeholder-loading-status", data, false),
|
|
1467
|
+
complete: () => sendOtterMessage("placeholder-loading-status", {
|
|
1468
|
+
placeholderId: this.id$.value,
|
|
1469
|
+
templateIds: []
|
|
1470
|
+
}, false)
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1473
|
+
ngAfterViewChecked() {
|
|
1474
|
+
this.afterViewInit$.next();
|
|
1475
|
+
}
|
|
1476
|
+
ngOnDestroy() {
|
|
1477
|
+
this.id$.complete();
|
|
1478
|
+
this.messages$.complete();
|
|
1479
|
+
this.afterViewInit$.complete();
|
|
1480
|
+
}
|
|
1481
|
+
static {
|
|
1482
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1483
|
+
minVersion: "12.0.0",
|
|
1484
|
+
version: "22.2.3",
|
|
1485
|
+
ngImport: i0,
|
|
1486
|
+
type: PlaceholderComponent,
|
|
1487
|
+
deps: [],
|
|
1488
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1489
|
+
});
|
|
1490
|
+
}
|
|
1491
|
+
static {
|
|
1492
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1493
|
+
minVersion: "17.0.0",
|
|
1494
|
+
version: "22.2.3",
|
|
1495
|
+
type: PlaceholderComponent,
|
|
1496
|
+
isStandalone: true,
|
|
1497
|
+
selector: "o3r-placeholder",
|
|
1498
|
+
inputs: { id: "id" },
|
|
1499
|
+
host: { properties: { "class.debug": "mode() === 'debug'" } },
|
|
1500
|
+
ngImport: i0,
|
|
1501
|
+
template: "<ng-template #projection>\n <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",
|
|
1502
|
+
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"],
|
|
1503
|
+
dependencies: [{
|
|
1504
|
+
kind: "directive",
|
|
1505
|
+
type: NgTemplateOutlet,
|
|
1506
|
+
selector: "[ngTemplateOutlet]",
|
|
1507
|
+
inputs: [
|
|
1508
|
+
"ngTemplateOutletContext",
|
|
1509
|
+
"ngTemplateOutlet",
|
|
1510
|
+
"ngTemplateOutletInjector"
|
|
1511
|
+
]
|
|
1512
|
+
}, {
|
|
1513
|
+
kind: "pipe",
|
|
1514
|
+
type: AsyncPipe,
|
|
1515
|
+
name: "async"
|
|
1516
|
+
}],
|
|
1517
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush,
|
|
1518
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
};
|
|
1522
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1523
|
+
minVersion: "12.0.0",
|
|
1524
|
+
version: "22.2.3",
|
|
1525
|
+
ngImport: i0,
|
|
1526
|
+
type: PlaceholderComponent,
|
|
1527
|
+
decorators: [{
|
|
1528
|
+
type: Component,
|
|
1529
|
+
args: [{
|
|
1530
|
+
selector: "o3r-placeholder",
|
|
1531
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1532
|
+
encapsulation: ViewEncapsulation.None,
|
|
1533
|
+
imports: [AsyncPipe, NgTemplateOutlet],
|
|
1534
|
+
host: { "[class.debug]": `mode() === 'debug'` },
|
|
1535
|
+
template: "<ng-template #projection>\n <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",
|
|
1536
|
+
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"]
|
|
1537
|
+
}]
|
|
1538
|
+
}],
|
|
1539
|
+
ctorParameters: () => [],
|
|
1540
|
+
propDecorators: { id: [{ type: Input }] }
|
|
1541
|
+
});
|
|
1542
|
+
var PlaceholderModule = class PlaceholderModule {
|
|
1543
|
+
static {
|
|
1544
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
1545
|
+
minVersion: "12.0.0",
|
|
1546
|
+
version: "22.2.3",
|
|
1547
|
+
ngImport: i0,
|
|
1548
|
+
type: PlaceholderModule,
|
|
1549
|
+
deps: [],
|
|
1550
|
+
target: i0.ɵɵFactoryTarget.NgModule
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
static {
|
|
1554
|
+
this.ɵmod = i0.ɵɵngDeclareNgModule({
|
|
1555
|
+
minVersion: "14.0.0",
|
|
1556
|
+
version: "22.2.3",
|
|
1557
|
+
ngImport: i0,
|
|
1558
|
+
type: PlaceholderModule,
|
|
1559
|
+
imports: [
|
|
1560
|
+
CommonModule,
|
|
1561
|
+
StoreModule,
|
|
1562
|
+
PlaceholderTemplateStoreModule,
|
|
1563
|
+
PlaceholderRequestStoreModule,
|
|
1564
|
+
PlaceholderComponent
|
|
1565
|
+
]
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
static {
|
|
1569
|
+
this.ɵinj = i0.ɵɵngDeclareInjector({
|
|
1570
|
+
minVersion: "12.0.0",
|
|
1571
|
+
version: "22.2.3",
|
|
1572
|
+
ngImport: i0,
|
|
1573
|
+
type: PlaceholderModule,
|
|
1574
|
+
imports: [
|
|
1575
|
+
CommonModule,
|
|
1576
|
+
StoreModule,
|
|
1577
|
+
PlaceholderTemplateStoreModule,
|
|
1578
|
+
PlaceholderRequestStoreModule
|
|
1579
|
+
]
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
};
|
|
1583
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1584
|
+
minVersion: "12.0.0",
|
|
1585
|
+
version: "22.2.3",
|
|
1586
|
+
ngImport: i0,
|
|
1587
|
+
type: PlaceholderModule,
|
|
1588
|
+
decorators: [{
|
|
1589
|
+
type: NgModule,
|
|
1590
|
+
args: [{ imports: [
|
|
1591
|
+
CommonModule,
|
|
1592
|
+
StoreModule,
|
|
1593
|
+
PlaceholderTemplateStoreModule,
|
|
1594
|
+
PlaceholderRequestStoreModule,
|
|
1595
|
+
PlaceholderComponent
|
|
1596
|
+
] }]
|
|
1597
|
+
}]
|
|
1598
|
+
});
|
|
1735
1599
|
function providePlaceholder() {
|
|
1736
|
-
|
|
1737
|
-
providePlaceholderTemplateStore(),
|
|
1738
|
-
providePlaceholderRequestStore()
|
|
1739
|
-
]);
|
|
1600
|
+
return makeEnvironmentProviders([providePlaceholderTemplateStore(), providePlaceholderRequestStore()]);
|
|
1740
1601
|
}
|
|
1741
|
-
|
|
1742
|
-
/**
|
|
1743
|
-
* Generated bundle index. Do not edit.
|
|
1744
|
-
*/
|
|
1745
|
-
|
|
1746
1602
|
export { C11N_PRESENTERS_MAP_TOKEN, C11N_REGISTER_FUNC_TOKEN, C11nDirective, C11nMockModule, C11nMockService, C11nService, ComponentsDevtoolsMessageService, ComponentsDevtoolsModule, INSPECTOR_CLASS, 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, 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, provideC11nMock, provideComponentsDevtools, provideCustomComponents, providePlaceholder, providePlaceholderRequestStore, providePlaceholderTemplateStore, registerCustomComponent, selectPlaceholderRequestEntities, selectPlaceholderRequestEntityUsage, selectPlaceholderRequestState, selectPlaceholderTemplateEntities, selectPlaceholderTemplateEntity, selectPlaceholderTemplateMode, selectPlaceholderTemplateState, selectSortedTemplates, setPlaceholderRequestEntityFromUrl, setPlaceholderTemplateEntity, togglePlaceholderModeTemplate, updatePlaceholderRequestEntity, updatePlaceholderRequestEntitySync, withComponent };
|
|
1747
|
-
|
|
1603
|
+
|
|
1604
|
+
//# sourceMappingURL=o3r-components.mjs.map
|