@mikkel-ol/federation-session 22.0.4 → 22.0.5
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 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-component.d.ts","sourceRoot":"","sources":["../../src/host/resolve-component.ts"],"names":[],"mappings":"AAMA,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,GAAG,SAAS,CAQrB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAK1D"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveExposedComponent = resolveExposedComponent;
|
|
4
|
+
exports.isAngularComponent = isAngularComponent;
|
|
5
|
+
// The exposed "./Component" is just the remote's root component module, so the
|
|
6
|
+
// export name follows whatever convention the remote uses. Older Angular apps
|
|
7
|
+
// export `AppComponent` from app.component.ts; Angular's current generator
|
|
8
|
+
// exports `App` from app.ts. Rather than chase names, prefer the conventional
|
|
9
|
+
// exports and otherwise pick the first export that carries an Angular component
|
|
10
|
+
// definition (the compiler stamps `ɵcmp` onto every @Component class).
|
|
11
|
+
function resolveExposedComponent(module) {
|
|
12
|
+
for (const preferred of [module.default, module.AppComponent, module.App]) {
|
|
13
|
+
if (isAngularComponent(preferred))
|
|
14
|
+
return preferred;
|
|
15
|
+
}
|
|
16
|
+
for (const value of Object.values(module)) {
|
|
17
|
+
if (isAngularComponent(value))
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
function isAngularComponent(value) {
|
|
23
|
+
return (typeof value === "function" &&
|
|
24
|
+
Object.prototype.hasOwnProperty.call(value, "ɵcmp"));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=resolve-component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-component.js","sourceRoot":"","sources":["../../src/host/resolve-component.ts"],"names":[],"mappings":";;AAMA,0DAUC;AAED,gDAKC;AAvBD,+EAA+E;AAC/E,8EAA8E;AAC9E,2EAA2E;AAC3E,8EAA8E;AAC9E,gFAAgF;AAChF,uEAAuE;AACvE,SAAgB,uBAAuB,CACrC,MAA+B;IAE/B,KAAK,MAAM,SAAS,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;QAC1E,IAAI,kBAAkB,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IACtD,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1C,IAAI,kBAAkB,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IAC9C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAgB,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,OAAO,KAAK,KAAK,UAAU;QAC3B,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CACpD,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
// src/host/resolve-component.ts
|
|
2
|
+
function resolveExposedComponent(module) {
|
|
3
|
+
for (const preferred of [module.default, module.AppComponent, module.App]) {
|
|
4
|
+
if (isAngularComponent(preferred)) return preferred;
|
|
5
|
+
}
|
|
6
|
+
for (const value of Object.values(module)) {
|
|
7
|
+
if (isAngularComponent(value)) return value;
|
|
8
|
+
}
|
|
9
|
+
return void 0;
|
|
10
|
+
}
|
|
11
|
+
function isAngularComponent(value) {
|
|
12
|
+
return typeof value === "function" && Object.prototype.hasOwnProperty.call(value, "\u0275cmp");
|
|
13
|
+
}
|
|
14
|
+
|
|
1
15
|
// src/host/runtime-browser.ts
|
|
2
16
|
var pageUrl = new URL(location.href);
|
|
3
17
|
var hashParams = new URLSearchParams(pageUrl.hash.slice(1));
|
|
@@ -89,9 +103,11 @@ async function mountRevision(item, remote) {
|
|
|
89
103
|
const componentUrl = new URL(exposure.outFileName, entry);
|
|
90
104
|
componentUrl.searchParams.set("revision", String(remote.revision));
|
|
91
105
|
const module = await importShim(componentUrl.href);
|
|
92
|
-
const component = module
|
|
106
|
+
const component = resolveExposedComponent(module);
|
|
93
107
|
if (!component) {
|
|
94
|
-
throw new Error(
|
|
108
|
+
throw new Error(
|
|
109
|
+
"./Component does not export an Angular component (looked for a default export, AppComponent, App, or any exported @Component class)"
|
|
110
|
+
);
|
|
95
111
|
}
|
|
96
112
|
const next = document.createElement("div");
|
|
97
113
|
const componentRef = createComponent(component, {
|