@umijs/renderer-react 4.6.66 → 4.6.68

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.
@@ -16,7 +16,7 @@ export declare const AppContext: React.Context<IAppContextType>;
16
16
  export declare function useAppData(): IAppContextType;
17
17
  export declare function useSelectedRoutes(): ISelectedRoutes[];
18
18
  export declare function useRouteProps<T extends Record<string, any> = any>(): T;
19
- declare type ServerLoaderFunc = (...args: any[]) => Promise<any> | any;
19
+ type ServerLoaderFunc = (...args: any[]) => Promise<any> | any;
20
20
  export declare function useServerLoaderData<T extends ServerLoaderFunc = any>(): {
21
21
  data: Awaited<ReturnType<T>> | undefined;
22
22
  };
@@ -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.d.ts CHANGED
@@ -3,11 +3,11 @@ import React from 'react';
3
3
  import ReactDOM from 'react-dom/client';
4
4
  import { IRouteComponents, IRoutesById } from './types';
5
5
  export declare function __getRoot(): ReactDOM.Root | null;
6
- export declare function Routes(): any;
6
+ export declare function Routes(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
7
7
  /**
8
8
  * umi 渲染需要的配置,在node端调用的哦
9
9
  */
10
- export declare type RenderClientOpts = {
10
+ export type RenderClientOpts = {
11
11
  /**
12
12
  * 配置 webpack 的 publicPath。
13
13
  * @doc https://umijs.org/docs/api/config#publicpath
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
@@ -1,5 +1,10 @@
1
- export declare function fetchServerLoader({ id, basename, cb, }: {
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;
@@ -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 url = "".concat(withEndSlash(window.umiServerLoaderPath || basename), "__serverLoader?").concat(query);
12
- fetch(url, {
13
- credentials: 'include'
14
- }).then(function (d) {
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/dist/link.d.ts CHANGED
@@ -1,2 +1,6 @@
1
- import React from 'react';
2
- export declare const LinkWithPrefetch: React.ForwardRefExoticComponent<Omit<any, "ref"> & React.RefAttributes<unknown>>;
1
+ import React, { PropsWithChildren } from 'react';
2
+ import { LinkProps } from 'react-router-dom';
3
+ export declare const LinkWithPrefetch: React.ForwardRefExoticComponent<Omit<PropsWithChildren<{
4
+ prefetch?: boolean | 'intent' | 'render' | 'viewport' | 'none';
5
+ prefetchTimeout?: number;
6
+ } & LinkProps & React.RefAttributes<HTMLAnchorElement>>, "ref"> & React.RefAttributes<unknown>>;
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { IhtmlPageOpts, ServerLoader } from '@umijs/server/dist/types';
1
+ import type { IhtmlPageOpts, ServerLoader } from '@umijs/server';
2
2
  import type { RouteMatch, RouteObject } from 'react-router-dom';
3
3
  declare global {
4
4
  interface Window {
@@ -7,10 +7,10 @@ declare global {
7
7
  __UMI_BUILD_ClIENT_CSS__: any;
8
8
  }
9
9
  }
10
- declare type ClientLoaderFunctionArgs = {
10
+ type ClientLoaderFunctionArgs = {
11
11
  serverLoader: ServerLoader;
12
12
  };
13
- export declare type ClientLoader = ((args: ClientLoaderFunctionArgs) => Promise<any>) & {
13
+ export type ClientLoader = ((args: ClientLoaderFunctionArgs) => Promise<any>) & {
14
14
  hydrate?: boolean;
15
15
  };
16
16
  export interface IRouteSSRProps {
@@ -73,7 +73,7 @@ export interface IHtmlProps extends IHtmlHydrateOptions {
73
73
  };
74
74
  manifest?: any;
75
75
  }
76
- export declare type IScript = Partial<{
76
+ export type IScript = Partial<{
77
77
  async: boolean;
78
78
  charset: string;
79
79
  content: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/renderer-react",
3
- "version": "4.6.66",
3
+ "version": "4.6.68",
4
4
  "description": "@umijs/renderer-react",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/renderer-react#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",
@@ -20,7 +20,8 @@
20
20
  "@loadable/component": "5.15.2",
21
21
  "history": "5.3.0",
22
22
  "react-helmet-async": "1.3.0",
23
- "react-router-dom": "6.3.0"
23
+ "react-router-dom": "6.3.0",
24
+ "@umijs/server": "4.6.68"
24
25
  },
25
26
  "devDependencies": {
26
27
  "react": "18.3.1",