@raf-query/core 0.13.0 → 0.13.2
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 +23 -11
- package/dist/infinite/infinite.d.mts +10 -0
- package/dist/infinite/infinite.mjs +1 -0
- package/dist/load.mjs +14 -4
- package/dist/options.d.mts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,32 +1,44 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.13.2](https://github.com/KATT/raf-query/compare/0.13.1...0.13.2) (2026-11-10)
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **core:** a prefetch never drops pages keepPages turns down ([#249](https://github.com/KATT/raf-query/issues/249)) ([3c66020](https://github.com/KATT/raf-query/commit/3c66020ee7562c6e2592017a1b11af94bc89e340))
|
|
8
|
+
|
|
9
|
+
## [0.13.1](https://github.com/KATT/raf-query/compare/0.13.0...0.13.1) (2026-11-10)
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
- **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))
|
|
14
|
+
|
|
3
15
|
## [0.13.0](https://github.com/KATT/raf-query/compare/0.12.0...0.13.0) (2026-11-10)
|
|
4
16
|
|
|
5
17
|
### ⚠ BREAKING CHANGES
|
|
6
18
|
|
|
7
|
-
|
|
19
|
+
- **core:** paging lives in core; useInfiniteQuery reads core's PageControls ([#246](https://github.com/KATT/raf-query/issues/246))
|
|
8
20
|
|
|
9
21
|
### Features
|
|
10
22
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
- **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))
|
|
24
|
+
- **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))
|
|
25
|
+
- **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))
|
|
26
|
+
- **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
27
|
|
|
16
28
|
### Bug Fixes
|
|
17
29
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
- **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))
|
|
31
|
+
- **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))
|
|
32
|
+
- **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
33
|
|
|
22
34
|
### Documentation
|
|
23
35
|
|
|
24
|
-
|
|
36
|
+
- 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
37
|
|
|
26
38
|
### Miscellaneous Chores
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
40
|
+
- **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))
|
|
41
|
+
- 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
42
|
|
|
31
43
|
## [0.12.0](https://github.com/KATT/raf-query/compare/0.11.1...0.12.0) (2026-11-08)
|
|
32
44
|
|
|
@@ -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,11 @@ function startIfStale(entry) {
|
|
|
81
81
|
function isFresh(entry) {
|
|
82
82
|
return entry.client.isServer ? entry.state.hasData && !isInvalidated(entry) : !isStale(entry);
|
|
83
83
|
}
|
|
84
|
+
/** Whether the entry's `keepPages` takes its cached pages for the input it was just loaded with. */
|
|
85
|
+
function keepsPages(entry) {
|
|
86
|
+
const keep = entry.options?.["~keep"];
|
|
87
|
+
return !keep || !entry.state.hasData || keep(entry.state.data);
|
|
88
|
+
}
|
|
84
89
|
function waitFresh(entry, pages) {
|
|
85
90
|
if (isFresh(entry)) return Promise.resolve({ ok: true });
|
|
86
91
|
return fetchEntry(entry, { pages });
|
|
@@ -115,13 +120,18 @@ async function load(client, entries) {
|
|
|
115
120
|
}]).map((loaded) => {
|
|
116
121
|
const item = loaded.item;
|
|
117
122
|
const cached = entryOf(client, item.factory, item.input);
|
|
123
|
+
const kept = keepsPages(cached);
|
|
118
124
|
let wait;
|
|
119
|
-
if (item.kind === "prefetch")
|
|
120
|
-
|
|
125
|
+
if (item.kind === "prefetch") {
|
|
126
|
+
if (kept) startIfStale(cached);
|
|
127
|
+
} else if (isBrowserOnly(cached) && !cached.state.hasData) wait = Promise.resolve({
|
|
121
128
|
error: /* @__PURE__ */ new Error(`raf-query: ${cached.hash} has \`ssr: false\`, so the server can't wait for it. Load it with prefetch() instead of ${item.kind}().`),
|
|
122
129
|
ok: false
|
|
123
130
|
});
|
|
124
|
-
else
|
|
131
|
+
else {
|
|
132
|
+
if (!kept) reset(cached);
|
|
133
|
+
wait = (item.kind === "revalidate" ? waitFresh : waitAny)(cached, item.pages);
|
|
134
|
+
}
|
|
125
135
|
return {
|
|
126
136
|
entry: cached,
|
|
127
137
|
item,
|
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. */
|