@o3r/dynamic-content 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.
@@ -1,580 +1,442 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, NgModule, makeEnvironmentProviders, inject, Injectable, ChangeDetectorRef, Pipe } from '@angular/core';
3
- import * as i1 from '@ngrx/store';
4
- import { createAction, props, on, createReducer, StoreModule, provideState, createFeatureSelector, createSelector, Store, select } from '@ngrx/store';
5
- import { of, firstValueFrom } from 'rxjs';
6
- import { map, distinctUntilChanged, shareReplay } from 'rxjs/operators';
7
-
8
- /** Actions */
9
- const ACTION_SET = '[AssetPathOverride] set entities';
10
- /**
11
- * Clear all overrides and fill the store with the payload
12
- */
13
- const setAssetPathOverride = createAction(ACTION_SET, props());
14
-
15
- /**
16
- * AssetPathOverride Store initial value
17
- */
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectorRef, Injectable, InjectionToken, NgModule, Pipe, inject, makeEnvironmentProviders } from "@angular/core";
3
+ import * as i1 from "@ngrx/store";
4
+ import { Store, StoreModule, createAction, createFeatureSelector, createReducer, createSelector, on, props, provideState, select } from "@ngrx/store";
5
+ import { firstValueFrom, of } from "rxjs";
6
+ import { distinctUntilChanged, map, shareReplay } from "rxjs/operators";
7
+ const setAssetPathOverride = createAction("[AssetPathOverride] set entities", props());
18
8
  const assetPathOverrideInitialState = { assetPathOverrides: {} };
19
- /**
20
- * List of basic actions for AssetPathOverride Store
21
- */
22
- const assetPathOverrideReducerFeatures = [
23
- on(setAssetPathOverride, (_state, payload) => ({ ...payload.state }))
24
- ];
25
- /**
26
- * AssetPathOverride Store reducer
27
- */
9
+ const assetPathOverrideReducerFeatures = [on(setAssetPathOverride, (_state, payload) => ({ ...payload.state }))];
28
10
  const assetPathOverrideReducer = createReducer(assetPathOverrideInitialState, ...assetPathOverrideReducerFeatures);
29
-
30
- /**
31
- * Name of the AssetPathOverride Store
32
- */
33
- const ASSET_PATH_OVERRIDE_STORE_NAME = 'assetPathOverride';
34
-
35
- /** Token of the AssetPathOverride reducer */
36
- const ASSET_PATH_OVERRIDE_REDUCER_TOKEN = new InjectionToken('Feature AssetPathOverride Reducer');
37
- /** Provide default reducer for AssetPathOverride store */
11
+ const ASSET_PATH_OVERRIDE_STORE_NAME = "assetPathOverride";
12
+ const ASSET_PATH_OVERRIDE_REDUCER_TOKEN = new InjectionToken("Feature AssetPathOverride Reducer");
38
13
  function getDefaultAssetPathOverrideReducer() {
39
- return assetPathOverrideReducer;
14
+ return assetPathOverrideReducer;
40
15
  }
41
- /**
42
- * @deprecated Will be removed in v16. Use {@link provideAssetPathOverrideStore} instead.
43
- */
44
- class AssetPathOverrideStoreModule {
45
- static forRoot(reducerFactory) {
46
- return {
47
- ngModule: AssetPathOverrideStoreModule,
48
- providers: [
49
- { provide: ASSET_PATH_OVERRIDE_REDUCER_TOKEN, useFactory: reducerFactory }
50
- ]
51
- };
52
- }
53
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: AssetPathOverrideStoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
54
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: AssetPathOverrideStoreModule, imports: [i1.StoreFeatureModule] }); }
55
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: AssetPathOverrideStoreModule, providers: [
56
- { provide: ASSET_PATH_OVERRIDE_REDUCER_TOKEN, useFactory: getDefaultAssetPathOverrideReducer }
57
- ], imports: [StoreModule.forFeature(ASSET_PATH_OVERRIDE_STORE_NAME, ASSET_PATH_OVERRIDE_REDUCER_TOKEN)] }); }
58
- }
59
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: AssetPathOverrideStoreModule, decorators: [{
60
- type: NgModule,
61
- args: [{
62
- imports: [
63
- StoreModule.forFeature(ASSET_PATH_OVERRIDE_STORE_NAME, ASSET_PATH_OVERRIDE_REDUCER_TOKEN)
64
- ],
65
- providers: [
66
- { provide: ASSET_PATH_OVERRIDE_REDUCER_TOKEN, useFactory: getDefaultAssetPathOverrideReducer }
67
- ]
68
- }]
69
- }] });
70
- /**
71
- * Provide AssetPathOverride feature store.
72
- * @param reducerFactory Optional factory to override the default reducer.
73
- */
16
+ var AssetPathOverrideStoreModule = class AssetPathOverrideStoreModule {
17
+ static forRoot(reducerFactory) {
18
+ return {
19
+ ngModule: AssetPathOverrideStoreModule,
20
+ providers: [{
21
+ provide: ASSET_PATH_OVERRIDE_REDUCER_TOKEN,
22
+ useFactory: reducerFactory
23
+ }]
24
+ };
25
+ }
26
+ static {
27
+ this.ɵfac = i0.ɵɵngDeclareFactory({
28
+ minVersion: "12.0.0",
29
+ version: "22.2.3",
30
+ ngImport: i0,
31
+ type: AssetPathOverrideStoreModule,
32
+ deps: [],
33
+ target: i0.ɵɵFactoryTarget.NgModule
34
+ });
35
+ }
36
+ static {
37
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
38
+ minVersion: "14.0.0",
39
+ version: "22.2.3",
40
+ ngImport: i0,
41
+ type: AssetPathOverrideStoreModule,
42
+ imports: [i1.StoreFeatureModule]
43
+ });
44
+ }
45
+ static {
46
+ this.ɵinj = i0.ɵɵngDeclareInjector({
47
+ minVersion: "12.0.0",
48
+ version: "22.2.3",
49
+ ngImport: i0,
50
+ type: AssetPathOverrideStoreModule,
51
+ providers: [{
52
+ provide: ASSET_PATH_OVERRIDE_REDUCER_TOKEN,
53
+ useFactory: getDefaultAssetPathOverrideReducer
54
+ }],
55
+ imports: [StoreModule.forFeature(ASSET_PATH_OVERRIDE_STORE_NAME, ASSET_PATH_OVERRIDE_REDUCER_TOKEN)]
56
+ });
57
+ }
58
+ };
59
+ i0.ɵɵngDeclareClassMetadata({
60
+ minVersion: "12.0.0",
61
+ version: "22.2.3",
62
+ ngImport: i0,
63
+ type: AssetPathOverrideStoreModule,
64
+ decorators: [{
65
+ type: NgModule,
66
+ args: [{
67
+ imports: [StoreModule.forFeature(ASSET_PATH_OVERRIDE_STORE_NAME, ASSET_PATH_OVERRIDE_REDUCER_TOKEN)],
68
+ providers: [{
69
+ provide: ASSET_PATH_OVERRIDE_REDUCER_TOKEN,
70
+ useFactory: getDefaultAssetPathOverrideReducer
71
+ }]
72
+ }]
73
+ }]
74
+ });
74
75
  function provideAssetPathOverrideStore(reducerFactory) {
75
- return makeEnvironmentProviders([
76
- provideState(ASSET_PATH_OVERRIDE_STORE_NAME, reducerFactory ? reducerFactory() : assetPathOverrideReducer)
77
- ]);
76
+ return makeEnvironmentProviders([provideState(ASSET_PATH_OVERRIDE_STORE_NAME, reducerFactory ? reducerFactory() : assetPathOverrideReducer)]);
78
77
  }
