@softarc/native-federation-orchestrator 4.6.0 → 4.6.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.
- package/README.md +2 -2
- package/fesm2022/@softarc/native-federation-orchestrator.mjs +101 -20
- package/fesm2022/@softarc/native-federation-orchestrator.mjs.map +3 -3
- package/fesm2022/node.mjs +1 -1
- package/fesm2022/node.mjs.map +1 -1
- package/node-loader/loader.mjs +19 -2
- package/node-loader/loader.mjs.map +2 -2
- package/package.json +1 -1
- package/quickstart.mjs +11 -11
- package/types/lib/core/3.adapters/browser/sse-handler.d.ts +0 -8
- package/types/scripts/node-loader.d.ts +1 -0
package/README.md
CHANGED
|
@@ -70,7 +70,7 @@ Get up and running in under 2 minutes:
|
|
|
70
70
|
</script>
|
|
71
71
|
|
|
72
72
|
<!-- Include the orchestrator runtime -->
|
|
73
|
-
<script src="https://unpkg.com/@softarc/native-federation-orchestrator@4.6.
|
|
73
|
+
<script src="https://unpkg.com/@softarc/native-federation-orchestrator@4.6.1/quickstart.mjs"></script>
|
|
74
74
|
</head>
|
|
75
75
|
<body>
|
|
76
76
|
<!-- Use your loaded components -->
|
|
@@ -88,7 +88,7 @@ Your micro frontends are now loaded and ready to use. The runtime handles the wh
|
|
|
88
88
|
|
|
89
89
|
```html
|
|
90
90
|
<!-- Development and quick testing -->
|
|
91
|
-
<script src="https://unpkg.com/@softarc/native-federation-orchestrator@4.6.
|
|
91
|
+
<script src="https://unpkg.com/@softarc/native-federation-orchestrator@4.6.1/quickstart.mjs"></script>
|
|
92
92
|
```
|
|
93
93
|
|
|
94
94
|
## Advanced Usage
|
|
@@ -2679,7 +2679,7 @@ function createMarkPoolsForReelection(config, ports) {
|
|
|
2679
2679
|
};
|
|
2680
2680
|
}
|
|
2681
2681
|
|
|
2682
|
-
// node_modules/.pnpm/@softarc+native-federation@4.
|
|
2682
|
+
// node_modules/.pnpm/@softarc+native-federation@4.5.0_typescript@6.0.3/node_modules/@softarc/native-federation/dist/lib/domain/core/build-notification-options.contract.js
|
|
2683
2683
|
var BuildNotificationType = /* @__PURE__ */ ((BuildNotificationType2) => {
|
|
2684
2684
|
BuildNotificationType2["COMPLETED"] = "federation-rebuild-complete";
|
|
2685
2685
|
BuildNotificationType2["ERROR"] = "federation-rebuild-error";
|
|
@@ -2687,7 +2687,7 @@ var BuildNotificationType = /* @__PURE__ */ ((BuildNotificationType2) => {
|
|
|
2687
2687
|
return BuildNotificationType2;
|
|
2688
2688
|
})(BuildNotificationType || {});
|
|
2689
2689
|
|
|
2690
|
-
// node_modules/.pnpm/@softarc+native-federation@4.
|
|
2690
|
+
// node_modules/.pnpm/@softarc+native-federation@4.5.0_typescript@6.0.3/node_modules/@softarc/native-federation/dist/lib/domain/core/chunk.js
|
|
2691
2691
|
var CHUNK_PREFIX = "@nf-internal";
|
|
2692
2692
|
function toChunkImport(fileName) {
|
|
2693
2693
|
if (fileName.startsWith("./")) {
|
|
@@ -3732,7 +3732,7 @@ var createManifestProvider = () => {
|
|
|
3732
3732
|
};
|
|
3733
3733
|
};
|
|
3734
3734
|
|
|
3735
|
-
// node_modules/.pnpm/@softarc+native-federation@4.
|
|
3735
|
+
// node_modules/.pnpm/@softarc+native-federation@4.5.0_typescript@6.0.3/node_modules/@softarc/native-federation/dist/lib/utils/normalize.js
|
|
3736
3736
|
function inferPackageFromSecondary(secondary) {
|
|
3737
3737
|
const parts = secondary.split("/");
|
|
3738
3738
|
if (secondary.startsWith("@") && parts.length >= 2) {
|
|
@@ -3741,7 +3741,7 @@ function inferPackageFromSecondary(secondary) {
|
|
|
3741
3741
|
return parts[0];
|
|
3742
3742
|
}
|
|
3743
3743
|
|
|
3744
|
-
// node_modules/.pnpm/@softarc+native-federation@4.
|
|
3744
|
+
// node_modules/.pnpm/@softarc+native-federation@4.5.0_typescript@6.0.3/node_modules/@softarc/native-federation/dist/lib/core/output/densify-externals.js
|
|
3745
3745
|
function isDense(entry) {
|
|
3746
3746
|
return "entries" in entry;
|
|
3747
3747
|
}
|
|
@@ -4008,27 +4008,108 @@ var createSharedExternalsRepository = (config) => {
|
|
|
4008
4008
|
};
|
|
4009
4009
|
|
|
4010
4010
|
// src/lib/core/3.adapters/browser/sse-handler.ts
|
|
4011
|
+
var RELAY_CHANNEL = "native-federation-sse";
|
|
4012
|
+
var LOCK_PREFIX = "native-federation-sse:";
|
|
4011
4013
|
var createSSEHandler = (config) => {
|
|
4012
|
-
const
|
|
4014
|
+
const subscriptions = /* @__PURE__ */ new Map();
|
|
4015
|
+
const locks = typeof navigator !== "undefined" ? navigator.locks : void 0;
|
|
4016
|
+
const canRelay = !!locks && typeof BroadcastChannel !== "undefined";
|
|
4017
|
+
let relay;
|
|
4018
|
+
let bound = false;
|
|
4019
|
+
function reload(reason) {
|
|
4020
|
+
config.log.debug(0, `[SSE] ${reason}, reloading...`);
|
|
4021
|
+
config.reloadBrowserFn();
|
|
4022
|
+
}
|
|
4023
|
+
function openEventSource(endpoint, subscription) {
|
|
4024
|
+
const eventSource = new EventSource(endpoint);
|
|
4025
|
+
eventSource.onmessage = function(event) {
|
|
4026
|
+
const data = JSON.parse(event.data);
|
|
4027
|
+
if (data.type === BuildNotificationType.COMPLETED) {
|
|
4028
|
+
relay?.postMessage({ endpoint });
|
|
4029
|
+
reload("Rebuild completed");
|
|
4030
|
+
}
|
|
4031
|
+
};
|
|
4032
|
+
eventSource.onerror = function(event) {
|
|
4033
|
+
config.log.error(0, "[SSE] Connection error:", event);
|
|
4034
|
+
if (eventSource.readyState !== eventSource.CLOSED) return;
|
|
4035
|
+
config.log.debug(0, `[SSE] Stream for '${endpoint}' will not reopen, releasing the lock`);
|
|
4036
|
+
disconnect(subscription);
|
|
4037
|
+
};
|
|
4038
|
+
return eventSource;
|
|
4039
|
+
}
|
|
4040
|
+
function connect(endpoint, subscription) {
|
|
4041
|
+
if (!locks) {
|
|
4042
|
+
subscription.source = openEventSource(endpoint, subscription);
|
|
4043
|
+
return;
|
|
4044
|
+
}
|
|
4045
|
+
const abort = new AbortController();
|
|
4046
|
+
const held = new Promise((resolve) => {
|
|
4047
|
+
subscription.releaseLock = resolve;
|
|
4048
|
+
});
|
|
4049
|
+
subscription.abort = abort;
|
|
4050
|
+
locks.request(`${LOCK_PREFIX}${endpoint}`, { signal: abort.signal }, () => {
|
|
4051
|
+
if (abort.signal.aborted) return;
|
|
4052
|
+
config.log.debug(0, `[SSE] Holding the connection for '${endpoint}'`);
|
|
4053
|
+
subscription.source = openEventSource(endpoint, subscription);
|
|
4054
|
+
return held;
|
|
4055
|
+
}).catch(() => {
|
|
4056
|
+
config.log.debug(0, `[SSE] Released the connection for '${endpoint}'`);
|
|
4057
|
+
});
|
|
4058
|
+
}
|
|
4059
|
+
function disconnect(subscription) {
|
|
4060
|
+
subscription.source?.close();
|
|
4061
|
+
subscription.abort?.abort();
|
|
4062
|
+
subscription.releaseLock?.();
|
|
4063
|
+
subscription.source = void 0;
|
|
4064
|
+
subscription.abort = void 0;
|
|
4065
|
+
subscription.releaseLock = void 0;
|
|
4066
|
+
}
|
|
4067
|
+
function onPageHide(event) {
|
|
4068
|
+
if (event.persisted) subscriptions.forEach(disconnect);
|
|
4069
|
+
}
|
|
4070
|
+
function onPageShow(event) {
|
|
4071
|
+
if (event.persisted)
|
|
4072
|
+
subscriptions.forEach((subscription, endpoint) => connect(endpoint, subscription));
|
|
4073
|
+
}
|
|
4074
|
+
function bind() {
|
|
4075
|
+
if (bound) return;
|
|
4076
|
+
bound = true;
|
|
4077
|
+
if (canRelay) {
|
|
4078
|
+
relay = new BroadcastChannel(RELAY_CHANNEL);
|
|
4079
|
+
relay.onmessage = (event) => {
|
|
4080
|
+
if (subscriptions.has(event.data?.endpoint)) reload("Rebuild completed in another tab");
|
|
4081
|
+
};
|
|
4082
|
+
}
|
|
4083
|
+
if (typeof window !== "undefined") {
|
|
4084
|
+
window.addEventListener("pagehide", onPageHide);
|
|
4085
|
+
window.addEventListener("pageshow", onPageShow);
|
|
4086
|
+
}
|
|
4087
|
+
}
|
|
4088
|
+
function unbind() {
|
|
4089
|
+
if (!bound) return;
|
|
4090
|
+
bound = false;
|
|
4091
|
+
relay?.close();
|
|
4092
|
+
relay = void 0;
|
|
4093
|
+
if (typeof window !== "undefined") {
|
|
4094
|
+
window.removeEventListener("pagehide", onPageHide);
|
|
4095
|
+
window.removeEventListener("pageshow", onPageShow);
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4013
4098
|
return {
|
|
4014
4099
|
watchRemoteBuilds: function(endpoint) {
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
};
|
|
4024
|
-
eventSource.onerror = function(event) {
|
|
4025
|
-
config.log.error(0, "[SSE] Connection error:", event);
|
|
4026
|
-
};
|
|
4027
|
-
subscribers.push(eventSource);
|
|
4100
|
+
if (subscriptions.has(endpoint)) {
|
|
4101
|
+
config.log.debug(0, `[SSE] Already watching '${endpoint}'`);
|
|
4102
|
+
return;
|
|
4103
|
+
}
|
|
4104
|
+
bind();
|
|
4105
|
+
const subscription = {};
|
|
4106
|
+
subscriptions.set(endpoint, subscription);
|
|
4107
|
+
connect(endpoint, subscription);
|
|
4028
4108
|
},
|
|
4029
4109
|
closeAll: function() {
|
|
4030
|
-
|
|
4031
|
-
|
|
4110
|
+
subscriptions.forEach(disconnect);
|
|
4111
|
+
subscriptions.clear();
|
|
4112
|
+
unbind();
|
|
4032
4113
|
}
|
|
4033
4114
|
};
|
|
4034
4115
|
};
|