@modern-js/plugin-garfish 2.68.19-alpha.1 → 2.68.19-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.
@@ -96,8 +96,10 @@ function getAppInstance(options, appInfo, manifest) {
96
96
  const previousPropsRef = (0, import_react.useRef)(props);
97
97
  const propsUpdateCounterRef = (0, import_react.useRef)(0);
98
98
  const domId = (0, import_util.generateSubAppContainerKey)(appInfo);
99
- const [{ component: SubModuleComponent }, setSubModuleComponent] = (0, import_react.useState)({
100
- component: null
99
+ const componentRef = (0, import_react.useRef)(null);
100
+ const [{ component: SubModuleComponent, isFromJupiter }, setSubModuleComponent] = (0, import_react.useState)({
101
+ component: null,
102
+ isFromJupiter: false
101
103
  });
102
104
  const [propsUpdateKey, setPropsUpdateKey] = (0, import_react.useState)(0);
103
105
  const context = (0, import_react.useContext)(import_runtime.RuntimeReactContext);
@@ -184,19 +186,10 @@ or directly pass the "basename":
184
186
  }
185
187
  });
186
188
  if (!deepEqualExcludeFunctions(prevPropsForCompare, currentPropsForCompare)) {
187
- var _appRef_current;
188
189
  previousPropsRef.current = props;
189
190
  propsRef.current = props;
190
191
  propsUpdateCounterRef.current += 1;
191
192
  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
193
  }
201
194
  }, [
202
195
  props,
@@ -221,13 +214,16 @@ or directly pass the "basename":
221
214
  customLoader: (provider) => {
222
215
  const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
223
216
  const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
217
+ const isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
224
218
  const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
225
219
  return {
226
220
  mount: (...props2) => {
227
221
  if (componetRenderMode && SubComponent) {
228
222
  if (componentSetterRegistry.current) {
223
+ componentRef.current = SubComponent;
229
224
  componentSetterRegistry.current({
230
- component: SubComponent
225
+ component: SubComponent,
226
+ isFromJupiter: isFromJupiter2
231
227
  });
232
228
  } else {
233
229
  (0, import_util.logger)(`[Garfish] MicroApp for "${appInfo.name}" tried to mount, but no active component setter was found.`);
@@ -321,18 +317,54 @@ or directly pass the "basename":
321
317
  propsUpdateKey,
322
318
  props
323
319
  ]);
320
+ (0, import_react.useEffect)(() => {
321
+ var _appRef_current;
322
+ const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
323
+ if (componetRenderMode && ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted)) {
324
+ const componentToUse = SubModuleComponent || componentRef.current;
325
+ if (componentToUse) {
326
+ const currentComponent = componentToUse;
327
+ const currentIsFromJupiter = isFromJupiter;
328
+ setSubModuleComponent({
329
+ component: null,
330
+ isFromJupiter: false
331
+ });
332
+ setTimeout(() => {
333
+ setSubModuleComponent({
334
+ component: currentComponent,
335
+ isFromJupiter: currentIsFromJupiter
336
+ });
337
+ }, 50);
338
+ } else {
339
+ var _appRef_current1;
340
+ if ((_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.mounted) {
341
+ var _appRef_current2;
342
+ (_appRef_current2 = appRef.current) === null || _appRef_current2 === void 0 ? void 0 : _appRef_current2.hide();
343
+ setTimeout(() => {
344
+ var _appRef_current3;
345
+ (_appRef_current3 = appRef.current) === null || _appRef_current3 === void 0 ? void 0 : _appRef_current3.show();
346
+ }, 10);
347
+ }
348
+ }
349
+ }
350
+ }, [
351
+ propsUpdateKey
352
+ ]);
324
353
  const { setLoadingState, ...renderProps } = props;
325
354
  const finalRenderProps = {
326
355
  ...renderProps,
327
356
  _garfishPropsUpdateKey: propsUpdateKey
328
357
  };
329
- const componentKey = `${appInfo.name}-${propsUpdateKey}`;
358
+ const componentKey = isFromJupiter ? void 0 : `${appInfo.name}-${propsUpdateKey}`;
330
359
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
331
360
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
332
361
  id: domId,
333
362
  children: SubModuleComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubModuleComponent, {
363
+ ...componentKey ? {
364
+ key: componentKey
365
+ } : {},
334
366
  ...finalRenderProps
335
- }, componentKey)
367
+ })
336
368
  })
337
369
  });
338
370
  }
@@ -94,9 +94,11 @@ function getAppInstance(options, appInfo, manifest) {
94
94
  var previousPropsRef = useRef(props);
95
95
  var propsUpdateCounterRef = useRef(0);
96
96
  var domId = generateSubAppContainerKey(appInfo);
97
+ var componentRef = useRef(null);
97
98
  var _useState = _sliced_to_array(useState({
98
- component: null
99
- }), 2), _useState_ = _useState[0], SubModuleComponent = _useState_.component, setSubModuleComponent = _useState[1];
99
+ component: null,
100
+ isFromJupiter: false
101
+ }), 2), _useState_ = _useState[0], SubModuleComponent = _useState_.component, isFromJupiter = _useState_.isFromJupiter, setSubModuleComponent = _useState[1];
100
102
  var _useState1 = _sliced_to_array(useState(0), 2), propsUpdateKey = _useState1[0], setPropsUpdateKey = _useState1[1];