79
-
80
- /** Select AssetPathOverride State */
81
78
  const selectAssetPathOverrideState = createFeatureSelector(ASSET_PATH_OVERRIDE_STORE_NAME);
82
- /** Select all assetPath override map */
83
79
  const selectAssetPathOverride = createSelector(selectAssetPathOverrideState, (state) => state?.assetPathOverrides || {});
84
-
85
- /**
86
- * Deserializer
87
- * @param rawObject
88
- */
89
80
  const assetPathOverrideStorageDeserializer = (rawObject) => {
90
- if (!rawObject) {
91
- return assetPathOverrideInitialState;
92
- }
93
- return rawObject;
81
+ if (!rawObject) return assetPathOverrideInitialState;
82
+ return rawObject;
94
83
  };
95
- const assetPathOverrideStorageSync = {
96
- deserialize: assetPathOverrideStorageDeserializer
84
+ const assetPathOverrideStorageSync = { deserialize: assetPathOverrideStorageDeserializer };
85
+ const DYNAMIC_CONTENT_BASE_PATH_TOKEN = new InjectionToken("Dynamic content path injection token");
86
+ const CMS_ASSETS_PATH_TOKEN = new InjectionToken("CMS assets path injection token");
87
+ const MEDIA_FOLDER_NAME = "assets";
88
+ var DynamicContentService = class DynamicContentService {
89
+ constructor() {
90
+ this.cmsOnlyAssetsPath = inject(CMS_ASSETS_PATH_TOKEN);
91
+ this.store = inject(Store, { optional: true });
92
+ const dynamicContentPath = inject(DYNAMIC_CONTENT_BASE_PATH_TOKEN);
93
+ this.basePath = dynamicContentPath.replace(/\/$/, "");
94
+ this.mediaFolder = MEDIA_FOLDER_NAME;
95
+ }
96
+ normalizePath(assetPath) {
97
+ return assetPath ? assetPath.replace(/^\//, "") : "";
98
+ }
99
+ isAbsoluteUrl(assetPath) {
100
+ return URL.canParse(assetPath);
101
+ }
102
+ getContentPath(assetPath) {
103
+ if (assetPath && this.isAbsoluteUrl(assetPath)) return assetPath;
104
+ const normalizedAssetPath = this.normalizePath(assetPath);
105
+ return this.basePath === "" ? assetPath || "" : `${this.basePath}/${normalizedAssetPath}`;
106
+ }
107
+ getMediaPath(assetPath) {
108
+ if (assetPath && this.isAbsoluteUrl(assetPath)) return assetPath;
109
+ if (this.cmsOnlyAssetsPath && assetPath) return assetPath.startsWith("/") ? assetPath : `${this.cmsOnlyAssetsPath.replace(/\/$/, "")}/${assetPath}`;
110
+ return this.getContentPath(this.mediaFolder ? `${this.mediaFolder}/${this.normalizePath(assetPath)}` : assetPath);
111
+ }
112
+ getContentPathStream(assetPath) {
113
+ return of(this.getContentPath(assetPath));
114
+ }
115
+ getMediaPathStream(assetPath) {
116
+ if (!this.store) return of(this.getMediaPath(assetPath));
117
+ return this.store.pipe(select(selectAssetPathOverride), map((entities) => assetPath && entities && entities[assetPath] ? entities[assetPath] : assetPath), map((finalAssetPath) => this.getMediaPath(finalAssetPath)), distinctUntilChanged(), shareReplay({
118
+ bufferSize: 1,
119
+ refCount: true
120
+ }));
121
+ }
122
+ static {
123
+ this.ɵfac = i0.ɵɵngDeclareFactory({
124
+ minVersion: "12.0.0",
125
+ version: "22.2.3",
126
+ ngImport: i0,
127
+ type: DynamicContentService,
128
+ deps: [],
129
+ target: i0.ɵɵFactoryTarget.Injectable
130
+ });
131
+ }
132
+ static {
133
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
134
+ minVersion: "12.0.0",
135
+ version: "22.2.3",
136
+ ngImport: i0,
137
+ type: DynamicContentService
138
+ });
139
+ }
97
140
  };
