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