@tanstack/svelte-query 6.3.1 → 6.3.3

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.
Files changed (66) hide show
  1. package/dist/containers.svelte.d.ts +16 -0
  2. package/dist/containers.svelte.d.ts.map +1 -1
  3. package/dist/containers.svelte.js +26 -0
  4. package/dist/context.d.ts +10 -6
  5. package/dist/context.d.ts.map +1 -1
  6. package/dist/context.js +10 -6
  7. package/dist/createBaseQuery.svelte.d.ts +1 -0
  8. package/dist/createBaseQuery.svelte.d.ts.map +1 -1
  9. package/dist/createBaseQuery.svelte.js +6 -0
  10. package/dist/createInfiniteQuery.d.ts +6 -11
  11. package/dist/createInfiniteQuery.d.ts.map +1 -1
  12. package/dist/createMutation.svelte.d.ts +2 -8
  13. package/dist/createMutation.svelte.d.ts.map +1 -1
  14. package/dist/createMutation.svelte.js +2 -8
  15. package/dist/createQueries.svelte.d.ts +0 -3
  16. package/dist/createQueries.svelte.d.ts.map +1 -1
  17. package/dist/createQueries.svelte.js +4 -3
  18. package/dist/createQuery.d.ts +6 -12
  19. package/dist/createQuery.d.ts.map +1 -1
  20. package/dist/infiniteQueryOptions.d.ts +10 -6
  21. package/dist/infiniteQueryOptions.d.ts.map +1 -1
  22. package/dist/mutationOptions.d.ts +2 -6
  23. package/dist/mutationOptions.d.ts.map +1 -1
  24. package/dist/queryOptions.d.ts +10 -6
  25. package/dist/queryOptions.d.ts.map +1 -1
  26. package/dist/types.d.ts +37 -0
  27. package/dist/types.d.ts.map +1 -1
  28. package/dist/useHydrate.d.ts +0 -2
  29. package/dist/useHydrate.d.ts.map +1 -1
  30. package/dist/useHydrate.js +0 -2
  31. package/dist/useIsFetching.svelte.d.ts +0 -3
  32. package/dist/useIsFetching.svelte.d.ts.map +1 -1
  33. package/dist/useIsFetching.svelte.js +0 -3
  34. package/dist/useIsMutating.svelte.d.ts +0 -2
  35. package/dist/useIsMutating.svelte.d.ts.map +1 -1
  36. package/dist/useIsMutating.svelte.js +0 -2
  37. package/dist/useIsRestoring.d.ts +0 -1
  38. package/dist/useIsRestoring.d.ts.map +1 -1
  39. package/dist/useIsRestoring.js +0 -1
  40. package/dist/useMutationState.svelte.d.ts +0 -4
  41. package/dist/useMutationState.svelte.d.ts.map +1 -1
  42. package/dist/useMutationState.svelte.js +7 -4
  43. package/dist/useQueryClient.d.ts +2 -2
  44. package/dist/useQueryClient.js +2 -2
  45. package/dist/utils.svelte.d.ts +8 -0
  46. package/dist/utils.svelte.d.ts.map +1 -1
  47. package/dist/utils.svelte.js +13 -0
  48. package/package.json +4 -4
  49. package/src/containers.svelte.ts +35 -1
  50. package/src/context.ts +10 -6
  51. package/src/createBaseQuery.svelte.ts +6 -0
  52. package/src/createInfiniteQuery.ts +6 -11
  53. package/src/createMutation.svelte.ts +2 -8
  54. package/src/createQueries.svelte.ts +4 -3
  55. package/src/createQuery.ts +6 -12
  56. package/src/infiniteQueryOptions.ts +10 -6
  57. package/src/mutationOptions.ts +2 -6
  58. package/src/queryOptions.ts +12 -7
  59. package/src/types.ts +37 -0
  60. package/src/useHydrate.ts +0 -2
  61. package/src/useIsFetching.svelte.ts +0 -3
  62. package/src/useIsMutating.svelte.ts +0 -2
  63. package/src/useIsRestoring.ts +0 -1
  64. package/src/useMutationState.svelte.ts +7 -4
  65. package/src/useQueryClient.ts +2 -2
  66. package/src/utils.svelte.ts +13 -0