98
-
99
- /**
100
- * Injection token for the rootpath of dynamic content
101
- */
102
- const DYNAMIC_CONTENT_BASE_PATH_TOKEN = new InjectionToken('Dynamic content path injection token');
103
- /**
104
- * Injection token for the assets path injected by the cms
105
- * This token will be injected only in editor mode
106
- */
107
- const CMS_ASSETS_PATH_TOKEN = new InjectionToken('CMS assets path injection token');
108
-
109
- const MEDIA_FOLDER_NAME = 'assets';
110
- /**
111
- * Service for getting dynamic content path
112
- */
113
- class DynamicContentService {
114
- constructor() {
115
- this.cmsOnlyAssetsPath = inject(CMS_ASSETS_PATH_TOKEN);
116
- this.store = inject(Store, { optional: true });
117
- const dynamicContentPath = inject(DYNAMIC_CONTENT_BASE_PATH_TOKEN);
118
- this.basePath = dynamicContentPath.replace(/\/$/, '');
119
- this.mediaFolder = MEDIA_FOLDER_NAME;
120
- }
121
- normalizePath(assetPath) {
122
- return assetPath ? assetPath.replace(/^\//, '') : '';
123
- }
124
- isAbsoluteUrl(assetPath) {
125
- return URL.canParse(assetPath);
126
- }
127
- getContentPath(assetPath) {
128
- if (assetPath && this.isAbsoluteUrl(assetPath)) {
129
- return assetPath;
130
- }
131
- const normalizedAssetPath = this.normalizePath(assetPath);
132
- return this.basePath === '' ? assetPath || '' : `${this.basePath}/${normalizedAssetPath}`;
133
- }
134
- getMediaPath(assetPath) {
135
- if (assetPath && this.isAbsoluteUrl(assetPath)) {
136
- return assetPath;
137
- }
138
- if (this.cmsOnlyAssetsPath && assetPath) {
139
- return assetPath.startsWith('/') ? assetPath : `${this.cmsOnlyAssetsPath.replace(/\/$/, '')}/${assetPath}`;
140
- }
141
- return this.getContentPath(this.mediaFolder ? `${this.mediaFolder}/${this.normalizePath(assetPath)}` : assetPath);
142
- }
143
- /**
144
- * Gets the full path of a content relative to the root
145
- * Content path doesn't consider any override, you will always get the same file
146
- * @param assetPath asset location in the root folder
147
- * @example
148
- * ```typescript
149
- * getMediaPath('assets/imgs/my-image.png') // will give you the basePath + 'assets/imgs/my-image.png'
150
- * ```
151
- */
152
- getContentPathStream(assetPath) {
153
- return of(this.getContentPath(assetPath));
154
- }
155
- /**
156
- * Gets the stream that provides the full path of a media content
157
- * A Media content is always stored in the 'assets' media folder, no external content will be accessible through this function
158
- * If any override is applied to the content, returns the override path instead
159
- * @param assetPath asset location in the media folder (e.g imgs/my-image.png)
160
- * @example
161
- * ```typescript
162
- * getMediaPathStream('imgs/my-image.png') // will give you the basePath + mediaFolder + 'imgs/my-image.png'
163
- * ```
164
- */
165
- getMediaPathStream(assetPath) {
166
- if (!this.store) {
167
- return of(this.getMediaPath(assetPath));
168
- }
169
- return this.store.pipe(select(selectAssetPathOverride), map((entities) => assetPath && entities && entities[assetPath] ? entities[assetPath] : assetPath), map((finalAssetPath) => this.getMediaPath(finalAssetPath)), distinctUntilChanged(), shareReplay({ bufferSize: 1, refCount: true }));
170
- }
171
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: DynamicContentService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
172
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: DynamicContentService }); }
173
- }
174
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: DynamicContentService, decorators: [{
175
- type: Injectable
176
- }], ctorParameters: () => [] });
177
-
178
- /**
179
- * Function to get dynamic content from body dataset
180
- */
141
+ i0.ɵɵngDeclareClassMetadata({
142
+ minVersion: "12.0.0",
143
+ version: "22.2.3",
144
+ ngImport: i0,
145
+ type: DynamicContentService,
146
+ decorators: [{ type: Injectable }],
147
+ ctorParameters: () => []
148
+ });
181
149
  function getDynamicContent() {
182
- return document.body.dataset.dynamiccontentpath || '';
150
+ return document.body.dataset.dynamiccontentpath || "";
183
151
  }
184
- /**
185
- * Function to get the cms assets from body dataset
186
- * This will be used only in a CMS context(not in local or prod) to display correctly the assets in the editor
187
- */
188
152
  function getCmsAssets() {
189
- return document.body.dataset.cmsassetspath || '';
153
+ return document.body.dataset.cmsassetspath || "";
190
154
  }
