@module-federation/bridge-react 0.0.0-next-20250224065053 → 0.0.0-next-20250224065855
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 +5 -4
- package/dist/context-BwD5jfgB.cjs +364 -0
- package/dist/context-BwUPFSB2.js +365 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- 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.cjs.js +1 -1
- package/dist/router.es.js +1 -1
- package/package.json +4 -4
- package/dist/context-CRuF6Lwb.cjs +0 -99
- package/dist/context-xD9r7Htw.js +0 -100
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20250224065855
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
- Updated dependencies [
|
|
8
|
-
|
|
9
|
-
- @module-federation/
|
|
7
|
+
- Updated dependencies [624ad6b]
|
|
8
|
+
- Updated dependencies [5d988c2]
|
|
9
|
+
- @module-federation/sdk@0.0.0-next-20250224065855
|
|
10
|
+
- @module-federation/bridge-shared@0.0.0-next-20250224065855
|
|
10
11
|
|
|
11
12
|
## 0.9.0
|
|
12
13
|
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const React = require("react");
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
var browser_exports = {};
|
|
21
|
+
__export(browser_exports, {
|
|
22
|
+
createLogger: () => createLogger2,
|
|
23
|
+
logger: () => logger
|
|
24
|
+
});
|
|
25
|
+
var browser = __toCommonJS(browser_exports);
|
|
26
|
+
var supportsSubstitutions = void 0;
|
|
27
|
+
var supportColor = () => {
|
|
28
|
+
if (typeof supportsSubstitutions !== "undefined") {
|
|
29
|
+
return supportsSubstitutions;
|
|
30
|
+
}
|
|
31
|
+
const originalConsoleLog = console.log;
|
|
32
|
+
try {
|
|
33
|
+
const testString = "color test";
|
|
34
|
+
const css = "color: red;";
|
|
35
|
+
supportsSubstitutions = false;
|
|
36
|
+
console.log = (...args) => {
|
|
37
|
+
if (args[0] === `%c${testString}` && args[1] === css) {
|
|
38
|
+
supportsSubstitutions = true;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
console.log(`%c${testString}`, css);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
supportsSubstitutions = false;
|
|
44
|
+
} finally {
|
|
45
|
+
console.log = originalConsoleLog;
|
|
46
|
+
}
|
|
47
|
+
return supportsSubstitutions;
|
|
48
|
+
};
|
|
49
|
+
var ansiToCss = {
|
|
50
|
+
"bold": "font-weight: bold;",
|
|
51
|
+
"red": "color: red;",
|
|
52
|
+
"green": "color: green;",
|
|
53
|
+
"orange": "color: orange;",
|
|
54
|
+
"dodgerblue": "color: dodgerblue;",
|
|
55
|
+
"magenta": "color: magenta;",
|
|
56
|
+
"gray": "color: gray;"
|
|
57
|
+
};
|
|
58
|
+
var formatter = (key) => supportColor() ? (input) => {
|
|
59
|
+
if (Array.isArray(input)) {
|
|
60
|
+
const [label, style] = input;
|
|
61
|
+
return [`%c${label.replace("%c", "")}`, style ? `${ansiToCss[key]}${style}` : `${ansiToCss[key] || ""}`];
|
|
62
|
+
}
|
|
63
|
+
return [`%c${String(input).replace("%c", "")}`, ansiToCss[key] || ""];
|
|
64
|
+
} : (input) => [String(input)];
|
|
65
|
+
var bold = formatter("bold");
|
|
66
|
+
var red = formatter("red");
|
|
67
|
+
var green = formatter("green");
|
|
68
|
+
var orange = formatter("orange");
|
|
69
|
+
var dodgerblue = formatter("dodgerblue");
|
|
70
|
+
var magenta = formatter("magenta");
|
|
71
|
+
formatter("gray");
|
|
72
|
+
function getLabel(type, logType, labels) {
|
|
73
|
+
let label = [""];
|
|
74
|
+
if ("label" in logType) {
|
|
75
|
+
const labelText = type !== "log" ? labels[type] : void 0;
|
|
76
|
+
label = [labelText || logType.label || ""];
|
|
77
|
+
if (logType.color) {
|
|
78
|
+
const colorResult = logType.color(label[0]);
|
|
79
|
+
if (Array.isArray(colorResult) && colorResult.length === 2) {
|
|
80
|
+
label = bold([colorResult[0], colorResult[1]]);
|
|
81
|
+
} else {
|
|
82
|
+
label = bold(colorResult[0] || "");
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
label = bold(label[0]);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
label = label.filter(Boolean);
|
|
89
|
+
return label;
|
|
90
|
+
}
|
|
91
|
+
function finalLog(label, text, args, message) {
|
|
92
|
+
if (label.length) {
|
|
93
|
+
if (Array.isArray(message)) {
|
|
94
|
+
console.log(...label, ...message, ...args);
|
|
95
|
+
} else {
|
|
96
|
+
console.log(...label, text, ...args);
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
Array.isArray(message) ? console.log(...message) : console.log(text, ...args);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
var LOG_LEVEL = {
|
|
103
|
+
error: 0,
|
|
104
|
+
warn: 1,
|
|
105
|
+
info: 2,
|
|
106
|
+
log: 3,
|
|
107
|
+
verbose: 4
|
|
108
|
+
};
|
|
109
|
+
var errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
|
|
110
|
+
var anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
|
|
111
|
+
var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
|
|
112
|
+
function validateOptions(options) {
|
|
113
|
+
const validatedOptions = { ...options };
|
|
114
|
+
if (options.labels && typeof options.labels !== "object") {
|
|
115
|
+
throw new Error("Labels must be an object");
|
|
116
|
+
}
|
|
117
|
+
if (options.level && typeof options.level !== "string") {
|
|
118
|
+
throw new Error("Level must be a string");
|
|
119
|
+
}
|
|
120
|
+
return validatedOptions;
|
|
121
|
+
}
|
|
122
|
+
var createLogger$1 = (options = {}, { getLabel: getLabel2, handleError, finalLog: finalLog2, greet, LOG_TYPES: LOG_TYPES2 }) => {
|
|
123
|
+
const validatedOptions = validateOptions(options);
|
|
124
|
+
let maxLevel = validatedOptions.level || "log";
|
|
125
|
+
let customLabels = validatedOptions.labels || {};
|
|
126
|
+
let log = (type, message, ...args) => {
|
|
127
|
+
if (LOG_LEVEL[LOG_TYPES2[type].level] > LOG_LEVEL[maxLevel]) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (message === void 0 || message === null) {
|
|
131
|
+
return console.log();
|
|
132
|
+
}
|
|
133
|
+
let logType = LOG_TYPES2[type];
|
|
134
|
+
let text = "";
|
|
135
|
+
const label = getLabel2(type, logType, customLabels);
|
|
136
|
+
if (message instanceof Error) {
|
|
137
|
+
if (message.stack) {
|
|
138
|
+
let [name, ...rest] = message.stack.split("\n");
|
|
139
|
+
if (name.startsWith("Error: ")) {
|
|
140
|
+
name = name.slice(7);
|
|
141
|
+
}
|
|
142
|
+
text = `${name}
|
|
143
|
+
${handleError(rest.join("\n"))}`;
|
|
144
|
+
} else {
|
|
145
|
+
text = message.message;
|
|
146
|
+
}
|
|
147
|
+
} else if (logType.level === "error" && typeof message === "string") {
|
|
148
|
+
let lines = message.split("\n");
|
|
149
|
+
text = lines.map((line) => isErrorStackMessage(line) ? handleError(line) : line).join("\n");
|
|
150
|
+
} else {
|
|
151
|
+
text = `${message}`;
|
|
152
|
+
}
|
|
153
|
+
finalLog2(label, text, args, message);
|
|
154
|
+
};
|
|
155
|
+
let logger2 = {
|
|
156
|
+
// greet
|
|
157
|
+
greet: (message) => log("log", greet(message))
|
|
158
|
+
};
|
|
159
|
+
Object.keys(LOG_TYPES2).forEach((key) => {
|
|
160
|
+
logger2[key] = (...args) => log(key, ...args);
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(logger2, "level", {
|
|
163
|
+
get: () => maxLevel,
|
|
164
|
+
set(val) {
|
|
165
|
+
maxLevel = val;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(logger2, "labels", {
|
|
169
|
+
get: () => customLabels,
|
|
170
|
+
set(val) {
|
|
171
|
+
customLabels = val;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
logger2.override = (customLogger) => {
|
|
175
|
+
Object.assign(logger2, customLogger);
|
|
176
|
+
};
|
|
177
|
+
return logger2;
|
|
178
|
+
};
|
|
179
|
+
var startColor = [189, 255, 243];
|
|
180
|
+
var endColor = [74, 194, 154];
|
|
181
|
+
var isWord = (char) => !/[\s\n]/.test(char);
|
|
182
|
+
function gradient(message) {
|
|
183
|
+
if (!supportColor()) {
|
|
184
|
+
return [message];
|
|
185
|
+
}
|
|
186
|
+
const chars = [...message];
|
|
187
|
+
const words = chars.filter(isWord);
|
|
188
|
+
const steps = words.length - 1;
|
|
189
|
+
if (steps === 0) {
|
|
190
|
+
console.log(`%c${message}`, `color: rgb(${startColor.join(",")}); font-weight: bold;`);
|
|
191
|
+
return [message];
|
|
192
|
+
}
|
|
193
|
+
let output = "";
|
|
194
|
+
let styles = [];
|
|
195
|
+
chars.forEach((char) => {
|
|
196
|
+
if (isWord(char)) {
|
|
197
|
+
const progress = words.indexOf(char) / steps;
|
|
198
|
+
const r = Math.round(startColor[0] + (endColor[0] - startColor[0]) * progress);
|
|
199
|
+
const g = Math.round(startColor[1] + (endColor[1] - startColor[1]) * progress);
|
|
200
|
+
const b = Math.round(startColor[2] + (endColor[2] - startColor[2]) * progress);
|
|
201
|
+
output += `%c${char}`;
|
|
202
|
+
styles.push(`color: rgb(${r},${g},${b}); font-weight: bold;`);
|
|
203
|
+
} else {
|
|
204
|
+
output += char;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return [output, ...styles];
|
|
208
|
+
}
|
|
209
|
+
var LOG_TYPES = {
|
|
210
|
+
// Level error
|
|
211
|
+
error: {
|
|
212
|
+
label: "error",
|
|
213
|
+
level: "error",
|
|
214
|
+
color: red
|
|
215
|
+
},
|
|
216
|
+
// Level warn
|
|
217
|
+
warn: {
|
|
218
|
+
label: "warn",
|
|
219
|
+
level: "warn",
|
|
220
|
+
color: orange
|
|
221
|
+
},
|
|
222
|
+
// Level info
|
|
223
|
+
info: {
|
|
224
|
+
label: "info",
|
|
225
|
+
level: "info",
|
|
226
|
+
color: dodgerblue
|
|
227
|
+
},
|
|
228
|
+
start: {
|
|
229
|
+
label: "start",
|
|
230
|
+
level: "info",
|
|
231
|
+
color: dodgerblue
|
|
232
|
+
},
|
|
233
|
+
ready: {
|
|
234
|
+
label: "ready",
|
|
235
|
+
level: "info",
|
|
236
|
+
color: green
|
|
237
|
+
},
|
|
238
|
+
success: {
|
|
239
|
+
label: "success",
|
|
240
|
+
level: "info",
|
|
241
|
+
color: green
|
|
242
|
+
},
|
|
243
|
+
// Level log
|
|
244
|
+
log: {
|
|
245
|
+
level: "log"
|
|
246
|
+
},
|
|
247
|
+
// Level debug
|
|
248
|
+
debug: {
|
|
249
|
+
label: "debug",
|
|
250
|
+
level: "verbose",
|
|
251
|
+
color: magenta
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
function createLogger2(options = {}) {
|
|
255
|
+
return createLogger$1(options, {
|
|
256
|
+
handleError: (msg) => msg,
|
|
257
|
+
getLabel,
|
|
258
|
+
gradient,
|
|
259
|
+
finalLog,
|
|
260
|
+
LOG_TYPES,
|
|
261
|
+
greet: (msg) => {
|
|
262
|
+
return gradient(msg);
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
var logger = createLogger2();
|
|
267
|
+
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
268
|
+
const BROWSER_LOG_VALUE = "1";
|
|
269
|
+
function isBrowserEnv() {
|
|
270
|
+
return typeof window !== "undefined";
|
|
271
|
+
}
|
|
272
|
+
function isBrowserDebug() {
|
|
273
|
+
try {
|
|
274
|
+
if (isBrowserEnv() && window.localStorage) {
|
|
275
|
+
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
276
|
+
}
|
|
277
|
+
} catch (error) {
|
|
278
|
+
return false;
|
|
279
|
+
}
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
function isDebugMode() {
|
|
283
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
284
|
+
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
285
|
+
}
|
|
286
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
287
|
+
return true;
|
|
288
|
+
}
|
|
289
|
+
return isBrowserDebug();
|
|
290
|
+
}
|
|
291
|
+
const PREFIX = "[ Module Federation ]";
|
|
292
|
+
function setDebug(loggerInstance) {
|
|
293
|
+
if (isDebugMode()) {
|
|
294
|
+
loggerInstance.level = "verbose";
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function setPrefix(loggerInstance, prefix) {
|
|
298
|
+
loggerInstance.labels = {
|
|
299
|
+
warn: `${prefix} Warn`,
|
|
300
|
+
error: `${prefix} Error`,
|
|
301
|
+
success: `${prefix} Success`,
|
|
302
|
+
info: `${prefix} Info`,
|
|
303
|
+
ready: `${prefix} Ready`,
|
|
304
|
+
debug: `${prefix} Debug`
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
function createLogger(prefix) {
|
|
308
|
+
const loggerInstance = browser.createLogger({
|
|
309
|
+
labels: {
|
|
310
|
+
warn: `${PREFIX} Warn`,
|
|
311
|
+
error: `${PREFIX} Error`,
|
|
312
|
+
success: `${PREFIX} Success`,
|
|
313
|
+
info: `${PREFIX} Info`,
|
|
314
|
+
ready: `${PREFIX} Ready`,
|
|
315
|
+
debug: `${PREFIX} Debug`
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
setDebug(loggerInstance);
|
|
319
|
+
setPrefix(loggerInstance, prefix);
|
|
320
|
+
return loggerInstance;
|
|
321
|
+
}
|
|
322
|
+
createLogger(PREFIX);
|
|
323
|
+
const LoggerInstance = createLogger(
|
|
324
|
+
"[ Module Federation Bridge React ]"
|
|
325
|
+
);
|
|
326
|
+
function pathJoin(...args) {
|
|
327
|
+
const res = args.reduce((res2, path) => {
|
|
328
|
+
let nPath = path;
|
|
329
|
+
if (!nPath || typeof nPath !== "string") {
|
|
330
|
+
return res2;
|
|
331
|
+
}
|
|
332
|
+
if (nPath[0] !== "/") {
|
|
333
|
+
nPath = `/${nPath}`;
|
|
334
|
+
}
|
|
335
|
+
const lastIndex = nPath.length - 1;
|
|
336
|
+
if (nPath[lastIndex] === "/") {
|
|
337
|
+
nPath = nPath.substring(0, lastIndex);
|
|
338
|
+
}
|
|
339
|
+
return res2 + nPath;
|
|
340
|
+
}, "");
|
|
341
|
+
return res || "/";
|
|
342
|
+
}
|
|
343
|
+
const getModuleName = (id) => {
|
|
344
|
+
if (!id) {
|
|
345
|
+
return id;
|
|
346
|
+
}
|
|
347
|
+
const idArray = id.split("/");
|
|
348
|
+
if (idArray.length < 2) {
|
|
349
|
+
return id;
|
|
350
|
+
}
|
|
351
|
+
return idArray[0] + "/" + idArray[1];
|
|
352
|
+
};
|
|
353
|
+
const getRootDomDefaultClassName = (moduleName) => {
|
|
354
|
+
if (!moduleName) {
|
|
355
|
+
return "";
|
|
356
|
+
}
|
|
357
|
+
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
358
|
+
return `bridge-root-component-${name}`;
|
|
359
|
+
};
|
|
360
|
+
const RouterContext = React.createContext(null);
|
|
361
|
+
exports.LoggerInstance = LoggerInstance;
|
|
362
|
+
exports.RouterContext = RouterContext;
|
|
363
|
+
exports.getRootDomDefaultClassName = getRootDomDefaultClassName;
|
|
364
|
+
exports.pathJoin = pathJoin;
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import React__default from "react";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var browser_exports = {};
|
|
20
|
+
__export(browser_exports, {
|
|
21
|
+
createLogger: () => createLogger2,
|
|
22
|
+
logger: () => logger
|
|
23
|
+
});
|
|
24
|
+
var browser = __toCommonJS(browser_exports);
|
|
25
|
+
var supportsSubstitutions = void 0;
|
|
26
|
+
var supportColor = () => {
|
|
27
|
+
if (typeof supportsSubstitutions !== "undefined") {
|
|
28
|
+
return supportsSubstitutions;
|
|
29
|
+
}
|
|
30
|
+
const originalConsoleLog = console.log;
|
|
31
|
+
try {
|
|
32
|
+
const testString = "color test";
|
|
33
|
+
const css = "color: red;";
|
|
34
|
+
supportsSubstitutions = false;
|
|
35
|
+
console.log = (...args) => {
|
|
36
|
+
if (args[0] === `%c${testString}` && args[1] === css) {
|
|
37
|
+
supportsSubstitutions = true;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
console.log(`%c${testString}`, css);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
supportsSubstitutions = false;
|
|
43
|
+
} finally {
|
|
44
|
+
console.log = originalConsoleLog;
|
|
45
|
+
}
|
|
46
|
+
return supportsSubstitutions;
|
|
47
|
+
};
|
|
48
|
+
var ansiToCss = {
|
|
49
|
+
"bold": "font-weight: bold;",
|
|
50
|
+
"red": "color: red;",
|
|
51
|
+
"green": "color: green;",
|
|
52
|
+
"orange": "color: orange;",
|
|
53
|
+
"dodgerblue": "color: dodgerblue;",
|
|
54
|
+
"magenta": "color: magenta;",
|
|
55
|
+
"gray": "color: gray;"
|
|
56
|
+
};
|
|
57
|
+
var formatter = (key) => supportColor() ? (input) => {
|
|
58
|
+
if (Array.isArray(input)) {
|
|
59
|
+
const [label, style] = input;
|
|
60
|
+
return [`%c${label.replace("%c", "")}`, style ? `${ansiToCss[key]}${style}` : `${ansiToCss[key] || ""}`];
|
|
61
|
+
}
|
|
62
|
+
return [`%c${String(input).replace("%c", "")}`, ansiToCss[key] || ""];
|
|
63
|
+
} : (input) => [String(input)];
|
|
64
|
+
var bold = formatter("bold");
|
|
65
|
+
var red = formatter("red");
|
|
66
|
+
var green = formatter("green");
|
|
67
|
+
var orange = formatter("orange");
|
|
68
|
+
var dodgerblue = formatter("dodgerblue");
|
|
69
|
+
var magenta = formatter("magenta");
|
|
70
|
+
formatter("gray");
|
|
71
|
+
function getLabel(type, logType, labels) {
|
|
72
|
+
let label = [""];
|
|
73
|
+
if ("label" in logType) {
|
|
74
|
+
const labelText = type !== "log" ? labels[type] : void 0;
|
|
75
|
+
label = [labelText || logType.label || ""];
|
|
76
|
+
if (logType.color) {
|
|
77
|
+
const colorResult = logType.color(label[0]);
|
|
78
|
+
if (Array.isArray(colorResult) && colorResult.length === 2) {
|
|
79
|
+
label = bold([colorResult[0], colorResult[1]]);
|
|
80
|
+
} else {
|
|
81
|
+
label = bold(colorResult[0] || "");
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
label = bold(label[0]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
label = label.filter(Boolean);
|
|
88
|
+
return label;
|
|
89
|
+
}
|
|
90
|
+
function finalLog(label, text, args, message) {
|
|
91
|
+
if (label.length) {
|
|
92
|
+
if (Array.isArray(message)) {
|
|
93
|
+
console.log(...label, ...message, ...args);
|
|
94
|
+
} else {
|
|
95
|
+
console.log(...label, text, ...args);
|
|
96
|
+
}
|
|
97
|
+
} else {
|
|
98
|
+
Array.isArray(message) ? console.log(...message) : console.log(text, ...args);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
var LOG_LEVEL = {
|
|
102
|
+
error: 0,
|
|
103
|
+
warn: 1,
|
|
104
|
+
info: 2,
|
|
105
|
+
log: 3,
|
|
106
|
+
verbose: 4
|
|
107
|
+
};
|
|
108
|
+
var errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
|
|
109
|
+
var anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
|
|
110
|
+
var isErrorStackMessage = (message) => errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message);
|
|
111
|
+
function validateOptions(options) {
|
|
112
|
+
const validatedOptions = { ...options };
|
|
113
|
+
if (options.labels && typeof options.labels !== "object") {
|
|
114
|
+
throw new Error("Labels must be an object");
|
|
115
|
+
}
|
|
116
|
+
if (options.level && typeof options.level !== "string") {
|
|
117
|
+
throw new Error("Level must be a string");
|
|
118
|
+
}
|
|
119
|
+
return validatedOptions;
|
|
120
|
+
}
|
|
121
|
+
var createLogger$1 = (options = {}, { getLabel: getLabel2, handleError, finalLog: finalLog2, greet, LOG_TYPES: LOG_TYPES2 }) => {
|
|
122
|
+
const validatedOptions = validateOptions(options);
|
|
123
|
+
let maxLevel = validatedOptions.level || "log";
|
|
124
|
+
let customLabels = validatedOptions.labels || {};
|
|
125
|
+
let log = (type, message, ...args) => {
|
|
126
|
+
if (LOG_LEVEL[LOG_TYPES2[type].level] > LOG_LEVEL[maxLevel]) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (message === void 0 || message === null) {
|
|
130
|
+
return console.log();
|
|
131
|
+
}
|
|
132
|
+
let logType = LOG_TYPES2[type];
|
|
133
|
+
let text = "";
|
|
134
|
+
const label = getLabel2(type, logType, customLabels);
|
|
135
|
+
if (message instanceof Error) {
|
|
136
|
+
if (message.stack) {
|
|
137
|
+
let [name, ...rest] = message.stack.split("\n");
|
|
138
|
+
if (name.startsWith("Error: ")) {
|
|
139
|
+
name = name.slice(7);
|
|
140
|
+
}
|
|
141
|
+
text = `${name}
|
|
142
|
+
${handleError(rest.join("\n"))}`;
|
|
143
|
+
} else {
|
|
144
|
+
text = message.message;
|
|
145
|
+
}
|
|
146
|
+
} else if (logType.level === "error" && typeof message === "string") {
|
|
147
|
+
let lines = message.split("\n");
|
|
148
|
+
text = lines.map((line) => isErrorStackMessage(line) ? handleError(line) : line).join("\n");
|
|
149
|
+
} else {
|
|
150
|
+
text = `${message}`;
|
|
151
|
+
}
|
|
152
|
+
finalLog2(label, text, args, message);
|
|
153
|
+
};
|
|
154
|
+
let logger2 = {
|
|
155
|
+
// greet
|
|
156
|
+
greet: (message) => log("log", greet(message))
|
|
157
|
+
};
|
|
158
|
+
Object.keys(LOG_TYPES2).forEach((key) => {
|
|
159
|
+
logger2[key] = (...args) => log(key, ...args);
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(logger2, "level", {
|
|
162
|
+
get: () => maxLevel,
|
|
163
|
+
set(val) {
|
|
164
|
+
maxLevel = val;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
Object.defineProperty(logger2, "labels", {
|
|
168
|
+
get: () => customLabels,
|
|
169
|
+
set(val) {
|
|
170
|
+
customLabels = val;
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
logger2.override = (customLogger) => {
|
|
174
|
+
Object.assign(logger2, customLogger);
|
|
175
|
+
};
|
|
176
|
+
return logger2;
|
|
177
|
+
};
|
|
178
|
+
var startColor = [189, 255, 243];
|
|
179
|
+
var endColor = [74, 194, 154];
|
|
180
|
+
var isWord = (char) => !/[\s\n]/.test(char);
|
|
181
|
+
function gradient(message) {
|
|
182
|
+
if (!supportColor()) {
|
|
183
|
+
return [message];
|
|
184
|
+
}
|
|
185
|
+
const chars = [...message];
|
|
186
|
+
const words = chars.filter(isWord);
|
|
187
|
+
const steps = words.length - 1;
|
|
188
|
+
if (steps === 0) {
|
|
189
|
+
console.log(`%c${message}`, `color: rgb(${startColor.join(",")}); font-weight: bold;`);
|
|
190
|
+
return [message];
|
|
191
|
+
}
|
|
192
|
+
let output = "";
|
|
193
|
+
let styles = [];
|
|
194
|
+
chars.forEach((char) => {
|
|
195
|
+
if (isWord(char)) {
|
|
196
|
+
const progress = words.indexOf(char) / steps;
|
|
197
|
+
const r = Math.round(startColor[0] + (endColor[0] - startColor[0]) * progress);
|
|
198
|
+
const g = Math.round(startColor[1] + (endColor[1] - startColor[1]) * progress);
|
|
199
|
+
const b = Math.round(startColor[2] + (endColor[2] - startColor[2]) * progress);
|
|
200
|
+
output += `%c${char}`;
|
|
201
|
+
styles.push(`color: rgb(${r},${g},${b}); font-weight: bold;`);
|
|
202
|
+
} else {
|
|
203
|
+
output += char;
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
return [output, ...styles];
|
|
207
|
+
}
|
|
208
|
+
var LOG_TYPES = {
|
|
209
|
+
// Level error
|
|
210
|
+
error: {
|
|
211
|
+
label: "error",
|
|
212
|
+
level: "error",
|
|
213
|
+
color: red
|
|
214
|
+
},
|
|
215
|
+
// Level warn
|
|
216
|
+
warn: {
|
|
217
|
+
label: "warn",
|
|
218
|
+
level: "warn",
|
|
219
|
+
color: orange
|
|
220
|
+
},
|
|
221
|
+
// Level info
|
|
222
|
+
info: {
|
|
223
|
+
label: "info",
|
|
224
|
+
level: "info",
|
|
225
|
+
color: dodgerblue
|
|
226
|
+
},
|
|
227
|
+
start: {
|
|
228
|
+
label: "start",
|
|
229
|
+
level: "info",
|
|
230
|
+
color: dodgerblue
|
|
231
|
+
},
|
|
232
|
+
ready: {
|
|
233
|
+
label: "ready",
|
|
234
|
+
level: "info",
|
|
235
|
+
color: green
|
|
236
|
+
},
|
|
237
|
+
success: {
|
|
238
|
+
label: "success",
|
|
239
|
+
level: "info",
|
|
240
|
+
color: green
|
|
241
|
+
},
|
|
242
|
+
// Level log
|
|
243
|
+
log: {
|
|
244
|
+
level: "log"
|
|
245
|
+
},
|
|
246
|
+
// Level debug
|
|
247
|
+
debug: {
|
|
248
|
+
label: "debug",
|
|
249
|
+
level: "verbose",
|
|
250
|
+
color: magenta
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
function createLogger2(options = {}) {
|
|
254
|
+
return createLogger$1(options, {
|
|
255
|
+
handleError: (msg) => msg,
|
|
256
|
+
getLabel,
|
|
257
|
+
gradient,
|
|
258
|
+
finalLog,
|
|
259
|
+
LOG_TYPES,
|
|
260
|
+
greet: (msg) => {
|
|
261
|
+
return gradient(msg);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
var logger = createLogger2();
|
|
266
|
+
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
267
|
+
const BROWSER_LOG_VALUE = "1";
|
|
268
|
+
function isBrowserEnv() {
|
|
269
|
+
return typeof window !== "undefined";
|
|
270
|
+
}
|
|
271
|
+
function isBrowserDebug() {
|
|
272
|
+
try {
|
|
273
|
+
if (isBrowserEnv() && window.localStorage) {
|
|
274
|
+
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
275
|
+
}
|
|
276
|
+
} catch (error) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
function isDebugMode() {
|
|
282
|
+
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
283
|
+
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
284
|
+
}
|
|
285
|
+
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
return isBrowserDebug();
|
|
289
|
+
}
|
|
290
|
+
const PREFIX = "[ Module Federation ]";
|
|
291
|
+
function setDebug(loggerInstance) {
|
|
292
|
+
if (isDebugMode()) {
|
|
293
|
+
loggerInstance.level = "verbose";
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function setPrefix(loggerInstance, prefix) {
|
|
297
|
+
loggerInstance.labels = {
|
|
298
|
+
warn: `${prefix} Warn`,
|
|
299
|
+
error: `${prefix} Error`,
|
|
300
|
+
success: `${prefix} Success`,
|
|
301
|
+
info: `${prefix} Info`,
|
|
302
|
+
ready: `${prefix} Ready`,
|
|
303
|
+
debug: `${prefix} Debug`
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function createLogger(prefix) {
|
|
307
|
+
const loggerInstance = browser.createLogger({
|
|
308
|
+
labels: {
|
|
309
|
+
warn: `${PREFIX} Warn`,
|
|
310
|
+
error: `${PREFIX} Error`,
|
|
311
|
+
success: `${PREFIX} Success`,
|
|
312
|
+
info: `${PREFIX} Info`,
|
|
313
|
+
ready: `${PREFIX} Ready`,
|
|
314
|
+
debug: `${PREFIX} Debug`
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
setDebug(loggerInstance);
|
|
318
|
+
setPrefix(loggerInstance, prefix);
|
|
319
|
+
return loggerInstance;
|
|
320
|
+
}
|
|
321
|
+
createLogger(PREFIX);
|
|
322
|
+
const LoggerInstance = createLogger(
|
|
323
|
+
"[ Module Federation Bridge React ]"
|
|
324
|
+
);
|
|
325
|
+
function pathJoin(...args) {
|
|
326
|
+
const res = args.reduce((res2, path) => {
|
|
327
|
+
let nPath = path;
|
|
328
|
+
if (!nPath || typeof nPath !== "string") {
|
|
329
|
+
return res2;
|
|
330
|
+
}
|
|
331
|
+
if (nPath[0] !== "/") {
|
|
332
|
+
nPath = `/${nPath}`;
|
|
333
|
+
}
|
|
334
|
+
const lastIndex = nPath.length - 1;
|
|
335
|
+
if (nPath[lastIndex] === "/") {
|
|
336
|
+
nPath = nPath.substring(0, lastIndex);
|
|
337
|
+
}
|
|
338
|
+
return res2 + nPath;
|
|
339
|
+
}, "");
|
|
340
|
+
return res || "/";
|
|
341
|
+
}
|
|
342
|
+
const getModuleName = (id) => {
|
|
343
|
+
if (!id) {
|
|
344
|
+
return id;
|
|
345
|
+
}
|
|
346
|
+
const idArray = id.split("/");
|
|
347
|
+
if (idArray.length < 2) {
|
|
348
|
+
return id;
|
|
349
|
+
}
|
|
350
|
+
return idArray[0] + "/" + idArray[1];
|
|
351
|
+
};
|
|
352
|
+
const getRootDomDefaultClassName = (moduleName) => {
|
|
353
|
+
if (!moduleName) {
|
|
354
|
+
return "";
|
|
355
|
+
}
|
|
356
|
+
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
357
|
+
return `bridge-root-component-${name}`;
|
|
358
|
+
};
|
|
359
|
+
const RouterContext = React__default.createContext(null);
|
|
360
|
+
export {
|
|
361
|
+
LoggerInstance as L,
|
|
362
|
+
RouterContext as R,
|
|
363
|
+
getRootDomDefaultClassName as g,
|
|
364
|
+
pathJoin as p
|
|
365
|
+
};
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
|
-
const context = require("./context-
|
|
4
|
+
const context = require("./context-BwD5jfgB.cjs");
|
|
5
5
|
const ReactRouterDOM = require("react-router-dom");
|
|
6
6
|
const plugin = require("./plugin.cjs.js");
|
|
7
7
|
const ReactDOM = require("react-dom");
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React__default, { createContext, Component, createElement, forwardRef, useRef, useEffect, useContext, useState } from "react";
|
|
3
|
-
import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, R as RouterContext } from "./context-
|
|
3
|
+
import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, R as RouterContext } from "./context-BwUPFSB2.js";
|
|
4
4
|
import * as ReactRouterDOM from "react-router-dom";
|
|
5
5
|
import { federationRuntime } from "./plugin.es.js";
|
|
6
6
|
import ReactDOM from "react-dom";
|
package/dist/router-v5.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom$1 = require("react-router-dom/index.js");
|
|
5
|
-
const context = require("./context-
|
|
5
|
+
const context = require("./context-BwD5jfgB.cjs");
|
|
6
6
|
const ReactRouterDom = require("react-router-dom/index.js");
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
package/dist/router-v5.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom$1 from "react-router-dom/index.js";
|
|
3
|
-
import { R as RouterContext, L as LoggerInstance } from "./context-
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-BwUPFSB2.js";
|
|
4
4
|
export * from "react-router-dom/index.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
package/dist/router-v6.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom$1 = require("react-router-dom/dist/index.js");
|
|
5
|
-
const context = require("./context-
|
|
5
|
+
const context = require("./context-BwD5jfgB.cjs");
|
|
6
6
|
const ReactRouterDom = require("react-router-dom/dist/index.js");
|
|
7
7
|
function _interopNamespaceDefault(e) {
|
|
8
8
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
package/dist/router-v6.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom$1 from "react-router-dom/dist/index.js";
|
|
3
|
-
import { R as RouterContext, L as LoggerInstance } from "./context-
|
|
3
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-BwUPFSB2.js";
|
|
4
4
|
export * from "react-router-dom/dist/index.js";
|
|
5
5
|
function WraperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
package/dist/router.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const React = require("react");
|
|
4
4
|
const ReactRouterDom = require("react-router-dom/");
|
|
5
|
-
const context = require("./context-
|
|
5
|
+
const context = require("./context-BwD5jfgB.cjs");
|
|
6
6
|
function _interopNamespaceDefault(e) {
|
|
7
7
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
8
|
if (e) {
|
package/dist/router.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React__default, { useContext } from "react";
|
|
2
2
|
import * as ReactRouterDom from "react-router-dom/";
|
|
3
3
|
export * from "react-router-dom/";
|
|
4
|
-
import { R as RouterContext, L as LoggerInstance } from "./context-
|
|
4
|
+
import { R as RouterContext, L as LoggerInstance } from "./context-BwUPFSB2.js";
|
|
5
5
|
function WrapperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
|
7
7
|
const routerContextProps = useContext(RouterContext) || {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/bridge-react",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250224065855",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@loadable/component": "^5.16.4",
|
|
48
48
|
"react-error-boundary": "^4.1.2",
|
|
49
|
-
"@module-federation/bridge-shared": "0.0.0-next-
|
|
50
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
49
|
+
"@module-federation/bridge-shared": "0.0.0-next-20250224065855",
|
|
50
|
+
"@module-federation/sdk": "0.0.0-next-20250224065855"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=16.9.0",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"typescript": "^5.2.2",
|
|
69
69
|
"vite": "^5.2.14",
|
|
70
70
|
"vite-plugin-dts": "^4.3.0",
|
|
71
|
-
"@module-federation/runtime": "0.0.0-next-
|
|
71
|
+
"@module-federation/runtime": "0.0.0-next-20250224065855"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"dev": "vite",
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const React = require("react");
|
|
3
|
-
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
4
|
-
const BROWSER_LOG_VALUE = "1";
|
|
5
|
-
function isBrowserEnv() {
|
|
6
|
-
return typeof window !== "undefined";
|
|
7
|
-
}
|
|
8
|
-
function isBrowserDebug() {
|
|
9
|
-
try {
|
|
10
|
-
if (isBrowserEnv() && window.localStorage) {
|
|
11
|
-
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
12
|
-
}
|
|
13
|
-
} catch (error) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
function isDebugMode() {
|
|
19
|
-
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
20
|
-
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
21
|
-
}
|
|
22
|
-
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
return isBrowserDebug();
|
|
26
|
-
}
|
|
27
|
-
let Logger = class Logger2 {
|
|
28
|
-
log(...args) {
|
|
29
|
-
console.log(this.prefix, ...args);
|
|
30
|
-
}
|
|
31
|
-
warn(...args) {
|
|
32
|
-
console.warn(this.prefix, ...args);
|
|
33
|
-
}
|
|
34
|
-
error(...args) {
|
|
35
|
-
console.error(this.prefix, ...args);
|
|
36
|
-
}
|
|
37
|
-
success(...args) {
|
|
38
|
-
console.log(this.prefix, ...args);
|
|
39
|
-
}
|
|
40
|
-
info(...args) {
|
|
41
|
-
console.log(this.prefix, ...args);
|
|
42
|
-
}
|
|
43
|
-
ready(...args) {
|
|
44
|
-
console.log(this.prefix, ...args);
|
|
45
|
-
}
|
|
46
|
-
debug(...args) {
|
|
47
|
-
if (isDebugMode()) {
|
|
48
|
-
console.log(this.prefix, ...args);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
constructor(prefix) {
|
|
52
|
-
this.prefix = prefix;
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
function createLogger(prefix) {
|
|
56
|
-
return new Logger(prefix);
|
|
57
|
-
}
|
|
58
|
-
const LoggerInstance = createLogger(
|
|
59
|
-
"[ Module Federation Bridge React ]"
|
|
60
|
-
);
|
|
61
|
-
function pathJoin(...args) {
|
|
62
|
-
const res = args.reduce((res2, path) => {
|
|
63
|
-
let nPath = path;
|
|
64
|
-
if (!nPath || typeof nPath !== "string") {
|
|
65
|
-
return res2;
|
|
66
|
-
}
|
|
67
|
-
if (nPath[0] !== "/") {
|
|
68
|
-
nPath = `/${nPath}`;
|
|
69
|
-
}
|
|
70
|
-
const lastIndex = nPath.length - 1;
|
|
71
|
-
if (nPath[lastIndex] === "/") {
|
|
72
|
-
nPath = nPath.substring(0, lastIndex);
|
|
73
|
-
}
|
|
74
|
-
return res2 + nPath;
|
|
75
|
-
}, "");
|
|
76
|
-
return res || "/";
|
|
77
|
-
}
|
|
78
|
-
const getModuleName = (id) => {
|
|
79
|
-
if (!id) {
|
|
80
|
-
return id;
|
|
81
|
-
}
|
|
82
|
-
const idArray = id.split("/");
|
|
83
|
-
if (idArray.length < 2) {
|
|
84
|
-
return id;
|
|
85
|
-
}
|
|
86
|
-
return idArray[0] + "/" + idArray[1];
|
|
87
|
-
};
|
|
88
|
-
const getRootDomDefaultClassName = (moduleName) => {
|
|
89
|
-
if (!moduleName) {
|
|
90
|
-
return "";
|
|
91
|
-
}
|
|
92
|
-
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
93
|
-
return `bridge-root-component-${name}`;
|
|
94
|
-
};
|
|
95
|
-
const RouterContext = React.createContext(null);
|
|
96
|
-
exports.LoggerInstance = LoggerInstance;
|
|
97
|
-
exports.RouterContext = RouterContext;
|
|
98
|
-
exports.getRootDomDefaultClassName = getRootDomDefaultClassName;
|
|
99
|
-
exports.pathJoin = pathJoin;
|
package/dist/context-xD9r7Htw.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import React__default from "react";
|
|
2
|
-
const BROWSER_LOG_KEY = "FEDERATION_DEBUG";
|
|
3
|
-
const BROWSER_LOG_VALUE = "1";
|
|
4
|
-
function isBrowserEnv() {
|
|
5
|
-
return typeof window !== "undefined";
|
|
6
|
-
}
|
|
7
|
-
function isBrowserDebug() {
|
|
8
|
-
try {
|
|
9
|
-
if (isBrowserEnv() && window.localStorage) {
|
|
10
|
-
return localStorage.getItem(BROWSER_LOG_KEY) === BROWSER_LOG_VALUE;
|
|
11
|
-
}
|
|
12
|
-
} catch (error) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
function isDebugMode() {
|
|
18
|
-
if (typeof process !== "undefined" && process.env && process.env["FEDERATION_DEBUG"]) {
|
|
19
|
-
return Boolean(process.env["FEDERATION_DEBUG"]);
|
|
20
|
-
}
|
|
21
|
-
if (typeof FEDERATION_DEBUG !== "undefined" && Boolean(FEDERATION_DEBUG)) {
|
|
22
|
-
return true;
|
|
23
|
-
}
|
|
24
|
-
return isBrowserDebug();
|
|
25
|
-
}
|
|
26
|
-
let Logger = class Logger2 {
|
|
27
|
-
log(...args) {
|
|
28
|
-
console.log(this.prefix, ...args);
|
|
29
|
-
}
|
|
30
|
-
warn(...args) {
|
|
31
|
-
console.warn(this.prefix, ...args);
|
|
32
|
-
}
|
|
33
|
-
error(...args) {
|
|
34
|
-
console.error(this.prefix, ...args);
|
|
35
|
-
}
|
|
36
|
-
success(...args) {
|
|
37
|
-
console.log(this.prefix, ...args);
|
|
38
|
-
}
|
|
39
|
-
info(...args) {
|
|
40
|
-
console.log(this.prefix, ...args);
|
|
41
|
-
}
|
|
42
|
-
ready(...args) {
|
|
43
|
-
console.log(this.prefix, ...args);
|
|
44
|
-
}
|
|
45
|
-
debug(...args) {
|
|
46
|
-
if (isDebugMode()) {
|
|
47
|
-
console.log(this.prefix, ...args);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
constructor(prefix) {
|
|
51
|
-
this.prefix = prefix;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
function createLogger(prefix) {
|
|
55
|
-
return new Logger(prefix);
|
|
56
|
-
}
|
|
57
|
-
const LoggerInstance = createLogger(
|
|
58
|
-
"[ Module Federation Bridge React ]"
|
|
59
|
-
);
|
|
60
|
-
function pathJoin(...args) {
|
|
61
|
-
const res = args.reduce((res2, path) => {
|
|
62
|
-
let nPath = path;
|
|
63
|
-
if (!nPath || typeof nPath !== "string") {
|
|
64
|
-
return res2;
|
|
65
|
-
}
|
|
66
|
-
if (nPath[0] !== "/") {
|
|
67
|
-
nPath = `/${nPath}`;
|
|
68
|
-
}
|
|
69
|
-
const lastIndex = nPath.length - 1;
|
|
70
|
-
if (nPath[lastIndex] === "/") {
|
|
71
|
-
nPath = nPath.substring(0, lastIndex);
|
|
72
|
-
}
|
|
73
|
-
return res2 + nPath;
|
|
74
|
-
}, "");
|
|
75
|
-
return res || "/";
|
|
76
|
-
}
|
|
77
|
-
const getModuleName = (id) => {
|
|
78
|
-
if (!id) {
|
|
79
|
-
return id;
|
|
80
|
-
}
|
|
81
|
-
const idArray = id.split("/");
|
|
82
|
-
if (idArray.length < 2) {
|
|
83
|
-
return id;
|
|
84
|
-
}
|
|
85
|
-
return idArray[0] + "/" + idArray[1];
|
|
86
|
-
};
|
|
87
|
-
const getRootDomDefaultClassName = (moduleName) => {
|
|
88
|
-
if (!moduleName) {
|
|
89
|
-
return "";
|
|
90
|
-
}
|
|
91
|
-
const name = getModuleName(moduleName).replace(/\@/, "").replace(/\//, "-");
|
|
92
|
-
return `bridge-root-component-${name}`;
|
|
93
|
-
};
|
|
94
|
-
const RouterContext = React__default.createContext(null);
|
|
95
|
-
export {
|
|
96
|
-
LoggerInstance as L,
|
|
97
|
-
RouterContext as R,
|
|
98
|
-
getRootDomDefaultClassName as g,
|
|
99
|
-
pathJoin as p
|
|
100
|
-
};
|