soda-tanstack-query 0.0.8 → 0.0.10
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.
|
@@ -24,13 +24,18 @@ var __webpack_require__ = {};
|
|
|
24
24
|
var __webpack_exports__ = {};
|
|
25
25
|
__webpack_require__.r(__webpack_exports__);
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
setUseQuery: ()=>setUseQuery,
|
|
27
28
|
createUseQuery: ()=>createUseQuery
|
|
28
29
|
});
|
|
29
30
|
const react_query_namespaceObject = require("@tanstack/react-query");
|
|
31
|
+
let __useQuery = react_query_namespaceObject.useQuery;
|
|
32
|
+
function setUseQuery(useQuery) {
|
|
33
|
+
__useQuery = useQuery;
|
|
34
|
+
}
|
|
30
35
|
function createUseQuery(params, client) {
|
|
31
36
|
const { queryFn, queryKey, ...rest } = params;
|
|
32
37
|
const useQuery = function(params2, options, client2 = client) {
|
|
33
|
-
return (
|
|
38
|
+
return __useQuery({
|
|
34
39
|
queryKey: [
|
|
35
40
|
queryKey,
|
|
36
41
|
params2
|
|
@@ -51,8 +56,10 @@ function createUseQuery(params, client) {
|
|
|
51
56
|
return useQuery;
|
|
52
57
|
}
|
|
53
58
|
exports.createUseQuery = __webpack_exports__.createUseQuery;
|
|
59
|
+
exports.setUseQuery = __webpack_exports__.setUseQuery;
|
|
54
60
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
55
|
-
"createUseQuery"
|
|
61
|
+
"createUseQuery",
|
|
62
|
+
"setUseQuery"
|
|
56
63
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
57
64
|
Object.defineProperty(exports, '__esModule', {
|
|
58
65
|
value: true
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, UndefinedInitialDataOptions, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
|
1
|
+
import { useQuery as _useQuery, DefinedInitialDataOptions, DefinedUseQueryResult, QueryClient, UndefinedInitialDataOptions, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
|
|
2
2
|
import { Assign, IsParamRequired, StrictPartial } from "soda-type";
|
|
3
3
|
/** 参数必须的 useQuery */
|
|
4
4
|
interface _UseQueryWithParams<TFn extends (params: any) => any, TInitSelectData = Awaited<ReturnType<TFn>>, TParams = Parameters<TFn>[0], TResponse = Awaited<ReturnType<TFn>>> {
|
|
@@ -83,6 +83,7 @@ interface _CreateUseQueryParams<TFn extends (param: any) => any, TInitSelectData
|
|
|
83
83
|
}
|
|
84
84
|
export interface CreateUseQueryParams<TFn extends (param: any) => any, TInitSelectData = Awaited<ReturnType<TFn>>> extends _CreateUseQueryParams<TFn, TInitSelectData> {
|
|
85
85
|
}
|
|
86
|
+
export declare function setUseQuery(useQuery: typeof _useQuery): void;
|
|
86
87
|
export declare function createUseQuery<TFn extends (param: any) => any, TInitSelectData = Awaited<ReturnType<TFn>>>(params: CreateUseQueryDefinedInitialDataParams<TFn, TInitSelectData>, client?: QueryClient): UseQueryDefinedInitialData<TFn, TInitSelectData>;
|
|
87
88
|
export declare function createUseQuery<TFn extends (param: any) => any, TInitSelectData = Awaited<ReturnType<TFn>>>(pararm: CreateUseQueryUndefinedInitialDataParams<TFn, TInitSelectData>, client?: QueryClient): UseQueryUndefinedInitialData<TFn, TInitSelectData>;
|
|
88
89
|
export declare function createUseQuery<TFn extends (param: any) => any, TInitSelectData = Awaited<ReturnType<TFn>>>(pararm: CreateUseQueryParams<TFn, TInitSelectData>, client?: QueryClient): UseQuery<TFn, TInitSelectData>;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { useQuery as react_query_useQuery } from "@tanstack/react-query";
|
|
2
|
+
let __useQuery = react_query_useQuery;
|
|
3
|
+
function setUseQuery(useQuery) {
|
|
4
|
+
__useQuery = useQuery;
|
|
5
|
+
}
|
|
2
6
|
function createUseQuery(params, client) {
|
|
3
7
|
const { queryFn, queryKey, ...rest } = params;
|
|
4
8
|
const useQuery = function(params2, options, client2 = client) {
|
|
5
|
-
return
|
|
9
|
+
return __useQuery({
|
|
6
10
|
queryKey: [
|
|
7
11
|
queryKey,
|
|
8
12
|
params2
|
|
@@ -22,4 +26,4 @@ function createUseQuery(params, client) {
|
|
|
22
26
|
};
|
|
23
27
|
return useQuery;
|
|
24
28
|
}
|
|
25
|
-
export { createUseQuery };
|
|
29
|
+
export { createUseQuery, setUseQuery };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "soda-tanstack-query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -34,14 +34,12 @@
|
|
|
34
34
|
"url": "git+https://github.com/1adybug/deepsea.git"
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://github.com/1adybug/deepsea/tree/main/packages/soda-tanstack-query",
|
|
37
|
-
"dependencies": {
|
|
38
|
-
"@tanstack/react-query": "^5.90.19"
|
|
39
|
-
},
|
|
40
37
|
"devDependencies": {
|
|
41
|
-
"
|
|
42
|
-
"
|
|
38
|
+
"soda-type": "",
|
|
39
|
+
"typescript": ">=5.8.3"
|
|
43
40
|
},
|
|
44
41
|
"peerDependencies": {
|
|
42
|
+
"@tanstack/react-query": "^5.90.21",
|
|
45
43
|
"@types/react": ">=19.2.7",
|
|
46
44
|
"react": ">=19.2.3"
|
|
47
45
|
},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
|
+
useQuery as _useQuery,
|
|
2
3
|
DefinedInitialDataOptions,
|
|
3
4
|
DefinedUseQueryResult,
|
|
4
5
|
QueryClient,
|
|
5
6
|
UndefinedInitialDataOptions,
|
|
6
|
-
useQuery as _useQuery,
|
|
7
7
|
UseQueryOptions,
|
|
8
8
|
UseQueryResult,
|
|
9
9
|
} from "@tanstack/react-query"
|
|
@@ -261,6 +261,12 @@ export interface CreateUseQueryParams<TFn extends (param: any) => any, TInitSele
|
|
|
261
261
|
TInitSelectData
|
|
262
262
|
> {}
|
|
263
263
|
|
|
264
|
+
let __useQuery = _useQuery
|
|
265
|
+
|
|
266
|
+
export function setUseQuery(useQuery: typeof _useQuery) {
|
|
267
|
+
__useQuery = useQuery
|
|
268
|
+
}
|
|
269
|
+
|
|
264
270
|
// 根据是否传递初始化参数,选择不同的 createUseQuery,目前存在一个问题,UndefinedInitialDataOptions 和 UseQueryOptions 是完全一致的,所以匹配不到第三种可能,但这是 @tanstack/react-query 的问题
|
|
265
271
|
export function createUseQuery<TFn extends (param: any) => any, TInitSelectData = Awaited<ReturnType<TFn>>>(
|
|
266
272
|
params: CreateUseQueryDefinedInitialDataParams<TFn, TInitSelectData>,
|
|
@@ -282,7 +288,7 @@ export function createUseQuery<TFn extends (param: any) => any, TInitSelectData
|
|
|
282
288
|
const { queryFn, queryKey, ...rest } = params
|
|
283
289
|
|
|
284
290
|
const useQuery: any = function useRequest(params2: any, options?: any, client2: QueryClient | undefined = client) {
|
|
285
|
-
return
|
|
291
|
+
return __useQuery(
|
|
286
292
|
{
|
|
287
293
|
queryKey: [queryKey, params2],
|
|
288
294
|
queryFn: () => queryFn(params2),
|