191
- /**
192
- * Specify a custom base path
193
- * @param basePath
194
- */
195
155
  function withBasePath(basePath) {
196
- return {
197
- ɵkind: 'base-path',
198
- ɵproviders: [
199
- {
200
- provide: DYNAMIC_CONTENT_BASE_PATH_TOKEN,
201
- ...(typeof basePath === 'string'
202
- ? { useValue: basePath }
203
- : { useFactory: basePath })
204
- }
205
- ]
206
- };
156
+ return {
157
+ ɵkind: "base-path",
158
+ ɵproviders: [{
159
+ provide: DYNAMIC_CONTENT_BASE_PATH_TOKEN,
160
+ ...typeof basePath === "string" ? { useValue: basePath } : { useFactory: basePath }
161
+ }]
162
+ };
207
163
  }
208
- /**
209
- * Specify a custom CMS assets path
210
- * @param cmsAssetsPath
211
- */
212
164
  function withCmsAssetsPath(cmsAssetsPath) {
213
- return {
214
- ɵkind: 'cms-assets-path',
215
- ɵproviders: [
216
- {
217
- provide: CMS_ASSETS_PATH_TOKEN,
218
- ...(typeof cmsAssetsPath === 'string'
219
- ? { useValue: cmsAssetsPath }
220
- : { useFactory: cmsAssetsPath })
221
- }
222
- ]
223
- };
165
+ return {
166
+ ɵkind: "cms-assets-path",
167
+ ɵproviders: [{
168
+ provide: CMS_ASSETS_PATH_TOKEN,
169
+ ...typeof cmsAssetsPath === "string" ? { useValue: cmsAssetsPath } : { useFactory: cmsAssetsPath }
170
+ }]
171
+ };
224
172
  }
225
- /**
226
- * Provide dynamic content default configuration.
227
- * To customize the location where the application will search for the base path of dynamic content
228
- * @see {@link withBasePath}
229
- * @see {@link withCmsAssetsPath}
230
- * @note The cmsAssets will be used only in the cms editor mode and it will take priority over dynamic content
231
- * @param features
232
- * @example
233
- * ```typescript
234
- * bootstrapApplication(App,
235
- * {
236
- * providers: [
237
- * provideDynamicContent(
238
- * withBasePath('custom/base/path'),
239
- * withCmsAssetsPath('custom/cms/assets/path'),
240
- * )
241
- * ]
242
- * }
243
- * );
244
- */
245
173
  function provideDynamicContent(...features) {
246
- const providers = [
247
- DynamicContentService
248
- ];
249
- const basePathFeature = features.find((f) => f.ɵkind === 'base-path') ?? withBasePath(getDynamicContent);
250
- providers.push(basePathFeature.ɵproviders);
251
- const cmsAssetsPathFeature = features.find((f) => f.ɵkind === 'cms-assets-path') ?? withCmsAssetsPath(getCmsAssets);
252
- providers.push(cmsAssetsPathFeature.ɵproviders);
253
- return makeEnvironmentProviders(providers);
254
- }
255
-
256
- class O3rDynamicContentPipe {
257
- constructor() {
258
- this.service = inject(DynamicContentService);
259
- this.cd = inject(ChangeDetectorRef);
260
- /** Path to the media */
261
- this.mediaPath = '';
262
- }
263
- /** @inheritDoc */
264
- transform(query) {
265
- if (query !== this.lastQuery) {
266
- this.lastQuery = query;
267
- if (this.onMediaPathChange) {
268
- this.onMediaPathChange.unsubscribe();
269
- }
270
- this.onMediaPathChange = this.service.getMediaPathStream(query).subscribe((mediaPath) => {
271
- this.mediaPath = mediaPath;
272
- this.cd.markForCheck();
273
- });
274
- }
275
- return this.mediaPath;
276
- }
277
- /** @inheritDoc */
278
- ngOnDestroy() {
279
- if (this.onMediaPathChange) {
280
- this.onMediaPathChange.unsubscribe();
281
- }
282
- }
283
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: O3rDynamicContentPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
284
- /** @nocollapse */ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "22.2.0", ngImport: i0, type: O3rDynamicContentPipe, isStandalone: true, name: "o3rDynamicContent", pure: false }); }
174
+ const providers = [DynamicContentService];
175
+ const basePathFeature = features.find((f) => f.ɵkind === "base-path") ?? withBasePath(getDynamicContent);
176
+ providers.push(basePathFeature.ɵproviders);
177
+ const cmsAssetsPathFeature = features.find((f) => f.ɵkind === "cms-assets-path") ?? withCmsAssetsPath(getCmsAssets);
178
+ providers.push(cmsAssetsPathFeature.ɵproviders);
179
+ return makeEnvironmentProviders(providers);
285
180
  }
