@emeryld/rrroutes-client 2.7.1 → 2.7.3
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/index.cjs +33 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +33 -9
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.shared.d.ts +5 -0
- package/dist/routesV3.client.types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -300,6 +300,16 @@ function buildUrl(leaf, baseUrl, params, query) {
|
|
|
300
300
|
const url = `${baseUrl ?? ""}${path}${toSearchString(normalizedQuery)}`;
|
|
301
301
|
return { url, normalizedQuery, normalizedParams };
|
|
302
302
|
}
|
|
303
|
+
function areEndpointArgsComplete(leaf, args) {
|
|
304
|
+
const params = args?.params;
|
|
305
|
+
const query = args?.query;
|
|
306
|
+
try {
|
|
307
|
+
buildUrl(leaf, "", params, query);
|
|
308
|
+
return true;
|
|
309
|
+
} catch {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
303
313
|
function isBlobLike(value) {
|
|
304
314
|
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
305
315
|
}
|
|
@@ -643,6 +653,7 @@ function buildGetLeaf(leaf, rqOpts, env) {
|
|
|
643
653
|
const useEndpoint = (...useArgs) => {
|
|
644
654
|
const args = expectsArgs ? useArgs[0] : void 0;
|
|
645
655
|
const useEndpointOptions = expectsArgs ? useArgs[1] : useArgs[0];
|
|
656
|
+
const hasCompleteArgs = !expectsArgs || areEndpointArgsComplete(leaf, args);
|
|
646
657
|
const tuple = toArgsTuple(args);
|
|
647
658
|
const queryKeys = getQueryKeys(...tuple);
|
|
648
659
|
emit({
|
|
@@ -657,6 +668,8 @@ function buildGetLeaf(leaf, rqOpts, env) {
|
|
|
657
668
|
...buildQueryOptions,
|
|
658
669
|
...runtimeQueryOptions
|
|
659
670
|
};
|
|
671
|
+
const mergedEnabled = mergedQueryOptions.enabled;
|
|
672
|
+
const guardedEnabled = hasCompleteArgs && (typeof mergedEnabled === "undefined" ? true : mergedEnabled);
|
|
660
673
|
const listenersRef = (0, import_react2.useRef)(/* @__PURE__ */ new Set());
|
|
661
674
|
const notifyOnReceive = (0, import_react2.useCallback)((data) => {
|
|
662
675
|
buildOnReceive2?.(data);
|
|
@@ -675,11 +688,17 @@ function buildGetLeaf(leaf, rqOpts, env) {
|
|
|
675
688
|
const queryResult = (0, import_react_query2.useQuery)(
|
|
676
689
|
{
|
|
677
690
|
...mergedQueryOptions,
|
|
691
|
+
enabled: guardedEnabled,
|
|
678
692
|
queryKey: getQueryKeys(...tuple),
|
|
679
693
|
placeholderData: mergedQueryOptions.placeholderData ?? import_react_query2.keepPreviousData,
|
|
680
|
-
queryFn: () =>
|
|
681
|
-
|
|
682
|
-
|
|
694
|
+
queryFn: () => {
|
|
695
|
+
if (!hasCompleteArgs) {
|
|
696
|
+
return Promise.resolve(void 0);
|
|
697
|
+
}
|
|
698
|
+
return fetchEndpoint(tuple, {
|
|
699
|
+
onReceive: notifyOnReceive
|
|
700
|
+
});
|
|
701
|
+
}
|
|
683
702
|
},
|
|
684
703
|
queryClient
|
|
685
704
|
);
|
|
@@ -923,6 +942,7 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
|
|
|
923
942
|
const useEndpoint = (...useArgs) => {
|
|
924
943
|
const args = expectsArgs ? useArgs[0] : void 0;
|
|
925
944
|
const useEndpointOptions = expectsArgs ? useArgs[1] : useArgs[0];
|
|
945
|
+
const hasCompleteArgs = !expectsArgs || areEndpointArgsComplete(leaf, args);
|
|
926
946
|
const tuple = toArgsTuple(args);
|
|
927
947
|
const queryKeys = getQueryKeys(...tuple);
|
|
928
948
|
emit({
|
|
@@ -940,6 +960,8 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
|
|
|
940
960
|
...buildInfiniteQueryOptions,
|
|
941
961
|
...runtimeInfiniteQueryOptions
|
|
942
962
|
};
|
|
963
|
+
const mergedEnabled = mergedInfiniteQueryOptions.enabled;
|
|
964
|
+
const guardedEnabled = hasCompleteArgs && (typeof mergedEnabled === "undefined" ? true : mergedEnabled);
|
|
943
965
|
const listenersRef = (0, import_react3.useRef)(/* @__PURE__ */ new Set());
|
|
944
966
|
const notifyOnReceive = (0, import_react3.useCallback)((data) => {
|
|
945
967
|
buildOnReceive2?.(data);
|
|
@@ -955,20 +977,22 @@ function buildInfiniteGetLeaf(leaf, rqOpts, env) {
|
|
|
955
977
|
},
|
|
956
978
|
[]
|
|
957
979
|
);
|
|
958
|
-
const { normalizedQuery, normalizedParams } = buildUrl(
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
query
|
|
963
|
-
);
|
|
980
|
+
const { normalizedQuery, normalizedParams } = hasCompleteArgs ? buildUrl({ ...leaf, cfg: leafCfg }, baseUrl, params, query) : {
|
|
981
|
+
normalizedQuery: query ?? {},
|
|
982
|
+
normalizedParams: params ?? {}
|
|
983
|
+
};
|
|
964
984
|
const queryResult = (0, import_react_query3.useInfiniteQuery)(
|
|
965
985
|
{
|
|
966
986
|
...mergedInfiniteQueryOptions,
|
|
987
|
+
enabled: guardedEnabled,
|
|
967
988
|
placeholderData: mergedInfiniteQueryOptions.placeholderData ?? import_react_query3.keepPreviousData,
|
|
968
989
|
initialPageParam: feedInitialPageParam,
|
|
969
990
|
getNextPageParam: (lastPage) => cursorFromPage(lastPage),
|
|
970
991
|
queryKey: queryKeys,
|
|
971
992
|
queryFn: ({ pageParam }) => {
|
|
993
|
+
if (!hasCompleteArgs) {
|
|
994
|
+
return Promise.resolve(void 0);
|
|
995
|
+
}
|
|
972
996
|
if (!effectiveSplitPageSize) {
|
|
973
997
|
const pageQuery = {
|
|
974
998
|
...normalizedQuery,
|