@module-federation/bridge-react 0.0.0-next-20241226090607 → 0.0.0-next-20241230030326
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 +13 -3
- package/dist/{context-CUbFnlO5.js → context-BgBVJ06L.js} +31 -8
- package/dist/{context-BcJ-YlNr.cjs → context-DS0wRSh7.cjs} +31 -8
- package/dist/index.cjs.js +5 -2
- package/dist/index.es.js +5 -2
- 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/src/remote/index.tsx +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
# @module-federation/bridge-react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-20241230030326
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4102786: feat: support basename passed by remote module props
|
|
8
|
+
- Updated dependencies [835b09c]
|
|
9
|
+
- Updated dependencies [4fd33fb]
|
|
10
|
+
- @module-federation/sdk@0.0.0-next-20241230030326
|
|
11
|
+
- @module-federation/bridge-shared@0.0.0-next-20241230030326
|
|
12
|
+
|
|
13
|
+
## 0.8.6
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
6
16
|
|
|
7
17
|
- 85e7482: fix(bridge-react): change all logs from info to debug in all bridge packages
|
|
8
|
-
- @module-federation/sdk@0.
|
|
9
|
-
- @module-federation/bridge-shared@0.
|
|
18
|
+
- @module-federation/sdk@0.8.6
|
|
19
|
+
- @module-federation/bridge-shared@0.8.6
|
|
10
20
|
|
|
11
21
|
## 0.8.5
|
|
12
22
|
|
|
@@ -27,19 +27,21 @@ var supportColor = () => {
|
|
|
27
27
|
if (typeof supportsSubstitutions !== "undefined") {
|
|
28
28
|
return supportsSubstitutions;
|
|
29
29
|
}
|
|
30
|
+
const originalConsoleLog = console.log;
|
|
30
31
|
try {
|
|
31
32
|
const testString = "color test";
|
|
32
33
|
const css = "color: red;";
|
|
33
|
-
|
|
34
|
+
supportsSubstitutions = false;
|
|
34
35
|
console.log = (...args) => {
|
|
35
36
|
if (args[0] === `%c${testString}` && args[1] === css) {
|
|
36
37
|
supportsSubstitutions = true;
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
40
|
console.log(`%c${testString}`, css);
|
|
40
|
-
console.log = originalConsoleLog;
|
|
41
41
|
} catch (e) {
|
|
42
42
|
supportsSubstitutions = false;
|
|
43
|
+
} finally {
|
|
44
|
+
console.log = originalConsoleLog;
|
|
43
45
|
}
|
|
44
46
|
return supportsSubstitutions;
|
|
45
47
|
};
|
|
@@ -69,8 +71,18 @@ formatter("gray");
|
|
|
69
71
|
function getLabel(type, logType, labels) {
|
|
70
72
|
let label = [""];
|
|
71
73
|
if ("label" in logType) {
|
|
72
|
-
|
|
73
|
-
label =
|
|
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
|
+
}
|
|
74
86
|
}
|
|
75
87
|
label = label.filter(Boolean);
|
|
76
88
|
return label;
|
|
@@ -78,9 +90,9 @@ function getLabel(type, logType, labels) {
|
|
|
78
90
|
function finalLog(label, text, args, message) {
|
|
79
91
|
if (label.length) {
|
|
80
92
|
if (Array.isArray(message)) {
|
|
81
|
-
console.log(...label, ...message);
|
|
93
|
+
console.log(...label, ...message, ...args);
|
|
82
94
|
} else {
|
|
83
|
-
console.log(...label, text);
|
|
95
|
+
console.log(...label, text, ...args);
|
|
84
96
|
}
|
|
85
97
|
} else {
|
|
86
98
|
Array.isArray(message) ? console.log(...message) : console.log(text, ...args);
|
|
@@ -96,9 +108,20 @@ var LOG_LEVEL = {
|
|
|
96
108
|
var errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
|
|
97
109
|
var anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
|
|
98
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
|
+
}
|
|
99
121
|
var createLogger$1 = (options = {}, { getLabel: getLabel2, handleError, finalLog: finalLog2, greet, LOG_TYPES: LOG_TYPES2 }) => {
|
|
100
|
-
|
|
101
|
-
let
|
|
122
|
+
const validatedOptions = validateOptions(options);
|
|
123
|
+
let maxLevel = validatedOptions.level || "log";
|
|
124
|
+
let customLabels = validatedOptions.labels || {};
|
|
102
125
|
let log = (type, message, ...args) => {
|
|
103
126
|
if (LOG_LEVEL[LOG_TYPES2[type].level] > LOG_LEVEL[maxLevel]) {
|
|
104
127
|
return;
|
|
@@ -28,19 +28,21 @@ var supportColor = () => {
|
|
|
28
28
|
if (typeof supportsSubstitutions !== "undefined") {
|
|
29
29
|
return supportsSubstitutions;
|
|
30
30
|
}
|
|
31
|
+
const originalConsoleLog = console.log;
|
|
31
32
|
try {
|
|
32
33
|
const testString = "color test";
|
|
33
34
|
const css = "color: red;";
|
|
34
|
-
|
|
35
|
+
supportsSubstitutions = false;
|
|
35
36
|
console.log = (...args) => {
|
|
36
37
|
if (args[0] === `%c${testString}` && args[1] === css) {
|
|
37
38
|
supportsSubstitutions = true;
|
|
38
39
|
}
|
|
39
40
|
};
|
|
40
41
|
console.log(`%c${testString}`, css);
|
|
41
|
-
console.log = originalConsoleLog;
|
|
42
42
|
} catch (e) {
|
|
43
43
|
supportsSubstitutions = false;
|
|
44
|
+
} finally {
|
|
45
|
+
console.log = originalConsoleLog;
|
|
44
46
|
}
|
|
45
47
|
return supportsSubstitutions;
|
|
46
48
|
};
|
|
@@ -70,8 +72,18 @@ formatter("gray");
|
|
|
70
72
|
function getLabel(type, logType, labels) {
|
|
71
73
|
let label = [""];
|
|
72
74
|
if ("label" in logType) {
|
|
73
|
-
|
|
74
|
-
label =
|
|
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
|
+
}
|
|
75
87
|
}
|
|
76
88
|
label = label.filter(Boolean);
|
|
77
89
|
return label;
|
|
@@ -79,9 +91,9 @@ function getLabel(type, logType, labels) {
|
|
|
79
91
|
function finalLog(label, text, args, message) {
|
|
80
92
|
if (label.length) {
|
|
81
93
|
if (Array.isArray(message)) {
|
|
82
|
-
console.log(...label, ...message);
|
|
94
|
+
console.log(...label, ...message, ...args);
|
|
83
95
|
} else {
|
|
84
|
-
console.log(...label, text);
|
|
96
|
+
console.log(...label, text, ...args);
|
|
85
97
|
}
|
|
86
98
|
} else {
|
|
87
99
|
Array.isArray(message) ? console.log(...message) : console.log(text, ...args);
|
|
@@ -97,9 +109,20 @@ var LOG_LEVEL = {
|
|
|
97
109
|
var errorStackRegExp = /at\s.*:\d+:\d+[\s\)]*$/;
|
|
98
110
|
var anonymousErrorStackRegExp = /at\s.*\(<anonymous>\)$/;
|
|
99
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
|
+
}
|
|
100
122
|
var createLogger$1 = (options = {}, { getLabel: getLabel2, handleError, finalLog: finalLog2, greet, LOG_TYPES: LOG_TYPES2 }) => {
|
|
101
|
-
|
|
102
|
-
let
|
|
123
|
+
const validatedOptions = validateOptions(options);
|
|
124
|
+
let maxLevel = validatedOptions.level || "log";
|
|
125
|
+
let customLabels = validatedOptions.labels || {};
|
|
103
126
|
let log = (type, message, ...args) => {
|
|
104
127
|
if (LOG_LEVEL[LOG_TYPES2[type].level] > LOG_LEVEL[maxLevel]) {
|
|
105
128
|
return;
|
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-DS0wRSh7.cjs");
|
|
5
5
|
const ReactRouterDOM = require("react-router-dom");
|
|
6
6
|
const plugin = require("./plugin.cjs.js");
|
|
7
7
|
const ReactDOM = require("react-dom");
|
|
@@ -212,12 +212,15 @@ const RemoteAppWrapper = React.forwardRef(function(props, ref) {
|
|
|
212
212
|
}
|
|
213
213
|
);
|
|
214
214
|
};
|
|
215
|
-
RemoteApp2["__APP_VERSION__"] = "0.8.
|
|
215
|
+
RemoteApp2["__APP_VERSION__"] = "0.8.6";
|
|
216
216
|
return /* @__PURE__ */ React.createElement(RemoteApp2, null);
|
|
217
217
|
});
|
|
218
218
|
function withRouterData(WrappedComponent) {
|
|
219
219
|
const Component = React.forwardRef(function(props, ref) {
|
|
220
220
|
var _a;
|
|
221
|
+
if (props == null ? void 0 : props.basename) {
|
|
222
|
+
return /* @__PURE__ */ React.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
|
|
223
|
+
}
|
|
221
224
|
let enableDispathPopstate = false;
|
|
222
225
|
let routerContextVal;
|
|
223
226
|
try {
|
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, a as atLeastReact18, R as RouterContext } from "./context-
|
|
3
|
+
import { L as LoggerInstance, g as getRootDomDefaultClassName, p as pathJoin, a as atLeastReact18, R as RouterContext } from "./context-BgBVJ06L.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";
|
|
@@ -193,12 +193,15 @@ const RemoteAppWrapper = forwardRef(function(props, ref) {
|
|
|
193
193
|
}
|
|
194
194
|
);
|
|
195
195
|
};
|
|
196
|
-
RemoteApp2["__APP_VERSION__"] = "0.8.
|
|
196
|
+
RemoteApp2["__APP_VERSION__"] = "0.8.6";
|
|
197
197
|
return /* @__PURE__ */ React__default.createElement(RemoteApp2, null);
|
|
198
198
|
});
|
|
199
199
|
function withRouterData(WrappedComponent) {
|
|
200
200
|
const Component2 = forwardRef(function(props, ref) {
|
|
201
201
|
var _a;
|
|
202
|
+
if (props == null ? void 0 : props.basename) {
|
|
203
|
+
return /* @__PURE__ */ React__default.createElement(WrappedComponent, { ...props, basename: props.basename, ref });
|
|
204
|
+
}
|
|
202
205
|
let enableDispathPopstate = false;
|
|
203
206
|
let routerContextVal;
|
|
204
207
|
try {
|
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-DS0wRSh7.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-BgBVJ06L.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-DS0wRSh7.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-BgBVJ06L.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-DS0wRSh7.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-BgBVJ06L.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-20241230030326",
|
|
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-20241230030326",
|
|
50
|
+
"@module-federation/sdk": "0.0.0-next-20241230030326"
|
|
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-20241230030326"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"dev": "vite",
|
package/src/remote/index.tsx
CHANGED
|
@@ -158,6 +158,11 @@ export function withRouterData<
|
|
|
158
158
|
WrappedComponent: React.ComponentType<P & ExtraDataProps>,
|
|
159
159
|
): React.FC<Omit<P, keyof ExtraDataProps>> {
|
|
160
160
|
const Component = forwardRef(function (props: any, ref) {
|
|
161
|
+
if (props?.basename) {
|
|
162
|
+
return (
|
|
163
|
+
<WrappedComponent {...props} basename={props.basename} ref={ref} />
|
|
164
|
+
);
|
|
165
|
+
}
|
|
161
166
|
let enableDispathPopstate = false;
|
|
162
167
|
let routerContextVal: any;
|
|
163
168
|
try {
|