286
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: O3rDynamicContentPipe, decorators: [{
287
- type: Pipe,
288
- args: [{
289
- name: 'o3rDynamicContent',
290
- pure: false
291
- }]
292
- }] });
293
-
294
- /**
295
- * Strategies available to read / write data in the RequestParameters service.
296
- * Rehydrate: if the storage already have data, those will be used by the service, ignoring new data. Otherwise set the storage
297
- * Merge: storage data will be merged with the ones provided. (provided data has priority)
298
- * Replace: storage data will be completely replaced by the ones provided
299
- * ReplaceIfNotEmpty: If no parameters are provided, use the content from storage. Otherwise use the ones provided and update the storage with them.
300
- */
181
+ var O3rDynamicContentPipe = class O3rDynamicContentPipe {
182
+ constructor() {
183
+ this.service = inject(DynamicContentService);
184
+ this.cd = inject(ChangeDetectorRef);
185
+ this.mediaPath = "";
186
+ }
187
+ transform(query) {
188
+ if (query !== this.lastQuery) {
189
+ this.lastQuery = query;
190
+ if (this.onMediaPathChange) this.onMediaPathChange.unsubscribe();
191
+ this.onMediaPathChange = this.service.getMediaPathStream(query).subscribe((mediaPath) => {
192
+ this.mediaPath = mediaPath;
193
+ this.cd.markForCheck();
194
+ });
195
+ }
196
+ return this.mediaPath;
197
+ }
198
+ ngOnDestroy() {
199
+ if (this.onMediaPathChange) this.onMediaPathChange.unsubscribe();
200
+ }
201
+ static {
202
+ this.ɵfac = i0.ɵɵngDeclareFactory({
203
+ minVersion: "12.0.0",
204
+ version: "22.2.3",
205
+ ngImport: i0,
206
+ type: O3rDynamicContentPipe,
207
+ deps: [],
208
+ target: i0.ɵɵFactoryTarget.Pipe
209
+ });
210
+ }
211
+ static {
212
+ this.ɵpipe = i0.ɵɵngDeclarePipe({
213
+ minVersion: "14.0.0",
214
+ version: "22.2.3",
215
+ ngImport: i0,
216
+ type: O3rDynamicContentPipe,
217
+ isStandalone: true,
218
+ name: "o3rDynamicContent",
219
+ pure: false
220
+ });
221
+ }
222
+ };
223
+ i0.ɵɵngDeclareClassMetadata({
224
+ minVersion: "12.0.0",
225
+ version: "22.2.3",
226
+ ngImport: i0,
227
+ type: O3rDynamicContentPipe,
228
+ decorators: [{
229
+ type: Pipe,
230
+ args: [{
231
+ name: "o3rDynamicContent",
232
+ pure: false
233
+ }]
234
+ }]
235
+ });
301
236
  var StorageStrategy;
