@raf-query/core 0.13.0 → 0.13.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/CHANGELOG.md +17 -11
- package/dist/infinite/infinite.d.mts +10 -0
- package/dist/infinite/infinite.mjs +1 -0
- package/dist/load.mjs +10 -1
- package/dist/options.d.mts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,32 +1,38 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.13.1](https://github.com/KATT/raf-query/compare/0.13.0...0.13.1) (2026-11-10)
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **core:** keepPages, for lists whose start stays out of the key ([#248](https://github.com/KATT/raf-query/issues/248)) ([164c88c](https://github.com/KATT/raf-query/commit/164c88c4509a34c9ec51f089c3b70c03ea13cac0))
|
|
8
|
+
|
|
3
9
|
## [0.13.0](https://github.com/KATT/raf-query/compare/0.12.0...0.13.0) (2026-11-10)
|
|
4
10
|
|
|
5
11
|
### ⚠ BREAKING CHANGES
|
|
6
12
|
|
|
7
|
-
|
|
13
|
+
- **core:** paging lives in core; useInfiniteQuery reads core's PageControls ([#246](https://github.com/KATT/raf-query/issues/246))
|
|
8
14
|
|
|
9
15
|
### Features
|
|
10
16
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
- **core:** paging lives in core; useInfiniteQuery reads core's PageControls ([#246](https://github.com/KATT/raf-query/issues/246)) ([f6b4ed2](https://github.com/KATT/raf-query/commit/f6b4ed210340b4b25bf3316ef08a9c8ceb9ed112))
|
|
18
|
+
- **core:** pass the client making the request to queryFn ([#241](https://github.com/KATT/raf-query/issues/241)) ([8c85746](https://github.com/KATT/raf-query/commit/8c85746c230bc3d8a426b32a130a260fa7e8ca62))
|
|
19
|
+
- **core:** replay cached entries to a new client subscriber ([#243](https://github.com/KATT/raf-query/issues/243)) ([1455eed](https://github.com/KATT/raf-query/commit/1455eed2612fe69f0f10bfec08cfd552ef90c786))
|
|
20
|
+
- **core:** ssr: false for queries only a browser can run ([#240](https://github.com/KATT/raf-query/issues/240)) ([077de62](https://github.com/KATT/raf-query/commit/077de6223a92b8bd8d35f7df043d1efe147ca403))
|
|
15
21
|
|
|
16
22
|
### Bug Fixes
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
24
|
+
- **core:** infer factories built inline by a generic maker in setData ([#244](https://github.com/KATT/raf-query/issues/244)) ([da87c07](https://github.com/KATT/raf-query/commit/da87c07a3463a919c154ac3ac5fba3d546b3231e))
|
|
25
|
+
- **core:** keep data written while a request ran ([#239](https://github.com/KATT/raf-query/issues/239)) ([4cb7cc0](https://github.com/KATT/raf-query/commit/4cb7cc0605a2d4637591eb365153c5e955eb41a8))
|
|
26
|
+
- **core:** start features once for providers that share a client ([#242](https://github.com/KATT/raf-query/issues/242)) ([d5968fb](https://github.com/KATT/raf-query/commit/d5968fb140429a1b2e7fb94662c266a52e877cc0))
|
|
21
27
|
|
|
22
28
|
### Documentation
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
- every example is the blog's posts, comments and authors ([#236](https://github.com/KATT/raf-query/issues/236)) ([2551e97](https://github.com/KATT/raf-query/commit/2551e9710aa7b149be333a1675dae31d9d1f5efd)), references [#230](https://github.com/KATT/raf-query/issues/230)
|
|
25
31
|
|
|
26
32
|
### Miscellaneous Chores
|
|
27
33
|
|
|
28
|
-
|
|
29
|
-
|
|
34
|
+
- **lint:** require a docs link on every public export ([#237](https://github.com/KATT/raf-query/issues/237)) ([b5c8133](https://github.com/KATT/raf-query/commit/b5c8133c129e0412e82cd2f24da6a2516b4a2012))
|
|
35
|
+
- unblock CI: [@see](https://github.com/see) links and the RSC test's build ([#245](https://github.com/KATT/raf-query/issues/245)) ([84927e4](https://github.com/KATT/raf-query/commit/84927e4a900f7608e1e17b022e28afadbe00e4ae)), references [#243](https://github.com/KATT/raf-query/issues/243) [#246](https://github.com/KATT/raf-query/issues/246) [#240](https://github.com/KATT/raf-query/issues/240) [#238](https://github.com/KATT/raf-query/issues/238)
|
|
30
36
|
|
|
31
37
|
## [0.12.0](https://github.com/KATT/raf-query/compare/0.11.1...0.12.0) (2026-11-08)
|
|
32
38
|
|
|
@@ -26,6 +26,16 @@ interface InfiniteOptions<TKey extends QueryKey, TPage, TParam, TData, TTypes ex
|
|
|
26
26
|
readonly getNextPageParam: PageParamFn<TPage, TParam>;
|
|
27
27
|
readonly getPreviousPageParam?: PageParamFn<TPage, TParam>;
|
|
28
28
|
readonly initialPageParam: TParam;
|
|
29
|
+
/**
|
|
30
|
+
* Whether the cached pages suit this input. Pages grow from the
|
|
31
|
+
* `initialPageParam` the entry was first loaded with; when part of the
|
|
32
|
+
* input picks only that start and stays out of the key (the item a list
|
|
33
|
+
* opens at), inputs that differ there share one entry. `load` asks
|
|
34
|
+
* before it uses the pages: on `false` it drops them, and the list loads
|
|
35
|
+
* again from this input's `initialPageParam`. Readers never drop pages.
|
|
36
|
+
* Default: keep them.
|
|
37
|
+
*/
|
|
38
|
+
readonly keepPages?: (data: InfiniteData<TPage, TParam>) => boolean;
|
|
29
39
|
/** Keep at most this many pages, dropping from the other end. */
|
|
30
40
|
readonly maxPages?: number;
|
|
31
41
|
readonly select?: (data: InfiniteData<TPage, TParam>) => TData;
|
package/dist/load.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { hashKey } from "./keys/keys.mjs";
|
|
2
2
|
import { optionsOf } from "./options.mjs";
|
|
3
|
-
import { entryOf, fetchEntry, isBrowserOnly, isInvalidated, isStale } from "./entry.mjs";
|
|
3
|
+
import { entryOf, fetchEntry, isBrowserOnly, isInvalidated, isStale, reset } from "./entry.mjs";
|
|
4
4
|
//#region src/load.ts
|
|
5
5
|
function loadEntry(kind, factory, args) {
|
|
6
6
|
return {
|
|
@@ -81,6 +81,14 @@ function startIfStale(entry) {
|
|
|
81
81
|
function isFresh(entry) {
|
|
82
82
|
return entry.client.isServer ? entry.state.hasData && !isInvalidated(entry) : !isStale(entry);
|
|
83
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Drop pages the entry's `keepPages` turns down for the input it was just
|
|
86
|
+
* loaded with, so they load again from that input's `initialPageParam`.
|
|
87
|
+
*/
|
|
88
|
+
function dropUnkeptPages(entry) {
|
|
89
|
+
const keep = entry.options?.["~keep"];
|
|
90
|
+
if (keep && entry.state.hasData && !keep(entry.state.data)) reset(entry);
|
|
91
|
+
}
|
|
84
92
|
function waitFresh(entry, pages) {
|
|
85
93
|
if (isFresh(entry)) return Promise.resolve({ ok: true });
|
|
86
94
|
return fetchEntry(entry, { pages });
|
|
@@ -115,6 +123,7 @@ async function load(client, entries) {
|
|
|
115
123
|
}]).map((loaded) => {
|
|
116
124
|
const item = loaded.item;
|
|
117
125
|
const cached = entryOf(client, item.factory, item.input);
|
|
126
|
+
dropUnkeptPages(cached);
|
|
118
127
|
let wait;
|
|
119
128
|
if (item.kind === "prefetch") startIfStale(cached);
|
|
120
129
|
else if (isBrowserOnly(cached) && !cached.state.hasData) wait = Promise.resolve({
|
package/dist/options.d.mts
CHANGED
|
@@ -55,6 +55,8 @@ export interface BaseOptions<TKey extends QueryKey, TTypes extends RootTypes = R
|
|
|
55
55
|
* @see https://raf-query.katt.dev/docs/api-reference#query-factories
|
|
56
56
|
*/
|
|
57
57
|
export interface QueryOptions<TKey extends QueryKey = QueryKey, TQueryFnData = unknown, TData = TQueryFnData, TTypes extends RootTypes = RootTypes> extends BaseOptions<TKey, TTypes> {
|
|
58
|
+
/** Set by `infiniteQueryOptions` from `keepPages`: whether `load` keeps the cached pages. */
|
|
59
|
+
readonly "~keep"?: (data: never) => boolean;
|
|
58
60
|
/** Phantom: the root the builder is bound to. Never set at runtime. */
|
|
59
61
|
readonly "~root"?: RootTag<TTypes>;
|
|
60
62
|
/** Set by `infiniteQueryOptions`: runs the request page by page. */
|