@ama-mfe/ng-utils 14.1.0-prerelease.56 → 14.1.0-prerelease.58

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/README.md CHANGED
@@ -13,6 +13,7 @@ look and feel.
13
13
  - [Resize](https://github.com/AmadeusITGroup/otter/blob/main/packages/%40ama-mfe/ng-utils/src/resize/): Dynamically adjusts the iframe dimensions to fit the content of the embedded application, enhancing the
14
14
  user experience.
15
15
  - [User Activity](https://github.com/AmadeusITGroup/otter/blob/main/packages/%40ama-mfe/ng-utils/src/user-activity/): Tracks user interactions across embedded micro-frontends for session timeout functionality, analytics, or any feature that needs to detect user activity.
16
+ - [Iframe Embed](https://github.com/AmadeusITGroup/otter/blob/main/packages/%40ama-mfe/ng-utils/src/iframe-embed/): A ready-to-use Angular component that renders an iframe with all MFE integration directives pre-wired (connect, scalable, host info, theme).
16
17
 
17
18
  ## Installation
18
19
  To install the package, run:
@@ -73,7 +74,17 @@ bootstrapApplication(App, appConfig)
73
74
  ```
74
75
 
75
76
  #### Initiate the connection to your embedded module
76
- Use the `connect` directive to initiate the communication between your application and the module in the iframe.
77
+ The recommended way to embed a module is to use the [`IframeEmbedComponent`](#iframe-embed-component), which
78
+ pre-wires `connect`, `scalable`, `hostInfo` and `applyTheme` on the iframe:
79
+
80
+ ```html
81
+ <mfe-iframe-embed
82
+ src="https://my-embedded-app.example.com"
83
+ moduleId="myModuleUniqueID"
84
+ hostApplicationId="hostUniqueID" />
85
+ ```
86
+
87
+ Alternatively, if you need full control over the iframe, you can use the `connect` directive directly.
77
88
  The communication pipe will be closed once the iframe is destroyed.
78
89
 
79
90
  ```html
@@ -255,12 +266,47 @@ export class CustomService implements MessageProducer<CustomMessageVersions> {
255
266
  }
256
267
  }
257
268
  ```
269
+ ### Iframe Embed Component
270
+
271
+ The `IframeEmbedComponent` is a ready-to-use component that renders an iframe with all MFE integration directives
272
+ pre-configured. It handles URL sanitization, cross-iframe communication (`connect`), auto-resizing (`scalable`),
273
+ host info injection (`hostInfo`) and theming (`applyTheme`).
274
+
275
+ ```typescript
276
+ import {IframeEmbedComponent} from '@ama-mfe/ng-utils';
277
+
278
+ @Component({
279
+ selector: 'app-host',
280
+ imports: [IframeEmbedComponent],
281
+ template: `
282
+ <mfe-iframe-embed
283
+ src="https://my-embedded-app.example.com"
284
+ moduleId="my-module-id"
285
+ hostApplicationId="host-app-id" />
286
+ `
287
+ })
288
+ export class HostComponent {}
289
+ ```
290
+
291
+ | Input | Type | Description |
292
+ |-------|------|-------------|
293
+ | `src` | `string \| SafeResourceUrl` | The URL for the iframe. Plain strings are automatically sanitized. |
294
+ | `moduleId` | `string` | Unique identifier for the embedded module (used by the `connect` directive). |
295
+ | `hostApplicationId` | `string` | The host application identifier sent to the embedded module via `hostInfo`. |
296
+
297
+ The component applies the `sandbox` attribute to the iframe for security.
298
+
258
299
  ### Host information
259
300
 
260
301
  #### Host application
261
302
 
262
303
  A host application can send information to the embedded applications using parameters in the URL.
263
304
 
305
+ The [`IframeEmbedComponent`](#iframe-embed-component) handles this automatically via its `moduleId` and
306
+ `hostApplicationId` inputs — no extra setup is needed.
307
+
308
+ If you manage the iframe yourself, you can apply the `hostInfo` pipe directly:
309
+
264
310
  ```html
265
311
  <iframe [src]="'myModuleUrl' | hostInfo: {hostId: 'host-app-id', moduleId: 'my-module-to-embed'}"></iframe>
266
312
  ```