@zeno-lib/query 0.1.0 → 0.1.1
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/prefetched-queries.d.mts +1 -3
- package/dist/prefetched-queries.mjs +1 -2
- package/dist/query-caller.d.mts +1 -3
- package/dist/query-caller.mjs +2 -3
- package/dist/query-defaults.d.mts +1 -3
- package/dist/query-defaults.mjs +1 -2
- package/dist/query-hydration-boundary.d.mts +2 -4
- package/dist/query-hydration-boundary.mjs +2 -3
- package/dist/{query-map-Dbbk7vtk.d.mts → query-map-Catubr0X.d.mts} +0 -2
- package/dist/{query-map-XxynJ3jl.mjs → query-map-DD9UrwSx.mjs} +1 -2
- package/dist/query-route.d.mts +1 -3
- package/dist/query-route.mjs +3 -4
- package/dist/query-suspense-loading.d.mts +1 -3
- package/dist/query-suspense-loading.mjs +1 -2
- package/dist/query-suspense.d.mts +1 -3
- package/dist/query-suspense.mjs +1 -2
- package/package.json +9 -9
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { DehydratedState } from "@tanstack/react-query";
|
|
2
2
|
import { ReactNode } from "react";
|
|
3
|
-
//#region src/prefetched-queries.d.ts
|
|
4
3
|
/** Whether the nearest `PrefetchedQueries` above was handed at least one dehydrated query. */
|
|
5
4
|
export declare function useHasPrefetchedQueries(): boolean;
|
|
6
5
|
export type PrefetchedQueriesProps = {
|
|
@@ -12,5 +11,4 @@ export type PrefetchedQueriesProps = {
|
|
|
12
11
|
* render** (on the server pass as well as in the browser), so a `useSuspenseQuery` below it
|
|
13
12
|
* resolves synchronously in both and the two passes produce the same markup.
|
|
14
13
|
*/
|
|
15
|
-
export declare function PrefetchedQueries({ children, state }: PrefetchedQueriesProps): import("react").JSX.Element;
|
|
16
|
-
//#endregion
|
|
14
|
+
export declare function PrefetchedQueries({ children, state }: PrefetchedQueriesProps): import("react").JSX.Element;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { HydrationBoundary } from "@tanstack/react-query";
|
|
3
3
|
import { createContext, useContext } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/prefetched-queries.tsx
|
|
6
6
|
/**
|
|
7
7
|
* True inside a subtree that was handed a filled dehydrated cache.
|
|
8
8
|
*
|
|
@@ -33,5 +33,4 @@ function PrefetchedQueries({ children, state }) {
|
|
|
33
33
|
})
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
|
-
//#endregion
|
|
37
36
|
export { PrefetchedQueries, useHasPrefetchedQueries };
|
package/dist/query-caller.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { t as QueryMap } from "./query-map-
|
|
1
|
+
import { t as QueryMap } from "./query-map-Catubr0X.mjs";
|
|
2
2
|
import { QueryClient } from "@tanstack/react-query";
|
|
3
|
-
//#region src/query-caller.d.ts
|
|
4
3
|
/** The part of TanStack's `QueryFunctionContext` a call reads. */
|
|
5
4
|
export type QueryCallContext = {
|
|
6
5
|
/** Finds the queries a `QueryHydrationBoundary` bound for its server pass. */
|
|
@@ -44,5 +43,4 @@ export declare function createQueryCaller<TQueries extends QueryMap>({ path }: {
|
|
|
44
43
|
/** Where the route is mounted, without the trailing name segment. */
|
|
45
44
|
path: string;
|
|
46
45
|
}): QueryCaller<TQueries>;
|
|
47
|
-
//#endregion
|
|
48
46
|
export type { QueryMap };
|
package/dist/query-caller.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as getBoundQueries, r as findQuery, t as QUERY_CONTENT_TYPE } from "./query-map-
|
|
1
|
+
import { i as getBoundQueries, r as findQuery, t as QUERY_CONTENT_TYPE } from "./query-map-DD9UrwSx.mjs";
|
|
2
2
|
import { parse, stringify } from "devalue";
|
|
3
|
-
|
|
3
|
+
// src/query-caller.ts
|
|
4
4
|
/** A query the route answered with an error status. */
|
|
5
5
|
var QueryRequestError = class extends Error {
|
|
6
6
|
constructor(query, status) {
|
|
@@ -67,5 +67,4 @@ function reloadOnce() {
|
|
|
67
67
|
sessionStorage.setItem(RELOADED_AT_KEY, String(Date.now()));
|
|
68
68
|
window.location.reload();
|
|
69
69
|
}
|
|
70
|
-
//#endregion
|
|
71
70
|
export { QueryRequestError, createQueryCaller };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/query-defaults.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Timing presets to spread as the first property of a `queryOptions(…)` call, so freshness stays
|
|
4
3
|
* consistent across a codebase instead of every query inventing its own `staleTime`.
|
|
@@ -36,5 +35,4 @@ export declare const cachedQueryDefaults: {
|
|
|
36
35
|
/** Effectively immutable data: never stale. */
|
|
37
36
|
export declare const staticQueryDefaults: {
|
|
38
37
|
readonly staleTime: number;
|
|
39
|
-
};
|
|
40
|
-
//#endregion
|
|
38
|
+
};
|
package/dist/query-defaults.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/query-defaults.ts
|
|
2
2
|
/**
|
|
3
3
|
* Timing presets to spread as the first property of a `queryOptions(…)` call, so freshness stays
|
|
4
4
|
* consistent across a codebase instead of every query inventing its own `staleTime`.
|
|
@@ -33,5 +33,4 @@ const cachedQueryDefaults = {
|
|
|
33
33
|
};
|
|
34
34
|
/** Effectively immutable data: never stale. */
|
|
35
35
|
const staticQueryDefaults = { staleTime: Number.POSITIVE_INFINITY };
|
|
36
|
-
//#endregion
|
|
37
36
|
export { cachedQueryDefaults, liveBackgroundQueryDefaults, liveQueryDefaults, longLivedQueryDefaults, shortLivedQueryDefaults, staticQueryDefaults };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { t as QueryMap } from "./query-map-
|
|
1
|
+
import { t as QueryMap } from "./query-map-Catubr0X.mjs";
|
|
2
2
|
import { DehydrateOptions, QueryClient } from "@tanstack/react-query";
|
|
3
3
|
import { ReactNode } from "react";
|
|
4
|
-
//#region src/query-hydration-boundary.d.ts
|
|
5
4
|
export type QueryHydrationBoundaryProps = {
|
|
6
5
|
children: ReactNode;
|
|
7
6
|
/**
|
|
@@ -38,5 +37,4 @@ export type QueryHydrationBoundaryProps = {
|
|
|
38
37
|
* </QueryHydrationBoundary>
|
|
39
38
|
* ```
|
|
40
39
|
*/
|
|
41
|
-
export declare function QueryHydrationBoundary({ children, createQueryClient, dehydrateOptions, prefetch, queries }: QueryHydrationBoundaryProps): Promise<import("react").JSX.Element>;
|
|
42
|
-
//#endregion
|
|
40
|
+
export declare function QueryHydrationBoundary({ children, createQueryClient, dehydrateOptions, prefetch, queries }: QueryHydrationBoundaryProps): Promise<import("react").JSX.Element>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PrefetchedQueries } from "./prefetched-queries.mjs";
|
|
2
|
-
import { n as bindQueries } from "./query-map-
|
|
2
|
+
import { n as bindQueries } from "./query-map-DD9UrwSx.mjs";
|
|
3
3
|
import { QueryClient, dehydrate } from "@tanstack/react-query";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
|
|
5
|
+
// src/query-hydration-boundary.tsx
|
|
6
6
|
/**
|
|
7
7
|
* Async **server component**: runs `prefetch` against a fresh `QueryClient` and dehydrates the
|
|
8
8
|
* result into `PrefetchedQueries`, so the suspense queries below resolve from the cache in the
|
|
@@ -26,5 +26,4 @@ async function QueryHydrationBoundary({ children, createQueryClient = () => new
|
|
|
26
26
|
children
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
//#endregion
|
|
30
29
|
export { QueryHydrationBoundary };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { QueryClient } from "@tanstack/react-query";
|
|
2
|
-
//#region src/query-map.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* The server functions a query route serves, keyed by the name the browser
|
|
5
4
|
* calls them by. Each takes one argument and resolves to the query's data.
|
|
6
5
|
*/
|
|
7
6
|
type QueryMap = Record<string, (input: any) => Promise<unknown>>;
|
|
8
|
-
//#endregion
|
|
9
7
|
export { QueryMap as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/query-map.ts
|
|
2
2
|
/**
|
|
3
3
|
* The function `queries` serves as `name`. `Object.hasOwn`, so `constructor` or
|
|
4
4
|
* `__proto__` is not a query, and the type check, so a module namespace's
|
|
@@ -22,5 +22,4 @@ function bindQueries(client, queries) {
|
|
|
22
22
|
function getBoundQueries(client) {
|
|
23
23
|
return boundQueries.get(client);
|
|
24
24
|
}
|
|
25
|
-
//#endregion
|
|
26
25
|
export { getBoundQueries as i, bindQueries as n, findQuery as r, QUERY_CONTENT_TYPE as t };
|
package/dist/query-route.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { t as QueryMap } from "./query-map-
|
|
2
|
-
//#region src/query-route.d.ts
|
|
1
|
+
import { t as QueryMap } from "./query-map-Catubr0X.mjs";
|
|
3
2
|
/**
|
|
4
3
|
* Builds the `POST` handler of a route that serves `queries` to the browser,
|
|
5
4
|
* one request per call, so the reads of a screen run in parallel. Mount it on a
|
|
@@ -19,5 +18,4 @@ import { t as QueryMap } from "./query-map-Dbbk7vtk.mjs";
|
|
|
19
18
|
export declare function createQueryRoute(queries: QueryMap): {
|
|
20
19
|
POST: (request: Request) => Promise<Response>;
|
|
21
20
|
};
|
|
22
|
-
//#endregion
|
|
23
21
|
export type { QueryMap };
|
package/dist/query-route.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { r as findQuery, t as QUERY_CONTENT_TYPE } from "./query-map-
|
|
1
|
+
import { r as findQuery, t as QUERY_CONTENT_TYPE } from "./query-map-DD9UrwSx.mjs";
|
|
2
2
|
import { parse, stringify } from "devalue";
|
|
3
|
-
|
|
3
|
+
// src/query-route.ts
|
|
4
4
|
/** The largest body the route parses, the default Server Functions accept. */
|
|
5
5
|
const MAX_BODY_BYTES = 1048576;
|
|
6
|
-
const TRAILING_SLASH =
|
|
6
|
+
const TRAILING_SLASH = /\/$/u;
|
|
7
7
|
/**
|
|
8
8
|
* Builds the `POST` handler of a route that serves `queries` to the browser,
|
|
9
9
|
* one request per call, so the reads of a screen run in parallel. Mount it on a
|
|
@@ -50,5 +50,4 @@ function queryName(request) {
|
|
|
50
50
|
return "";
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { createQueryRoute };
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { ComponentPropsWithoutRef } from "react";
|
|
2
|
-
//#region src/query-suspense-loading.d.ts
|
|
3
2
|
export type QuerySuspenseLoadingProps = ComponentPropsWithoutRef<"div">;
|
|
4
3
|
/**
|
|
5
4
|
* Single layout root for Suspense loading UI: set `className` and children here so `aria-busy` /
|
|
6
5
|
* `aria-live` apply to the same element as your skeleton stack (no inner wrapper div). Accepts
|
|
7
6
|
* all `div` props; the `aria-busy` and `aria-live` defaults can be overridden.
|
|
8
7
|
*/
|
|
9
|
-
export declare function QuerySuspenseLoading({ "aria-busy": ariaBusy, "aria-live": ariaLive, children, ...props }: QuerySuspenseLoadingProps): import("react").JSX.Element;
|
|
10
|
-
//#endregion
|
|
8
|
+
export declare function QuerySuspenseLoading({ "aria-busy": ariaBusy, "aria-live": ariaLive, children, ...props }: QuerySuspenseLoadingProps): import("react").JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
|
|
2
|
+
// src/query-suspense-loading.tsx
|
|
3
3
|
/**
|
|
4
4
|
* Single layout root for Suspense loading UI: set `className` and children here so `aria-busy` /
|
|
5
5
|
* `aria-live` apply to the same element as your skeleton stack (no inner wrapper div). Accepts
|
|
@@ -13,5 +13,4 @@ function QuerySuspenseLoading({ "aria-busy": ariaBusy = true, "aria-live": ariaL
|
|
|
13
13
|
children
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
|
-
//#endregion
|
|
17
16
|
export { QuerySuspenseLoading };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
//#region src/query-suspense.d.ts
|
|
3
2
|
export type QuerySuspenseErrorFallbackProps = {
|
|
4
3
|
error: Error;
|
|
5
4
|
onRetry: () => void;
|
|
@@ -25,5 +24,4 @@ export type QuerySuspenseProps = {
|
|
|
25
24
|
* hydration gate: `fallback` is all it renders on the server and through hydration, unless a
|
|
26
25
|
* `PrefetchedQueries` (e.g. from `QueryHydrationBoundary`) above it was handed dehydrated queries.
|
|
27
26
|
*/
|
|
28
|
-
export declare function QuerySuspense({ children, errorFallback, fallback, debugState }: QuerySuspenseProps): import("react").JSX.Element;
|
|
29
|
-
//#endregion
|
|
27
|
+
export declare function QuerySuspense({ children, errorFallback, fallback, debugState }: QuerySuspenseProps): import("react").JSX.Element;
|
package/dist/query-suspense.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { useHasPrefetchedQueries } from "./prefetched-queries.mjs";
|
|
|
3
3
|
import { QueryErrorResetBoundary } from "@tanstack/react-query";
|
|
4
4
|
import { Component, Suspense, useSyncExternalStore } from "react";
|
|
5
5
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
6
|
-
|
|
6
|
+
// src/query-suspense.tsx
|
|
7
7
|
const debugStateEnabled = process.env.NODE_ENV !== "production";
|
|
8
8
|
const subscribeToNothing = () => () => {};
|
|
9
9
|
const useIsHydrated = () => useSyncExternalStore(subscribeToNothing, () => true, () => false);
|
|
@@ -59,5 +59,4 @@ function QuerySuspense({ children, errorFallback, fallback, debugState }) {
|
|
|
59
59
|
})
|
|
60
60
|
}) });
|
|
61
61
|
}
|
|
62
|
-
//#endregion
|
|
63
62
|
export { QuerySuspense };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeno-lib/query",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "https://github.com/zeno-lib/zeno.git",
|
|
6
6
|
"directory": "packages/query"
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"devalue": "^6.0.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@tanstack/react-query": "^5.
|
|
54
|
-
"@types/node": "26.6.
|
|
53
|
+
"@tanstack/react-query": "^5.105.0",
|
|
54
|
+
"@types/node": "26.6.5",
|
|
55
55
|
"@types/react": "19.3.0",
|
|
56
56
|
"@types/react-dom": "19.3.0",
|
|
57
|
-
"@zeno-lib/test": "^0.1.
|
|
57
|
+
"@zeno-lib/test": "^0.1.2",
|
|
58
58
|
"@zeno-lib/typescript": "^1.2.0",
|
|
59
59
|
"@zeno-lib/ui": "^0.0.1",
|
|
60
|
-
"react": "^19.3.
|
|
61
|
-
"react-dom": "^19.3.
|
|
62
|
-
"tsdown": "^0.23.
|
|
60
|
+
"react": "^19.3.1",
|
|
61
|
+
"react-dom": "^19.3.1",
|
|
62
|
+
"tsdown": "^0.23.1",
|
|
63
63
|
"typescript": "7.0.2",
|
|
64
|
-
"vite": "8.3.
|
|
65
|
-
"vitest": "5.0.
|
|
64
|
+
"vite": "8.3.5",
|
|
65
|
+
"vitest": "5.0.5"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
68
|
"@tanstack/react-query": ">=5.66.0",
|