@modern-js/plugin-garfish 2.0.0-beta.6 → 2.0.0-beta.7
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 +17 -0
- package/dist/js/modern/cli/index.js +2 -13
- package/dist/js/modern/runtime/plugin.js +1 -1
- package/dist/js/modern/runtime/utils/apps.js +138 -124
- package/dist/js/node/cli/index.js +2 -19
- package/dist/js/node/runtime/plugin.js +1 -1
- package/dist/js/node/runtime/utils/apps.js +140 -125
- package/dist/js/treeshaking/cli/index.js +2 -7
- package/dist/js/treeshaking/runtime/plugin.js +1 -1
- package/dist/js/treeshaking/runtime/utils/apps.js +229 -287
- package/dist/types/cli/index.d.ts +1 -4
- package/dist/types/runtime/loadable.d.ts +1 -2
- package/dist/types/runtime/utils/apps.d.ts +1 -0
- package/package.json +11 -10
- package/type.d.ts +5 -0
- package/dist/js/modern/cli/types.js +0 -0
- package/dist/js/node/cli/types.js +0 -0
- package/dist/js/treeshaking/cli/types.js +0 -1
- package/dist/types/cli/types.d.ts +0 -6
|
@@ -3,15 +3,12 @@ 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
|
+
}
|
|
6
9
|
function _arrayWithoutHoles(arr) {
|
|
7
10
|
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
8
11
|
}
|
|
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
|
-
}
|
|
15
12
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
16
13
|
try {
|
|
17
14
|
var info = gen[key](arg);
|
|
@@ -41,25 +38,6 @@ function _asyncToGenerator(fn) {
|
|
|
41
38
|
});
|
|
42
39
|
};
|
|
43
40
|
}
|
|
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
|
-
}
|
|
63
41
|
function _defineProperty(obj, key, value) {
|
|
64
42
|
if (key in obj) {
|
|
65
43
|
Object.defineProperty(obj, key, {
|
|
@@ -73,27 +51,35 @@ function _defineProperty(obj, key, value) {
|
|
|
73
51
|
}
|
|
74
52
|
return obj;
|
|
75
53
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
return o.__proto__ || Object.getPrototypeOf(o);
|
|
79
|
-
};
|
|
80
|
-
return _getPrototypeOf(o);
|
|
54
|
+
function _iterableToArray(iter) {
|
|
55
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
81
56
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
57
|
+
function _iterableToArrayLimit(arr, i) {
|
|
58
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
59
|
+
if (_i == null) return;
|
|
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;
|
|
91
68
|
}
|
|
92
|
-
})
|
|
93
|
-
|
|
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
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return _arr;
|
|
94
80
|
}
|
|
95
|
-
function
|
|
96
|
-
|
|
81
|
+
function _nonIterableRest() {
|
|
82
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
97
83
|
}
|
|
98
84
|
function _nonIterableSpread() {
|
|
99
85
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
@@ -164,26 +150,12 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
164
150
|
}
|
|
165
151
|
return target;
|
|
166
152
|
}
|
|
167
|
-
function
|
|
168
|
-
|
|
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);
|
|
153
|
+
function _slicedToArray(arr, i) {
|
|
154
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
179
155
|
}
|
|
180
156
|
function _toConsumableArray(arr) {
|
|
181
157
|
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
182
158
|
}
|
|
183
|
-
var _typeof = function(obj) {
|
|
184
|
-
"@swc/helpers - typeof";
|
|
185
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
186
|
-
};
|
|
187
159
|
function _unsupportedIterableToArray(o, minLen) {
|
|
188
160
|
if (!o) return;
|
|
189
161
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
@@ -192,30 +164,6 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
192
164
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
193
165
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
194
166
|
}
|
|
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
|
-
}
|
|
219
167
|
var __generator = this && this.__generator || function(thisArg, body) {
|
|
220
168
|
var f, y, t, g, _ = {
|
|
221
169
|
label: 0,
|
|
@@ -312,219 +260,213 @@ var __generator = this && this.__generator || function(thisArg, body) {
|
|
|
312
260
|
}
|
|
313
261
|
};
|
|
314
262
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
315
|
-
import
|
|
316
|
-
import
|
|
263
|
+
import { useContext, useState, useEffect, useRef } from "react";
|
|
264
|
+
import { RuntimeReactContext } from "@modern-js/runtime";
|
|
317
265
|
import Garfish from "garfish";
|
|
318
|
-
import { withRouter } from "@modern-js/plugin-router-v5/runtime";
|
|
319
266
|
import { logger, generateSubAppContainerKey } from "../../util";
|
|
320
267
|
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 = nPath.length - 1;
|
|
281
|
+
if (nPath[lastIndex] === "/") {
|
|
282
|
+
nPath = nPath.substring(0, lastIndex);
|
|
283
|
+
}
|
|
284
|
+
return res2 + nPath;
|
|
285
|
+
}, "");
|
|
286
|
+
return res || "/";
|
|
287
|
+
}
|
|
321
288
|
function getAppInstance(options, appInfo, manifest) {
|
|
322
|
-
var
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
var
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
_defineProperty(_assertThisInitialized(_this), "unregisterHistoryListener", function() {});
|
|
337
|
-
return _this;
|
|
289
|
+
var MicroApp = function MicroApp(props) {
|
|
290
|
+
var ref, ref1, ref2, ref3, ref4, ref5;
|
|
291
|
+
var appRef = useRef(null);
|
|
292
|
+
var domId = generateSubAppContainerKey(appInfo);
|
|
293
|
+
var ref6 = _slicedToArray(useState(), 2), SubModuleComponent = ref6[0], setSubModuleComponent = ref6[1];
|
|
294
|
+
var context = useContext(RuntimeReactContext);
|
|
295
|
+
var match = context === null || context === void 0 ? void 0 : (ref = context.router) === null || ref === void 0 ? void 0 : (ref1 = ref.useRouteMatch) === null || ref1 === void 0 ? void 0 : ref1.call(ref);
|
|
296
|
+
var matchs = context === null || context === void 0 ? void 0 : (ref2 = context.router) === null || ref2 === void 0 ? void 0 : (ref3 = ref2.useMatches) === null || ref3 === void 0 ? void 0 : ref3.call(ref2);
|
|
297
|
+
var location = context === null || context === void 0 ? void 0 : (ref4 = context.router) === null || ref4 === void 0 ? void 0 : (ref5 = ref4.useLocation) === null || ref5 === void 0 ? void 0 : ref5.call(ref4);
|
|
298
|
+
var basename = (options === null || options === void 0 ? void 0 : options.basename) || "/";
|
|
299
|
+
if (matchs && matchs.length > 0) {
|
|
300
|
+
basename = pathJoin(basename, matchs[matchs.length - 1].pathname || "/");
|
|
301
|
+
} else if (match) {
|
|
302
|
+
basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
|
|
338
303
|
}
|
|
339
|
-
|
|
340
|
-
{
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
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
|
-
];
|
|
304
|
+
useEffect(function() {
|
|
305
|
+
if (location && locationHref !== location.pathname && !Garfish.running) {
|
|
306
|
+
locationHref = location.pathname;
|
|
307
|
+
var popStateEvent = new PopStateEvent("popstate");
|
|
308
|
+
popStateEvent.garfish = true;
|
|
309
|
+
dispatchEvent(popStateEvent);
|
|
310
|
+
logger("MicroApp Garfish.loadApp popstate");
|
|
311
|
+
}
|
|
312
|
+
}, [
|
|
313
|
+
location
|
|
314
|
+
]);
|
|
315
|
+
useEffect(function() {
|
|
316
|
+
var setLoadingState = props.setLoadingState, userProps = _objectWithoutProperties(props, [
|
|
317
|
+
"setLoadingState"
|
|
318
|
+
]);
|
|
319
|
+
var loadAppOptions = _objectSpreadProps(_objectSpread({}, appInfo), {
|
|
320
|
+
insulationVariable: _toConsumableArray(appInfo.insulationVariable || []).concat([
|
|
321
|
+
"_SERVER_DATA"
|
|
322
|
+
]),
|
|
323
|
+
domGetter: "#".concat(domId),
|
|
324
|
+
basename: basename,
|
|
325
|
+
cache: true,
|
|
326
|
+
props: _objectSpread({}, appInfo.props, userProps),
|
|
327
|
+
customLoader: function(provider) {
|
|
328
|
+
var render = provider.render, destroy = provider.destroy, SubModuleComponent2 = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
329
|
+
var componetRenderMode = (manifest === null || manifest === void 0 ? void 0 : manifest.componentRender) && (SubModuleComponent2 || jupiter_submodule_app_key);
|
|
330
|
+
return {
|
|
331
|
+
mount: function() {
|
|
332
|
+
for(var _len = arguments.length, props2 = new Array(_len), _key = 0; _key < _len; _key++){
|
|
333
|
+
props2[_key] = arguments[_key];
|
|
481
334
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
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();
|
|
503
|
-
}
|
|
335
|
+
if (componetRenderMode) {
|
|
336
|
+
setSubModuleComponent(SubModuleComponent2);
|
|
337
|
+
return void 0;
|
|
338
|
+
} else {
|
|
339
|
+
logger("MicroApp customer render", props2);
|
|
340
|
+
return render === null || render === void 0 ? void 0 : render.apply(provider, props2);
|
|
341
|
+
}
|
|
342
|
+
},
|
|
343
|
+
unmount: function unmount() {
|
|
344
|
+
for(var _len = arguments.length, props2 = new Array(_len), _key = 0; _key < _len; _key++){
|
|
345
|
+
props2[_key] = arguments[_key];
|
|
504
346
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
347
|
+
if (componetRenderMode) {
|
|
348
|
+
return void 0;
|
|
349
|
+
}
|
|
350
|
+
logger("MicroApp customer destroy", props2);
|
|
351
|
+
return destroy === null || destroy === void 0 ? void 0 : destroy.apply(provider, props2);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
510
354
|
}
|
|
511
|
-
}
|
|
512
|
-
{
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
355
|
+
});
|
|
356
|
+
setLoadingState({
|
|
357
|
+
isLoading: true,
|
|
358
|
+
error: null
|
|
359
|
+
});
|
|
360
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '"'), {
|
|
361
|
+
loadAppOptions: loadAppOptions
|
|
362
|
+
});
|
|
363
|
+
function renderApp() {
|
|
364
|
+
return _renderApp.apply(this, arguments);
|
|
365
|
+
}
|
|
366
|
+
function _renderApp() {
|
|
367
|
+
_renderApp = _asyncToGenerator(function() {
|
|
368
|
+
var appInstance, error;
|
|
369
|
+
return __generator(this, function(_state) {
|
|
370
|
+
switch(_state.label){
|
|
371
|
+
case 0:
|
|
372
|
+
_state.trys.push([
|
|
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'));
|
|
386
|
+
}
|
|
387
|
+
appRef.current = appInstance;
|
|
388
|
+
setLoadingState({
|
|
389
|
+
isLoading: false
|
|
390
|
+
});
|
|
391
|
+
if (!(appInstance.mounted && appInstance.appInfo.cache)) return [
|
|
392
|
+
3,
|
|
393
|
+
3
|
|
394
|
+
];
|
|
395
|
+
logger('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" show'), {
|
|
396
|
+
appInfo: appInstance.appInfo,
|
|
397
|
+
appInstance: appInstance
|
|
398
|
+
});
|
|
399
|
+
return [
|
|
400
|
+
4,
|
|
401
|
+
appInstance === null || appInstance === void 0 ? void 0 : appInstance.show()
|
|
402
|
+
];
|
|
403
|
+
case 2:
|
|
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
|
+
}
|
|
521
441
|
});
|
|
522
|
-
}
|
|
442
|
+
});
|
|
443
|
+
return _renderApp.apply(this, arguments);
|
|
523
444
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
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
|
+
}
|
|
459
|
+
};
|
|
460
|
+
}, []);
|
|
461
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
462
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
463
|
+
id: domId,
|
|
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);
|
|
528
470
|
}
|
|
529
471
|
function generateApps(options, manifest) {
|
|
530
472
|
var ref;
|
|
@@ -539,4 +481,4 @@ function generateApps(options, manifest) {
|
|
|
539
481
|
appInfoList: options.apps || []
|
|
540
482
|
};
|
|
541
483
|
}
|
|
542
|
-
export { generateApps };
|
|
484
|
+
export { generateApps, pathJoin };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { CliHookCallbacks, useConfigContext } from '@modern-js/core';
|
|
2
2
|
import type { CliPlugin, AppTools } from '@modern-js/app-tools';
|
|
3
|
-
import './types';
|
|
4
3
|
export declare type UseConfig = ReturnType<typeof useConfigContext>;
|
|
5
4
|
export declare const externals: {
|
|
6
5
|
'react-dom': string;
|
|
@@ -12,12 +11,10 @@ export declare function getDefaultMicroFrontedConfig(microFrontend: NonInValidAb
|
|
|
12
11
|
|
|
13
12
|
declare const _default: ({
|
|
14
13
|
pluginName,
|
|
15
|
-
runtimePluginName
|
|
16
|
-
mfPackagePath
|
|
14
|
+
runtimePluginName
|
|
17
15
|
}?: {
|
|
18
16
|
pluginName?: string | undefined;
|
|
19
17
|
runtimePluginName?: string | undefined;
|
|
20
|
-
mfPackagePath?: string | undefined;
|
|
21
18
|
}) => CliPlugin<AppTools>;
|
|
22
19
|
|
|
23
20
|
export default _default;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { RouteComponentProps } from '@modern-js/plugin-router-v5/runtime';
|
|
3
2
|
import { LoadableConfig, MicroComponentProps } from './useModuleApps';
|
|
4
|
-
export interface MicroProps
|
|
3
|
+
export interface MicroProps {
|
|
5
4
|
setLoadingState: (state: {
|
|
6
5
|
isLoading?: boolean;
|
|
7
6
|
error?: unknown;
|
|
@@ -8,6 +8,7 @@ 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;
|
|
11
12
|
export declare function generateApps(options: typeof Garfish.options, manifest?: Manifest): {
|
|
12
13
|
apps: AppMap;
|
|
13
14
|
appInfoList: ModulesInfo;
|