@raf-query/react 0.5.3 → 0.6.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/CHANGELOG.md +19 -1
- package/dist/client.d.mts +7 -3
- package/dist/client.mjs +8 -15
- package/dist/tanstack-router-shared.d.mts +12 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.0](https://github.com/KATT/raf-query/compare/0.5.3...0.6.0) (2026-10-14)
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* **core:** LoadOptions takes no type argument, and QueryCache.LoadArgs is gone.
|
|
8
|
+
|
|
9
|
+
* **testing:** render in an async act so suspended trees resume ([#78](https://github.com/KATT/raf-query/issues/78)) ([c706b9d](https://github.com/KATT/raf-query/commit/c706b9db0d3ba3ea2d5b3fd1e21dc8e1fe315b82))
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **core:** ssr: false runs a query in the browser only ([#77](https://github.com/KATT/raf-query/issues/77)) ([22c47bd](https://github.com/KATT/raf-query/commit/22c47bdad9da2e9e84728017db3dde636c5d4113))
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **core:** infer generic factory makers passed inline to a verb ([#76](https://github.com/KATT/raf-query/issues/76)) ([f0616f7](https://github.com/KATT/raf-query/commit/f0616f7cd4288fb4a00e784f6d94dc3880d19a39))
|
|
18
|
+
* **core:** keep data written while a page loads ([#75](https://github.com/KATT/raf-query/issues/75)) ([d1b8ae5](https://github.com/KATT/raf-query/commit/d1b8ae560540cea345dad1008f8b4d8a467f48aa))
|
|
19
|
+
* **react:** let beforeLoad return handles in TanStack Start route context ([#74](https://github.com/KATT/raf-query/issues/74)) ([70c2121](https://github.com/KATT/raf-query/commit/70c2121a1926b4045049e6d9bfe56778262be42f))
|
|
20
|
+
|
|
3
21
|
## [0.5.3](https://github.com/KATT/raf-query/compare/0.5.2...0.5.3) (2026-10-14)
|
|
4
22
|
|
|
5
|
-
|
|
23
|
+
- compare prefetch, ensure and fetch in the starting queries demo ([#73](https://github.com/KATT/raf-query/issues/73)) ([b26a65e](https://github.com/KATT/raf-query/commit/b26a65e3e003f18308ce456646eba1d3f50c1357))
|
|
6
24
|
|
|
7
25
|
## [0.5.2](https://github.com/KATT/raf-query/compare/0.5.1...0.5.2) (2026-10-14)
|
|
8
26
|
|
package/dist/client.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataOf, DehydrateOptions, DehydratedState, EnsuredQueryHandle, HydrateOptions, InputArgs, InputOf, Query, QueryCache, QueryFactory, QueryHandle } from "@raf-query/core";
|
|
1
|
+
import { DataOf, DehydrateOptions, DehydratedState, EnsuredQueryHandle, HydrateOptions, InputArgs, InputOf, LoadOptions, PagedQueryFactory, Query, QueryCache, QueryFactory, QueryHandle } from "@raf-query/core";
|
|
2
2
|
import { Layer } from "effect";
|
|
3
3
|
//#region src/client.d.ts
|
|
4
4
|
export interface QueryClientConfig<TServices = never> extends QueryCache.Config {
|
|
@@ -40,13 +40,17 @@ export declare class QueryClient<TServices = never> {
|
|
|
40
40
|
* browser. The handle is marked `ensured`, so `useQuery` returns its data
|
|
41
41
|
* directly.
|
|
42
42
|
*/
|
|
43
|
-
ensure<TFactory extends QueryFactory<TServices>>(factory: TFactory, ...args:
|
|
43
|
+
ensure<TFactory extends QueryFactory<TServices>>(factory: TFactory, ...args: InputArgs<TFactory>): Promise<EnsuredQueryHandle<TFactory>>;
|
|
44
|
+
/** {@link ensure}, loading `options.pages` pages of a paged query. */
|
|
45
|
+
ensure<TFactory extends PagedQueryFactory<TServices>>(factory: TFactory, input: InputOf<TFactory>, options: LoadOptions): Promise<EnsuredQueryHandle<TFactory>>;
|
|
44
46
|
/**
|
|
45
47
|
* Start a query and resolve to its data. Waits on a cache miss and on
|
|
46
48
|
* stale data (on the server, only invalidated data), so the data is fresh.
|
|
47
49
|
* Rejects if that request fails.
|
|
48
50
|
*/
|
|
49
|
-
fetch<TFactory extends QueryFactory<TServices>>(factory: TFactory, ...args:
|
|
51
|
+
fetch<TFactory extends QueryFactory<TServices>>(factory: TFactory, ...args: InputArgs<TFactory>): Promise<DataOf<TFactory>>;
|
|
52
|
+
/** {@link fetch}, loading `options.pages` pages of a paged query. */
|
|
53
|
+
fetch<TFactory extends PagedQueryFactory<TServices>>(factory: TFactory, input: InputOf<TFactory>, options: LoadOptions): Promise<DataOf<TFactory>>;
|
|
50
54
|
/**
|
|
51
55
|
* Mark queries stale and refetch the ones being read. Resolves once those
|
|
52
56
|
* refetches settle, so an action stays pending until fresh data is on
|
package/dist/client.mjs
CHANGED
|
@@ -20,6 +20,10 @@ function runLoad(effect) {
|
|
|
20
20
|
throw Predicate.isTagged(error, "CancelledError") ? new DOMException("The query was cancelled", "AbortError") : error;
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
+
/** `ensure` / `fetch` arguments, forwarded to the cache's same verb. */
|
|
24
|
+
function loadArgs(input, options) {
|
|
25
|
+
return unsafeCast([input, options]);
|
|
26
|
+
}
|
|
23
27
|
/**
|
|
24
28
|
* The query cache, with Promise methods. Create one per request on the
|
|
25
29
|
* server and one per browser tab. `effect` is the same cache's Effect API.
|
|
@@ -60,22 +64,11 @@ var QueryClient = class {
|
|
|
60
64
|
prefetch(factory, ...args) {
|
|
61
65
|
return Effect.runSync(provided(this.effect.prefetch(factory, ...args)));
|
|
62
66
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
* fails. Stale cached data resolves immediately and revalidates in the
|
|
66
|
-
* browser. The handle is marked `ensured`, so `useQuery` returns its data
|
|
67
|
-
* directly.
|
|
68
|
-
*/
|
|
69
|
-
ensure(factory, ...args) {
|
|
70
|
-
return runLoad(provided(this.effect.ensure(factory, ...args)));
|
|
67
|
+
ensure(factory, input, options) {
|
|
68
|
+
return runLoad(provided(this.effect.ensure(factory, ...loadArgs(input, options))));
|
|
71
69
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* stale data (on the server, only invalidated data), so the data is fresh.
|
|
75
|
-
* Rejects if that request fails.
|
|
76
|
-
*/
|
|
77
|
-
fetch(factory, ...args) {
|
|
78
|
-
return runLoad(provided(this.effect.fetch(factory, ...args)));
|
|
70
|
+
fetch(factory, input, options) {
|
|
71
|
+
return runLoad(provided(this.effect.fetch(factory, ...loadArgs(input, options))));
|
|
79
72
|
}
|
|
80
73
|
/**
|
|
81
74
|
* Mark queries stale and refetch the ones being read. Resolves once those
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { QueryClient } from "./client.mjs";
|
|
2
|
-
import { DehydrateOptions, DehydratedState, HydrateOptions } from "@raf-query/core";
|
|
2
|
+
import { DehydrateOptions, DehydratedState, EnsuredQueryHandle, HydrateOptions, QueryHandle } from "@raf-query/core";
|
|
3
3
|
import { AnyRouter } from "@tanstack/react-router";
|
|
4
4
|
//#region src/tanstack-router-shared.d.ts
|
|
5
|
+
declare module "@tanstack/react-router" {
|
|
6
|
+
interface SerializableExtensions {
|
|
7
|
+
/**
|
|
8
|
+
* Handles are `{ key, input, ensured? }`, which the router's serializer
|
|
9
|
+
* sends as is. Its type check can't see that on its own: keys are
|
|
10
|
+
* `ReadonlyArray<unknown>`, and the handle type names its factory.
|
|
11
|
+
* So `beforeLoad` can put handles in route context.
|
|
12
|
+
*/
|
|
13
|
+
rafQueryHandle: EnsuredQueryHandle | QueryHandle;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
5
16
|
export interface RouterIntegrationOptions<TRouter extends AnyRouter> {
|
|
6
17
|
readonly dehydrateOptions?: DehydrateOptions;
|
|
7
18
|
/** Navigate when a `queryFn` throws `redirect()`. Default `true`. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@raf-query/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "React bindings for raf-query, a render-as-you-fetch query library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"query",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@raf-query/core": "0.
|
|
50
|
+
"@raf-query/core": "0.6.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"@tanstack/react-router": "^1.170.0",
|