@@ -1 +1 @@
1
- {"version":3,"file":"infiniteQueryOptions.d.ts","sourceRoot":"","sources":["../src/infiniteQueryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAE5D,MAAM,MAAM,mCAAmC,CAC7C,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,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AU,CACX,GACA,mCAAmC,CACpC,YAAY,EACZ,MAAM,EACN,KAAK,EACL,SAAS,EACT,UAAU,CACX,GACC,mBAAmB,CAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,CAAA"}
@@ -4,11 +4,9 @@ import type { CreateMutationOptions } from './types.js';
4
4
  * You can generally pass everything to `mutationOptions` that you can also pass to `createMutation`. This
5
5
  * overload requires `mutationKey`, so the resulting options can be looked up elsewhere (e.g. with
6
6
  * `useMutationState`).
7
- *
8
- * @see {@link createMutation} to run a mutation with these options.
9
7
  * @param options - The options to use — everything you can pass to `createMutation`, with `mutationKey` set.
10
8
  * @returns The same options object.
11
- *
9
+ * @see {@link createMutation} to run a mutation with these options.
12
10
  * @example
13
11
  * Looking the mutation up elsewhere via its `mutationKey`, e.g. for a global "saving…" indicator:
14
12
  * ```svelte
@@ -33,11 +31,9 @@ import type { CreateMutationOptions } from './types.js';
33
31
  export declare function mutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown>(options: WithRequired<CreateMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>): WithRequired<CreateMutationOptions<TData, TError, TVariables, TOnMutateResult>, 'mutationKey'>;
34
32
  /**
35
33
  * You can generally pass everything to `mutationOptions` that you can also pass to `createMutation`.
36
- *
37
- * @see {@link createMutation} to run a mutation with these options.
38
34
  * @param options - The options to use — everything you can pass to `createMutation`.
39
35
  * @returns The same options object.
40
- *
36
+ * @see {@link createMutation} to run a mutation with these options.
41
37
  * @example
42
38
  * ```svelte
43
39
  * <script lang="ts">
@@ -1 +1 @@
1
- {"version":3,"file":"mutationOptions.d.ts","sourceRoot":"","sources":["../src/mutationOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACtE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD;;;;;;;;;;;;;;;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MAAM,EAAE,UAAU,EAAE,eAAe,CAAC,EACjE,aAAa,CACd,CAAA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAC7B,KAAK,GAAG,OAAO,EACf,MAAM,GAAG,YAAY,EACrB,UAAU,GAAG,IAAI,EACjB,eAAe,GAAG,OAAO,EAEzB,OAAO,EAAE,IAAI,CACX,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,CAAC,EACjE,aAAa,CACd,GACA,IAAI,CACL,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,CAAC,EACjE,aAAa,CACd,CAAA"}
@@ -1,8 +1,16 @@
1
1
  import type { DefaultError, InitialDataFunction, NonUndefinedGuard, QueryKey, QueryKeyWithDataTag } from '@tanstack/query-core';
2
2
  import type { CreateQueryOptions } from './types.js';
3
+ /**
4
+ * The options accepted by the `queryOptions` overload selected when `initialData` is omitted or may be
5
+ * `undefined` — `data` may be `undefined` while the query is `pending`.
6
+ */
3
7
  export type UndefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
4
8
  initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>> | NonUndefinedGuard<TQueryFnData>;
5
9
  };
10
+ /**
11
+ * The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never
12
+ * `undefined` (unless a `select` changes `TData` to include `undefined`).
13
+ */
6
14
  export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {
7
15
  initialData: NonUndefinedGuard<TQueryFnData> | (() => NonUndefinedGuard<TQueryFnData>);
8
16
  };
@@ -13,12 +21,10 @@ export type DefinedInitialDataOptions<TQueryFnData = unknown, TError = DefaultEr
13
21
  *
14
22
  * This overload is selected when `initialData` is set, so the resulting `data` is never `undefined` (unless
15
23
  * a `select` changes `TData` to include `undefined`).
16
- *
17
- * @see {@link createQuery} to run a query with these options.
18
24
  * @param options - The {@link DefinedInitialDataOptions} to use — everything you can pass to `createQuery`,
19
25
  * with `initialData` set.
20
26
  * @returns The same options object, typed so that `queryKey` carries the inferred data type.
21
- *
27
+ * @see {@link createQuery} to run a query with these options.
22
28
  * @example
23
29
  * ```svelte
24
30
  * <script lang="ts">
@@ -50,11 +56,9 @@ export declare function queryOptions<TQueryFnData = unknown, TError = DefaultErr
50
56
  * You can generally pass everything to `queryOptions` that you can also pass to `createQuery`. These options
51
57
  * can be shared across `createQuery` calls and imperative APIs such as `queryClient.query`. `options.queryKey`
52
58
  * is required and is the query key to generate options for.
53
- *
54
- * @see {@link createQuery} to run a query with these options.
55
59
  * @param options - The {@link UndefinedInitialDataOptions} to use — everything you can pass to `createQuery`.
56
60
  * @returns The same options object, typed so that `queryKey` carries the inferred data type.
57
- *
61
+ * @see {@link createQuery} to run a query with these options.
58
62
  * @example
59
63
  * A parameterized factory, so the same options object can be reused per `id`:
60
64
  * ```svelte
@@ -1 +1 @@
1
- {"version":3,"file":"queryOptions.d.ts","sourceRoot":"","sources":["../src/queryOptions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,iBAAiB,EACjB,QAAQ,EACR,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAEpD,MAAM,MAAM,2BAA2B,CACrC,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,SAAS,SAAS,QAAQ,GAAG,QAAQ,IACnC,kBAAkB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,GAAG;IAC/D,WAAW,CAAC,EACR,SAAS,GACT,mBAAmB,CA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AAK,EAAE,SAAS,CAAC,GAClE,mBAAmB,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,YAAY,CAC1B,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,SAAS,SAAS,QAAQ,GAAG,QAAQ,EAErC,OAAO,EAAE,2BAA2B,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,GAC3E,2BAA2B,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAC,GACpE,mBAAmB,CAAC,SAAS,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA"}
package/dist/types.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { DefaultError, DefinedInfiniteQueryObserverResult, DefinedQueryObserverResult, InfiniteQueryObserverOptions, InfiniteQueryObserverResult, MutateFunction, Mutation, MutationFilters, MutationObserverOptions, MutationObserverResult, MutationState, OmitKeyof, Override, QueryClient, QueryKey, QueryObserverOptions, QueryObserverResult } from '@tanstack/query-core';
3
+ /**
4
+ * A function that returns a value. Options passed as an accessor are read inside reactive contexts, so they
5
+ * update when the state they read changes.
6
+ */
3
7
  export type Accessor<T> = () => T;
4
8
  /** Options for createBaseQuery */
5
9
  export type CreateBaseQueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>;
@@ -21,8 +25,22 @@ export type DefinedCreateBaseQueryResult<TData = unknown, TError = DefaultError>
21
25
  export type DefinedCreateQueryResult<TData = unknown, TError = DefaultError> = DefinedCreateBaseQueryResult<TData, TError>;
22
26
  /** Options for createMutation */
23
27
  export type CreateMutationOptions<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = OmitKeyof<MutationObserverOptions<TData, TError, TVariables, TOnMutateResult>, '_defaulted'>;
28
+ /**
29
+ * The type of `mutate`, as returned by `createMutation`. Forwards the variables (and an optional per-call
30
+ * `onSuccess`/`onError`/`onSettled`) to the underlying `mutate` call. Fire-and-forget — errors are surfaced
31
+ * through the mutation result, not thrown.
32
+ */
24
33
  export type CreateMutateFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = (...args: Parameters<MutateFunction<TData, TError, TVariables, TOnMutateResult>>) => void;
34
+ /**
35
+ * The type of `mutateAsync`, as returned by `createMutation`. Similar to {@link CreateMutateFunction}, but
36
+ * returns a promise which can be awaited.
37
+ */
25
38
  export type CreateMutateAsyncFunction<TData = unknown, TError = DefaultError, TVariables = void, TOnMutateResult = unknown> = MutateFunction<TData, TError, TVariables, TOnMutateResult>;
39
+ /**
40
+ * The result of `createMutation`. Same as {@link MutationObserverResult} from `@tanstack/query-core`, with
41
+ * `mutate` narrowed to the fire-and-forget {@link CreateMutateFunction} signature, plus the added
42
+ * `mutateAsync`.
43
+ */
26
44
  export type CreateBaseMutationResult<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> = Override<MutationObserverResult<TData, TError, TVariables, TOnMutateResult>, {
27
45
  mutate: CreateMutateFunction<TData, TError, TVariables, TOnMutateResult>;
28
46
  }> & {
@@ -30,16 +48,35 @@ export type CreateBaseMutationResult<TData = unknown, TError = DefaultError, TVa
30
48
  };
31
49
  /** Result from createMutation */
32
50
  export type CreateMutationResult<TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown> = CreateBaseMutationResult<TData, TError, TVariables, TOnMutateResult>;
51
+ /**
52
+ * Infers the `Mutation` type passed to `useMutationState`'s `select` from the `MutationState` type it
53
+ * returns, falling back to `Mutation` otherwise.
54
+ */
33
55
  export type MutationTypeFromResult<TResult> = [TResult] extends [
34
56
  MutationState<infer TData, infer TError, infer TVariables, infer TOnMutateResult>
35
57
  ] ? Mutation<TData, TError, TVariables, TOnMutateResult> : Mutation;
36
58
  /** Options for useMutationState */
37
59
  export type MutationStateOptions<TResult = MutationState, TMutation extends Mutation<any, any, any, any> = MutationTypeFromResult<TResult>> = {
60
+ /**
61
+ * The filters that select the mutations to return the state of.
62
+ */
38
63
  filters?: MutationFilters;
64
+ /**
65
+ * Maps each matching mutation to the value returned for it. Defaults to the mutation's `state`.
66
+ */
39
67
  select?: (mutation: TMutation) => TResult;
40
68
  };
69
+ /**
70
+ * The props accepted by `QueryClientProvider`.
71
+ */
41
72
  export type QueryClientProviderProps = {
73
+ /**
74
+ * The `QueryClient` to provide to the children.
75
+ */
42
76
  client: QueryClient;
77
+ /**
78
+ * The children that can use the provided `QueryClient`.
79
+ */
43
80
  children: Snippet;
44
81
  };
45
82
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EACV,YAAY,EACZ,kCAAkC,EAClC,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,EAC3B,cAAc,EACd,QAAQ,EACR,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACtB,aAAa,EACb,SAAS,EACT,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,sBAAsB,CAAA;AAE7B,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,MAAM,CAAC,CAAA;AAEjC,kCAAkC;AAClC,MAAM,MAAM,sBAAsB,CAChC,YAAY,GAAG,OAAO,EACtB,MAAM,GAAG,YAAY,EACrB,KAAK,GAAG,YAAY,EACpB,UAAU,GAAG,YAAY,EACzB,SAAS,SAAS,QAAQ,GAAG,QAAQ,IACnC,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAA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AA;IACnB;;OAEG;IACH,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA"}
@@ -4,12 +4,10 @@ import type { HydrateOptions, QueryClient } from '@tanstack/query-core';
4
4
  * passed explicitly). If the client already contains data, the new queries will be intelligently merged based
5
5
  * on update timestamp. `HydrationBoundary` wraps this — use it directly only if you need to hydrate from your
6
6
  * own component instead.
7
- *
8
7
  * @param state - The dehydrated state to hydrate into the cache, as produced by `dehydrate`.
9
8
  * @param options - {@link HydrateOptions} to control the hydration.
10
9
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
11
10
  * be used.
12
- *
13
11
  * @example
14
12
  * Server-side prefetch handed off to the client via `dehydrate` — `dehydratedState` would typically come
15
13
  * from a server load function that prefetched with `queryClient.query` and called `dehydrate(queryClient)`:
@@ -1 +1 @@
1
- {"version":3,"file":"useHydrate.d.ts","sourceRoot":"","sources":["../src/useHydrate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CACxB,KAAK,CAAC,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,cAAc,EACxB,WAAW,CAAC,EAAE,WAAW,QAO1B"}
1
+ {"version":3,"file":"useHydrate.d.ts","sourceRoot":"","sources":["../src/useHydrate.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,UAAU,CACxB,KAAK,CAAC,EAAE,OAAO,EACf,OAAO,CAAC,EAAE,cAAc,EACxB,WAAW,CAAC,EAAE,WAAW,QAO1B"}
@@ -5,12 +5,10 @@ import { useQueryClient } from './useQueryClient.js';
5
5
  * passed explicitly). If the client already contains data, the new queries will be intelligently merged based
6
6
  * on update timestamp. `HydrationBoundary` wraps this — use it directly only if you need to hydrate from your
7
7
  * own component instead.
8
- *
9
8
  * @param state - The dehydrated state to hydrate into the cache, as produced by `dehydrate`.
10
9
  * @param options - {@link HydrateOptions} to control the hydration.
11
10
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
12
11
  * be used.
13
- *
14
12
  * @example
15
13
  * Server-side prefetch handed off to the client via `dehydrate` — `dehydratedState` would typically come
16
14
  * from a server load function that prefetched with `queryClient.query` and called `dehydrate(queryClient)`:
@@ -3,13 +3,11 @@ import type { QueryClient, QueryFilters } from '@tanstack/query-core';
3
3
  /**
4
4
  * The `useIsFetching` function returns the `number` of the queries that your application is loading or
5
5
  * fetching in the background (useful for app-wide loading indicators).
6
- *
7
6
  * @param filters - {@link QueryFilters} to narrow down which queries to count. Omit to count every fetching
8
7
  * query.
9
8
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
10
9
  * be used.
11
10
  * @returns A reactive value — read `.current` to get how many matching queries are currently fetching.
12
- *
13
11
  * @example
14
12
  * ```svelte
15
13
  * <script lang="ts">
@@ -23,7 +21,6 @@ import type { QueryClient, QueryFilters } from '@tanstack/query-core';
23
21
  * <span>Refreshing posts...</span>
24
22
  * {/if}
25
23
  * ```
26
- *
27
24
  * @example
28
25
  * A global loading indicator for any query fetching in the background, not just the ones on screen:
29
26
  * ```svelte
@@ -1 +1 @@
1
- {"version":3,"file":"useIsFetching.svelte.d.ts","sourceRoot":"","sources":["../src/useIsFetching.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,YAAY,EACtB,WAAW,CAAC,EAAE,WAAW,GACxB,aAAa,CAAC,MAAM,CAAC,CAQvB"}
1
+ {"version":3,"file":"useIsFetching.svelte.d.ts","sourceRoot":"","sources":["../src/useIsFetching.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,YAAY,EACtB,WAAW,CAAC,EAAE,WAAW,GACxB,aAAa,CAAC,MAAM,CAAC,CAQvB"}
@@ -3,13 +3,11 @@ import { useQueryClient } from './useQueryClient.js';
3
3
  /**
4
4
  * The `useIsFetching` function returns the `number` of the queries that your application is loading or
5
5
  * fetching in the background (useful for app-wide loading indicators).
6
- *
7
6
  * @param filters - {@link QueryFilters} to narrow down which queries to count. Omit to count every fetching
8
7
  * query.
9
8
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
10
9
  * be used.
11
10
  * @returns A reactive value — read `.current` to get how many matching queries are currently fetching.
12
- *
13
11
  * @example
14
12
  * ```svelte
15
13
  * <script lang="ts">
@@ -23,7 +21,6 @@ import { useQueryClient } from './useQueryClient.js';
23
21
  * <span>Refreshing posts...</span>
24
22
  * {/if}
25
23
  * ```
26
- *
27
24
  * @example
28
25
  * A global loading indicator for any query fetching in the background, not just the ones on screen:
29
26
  * ```svelte
@@ -3,12 +3,10 @@ import type { MutationFilters, QueryClient } from '@tanstack/query-core';
3
3
  /**
4
4
  * `useIsMutating` is an optional function that returns the `number` of mutations that your application is
5
5
  * running (useful for app-wide loading indicators).
6
- *
7
6
  * @param filters - {@link MutationFilters} to narrow down which mutations to count.
8
7
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
9
8
  * be used.
10
9
  * @returns A reactive value — read `.current` to get how many matching mutations are currently running.
11
- *
12
10
  * @example
13
11
  * ```svelte
14
12
  * <script lang="ts">
@@ -1 +1 @@
1
- {"version":3,"file":"useIsMutating.svelte.d.ts","sourceRoot":"","sources":["../src/useIsMutating.svelte.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,eAAe,EACzB,WAAW,CAAC,EAAE,WAAW,GACxB,aAAa,CAAC,MAAM,CAAC,CAQvB"}
1
+ {"version":3,"file":"useIsMutating.svelte.d.ts","sourceRoot":"","sources":["../src/useIsMutating.svelte.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAC3B,OAAO,CAAC,EAAE,eAAe,EACzB,WAAW,CAAC,EAAE,WAAW,GACxB,aAAa,CAAC,MAAM,CAAC,CAQvB"}
@@ -3,12 +3,10 @@ import { ReactiveValue } from './containers.svelte.js';
3
3
  /**
4
4
  * `useIsMutating` is an optional function that returns the `number` of mutations that your application is
5
5
  * running (useful for app-wide loading indicators).
6
- *
7
6
  * @param filters - {@link MutationFilters} to narrow down which mutations to count.
8
7
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
9
8
  * be used.
10
9
  * @returns A reactive value — read `.current` to get how many matching mutations are currently running.
11
- *
12
10
  * @example
13
11
  * ```svelte
14
12
  * <script lang="ts">
@@ -3,7 +3,6 @@ import type { Box } from './containers.svelte.js';
3
3
  * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` function alongside it to
4
4
  * check if a restore is currently in progress. `createQuery` and friends also check this internally to avoid
5
5
  * race conditions between the restore and mounting queries.
6
- *
7
6
  * @returns A reactive box — read `.current` for `true` while a persisted client is being restored, `false`
8
7
  * otherwise.
9
8
  * @example
@@ -1 +1 @@
1
- {"version":3,"file":"useIsRestoring.d.ts","sourceRoot":"","sources":["../src/useIsRestoring.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,cAAc,IAAI,GAAG,CAAC,OAAO,CAAC,CAE7C"}
1
+ {"version":3,"file":"useIsRestoring.d.ts","sourceRoot":"","sources":["../src/useIsRestoring.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AAEjD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,IAAI,GAAG,CAAC,OAAO,CAAC,CAE7C"}
@@ -3,7 +3,6 @@ import { getIsRestoringContext } from './context.js';
3
3
  * If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` function alongside it to
4
4
  * check if a restore is currently in progress. `createQuery` and friends also check this internally to avoid
5
5
  * race conditions between the restore and mounting queries.
6
- *
7
6
  * @returns A reactive box — read `.current` for `true` while a persisted client is being restored, `false`
8
7
  * otherwise.
9
8
  * @example
@@ -4,13 +4,11 @@ import type { MutationStateOptions, MutationTypeFromResult } from './types.js';
4
4
  * `useMutationState` is a function that gives you access to all mutations in the `MutationCache`. You can pass
5
5
  * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
6
6
  * state.
7
- *
8
7
  * @param options - The `filters` to narrow down matched mutations, and an optional `select` to transform the
9
8
  * mutation state.
10
9
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
11
10
  * be used.
12
11
  * @returns An Array of whatever `select` returns for each matching mutation.
13
- *
14
12
  * @example
15
13
  * Get all variables of all running mutations:
16
14
  * ```svelte
@@ -25,7 +23,6 @@ import type { MutationStateOptions, MutationTypeFromResult } from './types.js';
25
23
  *
26
24
  * {pendingVariables.length} posts saving...
27
25
  * ```
28
- *
29
26
  * @example
30
27
  * Get all data for specific mutations via the `mutationKey`:
31
28
  * ```svelte
@@ -51,7 +48,6 @@ import type { MutationStateOptions, MutationTypeFromResult } from './types.js';
51
48
  * Create post ({savedPosts.length} saved so far)
52
49
  * </button>
53
50
  * ```
54
- *
55
51
  * @example
56
52
  * Access the latest mutation data via the `mutationKey`. Each invocation of `mutate` adds a new entry to the
57
53
  * mutation cache for `gcTime` milliseconds — check the last item that `useMutationState` returns to get the
@@ -1 +1 @@
1
- {"version":3,"file":"useMutationState.svelte.d.ts","sourceRoot":"","sources":["../src/useMutationState.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EAER,aAAa,EACb,WAAW,EACZ,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAoB9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAG,aAAa,EACvB,SAAS,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAC5C,sBAAsB,CAAC,OAAO,CAAC,EAEjC,OAAO,GAAE,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAM,EACtD,WAAW,CAAC,EAAE,WAAW,GACxB,KAAK,CAAC,OAAO,CAAC,CA+BhB"}
1
+ {"version":3,"file":"useMutationState.svelte.d.ts","sourceRoot":"","sources":["../src/useMutationState.svelte.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,QAAQ,EAER,aAAa,EACb,WAAW,EACZ,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AA2B9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAG,aAAa,EACvB,SAAS,SAAS,QAAQ,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,GAC5C,sBAAsB,CAAC,OAAO,CAAC,EAEjC,OAAO,GAAE,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAM,EACtD,WAAW,CAAC,EAAE,WAAW,GACxB,KAAK,CAAC,OAAO,CAAC,CA+BhB"}
@@ -1,5 +1,12 @@
1
1
  import { replaceEqualDeep } from '@tanstack/query-core';
2
2
  import { useQueryClient } from './useQueryClient.js';
3
+ /**
4
+ * Collects the mutations in the cache that match `options.filters`, mapped with `options.select`
5
+ * (or to their state, by default).
6
+ * @param mutationCache - The mutation cache to read.
7
+ * @param options - The `filters` to match and the `select` function to map each mutation with.
8
+ * @returns The selected value of every matching mutation.
9
+ */
3
10
  function getResult(mutationCache, options) {
4
11
  return mutationCache
5
12
  .findAll(options.filters)
@@ -11,13 +18,11 @@ function getResult(mutationCache, options) {
11
18
  * `useMutationState` is a function that gives you access to all mutations in the `MutationCache`. You can pass
12
19
  * `filters` ({@link MutationFilters}) to narrow down your mutations, and `select` to transform the mutation
13
20
  * state.
14
- *
15
21
  * @param options - The `filters` to narrow down matched mutations, and an optional `select` to transform the
16
22
  * mutation state.
17
23
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
18
24
  * be used.
19
25
  * @returns An Array of whatever `select` returns for each matching mutation.
20
- *
21
26
  * @example
22
27
  * Get all variables of all running mutations:
23
28
  * ```svelte
@@ -32,7 +37,6 @@ function getResult(mutationCache, options) {
32
37
  *
33
38
  * {pendingVariables.length} posts saving...
34
39
  * ```
35
- *
36
40
  * @example
37
41
  * Get all data for specific mutations via the `mutationKey`:
38
42
  * ```svelte
@@ -58,7 +62,6 @@ function getResult(mutationCache, options) {
58
62
  * Create post ({savedPosts.length} saved so far)
59
63
  * </button>
60
64
  * ```
61
- *
62
65
  * @example
63
66
  * Access the latest mutation data via the `mutationKey`. Each invocation of `mutate` adds a new entry to the
64
67
  * mutation cache for `gcTime` milliseconds — check the last item that `useMutationState` returns to get the
@@ -1,11 +1,11 @@
1
1
  import type { QueryClient } from '@tanstack/query-core';
2
2
  /**
3
3
  * The `useQueryClient` function returns the current `QueryClient` instance.
4
- *
5
4
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
6
5
  * be used.
7
6
  * @returns The current `QueryClient` instance.
8
- * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
7
+ * @throws {Error} If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
8
+ * component tree.
9
9
  * @example
10
10
  * ```svelte
11
11
  * <script lang="ts">
@@ -1,11 +1,11 @@
1
1
  import { getQueryClientContext } from './context.js';
2
2
  /**
3
3
  * The `useQueryClient` function returns the current `QueryClient` instance.
4
- *
5
4
  * @param queryClient - Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will
6
5
  * be used.
7
6
  * @returns The current `QueryClient` instance.
8
- * @throws If no `queryClient` argument is passed and no `QueryClientProvider` is found in the component tree.
7
+ * @throws {Error} If no `queryClient` argument is passed and no `QueryClientProvider` is found in the
8
+ * component tree.
9
9
  * @example
10
10
  * ```svelte
11
11
  * <script lang="ts">
@@ -1,4 +1,12 @@
1
1
  type Getter<T> = () => T;
2
+ /**
3
+ * Runs `effect` whenever the reactive state read by `sources` changes, even if they return the
4
+ * same values, skipping the first run. The effect receives the new and previous values, and is
5
+ * called untracked, so only `sources` are tracked.
6
+ * @param sources - The getter, or array of getters, to watch.
7
+ * @param flush - Whether to run after (`'post'`) or before (`'pre'`) the DOM updates.
8
+ * @param effect - Called with the new and previous values. It may return a cleanup function.
9
+ */
2
10
  export declare const watchChanges: <T>(sources: Getter<T> | Array<Getter<T>>, flush: "post" | "pre", effect: (values: T | Array<T>, previousValues: T | undefined | Array<T | undefined>) => void) => void;
3
11
  export {};
4
12
  //# sourceMappingURL=utils.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.svelte.d.ts","sourceRoot":"","sources":["../src/utils.svelte.ts"],"names":[],"mappings":"AAeA,KAAK,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAA;AACxB,eAAO,MAAM,YAAY,GAAI,CAAC,EAC5B,SAAS,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACrC,OAAO,MAAM,GAAG,KAAK,EACrB,QAAQ,CACN,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EACpB,cAAc,EAAE,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,KACjD,IAAI,SAqBV,CAAA"}
1
+ {"version":3,"file":"utils.svelte.d.ts","sourceRoot":"","sources":["../src/utils.svelte.ts"],"names":[],"mappings":"AAoBA,KAAK,MAAM,CAAC,CAAC,IAAI,MAAM,CAAC,CAAA;AACxB;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAC5B,SAAS,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EACrC,OAAO,MAAM,GAAG,KAAK,EACrB,QAAQ,CACN,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,EACpB,cAAc,EAAE,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,CAAC,GAAG,SAAS,CAAC,KACjD,IAAI,SAqBV,CAAA"}
@@ -1,5 +1,10 @@
1
1
  import { untrack } from 'svelte';
2
2
  // modified from the great https://github.com/svecosystem/runed
3
+ /**
4
+ * Runs an effect after (`'post'`) or before (`'pre'`) the DOM updates.
5
+ * @param flush - When to run the effect: `'post'` uses `$effect`, `'pre'` uses `$effect.pre`.
6
+ * @param effect - The effect to run. It may return a cleanup function.
7
+ */
3
8
  function runEffect(flush, effect) {
4
9
  switch (flush) {
5
10
  case 'post':
@@ -10,6 +15,14 @@ function runEffect(flush, effect) {
10
15
  break;
11
16
  }
12
17
  }
18
+ /**
19
+ * Runs `effect` whenever the reactive state read by `sources` changes, even if they return the
20
+ * same values, skipping the first run. The effect receives the new and previous values, and is
21
+ * called untracked, so only `sources` are tracked.
22
+ * @param sources - The getter, or array of getters, to watch.
23
+ * @param flush - Whether to run after (`'post'`) or before (`'pre'`) the DOM updates.
24
+ * @param effect - Called with the new and previous values. It may return a cleanup function.
25
+ */
13
26
  export const watchChanges = (sources, flush, effect) => {
14
27
  let active = false;
15
28
  let previousValues = Array.isArray(sources)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/svelte-query",
3
- "version": "6.3.1",
3
+ "version": "6.3.3",
4
4
  "description": "Primitives for managing, caching and syncing asynchronous and remote data in Svelte",
5
5
  "author": "Lachlan Collins",
6
6
  "license": "MIT",
@@ -39,14 +39,14 @@
39
39
  "!src/__tests__"
40
40
  ],
41
41
  "dependencies": {
42
- "@tanstack/query-core": "5.104.1"
42
+ "@tanstack/query-core": "5.104.3"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@sveltejs/package": "^2.5.8",
46
46
  "@sveltejs/vite-plugin-svelte": "^7.3.1",
47
47
  "@tanstack/query-test-utils": "0.0.0",
48
48
  "@testing-library/svelte": "^5.2.8",
49
- "@typescript-eslint/parser": "^8.70.1",
49
+ "@typescript-eslint/parser": "^8.71.1",
50
50
  "eslint-plugin-svelte": "^3.23.0",
51
51
  "svelte": "^5.57.1",
52
52
  "svelte-check": "^4.4.5",
@@ -59,12 +59,12 @@
59
59
  "clean": "premove ./dist ./coverage ./.svelte-kit ./dist-ts",
60
60
  "compile": "tsc --project tsconfig.json",
61
61
  "test:types": "npm-run-all --serial test:types:*",
62
- "test:types:ts56": "node -e \"const Module = require('module'); const resolveFilename = Module._resolveFilename; let swapped = false; Module._resolveFilename = function (request, ...args) { if (request === 'typescript' || request.startsWith('typescript/')) { request = request.replace('typescript', 'typescript56'); swapped = true } return resolveFilename.call(this, request, ...args) }; process.on('exit', () => { if (!swapped) { console.error('svelte-check did not load typescript56'); process.exitCode = 1 } }); process.argv.splice(1, 0, ''); require('svelte-check/bin/svelte-check')\" -- --tsconfig ./tsconfig.legacy.json",
63
62
  "test:types:ts57": "node -e \"const Module = require('module'); const resolveFilename = Module._resolveFilename; let swapped = false; Module._resolveFilename = function (request, ...args) { if (request === 'typescript' || request.startsWith('typescript/')) { request = request.replace('typescript', 'typescript57'); swapped = true } return resolveFilename.call(this, request, ...args) }; process.on('exit', () => { if (!swapped) { console.error('svelte-check did not load typescript57'); process.exitCode = 1 } }); process.argv.splice(1, 0, ''); require('svelte-check/bin/svelte-check')\" -- --tsconfig ./tsconfig.legacy.json",
64
63
  "test:types:ts58": "node -e \"const Module = require('module'); const resolveFilename = Module._resolveFilename; let swapped = false; Module._resolveFilename = function (request, ...args) { if (request === 'typescript' || request.startsWith('typescript/')) { request = request.replace('typescript', 'typescript58'); swapped = true } return resolveFilename.call(this, request, ...args) }; process.on('exit', () => { if (!swapped) { console.error('svelte-check did not load typescript58'); process.exitCode = 1 } }); process.argv.splice(1, 0, ''); require('svelte-check/bin/svelte-check')\" -- --tsconfig ./tsconfig.legacy.json",
65
64
  "test:types:ts59": "node -e \"const Module = require('module'); const resolveFilename = Module._resolveFilename; let swapped = false; Module._resolveFilename = function (request, ...args) { if (request === 'typescript' || request.startsWith('typescript/')) { request = request.replace('typescript', 'typescript59'); swapped = true } return resolveFilename.call(this, request, ...args) }; process.on('exit', () => { if (!swapped) { console.error('svelte-check did not load typescript59'); process.exitCode = 1 } }); process.argv.splice(1, 0, ''); require('svelte-check/bin/svelte-check')\" -- --tsconfig ./tsconfig.legacy.json",
66
65
  "test:types:tscurrent": "svelte-check --tsconfig ./tsconfig.json",
67
66
  "test:eslint": "eslint --concurrency=auto ./src ./tests",
67
+ "test:oxlint": "oxlint ./src ./tests",
68
68
  "test:lib": "vitest",
69
69
  "test:lib:dev": "pnpm run test:lib --watch",
70
70
  "test:build": "publint --strict && attw --pack",
@@ -3,8 +3,20 @@ import { SvelteSet, createSubscriber } from 'svelte/reactivity'
3
3
  type VoidFn = () => void
4
4
  type Subscriber = (update: VoidFn) => void | VoidFn
5
5
 
6
- export type Box<T> = { current: T }
6
+ /**
7
+ * An object holding a value in its `current` property, e.g. a reactive value backed by `$state`.
8
+ */
9
+ export type Box<T> = {
10
+ /**
11
+ * The held value.
12
+ */
13
+ current: T
14
+ }
7
15
 
16
+ /**
17
+ * A {@link Box} whose `current` value is computed on each read, and that notifies the reactive
18
+ * contexts reading it through the given subscriber.
19
+ */
8
20
  export class ReactiveValue<T> implements Box<T> {
9
21
  #fn
10
22
  #subscribe
@@ -14,6 +26,10 @@ export class ReactiveValue<T> implements Box<T> {
14
26
  this.#subscribe = createSubscriber((update) => onSubscribe(update))
15
27
  }
16
28
 
29
+ /**
30
+ * Subscribes the reactive context reading it, then computes the value.
31
+ * @returns The value returned by the compute function.
32
+ */
17
33
  get current() {
18
34
  this.#subscribe()
19
35
  return this.#fn()
@@ -25,6 +41,8 @@ export class ReactiveValue<T> implements Box<T> {
25
41
  * are the same as in the original object. Does not mutate the original object. Provides an `update`
26
42
  * function that _can_ (but does not have to be) be used to replace all of the object's top-level keys
27
43
  * with the values of the new object, while maintaining the original root object's reference.
44
+ * @param init - The object or array whose top-level keys become the initial fields.
45
+ * @returns A tuple of the reactive object and the `update` function.
28
46
  */
29
47
  export function createRawRef<T extends {} | Array<unknown>>(
30
48
  init: T,
@@ -99,6 +117,11 @@ export function createRawRef<T extends {} | Array<unknown>>(
99
117
  },
100
118
  })
101
119
 
120
+ /**
121
+ * Replaces the top-level keys of the reactive object with those of `newValue`, removing keys that
122
+ * `newValue` doesn't have, while keeping the object's reference.
123
+ * @param newValue - The object or array to take the new keys and values from.
124
+ */
102
125
  function update(newValue: T) {
103
126
  const existingKeys = Object.keys(out)
104
127
  const newKeys = Object.keys(newValue)
@@ -138,12 +161,23 @@ export function createRawRef<T extends {} | Array<unknown>>(
138
161
  const lazyBrand = Symbol('LazyValue')
139
162
  type Branded<T extends () => unknown> = T & { [lazyBrand]: true }
140
163
 
164
+ /**
165
+ * Marks a function as a lazy value, so that reading the property it is stored in calls it instead of
166
+ * returning the function.
167
+ * @param fn - The function that returns the value.
168
+ * @returns The same function, marked as lazy.
169
+ */
141
170
  function brand<T extends () => unknown>(fn: T): Branded<T> {
142
171
  // @ts-expect-error
143
172
  fn[lazyBrand] = true
144
173
  return fn as Branded<T>
145
174
  }
146
175
 
176
+ /**
177
+ * Checks whether a function was marked as a lazy value with {@link brand}.
178
+ * @param fn - The function to check.
179
+ * @returns `true` if the function is marked as lazy.
180
+ */
147
181
  function isBranded<T extends () => unknown>(fn: T): fn is Branded<T> {
148
182
  return Boolean((fn as Branded<T>)[lazyBrand])
149
183
  }