@modern-js/plugin-garfish 2.68.19-alpha.0 → 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.
|
@@ -99,6 +99,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
99
99
|
const [{ component: SubModuleComponent }, setSubModuleComponent] = (0, import_react.useState)({
|
|
100
100
|
component: null
|
|
101
101
|
});
|
|
102
|
+
const [propsUpdateKey, setPropsUpdateKey] = (0, import_react.useState)(0);
|
|
102
103
|
const context = (0, import_react.useContext)(import_runtime.RuntimeReactContext);
|
|
103
104
|
var _props_useRouteMatch;
|
|
104
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;
|
|
@@ -187,6 +188,7 @@ or directly pass the "basename":
|
|
|
187
188
|
previousPropsRef.current = props;
|
|
188
189
|
propsRef.current = props;
|
|
189
190
|
propsUpdateCounterRef.current += 1;
|
|
191
|
+
setPropsUpdateKey((prev) => prev + 1);
|
|
190
192
|
if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted) {
|
|
191
193
|
window.dispatchEvent(new CustomEvent("garfishPropsUpdated", {
|
|
192
194
|
detail: {
|
|
@@ -202,7 +204,7 @@ or directly pass the "basename":
|
|
|
202
204
|
]);
|
|
203
205
|
(0, import_react.useEffect)(() => {
|
|
204
206
|
componentSetterRegistry.current = setSubModuleComponent;
|
|
205
|
-
const { setLoadingState, ...userProps } = propsRef.current;
|
|
207
|
+
const { setLoadingState: setLoadingState2, ...userProps } = propsRef.current;
|
|
206
208
|
const loadAppOptions = {
|
|
207
209
|
cache: true,
|
|
208
210
|
insulationVariable: [
|
|
@@ -246,7 +248,7 @@ or directly pass the "basename":
|
|
|
246
248
|
};
|
|
247
249
|
}
|
|
248
250
|
};
|
|
249
|
-
|
|
251
|
+
setLoadingState2({
|
|
250
252
|
isLoading: true,
|
|
251
253
|
error: null
|
|
252
254
|
});
|
|
@@ -260,7 +262,7 @@ or directly pass the "basename":
|
|
|
260
262
|
throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
|
|
261
263
|
}
|
|
262
264
|
appRef.current = appInstance;
|
|
263
|
-
|
|
265
|
+
setLoadingState2({
|
|
264
266
|
isLoading: false
|
|
265
267
|
});
|
|
266
268
|
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
@@ -277,7 +279,7 @@ or directly pass the "basename":
|
|
|
277
279
|
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
278
280
|
}
|
|
279
281
|
} catch (error) {
|
|
280
|
-
|
|
282
|
+
setLoadingState2({
|
|
281
283
|
isLoading: true,
|
|
282
284
|
error
|
|
283
285
|
});
|
|
@@ -304,12 +306,33 @@ or directly pass the "basename":
|
|
|
304
306
|
domId,
|
|
305
307
|
appInfo.name
|
|
306
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}`;
|
|
307
330
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
308
331
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
309
332
|
id: domId,
|
|
310
333
|
children: SubModuleComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SubModuleComponent, {
|
|
311
|
-
...
|
|
312
|
-
},
|
|
334
|
+
...finalRenderProps
|
|
335
|
+
}, componentKey)
|
|
313
336
|
})
|
|
314
337
|
});
|
|
315
338
|
}
|
|
@@ -97,6 +97,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
97
97
|
var _useState = _sliced_to_array(useState({
|
|
98
98
|
component: null
|
|
99
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];
|
|
100
101
|
var context = useContext(RuntimeReactContext);
|
|
101
102
|
var _props_useRouteMatch;
|
|
102
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;
|
|
@@ -179,6 +180,9 @@ or directly pass the "basename":
|
|
|
179
180
|
previousPropsRef.current = props;
|
|
180
181
|
propsRef.current = props;
|
|
181
182
|
propsUpdateCounterRef.current += 1;
|
|
183
|
+
setPropsUpdateKey(function(prev) {
|
|
184
|
+
return prev + 1;
|
|
185
|
+
});
|
|
182
186
|
if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted) {
|
|
183
187
|
window.dispatchEvent(new CustomEvent("garfishPropsUpdated", {
|
|
184
188
|
detail: {
|
|
@@ -197,7 +201,7 @@ or directly pass the "basename":
|
|
|
197
201
|
return _renderApp.apply(this, arguments);
|
|
198
202
|
};
|
|
199
203
|
componentSetterRegistry.current = setSubModuleComponent;
|
|
200
|
-
var _propsRef_current = propsRef.current,
|
|
204
|
+
var _propsRef_current = propsRef.current, setLoadingState2 = _propsRef_current.setLoadingState, userProps = _object_without_properties(_propsRef_current, [
|
|
201
205
|
"setLoadingState"
|
|
202
206
|
]);
|
|
203
207
|
var loadAppOptions = _object_spread_props(_object_spread({
|
|
@@ -245,7 +249,7 @@ or directly pass the "basename":
|
|
|
245
249
|
};
|
|
246
250
|
}
|
|
247
251
|
});
|
|
248
|
-
|
|
252
|
+
setLoadingState2({
|
|
249
253
|
isLoading: true,
|
|
250
254
|
error: null
|
|
251
255
|
});
|
|
@@ -274,7 +278,7 @@ or directly pass the "basename":
|
|
|
274
278
|
throw new Error('MicroApp Garfish.loadApp "'.concat(appInfo.name, '" result is null'));
|
|
275
279
|
}
|
|
276
280
|
appRef.current = appInstance;
|
|
277
|
-
|
|
281
|
+
setLoadingState2({
|
|
278
282
|
isLoading: false
|
|
279
283
|
});
|
|
280
284
|
if (!(appInstance.mounted && appInstance.appInfo.cache))
|
|
@@ -315,7 +319,7 @@ or directly pass the "basename":
|
|
|
315
319
|
];
|
|
316
320
|
case 6:
|
|
317
321
|
error = _state.sent();
|
|
318
|
-
|
|
322
|
+
setLoadingState2({
|
|
319
323
|
isLoading: true,
|
|
320
324
|
error
|
|
321
325
|
});
|
|
@@ -353,10 +357,32 @@ or directly pass the "basename":
|
|
|
353
357
|
domId,
|
|
354
358
|
appInfo.name
|
|
355
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);
|
|
356
382
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
357
383
|
children: /* @__PURE__ */ _jsx("div", {
|
|
358
384
|
id: domId,
|
|
359
|
-
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({},
|
|
385
|
+
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, _object_spread({}, finalRenderProps), componentKey)
|
|
360
386
|
})
|
|
361
387
|
});
|
|
362
388
|
}
|
|
@@ -65,6 +65,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
65
65
|
const [{ component: SubModuleComponent }, setSubModuleComponent] = useState({
|
|
66
66
|
component: null
|
|
67
67
|
});
|
|
68
|
+
const [propsUpdateKey, setPropsUpdateKey] = useState(0);
|
|
68
69
|
const context = useContext(RuntimeReactContext);
|
|
69
70
|
var _props_useRouteMatch;
|
|
70
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;
|
|
@@ -153,6 +154,7 @@ or directly pass the "basename":
|
|
|
153
154
|
previousPropsRef.current = props;
|
|
154
155
|
propsRef.current = props;
|
|
155
156
|
propsUpdateCounterRef.current += 1;
|
|
157
|
+
setPropsUpdateKey((prev) => prev + 1);
|
|
156
158
|
if ((_appRef_current = appRef.current) === null || _appRef_current === void 0 ? void 0 : _appRef_current.mounted) {
|
|
157
159
|
window.dispatchEvent(new CustomEvent("garfishPropsUpdated", {
|
|
158
160
|
detail: {
|
|
@@ -168,7 +170,7 @@ or directly pass the "basename":
|
|
|
168
170
|
]);
|
|
169
171
|
useEffect(() => {
|
|
170
172
|
componentSetterRegistry.current = setSubModuleComponent;
|
|
171
|
-
const { setLoadingState, ...userProps } = propsRef.current;
|
|
173
|
+
const { setLoadingState: setLoadingState2, ...userProps } = propsRef.current;
|
|
172
174
|
const loadAppOptions = {
|
|
173
175
|
cache: true,
|
|
174
176
|
insulationVariable: [
|
|
@@ -212,7 +214,7 @@ or directly pass the "basename":
|
|
|
212
214
|
};
|
|
213
215
|
}
|
|
214
216
|
};
|
|
215
|
-
|
|
217
|
+
setLoadingState2({
|
|
216
218
|
isLoading: true,
|
|
217
219
|
error: null
|
|
218
220
|
});
|
|
@@ -226,7 +228,7 @@ or directly pass the "basename":
|
|
|
226
228
|
throw new Error(`MicroApp Garfish.loadApp "${appInfo.name}" result is null`);
|
|
227
229
|
}
|
|
228
230
|
appRef.current = appInstance;
|
|
229
|
-
|
|
231
|
+
setLoadingState2({
|
|
230
232
|
isLoading: false
|
|
231
233
|
});
|
|
232
234
|
if (appInstance.mounted && appInstance.appInfo.cache) {
|
|
@@ -243,7 +245,7 @@ or directly pass the "basename":
|
|
|
243
245
|
await (appInstance === null || appInstance === void 0 ? void 0 : appInstance.mount());
|
|
244
246
|
}
|
|
245
247
|
} catch (error) {
|
|
246
|
-
|
|
248
|
+
setLoadingState2({
|
|
247
249
|
isLoading: true,
|
|
248
250
|
error
|
|
249
251
|
});
|
|
@@ -270,12 +272,33 @@ or directly pass the "basename":
|
|
|
270
272
|
domId,
|
|
271
273
|
appInfo.name
|
|
272
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}`;
|
|
273
296
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
274
297
|
children: /* @__PURE__ */ _jsx("div", {
|
|
275
298
|
id: domId,
|
|
276
299
|
children: SubModuleComponent && /* @__PURE__ */ _jsx(SubModuleComponent, {
|
|
277
|
-
...
|
|
278
|
-
},
|
|
300
|
+
...finalRenderProps
|
|
301
|
+
}, componentKey)
|
|
279
302
|
})
|
|
280
303
|
});
|
|
281
304
|
}
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.68.19-alpha.
|
|
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/utils": "2.68.18",
|
|
72
73
|
"@modern-js/runtime-utils": "2.68.18",
|
|
73
|
-
"@modern-js/plugin-v2": "2.68.18"
|
|
74
|
-
"@modern-js/utils": "2.68.18"
|
|
74
|
+
"@modern-js/plugin-v2": "2.68.18"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@modern-js/runtime": "^2.68.18",
|
|
@@ -97,9 +97,9 @@
|
|
|
97
97
|
"@scripts/build": "2.66.0",
|
|
98
98
|
"@modern-js/core": "2.68.18",
|
|
99
99
|
"@modern-js/plugin-router-v5": "2.68.18",
|
|
100
|
-
"@modern-js/
|
|
100
|
+
"@modern-js/types": "2.68.18",
|
|
101
101
|
"@scripts/jest-config": "2.66.0",
|
|
102
|
-
"@modern-js/
|
|
102
|
+
"@modern-js/runtime": "2.68.18"
|
|
103
103
|
},
|
|
104
104
|
"sideEffects": false,
|
|
105
105
|
"publishConfig": {
|