302
- (function (StorageStrategy) {
303
- // eslint-disable-next-line @typescript-eslint/naming-convention -- required naming convention
304
- StorageStrategy[StorageStrategy["Rehydrate"] = 0] = "Rehydrate";
305
- // eslint-disable-next-line @typescript-eslint/naming-convention -- required naming convention
306
- StorageStrategy[StorageStrategy["Merge"] = 1] = "Merge";
307
- // eslint-disable-next-line @typescript-eslint/naming-convention -- required naming convention
308
- StorageStrategy[StorageStrategy["Replace"] = 2] = "Replace";
309
- // eslint-disable-next-line @typescript-eslint/naming-convention -- required naming convention
310
- StorageStrategy[StorageStrategy["ReplaceIfNotEmpty"] = 3] = "ReplaceIfNotEmpty";
237
+ (function(StorageStrategy) {
238
+ StorageStrategy[StorageStrategy["Rehydrate"] = 0] = "Rehydrate";
239
+ StorageStrategy[StorageStrategy["Merge"] = 1] = "Merge";
240
+ StorageStrategy[StorageStrategy["Replace"] = 2] = "Replace";
241
+ StorageStrategy[StorageStrategy["ReplaceIfNotEmpty"] = 3] = "ReplaceIfNotEmpty";
311
242
  })(StorageStrategy || (StorageStrategy = {}));
312
243
  const defaultRequestParametersConfig = {
313
- storage: (typeof window === 'undefined') ? undefined : window.sessionStorage,
314
- strategy: StorageStrategy.Rehydrate,
315
- queryParamsValue: (typeof document !== 'undefined' && document.body?.dataset?.query) || '{}',
316
- postParamsValue: (typeof document !== 'undefined' && document.body?.dataset?.post) || '{}'
244
+ storage: typeof window === "undefined" ? void 0 : window.sessionStorage,
245
+ strategy: StorageStrategy.Rehydrate,
246
+ queryParamsValue: typeof document !== "undefined" && document.body?.dataset?.query || "{}",
247
+ postParamsValue: typeof document !== "undefined" && document.body?.dataset?.post || "{}"
317
248
  };
318
-
319
- /**
320
- * Token to be provided in case of service customization needs.
321
- */
322
- const REQUEST_PARAMETERS_CONFIG_TOKEN = new InjectionToken('RequestParametersConfig injection token', { factory: () => ({}) });
323
-
324
- /**
325
- * Service used to store the request parameters of your requests so that subsequent calls or refresh the page will preserve
326
- * them.
327
- */
328
- class RequestParametersService {
329
- constructor() {
330
- this._query = {};
331
- this._post = {};
332
- const config = inject(REQUEST_PARAMETERS_CONFIG_TOKEN);
333
- this.config = defaultRequestParametersConfig;
334
- Object.keys(config)
335
- .filter((key) => config[key] !== undefined)
336
- .forEach((key) => this.config[key] = config[key]);
337
- this.setParameters('query', JSON.parse(this.config.queryParamsValue));
338
- this.setParameters('post', JSON.parse(this.config.postParamsValue));
339
- }
340
- /**
341
- * Depending on the strategy, set the internal values for the parameters.
342
- * See StorageStrategy for more info.
343
- * @param key
344
- * @param value
345
- */
346
- setParameters(key, value) {
347
- const privateKey = `_${key}`;
348
- if (!this.config.storage) {
349
- // No storage is available , cannot set items
350
- return;
351
- }
352
- switch (this.config.strategy) {
353
- case StorageStrategy.Rehydrate: {
354
- if (!this.config.storage.getItem(privateKey)) {
355
- this[privateKey] = value;
356
- this.config.storage.setItem(privateKey, JSON.stringify(value));
357
- break;
358
- }
359
- this[privateKey] = JSON.parse(this.config.storage.getItem(privateKey) || '{}');
360
- break;
361
- }
362
- case StorageStrategy.Replace: {
363
- this[privateKey] = value;
364
- this.config.storage.setItem(privateKey, JSON.stringify(value));
365
- break;
366
- }
367
- case StorageStrategy.Merge: {
368
- const storageData = Object.assign(JSON.parse(this.config.storage.getItem(privateKey) || '{}'), value);
369
- this[privateKey] = storageData;
370
- this.config.storage.setItem(privateKey, JSON.stringify(storageData));
371
- break;
372
- }
373
- case StorageStrategy.ReplaceIfNotEmpty: {
374
- if (Object.keys(value).length > 0) {
375
- this[privateKey] = value;
376
- this.config.storage.setItem(privateKey, JSON.stringify(value));
377
- break;
378
- }
379
- this[privateKey] = JSON.parse(this.config.storage.getItem(privateKey) || '{}');
380
- break;
381
- }
382
- }
383
- }
384
- /**
385
- * Get all the query parameters in a map.
386
- */
387
- get query() {
388
- return this._query;
389
- }
390
- /**
391
- * Get all the post parameters in a map.
392
- */
393
- get post() {
394
- return this._post;
395
- }
396
- /**
397
- * Get a specific query parameter value, given the key.
398
- * @param key
399
- */
400
- getQueryParameter(key) {
401
- return this._query[key];
402
- }
403
- /**
404
- * Get a specific query parameter value as boolean, given the key.
405
- * @param key
406
- */
407
- getQueryParameterAsBoolean(key) {
408
- const queryParameter = this.getQueryParameter(key);
409
- return queryParameter ? queryParameter.toLowerCase() === 'true' : undefined;
410
- }
411
- /**
412
- * Get a specific post parameter value, given the key.
413
- * @param key
414
- */
415
- getPostParameter(key) {
416
- return this._post[key];
417
- }
418
- /**
419
- * Get a specific post parameter value as boolean, given the key.
420
- * @param key
421
- */
422
- getPostParameterAsBoolean(key) {
423
- const postParameter = this.getPostParameter(key);
424
- return postParameter ? postParameter.toLowerCase() === 'true' : undefined;
425
- }
426
- /**
427
- * Get a specific parameter value, given the key.
428
- * @param key
429
- */
430
- getParameter(key) {
431
- return this._query[key] || this._post[key];
432
- }
433
- /**
434
- * Get a specific parameter value as boolean, given the key.
435
- * @param key
436
- */
437
- getParameterAsBoolean(key) {
438
- const parameter = this.getParameter(key);
439
- return parameter ? parameter.toLowerCase() === 'true' : undefined;
440
- }
441
- /**
442
- * Clear GET parameters from the storage
443
- * @param paramsToClear the list on key that you want to clear in get parameters
444
- */
445
- clearQueryParameters(paramsToClear) {
446
- const newQuery = (paramsToClear ? Object.keys(this._query).filter((key) => !paramsToClear.includes(key)) : [])
447
- .reduce((acc, key) => {
448
- acc[key] = this._query[key];
449
- return acc;
450
- }, {});
451
- if (this.config.storage) {
452
- this.config.storage.setItem('_query', JSON.stringify(newQuery));
453
- }
454
- this._query = newQuery;
455
- }
456
- /**
457
- * Clear POST parameters from the storage
458
- * @param paramsToClear the list on key that you want to clean in post parameters
459
- */
460
- clearPostParameters(paramsToClear) {
461
- const newPost = (paramsToClear ? Object.keys(this._post).filter((key) => !paramsToClear.includes(key)) : [])
462
- .reduce((acc, key) => {
463
- acc[key] = this._post[key];
464
- return acc;
465
- }, {});
466
- if (this.config.storage) {
467
- this.config.storage.setItem('_post', JSON.stringify(newPost));
468
- }
469
- this._post = newPost;
470
- }
471
- /**
472
- * Get all the parameters in a map.
473
- * @param priority the parameter to be given priority in case same key is in get and post params.
474
- */
475
- getParams(priority = 'query') {
476
- return priority === 'query' ? { ...this._post, ...this._query } : { ...this._query, ...this._post };
477
- }
478
- /**
479
- * Filter Parameters(both Query/POST) from the storage
480
- * @param paramstoFilter the list on key that you want to filter from parameters
481
- * @param priority the priorty of the parameter type(POST/Query)
482
- */
483
- getFilteredParameters(paramstoFilter, priority = 'query') {
484
- const params = this.getParams(priority);
485
- if (!paramstoFilter) {
486
- return params;
487
- }
488
- return Object.keys(params)
489
- .filter((key) => !paramstoFilter.includes(key))
490
- .reduce((acc, key) => {
491
- acc[key] = params[key];
492
- return acc;
493
- }, {});
494
- }
495
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: RequestParametersService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
496
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: RequestParametersService }); }
497
- }
498
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: RequestParametersService, decorators: [{
499
- type: Injectable
500
- }], ctorParameters: () => [] });
501
-
502
- /**
503
- * Empty configuration factory, used when config is not provided. It needs a separate function for AOT.
504
- */
249
+ const REQUEST_PARAMETERS_CONFIG_TOKEN = new InjectionToken("RequestParametersConfig injection token", { factory: () => ({}) });
250
+ var RequestParametersService = class RequestParametersService {
251
+ constructor() {
252
+ this._query = {};
253
+ this._post = {};
254
+ const config = inject(REQUEST_PARAMETERS_CONFIG_TOKEN);
255
+ this.config = defaultRequestParametersConfig;
256
+ Object.keys(config).filter((key) => config[key] !== void 0).forEach((key) => this.config[key] = config[key]);
257
+ this.setParameters("query", JSON.parse(this.config.queryParamsValue));
258
+ this.setParameters("post", JSON.parse(this.config.postParamsValue));
259
+ }
260
+ setParameters(key, value) {
261
+ const privateKey = `_${key}`;
262
+ if (!this.config.storage) return;
263
+ switch (this.config.strategy) {
264
+ case StorageStrategy.Rehydrate:
265
+ if (!this.config.storage.getItem(privateKey)) {
266
+ this[privateKey] = value;
267
+ this.config.storage.setItem(privateKey, JSON.stringify(value));
268
+ break;
269
+ }
270
+ this[privateKey] = JSON.parse(this.config.storage.getItem(privateKey) || "{}");
271
+ break;
272
+ case StorageStrategy.Replace:
273
+ this[privateKey] = value;
274
+ this.config.storage.setItem(privateKey, JSON.stringify(value));
275
+ break;
276
+ case StorageStrategy.Merge: {
277
+ const storageData = Object.assign(JSON.parse(this.config.storage.getItem(privateKey) || "{}"), value);
278
+ this[privateKey] = storageData;
279
+ this.config.storage.setItem(privateKey, JSON.stringify(storageData));
280
+ break;
281
+ }
282
+ case StorageStrategy.ReplaceIfNotEmpty:
283
+ if (Object.keys(value).length > 0) {
284
+ this[privateKey] = value;
285
+ this.config.storage.setItem(privateKey, JSON.stringify(value));
286
+ break;
287
+ }
288
+ this[privateKey] = JSON.parse(this.config.storage.getItem(privateKey) || "{}");
289
+ }
290
+ }
291
+ get query() {
292
+ return this._query;
293
+ }
294
+ get post() {
295
+ return this._post;
296
+ }
297
+ getQueryParameter(key) {
298
+ return this._query[key];
299
+ }
300
+ getQueryParameterAsBoolean(key) {
301
+ const queryParameter = this.getQueryParameter(key);
302
+ return queryParameter ? queryParameter.toLowerCase() === "true" : void 0;
303
+ }
304
+ getPostParameter(key) {
305
+ return this._post[key];
306
+ }
307
+ getPostParameterAsBoolean(key) {
308
+ const postParameter = this.getPostParameter(key);
309
+ return postParameter ? postParameter.toLowerCase() === "true" : void 0;
310
+ }
311
+ getParameter(key) {
312
+ return this._query[key] || this._post[key];
313
+ }
314
+ getParameterAsBoolean(key) {
315
+ const parameter = this.getParameter(key);
316
+ return parameter ? parameter.toLowerCase() === "true" : void 0;
317
+ }
318
+ clearQueryParameters(paramsToClear) {
319
+ const newQuery = (paramsToClear ? Object.keys(this._query).filter((key) => !paramsToClear.includes(key)) : []).reduce((acc, key) => {
320
+ acc[key] = this._query[key];
321
+ return acc;
322
+ }, {});
323
+ if (this.config.storage) this.config.storage.setItem("_query", JSON.stringify(newQuery));
324
+ this._query = newQuery;
325
+ }
326
+ clearPostParameters(paramsToClear) {
327
+ const newPost = (paramsToClear ? Object.keys(this._post).filter((key) => !paramsToClear.includes(key)) : []).reduce((acc, key) => {
328
+ acc[key] = this._post[key];
329
+ return acc;
330
+ }, {});
331
+ if (this.config.storage) this.config.storage.setItem("_post", JSON.stringify(newPost));
332
+ this._post = newPost;
333
+ }
334
+ getParams(priority = "query") {
335
+ return priority === "query" ? {
336
+ ...this._post,
337
+ ...this._query
338
+ } : {
339
+ ...this._query,
340
+ ...this._post
341
+ };
342
+ }
343
+ getFilteredParameters(paramstoFilter, priority = "query") {
344
+ const params = this.getParams(priority);
345
+ if (!paramstoFilter) return params;
346
+ return Object.keys(params).filter((key) => !paramstoFilter.includes(key)).reduce((acc, key) => {
347
+ acc[key] = params[key];
348
+ return acc;
349
+ }, {});
350
+ }
351
+ static {
352
+ this.ɵfac = i0.ɵɵngDeclareFactory({
353
+ minVersion: "12.0.0",
354
+ version: "22.2.3",
355
+ ngImport: i0,
356
+ type: RequestParametersService,
357
+ deps: [],
358
+ target: i0.ɵɵFactoryTarget.Injectable
359
+ });
360
+ }
361
+ static {
362
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
363
+ minVersion: "12.0.0",
364
+ version: "22.2.3",
365
+ ngImport: i0,
366
+ type: RequestParametersService
367
+ });
368
+ }
369
+ };
370
+ i0.ɵɵngDeclareClassMetadata({
371
+ minVersion: "12.0.0",
372
+ version: "22.2.3",
373
+ ngImport: i0,
374
+ type: RequestParametersService,
375
+ decorators: [{ type: Injectable }],
376
+ ctorParameters: () => []
377
+ });
505
378
  function defaultConfigFactory() {
506
- return {};
379
+ return {};
507
380
  }
