@modern-js/plugin-garfish 2.0.0-beta.3 → 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 +67 -0
- package/dist/js/modern/cli/index.js +164 -157
- 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 -168
- 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 -284
- 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 +10 -10
|
@@ -1,64 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
import { useState, useEffect, useCallback } from "react";
|
|
9
34
|
import { logger } from "../util";
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
35
|
const DEFAULT_LOADABLE = {
|
|
14
36
|
delay: 200,
|
|
15
|
-
timeout:
|
|
37
|
+
timeout: 1e4,
|
|
16
38
|
loading: null
|
|
17
39
|
};
|
|
18
|
-
|
|
19
|
-
return function
|
|
40
|
+
function Loadable(WrapComponent) {
|
|
41
|
+
return function(defaultLoadable) {
|
|
20
42
|
return function Lodable(props) {
|
|
21
|
-
var
|
|
22
|
-
const {
|
|
23
|
-
loadable = defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE
|
|
24
|
-
} = props,
|
|
25
|
-
otherProps = _objectWithoutProperties(props, _excluded);
|
|
43
|
+
var _b;
|
|
44
|
+
const _a = props, { loadable = defaultLoadable != null ? defaultLoadable : DEFAULT_LOADABLE } = _a, otherProps = __objRest(_a, ["loadable"]);
|
|
26
45
|
let delayTimer = null;
|
|
27
46
|
let timeoutTimer = null;
|
|
28
47
|
const [state, setState] = useState(() => {
|
|
29
|
-
const {
|
|
30
|
-
delay,
|
|
31
|
-
timeout
|
|
32
|
-
} = loadable;
|
|
48
|
+
const { delay, timeout } = loadable;
|
|
33
49
|
const initState = {
|
|
34
50
|
error: null,
|
|
35
51
|
pastDelay: false,
|
|
36
52
|
timedOut: false,
|
|
37
53
|
isLoading: false
|
|
38
54
|
};
|
|
39
|
-
if (typeof delay ===
|
|
55
|
+
if (typeof delay === "number") {
|
|
40
56
|
if (delay === 0) {
|
|
41
57
|
initState.pastDelay = true;
|
|
42
58
|
} else {
|
|
43
59
|
delayTimer = setTimeout(() => {
|
|
44
|
-
setStateWithMountCheck({
|
|
45
|
-
pastDelay: true
|
|
46
|
-
});
|
|
60
|
+
setStateWithMountCheck({ pastDelay: true });
|
|
47
61
|
}, delay);
|
|
48
62
|
}
|
|
49
63
|
}
|
|
50
|
-
if (typeof timeout ===
|
|
64
|
+
if (typeof timeout === "number") {
|
|
51
65
|
timeoutTimer = setTimeout(() => {
|
|
52
|
-
setStateWithMountCheck({
|
|
53
|
-
timedOut: true
|
|
54
|
-
});
|
|
66
|
+
setStateWithMountCheck({ timedOut: true });
|
|
55
67
|
}, timeout);
|
|
56
68
|
}
|
|
57
69
|
return initState;
|
|
58
70
|
});
|
|
59
|
-
const LoadingComponent = (
|
|
71
|
+
const LoadingComponent = (_b = props.loadable) == null ? void 0 : _b.loading;
|
|
60
72
|
useEffect(() => {
|
|
61
|
-
logger(
|
|
73
|
+
logger("Loadable render state", {
|
|
62
74
|
state,
|
|
63
75
|
props: otherProps,
|
|
64
76
|
loadable,
|
|
@@ -80,36 +92,42 @@ export function Loadable(WrapComponent) {
|
|
|
80
92
|
};
|
|
81
93
|
}, []);
|
|
82
94
|
const retry = useCallback(() => {
|
|
83
|
-
setState(
|
|
95
|
+
setState(__spreadProps(__spreadValues({}, state), {
|
|
84
96
|
error: null,
|
|
85
97
|
isLoading: true,
|
|
86
98
|
timedOut: false
|
|
87
99
|
}));
|
|
88
100
|
}, [state]);
|
|
89
|
-
const setStateWithMountCheck = useCallback(
|
|
90
|
-
|
|
91
|
-
|
|
101
|
+
const setStateWithMountCheck = useCallback(
|
|
102
|
+
(newState) => {
|
|
103
|
+
setState((state2) => __spreadValues(__spreadValues({}, state2), newState));
|
|
104
|
+
},
|
|
105
|
+
[state]
|
|
106
|
+
);
|
|
92
107
|
const showLoading = (state.isLoading || state.error) && LoadingComponent;
|
|
93
|
-
return
|
|
94
|
-
children: [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
109
|
+
children: [
|
|
110
|
+
showLoading && /* @__PURE__ */ jsx(LoadingComponent, {
|
|
111
|
+
isLoading: state.isLoading,
|
|
112
|
+
pastDelay: state.pastDelay,
|
|
113
|
+
timedOut: state.timedOut,
|
|
114
|
+
error: state == null ? void 0 : state.error,
|
|
115
|
+
retry
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx(WrapComponent, __spreadValues({
|
|
118
|
+
style: { display: showLoading ? "none" : "block" },
|
|
119
|
+
setLoadingState: (props2) => {
|
|
120
|
+
if (props2.error && !LoadingComponent) {
|
|
121
|
+
throw props2.error;
|
|
122
|
+
}
|
|
123
|
+
setStateWithMountCheck(props2);
|
|
108
124
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}, otherProps))]
|
|
125
|
+
}, otherProps))
|
|
126
|
+
]
|
|
112
127
|
});
|
|
113
128
|
};
|
|
114
129
|
};
|
|
115
|
-
}
|
|
130
|
+
}
|
|
131
|
+
export {
|
|
132
|
+
Loadable
|
|
133
|
+
};
|
|
@@ -1,114 +1,146 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 { jsx } from "react/jsx-runtime";
|
|
53
|
+
import GarfishInstance from "garfish";
|
|
54
|
+
import React from "react";
|
|
55
|
+
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
10
56
|
import { logger } from "../util";
|
|
11
57
|
import { GarfishProvider } from "./utils/Context";
|
|
12
58
|
import setExternal from "./utils/setExternal";
|
|
13
59
|
import { generateMApp } from "./utils/MApp";
|
|
14
60
|
import { generateApps } from "./utils/apps";
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
61
|
+
function initOptions() {
|
|
62
|
+
return __async(this, arguments, function* (manifest = {}, options) {
|
|
63
|
+
var _a, _b, _c;
|
|
64
|
+
let apps = options.apps || [];
|
|
65
|
+
if (manifest == null ? void 0 : manifest.modules) {
|
|
66
|
+
if ((manifest == null ? void 0 : manifest.modules.length) > 0) {
|
|
67
|
+
apps = manifest == null ? void 0 : manifest.modules;
|
|
68
|
+
}
|
|
69
|
+
logger("manifest modules", apps);
|
|
24
70
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (getAppList.length > 0) {
|
|
32
|
-
apps = getAppList;
|
|
71
|
+
if (manifest == null ? void 0 : manifest.getAppList) {
|
|
72
|
+
const getAppList = yield manifest == null ? void 0 : manifest.getAppList(manifest);
|
|
73
|
+
if (getAppList.length > 0) {
|
|
74
|
+
apps = getAppList;
|
|
75
|
+
}
|
|
76
|
+
logger("getAppList modules", apps);
|
|
33
77
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
logger('modern_manifest', apps);
|
|
42
|
-
}
|
|
43
|
-
return _objectSpread(_objectSpread({}, options), {}, {
|
|
44
|
-
apps
|
|
78
|
+
if (((_a = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _a.modules) && ((_b = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _b.modules.length) > 0) {
|
|
79
|
+
apps = (_c = window == null ? void 0 : window.modern_manifest) == null ? void 0 : _c.modules;
|
|
80
|
+
logger("modern_manifest", apps);
|
|
81
|
+
}
|
|
82
|
+
return __spreadProps(__spreadValues({}, options), {
|
|
83
|
+
apps
|
|
84
|
+
});
|
|
45
85
|
});
|
|
46
86
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export default (config => ({
|
|
50
|
-
name: '@modern-js/garfish-plugin',
|
|
87
|
+
var plugin_default = (config) => ({
|
|
88
|
+
name: "@modern-js/garfish-plugin",
|
|
51
89
|
setup: () => {
|
|
52
90
|
setExternal();
|
|
53
|
-
const {
|
|
54
|
-
|
|
55
|
-
} = config,
|
|
56
|
-
options = _objectWithoutProperties(config, _excluded);
|
|
57
|
-
logger('createPlugin', config);
|
|
91
|
+
const _a = config, { manifest } = _a, options = __objRest(_a, ["manifest"]);
|
|
92
|
+
logger("createPlugin", config);
|
|
58
93
|
const promise = initOptions(manifest, options);
|
|
59
94
|
return {
|
|
60
|
-
hoc({
|
|
61
|
-
App
|
|
62
|
-
}, next) {
|
|
95
|
+
hoc({ App }, next) {
|
|
63
96
|
class GetMicroFrontendApp extends React.Component {
|
|
64
97
|
constructor(props) {
|
|
65
98
|
super(props);
|
|
66
|
-
|
|
99
|
+
this.state = {
|
|
67
100
|
MApp: () => {
|
|
68
|
-
logger(
|
|
69
|
-
return
|
|
101
|
+
logger("MApp init Component Render");
|
|
102
|
+
return React.createElement("div");
|
|
70
103
|
},
|
|
71
|
-
apps: new Proxy(
|
|
72
|
-
|
|
73
|
-
|
|
104
|
+
apps: new Proxy(
|
|
105
|
+
{},
|
|
106
|
+
{
|
|
107
|
+
get() {
|
|
108
|
+
return () => React.createElement("div");
|
|
109
|
+
}
|
|
74
110
|
}
|
|
75
|
-
|
|
111
|
+
),
|
|
76
112
|
appInfoList: []
|
|
77
|
-
}
|
|
78
|
-
const load =
|
|
79
|
-
GarfishInstance.setOptions(
|
|
80
|
-
insulationVariable: [
|
|
113
|
+
};
|
|
114
|
+
const load = () => __async(this, null, function* () {
|
|
115
|
+
GarfishInstance.setOptions(__spreadProps(__spreadValues({}, options), {
|
|
116
|
+
insulationVariable: [
|
|
117
|
+
...options.insulationVariable || [],
|
|
118
|
+
"_SERVER_DATA"
|
|
119
|
+
],
|
|
81
120
|
apps: []
|
|
82
121
|
}));
|
|
83
|
-
const GarfishConfig =
|
|
84
|
-
const {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
122
|
+
const GarfishConfig = yield promise;
|
|
123
|
+
const { appInfoList, apps } = generateApps(
|
|
124
|
+
GarfishConfig,
|
|
125
|
+
manifest
|
|
126
|
+
);
|
|
88
127
|
GarfishInstance.registerApp(appInfoList);
|
|
89
128
|
const MApp = generateMApp(GarfishConfig, manifest);
|
|
90
|
-
logger(
|
|
91
|
-
|
|
92
|
-
GarfishConfig
|
|
93
|
-
});
|
|
94
|
-
logger('generateApps', {
|
|
95
|
-
MApp,
|
|
96
|
-
apps,
|
|
97
|
-
appInfoList
|
|
98
|
-
});
|
|
129
|
+
logger("initOptions result", { manifest, GarfishConfig });
|
|
130
|
+
logger("generateApps", { MApp, apps, appInfoList });
|
|
99
131
|
this.setState({
|
|
100
132
|
MApp,
|
|
101
133
|
apps,
|
|
102
134
|
appInfoList
|
|
103
135
|
});
|
|
104
|
-
};
|
|
136
|
+
});
|
|
105
137
|
load();
|
|
106
138
|
}
|
|
107
139
|
render() {
|
|
108
|
-
logger(
|
|
109
|
-
return
|
|
140
|
+
logger("GarfishProvider state", this.state);
|
|
141
|
+
return /* @__PURE__ */ jsx(GarfishProvider, {
|
|
110
142
|
value: this.state,
|
|
111
|
-
children:
|
|
143
|
+
children: /* @__PURE__ */ jsx(App, __spreadValues(__spreadValues({}, this.props), this.state))
|
|
112
144
|
});
|
|
113
145
|
}
|
|
114
146
|
}
|
|
@@ -118,4 +150,7 @@ export default (config => ({
|
|
|
118
150
|
}
|
|
119
151
|
};
|
|
120
152
|
}
|
|
121
|
-
})
|
|
153
|
+
});
|
|
154
|
+
export {
|
|
155
|
+
plugin_default as default
|
|
156
|
+
};
|
|
@@ -1,36 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
import React, { useContext } from "react";
|
|
5
18
|
import { logger } from "../util";
|
|
6
19
|
import { GarfishContext } from "./utils/Context";
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
MApp,
|
|
11
|
-
appInfoList
|
|
12
|
-
} = useContext(GarfishContext);
|
|
13
|
-
logger('call useModuleApps', _objectSpread({
|
|
20
|
+
function useModuleApps() {
|
|
21
|
+
const { apps, MApp, appInfoList } = useContext(GarfishContext);
|
|
22
|
+
logger("call useModuleApps", __spreadValues({
|
|
14
23
|
MApp,
|
|
15
24
|
apps: appInfoList
|
|
16
25
|
}, apps));
|
|
17
|
-
const Info = new Proxy(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const Info = new Proxy(
|
|
27
|
+
__spreadValues({
|
|
28
|
+
MApp,
|
|
29
|
+
apps: appInfoList
|
|
30
|
+
}, apps),
|
|
31
|
+
{
|
|
32
|
+
get(target, p, receiver) {
|
|
33
|
+
if (typeof p === "string" && p in target) {
|
|
34
|
+
return Reflect.get(target, p, receiver);
|
|
35
|
+
}
|
|
36
|
+
return () => React.createElement("div");
|
|
24
37
|
}
|
|
25
|
-
return () => /*#__PURE__*/React.createElement('div');
|
|
26
38
|
}
|
|
27
|
-
|
|
39
|
+
);
|
|
28
40
|
return Info;
|
|
29
41
|
}
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
|
|
33
|
-
} = useContext(GarfishContext);
|
|
34
|
-
logger('call useModuleApps', MApp);
|
|
42
|
+
function useModuleApp() {
|
|
43
|
+
const { MApp } = useContext(GarfishContext);
|
|
44
|
+
logger("call useModuleApps", MApp);
|
|
35
45
|
return MApp;
|
|
36
|
-
}
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
useModuleApp,
|
|
49
|
+
useModuleApps
|
|
50
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
const GarfishContext =
|
|
1
|
+
import React from "react";
|
|
2
|
+
const GarfishContext = React.createContext(null);
|
|
3
3
|
const GarfishProvider = GarfishContext.Provider;
|
|
4
|
-
export {
|
|
4
|
+
export {
|
|
5
|
+
GarfishContext,
|
|
6
|
+
GarfishProvider
|
|
7
|
+
};
|