@modern-js/plugin-garfish 2.35.0 → 2.36.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/dist/cjs/cli/index.js +75 -76
- package/dist/cjs/cli/utils.js +39 -32
- package/dist/cjs/deps/index.js +35 -9
- package/dist/cjs/index.js +37 -10
- package/dist/cjs/runtime/index.js +43 -28
- package/dist/cjs/runtime/loadable.js +37 -20
- package/dist/cjs/runtime/plugin.js +68 -54
- package/dist/cjs/runtime/useModuleApps.js +43 -24
- package/dist/cjs/runtime/utils/Context.js +37 -18
- package/dist/cjs/runtime/utils/MApp.js +69 -52
- package/dist/cjs/runtime/utils/apps.js +72 -61
- package/dist/cjs/runtime/utils/setExternal.js +40 -18
- package/dist/cjs/util.js +40 -23
- package/dist/esm/cli/index.js +50 -53
- package/dist/esm/cli/utils.js +20 -13
- package/dist/esm/deps/index.js +4 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/runtime/index.js +10 -3
- package/dist/esm/runtime/loadable.js +10 -7
- package/dist/esm/runtime/plugin.js +19 -18
- package/dist/esm/runtime/useModuleApps.js +8 -4
- package/dist/esm/runtime/utils/Context.js +4 -1
- package/dist/esm/runtime/utils/MApp.js +17 -23
- package/dist/esm/runtime/utils/apps.js +25 -26
- package/dist/esm/runtime/utils/setExternal.js +4 -1
- package/dist/esm/util.js +9 -5
- package/dist/esm-node/cli/index.js +36 -38
- package/dist/esm-node/cli/utils.js +20 -13
- package/dist/esm-node/deps/index.js +4 -1
- package/dist/esm-node/index.js +4 -1
- package/dist/esm-node/runtime/index.js +10 -3
- package/dist/esm-node/runtime/loadable.js +6 -3
- package/dist/esm-node/runtime/plugin.js +10 -10
- package/dist/esm-node/runtime/useModuleApps.js +6 -2
- package/dist/esm-node/runtime/utils/Context.js +4 -1
- package/dist/esm-node/runtime/utils/MApp.js +13 -19
- package/dist/esm-node/runtime/utils/apps.js +18 -21
- package/dist/esm-node/runtime/utils/setExternal.js +4 -1
- package/dist/esm-node/util.js +9 -5
- package/package.json +10 -10
|
@@ -1,93 +1,107 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
enumerable: true
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
17
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var plugin_exports = {};
|
|
30
|
+
__export(plugin_exports, {
|
|
31
|
+
default: () => plugin_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
34
|
+
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_garfish = __toESM(require("garfish"));
|
|
37
|
+
var import_react = __toESM(require("react"));
|
|
38
|
+
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
|
39
|
+
var import_util = require("../util");
|
|
40
|
+
var import_Context = require("./utils/Context");
|
|
41
|
+
var import_setExternal = __toESM(require("./utils/setExternal"));
|
|
42
|
+
var import_MApp = require("./utils/MApp");
|
|
43
|
+
var import_apps = require("./utils/apps");
|
|
27
44
|
async function initOptions(manifest = {}, options) {
|
|
28
|
-
var
|
|
45
|
+
var _window_modern_manifest, _window, _window_modern_manifest1, _window1;
|
|
29
46
|
let apps = options.apps || [];
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
var _manifest3;
|
|
34
|
-
apps = (_manifest3 = manifest) === null || _manifest3 === void 0 ? void 0 : _manifest3.modules;
|
|
47
|
+
if (manifest === null || manifest === void 0 ? void 0 : manifest.modules) {
|
|
48
|
+
if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
|
|
49
|
+
apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
|
|
35
50
|
}
|
|
36
|
-
(0,
|
|
51
|
+
(0, import_util.logger)("manifest modules", apps);
|
|
37
52
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
const getAppList = await ((_manifest4 = manifest) === null || _manifest4 === void 0 ? void 0 : _manifest4.getAppList(manifest));
|
|
53
|
+
if (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList) {
|
|
54
|
+
const getAppList = await (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest));
|
|
41
55
|
if (getAppList.length > 0) {
|
|
42
56
|
apps = getAppList;
|
|
43
57
|
}
|
|
44
|
-
(0,
|
|
58
|
+
(0, import_util.logger)("getAppList modules", apps);
|
|
45
59
|
}
|
|
46
60
|
if (((_window = window) === null || _window === void 0 ? void 0 : (_window_modern_manifest = _window.modern_manifest) === null || _window_modern_manifest === void 0 ? void 0 : _window_modern_manifest.modules) && ((_window1 = window) === null || _window1 === void 0 ? void 0 : (_window_modern_manifest1 = _window1.modern_manifest) === null || _window_modern_manifest1 === void 0 ? void 0 : _window_modern_manifest1.modules.length) > 0) {
|
|
47
61
|
var _window_modern_manifest2, _window2;
|
|
48
62
|
apps = (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window_modern_manifest2 = _window2.modern_manifest) === null || _window_modern_manifest2 === void 0 ? void 0 : _window_modern_manifest2.modules;
|
|
49
|
-
(0,
|
|
63
|
+
(0, import_util.logger)("modern_manifest", apps);
|
|
50
64
|
}
|
|
51
65
|
return {
|
|
52
66
|
...options,
|
|
53
67
|
apps
|
|
54
68
|
};
|
|
55
69
|
}
|
|
56
|
-
|
|
70
|
+
var plugin_default = (config) => ({
|
|
57
71
|
name: "@modern-js/garfish-plugin",
|
|
58
72
|
setup: () => {
|
|
59
|
-
(0,
|
|
73
|
+
(0, import_setExternal.default)();
|
|
60
74
|
const { manifest, ...options } = config;
|
|
61
|
-
(0,
|
|
75
|
+
(0, import_util.logger)("createPlugin", config);
|
|
62
76
|
const promise = initOptions(manifest, options);
|
|
63
77
|
return {
|
|
64
78
|
hoc({ App }, next) {
|
|
65
|
-
class GetMicroFrontendApp extends
|
|
79
|
+
class GetMicroFrontendApp extends import_react.default.Component {
|
|
66
80
|
render() {
|
|
67
|
-
(0,
|
|
68
|
-
return /* @__PURE__ */ (0,
|
|
81
|
+
(0, import_util.logger)("GarfishProvider state", this.state);
|
|
82
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Context.GarfishProvider, {
|
|
69
83
|
value: this.state,
|
|
70
|
-
children: /* @__PURE__ */ (0,
|
|
84
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
71
85
|
...this.props
|
|
72
86
|
})
|
|
73
87
|
});
|
|
74
88
|
}
|
|
75
89
|
constructor(props) {
|
|
76
90
|
super(props);
|
|
77
|
-
|
|
91
|
+
(0, import_define_property._)(this, "state", {
|
|
78
92
|
MApp: () => {
|
|
79
|
-
(0,
|
|
80
|
-
return /* @__PURE__ */
|
|
93
|
+
(0, import_util.logger)("MApp init Component Render");
|
|
94
|
+
return /* @__PURE__ */ import_react.default.createElement("div");
|
|
81
95
|
},
|
|
82
96
|
apps: new Proxy({}, {
|
|
83
97
|
get() {
|
|
84
|
-
return () => /* @__PURE__ */
|
|
98
|
+
return () => /* @__PURE__ */ import_react.default.createElement("div");
|
|
85
99
|
}
|
|
86
100
|
}),
|
|
87
101
|
appInfoList: []
|
|
88
102
|
});
|
|
89
103
|
const load = async () => {
|
|
90
|
-
|
|
104
|
+
import_garfish.default.setOptions({
|
|
91
105
|
...options,
|
|
92
106
|
insulationVariable: [
|
|
93
107
|
...options.insulationVariable || [],
|
|
@@ -96,14 +110,14 @@ const _default = (config) => ({
|
|
|
96
110
|
apps: []
|
|
97
111
|
});
|
|
98
112
|
const GarfishConfig = await promise;
|
|
99
|
-
const { appInfoList, apps } = (0,
|
|
100
|
-
|
|
101
|
-
const MApp = (0,
|
|
102
|
-
(0,
|
|
113
|
+
const { appInfoList, apps } = (0, import_apps.generateApps)(GarfishConfig, manifest);
|
|
114
|
+
import_garfish.default.registerApp(appInfoList);
|
|
115
|
+
const MApp = (0, import_MApp.generateMApp)(GarfishConfig, manifest);
|
|
116
|
+
(0, import_util.logger)("initOptions result", {
|
|
103
117
|
manifest,
|
|
104
118
|
GarfishConfig
|
|
105
119
|
});
|
|
106
|
-
(0,
|
|
120
|
+
(0, import_util.logger)("generateApps", {
|
|
107
121
|
MApp,
|
|
108
122
|
apps,
|
|
109
123
|
appInfoList
|
|
@@ -118,7 +132,7 @@ const _default = (config) => ({
|
|
|
118
132
|
}
|
|
119
133
|
}
|
|
120
134
|
return next({
|
|
121
|
-
App: (0,
|
|
135
|
+
App: (0, import_hoist_non_react_statics.default)(GetMicroFrontendApp, App)
|
|
122
136
|
});
|
|
123
137
|
}
|
|
124
138
|
};
|
|
@@ -1,29 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return useModuleApps;
|
|
15
|
-
},
|
|
16
|
-
useModuleApp: function() {
|
|
17
|
-
return useModuleApp;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var useModuleApps_exports = {};
|
|
30
|
+
__export(useModuleApps_exports, {
|
|
31
|
+
useModuleApp: () => useModuleApp,
|
|
32
|
+
useModuleApps: () => useModuleApps
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
module.exports = __toCommonJS(useModuleApps_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_util = require("../util");
|
|
37
|
+
var import_Context = require("./utils/Context");
|
|
24
38
|
function useModuleApps() {
|
|
25
|
-
const { apps, MApp, appInfoList } = (0,
|
|
26
|
-
(0,
|
|
39
|
+
const { apps, MApp, appInfoList } = (0, import_react.useContext)(import_Context.GarfishContext);
|
|
40
|
+
(0, import_util.logger)("call useModuleApps", {
|
|
27
41
|
MApp,
|
|
28
42
|
apps: appInfoList,
|
|
29
43
|
...apps
|
|
@@ -37,13 +51,18 @@ function useModuleApps() {
|
|
|
37
51
|
if (typeof p === "string" && p in target) {
|
|
38
52
|
return Reflect.get(target, p, receiver);
|
|
39
53
|
}
|
|
40
|
-
return () =>
|
|
54
|
+
return () => import_react.default.createElement("div");
|
|
41
55
|
}
|
|
42
56
|
});
|
|
43
57
|
return Info;
|
|
44
58
|
}
|
|
45
59
|
function useModuleApp() {
|
|
46
|
-
const { MApp } = (0,
|
|
47
|
-
(0,
|
|
60
|
+
const { MApp } = (0, import_react.useContext)(import_Context.GarfishContext);
|
|
61
|
+
(0, import_util.logger)("call useModuleApps", MApp);
|
|
48
62
|
return MApp;
|
|
49
63
|
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
useModuleApp,
|
|
67
|
+
useModuleApps
|
|
68
|
+
});
|
|
@@ -1,23 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
6
9
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return GarfishContext;
|
|
15
|
-
},
|
|
16
|
-
GarfishProvider: function() {
|
|
17
|
-
return GarfishProvider;
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var Context_exports = {};
|
|
30
|
+
__export(Context_exports, {
|
|
31
|
+
GarfishContext: () => GarfishContext,
|
|
32
|
+
GarfishProvider: () => GarfishProvider
|
|
19
33
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const GarfishContext = /* @__PURE__ */
|
|
34
|
+
module.exports = __toCommonJS(Context_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
const GarfishContext = /* @__PURE__ */ import_react.default.createContext(null);
|
|
23
37
|
const GarfishProvider = GarfishContext.Provider;
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
GarfishContext,
|
|
41
|
+
GarfishProvider
|
|
42
|
+
});
|
|
@@ -1,35 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
9
17
|
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var MApp_exports = {};
|
|
30
|
+
__export(MApp_exports, {
|
|
31
|
+
generateMApp: () => generateMApp
|
|
10
32
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
33
|
+
module.exports = __toCommonJS(MApp_exports);
|
|
34
|
+
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
35
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_garfish = __toESM(require("garfish"));
|
|
38
|
+
var import_util = require("../../util");
|
|
39
|
+
var import_loadable = require("../loadable");
|
|
18
40
|
function generateMApp(options, manifest) {
|
|
19
|
-
|
|
20
|
-
class MApp extends _react.default.Component {
|
|
41
|
+
class MApp extends import_react.default.Component {
|
|
21
42
|
componentDidMount() {
|
|
22
43
|
const { domId } = this.state;
|
|
23
44
|
const { setLoadingState } = this.props;
|
|
24
45
|
const { beforeLoad, beforeMount, errorLoadApp, errorMountApp, errorUnmountApp } = options;
|
|
25
|
-
|
|
46
|
+
import_garfish.default.router.setRouterConfig({
|
|
26
47
|
listening: true
|
|
27
48
|
});
|
|
28
49
|
const garfishOptions = {
|
|
29
50
|
domGetter: `#${domId}`,
|
|
30
51
|
beforeLoad(appInfo, ...args) {
|
|
31
|
-
|
|
32
|
-
(0, _util.logger)("MApp beforeLoad", [
|
|
52
|
+
(0, import_util.logger)("MApp beforeLoad", [
|
|
33
53
|
appInfo
|
|
34
54
|
]);
|
|
35
55
|
if (appInfo.activeWhen) {
|
|
@@ -38,52 +58,47 @@ function generateMApp(options, manifest) {
|
|
|
38
58
|
error: null
|
|
39
59
|
});
|
|
40
60
|
}
|
|
41
|
-
return
|
|
61
|
+
return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad(appInfo, ...args);
|
|
42
62
|
},
|
|
43
63
|
beforeMount(appInfo, ...args) {
|
|
44
|
-
|
|
45
|
-
(0, _util.logger)("MApp beforeMount", args);
|
|
64
|
+
(0, import_util.logger)("MApp beforeMount", args);
|
|
46
65
|
if (appInfo.activeWhen) {
|
|
47
66
|
setLoadingState({
|
|
48
67
|
isLoading: false
|
|
49
68
|
});
|
|
50
69
|
}
|
|
51
|
-
return
|
|
70
|
+
return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount(appInfo, ...args);
|
|
52
71
|
},
|
|
53
72
|
errorLoadApp(error, appInfo, ...args) {
|
|
54
|
-
|
|
55
|
-
(0, _util.logger)("MApp errorLoadApp", error, args);
|
|
73
|
+
(0, import_util.logger)("MApp errorLoadApp", error, args);
|
|
56
74
|
if (appInfo.activeWhen) {
|
|
57
75
|
setLoadingState({
|
|
58
76
|
error
|
|
59
77
|
});
|
|
60
78
|
}
|
|
61
|
-
return
|
|
79
|
+
return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp(error, appInfo, ...args);
|
|
62
80
|
},
|
|
63
81
|
errorMountApp(error, appInfo, ...args) {
|
|
64
|
-
|
|
65
|
-
(0, _util.logger)("MApp errorMountApp", error, args);
|
|
82
|
+
(0, import_util.logger)("MApp errorMountApp", error, args);
|
|
66
83
|
if (appInfo.activeWhen) {
|
|
67
84
|
setLoadingState({
|
|
68
85
|
error
|
|
69
86
|
});
|
|
70
87
|
}
|
|
71
|
-
return
|
|
88
|
+
return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp(error, appInfo, ...args);
|
|
72
89
|
},
|
|
73
90
|
errorUnmountApp(error, appInfo, ...args) {
|
|
74
|
-
|
|
75
|
-
(0, _util.logger)("MApp errorUnmountApp", error, args);
|
|
91
|
+
(0, import_util.logger)("MApp errorUnmountApp", error, args);
|
|
76
92
|
if (appInfo.activeWhen) {
|
|
77
93
|
setLoadingState({
|
|
78
94
|
error
|
|
79
95
|
});
|
|
80
96
|
}
|
|
81
|
-
return
|
|
97
|
+
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
|
|
82
98
|
},
|
|
83
99
|
customLoader: (provider) => {
|
|
84
|
-
var _manifest2;
|
|
85
100
|
const { render, destroy, SubModuleComponent, jupiter_submodule_app_key } = provider;
|
|
86
|
-
const componetRenderMode = (
|
|
101
|
+
const componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
87
102
|
return {
|
|
88
103
|
mount: (appInfo) => {
|
|
89
104
|
const transferProps = this.filterTransferProps();
|
|
@@ -97,15 +112,13 @@ function generateMApp(options, manifest) {
|
|
|
97
112
|
});
|
|
98
113
|
return void 0;
|
|
99
114
|
} else {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return (_render = render) === null || _render === void 0 ? void 0 : _render.apply(provider, [
|
|
115
|
+
(0, import_util.logger)("MicroApp customer render", appInfo);
|
|
116
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, [
|
|
103
117
|
appInfo
|
|
104
118
|
]);
|
|
105
119
|
}
|
|
106
120
|
},
|
|
107
121
|
unmount: (appInfo) => {
|
|
108
|
-
var _destroy;
|
|
109
122
|
const transferProps = this.filterTransferProps();
|
|
110
123
|
appInfo.props = {
|
|
111
124
|
...appInfo.props,
|
|
@@ -114,27 +127,27 @@ function generateMApp(options, manifest) {
|
|
|
114
127
|
if (componetRenderMode) {
|
|
115
128
|
return void 0;
|
|
116
129
|
}
|
|
117
|
-
(0,
|
|
118
|
-
return
|
|
130
|
+
(0, import_util.logger)("MicroApp customer destroy", appInfo);
|
|
131
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
|
|
119
132
|
appInfo
|
|
120
133
|
]);
|
|
121
134
|
}
|
|
122
135
|
};
|
|
123
136
|
}
|
|
124
137
|
};
|
|
125
|
-
(0,
|
|
126
|
-
garfishRunning:
|
|
138
|
+
(0, import_util.logger)("MApp componentDidMount", {
|
|
139
|
+
garfishRunning: import_garfish.default.running,
|
|
127
140
|
garfishOptions
|
|
128
141
|
});
|
|
129
|
-
if (!
|
|
130
|
-
|
|
142
|
+
if (!import_garfish.default.running) {
|
|
143
|
+
import_garfish.default.run(garfishOptions);
|
|
131
144
|
}
|
|
132
145
|
}
|
|
133
146
|
componentWillUnmount() {
|
|
134
|
-
|
|
147
|
+
import_garfish.default.router.setRouterConfig({
|
|
135
148
|
listening: false
|
|
136
149
|
});
|
|
137
|
-
(0,
|
|
150
|
+
(0, import_util.logger)("MApp componentWillUnmount");
|
|
138
151
|
}
|
|
139
152
|
filterTransferProps() {
|
|
140
153
|
const { style, setLoadingState, ...others } = this.props;
|
|
@@ -143,20 +156,24 @@ function generateMApp(options, manifest) {
|
|
|
143
156
|
render() {
|
|
144
157
|
const { style } = this.props;
|
|
145
158
|
const { SubModuleComponent } = this.state;
|
|
146
|
-
return /* @__PURE__ */ (0,
|
|
159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
147
160
|
style: {
|
|
148
161
|
...style
|
|
149
162
|
},
|
|
150
|
-
id: (0,
|
|
151
|
-
children: SubModuleComponent && /* @__PURE__ */ (0,
|
|
163
|
+
id: (0, import_util.generateSubAppContainerKey)(),
|
|
164
|
+
children: SubModuleComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubModuleComponent, {})
|
|
152
165
|
});
|
|
153
166
|
}
|
|
154
167
|
constructor(...args) {
|
|
155
168
|
super(...args);
|
|
156
|
-
|
|
157
|
-
domId: (0,
|
|
169
|
+
(0, import_define_property._)(this, "state", {
|
|
170
|
+
domId: (0, import_util.generateSubAppContainerKey)()
|
|
158
171
|
});
|
|
159
172
|
}
|
|
160
173
|
}
|
|
161
|
-
return (0,
|
|
174
|
+
return (0, import_loadable.Loadable)(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
|
|
162
175
|
}
|
|
176
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
177
|
+
0 && (module.exports = {
|
|
178
|
+
generateMApp
|
|
179
|
+
});
|