@modern-js/plugin-garfish 2.68.19-alpha.2 → 2.68.19
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/dist/cjs/runtime/utils/apps.js +9 -100
- package/dist/esm/runtime/utils/apps.js +9 -120
- package/dist/esm-node/runtime/utils/apps.js +9 -100
- package/package.json +12 -12
|
@@ -55,35 +55,6 @@ function pathJoin(...args) {
|
|
|
55
55
|
}, "");
|
|
56
56
|
return res || "/";
|
|
57
57
|
}
|
|
58
|
-
function deepEqualExcludeFunctions(prev, next) {
|
|
59
|
-
if (prev === next)
|
|
60
|
-
return true;
|
|
61
|
-
if (!prev || !next)
|
|
62
|
-
return false;
|
|
63
|
-
if (typeof prev !== "object" || typeof next !== "object")
|
|
64
|
-
return false;
|
|
65
|
-
const prevKeys = Object.keys(prev).filter((key) => typeof prev[key] !== "function");
|
|
66
|
-
const nextKeys = Object.keys(next).filter((key) => typeof next[key] !== "function");
|
|
67
|
-
if (prevKeys.length !== nextKeys.length)
|
|
68
|
-
return false;
|
|
69
|
-
for (const key of prevKeys) {
|
|
70
|
-
if (!nextKeys.includes(key))
|
|
71
|
-
return false;
|
|
72
|
-
const prevVal = prev[key];
|
|
73
|
-
const nextVal = next[key];
|
|
74
|
-
if (typeof prevVal === "function" || typeof nextVal === "function") {
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (typeof prevVal === "object" && typeof nextVal === "object") {
|
|
78
|
-
if (!deepEqualExcludeFunctions(prevVal, nextVal)) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
} else if (prevVal !== nextVal) {
|
|
82
|
-
return false;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
58
|
function getAppInstance(options, appInfo, manifest) {
|
|
88
59
|
const componentSetterRegistry = {
|
|
89
60
|
current: null
|
|
@@ -92,15 +63,10 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
92
63
|
var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
|
|
93
64
|
const appRef = (0, import_react.useRef)(null);
|
|
94
65
|
const locationHrefRef = (0, import_react.useRef)("");
|
|
95
|
-
const propsRef = (0, import_react.useRef)(props);
|
|
96
|
-
const previousPropsRef = (0, import_react.useRef)(props);
|
|
97
|
-
const propsUpdateCounterRef = (0, import_react.useRef)(0);
|
|
98
66
|
const domId = (0, import_util.generateSubAppContainerKey)(appInfo);
|
|
99
|
-
const [{ component: SubModuleComponent
|
|
100
|
-
component: null
|
|
101
|
-
isFromJupiter: false
|
|
67
|
+
const [{ component: SubModuleComponent }, setSubModuleComponent] = (0, import_react.useState)({
|
|
68
|
+
component: null
|
|
102
69
|
});
|
|
103
|
-
const [propsUpdateKey, setPropsUpdateKey] = (0, import_react.useState)(0);
|
|
104
70
|
const context = (0, import_react.useContext)(import_runtime.RuntimeReactContext);
|
|
105
71
|
var _props_useRouteMatch;
|
|
106
72
|
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;
|
|
@@ -167,36 +133,9 @@ or directly pass the "basename":
|
|
|
167
133
|
}, [
|
|
168
134
|
locationPathname
|
|
169
135
|
]);
|
|
170
|
-
(0, import_react.useEffect)(() => {
|
|
171
|
-
const prevPropsForCompare = {
|
|
172
|
-
...previousPropsRef.current
|
|
173
|
-
};
|
|
174
|
-
const currentPropsForCompare = {
|
|
175
|
-
...props
|
|
176
|
-
};
|
|
177
|
-
Object.keys(prevPropsForCompare).forEach((key) => {
|
|
178
|
-
if (typeof prevPropsForCompare[key] === "function") {
|
|
179
|
-
delete prevPropsForCompare[key];
|
|
180
|
-
}
|
|
181
|
-
});
|
|
182
|
-
Object.keys(currentPropsForCompare).forEach((key) => {
|
|
183
|
-
if (typeof currentPropsForCompare[key] === "function") {
|
|
184
|
-
delete currentPropsForCompare[key];
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
if (!deepEqualExcludeFunctions(prevPropsForCompare, currentPropsForCompare)) {
|
|
188
|
-
previousPropsRef.current = props;
|
|
189
|
-
propsRef.current = props;
|
|
190
|
-
propsUpdateCounterRef.current += 1;
|
|
191
|
-
setPropsUpdateKey((prev) => prev + 1);
|
|
192
|
-
}
|
|
193
|
-
}, [
|
|
194
|
-
props,
|
|
195
|
-
appInfo.name
|
|
196
|
-
]);
|
|
197
136
|
(0, import_react.useEffect)(() => {
|
|
198
137
|
componentSetterRegistry.current = setSubModuleComponent;
|
|
199
|
-
const { setLoadingState
|
|
138
|
+
const { setLoadingState, ...userProps } = props;
|
|
200
139
|
const loadAppOptions = {
|
|
201
140
|
cache: true,
|
|
202
141
|
insulationVariable: [
|
|
@@ -213,15 +152,13 @@ or directly pass the "basename":
|
|
|
213
152
|
customLoader: (provider) => {
|
|
214
153
|
const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
|
|
215
154
|
const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
|
|
216
|
-
const isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
|
|
217
155
|
const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
|
|
218
156
|
return {
|
|
219
157
|
mount: (...props2) => {
|
|
220
158
|
if (componetRenderMode && SubComponent) {
|
|
221
159
|
if (componentSetterRegistry.current) {
|
|
222
160
|
componentSetterRegistry.current({
|
|
223
|
-
component: SubComponent
|
|
224
|
-
isFromJupiter: isFromJupiter2
|
|
161
|
+
component: SubComponent
|
|
225
162
|
});
|
|
226
163
|
} else {
|
|
227
164
|
(0, import_util.logger)(`[Garfish] MicroApp for "${appInfo.name}" tried to mount, but no active component setter was found.`);
|
|
@@ -242,7 +179,7 @@ or directly pass the "basename":
|
|
|
242
179
|
};
|
|
243
180
|
}
|
|
244
181
|
};
|
|
245
|
-
|
|
182
|
+
setLoadingState({
|
|
246
183
|
isLoading: true,
|
|
247
184
|
error: null
|
|
248
185
|
});
|
|
@@ -256,7 +193,7 @@ or directly pass the "basename":
|
|
|
256
193
|
throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
|
|
257
194
|
}
|
|
258
195
|
appRef.current = appInstance;
|
|
259
|
-
|
|
196
|
+
setLoadingState({
|
|
260
197
|
isLoading: false
|
|
261
198
|
});
|
|
262
199
|
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
@@ -273,7 +210,7 @@ or directly pass the "basename":
|
|
|
273
210
|
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
274
211
|
}
|
|
275
212
|
} catch (error) {
|
|
276
|
-
|
|
213
|
+
setLoadingState({
|
|
277
214
|
isLoading: true,
|
|
278
215
|
error
|
|
279
216
|
});
|
|
@@ -295,40 +232,12 @@ or directly pass the "basename":
|
|
|
295
232
|
}
|
|
296
233
|
}
|
|
297
234
|
};
|
|
298
|
-
}, [
|
|
299
|
-
basename,
|
|
300
|
-
domId,
|
|
301
|
-
appInfo.name
|
|
302
|
-
]);
|
|
303
|
-
(0, import_react.useEffect)(() => {
|
|
304
|
-
var _appRef_current;
|
|
305
|
-
if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.appInfo) {
|
|
306
|
-
const { setLoadingState: setLoadingState2, ...updatedProps } = props;
|
|
307
|
-
const updatedPropsWithKey = {
|
|
308
|
-
...appInfo.props,
|
|
309
|
-
...updatedProps,
|
|
310
|
-
_garfishPropsUpdateKey: propsUpdateKey
|
|
311
|
-
};
|
|
312
|
-
appRef.current.appInfo.props = updatedPropsWithKey;
|
|
313
|
-
}
|
|
314
|
-
}, [
|
|
315
|
-
propsUpdateKey,
|
|
316
|
-
props
|
|
317
|
-
]);
|
|
318
|
-
const { setLoadingState, ...renderProps } = props;
|
|
319
|
-
const finalRenderProps = {
|
|
320
|
-
...renderProps,
|
|
321
|
-
_garfishPropsUpdateKey: propsUpdateKey
|
|
322
|
-
};
|
|
323
|
-
const componentKey = isFromJupiter ? void 0 : `${appInfo.name}-${propsUpdateKey}`;
|
|
235
|
+
}, []);
|
|
324
236
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
325
237
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
326
238
|
id: domId,
|
|
327
239
|
children: SubModuleComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubModuleComponent, {
|
|
328
|
-
...
|
|
329
|
-
key: componentKey
|
|
330
|
-
} : {},
|
|
331
|
-
...finalRenderProps
|
|
240
|
+
...props
|
|
332
241
|
})
|
|
333
242
|
})
|
|
334
243
|
});
|
|
@@ -4,7 +4,6 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
|
4
4
|
import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
5
5
|
import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
6
6
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
7
|
-
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
8
7
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
9
8
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
9
|
import { RuntimeReactContext } from "@meta/runtime";
|
|
@@ -32,56 +31,6 @@ function pathJoin() {
|
|
|
32
31
|
}, "");
|
|
33
32
|
return res || "/";
|
|
34
33
|
}
|
|
35
|
-
function deepEqualExcludeFunctions(prev, next) {
|
|
36
|
-
if (prev === next)
|
|
37
|
-
return true;
|
|
38
|
-
if (!prev || !next)
|
|
39
|
-
return false;
|
|
40
|
-
if ((typeof prev === "undefined" ? "undefined" : _type_of(prev)) !== "object" || (typeof next === "undefined" ? "undefined" : _type_of(next)) !== "object")
|
|
41
|
-
return false;
|
|
42
|
-
var prevKeys = Object.keys(prev).filter(function(key2) {
|
|
43
|
-
return typeof prev[key2] !== "function";
|
|
44
|
-
});
|
|
45
|
-
var nextKeys = Object.keys(next).filter(function(key2) {
|
|
46
|
-
return typeof next[key2] !== "function";
|
|
47
|
-
});
|
|
48
|
-
if (prevKeys.length !== nextKeys.length)
|
|
49
|
-
return false;
|
|
50
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
51
|
-
try {
|
|
52
|
-
for (var _iterator = prevKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
53
|
-
var key = _step.value;
|
|
54
|
-
if (!nextKeys.includes(key))
|
|
55
|
-
return false;
|
|
56
|
-
var prevVal = prev[key];
|
|
57
|
-
var nextVal = next[key];
|
|
58
|
-
if (typeof prevVal === "function" || typeof nextVal === "function") {
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
if ((typeof prevVal === "undefined" ? "undefined" : _type_of(prevVal)) === "object" && (typeof nextVal === "undefined" ? "undefined" : _type_of(nextVal)) === "object") {
|
|
62
|
-
if (!deepEqualExcludeFunctions(prevVal, nextVal)) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
} else if (prevVal !== nextVal) {
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
} catch (err) {
|
|
70
|
-
_didIteratorError = true;
|
|
71
|
-
_iteratorError = err;
|
|
72
|
-
} finally {
|
|
73
|
-
try {
|
|
74
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
75
|
-
_iterator.return();
|
|
76
|
-
}
|
|
77
|
-
} finally {
|
|
78
|
-
if (_didIteratorError) {
|
|
79
|
-
throw _iteratorError;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
}
|
|
85
34
|
function getAppInstance(options, appInfo, manifest) {
|
|
86
35
|
var componentSetterRegistry = {
|
|
87
36
|
current: null
|
|
@@ -90,15 +39,10 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
90
39
|
var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
|
|
91
40
|
var appRef = useRef(null);
|
|
92
41
|
var locationHrefRef = useRef("");
|
|
93
|
-
var propsRef = useRef(props);
|
|
94
|
-
var previousPropsRef = useRef(props);
|
|
95
|
-
var propsUpdateCounterRef = useRef(0);
|
|
96
42
|
var domId = generateSubAppContainerKey(appInfo);
|
|
97
43
|
var _useState = _sliced_to_array(useState({
|
|
98
|
-
component: null
|
|
99
|
-
|
|
100
|
-
}), 2), _useState_ = _useState[0], SubModuleComponent = _useState_.component, isFromJupiter = _useState_.isFromJupiter, setSubModuleComponent = _useState[1];
|
|
101
|
-
var _useState1 = _sliced_to_array(useState(0), 2), propsUpdateKey = _useState1[0], setPropsUpdateKey = _useState1[1];
|
|
44
|
+
component: null
|
|
45
|
+
}), 2), _useState_ = _useState[0], SubModuleComponent = _useState_.component, setSubModuleComponent = _useState[1];
|
|
102
46
|
var context = useContext(RuntimeReactContext);
|
|
103
47
|
var _props_useRouteMatch;
|
|
104
48
|
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;
|
|
@@ -163,37 +107,12 @@ or directly pass the "basename":
|
|
|
163
107
|
}, [
|
|
164
108
|
locationPathname
|
|
165
109
|
]);
|
|
166
|
-
useEffect(function() {
|
|
167
|
-
var prevPropsForCompare = _object_spread({}, previousPropsRef.current);
|
|
168
|
-
var currentPropsForCompare = _object_spread({}, props);
|
|
169
|
-
Object.keys(prevPropsForCompare).forEach(function(key2) {
|
|
170
|
-
if (typeof prevPropsForCompare[key2] === "function") {
|
|
171
|
-
delete prevPropsForCompare[key2];
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
Object.keys(currentPropsForCompare).forEach(function(key2) {
|
|
175
|
-
if (typeof currentPropsForCompare[key2] === "function") {
|
|
176
|
-
delete currentPropsForCompare[key2];
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
if (!deepEqualExcludeFunctions(prevPropsForCompare, currentPropsForCompare)) {
|
|
180
|
-
previousPropsRef.current = props;
|
|
181
|
-
propsRef.current = props;
|
|
182
|
-
propsUpdateCounterRef.current += 1;
|
|
183
|
-
setPropsUpdateKey(function(prev) {
|
|
184
|
-
return prev + 1;
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}, [
|
|
188
|
-
props,
|
|
189
|
-
appInfo.name
|
|
190
|
-
]);
|
|
191
110
|
useEffect(function() {
|
|
192
111
|
var renderApp = function renderApp2() {
|
|
193
112
|
return _renderApp.apply(this, arguments);
|
|
194
113
|
};
|
|
195
114
|
componentSetterRegistry.current = setSubModuleComponent;
|
|
196
|
-
var
|
|
115
|
+
var setLoadingState = props.setLoadingState, userProps = _object_without_properties(props, [
|
|
197
116
|
"setLoadingState"
|
|
198
117
|
]);
|
|
199
118
|
var loadAppOptions = _object_spread_props(_object_spread({
|
|
@@ -208,7 +127,6 @@ or directly pass the "basename":
|
|
|
208
127
|
customLoader: function(provider) {
|
|
209
128
|
var render = provider.render, destroy = provider.destroy, SubModuleComponent2 = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
|
|
210
129
|
var SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
|
|
211
|
-
var isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
|
|
212
130
|
var componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
|
|
213
131
|
return {
|
|
214
132
|
mount: function() {
|
|
@@ -218,8 +136,7 @@ or directly pass the "basename":
|
|
|
218
136
|
if (componetRenderMode && SubComponent) {
|
|
219
137
|
if (componentSetterRegistry.current) {
|
|
220
138
|
componentSetterRegistry.current({
|
|
221
|
-
component: SubComponent
|
|
222
|
-
isFromJupiter: isFromJupiter2
|
|
139
|
+
component: SubComponent
|
|
223
140
|
});
|
|
224
141
|
} else {
|
|
225
142
|
logger('[Garfish] MicroApp for "'.concat(appInfo.name, '" tried to mount, but no active component setter was found.'));
|
|
@@ -243,7 +160,7 @@ or directly pass the "basename":
|
|
|
243
160
|
};
|
|
244
161
|
}
|
|
245
162
|
});
|
|
246
|
-
|
|
163
|
+
setLoadingState({
|
|
247
164
|
isLoading: true,
|
|
248
165
|
error: null
|
|
249
166
|
});
|
|
@@ -272,7 +189,7 @@ or directly pass the "basename":
|
|
|
272
189
|
throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
|
|
273
190
|
}
|
|
274
191
|
appRef.current = appInstance;
|
|
275
|
-
|
|
192
|
+
setLoadingState({
|
|
276
193
|
isLoading: false
|
|
277
194
|
});
|
|
278
195
|
if (!(appInstance.mounted && appInstance.appInfo.cache))
|
|
@@ -313,7 +230,7 @@ or directly pass the "basename":
|
|
|
313
230
|
];
|
|
314
231
|
case 6:
|
|
315
232
|
error = _state.sent();
|
|
316
|
-
|
|
233
|
+
setLoadingState({
|
|
317
234
|
isLoading: true,
|
|
318
235
|
error
|
|
319
236
|
});
|
|
@@ -346,39 +263,11 @@ or directly pass the "basename":
|
|
|
346
263
|
}
|
|
347
264
|
}
|
|
348
265
|
};
|
|
349
|
-
}, [
|
|
350
|
-
basename,
|
|
351
|
-
domId,
|
|
352
|
-
appInfo.name
|
|
353
|
-
]);
|
|
354
|
-
useEffect(function() {
|
|
355
|
-
var _appRef_current;
|
|
356
|
-
if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.appInfo) {
|
|
357
|
-
var setLoadingState2 = props.setLoadingState, updatedProps = _object_without_properties(props, [
|
|
358
|
-
"setLoadingState"
|
|
359
|
-
]);
|
|
360
|
-
var updatedPropsWithKey = _object_spread_props(_object_spread({}, appInfo.props, updatedProps), {
|
|
361
|
-
_garfishPropsUpdateKey: propsUpdateKey
|
|
362
|
-
});
|
|
363
|
-
appRef.current.appInfo.props = updatedPropsWithKey;
|
|
364
|
-
}
|
|
365
|
-
}, [
|
|
366
|
-
propsUpdateKey,
|
|
367
|
-
props
|
|
368
|
-
]);
|
|
369
|
-
var setLoadingState = props.setLoadingState, renderProps = _object_without_properties(props, [
|
|
370
|
-
"setLoadingState"
|
|
371
|
-
]);
|
|
372
|
-
var finalRenderProps = _object_spread_props(_object_spread({}, renderProps), {
|
|
373
|
-
_garfishPropsUpdateKey: propsUpdateKey
|
|
374
|
-
});
|
|
375
|
-
var componentKey = isFromJupiter ? void 0 : "".concat(appInfo.name, "-").concat(propsUpdateKey);
|
|
266
|
+
}, []);
|
|
376
267
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
377
268
|
children: /* @__PURE__ */ _jsx("div", {
|
|
378
269
|
id: domId,
|
|
379
|
-
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({},
|
|
380
|
-
key: componentKey
|
|
381
|
-
} : {}, finalRenderProps))
|
|
270
|
+
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({}, props))
|
|
382
271
|
})
|
|
383
272
|
});
|
|
384
273
|
}
|
|
@@ -21,35 +21,6 @@ function pathJoin(...args) {
|
|
|
21
21
|
}, "");
|
|
22
22
|
return res || "/";
|
|
23
23
|
}
|
|
24
|
-
function deepEqualExcludeFunctions(prev, next) {
|
|
25
|
-
if (prev === next)
|
|
26
|
-
return true;
|
|
27
|
-
if (!prev || !next)
|
|
28
|
-
return false;
|
|
29
|
-
if (typeof prev !== "object" || typeof next !== "object")
|
|
30
|
-
return false;
|
|
31
|
-
const prevKeys = Object.keys(prev).filter((key) => typeof prev[key] !== "function");
|
|
32
|
-
const nextKeys = Object.keys(next).filter((key) => typeof next[key] !== "function");
|
|
33
|
-
if (prevKeys.length !== nextKeys.length)
|
|
34
|
-
return false;
|
|
35
|
-
for (const key of prevKeys) {
|
|
36
|
-
if (!nextKeys.includes(key))
|
|
37
|
-
return false;
|
|
38
|
-
const prevVal = prev[key];
|
|
39
|
-
const nextVal = next[key];
|
|
40
|
-
if (typeof prevVal === "function" || typeof nextVal === "function") {
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
if (typeof prevVal === "object" && typeof nextVal === "object") {
|
|
44
|
-
if (!deepEqualExcludeFunctions(prevVal, nextVal)) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
} else if (prevVal !== nextVal) {
|
|
48
|
-
return false;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
24
|
function getAppInstance(options, appInfo, manifest) {
|
|
54
25
|
const componentSetterRegistry = {
|
|
55
26
|
current: null
|
|
@@ -58,15 +29,10 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
58
29
|
var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
|
|
59
30
|
const appRef = useRef(null);
|
|
60
31
|
const locationHrefRef = useRef("");
|
|
61
|
-
const propsRef = useRef(props);
|
|
62
|
-
const previousPropsRef = useRef(props);
|
|
63
|
-
const propsUpdateCounterRef = useRef(0);
|
|
64
32
|
const domId = generateSubAppContainerKey(appInfo);
|
|
65
|
-
const [{ component: SubModuleComponent
|
|
66
|
-
component: null
|
|
67
|
-
isFromJupiter: false
|
|
33
|
+
const [{ component: SubModuleComponent }, setSubModuleComponent] = useState({
|
|
34
|
+
component: null
|
|
68
35
|
});
|
|
69
|
-
const [propsUpdateKey, setPropsUpdateKey] = useState(0);
|
|
70
36
|
const context = useContext(RuntimeReactContext);
|
|
71
37
|
var _props_useRouteMatch;
|
|
72
38
|
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;
|
|
@@ -133,36 +99,9 @@ or directly pass the "basename":
|
|
|
133
99
|
}, [
|
|
134
100
|
locationPathname
|
|
135
101
|
]);
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
const prevPropsForCompare = {
|
|
138
|
-
...previousPropsRef.current
|
|
139
|
-
};
|
|
140
|
-
const currentPropsForCompare = {
|
|
141
|
-
...props
|
|
142
|
-
};
|
|
143
|
-
Object.keys(prevPropsForCompare).forEach((key) => {
|
|
144
|
-
if (typeof prevPropsForCompare[key] === "function") {
|
|
145
|
-
delete prevPropsForCompare[key];
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
Object.keys(currentPropsForCompare).forEach((key) => {
|
|
149
|
-
if (typeof currentPropsForCompare[key] === "function") {
|
|
150
|
-
delete currentPropsForCompare[key];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
if (!deepEqualExcludeFunctions(prevPropsForCompare, currentPropsForCompare)) {
|
|
154
|
-
previousPropsRef.current = props;
|
|
155
|
-
propsRef.current = props;
|
|
156
|
-
propsUpdateCounterRef.current += 1;
|
|
157
|
-
setPropsUpdateKey((prev) => prev + 1);
|
|
158
|
-
}
|
|
159
|
-
}, [
|
|
160
|
-
props,
|
|
161
|
-
appInfo.name
|
|
162
|
-
]);
|
|
163
102
|
useEffect(() => {
|
|
164
103
|
componentSetterRegistry.current = setSubModuleComponent;
|
|
165
|
-
const { setLoadingState
|
|
104
|
+
const { setLoadingState, ...userProps } = props;
|
|
166
105
|
const loadAppOptions = {
|
|
167
106
|
cache: true,
|
|
168
107
|
insulationVariable: [
|
|
@@ -179,15 +118,13 @@ or directly pass the "basename":
|
|
|
179
118
|
customLoader: (provider) => {
|
|
180
119
|
const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
|
|
181
120
|
const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
|
|
182
|
-
const isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
|
|
183
121
|
const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
|
|
184
122
|
return {
|
|
185
123
|
mount: (...props2) => {
|
|
186
124
|
if (componetRenderMode && SubComponent) {
|
|
187
125
|
if (componentSetterRegistry.current) {
|
|
188
126
|
componentSetterRegistry.current({
|
|
189
|
-
component: SubComponent
|
|
190
|
-
isFromJupiter: isFromJupiter2
|
|
127
|
+
component: SubComponent
|
|
191
128
|
});
|
|
192
129
|
} else {
|
|
193
130
|
logger(`[Garfish] MicroApp for "${appInfo.name}" tried to mount, but no active component setter was found.`);
|
|
@@ -208,7 +145,7 @@ or directly pass the "basename":
|
|
|
208
145
|
};
|
|
209
146
|
}
|
|
210
147
|
};
|
|
211
|
-
|
|
148
|
+
setLoadingState({
|
|
212
149
|
isLoading: true,
|
|
213
150
|
error: null
|
|
214
151
|
});
|
|
@@ -222,7 +159,7 @@ or directly pass the "basename":
|
|
|
222
159
|
throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
|
|
223
160
|
}
|
|
224
161
|
appRef.current = appInstance;
|
|
225
|
-
|
|
162
|
+
setLoadingState({
|
|
226
163
|
isLoading: false
|
|
227
164
|
});
|
|
228
165
|
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
@@ -239,7 +176,7 @@ or directly pass the "basename":
|
|
|
239
176
|
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
240
177
|
}
|
|
241
178
|
} catch (error) {
|
|
242
|
-
|
|
179
|
+
setLoadingState({
|
|
243
180
|
isLoading: true,
|
|
244
181
|
error
|
|
245
182
|
});
|
|
@@ -261,40 +198,12 @@ or directly pass the "basename":
|
|
|
261
198
|
}
|
|
262
199
|
}
|
|
263
200
|
};
|
|
264
|
-
}, [
|
|
265
|
-
basename,
|
|
266
|
-
domId,
|
|
267
|
-
appInfo.name
|
|
268
|
-
]);
|
|
269
|
-
useEffect(() => {
|
|
270
|
-
var _appRef_current;
|
|
271
|
-
if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.appInfo) {
|
|
272
|
-
const { setLoadingState: setLoadingState2, ...updatedProps } = props;
|
|
273
|
-
const updatedPropsWithKey = {
|
|
274
|
-
...appInfo.props,
|
|
275
|
-
...updatedProps,
|
|
276
|
-
_garfishPropsUpdateKey: propsUpdateKey
|
|
277
|
-
};
|
|
278
|
-
appRef.current.appInfo.props = updatedPropsWithKey;
|
|
279
|
-
}
|
|
280
|
-
}, [
|
|
281
|
-
propsUpdateKey,
|
|
282
|
-
props
|
|
283
|
-
]);
|
|
284
|
-
const { setLoadingState, ...renderProps } = props;
|
|
285
|
-
const finalRenderProps = {
|
|
286
|
-
...renderProps,
|
|
287
|
-
_garfishPropsUpdateKey: propsUpdateKey
|
|
288
|
-
};
|
|
289
|
-
const componentKey = isFromJupiter ? void 0 : `${appInfo.name}-${propsUpdateKey}`;
|
|
201
|
+
}, []);
|
|
290
202
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
291
203
|
children: /* @__PURE__ */ _jsx("div", {
|
|
292
204
|
id: domId,
|
|
293
205
|
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {
|
|
294
|
-
...
|
|
295
|
-
key: componentKey
|
|
296
|
-
} : {},
|
|
297
|
-
...finalRenderProps
|
|
206
|
+
...props
|
|
298
207
|
})
|
|
299
208
|
})
|
|
300
209
|
});
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.68.19
|
|
18
|
+
"version": "2.68.19",
|
|
19
19
|
"jsnext:source": "./src/cli/index.ts",
|
|
20
20
|
"types": "./dist/types/cli/index.d.ts",
|
|
21
21
|
"typesVersions": {
|
|
@@ -69,12 +69,12 @@
|
|
|
69
69
|
"debug": "4.3.7",
|
|
70
70
|
"garfish": "^1.8.1",
|
|
71
71
|
"react-loadable": "^5.5.0",
|
|
72
|
-
"@modern-js/plugin-v2": "2.68.
|
|
73
|
-
"@modern-js/runtime-utils": "2.68.
|
|
74
|
-
"@modern-js/utils": "2.68.
|
|
72
|
+
"@modern-js/plugin-v2": "2.68.19",
|
|
73
|
+
"@modern-js/runtime-utils": "2.68.19",
|
|
74
|
+
"@modern-js/utils": "2.68.19"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@modern-js/runtime": "^2.68.
|
|
77
|
+
"@modern-js/runtime": "^2.68.19",
|
|
78
78
|
"react": ">=17",
|
|
79
79
|
"react-dom": ">=17"
|
|
80
80
|
},
|
|
@@ -93,13 +93,13 @@
|
|
|
93
93
|
"react-dom": "^18.3.1",
|
|
94
94
|
"react-router-dom": "6.27.0",
|
|
95
95
|
"typescript": "^5",
|
|
96
|
-
"@modern-js/app-tools": "2.68.
|
|
97
|
-
"@
|
|
98
|
-
"@modern-js/core": "2.68.
|
|
99
|
-
"@modern-js/
|
|
100
|
-
"@modern-js/types": "2.68.
|
|
101
|
-
"@
|
|
102
|
-
"@scripts/
|
|
96
|
+
"@modern-js/app-tools": "2.68.19",
|
|
97
|
+
"@modern-js/plugin-router-v5": "2.68.19",
|
|
98
|
+
"@modern-js/core": "2.68.19",
|
|
99
|
+
"@modern-js/runtime": "2.68.19",
|
|
100
|
+
"@modern-js/types": "2.68.19",
|
|
101
|
+
"@scripts/jest-config": "2.66.0",
|
|
102
|
+
"@scripts/build": "2.66.0"
|
|
103
103
|
},
|
|
104
104
|
"sideEffects": false,
|
|
105
105
|
"publishConfig": {
|