@module-federation/bridge-react 0.0.0-next-20250408084324 → 0.0.0-next-20250410121036
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 +9 -3
- package/dist/index.cjs.js +64 -136
- package/dist/index.d.ts +24 -1
- package/dist/index.es.js +67 -139
- package/dist/internal/bridge-base-CW88-1Be.es.js +103 -0
- package/dist/internal/bridge-base-DBiwuddQ.cjs.js +119 -0
- package/dist/internal/react-error-boundary.esm-CMdlkNPP.es.js +99 -0
- package/dist/internal/react-error-boundary.esm-D8nxmvmv.cjs.js +98 -0
- package/dist/legacy.cjs.js +4 -0
- package/dist/legacy.d.ts +104 -0
- package/dist/legacy.es.js +4 -0
- 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/dist/v16.cjs.js +22 -0
- package/dist/v16.d.ts +104 -0
- package/dist/v16.es.js +22 -0
- package/dist/v18.cjs.js +15 -0
- package/dist/v18.d.ts +105 -0
- package/dist/v18.es.js +15 -0
- package/dist/v19.cjs.js +15 -0
- package/dist/v19.d.ts +106 -0
- package/dist/v19.es.js +15 -0
- package/package.json +19 -4
- package/src/index.ts +6 -0
- package/src/legacy.ts +13 -0
- package/src/provider/create.tsx +73 -20
- package/src/provider/versions/bridge-base.tsx +122 -0
- package/src/provider/versions/legacy.ts +42 -0
- package/src/provider/versions/v18.ts +47 -0
- package/src/provider/versions/v19.ts +48 -0
- package/src/remote/create.tsx +4 -2
- package/src/types.ts +19 -0
- package/src/utils/index.ts +0 -20
- package/src/v18.ts +9 -0
- package/src/v19.ts +9 -0
- package/vite.config.ts +54 -0
- package/src/provider/compat.ts +0 -60
- /package/dist/{context-C79iMWYD.cjs → internal/context.cjs.js} +0 -0
- /package/dist/{context-Dbqf0szX.js → internal/context.es.js} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { E as ErrorBoundary } from "./react-error-boundary.esm-CMdlkNPP.es.js";
|
|
3
|
+
import { L as LoggerInstance, R as RouterContext } from "./context.es.js";
|
|
4
|
+
import { federationRuntime } from "../plugin.es.js";
|
|
5
|
+
function createBaseBridgeComponent({
|
|
6
|
+
createRoot,
|
|
7
|
+
defaultRootOptions,
|
|
8
|
+
...bridgeInfo
|
|
9
|
+
}) {
|
|
10
|
+
return () => {
|
|
11
|
+
const rootMap = /* @__PURE__ */ new Map();
|
|
12
|
+
const instance = federationRuntime.instance;
|
|
13
|
+
LoggerInstance.debug(
|
|
14
|
+
`createBridgeComponent instance from props >>>`,
|
|
15
|
+
instance
|
|
16
|
+
);
|
|
17
|
+
const RawComponent = (info) => {
|
|
18
|
+
const { appInfo, propsInfo, ...restProps } = info;
|
|
19
|
+
const { moduleName, memoryRoute, basename = "/" } = appInfo;
|
|
20
|
+
return /* @__PURE__ */ React.createElement(RouterContext.Provider, { value: { moduleName, basename, memoryRoute } }, /* @__PURE__ */ React.createElement(
|
|
21
|
+
bridgeInfo.rootComponent,
|
|
22
|
+
{
|
|
23
|
+
...propsInfo,
|
|
24
|
+
basename,
|
|
25
|
+
...restProps
|
|
26
|
+
}
|
|
27
|
+
));
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
async render(info) {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f;
|
|
32
|
+
LoggerInstance.debug(`createBridgeComponent render Info`, info);
|
|
33
|
+
const {
|
|
34
|
+
moduleName,
|
|
35
|
+
dom,
|
|
36
|
+
basename,
|
|
37
|
+
memoryRoute,
|
|
38
|
+
fallback,
|
|
39
|
+
rootOptions,
|
|
40
|
+
...propsInfo
|
|
41
|
+
} = info;
|
|
42
|
+
const mergedRootOptions = {
|
|
43
|
+
...defaultRootOptions,
|
|
44
|
+
...rootOptions
|
|
45
|
+
};
|
|
46
|
+
const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
|
|
47
|
+
const rootComponentWithErrorBoundary = /* @__PURE__ */ React.createElement(
|
|
48
|
+
ErrorBoundary,
|
|
49
|
+
{
|
|
50
|
+
FallbackComponent: fallback
|
|
51
|
+
},
|
|
52
|
+
/* @__PURE__ */ React.createElement(
|
|
53
|
+
RawComponent,
|
|
54
|
+
{
|
|
55
|
+
appInfo: {
|
|
56
|
+
moduleName,
|
|
57
|
+
basename,
|
|
58
|
+
memoryRoute
|
|
59
|
+
},
|
|
60
|
+
propsInfo: {
|
|
61
|
+
...propsInfo,
|
|
62
|
+
...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
if (bridgeInfo.render) {
|
|
68
|
+
await Promise.resolve(
|
|
69
|
+
bridgeInfo.render(rootComponentWithErrorBoundary, dom)
|
|
70
|
+
).then((root) => rootMap.set(dom, root));
|
|
71
|
+
} else {
|
|
72
|
+
let root = rootMap.get(dom);
|
|
73
|
+
if (!root && createRoot) {
|
|
74
|
+
root = createRoot(dom, mergedRootOptions);
|
|
75
|
+
rootMap.set(dom, root);
|
|
76
|
+
}
|
|
77
|
+
if (root && "render" in root) {
|
|
78
|
+
root.render(rootComponentWithErrorBoundary);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
|
|
82
|
+
},
|
|
83
|
+
destroy(info) {
|
|
84
|
+
var _a, _b, _c;
|
|
85
|
+
const { dom } = info;
|
|
86
|
+
LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
|
|
87
|
+
const root = rootMap.get(dom);
|
|
88
|
+
if (root) {
|
|
89
|
+
if ("unmount" in root) {
|
|
90
|
+
root.unmount();
|
|
91
|
+
} else {
|
|
92
|
+
console.warn("Root does not have unmount method");
|
|
93
|
+
}
|
|
94
|
+
rootMap.delete(dom);
|
|
95
|
+
}
|
|
96
|
+
(_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export {
|
|
102
|
+
createBaseBridgeComponent as c
|
|
103
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const React = require("react");
|
|
3
|
+
const reactErrorBoundary_esm = require("./react-error-boundary.esm-D8nxmvmv.cjs.js");
|
|
4
|
+
const context = require("./context.cjs.js");
|
|
5
|
+
const plugin = require("../plugin.cjs.js");
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
23
|
+
function createBaseBridgeComponent({
|
|
24
|
+
createRoot,
|
|
25
|
+
defaultRootOptions,
|
|
26
|
+
...bridgeInfo
|
|
27
|
+
}) {
|
|
28
|
+
return () => {
|
|
29
|
+
const rootMap = /* @__PURE__ */ new Map();
|
|
30
|
+
const instance = plugin.federationRuntime.instance;
|
|
31
|
+
context.LoggerInstance.debug(
|
|
32
|
+
`createBridgeComponent instance from props >>>`,
|
|
33
|
+
instance
|
|
34
|
+
);
|
|
35
|
+
const RawComponent = (info) => {
|
|
36
|
+
const { appInfo, propsInfo, ...restProps } = info;
|
|
37
|
+
const { moduleName, memoryRoute, basename = "/" } = appInfo;
|
|
38
|
+
return /* @__PURE__ */ React__namespace.createElement(context.RouterContext.Provider, { value: { moduleName, basename, memoryRoute } }, /* @__PURE__ */ React__namespace.createElement(
|
|
39
|
+
bridgeInfo.rootComponent,
|
|
40
|
+
{
|
|
41
|
+
...propsInfo,
|
|
42
|
+
basename,
|
|
43
|
+
...restProps
|
|
44
|
+
}
|
|
45
|
+
));
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
async render(info) {
|
|
49
|
+
var _a, _b, _c, _d, _e, _f;
|
|
50
|
+
context.LoggerInstance.debug(`createBridgeComponent render Info`, info);
|
|
51
|
+
const {
|
|
52
|
+
moduleName,
|
|
53
|
+
dom,
|
|
54
|
+
basename,
|
|
55
|
+
memoryRoute,
|
|
56
|
+
fallback,
|
|
57
|
+
rootOptions,
|
|
58
|
+
...propsInfo
|
|
59
|
+
} = info;
|
|
60
|
+
const mergedRootOptions = {
|
|
61
|
+
...defaultRootOptions,
|
|
62
|
+
...rootOptions
|
|
63
|
+
};
|
|
64
|
+
const beforeBridgeRenderRes = ((_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.beforeBridgeRender) == null ? void 0 : _c.emit(info)) || {};
|
|
65
|
+
const rootComponentWithErrorBoundary = /* @__PURE__ */ React__namespace.createElement(
|
|
66
|
+
reactErrorBoundary_esm.ErrorBoundary,
|
|
67
|
+
{
|
|
68
|
+
FallbackComponent: fallback
|
|
69
|
+
},
|
|
70
|
+
/* @__PURE__ */ React__namespace.createElement(
|
|
71
|
+
RawComponent,
|
|
72
|
+
{
|
|
73
|
+
appInfo: {
|
|
74
|
+
moduleName,
|
|
75
|
+
basename,
|
|
76
|
+
memoryRoute
|
|
77
|
+
},
|
|
78
|
+
propsInfo: {
|
|
79
|
+
...propsInfo,
|
|
80
|
+
...beforeBridgeRenderRes == null ? void 0 : beforeBridgeRenderRes.extraProps
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
);
|
|
85
|
+
if (bridgeInfo.render) {
|
|
86
|
+
await Promise.resolve(
|
|
87
|
+
bridgeInfo.render(rootComponentWithErrorBoundary, dom)
|
|
88
|
+
).then((root) => rootMap.set(dom, root));
|
|
89
|
+
} else {
|
|
90
|
+
let root = rootMap.get(dom);
|
|
91
|
+
if (!root && createRoot) {
|
|
92
|
+
root = createRoot(dom, mergedRootOptions);
|
|
93
|
+
rootMap.set(dom, root);
|
|
94
|
+
}
|
|
95
|
+
if (root && "render" in root) {
|
|
96
|
+
root.render(rootComponentWithErrorBoundary);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
((_f = (_e = (_d = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _d.lifecycle) == null ? void 0 : _e.afterBridgeRender) == null ? void 0 : _f.emit(info)) || {};
|
|
100
|
+
},
|
|
101
|
+
destroy(info) {
|
|
102
|
+
var _a, _b, _c;
|
|
103
|
+
const { dom } = info;
|
|
104
|
+
context.LoggerInstance.debug(`createBridgeComponent destroy Info`, info);
|
|
105
|
+
const root = rootMap.get(dom);
|
|
106
|
+
if (root) {
|
|
107
|
+
if ("unmount" in root) {
|
|
108
|
+
root.unmount();
|
|
109
|
+
} else {
|
|
110
|
+
console.warn("Root does not have unmount method");
|
|
111
|
+
}
|
|
112
|
+
rootMap.delete(dom);
|
|
113
|
+
}
|
|
114
|
+
(_c = (_b = (_a = instance == null ? void 0 : instance.bridgeHook) == null ? void 0 : _a.lifecycle) == null ? void 0 : _b.afterBridgeDestroy) == null ? void 0 : _c.emit(info);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
exports.createBaseBridgeComponent = createBaseBridgeComponent;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { createContext, Component, createElement } from "react";
|
|
2
|
+
const ErrorBoundaryContext = createContext(null);
|
|
3
|
+
const initialState = {
|
|
4
|
+
didCatch: false,
|
|
5
|
+
error: null
|
|
6
|
+
};
|
|
7
|
+
class ErrorBoundary extends Component {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
11
|
+
this.state = initialState;
|
|
12
|
+
}
|
|
13
|
+
static getDerivedStateFromError(error) {
|
|
14
|
+
return {
|
|
15
|
+
didCatch: true,
|
|
16
|
+
error
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
resetErrorBoundary() {
|
|
20
|
+
const {
|
|
21
|
+
error
|
|
22
|
+
} = this.state;
|
|
23
|
+
if (error !== null) {
|
|
24
|
+
var _this$props$onReset, _this$props;
|
|
25
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
26
|
+
args[_key] = arguments[_key];
|
|
27
|
+
}
|
|
28
|
+
(_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
|
|
29
|
+
args,
|
|
30
|
+
reason: "imperative-api"
|
|
31
|
+
});
|
|
32
|
+
this.setState(initialState);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
componentDidCatch(error, info) {
|
|
36
|
+
var _this$props$onError, _this$props2;
|
|
37
|
+
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
38
|
+
}
|
|
39
|
+
componentDidUpdate(prevProps, prevState) {
|
|
40
|
+
const {
|
|
41
|
+
didCatch
|
|
42
|
+
} = this.state;
|
|
43
|
+
const {
|
|
44
|
+
resetKeys
|
|
45
|
+
} = this.props;
|
|
46
|
+
if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
|
|
47
|
+
var _this$props$onReset2, _this$props3;
|
|
48
|
+
(_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
|
|
49
|
+
next: resetKeys,
|
|
50
|
+
prev: prevProps.resetKeys,
|
|
51
|
+
reason: "keys"
|
|
52
|
+
});
|
|
53
|
+
this.setState(initialState);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
render() {
|
|
57
|
+
const {
|
|
58
|
+
children,
|
|
59
|
+
fallbackRender,
|
|
60
|
+
FallbackComponent,
|
|
61
|
+
fallback
|
|
62
|
+
} = this.props;
|
|
63
|
+
const {
|
|
64
|
+
didCatch,
|
|
65
|
+
error
|
|
66
|
+
} = this.state;
|
|
67
|
+
let childToRender = children;
|
|
68
|
+
if (didCatch) {
|
|
69
|
+
const props = {
|
|
70
|
+
error,
|
|
71
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
72
|
+
};
|
|
73
|
+
if (typeof fallbackRender === "function") {
|
|
74
|
+
childToRender = fallbackRender(props);
|
|
75
|
+
} else if (FallbackComponent) {
|
|
76
|
+
childToRender = createElement(FallbackComponent, props);
|
|
77
|
+
} else if (fallback !== void 0) {
|
|
78
|
+
childToRender = fallback;
|
|
79
|
+
} else {
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return createElement(ErrorBoundaryContext.Provider, {
|
|
84
|
+
value: {
|
|
85
|
+
didCatch,
|
|
86
|
+
error,
|
|
87
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
88
|
+
}
|
|
89
|
+
}, childToRender);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function hasArrayChanged() {
|
|
93
|
+
let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
94
|
+
let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
95
|
+
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
96
|
+
}
|
|
97
|
+
export {
|
|
98
|
+
ErrorBoundary as E
|
|
99
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const React = require("react");
|
|
3
|
+
const ErrorBoundaryContext = React.createContext(null);
|
|
4
|
+
const initialState = {
|
|
5
|
+
didCatch: false,
|
|
6
|
+
error: null
|
|
7
|
+
};
|
|
8
|
+
class ErrorBoundary extends React.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
|
|
12
|
+
this.state = initialState;
|
|
13
|
+
}
|
|
14
|
+
static getDerivedStateFromError(error) {
|
|
15
|
+
return {
|
|
16
|
+
didCatch: true,
|
|
17
|
+
error
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
resetErrorBoundary() {
|
|
21
|
+
const {
|
|
22
|
+
error
|
|
23
|
+
} = this.state;
|
|
24
|
+
if (error !== null) {
|
|
25
|
+
var _this$props$onReset, _this$props;
|
|
26
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
27
|
+
args[_key] = arguments[_key];
|
|
28
|
+
}
|
|
29
|
+
(_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
|
|
30
|
+
args,
|
|
31
|
+
reason: "imperative-api"
|
|
32
|
+
});
|
|
33
|
+
this.setState(initialState);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
componentDidCatch(error, info) {
|
|
37
|
+
var _this$props$onError, _this$props2;
|
|
38
|
+
(_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
39
|
+
}
|
|
40
|
+
componentDidUpdate(prevProps, prevState) {
|
|
41
|
+
const {
|
|
42
|
+
didCatch
|
|
43
|
+
} = this.state;
|
|
44
|
+
const {
|
|
45
|
+
resetKeys
|
|
46
|
+
} = this.props;
|
|
47
|
+
if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
|
|
48
|
+
var _this$props$onReset2, _this$props3;
|
|
49
|
+
(_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
|
|
50
|
+
next: resetKeys,
|
|
51
|
+
prev: prevProps.resetKeys,
|
|
52
|
+
reason: "keys"
|
|
53
|
+
});
|
|
54
|
+
this.setState(initialState);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
const {
|
|
59
|
+
children,
|
|
60
|
+
fallbackRender,
|
|
61
|
+
FallbackComponent,
|
|
62
|
+
fallback
|
|
63
|
+
} = this.props;
|
|
64
|
+
const {
|
|
65
|
+
didCatch,
|
|
66
|
+
error
|
|
67
|
+
} = this.state;
|
|
68
|
+
let childToRender = children;
|
|
69
|
+
if (didCatch) {
|
|
70
|
+
const props = {
|
|
71
|
+
error,
|
|
72
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
73
|
+
};
|
|
74
|
+
if (typeof fallbackRender === "function") {
|
|
75
|
+
childToRender = fallbackRender(props);
|
|
76
|
+
} else if (FallbackComponent) {
|
|
77
|
+
childToRender = React.createElement(FallbackComponent, props);
|
|
78
|
+
} else if (fallback !== void 0) {
|
|
79
|
+
childToRender = fallback;
|
|
80
|
+
} else {
|
|
81
|
+
throw error;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return React.createElement(ErrorBoundaryContext.Provider, {
|
|
85
|
+
value: {
|
|
86
|
+
didCatch,
|
|
87
|
+
error,
|
|
88
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
89
|
+
}
|
|
90
|
+
}, childToRender);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function hasArrayChanged() {
|
|
94
|
+
let a = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
|
|
95
|
+
let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
|
|
96
|
+
return a.length !== b.length || a.some((item, index) => !Object.is(item, b[index]));
|
|
97
|
+
}
|
|
98
|
+
exports.ErrorBoundary = ErrorBoundary;
|
package/dist/legacy.d.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React_2 from 'react';
|
|
2
|
+
|
|
3
|
+
export declare function createBridgeComponent<T = any>(bridgeInfo: Omit<ProviderFnParams<T>, 'createRoot'>): () => {
|
|
4
|
+
render(info: RenderParams): Promise<void>;
|
|
5
|
+
destroy(info: DestroyParams): void;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export declare interface CreateRootOptions {
|
|
9
|
+
identifierPrefix?: string;
|
|
10
|
+
onRecoverableError?: (error: unknown, errorInfo: unknown) => void;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options for creating a React root
|
|
15
|
+
*/
|
|
16
|
+
declare interface CreateRootOptions_2 {
|
|
17
|
+
identifierPrefix?: string;
|
|
18
|
+
onRecoverableError?: (error: unknown) => void;
|
|
19
|
+
transitionCallbacks?: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Parameters for the destroy function
|
|
24
|
+
*/
|
|
25
|
+
export declare interface DestroyParams {
|
|
26
|
+
moduleName: string;
|
|
27
|
+
dom: HTMLElement;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Parameters for the provider function
|
|
32
|
+
*/
|
|
33
|
+
export declare interface ProviderFnParams<T> {
|
|
34
|
+
rootComponent: React_2.ComponentType<T>;
|
|
35
|
+
render?: (App: React_2.ReactElement, id?: HTMLElement | string) => RootType | Promise<RootType>;
|
|
36
|
+
createRoot?: (container: Element | DocumentFragment, options?: CreateRootOptions_2) => Root_2;
|
|
37
|
+
/**
|
|
38
|
+
* Default options to pass to createRoot for React 18 and 19
|
|
39
|
+
* These options will be used when creating a root unless overridden by rootOptions in render params
|
|
40
|
+
* @example
|
|
41
|
+
* {
|
|
42
|
+
* identifierPrefix: 'app-',
|
|
43
|
+
* onRecoverableError: (err) => console.error(err)
|
|
44
|
+
* }
|
|
45
|
+
*/
|
|
46
|
+
defaultRootOptions?: CreateRootOptions_2;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Parameters for the provider function
|
|
51
|
+
*/
|
|
52
|
+
export declare interface ProviderParams {
|
|
53
|
+
moduleName?: string;
|
|
54
|
+
basename?: string;
|
|
55
|
+
memoryRoute?: {
|
|
56
|
+
entryPath: string;
|
|
57
|
+
initialState?: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
style?: React_2.CSSProperties;
|
|
60
|
+
className?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Parameters for the render function
|
|
65
|
+
*/
|
|
66
|
+
export declare interface RenderParams {
|
|
67
|
+
moduleName?: string;
|
|
68
|
+
basename?: string;
|
|
69
|
+
memoryRoute?: {
|
|
70
|
+
entryPath: string;
|
|
71
|
+
initialState?: Record<string, unknown>;
|
|
72
|
+
};
|
|
73
|
+
dom: HTMLElement;
|
|
74
|
+
/**
|
|
75
|
+
* Options to pass to createRoot for React 18 and 19
|
|
76
|
+
* @example
|
|
77
|
+
* {
|
|
78
|
+
* identifierPrefix: 'app-',
|
|
79
|
+
* onRecoverableError: (err) => console.error(err)
|
|
80
|
+
* }
|
|
81
|
+
*/
|
|
82
|
+
rootOptions?: CreateRootOptions_2;
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export declare interface Root {
|
|
87
|
+
render(children: React.ReactNode): void;
|
|
88
|
+
unmount(): void;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Interface for a React root object
|
|
93
|
+
*/
|
|
94
|
+
declare interface Root_2 {
|
|
95
|
+
render(children: React_2.ReactNode): void;
|
|
96
|
+
unmount(): void;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Type for a root element, which can be either an HTMLElement or a React root
|
|
101
|
+
*/
|
|
102
|
+
export declare type RootType = HTMLElement | Root_2;
|
|
103
|
+
|
|
104
|
+
export { }
|
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("./internal/context.cjs.js");
|
|
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 "./internal/context.es.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("./internal/context.cjs.js");
|
|
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 "./internal/context.es.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("./internal/context.cjs.js");
|
|
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 "./internal/context.es.js";
|
|
5
5
|
function WrapperRouter(props) {
|
|
6
6
|
const { basename, ...propsRes } = props;
|
|
7
7
|
const routerContextProps = useContext(RouterContext) || {};
|
package/dist/v16.cjs.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const bridgeBase = require("./internal/bridge-base-DBiwuddQ.cjs.js");
|
|
4
|
+
const ReactDOM = require("react-dom");
|
|
5
|
+
function createReact16Or17Root(container) {
|
|
6
|
+
return {
|
|
7
|
+
render(children) {
|
|
8
|
+
ReactDOM.render(children, container);
|
|
9
|
+
},
|
|
10
|
+
unmount() {
|
|
11
|
+
ReactDOM.unmountComponentAtNode(container);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function createBridgeComponent(bridgeInfo) {
|
|
16
|
+
const fullBridgeInfo = {
|
|
17
|
+
...bridgeInfo,
|
|
18
|
+
createRoot: createReact16Or17Root
|
|
19
|
+
};
|
|
20
|
+
return bridgeBase.createBaseBridgeComponent(fullBridgeInfo);
|
|
21
|
+
}
|
|
22
|
+
exports.createBridgeComponent = createBridgeComponent;
|