@modern-js/plugin-garfish 1.5.2 → 1.5.3
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/dist/js/modern/cli/index.js +2 -1
- package/dist/js/modern/cli/utils.js +8 -4
- package/dist/js/modern/runtime/loadable.js +8 -1
- package/dist/js/modern/runtime/utils/MApp.js +85 -29
- package/dist/js/modern/runtime/utils/apps.js +25 -13
- package/dist/js/node/cli/index.js +2 -1
- package/dist/js/node/cli/utils.js +8 -4
- package/dist/js/node/runtime/loadable.js +8 -1
- package/dist/js/node/runtime/utils/MApp.js +85 -29
- package/dist/js/node/runtime/utils/apps.js +24 -7
- package/dist/js/treeshaking/cli/index.js +2 -1
- package/dist/js/treeshaking/cli/utils.js +2 -2
- package/dist/js/treeshaking/runtime/loadable.js +6 -1
- package/dist/js/treeshaking/runtime/utils/MApp.js +100 -39
- package/dist/js/treeshaking/runtime/utils/apps.js +31 -15
- package/dist/types/runtime/loadable.d.ts +2 -1
- package/dist/types/runtime/useModuleApps.d.ts +1 -0
- package/dist/types/runtime/utils/apps.d.ts +5 -1
- package/package.json +3 -3
- package/type.d.ts +3 -2
|
@@ -103,7 +103,8 @@ export default (({
|
|
|
103
103
|
},
|
|
104
104
|
source: {
|
|
105
105
|
alias: {
|
|
106
|
-
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
106
|
+
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath(),
|
|
107
|
+
'@modern-js/runtime/garfish': _mfPackagePath
|
|
107
108
|
}
|
|
108
109
|
},
|
|
109
110
|
tools: {
|
|
@@ -32,16 +32,20 @@ export const provider = function ({basename, dom}) {
|
|
|
32
32
|
if (typeof __GARFISH_EXPORTS__ !== 'undefined') {
|
|
33
33
|
__GARFISH_EXPORTS__.provider = provider;
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
function renderInGarfish () {
|
|
37
|
+
if (IS_BROWSER && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.length !== 0) return true;
|
|
38
|
+
if (IS_BROWSER && window.Garfish && window.Garfish.apps && Object.keys(window.Garfish.apps).length !== 0) return true;
|
|
39
|
+
if (typeof __GARFISH_EXPORTS__ !== 'undefined') return true;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
35
42
|
`;
|
|
36
43
|
export const makeRenderFunction = code => {
|
|
37
44
|
const inGarfishToRender = `
|
|
38
45
|
const { basename, props } = arguments[0] || {};
|
|
39
|
-
let renderByGarfish =
|
|
46
|
+
let renderByGarfish = renderInGarfish();
|
|
40
47
|
const renderByProvider = !!basename;
|
|
41
48
|
|
|
42
|
-
if (IS_BROWSER && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.length !== 0) renderByGarfish = true;
|
|
43
|
-
if (IS_BROWSER && window.Garfish && window.Garfish.apps && Object.keys(window.Garfish.apps).length !== 0) renderByGarfish = true;
|
|
44
|
-
if (typeof __GARFISH_EXPORTS__ !== 'undefined') renderByGarfish = true;
|
|
45
49
|
if (renderByGarfish && !renderByProvider) return null;
|
|
46
50
|
|
|
47
51
|
function RouterPlugin (routerConfig) {
|
|
@@ -144,7 +144,14 @@ export function Loadable(WrapComponent) {
|
|
|
144
144
|
style: {
|
|
145
145
|
display: showLoading ? 'none' : 'block'
|
|
146
146
|
},
|
|
147
|
-
setLoadingState: props =>
|
|
147
|
+
setLoadingState: props => {
|
|
148
|
+
// loading is not provided and there is a rendering exception
|
|
149
|
+
if (props.error && !LoadingComponent) {
|
|
150
|
+
throw props.error;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this.setStateWithMountCheck(props);
|
|
154
|
+
}
|
|
148
155
|
}, otherProps))]
|
|
149
156
|
});
|
|
150
157
|
}
|
|
@@ -51,49 +51,101 @@ export function generateMApp(options, manifest) {
|
|
|
51
51
|
const garfishOptions = _objectSpread(_objectSpread({
|
|
52
52
|
domGetter: `#${domId}`,
|
|
53
53
|
|
|
54
|
-
beforeLoad(...args) {
|
|
55
|
-
logger('MApp beforeLoad',
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
beforeLoad(appInfo, ...args) {
|
|
55
|
+
logger('MApp beforeLoad', [appInfo]);
|
|
56
|
+
|
|
57
|
+
if (appInfo.activeWhen) {
|
|
58
|
+
setLoadingState({
|
|
59
|
+
isLoading: true,
|
|
60
|
+
error: null
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad(appInfo, ...args);
|
|
61
65
|
},
|
|
62
66
|
|
|
63
|
-
beforeMount(...args) {
|
|
67
|
+
beforeMount(appInfo, ...args) {
|
|
64
68
|
logger('MApp beforeMount', args);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
|
|
70
|
+
if (appInfo.activeWhen) {
|
|
71
|
+
setLoadingState({
|
|
72
|
+
isLoading: false
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount(appInfo, ...args);
|
|
69
77
|
},
|
|
70
78
|
|
|
71
|
-
errorLoadApp(error, ...args) {
|
|
79
|
+
errorLoadApp(error, appInfo, ...args) {
|
|
72
80
|
logger('MApp errorLoadApp', error, args);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
81
|
+
|
|
82
|
+
if (appInfo.activeWhen) {
|
|
83
|
+
setLoadingState({
|
|
84
|
+
error
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp(error, appInfo, ...args);
|
|
77
89
|
},
|
|
78
90
|
|
|
79
|
-
errorMountApp(error, ...args) {
|
|
91
|
+
errorMountApp(error, appInfo, ...args) {
|
|
80
92
|
logger('MApp errorMountApp', error, args);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
93
|
+
|
|
94
|
+
if (appInfo.activeWhen) {
|
|
95
|
+
setLoadingState({
|
|
96
|
+
error
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp(error, appInfo, ...args);
|
|
85
101
|
},
|
|
86
102
|
|
|
87
|
-
errorUnmountApp(error, ...args) {
|
|
103
|
+
errorUnmountApp(error, appInfo, ...args) {
|
|
88
104
|
logger('MApp errorUnmountApp', error, args);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
105
|
+
|
|
106
|
+
if (appInfo.activeWhen) {
|
|
107
|
+
setLoadingState({
|
|
108
|
+
error
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
|
|
93
113
|
}
|
|
94
114
|
|
|
95
115
|
}, otherOptions), {}, {
|
|
96
|
-
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA']
|
|
116
|
+
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA'],
|
|
117
|
+
customLoader: provider => {
|
|
118
|
+
const {
|
|
119
|
+
render,
|
|
120
|
+
destroy,
|
|
121
|
+
SubModuleComponent,
|
|
122
|
+
jupiter_submodule_app_key
|
|
123
|
+
} = provider;
|
|
124
|
+
const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
125
|
+
return {
|
|
126
|
+
mount: (...props) => {
|
|
127
|
+
if (componetRenderMode) {
|
|
128
|
+
this.setState({
|
|
129
|
+
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
130
|
+
});
|
|
131
|
+
return undefined;
|
|
132
|
+
} else {
|
|
133
|
+
logger('MicroApp customer render', props);
|
|
134
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props);
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
|
|
138
|
+
unmount(...props) {
|
|
139
|
+
if (componetRenderMode) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
logger('MicroApp customer destroy', props);
|
|
144
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
};
|
|
148
|
+
}
|
|
97
149
|
});
|
|
98
150
|
|
|
99
151
|
logger('MApp componentDidMount', {
|
|
@@ -115,8 +167,12 @@ export function generateMApp(options, manifest) {
|
|
|
115
167
|
}
|
|
116
168
|
|
|
117
169
|
render() {
|
|
170
|
+
const {
|
|
171
|
+
SubModuleComponent
|
|
172
|
+
} = this.state;
|
|
118
173
|
return /*#__PURE__*/_jsx("div", {
|
|
119
|
-
id: generateSubAppContainerKey()
|
|
174
|
+
id: generateSubAppContainerKey(),
|
|
175
|
+
children: SubModuleComponent && /*#__PURE__*/_jsx(SubModuleComponent, {})
|
|
120
176
|
});
|
|
121
177
|
}
|
|
122
178
|
|
|
@@ -18,12 +18,7 @@ import Garfish from 'garfish';
|
|
|
18
18
|
import { withRouter } from '@modern-js/plugin-router'; // import Loadable from 'react-loadable';
|
|
19
19
|
|
|
20
20
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
21
|
-
import { Loadable } from "../loadable";
|
|
22
|
-
// render: () => void;
|
|
23
|
-
// destroy: () => void;
|
|
24
|
-
// [SUBMODULE_APP_COMPONENT_KEY]?: React.ComponentType<any>;
|
|
25
|
-
// };
|
|
26
|
-
|
|
21
|
+
import { Loadable } from "../loadable";
|
|
27
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
23
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
29
24
|
|
|
@@ -36,7 +31,8 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
36
31
|
|
|
37
32
|
_defineProperty(this, "state", {
|
|
38
33
|
appInstance: null,
|
|
39
|
-
domId: generateSubAppContainerKey(appInfo)
|
|
34
|
+
domId: generateSubAppContainerKey(appInfo),
|
|
35
|
+
SubModuleComponent: undefined
|
|
40
36
|
});
|
|
41
37
|
|
|
42
38
|
_defineProperty(this, "unregisterHistoryListener", () => {});
|
|
@@ -65,15 +61,29 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
65
61
|
customLoader: provider => {
|
|
66
62
|
const {
|
|
67
63
|
render,
|
|
68
|
-
destroy
|
|
64
|
+
destroy,
|
|
65
|
+
SubModuleComponent,
|
|
66
|
+
jupiter_submodule_app_key
|
|
69
67
|
} = provider;
|
|
68
|
+
const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
70
69
|
return {
|
|
71
|
-
mount(...props) {
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
mount: (...props) => {
|
|
71
|
+
if (componetRenderMode) {
|
|
72
|
+
this.setState({
|
|
73
|
+
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
74
|
+
});
|
|
75
|
+
return undefined;
|
|
76
|
+
} else {
|
|
77
|
+
logger('MicroApp customer render', props);
|
|
78
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props);
|
|
79
|
+
}
|
|
74
80
|
},
|
|
75
81
|
|
|
76
82
|
unmount(...props) {
|
|
83
|
+
if (componetRenderMode) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
|
|
77
87
|
logger('MicroApp customer destroy', props);
|
|
78
88
|
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props);
|
|
79
89
|
}
|
|
@@ -159,11 +169,13 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
159
169
|
|
|
160
170
|
render() {
|
|
161
171
|
const {
|
|
162
|
-
domId
|
|
172
|
+
domId,
|
|
173
|
+
SubModuleComponent
|
|
163
174
|
} = this.state;
|
|
164
175
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
165
176
|
children: /*#__PURE__*/_jsx("div", {
|
|
166
|
-
id: domId
|
|
177
|
+
id: domId,
|
|
178
|
+
children: SubModuleComponent && /*#__PURE__*/_jsx(SubModuleComponent, {})
|
|
167
179
|
})
|
|
168
180
|
});
|
|
169
181
|
}
|
|
@@ -120,7 +120,8 @@ var _default = ({
|
|
|
120
120
|
},
|
|
121
121
|
source: {
|
|
122
122
|
alias: {
|
|
123
|
-
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
123
|
+
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath(),
|
|
124
|
+
'@modern-js/runtime/garfish': _mfPackagePath
|
|
124
125
|
}
|
|
125
126
|
},
|
|
126
127
|
tools: {
|
|
@@ -41,6 +41,13 @@ export const provider = function ({basename, dom}) {
|
|
|
41
41
|
if (typeof __GARFISH_EXPORTS__ !== 'undefined') {
|
|
42
42
|
__GARFISH_EXPORTS__.provider = provider;
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
function renderInGarfish () {
|
|
46
|
+
if (IS_BROWSER && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.length !== 0) return true;
|
|
47
|
+
if (IS_BROWSER && window.Garfish && window.Garfish.apps && Object.keys(window.Garfish.apps).length !== 0) return true;
|
|
48
|
+
if (typeof __GARFISH_EXPORTS__ !== 'undefined') return true;
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
44
51
|
`;
|
|
45
52
|
|
|
46
53
|
exports.makeProvider = makeProvider;
|
|
@@ -48,12 +55,9 @@ exports.makeProvider = makeProvider;
|
|
|
48
55
|
const makeRenderFunction = code => {
|
|
49
56
|
const inGarfishToRender = `
|
|
50
57
|
const { basename, props } = arguments[0] || {};
|
|
51
|
-
let renderByGarfish =
|
|
58
|
+
let renderByGarfish = renderInGarfish();
|
|
52
59
|
const renderByProvider = !!basename;
|
|
53
60
|
|
|
54
|
-
if (IS_BROWSER && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.length !== 0) renderByGarfish = true;
|
|
55
|
-
if (IS_BROWSER && window.Garfish && window.Garfish.apps && Object.keys(window.Garfish.apps).length !== 0) renderByGarfish = true;
|
|
56
|
-
if (typeof __GARFISH_EXPORTS__ !== 'undefined') renderByGarfish = true;
|
|
57
61
|
if (renderByGarfish && !renderByProvider) return null;
|
|
58
62
|
|
|
59
63
|
function RouterPlugin (routerConfig) {
|
|
@@ -153,7 +153,14 @@ function Loadable(WrapComponent) {
|
|
|
153
153
|
style: {
|
|
154
154
|
display: showLoading ? 'none' : 'block'
|
|
155
155
|
},
|
|
156
|
-
setLoadingState: props =>
|
|
156
|
+
setLoadingState: props => {
|
|
157
|
+
// loading is not provided and there is a rendering exception
|
|
158
|
+
if (props.error && !LoadingComponent) {
|
|
159
|
+
throw props.error;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
this.setStateWithMountCheck(props);
|
|
163
|
+
}
|
|
157
164
|
}, otherProps))]
|
|
158
165
|
});
|
|
159
166
|
}
|
|
@@ -64,49 +64,101 @@ function generateMApp(options, manifest) {
|
|
|
64
64
|
const garfishOptions = _objectSpread(_objectSpread({
|
|
65
65
|
domGetter: `#${domId}`,
|
|
66
66
|
|
|
67
|
-
beforeLoad(...args) {
|
|
68
|
-
(0, _util.logger)('MApp beforeLoad',
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
beforeLoad(appInfo, ...args) {
|
|
68
|
+
(0, _util.logger)('MApp beforeLoad', [appInfo]);
|
|
69
|
+
|
|
70
|
+
if (appInfo.activeWhen) {
|
|
71
|
+
setLoadingState({
|
|
72
|
+
isLoading: true,
|
|
73
|
+
error: null
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad(appInfo, ...args);
|
|
74
78
|
},
|
|
75
79
|
|
|
76
|
-
beforeMount(...args) {
|
|
80
|
+
beforeMount(appInfo, ...args) {
|
|
77
81
|
(0, _util.logger)('MApp beforeMount', args);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
+
|
|
83
|
+
if (appInfo.activeWhen) {
|
|
84
|
+
setLoadingState({
|
|
85
|
+
isLoading: false
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount(appInfo, ...args);
|
|
82
90
|
},
|
|
83
91
|
|
|
84
|
-
errorLoadApp(error, ...args) {
|
|
92
|
+
errorLoadApp(error, appInfo, ...args) {
|
|
85
93
|
(0, _util.logger)('MApp errorLoadApp', error, args);
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
|
|
95
|
+
if (appInfo.activeWhen) {
|
|
96
|
+
setLoadingState({
|
|
97
|
+
error
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp(error, appInfo, ...args);
|
|
90
102
|
},
|
|
91
103
|
|
|
92
|
-
errorMountApp(error, ...args) {
|
|
104
|
+
errorMountApp(error, appInfo, ...args) {
|
|
93
105
|
(0, _util.logger)('MApp errorMountApp', error, args);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
106
|
+
|
|
107
|
+
if (appInfo.activeWhen) {
|
|
108
|
+
setLoadingState({
|
|
109
|
+
error
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp(error, appInfo, ...args);
|
|
98
114
|
},
|
|
99
115
|
|
|
100
|
-
errorUnmountApp(error, ...args) {
|
|
116
|
+
errorUnmountApp(error, appInfo, ...args) {
|
|
101
117
|
(0, _util.logger)('MApp errorUnmountApp', error, args);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
118
|
+
|
|
119
|
+
if (appInfo.activeWhen) {
|
|
120
|
+
setLoadingState({
|
|
121
|
+
error
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
|
|
106
126
|
}
|
|
107
127
|
|
|
108
128
|
}, otherOptions), {}, {
|
|
109
|
-
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA']
|
|
129
|
+
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA'],
|
|
130
|
+
customLoader: provider => {
|
|
131
|
+
const {
|
|
132
|
+
render,
|
|
133
|
+
destroy,
|
|
134
|
+
SubModuleComponent,
|
|
135
|
+
jupiter_submodule_app_key
|
|
136
|
+
} = provider;
|
|
137
|
+
const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
138
|
+
return {
|
|
139
|
+
mount: (...props) => {
|
|
140
|
+
if (componetRenderMode) {
|
|
141
|
+
this.setState({
|
|
142
|
+
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
143
|
+
});
|
|
144
|
+
return undefined;
|
|
145
|
+
} else {
|
|
146
|
+
(0, _util.logger)('MicroApp customer render', props);
|
|
147
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props);
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
unmount(...props) {
|
|
152
|
+
if (componetRenderMode) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
(0, _util.logger)('MicroApp customer destroy', props);
|
|
157
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
};
|
|
161
|
+
}
|
|
110
162
|
});
|
|
111
163
|
|
|
112
164
|
(0, _util.logger)('MApp componentDidMount', {
|
|
@@ -129,8 +181,12 @@ function generateMApp(options, manifest) {
|
|
|
129
181
|
}
|
|
130
182
|
|
|
131
183
|
render() {
|
|
184
|
+
const {
|
|
185
|
+
SubModuleComponent
|
|
186
|
+
} = this.state;
|
|
132
187
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
133
|
-
id: (0, _util.generateSubAppContainerKey)()
|
|
188
|
+
id: (0, _util.generateSubAppContainerKey)(),
|
|
189
|
+
children: SubModuleComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(SubModuleComponent, {})
|
|
134
190
|
});
|
|
135
191
|
}
|
|
136
192
|
|
|
@@ -42,7 +42,8 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
42
42
|
|
|
43
43
|
_defineProperty(this, "state", {
|
|
44
44
|
appInstance: null,
|
|
45
|
-
domId: (0, _util.generateSubAppContainerKey)(appInfo)
|
|
45
|
+
domId: (0, _util.generateSubAppContainerKey)(appInfo),
|
|
46
|
+
SubModuleComponent: undefined
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
_defineProperty(this, "unregisterHistoryListener", () => {});
|
|
@@ -71,15 +72,29 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
71
72
|
customLoader: provider => {
|
|
72
73
|
const {
|
|
73
74
|
render,
|
|
74
|
-
destroy
|
|
75
|
+
destroy,
|
|
76
|
+
SubModuleComponent,
|
|
77
|
+
jupiter_submodule_app_key
|
|
75
78
|
} = provider;
|
|
79
|
+
const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
76
80
|
return {
|
|
77
|
-
mount(...props) {
|
|
78
|
-
(
|
|
79
|
-
|
|
81
|
+
mount: (...props) => {
|
|
82
|
+
if (componetRenderMode) {
|
|
83
|
+
this.setState({
|
|
84
|
+
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
85
|
+
});
|
|
86
|
+
return undefined;
|
|
87
|
+
} else {
|
|
88
|
+
(0, _util.logger)('MicroApp customer render', props);
|
|
89
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props);
|
|
90
|
+
}
|
|
80
91
|
},
|
|
81
92
|
|
|
82
93
|
unmount(...props) {
|
|
94
|
+
if (componetRenderMode) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
|
|
83
98
|
(0, _util.logger)('MicroApp customer destroy', props);
|
|
84
99
|
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props);
|
|
85
100
|
}
|
|
@@ -165,11 +180,13 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
165
180
|
|
|
166
181
|
render() {
|
|
167
182
|
const {
|
|
168
|
-
domId
|
|
183
|
+
domId,
|
|
184
|
+
SubModuleComponent
|
|
169
185
|
} = this.state;
|
|
170
186
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
171
187
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
172
|
-
id: domId
|
|
188
|
+
id: domId,
|
|
189
|
+
children: SubModuleComponent && /*#__PURE__*/(0, _jsxRuntime.jsx)(SubModuleComponent, {})
|
|
173
190
|
})
|
|
174
191
|
});
|
|
175
192
|
}
|
|
@@ -115,7 +115,8 @@ export default (function () {
|
|
|
115
115
|
},
|
|
116
116
|
source: {
|
|
117
117
|
alias: {
|
|
118
|
-
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
118
|
+
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath(),
|
|
119
|
+
'@modern-js/runtime/garfish': mfPackagePath
|
|
119
120
|
}
|
|
120
121
|
},
|
|
121
122
|
tools: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export var makeProvider = function makeProvider() {
|
|
2
|
-
return "\nexport const provider = function ({basename, dom}) {\n return {\n render({basename, dom, props}) {\n const SubApp = render({ props, basename });\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n const App = function () {\n return React.createElement(SubApp, props)\n };\n bootstrap(hoistNonReactStatics(App,SubApp), node);\n },\n destroy({ dom }) {\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n\n if (node) {\n unmountComponentAtNode(node);\n }\n },\n SubModuleComponent: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n },\n jupiter_submodule_app_key: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n }\n }\n};\n\nif (typeof __GARFISH_EXPORTS__ !== 'undefined') {\n __GARFISH_EXPORTS__.provider = provider;\n}\n";
|
|
2
|
+
return "\nexport const provider = function ({basename, dom}) {\n return {\n render({basename, dom, props}) {\n const SubApp = render({ props, basename });\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n const App = function () {\n return React.createElement(SubApp, props)\n };\n bootstrap(hoistNonReactStatics(App,SubApp), node);\n },\n destroy({ dom }) {\n const node = dom.querySelector('#' + MOUNT_ID) || dom;\n\n if (node) {\n unmountComponentAtNode(node);\n }\n },\n SubModuleComponent: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n },\n jupiter_submodule_app_key: (props) => {\n const SubApp = render({props, basename});\n\n return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);\n }\n }\n};\n\nif (typeof __GARFISH_EXPORTS__ !== 'undefined') {\n __GARFISH_EXPORTS__.provider = provider;\n}\n\nfunction renderInGarfish () {\n if (IS_BROWSER && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.length !== 0) return true;\n if (IS_BROWSER && window.Garfish && window.Garfish.apps && Object.keys(window.Garfish.apps).length !== 0) return true;\n if (typeof __GARFISH_EXPORTS__ !== 'undefined') return true;\n return false;\n}\n";
|
|
3
3
|
};
|
|
4
4
|
export var makeRenderFunction = function makeRenderFunction(code) {
|
|
5
|
-
var inGarfishToRender = "\n const { basename, props } = arguments[0] || {};\n let renderByGarfish =
|
|
5
|
+
var inGarfishToRender = "\n const { basename, props } = arguments[0] || {};\n let renderByGarfish = renderInGarfish();\n const renderByProvider = !!basename;\n\n if (renderByGarfish && !renderByProvider) return null;\n\n function RouterPlugin (routerConfig) {\n if (basename) {\n routerConfig.basename = basename;\n if (routerConfig.supportHtml5History !== false) {\n if (!routerConfig.historyOptions) {\n routerConfig.historyOptions = {\n basename: basename\n };\n } else {\n routerConfig.historyOptions.basename = basename;\n }\n }\n }\n return router(routerConfig);\n }\n ";
|
|
6
6
|
return inGarfishToRender + code.replace("router(", "RouterPlugin(").replace('IS_BROWSER', "IS_BROWSER && !renderByGarfish");
|
|
7
7
|
}; // support legacy config
|
|
8
8
|
|
|
@@ -160,7 +160,12 @@ export function Loadable(WrapComponent) {
|
|
|
160
160
|
display: showLoading ? 'none' : 'block'
|
|
161
161
|
},
|
|
162
162
|
setLoadingState: function setLoadingState(props) {
|
|
163
|
-
|
|
163
|
+
// loading is not provided and there is a rendering exception
|
|
164
|
+
if (props.error && !LoadingComponent) {
|
|
165
|
+
throw props.error;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
_this3.setStateWithMountCheck(props);
|
|
164
169
|
}
|
|
165
170
|
}, otherProps))]
|
|
166
171
|
});
|
|
@@ -41,6 +41,8 @@ export function generateMApp(options, manifest) {
|
|
|
41
41
|
_createClass(MApp, [{
|
|
42
42
|
key: "componentDidMount",
|
|
43
43
|
value: function componentDidMount() {
|
|
44
|
+
var _this2 = this;
|
|
45
|
+
|
|
44
46
|
var domId = this.state.domId;
|
|
45
47
|
var setLoadingState = this.props.setLoadingState;
|
|
46
48
|
|
|
@@ -58,64 +60,121 @@ export function generateMApp(options, manifest) {
|
|
|
58
60
|
|
|
59
61
|
var garfishOptions = _objectSpread(_objectSpread({
|
|
60
62
|
domGetter: "#".concat(domId),
|
|
61
|
-
beforeLoad: function beforeLoad() {
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
beforeLoad: function beforeLoad(appInfo) {
|
|
64
|
+
logger('MApp beforeLoad', [appInfo]);
|
|
65
|
+
|
|
66
|
+
if (appInfo.activeWhen) {
|
|
67
|
+
setLoadingState({
|
|
68
|
+
isLoading: true,
|
|
69
|
+
error: null
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
74
|
+
args[_key2 - 1] = arguments[_key2];
|
|
64
75
|
}
|
|
65
76
|
|
|
66
|
-
|
|
67
|
-
setLoadingState({
|
|
68
|
-
isLoading: true,
|
|
69
|
-
error: null
|
|
70
|
-
});
|
|
71
|
-
return _beforeLoad === null || _beforeLoad === void 0 ? void 0 : _beforeLoad.apply(void 0, args);
|
|
77
|
+
return _beforeLoad === null || _beforeLoad === void 0 ? void 0 : _beforeLoad.apply(void 0, [appInfo].concat(args));
|
|
72
78
|
},
|
|
73
|
-
beforeMount: function beforeMount() {
|
|
74
|
-
for (var _len3 = arguments.length, args = new Array(_len3), _key3 =
|
|
75
|
-
args[_key3] = arguments[_key3];
|
|
79
|
+
beforeMount: function beforeMount(appInfo) {
|
|
80
|
+
for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
81
|
+
args[_key3 - 1] = arguments[_key3];
|
|
76
82
|
}
|
|
77
83
|
|
|
78
84
|
logger('MApp beforeMount', args);
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
|
|
86
|
+
if (appInfo.activeWhen) {
|
|
87
|
+
setLoadingState({
|
|
88
|
+
isLoading: false
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return _beforeMount === null || _beforeMount === void 0 ? void 0 : _beforeMount.apply(void 0, [appInfo].concat(args));
|
|
83
93
|
},
|
|
84
|
-
errorLoadApp: function errorLoadApp(error) {
|
|
85
|
-
for (var _len4 = arguments.length, args = new Array(_len4 >
|
|
86
|
-
args[_key4 -
|
|
94
|
+
errorLoadApp: function errorLoadApp(error, appInfo) {
|
|
95
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 2 ? _len4 - 2 : 0), _key4 = 2; _key4 < _len4; _key4++) {
|
|
96
|
+
args[_key4 - 2] = arguments[_key4];
|
|
87
97
|
}
|
|
88
98
|
|
|
89
99
|
logger('MApp errorLoadApp', error, args);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
|
|
101
|
+
if (appInfo.activeWhen) {
|
|
102
|
+
setLoadingState({
|
|
103
|
+
error: error
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return _errorLoadApp === null || _errorLoadApp === void 0 ? void 0 : _errorLoadApp.apply(void 0, [error, appInfo].concat(args));
|
|
94
108
|
},
|
|
95
|
-
errorMountApp: function errorMountApp(error) {
|
|
96
|
-
for (var _len5 = arguments.length, args = new Array(_len5 >
|
|
97
|
-
args[_key5 -
|
|
109
|
+
errorMountApp: function errorMountApp(error, appInfo) {
|
|
110
|
+
for (var _len5 = arguments.length, args = new Array(_len5 > 2 ? _len5 - 2 : 0), _key5 = 2; _key5 < _len5; _key5++) {
|
|
111
|
+
args[_key5 - 2] = arguments[_key5];
|
|
98
112
|
}
|
|
99
113
|
|
|
100
114
|
logger('MApp errorMountApp', error, args);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
115
|
+
|
|
116
|
+
if (appInfo.activeWhen) {
|
|
117
|
+
setLoadingState({
|
|
118
|
+
error: error
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return _errorMountApp === null || _errorMountApp === void 0 ? void 0 : _errorMountApp.apply(void 0, [error, appInfo].concat(args));
|
|
105
123
|
},
|
|
106
|
-
errorUnmountApp: function errorUnmountApp(error) {
|
|
107
|
-
for (var _len6 = arguments.length, args = new Array(_len6 >
|
|
108
|
-
args[_key6 -
|
|
124
|
+
errorUnmountApp: function errorUnmountApp(error, appInfo) {
|
|
125
|
+
for (var _len6 = arguments.length, args = new Array(_len6 > 2 ? _len6 - 2 : 0), _key6 = 2; _key6 < _len6; _key6++) {
|
|
126
|
+
args[_key6 - 2] = arguments[_key6];
|
|
109
127
|
}
|
|
110
128
|
|
|
111
129
|
logger('MApp errorUnmountApp', error, args);
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
130
|
+
|
|
131
|
+
if (appInfo.activeWhen) {
|
|
132
|
+
setLoadingState({
|
|
133
|
+
error: error
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return _errorUnmountApp === null || _errorUnmountApp === void 0 ? void 0 : _errorUnmountApp.apply(void 0, [error, appInfo].concat(args));
|
|
116
138
|
}
|
|
117
139
|
}, otherOptions), {}, {
|
|
118
|
-
insulationVariable: [].concat(_toConsumableArray(otherOptions.insulationVariable || []), ['_SERVER_DATA'])
|
|
140
|
+
insulationVariable: [].concat(_toConsumableArray(otherOptions.insulationVariable || []), ['_SERVER_DATA']),
|
|
141
|
+
customLoader: function customLoader(provider) {
|
|
142
|
+
var render = provider.render,
|
|
143
|
+
destroy = provider.destroy,
|
|
144
|
+
SubModuleComponent = provider.SubModuleComponent,
|
|
145
|
+
jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
146
|
+
var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
147
|
+
return {
|
|
148
|
+
mount: function mount() {
|
|
149
|
+
if (componetRenderMode) {
|
|
150
|
+
_this2.setState({
|
|
151
|
+
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return undefined;
|
|
155
|
+
} else {
|
|
156
|
+
for (var _len7 = arguments.length, props = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
157
|
+
props[_key7] = arguments[_key7];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
logger('MicroApp customer render', props);
|
|
161
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
unmount: function unmount() {
|
|
165
|
+
if (componetRenderMode) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
for (var _len8 = arguments.length, props = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
|
|
170
|
+
props[_key8] = arguments[_key8];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
logger('MicroApp customer destroy', props);
|
|
174
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
119
178
|
});
|
|
120
179
|
|
|
121
180
|
logger('MApp componentDidMount', {
|
|
@@ -139,8 +198,10 @@ export function generateMApp(options, manifest) {
|
|
|
139
198
|
}, {
|
|
140
199
|
key: "render",
|
|
141
200
|
value: function render() {
|
|
201
|
+
var SubModuleComponent = this.state.SubModuleComponent;
|
|
142
202
|
return /*#__PURE__*/_jsx("div", {
|
|
143
|
-
id: generateSubAppContainerKey()
|
|
203
|
+
id: generateSubAppContainerKey(),
|
|
204
|
+
children: SubModuleComponent && /*#__PURE__*/_jsx(SubModuleComponent, {})
|
|
144
205
|
});
|
|
145
206
|
}
|
|
146
207
|
}]);
|
|
@@ -18,12 +18,7 @@ import Garfish from 'garfish';
|
|
|
18
18
|
import { withRouter } from '@modern-js/plugin-router'; // import Loadable from 'react-loadable';
|
|
19
19
|
|
|
20
20
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
21
|
-
import { Loadable } from "../loadable";
|
|
22
|
-
// render: () => void;
|
|
23
|
-
// destroy: () => void;
|
|
24
|
-
// [SUBMODULE_APP_COMPONENT_KEY]?: React.ComponentType<any>;
|
|
25
|
-
// };
|
|
26
|
-
|
|
21
|
+
import { Loadable } from "../loadable";
|
|
27
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
28
23
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
29
24
|
|
|
@@ -48,7 +43,8 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
48
43
|
|
|
49
44
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
50
45
|
appInstance: null,
|
|
51
|
-
domId: generateSubAppContainerKey(appInfo)
|
|
46
|
+
domId: generateSubAppContainerKey(appInfo),
|
|
47
|
+
SubModuleComponent: undefined
|
|
52
48
|
});
|
|
53
49
|
|
|
54
50
|
_defineProperty(_assertThisInitialized(_this), "unregisterHistoryListener", function () {});
|
|
@@ -61,6 +57,8 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
61
57
|
value: // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
62
58
|
function () {
|
|
63
59
|
var _UNSAFE_componentWillMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
60
|
+
var _this2 = this;
|
|
61
|
+
|
|
64
62
|
var _this$props, match, history, setLoadingState, userProps, domId, loadAppOptions, appInstance;
|
|
65
63
|
|
|
66
64
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -77,17 +75,32 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
77
75
|
props: _objectSpread(_objectSpread({}, appInfo.props), userProps),
|
|
78
76
|
customLoader: function customLoader(provider) {
|
|
79
77
|
var render = provider.render,
|
|
80
|
-
destroy = provider.destroy
|
|
78
|
+
destroy = provider.destroy,
|
|
79
|
+
SubModuleComponent = provider.SubModuleComponent,
|
|
80
|
+
jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
81
|
+
var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
81
82
|
return {
|
|
82
83
|
mount: function mount() {
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
if (componetRenderMode) {
|
|
85
|
+
_this2.setState({
|
|
86
|
+
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
return undefined;
|
|
90
|
+
} else {
|
|
91
|
+
for (var _len2 = arguments.length, props = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
92
|
+
props[_key2] = arguments[_key2];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
logger('MicroApp customer render', props);
|
|
96
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props);
|
|
85
97
|
}
|
|
86
|
-
|
|
87
|
-
logger('MicroApp customer render', props);
|
|
88
|
-
return render === null || render === void 0 ? void 0 : render.apply(provider, props);
|
|
89
98
|
},
|
|
90
99
|
unmount: function unmount() {
|
|
100
|
+
if (componetRenderMode) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
|
|
91
104
|
for (var _len3 = arguments.length, props = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
92
105
|
props[_key3] = arguments[_key3];
|
|
93
106
|
}
|
|
@@ -229,10 +242,13 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
229
242
|
}, {
|
|
230
243
|
key: "render",
|
|
231
244
|
value: function render() {
|
|
232
|
-
var
|
|
245
|
+
var _this$state = this.state,
|
|
246
|
+
domId = _this$state.domId,
|
|
247
|
+
SubModuleComponent = _this$state.SubModuleComponent;
|
|
233
248
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
234
249
|
children: /*#__PURE__*/_jsx("div", {
|
|
235
|
-
id: domId
|
|
250
|
+
id: domId,
|
|
251
|
+
children: SubModuleComponent && /*#__PURE__*/_jsx(SubModuleComponent, {})
|
|
236
252
|
})
|
|
237
253
|
});
|
|
238
254
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { RouteComponentProps } from '@modern-js/plugin-router';
|
|
2
3
|
import { LoadableConfig, MicroComponentProps } from './useModuleApps';
|
|
3
|
-
export interface MicroProps {
|
|
4
|
+
export interface MicroProps extends RouteComponentProps {
|
|
4
5
|
setLoadingState: (state: {
|
|
5
6
|
isLoading?: boolean;
|
|
6
7
|
error?: unknown;
|
|
@@ -10,6 +10,7 @@ export declare type ModulesInfo = Array<ModuleInfo>;
|
|
|
10
10
|
export declare type Manifest = {
|
|
11
11
|
modules?: ModulesInfo;
|
|
12
12
|
loadable?: LoadableConfig;
|
|
13
|
+
componentRender?: boolean;
|
|
13
14
|
getAppList?: (info: any) => Promise<Array<GarfishInterfaces.AppInfo>>;
|
|
14
15
|
};
|
|
15
16
|
export declare type LoadingComponent = React.ComponentType<{
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import Garfish from 'garfish';
|
|
2
|
+
import Garfish, { interfaces } from 'garfish';
|
|
3
3
|
import { Manifest, MicroComponentProps, ModulesInfo } from '../useModuleApps';
|
|
4
|
+
export interface Provider extends interfaces.Provider {
|
|
5
|
+
SubModuleComponent?: React.ComponentType<any>;
|
|
6
|
+
jupiter_submodule_app_key?: React.ComponentType<any>;
|
|
7
|
+
}
|
|
4
8
|
export interface AppMap {
|
|
5
9
|
[key: string]: React.FC<MicroComponentProps>;
|
|
6
10
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.5.
|
|
14
|
+
"version": "1.5.3",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/runtime/index.d.ts",
|
|
17
17
|
"typesVersions": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/debug": "^4.1.7",
|
|
55
55
|
"@types/react-loadable": "^5.5.6",
|
|
56
56
|
"debug": "^4.3.2",
|
|
57
|
-
"garfish": "^1.
|
|
57
|
+
"garfish": "^1.8.1",
|
|
58
58
|
"hoist-non-react-statics": "^3.3.2",
|
|
59
59
|
"react-loadable": "^5.5.0"
|
|
60
60
|
},
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@modern-js/core": "1.11.2",
|
|
71
71
|
"@modern-js/plugin-router": "1.2.15",
|
|
72
|
-
"@modern-js/runtime-core": "1.4.
|
|
72
|
+
"@modern-js/runtime-core": "1.4.10",
|
|
73
73
|
"@modern-js/types": "1.5.4",
|
|
74
74
|
"@scripts/build": "0.0.0",
|
|
75
75
|
"@scripts/jest-config": "0.0.0",
|
package/type.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
declare module '@modern-js/runtime' {
|
|
1
|
+
declare module '@modern-js/runtime/garfish' {
|
|
2
2
|
export const useModuleApp: typeof import('./dist/types/runtime').useModuleApp;
|
|
3
3
|
export const useModuleApps: typeof import('./dist/types/runtime').useModuleApps;
|
|
4
|
-
export const
|
|
4
|
+
export const Garfish: typeof import('./dist/types/runtime').Garfish;
|
|
5
|
+
export const garfish: typeof import('./dist/types/runtime').garfish;
|
|
5
6
|
}
|