@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
|
@@ -1,352 +1,373 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length)
|
|
3
|
+
len = arr.length;
|
|
4
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
5
|
+
arr2[i] = arr[i];
|
|
6
|
+
return arr2;
|
|
5
7
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
+
function _array_without_holes(arr) {
|
|
9
|
+
if (Array.isArray(arr))
|
|
10
|
+
return _array_like_to_array(arr);
|
|
8
11
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
function _assert_this_initialized(self) {
|
|
13
|
+
if (self === void 0) {
|
|
14
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
15
|
+
}
|
|
16
|
+
return self;
|
|
14
17
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
function _class_call_check(instance, Constructor) {
|
|
19
|
+
if (!(instance instanceof Constructor)) {
|
|
20
|
+
throw new TypeError("Cannot call a class as a function");
|
|
21
|
+
}
|
|
19
22
|
}
|
|
20
23
|
function _defineProperties(target, props) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
for (var i = 0; i < props.length; i++) {
|
|
25
|
+
var descriptor = props[i];
|
|
26
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
27
|
+
descriptor.configurable = true;
|
|
28
|
+
if ("value" in descriptor)
|
|
29
|
+
descriptor.writable = true;
|
|
30
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
31
|
+
}
|
|
28
32
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
34
|
+
if (protoProps)
|
|
35
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
36
|
+
if (staticProps)
|
|
37
|
+
_defineProperties(Constructor, staticProps);
|
|
38
|
+
return Constructor;
|
|
33
39
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
function _define_property(obj, key, value) {
|
|
41
|
+
if (key in obj) {
|
|
42
|
+
Object.defineProperty(obj, key, {
|
|
43
|
+
value,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
obj[key] = value;
|
|
50
|
+
}
|
|
51
|
+
return obj;
|
|
46
52
|
}
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
53
|
+
function _get_prototype_of(o) {
|
|
54
|
+
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o2) {
|
|
55
|
+
return o2.__proto__ || Object.getPrototypeOf(o2);
|
|
56
|
+
};
|
|
57
|
+
return _get_prototype_of(o);
|
|
52
58
|
}
|
|
53
59
|
function _inherits(subClass, superClass) {
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
61
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
62
|
+
}
|
|
63
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
64
|
+
constructor: {
|
|
65
|
+
value: subClass,
|
|
66
|
+
writable: true,
|
|
67
|
+
configurable: true
|
|
56
68
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
writable: true,
|
|
61
|
-
configurable: true
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
69
|
+
});
|
|
70
|
+
if (superClass)
|
|
71
|
+
_set_prototype_of(subClass, superClass);
|
|
65
72
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
73
|
+
function _iterable_to_array(iter) {
|
|
74
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
75
|
+
return Array.from(iter);
|
|
68
76
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
77
|
+
function _non_iterable_spread() {
|
|
78
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
71
79
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
ownKeys.forEach(function(key) {
|
|
82
|
-
_defineProperty(target, key, source[key]);
|
|
83
|
-
});
|
|
80
|
+
function _object_spread(target) {
|
|
81
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
82
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
83
|
+
var ownKeys = Object.keys(source);
|
|
84
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
85
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
86
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
87
|
+
}));
|
|
84
88
|
}
|
|
85
|
-
|
|
89
|
+
ownKeys.forEach(function(key) {
|
|
90
|
+
_define_property(target, key, source[key]);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return target;
|
|
86
94
|
}
|
|
87
|
-
function
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
function _object_without_properties(source, excluded) {
|
|
96
|
+
if (source == null)
|
|
97
|
+
return {};
|
|
98
|
+
var target = _object_without_properties_loose(source, excluded);
|
|
99
|
+
var key, i;
|
|
100
|
+
if (Object.getOwnPropertySymbols) {
|
|
101
|
+
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
102
|
+
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
103
|
+
key = sourceSymbolKeys[i];
|
|
104
|
+
if (excluded.indexOf(key) >= 0)
|
|
105
|
+
continue;
|
|
106
|
+
if (!Object.prototype.propertyIsEnumerable.call(source, key))
|
|
107
|
+
continue;
|
|
108
|
+
target[key] = source[key];
|
|
99
109
|
}
|
|
100
|
-
|
|
110
|
+
}
|
|
111
|
+
return target;
|
|
101
112
|
}
|
|
102
|
-
function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
function _object_without_properties_loose(source, excluded) {
|
|
114
|
+
if (source == null)
|
|
115
|
+
return {};
|
|
116
|
+
var target = {};
|
|
117
|
+
var sourceKeys = Object.keys(source);
|
|
118
|
+
var key, i;
|
|
119
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
120
|
+
key = sourceKeys[i];
|
|
121
|
+
if (excluded.indexOf(key) >= 0)
|
|
122
|
+
continue;
|
|
123
|
+
target[key] = source[key];
|
|
124
|
+
}
|
|
125
|
+
return target;
|
|
113
126
|
}
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
function _possible_constructor_return(self, call) {
|
|
128
|
+
if (call && (_type_of(call) === "object" || typeof call === "function")) {
|
|
129
|
+
return call;
|
|
130
|
+
}
|
|
131
|
+
return _assert_this_initialized(self);
|
|
119
132
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
133
|
+
function _set_prototype_of(o, p) {
|
|
134
|
+
_set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o2, p2) {
|
|
135
|
+
o2.__proto__ = p2;
|
|
136
|
+
return o2;
|
|
137
|
+
};
|
|
138
|
+
return _set_prototype_of(o, p);
|
|
126
139
|
}
|
|
127
|
-
function
|
|
128
|
-
|
|
140
|
+
function _to_consumable_array(arr) {
|
|
141
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
129
142
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
};
|
|
134
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
135
|
-
if (!o) return;
|
|
136
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
137
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
138
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
139
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
140
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
143
|
+
function _type_of(obj) {
|
|
144
|
+
"@swc/helpers - typeof";
|
|
145
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
141
146
|
}
|
|
142
|
-
function
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
148
|
+
if (!o)
|
|
149
|
+
return;
|
|
150
|
+
if (typeof o === "string")
|
|
151
|
+
return _array_like_to_array(o, minLen);
|
|
152
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
153
|
+
if (n === "Object" && o.constructor)
|
|
154
|
+
n = o.constructor.name;
|
|
155
|
+
if (n === "Map" || n === "Set")
|
|
156
|
+
return Array.from(n);
|
|
157
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
158
|
+
return _array_like_to_array(o, minLen);
|
|
152
159
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
155
|
-
return
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
function _is_native_reflect_construct() {
|
|
161
|
+
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
162
|
+
return false;
|
|
163
|
+
if (Reflect.construct.sham)
|
|
164
|
+
return false;
|
|
165
|
+
if (typeof Proxy === "function")
|
|
166
|
+
return true;
|
|
167
|
+
try {
|
|
168
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
169
|
+
}));
|
|
170
|
+
return true;
|
|
171
|
+
} catch (e) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function _create_super(Derived) {
|
|
176
|
+
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
177
|
+
return function _createSuperInternal() {
|
|
178
|
+
var Super = _get_prototype_of(Derived), result;
|
|
179
|
+
if (hasNativeReflectConstruct) {
|
|
180
|
+
var NewTarget = _get_prototype_of(this).constructor;
|
|
181
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
182
|
+
} else {
|
|
183
|
+
result = Super.apply(this, arguments);
|
|
184
|
+
}
|
|
185
|
+
return _possible_constructor_return(this, result);
|
|
186
|
+
};
|
|
165
187
|
}
|
|
166
|
-
import { jsx } from "react/jsx-runtime";
|
|
188
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
167
189
|
import React from "react";
|
|
168
190
|
import Garfish from "garfish";
|
|
169
191
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
170
192
|
import { Loadable } from "../loadable";
|
|
171
|
-
function generateMApp(options, manifest) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
},
|
|
215
|
-
beforeMount: function beforeMount1(appInfo) {
|
|
216
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
217
|
-
args[_key - 1] = arguments[_key];
|
|
218
|
-
}
|
|
219
|
-
logger("MApp beforeMount", args);
|
|
220
|
-
if (appInfo.activeWhen) {
|
|
221
|
-
setLoadingState({
|
|
222
|
-
isLoading: false
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount.apply(void 0, [
|
|
226
|
-
appInfo
|
|
227
|
-
].concat(_toConsumableArray(args)));
|
|
228
|
-
},
|
|
229
|
-
errorLoadApp: function errorLoadApp1(error, appInfo) {
|
|
230
|
-
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
231
|
-
args[_key - 2] = arguments[_key];
|
|
232
|
-
}
|
|
233
|
-
logger("MApp errorLoadApp", error, args);
|
|
234
|
-
if (appInfo.activeWhen) {
|
|
235
|
-
setLoadingState({
|
|
236
|
-
error: error
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp.apply(void 0, [
|
|
240
|
-
error,
|
|
241
|
-
appInfo
|
|
242
|
-
].concat(_toConsumableArray(args)));
|
|
243
|
-
},
|
|
244
|
-
errorMountApp: function errorMountApp1(error, appInfo) {
|
|
245
|
-
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
246
|
-
args[_key - 2] = arguments[_key];
|
|
247
|
-
}
|
|
248
|
-
logger("MApp errorMountApp", error, args);
|
|
249
|
-
if (appInfo.activeWhen) {
|
|
250
|
-
setLoadingState({
|
|
251
|
-
error: error
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp.apply(void 0, [
|
|
255
|
-
error,
|
|
256
|
-
appInfo
|
|
257
|
-
].concat(_toConsumableArray(args)));
|
|
258
|
-
},
|
|
259
|
-
errorUnmountApp: function errorUnmountApp1(error, appInfo) {
|
|
260
|
-
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
261
|
-
args[_key - 2] = arguments[_key];
|
|
262
|
-
}
|
|
263
|
-
logger("MApp errorUnmountApp", error, args);
|
|
264
|
-
if (appInfo.activeWhen) {
|
|
265
|
-
setLoadingState({
|
|
266
|
-
error: error
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp.apply(void 0, [
|
|
270
|
-
error,
|
|
271
|
-
appInfo
|
|
272
|
-
].concat(_toConsumableArray(args)));
|
|
273
|
-
},
|
|
274
|
-
customLoader: function(provider) {
|
|
275
|
-
var render = provider.render, destroy = provider.destroy, SubModuleComponent = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
276
|
-
var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
277
|
-
return {
|
|
278
|
-
mount: function(appInfo) {
|
|
279
|
-
var transferProps = _this.filterTransferProps();
|
|
280
|
-
appInfo.props = _objectSpread({}, appInfo.props, transferProps);
|
|
281
|
-
if (componetRenderMode) {
|
|
282
|
-
_this.setState({
|
|
283
|
-
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
284
|
-
});
|
|
285
|
-
return void 0;
|
|
286
|
-
} else {
|
|
287
|
-
logger("MicroApp customer render", appInfo);
|
|
288
|
-
return render === null || render === void 0 ? void 0 : render.apply(provider, [
|
|
289
|
-
appInfo
|
|
290
|
-
]);
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
unmount: function(appInfo) {
|
|
294
|
-
var transferProps = _this.filterTransferProps();
|
|
295
|
-
appInfo.props = _objectSpread({}, appInfo.props, transferProps);
|
|
296
|
-
if (componetRenderMode) {
|
|
297
|
-
return void 0;
|
|
298
|
-
}
|
|
299
|
-
logger("MicroApp customer destroy", appInfo);
|
|
300
|
-
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
|
|
301
|
-
appInfo
|
|
302
|
-
]);
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
};
|
|
307
|
-
logger("MApp componentDidMount", {
|
|
308
|
-
garfishRunning: Garfish.running,
|
|
309
|
-
garfishOptions: garfishOptions
|
|
310
|
-
});
|
|
311
|
-
if (!Garfish.running) {
|
|
312
|
-
Garfish.run(garfishOptions);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
193
|
+
export function generateMApp(options, manifest) {
|
|
194
|
+
var MApp = /* @__PURE__ */ function(_React_Component) {
|
|
195
|
+
"use strict";
|
|
196
|
+
_inherits(MApp2, _React_Component);
|
|
197
|
+
var _super = _create_super(MApp2);
|
|
198
|
+
function MApp2() {
|
|
199
|
+
_class_call_check(this, MApp2);
|
|
200
|
+
var _this;
|
|
201
|
+
_this = _super.apply(this, arguments);
|
|
202
|
+
_define_property(_assert_this_initialized(_this), "state", {
|
|
203
|
+
domId: generateSubAppContainerKey()
|
|
204
|
+
});
|
|
205
|
+
return _this;
|
|
206
|
+
}
|
|
207
|
+
_create_class(MApp2, [
|
|
208
|
+
{
|
|
209
|
+
key: "componentDidMount",
|
|
210
|
+
value: function componentDidMount() {
|
|
211
|
+
var _this = this;
|
|
212
|
+
var domId = this.state.domId;
|
|
213
|
+
var setLoadingState = this.props.setLoadingState;
|
|
214
|
+
var beforeLoad = options.beforeLoad, beforeMount = options.beforeMount, errorLoadApp = options.errorLoadApp, errorMountApp = options.errorMountApp, errorUnmountApp = options.errorUnmountApp;
|
|
215
|
+
Garfish.router.setRouterConfig({
|
|
216
|
+
listening: true
|
|
217
|
+
});
|
|
218
|
+
var garfishOptions = {
|
|
219
|
+
domGetter: "#".concat(domId),
|
|
220
|
+
beforeLoad: function beforeLoad1(appInfo) {
|
|
221
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
222
|
+
args[_key - 1] = arguments[_key];
|
|
223
|
+
}
|
|
224
|
+
logger("MApp beforeLoad", [
|
|
225
|
+
appInfo
|
|
226
|
+
]);
|
|
227
|
+
if (appInfo.activeWhen) {
|
|
228
|
+
setLoadingState({
|
|
229
|
+
isLoading: true,
|
|
230
|
+
error: null
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return beforeLoad === null || beforeLoad === void 0 ? void 0 : beforeLoad.apply(void 0, [
|
|
234
|
+
appInfo
|
|
235
|
+
].concat(_to_consumable_array(args)));
|
|
315
236
|
},
|
|
316
|
-
{
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
237
|
+
beforeMount: function beforeMount1(appInfo) {
|
|
238
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
239
|
+
args[_key - 1] = arguments[_key];
|
|
240
|
+
}
|
|
241
|
+
logger("MApp beforeMount", args);
|
|
242
|
+
if (appInfo.activeWhen) {
|
|
243
|
+
setLoadingState({
|
|
244
|
+
isLoading: false
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
return beforeMount === null || beforeMount === void 0 ? void 0 : beforeMount.apply(void 0, [
|
|
248
|
+
appInfo
|
|
249
|
+
].concat(_to_consumable_array(args)));
|
|
324
250
|
},
|
|
325
|
-
{
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
251
|
+
errorLoadApp: function errorLoadApp1(error, appInfo) {
|
|
252
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
253
|
+
args[_key - 2] = arguments[_key];
|
|
254
|
+
}
|
|
255
|
+
logger("MApp errorLoadApp", error, args);
|
|
256
|
+
if (appInfo.activeWhen) {
|
|
257
|
+
setLoadingState({
|
|
258
|
+
error
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
return errorLoadApp === null || errorLoadApp === void 0 ? void 0 : errorLoadApp.apply(void 0, [
|
|
262
|
+
error,
|
|
263
|
+
appInfo
|
|
264
|
+
].concat(_to_consumable_array(args)));
|
|
265
|
+
},
|
|
266
|
+
errorMountApp: function errorMountApp1(error, appInfo) {
|
|
267
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
268
|
+
args[_key - 2] = arguments[_key];
|
|
269
|
+
}
|
|
270
|
+
logger("MApp errorMountApp", error, args);
|
|
271
|
+
if (appInfo.activeWhen) {
|
|
272
|
+
setLoadingState({
|
|
273
|
+
error
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
return errorMountApp === null || errorMountApp === void 0 ? void 0 : errorMountApp.apply(void 0, [
|
|
277
|
+
error,
|
|
278
|
+
appInfo
|
|
279
|
+
].concat(_to_consumable_array(args)));
|
|
334
280
|
},
|
|
335
|
-
{
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
281
|
+
errorUnmountApp: function errorUnmountApp1(error, appInfo) {
|
|
282
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
283
|
+
args[_key - 2] = arguments[_key];
|
|
284
|
+
}
|
|
285
|
+
logger("MApp errorUnmountApp", error, args);
|
|
286
|
+
if (appInfo.activeWhen) {
|
|
287
|
+
setLoadingState({
|
|
288
|
+
error
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp.apply(void 0, [
|
|
292
|
+
error,
|
|
293
|
+
appInfo
|
|
294
|
+
].concat(_to_consumable_array(args)));
|
|
295
|
+
},
|
|
296
|
+
customLoader: function(provider) {
|
|
297
|
+
var render = provider.render, destroy = provider.destroy, SubModuleComponent = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
298
|
+
var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
299
|
+
return {
|
|
300
|
+
mount: function(appInfo) {
|
|
301
|
+
var transferProps = _this.filterTransferProps();
|
|
302
|
+
appInfo.props = _object_spread({}, appInfo.props, transferProps);
|
|
303
|
+
if (componetRenderMode) {
|
|
304
|
+
_this.setState({
|
|
305
|
+
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
344
306
|
});
|
|
307
|
+
return void 0;
|
|
308
|
+
} else {
|
|
309
|
+
logger("MicroApp customer render", appInfo);
|
|
310
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, [
|
|
311
|
+
appInfo
|
|
312
|
+
]);
|
|
313
|
+
}
|
|
314
|
+
},
|
|
315
|
+
unmount: function(appInfo) {
|
|
316
|
+
var transferProps = _this.filterTransferProps();
|
|
317
|
+
appInfo.props = _object_spread({}, appInfo.props, transferProps);
|
|
318
|
+
if (componetRenderMode) {
|
|
319
|
+
return void 0;
|
|
320
|
+
}
|
|
321
|
+
logger("MicroApp customer destroy", appInfo);
|
|
322
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, [
|
|
323
|
+
appInfo
|
|
324
|
+
]);
|
|
345
325
|
}
|
|
326
|
+
};
|
|
346
327
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
328
|
+
};
|
|
329
|
+
logger("MApp componentDidMount", {
|
|
330
|
+
garfishRunning: Garfish.running,
|
|
331
|
+
garfishOptions
|
|
332
|
+
});
|
|
333
|
+
if (!Garfish.running) {
|
|
334
|
+
Garfish.run(garfishOptions);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
key: "componentWillUnmount",
|
|
340
|
+
value: function componentWillUnmount() {
|
|
341
|
+
Garfish.router.setRouterConfig({
|
|
342
|
+
listening: false
|
|
343
|
+
});
|
|
344
|
+
logger("MApp componentWillUnmount");
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
key: "filterTransferProps",
|
|
349
|
+
value: function filterTransferProps() {
|
|
350
|
+
var _this_props = this.props, style = _this_props.style, setLoadingState = _this_props.setLoadingState, others = _object_without_properties(_this_props, [
|
|
351
|
+
"style",
|
|
352
|
+
"setLoadingState"
|
|
353
|
+
]);
|
|
354
|
+
return others;
|
|
355
|
+
}
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
key: "render",
|
|
359
|
+
value: function render() {
|
|
360
|
+
var style = this.props.style;
|
|
361
|
+
var SubModuleComponent = this.state.SubModuleComponent;
|
|
362
|
+
return /* @__PURE__ */ _jsx("div", {
|
|
363
|
+
style: _object_spread({}, style),
|
|
364
|
+
id: generateSubAppContainerKey(),
|
|
365
|
+
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {})
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
]);
|
|
370
|
+
return MApp2;
|
|
371
|
+
}(React.Component);
|
|
372
|
+
return Loadable(MApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
|
|
351
373
|
}
|
|
352
|
-
export { generateMApp };
|