@modern-js/plugin-garfish 2.68.13-alpha.2 → 2.68.13-alpha.3
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.
|
@@ -29,8 +29,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
29
29
|
var apps_exports = {};
|
|
30
30
|
__export(apps_exports, {
|
|
31
31
|
generateApps: () => generateApps,
|
|
32
|
-
pathJoin: () => pathJoin
|
|
33
|
-
useMicroAppMountStatus: () => useMicroAppMountStatus
|
|
32
|
+
pathJoin: () => pathJoin
|
|
34
33
|
});
|
|
35
34
|
module.exports = __toCommonJS(apps_exports);
|
|
36
35
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -39,13 +38,6 @@ var import_garfish = __toESM(require("garfish"));
|
|
|
39
38
|
var import_react = require("react");
|
|
40
39
|
var import_util = require("../../util");
|
|
41
40
|
var import_loadable = require("../loadable");
|
|
42
|
-
const MicroAppMountContext = /* @__PURE__ */ (0, import_react.createContext)({
|
|
43
|
-
isMounted: true
|
|
44
|
-
});
|
|
45
|
-
const useMicroAppMountStatus = () => {
|
|
46
|
-
const { isMounted } = (0, import_react.useContext)(MicroAppMountContext);
|
|
47
|
-
return isMounted;
|
|
48
|
-
};
|
|
49
41
|
function pathJoin(...args) {
|
|
50
42
|
const res = args.reduce((res2, path) => {
|
|
51
43
|
let nPath = path;
|
|
@@ -72,9 +64,6 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
72
64
|
const [{ component: SubModuleComponent }, setSubModuleComponent] = (0, import_react.useState)({
|
|
73
65
|
component: null
|
|
74
66
|
});
|
|
75
|
-
const destroyRef = (0, import_react.useRef)(null);
|
|
76
|
-
const isMountedRef = (0, import_react.useRef)(true);
|
|
77
|
-
const abortControllerRef = (0, import_react.useRef)(null);
|
|
78
67
|
const context = (0, import_react.useContext)(import_runtime.RuntimeReactContext);
|
|
79
68
|
var _props_useRouteMatch;
|
|
80
69
|
const useRouteMatch = (_props_useRouteMatch = props.useRouteMatch) !== null && _props_useRouteMatch !== void 0 ? _props_useRouteMatch : context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : _context_router.useRouteMatch;
|
|
@@ -138,13 +127,6 @@ or directly pass the "basename":
|
|
|
138
127
|
]);
|
|
139
128
|
(0, import_react.useEffect)(() => {
|
|
140
129
|
const { setLoadingState, ...userProps } = props;
|
|
141
|
-
abortControllerRef.current = new AbortController();
|
|
142
|
-
const safeSetLoadingState = (state) => {
|
|
143
|
-
var _abortControllerRef_current;
|
|
144
|
-
if (isMountedRef.current && !((_abortControllerRef_current = abortControllerRef.current) === null || _abortControllerRef_current === void 0 ? void 0 : _abortControllerRef_current.signal.aborted)) {
|
|
145
|
-
setLoadingState(state);
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
130
|
const loadAppOptions = {
|
|
149
131
|
cache: true,
|
|
150
132
|
insulationVariable: [
|
|
@@ -162,34 +144,12 @@ or directly pass the "basename":
|
|
|
162
144
|
const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
|
|
163
145
|
const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
|
|
164
146
|
const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
|
|
165
|
-
if (destroy) {
|
|
166
|
-
destroyRef.current = () => {
|
|
167
|
-
const dom = document.getElementById(domId);
|
|
168
|
-
if (dom) {
|
|
169
|
-
const destroyProps = {
|
|
170
|
-
dom,
|
|
171
|
-
basename,
|
|
172
|
-
appName: appInfo.name,
|
|
173
|
-
appRenderInfo: {},
|
|
174
|
-
props: {
|
|
175
|
-
...appInfo.props,
|
|
176
|
-
...userProps
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
destroy.apply(provider, [
|
|
180
|
-
destroyProps
|
|
181
|
-
]);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
147
|
return {
|
|
186
148
|
mount: (...props2) => {
|
|
187
149
|
if (componetRenderMode && SubComponent) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
});
|
|
192
|
-
}
|
|
150
|
+
setSubModuleComponent({
|
|
151
|
+
component: SubComponent
|
|
152
|
+
});
|
|
193
153
|
return void 0;
|
|
194
154
|
} else {
|
|
195
155
|
(0, import_util.logger)("MicroApp customer render", props2);
|
|
@@ -206,7 +166,7 @@ or directly pass the "basename":
|
|
|
206
166
|
};
|
|
207
167
|
}
|
|
208
168
|
};
|
|
209
|
-
|
|
169
|
+
setLoadingState({
|
|
210
170
|
isLoading: true,
|
|
211
171
|
error: null
|
|
212
172
|
});
|
|
@@ -215,19 +175,12 @@ or directly pass the "basename":
|
|
|
215
175
|
});
|
|
216
176
|
async function renderApp() {
|
|
217
177
|
try {
|
|
218
|
-
var _abortControllerRef_current, _abortControllerRef_current1;
|
|
219
|
-
if ((_abortControllerRef_current = abortControllerRef.current) === null || _abortControllerRef_current === void 0 ? void 0 : _abortControllerRef_current.signal.aborted) {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
178
|
const appInstance = await import_garfish.default.loadApp(appInfo.name, loadAppOptions);
|
|
223
|
-
if ((_abortControllerRef_current1 = abortControllerRef.current) === null || _abortControllerRef_current1 === void 0 ? void 0 : _abortControllerRef_current1.signal.aborted) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
179
|
if (!appInstance) {
|
|
227
180
|
throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
|
|
228
181
|
}
|
|
229
182
|
appRef.current = appInstance;
|
|
230
|
-
|
|
183
|
+
setLoadingState({
|
|
231
184
|
isLoading: false
|
|
232
185
|
});
|
|
233
186
|
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
@@ -244,21 +197,14 @@ or directly pass the "basename":
|
|
|
244
197
|
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
245
198
|
}
|
|
246
199
|
} catch (error) {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
error
|
|
252
|
-
});
|
|
253
|
-
}
|
|
200
|
+
setLoadingState({
|
|
201
|
+
isLoading: true,
|
|
202
|
+
error
|
|
203
|
+
});
|
|
254
204
|
}
|
|
255
205
|
}
|
|
256
206
|
renderApp();
|
|
257
207
|
return () => {
|
|
258
|
-
isMountedRef.current = false;
|
|
259
|
-
if (abortControllerRef.current) {
|
|
260
|
-
abortControllerRef.current.abort();
|
|
261
|
-
}
|
|
262
208
|
if (appRef.current) {
|
|
263
209
|
const { appInfo: appInfo2 } = appRef.current;
|
|
264
210
|
if (appInfo2.cache) {
|
|
@@ -273,40 +219,12 @@ or directly pass the "basename":
|
|
|
273
219
|
}
|
|
274
220
|
};
|
|
275
221
|
}, []);
|
|
276
|
-
(0, import_react.useEffect)(() => {
|
|
277
|
-
return () => {
|
|
278
|
-
if (SubModuleComponent && destroyRef.current && isMountedRef.current) {
|
|
279
|
-
(0, import_util.logger)("MicroApp SubModuleComponent cleanup");
|
|
280
|
-
try {
|
|
281
|
-
destroyRef.current();
|
|
282
|
-
} catch (error) {
|
|
283
|
-
(0, import_util.logger)("Error during SubModuleComponent cleanup:", error);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
}, [
|
|
288
|
-
SubModuleComponent
|
|
289
|
-
]);
|
|
290
|
-
const SafeSubModuleComponent = (0, import_react.useCallback)(() => {
|
|
291
|
-
if (!SubModuleComponent || !isMountedRef.current) {
|
|
292
|
-
return null;
|
|
293
|
-
}
|
|
294
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MicroAppMountContext.Provider, {
|
|
295
|
-
value: {
|
|
296
|
-
isMounted: isMountedRef.current
|
|
297
|
-
},
|
|
298
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubModuleComponent, {
|
|
299
|
-
...props
|
|
300
|
-
})
|
|
301
|
-
});
|
|
302
|
-
}, [
|
|
303
|
-
SubModuleComponent,
|
|
304
|
-
props
|
|
305
|
-
]);
|
|
306
222
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
307
223
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
308
224
|
id: domId,
|
|
309
|
-
children: SubModuleComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
225
|
+
children: SubModuleComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubModuleComponent, {
|
|
226
|
+
...props
|
|
227
|
+
})
|
|
310
228
|
})
|
|
311
229
|
});
|
|
312
230
|
}
|
|
@@ -328,6 +246,5 @@ function generateApps(options, manifest) {
|
|
|
328
246
|
// Annotate the CommonJS export names for ESM import in node:
|
|
329
247
|
0 && (module.exports = {
|
|
330
248
|
generateApps,
|
|
331
|
-
pathJoin
|
|
332
|
-
useMicroAppMountStatus
|
|
249
|
+
pathJoin
|
|
333
250
|
});
|
|
@@ -8,16 +8,9 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
8
8
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
9
9
|
import { RuntimeReactContext } from "@meta/runtime";
|
|
10
10
|
import Garfish from "garfish";
|
|
11
|
-
import {
|
|
11
|
+
import { useContext, useEffect, useRef, useState } from "react";
|
|
12
12
|
import { generateSubAppContainerKey, logger } from "../../util";
|
|
13
13
|
import { Loadable } from "../loadable";
|
|
14
|
-
var MicroAppMountContext = /* @__PURE__ */ createContext({
|
|
15
|
-
isMounted: true
|
|
16
|
-
});
|
|
17
|
-
var useMicroAppMountStatus = function() {
|
|
18
|
-
var isMounted = useContext(MicroAppMountContext).isMounted;
|
|
19
|
-
return isMounted;
|
|
20
|
-
};
|
|
21
14
|
function pathJoin() {
|
|
22
15
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
23
16
|
args[_key] = arguments[_key];
|
|
@@ -47,9 +40,6 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
47
40
|
var _useState = _sliced_to_array(useState({
|
|
48
41
|
component: null
|
|
49
42
|
}), 2), _useState_ = _useState[0], SubModuleComponent = _useState_.component, setSubModuleComponent = _useState[1];
|
|
50
|
-
var destroyRef = useRef(null);
|
|
51
|
-
var isMountedRef = useRef(true);
|
|
52
|
-
var abortControllerRef = useRef(null);
|
|
53
43
|
var context = useContext(RuntimeReactContext);
|
|
54
44
|
var _props_useRouteMatch;
|
|
55
45
|
var useRouteMatch = (_props_useRouteMatch = props.useRouteMatch) !== null && _props_useRouteMatch !== void 0 ? _props_useRouteMatch : context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : _context_router.useRouteMatch;
|
|
@@ -116,13 +106,6 @@ or directly pass the "basename":
|
|
|
116
106
|
var setLoadingState = props.setLoadingState, userProps = _object_without_properties(props, [
|
|
117
107
|
"setLoadingState"
|
|
118
108
|
]);
|
|
119
|
-
abortControllerRef.current = new AbortController();
|
|
120
|
-
var safeSetLoadingState = function(state) {
|
|
121
|
-
var _abortControllerRef_current;
|
|
122
|
-
if (isMountedRef.current && !((_abortControllerRef_current = abortControllerRef.current) === null || _abortControllerRef_current === void 0 ? void 0 : _abortControllerRef_current.signal.aborted)) {
|
|
123
|
-
setLoadingState(state);
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
109
|
var loadAppOptions = _object_spread_props(_object_spread({
|
|
127
110
|
cache: true,
|
|
128
111
|
insulationVariable: _to_consumable_array(appInfo.insulationVariable || []).concat([
|
|
@@ -136,34 +119,15 @@ or directly pass the "basename":
|
|
|
136
119
|
var render = provider.render, destroy = provider.destroy, SubModuleComponent2 = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
137
120
|
var SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
|
|
138
121
|
var componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
|
|
139
|
-
if (destroy) {
|
|
140
|
-
destroyRef.current = function() {
|
|
141
|
-
var dom = document.getElementById(domId);
|
|
142
|
-
if (dom) {
|
|
143
|
-
var destroyProps = {
|
|
144
|
-
dom,
|
|
145
|
-
basename,
|
|
146
|
-
appName: appInfo.name,
|
|
147
|
-
appRenderInfo: {},
|
|
148
|
-
props: _object_spread({}, appInfo.props, userProps)
|
|
149
|
-
};
|
|
150
|
-
destroy.apply(provider, [
|
|
151
|
-
destroyProps
|
|
152
|
-
]);
|
|
153
|
-
}
|
|
154
|
-
};
|
|
155
|
-
}
|
|
156
122
|
return {
|
|
157
123
|
mount: function() {
|
|
158
124
|
for (var _len = arguments.length, _$props = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
159
125
|
_$props[_key] = arguments[_key];
|
|
160
126
|
}
|
|
161
127
|
if (componetRenderMode && SubComponent) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
});
|
|
166
|
-
}
|
|
128
|
+
setSubModuleComponent({
|
|
129
|
+
component: SubComponent
|
|
130
|
+
});
|
|
167
131
|
return void 0;
|
|
168
132
|
} else {
|
|
169
133
|
logger("MicroApp customer render", _$props);
|
|
@@ -183,7 +147,7 @@ or directly pass the "basename":
|
|
|
183
147
|
};
|
|
184
148
|
}
|
|
185
149
|
});
|
|
186
|
-
|
|
150
|
+
setLoadingState({
|
|
187
151
|
isLoading: true,
|
|
188
152
|
error: null
|
|
189
153
|
});
|
|
@@ -192,7 +156,7 @@ or directly pass the "basename":
|
|
|
192
156
|
});
|
|
193
157
|
function _renderApp() {
|
|
194
158
|
_renderApp = _async_to_generator(function() {
|
|
195
|
-
var
|
|
159
|
+
var appInstance, error;
|
|
196
160
|
return _ts_generator(this, function(_state) {
|
|
197
161
|
switch (_state.label) {
|
|
198
162
|
case 0:
|
|
@@ -202,27 +166,17 @@ or directly pass the "basename":
|
|
|
202
166
|
,
|
|
203
167
|
7
|
|
204
168
|
]);
|
|
205
|
-
if ((_abortControllerRef_current = abortControllerRef.current) === null || _abortControllerRef_current === void 0 ? void 0 : _abortControllerRef_current.signal.aborted) {
|
|
206
|
-
return [
|
|
207
|
-
2
|
|
208
|
-
];
|
|
209
|
-
}
|
|
210
169
|
return [
|
|
211
170
|
4,
|
|
212
171
|
Garfish.loadApp(appInfo.name, loadAppOptions)
|
|
213
172
|
];
|
|
214
173
|
case 1:
|
|
215
174
|
appInstance = _state.sent();
|
|
216
|
-
if ((_abortControllerRef_current1 = abortControllerRef.current) === null || _abortControllerRef_current1 === void 0 ? void 0 : _abortControllerRef_current1.signal.aborted) {
|
|
217
|
-
return [
|
|
218
|
-
2
|
|
219
|
-
];
|
|
220
|
-
}
|
|
221
175
|
if (!appInstance) {
|
|
222
176
|
throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
|
|
223
177
|
}
|
|
224
178
|
appRef.current = appInstance;
|
|
225
|
-
|
|
179
|
+
setLoadingState({
|
|
226
180
|
isLoading: false
|
|
227
181
|
});
|
|
228
182
|
if (!(appInstance.mounted && appInstance.appInfo.cache))
|
|
@@ -263,12 +217,10 @@ or directly pass the "basename":
|
|
|
263
217
|
];
|
|
264
218
|
case 6:
|
|
265
219
|
error = _state.sent();
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
});
|
|
271
|
-
}
|
|
220
|
+
setLoadingState({
|
|
221
|
+
isLoading: true,
|
|
222
|
+
error
|
|
223
|
+
});
|
|
272
224
|
return [
|
|
273
225
|
3,
|
|
274
226
|
7
|
|
@@ -284,10 +236,6 @@ or directly pass the "basename":
|
|
|
284
236
|
}
|
|
285
237
|
renderApp();
|
|
286
238
|
return function() {
|
|
287
|
-
isMountedRef.current = false;
|
|
288
|
-
if (abortControllerRef.current) {
|
|
289
|
-
abortControllerRef.current.abort();
|
|
290
|
-
}
|
|
291
239
|
if (appRef.current) {
|
|
292
240
|
var _$appInfo = appRef.current.appInfo;
|
|
293
241
|
if (_$appInfo.cache) {
|
|
@@ -302,38 +250,10 @@ or directly pass the "basename":
|
|
|
302
250
|
}
|
|
303
251
|
};
|
|
304
252
|
}, []);
|
|
305
|
-
useEffect(function() {
|
|
306
|
-
return function() {
|
|
307
|
-
if (SubModuleComponent && destroyRef.current && isMountedRef.current) {
|
|
308
|
-
logger("MicroApp SubModuleComponent cleanup");
|
|
309
|
-
try {
|
|
310
|
-
destroyRef.current();
|
|
311
|
-
} catch (error) {
|
|
312
|
-
logger("Error during SubModuleComponent cleanup:", error);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
}, [
|
|
317
|
-
SubModuleComponent
|
|
318
|
-
]);
|
|
319
|
-
var SafeSubModuleComponent = useCallback(function() {
|
|
320
|
-
if (!SubModuleComponent || !isMountedRef.current) {
|
|
321
|
-
return null;
|
|
322
|
-
}
|
|
323
|
-
return /* @__PURE__ */ _jsx(MicroAppMountContext.Provider, {
|
|
324
|
-
value: {
|
|
325
|
-
isMounted: isMountedRef.current
|
|
326
|
-
},
|
|
327
|
-
children: /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({}, props))
|
|
328
|
-
});
|
|
329
|
-
}, [
|
|
330
|
-
SubModuleComponent,
|
|
331
|
-
props
|
|
332
|
-
]);
|
|
333
253
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
334
254
|
children: /* @__PURE__ */ _jsx("div", {
|
|
335
255
|
id: domId,
|
|
336
|
-
children: SubModuleComponent && /* @__PURE__ */ _jsx(
|
|
256
|
+
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({}, props))
|
|
337
257
|
})
|
|
338
258
|
});
|
|
339
259
|
}
|
|
@@ -354,6 +274,5 @@ function generateApps(options, manifest) {
|
|
|
354
274
|
}
|
|
355
275
|
export {
|
|
356
276
|
generateApps,
|
|
357
|
-
pathJoin
|
|
358
|
-
useMicroAppMountStatus
|
|
277
|
+
pathJoin
|
|
359
278
|
};
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { RuntimeReactContext } from "@meta/runtime";
|
|
3
3
|
import Garfish from "garfish";
|
|
4
|
-
import {
|
|
4
|
+
import { useContext, useEffect, useRef, useState } from "react";
|
|
5
5
|
import { generateSubAppContainerKey, logger } from "../../util";
|
|
6
6
|
import { Loadable } from "../loadable";
|
|
7
|
-
const MicroAppMountContext = /* @__PURE__ */ createContext({
|
|
8
|
-
isMounted: true
|
|
9
|
-
});
|
|
10
|
-
const useMicroAppMountStatus = () => {
|
|
11
|
-
const { isMounted } = useContext(MicroAppMountContext);
|
|
12
|
-
return isMounted;
|
|
13
|
-
};
|
|
14
7
|
function pathJoin(...args) {
|
|
15
8
|
const res = args.reduce((res2, path) => {
|
|
16
9
|
let nPath = path;
|
|
@@ -37,9 +30,6 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
37
30
|
const [{ component: SubModuleComponent }, setSubModuleComponent] = useState({
|
|
38
31
|
component: null
|
|
39
32
|
});
|
|
40
|
-
const destroyRef = useRef(null);
|
|
41
|
-
const isMountedRef = useRef(true);
|
|
42
|
-
const abortControllerRef = useRef(null);
|
|
43
33
|
const context = useContext(RuntimeReactContext);
|
|
44
34
|
var _props_useRouteMatch;
|
|
45
35
|
const useRouteMatch = (_props_useRouteMatch = props.useRouteMatch) !== null && _props_useRouteMatch !== void 0 ? _props_useRouteMatch : context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : _context_router.useRouteMatch;
|
|
@@ -103,13 +93,6 @@ or directly pass the "basename":
|
|
|
103
93
|
]);
|
|
104
94
|
useEffect(() => {
|
|
105
95
|
const { setLoadingState, ...userProps } = props;
|
|
106
|
-
abortControllerRef.current = new AbortController();
|
|
107
|
-
const safeSetLoadingState = (state) => {
|
|
108
|
-
var _abortControllerRef_current;
|
|
109
|
-
if (isMountedRef.current && !((_abortControllerRef_current = abortControllerRef.current) === null || _abortControllerRef_current === void 0 ? void 0 : _abortControllerRef_current.signal.aborted)) {
|
|
110
|
-
setLoadingState(state);
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
96
|
const loadAppOptions = {
|
|
114
97
|
cache: true,
|
|
115
98
|
insulationVariable: [
|
|
@@ -127,34 +110,12 @@ or directly pass the "basename":
|
|
|
127
110
|
const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
|
|
128
111
|
const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
|
|
129
112
|
const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
|
|
130
|
-
if (destroy) {
|
|
131
|
-
destroyRef.current = () => {
|
|
132
|
-
const dom = document.getElementById(domId);
|
|
133
|
-
if (dom) {
|
|
134
|
-
const destroyProps = {
|
|
135
|
-
dom,
|
|
136
|
-
basename,
|
|
137
|
-
appName: appInfo.name,
|
|
138
|
-
appRenderInfo: {},
|
|
139
|
-
props: {
|
|
140
|
-
...appInfo.props,
|
|
141
|
-
...userProps
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
destroy.apply(provider, [
|
|
145
|
-
destroyProps
|
|
146
|
-
]);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
113
|
return {
|
|
151
114
|
mount: (...props2) => {
|
|
152
115
|
if (componetRenderMode && SubComponent) {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
});
|
|
157
|
-
}
|
|
116
|
+
setSubModuleComponent({
|
|
117
|
+
component: SubComponent
|
|
118
|
+
});
|
|
158
119
|
return void 0;
|
|
159
120
|
} else {
|
|
160
121
|
logger("MicroApp customer render", props2);
|
|
@@ -171,7 +132,7 @@ or directly pass the "basename":
|
|
|
171
132
|
};
|
|
172
133
|
}
|
|
173
134
|
};
|
|
174
|
-
|
|
135
|
+
setLoadingState({
|
|
175
136
|
isLoading: true,
|
|
176
137
|
error: null
|
|
177
138
|
});
|
|
@@ -180,19 +141,12 @@ or directly pass the "basename":
|
|
|
180
141
|
});
|
|
181
142
|
async function renderApp() {
|
|
182
143
|
try {
|
|
183
|
-
var _abortControllerRef_current, _abortControllerRef_current1;
|
|
184
|
-
if ((_abortControllerRef_current = abortControllerRef.current) === null || _abortControllerRef_current === void 0 ? void 0 : _abortControllerRef_current.signal.aborted) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
144
|
const appInstance = await Garfish.loadApp(appInfo.name, loadAppOptions);
|
|
188
|
-
if ((_abortControllerRef_current1 = abortControllerRef.current) === null || _abortControllerRef_current1 === void 0 ? void 0 : _abortControllerRef_current1.signal.aborted) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
145
|
if (!appInstance) {
|
|
192
146
|
throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
|
|
193
147
|
}
|
|
194
148
|
appRef.current = appInstance;
|
|
195
|
-
|
|
149
|
+
setLoadingState({
|
|
196
150
|
isLoading: false
|
|
197
151
|
});
|
|
198
152
|
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
@@ -209,21 +163,14 @@ or directly pass the "basename":
|
|
|
209
163
|
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
210
164
|
}
|
|
211
165
|
} catch (error) {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
error
|
|
217
|
-
});
|
|
218
|
-
}
|
|
166
|
+
setLoadingState({
|
|
167
|
+
isLoading: true,
|
|
168
|
+
error
|
|
169
|
+
});
|
|
219
170
|
}
|
|
220
171
|
}
|
|
221
172
|
renderApp();
|
|
222
173
|
return () => {
|
|
223
|
-
isMountedRef.current = false;
|
|
224
|
-
if (abortControllerRef.current) {
|
|
225
|
-
abortControllerRef.current.abort();
|
|
226
|
-
}
|
|
227
174
|
if (appRef.current) {
|
|
228
175
|
const { appInfo: appInfo2 } = appRef.current;
|
|
229
176
|
if (appInfo2.cache) {
|
|
@@ -238,40 +185,12 @@ or directly pass the "basename":
|
|
|
238
185
|
}
|
|
239
186
|
};
|
|
240
187
|
}, []);
|
|
241
|
-
useEffect(() => {
|
|
242
|
-
return () => {
|
|
243
|
-
if (SubModuleComponent && destroyRef.current && isMountedRef.current) {
|
|
244
|
-
logger("MicroApp SubModuleComponent cleanup");
|
|
245
|
-
try {
|
|
246
|
-
destroyRef.current();
|
|
247
|
-
} catch (error) {
|
|
248
|
-
logger("Error during SubModuleComponent cleanup:", error);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
}, [
|
|
253
|
-
SubModuleComponent
|
|
254
|
-
]);
|
|
255
|
-
const SafeSubModuleComponent = useCallback(() => {
|
|
256
|
-
if (!SubModuleComponent || !isMountedRef.current) {
|
|
257
|
-
return null;
|
|
258
|
-
}
|
|
259
|
-
return /* @__PURE__ */ _jsx(MicroAppMountContext.Provider, {
|
|
260
|
-
value: {
|
|
261
|
-
isMounted: isMountedRef.current
|
|
262
|
-
},
|
|
263
|
-
children: /* @__PURE__ */ _jsx(SubModuleComponent, {
|
|
264
|
-
...props
|
|
265
|
-
})
|
|
266
|
-
});
|
|
267
|
-
}, [
|
|
268
|
-
SubModuleComponent,
|
|
269
|
-
props
|
|
270
|
-
]);
|
|
271
188
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
272
189
|
children: /* @__PURE__ */ _jsx("div", {
|
|
273
190
|
id: domId,
|
|
274
|
-
children: SubModuleComponent && /* @__PURE__ */ _jsx(
|
|
191
|
+
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {
|
|
192
|
+
...props
|
|
193
|
+
})
|
|
275
194
|
})
|
|
276
195
|
});
|
|
277
196
|
}
|
|
@@ -292,6 +211,5 @@ function generateApps(options, manifest) {
|
|
|
292
211
|
}
|
|
293
212
|
export {
|
|
294
213
|
generateApps,
|
|
295
|
-
pathJoin
|
|
296
|
-
useMicroAppMountStatus
|
|
214
|
+
pathJoin
|
|
297
215
|
};
|
|
@@ -5,7 +5,6 @@ export interface Provider extends interfaces.Provider {
|
|
|
5
5
|
SubModuleComponent?: React.ComponentType<any>;
|
|
6
6
|
jupiter_submodule_app_key?: React.ComponentType<any>;
|
|
7
7
|
}
|
|
8
|
-
export declare const useMicroAppMountStatus: () => boolean;
|
|
9
8
|
export interface AppMap {
|
|
10
9
|
[key: string]: React.FC<MicroComponentProps>;
|
|
11
10
|
}
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.68.13-alpha.
|
|
18
|
+
"version": "2.68.13-alpha.3",
|
|
19
19
|
"jsnext:source": "./src/cli/index.ts",
|
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
|
21
21
|
"typesVersions": {
|
|
@@ -69,8 +69,8 @@
|
|
|
69
69
|
"debug": "4.3.7",
|
|
70
70
|
"garfish": "^1.8.1",
|
|
71
71
|
"react-loadable": "^5.5.0",
|
|
72
|
-
"@modern-js/runtime-utils": "2.68.12",
|
|
73
72
|
"@modern-js/plugin-v2": "2.68.12",
|
|
73
|
+
"@modern-js/runtime-utils": "2.68.12",
|
|
74
74
|
"@modern-js/utils": "2.68.12"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
@@ -94,12 +94,12 @@
|
|
|
94
94
|
"react-router-dom": "6.27.0",
|
|
95
95
|
"typescript": "^5",
|
|
96
96
|
"@modern-js/app-tools": "2.68.12",
|
|
97
|
-
"@scripts/build": "2.66.0",
|
|
98
97
|
"@modern-js/core": "2.68.12",
|
|
99
|
-
"@modern-js/plugin-router-v5": "2.68.12",
|
|
100
|
-
"@modern-js/types": "2.68.12",
|
|
101
98
|
"@modern-js/runtime": "2.68.12",
|
|
102
|
-
"@
|
|
99
|
+
"@modern-js/types": "2.68.12",
|
|
100
|
+
"@scripts/build": "2.66.0",
|
|
101
|
+
"@scripts/jest-config": "2.66.0",
|
|
102
|
+
"@modern-js/plugin-router-v5": "2.68.12"
|
|
103
103
|
},
|
|
104
104
|
"sideEffects": false,
|
|
105
105
|
"publishConfig": {
|