@modern-js/plugin-garfish 2.68.13-alpha.1 → 2.68.13-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,8 +64,6 @@ function getAppInstance(options, appInfo, manifest) {
64
64
  const [{ component: SubModuleComponent }, setSubModuleComponent] = (0, import_react.useState)({
65
65
  component: null
66
66
  });
67
- const destroyRef = (0, import_react.useRef)(null);
68
- const isMountedRef = (0, import_react.useRef)(true);
69
67
  const context = (0, import_react.useContext)(import_runtime.RuntimeReactContext);
70
68
  var _props_useRouteMatch;
71
69
  const useRouteMatch = (_props_useRouteMatch = props.useRouteMatch) !== null && _props_useRouteMatch !== void 0 ? _props_useRouteMatch : context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : _context_router.useRouteMatch;
@@ -129,11 +127,6 @@ or directly pass the "basename":
129
127
  ]);
130
128
  (0, import_react.useEffect)(() => {
131
129
  const { setLoadingState, ...userProps } = props;
132
- const safeSetLoadingState = (state) => {
133
- if (isMountedRef.current) {
134
- setLoadingState(state);
135
- }
136
- };
137
130
  const loadAppOptions = {
138
131
  cache: true,
139
132
  insulationVariable: [
@@ -151,26 +144,6 @@ or directly pass the "basename":
151
144
  const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
152
145
  const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
153
146
  const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
154
- if (destroy) {
155
- destroyRef.current = () => {
156
- const dom = document.getElementById(domId);
157
- if (dom) {
158
- const destroyProps = {
159
- dom,
160
- basename,
161
- appName: appInfo.name,
162
- appRenderInfo: {},
163
- props: {
164
- ...appInfo.props,
165
- ...userProps
166
- }
167
- };
168
- destroy.apply(provider, [
169
- destroyProps
170
- ]);
171
- }
172
- };
173
- }
174
147
  return {
175
148
  mount: (...props2) => {
176
149
  if (componetRenderMode && SubComponent) {
@@ -193,7 +166,7 @@ or directly pass the "basename":
193
166
  };
194
167
  }
195
168
  };
196
- safeSetLoadingState({
169
+ setLoadingState({
197
170
  isLoading: true,
198
171
  error: null
199
172
  });
@@ -207,7 +180,7 @@ or directly pass the "basename":
207
180
  throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
208
181
  }
209
182
  appRef.current = appInstance;
210
- safeSetLoadingState({
183
+ setLoadingState({
211
184
  isLoading: false
212
185
  });
213
186
  if (appInstance.mounted && appInstance.appInfo.cache) {
@@ -224,7 +197,7 @@ or directly pass the "basename":
224
197
  await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
225
198
  }
226
199
  } catch (error) {
227
- safeSetLoadingState({
200
+ setLoadingState({
228
201
  isLoading: true,
229
202
  error
230
203
  });
@@ -232,7 +205,6 @@ or directly pass the "basename":
232
205
  }
233
206
  renderApp();
234
207
  return () => {
235
- isMountedRef.current = false;
236
208
  if (appRef.current) {
237
209
  const { appInfo: appInfo2 } = appRef.current;
238
210
  if (appInfo2.cache) {
@@ -247,20 +219,6 @@ or directly pass the "basename":
247
219
  }
248
220
  };
249
221
  }, []);
250
- (0, import_react.useEffect)(() => {
251
- return () => {
252
- if (SubModuleComponent && destroyRef.current && isMountedRef.current) {
253
- (0, import_util.logger)("MicroApp SubModuleComponent cleanup");
254
- try {
255
- destroyRef.current();
256
- } catch (error) {
257
- (0, import_util.logger)("Error during SubModuleComponent cleanup:", error);
258
- }
259
- }
260
- };
261
- }, [
262
- SubModuleComponent
263
- ]);
264
222
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
265
223
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
266
224
  id: domId,
@@ -40,8 +40,6 @@ function getAppInstance(options, appInfo, manifest) {
40
40
  var _useState = _sliced_to_array(useState({
41
41
  component: null
42
42
  }), 2), _useState_ = _useState[0], SubModuleComponent = _useState_.component, setSubModuleComponent = _useState[1];
43
- var destroyRef = useRef(null);
44
- var isMountedRef = useRef(true);
45
43
  var context = useContext(RuntimeReactContext);
46
44
  var _props_useRouteMatch;
47
45
  var useRouteMatch = (_props_useRouteMatch = props.useRouteMatch) !== null && _props_useRouteMatch !== void 0 ? _props_useRouteMatch : context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : _context_router.useRouteMatch;
@@ -108,11 +106,6 @@ or directly pass the "basename":
108
106
  var setLoadingState = props.setLoadingState, userProps = _object_without_properties(props, [
109
107
  "setLoadingState"
110
108
  ]);
111
- var safeSetLoadingState = function(state) {
112
- if (isMountedRef.current) {
113
- setLoadingState(state);
114
- }
115
- };
116
109
  var loadAppOptions = _object_spread_props(_object_spread({
117
110
  cache: true,
118
111
  insulationVariable: _to_consumable_array(appInfo.insulationVariable || []).concat([
@@ -126,23 +119,6 @@ or directly pass the "basename":
126
119
  var render = provider.render, destroy = provider.destroy, SubModuleComponent2 = provider.SubModuleComponent, jupiter_submodule_app_key = provider.jupiter_submodule_app_key;
127
120
  var SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
128
121
  var componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
129
- if (destroy) {
130
- destroyRef.current = function() {
131
- var dom = document.getElementById(domId);
132
- if (dom) {
133
- var destroyProps = {
134
- dom,
135
- basename,
136
- appName: appInfo.name,
137
- appRenderInfo: {},
138
- props: _object_spread({}, appInfo.props, userProps)
139
- };
140
- destroy.apply(provider, [
141
- destroyProps
142
- ]);
143
- }
144
- };
145
- }
146
122
  return {
147
123
  mount: function() {
148
124
  for (var _len = arguments.length, _$props = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -171,7 +147,7 @@ or directly pass the "basename":
171
147
  };
172
148
  }
173
149
  });
174
- safeSetLoadingState({
150
+ setLoadingState({
175
151
  isLoading: true,
176
152
  error: null
177
153
  });
@@ -200,7 +176,7 @@ or directly pass the "basename":
200
176
  throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
201
177
  }
202
178
  appRef.current = appInstance;
203
- safeSetLoadingState({
179
+ setLoadingState({
204
180
  isLoading: false
205
181
  });
206
182
  if (!(appInstance.mounted && appInstance.appInfo.cache))
@@ -241,7 +217,7 @@ or directly pass the "basename":
241
217
  ];
242
218
  case 6:
243
219
  error = _state.sent();
244
- safeSetLoadingState({
220
+ setLoadingState({
245
221
  isLoading: true,
246
222
  error
247
223
  });
@@ -260,7 +236,6 @@ or directly pass the "basename":
260
236
  }
261
237
  renderApp();
262
238
  return function() {
263
- isMountedRef.current = false;
264
239
  if (appRef.current) {
265
240
  var _$appInfo = appRef.current.appInfo;
266
241
  if (_$appInfo.cache) {
@@ -275,20 +250,6 @@ or directly pass the "basename":
275
250
  }
276
251
  };
277
252
  }, []);
278
- useEffect(function() {
279
- return function() {
280
- if (SubModuleComponent && destroyRef.current && isMountedRef.current) {
281
- logger("MicroApp SubModuleComponent cleanup");
282
- try {
283
- destroyRef.current();
284
- } catch (error) {
285
- logger("Error during SubModuleComponent cleanup:", error);
286
- }
287
- }
288
- };
289
- }, [
290
- SubModuleComponent
291
- ]);
292
253
  return /* @__PURE__ */ _jsx(_Fragment, {
293
254
  children: /* @__PURE__ */ _jsx("div", {
294
255
  id: domId,
@@ -30,8 +30,6 @@ function getAppInstance(options, appInfo, manifest) {
30
30
  const [{ component: SubModuleComponent }, setSubModuleComponent] = useState({
31
31
  component: null
32
32
  });
33
- const destroyRef = useRef(null);
34
- const isMountedRef = useRef(true);
35
33
  const context = useContext(RuntimeReactContext);
36
34
  var _props_useRouteMatch;
37
35
  const useRouteMatch = (_props_useRouteMatch = props.useRouteMatch) !== null && _props_useRouteMatch !== void 0 ? _props_useRouteMatch : context === null || context === void 0 ? void 0 : (_context_router = context.router) === null || _context_router === void 0 ? void 0 : _context_router.useRouteMatch;
@@ -95,11 +93,6 @@ or directly pass the "basename":
95
93
  ]);
96
94
  useEffect(() => {
97
95
  const { setLoadingState, ...userProps } = props;
98
- const safeSetLoadingState = (state) => {
99
- if (isMountedRef.current) {
100
- setLoadingState(state);
101
- }
102
- };
103
96
  const loadAppOptions = {
104
97
  cache: true,
105
98
  insulationVariable: [
@@ -117,26 +110,6 @@ or directly pass the "basename":
117
110
  const { render, destroy, SubModuleComponent: SubModuleComponent2, jupiter_submodule_app_key } = provider;
118
111
  const SubComponent = SubModuleComponent2 || jupiter_submodule_app_key;
119
112
  const componetRenderMode = manifest === null || manifest === void 0 ? void 0 : manifest.componentRender;
120
- if (destroy) {
121
- destroyRef.current = () => {
122
- const dom = document.getElementById(domId);
123
- if (dom) {
124
- const destroyProps = {
125
- dom,
126
- basename,
127
- appName: appInfo.name,
128
- appRenderInfo: {},
129
- props: {
130
- ...appInfo.props,
131
- ...userProps
132
- }
133
- };
134
- destroy.apply(provider, [
135
- destroyProps
136
- ]);
137
- }
138
- };
139
- }
140
113
  return {
141
114
  mount: (...props2) => {
142
115
  if (componetRenderMode && SubComponent) {
@@ -159,7 +132,7 @@ or directly pass the "basename":
159
132
  };
160
133
  }
161
134
  };
162
- safeSetLoadingState({
135
+ setLoadingState({
163
136
  isLoading: true,
164
137
  error: null
165
138
  });
@@ -173,7 +146,7 @@ or directly pass the "basename":
173
146
  throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
174
147
  }
175
148
  appRef.current = appInstance;
176
- safeSetLoadingState({
149
+ setLoadingState({
177
150
  isLoading: false
178
151
  });
179
152
  if (appInstance.mounted && appInstance.appInfo.cache) {
@@ -190,7 +163,7 @@ or directly pass the "basename":
190
163
  await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
191
164
  }
192
165
  } catch (error) {
193
- safeSetLoadingState({
166
+ setLoadingState({
194
167
  isLoading: true,
195
168
  error
196
169
  });
@@ -198,7 +171,6 @@ or directly pass the "basename":
198
171
  }
199
172
  renderApp();
200
173
  return () => {
201
- isMountedRef.current = false;
202
174
  if (appRef.current) {
203
175
  const { appInfo: appInfo2 } = appRef.current;
204
176
  if (appInfo2.cache) {
@@ -213,20 +185,6 @@ or directly pass the "basename":
213
185
  }
214
186
  };
215
187
  }, []);
216
- useEffect(() => {
217
- return () => {
218
- if (SubModuleComponent && destroyRef.current && isMountedRef.current) {
219
- logger("MicroApp SubModuleComponent cleanup");
220
- try {
221
- destroyRef.current();
222
- } catch (error) {
223
- logger("Error during SubModuleComponent cleanup:", error);
224
- }
225
- }
226
- };
227
- }, [
228
- SubModuleComponent
229
- ]);
230
188
  return /* @__PURE__ */ _jsx(_Fragment, {
231
189
  children: /* @__PURE__ */ _jsx("div", {
232
190
  id: domId,
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.68.13-alpha.1",
18
+ "version": "2.68.13-alpha.3",
19
19
  "jsnext:source": "./src/cli/index.ts",
20
20
  "types": "./dist/types/cli/index.d.ts",
21
21
  "typesVersions": {
@@ -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.12",
97
+ "@modern-js/core": "2.68.12",
96
98
  "@modern-js/runtime": "2.68.12",
97
- "@scripts/build": "2.66.0",
98
99
  "@modern-js/types": "2.68.12",
99
- "@modern-js/app-tools": "2.68.12",
100
+ "@scripts/build": "2.66.0",
100
101
  "@scripts/jest-config": "2.66.0",
101
- "@modern-js/plugin-router-v5": "2.68.12",
102
- "@modern-js/core": "2.68.12"
102
+ "@modern-js/plugin-router-v5": "2.68.12"
103
103
  },
104
104
  "sideEffects": false,
105
105
  "publishConfig": {