@modern-js/plugin-garfish 2.0.0-beta.5 → 2.0.0-beta.6
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 +75 -0
- package/dist/js/modern/runtime/plugin.js +1 -1
- package/dist/js/modern/runtime/utils/apps.js +124 -138
- package/dist/js/node/runtime/plugin.js +1 -1
- package/dist/js/node/runtime/utils/apps.js +125 -140
- package/dist/js/treeshaking/runtime/plugin.js +1 -1
- package/dist/js/treeshaking/runtime/utils/apps.js +287 -229
- package/dist/types/runtime/loadable.d.ts +2 -1
- package/dist/types/runtime/utils/apps.d.ts +0 -1
- package/package.json +13 -14
|
@@ -3,12 +3,15 @@ function _arrayLikeToArray(arr, len) {
|
|
|
3
3
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
4
|
return arr2;
|
|
5
5
|
}
|
|
6
|
-
function _arrayWithHoles(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
6
|
function _arrayWithoutHoles(arr) {
|
|
10
7
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
11
8
|
}
|
|
9
|
+
function _assertThisInitialized(self) {
|
|
10
|
+
if (self === void 0) {
|
|
11
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
12
|
+
}
|
|
13
|
+
return self;
|
|
14
|
+
}
|
|
12
15
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
13
16
|
try {
|
|
14
17
|
var info = gen[key](arg);
|
|
@@ -38,6 +41,25 @@ function _asyncToGenerator(fn) {
|
|
|
38
41
|
});
|
|
39
42
|
};
|
|
40
43
|
}
|
|
44
|
+
function _classCallCheck(instance, Constructor) {
|
|
45
|
+
if (!(instance instanceof Constructor)) {
|
|
46
|
+
throw new TypeError("Cannot call a class as a function");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function _defineProperties(target, props) {
|
|
50
|
+
for(var i = 0; i < props.length; i++){
|
|
51
|
+
var descriptor = props[i];
|
|
52
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
53
|
+
descriptor.configurable = true;
|
|
54
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
55
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
59
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
60
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
61
|
+
return Constructor;
|
|
62
|
+
}
|
|
41
63
|
function _defineProperty(obj, key, value) {
|
|
42
64
|
if (key in obj) {
|
|
43
65
|
Object.defineProperty(obj, key, {
|
|
@@ -51,35 +73,27 @@ function _defineProperty(obj, key, value) {
|
|
|
51
73
|
}
|
|
52
74
|
return obj;
|
|
53
75
|
}
|
|
54
|
-
function
|
|
55
|
-
|
|
76
|
+
function _getPrototypeOf(o) {
|
|
77
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
78
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
79
|
+
};
|
|
80
|
+
return _getPrototypeOf(o);
|
|
56
81
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
var _arr = [];
|
|
61
|
-
var _n = true;
|
|
62
|
-
var _d = false;
|
|
63
|
-
var _s, _e;
|
|
64
|
-
try {
|
|
65
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
66
|
-
_arr.push(_s.value);
|
|
67
|
-
if (i && _arr.length === i) break;
|
|
68
|
-
}
|
|
69
|
-
} catch (err) {
|
|
70
|
-
_d = true;
|
|
71
|
-
_e = err;
|
|
72
|
-
} finally{
|
|
73
|
-
try {
|
|
74
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
75
|
-
} finally{
|
|
76
|
-
if (_d) throw _e;
|
|
77
|
-
}
|
|
82
|
+
function _inherits(subClass, superClass) {
|
|
83
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
84
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
78
85
|
}
|
|
79
|
-
|
|
86
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
87
|
+
constructor: {
|
|
88
|
+
value: subClass,
|
|
89
|
+
writable: true,
|
|
90
|
+
configurable: true
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
80
94
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
95
|
+
function _iterableToArray(iter) {
|
|
96
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
83
97
|
}
|
|
84
98
|
function _nonIterableSpread() {
|
|
85
99
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
@@ -150,12 +164,26 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
150
164
|
}
|
|
151
165
|
return target;
|
|
152
166
|
}
|
|
153
|
-
function
|
|
154
|
-
|
|
167
|
+
function _possibleConstructorReturn(self, call) {
|
|
168
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
169
|
+
return call;
|
|
170
|
+
}
|
|
171
|
+
return _assertThisInitialized(self);
|
|
172
|
+
}
|
|
173
|
+
function _setPrototypeOf(o, p) {
|
|
174
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
175
|
+
o.__proto__ = p;
|
|
176
|
+
return o;
|
|
177
|
+
};
|
|
178
|
+
return _setPrototypeOf(o, p);
|
|
155
179
|
}
|
|
156
180
|
function _toConsumableArray(arr) {
|
|
157
181
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
158
182
|
}
|
|
183
|
+
var _typeof = function(obj) {
|
|
184
|
+
"@swc/helpers - typeof";
|
|
185
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
186
|
+
};
|
|
159
187
|
function _unsupportedIterableToArray(o, minLen) {
|
|
160
188
|
if (!o) return;
|
|
161
189
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -164,6 +192,30 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
164
192
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
165
193
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
166
194
|
}
|
|
195
|
+
function _isNativeReflectConstruct() {
|
|
196
|
+
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
197
|
+
if (Reflect.construct.sham) return false;
|
|
198
|
+
if (typeof Proxy === "function") return true;
|
|
199
|
+
try {
|
|
200
|
+
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
201
|
+
return true;
|
|
202
|
+
} catch (e) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function _createSuper(Derived) {
|
|
207
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
208
|
+
return function _createSuperInternal() {
|
|
209
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
210
|
+
if (hasNativeReflectConstruct) {
|
|
211
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
212
|
+
result = Reflect.construct(Super, arguments, NewTarget);
|
|
213
|
+
} else {
|
|
214
|
+
result = Super.apply(this, arguments);
|
|
215
|
+
}
|
|
216
|
+
return _possibleConstructorReturn(this, result);
|
|
217
|
+
};
|
|
218
|
+
}
|
|
167
219
|
var __generator = this && this.__generator || function(thisArg, body) {
|
|
168
220
|
var f, y, t, g, _ = {
|
|
169
221
|
label: 0,
|
|
@@ -260,213 +312,219 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
260
312
|
}
|
|
261
313
|
};
|
|
262
314
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
263
|
-
import
|
|
264
|
-
import
|
|
315
|
+
import path from "path";
|
|
316
|
+
import React from "react";
|
|
265
317
|
import Garfish from "garfish";
|
|
318
|
+
import { withRouter } from "@modern-js/plugin-router-v5/runtime";
|
|
266
319
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
267
320
|
import { Loadable } from "../loadable";
|
|
268
|
-
function pathJoin() {
|
|
269
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
270
|
-
args[_key] = arguments[_key];
|
|
271
|
-
}
|
|
272
|
-
var res = args.reduce(function(res2, path) {
|
|
273
|
-
var nPath = path;
|
|
274
|
-
if (!nPath || typeof nPath !== "string") {
|
|
275
|
-
return res2;
|
|
276
|
-
}
|
|
277
|
-
if (nPath[0] !== "/") {
|
|
278
|
-
nPath = "/".concat(nPath);
|
|
279
|
-
}
|
|
280
|
-
var lastIndex = path.length - 1;
|
|
281
|
-
if (nPath[lastIndex] === "/") {
|
|
282
|
-
nPath = nPath.substring(0, lastIndex);
|
|
283
|
-
}
|
|
284
|
-
return res2 + nPath;
|
|
285
|
-
}, "");
|
|
286
|
-
return res || "/";
|
|
287
|
-
}
|
|
288
321
|
function getAppInstance(options, appInfo, manifest) {
|
|
289
|
-
var
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
var
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
322
|
+
var locationHref = "";
|
|
323
|
+
var MicroApp = /*#__PURE__*/ function(_Component) {
|
|
324
|
+
"use strict";
|
|
325
|
+
_inherits(MicroApp, _Component);
|
|
326
|
+
var _super = _createSuper(MicroApp);
|
|
327
|
+
function MicroApp() {
|
|
328
|
+
_classCallCheck(this, MicroApp);
|
|
329
|
+
var _this;
|
|
330
|
+
_this = _super.apply(this, arguments);
|
|
331
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
332
|
+
appInstance: null,
|
|
333
|
+
domId: generateSubAppContainerKey(appInfo),
|
|
334
|
+
SubModuleComponent: void 0
|
|
335
|
+
});
|
|
336
|
+
_defineProperty(_assertThisInitialized(_this), "unregisterHistoryListener", function() {});
|
|
337
|
+
return _this;
|
|
303
338
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
339
|
+
_createClass(MicroApp, [
|
|
340
|
+
{
|
|
341
|
+
key: "componentDidMount",
|
|
342
|
+
value: function componentDidMount() {
|
|
343
|
+
var _this = this;
|
|
344
|
+
return _asyncToGenerator(function() {
|
|
345
|
+
var _props, match, history, setLoadingState, userProps, domId, loadAppOptions, appInstance, error;
|
|
346
|
+
return __generator(this, function(_state) {
|
|
347
|
+
switch(_state.label){
|
|
348
|
+
case 0:
|
|
349
|
+
_props = _this.props, match = _props.match, history = _props.history, setLoadingState = _props.setLoadingState, userProps = _objectWithoutProperties(_props, [
|
|
350
|
+
"match",
|
|
351
|
+
"history",
|
|
352
|
+
"setLoadingState"
|
|
353
|
+
]);
|
|
354
|
+
domId = _this.state.domId;
|
|
355
|
+
loadAppOptions = _objectSpreadProps(_objectSpread({}, appInfo), {
|
|
356
|
+
insulationVariable: _toConsumableArray(appInfo.insulationVariable || []).concat([
|
|
357
|
+
"_SERVER_DATA"
|
|
358
|
+
]),
|
|
359
|
+
domGetter: "#".concat(domId),
|
|
360
|
+
basename: path.join((options === null || options === void 0 ? void 0 : options.basename) || "/", (match === null || match === void 0 ? void 0 : match.path) || "/"),
|
|
361
|
+
cache: true,
|
|
362
|
+
props: _objectSpread({}, appInfo.props, userProps),
|
|
363
|
+
customLoader: function(provider) {
|
|
364
|
+
var render = provider.render, destroy = provider.destroy, SubModuleComponent = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
365
|
+
var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent || jupiter_submodule_app_key);
|
|
366
|
+
return {
|
|
367
|
+
mount: function() {
|
|
368
|
+
for(var _len = arguments.length, props = new Array(_len), _key = 0; _key < _len; _key++){
|
|
369
|
+
props[_key] = arguments[_key];
|
|
370
|
+
}
|
|
371
|
+
if (componetRenderMode) {
|
|
372
|
+
_this.setState({
|
|
373
|
+
SubModuleComponent: SubModuleComponent !== null && SubModuleComponent !== void 0 ? SubModuleComponent : jupiter_submodule_app_key
|
|
374
|
+
});
|
|
375
|
+
return void 0;
|
|
376
|
+
} else {
|
|
377
|
+
logger("MicroApp customer render", props);
|
|
378
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props);
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
unmount: function unmount() {
|
|
382
|
+
for(var _len = arguments.length, props = new Array(_len), _key = 0; _key < _len; _key++){
|
|
383
|
+
props[_key] = arguments[_key];
|
|
384
|
+
}
|
|
385
|
+
if (componetRenderMode) {
|
|
386
|
+
return void 0;
|
|
387
|
+
}
|
|
388
|
+
logger("MicroApp customer destroy", props);
|
|
389
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props);
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
setLoadingState({
|
|
395
|
+
isLoading: true,
|
|
396
|
+
error: null
|
|
397
|
+
});
|
|
398
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '"'), {
|
|
399
|
+
loadAppOptions: loadAppOptions
|
|
400
|
+
});
|
|
401
|
+
_state.label = 1;
|
|
402
|
+
case 1:
|
|
403
|
+
_state.trys.push([
|
|
404
|
+
1,
|
|
405
|
+
7,
|
|
406
|
+
,
|
|
407
|
+
8
|
|
408
|
+
]);
|
|
409
|
+
return [
|
|
410
|
+
4,
|
|
411
|
+
Garfish.loadApp(appInfo.name, loadAppOptions)
|
|
412
|
+
];
|
|
413
|
+
case 2:
|
|
414
|
+
appInstance = _state.sent();
|
|
415
|
+
if (!appInstance) {
|
|
416
|
+
throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
|
|
417
|
+
}
|
|
418
|
+
_this.setState({
|
|
419
|
+
appInstance: appInstance
|
|
420
|
+
});
|
|
421
|
+
setLoadingState({
|
|
422
|
+
isLoading: false
|
|
423
|
+
});
|
|
424
|
+
if (!(appInstance.mounted && appInstance.appInfo.cache)) return [
|
|
425
|
+
3,
|
|
426
|
+
4
|
|
427
|
+
];
|
|
428
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" show'), {
|
|
429
|
+
appInfo: appInstance.appInfo,
|
|
430
|
+
appInstance: appInstance
|
|
431
|
+
});
|
|
432
|
+
return [
|
|
433
|
+
4,
|
|
434
|
+
appInstance === null || appInstance === void 0 ? void 0 : appInstance.show()
|
|
435
|
+
];
|
|
436
|
+
case 3:
|
|
437
|
+
_state.sent();
|
|
438
|
+
return [
|
|
439
|
+
3,
|
|
440
|
+
6
|
|
441
|
+
];
|
|
442
|
+
case 4:
|
|
443
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" mount'), {
|
|
444
|
+
appInfo: appInstance.appInfo,
|
|
445
|
+
appInstance: appInstance
|
|
446
|
+
});
|
|
447
|
+
return [
|
|
448
|
+
4,
|
|
449
|
+
appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount()
|
|
450
|
+
];
|
|
451
|
+
case 5:
|
|
452
|
+
_state.sent();
|
|
453
|
+
_state.label = 6;
|
|
454
|
+
case 6:
|
|
455
|
+
_this.unregisterHistoryListener = history === null || history === void 0 ? void 0 : history.listen(function() {
|
|
456
|
+
if (locationHref !== history.location.pathname) {
|
|
457
|
+
locationHref = history.location.pathname;
|
|
458
|
+
var popStateEvent = new PopStateEvent("popstate");
|
|
459
|
+
dispatchEvent(popStateEvent);
|
|
460
|
+
logger("MicroApp Garfish.loadApp popstate");
|
|
461
|
+
}
|
|
462
|
+
});
|
|
463
|
+
return [
|
|
464
|
+
3,
|
|
465
|
+
8
|
|
466
|
+
];
|
|
467
|
+
case 7:
|
|
468
|
+
error = _state.sent();
|
|
469
|
+
setLoadingState({
|
|
470
|
+
isLoading: true,
|
|
471
|
+
error: error
|
|
472
|
+
});
|
|
473
|
+
return [
|
|
474
|
+
3,
|
|
475
|
+
8
|
|
476
|
+
];
|
|
477
|
+
case 8:
|
|
478
|
+
return [
|
|
479
|
+
2
|
|
480
|
+
];
|
|
349
481
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
};
|
|
482
|
+
});
|
|
483
|
+
})();
|
|
354
484
|
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
0,
|
|
374
|
-
6,
|
|
375
|
-
,
|
|
376
|
-
7
|
|
377
|
-
]);
|
|
378
|
-
return [
|
|
379
|
-
4,
|
|
380
|
-
Garfish.loadApp(appInfo.name, loadAppOptions)
|
|
381
|
-
];
|
|
382
|
-
case 1:
|
|
383
|
-
appInstance = _state.sent();
|
|
384
|
-
if (!appInstance) {
|
|
385
|
-
throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
|
|
485
|
+
},
|
|
486
|
+
{
|
|
487
|
+
key: "componentWillUnmount",
|
|
488
|
+
value: function componentWillUnmount() {
|
|
489
|
+
var _this = this;
|
|
490
|
+
return _asyncToGenerator(function() {
|
|
491
|
+
var _obj, ref, appInstance, appInfo2;
|
|
492
|
+
return __generator(this, function(_state) {
|
|
493
|
+
appInstance = _this.state.appInstance;
|
|
494
|
+
(ref = (_obj = _this).unregisterHistoryListener) === null || ref === void 0 ? void 0 : ref.call(_obj);
|
|
495
|
+
if (appInstance) {
|
|
496
|
+
appInfo2 = appInstance.appInfo;
|
|
497
|
+
if (appInfo2.cache) {
|
|
498
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo2.name, '" hide'));
|
|
499
|
+
appInstance === null || appInstance === void 0 ? void 0 : appInstance.hide();
|
|
500
|
+
} else {
|
|
501
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo2.name, '" unmount'));
|
|
502
|
+
appInstance === null || appInstance === void 0 ? void 0 : appInstance.unmount();
|
|
386
503
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
_state.sent();
|
|
405
|
-
return [
|
|
406
|
-
3,
|
|
407
|
-
5
|
|
408
|
-
];
|
|
409
|
-
case 3:
|
|
410
|
-
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" mount'), {
|
|
411
|
-
appInfo: appInstance.appInfo,
|
|
412
|
-
appInstance: appInstance
|
|
413
|
-
});
|
|
414
|
-
return [
|
|
415
|
-
4,
|
|
416
|
-
appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount()
|
|
417
|
-
];
|
|
418
|
-
case 4:
|
|
419
|
-
_state.sent();
|
|
420
|
-
_state.label = 5;
|
|
421
|
-
case 5:
|
|
422
|
-
return [
|
|
423
|
-
3,
|
|
424
|
-
7
|
|
425
|
-
];
|
|
426
|
-
case 6:
|
|
427
|
-
error = _state.sent();
|
|
428
|
-
setLoadingState({
|
|
429
|
-
isLoading: true,
|
|
430
|
-
error: error
|
|
431
|
-
});
|
|
432
|
-
return [
|
|
433
|
-
3,
|
|
434
|
-
7
|
|
435
|
-
];
|
|
436
|
-
case 7:
|
|
437
|
-
return [
|
|
438
|
-
2
|
|
439
|
-
];
|
|
440
|
-
}
|
|
504
|
+
}
|
|
505
|
+
return [
|
|
506
|
+
2
|
|
507
|
+
];
|
|
508
|
+
});
|
|
509
|
+
})();
|
|
510
|
+
}
|
|
511
|
+
},
|
|
512
|
+
{
|
|
513
|
+
key: "render",
|
|
514
|
+
value: function render() {
|
|
515
|
+
var _state = this.state, domId = _state.domId, SubModuleComponent = _state.SubModuleComponent;
|
|
516
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
517
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
518
|
+
id: domId,
|
|
519
|
+
children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {})
|
|
520
|
+
})
|
|
441
521
|
});
|
|
442
|
-
});
|
|
443
|
-
return _renderApp.apply(this, arguments);
|
|
444
|
-
}
|
|
445
|
-
renderApp();
|
|
446
|
-
return function() {
|
|
447
|
-
if (appRef.current) {
|
|
448
|
-
var _current = appRef.current, appInfo2 = _current.appInfo;
|
|
449
|
-
if (appInfo2.cache) {
|
|
450
|
-
var ref;
|
|
451
|
-
logger('MicroApp Garfish.loadApp "'.concat(appInfo2.name, '" hide'));
|
|
452
|
-
(ref = appRef.current) === null || ref === void 0 ? void 0 : ref.hide();
|
|
453
|
-
} else {
|
|
454
|
-
var ref1;
|
|
455
|
-
logger('MicroApp Garfish.loadApp "'.concat(appInfo2.name, '" unmount'));
|
|
456
|
-
(ref1 = appRef.current) === null || ref1 === void 0 ? void 0 : ref1.unmount();
|
|
457
|
-
}
|
|
458
522
|
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
return
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
children: SubModuleComponent && /* @__PURE__ */ jsx(SubModuleComponent, {})
|
|
465
|
-
})
|
|
466
|
-
});
|
|
467
|
-
};
|
|
468
|
-
var locationHref = "";
|
|
469
|
-
return Loadable(MicroApp)(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
|
|
523
|
+
}
|
|
524
|
+
]);
|
|
525
|
+
return MicroApp;
|
|
526
|
+
}(React.Component);
|
|
527
|
+
return Loadable(withRouter(MicroApp))(manifest === null || manifest === void 0 ? void 0 : manifest.loadable);
|
|
470
528
|
}
|
|
471
529
|
function generateApps(options, manifest) {
|
|
472
530
|
var ref;
|
|
@@ -481,4 +539,4 @@ function generateApps(options, manifest) {
|
|
|
481
539
|
appInfoList: options.apps || []
|
|
482
540
|
};
|
|
483
541
|
}
|
|
484
|
-
export { generateApps
|
|
542
|
+
export { generateApps };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { RouteComponentProps } from '@modern-js/plugin-router-v5/runtime';
|
|
2
3
|
import { LoadableConfig, MicroComponentProps } from './useModuleApps';
|
|
3
|
-
export interface MicroProps {
|
|
4
|
+
export interface MicroProps extends RouteComponentProps {
|
|
4
5
|
setLoadingState: (state: {
|
|
5
6
|
isLoading?: boolean;
|
|
6
7
|
error?: unknown;
|
|
@@ -8,7 +8,6 @@ export interface Provider extends interfaces.Provider {
|
|
|
8
8
|
export interface AppMap {
|
|
9
9
|
[key: string]: React.FC<MicroComponentProps>;
|
|
10
10
|
}
|
|
11
|
-
export declare function pathJoin(...args: string[]): string;
|
|
12
11
|
export declare function generateApps(options: typeof Garfish.options, manifest?: Manifest): {
|
|
13
12
|
apps: AppMap;
|
|
14
13
|
appInfoList: ModulesInfo;
|