101
103
  var context = useContext(RuntimeReactContext);
102
104
  var _props_useRouteMatch;
@@ -176,21 +178,12 @@ or directly pass the "basename":
176
178
  }
177
179
  });
178
180
  if (!deepEqualExcludeFunctions(prevPropsForCompare, currentPropsForCompare)) {
179
- var _appRef_current;
180
181
  previousPropsRef.current = props;
181
182
  propsRef.current = props;
182
183
  propsUpdateCounterRef.current += 1;
183
184
  setPropsUpdateKey(function(prev) {
184
185
  return prev + 1;
185
186
  });
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
187
  }
195
188
  }, [
196
189
  props,
@@ -216,6 +209,7 @@ or directly pass the "basename":
216
209
  customLoader: function(provider) {
217
210
  var render = provider.render, destroy = provider.destroy, SubModuleComponent2 = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
218
211
  var SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
212
+ var isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
219
213
  var componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
220
214
  return {
221
215
  mount: function() {
@@ -224,8 +218,10 @@ or directly pass the "basename":
224
218
  }
225
219
  if (componetRenderMode && SubComponent) {
226
220
  if (componentSetterRegistry.current) {
221
+ componentRef.current = SubComponent;
227
222
  componentSetterRegistry.current({
228
- component: SubComponent
223
+ component: SubComponent,
224
+ isFromJupiter: isFromJupiter2
229
225
  });
230
226
  } else {
231
227
  logger('[Garfish] MicroApp for "'.concat(appInfo.name, '" tried to mount, but no active component setter was found.'));
@@ -372,17 +368,52 @@ or directly pass the "basename":
372
368
  propsUpdateKey,
373
369
  props
374
370
  ]);
371
+ useEffect(function() {
372
+ var _appRef_current;
373
+ var componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
374
+ if (componetRenderMode && ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted)) {
375
+ var componentToUse = SubModuleComponent || componentRef.current;
376
+ if (componentToUse) {
377
+ var currentComponent = componentToUse;
378
+ var currentIsFromJupiter = isFromJupiter;
379
+ setSubModuleComponent({
380
+ component: null,
381
+ isFromJupiter: false
382
+ });
383
+ setTimeout(function() {
384
+ setSubModuleComponent({
385
+ component: currentComponent,
386
+ isFromJupiter: currentIsFromJupiter
387
+ });
388
+ }, 50);
389
+ } else {
390
+ var _appRef_current1;
391
+ if ((_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.mounted) {
392
+ var _appRef_current2;
393
+ (_appRef_current2 = appRef.current) === null || _appRef_current2 === void 0 ? void 0 : _appRef_current2.hide();
394
+ setTimeout(function() {
395
+ var _appRef_current3;
396
+ (_appRef_current3 = appRef.current) === null || _appRef_current3 === void 0 ? void 0 : _appRef_current3.show();
397
+ }, 10);
398
+ }
399
+ }
400
+ }
401
+ }, [
402
+ propsUpdateKey
403
+ ]);
375
404
  var setLoadingState = props.setLoadingState, renderProps = _object_without_properties(props, [
376
405
  "setLoadingState"
377
406
  ]);
378
407
  var finalRenderProps = _object_spread_props(_object_spread({}, renderProps), {
379
408
  _garfishPropsUpdateKey: propsUpdateKey
380
409
  });
381
- var componentKey = "".concat(appInfo.name, "-").concat(propsUpdateKey);
410
+ var componentKey = isFromJupiter ? void 0 : "".concat(appInfo.name, "-").concat(propsUpdateKey);
382
411
  return /* @__PURE__ */ _jsx(_Fragment, {
383
412
  children: /* @__PURE__ */ _jsx("div", {
384
413
  id: domId,
385
- children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({}, finalRenderProps), componentKey)
414
+ children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({}, componentKey ? {
415
+ key: componentKey
416
+ } : {}, finalRenderProps))
386
417
  })
387
418
  });
388
419
  }
@@ -62,8 +62,10 @@ function getAppInstance(options, appInfo, manifest) {
62
62
  const previousPropsRef = useRef(props);
63
63
  const propsUpdateCounterRef = useRef(0);
64
64
  const domId = generateSubAppContainerKey(appInfo);
65
- const [{ component: SubModuleComponent }, setSubModuleComponent] = useState({
66
- component: null
65
+ const componentRef = useRef(null);
66
+ const [{ component: SubModuleComponent, isFromJupiter }, setSubModuleComponent] = useState({
67
+ component: null,
68
+ isFromJupiter: false
67
69
  });
68
70
  const [propsUpdateKey, setPropsUpdateKey] = useState(0);
69
71
  const context = useContext(RuntimeReactContext);
@@ -150,19 +152,10 @@ or directly pass the "basename":
150
152
  }
151
153
  });
