@modern-js/plugin-garfish 2.0.0-beta.2 → 2.0.0-beta.4
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 +125 -0
- package/dist/js/modern/cli/index.js +164 -158
- 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 +177 -142
- package/dist/js/modern/runtime/utils/setExternal.js +11 -11
- package/dist/js/modern/type.d.js +0 -0
- package/dist/js/modern/util.js +11 -9
- package/dist/js/node/cli/index.js +184 -169
- package/dist/js/node/cli/utils.js +45 -30
- package/dist/js/node/global.d.js +0 -0
- package/dist/js/node/index.js +29 -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 +35 -44
- package/dist/js/node/runtime/loadable.js +95 -61
- package/dist/js/node/runtime/plugin.js +147 -95
- package/dist/js/node/runtime/useModuleApps.js +64 -34
- package/dist/js/node/runtime/utils/Context.js +30 -10
- package/dist/js/node/runtime/utils/MApp.js +107 -84
- package/dist/js/node/runtime/utils/apps.js +204 -146
- package/dist/js/node/runtime/utils/setExternal.js +35 -18
- package/dist/js/node/type.d.js +0 -0
- package/dist/js/node/util.js +34 -19
- package/dist/js/treeshaking/cli/index.js +402 -285
- 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 +536 -230
- package/dist/js/treeshaking/runtime/utils/setExternal.js +12 -11
- package/dist/js/treeshaking/type.d.js +1 -0
- package/dist/js/treeshaking/util.js +7 -9
- package/dist/types/cli/index.d.ts +2 -0
- package/dist/types/runtime/plugin.d.ts +2 -0
- package/dist/types/runtime/utils/setExternal.d.ts +1 -0
- package/package.json +11 -11
|
@@ -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,172 +1,207 @@
|
|
|
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 path from "path";
|
|
54
|
+
import React from "react";
|
|
55
|
+
import Garfish from "garfish";
|
|
56
|
+
import { withRouter } from "@modern-js/plugin-router-legacy";
|
|
15
57
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
16
58
|
import { Loadable } from "../loadable";
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
59
|
function getAppInstance(options, appInfo, manifest) {
|
|
20
|
-
let locationHref =
|
|
60
|
+
let locationHref = "";
|
|
21
61
|
class MicroApp extends React.Component {
|
|
22
|
-
constructor(
|
|
23
|
-
super(...
|
|
24
|
-
|
|
62
|
+
constructor() {
|
|
63
|
+
super(...arguments);
|
|
64
|
+
this.state = {
|
|
25
65
|
appInstance: null,
|
|
26
66
|
domId: generateSubAppContainerKey(appInfo),
|
|
27
|
-
SubModuleComponent:
|
|
28
|
-
}
|
|
29
|
-
|
|
67
|
+
SubModuleComponent: void 0
|
|
68
|
+
};
|
|
69
|
+
this.unregisterHistoryListener = () => {
|
|
70
|
+
};
|
|
30
71
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return undefined;
|
|
72
|
+
componentDidMount() {
|
|
73
|
+
return __async(this, null, function* () {
|
|
74
|
+
const _a = this.props, { match, history, setLoadingState } = _a, userProps = __objRest(_a, ["match", "history", "setLoadingState"]);
|
|
75
|
+
const { domId } = this.state;
|
|
76
|
+
const loadAppOptions = __spreadProps(__spreadValues({}, appInfo), {
|
|
77
|
+
insulationVariable: [
|
|
78
|
+
...appInfo.insulationVariable || [],
|
|
79
|
+
"_SERVER_DATA"
|
|
80
|
+
],
|
|
81
|
+
domGetter: `#${domId}`,
|
|
82
|
+
basename: path.join((options == null ? void 0 : options.basename) || "/", (match == null ? void 0 : match.path) || "/"),
|
|
83
|
+
cache: true,
|
|
84
|
+
props: __spreadValues(__spreadValues({}, appInfo.props), userProps),
|
|
85
|
+
customLoader: (provider) => {
|
|
86
|
+
const {
|
|
87
|
+
render,
|
|
88
|
+
destroy,
|
|
89
|
+
SubModuleComponent,
|
|
90
|
+
jupiter_submodule_app_key
|
|
91
|
+
} = provider;
|
|
92
|
+
const componetRenderMode = (manifest == null ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
93
|
+
return {
|
|
94
|
+
mount: (...props) => {
|
|
95
|
+
if (componetRenderMode) {
|
|
96
|
+
this.setState({
|
|
97
|
+
SubModuleComponent: SubModuleComponent != null ? SubModuleComponent : jupiter_submodule_app_key
|
|
98
|
+
});
|
|
99
|
+
return void 0;
|
|
100
|
+
} else {
|
|
101
|
+
logger("MicroApp customer render", props);
|
|
102
|
+
return render == null ? void 0 : render.apply(provider, props);
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
unmount(...props) {
|
|
106
|
+
if (componetRenderMode) {
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
logger("MicroApp customer destroy", props);
|
|
110
|
+
return destroy == null ? void 0 : destroy.apply(provider, props);
|
|
71
111
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
setLoadingState({
|
|
79
|
-
isLoading: true,
|
|
80
|
-
error: null
|
|
81
|
-
});
|
|
82
|
-
logger(`MicroApp Garfish.loadApp "${appInfo.name}"`, {
|
|
83
|
-
loadAppOptions
|
|
84
|
-
});
|
|
85
|
-
try {
|
|
86
|
-
const appInstance = await Garfish.loadApp(appInfo.name, loadAppOptions);
|
|
87
|
-
if (!appInstance) {
|
|
88
|
-
throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// eslint-disable-next-line react/no-did-mount-set-state
|
|
92
|
-
this.setState({
|
|
93
|
-
appInstance
|
|
112
|
+
};
|
|
113
|
+
}
|
|
94
114
|
});
|
|
95
115
|
setLoadingState({
|
|
96
|
-
isLoading:
|
|
116
|
+
isLoading: true,
|
|
117
|
+
error: null
|
|
97
118
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
logger(`MicroApp Garfish.loadApp "${appInfo.name}"`, {
|
|
120
|
+
loadAppOptions
|
|
121
|
+
});
|
|
122
|
+
try {
|
|
123
|
+
const appInstance = yield Garfish.loadApp(appInfo.name, loadAppOptions);
|
|
124
|
+
if (!appInstance) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
`MicroApp Garfish.loadApp "${appInfo.name}" result is null`
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
this.setState({
|
|
101
130
|
appInstance
|
|
102
131
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
logger(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
|
|
106
|
-
appInfo: appInstance.appInfo,
|
|
107
|
-
appInstance
|
|
132
|
+
setLoadingState({
|
|
133
|
+
isLoading: false
|
|
108
134
|
});
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
logger(`MicroApp Garfish.loadApp
|
|
135
|
+
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
136
|
+
logger(`MicroApp Garfish.loadApp "${appInfo.name}" show`, {
|
|
137
|
+
appInfo: appInstance.appInfo,
|
|
138
|
+
appInstance
|
|
139
|
+
});
|
|
140
|
+
yield appInstance == null ? void 0 : appInstance.show();
|
|
141
|
+
} else {
|
|
142
|
+
logger(`MicroApp Garfish.loadApp "${appInfo.name}" mount`, {
|
|
143
|
+
appInfo: appInstance.appInfo,
|
|
144
|
+
appInstance
|
|
145
|
+
});
|
|
146
|
+
yield appInstance == null ? void 0 : appInstance.mount();
|
|
117
147
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
148
|
+
this.unregisterHistoryListener = history == null ? void 0 : history.listen(() => {
|
|
149
|
+
if (locationHref !== history.location.pathname) {
|
|
150
|
+
locationHref = history.location.pathname;
|
|
151
|
+
const popStateEvent = new PopStateEvent("popstate");
|
|
152
|
+
dispatchEvent(popStateEvent);
|
|
153
|
+
logger(`MicroApp Garfish.loadApp popstate`);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
} catch (error) {
|
|
157
|
+
setLoadingState({
|
|
158
|
+
isLoading: true,
|
|
159
|
+
error
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
});
|
|
125
163
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
appInstance
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
logger(`MicroApp Garfish.loadApp "${appInfo.name}" unmount`);
|
|
141
|
-
appInstance === null || appInstance === void 0 ? void 0 : appInstance.unmount();
|
|
164
|
+
componentWillUnmount() {
|
|
165
|
+
return __async(this, null, function* () {
|
|
166
|
+
var _a;
|
|
167
|
+
const { appInstance } = this.state;
|
|
168
|
+
(_a = this.unregisterHistoryListener) == null ? void 0 : _a.call(this);
|
|
169
|
+
if (appInstance) {
|
|
170
|
+
const { appInfo: appInfo2 } = appInstance;
|
|
171
|
+
if (appInfo2.cache) {
|
|
172
|
+
logger(`MicroApp Garfish.loadApp "${appInfo2.name}" hide`);
|
|
173
|
+
appInstance == null ? void 0 : appInstance.hide();
|
|
174
|
+
} else {
|
|
175
|
+
logger(`MicroApp Garfish.loadApp "${appInfo2.name}" unmount`);
|
|
176
|
+
appInstance == null ? void 0 : appInstance.unmount();
|
|
177
|
+
}
|
|
142
178
|
}
|
|
143
|
-
}
|
|
179
|
+
});
|
|
144
180
|
}
|
|
145
181
|
render() {
|
|
146
|
-
const {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
} = this.state;
|
|
150
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
151
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
182
|
+
const { domId, SubModuleComponent } = this.state;
|
|
183
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
184
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
152
185
|
id: domId,
|
|
153
|
-
children: SubModuleComponent &&
|
|
186
|
+
children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {})
|
|
154
187
|
})
|
|
155
188
|
});
|
|
156
189
|
}
|
|
157
190
|
}
|
|
158
|
-
return Loadable(withRouter(MicroApp))(
|
|
191
|
+
return Loadable(withRouter(MicroApp))(
|
|
192
|
+
manifest == null ? void 0 : manifest.loadable
|
|
193
|
+
);
|
|
159
194
|
}
|
|
160
|
-
|
|
161
|
-
var
|
|
195
|
+
function generateApps(options, manifest) {
|
|
196
|
+
var _a;
|
|
162
197
|
const apps = {};
|
|
163
|
-
(
|
|
198
|
+
(_a = options.apps) == null ? void 0 : _a.forEach((appInfo) => {
|
|
164
199
|
const Component = getAppInstance(options, appInfo, manifest);
|
|
165
200
|
appInfo.Component = Component;
|
|
166
201
|
apps[appInfo.name] = Component;
|
|
167
202
|
});
|
|
168
|
-
return {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
203
|
+
return { apps, appInfoList: options.apps || [] };
|
|
204
|
+
}
|
|
205
|
+
export {
|
|
206
|
+
generateApps
|
|
207
|
+
};
|
|
@@ -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
|
+
};
|
|
File without changes
|
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
|
+
};
|