@siemens/dashboards-ng 48.10.0 → 49.0.0-rc.2
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 +169 -21
- package/fesm2022/siemens-dashboards-ng-module-federation.mjs.map +1 -1
- package/fesm2022/siemens-dashboards-ng-native-federation-mf-bridge.mjs +38 -0
- package/fesm2022/siemens-dashboards-ng-native-federation-mf-bridge.mjs.map +1 -0
- package/fesm2022/siemens-dashboards-ng-native-federation.mjs +39 -0
- package/fesm2022/siemens-dashboards-ng-native-federation.mjs.map +1 -0
- package/fesm2022/siemens-dashboards-ng.mjs +180 -178
- package/fesm2022/siemens-dashboards-ng.mjs.map +1 -1
- package/module-federation/package.json +2 -1
- package/native-federation/mf-bridge/package.json +4 -0
- package/native-federation/package.json +4 -0
- package/package.json +32 -11
- package/translate/package.json +2 -1
- package/types/siemens-dashboards-ng-native-federation-mf-bridge.d.ts +9 -0
- package/types/siemens-dashboards-ng-native-federation.d.ts +3 -0
- package/{index.d.ts → types/siemens-dashboards-ng.d.ts} +119 -84
- /package/{module-federation/index.d.ts → types/siemens-dashboards-ng-module-federation.d.ts} +0 -0
- /package/{translate/index.d.ts → types/siemens-dashboards-ng-translate.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -28,16 +28,14 @@ providers: [
|
|
|
28
28
|
provideRouter(routes, withHashLocation()),
|
|
29
29
|
{ provide: SI_WIDGET_STORE, useClass: AppWidgetStorage },
|
|
30
30
|
{ provide: SI_DASHBOARD_CONFIGURATION, useValue: config },
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
),
|
|
40
|
-
provideAnimations(),
|
|
31
|
+
provideTranslateService({
|
|
32
|
+
loader: {
|
|
33
|
+
provide: TranslateLoader,
|
|
34
|
+
useFactory: createTranslateLoader,
|
|
35
|
+
deps: [HttpBackend]
|
|
36
|
+
},
|
|
37
|
+
missingTranslationHandler: provideMissingTranslationHandlerForElement()
|
|
38
|
+
}),
|
|
41
39
|
provideNgxTranslateForElement(),
|
|
42
40
|
provideHttpClient(withInterceptorsFromDi())
|
|
43
41
|
];
|
|
@@ -61,7 +59,7 @@ import { SiTranslateModule } from '@siemens/element-translate-ng/translate';
|
|
|
61
59
|
BrowserModule,
|
|
62
60
|
|
|
63
61
|
// Import this library
|
|
64
|
-
SiDashboardsNgModule
|
|
62
|
+
SiDashboardsNgModule
|
|
65
63
|
],
|
|
66
64
|
providers: [
|
|
67
65
|
provideNgxTranslateForElement()
|
|
@@ -184,6 +182,162 @@ The Angular component should export the template as the public attribute `footer
|
|
|
184
182
|
@ViewChild('footer', { static: true }) footer?: TemplateRef<unknown>;
|
|
185
183
|
```
|
|
186
184
|
|
|
185
|
+
### Remote Widget Loading (Microfrontends)
|
|
186
|
+
|
|
187
|
+
The flexible dashboard supports loading widgets as remote microfrontends, allowing widgets to be deployed and updated independently from the host application. Three integration options are available:
|
|
188
|
+
|
|
189
|
+
#### Pure Module Federation (Webpack-based)
|
|
190
|
+
|
|
191
|
+
Uses `@angular-architects/module-federation` to share code between host and remote applications. Both host and remotes must use Webpack as the bundler.
|
|
192
|
+
|
|
193
|
+
Register the loader in your application bootstrap:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { registerModuleFederatedWidgetLoader } from '@siemens/dashboards-ng/module-federation';
|
|
197
|
+
|
|
198
|
+
registerModuleFederatedWidgetLoader();
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
+-------------------------+ +----------------------------------+
|
|
203
|
+
| Host App | | @angular-architects/ |
|
|
204
|
+
| Module Federation |------>| module-federation |
|
|
205
|
+
| (webpack) | | |
|
|
206
|
+
+------------+------------+ +---------------^------------------+
|
|
207
|
+
| |
|
|
208
|
+
registerModuleFederatedWidgetLoader |
|
|
209
|
+
| |
|
|
210
|
+
+------------v------------+ +---------------+------------------+
|
|
211
|
+
| @siemens/dashboards-ng/ | | Remote Widget |
|
|
212
|
+
| module-federation | | Module Federation |
|
|
213
|
+
+-------------------------+ | (webpack) |
|
|
214
|
+
+----------------------------------+
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### Pure Native Federation (ESM-based)
|
|
218
|
+
|
|
219
|
+
Uses `@angular-architects/native-federation` with ES Module-based federation, independent of the bundler. Works with any build tool (esbuild, Vite, Webpack). Recommended for modern Angular applications.
|
|
220
|
+
|
|
221
|
+
Register the loader in your application bootstrap:
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
import { registerNativeFederatedWidgetLoader } from '@siemens/dashboards-ng/native-federation';
|
|
225
|
+
|
|
226
|
+
registerNativeFederatedWidgetLoader();
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
+-------------------------+ +----------------------------------+
|
|
231
|
+
| Host App | | @angular-architects/ |
|
|
232
|
+
| Native Federation |------>| native-federation |
|
|
233
|
+
| (esbuild/Vite/webpack) | | |
|
|
234
|
+
+------------+------------+ +---------------^------------------+
|
|
235
|
+
| |
|
|
236
|
+
registerNativeFederatedWidgetLoader |
|
|
237
|
+
| |
|
|
238
|
+
+------------v------------+ +---------------+------------------+
|
|
239
|
+
| @siemens/dashboards-ng/ | | Remote Widget |
|
|
240
|
+
| native-federation | | Native Federation |
|
|
241
|
+
+-------------------------+ | (esbuild) |
|
|
242
|
+
+----------------------------------+
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
#### Hybrid/Bridge (Native Federation + Module Federation)
|
|
246
|
+
|
|
247
|
+
Enables a Native Federation shell to load Module Federation remotes using `@module-federation/runtime`. Useful for gradual migration or when integrating existing Webpack-based remotes into a modern ESM-based host.
|
|
248
|
+
|
|
249
|
+
Register the loader with your Module Federation instance:
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
import { registerModuleFederatedWidgetLoader } from '@siemens/dashboards-ng/native-federation/mf-bridge';
|
|
253
|
+
|
|
254
|
+
registerModuleFederatedWidgetLoader(mfInstance);
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
```
|
|
258
|
+
+-------------------------+ +----------------------------------+
|
|
259
|
+
| Host App | | @angular-architects/ |
|
|
260
|
+
| Native Federation |------>| native-federation |
|
|
261
|
+
| (esbuild) | | |
|
|
262
|
+
+------------+------------+ +----------------------------------+
|
|
263
|
+
|
|
|
264
|
+
| registerModuleFederatedWidgetLoader(mfInstance)
|
|
265
|
+
|
|
|
266
|
+
+------------v-----------------------+
|
|
267
|
+
| @siemens/dashboards-ng/ |
|
|
268
|
+
| native-federation/mf-bridge |
|
|
269
|
+
+------------+-----------------------+
|
|
270
|
+
|
|
|
271
|
+
| loads
|
|
272
|
+
|
|
|
273
|
+
+------------v------------+ +----------------------------------+
|
|
274
|
+
| @module-federation/ | | Remote Widget |
|
|
275
|
+
| runtime |------>| Module Federation |
|
|
276
|
+
+-------------------------+ | (webpack) |
|
|
277
|
+
+----------------------------------+
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
For more details, refer to [Combining Native Federation and Module Federation](https://www.angulararchitects.io/blog/combining-native-federation-and-module-federation/).
|
|
281
|
+
|
|
282
|
+
#### Running the Demo Application
|
|
283
|
+
|
|
284
|
+
The [dashboard demo project](https://github.com/siemens/element/blob/main/projects/dashboards-demo/) includes examples of all microfrontend modes. Use these npm scripts to run locally:
|
|
285
|
+
|
|
286
|
+
```sh
|
|
287
|
+
# Module Federation mode (Webpack-based host and remotes)
|
|
288
|
+
npm run dashboards-demo:run-all:local
|
|
289
|
+
|
|
290
|
+
# Native Federation mode with Hybrid/Bridge support (ESM-based host with both Native and Module Federation remotes)
|
|
291
|
+
npm run dashboards-demo:run-all:esm:local
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Widget instance ID generation
|
|
295
|
+
|
|
296
|
+
Each widget instance on a dashboard requires a unique ID for identification and persistence. The library
|
|
297
|
+
provides a flexible system for generating these IDs through the `SiWidgetIdProvider` abstract class.
|
|
298
|
+
|
|
299
|
+
#### Default ID generation
|
|
300
|
+
|
|
301
|
+
By default, the library uses `SiWidgetDefaultIdProvider`, which generates unique IDs using
|
|
302
|
+
a RFC4122 version 4 UUID (e.g.,`'550e8400-e29b-41d4-a716-446655440000'`). This default implementation
|
|
303
|
+
uses `crypto.randomUUID()` to ensure cryptographically secure uniqueness with 122 bits of entropy.
|
|
304
|
+
|
|
305
|
+
#### Custom ID generation
|
|
306
|
+
|
|
307
|
+
To implement custom ID generation logic (e.g., UUID-based, sequential or
|
|
308
|
+
context-aware IDs), create a class that extends `SiWidgetIdProvider` and implement the
|
|
309
|
+
`generateWidgetId` method:
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
import { Injectable } from '@angular/core';
|
|
313
|
+
import { SiWidgetIdProvider } from '@siemens/dashboards-ng';
|
|
314
|
+
|
|
315
|
+
@Injectable()
|
|
316
|
+
export class CustomWidgetIdProvider extends SiWidgetIdProvider {
|
|
317
|
+
override generateWidgetId(widget: WidgetConfig, dashboardId?: string): string {
|
|
318
|
+
// Example: Create a composite ID from dashboard and widget type
|
|
319
|
+
const prefix = dashboardId ?? 'default';
|
|
320
|
+
const timestamp = Date.now();
|
|
321
|
+
return `${prefix}-${widget.widgetId}-${timestamp}`;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
#### Providing a custom ID provider
|
|
327
|
+
|
|
328
|
+
To use your custom ID provider, register it in your application's providers:
|
|
329
|
+
|
|
330
|
+
```ts
|
|
331
|
+
// For standalone applications
|
|
332
|
+
providers: [{ provide: SI_WIDGET_ID_PROVIDER, useClass: CustomWidgetIdProvider }];
|
|
333
|
+
|
|
334
|
+
// For module-based applications
|
|
335
|
+
@NgModule({
|
|
336
|
+
providers: [{ provide: SI_WIDGET_ID_PROVIDER, useClass: CustomWidgetIdProvider }]
|
|
337
|
+
})
|
|
338
|
+
export class AppModule {}
|
|
339
|
+
```
|
|
340
|
+
|
|
187
341
|
### Dashboard persistence
|
|
188
342
|
|
|
189
343
|
The library persists a dashboard configuration by the default `SiDefaultWidgetStorage` implementation
|
|
@@ -197,16 +351,10 @@ providers: [..., { provide: DEFAULT_WIDGET_STORAGE_TOKEN, useValue: localStorage
|
|
|
197
351
|
|
|
198
352
|
For persistence in a backend service, you should implement your own
|
|
199
353
|
[SiWidgetStorage](https://github.com/siemens/element/blob/main/projects/dashboards-ng/src/model/si-widget-storage.ts) and provide it in
|
|
200
|
-
|
|
354
|
+
your module providers or application config.
|
|
201
355
|
|
|
202
356
|
```ts
|
|
203
|
-
|
|
204
|
-
config: {},
|
|
205
|
-
dashboardApi: {
|
|
206
|
-
provide: SiWidgetStorage,
|
|
207
|
-
useClass: CustomWidgetStorage
|
|
208
|
-
}
|
|
209
|
-
});
|
|
357
|
+
providers: [{ provide: SI_WIDGET_STORE, useClass: CustomWidgetStorage }];
|
|
210
358
|
```
|
|
211
359
|
|
|
212
360
|
### Configuration
|
|
@@ -215,8 +363,8 @@ The dashboard is configurable through the Angular inputs of the exposed componen
|
|
|
215
363
|
the usage of the configuration object `Config`, which includes a `GridConfig` and including
|
|
216
364
|
the [GridStackOptions](https://github.com/siemens/element/blob/main/projects/dashboards-ng/src/model/gridstack.model.ts).
|
|
217
365
|
|
|
218
|
-
To configure all dashboard instances, you can leverage dependency injection
|
|
219
|
-
the `
|
|
366
|
+
To configure all dashboard instances, you can leverage dependency injection by providing
|
|
367
|
+
the `SI_DASHBOARD_CONFIGURATION` token in your providers.
|
|
220
368
|
Alternatively, you have the option to configure individual dashboard instances by setting
|
|
221
369
|
the input property `SiFlexibleDashboardComponent.config = {...}`.
|
|
222
370
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"siemens-dashboards-ng-module-federation.mjs","sources":["../../../../projects/dashboards-ng/module-federation/index.ts","../../../../projects/dashboards-ng/module-federation/siemens-dashboards-ng-module-federation.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { loadRemoteModule } from '@angular-architects/module-federation';\nimport { ComponentRef, EnvironmentInjector, Injector, ViewContainerRef, Type } from '@angular/core';\nimport { FederatedModule, SetupComponentFn, widgetFactoryRegistry } from '@siemens/dashboards-ng';\nimport { Observable, Subject } from 'rxjs';\n\nconst setupRemoteComponent = <T>(\n factory: FederatedModule,\n componentName: string,\n host: ViewContainerRef,\n injector: Injector,\n environmentInjector: EnvironmentInjector\n): Observable<ComponentRef<T>> => {\n const result = new Subject<ComponentRef<T>>();\n\n loadRemoteModule<Type<T>[]>(factory).then(\n module => {\n const componentType = module[factory[componentName]];\n const widgetInstanceRef = host.createComponent<T>(componentType, {\n injector,\n environmentInjector\n });\n result.next(widgetInstanceRef);\n result.complete();\n },\n rejection => {\n const msg = rejection\n ? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(\n rejection.toString()\n )}`\n : `Loading widget module ${factory.exposedModule} failed`;\n result.error(msg);\n result.complete();\n }\n );\n return result;\n};\n\nexport const registerModuleFederatedWidgetLoader = (): void => {\n widgetFactoryRegistry.register('module-federation', setupRemoteComponent as SetupComponentFn);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAMH,MAAM,oBAAoB,GAAG,CAC3B,OAAwB,EACxB,aAAqB,EACrB,IAAsB,EACtB,QAAkB,EAClB,mBAAwC,KACT;AAC/B,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAmB;IAE7C,gBAAgB,CAAY,OAAO,CAAC,CAAC,IAAI,CACvC,MAAM,IAAG;QACP,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACpD,QAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAI,aAAa,EAAE;YAC/D,QAAQ;YACR;AACD,SAAA,CAAC;AACF,QAAA,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAC9B,MAAM,CAAC,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"siemens-dashboards-ng-module-federation.mjs","sources":["../../../../projects/dashboards-ng/module-federation/index.ts","../../../../projects/dashboards-ng/module-federation/siemens-dashboards-ng-module-federation.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { loadRemoteModule } from '@angular-architects/module-federation';\nimport { ComponentRef, EnvironmentInjector, Injector, ViewContainerRef, Type } from '@angular/core';\nimport { FederatedModule, SetupComponentFn, widgetFactoryRegistry } from '@siemens/dashboards-ng';\nimport { Observable, Subject } from 'rxjs';\n\nconst setupRemoteComponent = <T>(\n factory: FederatedModule,\n componentName: string,\n host: ViewContainerRef,\n injector: Injector,\n environmentInjector: EnvironmentInjector\n): Observable<ComponentRef<T>> => {\n const result = new Subject<ComponentRef<T>>();\n\n loadRemoteModule<Type<T>[]>(factory).then(\n module => {\n const componentType = module[factory[componentName]];\n const widgetInstanceRef = host.createComponent<T>(componentType, {\n injector,\n environmentInjector\n });\n result.next(widgetInstanceRef);\n result.complete();\n },\n rejection => {\n const msg = rejection\n ? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(\n rejection.toString()\n )}`\n : `Loading widget module ${factory.exposedModule} failed`;\n result.error(msg);\n result.complete();\n }\n );\n return result;\n};\n\nexport const registerModuleFederatedWidgetLoader = (): void => {\n widgetFactoryRegistry.register('module-federation', setupRemoteComponent as SetupComponentFn);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAMH,MAAM,oBAAoB,GAAG,CAC3B,OAAwB,EACxB,aAAqB,EACrB,IAAsB,EACtB,QAAkB,EAClB,mBAAwC,KACT;AAC/B,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAmB;IAE7C,gBAAgB,CAAY,OAAO,CAAC,CAAC,IAAI,CACvC,MAAM,IAAG;QACP,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACpD,QAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAI,aAAa,EAAE;YAC/D,QAAQ;YACR;AACD,SAAA,CAAC;AACF,QAAA,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAC9B,MAAM,CAAC,QAAQ,EAAE;IACnB,CAAC,EACD,SAAS,IAAG;QACV,MAAM,GAAG,GAAG;AACV,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,CAAA,aAAA,EAAgB,IAAI,CAAC,SAAS,CAC1E,SAAS,CAAC,QAAQ,EAAE,CACrB,CAAA;AACH,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,SAAS;AAC3D,QAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACjB,MAAM,CAAC,QAAQ,EAAE;AACnB,IAAA,CAAC,CACF;AACD,IAAA,OAAO,MAAM;AACf,CAAC;AAEM,MAAM,mCAAmC,GAAG,MAAW;AAC5D,IAAA,qBAAqB,CAAC,QAAQ,CAAC,mBAAmB,EAAE,oBAAwC,CAAC;AAC/F;;AC3CA;;AAEG;;;;"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { widgetFactoryRegistry } from '@siemens/dashboards-ng';
|
|
2
|
+
import { Subject } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
function setupRemoteComponent(factory, componentName, host, injector, environmentInjector) {
|
|
5
|
+
const result = new Subject();
|
|
6
|
+
this.loadRemote(factory.id, factory.options).then(module => {
|
|
7
|
+
if (module) {
|
|
8
|
+
const componentType = module[factory[componentName]];
|
|
9
|
+
const widgetInstanceRef = host.createComponent(componentType, {
|
|
10
|
+
injector,
|
|
11
|
+
environmentInjector
|
|
12
|
+
});
|
|
13
|
+
result.next(widgetInstanceRef);
|
|
14
|
+
}
|
|
15
|
+
result.complete();
|
|
16
|
+
}, rejection => {
|
|
17
|
+
const msg = rejection
|
|
18
|
+
? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(rejection.toString())}`
|
|
19
|
+
: `Loading widget module ${factory.exposedModule} failed`;
|
|
20
|
+
result.error(msg);
|
|
21
|
+
result.complete();
|
|
22
|
+
});
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Use this when having native federation shell and remote module is using module federation.
|
|
27
|
+
* @param mfInstance - The ModuleFederation instance returned by `createInstance` from '\@module-federation/runtime'
|
|
28
|
+
*/
|
|
29
|
+
const registerModuleFederatedWidgetLoader = (mfInstance) => {
|
|
30
|
+
widgetFactoryRegistry.register('native-federation-module-bridge', setupRemoteComponent.bind(mfInstance));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Generated bundle index. Do not edit.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
export { registerModuleFederatedWidgetLoader };
|
|
38
|
+
//# sourceMappingURL=siemens-dashboards-ng-native-federation-mf-bridge.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siemens-dashboards-ng-native-federation-mf-bridge.mjs","sources":["../../../../projects/dashboards-ng/native-federation/mf-bridge/index.ts","../../../../projects/dashboards-ng/native-federation/mf-bridge/siemens-dashboards-ng-native-federation-mf-bridge.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { ComponentRef, EnvironmentInjector, Injector, ViewContainerRef, Type } from '@angular/core';\nimport { ModuleFederation } from '@module-federation/runtime';\nimport {\n FederatedBridgeModule,\n SetupComponentFn,\n widgetFactoryRegistry\n} from '@siemens/dashboards-ng';\nimport { Observable, Subject } from 'rxjs';\n\nfunction setupRemoteComponent<T>(\n this: ModuleFederation,\n factory: FederatedBridgeModule,\n componentName: string,\n host: ViewContainerRef,\n injector: Injector,\n environmentInjector: EnvironmentInjector\n): Observable<ComponentRef<T>> {\n const result = new Subject<ComponentRef<T>>();\n this.loadRemote<Type<T>[]>(factory.id, factory.options).then(\n module => {\n if (module) {\n const componentType = module[factory[componentName]];\n const widgetInstanceRef = host.createComponent<T>(componentType, {\n injector,\n environmentInjector\n });\n result.next(widgetInstanceRef);\n }\n result.complete();\n },\n rejection => {\n const msg = rejection\n ? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(\n rejection.toString()\n )}`\n : `Loading widget module ${factory.exposedModule} failed`;\n result.error(msg);\n result.complete();\n }\n );\n return result;\n}\n\n/**\n * Use this when having native federation shell and remote module is using module federation.\n * @param mfInstance - The ModuleFederation instance returned by `createInstance` from '\\@module-federation/runtime'\n */\nexport const registerModuleFederatedWidgetLoader = (mfInstance: ModuleFederation): void => {\n widgetFactoryRegistry.register(\n 'native-federation-module-bridge',\n setupRemoteComponent.bind(mfInstance) as SetupComponentFn\n );\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAaA,SAAS,oBAAoB,CAE3B,OAA8B,EAC9B,aAAqB,EACrB,IAAsB,EACtB,QAAkB,EAClB,mBAAwC,EAAA;AAExC,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAmB;AAC7C,IAAA,IAAI,CAAC,UAAU,CAAY,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAC1D,MAAM,IAAG;QACP,IAAI,MAAM,EAAE;YACV,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACpD,YAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAI,aAAa,EAAE;gBAC/D,QAAQ;gBACR;AACD,aAAA,CAAC;AACF,YAAA,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAChC;QACA,MAAM,CAAC,QAAQ,EAAE;IACnB,CAAC,EACD,SAAS,IAAG;QACV,MAAM,GAAG,GAAG;AACV,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,CAAA,aAAA,EAAgB,IAAI,CAAC,SAAS,CAC1E,SAAS,CAAC,QAAQ,EAAE,CACrB,CAAA;AACH,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,SAAS;AAC3D,QAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACjB,MAAM,CAAC,QAAQ,EAAE;AACnB,IAAA,CAAC,CACF;AACD,IAAA,OAAO,MAAM;AACf;AAEA;;;AAGG;AACI,MAAM,mCAAmC,GAAG,CAAC,UAA4B,KAAU;AACxF,IAAA,qBAAqB,CAAC,QAAQ,CAC5B,iCAAiC,EACjC,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAqB,CAC1D;AACH;;ACxDA;;AAEG;;;;"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { loadRemoteModule } from '@angular-architects/native-federation';
|
|
2
|
+
import { widgetFactoryRegistry } from '@siemens/dashboards-ng';
|
|
3
|
+
import { Subject } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Copyright (c) Siemens 2016 - 2025
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
*/
|
|
9
|
+
const setupRemoteComponent = (factory, componentName, host, injector, environmentInjector) => {
|
|
10
|
+
const result = new Subject();
|
|
11
|
+
loadRemoteModule(factory).then(module => {
|
|
12
|
+
if (module) {
|
|
13
|
+
const componentType = module[factory[componentName]];
|
|
14
|
+
const widgetInstanceRef = host.createComponent(componentType, {
|
|
15
|
+
injector,
|
|
16
|
+
environmentInjector
|
|
17
|
+
});
|
|
18
|
+
result.next(widgetInstanceRef);
|
|
19
|
+
}
|
|
20
|
+
result.complete();
|
|
21
|
+
}, rejection => {
|
|
22
|
+
const msg = rejection
|
|
23
|
+
? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(rejection.toString())}`
|
|
24
|
+
: `Loading widget module ${factory.exposedModule} failed`;
|
|
25
|
+
result.error(msg);
|
|
26
|
+
result.complete();
|
|
27
|
+
});
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
const registerNativeFederatedWidgetLoader = () => {
|
|
31
|
+
widgetFactoryRegistry.register('native-federation', setupRemoteComponent);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Generated bundle index. Do not edit.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
export { registerNativeFederatedWidgetLoader };
|
|
39
|
+
//# sourceMappingURL=siemens-dashboards-ng-native-federation.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"siemens-dashboards-ng-native-federation.mjs","sources":["../../../../projects/dashboards-ng/native-federation/index.ts","../../../../projects/dashboards-ng/native-federation/siemens-dashboards-ng-native-federation.ts"],"sourcesContent":["/**\n * Copyright (c) Siemens 2016 - 2025\n * SPDX-License-Identifier: MIT\n */\nimport { loadRemoteModule } from '@angular-architects/native-federation';\nimport { ComponentRef, EnvironmentInjector, Injector, ViewContainerRef, Type } from '@angular/core';\nimport { FederatedModule, SetupComponentFn, widgetFactoryRegistry } from '@siemens/dashboards-ng';\nimport { Observable, Subject } from 'rxjs';\n\nconst setupRemoteComponent = <T>(\n factory: FederatedModule,\n componentName: string,\n host: ViewContainerRef,\n injector: Injector,\n environmentInjector: EnvironmentInjector\n): Observable<ComponentRef<T>> => {\n const result = new Subject<ComponentRef<T>>();\n\n loadRemoteModule<Type<T>[]>(factory).then(\n module => {\n if (module) {\n const componentType = module[factory[componentName]];\n const widgetInstanceRef = host.createComponent<T>(componentType, {\n injector,\n environmentInjector\n });\n result.next(widgetInstanceRef);\n }\n result.complete();\n },\n rejection => {\n const msg = rejection\n ? `Loading widget module ${factory.exposedModule} failed with ${JSON.stringify(\n rejection.toString()\n )}`\n : `Loading widget module ${factory.exposedModule} failed`;\n result.error(msg);\n result.complete();\n }\n );\n return result;\n};\n\nexport const registerNativeFederatedWidgetLoader = (): void => {\n widgetFactoryRegistry.register('native-federation', setupRemoteComponent as SetupComponentFn);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAAA;;;AAGG;AAMH,MAAM,oBAAoB,GAAG,CAC3B,OAAwB,EACxB,aAAqB,EACrB,IAAsB,EACtB,QAAkB,EAClB,mBAAwC,KACT;AAC/B,IAAA,MAAM,MAAM,GAAG,IAAI,OAAO,EAAmB;IAE7C,gBAAgB,CAAY,OAAO,CAAC,CAAC,IAAI,CACvC,MAAM,IAAG;QACP,IAAI,MAAM,EAAE;YACV,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACpD,YAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,eAAe,CAAI,aAAa,EAAE;gBAC/D,QAAQ;gBACR;AACD,aAAA,CAAC;AACF,YAAA,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;QAChC;QACA,MAAM,CAAC,QAAQ,EAAE;IACnB,CAAC,EACD,SAAS,IAAG;QACV,MAAM,GAAG,GAAG;AACV,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,CAAA,aAAA,EAAgB,IAAI,CAAC,SAAS,CAC1E,SAAS,CAAC,QAAQ,EAAE,CACrB,CAAA;AACH,cAAE,CAAA,sBAAA,EAAyB,OAAO,CAAC,aAAa,SAAS;AAC3D,QAAA,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC;QACjB,MAAM,CAAC,QAAQ,EAAE;AACnB,IAAA,CAAC,CACF;AACD,IAAA,OAAO,MAAM;AACf,CAAC;AAEM,MAAM,mCAAmC,GAAG,MAAW;AAC5D,IAAA,qBAAqB,CAAC,QAAQ,CAAC,mBAAmB,EAAE,oBAAwC,CAAC;AAC/F;;AC7CA;;AAEG;;;;"}
|