@modern-js/plugin-garfish 2.68.19-alpha.4 → 2.68.20

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,41 +55,6 @@ function pathJoin(...args) {
55
55
  }, "");
56
56
  return res || "/";
57
57
  }
58
- function deepEqualExcludeFunctions(prev, next, visited) {
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 visitedSet = visited !== null && visited !== void 0 ? visited : /* @__PURE__ */ new WeakSet();
66
- if (visitedSet.has(prev) || visitedSet.has(next)) {
67
- return true;
68
- }
69
- visitedSet.add(prev);
70
- visitedSet.add(next);
71
- const prevKeys = Object.keys(prev).filter((key) => typeof prev[key] !== "function");
72
- const nextKeys = Object.keys(next).filter((key) => typeof next[key] !== "function");
73
- if (prevKeys.length !== nextKeys.length)
74
- return false;
75
- for (const key of prevKeys) {
76
- if (!nextKeys.includes(key))
77
- return false;
78
- const prevVal = prev[key];
79
- const nextVal = next[key];
80
- if (typeof prevVal === "function" || typeof nextVal === "function") {
81
- continue;
82
- }
83
- if (typeof prevVal === "object" && typeof nextVal === "object") {
84
- if (!deepEqualExcludeFunctions(prevVal, nextVal, visitedSet)) {
85
- return false;
86
- }
87
- } else if (prevVal !== nextVal) {
88
- return false;
89
- }
90
- }
91
- return true;
92
- }
93
58
  function getAppInstance(options, appInfo, manifest) {
94
59
  const componentSetterRegistry = {
95
60
  current: null
@@ -98,16 +63,10 @@ function getAppInstance(options, appInfo, manifest) {
98
63
  var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
99
64
  const appRef = (0, import_react.useRef)(null);
100
65
  const locationHrefRef = (0, import_react.useRef)("");
101
- const propsRef = (0, import_react.useRef)(props);
102
- const previousPropsRef = (0, import_react.useRef)(props);
103
- const propsUpdateCounterRef = (0, import_react.useRef)(0);
104
66
  const domId = (0, import_util.generateSubAppContainerKey)(appInfo);
105
- const componentRef = (0, import_react.useRef)(null);
106
- const [{ component: SubModuleComponent, isFromJupiter }, setSubModuleComponent] = (0, import_react.useState)({
107
- component: null,
108
- isFromJupiter: false
67
+ const [{ component: SubModuleComponent }, setSubModuleComponent] = (0, import_react.useState)({
68
+ component: null
109
69
  });
110
- const [propsUpdateKey, setPropsUpdateKey] = (0, import_react.useState)(0);
111
70
  const context = (0, import_react.useContext)(import_runtime.RuntimeReactContext);
112
71
  var _props_useRouteMatch;
113
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;
@@ -119,8 +78,6 @@ function getAppInstance(options, appInfo, manifest) {
119
78
  const useHistory = (_props_useHistory = props.useHistory) !== null && _props_useHistory !== void 0 ? _props_useHistory : context === null || context === void 0 ? void 0 : (_context_router3 = context.router) === null || _context_router3 === void 0 ? void 0 : _context_router3.useHistory;
120
79
  var _props_useHistory1;
121
80
  const useHref = (_props_useHistory1 = props.useHistory) !== null && _props_useHistory1 !== void 0 ? _props_useHistory1 : context === null || context === void 0 ? void 0 : (_context_router4 = context.router) === null || _context_router4 === void 0 ? void 0 : _context_router4.useHref;
122
- const lastPropsUpdateKeyRef = (0, import_react.useRef)(0);
123
- const isRemountingRef = (0, import_react.useRef)(false);
124
81
  const match = useRouteMatch === null || useRouteMatch === void 0 ? void 0 : useRouteMatch();
125
82
  const matchs = useMatches === null || useMatches === void 0 ? void 0 : useMatches();
126
83
  if (!useLocation) {
@@ -176,64 +133,9 @@ or directly pass the "basename":
176
133
  }, [
177
134
  locationPathname
178
135
  ]);
179
- (0, import_react.useEffect)(() => {
180
- if (previousPropsRef.current === props) {
181
- return;
182
- }
183
- const prevPropsForCompare = {
184
- ...previousPropsRef.current
185
- };
186
- const currentPropsForCompare = {
187
- ...props
188
- };
189
- const ignoredKeysForRemount = [
190
- "style",
191
- "location",
192
- "match",
193
- "history",
194
- "staticContext",
195
- "guideState",
196
- "guideConfig"
197
- ];
198
- Object.keys(prevPropsForCompare).forEach((key) => {
199
- if (typeof prevPropsForCompare[key] === "function") {
200
- delete prevPropsForCompare[key];
201
- }
202
- });
203
- Object.keys(currentPropsForCompare).forEach((key) => {
204
- if (typeof currentPropsForCompare[key] === "function") {
205
- delete currentPropsForCompare[key];
206
- }
207
- });
208
- const prevPropsForDeepCompare = {};
209
- const currentPropsForDeepCompare = {};
210
- Object.keys(prevPropsForCompare).forEach((key) => {
211
- if (!ignoredKeysForRemount.includes(key)) {
212
- prevPropsForDeepCompare[key] = prevPropsForCompare[key];
213
- }
214
- });
215
- Object.keys(currentPropsForCompare).forEach((key) => {
216
- if (!ignoredKeysForRemount.includes(key)) {
217
- currentPropsForDeepCompare[key] = currentPropsForCompare[key];
218
- }
219
- });
220
- const propsEqual = deepEqualExcludeFunctions(prevPropsForDeepCompare, currentPropsForDeepCompare);
221
- if (!propsEqual) {
222
- previousPropsRef.current = props;
223
- propsRef.current = props;
224
- propsUpdateCounterRef.current += 1;
225
- setPropsUpdateKey((prev) => prev + 1);
226
- } else {
227
- previousPropsRef.current = props;
228
- propsRef.current = props;
229
- }
230
- }, [
231
- props,
232
- appInfo.name
233
- ]);
234
136
  (0, import_react.useEffect)(() => {
235
137
  componentSetterRegistry.current = setSubModuleComponent;
236
- const { setLoadingState: setLoadingState2, ...userProps } = propsRef.current;
138
+ const { setLoadingState, ...userProps } = props;
237
139
  const loadAppOptions = {
238
140
  cache: true,
239
141
  insulationVariable: [
@@ -250,16 +152,13 @@ or directly pass the "basename":
250
152
  customLoader: (provider) => {
251
153
  const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
252
154
  const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
253
- const isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
254
155
  const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
255
156
  return {
256
157
  mount: (...props2) => {
257
158
  if (componetRenderMode && SubComponent) {
258
159
  if (componentSetterRegistry.current) {
259
- componentRef.current = SubComponent;
260
160
  componentSetterRegistry.current({
261
- component: SubComponent,
262
- isFromJupiter: isFromJupiter2
161
+ component: SubComponent
263
162
  });
264
163
  } else {
265
164
  (0, import_util.logger)(`[Garfish] MicroApp for "${appInfo.name}" tried to mount, but no active component setter was found.`);
@@ -280,7 +179,7 @@ or directly pass the "basename":
280
179
  };
281
180
  }
282
181
  };
283
- setLoadingState2({
182
+ setLoadingState({
284
183
  isLoading: true,
285
184
  error: null
286
185
  });
@@ -294,7 +193,7 @@ or directly pass the "basename":
294
193
  throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
295
194
  }
296
195
  appRef.current = appInstance;
297
- setLoadingState2({
196
+ setLoadingState({
298
197
  isLoading: false
299
198
  });
300
199
  if (appInstance.mounted && appInstance.appInfo.cache) {
@@ -311,7 +210,7 @@ or directly pass the "basename":
311
210
  await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
312
211
  }
313
212
  } catch (error) {
314
- setLoadingState2({
213
+ setLoadingState({
315
214
  isLoading: true,
316
215
  error
317
216
  });
@@ -333,80 +232,12 @@ or directly pass the "basename":
333
232
  }
334
233
  }
335
234
  };
336
- }, [
337
- basename,
338
- domId,
339
- appInfo.name
340
- ]);
341
- (0, import_react.useEffect)(() => {
342
- var _appRef_current;
343
- if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.appInfo) {
344
- const { setLoadingState: setLoadingState2, ...updatedProps } = props;
345
- const updatedPropsWithKey = {
346
- ...appInfo.props,
347
- ...updatedProps,
348
- _garfishPropsUpdateKey: propsUpdateKey
349
- };
350
- appRef.current.appInfo.props = updatedPropsWithKey;
351
- }
352
- }, [
353
- propsUpdateKey,
354
- props
355
- ]);
356
- (0, import_react.useEffect)(() => {
357
- var _appRef_current;
358
- const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
359
- if (propsUpdateKey === lastPropsUpdateKeyRef.current || isRemountingRef.current) {
360
- return;
361
- }
362
- lastPropsUpdateKeyRef.current = propsUpdateKey;
363
- if (componetRenderMode && ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted)) {
364
- const componentToUse = SubModuleComponent || componentRef.current;
365
- if (componentToUse) {
366
- const currentComponent = componentToUse;
367
- const currentIsFromJupiter = isFromJupiter;
368
- setSubModuleComponent({
369
- component: null,
370
- isFromJupiter: false
371
- });
372
- setTimeout(() => {
373
- setSubModuleComponent({
374
- component: currentComponent,
375
- isFromJupiter: currentIsFromJupiter
376
- });
377
- }, 50);
378
- } else {
379
- var _appRef_current1;
380
- if ((_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.mounted) {
381
- var _appRef_current2;
382
- (_appRef_current2 = appRef.current) === null || _appRef_current2 === void 0 ? void 0 : _appRef_current2.hide();
383
- setTimeout(() => {
384
- var _appRef_current3;
385
- (_appRef_current3 = appRef.current) === null || _appRef_current3 === void 0 ? void 0 : _appRef_current3.show();
386
- setTimeout(() => {
387
- isRemountingRef.current = false;
388
- }, 100);
389
- }, 10);
390
- }
391
- }
392
- }
393
- }, [
394
- propsUpdateKey
395
- ]);
396
- const { setLoadingState, ...renderProps } = props;
397
- const finalRenderProps = {
398
- ...renderProps,
399
- _garfishPropsUpdateKey: propsUpdateKey
400
- };
401
- const componentKey = isFromJupiter ? void 0 : `${appInfo.name}-${propsUpdateKey}`;
235
+ }, []);
402
236
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
403
237
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
404
238
  id: domId,
405
239
  children: SubModuleComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubModuleComponent, {
406
- ...componentKey ? {
407
- key: componentKey
408
- } : {},
409
- ...finalRenderProps
240
+ ...props
410
241
  })
411
242
  })
412
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,62 +31,6 @@ function pathJoin() {
32
31
  }, "");
33
32
  return res || "/";
34
33
  }
35
- function deepEqualExcludeFunctions(prev, next, visited) {
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 visitedSet = visited !== null && visited !== void 0 ? visited : /* @__PURE__ */ new WeakSet();
43
- if (visitedSet.has(prev) || visitedSet.has(next)) {
44
- return true;
45
- }
46
- visitedSet.add(prev);
47
- visitedSet.add(next);
48
- var prevKeys = Object.keys(prev).filter(function(key2) {
49
- return typeof prev[key2] !== "function";
50
- });
51
- var nextKeys = Object.keys(next).filter(function(key2) {
52
- return typeof next[key2] !== "function";
53
- });
54
- if (prevKeys.length !== nextKeys.length)
55
- return false;
56
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
57
- try {
58
- for (var _iterator = prevKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
59
- var key = _step.value;
60
- if (!nextKeys.includes(key))
61
- return false;
62
- var prevVal = prev[key];
63
- var nextVal = next[key];
64
- if (typeof prevVal === "function" || typeof nextVal === "function") {
65
- continue;
66
- }
67
- if ((typeof prevVal === "undefined" ? "undefined" : _type_of(prevVal)) === "object" && (typeof nextVal === "undefined" ? "undefined" : _type_of(nextVal)) === "object") {
68
- if (!deepEqualExcludeFunctions(prevVal, nextVal, visitedSet)) {
69
- return false;
70
- }
71
- } else if (prevVal !== nextVal) {
72
- return false;
73
- }
74
- }
75
- } catch (err) {
76
- _didIteratorError = true;
77
- _iteratorError = err;
78
- } finally {
79
- try {
80
- if (!_iteratorNormalCompletion && _iterator.return != null) {
81
- _iterator.return();
82
- }
83
- } finally {
84
- if (_didIteratorError) {
85
- throw _iteratorError;
86
- }
87
- }
88
- }
89
- return true;
90
- }
91
34
  function getAppInstance(options, appInfo, manifest) {
92
35
  var componentSetterRegistry = {
93
36
  current: null
@@ -96,16 +39,10 @@ function getAppInstance(options, appInfo, manifest) {
96
39
  var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
97
40
  var appRef = useRef(null);
98
41
  var locationHrefRef = useRef("");
99
- var propsRef = useRef(props);
100
- var previousPropsRef = useRef(props);
101
- var propsUpdateCounterRef = useRef(0);
102
42
  var domId = generateSubAppContainerKey(appInfo);
103
- var componentRef = useRef(null);
104
43
  var _useState = _sliced_to_array(useState({
105
- component: null,
106
- isFromJupiter: false
107
- }), 2), _useState_ = _useState[0], SubModuleComponent = _useState_.component, isFromJupiter = _useState_.isFromJupiter, setSubModuleComponent = _useState[1];
108
- 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];
109
46
  var context = useContext(RuntimeReactContext);
110
47
  var _props_useRouteMatch;
111
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;
@@ -117,8 +54,6 @@ function getAppInstance(options, appInfo, manifest) {
117
54
  var useHistory = (_props_useHistory = props.useHistory) !== null && _props_useHistory !== void 0 ? _props_useHistory : context === null || context === void 0 ? void 0 : (_context_router3 = context.router) === null || _context_router3 === void 0 ? void 0 : _context_router3.useHistory;
118
55
  var _props_useHistory1;
119
56
  var useHref = (_props_useHistory1 = props.useHistory) !== null && _props_useHistory1 !== void 0 ? _props_useHistory1 : context === null || context === void 0 ? void 0 : (_context_router4 = context.router) === null || _context_router4 === void 0 ? void 0 : _context_router4.useHref;
120
- var lastPropsUpdateKeyRef = useRef(0);
121
- var isRemountingRef = useRef(false);
122
57
  var match = useRouteMatch === null || useRouteMatch === void 0 ? void 0 : useRouteMatch();
123
58
  var matchs = useMatches === null || useMatches === void 0 ? void 0 : useMatches();
124
59
  if (!useLocation) {
@@ -172,65 +107,12 @@ or directly pass the "basename":
172
107
  }, [
173
108
  locationPathname
174
109
  ]);
175
- useEffect(function() {
176
- if (previousPropsRef.current === props) {
177
- return;
178
- }
179
- var prevPropsForCompare = _object_spread({}, previousPropsRef.current);
180
- var currentPropsForCompare = _object_spread({}, props);
181
- var ignoredKeysForRemount = [
182
- "style",
183
- "location",
184
- "match",
185
- "history",
186
- "staticContext",
187
- "guideState",
188
- "guideConfig"
189
- ];
190
- Object.keys(prevPropsForCompare).forEach(function(key2) {
191
- if (typeof prevPropsForCompare[key2] === "function") {
192
- delete prevPropsForCompare[key2];
193
- }
194
- });
195
- Object.keys(currentPropsForCompare).forEach(function(key2) {
196
- if (typeof currentPropsForCompare[key2] === "function") {
197
- delete currentPropsForCompare[key2];
198
- }
199
- });
200
- var prevPropsForDeepCompare = {};
201
- var currentPropsForDeepCompare = {};
202
- Object.keys(prevPropsForCompare).forEach(function(key2) {
203
- if (!ignoredKeysForRemount.includes(key2)) {
204
- prevPropsForDeepCompare[key2] = prevPropsForCompare[key2];
205
- }
206
- });
207
- Object.keys(currentPropsForCompare).forEach(function(key2) {
208
- if (!ignoredKeysForRemount.includes(key2)) {
209
- currentPropsForDeepCompare[key2] = currentPropsForCompare[key2];
210
- }
211
- });
212
- var propsEqual = deepEqualExcludeFunctions(prevPropsForDeepCompare, currentPropsForDeepCompare);
213
- if (!propsEqual) {
214
- previousPropsRef.current = props;
215
- propsRef.current = props;
216
- propsUpdateCounterRef.current += 1;
217
- setPropsUpdateKey(function(prev) {
218
- return prev + 1;
219
- });
220
- } else {
221
- previousPropsRef.current = props;
222
- propsRef.current = props;
223
- }
224
- }, [
225
- props,
226
- appInfo.name
227
- ]);
228
110
  useEffect(function() {
229
111
  var renderApp = function renderApp2() {
230
112
  return _renderApp.apply(this, arguments);
231
113
  };
232
114
  componentSetterRegistry.current = setSubModuleComponent;
233
- var _propsRef_current = propsRef.current, setLoadingState2 = _propsRef_current.setLoadingState, userProps = _object_without_properties(_propsRef_current, [
115
+ var setLoadingState = props.setLoadingState, userProps = _object_without_properties(props, [
234
116
  "setLoadingState"
235
117
  ]);
236
118
  var loadAppOptions = _object_spread_props(_object_spread({
@@ -245,7 +127,6 @@ or directly pass the "basename":
245
127
  customLoader: function(provider) {
246
128
  var render = provider.render, destroy = provider.destroy, SubModuleComponent2 = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
247
129
  var SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
248
- var isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
249
130
  var componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
250
131
  return {
251
132
  mount: function() {
@@ -254,10 +135,8 @@ or directly pass the "basename":
254
135
  }
255
136
  if (componetRenderMode && SubComponent) {
256
137
  if (componentSetterRegistry.current) {
257
- componentRef.current = SubComponent;
258
138
  componentSetterRegistry.current({
259
- component: SubComponent,
260
- isFromJupiter: isFromJupiter2
139
+ component: SubComponent
261
140
  });
262
141
  } else {
263
142
  logger('[Garfish] MicroApp for "'.concat(appInfo.name, '" tried to mount, but no active component setter was found.'));
@@ -281,7 +160,7 @@ or directly pass the "basename":
281
160
  };
282
161
  }
283
162
  });
284
- setLoadingState2({
163
+ setLoadingState({
285
164
  isLoading: true,
286
165
  error: null
287
166
  });
@@ -310,7 +189,7 @@ or directly pass the "basename":
310
189
  throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
311
190
  }
312
191
  appRef.current = appInstance;
313
- setLoadingState2({
192
+ setLoadingState({
314
193
  isLoading: false
315
194
  });
316
195
  if (!(appInstance.mounted && appInstance.appInfo.cache))
@@ -351,7 +230,7 @@ or directly pass the "basename":
351
230
  ];
352
231
  case 6:
353
232
  error = _state.sent();
354
- setLoadingState2({
233
+ setLoadingState({
355
234
  isLoading: true,
356
235
  error
357
236
  });
@@ -384,79 +263,11 @@ or directly pass the "basename":
384
263
  }
385
264
  }
386
265
  };
387
- }, [
388
- basename,
389
- domId,
390
- appInfo.name
391
- ]);
392
- useEffect(function() {
393
- var _appRef_current;
394
- if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.appInfo) {
395
- var setLoadingState2 = props.setLoadingState, updatedProps = _object_without_properties(props, [
396
- "setLoadingState"
397
- ]);
398
- var updatedPropsWithKey = _object_spread_props(_object_spread({}, appInfo.props, updatedProps), {
399
- _garfishPropsUpdateKey: propsUpdateKey
400
- });
401
- appRef.current.appInfo.props = updatedPropsWithKey;
402
- }
403
- }, [
404
- propsUpdateKey,
405
- props
406
- ]);
407
- useEffect(function() {
408
- var _appRef_current;
409
- var componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
410
- if (propsUpdateKey === lastPropsUpdateKeyRef.current || isRemountingRef.current) {
411
- return;
412
- }
413
- lastPropsUpdateKeyRef.current = propsUpdateKey;
414
- if (componetRenderMode && ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted)) {
415
- var componentToUse = SubModuleComponent || componentRef.current;
416
- if (componentToUse) {
417
- var currentComponent = componentToUse;
418
- var currentIsFromJupiter = isFromJupiter;
419
- setSubModuleComponent({
420
- component: null,
421
- isFromJupiter: false
422
- });
423
- setTimeout(function() {
424
- setSubModuleComponent({
425
- component: currentComponent,
426
- isFromJupiter: currentIsFromJupiter
427
- });
428
- }, 50);
429
- } else {
430
- var _appRef_current1;
431
- if ((_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.mounted) {
432
- var _appRef_current2;
433
- (_appRef_current2 = appRef.current) === null || _appRef_current2 === void 0 ? void 0 : _appRef_current2.hide();
434
- setTimeout(function() {
435
- var _appRef_current3;
436
- (_appRef_current3 = appRef.current) === null || _appRef_current3 === void 0 ? void 0 : _appRef_current3.show();
437
- setTimeout(function() {
438
- isRemountingRef.current = false;
439
- }, 100);
440
- }, 10);
441
- }
442
- }
443
- }
444
- }, [
445
- propsUpdateKey
446
- ]);
447
- var setLoadingState = props.setLoadingState, renderProps = _object_without_properties(props, [
448
- "setLoadingState"
449
- ]);
450
- var finalRenderProps = _object_spread_props(_object_spread({}, renderProps), {
451
- _garfishPropsUpdateKey: propsUpdateKey
452
- });
453
- var componentKey = isFromJupiter ? void 0 : "".concat(appInfo.name, "-").concat(propsUpdateKey);
266
+ }, []);
454
267
  return /* @__PURE__ */ _jsx(_Fragment, {
455
268
  children: /* @__PURE__ */ _jsx("div", {
456
269
  id: domId,
457
- children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({}, componentKey ? {
458
- key: componentKey
459
- } : {}, finalRenderProps))
270
+ children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({}, props))
460
271
  })
461
272
  });
462
273
  }
@@ -21,41 +21,6 @@ function pathJoin(...args) {
21
21
  }, "");
22
22
  return res || "/";
23
23
  }
24
- function deepEqualExcludeFunctions(prev, next, visited) {
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 visitedSet = visited !== null && visited !== void 0 ? visited : /* @__PURE__ */ new WeakSet();
32
- if (visitedSet.has(prev) || visitedSet.has(next)) {
33
- return true;
34
- }
35
- visitedSet.add(prev);
36
- visitedSet.add(next);
37
- const prevKeys = Object.keys(prev).filter((key) => typeof prev[key] !== "function");
38
- const nextKeys = Object.keys(next).filter((key) => typeof next[key] !== "function");
39
- if (prevKeys.length !== nextKeys.length)
40
- return false;
41
- for (const key of prevKeys) {
42
- if (!nextKeys.includes(key))
43
- return false;
44
- const prevVal = prev[key];
45
- const nextVal = next[key];
46
- if (typeof prevVal === "function" || typeof nextVal === "function") {
47
- continue;
48
- }
49
- if (typeof prevVal === "object" && typeof nextVal === "object") {
50
- if (!deepEqualExcludeFunctions(prevVal, nextVal, visitedSet)) {
51
- return false;
52
- }
53
- } else if (prevVal !== nextVal) {
54
- return false;
55
- }
56
- }
57
- return true;
58
- }
59
24
  function getAppInstance(options, appInfo, manifest) {
60
25
  const componentSetterRegistry = {
61
26
  current: null
@@ -64,16 +29,10 @@ function getAppInstance(options, appInfo, manifest) {
64
29
  var _context_router, _context_router1, _context_router2, _context_router3, _context_router4;
65
30
  const appRef = useRef(null);
66
31
  const locationHrefRef = useRef("");
67
- const propsRef = useRef(props);
68
- const previousPropsRef = useRef(props);
69
- const propsUpdateCounterRef = useRef(0);
70
32
  const domId = generateSubAppContainerKey(appInfo);
71
- const componentRef = useRef(null);
72
- const [{ component: SubModuleComponent, isFromJupiter }, setSubModuleComponent] = useState({
73
- component: null,
74
- isFromJupiter: false
33
+ const [{ component: SubModuleComponent }, setSubModuleComponent] = useState({
34
+ component: null
75
35
  });
76
- const [propsUpdateKey, setPropsUpdateKey] = useState(0);
77
36
  const context = useContext(RuntimeReactContext);
78
37
  var _props_useRouteMatch;
79
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;
@@ -85,8 +44,6 @@ function getAppInstance(options, appInfo, manifest) {
85
44
  const useHistory = (_props_useHistory = props.useHistory) !== null && _props_useHistory !== void 0 ? _props_useHistory : context === null || context === void 0 ? void 0 : (_context_router3 = context.router) === null || _context_router3 === void 0 ? void 0 : _context_router3.useHistory;
86
45
  var _props_useHistory1;
87
46
  const useHref = (_props_useHistory1 = props.useHistory) !== null && _props_useHistory1 !== void 0 ? _props_useHistory1 : context === null || context === void 0 ? void 0 : (_context_router4 = context.router) === null || _context_router4 === void 0 ? void 0 : _context_router4.useHref;
88
- const lastPropsUpdateKeyRef = useRef(0);
89
- const isRemountingRef = useRef(false);
90
47
  const match = useRouteMatch === null || useRouteMatch === void 0 ? void 0 : useRouteMatch();
91
48
  const matchs = useMatches === null || useMatches === void 0 ? void 0 : useMatches();
92
49
  if (!useLocation) {
@@ -142,64 +99,9 @@ or directly pass the "basename":
142
99
  }, [
143
100
  locationPathname
144
101
  ]);
145
- useEffect(() => {
146
- if (previousPropsRef.current === props) {
147
- return;
148
- }
149
- const prevPropsForCompare = {
150
- ...previousPropsRef.current
151
- };
152
- const currentPropsForCompare = {
153
- ...props
154
- };
155
- const ignoredKeysForRemount = [
156
- "style",
157
- "location",
158
- "match",
159
- "history",
160
- "staticContext",
161
- "guideState",
162
- "guideConfig"
163
- ];
164
- Object.keys(prevPropsForCompare).forEach((key) => {
165
- if (typeof prevPropsForCompare[key] === "function") {
166
- delete prevPropsForCompare[key];
167
- }
168
- });
169
- Object.keys(currentPropsForCompare).forEach((key) => {
170
- if (typeof currentPropsForCompare[key] === "function") {
171
- delete currentPropsForCompare[key];
172
- }
173
- });
174
- const prevPropsForDeepCompare = {};
175
- const currentPropsForDeepCompare = {};
176
- Object.keys(prevPropsForCompare).forEach((key) => {
177
- if (!ignoredKeysForRemount.includes(key)) {
178
- prevPropsForDeepCompare[key] = prevPropsForCompare[key];
179
- }
180
- });
181
- Object.keys(currentPropsForCompare).forEach((key) => {
182
- if (!ignoredKeysForRemount.includes(key)) {
183
- currentPropsForDeepCompare[key] = currentPropsForCompare[key];
184
- }
185
- });
186
- const propsEqual = deepEqualExcludeFunctions(prevPropsForDeepCompare, currentPropsForDeepCompare);
187
- if (!propsEqual) {
188
- previousPropsRef.current = props;
189
- propsRef.current = props;
190
- propsUpdateCounterRef.current += 1;
191
- setPropsUpdateKey((prev) => prev + 1);
192
- } else {
193
- previousPropsRef.current = props;
194
- propsRef.current = props;
195
- }
196
- }, [
197
- props,
198
- appInfo.name
199
- ]);
200
102
  useEffect(() => {
201
103
  componentSetterRegistry.current = setSubModuleComponent;
202
- const { setLoadingState: setLoadingState2, ...userProps } = propsRef.current;
104
+ const { setLoadingState, ...userProps } = props;
203
105
  const loadAppOptions = {
204
106
  cache: true,
205
107
  insulationVariable: [
@@ -216,16 +118,13 @@ or directly pass the "basename":
216
118
  customLoader: (provider) => {
217
119
  const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
218
120
  const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
219
- const isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
220
121
  const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
221
122
  return {
222
123
  mount: (...props2) => {
223
124
  if (componetRenderMode && SubComponent) {
224
125
  if (componentSetterRegistry.current) {
225
- componentRef.current = SubComponent;
226
126
  componentSetterRegistry.current({
227
- component: SubComponent,
228
- isFromJupiter: isFromJupiter2
127
+ component: SubComponent
229
128
  });
230
129
  } else {
231
130
  logger(`[Garfish] MicroApp for "${appInfo.name}" tried to mount, but no active component setter was found.`);
@@ -246,7 +145,7 @@ or directly pass the "basename":
246
145
  };
247
146
  }
248
147
  };
249
- setLoadingState2({
148
+ setLoadingState({
250
149
  isLoading: true,
251
150
  error: null
252
151
  });
@@ -260,7 +159,7 @@ or directly pass the "basename":
260
159
  throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
261
160
  }
262
161
  appRef.current = appInstance;
263
- setLoadingState2({
162
+ setLoadingState({
264
163
  isLoading: false
265
164
  });
266
165
  if (appInstance.mounted && appInstance.appInfo.cache) {
@@ -277,7 +176,7 @@ or directly pass the "basename":
277
176
  await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
278
177
  }
279
178
  } catch (error) {
280
- setLoadingState2({
179
+ setLoadingState({
281
180
  isLoading: true,
282
181
  error
283
182
  });
@@ -299,80 +198,12 @@ or directly pass the "basename":
299
198
  }
300
199
  }
301
200
  };
302
- }, [
303
- basename,
304
- domId,
305
- appInfo.name
306
- ]);
307
- useEffect(() => {
308
- var _appRef_current;
309
- if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.appInfo) {
310
- const { setLoadingState: setLoadingState2, ...updatedProps } = props;
311
- const updatedPropsWithKey = {
312
- ...appInfo.props,
313
- ...updatedProps,
314
- _garfishPropsUpdateKey: propsUpdateKey
315
- };
316
- appRef.current.appInfo.props = updatedPropsWithKey;
317
- }
318
- }, [
319
- propsUpdateKey,
320
- props
321
- ]);
322
- useEffect(() => {
323
- var _appRef_current;
324
- const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
325
- if (propsUpdateKey === lastPropsUpdateKeyRef.current || isRemountingRef.current) {
326
- return;
327
- }
328
- lastPropsUpdateKeyRef.current = propsUpdateKey;
329
- if (componetRenderMode && ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted)) {
330
- const componentToUse = SubModuleComponent || componentRef.current;
331
- if (componentToUse) {
332
- const currentComponent = componentToUse;
333
- const currentIsFromJupiter = isFromJupiter;
334
- setSubModuleComponent({
335
- component: null,
336
- isFromJupiter: false
337
- });
338
- setTimeout(() => {
339
- setSubModuleComponent({
340
- component: currentComponent,
341
- isFromJupiter: currentIsFromJupiter
342
- });
343
- }, 50);
344
- } else {
345
- var _appRef_current1;
346
- if ((_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.mounted) {
347
- var _appRef_current2;
348
- (_appRef_current2 = appRef.current) === null || _appRef_current2 === void 0 ? void 0 : _appRef_current2.hide();
349
- setTimeout(() => {
350
- var _appRef_current3;
351
- (_appRef_current3 = appRef.current) === null || _appRef_current3 === void 0 ? void 0 : _appRef_current3.show();
352
- setTimeout(() => {
353
- isRemountingRef.current = false;
354
- }, 100);
355
- }, 10);
356
- }
357
- }
358
- }
359
- }, [
360
- propsUpdateKey
361
- ]);
362
- const { setLoadingState, ...renderProps } = props;
363
- const finalRenderProps = {
364
- ...renderProps,
365
- _garfishPropsUpdateKey: propsUpdateKey
366
- };
367
- const componentKey = isFromJupiter ? void 0 : `${appInfo.name}-${propsUpdateKey}`;
201
+ }, []);
368
202
  return /* @__PURE__ */ _jsx(_Fragment, {
369
203
  children: /* @__PURE__ */ _jsx("div", {
370
204
  id: domId,
371
205
  children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {
372
- ...componentKey ? {
373
- key: componentKey
374
- } : {},
375
- ...finalRenderProps
206
+ ...props
376
207
  })
377
208
  })
378
209
  });
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.68.19-alpha.4",
18
+ "version": "2.68.20",
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.18",
73
- "@modern-js/runtime-utils": "2.68.18",
74
- "@modern-js/utils": "2.68.18"
72
+ "@modern-js/plugin-v2": "2.68.20",
73
+ "@modern-js/runtime-utils": "2.68.20",
74
+ "@modern-js/utils": "2.68.20"
75
75
  },
76
76
  "peerDependencies": {
77
- "@modern-js/runtime": "^2.68.18",
77
+ "@modern-js/runtime": "^2.68.20",
78
78
  "react": ">=17",
79
79
  "react-dom": ">=17"
80
80
  },
@@ -93,12 +93,12 @@
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.20",
97
+ "@modern-js/core": "2.68.20",
98
+ "@modern-js/plugin-router-v5": "2.68.20",
99
+ "@modern-js/runtime": "2.68.20",
100
+ "@modern-js/types": "2.68.20",
96
101
  "@scripts/build": "2.66.0",
97
- "@modern-js/app-tools": "2.68.18",
98
- "@modern-js/core": "2.68.18",
99
- "@modern-js/types": "2.68.18",
100
- "@modern-js/runtime": "2.68.18",
101
- "@modern-js/plugin-router-v5": "2.68.18",
102
102
  "@scripts/jest-config": "2.66.0"
103
103
  },
104
104
  "sideEffects": false,