@raf-query/core 0.5.2 → 0.5.4

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 CHANGED
@@ -1,8 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.5.4](https://github.com/KATT/raf-query/compare/0.5.3...0.5.4) (2026-10-14)
4
+
5
+ ### Bug Fixes
6
+
7
+ * **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))
8
+ * **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))
9
+
10
+ ## [0.5.3](https://github.com/KATT/raf-query/compare/0.5.2...0.5.3) (2026-10-14)
11
+
12
+ - 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))
13
+
3
14
  ## [0.5.2](https://github.com/KATT/raf-query/compare/0.5.1...0.5.2) (2026-10-14)
4
15
 
5
- * fix demo header on mobile, explain prefetch vs ensure more concisely ([#71](https://github.com/KATT/raf-query/issues/71)) ([3909b22](https://github.com/KATT/raf-query/commit/3909b224296921aa36424c2f942b28aa8f0b3e7e))
16
+ - fix demo header on mobile, explain prefetch vs ensure more concisely ([#71](https://github.com/KATT/raf-query/issues/71)) ([3909b22](https://github.com/KATT/raf-query/commit/3909b224296921aa36424c2f942b28aa8f0b3e7e))
6
17
 
7
18
  ## [0.5.1](https://github.com/KATT/raf-query/compare/0.5.0...0.5.1) (2026-10-14)
8
19
 
package/dist/cache.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.mjs";
2
2
  import { Platform } from "./platform.mjs";
3
3
  import { unsafeCast } from "./cast.mjs";
4
- import { listen } from "./listen.mjs";
5
4
  import { hashKey, matchesKey } from "./key.mjs";
5
+ import { listen } from "./listen.mjs";
6
6
  import { changes, emit, fetch, invalidate, isObserved, make as make$1, needsRefetch, onPlatformEvent, provide, remove, reset, revalidate, setData, setOptions, start } from "./entry.mjs";
7
7
  import { dehydrateEntries, dehydrateStream, hydrateEntries } from "./hydration.mjs";
8
8
  import { optionsFor } from "./options.mjs";
package/dist/entry.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { whenOnline } from "./platform.mjs";
2
2
  import { unsafeCast } from "./cast.mjs";
3
+ import { replaceEqualDeep } from "./share.mjs";
3
4
  import { fetchPages, isInfiniteData, nextPageParam, previousPageParam } from "./infinite.mjs";
4
5
  import { listen } from "./listen.mjs";
5
6
  import { scheduleNotify } from "./notify.mjs";
6
7
  import { fromQueryFn, requestServices, runRequest } from "./request.mjs";
7
8
  import { retrySchedule } from "./retry.mjs";
8
- import { replaceEqualDeep } from "./share.mjs";
9
9
  import { fulfilled, pending } from "./thenable.mjs";
10
10
  import { Cause, Data, Deferred, Effect, Exit, FiberMap, Pipeable, Predicate, Schedule, Scope } from "effect";
11
11
  //#region src/entry.ts
@@ -432,8 +432,8 @@ function requestEffect(entry, options, request) {
432
432
  return readSignal();
433
433
  }
434
434
  }));
435
- const current = isInfiniteData(entry.state.data) ? entry.state.data : void 0;
436
- return fetchPages(options, current, request, (pageParam, direction) => attempt(entry, (readSignal) => options.queryFn({
435
+ const pagesOf = () => isInfiniteData(entry.state.data) ? entry.state.data : void 0;
436
+ return fetchPages(options, pagesOf(), request, (pageParam, direction) => attempt(entry, (readSignal) => options.queryFn({
437
437
  direction,
438
438
  meta,
439
439
  pageParam,
@@ -441,7 +441,7 @@ function requestEffect(entry, options, request) {
441
441
  get signal() {
442
442
  return readSignal();
443
443
  }
444
- })));
444
+ })), pagesOf);
445
445
  }
446
446
  /**
447
447
  * One `queryFn` call, retried per the query's policy. Every failure counts.
package/dist/infinite.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { replaceEqualDeep } from "./share.mjs";
1
2
  import { Effect, Predicate } from "effect";
2
3
  //#region src/infinite.ts
3
4
  function isInfiniteData(data) {
@@ -27,16 +28,28 @@ function addPage(data, page, pageParam, direction, maxPages) {
27
28
  pages: pages.slice(0, maxPages)
28
29
  };
29
30
  }
31
+ function edgeParam(data, direction) {
32
+ return direction === "forward" ? data.pageParams.at(-1) : data.pageParams[0];
33
+ }
30
34
  /**
31
35
  * A paged query's request. With a `direction`, adds one page at that end of
32
- * `current`. Otherwise loads from the first page param again: as many pages
33
- * as `current` has, or `pages` if that's more, stopping at the last page.
36
+ * the entry's data, read again with `latest` once the page loads, so data
37
+ * written meanwhile (`setData`, a live subscription) stays. If that data no
38
+ * longer ends at the page param the request started from, the write
39
+ * replaced the list, and the page is dropped. Without a `direction`, loads
40
+ * from the first page param again: as many pages as `current` has, or
41
+ * `pages` if that's more, stopping at the last page.
34
42
  */
35
- const fetchPages = /*#__PURE__*/ Effect.fnUntraced(function* (options, current, request, fetchPage) {
36
- if (request.direction && current) {
37
- const pageParam = request.direction === "forward" ? nextPageParam(options, current) : previousPageParam(options, current);
43
+ const fetchPages = /*#__PURE__*/ Effect.fnUntraced(function* (options, current, request, fetchPage, latest) {
44
+ const direction = request.direction;
45
+ if (direction && current) {
46
+ const pageParam = direction === "forward" ? nextPageParam(options, current) : previousPageParam(options, current);
38
47
  if (pageParam == null) return current;
39
- return addPage(current, yield* fetchPage(pageParam, request.direction), pageParam, request.direction, options.maxPages);
48
+ const page = yield* fetchPage(pageParam, direction);
49
+ const now = latest() ?? current;
50
+ const startedFrom = edgeParam(current, direction);
51
+ if (replaceEqualDeep(startedFrom, edgeParam(now, direction)) !== startedFrom) return now;
52
+ return addPage(now, page, pageParam, direction, options.maxPages);
40
53
  }
41
54
  const count = Math.max(request.pages ?? 1, current?.pages.length ?? 0);
42
55
  let data = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raf-query/core",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Framework-agnostic core of raf-query, a render-as-you-fetch query library",
5
5
  "keywords": [
6
6
  "query",