@tanstack/angular-query-experimental 5.61.1 → 5.61.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/build/index.js CHANGED
@@ -137,19 +137,23 @@ function createBaseQuery(optionsFn, Observer) {
137
137
  injector
138
138
  }
139
139
  );
140
- const unsubscribe = observer.subscribe(
141
- notifyManager.batchCalls((state) => {
142
- ngZone.run(() => {
143
- if (state.isError && !state.isFetching && // !isRestoring() && // todo: enable when client persistence is implemented
144
- shouldThrowError(observer.options.throwOnError, [
145
- state.error,
146
- observer.getCurrentQuery()
147
- ])) {
148
- throw state.error;
140
+ const unsubscribe = ngZone.runOutsideAngular(
141
+ () => observer.subscribe(
142
+ notifyManager.batchCalls(
143
+ (state) => {
144
+ ngZone.run(() => {
145
+ if (state.isError && !state.isFetching && // !isRestoring() && // todo: enable when client persistence is implemented
146
+ shouldThrowError(observer.options.throwOnError, [
147
+ state.error,
148
+ observer.getCurrentQuery()
149
+ ])) {
150
+ throw state.error;
151
+ }
152
+ resultSignal.set(state);
153
+ });
149
154
  }
150
- resultSignal.set(state);
151
- });
152
- })
155
+ )
156
+ )
153
157
  );
154
158
  destroyRef.onDestroy(unsubscribe);
155
159
  return signalProxy(resultSignal);
@@ -191,16 +195,18 @@ function injectIsFetching(filters, injector) {
191
195
  const cache = queryClient.getQueryCache();
192
196
  let isFetching = queryClient.isFetching(filters);
193
197
  const result = signal2(isFetching);
194
- const unsubscribe = cache.subscribe(
195
- notifyManager2.batchCalls(() => {
196
- const newIsFetching = queryClient.isFetching(filters);
197
- if (isFetching !== newIsFetching) {
198
- isFetching = newIsFetching;
199
- ngZone.run(() => {
200
- result.set(isFetching);
201
- });
202
- }
203
- })
198
+ const unsubscribe = ngZone.runOutsideAngular(
199
+ () => cache.subscribe(
200
+ notifyManager2.batchCalls(() => {
201
+ const newIsFetching = queryClient.isFetching(filters);
202
+ if (isFetching !== newIsFetching) {
203
+ isFetching = newIsFetching;
204
+ ngZone.run(() => {
205
+ result.set(isFetching);
206
+ });
207
+ }
208
+ })
209
+ )
204
210
  );
205
211
  destroyRef.onDestroy(unsubscribe);
206
212
  return result;
@@ -218,16 +224,18 @@ function injectIsMutating(filters, injector) {
218
224
  const cache = queryClient.getMutationCache();
219
225
  let isMutating = queryClient.isMutating(filters);
220
226
  const result = signal3(isMutating);
221
- const unsubscribe = cache.subscribe(
222
- notifyManager3.batchCalls(() => {
223
- const newIsMutating = queryClient.isMutating(filters);
224
- if (isMutating !== newIsMutating) {
225
- isMutating = newIsMutating;
226
- ngZone.run(() => {
227
- result.set(isMutating);
228
- });
229
- }
230
- })
227
+ const unsubscribe = ngZone.runOutsideAngular(
228
+ () => cache.subscribe(
229
+ notifyManager3.batchCalls(() => {
230
+ const newIsMutating = queryClient.isMutating(filters);
231
+ if (isMutating !== newIsMutating) {
232
+ isMutating = newIsMutating;
233
+ ngZone.run(() => {
234
+ result.set(isMutating);
235
+ });
236
+ }
237
+ })
238
+ )
231
239
  );
232
240
  destroyRef.onDestroy(unsubscribe);
233
241
  return result;
@@ -268,16 +276,20 @@ function injectMutation(optionsFn, injector) {
268
276
  );
269
277
  });
270
278
  const result = signal4(observer.getCurrentResult());
271
- const unsubscribe = observer.subscribe(
272
- notifyManager4.batchCalls(
273
- (state) => {
274
- ngZone.run(() => {
275
- if (state.isError && shouldThrowError(observer.options.throwOnError, [state.error])) {
276
- throw state.error;
277
- }
278
- result.set(state);
279
- });
280
- }
279
+ const unsubscribe = ngZone.runOutsideAngular(
280
+ () => observer.subscribe(
281
+ notifyManager4.batchCalls(
282
+ (state) => {
283
+ ngZone.run(() => {
284
+ if (state.isError && shouldThrowError(observer.options.throwOnError, [
285
+ state.error
286
+ ])) {
287
+ throw state.error;
288
+ }
289
+ result.set(state);
290
+ });
291
+ }
292
+ )
281
293
  )
282
294
  );
283
295
  destroyRef.onDestroy(unsubscribe);
@@ -347,18 +359,20 @@ function injectMutationState(mutationStateOptionsFn = () => ({}), options) {
347
359
  },
348
360
  { injector }
349
361
  );
350
- const unsubscribe = mutationCache.subscribe(
351
- notifyManager5.batchCalls(() => {
352
- const nextResult = replaceEqualDeep(
353
- result(),
354
- getResult(mutationCache, mutationStateOptionsFn())
355
- );
356
- if (result() !== nextResult) {
357
- ngZone.run(() => {
358
- result.set(nextResult);
359
- });
360
- }
361
- })
362
+ const unsubscribe = ngZone.runOutsideAngular(
363
+ () => mutationCache.subscribe(
364
+ notifyManager5.batchCalls(() => {
365
+ const nextResult = replaceEqualDeep(
366
+ result(),
367
+ getResult(mutationCache, mutationStateOptionsFn())
368
+ );
369
+ if (result() !== nextResult) {
370
+ ngZone.run(() => {
371
+ result.set(nextResult);
372
+ });
373
+ }
374
+ })
375
+ )
362
376
  );
363
377
  destroyRef.onDestroy(unsubscribe);
364
378
  return result;
@@ -372,14 +386,22 @@ import {
372
386
  QueryClient as QueryClient6,
373
387
  notifyManager as notifyManager6
374
388
  } from "@tanstack/query-core";
375
- import { DestroyRef as DestroyRef6, computed as computed5, effect as effect4, inject as inject8, signal as signal6 } from "@angular/core";
389
+ import {
390
+ DestroyRef as DestroyRef6,
391
+ NgZone as NgZone6,
392
+ computed as computed5,
393
+ effect as effect4,
394
+ inject as inject8,
395
+ signal as signal6
396
+ } from "@angular/core";
376
397
  function injectQueries({
377
398
  queries,
378
399
  ...options
379
400
  }, injector) {
380
401
  return assertInjector(injectQueries, injector, () => {
381
- const queryClient = inject8(QueryClient6);
382
402
  const destroyRef = inject8(DestroyRef6);
403
+ const ngZone = inject8(NgZone6);
404
+ const queryClient = inject8(QueryClient6);
383
405
  const defaultedQueries = computed5(() => {
384
406
  return queries().map((opts) => {
385
407
  const defaultedOptions = queryClient.defaultQueryOptions(opts);
@@ -404,7 +426,9 @@ function injectQueries({
404
426
  options.combine
405
427
  );
406
428
  const result = signal6(getCombinedResult());
407
- const unsubscribe = observer.subscribe(notifyManager6.batchCalls(result.set));
429
+ const unsubscribe = ngZone.runOutsideAngular(
430
+ () => observer.subscribe(notifyManager6.batchCalls(result.set))
431
+ );
408
432
  destroyRef.onDestroy(unsubscribe);
409
433
  return result;
410
434
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/query-options.ts","../src/mutation-options.ts","../src/infinite-query-options.ts","../src/inject-infinite-query.ts","../src/create-base-query.ts","../src/signal-proxy.ts","../src/util/index.ts","../src/util/lazy-init/lazy-init.ts","../src/util/assert-injector/assert-injector.ts","../src/inject-is-fetching.ts","../src/inject-is-mutating.ts","../src/inject-mutation.ts","../src/inject-mutation-state.ts","../src/util/lazy-signal-initializer/lazy-signal-initializer.ts","../src/inject-queries.ts","../src/inject-query.ts","../src/inject-query-client.ts","../src/providers.ts","../src/util/is-dev-mode/is-dev-mode.ts"],"sourcesContent":["/* istanbul ignore file */\n\n// Re-export core\nexport * from '@tanstack/query-core'\n\nexport * from './types'\n\nexport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './query-options'\nexport { queryOptions } from './query-options'\nexport { mutationOptions } from './mutation-options'\nexport type { CreateMutationOptions } from './mutation-options'\n\nexport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infinite-query-options'\nexport { infiniteQueryOptions } from './infinite-query-options'\n\nexport * from './inject-infinite-query'\nexport * from './inject-is-fetching'\nexport * from './inject-is-mutating'\nexport * from './inject-mutation'\nexport * from './inject-mutation-state'\nexport * from './inject-queries'\nexport * from './inject-query'\nexport * from './inject-query-client'\nexport * from './providers'\n","import type {\n DataTag,\n DefaultError,\n InitialDataFunction,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { CreateQueryOptions, NonUndefinedGuard } from './types'\n\n/**\n * @public\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n}\n\n/**\n * @public\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TQueryFnData>\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TQueryFnData>\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\n */\nexport function queryOptions(options: unknown) {\n return options\n}\n","import type {\n DefaultError,\n MutationObserverOptions,\n OmitKeyof,\n} from '@tanstack/query-core'\n\n/**\n * Allows to share and re-use mutation options in a type-safe way.\n *\n * **Example**\n *\n * ```ts\n * export class QueriesService {\n * private http = inject(HttpClient);\n *\n * updatePost(id: number) {\n * return mutationOptions({\n * mutationFn: (post: Post) => Promise.resolve(post),\n * mutationKey: [\"updatePost\", id],\n * onSuccess: (newPost) => {\n * // ^? newPost: Post\n * this.queryClient.setQueryData([\"posts\", id], newPost);\n * },\n * });\n * }\n * }\n *\n * queries = inject(QueriesService)\n * idSignal = new Signal(0);\n * mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))\n *\n * mutation.mutate({ title: 'New Title' })\n * ```\n * @param options - The mutation options.\n * @returns Mutation options.\n * @public\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\n): CreateMutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n\n/**\n * @public\n */\nexport interface CreateMutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends OmitKeyof<\n MutationObserverOptions<TData, TError, TVariables, TContext>,\n '_defaulted'\n > {}\n","import type {\n DataTag,\n DefaultError,\n InfiniteData,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { CreateInfiniteQueryOptions, NonUndefinedGuard } from './types'\n\n/**\n * @public\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey,\n TPageParam\n> & {\n initialData?: undefined\n}\n\n/**\n * @public\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey,\n TPageParam\n> & {\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n * @public\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>>\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n * @public\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>>\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n * @public\n */\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n","import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { createBaseQuery } from './create-base-query'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport type { Injector } from '@angular/core'\nimport type {\n DefaultError,\n InfiniteData,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type {\n CreateInfiniteQueryOptions,\n CreateInfiniteQueryResult,\n DefinedCreateInfiniteQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infinite-query-options'\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param optionsFn - A function that returns infinite query options.\n * @param injector - The Angular injector to use.\n * @returns The infinite query result.\n * @public\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n optionsFn: () => DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n injector?: Injector,\n): DefinedCreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param optionsFn - A function that returns infinite query options.\n * @param injector - The Angular injector to use.\n * @returns The infinite query result.\n * @public\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n optionsFn: () => UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n injector?: Injector,\n): CreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param optionsFn - A function that returns infinite query options.\n * @param injector - The Angular injector to use.\n * @returns The infinite query result.\n * @public\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n optionsFn: () => CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey,\n TPageParam\n >,\n injector?: Injector,\n): CreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param optionsFn - A function that returns infinite query options.\n * @param injector - The Angular injector to use.\n * @returns The infinite query result.\n * @public\n */\nexport function injectInfiniteQuery(\n optionsFn: () => CreateInfiniteQueryOptions,\n injector?: Injector,\n) {\n return assertInjector(injectInfiniteQuery, injector, () =>\n createBaseQuery(optionsFn, InfiniteQueryObserver as typeof QueryObserver),\n )\n}\n","import {\n DestroyRef,\n Injector,\n NgZone,\n computed,\n effect,\n inject,\n runInInjectionContext,\n signal,\n untracked,\n} from '@angular/core'\nimport { QueryClient, notifyManager } from '@tanstack/query-core'\nimport { signalProxy } from './signal-proxy'\nimport { shouldThrowError } from './util'\nimport { lazyInit } from './util/lazy-init/lazy-init'\nimport type {\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { CreateBaseQueryOptions, CreateBaseQueryResult } from './types'\n\n/**\n * Base implementation for `injectQuery` and `injectInfiniteQuery`.\n */\nexport function createBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n optionsFn: () => CreateBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n): CreateBaseQueryResult<TData, TError> {\n const injector = inject(Injector)\n return lazyInit(() => {\n const ngZone = injector.get(NgZone)\n const destroyRef = injector.get(DestroyRef)\n const queryClient = injector.get(QueryClient)\n\n /**\n * Signal that has the default options from query client applied\n * computed() is used so signals can be inserted into the options\n * making it reactive. Wrapping options in a function ensures embedded expressions\n * are preserved and can keep being applied after signal changes\n */\n const defaultedOptionsSignal = computed(() => {\n const options = runInInjectionContext(injector, () => optionsFn())\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n defaultedOptions._optimisticResults = 'optimistic'\n return defaultedOptions\n })\n\n const observer = new Observer<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >(queryClient, defaultedOptionsSignal())\n\n const resultSignal = signal(\n observer.getOptimisticResult(defaultedOptionsSignal()),\n )\n\n effect(\n () => {\n const defaultedOptions = defaultedOptionsSignal()\n observer.setOptions(defaultedOptions, {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n listeners: false,\n })\n untracked(() => {\n resultSignal.set(observer.getOptimisticResult(defaultedOptions))\n })\n },\n {\n injector,\n },\n )\n\n // observer.trackResult is not used as this optimization is not needed for Angular\n const unsubscribe = observer.subscribe(\n notifyManager.batchCalls((state: QueryObserverResult<TData, TError>) => {\n ngZone.run(() => {\n if (\n state.isError &&\n !state.isFetching &&\n // !isRestoring() && // todo: enable when client persistence is implemented\n shouldThrowError(observer.options.throwOnError, [\n state.error,\n observer.getCurrentQuery(),\n ])\n ) {\n throw state.error\n }\n resultSignal.set(state)\n })\n }),\n )\n destroyRef.onDestroy(unsubscribe)\n\n return signalProxy(resultSignal) as CreateBaseQueryResult<TData, TError>\n })\n}\n","import { computed, untracked } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\nexport type MapToSignals<T> = {\n [K in keyof T]: T[K] extends Function ? T[K] : Signal<T[K]>\n}\n\n/**\n * Exposes fields of an object passed via an Angular `Signal` as `Computed` signals.\n * Functions on the object are passed through as-is.\n * @param inputSignal - `Signal` that must return an object.\n * @returns A proxy object with the same fields as the input object, but with each field wrapped in a `Computed` signal.\n */\nexport function signalProxy<TInput extends Record<string | symbol, any>>(\n inputSignal: Signal<TInput>,\n) {\n const internalState = {} as MapToSignals<TInput>\n\n return new Proxy<MapToSignals<TInput>>(internalState, {\n get(target, prop) {\n // first check if we have it in our internal state and return it\n const computedField = target[prop]\n if (computedField) return computedField\n\n // then, check if it's a function on the resultState and return it\n const targetField = untracked(inputSignal)[prop]\n if (typeof targetField === 'function') return targetField\n\n // finally, create a computed field, store it and return it\n // @ts-expect-error\n return (target[prop] = computed(() => inputSignal()[prop]))\n },\n has(_, prop) {\n return !!untracked(inputSignal)[prop]\n },\n ownKeys() {\n return Reflect.ownKeys(untracked(inputSignal))\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n })\n}\n","export function shouldThrowError<T extends (...args: Array<any>) => boolean>(\n throwError: boolean | T | undefined,\n params: Parameters<T>,\n): boolean {\n // Allow throwError function to override throwing behavior on a per-error basis\n if (typeof throwError === 'function') {\n return throwError(...params)\n }\n\n return !!throwError\n}\n\nexport function noop(): void {}\n","import { untracked } from '@angular/core'\n\nexport function lazyInit<T extends object>(initializer: () => T): T {\n let object: T | null = null\n\n const initializeObject = () => {\n if (!object) {\n object = untracked(() => initializer())\n }\n }\n\n queueMicrotask(() => initializeObject())\n\n return new Proxy<T>({} as T, {\n get(_, prop, receiver) {\n initializeObject()\n return Reflect.get(object as T, prop, receiver)\n },\n has(_, prop) {\n initializeObject()\n return Reflect.has(object as T, prop)\n },\n ownKeys() {\n initializeObject()\n return Reflect.ownKeys(object as T)\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n })\n}\n","/* eslint-disable cspell/spellchecker */\n/**\n * The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app.\n *\n * Original Author: Chau Tran\n *\n * NG Extension Platform is an open-source project licensed under the MIT license.\n *\n * For more information about the original code, see\n * https://github.com/nartc/ngxtension-platform\n */\n/* eslint-enable */\n\nimport {\n Injector,\n assertInInjectionContext,\n inject,\n runInInjectionContext,\n} from '@angular/core'\n\n/**\n * `assertInjector` extends `assertInInjectionContext` with an optional `Injector`\n * After assertion, `assertInjector` runs the `runner` function with the guaranteed `Injector`\n * whether it is the default `Injector` within the current **Injection Context**\n * or the custom `Injector` that was passed in.\n *\n * @template {() => any} Runner - Runner is a function that can return anything\n * @param {Function} fn - the Function to pass in `assertInInjectionContext`\n * @param {Injector | undefined | null} injector - the optional \"custom\" Injector\n * @param {Runner} runner - the runner fn\n * @returns {ReturnType<Runner>} result - returns the result of the Runner\n *\n * @example\n * ```ts\n * function injectValue(injector?: Injector) {\n * return assertInjector(injectValue, injector, () => 'value');\n * }\n *\n * injectValue(); // string\n * ```\n */\nexport function assertInjector<TRunner extends () => any>(\n fn: Function,\n injector: Injector | undefined | null,\n runner: TRunner,\n): ReturnType<TRunner>\n/**\n * `assertInjector` extends `assertInInjectionContext` with an optional `Injector`\n * After assertion, `assertInjector` returns a guaranteed `Injector` whether it is the default `Injector`\n * within the current **Injection Context** or the custom `Injector` that was passed in.\n *\n * @param {Function} fn - the Function to pass in `assertInInjectionContext`\n * @param {Injector | undefined | null} injector - the optional \"custom\" Injector\n * @returns Injector\n *\n * @example\n * ```ts\n * function injectDestroy(injector?: Injector) {\n * injector = assertInjector(injectDestroy, injector);\n *\n * return runInInjectionContext(injector, () => {\n * // code\n * })\n * }\n * ```\n */\nexport function assertInjector(\n fn: Function,\n injector: Injector | undefined | null,\n): Injector\nexport function assertInjector(\n fn: Function,\n injector: Injector | undefined | null,\n runner?: () => any,\n) {\n !injector && assertInInjectionContext(fn)\n const assertedInjector = injector ?? inject(Injector)\n\n if (!runner) return assertedInjector\n return runInInjectionContext(assertedInjector, runner)\n}\n","import { DestroyRef, NgZone, inject, signal } from '@angular/core'\nimport { QueryClient, notifyManager } from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport type { QueryFilters } from '@tanstack/query-core'\nimport type { Injector, Signal } from '@angular/core'\n\n/**\n * Injects a signal that tracks the number of queries that your application is loading or\n * fetching in the background.\n *\n * Can be used for app-wide loading indicators\n * @param filters - The filters to apply to the query.\n * @param injector - The Angular injector to use.\n * @returns signal with number of loading or fetching queries.\n * @public\n */\nexport function injectIsFetching(\n filters?: QueryFilters,\n injector?: Injector,\n): Signal<number> {\n return assertInjector(injectIsFetching, injector, () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n const cache = queryClient.getQueryCache()\n // isFetching is the prev value initialized on mount *\n let isFetching = queryClient.isFetching(filters)\n\n const result = signal(isFetching)\n\n const unsubscribe = cache.subscribe(\n notifyManager.batchCalls(() => {\n const newIsFetching = queryClient.isFetching(filters)\n if (isFetching !== newIsFetching) {\n // * and update with each change\n isFetching = newIsFetching\n ngZone.run(() => {\n result.set(isFetching)\n })\n }\n }),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n return result\n })\n}\n","import { DestroyRef, NgZone, inject, signal } from '@angular/core'\nimport { QueryClient, notifyManager } from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport type { MutationFilters } from '@tanstack/query-core'\nimport type { Injector, Signal } from '@angular/core'\n\n/**\n * Injects a signal that tracks the number of mutations that your application is fetching.\n *\n * Can be used for app-wide loading indicators\n * @param filters - The filters to apply to the query.\n * @param injector - The Angular injector to use.\n * @returns signal with number of fetching mutations.\n * @public\n */\nexport function injectIsMutating(\n filters?: MutationFilters,\n injector?: Injector,\n): Signal<number> {\n return assertInjector(injectIsMutating, injector, () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n const cache = queryClient.getMutationCache()\n // isMutating is the prev value initialized on mount *\n let isMutating = queryClient.isMutating(filters)\n\n const result = signal(isMutating)\n\n const unsubscribe = cache.subscribe(\n notifyManager.batchCalls(() => {\n const newIsMutating = queryClient.isMutating(filters)\n if (isMutating !== newIsMutating) {\n // * and update with each change\n isMutating = newIsMutating\n ngZone.run(() => {\n result.set(isMutating)\n })\n }\n }),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n return result\n })\n}\n","import {\n DestroyRef,\n Injector,\n NgZone,\n computed,\n effect,\n inject,\n runInInjectionContext,\n signal,\n} from '@angular/core'\nimport {\n MutationObserver,\n QueryClient,\n notifyManager,\n} from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport { signalProxy } from './signal-proxy'\nimport { noop, shouldThrowError } from './util'\n\nimport { lazyInit } from './util/lazy-init/lazy-init'\nimport type { DefaultError, MutationObserverResult } from '@tanstack/query-core'\nimport type { CreateMutateFunction, CreateMutationResult } from './types'\nimport type { CreateMutationOptions } from './mutation-options'\n\n/**\n * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.\n *\n * Unlike queries, mutations are not run automatically.\n * @param optionsFn - A function that returns mutation options.\n * @param injector - The Angular injector to use.\n * @returns The mutation.\n * @public\n */\nexport function injectMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n optionsFn: () => CreateMutationOptions<TData, TError, TVariables, TContext>,\n injector?: Injector,\n): CreateMutationResult<TData, TError, TVariables, TContext> {\n return assertInjector(injectMutation, injector, () => {\n const currentInjector = inject(Injector)\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n return lazyInit(() =>\n runInInjectionContext(currentInjector, () => {\n const observer = new MutationObserver<\n TData,\n TError,\n TVariables,\n TContext\n >(queryClient, optionsFn())\n const mutate: CreateMutateFunction<\n TData,\n TError,\n TVariables,\n TContext\n > = (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n }\n\n effect(() => {\n observer.setOptions(\n runInInjectionContext(currentInjector, () => optionsFn()),\n )\n })\n\n const result = signal(observer.getCurrentResult())\n\n const unsubscribe = observer.subscribe(\n notifyManager.batchCalls(\n (\n state: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >,\n ) => {\n ngZone.run(() => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [state.error])\n ) {\n throw state.error\n }\n result.set(state)\n })\n },\n ),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n const resultSignal = computed(() => ({\n ...result(),\n mutate,\n mutateAsync: result().mutate,\n }))\n\n return signalProxy(resultSignal) as unknown as CreateMutationResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n }),\n )\n })\n}\n","import {\n DestroyRef,\n NgZone,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport {\n QueryClient,\n notifyManager,\n replaceEqualDeep,\n} from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport { lazySignalInitializer } from './util/lazy-signal-initializer/lazy-signal-initializer'\nimport type { Injector, Signal } from '@angular/core'\nimport type {\n Mutation,\n MutationCache,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\n\ntype MutationStateOptions<TResult = MutationState> = {\n filters?: MutationFilters\n select?: (mutation: Mutation) => TResult\n}\n\nfunction getResult<TResult = MutationState>(\n mutationCache: MutationCache,\n options: MutationStateOptions<TResult>,\n): Array<TResult> {\n return mutationCache\n .findAll(options.filters)\n .map(\n (mutation): TResult =>\n (options.select ? options.select(mutation) : mutation.state) as TResult,\n )\n}\n\n/**\n * @public\n */\nexport interface InjectMutationStateOptions {\n injector?: Injector\n}\n\n/**\n * Injects a signal that tracks the state of all mutations.\n * @param mutationStateOptionsFn - A function that returns mutation state options.\n * @param options - The Angular injector to use.\n * @returns The signal that tracks the state of all mutations.\n * @public\n */\nexport function injectMutationState<TResult = MutationState>(\n mutationStateOptionsFn: () => MutationStateOptions<TResult> = () => ({}),\n options?: InjectMutationStateOptions,\n): Signal<Array<TResult>> {\n return assertInjector(injectMutationState, options?.injector, () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n const mutationCache = queryClient.getMutationCache()\n\n return lazySignalInitializer((injector) => {\n const result = signal<Array<TResult>>(\n getResult(mutationCache, mutationStateOptionsFn()),\n )\n\n effect(\n () => {\n const mutationStateOptions = mutationStateOptionsFn()\n untracked(() => {\n // Setting the signal from an effect because it's both 'computed' from options()\n // and needs to be set imperatively in the mutationCache listener.\n result.set(getResult(mutationCache, mutationStateOptions))\n })\n },\n { injector },\n )\n\n const unsubscribe = mutationCache.subscribe(\n notifyManager.batchCalls(() => {\n const nextResult = replaceEqualDeep(\n result(),\n getResult(mutationCache, mutationStateOptionsFn()),\n )\n if (result() !== nextResult) {\n ngZone.run(() => {\n result.set(nextResult)\n })\n }\n }),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n return result\n })\n })\n}\n","import { Injector, computed, inject, untracked } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\ntype SignalInitializerFn<T> = (injector: Injector) => Signal<T>\n\nexport function lazySignalInitializer<T>(\n initializerFn: SignalInitializerFn<T>,\n) {\n const injector = inject(Injector)\n\n let source: Signal<T> | null = null\n\n const unwrapSignal = () => {\n if (!source) {\n source = untracked(() => initializerFn(injector))\n }\n return source()\n }\n\n queueMicrotask(() => unwrapSignal())\n\n return computed(unwrapSignal)\n}\n","import {\n QueriesObserver,\n QueryClient,\n notifyManager,\n} from '@tanstack/query-core'\nimport { DestroyRef, computed, effect, inject, signal } from '@angular/core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport type { Injector, Signal } from '@angular/core'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `CreateQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype QueryObserverOptionsForCreateQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,\n 'placeholderData'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? QueryObserverOptionsForCreateQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? QueryObserverOptionsForCreateQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n QueryObserverOptionsForCreateQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? QueryObserverResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? QueryObserverResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? QueryObserverResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? QueryObserverResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? QueryObserverResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? QueryObserverResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? QueryObserverResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n QueryObserverResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n * @public\n */\nexport type QueriesOptions<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverOptionsForCreateQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<\n [...Tail],\n [...TResult, GetOptions<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n QueryObserverOptionsForCreateQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n QueryObserverOptionsForCreateQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<QueryObserverOptionsForCreateQueries>\n\n/**\n * QueriesResults reducer recursively maps type param to results\n * @public\n */\nexport type QueriesResults<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<\n [...Tail],\n [...TResult, GetResults<Head>],\n [...TDepth, 1]\n >\n : T extends Array<\n QueryObserverOptionsForCreateQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any\n >\n >\n ? // Dynamic-size (homogenous) CreateQueryOptions array: map directly to array of results\n Array<\n QueryObserverResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n >\n : // Fallback\n Array<QueryObserverResult>\n\n/**\n * @public\n */\nexport function injectQueries<\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>(\n {\n queries,\n ...options\n }: {\n queries: Signal<[...QueriesOptions<T>]>\n combine?: (result: QueriesResults<T>) => TCombinedResult\n },\n injector?: Injector,\n): Signal<TCombinedResult> {\n return assertInjector(injectQueries, injector, () => {\n const queryClient = inject(QueryClient)\n const destroyRef = inject(DestroyRef)\n\n const defaultedQueries = computed(() => {\n return queries().map((opts) => {\n const defaultedOptions = queryClient.defaultQueryOptions(opts)\n // Make sure the results are already in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = 'optimistic'\n\n return defaultedOptions as QueryObserverOptions\n })\n })\n\n const observer = new QueriesObserver<TCombinedResult>(\n queryClient,\n defaultedQueries(),\n options as QueriesObserverOptions<TCombinedResult>,\n )\n\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n effect(() => {\n observer.setQueries(\n defaultedQueries(),\n options as QueriesObserverOptions<TCombinedResult>,\n { listeners: false },\n )\n })\n\n const [, getCombinedResult] = observer.getOptimisticResult(\n defaultedQueries(),\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n const result = signal(getCombinedResult() as any)\n\n const unsubscribe = observer.subscribe(notifyManager.batchCalls(result.set))\n destroyRef.onDestroy(unsubscribe)\n\n return result\n })\n}\n","import { QueryObserver } from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport { createBaseQuery } from './create-base-query'\nimport type { Injector } from '@angular/core'\nimport type { DefaultError, QueryKey } from '@tanstack/query-core'\nimport type {\n CreateQueryOptions,\n CreateQueryResult,\n DefinedCreateQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './query-options'\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param optionsFn - A function that returns query options.\n * @param injector - The Angular injector to use.\n * @returns The query result.\n * @public\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => DefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n injector?: Injector,\n): DefinedCreateQueryResult<TData, TError>\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param optionsFn - A function that returns query options.\n * @param injector - The Angular injector to use.\n * @returns The query result.\n * @public\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => UndefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n injector?: Injector,\n): CreateQueryResult<TData, TError>\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param optionsFn - A function that returns query options.\n * @param injector - The Angular injector to use.\n * @returns The query result.\n * @public\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n injector?: Injector,\n): CreateQueryResult<TData, TError>\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param optionsFn - A function that returns query options.\n * @param injector - The Angular injector to use.\n * @returns The query result.\n * @public\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery(\n optionsFn: () => CreateQueryOptions,\n injector?: Injector,\n) {\n return assertInjector(injectQuery, injector, () =>\n createBaseQuery(optionsFn, QueryObserver),\n )\n}\n","import { Injector, inject } from '@angular/core'\nimport { QueryClient } from '@tanstack/query-core'\nimport type { InjectOptions } from '@angular/core'\n\n/**\n * Injects a `QueryClient` instance and allows passing a custom injector.\n *\n * You can also use `inject(QueryClient)` if you don't need to provide a custom injector.\n *\n * **Example**\n * ```ts\n * const queryClient = injectQueryClient();\n * ```\n * @param injectOptions - Type of the options argument to inject and optionally a custom injector.\n * @returns The `QueryClient` instance.\n * @public\n */\nexport function injectQueryClient(\n injectOptions: InjectOptions & { injector?: Injector } = {},\n) {\n return (injectOptions.injector ?? inject(Injector)).get(QueryClient)\n}\n","import {\n DestroyRef,\n ENVIRONMENT_INITIALIZER,\n Injector,\n PLATFORM_ID,\n computed,\n effect,\n inject,\n makeEnvironmentProviders,\n runInInjectionContext,\n} from '@angular/core'\nimport { QueryClient, onlineManager } from '@tanstack/query-core'\nimport { isPlatformBrowser } from '@angular/common'\nimport { isDevMode } from './util/is-dev-mode/is-dev-mode'\nimport { noop } from './util'\nimport type { EnvironmentProviders, Provider } from '@angular/core'\nimport type {\n DevtoolsButtonPosition,\n DevtoolsErrorType,\n DevtoolsPosition,\n TanstackQueryDevtools,\n} from '@tanstack/query-devtools'\n\n/**\n * Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the\n * {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}\n * for the entire application. You can use `provideQueryClient` to provide a\n * different `QueryClient` instance for a part of the application.\n * @param queryClient - the `QueryClient` instance to provide.\n * @public\n */\nexport function provideQueryClient(queryClient: QueryClient) {\n return { provide: QueryClient, useValue: queryClient }\n}\n\n/**\n * Sets up providers necessary to enable TanStack Query functionality for Angular applications.\n *\n * Allows to configure a `QueryClient` and optional features such as developer tools.\n *\n * **Example - standalone**\n *\n * ```ts\n * import {\n * provideTanStackQuery,\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * bootstrapApplication(AppComponent, {\n * providers: [provideTanStackQuery(new QueryClient())],\n * })\n * ```\n *\n * **Example - NgModule-based**\n *\n * ```ts\n * import {\n * provideTanStackQuery,\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * @NgModule({\n * declarations: [AppComponent],\n * imports: [BrowserModule],\n * providers: [provideTanStackQuery(new QueryClient())],\n * bootstrap: [AppComponent],\n * })\n * export class AppModule {}\n * ```\n *\n * You can also enable optional developer tools by adding `withDevtools`. By\n * default the tools will then be loaded when your app is in development mode.\n * ```ts\n * import {\n * provideTanStackQuery,\n * withDevtools\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * bootstrapApplication(AppComponent,\n * {\n * providers: [\n * provideTanStackQuery(new QueryClient(), withDevtools())\n * ]\n * }\n * )\n * ```\n * @param queryClient - A `QueryClient` instance.\n * @param features - Optional features to configure additional Query functionality.\n * @returns A set of providers to set up TanStack Query.\n * @public\n * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start\n * @see withDevtools\n */\nexport function provideTanStackQuery(\n queryClient: QueryClient,\n ...features: Array<QueryFeatures>\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideQueryClient(queryClient),\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => {\n queryClient.mount()\n // Unmount the query client on application destroy\n inject(DestroyRef).onDestroy(() => queryClient.unmount())\n },\n },\n features.map((feature) => feature.ɵproviders),\n ])\n}\n\n/**\n * Sets up providers necessary to enable TanStack Query functionality for Angular applications.\n *\n * Allows to configure a `QueryClient`.\n * @param queryClient - A `QueryClient` instance.\n * @returns A set of providers to set up TanStack Query.\n * @public\n * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start\n * @deprecated Use `provideTanStackQuery` instead.\n */\nexport function provideAngularQuery(\n queryClient: QueryClient,\n): EnvironmentProviders {\n return provideTanStackQuery(queryClient)\n}\n\n/**\n * Helper type to represent a Query feature.\n */\nexport interface QueryFeature<TFeatureKind extends QueryFeatureKind> {\n ɵkind: TFeatureKind\n ɵproviders: Array<Provider>\n}\n\n/**\n * Helper function to create an object that represents a Query feature.\n * @param kind -\n * @param providers -\n * @returns A Query feature.\n */\nfunction queryFeature<TFeatureKind extends QueryFeatureKind>(\n kind: TFeatureKind,\n providers: Array<Provider>,\n): QueryFeature<TFeatureKind> {\n return { ɵkind: kind, ɵproviders: providers }\n}\n\n/**\n * A type alias that represents a feature which enables developer tools.\n * The type is used to describe the return value of the `withDevtools` function.\n * @public\n * @see {@link withDevtools}\n */\nexport type DeveloperToolsFeature = QueryFeature<'DeveloperTools'>\n\n/**\n * Options for configuring the TanStack Query devtools.\n * @public\n */\nexport interface DevtoolsOptions {\n /**\n * Set this true if you want the devtools to default to being open\n */\n initialIsOpen?: boolean\n /**\n * The position of the TanStack logo to open and close the devtools panel.\n * `top-left` | `top-right` | `bottom-left` | `bottom-right` | `relative`\n * Defaults to `bottom-right`.\n */\n buttonPosition?: DevtoolsButtonPosition\n /**\n * The position of the TanStack Query devtools panel.\n * `top` | `bottom` | `left` | `right`\n * Defaults to `bottom`.\n */\n position?: DevtoolsPosition\n /**\n * Custom instance of QueryClient\n */\n client?: QueryClient\n /**\n * Use this so you can define custom errors that can be shown in the devtools.\n */\n errorTypes?: Array<DevtoolsErrorType>\n /**\n * Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.\n */\n styleNonce?: string\n /**\n * Use this so you can attach the devtool's styles to a specific element in the DOM.\n */\n shadowDOMTarget?: ShadowRoot\n\n /**\n * Whether the developer tools should load.\n * - `auto`- (Default) Lazily loads devtools when in development mode. Skips loading in production mode.\n * - `true`- Always load the devtools, regardless of the environment.\n * - `false`- Never load the devtools, regardless of the environment.\n *\n * You can use `true` and `false` to override loading developer tools from an environment file.\n * For example, a test environment might run in production mode but you may want to load developer tools.\n *\n * Additionally, you can use a signal in the callback to dynamically load the devtools based on a condition. For example,\n * a signal created from a RxJS observable that listens for a keyboard shortcut.\n *\n * **Example**\n * ```ts\n * withDevtools(() => ({\n * initialIsOpen: true,\n * loadDevtools: inject(ExampleService).loadDevtools()\n * }))\n * ```\n */\n loadDevtools?: 'auto' | boolean\n}\n\n/**\n * Enables developer tools.\n *\n * **Example**\n *\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideTanStackQuery(new QueryClient(), withDevtools())\n * ]\n * }\n * ```\n * By default the devtools will be loaded when Angular runs in development mode and rendered in `<body>`.\n *\n * If you need more control over when devtools are loaded, you can use the `loadDevtools` option. This is particularly useful if you want to load devtools based on environment configurations. For instance, you might have a test environment running in production mode but still require devtools to be available.\n *\n * If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.\n * @param optionsFn - A function that returns `DevtoolsOptions`.\n * @returns A set of providers for use with `provideTanStackQuery`.\n * @public\n * @see {@link provideTanStackQuery}\n * @see {@link DevtoolsOptions}\n */\nexport function withDevtools(\n optionsFn?: () => DevtoolsOptions,\n): DeveloperToolsFeature {\n let providers: Array<Provider> = []\n if (!isDevMode() && !optionsFn) {\n providers = []\n } else {\n providers = [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: () => {\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return noop\n const injector = inject(Injector)\n const options = computed(() =>\n runInInjectionContext(injector, () => optionsFn?.() ?? {}),\n )\n\n let devtools: TanstackQueryDevtools | null = null\n let el: HTMLElement | null = null\n\n const shouldLoadToolsSignal = computed(() => {\n const { loadDevtools } = options()\n return typeof loadDevtools === 'boolean'\n ? loadDevtools\n : isDevMode()\n })\n\n const destroyRef = inject(DestroyRef)\n\n const getResolvedQueryClient = () => {\n const injectedClient = injector.get(QueryClient, null)\n const client = options().client ?? injectedClient\n if (!client) {\n throw new Error('No QueryClient found')\n }\n return client\n }\n\n const destroyDevtools = () => {\n devtools?.unmount()\n el?.remove()\n devtools = null\n }\n\n return () =>\n effect(() => {\n const shouldLoadTools = shouldLoadToolsSignal()\n const {\n client,\n position,\n errorTypes,\n buttonPosition,\n initialIsOpen,\n } = options()\n\n if (devtools && !shouldLoadTools) {\n destroyDevtools()\n return\n } else if (devtools && shouldLoadTools) {\n client && devtools.setClient(client)\n position && devtools.setPosition(position)\n errorTypes && devtools.setErrorTypes(errorTypes)\n buttonPosition && devtools.setButtonPosition(buttonPosition)\n initialIsOpen && devtools.setInitialIsOpen(initialIsOpen)\n return\n } else if (!shouldLoadTools) {\n return\n }\n\n el = document.body.appendChild(document.createElement('div'))\n el.classList.add('tsqd-parent-container')\n\n import('@tanstack/query-devtools').then((queryDevtools) =>\n runInInjectionContext(injector, () => {\n devtools = new queryDevtools.TanstackQueryDevtools({\n ...options(),\n client: getResolvedQueryClient(),\n queryFlavor: 'Angular Query',\n version: '5',\n onlineManager,\n })\n\n el && devtools.mount(el)\n\n // Unmount the devtools on application destroy\n destroyRef.onDestroy(destroyDevtools)\n }),\n )\n })\n },\n },\n ]\n }\n return queryFeature('DeveloperTools', providers)\n}\n\n/**\n * A type alias that represents all Query features available for use with `provideTanStackQuery`.\n * Features can be enabled by adding special functions to the `provideTanStackQuery` call.\n * See documentation for each symbol to find corresponding function name. See also `provideTanStackQuery`\n * documentation on how to use those functions.\n * @public\n * @see {@link provideTanStackQuery}\n */\nexport type QueryFeatures = DeveloperToolsFeature // Union type of features but just one now\n\nexport const queryFeatures = ['DeveloperTools'] as const\n\nexport type QueryFeatureKind = (typeof queryFeatures)[number]\n","// Re-export for mocking in tests\n\nexport { isDevMode } from '@angular/core'\n"],"mappings":";AAGA,cAAc;;;ACuHP,SAAS,aAAa,SAAkB;AAC7C,SAAO;AACT;;;ACvFO,SAAS,gBAMd,SAC4D;AAC5D,SAAO;AACT;;;AC4EO,SAAS,qBAAqB,SAAkB;AACrD,SAAO;AACT;;;AC5HA,SAAS,6BAA6B;;;ACAtC;AAAA,EACE;AAAA,EAC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ACb,SAAS;AAAA,kBACT;AAAA,gBACF,CAAC;AAED,sBAAM,SAAS,MAAM,EAAE;AAGvB,2BAAW,UAAU,eAAe;AAAA,cACtC,CAAC;AAAA,YACH;AAAA,UACF,CAAC;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO,aAAa,kBAAkB,SAAS;AACjD;AAYO,IAAM,gBAAgB,CAAC,gBAAgB;","names":["computed","untracked","untracked","computed","untracked","Injector","inject","runInInjectionContext","DestroyRef","NgZone","inject","signal","QueryClient","notifyManager","inject","DestroyRef","NgZone","QueryClient","signal","notifyManager","DestroyRef","NgZone","inject","signal","QueryClient","notifyManager","inject","DestroyRef","NgZone","QueryClient","signal","notifyManager","DestroyRef","Injector","NgZone","computed","effect","inject","runInInjectionContext","signal","QueryClient","notifyManager","inject","Injector","DestroyRef","NgZone","QueryClient","runInInjectionContext","effect","signal","notifyManager","computed","DestroyRef","NgZone","effect","inject","signal","untracked","QueryClient","notifyManager","Injector","computed","inject","untracked","inject","DestroyRef","NgZone","QueryClient","signal","effect","untracked","notifyManager","QueryClient","notifyManager","DestroyRef","computed","effect","inject","signal","inject","QueryClient","DestroyRef","computed","effect","signal","notifyManager","Injector","inject","QueryClient","DestroyRef","Injector","computed","effect","inject","runInInjectionContext","QueryClient","QueryClient","inject","DestroyRef","Injector","computed","runInInjectionContext","effect"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/query-options.ts","../src/mutation-options.ts","../src/infinite-query-options.ts","../src/inject-infinite-query.ts","../src/create-base-query.ts","../src/signal-proxy.ts","../src/util/index.ts","../src/util/lazy-init/lazy-init.ts","../src/util/assert-injector/assert-injector.ts","../src/inject-is-fetching.ts","../src/inject-is-mutating.ts","../src/inject-mutation.ts","../src/inject-mutation-state.ts","../src/util/lazy-signal-initializer/lazy-signal-initializer.ts","../src/inject-queries.ts","../src/inject-query.ts","../src/inject-query-client.ts","../src/providers.ts","../src/util/is-dev-mode/is-dev-mode.ts"],"sourcesContent":["/* istanbul ignore file */\n\n// Re-export core\nexport * from '@tanstack/query-core'\n\nexport * from './types'\n\nexport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './query-options'\nexport { queryOptions } from './query-options'\nexport { mutationOptions } from './mutation-options'\nexport type { CreateMutationOptions } from './mutation-options'\n\nexport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infinite-query-options'\nexport { infiniteQueryOptions } from './infinite-query-options'\n\nexport * from './inject-infinite-query'\nexport * from './inject-is-fetching'\nexport * from './inject-is-mutating'\nexport * from './inject-mutation'\nexport * from './inject-mutation-state'\nexport * from './inject-queries'\nexport * from './inject-query'\nexport * from './inject-query-client'\nexport * from './providers'\n","import type {\n DataTag,\n DefaultError,\n InitialDataFunction,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { CreateQueryOptions, NonUndefinedGuard } from './types'\n\n/**\n * @public\n */\nexport type UndefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData?: undefined | InitialDataFunction<NonUndefinedGuard<TQueryFnData>>\n}\n\n/**\n * @public\n */\nexport type DefinedInitialDataOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey> & {\n initialData:\n | NonUndefinedGuard<TQueryFnData>\n | (() => NonUndefinedGuard<TQueryFnData>)\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TQueryFnData>\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\n */\nexport function queryOptions<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n options: UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>,\n): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & {\n queryKey: DataTag<TQueryKey, TQueryFnData>\n}\n\n/**\n * Allows to share and re-use query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n *\n * **Example**\n *\n * ```ts\n * const { queryKey } = queryOptions({\n * queryKey: ['key'],\n * queryFn: () => Promise.resolve(5),\n * // ^? Promise<number>\n * })\n *\n * const queryClient = new QueryClient()\n * const data = queryClient.getQueryData(queryKey)\n * // ^? number | undefined\n * ```\n * @param options - The query options to tag with the type from `queryFn`.\n * @returns The tagged query options.\n * @public\n */\nexport function queryOptions(options: unknown) {\n return options\n}\n","import type {\n DefaultError,\n MutationObserverOptions,\n OmitKeyof,\n} from '@tanstack/query-core'\n\n/**\n * Allows to share and re-use mutation options in a type-safe way.\n *\n * **Example**\n *\n * ```ts\n * export class QueriesService {\n * private http = inject(HttpClient);\n *\n * updatePost(id: number) {\n * return mutationOptions({\n * mutationFn: (post: Post) => Promise.resolve(post),\n * mutationKey: [\"updatePost\", id],\n * onSuccess: (newPost) => {\n * // ^? newPost: Post\n * this.queryClient.setQueryData([\"posts\", id], newPost);\n * },\n * });\n * }\n * }\n *\n * queries = inject(QueriesService)\n * idSignal = new Signal(0);\n * mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))\n *\n * mutation.mutate({ title: 'New Title' })\n * ```\n * @param options - The mutation options.\n * @returns Mutation options.\n * @public\n */\nexport function mutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n options: MutationObserverOptions<TData, TError, TVariables, TContext>,\n): CreateMutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n\n/**\n * @public\n */\nexport interface CreateMutationOptions<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n> extends OmitKeyof<\n MutationObserverOptions<TData, TError, TVariables, TContext>,\n '_defaulted'\n > {}\n","import type {\n DataTag,\n DefaultError,\n InfiniteData,\n QueryKey,\n} from '@tanstack/query-core'\nimport type { CreateInfiniteQueryOptions, NonUndefinedGuard } from './types'\n\n/**\n * @public\n */\nexport type UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey,\n TPageParam\n> & {\n initialData?: undefined\n}\n\n/**\n * @public\n */\nexport type DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n> = CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey,\n TPageParam\n> & {\n initialData:\n | NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>\n | (() => NonUndefinedGuard<InfiniteData<TQueryFnData, TPageParam>>)\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n * @public\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>>\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n * @public\n */\nexport function infiniteQueryOptions<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n options: UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n): UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n> & {\n queryKey: DataTag<TQueryKey, InfiniteData<TQueryFnData>>\n}\n\n/**\n * Allows to share and re-use infinite query options in a type-safe way.\n *\n * The `queryKey` will be tagged with the type from `queryFn`.\n * @param options - The infinite query options to tag with the type from `queryFn`.\n * @returns The tagged infinite query options.\n * @public\n */\nexport function infiniteQueryOptions(options: unknown) {\n return options\n}\n","import { InfiniteQueryObserver } from '@tanstack/query-core'\nimport { createBaseQuery } from './create-base-query'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport type { Injector } from '@angular/core'\nimport type {\n DefaultError,\n InfiniteData,\n QueryKey,\n QueryObserver,\n} from '@tanstack/query-core'\nimport type {\n CreateInfiniteQueryOptions,\n CreateInfiniteQueryResult,\n DefinedCreateInfiniteQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataInfiniteOptions,\n UndefinedInitialDataInfiniteOptions,\n} from './infinite-query-options'\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param optionsFn - A function that returns infinite query options.\n * @param injector - The Angular injector to use.\n * @returns The infinite query result.\n * @public\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n optionsFn: () => DefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n injector?: Injector,\n): DefinedCreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param optionsFn - A function that returns infinite query options.\n * @param injector - The Angular injector to use.\n * @returns The infinite query result.\n * @public\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n optionsFn: () => UndefinedInitialDataInfiniteOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey,\n TPageParam\n >,\n injector?: Injector,\n): CreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param optionsFn - A function that returns infinite query options.\n * @param injector - The Angular injector to use.\n * @returns The infinite query result.\n * @public\n */\nexport function injectInfiniteQuery<\n TQueryFnData,\n TError = DefaultError,\n TData = InfiniteData<TQueryFnData>,\n TQueryKey extends QueryKey = QueryKey,\n TPageParam = unknown,\n>(\n optionsFn: () => CreateInfiniteQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryFnData,\n TQueryKey,\n TPageParam\n >,\n injector?: Injector,\n): CreateInfiniteQueryResult<TData, TError>\n\n/**\n * Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n * Infinite queries can additively \"load more\" data onto an existing set of data or \"infinite scroll\"\n * @param optionsFn - A function that returns infinite query options.\n * @param injector - The Angular injector to use.\n * @returns The infinite query result.\n * @public\n */\nexport function injectInfiniteQuery(\n optionsFn: () => CreateInfiniteQueryOptions,\n injector?: Injector,\n) {\n return assertInjector(injectInfiniteQuery, injector, () =>\n createBaseQuery(optionsFn, InfiniteQueryObserver as typeof QueryObserver),\n )\n}\n","import {\n DestroyRef,\n Injector,\n NgZone,\n computed,\n effect,\n inject,\n runInInjectionContext,\n signal,\n untracked,\n} from '@angular/core'\nimport { QueryClient, notifyManager } from '@tanstack/query-core'\nimport { signalProxy } from './signal-proxy'\nimport { shouldThrowError } from './util'\nimport { lazyInit } from './util/lazy-init/lazy-init'\nimport type {\n QueryKey,\n QueryObserver,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { CreateBaseQueryOptions, CreateBaseQueryResult } from './types'\n\n/**\n * Base implementation for `injectQuery` and `injectInfiniteQuery`.\n */\nexport function createBaseQuery<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey extends QueryKey,\n>(\n optionsFn: () => CreateBaseQueryOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >,\n Observer: typeof QueryObserver,\n): CreateBaseQueryResult<TData, TError> {\n const injector = inject(Injector)\n return lazyInit(() => {\n const ngZone = injector.get(NgZone)\n const destroyRef = injector.get(DestroyRef)\n const queryClient = injector.get(QueryClient)\n\n /**\n * Signal that has the default options from query client applied\n * computed() is used so signals can be inserted into the options\n * making it reactive. Wrapping options in a function ensures embedded expressions\n * are preserved and can keep being applied after signal changes\n */\n const defaultedOptionsSignal = computed(() => {\n const options = runInInjectionContext(injector, () => optionsFn())\n const defaultedOptions = queryClient.defaultQueryOptions(options)\n defaultedOptions._optimisticResults = 'optimistic'\n return defaultedOptions\n })\n\n const observer = new Observer<\n TQueryFnData,\n TError,\n TData,\n TQueryData,\n TQueryKey\n >(queryClient, defaultedOptionsSignal())\n\n const resultSignal = signal(\n observer.getOptimisticResult(defaultedOptionsSignal()),\n )\n\n effect(\n () => {\n const defaultedOptions = defaultedOptionsSignal()\n observer.setOptions(defaultedOptions, {\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n listeners: false,\n })\n untracked(() => {\n resultSignal.set(observer.getOptimisticResult(defaultedOptions))\n })\n },\n {\n injector,\n },\n )\n\n // observer.trackResult is not used as this optimization is not needed for Angular\n const unsubscribe = ngZone.runOutsideAngular(() =>\n observer.subscribe(\n notifyManager.batchCalls(\n (state: QueryObserverResult<TData, TError>) => {\n ngZone.run(() => {\n if (\n state.isError &&\n !state.isFetching &&\n // !isRestoring() && // todo: enable when client persistence is implemented\n shouldThrowError(observer.options.throwOnError, [\n state.error,\n observer.getCurrentQuery(),\n ])\n ) {\n throw state.error\n }\n resultSignal.set(state)\n })\n },\n ),\n ),\n )\n destroyRef.onDestroy(unsubscribe)\n\n return signalProxy(resultSignal) as CreateBaseQueryResult<TData, TError>\n })\n}\n","import { computed, untracked } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\nexport type MapToSignals<T> = {\n [K in keyof T]: T[K] extends Function ? T[K] : Signal<T[K]>\n}\n\n/**\n * Exposes fields of an object passed via an Angular `Signal` as `Computed` signals.\n * Functions on the object are passed through as-is.\n * @param inputSignal - `Signal` that must return an object.\n * @returns A proxy object with the same fields as the input object, but with each field wrapped in a `Computed` signal.\n */\nexport function signalProxy<TInput extends Record<string | symbol, any>>(\n inputSignal: Signal<TInput>,\n) {\n const internalState = {} as MapToSignals<TInput>\n\n return new Proxy<MapToSignals<TInput>>(internalState, {\n get(target, prop) {\n // first check if we have it in our internal state and return it\n const computedField = target[prop]\n if (computedField) return computedField\n\n // then, check if it's a function on the resultState and return it\n const targetField = untracked(inputSignal)[prop]\n if (typeof targetField === 'function') return targetField\n\n // finally, create a computed field, store it and return it\n // @ts-expect-error\n return (target[prop] = computed(() => inputSignal()[prop]))\n },\n has(_, prop) {\n return !!untracked(inputSignal)[prop]\n },\n ownKeys() {\n return Reflect.ownKeys(untracked(inputSignal))\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n })\n}\n","export function shouldThrowError<T extends (...args: Array<any>) => boolean>(\n throwError: boolean | T | undefined,\n params: Parameters<T>,\n): boolean {\n // Allow throwError function to override throwing behavior on a per-error basis\n if (typeof throwError === 'function') {\n return throwError(...params)\n }\n\n return !!throwError\n}\n\nexport function noop(): void {}\n","import { untracked } from '@angular/core'\n\nexport function lazyInit<T extends object>(initializer: () => T): T {\n let object: T | null = null\n\n const initializeObject = () => {\n if (!object) {\n object = untracked(() => initializer())\n }\n }\n\n queueMicrotask(() => initializeObject())\n\n return new Proxy<T>({} as T, {\n get(_, prop, receiver) {\n initializeObject()\n return Reflect.get(object as T, prop, receiver)\n },\n has(_, prop) {\n initializeObject()\n return Reflect.has(object as T, prop)\n },\n ownKeys() {\n initializeObject()\n return Reflect.ownKeys(object as T)\n },\n getOwnPropertyDescriptor() {\n return {\n enumerable: true,\n configurable: true,\n }\n },\n })\n}\n","/* eslint-disable cspell/spellchecker */\n/**\n * The code in this file is adapted from NG Extension Platform at https://ngxtension.netlify.app.\n *\n * Original Author: Chau Tran\n *\n * NG Extension Platform is an open-source project licensed under the MIT license.\n *\n * For more information about the original code, see\n * https://github.com/nartc/ngxtension-platform\n */\n/* eslint-enable */\n\nimport {\n Injector,\n assertInInjectionContext,\n inject,\n runInInjectionContext,\n} from '@angular/core'\n\n/**\n * `assertInjector` extends `assertInInjectionContext` with an optional `Injector`\n * After assertion, `assertInjector` runs the `runner` function with the guaranteed `Injector`\n * whether it is the default `Injector` within the current **Injection Context**\n * or the custom `Injector` that was passed in.\n *\n * @template {() => any} Runner - Runner is a function that can return anything\n * @param {Function} fn - the Function to pass in `assertInInjectionContext`\n * @param {Injector | undefined | null} injector - the optional \"custom\" Injector\n * @param {Runner} runner - the runner fn\n * @returns {ReturnType<Runner>} result - returns the result of the Runner\n *\n * @example\n * ```ts\n * function injectValue(injector?: Injector) {\n * return assertInjector(injectValue, injector, () => 'value');\n * }\n *\n * injectValue(); // string\n * ```\n */\nexport function assertInjector<TRunner extends () => any>(\n fn: Function,\n injector: Injector | undefined | null,\n runner: TRunner,\n): ReturnType<TRunner>\n/**\n * `assertInjector` extends `assertInInjectionContext` with an optional `Injector`\n * After assertion, `assertInjector` returns a guaranteed `Injector` whether it is the default `Injector`\n * within the current **Injection Context** or the custom `Injector` that was passed in.\n *\n * @param {Function} fn - the Function to pass in `assertInInjectionContext`\n * @param {Injector | undefined | null} injector - the optional \"custom\" Injector\n * @returns Injector\n *\n * @example\n * ```ts\n * function injectDestroy(injector?: Injector) {\n * injector = assertInjector(injectDestroy, injector);\n *\n * return runInInjectionContext(injector, () => {\n * // code\n * })\n * }\n * ```\n */\nexport function assertInjector(\n fn: Function,\n injector: Injector | undefined | null,\n): Injector\nexport function assertInjector(\n fn: Function,\n injector: Injector | undefined | null,\n runner?: () => any,\n) {\n !injector && assertInInjectionContext(fn)\n const assertedInjector = injector ?? inject(Injector)\n\n if (!runner) return assertedInjector\n return runInInjectionContext(assertedInjector, runner)\n}\n","import { DestroyRef, NgZone, inject, signal } from '@angular/core'\nimport { QueryClient, notifyManager } from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport type { QueryFilters } from '@tanstack/query-core'\nimport type { Injector, Signal } from '@angular/core'\n\n/**\n * Injects a signal that tracks the number of queries that your application is loading or\n * fetching in the background.\n *\n * Can be used for app-wide loading indicators\n * @param filters - The filters to apply to the query.\n * @param injector - The Angular injector to use.\n * @returns signal with number of loading or fetching queries.\n * @public\n */\nexport function injectIsFetching(\n filters?: QueryFilters,\n injector?: Injector,\n): Signal<number> {\n return assertInjector(injectIsFetching, injector, () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n const cache = queryClient.getQueryCache()\n // isFetching is the prev value initialized on mount *\n let isFetching = queryClient.isFetching(filters)\n\n const result = signal(isFetching)\n\n const unsubscribe = ngZone.runOutsideAngular(() =>\n cache.subscribe(\n notifyManager.batchCalls(() => {\n const newIsFetching = queryClient.isFetching(filters)\n if (isFetching !== newIsFetching) {\n // * and update with each change\n isFetching = newIsFetching\n ngZone.run(() => {\n result.set(isFetching)\n })\n }\n }),\n ),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n return result\n })\n}\n","import { DestroyRef, NgZone, inject, signal } from '@angular/core'\nimport { QueryClient, notifyManager } from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport type { MutationFilters } from '@tanstack/query-core'\nimport type { Injector, Signal } from '@angular/core'\n\n/**\n * Injects a signal that tracks the number of mutations that your application is fetching.\n *\n * Can be used for app-wide loading indicators\n * @param filters - The filters to apply to the query.\n * @param injector - The Angular injector to use.\n * @returns signal with number of fetching mutations.\n * @public\n */\nexport function injectIsMutating(\n filters?: MutationFilters,\n injector?: Injector,\n): Signal<number> {\n return assertInjector(injectIsMutating, injector, () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n const cache = queryClient.getMutationCache()\n // isMutating is the prev value initialized on mount *\n let isMutating = queryClient.isMutating(filters)\n\n const result = signal(isMutating)\n\n const unsubscribe = ngZone.runOutsideAngular(() =>\n cache.subscribe(\n notifyManager.batchCalls(() => {\n const newIsMutating = queryClient.isMutating(filters)\n if (isMutating !== newIsMutating) {\n // * and update with each change\n isMutating = newIsMutating\n ngZone.run(() => {\n result.set(isMutating)\n })\n }\n }),\n ),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n return result\n })\n}\n","import {\n DestroyRef,\n Injector,\n NgZone,\n computed,\n effect,\n inject,\n runInInjectionContext,\n signal,\n} from '@angular/core'\nimport {\n MutationObserver,\n QueryClient,\n notifyManager,\n} from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport { signalProxy } from './signal-proxy'\nimport { noop, shouldThrowError } from './util'\n\nimport { lazyInit } from './util/lazy-init/lazy-init'\nimport type { DefaultError, MutationObserverResult } from '@tanstack/query-core'\nimport type { CreateMutateFunction, CreateMutationResult } from './types'\nimport type { CreateMutationOptions } from './mutation-options'\n\n/**\n * Injects a mutation: an imperative function that can be invoked which typically performs server side effects.\n *\n * Unlike queries, mutations are not run automatically.\n * @param optionsFn - A function that returns mutation options.\n * @param injector - The Angular injector to use.\n * @returns The mutation.\n * @public\n */\nexport function injectMutation<\n TData = unknown,\n TError = DefaultError,\n TVariables = void,\n TContext = unknown,\n>(\n optionsFn: () => CreateMutationOptions<TData, TError, TVariables, TContext>,\n injector?: Injector,\n): CreateMutationResult<TData, TError, TVariables, TContext> {\n return assertInjector(injectMutation, injector, () => {\n const currentInjector = inject(Injector)\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n return lazyInit(() =>\n runInInjectionContext(currentInjector, () => {\n const observer = new MutationObserver<\n TData,\n TError,\n TVariables,\n TContext\n >(queryClient, optionsFn())\n const mutate: CreateMutateFunction<\n TData,\n TError,\n TVariables,\n TContext\n > = (variables, mutateOptions) => {\n observer.mutate(variables, mutateOptions).catch(noop)\n }\n\n effect(() => {\n observer.setOptions(\n runInInjectionContext(currentInjector, () => optionsFn()),\n )\n })\n\n const result = signal(observer.getCurrentResult())\n\n const unsubscribe = ngZone.runOutsideAngular(() =>\n observer.subscribe(\n notifyManager.batchCalls(\n (\n state: MutationObserverResult<\n TData,\n TError,\n TVariables,\n TContext\n >,\n ) => {\n ngZone.run(() => {\n if (\n state.isError &&\n shouldThrowError(observer.options.throwOnError, [\n state.error,\n ])\n ) {\n throw state.error\n }\n result.set(state)\n })\n },\n ),\n ),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n const resultSignal = computed(() => ({\n ...result(),\n mutate,\n mutateAsync: result().mutate,\n }))\n\n return signalProxy(resultSignal) as unknown as CreateMutationResult<\n TData,\n TError,\n TVariables,\n TContext\n >\n }),\n )\n })\n}\n","import {\n DestroyRef,\n NgZone,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport {\n QueryClient,\n notifyManager,\n replaceEqualDeep,\n} from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport { lazySignalInitializer } from './util/lazy-signal-initializer/lazy-signal-initializer'\nimport type { Injector, Signal } from '@angular/core'\nimport type {\n Mutation,\n MutationCache,\n MutationFilters,\n MutationState,\n} from '@tanstack/query-core'\n\ntype MutationStateOptions<TResult = MutationState> = {\n filters?: MutationFilters\n select?: (mutation: Mutation) => TResult\n}\n\nfunction getResult<TResult = MutationState>(\n mutationCache: MutationCache,\n options: MutationStateOptions<TResult>,\n): Array<TResult> {\n return mutationCache\n .findAll(options.filters)\n .map(\n (mutation): TResult =>\n (options.select ? options.select(mutation) : mutation.state) as TResult,\n )\n}\n\n/**\n * @public\n */\nexport interface InjectMutationStateOptions {\n injector?: Injector\n}\n\n/**\n * Injects a signal that tracks the state of all mutations.\n * @param mutationStateOptionsFn - A function that returns mutation state options.\n * @param options - The Angular injector to use.\n * @returns The signal that tracks the state of all mutations.\n * @public\n */\nexport function injectMutationState<TResult = MutationState>(\n mutationStateOptionsFn: () => MutationStateOptions<TResult> = () => ({}),\n options?: InjectMutationStateOptions,\n): Signal<Array<TResult>> {\n return assertInjector(injectMutationState, options?.injector, () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n const mutationCache = queryClient.getMutationCache()\n\n return lazySignalInitializer((injector) => {\n const result = signal<Array<TResult>>(\n getResult(mutationCache, mutationStateOptionsFn()),\n )\n\n effect(\n () => {\n const mutationStateOptions = mutationStateOptionsFn()\n untracked(() => {\n // Setting the signal from an effect because it's both 'computed' from options()\n // and needs to be set imperatively in the mutationCache listener.\n result.set(getResult(mutationCache, mutationStateOptions))\n })\n },\n { injector },\n )\n\n const unsubscribe = ngZone.runOutsideAngular(() =>\n mutationCache.subscribe(\n notifyManager.batchCalls(() => {\n const nextResult = replaceEqualDeep(\n result(),\n getResult(mutationCache, mutationStateOptionsFn()),\n )\n if (result() !== nextResult) {\n ngZone.run(() => {\n result.set(nextResult)\n })\n }\n }),\n ),\n )\n\n destroyRef.onDestroy(unsubscribe)\n\n return result\n })\n })\n}\n","import { Injector, computed, inject, untracked } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\ntype SignalInitializerFn<T> = (injector: Injector) => Signal<T>\n\nexport function lazySignalInitializer<T>(\n initializerFn: SignalInitializerFn<T>,\n) {\n const injector = inject(Injector)\n\n let source: Signal<T> | null = null\n\n const unwrapSignal = () => {\n if (!source) {\n source = untracked(() => initializerFn(injector))\n }\n return source()\n }\n\n queueMicrotask(() => unwrapSignal())\n\n return computed(unwrapSignal)\n}\n","import {\n QueriesObserver,\n QueryClient,\n notifyManager,\n} from '@tanstack/query-core'\nimport {\n DestroyRef,\n NgZone,\n computed,\n effect,\n inject,\n signal,\n} from '@angular/core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport type { Injector, Signal } from '@angular/core'\nimport type {\n DefaultError,\n OmitKeyof,\n QueriesObserverOptions,\n QueriesPlaceholderDataFunction,\n QueryFunction,\n QueryKey,\n QueryObserverOptions,\n QueryObserverResult,\n ThrowOnError,\n} from '@tanstack/query-core'\n\n// This defines the `CreateQueryOptions` that are accepted in `QueriesOptions` & `GetOptions`.\n// `placeholderData` function does not have a parameter\ntype QueryObserverOptionsForCreateQueries<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n> = OmitKeyof<\n QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>,\n 'placeholderData'\n> & {\n placeholderData?: TQueryFnData | QueriesPlaceholderDataFunction<TQueryFnData>\n}\n\n// Avoid TS depth-limit error in case of large array literal\ntype MAXIMUM_DEPTH = 20\n\n// Widen the type of the symbol to enable type inference even if skipToken is not immutable.\ntype SkipTokenForUseQueries = symbol\n\ntype GetOptions<T> =\n // Part 1: responsible for applying explicit type parameter to function arguments, if object { queryFnData: TQueryFnData, error: TError, data: TData }\n T extends {\n queryFnData: infer TQueryFnData\n error?: infer TError\n data: infer TData\n }\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? QueryObserverOptionsForCreateQueries<unknown, TError, TData>\n : // Part 2: responsible for applying explicit type parameter to function arguments, if tuple [TQueryFnData, TError, TData]\n T extends [infer TQueryFnData, infer TError, infer TData]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError, TData>\n : T extends [infer TQueryFnData, infer TError]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? QueryObserverOptionsForCreateQueries<TQueryFnData>\n : // Part 3: responsible for inferring and enforcing type if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, infer TQueryKey>\n | SkipTokenForUseQueries\n select: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? QueryObserverOptionsForCreateQueries<\n TQueryFnData,\n unknown extends TError ? DefaultError : TError,\n unknown extends TData ? TQueryFnData : TData,\n TQueryKey\n >\n : // Fallback\n QueryObserverOptionsForCreateQueries\n\ntype GetResults<T> =\n // Part 1: responsible for mapping explicit type parameter to function result, if object\n T extends { queryFnData: any; error?: infer TError; data: infer TData }\n ? QueryObserverResult<TData, TError>\n : T extends { queryFnData: infer TQueryFnData; error?: infer TError }\n ? QueryObserverResult<TQueryFnData, TError>\n : T extends { data: infer TData; error?: infer TError }\n ? QueryObserverResult<TData, TError>\n : // Part 2: responsible for mapping explicit type parameter to function result, if tuple\n T extends [any, infer TError, infer TData]\n ? QueryObserverResult<TData, TError>\n : T extends [infer TQueryFnData, infer TError]\n ? QueryObserverResult<TQueryFnData, TError>\n : T extends [infer TQueryFnData]\n ? QueryObserverResult<TQueryFnData>\n : // Part 3: responsible for mapping inferred type to results, if no explicit parameter was provided\n T extends {\n queryFn?:\n | QueryFunction<infer TQueryFnData, any>\n | SkipTokenForUseQueries\n select: (data: any) => infer TData\n throwOnError?: ThrowOnError<any, infer TError, any, any>\n }\n ? QueryObserverResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n : // Fallback\n QueryObserverResult\n\n/**\n * QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param\n * @public\n */\nexport type QueriesOptions<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverOptionsForCreateQueries>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetOptions<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesOptions<\n [...Tail],\n [...TResult, GetOptions<Head>],\n [...TDepth, 1]\n >\n : ReadonlyArray<unknown> extends T\n ? T\n : // If T is *some* array but we couldn't assign unknown[] to it, then it must hold some known/homogenous type!\n // use this to infer the param types in the case of Array.map() argument\n T extends Array<\n QueryObserverOptionsForCreateQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n infer TQueryKey\n >\n >\n ? Array<\n QueryObserverOptionsForCreateQueries<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >\n >\n : // Fallback\n Array<QueryObserverOptionsForCreateQueries>\n\n/**\n * QueriesResults reducer recursively maps type param to results\n * @public\n */\nexport type QueriesResults<\n T extends Array<any>,\n TResult extends Array<any> = [],\n TDepth extends ReadonlyArray<number> = [],\n> = TDepth['length'] extends MAXIMUM_DEPTH\n ? Array<QueryObserverResult>\n : T extends []\n ? []\n : T extends [infer Head]\n ? [...TResult, GetResults<Head>]\n : T extends [infer Head, ...infer Tail]\n ? QueriesResults<\n [...Tail],\n [...TResult, GetResults<Head>],\n [...TDepth, 1]\n >\n : T extends Array<\n QueryObserverOptionsForCreateQueries<\n infer TQueryFnData,\n infer TError,\n infer TData,\n any\n >\n >\n ? // Dynamic-size (homogenous) CreateQueryOptions array: map directly to array of results\n Array<\n QueryObserverResult<\n unknown extends TData ? TQueryFnData : TData,\n unknown extends TError ? DefaultError : TError\n >\n >\n : // Fallback\n Array<QueryObserverResult>\n\n/**\n * @public\n */\nexport function injectQueries<\n T extends Array<any>,\n TCombinedResult = QueriesResults<T>,\n>(\n {\n queries,\n ...options\n }: {\n queries: Signal<[...QueriesOptions<T>]>\n combine?: (result: QueriesResults<T>) => TCombinedResult\n },\n injector?: Injector,\n): Signal<TCombinedResult> {\n return assertInjector(injectQueries, injector, () => {\n const destroyRef = inject(DestroyRef)\n const ngZone = inject(NgZone)\n const queryClient = inject(QueryClient)\n\n const defaultedQueries = computed(() => {\n return queries().map((opts) => {\n const defaultedOptions = queryClient.defaultQueryOptions(opts)\n // Make sure the results are already in fetching state before subscribing or updating options\n defaultedOptions._optimisticResults = 'optimistic'\n\n return defaultedOptions as QueryObserverOptions\n })\n })\n\n const observer = new QueriesObserver<TCombinedResult>(\n queryClient,\n defaultedQueries(),\n options as QueriesObserverOptions<TCombinedResult>,\n )\n\n // Do not notify on updates because of changes in the options because\n // these changes should already be reflected in the optimistic result.\n effect(() => {\n observer.setQueries(\n defaultedQueries(),\n options as QueriesObserverOptions<TCombinedResult>,\n { listeners: false },\n )\n })\n\n const [, getCombinedResult] = observer.getOptimisticResult(\n defaultedQueries(),\n (options as QueriesObserverOptions<TCombinedResult>).combine,\n )\n\n const result = signal(getCombinedResult() as any)\n\n const unsubscribe = ngZone.runOutsideAngular(() =>\n observer.subscribe(notifyManager.batchCalls(result.set)),\n )\n destroyRef.onDestroy(unsubscribe)\n\n return result\n })\n}\n","import { QueryObserver } from '@tanstack/query-core'\nimport { assertInjector } from './util/assert-injector/assert-injector'\nimport { createBaseQuery } from './create-base-query'\nimport type { Injector } from '@angular/core'\nimport type { DefaultError, QueryKey } from '@tanstack/query-core'\nimport type {\n CreateQueryOptions,\n CreateQueryResult,\n DefinedCreateQueryResult,\n} from './types'\nimport type {\n DefinedInitialDataOptions,\n UndefinedInitialDataOptions,\n} from './query-options'\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param optionsFn - A function that returns query options.\n * @param injector - The Angular injector to use.\n * @returns The query result.\n * @public\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => DefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n injector?: Injector,\n): DefinedCreateQueryResult<TData, TError>\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param optionsFn - A function that returns query options.\n * @param injector - The Angular injector to use.\n * @returns The query result.\n * @public\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => UndefinedInitialDataOptions<\n TQueryFnData,\n TError,\n TData,\n TQueryKey\n >,\n injector?: Injector,\n): CreateQueryResult<TData, TError>\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param optionsFn - A function that returns query options.\n * @param injector - The Angular injector to use.\n * @returns The query result.\n * @public\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery<\n TQueryFnData = unknown,\n TError = DefaultError,\n TData = TQueryFnData,\n TQueryKey extends QueryKey = QueryKey,\n>(\n optionsFn: () => CreateQueryOptions<TQueryFnData, TError, TData, TQueryKey>,\n injector?: Injector,\n): CreateQueryResult<TData, TError>\n\n/**\n * Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key.\n *\n * **Basic example**\n * ```ts\n * class ServiceOrComponent {\n * query = injectQuery(() => ({\n * queryKey: ['repoData'],\n * queryFn: () =>\n * this.#http.get<Response>('https://api.github.com/repos/tanstack/query'),\n * }))\n * }\n * ```\n *\n * Similar to `computed` from Angular, the function passed to `injectQuery` will be run in the reactive context.\n * In the example below, the query will be automatically enabled and executed when the filter signal changes\n * to a truthy value. When the filter signal changes back to a falsy value, the query will be disabled.\n *\n * **Reactive example**\n * ```ts\n * class ServiceOrComponent {\n * filter = signal('')\n *\n * todosQuery = injectQuery(() => ({\n * queryKey: ['todos', this.filter()],\n * queryFn: () => fetchTodos(this.filter()),\n * // Signals can be combined with expressions\n * enabled: !!this.filter(),\n * }))\n * }\n * ```\n * @param optionsFn - A function that returns query options.\n * @param injector - The Angular injector to use.\n * @returns The query result.\n * @public\n * @see https://tanstack.com/query/latest/docs/framework/angular/guides/queries\n */\nexport function injectQuery(\n optionsFn: () => CreateQueryOptions,\n injector?: Injector,\n) {\n return assertInjector(injectQuery, injector, () =>\n createBaseQuery(optionsFn, QueryObserver),\n )\n}\n","import { Injector, inject } from '@angular/core'\nimport { QueryClient } from '@tanstack/query-core'\nimport type { InjectOptions } from '@angular/core'\n\n/**\n * Injects a `QueryClient` instance and allows passing a custom injector.\n *\n * You can also use `inject(QueryClient)` if you don't need to provide a custom injector.\n *\n * **Example**\n * ```ts\n * const queryClient = injectQueryClient();\n * ```\n * @param injectOptions - Type of the options argument to inject and optionally a custom injector.\n * @returns The `QueryClient` instance.\n * @public\n */\nexport function injectQueryClient(\n injectOptions: InjectOptions & { injector?: Injector } = {},\n) {\n return (injectOptions.injector ?? inject(Injector)).get(QueryClient)\n}\n","import {\n DestroyRef,\n ENVIRONMENT_INITIALIZER,\n Injector,\n PLATFORM_ID,\n computed,\n effect,\n inject,\n makeEnvironmentProviders,\n runInInjectionContext,\n} from '@angular/core'\nimport { QueryClient, onlineManager } from '@tanstack/query-core'\nimport { isPlatformBrowser } from '@angular/common'\nimport { isDevMode } from './util/is-dev-mode/is-dev-mode'\nimport { noop } from './util'\nimport type { EnvironmentProviders, Provider } from '@angular/core'\nimport type {\n DevtoolsButtonPosition,\n DevtoolsErrorType,\n DevtoolsPosition,\n TanstackQueryDevtools,\n} from '@tanstack/query-devtools'\n\n/**\n * Usually {@link provideTanStackQuery} is used once to set up TanStack Query and the\n * {@link https://tanstack.com/query/latest/docs/reference/QueryClient|QueryClient}\n * for the entire application. You can use `provideQueryClient` to provide a\n * different `QueryClient` instance for a part of the application.\n * @param queryClient - the `QueryClient` instance to provide.\n * @public\n */\nexport function provideQueryClient(queryClient: QueryClient) {\n return { provide: QueryClient, useValue: queryClient }\n}\n\n/**\n * Sets up providers necessary to enable TanStack Query functionality for Angular applications.\n *\n * Allows to configure a `QueryClient` and optional features such as developer tools.\n *\n * **Example - standalone**\n *\n * ```ts\n * import {\n * provideTanStackQuery,\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * bootstrapApplication(AppComponent, {\n * providers: [provideTanStackQuery(new QueryClient())],\n * })\n * ```\n *\n * **Example - NgModule-based**\n *\n * ```ts\n * import {\n * provideTanStackQuery,\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * @NgModule({\n * declarations: [AppComponent],\n * imports: [BrowserModule],\n * providers: [provideTanStackQuery(new QueryClient())],\n * bootstrap: [AppComponent],\n * })\n * export class AppModule {}\n * ```\n *\n * You can also enable optional developer tools by adding `withDevtools`. By\n * default the tools will then be loaded when your app is in development mode.\n * ```ts\n * import {\n * provideTanStackQuery,\n * withDevtools\n * QueryClient,\n * } from '@tanstack/angular-query-experimental'\n *\n * bootstrapApplication(AppComponent,\n * {\n * providers: [\n * provideTanStackQuery(new QueryClient(), withDevtools())\n * ]\n * }\n * )\n * ```\n * @param queryClient - A `QueryClient` instance.\n * @param features - Optional features to configure additional Query functionality.\n * @returns A set of providers to set up TanStack Query.\n * @public\n * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start\n * @see withDevtools\n */\nexport function provideTanStackQuery(\n queryClient: QueryClient,\n ...features: Array<QueryFeatures>\n): EnvironmentProviders {\n return makeEnvironmentProviders([\n provideQueryClient(queryClient),\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useValue: () => {\n queryClient.mount()\n // Unmount the query client on application destroy\n inject(DestroyRef).onDestroy(() => queryClient.unmount())\n },\n },\n features.map((feature) => feature.ɵproviders),\n ])\n}\n\n/**\n * Sets up providers necessary to enable TanStack Query functionality for Angular applications.\n *\n * Allows to configure a `QueryClient`.\n * @param queryClient - A `QueryClient` instance.\n * @returns A set of providers to set up TanStack Query.\n * @public\n * @see https://tanstack.com/query/v5/docs/framework/angular/quick-start\n * @deprecated Use `provideTanStackQuery` instead.\n */\nexport function provideAngularQuery(\n queryClient: QueryClient,\n): EnvironmentProviders {\n return provideTanStackQuery(queryClient)\n}\n\n/**\n * Helper type to represent a Query feature.\n */\nexport interface QueryFeature<TFeatureKind extends QueryFeatureKind> {\n ɵkind: TFeatureKind\n ɵproviders: Array<Provider>\n}\n\n/**\n * Helper function to create an object that represents a Query feature.\n * @param kind -\n * @param providers -\n * @returns A Query feature.\n */\nfunction queryFeature<TFeatureKind extends QueryFeatureKind>(\n kind: TFeatureKind,\n providers: Array<Provider>,\n): QueryFeature<TFeatureKind> {\n return { ɵkind: kind, ɵproviders: providers }\n}\n\n/**\n * A type alias that represents a feature which enables developer tools.\n * The type is used to describe the return value of the `withDevtools` function.\n * @public\n * @see {@link withDevtools}\n */\nexport type DeveloperToolsFeature = QueryFeature<'DeveloperTools'>\n\n/**\n * Options for configuring the TanStack Query devtools.\n * @public\n */\nexport interface DevtoolsOptions {\n /**\n * Set this true if you want the devtools to default to being open\n */\n initialIsOpen?: boolean\n /**\n * The position of the TanStack logo to open and close the devtools panel.\n * `top-left` | `top-right` | `bottom-left` | `bottom-right` | `relative`\n * Defaults to `bottom-right`.\n */\n buttonPosition?: DevtoolsButtonPosition\n /**\n * The position of the TanStack Query devtools panel.\n * `top` | `bottom` | `left` | `right`\n * Defaults to `bottom`.\n */\n position?: DevtoolsPosition\n /**\n * Custom instance of QueryClient\n */\n client?: QueryClient\n /**\n * Use this so you can define custom errors that can be shown in the devtools.\n */\n errorTypes?: Array<DevtoolsErrorType>\n /**\n * Use this to pass a nonce to the style tag that is added to the document head. This is useful if you are using a Content Security Policy (CSP) nonce to allow inline styles.\n */\n styleNonce?: string\n /**\n * Use this so you can attach the devtool's styles to a specific element in the DOM.\n */\n shadowDOMTarget?: ShadowRoot\n\n /**\n * Whether the developer tools should load.\n * - `auto`- (Default) Lazily loads devtools when in development mode. Skips loading in production mode.\n * - `true`- Always load the devtools, regardless of the environment.\n * - `false`- Never load the devtools, regardless of the environment.\n *\n * You can use `true` and `false` to override loading developer tools from an environment file.\n * For example, a test environment might run in production mode but you may want to load developer tools.\n *\n * Additionally, you can use a signal in the callback to dynamically load the devtools based on a condition. For example,\n * a signal created from a RxJS observable that listens for a keyboard shortcut.\n *\n * **Example**\n * ```ts\n * withDevtools(() => ({\n * initialIsOpen: true,\n * loadDevtools: inject(ExampleService).loadDevtools()\n * }))\n * ```\n */\n loadDevtools?: 'auto' | boolean\n}\n\n/**\n * Enables developer tools.\n *\n * **Example**\n *\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideTanStackQuery(new QueryClient(), withDevtools())\n * ]\n * }\n * ```\n * By default the devtools will be loaded when Angular runs in development mode and rendered in `<body>`.\n *\n * If you need more control over when devtools are loaded, you can use the `loadDevtools` option. This is particularly useful if you want to load devtools based on environment configurations. For instance, you might have a test environment running in production mode but still require devtools to be available.\n *\n * If you need more control over where devtools are rendered, consider `injectDevtoolsPanel`. This allows rendering devtools inside your own devtools for example.\n * @param optionsFn - A function that returns `DevtoolsOptions`.\n * @returns A set of providers for use with `provideTanStackQuery`.\n * @public\n * @see {@link provideTanStackQuery}\n * @see {@link DevtoolsOptions}\n */\nexport function withDevtools(\n optionsFn?: () => DevtoolsOptions,\n): DeveloperToolsFeature {\n let providers: Array<Provider> = []\n if (!isDevMode() && !optionsFn) {\n providers = []\n } else {\n providers = [\n {\n provide: ENVIRONMENT_INITIALIZER,\n multi: true,\n useFactory: () => {\n if (!isPlatformBrowser(inject(PLATFORM_ID))) return noop\n const injector = inject(Injector)\n const options = computed(() =>\n runInInjectionContext(injector, () => optionsFn?.() ?? {}),\n )\n\n let devtools: TanstackQueryDevtools | null = null\n let el: HTMLElement | null = null\n\n const shouldLoadToolsSignal = computed(() => {\n const { loadDevtools } = options()\n return typeof loadDevtools === 'boolean'\n ? loadDevtools\n : isDevMode()\n })\n\n const destroyRef = inject(DestroyRef)\n\n const getResolvedQueryClient = () => {\n const injectedClient = injector.get(QueryClient, null)\n const client = options().client ?? injectedClient\n if (!client) {\n throw new Error('No QueryClient found')\n }\n return client\n }\n\n const destroyDevtools = () => {\n devtools?.unmount()\n el?.remove()\n devtools = null\n }\n\n return () =>\n effect(() => {\n const shouldLoadTools = shouldLoadToolsSignal()\n const {\n client,\n position,\n errorTypes,\n buttonPosition,\n initialIsOpen,\n } = options()\n\n if (devtools && !shouldLoadTools) {\n destroyDevtools()\n return\n } else if (devtools && shouldLoadTools) {\n client && devtools.setClient(client)\n position && devtools.setPosition(position)\n errorTypes && devtools.setErrorTypes(errorTypes)\n buttonPosition && devtools.setButtonPosition(buttonPosition)\n initialIsOpen && devtools.setInitialIsOpen(initialIsOpen)\n return\n } else if (!shouldLoadTools) {\n return\n }\n\n el = document.body.appendChild(document.createElement('div'))\n el.classList.add('tsqd-parent-container')\n\n import('@tanstack/query-devtools').then((queryDevtools) =>\n runInInjectionContext(injector, () => {\n devtools = new queryDevtools.TanstackQueryDevtools({\n ...options(),\n client: getResolvedQueryClient(),\n queryFlavor: 'Angular Query',\n version: '5',\n onlineManager,\n })\n\n el && devtools.mount(el)\n\n // Unmount the devtools on application destroy\n destroyRef.onDestroy(destroyDevtools)\n }),\n )\n })\n },\n },\n ]\n }\n return queryFeature('DeveloperTools', providers)\n}\n\n/**\n * A type alias that represents all Query features available for use with `provideTanStackQuery`.\n * Features can be enabled by adding special functions to the `provideTanStackQuery` call.\n * See documentation for each symbol to find corresponding function name. See also `provideTanStackQuery`\n * documentation on how to use those functions.\n * @public\n * @see {@link provideTanStackQuery}\n */\nexport type QueryFeatures = DeveloperToolsFeature // Union type of features but just one now\n\nexport const queryFeatures = ['DeveloperTools'] as const\n\nexport type QueryFeatureKind = (typeof queryFeatures)[number]\n","// Re-export for mocking in tests\n\nexport { isDevMode } from '@angular/core'\n"],"mappings":";AAGA,cAAc;;;ACuHP,SAAS,aAAa,SAAkB;AAC7C,SAAO;AACT;;;ACvFO,SAAS,gBAMd,SAC4D;AAC5D,SAAO;AACT;;;AC4EO,SAAS,qBAAqB,SAAkB;AACrD,SAAO;AACT;;;AC5HA,SAAS,6BAA6B;;;ACAtC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAAC;AAAA,OACK;AACP,SAAS,aAAa,qBAAqB;;;ACX3C,SAAS,UAAU,iBAAiB;AAa7B,SAAS,YACd,aACA;AACA,QAAM,gBAAgB,CAAC;AAEvB,SAAO,IAAI,MAA4B,eAAe;AAAA,IACpD,I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jD,GAAG,QAAQ;AAAA,kBACX,QAAQ,uBAAuB;AAAA,kBAC/B,aAAa;AAAA,kBACb,SAAS;AAAA,kBACT;AAAA,gBACF,CAAC;AAED,sBAAM,SAAS,MAAM,EAAE;AAGvB,2BAAW,UAAU,eAAe;AAAA,cACtC,CAAC;AAAA,YACH;AAAA,UACF,CAAC;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACA,SAAO,aAAa,kBAAkB,SAAS;AACjD;AAYO,IAAM,gBAAgB,CAAC,gBAAgB;","names":["computed","untracked","untracked","computed","untracked","Injector","inject","runInInjectionContext","DestroyRef","NgZone","inject","signal","QueryClient","notifyManager","inject","DestroyRef","NgZone","QueryClient","signal","notifyManager","DestroyRef","NgZone","inject","signal","QueryClient","notifyManager","inject","DestroyRef","NgZone","QueryClient","signal","notifyManager","DestroyRef","Injector","NgZone","computed","effect","inject","runInInjectionContext","signal","QueryClient","notifyManager","inject","Injector","DestroyRef","NgZone","QueryClient","runInInjectionContext","effect","signal","notifyManager","computed","DestroyRef","NgZone","effect","inject","signal","untracked","QueryClient","notifyManager","Injector","computed","inject","untracked","inject","DestroyRef","NgZone","QueryClient","signal","effect","untracked","notifyManager","QueryClient","notifyManager","DestroyRef","NgZone","computed","effect","inject","signal","inject","DestroyRef","NgZone","QueryClient","computed","effect","signal","notifyManager","Injector","inject","QueryClient","DestroyRef","Injector","computed","effect","inject","runInInjectionContext","QueryClient","QueryClient","inject","DestroyRef","Injector","computed","runInInjectionContext","effect"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/angular-query-experimental",
3
- "version": "5.61.1",
3
+ "version": "5.61.2",
4
4
  "description": "Signals for managing, caching and syncing asynchronous and remote data in Angular",
5
5
  "author": "Arnoud de Vries",
6
6
  "license": "MIT",
@@ -88,23 +88,27 @@ export function createBaseQuery<
88
88
  )
89
89
 
90
90
  // observer.trackResult is not used as this optimization is not needed for Angular
91
- const unsubscribe = observer.subscribe(
92
- notifyManager.batchCalls((state: QueryObserverResult<TData, TError>) => {
93
- ngZone.run(() => {
94
- if (
95
- state.isError &&
96
- !state.isFetching &&
97
- // !isRestoring() && // todo: enable when client persistence is implemented
98
- shouldThrowError(observer.options.throwOnError, [
99
- state.error,
100
- observer.getCurrentQuery(),
101
- ])
102
- ) {
103
- throw state.error
104
- }
105
- resultSignal.set(state)
106
- })
107
- }),
91
+ const unsubscribe = ngZone.runOutsideAngular(() =>
92
+ observer.subscribe(
93
+ notifyManager.batchCalls(
94
+ (state: QueryObserverResult<TData, TError>) => {
95
+ ngZone.run(() => {
96
+ if (
97
+ state.isError &&
98
+ !state.isFetching &&
99
+ // !isRestoring() && // todo: enable when client persistence is implemented
100
+ shouldThrowError(observer.options.throwOnError, [
101
+ state.error,
102
+ observer.getCurrentQuery(),
103
+ ])
104
+ ) {
105
+ throw state.error
106
+ }
107
+ resultSignal.set(state)
108
+ })
109
+ },
110
+ ),
111
+ ),
108
112
  )
109
113
  destroyRef.onDestroy(unsubscribe)
110
114
 
@@ -29,17 +29,19 @@ export function injectIsFetching(
29
29
 
30
30
  const result = signal(isFetching)
31
31
 
32
- const unsubscribe = cache.subscribe(
33
- notifyManager.batchCalls(() => {
34
- const newIsFetching = queryClient.isFetching(filters)
35
- if (isFetching !== newIsFetching) {
36
- // * and update with each change
37
- isFetching = newIsFetching
38
- ngZone.run(() => {
39
- result.set(isFetching)
40
- })
41
- }
42
- }),
32
+ const unsubscribe = ngZone.runOutsideAngular(() =>
33
+ cache.subscribe(
34
+ notifyManager.batchCalls(() => {
35
+ const newIsFetching = queryClient.isFetching(filters)
36
+ if (isFetching !== newIsFetching) {
37
+ // * and update with each change
38
+ isFetching = newIsFetching
39
+ ngZone.run(() => {
40
+ result.set(isFetching)
41
+ })
42
+ }
43
+ }),
44
+ ),
43
45
  )
44
46
 
45
47
  destroyRef.onDestroy(unsubscribe)
@@ -28,17 +28,19 @@ export function injectIsMutating(
28
28
 
29
29
  const result = signal(isMutating)
30
30
 
31
- const unsubscribe = cache.subscribe(
32
- notifyManager.batchCalls(() => {
33
- const newIsMutating = queryClient.isMutating(filters)
34
- if (isMutating !== newIsMutating) {
35
- // * and update with each change
36
- isMutating = newIsMutating
37
- ngZone.run(() => {
38
- result.set(isMutating)
39
- })
40
- }
41
- }),
31
+ const unsubscribe = ngZone.runOutsideAngular(() =>
32
+ cache.subscribe(
33
+ notifyManager.batchCalls(() => {
34
+ const newIsMutating = queryClient.isMutating(filters)
35
+ if (isMutating !== newIsMutating) {
36
+ // * and update with each change
37
+ isMutating = newIsMutating
38
+ ngZone.run(() => {
39
+ result.set(isMutating)
40
+ })
41
+ }
42
+ }),
43
+ ),
42
44
  )
43
45
 
44
46
  destroyRef.onDestroy(unsubscribe)
@@ -80,18 +80,20 @@ export function injectMutationState<TResult = MutationState>(
80
80
  { injector },
81
81
  )
82
82
 
83
- const unsubscribe = mutationCache.subscribe(
84
- notifyManager.batchCalls(() => {
85
- const nextResult = replaceEqualDeep(
86
- result(),
87
- getResult(mutationCache, mutationStateOptionsFn()),
88
- )
89
- if (result() !== nextResult) {
90
- ngZone.run(() => {
91
- result.set(nextResult)
92
- })
93
- }
94
- }),
83
+ const unsubscribe = ngZone.runOutsideAngular(() =>
84
+ mutationCache.subscribe(
85
+ notifyManager.batchCalls(() => {
86
+ const nextResult = replaceEqualDeep(
87
+ result(),
88
+ getResult(mutationCache, mutationStateOptionsFn()),
89
+ )
90
+ if (result() !== nextResult) {
91
+ ngZone.run(() => {
92
+ result.set(nextResult)
93
+ })
94
+ }
95
+ }),
96
+ ),
95
97
  )
96
98
 
97
99
  destroyRef.onDestroy(unsubscribe)
@@ -71,26 +71,30 @@ export function injectMutation<
71
71
 
72
72
  const result = signal(observer.getCurrentResult())
73
73
 
74
- const unsubscribe = observer.subscribe(
75
- notifyManager.batchCalls(
76
- (
77
- state: MutationObserverResult<
78
- TData,
79
- TError,
80
- TVariables,
81
- TContext
82
- >,
83
- ) => {
84
- ngZone.run(() => {
85
- if (
86
- state.isError &&
87
- shouldThrowError(observer.options.throwOnError, [state.error])
88
- ) {
89
- throw state.error
90
- }
91
- result.set(state)
92
- })
93
- },
74
+ const unsubscribe = ngZone.runOutsideAngular(() =>
75
+ observer.subscribe(
76
+ notifyManager.batchCalls(
77
+ (
78
+ state: MutationObserverResult<
79
+ TData,
80
+ TError,
81
+ TVariables,
82
+ TContext
83
+ >,
84
+ ) => {
85
+ ngZone.run(() => {
86
+ if (
87
+ state.isError &&
88
+ shouldThrowError(observer.options.throwOnError, [
89
+ state.error,
90
+ ])
91
+ ) {
92
+ throw state.error
93
+ }
94
+ result.set(state)
95
+ })
96
+ },
97
+ ),
94
98
  ),
95
99
  )
96
100
 
@@ -3,7 +3,14 @@ import {
3
3
  QueryClient,
4
4
  notifyManager,
5
5
  } from '@tanstack/query-core'
6
- import { DestroyRef, computed, effect, inject, signal } from '@angular/core'
6
+ import {
7
+ DestroyRef,
8
+ NgZone,
9
+ computed,
10
+ effect,
11
+ inject,
12
+ signal,
13
+ } from '@angular/core'
7
14
  import { assertInjector } from './util/assert-injector/assert-injector'
8
15
  import type { Injector, Signal } from '@angular/core'
9
16
  import type {
@@ -202,8 +209,9 @@ export function injectQueries<
202
209
  injector?: Injector,
203
210
  ): Signal<TCombinedResult> {
204
211
  return assertInjector(injectQueries, injector, () => {
205
- const queryClient = inject(QueryClient)
206
212
  const destroyRef = inject(DestroyRef)
213
+ const ngZone = inject(NgZone)
214
+ const queryClient = inject(QueryClient)
207
215
 
208
216
  const defaultedQueries = computed(() => {
209
217
  return queries().map((opts) => {
@@ -238,7 +246,9 @@ export function injectQueries<
238
246
 
239
247
  const result = signal(getCombinedResult() as any)
240
248
 
241
- const unsubscribe = observer.subscribe(notifyManager.batchCalls(result.set))
249
+ const unsubscribe = ngZone.runOutsideAngular(() =>
250
+ observer.subscribe(notifyManager.batchCalls(result.set)),
251
+ )
242
252
  destroyRef.onDestroy(unsubscribe)
243
253
 
244
254
  return result