@faasjs/react 7.0.4 → 8.0.0-beta.0
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/README.md +1 -1
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +24 -27
- package/dist/index.mjs +0 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -11,7 +11,6 @@ React plugin for FaasJS.
|
|
|
11
11
|
|
|
12
12
|
- Support [FaasJS Request Specifications](https://faasjs.com/guide/request-spec.html).
|
|
13
13
|
- Support global and per-request configurations.
|
|
14
|
-
- Support [React Server Actions](https://react.dev/reference/rsc/server-actions).
|
|
15
14
|
- Compatible with [why-did-you-render](https://github.com/welldone-software/why-did-you-render).
|
|
16
15
|
- Additional React functions:
|
|
17
16
|
- Utils:
|
|
@@ -80,6 +79,7 @@ npm install @faasjs/react react
|
|
|
80
79
|
|
|
81
80
|
- [ErrorChildrenProps](type-aliases/ErrorChildrenProps.md)
|
|
82
81
|
- [FaasAction](type-aliases/FaasAction.md)
|
|
82
|
+
- [FaasActionUnionType](type-aliases/FaasActionUnionType.md)
|
|
83
83
|
- [FaasData](type-aliases/FaasData.md)
|
|
84
84
|
- [FaasDataInjection](type-aliases/FaasDataInjection.md)
|
|
85
85
|
- [FaasDataWrapperProps](type-aliases/FaasDataWrapperProps.md)
|
package/dist/index.cjs
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Response, BaseUrl,
|
|
1
|
+
import { Response, BaseUrl, Options, ResponseError, FaasBrowserClient } from '@faasjs/browser';
|
|
2
2
|
export { Options, Response, ResponseError, ResponseHeaders } from '@faasjs/browser';
|
|
3
3
|
import { FaasActionUnionType, FaasAction, FaasParams, FaasData } from '@faasjs/types';
|
|
4
|
-
export { FaasAction, FaasData, FaasParams } from '@faasjs/types';
|
|
4
|
+
export { FaasAction, FaasActionUnionType, FaasData, FaasParams } from '@faasjs/types';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { JSX, ReactNode, ReactElement, Component, ComponentType, JSXElementConstructor, ComponentProps, Dispatch, SetStateAction, RefObject } from 'react';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -22,7 +22,7 @@ type FaasDataInjection<PathOrData extends FaasActionUnionType = any> = {
|
|
|
22
22
|
*
|
|
23
23
|
* **Note**: It will sets skip to false before loading data.
|
|
24
24
|
*/
|
|
25
|
-
reload(params?: Record<string, any>): Promise<
|
|
25
|
+
reload(params?: Record<string, any>): Promise<FaasData<PathOrData>>;
|
|
26
26
|
setData: React.Dispatch<React.SetStateAction<FaasData<PathOrData>>>;
|
|
27
27
|
setLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
28
28
|
setPromise: React.Dispatch<React.SetStateAction<Promise<Response<FaasData<PathOrData>>>>>;
|
|
@@ -52,9 +52,25 @@ declare const FaasDataWrapper: <PathOrData extends FaasActionUnionType = any>(pr
|
|
|
52
52
|
* const MyComponent = withFaasData(({ data }) => <div>{data.name}</div>, { action: 'test', params: { a: 1 } })
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
|
-
declare function withFaasData<PathOrData extends
|
|
55
|
+
declare function withFaasData<PathOrData extends FaasActionUnionType, TComponentProps extends Required<FaasDataInjection<PathOrData>> = Required<FaasDataInjection<PathOrData>>>(Component: React.FC<TComponentProps>, faasProps: FaasDataWrapperProps<PathOrData>): React.FC<Omit<TComponentProps, keyof FaasDataInjection<PathOrData>> & Record<string, any>>;
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Request faas server
|
|
59
|
+
*
|
|
60
|
+
* @param action {string} action name
|
|
61
|
+
* @param params {object} action params
|
|
62
|
+
* @returns {Promise<Response<any>>}
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* faas<{ title: string }>('post/get', { id: 1 }).then(res => {
|
|
67
|
+
* console.log(res.data.title)
|
|
68
|
+
* })
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
declare function faas<PathOrData extends FaasActionUnionType>(action: FaasAction<PathOrData>, params: FaasParams<PathOrData>, options?: Options): Promise<Response<FaasData<PathOrData>>>;
|
|
72
|
+
|
|
73
|
+
type useFaasOptions<PathOrData extends FaasActionUnionType> = {
|
|
58
74
|
params?: FaasParams<PathOrData>;
|
|
59
75
|
data?: FaasData<PathOrData>;
|
|
60
76
|
setData?: React.Dispatch<React.SetStateAction<FaasData<PathOrData>>>;
|
|
@@ -84,9 +100,6 @@ type useFaasOptions<PathOrData extends FaasAction> = {
|
|
|
84
100
|
* ```
|
|
85
101
|
*/
|
|
86
102
|
declare function useFaas<PathOrData extends FaasActionUnionType>(action: FaasAction<PathOrData>, defaultParams: FaasParams<PathOrData>, options?: useFaasOptions<PathOrData>): FaasDataInjection<PathOrData>;
|
|
87
|
-
declare namespace useFaas {
|
|
88
|
-
var whyDidYouRender: boolean;
|
|
89
|
-
}
|
|
90
103
|
|
|
91
104
|
type OnError = (action: string, params: Record<string, any>) => (res: ResponseError) => Promise<void>;
|
|
92
105
|
type FaasReactClientOptions = {
|
|
@@ -105,9 +118,9 @@ type FaasReactClientOptions = {
|
|
|
105
118
|
};
|
|
106
119
|
type FaasReactClientInstance = {
|
|
107
120
|
id: string;
|
|
108
|
-
faas:
|
|
109
|
-
useFaas:
|
|
110
|
-
FaasDataWrapper
|
|
121
|
+
faas: typeof faas;
|
|
122
|
+
useFaas: typeof useFaas;
|
|
123
|
+
FaasDataWrapper: typeof FaasDataWrapper;
|
|
111
124
|
onError?: OnError;
|
|
112
125
|
browserClient: FaasBrowserClient;
|
|
113
126
|
};
|
|
@@ -414,22 +427,6 @@ declare const FormContextProvider: <NewT extends FormContextProps<Record<string,
|
|
|
414
427
|
}) => react.ReactNode;
|
|
415
428
|
declare const useFormContext: <NewT extends FormContextProps<Record<string, any>, FormElementTypes, FormRules> = FormContextProps<Record<string, any>, FormElementTypes, FormRules>>() => Readonly<NewT>;
|
|
416
429
|
|
|
417
|
-
/**
|
|
418
|
-
* Request faas server
|
|
419
|
-
*
|
|
420
|
-
* @param action {string} action name
|
|
421
|
-
* @param params {object} action params
|
|
422
|
-
* @returns {Promise<Response<any>>}
|
|
423
|
-
*
|
|
424
|
-
* @example
|
|
425
|
-
* ```ts
|
|
426
|
-
* faas<{ title: string }>('post/get', { id: 1 }).then(res => {
|
|
427
|
-
* console.log(res.data.title)
|
|
428
|
-
* })
|
|
429
|
-
* ```
|
|
430
|
-
*/
|
|
431
|
-
declare function faas<PathOrData extends FaasActionUnionType>(action: FaasAction<PathOrData>, params: FaasParams<PathOrData>, options?: Options): Promise<Response<FaasData<PathOrData>>>;
|
|
432
|
-
|
|
433
430
|
type OptionalWrapperProps<TWrapper extends ComponentType<{
|
|
434
431
|
children: ReactNode;
|
|
435
432
|
}> = any> = {
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "v8.0.0-beta.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@faasjs/browser": ">=
|
|
33
|
+
"@faasjs/browser": ">=v8.0.0-beta.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@faasjs/browser": ">=
|
|
37
|
-
"@types/react": "
|
|
38
|
-
"react": "
|
|
36
|
+
"@faasjs/browser": ">=v8.0.0-beta.0",
|
|
37
|
+
"@types/react": "^19.0.0",
|
|
38
|
+
"react": "^19.0.0"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=24.0.0",
|