@modern-js/plugin-garfish 1.21.0 → 1.21.2
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 +18 -0
- package/dist/js/modern/runtime/loadable.js +1 -8
- package/dist/js/modern/runtime/plugin.js +9 -6
- package/dist/js/modern/runtime/utils/MApp.js +10 -18
- package/dist/js/node/runtime/loadable.js +0 -7
- package/dist/js/node/runtime/plugin.js +10 -7
- package/dist/js/node/runtime/utils/MApp.js +10 -17
- package/dist/js/treeshaking/runtime/loadable.js +1 -8
- package/dist/js/treeshaking/runtime/plugin.js +12 -8
- package/dist/js/treeshaking/runtime/utils/MApp.js +7 -16
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @modern-js/plugin-garfish
|
|
2
2
|
|
|
3
|
+
## 1.21.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 92501d9: fix(garfish): fix reRender issue when use apps and Garfish.run with activeWhen parameter
|
|
8
|
+
修复在同时调用 apps 和 Garfish.run 方法并提供 activeWhen 参数时重复渲染的问题
|
|
9
|
+
- @modern-js/runtime@1.21.2
|
|
10
|
+
- @modern-js/utils@1.21.2
|
|
11
|
+
|
|
12
|
+
## 1.21.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 2baa20b: fix: remove useless mount check ref
|
|
17
|
+
移除过时的确认挂载的 ref
|
|
18
|
+
- @modern-js/runtime@1.21.1
|
|
19
|
+
- @modern-js/utils@1.21.1
|
|
20
|
+
|
|
3
21
|
## 1.21.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -11,7 +11,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
11
11
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
12
12
|
|
|
13
13
|
// logical reference to https://github.com/jamiebuilds/react-loadable/blob/6201c5837b212d6244c57f3748f2b1375096beeb/src/index.js
|
|
14
|
-
import { useState,
|
|
14
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
15
15
|
import { logger } from "../util";
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -31,7 +31,6 @@ export function Loadable(WrapComponent) {
|
|
|
31
31
|
} = props,
|
|
32
32
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
33
33
|
|
|
34
|
-
const mountRef = useRef(false);
|
|
35
34
|
let delayTimer = null;
|
|
36
35
|
let timeoutTimer = null;
|
|
37
36
|
const [state, setState] = useState(() => {
|
|
@@ -70,7 +69,6 @@ export function Loadable(WrapComponent) {
|
|
|
70
69
|
});
|
|
71
70
|
const LoadingComponent = (_props$loadable = props.loadable) === null || _props$loadable === void 0 ? void 0 : _props$loadable.loading;
|
|
72
71
|
useEffect(() => {
|
|
73
|
-
mountRef.current = true;
|
|
74
72
|
logger('Loadable render state', {
|
|
75
73
|
state,
|
|
76
74
|
props: otherProps,
|
|
@@ -78,7 +76,6 @@ export function Loadable(WrapComponent) {
|
|
|
78
76
|
defaultLoadable
|
|
79
77
|
});
|
|
80
78
|
return () => {
|
|
81
|
-
mountRef.current = false;
|
|
82
79
|
setStateWithMountCheck({
|
|
83
80
|
isLoading: false,
|
|
84
81
|
error: null
|
|
@@ -103,10 +100,6 @@ export function Loadable(WrapComponent) {
|
|
|
103
100
|
}));
|
|
104
101
|
}, [state]);
|
|
105
102
|
const setStateWithMountCheck = useCallback(newState => {
|
|
106
|
-
if (!mountRef.current) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
103
|
setState(state => _objectSpread(_objectSpread({}, state), newState));
|
|
111
104
|
}, [state]);
|
|
112
105
|
const showLoading = (state.isLoading || state.error) && LoadingComponent;
|
|
@@ -93,18 +93,21 @@ export default (config => ({
|
|
|
93
93
|
});
|
|
94
94
|
|
|
95
95
|
const load = async () => {
|
|
96
|
+
GarfishInstance.setOptions(_objectSpread(_objectSpread({}, options), {}, {
|
|
97
|
+
insulationVariable: [...(options.insulationVariable || []), '_SERVER_DATA'],
|
|
98
|
+
apps: []
|
|
99
|
+
}));
|
|
96
100
|
const GarfishConfig = await promise;
|
|
97
|
-
logger('initOptions result', {
|
|
98
|
-
manifest,
|
|
99
|
-
GarfishConfig
|
|
100
|
-
});
|
|
101
|
-
const MApp = generateMApp(GarfishConfig, manifest);
|
|
102
101
|
const {
|
|
103
102
|
appInfoList,
|
|
104
103
|
apps
|
|
105
104
|
} = generateApps(GarfishConfig, manifest);
|
|
106
|
-
GarfishInstance.setOptions(GarfishConfig);
|
|
107
105
|
GarfishInstance.registerApp(appInfoList);
|
|
106
|
+
const MApp = generateMApp(GarfishConfig, manifest);
|
|
107
|
+
logger('initOptions result', {
|
|
108
|
+
manifest,
|
|
109
|
+
GarfishConfig
|
|
110
|
+
});
|
|
108
111
|
logger('generateApps', {
|
|
109
112
|
MApp,
|
|
110
113
|
apps,
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
const _excluded = ["
|
|
2
|
-
_excluded2 = ["style", "setLoadingState"];
|
|
3
|
-
|
|
4
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
-
|
|
6
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1
|
+
const _excluded = ["style", "setLoadingState"];
|
|
7
2
|
|
|
8
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
9
4
|
|
|
10
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
11
6
|
|
|
7
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
+
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
|
|
12
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
12
|
|
|
14
13
|
import React from 'react'; // eslint-disable-next-line import/no-named-as-default
|
|
@@ -34,22 +33,18 @@ export function generateMApp(options, manifest) {
|
|
|
34
33
|
const {
|
|
35
34
|
setLoadingState
|
|
36
35
|
} = this.props;
|
|
37
|
-
|
|
38
36
|
const {
|
|
39
37
|
beforeLoad,
|
|
40
38
|
beforeMount,
|
|
41
39
|
errorLoadApp,
|
|
42
40
|
errorMountApp,
|
|
43
41
|
errorUnmountApp
|
|
44
|
-
} = options
|
|
45
|
-
otherOptions = _objectWithoutProperties(options, _excluded); // start auto render able
|
|
46
|
-
|
|
42
|
+
} = options; // start auto render able
|
|
47
43
|
|
|
48
44
|
Garfish.router.setRouterConfig({
|
|
49
45
|
listening: true
|
|
50
46
|
});
|
|
51
|
-
|
|
52
|
-
const garfishOptions = _objectSpread(_objectSpread({
|
|
47
|
+
const garfishOptions = {
|
|
53
48
|
domGetter: `#${domId}`,
|
|
54
49
|
|
|
55
50
|
beforeLoad(appInfo, ...args) {
|
|
@@ -111,10 +106,8 @@ export function generateMApp(options, manifest) {
|
|
|
111
106
|
}
|
|
112
107
|
|
|
113
108
|
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
|
|
114
|
-
}
|
|
109
|
+
},
|
|
115
110
|
|
|
116
|
-
}, otherOptions), {}, {
|
|
117
|
-
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA'],
|
|
118
111
|
customLoader: provider => {
|
|
119
112
|
const {
|
|
120
113
|
render,
|
|
@@ -151,8 +144,7 @@ export function generateMApp(options, manifest) {
|
|
|
151
144
|
}
|
|
152
145
|
};
|
|
153
146
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
147
|
+
};
|
|
156
148
|
logger('MApp componentDidMount', {
|
|
157
149
|
garfishRunning: Garfish.running,
|
|
158
150
|
garfishOptions
|
|
@@ -177,7 +169,7 @@ export function generateMApp(options, manifest) {
|
|
|
177
169
|
style,
|
|
178
170
|
setLoadingState
|
|
179
171
|
} = _this$props,
|
|
180
|
-
others = _objectWithoutProperties(_this$props,
|
|
172
|
+
others = _objectWithoutProperties(_this$props, _excluded);
|
|
181
173
|
|
|
182
174
|
return others;
|
|
183
175
|
}
|
|
@@ -39,7 +39,6 @@ function Loadable(WrapComponent) {
|
|
|
39
39
|
} = props,
|
|
40
40
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
41
41
|
|
|
42
|
-
const mountRef = (0, _react.useRef)(false);
|
|
43
42
|
let delayTimer = null;
|
|
44
43
|
let timeoutTimer = null;
|
|
45
44
|
const [state, setState] = (0, _react.useState)(() => {
|
|
@@ -78,7 +77,6 @@ function Loadable(WrapComponent) {
|
|
|
78
77
|
});
|
|
79
78
|
const LoadingComponent = (_props$loadable = props.loadable) === null || _props$loadable === void 0 ? void 0 : _props$loadable.loading;
|
|
80
79
|
(0, _react.useEffect)(() => {
|
|
81
|
-
mountRef.current = true;
|
|
82
80
|
(0, _util.logger)('Loadable render state', {
|
|
83
81
|
state,
|
|
84
82
|
props: otherProps,
|
|
@@ -86,7 +84,6 @@ function Loadable(WrapComponent) {
|
|
|
86
84
|
defaultLoadable
|
|
87
85
|
});
|
|
88
86
|
return () => {
|
|
89
|
-
mountRef.current = false;
|
|
90
87
|
setStateWithMountCheck({
|
|
91
88
|
isLoading: false,
|
|
92
89
|
error: null
|
|
@@ -111,10 +108,6 @@ function Loadable(WrapComponent) {
|
|
|
111
108
|
}));
|
|
112
109
|
}, [state]);
|
|
113
110
|
const setStateWithMountCheck = (0, _react.useCallback)(newState => {
|
|
114
|
-
if (!mountRef.current) {
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
111
|
setState(state => _objectSpread(_objectSpread({}, state), newState));
|
|
119
112
|
}, [state]);
|
|
120
113
|
const showLoading = (state.isLoading || state.error) && LoadingComponent;
|
|
@@ -110,21 +110,24 @@ var _default = config => ({
|
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
const load = async () => {
|
|
113
|
+
_garfish.default.setOptions(_objectSpread(_objectSpread({}, options), {}, {
|
|
114
|
+
insulationVariable: [...(options.insulationVariable || []), '_SERVER_DATA'],
|
|
115
|
+
apps: []
|
|
116
|
+
}));
|
|
117
|
+
|
|
113
118
|
const GarfishConfig = await promise;
|
|
114
|
-
(0, _util.logger)('initOptions result', {
|
|
115
|
-
manifest,
|
|
116
|
-
GarfishConfig
|
|
117
|
-
});
|
|
118
|
-
const MApp = (0, _MApp.generateMApp)(GarfishConfig, manifest);
|
|
119
119
|
const {
|
|
120
120
|
appInfoList,
|
|
121
121
|
apps
|
|
122
122
|
} = (0, _apps.generateApps)(GarfishConfig, manifest);
|
|
123
123
|
|
|
124
|
-
_garfish.default.setOptions(GarfishConfig);
|
|
125
|
-
|
|
126
124
|
_garfish.default.registerApp(appInfoList);
|
|
127
125
|
|
|
126
|
+
const MApp = (0, _MApp.generateMApp)(GarfishConfig, manifest);
|
|
127
|
+
(0, _util.logger)('initOptions result', {
|
|
128
|
+
manifest,
|
|
129
|
+
GarfishConfig
|
|
130
|
+
});
|
|
128
131
|
(0, _util.logger)('generateApps', {
|
|
129
132
|
MApp,
|
|
130
133
|
apps,
|
|
@@ -15,19 +15,18 @@ var _loadable = require("../loadable");
|
|
|
15
15
|
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
|
|
18
|
-
const _excluded = ["
|
|
19
|
-
_excluded2 = ["style", "setLoadingState"];
|
|
18
|
+
const _excluded = ["style", "setLoadingState"];
|
|
20
19
|
|
|
21
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
21
|
|
|
23
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
-
|
|
25
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
|
-
|
|
27
22
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
28
23
|
|
|
29
24
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
30
25
|
|
|
26
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
27
|
+
|
|
28
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
29
|
+
|
|
31
30
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
32
31
|
|
|
33
32
|
function generateMApp(options, manifest) {
|
|
@@ -47,22 +46,19 @@ function generateMApp(options, manifest) {
|
|
|
47
46
|
const {
|
|
48
47
|
setLoadingState
|
|
49
48
|
} = this.props;
|
|
50
|
-
|
|
51
49
|
const {
|
|
52
50
|
beforeLoad,
|
|
53
51
|
beforeMount,
|
|
54
52
|
errorLoadApp,
|
|
55
53
|
errorMountApp,
|
|
56
54
|
errorUnmountApp
|
|
57
|
-
} = options
|
|
58
|
-
otherOptions = _objectWithoutProperties(options, _excluded); // start auto render able
|
|
59
|
-
|
|
55
|
+
} = options; // start auto render able
|
|
60
56
|
|
|
61
57
|
_garfish.default.router.setRouterConfig({
|
|
62
58
|
listening: true
|
|
63
59
|
});
|
|
64
60
|
|
|
65
|
-
const garfishOptions =
|
|
61
|
+
const garfishOptions = {
|
|
66
62
|
domGetter: `#${domId}`,
|
|
67
63
|
|
|
68
64
|
beforeLoad(appInfo, ...args) {
|
|
@@ -124,10 +120,8 @@ function generateMApp(options, manifest) {
|
|
|
124
120
|
}
|
|
125
121
|
|
|
126
122
|
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, appInfo, ...args);
|
|
127
|
-
}
|
|
123
|
+
},
|
|
128
124
|
|
|
129
|
-
}, otherOptions), {}, {
|
|
130
|
-
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA'],
|
|
131
125
|
customLoader: provider => {
|
|
132
126
|
const {
|
|
133
127
|
render,
|
|
@@ -164,8 +158,7 @@ function generateMApp(options, manifest) {
|
|
|
164
158
|
}
|
|
165
159
|
};
|
|
166
160
|
}
|
|
167
|
-
}
|
|
168
|
-
|
|
161
|
+
};
|
|
169
162
|
(0, _util.logger)('MApp componentDidMount', {
|
|
170
163
|
garfishRunning: _garfish.default.running,
|
|
171
164
|
garfishOptions
|
|
@@ -191,7 +184,7 @@ function generateMApp(options, manifest) {
|
|
|
191
184
|
style,
|
|
192
185
|
setLoadingState
|
|
193
186
|
} = _this$props,
|
|
194
|
-
others = _objectWithoutProperties(_this$props,
|
|
187
|
+
others = _objectWithoutProperties(_this$props, _excluded);
|
|
195
188
|
|
|
196
189
|
return others;
|
|
197
190
|
}
|
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
4
|
var _excluded = ["loadable"];
|
|
5
5
|
// logical reference to https://github.com/jamiebuilds/react-loadable/blob/6201c5837b212d6244c57f3748f2b1375096beeb/src/index.js
|
|
6
|
-
import { useState,
|
|
6
|
+
import { useState, useEffect, useCallback } from 'react';
|
|
7
7
|
import { logger } from "../util";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -22,7 +22,6 @@ export function Loadable(WrapComponent) {
|
|
|
22
22
|
loadable = _props$loadable === void 0 ? defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE : _props$loadable,
|
|
23
23
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
24
24
|
|
|
25
|
-
var mountRef = useRef(false);
|
|
26
25
|
var delayTimer = null;
|
|
27
26
|
var timeoutTimer = null;
|
|
28
27
|
|
|
@@ -64,7 +63,6 @@ export function Loadable(WrapComponent) {
|
|
|
64
63
|
|
|
65
64
|
var LoadingComponent = (_props$loadable2 = props.loadable) === null || _props$loadable2 === void 0 ? void 0 : _props$loadable2.loading;
|
|
66
65
|
useEffect(function () {
|
|
67
|
-
mountRef.current = true;
|
|
68
66
|
logger('Loadable render state', {
|
|
69
67
|
state: state,
|
|
70
68
|
props: otherProps,
|
|
@@ -72,7 +70,6 @@ export function Loadable(WrapComponent) {
|
|
|
72
70
|
defaultLoadable: defaultLoadable
|
|
73
71
|
});
|
|
74
72
|
return function () {
|
|
75
|
-
mountRef.current = false;
|
|
76
73
|
setStateWithMountCheck({
|
|
77
74
|
isLoading: false,
|
|
78
75
|
error: null
|
|
@@ -97,10 +94,6 @@ export function Loadable(WrapComponent) {
|
|
|
97
94
|
}));
|
|
98
95
|
}, [state]);
|
|
99
96
|
var setStateWithMountCheck = useCallback(function (newState) {
|
|
100
|
-
if (!mountRef.current) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
97
|
setState(function (state) {
|
|
105
98
|
return _objectSpread(_objectSpread({}, state), newState);
|
|
106
99
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
1
|
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
|
|
2
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
5
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
6
|
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
@@ -135,25 +136,28 @@ export default (function (config) {
|
|
|
135
136
|
|
|
136
137
|
var load = /*#__PURE__*/function () {
|
|
137
138
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
138
|
-
var GarfishConfig,
|
|
139
|
+
var GarfishConfig, _generateApps, appInfoList, apps, MApp;
|
|
139
140
|
|
|
140
141
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
141
142
|
while (1) {
|
|
142
143
|
switch (_context.prev = _context.next) {
|
|
143
144
|
case 0:
|
|
144
|
-
|
|
145
|
+
GarfishInstance.setOptions(_objectSpread(_objectSpread({}, options), {}, {
|
|
146
|
+
insulationVariable: [].concat(_toConsumableArray(options.insulationVariable || []), ['_SERVER_DATA']),
|
|
147
|
+
apps: []
|
|
148
|
+
}));
|
|
149
|
+
_context.next = 3;
|
|
145
150
|
return promise;
|
|
146
151
|
|
|
147
|
-
case
|
|
152
|
+
case 3:
|
|
148
153
|
GarfishConfig = _context.sent;
|
|
154
|
+
_generateApps = generateApps(GarfishConfig, manifest), appInfoList = _generateApps.appInfoList, apps = _generateApps.apps;
|
|
155
|
+
GarfishInstance.registerApp(appInfoList);
|
|
156
|
+
MApp = generateMApp(GarfishConfig, manifest);
|
|
149
157
|
logger('initOptions result', {
|
|
150
158
|
manifest: manifest,
|
|
151
159
|
GarfishConfig: GarfishConfig
|
|
152
160
|
});
|
|
153
|
-
MApp = generateMApp(GarfishConfig, manifest);
|
|
154
|
-
_generateApps = generateApps(GarfishConfig, manifest), appInfoList = _generateApps.appInfoList, apps = _generateApps.apps;
|
|
155
|
-
GarfishInstance.setOptions(GarfishConfig);
|
|
156
|
-
GarfishInstance.registerApp(appInfoList);
|
|
157
161
|
logger('generateApps', {
|
|
158
162
|
MApp: MApp,
|
|
159
163
|
apps: apps,
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
1
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
5
|
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
7
6
|
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
7
|
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
9
8
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
10
|
-
var _excluded = ["
|
|
11
|
-
_excluded2 = ["style", "setLoadingState"];
|
|
9
|
+
var _excluded = ["style", "setLoadingState"];
|
|
12
10
|
import React from 'react'; // eslint-disable-next-line import/no-named-as-default
|
|
13
11
|
|
|
14
12
|
import Garfish from 'garfish';
|
|
@@ -46,20 +44,16 @@ export function generateMApp(options, manifest) {
|
|
|
46
44
|
|
|
47
45
|
var domId = this.state.domId;
|
|
48
46
|
var setLoadingState = this.props.setLoadingState;
|
|
49
|
-
|
|
50
47
|
var _beforeLoad = options.beforeLoad,
|
|
51
48
|
_beforeMount = options.beforeMount,
|
|
52
49
|
_errorLoadApp = options.errorLoadApp,
|
|
53
50
|
_errorMountApp = options.errorMountApp,
|
|
54
|
-
_errorUnmountApp = options.errorUnmountApp
|
|
55
|
-
otherOptions = _objectWithoutProperties(options, _excluded); // start auto render able
|
|
56
|
-
|
|
51
|
+
_errorUnmountApp = options.errorUnmountApp; // start auto render able
|
|
57
52
|
|
|
58
53
|
Garfish.router.setRouterConfig({
|
|
59
54
|
listening: true
|
|
60
55
|
});
|
|
61
|
-
|
|
62
|
-
var garfishOptions = _objectSpread(_objectSpread({
|
|
56
|
+
var garfishOptions = {
|
|
63
57
|
domGetter: "#".concat(domId),
|
|
64
58
|
beforeLoad: function beforeLoad(appInfo) {
|
|
65
59
|
logger('MApp beforeLoad', [appInfo]);
|
|
@@ -136,9 +130,7 @@ export function generateMApp(options, manifest) {
|
|
|
136
130
|
}
|
|
137
131
|
|
|
138
132
|
return _errorUnmountApp === null || _errorUnmountApp === void 0 ? void 0 : _errorUnmountApp.apply(void 0, [error, appInfo].concat(args));
|
|
139
|
-
}
|
|
140
|
-
}, otherOptions), {}, {
|
|
141
|
-
insulationVariable: [].concat(_toConsumableArray(otherOptions.insulationVariable || []), ['_SERVER_DATA']),
|
|
133
|
+
},
|
|
142
134
|
customLoader: function customLoader(provider) {
|
|
143
135
|
var render = provider.render,
|
|
144
136
|
destroy = provider.destroy,
|
|
@@ -176,8 +168,7 @@ export function generateMApp(options, manifest) {
|
|
|
176
168
|
}
|
|
177
169
|
};
|
|
178
170
|
}
|
|
179
|
-
}
|
|
180
|
-
|
|
171
|
+
};
|
|
181
172
|
logger('MApp componentDidMount', {
|
|
182
173
|
garfishRunning: Garfish.running,
|
|
183
174
|
garfishOptions: garfishOptions
|
|
@@ -202,7 +193,7 @@ export function generateMApp(options, manifest) {
|
|
|
202
193
|
var _this$props = this.props,
|
|
203
194
|
style = _this$props.style,
|
|
204
195
|
setLoadingState = _this$props.setLoadingState,
|
|
205
|
-
others = _objectWithoutProperties(_this$props,
|
|
196
|
+
others = _objectWithoutProperties(_this$props, _excluded);
|
|
206
197
|
|
|
207
198
|
return others;
|
|
208
199
|
}
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.21.
|
|
14
|
+
"version": "1.21.2",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/runtime/index.d.ts",
|
|
17
17
|
"typesVersions": {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@babel/runtime": "^7.18.0",
|
|
53
|
-
"@modern-js/utils": "1.21.
|
|
53
|
+
"@modern-js/utils": "1.21.2",
|
|
54
54
|
"@types/debug": "^4.1.7",
|
|
55
55
|
"@types/react-loadable": "^5.5.6",
|
|
56
56
|
"debug": "^4.3.2",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"react-loadable": "^5.5.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@modern-js/runtime": "^1.21.
|
|
62
|
+
"@modern-js/runtime": "^1.21.2"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
65
65
|
"@modern-js/runtime": {
|
|
@@ -67,11 +67,11 @@
|
|
|
67
67
|
}
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@modern-js/core": "1.21.
|
|
71
|
-
"@modern-js/runtime": "1.21.
|
|
72
|
-
"@modern-js/types": "1.21.
|
|
73
|
-
"@scripts/build": "1.21.
|
|
74
|
-
"@scripts/jest-config": "1.21.
|
|
70
|
+
"@modern-js/core": "1.21.2",
|
|
71
|
+
"@modern-js/runtime": "1.21.2",
|
|
72
|
+
"@modern-js/types": "1.21.2",
|
|
73
|
+
"@scripts/build": "1.21.2",
|
|
74
|
+
"@scripts/jest-config": "1.21.2",
|
|
75
75
|
"@testing-library/jest-dom": "^5.16.1",
|
|
76
76
|
"@testing-library/react": "^12.0.0",
|
|
77
77
|
"@testing-library/react-hooks": "^7.0.1",
|