@ice/mf-runtime 0.0.9 → 0.0.10-beta.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/es2017/FallBack.js +6 -7
- package/es2017/RemoteModule.js +7 -21
- package/esm/FallBack.js +2 -3
- package/esm/RemoteModule.js +7 -21
- package/package.json +1 -1
package/es2017/FallBack.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
3
2
|
import * as React from 'react';
|
|
4
3
|
class Component extends React.Component {
|
|
5
4
|
render() {
|
|
6
5
|
const { containerRef } = this.props;
|
|
7
|
-
return /*#__PURE__*/
|
|
6
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
8
7
|
ref: containerRef
|
|
9
8
|
});
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
11
|
export const FallBack = ({ Original, remoteReactDOM, remoteReact })=>{
|
|
13
12
|
const ReactDOM = remoteReactDOM();
|
|
14
|
-
const
|
|
15
|
-
class WrappedComponent extends
|
|
13
|
+
const React1 = remoteReact();
|
|
14
|
+
class WrappedComponent extends React1.Component {
|
|
16
15
|
componentDidMount() {
|
|
17
16
|
this.mountOriginalComponent(true);
|
|
18
17
|
}
|
|
@@ -25,18 +24,18 @@ export const FallBack = ({ Original, remoteReactDOM, remoteReact })=>{
|
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
mountOriginalComponent(shouldRender = false) {
|
|
28
|
-
const element =
|
|
27
|
+
const element = React1.createElement(Original, this.props);
|
|
29
28
|
const renderMethod = shouldRender ? ReactDOM.render : ReactDOM.hydrate;
|
|
30
29
|
renderMethod(element, this.containerRef.current);
|
|
31
30
|
}
|
|
32
31
|
render() {
|
|
33
|
-
return /*#__PURE__*/
|
|
32
|
+
return /*#__PURE__*/ React.createElement(Component, {
|
|
34
33
|
containerRef: this.containerRef
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
constructor(...args){
|
|
38
37
|
super(...args);
|
|
39
|
-
_define_property(this, "containerRef",
|
|
38
|
+
_define_property(this, "containerRef", React1.createRef());
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
return WrappedComponent;
|
package/es2017/RemoteModule.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
2
|
-
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
|
|
4
1
|
import { loadRemote } from '@module-federation/runtime';
|
|
5
2
|
import * as React from 'react';
|
|
6
3
|
import { useMemo } from 'react';
|
|
@@ -47,24 +44,13 @@ export const RemoteModule = ({ module, scope, runtime, publicPath, LoadingCompon
|
|
|
47
44
|
(_runtime = runtime) === null || _runtime === void 0 ? void 0 : _runtime.react,
|
|
48
45
|
(_runtime1 = runtime) === null || _runtime1 === void 0 ? void 0 : _runtime1.reactDOM
|
|
49
46
|
]);
|
|
50
|
-
const Loading = LoadingComponent || /*#__PURE__*/
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
const ErrorFallback = ({ error })=>ErrorComponent || /*#__PURE__*/ _jsxs("div", {
|
|
54
|
-
children: [
|
|
55
|
-
"远程模块加载失败: ",
|
|
56
|
-
error.message
|
|
57
|
-
]
|
|
58
|
-
});
|
|
47
|
+
const Loading = LoadingComponent || /*#__PURE__*/ React.createElement("div", null, "Loading...");
|
|
48
|
+
const ErrorFallback = ({ error })=>ErrorComponent || /*#__PURE__*/ React.createElement("div", null, "远程模块加载失败: ", error.message);
|
|
59
49
|
if (!Component) return Loading;
|
|
60
|
-
return /*#__PURE__*/
|
|
50
|
+
return /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
61
51
|
FallbackComponent: ErrorFallback,
|
|
62
|
-
onError: onError
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
children: children
|
|
67
|
-
}))
|
|
68
|
-
})
|
|
69
|
-
});
|
|
52
|
+
onError: onError
|
|
53
|
+
}, /*#__PURE__*/ React.createElement(React.Suspense, {
|
|
54
|
+
fallback: Loading
|
|
55
|
+
}, /*#__PURE__*/ React.createElement(Component, componentProps, children)));
|
|
70
56
|
};
|
package/esm/FallBack.js
CHANGED
|
@@ -4,7 +4,6 @@ import { _ as _create_class } from "@swc/helpers/_/_create_class";
|
|
|
4
4
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
5
5
|
import { _ as _inherits } from "@swc/helpers/_/_inherits";
|
|
6
6
|
import { _ as _create_super } from "@swc/helpers/_/_create_super";
|
|
7
|
-
import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime";
|
|
8
7
|
import * as React from "react";
|
|
9
8
|
var Component = /*#__PURE__*/ function(_React_Component) {
|
|
10
9
|
"use strict";
|
|
@@ -19,7 +18,7 @@ var Component = /*#__PURE__*/ function(_React_Component) {
|
|
|
19
18
|
key: "render",
|
|
20
19
|
value: function render() {
|
|
21
20
|
var containerRef = this.props.containerRef;
|
|
22
|
-
return /*#__PURE__*/
|
|
21
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
23
22
|
ref: containerRef
|
|
24
23
|
});
|
|
25
24
|
}
|
|
@@ -75,7 +74,7 @@ export var FallBack = function(param) {
|
|
|
75
74
|
{
|
|
76
75
|
key: "render",
|
|
77
76
|
value: function render() {
|
|
78
|
-
return /*#__PURE__*/
|
|
77
|
+
return /*#__PURE__*/ React.createElement(Component, {
|
|
79
78
|
containerRef: this.containerRef
|
|
80
79
|
});
|
|
81
80
|
}
|
package/esm/RemoteModule.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
|
-
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
2
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
|
|
6
3
|
import { loadRemote } from "@module-federation/runtime";
|
|
7
4
|
import * as React from "react";
|
|
8
5
|
import { useMemo } from "react";
|
|
@@ -73,27 +70,16 @@ export var RemoteModule = function(param) {
|
|
|
73
70
|
(_runtime = runtime) === null || _runtime === void 0 ? void 0 : _runtime.react,
|
|
74
71
|
(_runtime1 = runtime) === null || _runtime1 === void 0 ? void 0 : _runtime1.reactDOM
|
|
75
72
|
]);
|
|
76
|
-
var Loading = LoadingComponent || /*#__PURE__*/
|
|
77
|
-
children: "Loading..."
|
|
78
|
-
});
|
|
73
|
+
var Loading = LoadingComponent || /*#__PURE__*/ React.createElement("div", null, "Loading...");
|
|
79
74
|
var ErrorFallback = function(param) {
|
|
80
75
|
var error = param.error;
|
|
81
|
-
return ErrorComponent || /*#__PURE__*/
|
|
82
|
-
children: [
|
|
83
|
-
"远程模块加载失败: ",
|
|
84
|
-
error.message
|
|
85
|
-
]
|
|
86
|
-
});
|
|
76
|
+
return ErrorComponent || /*#__PURE__*/ React.createElement("div", null, "远程模块加载失败: ", error.message);
|
|
87
77
|
};
|
|
88
78
|
if (!Component) return Loading;
|
|
89
|
-
return /*#__PURE__*/
|
|
79
|
+
return /*#__PURE__*/ React.createElement(ErrorBoundary, {
|
|
90
80
|
FallbackComponent: ErrorFallback,
|
|
91
|
-
onError: onError
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
children: children
|
|
96
|
-
}))
|
|
97
|
-
})
|
|
98
|
-
});
|
|
81
|
+
onError: onError
|
|
82
|
+
}, /*#__PURE__*/ React.createElement(React.Suspense, {
|
|
83
|
+
fallback: Loading
|
|
84
|
+
}, /*#__PURE__*/ React.createElement(Component, componentProps, children)));
|
|
99
85
|
};
|