@yaagoub/federation-tools 1.0.7 → 1.0.8

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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
+ "dest": "../../dist/federation-tools",
4
+ "lib": {
5
+ "entryFile": "src/index.ts"
6
+ }
7
+ }
package/package.json CHANGED
@@ -1,23 +1,12 @@
1
- {
2
- "name": "@yaagoub/federation-tools",
3
- "version": "1.0.7",
4
- "peerDependencies": {
5
- "@angular/common": ">=15.0.0",
6
- "@angular/core": ">=15.0.0"
7
- },
8
- "dependencies": {
9
- "tslib": "^2.3.0"
10
- },
11
- "sideEffects": false,
12
- "module": "fesm2022/yaagoub-federation-tools.mjs",
13
- "typings": "index.d.ts",
14
- "exports": {
15
- "./package.json": {
16
- "default": "./package.json"
17
- },
18
- ".": {
19
- "types": "./index.d.ts",
20
- "default": "./fesm2022/yaagoub-federation-tools.mjs"
21
- }
22
- }
23
- }
1
+ {
2
+ "name": "@yaagoub/federation-tools",
3
+ "version": "1.0.8",
4
+ "peerDependencies": {
5
+ "@angular/common": ">=15.0.0",
6
+ "@angular/core": ">=15.0.0"
7
+ },
8
+ "dependencies": {
9
+ "tslib": "^2.3.0"
10
+ },
11
+ "sideEffects": false
12
+ }
@@ -0,0 +1,53 @@
1
+ import {
2
+ Directive,
3
+ ElementRef,
4
+ OnChanges,
5
+ inject,
6
+ SimpleChanges,
7
+ input,
8
+ } from '@angular/core';
9
+ import { AssetService } from './asset.service';
10
+
11
+ @Directive({
12
+ selector: '[asset]',
13
+ standalone: true,
14
+ })
15
+ export class AssetDirective implements OnChanges {
16
+ private readonly el = inject(ElementRef<HTMLElement>);
17
+ private readonly assetService = inject(AssetService);
18
+
19
+ asset = input<string>('');
20
+
21
+ ngOnChanges(changes: SimpleChanges): void {
22
+ if (!this.asset()) return;
23
+
24
+ const url = this.assetService.resolve(this.asset());
25
+ const nativeEl = this.el.nativeElement;
26
+
27
+ const attr = this.detectAttribute(nativeEl);
28
+
29
+ nativeEl.setAttribute(attr, url);
30
+ }
31
+
32
+ private detectAttribute(el: HTMLElement): string {
33
+ const tag = el.tagName.toLowerCase();
34
+
35
+ switch (tag) {
36
+ case 'img':
37
+ case 'video':
38
+ case 'audio':
39
+ case 'iframe':
40
+ case 'source':
41
+ return 'src';
42
+
43
+ case 'a':
44
+ return 'href';
45
+
46
+ case 'object':
47
+ return 'data';
48
+
49
+ default:
50
+ return 'src';
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,64 @@
1
+ import { InjectionToken } from "@angular/core";
2
+ import { inject, Injectable } from '@angular/core';
3
+ import { HttpClient } from '@angular/common/http';
4
+ import { firstValueFrom } from 'rxjs';
5
+
6
+ import { Federation } from '../federation/federation.service';
7
+
8
+ export type AssetRegistry = Map<string, string>;
9
+
10
+ export const APP_CONFIG_ASSETS = new InjectionToken<AssetRegistry>('asset-registry');
11
+
12
+
13
+ @Injectable({ providedIn: 'root' })
14
+ export class AssetService {
15
+
16
+ private readonly http = inject(HttpClient);
17
+ private readonly federation = inject(Federation);
18
+ private readonly assets = inject(APP_CONFIG_ASSETS);
19
+
20
+ private getAssetManifest() {
21
+ return this.http.get<Record<string, string>>(
22
+ this.federation.getShellOrigin() + '/assets.manifest.json'
23
+ );
24
+ }
25
+
26
+ async load(): Promise<void> {
27
+ try {
28
+ const manifest = await firstValueFrom(this.getAssetManifest());
29
+
30
+ // Remotes
31
+ Object.entries(manifest).forEach(([remote, origin]) => {
32
+ this.assets.set(remote, origin);
33
+ });
34
+
35
+ } catch (error) {
36
+ throw new Error(
37
+ 'Failed to load asset configuration, cannot continue. ' + error
38
+ );
39
+ }
40
+ }
41
+
42
+ resolve(assetRef: string): string {
43
+ /**
44
+ * assetRef format:
45
+ * shell:logo.svg
46
+ * user:img/avatar.png
47
+ * doc:video/intro.mp4
48
+ */
49
+
50
+ if (!assetRef.includes(':')) {
51
+ throw new Error(`Invalid asset reference: ${assetRef}`);
52
+ }
53
+
54
+ const [scope, path] = assetRef.split(':');
55
+ const origin = this.assets.get(scope);
56
+
57
+ if (!origin) {
58
+ throw new Error(`Unknown asset scope: ${scope}`);
59
+ }
60
+
61
+ return `${origin}/${path}`;
62
+ }
63
+
64
+ }
@@ -0,0 +1,12 @@
1
+ import { inject, Injectable } from '@angular/core';
2
+ import { AssetService } from "./asset.service";
3
+
4
+
5
+ @Injectable({ providedIn: 'root' })
6
+ export class Assets {
7
+ private readonly assetService = inject(AssetService);
8
+
9
+ get(assetRef: string): string {
10
+ return this.assetService.resolve(assetRef);
11
+ }
12
+ }
@@ -0,0 +1,54 @@
1
+ import { inject, Injectable } from '@angular/core';
2
+ import { HttpClient } from '@angular/common/http';
3
+ import { firstValueFrom } from 'rxjs';
4
+ import { InjectionToken } from '@angular/core';
5
+ import { Federation } from '../federation/federation.service';
6
+
7
+ export type EnvMap = Map<string, Record<string, any>>;
8
+
9
+ /**
10
+ * Holds all loaded env objects:
11
+ * - key: remoteName (from env-manifest.json) + 'shell'
12
+ * - value: parsed env.json for that remote
13
+ */
14
+ export const APP_CONFIG_ENV = new InjectionToken<EnvMap>('env-settings');
15
+
16
+ @Injectable({ providedIn: 'root' })
17
+ export class EnvService {
18
+ private readonly http = inject(HttpClient);
19
+ private readonly federation = inject(Federation);
20
+ private readonly envMap: EnvMap = inject(APP_CONFIG_ENV);
21
+
22
+ private getManifestUrl(): string {
23
+ return this.federation.getShellOrigin() + '/env.manifest.json';
24
+ }
25
+
26
+ private getRemoteEnvUrl(origin: string): string {
27
+ return origin.replace(/\/+$/, '') + '/env.json';
28
+ }
29
+
30
+ async load(): Promise<void> {
31
+ try {
32
+ const envManifest = await firstValueFrom(
33
+ this.http.get<Record<string, string>>(this.getManifestUrl())
34
+ );
35
+
36
+ const remoteNames = Object.keys(envManifest);
37
+
38
+ const remoteLoads = remoteNames.map(async (remoteName) => {
39
+ const remoteOrigin = envManifest[remoteName];
40
+ const env = await firstValueFrom(
41
+ this.http.get<Record<string, any>>(this.getRemoteEnvUrl(remoteOrigin))
42
+ );
43
+ this.envMap.set(remoteName, env);
44
+ });
45
+
46
+ await Promise.all(remoteLoads);
47
+
48
+ } catch (e: any) {
49
+ throw new Error(
50
+ `Failed to load environment configuration; cannot continue. ${e?.message ?? e}`
51
+ );
52
+ }
53
+ }
54
+ }
package/src/env/env.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { inject, Injectable } from "@angular/core";
2
+ import { APP_CONFIG_ENV, EnvMap } from "./env.service";
3
+
4
+ @Injectable({
5
+ providedIn: 'root'
6
+ })
7
+ export class Env {
8
+ private readonly envMap: EnvMap = inject(APP_CONFIG_ENV);
9
+
10
+ get(remoteName: string): Record<string, any> {
11
+ const v = this.envMap.get(remoteName);
12
+ if (!v) {
13
+ throw new Error(
14
+ `Env for "${remoteName}" not loaded. Did you register provideAppInitializer(() => env.load()) ?`
15
+ );
16
+ }
17
+ return v;
18
+ }
19
+ }
@@ -0,0 +1,10 @@
1
+ import { Injectable } from "@angular/core";
2
+
3
+ @Injectable({
4
+ providedIn: 'root'
5
+ })
6
+ export class Federation {
7
+ getShellOrigin(): string {
8
+ return window.location.origin;
9
+ }
10
+ }
@@ -0,0 +1,14 @@
1
+ import { TranslateLoader } from '@ngx-translate/core';
2
+ import { Observable, from } from 'rxjs';
3
+ import { map } from 'rxjs/operators';
4
+ import { TranslationRegistry } from './translation-registry.service';
5
+
6
+ export class FederatedTranslateLoader implements TranslateLoader {
7
+ constructor(private readonly registry: TranslationRegistry) {}
8
+
9
+ getTranslation(lang: string): Observable<any> {
10
+ return from(this.registry.load(lang)).pipe(
11
+ map(() => this.registry.getMergedTranslations())
12
+ );
13
+ }
14
+ }
@@ -0,0 +1,39 @@
1
+ import { Injectable, InjectionToken, inject } from '@angular/core';
2
+ import { HttpClient } from '@angular/common/http';
3
+ import { firstValueFrom } from 'rxjs';
4
+
5
+ import { Federation } from '../federation/federation.service';
6
+
7
+ export const APP_TRANSLATIONS_STORE =
8
+ new InjectionToken<Map<string, any>>('APP_TRANSLATIONS_STORE');
9
+
10
+ @Injectable({ providedIn: 'root' })
11
+ export class TranslationRegistry {
12
+ private readonly http = inject(HttpClient);
13
+ private readonly federation = inject(Federation);
14
+ private readonly store = inject(APP_TRANSLATIONS_STORE);
15
+
16
+ async load(lang: string): Promise<void> {
17
+
18
+ const manifest = await firstValueFrom(
19
+ this.http.get<Record<string, string>>(
20
+ this.federation.getShellOrigin() + '/i18n-manifest.json'
21
+ )
22
+ );
23
+
24
+ await Promise.all(
25
+ Object.entries(manifest).map(async ([name, origin]) => {
26
+ const translations = await firstValueFrom(
27
+ this.http.get(`${origin}/i18n/${lang}.json`)
28
+ );
29
+ this.store.set(name, translations);
30
+ }),
31
+ );
32
+ }
33
+
34
+ getMergedTranslations(): any {
35
+ const result: any = {};
36
+ this.store.forEach(value => Object.assign(result, value));
37
+ return result;
38
+ }
39
+ }
package/src/index.ts ADDED
@@ -0,0 +1,10 @@
1
+ export * from './env/env';
2
+ export * from './providers/provide-env';
3
+
4
+ export * from './asset/asset';
5
+ export * from './asset/asset.directive';
6
+ export * from './providers/provide-assets';
7
+
8
+ export * from './providers/provide-trans';
9
+ export * from './i18n/federated-translate.loader';
10
+ export * from './i18n/translation-registry.service';
@@ -0,0 +1,14 @@
1
+ import { inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';
2
+ import { APP_CONFIG_ASSETS, AssetService } from '../asset/asset.service';
3
+ import { Assets } from '../asset/asset';
4
+
5
+ export function provideFederationAsset() {
6
+ return makeEnvironmentProviders([
7
+ AssetService, Assets,
8
+ {
9
+ provide: APP_CONFIG_ASSETS,
10
+ useValue: new Map<string, string>(),
11
+ },
12
+ provideAppInitializer(() => inject(AssetService).load()),
13
+ ]);
14
+ }
@@ -0,0 +1,12 @@
1
+ import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';
2
+ import { APP_CONFIG_ENV, EnvService, EnvMap } from '../env/env.service';
3
+ import { Federation } from '../federation/federation.service';
4
+ import { Env } from '../env/env';
5
+
6
+ export function provideFederationEnv(): EnvironmentProviders {
7
+ return makeEnvironmentProviders([
8
+ EnvService, Federation, Env,
9
+ { provide: APP_CONFIG_ENV, useValue: new Map() as EnvMap },
10
+ provideAppInitializer(() => inject(EnvService).load()),
11
+ ]);
12
+ }
@@ -0,0 +1,13 @@
1
+ import { makeEnvironmentProviders } from '@angular/core';
2
+ import { APP_TRANSLATIONS_STORE, TranslationRegistry } from '../i18n/translation-registry.service';
3
+
4
+
5
+ export function provideFederationTranslation() {
6
+ return makeEnvironmentProviders([
7
+ {
8
+ provide: APP_TRANSLATIONS_STORE,
9
+ useFactory: () => new Map<string, any>(),
10
+ },
11
+ TranslationRegistry,
12
+ ]);
13
+ }
@@ -0,0 +1,18 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/lib",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "inlineSources": true,
10
+ "types": []
11
+ },
12
+ "include": [
13
+ "src/**/*.ts"
14
+ ],
15
+ "exclude": [
16
+ "**/*.spec.ts"
17
+ ]
18
+ }
@@ -0,0 +1,11 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "./tsconfig.lib.json",
5
+ "compilerOptions": {
6
+ "declarationMap": false
7
+ },
8
+ "angularCompilerOptions": {
9
+ "compilationMode": "partial"
10
+ }
11
+ }
@@ -0,0 +1,15 @@
1
+ /* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
2
+ /* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
3
+ {
4
+ "extends": "../../tsconfig.json",
5
+ "compilerOptions": {
6
+ "outDir": "../../out-tsc/spec",
7
+ "types": [
8
+ "jasmine"
9
+ ]
10
+ },
11
+ "include": [
12
+ "src/**/*.d.ts",
13
+ "src/**/*.spec.ts"
14
+ ]
15
+ }
@@ -1,252 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { Injectable, InjectionToken, inject, makeEnvironmentProviders, provideAppInitializer, ElementRef, input, Directive } from '@angular/core';
3
- import { HttpClient } from '@angular/common/http';
4
- import { firstValueFrom, from } from 'rxjs';
5
- import { TranslateLoader } from '@ngx-translate/core';
6
- import { map } from 'rxjs/operators';
7
-
8
- class Federation {
9
- getShellOrigin() {
10
- return window.location.origin;
11
- }
12
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Federation, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
13
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Federation, providedIn: 'root' });
14
- }
15
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Federation, decorators: [{
16
- type: Injectable,
17
- args: [{
18
- providedIn: 'root'
19
- }]
20
- }] });
21
-
22
- /**
23
- * Holds all loaded env objects:
24
- * - key: remoteName (from env-manifest.json) + 'shell'
25
- * - value: parsed env.json for that remote
26
- */
27
- const APP_CONFIG_ENV = new InjectionToken('env-settings');
28
- class EnvService {
29
- http = inject(HttpClient);
30
- federation = inject(Federation);
31
- envMap = inject(APP_CONFIG_ENV);
32
- getManifestUrl() {
33
- return this.federation.getShellOrigin() + '/env.manifest.json';
34
- }
35
- getRemoteEnvUrl(origin) {
36
- return origin.replace(/\/+$/, '') + '/env.json';
37
- }
38
- async load() {
39
- try {
40
- const envManifest = await firstValueFrom(this.http.get(this.getManifestUrl()));
41
- const remoteNames = Object.keys(envManifest);
42
- const remoteLoads = remoteNames.map(async (remoteName) => {
43
- const remoteOrigin = envManifest[remoteName];
44
- const env = await firstValueFrom(this.http.get(this.getRemoteEnvUrl(remoteOrigin)));
45
- this.envMap.set(remoteName, env);
46
- });
47
- await Promise.all(remoteLoads);
48
- }
49
- catch (e) {
50
- throw new Error(`Failed to load environment configuration; cannot continue. ${e?.message ?? e}`);
51
- }
52
- }
53
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: EnvService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
54
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: EnvService, providedIn: 'root' });
55
- }
56
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: EnvService, decorators: [{
57
- type: Injectable,
58
- args: [{ providedIn: 'root' }]
59
- }] });
60
-
61
- class Env {
62
- envMap = inject(APP_CONFIG_ENV);
63
- get(remoteName) {
64
- const v = this.envMap.get(remoteName);
65
- if (!v) {
66
- throw new Error(`Env for "${remoteName}" not loaded. Did you register provideAppInitializer(() => env.load()) ?`);
67
- }
68
- return v;
69
- }
70
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Env, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
71
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Env, providedIn: 'root' });
72
- }
73
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Env, decorators: [{
74
- type: Injectable,
75
- args: [{
76
- providedIn: 'root'
77
- }]
78
- }] });
79
-
80
- function provideFederationEnv() {
81
- return makeEnvironmentProviders([
82
- EnvService, Federation, Env,
83
- { provide: APP_CONFIG_ENV, useValue: new Map() },
84
- provideAppInitializer(() => inject(EnvService).load()),
85
- ]);
86
- }
87
-
88
- const APP_CONFIG_ASSETS = new InjectionToken('asset-registry');
89
- class AssetService {
90
- http = inject(HttpClient);
91
- federation = inject(Federation);
92
- assets = inject(APP_CONFIG_ASSETS);
93
- getAssetManifest() {
94
- return this.http.get(this.federation.getShellOrigin() + '/assets.manifest.json');
95
- }
96
- async load() {
97
- try {
98
- const manifest = await firstValueFrom(this.getAssetManifest());
99
- // Remotes
100
- Object.entries(manifest).forEach(([remote, origin]) => {
101
- this.assets.set(remote, origin);
102
- });
103
- }
104
- catch (error) {
105
- throw new Error('Failed to load asset configuration, cannot continue. ' + error);
106
- }
107
- }
108
- resolve(assetRef) {
109
- /**
110
- * assetRef format:
111
- * shell:logo.svg
112
- * user:img/avatar.png
113
- * doc:video/intro.mp4
114
- */
115
- if (!assetRef.includes(':')) {
116
- throw new Error(`Invalid asset reference: ${assetRef}`);
117
- }
118
- const [scope, path] = assetRef.split(':');
119
- const origin = this.assets.get(scope);
120
- if (!origin) {
121
- throw new Error(`Unknown asset scope: ${scope}`);
122
- }
123
- return `${origin}/${path}`;
124
- }
125
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AssetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
126
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AssetService, providedIn: 'root' });
127
- }
128
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AssetService, decorators: [{
129
- type: Injectable,
130
- args: [{ providedIn: 'root' }]
131
- }] });
132
-
133
- class Assets {
134
- assetService = inject(AssetService);
135
- get(assetRef) {
136
- return this.assetService.resolve(assetRef);
137
- }
138
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Assets, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
139
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Assets, providedIn: 'root' });
140
- }
141
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: Assets, decorators: [{
142
- type: Injectable,
143
- args: [{ providedIn: 'root' }]
144
- }] });
145
-
146
- class AssetDirective {
147
- el = inject((ElementRef));
148
- assetService = inject(AssetService);
149
- asset = input('', ...(ngDevMode ? [{ debugName: "asset" }] : []));
150
- ngOnChanges(changes) {
151
- if (!this.asset())
152
- return;
153
- const url = this.assetService.resolve(this.asset());
154
- const nativeEl = this.el.nativeElement;
155
- const attr = this.detectAttribute(nativeEl);
156
- nativeEl.setAttribute(attr, url);
157
- }
158
- detectAttribute(el) {
159
- const tag = el.tagName.toLowerCase();
160
- switch (tag) {
161
- case 'img':
162
- case 'video':
163
- case 'audio':
164
- case 'iframe':
165
- case 'source':
166
- return 'src';
167
- case 'a':
168
- return 'href';
169
- case 'object':
170
- return 'data';
171
- default:
172
- return 'src';
173
- }
174
- }
175
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AssetDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
176
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.15", type: AssetDirective, isStandalone: true, selector: "[asset]", inputs: { asset: { classPropertyName: "asset", publicName: "asset", isSignal: true, isRequired: false, transformFunction: null } }, usesOnChanges: true, ngImport: i0 });
177
- }
178
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: AssetDirective, decorators: [{
179
- type: Directive,
180
- args: [{
181
- selector: '[asset]',
182
- standalone: true,
183
- }]
184
- }], propDecorators: { asset: [{ type: i0.Input, args: [{ isSignal: true, alias: "asset", required: false }] }] } });
185
-
186
- function provideFederationAsset() {
187
- return makeEnvironmentProviders([
188
- AssetService, Assets,
189
- {
190
- provide: APP_CONFIG_ASSETS,
191
- useValue: new Map(),
192
- },
193
- provideAppInitializer(() => inject(AssetService).load()),
194
- ]);
195
- }
196
-
197
- const APP_TRANSLATIONS_STORE = new InjectionToken('APP_TRANSLATIONS_STORE');
198
- class TranslationRegistry {
199
- http = inject(HttpClient);
200
- federation = inject(Federation);
201
- store = inject(APP_TRANSLATIONS_STORE);
202
- async load(lang) {
203
- const manifest = await firstValueFrom(this.http.get(this.federation.getShellOrigin() + '/i18n-manifest.json'));
204
- await Promise.all(Object.entries(manifest).map(async ([name, origin]) => {
205
- const translations = await firstValueFrom(this.http.get(`${origin}/i18n/${lang}.json`));
206
- this.store.set(name, translations);
207
- }));
208
- }
209
- getMergedTranslations() {
210
- const result = {};
211
- this.store.forEach(value => Object.assign(result, value));
212
- return result;
213
- }
214
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TranslationRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
215
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TranslationRegistry, providedIn: 'root' });
216
- }
217
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: TranslationRegistry, decorators: [{
218
- type: Injectable,
219
- args: [{ providedIn: 'root' }]
220
- }] });
221
-
222
- class FederatedTranslateLoader {
223
- registry;
224
- constructor(registry) {
225
- this.registry = registry;
226
- }
227
- getTranslation(lang) {
228
- return from(this.registry.load(lang)).pipe(map(() => this.registry.getMergedTranslations()));
229
- }
230
- }
231
-
232
- function provideFederationTranslation() {
233
- return makeEnvironmentProviders([
234
- {
235
- provide: APP_TRANSLATIONS_STORE,
236
- useFactory: () => new Map(),
237
- },
238
- TranslationRegistry,
239
- {
240
- provide: TranslateLoader,
241
- useFactory: (registry) => new FederatedTranslateLoader(registry),
242
- deps: [TranslationRegistry],
243
- },
244
- ]);
245
- }
246
-
247
- /**
248
- * Generated bundle index. Do not edit.
249
- */
250
-
251
- export { AssetDirective, Assets, Env, provideFederationAsset, provideFederationEnv, provideFederationTranslation };
252
- //# sourceMappingURL=yaagoub-federation-tools.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"yaagoub-federation-tools.mjs","sources":["../../../projects/federation-tools/src/federation/federation.service.ts","../../../projects/federation-tools/src/env/env.service.ts","../../../projects/federation-tools/src/env/env.ts","../../../projects/federation-tools/src/providers/provide-env.ts","../../../projects/federation-tools/src/asset/asset.service.ts","../../../projects/federation-tools/src/asset/asset.ts","../../../projects/federation-tools/src/asset/asset.directive.ts","../../../projects/federation-tools/src/providers/provide-assets.ts","../../../projects/federation-tools/src/i18n/translation-registry.service.ts","../../../projects/federation-tools/src/i18n/federated-translate.loader.ts","../../../projects/federation-tools/src/providers/provide-trans.ts","../../../projects/federation-tools/src/yaagoub-federation-tools.ts"],"sourcesContent":["import { Injectable } from \"@angular/core\";\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class Federation {\r\n getShellOrigin(): string {\r\n return window.location.origin;\r\n }\r\n}\r\n","import { inject, Injectable } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { firstValueFrom } from 'rxjs';\r\nimport { InjectionToken } from '@angular/core';\r\nimport { Federation } from '../federation/federation.service';\r\n\r\nexport type EnvMap = Map<string, Record<string, any>>;\r\n\r\n/**\r\n * Holds all loaded env objects:\r\n * - key: remoteName (from env-manifest.json) + 'shell'\r\n * - value: parsed env.json for that remote\r\n */\r\nexport const APP_CONFIG_ENV = new InjectionToken<EnvMap>('env-settings');\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class EnvService {\r\n private readonly http = inject(HttpClient);\r\n private readonly federation = inject(Federation);\r\n private readonly envMap: EnvMap = inject(APP_CONFIG_ENV);\r\n\r\n private getManifestUrl(): string {\r\n return this.federation.getShellOrigin() + '/env.manifest.json';\r\n }\r\n\r\n private getRemoteEnvUrl(origin: string): string {\r\n return origin.replace(/\\/+$/, '') + '/env.json';\r\n }\r\n\r\n async load(): Promise<void> {\r\n try {\r\n const envManifest = await firstValueFrom(\r\n this.http.get<Record<string, string>>(this.getManifestUrl())\r\n );\r\n\r\n const remoteNames = Object.keys(envManifest);\r\n\r\n const remoteLoads = remoteNames.map(async (remoteName) => {\r\n const remoteOrigin = envManifest[remoteName];\r\n const env = await firstValueFrom(\r\n this.http.get<Record<string, any>>(this.getRemoteEnvUrl(remoteOrigin))\r\n );\r\n this.envMap.set(remoteName, env);\r\n });\r\n\r\n await Promise.all(remoteLoads);\r\n\r\n } catch (e: any) {\r\n throw new Error(\r\n `Failed to load environment configuration; cannot continue. ${e?.message ?? e}`\r\n );\r\n }\r\n }\r\n}\r\n","import { inject, Injectable } from \"@angular/core\";\r\nimport { APP_CONFIG_ENV, EnvMap } from \"./env.service\";\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class Env {\r\n private readonly envMap: EnvMap = inject(APP_CONFIG_ENV);\r\n\r\n get(remoteName: string): Record<string, any> {\r\n const v = this.envMap.get(remoteName);\r\n if (!v) {\r\n throw new Error(\r\n `Env for \"${remoteName}\" not loaded. Did you register provideAppInitializer(() => env.load()) ?`\r\n );\r\n }\r\n return v;\r\n }\r\n}","import { EnvironmentProviders, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\nimport { APP_CONFIG_ENV, EnvService, EnvMap } from '../env/env.service';\nimport { Federation } from '../federation/federation.service';\nimport { Env } from '../env/env';\n\nexport function provideFederationEnv(): EnvironmentProviders {\n return makeEnvironmentProviders([\n EnvService, Federation, Env,\n { provide: APP_CONFIG_ENV, useValue: new Map() as EnvMap },\n provideAppInitializer(() => inject(EnvService).load()),\n ]);\n}","import { InjectionToken } from \"@angular/core\";\r\nimport { inject, Injectable } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { firstValueFrom } from 'rxjs';\r\n\r\nimport { Federation } from '../federation/federation.service';\r\n\r\nexport type AssetRegistry = Map<string, string>;\r\n\r\nexport const APP_CONFIG_ASSETS = new InjectionToken<AssetRegistry>('asset-registry');\r\n\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class AssetService {\r\n\r\n private readonly http = inject(HttpClient);\r\n private readonly federation = inject(Federation);\r\n private readonly assets = inject(APP_CONFIG_ASSETS);\r\n\r\n private getAssetManifest() {\r\n return this.http.get<Record<string, string>>(\r\n this.federation.getShellOrigin() + '/assets.manifest.json'\r\n );\r\n }\r\n\r\n async load(): Promise<void> {\r\n try {\r\n const manifest = await firstValueFrom(this.getAssetManifest());\r\n\r\n // Remotes\r\n Object.entries(manifest).forEach(([remote, origin]) => {\r\n this.assets.set(remote, origin);\r\n });\r\n\r\n } catch (error) {\r\n throw new Error(\r\n 'Failed to load asset configuration, cannot continue. ' + error\r\n );\r\n }\r\n }\r\n\r\n resolve(assetRef: string): string {\r\n /**\r\n * assetRef format:\r\n * shell:logo.svg\r\n * user:img/avatar.png\r\n * doc:video/intro.mp4\r\n */\r\n\r\n if (!assetRef.includes(':')) {\r\n throw new Error(`Invalid asset reference: ${assetRef}`);\r\n }\r\n\r\n const [scope, path] = assetRef.split(':');\r\n const origin = this.assets.get(scope);\r\n\r\n if (!origin) {\r\n throw new Error(`Unknown asset scope: ${scope}`);\r\n }\r\n\r\n return `${origin}/${path}`;\r\n }\r\n\r\n}\r\n","import { inject, Injectable } from '@angular/core';\r\nimport { AssetService } from \"./asset.service\";\r\n\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class Assets {\r\n private readonly assetService = inject(AssetService);\r\n\r\n get(assetRef: string): string {\r\n return this.assetService.resolve(assetRef);\r\n }\r\n}\r\n","import {\r\n Directive,\r\n ElementRef,\r\n OnChanges,\r\n inject,\r\n SimpleChanges,\r\n input,\r\n} from '@angular/core';\r\nimport { AssetService } from './asset.service';\r\n\r\n@Directive({\r\n selector: '[asset]',\r\n standalone: true,\r\n})\r\nexport class AssetDirective implements OnChanges {\r\n private readonly el = inject(ElementRef<HTMLElement>);\r\n private readonly assetService = inject(AssetService);\r\n\r\n asset = input<string>('');\r\n\r\n ngOnChanges(changes: SimpleChanges): void {\r\n if (!this.asset()) return;\r\n\r\n const url = this.assetService.resolve(this.asset());\r\n const nativeEl = this.el.nativeElement;\r\n\r\n const attr = this.detectAttribute(nativeEl);\r\n\r\n nativeEl.setAttribute(attr, url);\r\n }\r\n\r\n private detectAttribute(el: HTMLElement): string {\r\n const tag = el.tagName.toLowerCase();\r\n\r\n switch (tag) {\r\n case 'img':\r\n case 'video':\r\n case 'audio':\r\n case 'iframe':\r\n case 'source':\r\n return 'src';\r\n\r\n case 'a':\r\n return 'href';\r\n\r\n case 'object':\r\n return 'data';\r\n\r\n default:\r\n return 'src';\r\n }\r\n }\r\n}\r\n","import { inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\r\nimport { APP_CONFIG_ASSETS, AssetService } from '../asset/asset.service';\r\nimport { Assets } from '../asset/asset';\r\n\r\nexport function provideFederationAsset() {\r\n return makeEnvironmentProviders([\r\n AssetService, Assets,\r\n {\r\n provide: APP_CONFIG_ASSETS,\r\n useValue: new Map<string, string>(),\r\n },\r\n provideAppInitializer(() => inject(AssetService).load()),\r\n ]);\r\n}\r\n","import { Injectable, InjectionToken, inject } from '@angular/core';\r\nimport { HttpClient } from '@angular/common/http';\r\nimport { firstValueFrom } from 'rxjs';\r\n\r\nimport { Federation } from '../federation/federation.service';\r\n\r\nexport const APP_TRANSLATIONS_STORE =\r\n new InjectionToken<Map<string, any>>('APP_TRANSLATIONS_STORE');\r\n\r\n@Injectable({ providedIn: 'root' })\r\nexport class TranslationRegistry {\r\n private readonly http = inject(HttpClient);\r\n private readonly federation = inject(Federation);\r\n private readonly store = inject(APP_TRANSLATIONS_STORE);\r\n\r\n async load(lang: string): Promise<void> {\r\n\r\n const manifest = await firstValueFrom(\r\n this.http.get<Record<string, string>>(\r\n this.federation.getShellOrigin() + '/i18n-manifest.json'\r\n )\r\n );\r\n\r\n await Promise.all(\r\n Object.entries(manifest).map(async ([name, origin]) => {\r\n const translations = await firstValueFrom(\r\n this.http.get(`${origin}/i18n/${lang}.json`)\r\n );\r\n this.store.set(name, translations);\r\n }),\r\n );\r\n }\r\n\r\n getMergedTranslations(): any {\r\n const result: any = {};\r\n this.store.forEach(value => Object.assign(result, value));\r\n return result;\r\n }\r\n}\r\n","import { TranslateLoader } from '@ngx-translate/core';\r\nimport { Observable, from } from 'rxjs';\r\nimport { map } from 'rxjs/operators';\r\nimport { TranslationRegistry } from './translation-registry.service';\r\n\r\nexport class FederatedTranslateLoader implements TranslateLoader {\r\n constructor(private readonly registry: TranslationRegistry) {}\r\n\r\n getTranslation(lang: string): Observable<any> {\r\n return from(this.registry.load(lang)).pipe(\r\n map(() => this.registry.getMergedTranslations())\r\n );\r\n }\r\n}\r\n","import { makeEnvironmentProviders } from '@angular/core';\r\nimport { TranslateLoader } from '@ngx-translate/core';\r\nimport { APP_TRANSLATIONS_STORE, TranslationRegistry } from '../i18n/translation-registry.service';\r\nimport { FederatedTranslateLoader } from '../i18n/federated-translate.loader';\r\n\r\nexport function provideFederationTranslation() {\r\n return makeEnvironmentProviders([\r\n {\r\n provide: APP_TRANSLATIONS_STORE,\r\n useFactory: () => new Map<string, any>(),\r\n },\r\n TranslationRegistry,\r\n {\r\n provide: TranslateLoader,\r\n useFactory: (registry: TranslationRegistry) =>\r\n new FederatedTranslateLoader(registry),\r\n deps: [TranslationRegistry],\r\n },\r\n ]);\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;MAKa,UAAU,CAAA;IACrB,cAAc,GAAA;AACZ,QAAA,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM;IAC/B;wGAHW,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAV,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,E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A;AACE,YAAA,OAAO,EAAE,eAAe;YACxB,UAAU,EAAE,CAAC,QAA6B,KACxC,IAAI,wBAAwB,CAAC,QAAQ,CAAC;YACxC,IAAI,EAAE,CAAC,mBAAmB,CAAC;AAC5B,SAAA;AACF,KAAA,CAAC;AACJ;;ACnBA;;AAEG;;;;"}
package/index.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import * as i0 from '@angular/core';
2
- import { EnvironmentProviders, OnChanges, SimpleChanges } from '@angular/core';
3
-
4
- declare class Env {
5
- private readonly envMap;
6
- get(remoteName: string): Record<string, any>;
7
- static ɵfac: i0.ɵɵFactoryDeclaration<Env, never>;
8
- static ɵprov: i0.ɵɵInjectableDeclaration<Env>;
9
- }
10
-
11
- declare function provideFederationEnv(): EnvironmentProviders;
12
-
13
- declare class Assets {
14
- private readonly assetService;
15
- get(assetRef: string): string;
16
- static ɵfac: i0.ɵɵFactoryDeclaration<Assets, never>;
17
- static ɵprov: i0.ɵɵInjectableDeclaration<Assets>;
18
- }
19
-
20
- declare class AssetDirective implements OnChanges {
21
- private readonly el;
22
- private readonly assetService;
23
- asset: i0.InputSignal<string>;
24
- ngOnChanges(changes: SimpleChanges): void;
25
- private detectAttribute;
26
- static ɵfac: i0.ɵɵFactoryDeclaration<AssetDirective, never>;
27
- static ɵdir: i0.ɵɵDirectiveDeclaration<AssetDirective, "[asset]", never, { "asset": { "alias": "asset"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
28
- }
29
-
30
- declare function provideFederationAsset(): i0.EnvironmentProviders;
31
-
32
- declare function provideFederationTranslation(): i0.EnvironmentProviders;
33
-
34
- export { AssetDirective, Assets, Env, provideFederationAsset, provideFederationEnv, provideFederationTranslation };