@modern-js/plugin-garfish 2.15.0 → 2.16.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/CHANGELOG.md +15 -0
- package/dist/cjs/cli/index.js +224 -236
- package/dist/cjs/cli/utils.js +24 -48
- package/dist/cjs/deps/index.js +12 -35
- package/dist/cjs/index.js +26 -36
- package/dist/cjs/runtime/index.js +24 -44
- package/dist/cjs/runtime/loadable.js +46 -58
- package/dist/cjs/runtime/plugin.js +86 -82
- package/dist/cjs/runtime/useModuleApps.js +70 -56
- package/dist/cjs/runtime/utils/Context.js +18 -36
- package/dist/cjs/runtime/utils/MApp.js +88 -87
- package/dist/cjs/runtime/utils/apps.js +114 -94
- package/dist/cjs/runtime/utils/setExternal.js +23 -41
- package/dist/cjs/util.js +21 -40
- package/dist/esm/cli/index.js +409 -402
- package/dist/esm/cli/utils.js +25 -26
- package/dist/esm/deps/index.js +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/runtime/index.js +3 -4
- package/dist/esm/runtime/loadable.js +226 -210
- package/dist/esm/runtime/plugin.js +456 -426
- package/dist/esm/runtime/useModuleApps.js +49 -50
- package/dist/esm/runtime/utils/Context.js +1 -1
- package/dist/esm/runtime/utils/MApp.js +337 -316
- package/dist/esm/runtime/utils/apps.js +468 -442
- package/dist/esm/runtime/utils/setExternal.js +9 -9
- package/dist/esm/util.js +4 -5
- package/dist/esm-node/cli/index.js +209 -219
- package/dist/esm-node/cli/utils.js +15 -30
- package/dist/esm-node/deps/index.js +1 -4
- package/dist/esm-node/index.js +1 -4
- package/dist/esm-node/runtime/index.js +3 -10
- package/dist/esm-node/runtime/loadable.js +34 -31
- package/dist/esm-node/runtime/plugin.js +50 -33
- package/dist/esm-node/runtime/useModuleApps.js +12 -19
- package/dist/esm-node/runtime/utils/Context.js +2 -5
- package/dist/esm-node/runtime/utils/MApp.js +61 -40
- package/dist/esm-node/runtime/utils/apps.js +38 -44
- package/dist/esm-node/runtime/utils/setExternal.js +5 -5
- package/dist/esm-node/util.js +4 -9
- package/package.json +15 -11
package/dist/cjs/deps/index.js
CHANGED
|
@@ -1,37 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var deps_exports = {};
|
|
29
|
-
__export(deps_exports, {
|
|
30
|
-
hoistNonReactStatics: () => import_hoist_non_react_statics.default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
0 && (module.exports = {
|
|
36
|
-
hoistNonReactStatics
|
|
5
|
+
Object.defineProperty(exports, "hoistNonReactStatics", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => _hoistnonreactstatics.default
|
|
37
8
|
});
|
|
9
|
+
const _hoistnonreactstatics = /* @__PURE__ */ _interop_require_default(require("hoist-non-react-statics"));
|
|
10
|
+
function _interop_require_default(obj) {
|
|
11
|
+
return obj && obj.__esModule ? obj : {
|
|
12
|
+
default: obj
|
|
13
|
+
};
|
|
14
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,37 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
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 src_exports = {};
|
|
30
|
-
__export(src_exports, {
|
|
31
|
-
default: () => import_runtime.default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
32
4
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => _runtime.default
|
|
8
|
+
});
|
|
9
|
+
const _runtime = /* @__PURE__ */ _interop_require_default(_export_star(require("./runtime"), exports));
|
|
10
|
+
function _export_star(from, to) {
|
|
11
|
+
Object.keys(from).forEach(function(k) {
|
|
12
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
13
|
+
Object.defineProperty(to, k, {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function() {
|
|
16
|
+
return from[k];
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return from;
|
|
22
|
+
}
|
|
23
|
+
function _interop_require_default(obj) {
|
|
24
|
+
return obj && obj.__esModule ? obj : {
|
|
25
|
+
default: obj
|
|
26
|
+
};
|
|
27
|
+
}
|
|
@@ -1,46 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var runtime_exports = {};
|
|
29
|
-
__export(runtime_exports, {
|
|
30
|
-
Garfish: () => import_garfish.default,
|
|
31
|
-
default: () => import_plugin.default,
|
|
32
|
-
garfish: () => import_garfish.default,
|
|
33
|
-
useModuleApp: () => import_useModuleApps.useModuleApp,
|
|
34
|
-
useModuleApps: () => import_useModuleApps.useModuleApps
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
35
4
|
});
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
useModuleApps
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
default: () => _plugin.default,
|
|
14
|
+
useModuleApps: () => _useModuleApps.useModuleApps,
|
|
15
|
+
useModuleApp: () => _useModuleApps.useModuleApp,
|
|
16
|
+
Garfish: () => _garfish.default,
|
|
17
|
+
garfish: () => _garfish.default
|
|
46
18
|
});
|
|
19
|
+
const _plugin = /* @__PURE__ */ _interop_require_default(require("./plugin"));
|
|
20
|
+
const _useModuleApps = require("./useModuleApps");
|
|
21
|
+
const _garfish = /* @__PURE__ */ _interop_require_default(require("garfish"));
|
|
22
|
+
function _interop_require_default(obj) {
|
|
23
|
+
return obj && obj.__esModule ? obj : {
|
|
24
|
+
default: obj
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var loadable_exports = {};
|
|
19
|
-
__export(loadable_exports, {
|
|
20
|
-
Loadable: () => Loadable
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
21
4
|
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
5
|
+
Object.defineProperty(exports, "Loadable", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: () => Loadable
|
|
8
|
+
});
|
|
9
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
10
|
+
const _react = require("react");
|
|
11
|
+
const _util = require("../util");
|
|
26
12
|
const DEFAULT_LOADABLE = {
|
|
27
13
|
delay: 200,
|
|
28
14
|
timeout: 1e4,
|
|
@@ -31,11 +17,11 @@ const DEFAULT_LOADABLE = {
|
|
|
31
17
|
function Loadable(WrapComponent) {
|
|
32
18
|
return function(defaultLoadable) {
|
|
33
19
|
return function Lodable(props) {
|
|
34
|
-
var
|
|
35
|
-
const { loadable = defaultLoadable
|
|
20
|
+
var _props_loadable;
|
|
21
|
+
const { loadable = defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE, ...otherProps } = props;
|
|
36
22
|
let delayTimer = null;
|
|
37
23
|
let timeoutTimer = null;
|
|
38
|
-
const [state, setState] = (0,
|
|
24
|
+
const [state, setState] = (0, _react.useState)(() => {
|
|
39
25
|
const { delay, timeout } = loadable;
|
|
40
26
|
const initState = {
|
|
41
27
|
error: null,
|
|
@@ -48,20 +34,24 @@ function Loadable(WrapComponent) {
|
|
|
48
34
|
initState.pastDelay = true;
|
|
49
35
|
} else {
|
|
50
36
|
delayTimer = setTimeout(() => {
|
|
51
|
-
setStateWithMountCheck({
|
|
37
|
+
setStateWithMountCheck({
|
|
38
|
+
pastDelay: true
|
|
39
|
+
});
|
|
52
40
|
}, delay);
|
|
53
41
|
}
|
|
54
42
|
}
|
|
55
43
|
if (typeof timeout === "number") {
|
|
56
44
|
timeoutTimer = setTimeout(() => {
|
|
57
|
-
setStateWithMountCheck({
|
|
45
|
+
setStateWithMountCheck({
|
|
46
|
+
timedOut: true
|
|
47
|
+
});
|
|
58
48
|
}, timeout);
|
|
59
49
|
}
|
|
60
50
|
return initState;
|
|
61
51
|
});
|
|
62
|
-
const LoadingComponent = (
|
|
63
|
-
(0,
|
|
64
|
-
(0,
|
|
52
|
+
const LoadingComponent = (_props_loadable = props.loadable) === null || _props_loadable === void 0 ? void 0 : _props_loadable.loading;
|
|
53
|
+
(0, _react.useEffect)(() => {
|
|
54
|
+
(0, _util.logger)("Loadable render state", {
|
|
65
55
|
state,
|
|
66
56
|
props: otherProps,
|
|
67
57
|
loadable,
|
|
@@ -82,36 +72,38 @@ function Loadable(WrapComponent) {
|
|
|
82
72
|
}
|
|
83
73
|
};
|
|
84
74
|
}, []);
|
|
85
|
-
const retry = (0,
|
|
75
|
+
const retry = (0, _react.useCallback)(() => {
|
|
86
76
|
setState({
|
|
87
77
|
...state,
|
|
88
78
|
error: null,
|
|
89
79
|
isLoading: true,
|
|
90
80
|
timedOut: false
|
|
91
81
|
});
|
|
92
|
-
}, [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
82
|
+
}, [
|
|
83
|
+
state
|
|
84
|
+
]);
|
|
85
|
+
const setStateWithMountCheck = (0, _react.useCallback)((newState) => {
|
|
86
|
+
setState((state2) => ({
|
|
87
|
+
...state2,
|
|
88
|
+
...newState
|
|
89
|
+
}));
|
|
90
|
+
}, [
|
|
91
|
+
state
|
|
92
|
+
]);
|
|
99
93
|
const showLoading = (state.isLoading || state.error) && LoadingComponent;
|
|
100
|
-
return /* @__PURE__ */ (0,
|
|
101
|
-
|
|
102
|
-
LoadingComponent,
|
|
103
|
-
{
|
|
94
|
+
return /* @__PURE__ */ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
|
|
95
|
+
children: [
|
|
96
|
+
showLoading && /* @__PURE__ */ (0, _jsxruntime.jsx)(LoadingComponent, {
|
|
104
97
|
isLoading: state.isLoading,
|
|
105
98
|
pastDelay: state.pastDelay,
|
|
106
99
|
timedOut: state.timedOut,
|
|
107
|
-
error: state
|
|
100
|
+
error: state === null || state === void 0 ? void 0 : state.error,
|
|
108
101
|
retry
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
style: { display: showLoading ? "none" : "block" },
|
|
102
|
+
}),
|
|
103
|
+
/* @__PURE__ */ (0, _jsxruntime.jsx)(WrapComponent, {
|
|
104
|
+
style: {
|
|
105
|
+
display: showLoading ? "none" : "block"
|
|
106
|
+
},
|
|
115
107
|
setLoadingState: (props2) => {
|
|
116
108
|
if (props2.error && !LoadingComponent) {
|
|
117
109
|
throw props2.error;
|
|
@@ -119,13 +111,9 @@ function Loadable(WrapComponent) {
|
|
|
119
111
|
setStateWithMountCheck(props2);
|
|
120
112
|
},
|
|
121
113
|
...otherProps
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
});
|
|
125
117
|
};
|
|
126
118
|
};
|
|
127
119
|
}
|
|
128
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
129
|
-
0 && (module.exports = {
|
|
130
|
-
Loadable
|
|
131
|
-
});
|
|
@@ -1,98 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var plugin_exports = {};
|
|
29
|
-
__export(plugin_exports, {
|
|
30
|
-
default: () => plugin_default
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
31
4
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
5
|
+
Object.defineProperty(
|
|
6
|
+
exports,
|
|
7
|
+
// export default garfishPlugin;
|
|
8
|
+
"default",
|
|
9
|
+
{
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: () => _default
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
const _jsxruntime = require("react/jsx-runtime");
|
|
15
|
+
const _garfish = /* @__PURE__ */ _interop_require_default(require("garfish"));
|
|
16
|
+
const _react = /* @__PURE__ */ _interop_require_default(require("react"));
|
|
17
|
+
const _hoistnonreactstatics = /* @__PURE__ */ _interop_require_default(require("hoist-non-react-statics"));
|
|
18
|
+
const _util = require("../util");
|
|
19
|
+
const _Context = require("./utils/Context");
|
|
20
|
+
const _setExternal = /* @__PURE__ */ _interop_require_default(require("./utils/setExternal"));
|
|
21
|
+
const _MApp = require("./utils/MApp");
|
|
22
|
+
const _apps = require("./utils/apps");
|
|
23
|
+
function _define_property(obj, key, value) {
|
|
24
|
+
if (key in obj) {
|
|
25
|
+
Object.defineProperty(obj, key, {
|
|
26
|
+
value,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
configurable: true,
|
|
29
|
+
writable: true
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
obj[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return obj;
|
|
35
|
+
}
|
|
36
|
+
function _interop_require_default(obj) {
|
|
37
|
+
return obj && obj.__esModule ? obj : {
|
|
38
|
+
default: obj
|
|
39
|
+
};
|
|
40
|
+
}
|
|
42
41
|
async function initOptions(manifest = {}, options) {
|
|
43
|
-
var
|
|
42
|
+
var _window_modern_manifest, _window_modern_manifest1;
|
|
44
43
|
let apps = options.apps || [];
|
|
45
|
-
if (manifest
|
|
46
|
-
if ((manifest
|
|
47
|
-
apps = manifest
|
|
44
|
+
if (manifest === null || manifest === void 0 ? void 0 : manifest.modules) {
|
|
45
|
+
if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
|
|
46
|
+
apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
|
|
48
47
|
}
|
|
49
|
-
(0,
|
|
48
|
+
(0, _util.logger)("manifest modules", apps);
|
|
50
49
|
}
|
|
51
|
-
if (manifest
|
|
52
|
-
const getAppList = await (manifest
|
|
50
|
+
if (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList) {
|
|
51
|
+
const getAppList = await (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest));
|
|
53
52
|
if (getAppList.length > 0) {
|
|
54
53
|
apps = getAppList;
|
|
55
54
|
}
|
|
56
|
-
(0,
|
|
55
|
+
(0, _util.logger)("getAppList modules", apps);
|
|
57
56
|
}
|
|
58
|
-
if ((
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
if ((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) && (window === null || window === void 0 ? void 0 : (_window_modern_manifest1 = window.modern_manifest) === null || _window_modern_manifest1 === void 0 ? void 0 : _window_modern_manifest1.modules.length) > 0) {
|
|
58
|
+
var _window_modern_manifest2;
|
|
59
|
+
apps = window === null || window === void 0 ? void 0 : (_window_modern_manifest2 = window.modern_manifest) === null || _window_modern_manifest2 === void 0 ? void 0 : _window_modern_manifest2.modules;
|
|
60
|
+
(0, _util.logger)("modern_manifest", apps);
|
|
61
61
|
}
|
|
62
62
|
return {
|
|
63
63
|
...options,
|
|
64
64
|
apps
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
const _default = (config) => ({
|
|
68
68
|
name: "@modern-js/garfish-plugin",
|
|
69
69
|
setup: () => {
|
|
70
|
-
(0,
|
|
70
|
+
(0, _setExternal.default)();
|
|
71
71
|
const { manifest, ...options } = config;
|
|
72
|
-
(0,
|
|
72
|
+
(0, _util.logger)("createPlugin", config);
|
|
73
73
|
const promise = initOptions(manifest, options);
|
|
74
74
|
return {
|
|
75
75
|
hoc({ App }, next) {
|
|
76
|
-
class GetMicroFrontendApp extends
|
|
76
|
+
class GetMicroFrontendApp extends _react.default.Component {
|
|
77
|
+
render() {
|
|
78
|
+
(0, _util.logger)("GarfishProvider state", this.state);
|
|
79
|
+
return /* @__PURE__ */ (0, _jsxruntime.jsx)(_Context.GarfishProvider, {
|
|
80
|
+
value: this.state,
|
|
81
|
+
children: /* @__PURE__ */ (0, _jsxruntime.jsx)(App, {
|
|
82
|
+
...this.props
|
|
83
|
+
})
|
|
84
|
+
});
|
|
85
|
+
}
|
|
77
86
|
constructor(props) {
|
|
78
87
|
super(props);
|
|
79
|
-
this
|
|
88
|
+
_define_property(this, "state", {
|
|
80
89
|
MApp: () => {
|
|
81
|
-
(0,
|
|
82
|
-
return
|
|
90
|
+
(0, _util.logger)("MApp init Component Render");
|
|
91
|
+
return /* @__PURE__ */ _react.default.createElement("div");
|
|
83
92
|
},
|
|
84
|
-
apps: new Proxy(
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
get() {
|
|
88
|
-
return () => import_react.default.createElement("div");
|
|
89
|
-
}
|
|
93
|
+
apps: new Proxy({}, {
|
|
94
|
+
get() {
|
|
95
|
+
return () => /* @__PURE__ */ _react.default.createElement("div");
|
|
90
96
|
}
|
|
91
|
-
),
|
|
97
|
+
}),
|
|
92
98
|
appInfoList: []
|
|
93
|
-
};
|
|
99
|
+
});
|
|
94
100
|
const load = async () => {
|
|
95
|
-
|
|
101
|
+
_garfish.default.setOptions({
|
|
96
102
|
...options,
|
|
97
103
|
insulationVariable: [
|
|
98
104
|
...options.insulationVariable || [],
|
|
@@ -101,14 +107,18 @@ var plugin_default = (config) => ({
|
|
|
101
107
|
apps: []
|
|
102
108
|
});
|
|
103
109
|
const GarfishConfig = await promise;
|
|
104
|
-
const { appInfoList, apps } = (0,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
(0,
|
|
110
|
+
const { appInfoList, apps } = (0, _apps.generateApps)(GarfishConfig, manifest);
|
|
111
|
+
_garfish.default.registerApp(appInfoList);
|
|
112
|
+
const MApp = (0, _MApp.generateMApp)(GarfishConfig, manifest);
|
|
113
|
+
(0, _util.logger)("initOptions result", {
|
|
114
|
+
manifest,
|
|
115
|
+
GarfishConfig
|
|
116
|
+
});
|
|
117
|
+
(0, _util.logger)("generateApps", {
|
|
118
|
+
MApp,
|
|
119
|
+
apps,
|
|
120
|
+
appInfoList
|
|
121
|
+
});
|
|
112
122
|
this.setState({
|
|
113
123
|
MApp,
|
|
114
124
|
apps,
|
|
@@ -117,17 +127,11 @@ var plugin_default = (config) => ({
|
|
|
117
127
|
};
|
|
118
128
|
load();
|
|
119
129
|
}
|
|
120
|
-
render() {
|
|
121
|
-
(0, import_util.logger)("GarfishProvider state", this.state);
|
|
122
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Context.GarfishProvider, { value: this.state, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, { ...this.props }) });
|
|
123
|
-
}
|
|
124
130
|
}
|
|
125
131
|
return next({
|
|
126
|
-
App: (0,
|
|
132
|
+
App: (0, _hoistnonreactstatics.default)(GetMicroFrontendApp, App)
|
|
127
133
|
});
|
|
128
134
|
}
|
|
129
135
|
};
|
|
130
136
|
}
|
|
131
137
|
});
|
|
132
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
-
0 && (module.exports = {});
|