@module-federation/bridge-react 2.0.1 → 2.1.0
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/CHANGELOG.md +8 -0
- package/dist/base.cjs.js +4 -4
- package/dist/base.es.js +5 -5
- package/dist/{bridge-base-BVX0EbsV.mjs → bridge-base-B7EKIpJ7.mjs} +1 -1
- package/dist/{bridge-base-vSCG9ebE.js → bridge-base-BLno0Ytr.js} +1 -1
- package/dist/{createHelpers-CGhHhtAd.mjs → createHelpers-4fOvXdyD.mjs} +2 -2
- package/dist/{createHelpers-12yCVhCu.js → createHelpers-DVr-JIwn.js} +2 -2
- package/dist/data-fetch-server-middleware.cjs.js +4 -4
- package/dist/data-fetch-server-middleware.es.js +2 -2
- package/dist/data-fetch-utils.cjs.js +2 -2
- package/dist/data-fetch-utils.es.js +4 -4
- package/dist/{index-DtXhorFI.mjs → index-CafhxM-l.mjs} +1 -1
- package/dist/{index-DhFNWacm.js → index-Cmp3JjCw.js} +2 -2
- package/dist/index.cjs.js +5 -5
- package/dist/index.es.js +6 -6
- package/dist/{lazy-load-component-plugin-C7jasFos.js → lazy-load-component-plugin-B0jL1C-H.js} +2 -2
- package/dist/{lazy-load-component-plugin-CrSLH5YP.mjs → lazy-load-component-plugin-CXfIn_mH.mjs} +2 -2
- package/dist/lazy-load-component-plugin.cjs.js +2 -2
- package/dist/lazy-load-component-plugin.es.js +2 -2
- package/dist/lazy-utils.cjs.js +2 -2
- package/dist/lazy-utils.es.js +7 -7
- package/dist/logger-BWq2gts-.mjs +138 -0
- package/dist/logger-DT66A_Pv.js +137 -0
- package/dist/{prefetch-DMJyBeIs.mjs → prefetch-CmkSilpl.mjs} +395 -167
- package/dist/{prefetch-CFRpPfZQ.js → prefetch-CvCACzJH.js} +401 -173
- package/dist/router-v5.cjs.js +1 -1
- package/dist/router-v5.es.js +1 -1
- package/dist/router-v6.cjs.js +1 -1
- package/dist/router-v6.es.js +1 -1
- package/dist/router-v7.cjs.js +1 -1
- package/dist/router-v7.es.js +1 -1
- package/dist/router.cjs.js +1 -1
- package/dist/router.es.js +1 -1
- package/dist/{utils-TDonIHDD.js → utils-BelRTG4G.js} +18 -4
- package/dist/{utils-DpoLOH_j.mjs → utils-DYUQLv_v.mjs} +21 -7
- package/dist/v18.cjs.js +1 -1
- package/dist/v18.es.js +1 -1
- package/dist/v19.cjs.js +1 -1
- package/dist/v19.es.js +1 -1
- package/package.json +6 -6
- package/dist/index.esm-BvTtsZnu.mjs +0 -491
- package/dist/index.esm-CYiGJfQW.js +0 -490
package/CHANGELOG.md
CHANGED
package/dist/base.cjs.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const createHelpers = require("./createHelpers-
|
|
4
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
5
|
-
const lazyUtils = require("./utils-
|
|
3
|
+
const createHelpers = require("./createHelpers-DVr-JIwn.js");
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-B0jL1C-H.js");
|
|
5
|
+
const lazyUtils = require("./utils-BelRTG4G.js");
|
|
6
6
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
7
|
-
const prefetch = require("./prefetch-
|
|
7
|
+
const prefetch = require("./prefetch-CvCACzJH.js");
|
|
8
8
|
const createRemoteAppComponent = createHelpers.createRemoteAppComponentFactory(createHelpers.RemoteAppWrapper);
|
|
9
9
|
const createRemoteComponent = createHelpers.createDeprecatedRemoteComponentFactory(
|
|
10
10
|
createRemoteAppComponent
|
package/dist/base.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory, R as RemoteAppWrapper } from "./createHelpers-
|
|
2
|
-
import { b } from "./createHelpers-
|
|
3
|
-
import { a, c, b as b2, l } from "./lazy-load-component-plugin-
|
|
4
|
-
import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-
|
|
1
|
+
import { c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory, R as RemoteAppWrapper } from "./createHelpers-4fOvXdyD.mjs";
|
|
2
|
+
import { b } from "./createHelpers-4fOvXdyD.mjs";
|
|
3
|
+
import { a, c, b as b2, l } from "./lazy-load-component-plugin-CXfIn_mH.mjs";
|
|
4
|
+
import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-DYUQLv_v.mjs";
|
|
5
5
|
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
6
|
-
import { p } from "./prefetch-
|
|
6
|
+
import { p } from "./prefetch-CmkSilpl.mjs";
|
|
7
7
|
const createRemoteAppComponent = createRemoteAppComponentFactory(RemoteAppWrapper);
|
|
8
8
|
const createRemoteComponent = createDeprecatedRemoteComponentFactory(
|
|
9
9
|
createRemoteAppComponent
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { Component, createElement, createContext } from "react";
|
|
3
|
-
import { L as LoggerInstance, R as RouterContext } from "./index-
|
|
3
|
+
import { L as LoggerInstance, R as RouterContext } from "./index-CafhxM-l.mjs";
|
|
4
4
|
import { federationRuntime } from "./plugin.es.js";
|
|
5
5
|
const ErrorBoundaryContext = createContext(null);
|
|
6
6
|
const initialState = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const React = require("react");
|
|
3
|
-
const index = require("./index-
|
|
3
|
+
const index = require("./index-Cmp3JjCw.js");
|
|
4
4
|
const plugin = require("./plugin.cjs.js");
|
|
5
5
|
function _interopNamespaceDefault(e) {
|
|
6
6
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-
|
|
1
|
+
import { c as createBaseBridgeComponent, E as ErrorBoundary } from "./bridge-base-B7EKIpJ7.mjs";
|
|
2
2
|
import ReactDOM from "react-dom";
|
|
3
|
-
import { L as LoggerInstance, g as getRootDomDefaultClassName } from "./index-
|
|
3
|
+
import { L as LoggerInstance, g as getRootDomDefaultClassName } from "./index-CafhxM-l.mjs";
|
|
4
4
|
import React__default, { forwardRef, useRef, useState, useEffect } from "react";
|
|
5
5
|
import { federationRuntime } from "./plugin.es.js";
|
|
6
6
|
function createReact16Or17Root(container) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const bridgeBase = require("./bridge-base-
|
|
2
|
+
const bridgeBase = require("./bridge-base-BLno0Ytr.js");
|
|
3
3
|
const ReactDOM = require("react-dom");
|
|
4
|
-
const index = require("./index-
|
|
4
|
+
const index = require("./index-Cmp3JjCw.js");
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const plugin = require("./plugin.cjs.js");
|
|
7
7
|
function createReact16Or17Root(container) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const lazyUtils = require("./utils-
|
|
3
|
-
const
|
|
2
|
+
const lazyUtils = require("./utils-BelRTG4G.js");
|
|
3
|
+
const logger = require("./logger-DT66A_Pv.js");
|
|
4
4
|
function wrapSetTimeout(targetPromise, delay = 2e4, id) {
|
|
5
5
|
if (targetPromise && typeof targetPromise.then === "function") {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
@@ -98,7 +98,7 @@ const dataFetchServerMiddleware = async (ctx, next) => {
|
|
|
98
98
|
entryGlobalName: remoteInfo.globalName
|
|
99
99
|
}
|
|
100
100
|
]);
|
|
101
|
-
} else if (!("entry" in remote) || !remote.entry.includes(
|
|
101
|
+
} else if (!("entry" in remote) || !remote.entry.includes(logger.MANIFEST_EXT)) {
|
|
102
102
|
const { hostGlobalSnapshot, remoteSnapshot } = hostInstance2.snapshotHandler.getGlobalRemoteInfo(remoteInfo);
|
|
103
103
|
lazyUtils.logger.debug(
|
|
104
104
|
"find hostGlobalSnapshot: ",
|
|
@@ -140,7 +140,7 @@ const dataFetchServerMiddleware = async (ctx, next) => {
|
|
|
140
140
|
return ctx.json(res);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
const remoteId = dataFetchKey.split(
|
|
143
|
+
const remoteId = dataFetchKey.split(logger.SEPARATOR)[0];
|
|
144
144
|
const hostInstance = globalThis.__FEDERATION__.__INSTANCES__[0];
|
|
145
145
|
if (!hostInstance) {
|
|
146
146
|
throw new Error("host instance not found!");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DATA_FETCH_QUERY, l as logger, e as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, h as loadDataFetchModule } from "./utils-
|
|
2
|
-
import { M as MANIFEST_EXT, S as SEPARATOR } from "./
|
|
1
|
+
import { D as DATA_FETCH_QUERY, l as logger, e as getDataFetchMap, i as initDataFetchMap, M as MF_DATA_FETCH_STATUS, f as fetchData, h as loadDataFetchModule } from "./utils-DYUQLv_v.mjs";
|
|
2
|
+
import { M as MANIFEST_EXT, S as SEPARATOR } from "./logger-BWq2gts-.mjs";
|
|
3
3
|
function wrapSetTimeout(targetPromise, delay = 2e4, id) {
|
|
4
4
|
if (targetPromise && typeof targetPromise.then === "function") {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const lazyUtils = require("./utils-
|
|
4
|
-
const prefetch = require("./prefetch-
|
|
3
|
+
const lazyUtils = require("./utils-BelRTG4G.js");
|
|
4
|
+
const prefetch = require("./prefetch-CvCACzJH.js");
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[lazyUtils.DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { x as DATA_FETCH_FUNCTION } from "./utils-
|
|
2
|
-
import { C, a, c, b, d, g, r } from "./utils-
|
|
3
|
-
import { d as dataFetchFunction } from "./prefetch-
|
|
4
|
-
import { i, p } from "./prefetch-
|
|
1
|
+
import { x as DATA_FETCH_FUNCTION } from "./utils-DYUQLv_v.mjs";
|
|
2
|
+
import { C, a, c, b, d, g, r } from "./utils-DYUQLv_v.mjs";
|
|
3
|
+
import { d as dataFetchFunction } from "./prefetch-CmkSilpl.mjs";
|
|
4
|
+
import { i, p } from "./prefetch-CmkSilpl.mjs";
|
|
5
5
|
async function callDataFetch() {
|
|
6
6
|
const dataFetch = globalThis[DATA_FETCH_FUNCTION];
|
|
7
7
|
if (dataFetch) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React__default from "react";
|
|
2
|
-
import { c as createLogger } from "./
|
|
2
|
+
import { c as createLogger } from "./logger-BWq2gts-.mjs";
|
|
3
3
|
const RouterContext = React__default.createContext(null);
|
|
4
4
|
const LoggerInstance = createLogger(
|
|
5
5
|
"[ Module Federation Bridge React ]"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const React = require("react");
|
|
3
|
-
const
|
|
3
|
+
const logger = require("./logger-DT66A_Pv.js");
|
|
4
4
|
const RouterContext = React.createContext(null);
|
|
5
|
-
const LoggerInstance =
|
|
5
|
+
const LoggerInstance = logger.createLogger(
|
|
6
6
|
"[ Module Federation Bridge React ]"
|
|
7
7
|
);
|
|
8
8
|
function pathJoin(...args) {
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const createHelpers = require("./createHelpers-
|
|
4
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
5
|
-
const lazyUtils = require("./utils-
|
|
3
|
+
const createHelpers = require("./createHelpers-DVr-JIwn.js");
|
|
4
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-B0jL1C-H.js");
|
|
5
|
+
const lazyUtils = require("./utils-BelRTG4G.js");
|
|
6
6
|
const dataFetchUtils = require("./data-fetch-utils.cjs.js");
|
|
7
7
|
const React = require("react");
|
|
8
8
|
const ReactRouterDOM = require("react-router-dom");
|
|
9
|
-
const index = require("./index-
|
|
10
|
-
const prefetch = require("./prefetch-
|
|
9
|
+
const index = require("./index-Cmp3JjCw.js");
|
|
10
|
+
const prefetch = require("./prefetch-CvCACzJH.js");
|
|
11
11
|
function _interopNamespaceDefault(e2) {
|
|
12
12
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
13
|
if (e2) {
|
package/dist/index.es.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-
|
|
2
|
-
import { b } from "./createHelpers-
|
|
3
|
-
import { a, c, b as b2, l } from "./lazy-load-component-plugin-
|
|
4
|
-
import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-
|
|
1
|
+
import { R as RemoteAppWrapper, c as createRemoteAppComponentFactory, a as createDeprecatedRemoteComponentFactory } from "./createHelpers-4fOvXdyD.mjs";
|
|
2
|
+
import { b } from "./createHelpers-4fOvXdyD.mjs";
|
|
3
|
+
import { a, c, b as b2, l } from "./lazy-load-component-plugin-CXfIn_mH.mjs";
|
|
4
|
+
import { C, a as a2, E, c as c2, b as b3, d, g, r, s } from "./utils-DYUQLv_v.mjs";
|
|
5
5
|
import { callDataFetch } from "./data-fetch-utils.es.js";
|
|
6
6
|
import React__default, { forwardRef, useContext, useState, useEffect } from "react";
|
|
7
7
|
import * as ReactRouterDOM from "react-router-dom";
|
|
8
|
-
import { p as pathJoin, L as LoggerInstance } from "./index-
|
|
9
|
-
import { p } from "./prefetch-
|
|
8
|
+
import { p as pathJoin, L as LoggerInstance } from "./index-CafhxM-l.mjs";
|
|
9
|
+
import { p } from "./prefetch-CmkSilpl.mjs";
|
|
10
10
|
function e() {
|
|
11
11
|
const t = new PopStateEvent("popstate", { state: window.history.state });
|
|
12
12
|
window.dispatchEvent(t);
|
package/dist/{lazy-load-component-plugin-C7jasFos.js → lazy-load-component-plugin-B0jL1C-H.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const prefetch = require("./prefetch-
|
|
3
|
-
const lazyUtils = require("./utils-
|
|
2
|
+
const prefetch = require("./prefetch-CvCACzJH.js");
|
|
3
|
+
const lazyUtils = require("./utils-BelRTG4G.js");
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const autoFetchData = () => {
|
|
6
6
|
lazyUtils.initDataFetchMap();
|
package/dist/{lazy-load-component-plugin-CrSLH5YP.mjs → lazy-load-component-plugin-CXfIn_mH.mjs}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as injectDataFetch, p as prefetch } from "./prefetch-
|
|
2
|
-
import { i as initDataFetchMap, j as isDataLoaderExpose, k as getDataFetchInfo, m as getDataFetchMapKey, l as logger, n as getDataFetchItem, o as DATA_FETCH_CLIENT_SUFFIX, p as MF_DATA_FETCH_TYPE, q as isCSROnly, M as MF_DATA_FETCH_STATUS, h as loadDataFetchModule, e as getDataFetchMap, t as isServerEnv, u as getDataFetchIdWithErrorMsgs, v as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, w as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, x as DATA_FETCH_FUNCTION, y as getLoadedRemoteInfos, f as fetchData$1, z as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-
|
|
1
|
+
import { i as injectDataFetch, p as prefetch } from "./prefetch-CmkSilpl.mjs";
|
|
2
|
+
import { i as initDataFetchMap, j as isDataLoaderExpose, k as getDataFetchInfo, m as getDataFetchMapKey, l as logger, n as getDataFetchItem, o as DATA_FETCH_CLIENT_SUFFIX, p as MF_DATA_FETCH_TYPE, q as isCSROnly, M as MF_DATA_FETCH_STATUS, h as loadDataFetchModule, e as getDataFetchMap, t as isServerEnv, u as getDataFetchIdWithErrorMsgs, v as DATA_FETCH_ERROR_PREFIX, E as ERROR_TYPE, w as wrapDataFetchId, L as LOAD_REMOTE_ERROR_PREFIX, x as DATA_FETCH_FUNCTION, y as getLoadedRemoteInfos, f as fetchData$1, z as setDataFetchItemLoadedStatus, F as FS_HREF } from "./utils-DYUQLv_v.mjs";
|
|
3
3
|
import React__default, { useRef, useState, Suspense, useEffect } from "react";
|
|
4
4
|
const autoFetchData = () => {
|
|
5
5
|
initDataFetchMap();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
-
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-
|
|
4
|
-
require("./prefetch-
|
|
3
|
+
const lazyLoadComponentPlugin = require("./lazy-load-component-plugin-B0jL1C-H.js");
|
|
4
|
+
require("./prefetch-CvCACzJH.js");
|
|
5
5
|
exports.default = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
6
6
|
exports.lazyLoadComponentPlugin = lazyLoadComponentPlugin.lazyLoadComponentPlugin;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { l, l as l2 } from "./lazy-load-component-plugin-
|
|
2
|
-
import "./prefetch-
|
|
1
|
+
import { l, l as l2 } from "./lazy-load-component-plugin-CXfIn_mH.mjs";
|
|
2
|
+
import "./prefetch-CmkSilpl.mjs";
|
|
3
3
|
export {
|
|
4
4
|
l as default,
|
|
5
5
|
l2 as lazyLoadComponentPlugin
|
package/dist/lazy-utils.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("./
|
|
4
|
-
const lazyUtils = require("./utils-
|
|
3
|
+
require("./logger-DT66A_Pv.js");
|
|
4
|
+
const lazyUtils = require("./utils-BelRTG4G.js");
|
|
5
5
|
exports.callAllDowngrade = lazyUtils.callAllDowngrade;
|
|
6
6
|
exports.callDowngrade = lazyUtils.callDowngrade;
|
|
7
7
|
exports.fetchData = lazyUtils.fetchData;
|
package/dist/lazy-utils.es.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
1
|
+
import "./logger-BWq2gts-.mjs";
|
|
2
|
+
import { G, H, f, K, N, u, k, n, e, m, I, y, i, q, j, t, h, z, s, w } from "./utils-DYUQLv_v.mjs";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
G as callAllDowngrade,
|
|
5
|
+
H as callDowngrade,
|
|
6
6
|
f as fetchData,
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
K as flushDataFetch,
|
|
8
|
+
N as getDataFetchCache,
|
|
9
9
|
u as getDataFetchIdWithErrorMsgs,
|
|
10
10
|
k as getDataFetchInfo,
|
|
11
11
|
n as getDataFetchItem,
|
|
12
12
|
e as getDataFetchMap,
|
|
13
13
|
m as getDataFetchMapKey,
|
|
14
|
-
|
|
14
|
+
I as getDowngradeTag,
|
|
15
15
|
y as getLoadedRemoteInfos,
|
|
16
16
|
i as initDataFetchMap,
|
|
17
17
|
q as isCSROnly,
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
const MANIFEST_EXT = ".json";
|
|
2
|
+
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
3
|
+
const SEPARATOR = ":";
|
|
4
|
+
function isBrowserEnv() {
|
|
5
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
6
|
+
}
|
|
7
|
+
function isBrowserDebug() {
|
|
8
|
+
try {
|
|
9
|
+
if (isBrowserEnv() && window.localStorage) return Boolean(localStorage.getItem(BROWSER_LOG_KEY));
|
|
10
|
+
} catch (error) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
function isDebugMode() {
|
|
16
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
17
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) return true;
|
|
18
|
+
return isBrowserDebug();
|
|
19
|
+
}
|
|
20
|
+
const PREFIX = "[ Module Federation ]";
|
|
21
|
+
const DEFAULT_DELEGATE = console;
|
|
22
|
+
const LOGGER_STACK_SKIP_TOKENS = [
|
|
23
|
+
"logger.ts",
|
|
24
|
+
"logger.js",
|
|
25
|
+
"captureStackTrace",
|
|
26
|
+
"Logger.emit",
|
|
27
|
+
"Logger.log",
|
|
28
|
+
"Logger.info",
|
|
29
|
+
"Logger.warn",
|
|
30
|
+
"Logger.error",
|
|
31
|
+
"Logger.debug"
|
|
32
|
+
];
|
|
33
|
+
function captureStackTrace() {
|
|
34
|
+
try {
|
|
35
|
+
const stack = (/* @__PURE__ */ new Error()).stack;
|
|
36
|
+
if (!stack) return;
|
|
37
|
+
const [, ...rawLines] = stack.split("\n");
|
|
38
|
+
const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
|
|
39
|
+
if (!filtered.length) return;
|
|
40
|
+
return `Stack trace:
|
|
41
|
+
${filtered.slice(0, 5).join("\n")}`;
|
|
42
|
+
} catch {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var Logger = class {
|
|
47
|
+
constructor(prefix, delegate = DEFAULT_DELEGATE) {
|
|
48
|
+
this.prefix = prefix;
|
|
49
|
+
this.delegate = delegate ?? DEFAULT_DELEGATE;
|
|
50
|
+
}
|
|
51
|
+
setPrefix(prefix) {
|
|
52
|
+
this.prefix = prefix;
|
|
53
|
+
}
|
|
54
|
+
setDelegate(delegate) {
|
|
55
|
+
this.delegate = delegate ?? DEFAULT_DELEGATE;
|
|
56
|
+
}
|
|
57
|
+
emit(method, args) {
|
|
58
|
+
const delegate = this.delegate;
|
|
59
|
+
const stackTrace = isDebugMode() ? captureStackTrace() : void 0;
|
|
60
|
+
const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
|
|
61
|
+
const order = (() => {
|
|
62
|
+
switch (method) {
|
|
63
|
+
case "log":
|
|
64
|
+
return ["log", "info"];
|
|
65
|
+
case "info":
|
|
66
|
+
return ["info", "log"];
|
|
67
|
+
case "warn":
|
|
68
|
+
return [
|
|
69
|
+
"warn",
|
|
70
|
+
"info",
|
|
71
|
+
"log"
|
|
72
|
+
];
|
|
73
|
+
case "error":
|
|
74
|
+
return [
|
|
75
|
+
"error",
|
|
76
|
+
"warn",
|
|
77
|
+
"log"
|
|
78
|
+
];
|
|
79
|
+
default:
|
|
80
|
+
return ["debug", "log"];
|
|
81
|
+
}
|
|
82
|
+
})();
|
|
83
|
+
for (const candidate of order) {
|
|
84
|
+
const handler = delegate[candidate];
|
|
85
|
+
if (typeof handler === "function") {
|
|
86
|
+
handler.call(delegate, this.prefix, ...enrichedArgs);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const candidate of order) {
|
|
91
|
+
const handler = DEFAULT_DELEGATE[candidate];
|
|
92
|
+
if (typeof handler === "function") {
|
|
93
|
+
handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
log(...args) {
|
|
99
|
+
this.emit("log", args);
|
|
100
|
+
}
|
|
101
|
+
warn(...args) {
|
|
102
|
+
this.emit("warn", args);
|
|
103
|
+
}
|
|
104
|
+
error(...args) {
|
|
105
|
+
this.emit("error", args);
|
|
106
|
+
}
|
|
107
|
+
success(...args) {
|
|
108
|
+
this.emit("info", args);
|
|
109
|
+
}
|
|
110
|
+
info(...args) {
|
|
111
|
+
this.emit("info", args);
|
|
112
|
+
}
|
|
113
|
+
ready(...args) {
|
|
114
|
+
this.emit("info", args);
|
|
115
|
+
}
|
|
116
|
+
debug(...args) {
|
|
117
|
+
if (isDebugMode()) this.emit("debug", args);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
function createLogger(prefix) {
|
|
121
|
+
return new Logger(prefix);
|
|
122
|
+
}
|
|
123
|
+
function createInfrastructureLogger(prefix) {
|
|
124
|
+
const infrastructureLogger = new Logger(prefix);
|
|
125
|
+
Object.defineProperty(infrastructureLogger, "__mf_infrastructure_logger__", {
|
|
126
|
+
value: true,
|
|
127
|
+
enumerable: false,
|
|
128
|
+
configurable: false
|
|
129
|
+
});
|
|
130
|
+
return infrastructureLogger;
|
|
131
|
+
}
|
|
132
|
+
createInfrastructureLogger(PREFIX);
|
|
133
|
+
export {
|
|
134
|
+
MANIFEST_EXT as M,
|
|
135
|
+
SEPARATOR as S,
|
|
136
|
+
createLogger as c,
|
|
137
|
+
isBrowserEnv as i
|
|
138
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const MANIFEST_EXT = ".json";
|
|
3
|
+
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
4
|
+
const SEPARATOR = ":";
|
|
5
|
+
function isBrowserEnv() {
|
|
6
|
+
return typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
7
|
+
}
|
|
8
|
+
function isBrowserDebug() {
|
|
9
|
+
try {
|
|
10
|
+
if (isBrowserEnv() && window.localStorage) return Boolean(localStorage.getItem(BROWSER_LOG_KEY));
|
|
11
|
+
} catch (error) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
function isDebugMode() {
|
|
17
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
18
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) return true;
|
|
19
|
+
return isBrowserDebug();
|
|
20
|
+
}
|
|
21
|
+
const PREFIX = "[ Module Federation ]";
|
|
22
|
+
const DEFAULT_DELEGATE = console;
|
|
23
|
+
const LOGGER_STACK_SKIP_TOKENS = [
|
|
24
|
+
"logger.ts",
|
|
25
|
+
"logger.js",
|
|
26
|
+
"captureStackTrace",
|
|
27
|
+
"Logger.emit",
|
|
28
|
+
"Logger.log",
|
|
29
|
+
"Logger.info",
|
|
30
|
+
"Logger.warn",
|
|
31
|
+
"Logger.error",
|
|
32
|
+
"Logger.debug"
|
|
33
|
+
];
|
|
34
|
+
function captureStackTrace() {
|
|
35
|
+
try {
|
|
36
|
+
const stack = (/* @__PURE__ */ new Error()).stack;
|
|
37
|
+
if (!stack) return;
|
|
38
|
+
const [, ...rawLines] = stack.split("\n");
|
|
39
|
+
const filtered = rawLines.filter((line) => !LOGGER_STACK_SKIP_TOKENS.some((token) => line.includes(token)));
|
|
40
|
+
if (!filtered.length) return;
|
|
41
|
+
return `Stack trace:
|
|
42
|
+
${filtered.slice(0, 5).join("\n")}`;
|
|
43
|
+
} catch {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
var Logger = class {
|
|
48
|
+
constructor(prefix, delegate = DEFAULT_DELEGATE) {
|
|
49
|
+
this.prefix = prefix;
|
|
50
|
+
this.delegate = delegate ?? DEFAULT_DELEGATE;
|
|
51
|
+
}
|
|
52
|
+
setPrefix(prefix) {
|
|
53
|
+
this.prefix = prefix;
|
|
54
|
+
}
|
|
55
|
+
setDelegate(delegate) {
|
|
56
|
+
this.delegate = delegate ?? DEFAULT_DELEGATE;
|
|
57
|
+
}
|
|
58
|
+
emit(method, args) {
|
|
59
|
+
const delegate = this.delegate;
|
|
60
|
+
const stackTrace = isDebugMode() ? captureStackTrace() : void 0;
|
|
61
|
+
const enrichedArgs = stackTrace ? [...args, stackTrace] : args;
|
|
62
|
+
const order = (() => {
|
|
63
|
+
switch (method) {
|
|
64
|
+
case "log":
|
|
65
|
+
return ["log", "info"];
|
|
66
|
+
case "info":
|
|
67
|
+
return ["info", "log"];
|
|
68
|
+
case "warn":
|
|
69
|
+
return [
|
|
70
|
+
"warn",
|
|
71
|
+
"info",
|
|
72
|
+
"log"
|
|
73
|
+
];
|
|
74
|
+
case "error":
|
|
75
|
+
return [
|
|
76
|
+
"error",
|
|
77
|
+
"warn",
|
|
78
|
+
"log"
|
|
79
|
+
];
|
|
80
|
+
default:
|
|
81
|
+
return ["debug", "log"];
|
|
82
|
+
}
|
|
83
|
+
})();
|
|
84
|
+
for (const candidate of order) {
|
|
85
|
+
const handler = delegate[candidate];
|
|
86
|
+
if (typeof handler === "function") {
|
|
87
|
+
handler.call(delegate, this.prefix, ...enrichedArgs);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
for (const candidate of order) {
|
|
92
|
+
const handler = DEFAULT_DELEGATE[candidate];
|
|
93
|
+
if (typeof handler === "function") {
|
|
94
|
+
handler.call(DEFAULT_DELEGATE, this.prefix, ...enrichedArgs);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
log(...args) {
|
|
100
|
+
this.emit("log", args);
|
|
101
|
+
}
|
|
102
|
+
warn(...args) {
|
|
103
|
+
this.emit("warn", args);
|
|
104
|
+
}
|
|
105
|
+
error(...args) {
|
|
106
|
+
this.emit("error", args);
|
|
107
|
+
}
|
|
108
|
+
success(...args) {
|
|
109
|
+
this.emit("info", args);
|
|
110
|
+
}
|
|
111
|
+
info(...args) {
|
|
112
|
+
this.emit("info", args);
|
|
113
|
+
}
|
|
114
|
+
ready(...args) {
|
|
115
|
+
this.emit("info", args);
|
|
116
|
+
}
|
|
117
|
+
debug(...args) {
|
|
118
|
+
if (isDebugMode()) this.emit("debug", args);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
function createLogger(prefix) {
|
|
122
|
+
return new Logger(prefix);
|
|
123
|
+
}
|
|
124
|
+
function createInfrastructureLogger(prefix) {
|
|
125
|
+
const infrastructureLogger = new Logger(prefix);
|
|
126
|
+
Object.defineProperty(infrastructureLogger, "__mf_infrastructure_logger__", {
|
|
127
|
+
value: true,
|
|
128
|
+
enumerable: false,
|
|
129
|
+
configurable: false
|
|
130
|
+
});
|
|
131
|
+
return infrastructureLogger;
|
|
132
|
+
}
|
|
133
|
+
createInfrastructureLogger(PREFIX);
|
|
134
|
+
exports.MANIFEST_EXT = MANIFEST_EXT;
|
|
135
|
+
exports.SEPARATOR = SEPARATOR;
|
|
136
|
+
exports.createLogger = createLogger;
|
|
137
|
+
exports.isBrowserEnv = isBrowserEnv;
|