152
154
  if (!deepEqualExcludeFunctions(prevPropsForCompare, currentPropsForCompare)) {
153
- var _appRef_current;
154
155
  previousPropsRef.current = props;
155
156
  propsRef.current = props;
156
157
  propsUpdateCounterRef.current += 1;
157
158
  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
159
  }
167
160
  }, [
168
161
  props,
@@ -187,13 +180,16 @@ or directly pass the "basename":
187
180
  customLoader: (provider) => {
188
181
  const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
189
182
  const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
183
+ const isFromJupiter2 = !SubModuleComponent2 && !!jupiter_submodule_app_key;
190
184
  const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
191
185
  return {
192
186
  mount: (...props2) => {
193
187
  if (componetRenderMode && SubComponent) {
194
188
  if (componentSetterRegistry.current) {
189
+ componentRef.current = SubComponent;
195
190
  componentSetterRegistry.current({
196
- component: SubComponent
191
+ component: SubComponent,
192
+ isFromJupiter: isFromJupiter2
197
193
  });
198
194
  } else {
199
195
  logger(`[Garfish] MicroApp for "${appInfo.name}" tried to mount, but no active component setter was found.`);
@@ -287,18 +283,54 @@ or directly pass the "basename":
287
283
  propsUpdateKey,
288
284
  props
289
285
  ]);
286
+ useEffect(() => {
287
+ var _appRef_current;
288
+ const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
289
+ if (componetRenderMode && ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted)) {
290
+ const componentToUse = SubModuleComponent || componentRef.current;
291
+ if (componentToUse) {
292
+ const currentComponent = componentToUse;
293
+ const currentIsFromJupiter = isFromJupiter;
294
+ setSubModuleComponent({
295
+ component: null,
296
+ isFromJupiter: false
297
+ });
298
+ setTimeout(() => {
299
+ setSubModuleComponent({
300
+ component: currentComponent,
301
+ isFromJupiter: currentIsFromJupiter
302
+ });
303
+ }, 50);
304
+ } else {
305
+ var _appRef_current1;
306
+ if ((_appRef_current1 = appRef.current) === null || _appRef_current1 === void 0 ? void 0 : _appRef_current1.mounted) {
307
+ var _appRef_current2;
308
+ (_appRef_current2 = appRef.current) === null || _appRef_current2 === void 0 ? void 0 : _appRef_current2.hide();
309
+ setTimeout(() => {
310
+ var _appRef_current3;
311
+ (_appRef_current3 = appRef.current) === null || _appRef_current3 === void 0 ? void 0 : _appRef_current3.show();
312
+ }, 10);
313
+ }
314
+ }
315
+ }
316
+ }, [
317
+ propsUpdateKey
318
+ ]);
290
319
  const { setLoadingState, ...renderProps } = props;
291
320
  const finalRenderProps = {
292
321
  ...renderProps,
293
322
  _garfishPropsUpdateKey: propsUpdateKey
294
323
  };
295
- const componentKey = `${appInfo.name}-${propsUpdateKey}`;
324
+ const componentKey = isFromJupiter ? void 0 : `${appInfo.name}-${propsUpdateKey}`;
296
325
  return /* @__PURE__ */ _jsx(_Fragment, {
297
326
  children: /* @__PURE__ */ _jsx("div", {
298
327
  id: domId,
299
328
  children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {
329
+ ...componentKey ? {
330
+ key: componentKey
331
+ } : {},
300
332
  ...finalRenderProps
301
- }, componentKey)
333
+ })
302
334
  })
303
335
  });
304
336
  }
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.68.19-alpha.1",
18
+ "version": "2.68.19-alpha.3",
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/plugin-v2": "2.68.18",
72
73
  "@modern-js/utils": "2.68.18",
73
- "@modern-js/runtime-utils": "2.68.18",
74
- "@modern-js/plugin-v2": "2.68.18"
74
+ "@modern-js/runtime-utils": "2.68.18"
75
75
  },
76
76
  "peerDependencies": {
77
77
  "@modern-js/runtime": "^2.68.18",
@@ -95,11 +95,11 @@
95
95
  "typescript": "^5",
96
96
  "@modern-js/app-tools": "2.68.18",
97
97
  "@scripts/build": "2.66.0",
98
- "@modern-js/core": "2.68.18",
98
+ "@modern-js/runtime": "2.68.18",
99
99
  "@modern-js/plugin-router-v5": "2.68.18",
100
100
  "@modern-js/types": "2.68.18",
101
101
  "@scripts/jest-config": "2.66.0",
102
- "@modern-js/runtime": "2.68.18"
102
+ "@modern-js/core": "2.68.18"
103
103
  },
104
104
  "sideEffects": false,
105
105
  "publishConfig": {