@cloud-app-dev/vidc 2.1.0-alpha.8 → 2.1.0-alpha.9
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/es/LoaderApp/index.js +26 -22
- package/package.json +1 -1
package/es/LoaderApp/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _useUnmount from "ahooks/es/useUnmount";
|
|
2
|
+
import _useMount from "ahooks/es/useMount";
|
|
1
3
|
import _uuid from "@cloud-app-dev/utils/es/uuid";
|
|
2
4
|
|
|
3
5
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -13,7 +15,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
|
13
15
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
16
|
|
|
15
17
|
import { __awaiter } from "tslib";
|
|
16
|
-
import React, { useRef,
|
|
18
|
+
import React, { useRef, useState, useMemo } from 'react';
|
|
17
19
|
import { getMicroConfig } from './utils';
|
|
18
20
|
import LoaderModule from './loader';
|
|
19
21
|
import "./index.css";
|
|
@@ -36,8 +38,7 @@ function LoaderApp(_ref) {
|
|
|
36
38
|
status = _useState2[0],
|
|
37
39
|
setStatus = _useState2[1];
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
var app;
|
|
41
|
+
_useMount(function () {
|
|
41
42
|
var config = getMicroConfig(appConfig, appProps, domRef.current);
|
|
42
43
|
|
|
43
44
|
if (!config) {
|
|
@@ -72,26 +73,25 @@ function LoaderApp(_ref) {
|
|
|
72
73
|
while (1) {
|
|
73
74
|
switch (_context.prev = _context.next) {
|
|
74
75
|
case 0:
|
|
75
|
-
app = mod;
|
|
76
76
|
loadedAppRef.current = mod;
|
|
77
77
|
|
|
78
78
|
if (!status) {
|
|
79
|
-
_context.next =
|
|
79
|
+
_context.next = 4;
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
_context.next =
|
|
84
|
-
return
|
|
83
|
+
_context.next = 4;
|
|
84
|
+
return mod.bootstrap(props);
|
|
85
85
|
|
|
86
|
-
case
|
|
86
|
+
case 4:
|
|
87
87
|
setStatus('bootstrap');
|
|
88
|
-
_context.next =
|
|
89
|
-
return
|
|
88
|
+
_context.next = 7;
|
|
89
|
+
return mod.mount(props);
|
|
90
90
|
|
|
91
|
-
case
|
|
91
|
+
case 7:
|
|
92
92
|
setStatus('mount');
|
|
93
93
|
|
|
94
|
-
case
|
|
94
|
+
case 8:
|
|
95
95
|
case "end":
|
|
96
96
|
return _context.stop();
|
|
97
97
|
}
|
|
@@ -99,16 +99,20 @@ function LoaderApp(_ref) {
|
|
|
99
99
|
}, _callee);
|
|
100
100
|
}));
|
|
101
101
|
});
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
_useUnmount(function () {
|
|
105
|
+
if (loadedAppRef.current) {
|
|
106
|
+
var app = loadedAppRef.current;
|
|
107
|
+
var props = Object.assign(Object.assign({}, appProps), {
|
|
108
|
+
container: domRef.current
|
|
109
|
+
});
|
|
110
|
+
app.unmount(props);
|
|
111
|
+
setStatus('unmount');
|
|
112
|
+
loadedAppRef.current = null;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
112
116
|
return /*#__PURE__*/React.createElement("main", {
|
|
113
117
|
ref: domRef,
|
|
114
118
|
className: "loaded-app-layout ".concat(appConfig.routerPrefix, "-").concat(id),
|