508
- /**
509
- * Provide request parameters config
510
- * We don't provide directly the value and use a factory because otherwise AOT compilation will resolve to undefined whatever is taken from window
511
- * @param config
512
- */
513
381
  function provideRequestParameters(config = defaultConfigFactory) {
514
- return makeEnvironmentProviders([
515
- {
516
- provide: REQUEST_PARAMETERS_CONFIG_TOKEN,
517
- useFactory: config
518
- },
519
- RequestParametersService
520
- ]);
382
+ return makeEnvironmentProviders([{
383
+ provide: REQUEST_PARAMETERS_CONFIG_TOKEN,
384
+ useFactory: config
385
+ }, RequestParametersService]);
521
386
  }
522
-
523
- /**
524
- * Service to lazy load a CSS file
525
- */
526
- class StyleLazyLoader {
527
- constructor() {
528
- this.dcService = inject(DynamicContentService);
529
- this.DEFAULT_STYLE_ELEMENT_ID = 'external-theme';
530
- }
531
- /**
532
- * Load a new CSS from an absolute URL, if we already HTML element exists with the url, otherwise
533
- * @param styleUrlConfig object containing CSS File absolute URL to load, integrity and crossOrigin attributes
534
- * and the styleId id of the dynamic style in the body tag.
535
- */
536
- loadStyleFromURL(styleUrlConfig) {
537
- const elementId = styleUrlConfig.id || this.DEFAULT_STYLE_ELEMENT_ID;
538
- let style = document.querySelector(`#${elementId}`);
539
- if (style === null) {
540
- style = document.createElement('link');
541
- style.rel = 'stylesheet';
542
- style.type = 'text/css';
543
- const head = document.querySelectorAll('head')[0];
544
- head.append(style);
545
- }
546
- if (styleUrlConfig.integrity) {
547
- style.integrity = styleUrlConfig.integrity;
548
- }
549
- if (styleUrlConfig.crossOrigin !== undefined) {
550
- style.crossOrigin = styleUrlConfig.crossOrigin;
551
- }
552
- style.href = styleUrlConfig.href;
553
- return style;
554
- }
555
- /**
556
- * Load a new CSS File
557
- * @param styleUrlConfig CSS File config containing URL to load, integrity and crossOrigin attributes
558
- * and the styleId id of the dynamic style in the body tag
559
- */
560
- async asyncLoadStyleFromDynamicContent(styleUrlConfig) {
561
- const dynamicContentPath = await firstValueFrom(this.dcService.getContentPathStream(styleUrlConfig.href));
562
- styleUrlConfig.href = dynamicContentPath;
563
- this.loadStyleFromURL(styleUrlConfig);
564
- }
565
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: StyleLazyLoader, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
566
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: StyleLazyLoader, providedIn: 'root' }); }
567
- }
568
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: StyleLazyLoader, decorators: [{
569
- type: Injectable,
570
- args: [{
571
- providedIn: 'root'
572
- }]
573
- }] });
574
-
575
- /**
576
- * Generated bundle index. Do not edit.
577
- */
578
-
387
+ var StyleLazyLoader = class StyleLazyLoader {
388
+ constructor() {
389
+ this.dcService = inject(DynamicContentService);
390
+ this.DEFAULT_STYLE_ELEMENT_ID = "external-theme";
391
+ }
392
+ loadStyleFromURL(styleUrlConfig) {
393
+ const elementId = styleUrlConfig.id || this.DEFAULT_STYLE_ELEMENT_ID;
394
+ let style = document.querySelector(`#${elementId}`);
395
+ if (style === null) {
396
+ style = document.createElement("link");
397
+ style.rel = "stylesheet";
398
+ style.type = "text/css";
399
+ document.querySelectorAll("head")[0].append(style);
400
+ }
401
+ if (styleUrlConfig.integrity) style.integrity = styleUrlConfig.integrity;
402
+ if (styleUrlConfig.crossOrigin !== void 0) style.crossOrigin = styleUrlConfig.crossOrigin;
403
+ style.href = styleUrlConfig.href;
404
+ return style;
405
+ }
406
+ async asyncLoadStyleFromDynamicContent(styleUrlConfig) {
407
+ styleUrlConfig.href = await firstValueFrom(this.dcService.getContentPathStream(styleUrlConfig.href));
408
+ this.loadStyleFromURL(styleUrlConfig);
409
+ }
410
+ static {
411
+ this.ɵfac = i0.ɵɵngDeclareFactory({
412
+ minVersion: "12.0.0",
413
+ version: "22.2.3",
414
+ ngImport: i0,
415
+ type: StyleLazyLoader,
416
+ deps: [],
417
+ target: i0.ɵɵFactoryTarget.Injectable
418
+ });
419
+ }
420
+ static {
421
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
422
+ minVersion: "12.0.0",
423
+ version: "22.2.3",
424
+ ngImport: i0,
425
+ type: StyleLazyLoader,
426
+ providedIn: "root"
427
+ });
428
+ }
429
+ };
430
+ i0.ɵɵngDeclareClassMetadata({
431
+ minVersion: "12.0.0",
432
+ version: "22.2.3",
433
+ ngImport: i0,
434
+ type: StyleLazyLoader,
435
+ decorators: [{
436
+ type: Injectable,
437
+ args: [{ providedIn: "root" }]
438
+ }]
439
+ });
579
440
  export { ASSET_PATH_OVERRIDE_REDUCER_TOKEN, ASSET_PATH_OVERRIDE_STORE_NAME, AssetPathOverrideStoreModule, CMS_ASSETS_PATH_TOKEN, DYNAMIC_CONTENT_BASE_PATH_TOKEN, DynamicContentService, O3rDynamicContentPipe, RequestParametersService, StorageStrategy, StyleLazyLoader, assetPathOverrideInitialState, assetPathOverrideReducer, assetPathOverrideReducerFeatures, assetPathOverrideStorageDeserializer, assetPathOverrideStorageSync, defaultConfigFactory, defaultRequestParametersConfig, getCmsAssets, getDefaultAssetPathOverrideReducer, getDynamicContent, provideAssetPathOverrideStore, provideDynamicContent, provideRequestParameters, selectAssetPathOverride, selectAssetPathOverrideState, setAssetPathOverride, withBasePath, withCmsAssetsPath };
580
- //# sourceMappingURL=o3r-dynamic-content.mjs.map
441
+
442
+ //# sourceMappingURL=o3r-dynamic-content.mjs.map