@umijs/renderer-react 4.6.66 → 4.6.67
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.
- package/dist/appContext.js +3 -1
- package/dist/browser.js +2 -0
- package/dist/dataFetcher.d.ts +6 -1
- package/dist/dataFetcher.js +25 -5
- package/package.json +1 -1
package/dist/appContext.js
CHANGED
|
@@ -31,7 +31,8 @@ export function useServerLoaderData() {
|
|
|
31
31
|
var routes = useSelectedRoutes();
|
|
32
32
|
var _useAppData2 = useAppData(),
|
|
33
33
|
serverLoaderData = _useAppData2.serverLoaderData,
|
|
34
|
-
basename = _useAppData2.basename
|
|
34
|
+
basename = _useAppData2.basename,
|
|
35
|
+
pluginManager = _useAppData2.pluginManager;
|
|
35
36
|
var _React$useState = React.useState(function () {
|
|
36
37
|
var ret = {};
|
|
37
38
|
var has = false;
|
|
@@ -58,6 +59,7 @@ export function useServerLoaderData() {
|
|
|
58
59
|
fetchServerLoader({
|
|
59
60
|
id: route.route.id,
|
|
60
61
|
basename: basename,
|
|
62
|
+
pluginManager: pluginManager,
|
|
61
63
|
cb: resolve
|
|
62
64
|
});
|
|
63
65
|
});
|
package/dist/browser.js
CHANGED
|
@@ -166,6 +166,7 @@ var getBrowser = function getBrowser(opts, routesElement) {
|
|
|
166
166
|
fetchServerLoader({
|
|
167
167
|
id: id,
|
|
168
168
|
basename: basename,
|
|
169
|
+
pluginManager: opts.pluginManager,
|
|
169
170
|
cb: function cb(data) {
|
|
170
171
|
// setServerLoaderData when startTransition because if ssr is enabled,
|
|
171
172
|
// the component may being hydrated and setLoaderData will break the hydration
|
|
@@ -193,6 +194,7 @@ var getBrowser = function getBrowser(opts, routesElement) {
|
|
|
193
194
|
return fetchServerLoader({
|
|
194
195
|
id: id,
|
|
195
196
|
basename: basename,
|
|
197
|
+
pluginManager: opts.pluginManager,
|
|
196
198
|
cb: function cb(data) {
|
|
197
199
|
// setServerLoaderData when startTransition because if ssr is enabled,
|
|
198
200
|
// the component may being hydrated and setLoaderData will break the hydration
|
package/dist/dataFetcher.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface IServerLoaderRequest {
|
|
2
|
+
url: string;
|
|
3
|
+
options: RequestInit;
|
|
4
|
+
}
|
|
5
|
+
export declare function fetchServerLoader({ id, basename, cb, pluginManager, }: {
|
|
2
6
|
id: string;
|
|
3
7
|
basename?: string;
|
|
4
8
|
cb: (data: any) => void;
|
|
9
|
+
pluginManager?: any;
|
|
5
10
|
}): void;
|
package/dist/dataFetcher.js
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
1
|
export function fetchServerLoader(_ref) {
|
|
2
2
|
var id = _ref.id,
|
|
3
3
|
basename = _ref.basename,
|
|
4
|
-
cb = _ref.cb
|
|
4
|
+
cb = _ref.cb,
|
|
5
|
+
pluginManager = _ref.pluginManager;
|
|
5
6
|
var query = new URLSearchParams({
|
|
6
7
|
route: id,
|
|
7
8
|
url: window.location.href
|
|
8
9
|
}).toString();
|
|
9
10
|
// 在有basename的情况下__serverLoader的请求路径需要加上basename
|
|
10
11
|
// FIXME: 先临时解自定义 serverLoader 请求路径的问题,后续改造 serverLoader 时再提取成类似 runtimeServerLoader 的配置项
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
var defaultUrl = "".concat(withEndSlash(window.umiServerLoaderPath || basename), "__serverLoader?").concat(query);
|
|
13
|
+
|
|
14
|
+
// Runtime hook to let consumers rewrite the direct serverLoader request
|
|
15
|
+
// (e.g. add gateway headers/query when calling WebGW FaaS directly).
|
|
16
|
+
// The framework stays agnostic of any gateway protocol.
|
|
17
|
+
var req = {
|
|
18
|
+
url: defaultUrl,
|
|
19
|
+
options: {
|
|
20
|
+
credentials: 'include'
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
if (pluginManager !== null && pluginManager !== void 0 && pluginManager.applyPlugins) {
|
|
24
|
+
req = pluginManager.applyPlugins({
|
|
25
|
+
key: 'modifyServerLoaderRequest',
|
|
26
|
+
type: 'modify',
|
|
27
|
+
initialValue: req,
|
|
28
|
+
args: {
|
|
29
|
+
id: id,
|
|
30
|
+
basename: basename
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
fetch(req.url, req.options).then(function (d) {
|
|
15
35
|
return d.json();
|
|
16
36
|
}).then(cb).catch(console.error);
|
|
17
37
|
}
|
package/package.json
CHANGED