@modern-js/plugin-garfish 2.0.0-beta.3 → 2.0.0-beta.5
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 +67 -0
- package/dist/js/modern/cli/index.js +167 -157
- package/dist/js/modern/cli/types.js +0 -0
- package/dist/js/modern/cli/utils.js +31 -23
- package/dist/js/modern/global.d.js +0 -0
- package/dist/js/modern/index.js +5 -2
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/modern/runtime/global.d.js +0 -0
- package/dist/js/modern/runtime/index.js +12 -4
- package/dist/js/modern/runtime/loadable.js +74 -56
- package/dist/js/modern/runtime/plugin.js +114 -79
- package/dist/js/modern/runtime/useModuleApps.js +40 -26
- package/dist/js/modern/runtime/utils/Context.js +6 -3
- package/dist/js/modern/runtime/utils/MApp.js +76 -72
- package/dist/js/modern/runtime/utils/apps.js +181 -132
- package/dist/js/modern/runtime/utils/setExternal.js +11 -11
- package/dist/js/modern/util.js +11 -9
- package/dist/js/node/cli/index.js +191 -169
- package/dist/js/node/cli/types.js +0 -0
- package/dist/js/node/cli/utils.js +53 -30
- package/dist/js/node/global.d.js +0 -0
- package/dist/js/node/index.js +31 -24
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/node/runtime/global.d.js +0 -0
- package/dist/js/node/runtime/index.js +42 -43
- package/dist/js/node/runtime/loadable.js +97 -61
- package/dist/js/node/runtime/plugin.js +147 -95
- package/dist/js/node/runtime/useModuleApps.js +67 -34
- package/dist/js/node/runtime/utils/Context.js +35 -10
- package/dist/js/node/runtime/utils/MApp.js +109 -84
- package/dist/js/node/runtime/utils/apps.js +210 -135
- package/dist/js/node/runtime/utils/setExternal.js +37 -18
- package/dist/js/node/util.js +40 -19
- package/dist/js/treeshaking/cli/index.js +403 -284
- package/dist/js/treeshaking/cli/types.js +1 -0
- package/dist/js/treeshaking/cli/utils.js +28 -31
- package/dist/js/treeshaking/global.d.js +1 -0
- package/dist/js/treeshaking/index.js +3 -2
- package/dist/js/treeshaking/modern-app.env.d.js +1 -0
- package/dist/js/treeshaking/runtime/global.d.js +1 -0
- package/dist/js/treeshaking/runtime/index.js +5 -4
- package/dist/js/treeshaking/runtime/loadable.js +230 -109
- package/dist/js/treeshaking/runtime/plugin.js +469 -168
- package/dist/js/treeshaking/runtime/useModuleApps.js +55 -31
- package/dist/js/treeshaking/runtime/utils/Context.js +3 -3
- package/dist/js/treeshaking/runtime/utils/MApp.js +348 -180
- package/dist/js/treeshaking/runtime/utils/apps.js +472 -224
- package/dist/js/treeshaking/runtime/utils/setExternal.js +12 -11
- package/dist/js/treeshaking/util.js +7 -9
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/types.d.ts +6 -0
- package/dist/types/runtime/index.d.ts +1 -1
- package/dist/types/runtime/loadable.d.ts +1 -2
- package/dist/types/runtime/plugin.d.ts +2 -0
- package/dist/types/runtime/utils/apps.d.ts +1 -0
- package/dist/types/runtime/utils/setExternal.d.ts +1 -0
- package/package.json +25 -20
- package/type.d.ts +5 -6
|
@@ -1,30 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __objRest = (source, exclude) => {
|
|
18
|
+
var target = {};
|
|
19
|
+
for (var prop in source)
|
|
20
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
21
|
+
target[prop] = source[prop];
|
|
22
|
+
if (source != null && __getOwnPropSymbols)
|
|
23
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
24
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
import { jsx } from "react/jsx-runtime";
|
|
30
|
+
import React from "react";
|
|
31
|
+
import Garfish from "garfish";
|
|
10
32
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
11
33
|
import { Loadable } from "../loadable";
|
|
12
|
-
|
|
13
|
-
export function generateMApp(options, manifest) {
|
|
34
|
+
function generateMApp(options, manifest) {
|
|
14
35
|
class MApp extends React.Component {
|
|
15
|
-
constructor(
|
|
16
|
-
super(...
|
|
17
|
-
|
|
36
|
+
constructor() {
|
|
37
|
+
super(...arguments);
|
|
38
|
+
this.state = {
|
|
18
39
|
domId: generateSubAppContainerKey()
|
|
19
|
-
}
|
|
40
|
+
};
|
|
20
41
|
}
|
|
21
42
|
componentDidMount() {
|
|
22
|
-
const {
|
|
23
|
-
|
|
24
|
-
} = this.state;
|
|
25
|
-
const {
|
|
26
|
-
setLoadingState
|
|
27
|
-
} = this.props;
|
|
43
|
+
const { domId } = this.state;
|
|
44
|
+
const { setLoadingState } = this.props;
|
|
28
45
|
const {
|
|
29
46
|
beforeLoad,
|
|
30
47
|
beforeMount,
|
|
@@ -32,94 +49,90 @@ export function generateMApp(options, manifest) {
|
|
|
32
49
|
errorMountApp,
|
|
33
50
|
errorUnmountApp
|
|
34
51
|
} = options;
|
|
35
|
-
|
|
36
|
-
// start auto render able
|
|
37
|
-
Garfish.router.setRouterConfig({
|
|
38
|
-
listening: true
|
|
39
|
-
});
|
|
52
|
+
Garfish.router.setRouterConfig({ listening: true });
|
|
40
53
|
const garfishOptions = {
|
|
41
54
|
domGetter: `#${domId}`,
|
|
42
55
|
beforeLoad(appInfo, ...args) {
|
|
43
|
-
logger(
|
|
56
|
+
logger("MApp beforeLoad", [appInfo]);
|
|
44
57
|
if (appInfo.activeWhen) {
|
|
45
58
|
setLoadingState({
|
|
46
59
|
isLoading: true,
|
|
47
60
|
error: null
|
|
48
61
|
});
|
|
49
62
|
}
|
|
50
|
-
return beforeLoad
|
|
63
|
+
return beforeLoad == null ? void 0 : beforeLoad(appInfo, ...args);
|
|
51
64
|
},
|
|
52
65
|
beforeMount(appInfo, ...args) {
|
|
53
|
-
logger(
|
|
66
|
+
logger("MApp beforeMount", args);
|
|
54
67
|
if (appInfo.activeWhen) {
|
|
55
68
|
setLoadingState({
|
|
56
69
|
isLoading: false
|
|
57
70
|
});
|
|
58
71
|
}
|
|
59
|
-
return beforeMount
|
|
72
|
+
return beforeMount == null ? void 0 : beforeMount(appInfo, ...args);
|
|
60
73
|
},
|
|
61
74
|
errorLoadApp(error, appInfo, ...args) {
|
|
62
|
-
logger(
|
|
75
|
+
logger("MApp errorLoadApp", error, args);
|
|
63
76
|
if (appInfo.activeWhen) {
|
|
64
77
|
setLoadingState({
|
|
65
78
|
error
|
|
66
79
|
});
|
|
67
80
|
}
|
|
68
|
-
return errorLoadApp
|
|
81
|
+
return errorLoadApp == null ? void 0 : errorLoadApp(error, appInfo, ...args);
|
|
69
82
|
},
|
|
70
83
|
errorMountApp(error, appInfo, ...args) {
|
|
71
|
-
logger(
|
|
84
|
+
logger("MApp errorMountApp", error, args);
|
|
72
85
|
if (appInfo.activeWhen) {
|
|
73
86
|
setLoadingState({
|
|
74
87
|
error
|
|
75
88
|
});
|
|
76
89
|
}
|
|
77
|
-
return errorMountApp
|
|
90
|
+
return errorMountApp == null ? void 0 : errorMountApp(error, appInfo, ...args);
|
|
78
91
|
},
|
|
79
92
|
errorUnmountApp(error, appInfo, ...args) {
|
|
80
|
-
logger(
|
|
93
|
+
logger("MApp errorUnmountApp", error, args);
|
|
81
94
|
if (appInfo.activeWhen) {
|
|
82
95
|
setLoadingState({
|
|
83
96
|
error
|
|
84
97
|
});
|
|
85
98
|
}
|
|
86
|
-
return errorUnmountApp
|
|
99
|
+
return errorUnmountApp == null ? void 0 : errorUnmountApp(error, appInfo, ...args);
|
|
87
100
|
},
|
|
88
|
-
customLoader: provider => {
|
|
101
|
+
customLoader: (provider) => {
|
|
89
102
|
const {
|
|
90
103
|
render,
|
|
91
104
|
destroy,
|
|
92
105
|
SubModuleComponent,
|
|
93
106
|
jupiter_submodule_app_key
|
|
94
107
|
} = provider;
|
|
95
|
-
const componetRenderMode = (manifest
|
|
108
|
+
const componetRenderMode = (manifest == null ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
96
109
|
return {
|
|
97
|
-
mount: appInfo => {
|
|
110
|
+
mount: (appInfo) => {
|
|
98
111
|
const transferProps = this.filterTransferProps();
|
|
99
|
-
appInfo.props =
|
|
112
|
+
appInfo.props = __spreadValues(__spreadValues({}, appInfo.props), transferProps);
|
|
100
113
|
if (componetRenderMode) {
|
|
101
114
|
this.setState({
|
|
102
|
-
SubModuleComponent: SubModuleComponent
|
|
115
|
+
SubModuleComponent: SubModuleComponent != null ? SubModuleComponent : jupiter_submodule_app_key
|
|
103
116
|
});
|
|
104
|
-
return
|
|
117
|
+
return void 0;
|
|
105
118
|
} else {
|
|
106
|
-
logger(
|
|
107
|
-
return render
|
|
119
|
+
logger("MicroApp customer render", appInfo);
|
|
120
|
+
return render == null ? void 0 : render.apply(provider, [appInfo]);
|
|
108
121
|
}
|
|
109
122
|
},
|
|
110
|
-
unmount: appInfo => {
|
|
123
|
+
unmount: (appInfo) => {
|
|
111
124
|
const transferProps = this.filterTransferProps();
|
|
112
|
-
appInfo.props =
|
|
125
|
+
appInfo.props = __spreadValues(__spreadValues({}, appInfo.props), transferProps);
|
|
113
126
|
if (componetRenderMode) {
|
|
114
|
-
return
|
|
127
|
+
return void 0;
|
|
115
128
|
}
|
|
116
|
-
logger(
|
|
117
|
-
return destroy
|
|
129
|
+
logger("MicroApp customer destroy", appInfo);
|
|
130
|
+
return destroy == null ? void 0 : destroy.apply(provider, [appInfo]);
|
|
118
131
|
}
|
|
119
132
|
};
|
|
120
133
|
}
|
|
121
134
|
};
|
|
122
|
-
logger(
|
|
135
|
+
logger("MApp componentDidMount", {
|
|
123
136
|
garfishRunning: Garfish.running,
|
|
124
137
|
garfishOptions
|
|
125
138
|
});
|
|
@@ -128,34 +141,25 @@ export function generateMApp(options, manifest) {
|
|
|
128
141
|
}
|
|
129
142
|
}
|
|
130
143
|
componentWillUnmount() {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
listening: false
|
|
134
|
-
});
|
|
135
|
-
logger('MApp componentWillUnmount');
|
|
144
|
+
Garfish.router.setRouterConfig({ listening: false });
|
|
145
|
+
logger("MApp componentWillUnmount");
|
|
136
146
|
}
|
|
137
147
|
filterTransferProps() {
|
|
138
|
-
const
|
|
139
|
-
{
|
|
140
|
-
style,
|
|
141
|
-
setLoadingState
|
|
142
|
-
} = _this$props,
|
|
143
|
-
others = _objectWithoutProperties(_this$props, _excluded);
|
|
148
|
+
const _a = this.props, { style, setLoadingState } = _a, others = __objRest(_a, ["style", "setLoadingState"]);
|
|
144
149
|
return others;
|
|
145
150
|
}
|
|
146
151
|
render() {
|
|
147
|
-
const {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
SubModuleComponent
|
|
152
|
-
} = this.state;
|
|
153
|
-
return /*#__PURE__*/_jsx("div", {
|
|
154
|
-
style: _objectSpread({}, style),
|
|
152
|
+
const { style } = this.props;
|
|
153
|
+
const { SubModuleComponent } = this.state;
|
|
154
|
+
return /* @__PURE__ */ jsx("div", {
|
|
155
|
+
style: __spreadValues({}, style),
|
|
155
156
|
id: generateSubAppContainerKey(),
|
|
156
|
-
children: SubModuleComponent &&
|
|
157
|
+
children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {})
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
160
|
}
|
|
160
|
-
return Loadable(MApp)(manifest
|
|
161
|
-
}
|
|
161
|
+
return Loadable(MApp)(manifest == null ? void 0 : manifest.loadable);
|
|
162
|
+
}
|
|
163
|
+
export {
|
|
164
|
+
generateMApp
|
|
165
|
+
};
|
|
@@ -1,76 +1,138 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __async = (__this, __arguments, generator) => {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
var fulfilled = (value) => {
|
|
35
|
+
try {
|
|
36
|
+
step(generator.next(value));
|
|
37
|
+
} catch (e) {
|
|
38
|
+
reject(e);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var rejected = (value) => {
|
|
42
|
+
try {
|
|
43
|
+
step(generator.throw(value));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
reject(e);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
49
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
import { Fragment, jsx } from "react/jsx-runtime";
|
|
53
|
+
import { useContext, useState, useEffect, useRef } from "react";
|
|
54
|
+
import { RuntimeReactContext } from "@modern-js/runtime";
|
|
55
|
+
import Garfish from "garfish";
|
|
15
56
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
16
57
|
import { Loadable } from "../loadable";
|
|
17
|
-
|
|
18
|
-
|
|
58
|
+
function pathJoin(...args) {
|
|
59
|
+
const res = args.reduce((res2, path) => {
|
|
60
|
+
let nPath = path;
|
|
61
|
+
if (!nPath || typeof nPath !== "string") {
|
|
62
|
+
return res2;
|
|
63
|
+
}
|
|
64
|
+
if (nPath[0] !== "/") {
|
|
65
|
+
nPath = `/${nPath}`;
|
|
66
|
+
}
|
|
67
|
+
const lastIndex = path.length - 1;
|
|
68
|
+
if (nPath[lastIndex] === "/") {
|
|
69
|
+
nPath = nPath.substring(0, lastIndex);
|
|
70
|
+
}
|
|
71
|
+
return res2 + nPath;
|
|
72
|
+
}, "");
|
|
73
|
+
return res || "/";
|
|
74
|
+
}
|
|
19
75
|
function getAppInstance(options, appInfo, manifest) {
|
|
20
|
-
let locationHref =
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
76
|
+
let locationHref = "";
|
|
77
|
+
function MicroApp(props) {
|
|
78
|
+
var _a, _b, _c, _d, _e, _f;
|
|
79
|
+
const appRef = useRef(null);
|
|
80
|
+
const domId = generateSubAppContainerKey(appInfo);
|
|
81
|
+
const [SubModuleComponent, setSubModuleComponent] = useState();
|
|
82
|
+
const context = useContext(RuntimeReactContext);
|
|
83
|
+
const match = (_b = (_a = context == null ? void 0 : context.router) == null ? void 0 : _a.useRouteMatch) == null ? void 0 : _b.call(_a);
|
|
84
|
+
const matchs = (_d = (_c = context == null ? void 0 : context.router) == null ? void 0 : _c.useMatches) == null ? void 0 : _d.call(_c);
|
|
85
|
+
const location = (_f = (_e = context == null ? void 0 : context.router) == null ? void 0 : _e.useLocation) == null ? void 0 : _f.call(_e);
|
|
86
|
+
let basename = (options == null ? void 0 : options.basename) || "/";
|
|
87
|
+
if (matchs && matchs.length > 0) {
|
|
88
|
+
basename = pathJoin(basename, matchs[matchs.length - 1].pathname || "/");
|
|
89
|
+
} else if (match) {
|
|
90
|
+
basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
|
|
30
91
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} =
|
|
42
|
-
const loadAppOptions =
|
|
43
|
-
insulationVariable: [
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (location && locationHref !== location.pathname) {
|
|
94
|
+
locationHref = location.pathname;
|
|
95
|
+
const popStateEvent = new PopStateEvent("popstate");
|
|
96
|
+
popStateEvent.garfish = true;
|
|
97
|
+
dispatchEvent(popStateEvent);
|
|
98
|
+
logger(`MicroApp Garfish.loadApp popstate`);
|
|
99
|
+
}
|
|
100
|
+
}, [location]);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
const _a2 = props, { setLoadingState } = _a2, userProps = __objRest(_a2, ["setLoadingState"]);
|
|
103
|
+
const loadAppOptions = __spreadProps(__spreadValues({}, appInfo), {
|
|
104
|
+
insulationVariable: [
|
|
105
|
+
...appInfo.insulationVariable || [],
|
|
106
|
+
"_SERVER_DATA"
|
|
107
|
+
],
|
|
44
108
|
domGetter: `#${domId}`,
|
|
45
|
-
basename
|
|
109
|
+
basename,
|
|
46
110
|
cache: true,
|
|
47
|
-
props:
|
|
48
|
-
customLoader: provider => {
|
|
111
|
+
props: __spreadValues(__spreadValues({}, appInfo.props), userProps),
|
|
112
|
+
customLoader: (provider) => {
|
|
49
113
|
const {
|
|
50
114
|
render,
|
|
51
115
|
destroy,
|
|
52
|
-
SubModuleComponent,
|
|
116
|
+
SubModuleComponent: SubModuleComponent2,
|
|
53
117
|
jupiter_submodule_app_key
|
|
54
118
|
} = provider;
|
|
55
|
-
const componetRenderMode = (manifest
|
|
119
|
+
const componetRenderMode = (manifest == null ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
|
|
56
120
|
return {
|
|
57
|
-
mount: (...
|
|
121
|
+
mount: (...props2) => {
|
|
58
122
|
if (componetRenderMode) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
});
|
|
62
|
-
return undefined;
|
|
123
|
+
setSubModuleComponent(SubModuleComponent2);
|
|
124
|
+
return void 0;
|
|
63
125
|
} else {
|
|
64
|
-
logger(
|
|
65
|
-
return render
|
|
126
|
+
logger("MicroApp customer render", props2);
|
|
127
|
+
return render == null ? void 0 : render.apply(provider, props2);
|
|
66
128
|
}
|
|
67
129
|
},
|
|
68
|
-
unmount(...
|
|
130
|
+
unmount(...props2) {
|
|
69
131
|
if (componetRenderMode) {
|
|
70
|
-
return
|
|
132
|
+
return void 0;
|
|
71
133
|
}
|
|
72
|
-
logger(
|
|
73
|
-
return destroy
|
|
134
|
+
logger("MicroApp customer destroy", props2);
|
|
135
|
+
return destroy == null ? void 0 : destroy.apply(provider, props2);
|
|
74
136
|
}
|
|
75
137
|
};
|
|
76
138
|
}
|
|
@@ -82,91 +144,78 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
82
144
|
logger(`MicroApp Garfish.loadApp "${appInfo.name}"`, {
|
|
83
145
|
loadAppOptions
|
|
84
146
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
appInstance
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
147
|
+
function renderApp() {
|
|
148
|
+
return __async(this, null, function* () {
|
|
149
|
+
try {
|
|
150
|
+
const appInstance = yield Garfish.loadApp(
|
|
151
|
+
appInfo.name,
|
|
152
|
+
loadAppOptions
|
|
153
|
+
);
|
|
154
|
+
if (!appInstance) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
`MicroApp Garfish.loadApp "${appInfo.name}" result is null`
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
appRef.current = appInstance;
|
|
160
|
+
setLoadingState({
|
|
161
|
+
isLoading: false
|
|
162
|
+
});
|
|
163
|
+
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
164
|
+
logger(`MicroApp Garfish.loadApp "${appInfo.name}" show`, {
|
|
165
|
+
appInfo: appInstance.appInfo,
|
|
166
|
+
appInstance
|
|
167
|
+
});
|
|
168
|
+
yield appInstance == null ? void 0 : appInstance.show();
|
|
169
|
+
} else {
|
|
170
|
+
logger(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
|
|
171
|
+
appInfo: appInstance.appInfo,
|
|
172
|
+
appInstance
|
|
173
|
+
});
|
|
174
|
+
yield appInstance == null ? void 0 : appInstance.mount();
|
|
175
|
+
}
|
|
176
|
+
} catch (error) {
|
|
177
|
+
setLoadingState({
|
|
178
|
+
isLoading: true,
|
|
179
|
+
error
|
|
180
|
+
});
|
|
117
181
|
}
|
|
118
182
|
});
|
|
119
|
-
} catch (error) {
|
|
120
|
-
setLoadingState({
|
|
121
|
-
isLoading: true,
|
|
122
|
-
error
|
|
123
|
-
});
|
|
124
183
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
logger(`MicroApp Garfish.loadApp "${appInfo.name}" hide`);
|
|
138
|
-
appInstance === null || appInstance === void 0 ? void 0 : appInstance.hide();
|
|
139
|
-
} else {
|
|
140
|
-
logger(`MicroApp Garfish.loadApp "${appInfo.name}" unmount`);
|
|
141
|
-
appInstance === null || appInstance === void 0 ? void 0 : appInstance.unmount();
|
|
184
|
+
renderApp();
|
|
185
|
+
return () => {
|
|
186
|
+
var _a3, _b2;
|
|
187
|
+
if (appRef.current) {
|
|
188
|
+
const { appInfo: appInfo2 } = appRef.current;
|
|
189
|
+
if (appInfo2.cache) {
|
|
190
|
+
logger(`MicroApp Garfish.loadApp "${appInfo2.name}" hide`);
|
|
191
|
+
(_a3 = appRef.current) == null ? void 0 : _a3.hide();
|
|
192
|
+
} else {
|
|
193
|
+
logger(`MicroApp Garfish.loadApp "${appInfo2.name}" unmount`);
|
|
194
|
+
(_b2 = appRef.current) == null ? void 0 : _b2.unmount();
|
|
195
|
+
}
|
|
142
196
|
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
domId,
|
|
148
|
-
SubModuleComponent
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
152
|
-
id: domId,
|
|
153
|
-
children: SubModuleComponent && /*#__PURE__*/_jsx(SubModuleComponent, {})
|
|
154
|
-
})
|
|
155
|
-
});
|
|
156
|
-
}
|
|
197
|
+
};
|
|
198
|
+
}, []);
|
|
199
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
200
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
201
|
+
id: domId,
|
|
202
|
+
children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {})
|
|
203
|
+
})
|
|
204
|
+
});
|
|
157
205
|
}
|
|
158
|
-
return Loadable(
|
|
206
|
+
return Loadable(MicroApp)(manifest == null ? void 0 : manifest.loadable);
|
|
159
207
|
}
|
|
160
|
-
|
|
161
|
-
var
|
|
208
|
+
function generateApps(options, manifest) {
|
|
209
|
+
var _a;
|
|
162
210
|
const apps = {};
|
|
163
|
-
(
|
|
211
|
+
(_a = options.apps) == null ? void 0 : _a.forEach((appInfo) => {
|
|
164
212
|
const Component = getAppInstance(options, appInfo, manifest);
|
|
165
213
|
appInfo.Component = Component;
|
|
166
214
|
apps[appInfo.name] = Component;
|
|
167
215
|
});
|
|
168
|
-
return {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
216
|
+
return { apps, appInfoList: options.apps || [] };
|
|
217
|
+
}
|
|
218
|
+
export {
|
|
219
|
+
generateApps,
|
|
220
|
+
pathJoin
|
|
221
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import ReactDOM from
|
|
3
|
-
import garfish from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import ReactDOM from "react-dom";
|
|
3
|
+
import garfish from "garfish";
|
|
4
4
|
import { logger } from "../../util";
|
|
5
|
-
|
|
6
|
-
logger(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
5
|
+
var setExternal_default = () => {
|
|
6
|
+
logger("setExternal ", { react: React, "react-dom": ReactDOM });
|
|
7
|
+
garfish.setExternal("react", React);
|
|
8
|
+
garfish.setExternal("react-dom", ReactDOM);
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
setExternal_default as default
|
|
12
|
+
};
|
package/dist/js/modern/util.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import createDebug from "debug";
|
|
2
|
+
const logger = createDebug("modern-js:plugin-garfish");
|
|
3
|
+
const SUBMODULE_APP_COMPONENT_KEY = "SubModuleComponent";
|
|
4
|
+
function generateSubAppContainerKey(moduleInfo) {
|
|
5
|
+
return moduleInfo ? `modern_sub_app_container_${decodeURIComponent(moduleInfo == null ? void 0 : moduleInfo.name)}` : "modern_sub_app_container";
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
SUBMODULE_APP_COMPONENT_KEY,
|
|
9
|
+
generateSubAppContainerKey,
|
|
10
|
+
logger
|
|
11
|
+
};
|