ngx-signal-query 1.5.1-dev.1 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ngx-signal-query.mjs +102 -65
- package/fesm2022/ngx-signal-query.mjs.map +1 -1
- package/index.d.ts +10 -4
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { inject, PLATFORM_ID, signal, Injectable, InjectionToken, EnvironmentInjector, DestroyRef, untracked, runInInjectionContext, makeEnvironmentProviders, assertInInjectionContext, effect, computed, Injector } from '@angular/core';
|
|
3
3
|
import { isPlatformBrowser, DOCUMENT } from '@angular/common';
|
|
4
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
5
|
-
import { fromEvent, filter, defer, from, take, retry, timer, throwIfEmpty, map,
|
|
5
|
+
import { fromEvent, filter, Subscription, defer, isObservable, from, take, retry, timer, tap, throwIfEmpty, map, concatMap, catchError, of, endWith, concat, ignoreElements, EMPTY } from 'rxjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Whether the app runs in the browser rather than on the server. On the
|
|
@@ -259,9 +259,10 @@ function deferred() {
|
|
|
259
259
|
/**
|
|
260
260
|
* The error a promise of a query's data rejects with when the fetch stops
|
|
261
261
|
* with no data to give: it was cancelled before the query had any
|
|
262
|
-
* (`cancelQueries()`, or the last component showing the query went away
|
|
263
|
-
*
|
|
264
|
-
* didn't fail, so tell
|
|
262
|
+
* (`cancelQueries()`, or the last component showing the query went away
|
|
263
|
+
* during an `Observable` fetch), or the query was removed
|
|
264
|
+
* (`removeQueries()`, e.g. on sign-out). The request didn't fail, so tell
|
|
265
|
+
* the two apart with `instanceof CancelledError`.
|
|
265
266
|
*
|
|
266
267
|
* A mutation's `mutateAsync()` rejects with one too, when the mutation cache
|
|
267
268
|
* is cleared while its run is in flight.
|
|
@@ -311,14 +312,8 @@ class Query {
|
|
|
311
312
|
// field it reads during initialization (field init order).
|
|
312
313
|
// eslint-disable-next-line @typescript-eslint/member-ordering
|
|
313
314
|
state = this.#state.asReadonly();
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
// fetch shares, and how to settle it; null while nothing is in flight.
|
|
317
|
-
#outcome = null;
|
|
318
|
-
// The state the fetch in flight started from, or the last write made
|
|
319
|
-
// during it: stopping the fetch with nothing in its place goes back to it
|
|
320
|
-
// (see #stop). null while nothing is in flight.
|
|
321
|
-
#beforeFetch = null;
|
|
315
|
+
// The fetch in flight; null while nothing is.
|
|
316
|
+
#inFlight = null;
|
|
322
317
|
// The structuralSharing of the fetch whose response the query holds.
|
|
323
318
|
#fetchedStructuralSharing;
|
|
324
319
|
#observers = new Set();
|
|
@@ -353,10 +348,16 @@ class Query {
|
|
|
353
348
|
// the fetch or schedule gc while others still watch.
|
|
354
349
|
if (!this.#observers.delete(observer))
|
|
355
350
|
return;
|
|
356
|
-
// No observers left:
|
|
357
|
-
//
|
|
351
|
+
// No observers left: nobody waits for the fetch in flight any more. Stop
|
|
352
|
+
// it if that aborts its request; a request that runs on anyway is let
|
|
353
|
+
// land, so its response isn't thrown away, but nobody is left to want a
|
|
354
|
+
// failure tried again. Then schedule gc to dispose the query if no
|
|
355
|
+
// observer returns.
|
|
358
356
|
if (this.#observers.size === 0) {
|
|
359
|
-
this
|
|
357
|
+
if (this.#inFlight?.abortable)
|
|
358
|
+
this.cancel();
|
|
359
|
+
else if (this.#inFlight)
|
|
360
|
+
this.#inFlight.retriesStopped = true;
|
|
360
361
|
this.#scheduleGc();
|
|
361
362
|
}
|
|
362
363
|
}
|
|
@@ -400,13 +401,18 @@ class Query {
|
|
|
400
401
|
// with its own outcome; one stopped with nothing in its place settles it as
|
|
401
402
|
// cancel() or destroy() says. Nobody has to wait for it.
|
|
402
403
|
fetch({ queryFn, retry: retry$1 = 0, retryDelay = defaultRetryDelay, structuralSharing = false, }, { cancelRefetch = false } = {}) {
|
|
403
|
-
const running = this.#
|
|
404
|
+
const running = this.#inFlight;
|
|
404
405
|
if (running) {
|
|
405
406
|
// Already in-flight: dedupe unless the caller explicitly wants a fresh
|
|
406
|
-
// fetch (e.g. invalidate/refetch) — then replace the old one.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
407
|
+
// fetch (e.g. invalidate/refetch) — then replace the old one. A caller
|
|
408
|
+
// that joins hands its queryFn over for the retries to come, and wants
|
|
409
|
+
// them made, even after the observers the fetch was started for left.
|
|
410
|
+
if (!cancelRefetch) {
|
|
411
|
+
running.queryFn = queryFn;
|
|
412
|
+
running.retriesStopped = false;
|
|
413
|
+
return running.outcome.promise;
|
|
414
|
+
}
|
|
415
|
+
running.subscription.unsubscribe();
|
|
410
416
|
}
|
|
411
417
|
const outcome = deferred();
|
|
412
418
|
// Its result or error lands in the state either way, so a caller may
|
|
@@ -414,12 +420,18 @@ class Query {
|
|
|
414
420
|
// unhandled rejection, and whoever awaits the promise still gets it.
|
|
415
421
|
outcome.promise.catch(() => undefined);
|
|
416
422
|
// Whoever waits for the fetch this one replaces gets this one's outcome.
|
|
417
|
-
running?.resolve(outcome.promise);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
+
running?.outcome.resolve(outcome.promise);
|
|
424
|
+
const inFlight = {
|
|
425
|
+
outcome,
|
|
426
|
+
subscription: new Subscription(),
|
|
427
|
+
// A fetch that replaces one in flight keeps the state the first one
|
|
428
|
+
// started from.
|
|
429
|
+
before: running?.before ?? this.state(),
|
|
430
|
+
queryFn,
|
|
431
|
+
abortable: false,
|
|
432
|
+
retriesStopped: false,
|
|
433
|
+
};
|
|
434
|
+
this.#inFlight = inFlight;
|
|
423
435
|
// A query with no data reads like a first load while it fetches, even
|
|
424
436
|
// after a failure: 'pending' with no error, so a loading state and
|
|
425
437
|
// placeholderData show rather than the old error. One with data keeps
|
|
@@ -431,10 +443,19 @@ class Query {
|
|
|
431
443
|
failureCount: 0,
|
|
432
444
|
failureReason: null,
|
|
433
445
|
}));
|
|
434
|
-
//
|
|
435
|
-
//
|
|
436
|
-
|
|
437
|
-
|
|
446
|
+
// The first attempt runs the caller's queryFn, each retry the one
|
|
447
|
+
// #retryQueryFn picks. defer + from: normalize Observable/Promise and
|
|
448
|
+
// make a fresh request for each attempt (a Promise is one-shot).
|
|
449
|
+
let firstAttempt = true;
|
|
450
|
+
const attempts = defer(() => {
|
|
451
|
+
const attemptQueryFn = firstAttempt
|
|
452
|
+
? queryFn
|
|
453
|
+
: this.#retryQueryFn(inFlight);
|
|
454
|
+
firstAttempt = false;
|
|
455
|
+
const request = attemptQueryFn();
|
|
456
|
+
inFlight.abortable = isObservable(request);
|
|
457
|
+
return from(request);
|
|
458
|
+
}).pipe(take(1), retry({
|
|
438
459
|
delay: (error, retryCount) => {
|
|
439
460
|
// retryCount (1-based) is the number of failures so far; the retry
|
|
440
461
|
// predicate/delay take a 0-based attempt index (0 = first retry).
|
|
@@ -444,20 +465,29 @@ class Query {
|
|
|
444
465
|
failureReason: error,
|
|
445
466
|
}));
|
|
446
467
|
const attemptIndex = retryCount - 1;
|
|
447
|
-
|
|
468
|
+
// Once the last observer left, the failure ends the fetch at once.
|
|
469
|
+
if (inFlight.retriesStopped ||
|
|
470
|
+
!shouldRetry(retry$1, attemptIndex, error)) {
|
|
448
471
|
throw error;
|
|
449
|
-
|
|
472
|
+
}
|
|
473
|
+
// The retry goes out when the wait is over. If the last observer
|
|
474
|
+
// left during the wait, an error thrown when the timer fires ends
|
|
475
|
+
// the fetch with this error instead, as in TanStack; whoever joins
|
|
476
|
+
// meanwhile clears the flag, and the retry goes out on time.
|
|
477
|
+
return timer(resolveRetryDelay(retryDelay, attemptIndex, error)).pipe(tap(() => {
|
|
478
|
+
if (inFlight.retriesStopped)
|
|
479
|
+
throw error;
|
|
480
|
+
}));
|
|
450
481
|
},
|
|
451
482
|
}), throwIfEmpty(() => new Error('Query function completed without emitting a value')),
|
|
452
483
|
// Keeps what didn't change from the data the query holds when the
|
|
453
484
|
// response lands, a write made during the fetch included. After the
|
|
454
485
|
// retries: a structuralSharing function that throws fails the fetch
|
|
455
486
|
// rather than retrying it, or leaving it in flight.
|
|
456
|
-
map((data) => replaceData(this.state().data, data, structuralSharing)))
|
|
457
|
-
|
|
487
|
+
map((data) => replaceData(this.state().data, data, structuralSharing)));
|
|
488
|
+
inFlight.subscription.add(attempts.subscribe({
|
|
458
489
|
next: (data) => {
|
|
459
|
-
this.#
|
|
460
|
-
this.#beforeFetch = null;
|
|
490
|
+
this.#inFlight = null;
|
|
461
491
|
this.#fetchedStructuralSharing = structuralSharing;
|
|
462
492
|
this.#state.set({
|
|
463
493
|
data,
|
|
@@ -473,8 +503,7 @@ class Query {
|
|
|
473
503
|
this.#scheduleGc();
|
|
474
504
|
},
|
|
475
505
|
error: (err) => {
|
|
476
|
-
this.#
|
|
477
|
-
this.#beforeFetch = null;
|
|
506
|
+
this.#inFlight = null;
|
|
478
507
|
this.#state.update((state) => ({
|
|
479
508
|
...state,
|
|
480
509
|
status: 'error',
|
|
@@ -484,7 +513,7 @@ class Query {
|
|
|
484
513
|
outcome.reject(err);
|
|
485
514
|
this.#scheduleGc();
|
|
486
515
|
},
|
|
487
|
-
});
|
|
516
|
+
}));
|
|
488
517
|
return outcome.promise;
|
|
489
518
|
}
|
|
490
519
|
// Without a structuralSharing setting the data is stored as is: which one
|
|
@@ -501,8 +530,8 @@ class Query {
|
|
|
501
530
|
updatedAt,
|
|
502
531
|
}));
|
|
503
532
|
// A write made during a fetch is what stopping the fetch goes back to.
|
|
504
|
-
if (this.#inFlight
|
|
505
|
-
this.#
|
|
533
|
+
if (this.#inFlight)
|
|
534
|
+
this.#inFlight.before = this.state();
|
|
506
535
|
// A write counts as use: a query nobody observes is kept for another
|
|
507
536
|
// gcTime, so a setQueryData write isn't collected before anyone shows it.
|
|
508
537
|
this.#scheduleGc();
|
|
@@ -520,7 +549,7 @@ class Query {
|
|
|
520
549
|
// holds, as in TanStack, or a CancelledError if it holds none.
|
|
521
550
|
cancel() {
|
|
522
551
|
const { data } = this.state();
|
|
523
|
-
const fetching = this.#inFlight
|
|
552
|
+
const fetching = this.#inFlight !== null;
|
|
524
553
|
this.#stop((outcome) => data === undefined
|
|
525
554
|
? outcome.reject(new CancelledError())
|
|
526
555
|
: outcome.resolve(data));
|
|
@@ -542,39 +571,33 @@ class Query {
|
|
|
542
571
|
#isStale(staleTime) {
|
|
543
572
|
return Date.now() - this.state().updatedAt >= staleTime;
|
|
544
573
|
}
|
|
545
|
-
#inFlight() {
|
|
546
|
-
return this.#outcome !== null;
|
|
547
|
-
}
|
|
548
574
|
// Stops the fetch in flight, if any, and settles its promise with settle.
|
|
549
575
|
#stop(settle) {
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
this.#
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
settle(outcome);
|
|
576
|
+
const inFlight = this.#inFlight;
|
|
577
|
+
if (!inFlight)
|
|
578
|
+
return;
|
|
579
|
+
inFlight.subscription.unsubscribe();
|
|
580
|
+
this.#inFlight = null;
|
|
581
|
+
settle(inFlight.outcome);
|
|
582
|
+
const { before } = inFlight;
|
|
558
583
|
// The fetch is no longer running, so isFetching mustn't stay stuck true,
|
|
559
584
|
// and what the fetch wrote over goes back to how it was: a query that
|
|
560
585
|
// failed shows its error again, as in TanStack. Data and the stale mark
|
|
561
586
|
// aren't the fetch's to put back: they stay as written meanwhile, so an
|
|
562
587
|
// invalidation made during the fetch still holds.
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
}));
|
|
572
|
-
}
|
|
588
|
+
this.#state.update((state) => ({
|
|
589
|
+
...state,
|
|
590
|
+
status: before.status,
|
|
591
|
+
error: before.error,
|
|
592
|
+
failureCount: before.failureCount,
|
|
593
|
+
failureReason: before.failureReason,
|
|
594
|
+
isFetching: false,
|
|
595
|
+
}));
|
|
573
596
|
}
|
|
574
597
|
// A fetch in flight is kept, as in TanStack, and the observers aren't even
|
|
575
598
|
// asked: fetch() would drop the refetch anyway.
|
|
576
599
|
#refetchOn(option) {
|
|
577
|
-
if (this.#inFlight
|
|
600
|
+
if (this.#inFlight)
|
|
578
601
|
return;
|
|
579
602
|
for (const observer of this.#observers) {
|
|
580
603
|
const options = observer.fetchOptions();
|
|
@@ -586,6 +609,20 @@ class Query {
|
|
|
586
609
|
}
|
|
587
610
|
}
|
|
588
611
|
}
|
|
612
|
+
// The queryFn a retry runs: that of the first observer that wants the
|
|
613
|
+
// query fetched, as for a refetch, else that of whoever asked for the
|
|
614
|
+
// fetch last. Not simply the one the fetch started with: a queryFn may
|
|
615
|
+
// read its key's value only when it runs, as `() => api(this.id())` does,
|
|
616
|
+
// and by the retry its component may have moved on to another key. An
|
|
617
|
+
// observer whose key moved on doesn't want this query fetched.
|
|
618
|
+
#retryQueryFn(inFlight) {
|
|
619
|
+
for (const observer of this.#observers) {
|
|
620
|
+
const options = observer.fetchOptions();
|
|
621
|
+
if (options)
|
|
622
|
+
return options.queryFn;
|
|
623
|
+
}
|
|
624
|
+
return inFlight.queryFn;
|
|
625
|
+
}
|
|
589
626
|
// Removes the query gcTime from now, unless something uses it by then: an
|
|
590
627
|
// observer, or a fetch of it in flight. Called whenever the query may have
|
|
591
628
|
// become unused: when it's created, when its last observer leaves, when a
|
|
@@ -600,7 +637,7 @@ class Query {
|
|
|
600
637
|
this.#gcTimer = setTimeout(() => {
|
|
601
638
|
this.#gcTimer = null;
|
|
602
639
|
// A fetch still in flight keeps it: the fetch's end calls this again.
|
|
603
|
-
if (!this.#inFlight
|
|
640
|
+
if (!this.#inFlight)
|
|
604
641
|
this.#cache.remove(this);
|
|
605
642
|
}, this.#gcTime);
|
|
606
643
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngx-signal-query.mjs","sources":["../../../projects/ngx-signal-query/src/lib/core/platform.ts","../../../projects/ngx-signal-query/src/lib/core/browser-events.ts","../../../projects/ngx-signal-query/src/lib/core/cache.ts","../../../projects/ngx-signal-query/src/lib/core/utils.ts","../../../projects/ngx-signal-query/src/lib/core/cancelled-error.ts","../../../projects/ngx-signal-query/src/lib/core/retryer.ts","../../../projects/ngx-signal-query/src/lib/core/query.ts","../../../projects/ngx-signal-query/src/lib/core/query-cache.ts","../../../projects/ngx-signal-query/src/lib/core/mutation.ts","../../../projects/ngx-signal-query/src/lib/core/mutation-cache.ts","../../../projects/ngx-signal-query/src/lib/core/injection-tokens.ts","../../../projects/ngx-signal-query/src/lib/core/query-client.ts","../../../projects/ngx-signal-query/src/lib/features/feature.ts","../../../projects/ngx-signal-query/src/lib/core/provider.ts","../../../projects/ngx-signal-query/src/lib/core/inject-query-client.ts","../../../projects/ngx-signal-query/src/lib/core/polling.ts","../../../projects/ngx-signal-query/src/lib/core/query-observer.ts","../../../projects/ngx-signal-query/src/lib/core/inject-query.ts","../../../projects/ngx-signal-query/src/lib/core/inject-queries.ts","../../../projects/ngx-signal-query/src/lib/core/inject-mutation.ts","../../../projects/ngx-signal-query/src/lib/core/inject-is-fetching.ts","../../../projects/ngx-signal-query/src/lib/core/inject-is-mutating.ts","../../../projects/ngx-signal-query/src/lib/core/query-options.ts","../../../projects/ngx-signal-query/src/lib/core/keep-previous-data.ts","../../../projects/ngx-signal-query/src/lib/core/mutation-options.ts","../../../projects/ngx-signal-query/src/lib/features/with-default-options.ts","../../../projects/ngx-signal-query/src/public-api.ts","../../../projects/ngx-signal-query/src/ngx-signal-query.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common'\nimport { PLATFORM_ID, inject } from '@angular/core'\n\n/**\n * Whether the app runs in the browser rather than on the server. On the\n * server, DOCUMENT is an emulated document that has listeners, a window and\n * no visibilityState: only the platform tells. Must run in an injection\n * context.\n *\n * @internal\n */\nexport function inBrowser(): boolean {\n return isPlatformBrowser(inject(PLATFORM_ID))\n}\n","import { DOCUMENT } from '@angular/common'\nimport { inject } from '@angular/core'\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop'\nimport { filter, fromEvent } from 'rxjs'\n\nimport { inBrowser } from './platform'\n\n/**\n * Calls `listener` whenever the user comes back to the page, as the tab or\n * the window turns visible again. The window's `focus` event isn't used: it\n * also fires when an alert or a file picker closes, or on coming back from\n * DevTools, with the user on the page all along.\n *\n * Listens until the current injector is destroyed, and only in the browser:\n * on the server there is no page to come back to. Must run in an injection\n * context.\n *\n * @internal\n */\nexport function onWindowFocus(listener: () => void): void {\n if (!inBrowser()) return\n\n const document = inject(DOCUMENT)\n\n fromEvent(document, 'visibilitychange')\n .pipe(\n filter(() => document.visibilityState !== 'hidden'),\n takeUntilDestroyed(),\n )\n .subscribe(() => listener())\n}\n\n/**\n * Calls `listener` whenever the browser reports that the network is back\n * (`online`). Each such event means it was off: the browser fires it only\n * when going from offline to online, a page opened offline included.\n *\n * Listens until the current injector is destroyed, and only in the browser.\n * Must run in an injection context.\n *\n * @internal\n */\nexport function onReconnect(listener: () => void): void {\n if (!inBrowser()) return\n\n const window = inject(DOCUMENT).defaultView\n\n if (!window) return\n\n fromEvent(window, 'online')\n .pipe(takeUntilDestroyed())\n .subscribe(() => listener())\n}\n","import { signal } from '@angular/core'\n\n/** @internal */\nexport abstract class Cache<TEntry> {\n readonly #entries = signal<TEntry[]>([])\n\n // Reactive snapshot of all entries; updated on add/remove/clear so that\n // findAll() (and its computed consumers like isFetching) react to the\n // collection. Protected: only subclasses read it, never external code.\n protected readonly entries = this.#entries.asReadonly()\n\n readonly #entriesMap = new Map<string, TEntry>()\n\n getAll(): TEntry[] {\n return Array.from(this.#entriesMap.values())\n }\n\n clear(): void {\n this.#entriesMap.clear()\n this.#sync()\n }\n\n protected addEntry(key: string, entry: TEntry): TEntry {\n this.#entriesMap.set(key, entry)\n this.#sync()\n\n return entry\n }\n\n protected getEntry(key: string): TEntry | undefined {\n return this.#entriesMap.get(key)\n }\n\n protected removeEntry(key: string): boolean {\n const removed = this.#entriesMap.delete(key)\n\n if (removed) this.#sync()\n\n return removed\n }\n\n #sync(): void {\n this.#entries.set(Array.from(this.#entriesMap.values()))\n }\n}\n","import type { QueryKey, StructuralSharingValue, Updater } from './types'\n\n// Resolves an updater: calls it with the previous value if it's a function,\n// otherwise uses it as the value directly.\n/** @internal */\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (input: TInput) => TOutput)(input)\n : updater\n}\n\n// True when `filter` is a (deep) prefix of `key`, e.g. ['app'] matches\n// ['app', 1]. Used to invalidate/find groups of queries by partial key.\n/** @internal */\nexport function partialMatchKey(key: QueryKey, filter: QueryKey): boolean {\n return partialDeepEqual(key, filter)\n}\n\nfunction partialDeepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (typeof a !== typeof b) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n // An array longer than the key's can't be a prefix of it, even when what\n // it adds is undefined, which an item the key lacks would equal.\n if (Array.isArray(a) && Array.isArray(b) && b.length > a.length) {\n return false\n }\n\n return Object.keys(b).every((key) =>\n partialDeepEqual(\n (a as Record<string, unknown>)[key],\n (b as Record<string, unknown>)[key],\n ),\n )\n }\n\n return false\n}\n\n/** @internal */\nexport function hashKey(key: QueryKey): string {\n return JSON.stringify(key, (_, value) =>\n isPlainObject(value)\n ? Object.keys(value)\n .sort()\n .reduce<Record<string, unknown>>((result, k) => {\n result[k] = value[k]\n\n return result\n }, {})\n : value,\n )\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isPlainObject(o: any): o is Record<PropertyKey, unknown> {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor. Read from the prototype, not the object: JSON data\n // can have its own `constructor` field, even a null one.\n const objectPrototype = Object.getPrototypeOf(o)\n const ctor = objectPrototype?.constructor\n\n if (ctor === undefined) {\n return true\n }\n\n if (typeof ctor !== 'function') {\n return false\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (objectPrototype !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\n// Past this many levels replaceEqualDeep takes the new value as is.\nconst MAX_SHARING_DEPTH = 500\n\n// Returns `prev` when `next` is deeply equal to it. Otherwise returns `next`\n// with every deeply equal part replaced by the one from `prev`, so whatever\n// didn't change keeps its reference. Only plain objects and arrays are\n// compared, as JSON parsing makes them: any other value (a Date, a class\n// instance, a Map) counts as changed. A value that references itself can't\n// overflow the stack: past MAX_SHARING_DEPTH levels `next` is taken as is.\n// The same algorithm as TanStack Query's replaceEqualDeep.\n/** @internal */\nexport function replaceEqualDeep<T>(prev: unknown, next: T, depth?: number): T\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function replaceEqualDeep(prev: any, next: any, depth = 0): any {\n if (prev === next) return prev\n if (depth > MAX_SHARING_DEPTH) return next\n\n const array = isPlainArray(prev) && isPlainArray(next)\n\n if (!array && !(isPlainObject(prev) && isPlainObject(next))) return next\n\n const prevItems = array ? prev : Object.keys(prev)\n const prevSize = prevItems.length\n const nextItems = array ? next : Object.keys(next)\n const nextSize = nextItems.length\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const copy: any = array ? new Array(nextSize) : {}\n\n let equalItems = 0\n\n for (let i = 0; i < nextSize; i++) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const key: any = array ? i : nextItems[i]\n const prevItem = prev[key]\n const nextItem = next[key]\n\n if (prevItem === nextItem) {\n copy[key] = prevItem\n if (array ? i < prevSize : Object.hasOwn(prev, key)) equalItems++\n continue\n }\n\n if (\n prevItem === null ||\n nextItem === null ||\n typeof prevItem !== 'object' ||\n typeof nextItem !== 'object'\n ) {\n copy[key] = nextItem\n continue\n }\n\n const shared = replaceEqualDeep(prevItem, nextItem, depth + 1)\n\n copy[key] = shared\n if (shared === prevItem) equalItems++\n }\n\n return prevSize === nextSize && equalItems === prevSize ? prev : copy\n}\n\n// An array without holes or extra properties, as JSON parsing makes.\nfunction isPlainArray(value: unknown): value is unknown[] {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Merges new data into the data a query holds, as its structuralSharing\n// option says: shared, as is, or by the option's own function.\n/** @internal */\nexport function replaceData<TData>(\n prevData: TData | undefined,\n data: TData,\n structuralSharing: StructuralSharingValue<TData>,\n): TData {\n if (typeof structuralSharing === 'function') {\n return structuralSharing(prevData, data)\n }\n\n return structuralSharing ? replaceEqualDeep(prevData, data) : data\n}\n\n// The longest delay a browser timer holds, in ms. A longer one overflows and\n// the timer fires at once.\nconst MAX_TIMEOUT = 2 ** 31 - 1\n\n// True for a delay a timer can hold. For anything else, Infinity and negative\n// numbers included, a browser runs the timer at once. TanStack's\n// isValidTimeout checks the same, without the upper bound.\n/** @internal */\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value <= MAX_TIMEOUT\n}\n\n// True for a promise, or for anything else with a then method.\n/** @internal */\nexport function isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return typeof (value as PromiseLike<unknown> | null)?.then === 'function'\n}\n\n// Resolves once every promise has settled, and never rejects. It resolves\n// with nothing: what the promises brought isn't the caller's to see.\n/** @internal */\nexport function whenAllSettled(\n promises: Array<Promise<unknown> | undefined>,\n): Promise<void> {\n return Promise.allSettled(promises).then(() => undefined)\n}\n\n// A promise with the functions that settle it. TODO: use\n// Promise.withResolvers() instead once every browser the supported Angular\n// versions target has it: Safari 17.4, Chrome 119, Firefox 121 (Angular 20\n// still targets Safari 16).\n/** @internal */\nexport interface Deferred<T> {\n promise: Promise<T>\n resolve: (value: T | PromiseLike<T>) => void\n reject: (reason: unknown) => void\n}\n\n/** @internal */\nexport function deferred<T = void>(): Deferred<T> {\n let resolve!: Deferred<T>['resolve']\n let reject!: Deferred<T>['reject']\n const promise = new Promise<T>((res, rej) => {\n resolve = res\n reject = rej\n })\n\n return { promise, resolve, reject }\n}\n","/**\n * The error a promise of a query's data rejects with when the fetch stops\n * with no data to give: it was cancelled before the query had any\n * (`cancelQueries()`, or the last component showing the query went away), or\n * the query was removed (`removeQueries()`, e.g. on sign-out). The request\n * didn't fail, so tell the two apart with `instanceof CancelledError`.\n *\n * A mutation's `mutateAsync()` rejects with one too, when the mutation cache\n * is cleared while its run is in flight.\n */\nexport class CancelledError extends Error {\n constructor(message = 'The query fetch was cancelled') {\n super(message)\n this.name = 'CancelledError'\n }\n}\n","import type { RetryDelayValue, RetryValue } from './types'\n\n// Exponential backoff capped at 30s, matching TanStack's default.\n/** @internal */\nexport function defaultRetryDelay(failureCount: number): number {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\n/** @internal */\nexport function shouldRetry<TError>(\n retry: RetryValue<TError>,\n failureCount: number,\n error: TError,\n): boolean {\n if (typeof retry === 'function') return retry(failureCount, error)\n if (typeof retry === 'number') return failureCount < retry\n\n return retry\n}\n\n/** @internal */\nexport function resolveRetryDelay<TError>(\n retryDelay: RetryDelayValue<TError>,\n failureCount: number,\n error: TError,\n): number {\n return typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n}\n","import { signal } from '@angular/core'\nimport {\n defer,\n from,\n map,\n retry as retryOperator,\n take,\n throwIfEmpty,\n timer,\n type Subscription,\n} from 'rxjs'\n\nimport { CancelledError } from './cancelled-error'\nimport type { QueryCache } from './query-cache'\nimport { defaultRetryDelay, resolveRetryDelay, shouldRetry } from './retryer'\nimport { type Deferred, deferred, isValidTimeout, replaceData } from './utils'\nimport type {\n DefaultedQueryOptions,\n QueryKey,\n QueryOptions,\n QueryState,\n StructuralSharingValue,\n} from './types'\n\n/**\n * An observer of a query, as the query sees it: the query asks its observers\n * how to fetch it when it refetches on their behalf (after invalidation, on\n * window focus or reconnect), and how data written into it by hand merges.\n *\n * @internal\n */\nexport interface QuerySubscriber<TData, TError = Error> {\n /**\n * How this observer would fetch the query right now, and when it wants it\n * refetched, read from its live options; `null` while it doesn't want the\n * query fetched: it is disabled, or its key has already moved on to another\n * query.\n */\n fetchOptions(): Pick<\n DefaultedQueryOptions<TData, TError>,\n | 'queryFn'\n | 'retry'\n | 'retryDelay'\n | 'structuralSharing'\n | 'staleTime'\n | 'refetchOnWindowFocus'\n | 'refetchOnReconnect'\n > | null\n\n /**\n * How this observer merges data written into the query by hand, read from\n * its live options, whether it's enabled or not.\n */\n structuralSharing(): StructuralSharingValue<TData>\n}\n\n/**\n * What a query is created with: its key and the key's hash, the cache it\n * lives in, and how long it stays there once nothing uses it.\n *\n * @internal\n */\nexport interface QueryConfig {\n key: QueryKey\n queryHash: string\n cache: QueryCache\n gcTime: number\n}\n\n/** @internal */\nexport class Query<TData, TError = Error> {\n readonly key: QueryKey\n readonly queryHash: string\n\n readonly #state = signal<QueryState<TData, TError>>({\n data: undefined,\n status: 'pending',\n error: null,\n isFetching: false,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt: 0,\n })\n\n // `state` must follow `#state`: a public field can't precede the private\n // field it reads during initialization (field init order).\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly state = this.#state.asReadonly()\n\n #subscription: Subscription | null = null\n // The promise of the fetch in flight, which every caller that joins the\n // fetch shares, and how to settle it; null while nothing is in flight.\n #outcome: Deferred<TData> | null = null\n // The state the fetch in flight started from, or the last write made\n // during it: stopping the fetch with nothing in its place goes back to it\n // (see #stop). null while nothing is in flight.\n #beforeFetch: QueryState<TData, TError> | null = null\n // The structuralSharing of the fetch whose response the query holds.\n #fetchedStructuralSharing: StructuralSharingValue<TData> | undefined\n readonly #observers = new Set<QuerySubscriber<TData, TError>>()\n #gcTime = 0\n #gcTimer: ReturnType<typeof setTimeout> | null = null\n readonly #cache: QueryCache\n\n constructor({ key, queryHash, cache, gcTime }: QueryConfig) {\n this.key = key\n this.queryHash = queryHash\n this.#cache = cache\n this.updateGcTime(gcTime)\n // A new query has nothing using it yet: its creator is about to, and if\n // nothing ever does, gc removes it.\n this.#scheduleGc()\n }\n\n get observerCount(): number {\n return this.#observers.size\n }\n\n // Keeps the longest gcTime asked for by anything that used the query, as\n // in TanStack: whoever created it, each component that showed it, each\n // fetchQuery. A shorter one doesn't cut short a longer one asked for\n // before. Never below 0.\n updateGcTime(ms: number): void {\n this.#gcTime = Math.max(this.#gcTime, ms)\n }\n\n addObserver(observer: QuerySubscriber<TData, TError>): void {\n this.#observers.add(observer)\n this.#clearGcTimer()\n }\n\n removeObserver(observer: QuerySubscriber<TData, TError>): void {\n // An observer this query doesn't have changes nothing: it mustn't cancel\n // the fetch or schedule gc while others still watch.\n if (!this.#observers.delete(observer)) return\n\n // No observers left: cancel any in-flight fetch (nobody is waiting for it)\n // and schedule gc to dispose the query if no observer returns.\n if (this.#observers.size === 0) {\n this.cancel()\n this.#scheduleGc()\n }\n }\n\n // Refetches the query if a component shows it: the first observer that\n // wants it fetched decides how, as in TanStack. A fetch in flight is\n // replaced, as it may predate the change the caller is after. Returns the\n // fetch's promise, or undefined if no observer wants the query fetched.\n refetchIfActive(): Promise<TData> | undefined {\n for (const observer of this.#observers) {\n const options = observer.fetchOptions()\n\n if (options) return this.fetch(options, { cancelRefetch: true })\n }\n\n return\n }\n\n // Refetches the query now that the user is back on the page, if one of its\n // observers wants that: its refetchOnWindowFocus is 'always', or true while\n // the data is stale for its staleTime. The first such observer decides\n // how, as in TanStack.\n onFocus(): void {\n this.#refetchOn('refetchOnWindowFocus')\n }\n\n // The same once the network is back, by refetchOnReconnect.\n onOnline(): void {\n this.#refetchOn('refetchOnReconnect')\n }\n\n // How data written into the query by hand merges with what it holds: as\n // its first observer says, enabled or not; with none, the way its data was\n // fetched; undefined if neither has a say.\n structuralSharing(): StructuralSharingValue<TData> | undefined {\n const [observer] = this.#observers\n\n return observer\n ? observer.structuralSharing()\n : this.#fetchedStructuralSharing\n }\n\n // Without a structuralSharing setting the response is stored as is: the\n // default is the client's to resolve.\n //\n // Returns a promise of the data as the query stores it, which every caller\n // that joins the fetch shares. A fetch that replaces this one settles it\n // with its own outcome; one stopped with nothing in its place settles it as\n // cancel() or destroy() says. Nobody has to wait for it.\n fetch(\n {\n queryFn,\n retry = 0,\n retryDelay = defaultRetryDelay,\n structuralSharing = false,\n }: Pick<\n QueryOptions<TData, TError>,\n 'queryFn' | 'retry' | 'retryDelay' | 'structuralSharing'\n >,\n { cancelRefetch = false }: { cancelRefetch?: boolean } = {},\n ): Promise<TData> {\n const running = this.#outcome\n\n if (running) {\n // Already in-flight: dedupe unless the caller explicitly wants a fresh\n // fetch (e.g. invalidate/refetch) — then replace the old one.\n if (!cancelRefetch) return running.promise\n\n this.#subscription?.unsubscribe()\n }\n\n const outcome = deferred<TData>()\n\n // Its result or error lands in the state either way, so a caller may\n // ignore the promise: handled here, a failure doesn't surface as an\n // unhandled rejection, and whoever awaits the promise still gets it.\n outcome.promise.catch(() => undefined)\n // Whoever waits for the fetch this one replaces gets this one's outcome.\n running?.resolve(outcome.promise)\n this.#outcome = outcome\n\n // A fetch that replaces one in flight keeps the state the first one\n // started from.\n if (!running) this.#beforeFetch = this.state()\n\n // A query with no data reads like a first load while it fetches, even\n // after a failure: 'pending' with no error, so a loading state and\n // placeholderData show rather than the old error. One with data keeps\n // its status and error until the response, as in TanStack.\n this.#state.update((state) => ({\n ...state,\n ...(state.data === undefined && { status: 'pending', error: null }),\n isFetching: true,\n failureCount: 0,\n failureReason: null,\n }))\n\n // defer + from: normalize Observable/Promise and re-invoke queryFn on each\n // retry (a Promise is one-shot, so retry must produce a fresh one).\n this.#subscription = defer(() => from(queryFn()))\n .pipe(\n take(1),\n retryOperator({\n delay: (error, retryCount) => {\n // retryCount (1-based) is the number of failures so far; the retry\n // predicate/delay take a 0-based attempt index (0 = first retry).\n this.#state.update((state) => ({\n ...state,\n failureCount: retryCount,\n failureReason: error as TError,\n }))\n\n const attemptIndex = retryCount - 1\n\n if (!shouldRetry(retry, attemptIndex, error as TError)) throw error\n\n return timer(\n resolveRetryDelay(retryDelay, attemptIndex, error as TError),\n )\n },\n }),\n throwIfEmpty(\n () => new Error('Query function completed without emitting a value'),\n ),\n // Keeps what didn't change from the data the query holds when the\n // response lands, a write made during the fetch included. After the\n // retries: a structuralSharing function that throws fails the fetch\n // rather than retrying it, or leaving it in flight.\n map((data) => replaceData(this.state().data, data, structuralSharing)),\n )\n .subscribe({\n next: (data) => {\n this.#outcome = null\n this.#beforeFetch = null\n this.#fetchedStructuralSharing = structuralSharing\n this.#state.set({\n data,\n status: 'success',\n error: null,\n isFetching: false,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt: Date.now(),\n })\n outcome.resolve(data)\n this.#scheduleGc()\n },\n error: (err) => {\n this.#outcome = null\n this.#beforeFetch = null\n this.#state.update((state) => ({\n ...state,\n status: 'error',\n error: err,\n isFetching: false,\n }))\n outcome.reject(err)\n this.#scheduleGc()\n },\n })\n\n return outcome.promise\n }\n\n // Without a structuralSharing setting the data is stored as is: which one\n // a write uses is the client's to resolve.\n setData(\n data: TData,\n {\n updatedAt = Date.now(),\n structuralSharing = false,\n }: {\n updatedAt?: number\n structuralSharing?: StructuralSharingValue<TData>\n } = {},\n ): void {\n this.#state.update((state) => ({\n ...state,\n data: replaceData(state.data, data, structuralSharing),\n status: 'success',\n error: null,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt,\n }))\n\n // A write made during a fetch is what stopping the fetch goes back to.\n if (this.#inFlight()) this.#beforeFetch = this.state()\n\n // A write counts as use: a query nobody observes is kept for another\n // gcTime, so a setQueryData write isn't collected before anyone shows it.\n this.#scheduleGc()\n }\n\n invalidate(): void {\n this.#state.update((state) => ({ ...state, isInvalidated: true }))\n }\n\n shouldFetch(staleTime: number): boolean {\n const state = this.state()\n\n return (\n state.status !== 'success' ||\n state.isInvalidated ||\n this.#isStale(staleTime)\n )\n }\n\n // Stops the fetch in flight. Whoever waits for it gets the data the query\n // holds, as in TanStack, or a CancelledError if it holds none.\n cancel(): void {\n const { data } = this.state()\n const fetching = this.#inFlight()\n\n this.#stop((outcome) =>\n data === undefined\n ? outcome.reject(new CancelledError())\n : outcome.resolve(data),\n )\n\n // Only a fetch that stops can leave the query unused: cancelling none\n // mustn't put off its gc.\n if (fetching) this.#scheduleGc()\n }\n\n // The query is thrown away with its data, so whoever waits for its fetch\n // gets a CancelledError, as in TanStack.\n destroy(): void {\n this.#stop((outcome) => outcome.reject(new CancelledError()))\n this.#clearGcTimer()\n }\n\n // Inclusive: data fetched exactly `staleTime` ago is already stale. This\n // matters for seeded data (initialData is stamped with the current time), so\n // the default staleTime of 0 still means \"stale at once\" → background\n // refetch, rather than depending on whether a millisecond happened to pass.\n #isStale(staleTime: number): boolean {\n return Date.now() - this.state().updatedAt >= staleTime\n }\n\n #inFlight(): boolean {\n return this.#outcome !== null\n }\n\n // Stops the fetch in flight, if any, and settles its promise with settle.\n #stop(settle: (outcome: Deferred<TData>) => void): void {\n const outcome = this.#outcome\n const before = this.#beforeFetch\n\n this.#subscription?.unsubscribe()\n this.#subscription = null\n this.#outcome = null\n this.#beforeFetch = null\n\n if (outcome) settle(outcome)\n\n // The fetch is no longer running, so isFetching mustn't stay stuck true,\n // and what the fetch wrote over goes back to how it was: a query that\n // failed shows its error again, as in TanStack. Data and the stale mark\n // aren't the fetch's to put back: they stay as written meanwhile, so an\n // invalidation made during the fetch still holds.\n if (before) {\n this.#state.update((state) => ({\n ...state,\n status: before.status,\n error: before.error,\n failureCount: before.failureCount,\n failureReason: before.failureReason,\n isFetching: false,\n }))\n }\n }\n\n // A fetch in flight is kept, as in TanStack, and the observers aren't even\n // asked: fetch() would drop the refetch anyway.\n #refetchOn(option: 'refetchOnWindowFocus' | 'refetchOnReconnect'): void {\n if (this.#inFlight()) return\n\n for (const observer of this.#observers) {\n const options = observer.fetchOptions()\n\n if (!options || options[option] === false) continue\n\n if (options[option] === 'always' || this.shouldFetch(options.staleTime)) {\n this.fetch(options)\n\n return\n }\n }\n }\n\n // Removes the query gcTime from now, unless something uses it by then: an\n // observer, or a fetch of it in flight. Called whenever the query may have\n // become unused: when it's created, when its last observer leaves, when a\n // fetch of it ends, when data is written into it by hand.\n #scheduleGc(): void {\n this.#clearGcTimer()\n\n // While observed, the query is in use: the last observer leaving calls\n // this again. Infinity, or a gcTime no timer can hold, keeps the query\n // until something removes it: a browser would run the timer at once.\n if (this.#observers.size > 0 || !isValidTimeout(this.#gcTime)) return\n\n this.#gcTimer = setTimeout(() => {\n this.#gcTimer = null\n\n // A fetch still in flight keeps it: the fetch's end calls this again.\n if (!this.#inFlight()) this.#cache.remove(this)\n }, this.#gcTime)\n }\n\n #clearGcTimer(): void {\n if (this.#gcTimer === null) return\n\n clearTimeout(this.#gcTimer)\n this.#gcTimer = null\n }\n}\n","import { Injectable } from '@angular/core'\n\nimport { Cache } from './cache'\nimport { hashKey, partialMatchKey } from './utils'\nimport { Query } from './query'\nimport type { QueryFilters, QueryKey } from './types'\n\n/** @internal */\n@Injectable()\nexport class QueryCache extends Cache<Query<unknown, unknown>> {\n getOrCreate<TData, TError = Error>(\n key: QueryKey,\n gcTime: number,\n ): Query<TData, TError> {\n const queryHash = hashKey(key)\n const exist = this.getEntry(queryHash)\n\n if (exist) return exist as Query<TData, TError>\n\n return this.addEntry(\n queryHash,\n new Query({ key, queryHash, cache: this, gcTime }),\n ) as Query<TData, TError>\n }\n\n get<TData, TError = Error>(key: QueryKey): Query<TData, TError> | undefined {\n return this.getEntry(hashKey(key)) as Query<TData, TError> | undefined\n }\n\n /**\n * Like get(), but reactive, as findAll() is: a computed or an effect that\n * calls it re-runs when an entry is added or removed.\n */\n find<TData, TError = Error>(key: QueryKey): Query<TData, TError> | undefined {\n this.entries()\n\n return this.get<TData, TError>(key)\n }\n\n findAll(filters: QueryFilters = {}): Array<Query<unknown, unknown>> {\n const { queryKey, exact } = filters\n\n // Reads the reactive `entries()` so findAll() works inside computed().\n const all = this.entries()\n\n if (!queryKey) return all\n\n if (exact) {\n const queryHash = hashKey(queryKey)\n\n return all.filter((query) => query.queryHash === queryHash)\n }\n\n return all.filter((query) => partialMatchKey(query.key, queryKey))\n }\n\n // Generic: a query is invariant in TError (its observers' retry options take\n // the error as an argument), so a typed one isn't a Query<unknown, unknown>.\n remove<TData, TError>(query: Query<TData, TError>): void {\n // Guard on identity, not just the hash: a stale instance (already removed\n // and recreated under the same key) must not evict the current query.\n if (this.getEntry(query.queryHash) === query) {\n // Whoever removes it, gc or removeQueries, it leaves cleaned up: its\n // fetch cancelled and its gc timer cleared.\n query.destroy()\n this.removeEntry(query.queryHash)\n }\n }\n\n override clear(): void {\n this.getAll().forEach((query) => query.destroy())\n super.clear()\n }\n}\n","import { type Signal, signal } from '@angular/core'\nimport {\n catchError,\n concat,\n concatMap,\n defer,\n EMPTY,\n endWith,\n from,\n ignoreElements,\n map,\n of,\n retry as retryOperator,\n take,\n tap,\n throwIfEmpty,\n timer,\n type Observable,\n type Subscription,\n} from 'rxjs'\n\nimport { CancelledError } from './cancelled-error'\nimport type { MutationCache } from './mutation-cache'\nimport { defaultRetryDelay, resolveRetryDelay, shouldRetry } from './retryer'\nimport type { RetryDelayValue, RetryValue } from './types'\nimport { type Deferred, deferred, isPromiseLike } from './utils'\n\n/** Lifecycle status of a mutation: not yet run, running (hooks included), succeeded, or failed. */\nexport type MutationStatus = 'idle' | 'pending' | 'success' | 'error'\n\n/** Selects which mutations an operation applies to (e.g. `injectIsMutating`). */\nexport type MutationFilters = {\n /** Match mutations in this status. */\n status?: MutationStatus\n}\n\n/** Full state snapshot of a mutation (the reactive source behind {@link MutationResult}). */\nexport type MutationState<TData, TError, TVariables, TContext> = {\n /** Current {@link MutationStatus}. */\n status: MutationStatus\n /** Data resolved by the last successful run, or `undefined`. */\n data: TData | undefined\n /** Error of the last failed run, or `null`. */\n error: TError | null\n /** Variables passed to the most recent `mutate()` call. */\n variables: TVariables | undefined\n /** Value returned by `onMutate` for the current run, or what its promise resolved to. */\n context: TContext | undefined\n /** Number of consecutive failed attempts in the current run. */\n failureCount: number\n /** Error of the most recent failed attempt, or `null`. */\n failureReason: TError | null\n /** Timestamp (ms) when the current run was submitted; `0` if never. */\n submittedAt: number\n}\n\n/**\n * What a run's write came to: its data, or the error it failed with. A\n * success also clears the failed attempts that came before it.\n */\ntype Outcome<TData, TError> =\n | {\n status: 'success'\n data: TData\n error: null\n failureCount: 0\n failureReason: null\n }\n | { status: 'error'; data: undefined; error: TError }\n\n/**\n * Configuration for a mutation, passed to {@link injectMutation} /\n * {@link mutationOptions}. The hooks fire in order: `onMutate` →\n * (`onSuccess` | `onError`) → `onSettled`. The value returned by `onMutate`\n * is passed as `context` to the later hooks — handy for rollback.\n *\n * A hook may return a promise: the next step waits for it, and the mutation\n * stays pending until the last hook is done. A hook that fails doesn't change\n * the outcome: its error is rethrown as an unhandled rejection, and the hooks\n * after it still run. Only a failing `onMutate` fails the mutation, before the\n * write is sent.\n */\nexport type MutationOptions<TData, TError, TVariables, TContext> = {\n /** Performs the write; receives `mutate()`'s argument. Returns `Observable`/`Promise`. */\n mutationFn: (variables: TVariables) => Observable<TData> | Promise<TData>\n /** Retry policy. Defaults to no retry (writes are not idempotent). */\n retry?: RetryValue<TError>\n /** Delay between retries. See {@link RetryDelayValue}. */\n retryDelay?: RetryDelayValue<TError>\n /**\n * Runs before `mutationFn`; what it returns becomes `context` (e.g. for\n * optimistic rollback). If it returns a promise, the write waits for it,\n * and `context` is what it resolves to. If it fails, the mutation fails\n * without sending the write.\n */\n onMutate?: (\n variables: TVariables,\n ) => Promise<TContext | undefined> | TContext | undefined\n /** Runs after a successful `mutationFn`. If it returns a promise, `onSettled` waits for it. */\n onSuccess?: (\n data: TData,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n /** Runs after a failed `mutationFn` or `onMutate`. If it returns a promise, `onSettled` waits for it. */\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n /**\n * Runs after success or error — for cleanup that should happen either way.\n * If it returns a promise, the mutation stays pending until it settles.\n */\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n}\n\n/** Reactive result returned by {@link injectMutation}; state fields are signals. */\nexport type MutationResult<TData, TError, TVariables> = {\n /** Triggers the mutation with the given variables. */\n mutate: (variables: TVariables) => void\n /**\n * Triggers the mutation as `mutate()` does, and returns a promise of that\n * run: it resolves with the data once the last hook is done, or rejects\n * with the error once `onError` and `onSettled` are. Unlike `mutate()`, a\n * failure nobody catches surfaces as an unhandled rejection, as with any\n * async call.\n */\n mutateAsync: (variables: TVariables) => Promise<TData>\n /**\n * Resets the state to `idle`. It forgets the result and doesn't stop the\n * request: a run in flight finishes and fires its hooks.\n */\n reset: () => void\n /** Data from the last successful run, or `undefined`. */\n data: Signal<TData | undefined>\n /** Error from the last failed run, or `null`. */\n error: Signal<TError | null>\n /** Variables from the most recent `mutate()` call. */\n variables: Signal<TVariables | undefined>\n /** Current {@link MutationStatus}. */\n status: Signal<MutationStatus>\n /** Whether the mutation has not been run yet. */\n isIdle: Signal<boolean>\n /** Whether the mutation is running, its hooks included. */\n isPending: Signal<boolean>\n /** Whether the last run succeeded. */\n isSuccess: Signal<boolean>\n /** Whether the last run failed. */\n isError: Signal<boolean>\n /** Consecutive failures in the current run. */\n failureCount: Signal<number>\n /** Error of the most recent failed attempt, or `null`. */\n failureReason: Signal<TError | null>\n}\n\n/** @internal */\nexport function getInitialState<\n TData,\n TError,\n TVariables,\n TContext,\n>(): MutationState<TData, TError, TVariables, TContext> {\n return {\n status: 'idle',\n data: undefined,\n error: null,\n variables: undefined,\n context: undefined,\n failureCount: 0,\n failureReason: null,\n submittedAt: 0,\n }\n}\n\n/** @internal */\nexport class Mutation<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n> {\n readonly #state =\n signal<MutationState<TData, TError, TVariables, TContext>>(\n getInitialState(),\n )\n\n // `state` must follow `#state`: a public field can't precede the private\n // field it reads during initialization (field init order).\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly state = this.#state.asReadonly()\n\n #subscription: Subscription | null = null\n // The promise of the run in flight and how to settle it; null once it has\n // settled, or before the run.\n #run: Deferred<TData> | null = null\n #observers = 0\n readonly #options: MutationOptions<TData, TError, TVariables, TContext>\n readonly #cache: MutationCache\n\n constructor(\n readonly mutationId: number,\n options: MutationOptions<TData, TError, TVariables, TContext>,\n cache: MutationCache,\n ) {\n this.#options = options\n this.#cache = cache\n }\n\n get observerCount(): number {\n return this.#observers\n }\n\n addObserver(): void {\n this.#observers++\n }\n\n /**\n * Unlike a query, losing its last observer does not cancel a mutation: the\n * write has most likely reached the server already, so it must be allowed to\n * land and run its hooks. It is only dropped from the cache once it has both\n * settled and been abandoned — whichever of the two happens last.\n */\n removeObserver(): void {\n if (this.#observers === 0) return\n\n this.#observers--\n\n this.#disposeIfDone()\n }\n\n /**\n * Runs the mutation once. `variables` are passed straight to `mutationFn`.\n * Returns a promise of the run, settled as the state is, once its last hook\n * is done: with the data, or with the error.\n */\n execute(variables: TVariables): Promise<TData> {\n const run = deferred<TData>()\n\n this.#run = run\n this.#state.set({\n status: 'pending',\n data: undefined,\n error: null,\n variables,\n context: undefined,\n failureCount: 0,\n failureReason: null,\n submittedAt: Date.now(),\n })\n\n // The outcome is fixed before the hooks that report it run: by onMutate,\n // whose failure calls off the write, then by the write. A hook that fails\n // after that can't turn a write that went through into an error. The run\n // stays pending, and in the cache, until its last hook is done.\n this.#subscription = awaitHook(() => this.#options.onMutate?.(variables))\n .pipe(\n tap((context) =>\n this.#state.update((state) => ({ ...state, context })),\n ),\n concatMap(() => this.#request(variables)),\n map(\n (data): Outcome<TData, TError> => ({\n status: 'success',\n data,\n error: null,\n failureCount: 0,\n failureReason: null,\n }),\n ),\n catchError((error: TError) =>\n of<Outcome<TData, TError>>({\n status: 'error',\n data: undefined,\n error,\n }),\n ),\n concatMap((outcome) =>\n this.#runHooks(outcome, variables).pipe(endWith(outcome)),\n ),\n )\n .subscribe((outcome) => {\n this.#state.update((state) => ({ ...state, ...outcome }))\n this.#run = null\n this.#disposeIfDone()\n\n if (outcome.status === 'success') {\n run.resolve(outcome.data)\n } else {\n run.reject(outcome.error)\n }\n })\n\n return run.promise\n }\n\n // Whoever waits for the run hears that it was cancelled, so its promise\n // doesn't hang.\n cancel(): void {\n this.#subscription?.unsubscribe()\n this.#subscription = null\n this.#run?.reject(new CancelledError('The mutation was cancelled'))\n this.#run = null\n }\n\n /** Sends the write, retrying as `retry` allows, and emits its data once. */\n #request(variables: TVariables): Observable<TData> {\n // Mutations default to no retry (not idempotent — a retried POST could\n // create a duplicate); opt in explicitly via options.retry.\n const retry = this.#options.retry ?? 0\n const retryDelay = this.#options.retryDelay ?? defaultRetryDelay\n\n // defer + from: normalize Observable/Promise and re-invoke mutationFn on\n // each retry (a Promise is one-shot, so retry must produce a fresh one).\n return defer(() => from(this.#options.mutationFn(variables))).pipe(\n take(1),\n retryOperator({\n delay: (error, retryCount) => {\n this.#state.update((state) => ({\n ...state,\n failureCount: retryCount,\n failureReason: error as TError,\n }))\n\n const attemptIndex = retryCount - 1\n\n if (!shouldRetry(retry, attemptIndex, error as TError)) throw error\n\n return timer(\n resolveRetryDelay(retryDelay, attemptIndex, error as TError),\n )\n },\n }),\n throwIfEmpty(\n () => new Error('Mutation function completed without emitting a value'),\n ),\n )\n }\n\n /**\n * Runs the hooks that report an outcome, in order: onSuccess or onError,\n * then onSettled. A hook that returns a promise holds the next one until it\n * settles. One that fails is reported, and the next still runs.\n */\n #runHooks(\n outcome: Outcome<TData, TError>,\n variables: TVariables,\n ): Observable<never> {\n const { context } = this.state()\n\n return concat(\n runHook(() =>\n outcome.status === 'success'\n ? this.#options.onSuccess?.(outcome.data, variables, context)\n : this.#options.onError?.(outcome.error, variables, context),\n ),\n runHook(() =>\n this.#options.onSettled?.(\n outcome.data,\n outcome.error,\n variables,\n context,\n ),\n ),\n )\n }\n\n /**\n * A run nobody observes any more, and which is no longer in flight, has\n * nothing left to report — drop it. Called from both ends, since the two\n * conditions can be met in either order: a superseded run may settle later,\n * and a settled run may be abandoned later.\n */\n #disposeIfDone(): void {\n if (this.#observers > 0) return\n if (this.state().status === 'pending') return\n\n this.#cache.remove(this)\n }\n}\n\n// Calls a hook and waits for the promise it returns, if any. Anything else\n// it returns doesn't wait, so a run whose mutationFn emits synchronously\n// still settles inside mutate().\nfunction awaitHook<T>(hook: () => T | PromiseLike<T>): Observable<T> {\n return defer(() => {\n const result = hook()\n\n return isPromiseLike(result) ? from(result) : of(result)\n })\n}\n\n// Runs a hook that reports an outcome. Only its end matters: what it\n// returns is dropped, and an error it throws is rethrown as an unhandled\n// rejection, so the app's error handling sees it while the run carries on.\nfunction runHook(hook: () => unknown): Observable<never> {\n return awaitHook(hook).pipe(\n ignoreElements(),\n catchError((error: unknown) => {\n void Promise.reject(error)\n\n return EMPTY\n }),\n )\n}\n","import { Injectable } from '@angular/core'\n\nimport { Cache } from './cache'\nimport {\n type MutationFilters,\n type MutationOptions,\n Mutation,\n} from './mutation'\n\n/** @internal */\n@Injectable()\nexport class MutationCache extends Cache<\n Mutation<unknown, unknown, unknown, unknown>\n> {\n #lastId = 0\n\n build<TData, TError, TVariables, TContext>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n ): Mutation<TData, TError, TVariables, TContext> {\n const mutation = new Mutation(++this.#lastId, options, this)\n\n this.addEntry(\n String(mutation.mutationId),\n mutation as Mutation<unknown, unknown, unknown, unknown>,\n )\n\n return mutation\n }\n\n findAll(\n filters: MutationFilters = {},\n ): Array<Mutation<unknown, unknown, unknown, unknown>> {\n // Reads the reactive `entries()` so findAll() works inside computed().\n const all = this.entries()\n\n if (!filters.status) return all\n\n return all.filter((mutation) => mutation.state().status === filters.status)\n }\n\n remove<TData, TError, TVariables, TContext>(\n mutation: Mutation<TData, TError, TVariables, TContext>,\n ): void {\n this.removeEntry(String(mutation.mutationId))\n }\n\n override clear(): void {\n this.getAll().forEach((mutation) => mutation.cancel())\n super.clear()\n }\n}\n","import { InjectionToken } from '@angular/core'\n\nimport type { DefaultOptions } from './types'\n\n/** @internal */\nexport interface QueryClientConfig {\n defaultOptions?: DefaultOptions\n}\n\n/** @internal */\nexport const QUERY_CLIENT_CONFIG = new InjectionToken<QueryClientConfig>(\n 'QUERY_CLIENT_CONFIG',\n)\n","import {\n DestroyRef,\n EnvironmentInjector,\n inject,\n Injectable,\n runInInjectionContext,\n untracked,\n} from '@angular/core'\nimport type { Observable } from 'rxjs'\n\nimport { onReconnect, onWindowFocus } from './browser-events'\nimport { inBrowser } from './platform'\nimport { QueryCache } from './query-cache'\nimport { MutationCache } from './mutation-cache'\nimport type { MutationOptions } from './mutation'\nimport { defaultRetryDelay } from './retryer'\nimport { functionalUpdate, whenAllSettled } from './utils'\nimport type {\n DefaultedQueryOptions,\n InvalidateQueryFilters,\n QueryFilters,\n QueryKey,\n QueryOptions,\n RetryDelayValue,\n RetryValue,\n StructuralSharingValue,\n Updater,\n} from './types'\nimport { QUERY_CLIENT_CONFIG } from './injection-tokens'\n\nconst DEFAULT_GC_TIME = 5 * 60 * 1000\n\n/**\n * Central registry and cache for queries and mutations.\n *\n * Provided by {@link provideQueryClient} and retrieved with\n * {@link injectQueryClient}. Offers imperative cache access — reading and\n * writing data, and invalidating, cancelling, or removing queries — that\n * complements the reactive {@link injectQuery} / {@link injectMutation} APIs.\n *\n * Its methods aren't reactive. Called from an effect, a method doesn't make\n * the effect depend on the cache, on a query's state, or on what `queryFn` or\n * an updater reads: the effect re-runs only when what it reads itself\n * changes. A read is a snapshot, in a template or a `computed` too; for state\n * that updates, use {@link injectQuery}, {@link injectIsFetching} and\n * {@link injectIsMutating}.\n */\n@Injectable()\nexport class QueryClient {\n // Every method that reads or writes the cache runs its body untracked. A\n // call made from an effect mustn't make the effect depend on what the\n // method reads to do its job: the cache, a query's state, or what queryFn\n // or an updater reads. Otherwise a change to any of them re-runs the effect,\n // and the effect repeats the call.\n readonly #cache = inject(QueryCache)\n readonly #mutationCache = inject(MutationCache)\n readonly #config = inject(QUERY_CLIENT_CONFIG, { optional: true }) ?? {}\n readonly #onServer = !inBrowser()\n /** @internal */\n readonly #injector = inject(EnvironmentInjector)\n /**\n * Set once #injector is destroyed. TODO: read DestroyRef.destroyed instead\n * once the minimum supported Angular is 20.1, where it became public.\n *\n * @internal\n */\n #destroyed = false\n\n /** @internal */\n constructor() {\n inject(DestroyRef).onDestroy(() => (this.#destroyed = true))\n\n // When the user comes back to the page, or the network comes back, each\n // query refetches if one of its observers wants that. Untracked like the\n // methods: an event fired from an effect mustn't make the effect depend\n // on what the refetch reads.\n onWindowFocus(() =>\n untracked(() => this.#cache.getAll().forEach((query) => query.onFocus())),\n )\n onReconnect(() =>\n untracked(() =>\n this.#cache.getAll().forEach((query) => query.onOnline()),\n ),\n )\n }\n\n /** Returns the underlying query cache. Advanced/internal use. */\n getQueryCache(): QueryCache {\n return this.#cache\n }\n\n /** Returns the underlying mutation cache. Advanced/internal use. */\n getMutationCache(): MutationCache {\n return this.#mutationCache\n }\n\n /**\n * Merges per-query options with the configured defaults, filling in\n * `staleTime`, `gcTime`, `retry`, `retryDelay`, `structuralSharing`,\n * `refetchOnWindowFocus` and `refetchOnReconnect`. Used internally by\n * {@link injectQuery}.\n */\n defaultQueryOptions<TData, TError = Error>(\n options: QueryOptions<TData, TError>,\n ): DefaultedQueryOptions<TData, TError> {\n const defaults = this.#config.defaultOptions?.queries\n\n return {\n ...options,\n staleTime: options.staleTime ?? defaults?.staleTime ?? 0,\n gcTime: this.#gcTime(options.gcTime),\n retry: options.retry ?? defaults?.retry ?? 3,\n retryDelay:\n options.retryDelay ?? defaults?.retryDelay ?? defaultRetryDelay,\n structuralSharing:\n options.structuralSharing ?? this.#defaultStructuralSharing(),\n refetchOnWindowFocus:\n options.refetchOnWindowFocus ?? defaults?.refetchOnWindowFocus ?? true,\n refetchOnReconnect:\n options.refetchOnReconnect ?? defaults?.refetchOnReconnect ?? true,\n }\n }\n\n /**\n * Fills in what a mutation leaves unset from the configured mutation\n * defaults, field by field. A field set to `undefined` counts as unset. A\n * default hook runs in the injection context of the injector that provides\n * the client.\n *\n * @internal\n */\n defaultMutationOptions<TData, TError, TVariables, TContext>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n ): MutationOptions<TData, TError, TVariables, TContext> {\n const defaults = this.#config.defaultOptions?.mutations\n\n return {\n ...options,\n retry: options.retry ?? defaults?.retry,\n retryDelay: options.retryDelay ?? defaults?.retryDelay,\n onSuccess: options.onSuccess ?? this.#inContext(defaults?.onSuccess),\n onError: options.onError ?? this.#inContext(defaults?.onError),\n onSettled: options.onSettled ?? this.#inContext(defaults?.onSettled),\n }\n }\n\n /**\n * Imperatively fetches and caches a query, unless fresh data already exists\n * (governed by `staleTime`). Prefer {@link injectQuery} in components; use\n * this to prefetch, from an event handler or an effect, or to wait for the\n * data, e.g. in a route resolver.\n *\n * Resolves with the data as the cache holds it: at once if it's fresh,\n * otherwise once the fetch lands. A key already fetching is waited for,\n * not fetched again, unless `cancelRefetch` is set. Rejects with the error\n * if the fetch fails. A cancelled fetch resolves with the data the cache\n * holds, or rejects with a {@link CancelledError} if it holds none; a\n * removed query always rejects with one. Nothing has to wait for the\n * promise: a prefetch that fails only leaves the query in `'error'`.\n *\n * Unlike a component's query, it doesn't retry a failure unless `retry` is\n * set here or in {@link withDefaultOptions}, so whoever waits for the data\n * hears of the failure at once.\n *\n * A query no component shows is removed `gcTime` after the fetch lands (the\n * configured default, or 5 minutes), as any unused query is.\n *\n * @param key - The query key to fetch and cache under.\n * @param queryFn - Function returning the data as an `Observable` or `Promise`.\n * @param options - Fetch tuning (`staleTime`, `retry`, `retryDelay`,\n * `structuralSharing`, `cancelRefetch`).\n * @returns A promise of the data.\n *\n * @example\n * ```ts\n * export const todoResolver: ResolveFn<Todo> = (route) => {\n * const http = inject(HttpClient)\n * const id = Number(route.paramMap.get('id'))\n *\n * return injectQueryClient().fetchQuery(['todos', id], () =>\n * http.get<Todo>(`/api/todos/${id}`),\n * )\n * }\n * ```\n */\n fetchQuery<TData>(\n key: QueryKey,\n queryFn: () => Observable<TData> | Promise<TData>,\n options: {\n staleTime?: number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n retry?: RetryValue<any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n retryDelay?: RetryDelayValue<any>\n structuralSharing?: StructuralSharingValue<TData>\n cancelRefetch?: boolean\n } = {},\n ): Promise<TData> {\n return untracked(() => {\n // Resolved as a query's options are, so one set of defaults serves\n // both, except that a failure isn't retried unless asked: whoever waits\n // for the data hears of it at once. cancelRefetch is about this call,\n // not an option of the query.\n const { cancelRefetch, ...queryOptions } = options\n const defaulted = this.defaultQueryOptions<TData>({\n ...queryOptions,\n queryKey: key,\n queryFn,\n retry:\n queryOptions.retry ??\n this.#config.defaultOptions?.queries?.retry ??\n false,\n })\n const query = this.#cache.getOrCreate<TData>(key, defaulted.gcTime)\n\n // A query already in the cache keeps this call's gcTime if it's\n // longer, as it does for each component showing it.\n query.updateGcTime(defaulted.gcTime)\n\n return query.shouldFetch(defaulted.staleTime)\n ? query.fetch(defaulted, { cancelRefetch })\n : Promise.resolve(query.state().data as TData)\n })\n }\n\n /**\n * Reads the current cached data for a query key, or `undefined` if the query\n * is not cached yet. A snapshot: it doesn't update a template, a `computed`\n * or an effect when the data changes. For data that updates, use\n * {@link injectQuery}.\n *\n * @param key - The query key to read.\n * @returns The cached data, or `undefined`.\n */\n getQueryData<TData>(key: QueryKey): TData | undefined {\n return untracked(() => this.#cache.get<TData>(key)?.state().data)\n }\n\n /**\n * Writes data into the cache for a query key, creating the entry if needed.\n * The `updater` may be a value or a function of the previous data; returning\n * `undefined` from the function is a no-op. Useful for optimistic updates.\n *\n * The data is merged like a response (see `structuralSharing`): what didn't\n * change keeps its reference, so writing what the cache holds changes\n * nothing. It merges as the query showing the key asks; with none showing\n * it, the way the cached data was fetched; otherwise by the default.\n *\n * A key no component shows is kept for `gcTime` after the last write, then\n * removed.\n *\n * @param key - The query key to write.\n * @param updater - The new data, or a function `(prev) => next`.\n *\n * @example\n * ```ts\n * client.setQueryData<Todo[]>(['todos'], (prev = []) => [...prev, newTodo])\n * ```\n */\n setQueryData<TData>(\n key: QueryKey,\n updater: Updater<TData | undefined, TData>,\n ): void {\n untracked(() => {\n const query = this.#cache.getOrCreate<TData>(key, this.#gcTime())\n const data = functionalUpdate(updater, query.state().data)\n\n // Matches TanStack: an updater returning undefined is a no-op.\n if (data === undefined) return\n\n // It has no options of its own: it merges the way the query's data was\n // fetched, or by the default before any fetch.\n query.setData(data, {\n structuralSharing:\n query.structuralSharing() ?? this.#defaultStructuralSharing<TData>(),\n })\n })\n }\n\n /**\n * Marks matching queries as stale and refetches the actively observed ones,\n * once per query however many components observe it. The refetch starts\n * right away and replaces a fetch already in flight, which may predate the\n * change. A query with no enabled observer keeps the stale mark and\n * refetches as soon as one appears. Commonly called after a mutation\n * succeeds.\n *\n * Resolves once those refetches have settled, so a mutation hook that\n * returns it keeps the mutation pending until the data is fresh. It never\n * rejects: a refetch that fails shows in its query's `error`.\n *\n * @param filters - Which queries to invalidate; omit to invalidate all.\n * `refetchType: 'none'` only marks them, and resolves at once.\n *\n * @example\n * ```ts\n * client.invalidateQueries({ queryKey: ['todos'] })\n * ```\n */\n invalidateQueries(filters?: InvalidateQueryFilters): Promise<void> {\n return untracked(() => {\n const queries = this.#cache.findAll(filters)\n\n queries.forEach((query) => query.invalidate())\n\n // An inactive query refetches when next observed, as shouldFetch sees\n // the flag.\n return filters?.refetchType === 'none'\n ? Promise.resolve()\n : whenAllSettled(queries.map((query) => query.refetchIfActive()))\n })\n }\n\n /**\n * Refetches the matching queries that a component shows, whether their\n * data is stale or not, once per query however many components show it. A\n * fetch already in flight is replaced. Queries nobody shows are left as\n * they are, not even marked stale: to have them refetch once they're shown,\n * invalidate them with `invalidateQueries()`.\n *\n * Resolves once the refetches have settled. It never rejects: a refetch\n * that fails shows in its query's `error`.\n *\n * @param filters - Which queries to refetch; omit to refetch all.\n *\n * @example\n * ```ts\n * await client.refetchQueries({ queryKey: ['todos'] })\n * ```\n */\n refetchQueries(filters?: QueryFilters): Promise<void> {\n return untracked(() =>\n whenAllSettled(\n this.#cache.findAll(filters).map((query) => query.refetchIfActive()),\n ),\n )\n }\n\n /**\n * Cancels any in-flight fetches for matching queries. Each query goes back\n * to how it was before its fetch: one that failed and was being tried\n * again shows its error again. Data written meanwhile stays, and so does a\n * stale mark from `invalidateQueries()`.\n *\n * @param filters - Which queries to cancel; omit to cancel all.\n */\n cancelQueries(filters?: QueryFilters): void {\n untracked(() =>\n this.#cache.findAll(filters).forEach((query) => query.cancel()),\n )\n }\n\n /**\n * Removes matching queries from the cache entirely, discarding their data\n * and cancelling their fetches. Nothing is refetched: a component still\n * showing a removed key keeps what it shows until something puts the key\n * back in the cache (a write, a refetch, another component, its own\n * polling), then shows what the cache holds, as after a key change.\n *\n * @param filters - Which queries to remove; omit to remove all.\n */\n removeQueries(filters?: QueryFilters): void {\n untracked(() =>\n this.#cache\n .findAll(filters)\n .forEach((query) => this.#cache.remove(query)),\n )\n }\n\n /**\n * Returns the number of matching queries currently fetching. A snapshot: it\n * doesn't update a template, a `computed` or an effect. For a count that\n * updates, use {@link injectIsFetching}.\n *\n * @param filters - Which queries to count; omit to count all.\n */\n isFetching(filters?: QueryFilters): number {\n return untracked(() => {\n const fetching = this.#cache\n .findAll(filters)\n .filter((query) => query.state().isFetching)\n\n return fetching.length\n })\n }\n\n /**\n * Returns the number of mutations currently pending. A snapshot: it doesn't\n * update a template, a `computed` or an effect. For a count that updates,\n * use {@link injectIsMutating}.\n */\n isMutating(): number {\n return untracked(\n () => this.#mutationCache.findAll({ status: 'pending' }).length,\n )\n }\n\n /**\n * How long a query stays in the cache once nothing uses it: the gcTime it\n * asks for, else the configured default, else 5 minutes. Every path that\n * puts a query into the cache takes it from here.\n *\n * On the server it's Infinity, whatever was asked: the cache lives as long\n * as the app that renders the request, and a pending timer would hold up a\n * render with zone.js.\n *\n * @internal\n */\n #gcTime(time?: number): number {\n if (this.#onServer) return Infinity\n\n return (\n time ?? this.#config.defaultOptions?.queries?.gcTime ?? DEFAULT_GC_TIME\n )\n }\n\n /**\n * The configured default structuralSharing, or `true`. One default serves\n * every query whatever its data, so a function there takes and returns\n * `unknown`; it's typed as the query's own here.\n *\n * @internal\n */\n #defaultStructuralSharing<TData>(): StructuralSharingValue<TData> {\n return (this.#config.defaultOptions?.queries?.structuralSharing ??\n true) as StructuralSharingValue<TData>\n }\n\n /**\n * Runs a default hook in the injection context of the injector that\n * provides the client, so it can call inject(). The defaults belong to the\n * app, so it's this injector, not the component that started the run.\n *\n * @internal\n */\n #inContext<TArgs extends unknown[]>(\n hook: ((...args: TArgs) => unknown) | undefined,\n ): ((...args: TArgs) => unknown) | undefined {\n if (!hook) return\n\n return (...args) => {\n // Once that injector is destroyed, the app the defaults belong to is\n // gone: a run that lands after it, e.g. after its test has ended,\n // skips them.\n if (this.#destroyed) return\n\n return runInInjectionContext(this.#injector, () => hook(...args))\n }\n }\n}\n","import type { Provider } from '@angular/core'\n\n/**\n * Discriminator identifying each kind of {@link QueryClientFeature}.\n *\n * @internal\n */\nexport enum QueryClientFeatureKind {\n DefaultOptions,\n}\n\n/**\n * An opaque feature passed to {@link provideQueryClient}. Create one with a\n * `with*` helper such as {@link withDefaultOptions} rather than constructing it\n * directly; the `ɵ`-prefixed members are internal.\n */\nexport interface QueryClientFeature<\n K extends QueryClientFeatureKind = QueryClientFeatureKind,\n> {\n ɵkind: K\n ɵproviders: Provider[]\n}\n\n/** @internal */\nexport function queryClientFeature<K extends QueryClientFeatureKind>(\n kind: K,\n providers: Provider[],\n): QueryClientFeature<K> {\n return { ɵkind: kind, ɵproviders: providers }\n}\n","import {\n type EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport { QueryCache } from './query-cache'\nimport { MutationCache } from './mutation-cache'\nimport {\n type QueryClientFeature,\n QueryClientFeatureKind,\n} from '../features/feature'\n\n/**\n * Registers the {@link QueryClient} and its caches for the application.\n *\n * Call once at the app root (in `ApplicationConfig.providers` or a root\n * `bootstrapApplication`). Pass features such as {@link withDefaultOptions} to\n * configure defaults. Registering the same feature twice throws.\n *\n * @param features - Optional {@link QueryClientFeature}s (e.g.\n * {@link withDefaultOptions}).\n * @returns Environment providers to add to the app's provider list.\n *\n * @example\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideHttpClient(),\n * provideQueryClient(\n * withDefaultOptions({ queries: { staleTime: 30_000 } }),\n * ),\n * ],\n * }\n * ```\n */\nexport function provideQueryClient(\n ...features: QueryClientFeature[]\n): EnvironmentProviders {\n const seenKinds = new Set<QueryClientFeatureKind>()\n\n for (const feature of features) {\n if (seenKinds.has(feature.ɵkind)) {\n throw new Error(\n `provideQueryClient: feature \"${QueryClientFeatureKind[feature.ɵkind]}\" is registered more than once`,\n )\n }\n seenKinds.add(feature.ɵkind)\n }\n\n return makeEnvironmentProviders([\n QueryCache,\n MutationCache,\n QueryClient,\n ...features.flatMap((feature) => feature.ɵproviders),\n ])\n}\n","import { type Injector, assertInInjectionContext, inject } from '@angular/core'\n\nimport { QueryClient } from './query-client'\n\n/**\n * Returns the application's {@link QueryClient} for imperative cache access.\n *\n * Use it to read or write cached data (`getQueryData`, `setQueryData`) and to\n * invalidate, cancel, or remove queries — typically from mutation hooks or\n * event handlers. Requires {@link provideQueryClient} to be registered.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param options - Optional `injector` to use outside an injection context.\n * @returns The shared {@link QueryClient} instance.\n *\n * @example\n * ```ts\n * const client = injectQueryClient()\n * client.setQueryData<Todo[]>(['todos'], (prev = []) => [...prev, newTodo])\n * client.invalidateQueries({ queryKey: ['todos'] })\n * ```\n */\nexport function injectQueryClient(options?: {\n injector?: Injector\n}): QueryClient {\n if (!options?.injector) assertInInjectionContext(injectQueryClient)\n\n return options?.injector?.get(QueryClient) ?? inject(QueryClient)\n}\n","/**\n * Calls `poll` every `ms`, but never sooner than `ms` after `updatedAt()`:\n * when the timer comes due earlier, it waits out the rest of the interval\n * from then. Returns a function that stops polling.\n *\n * @internal\n */\nexport function startPolling(\n ms: number,\n updatedAt: () => number,\n poll: () => void,\n): () => void {\n let timer: ReturnType<typeof setTimeout>\n\n const wait = (delay: number): void => {\n timer = setTimeout(() => {\n const elapsed = Date.now() - updatedAt()\n\n if (elapsed < ms) {\n wait(ms - elapsed)\n\n return\n }\n\n poll()\n wait(ms)\n }, delay)\n }\n\n wait(ms)\n\n return () => clearTimeout(timer)\n}\n","import {\n type EffectCleanupRegisterFn,\n type EffectRef,\n type Injector,\n computed,\n effect,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { startPolling } from './polling'\nimport { QueryClient } from './query-client'\nimport type { Query, QuerySubscriber } from './query'\nimport type {\n PlaceholderDataFunction,\n QueryKey,\n QueryOptions,\n QueryResult,\n QueryStatus,\n} from './types'\nimport { hashKey, isValidTimeout } from './utils'\n\n/**\n * One observed query: its reactive {@link QueryResult} and a `destroy()` that\n * ends the observation (drops the cache observer, stops polling).\n *\n * @internal\n */\nexport interface QueryObserver<TData, TError = Error> {\n result: QueryResult<TData, TError>\n destroy: () => void\n}\n\n/**\n * Observes a single query and exposes its state as signals — the engine behind\n * {@link injectQuery} and {@link injectQueries}.\n *\n * Nothing is evaluated on creation: `optionsFn` is first called by the first\n * effect run or the first read of a result signal, so it may depend on state\n * that isn't ready while the owner is being constructed (inputs, fields\n * declared later).\n *\n * Effects are created on `injector` with `manualCleanup` so the observer can be\n * torn down on its own via `destroy()`, independently of the injector's\n * lifetime (a component may drop one query out of many). In a component\n * injector they run as view effects, elsewhere as root effects — the same as\n * `effect()` called directly in that context.\n *\n * @internal\n */\nexport function createQueryObserver<TData, TError = Error>(\n optionsFn: () => QueryOptions<TData, TError>,\n injector: Injector,\n): QueryObserver<TData, TError> {\n const client = injector.get(QueryClient)\n const cache = client.getQueryCache()\n\n // Every effect is registered here so destroy() covers all of them.\n const refs: EffectRef[] = []\n const track = (fn: (onCleanup: EffectCleanupRegisterFn) => void): void => {\n refs.push(effect(fn, { injector, manualCleanup: true }))\n }\n\n // Single source of truth for defaulted options; resolves config defaults\n // (staleTime, gcTime) once instead of scattering the logic across effects.\n const defaultedOptions = computed(() =>\n client.defaultQueryOptions(optionsFn()),\n )\n\n // Seed a fresh query (status 'pending', no data yet) with initialData so\n // it renders immediately as 'success'. Without an explicit\n // initialDataUpdatedAt the seed is treated as fetched right now, so\n // staleTime applies to it as it would to any other data (a staleTime of 0\n // still means \"stale immediately\" → background refetch). A function that\n // returns undefined has nothing to seed, so the query stays 'pending' and\n // fetches; it is asked again whenever the key is resolved while the query\n // is still pending, and seeds it if it has data by then, as in TanStack.\n const applyInitialData = (q: Query<TData, TError>): void => {\n const { initialData, initialDataUpdatedAt } = untracked(defaultedOptions)\n\n if (initialData === undefined || q.state().status !== 'pending') return\n\n const data =\n typeof initialData === 'function'\n ? (initialData as () => TData | undefined)()\n : initialData\n\n if (data === undefined) return\n\n const updatedAt =\n typeof initialDataUpdatedAt === 'function'\n ? initialDataUpdatedAt()\n : (initialDataUpdatedAt ?? Date.now())\n\n q.setData(data, { updatedAt })\n }\n\n // Resolves the query for a key, seeding a fresh one with initialData. It\n // writes signals (the cache's entries, the query's state), so callers run it\n // untracked: reached from a computed, a tracked write throws NG0600.\n const resolve = (key: QueryKey): Query<TData, TError> => {\n const q = cache.getOrCreate<TData, TError>(\n key,\n untracked(defaultedOptions).gcTime,\n )\n\n applyInitialData(q)\n\n return q\n }\n\n // The query the observer last switched to, by the key effect or the follow\n // effect below; unset until the key effect first runs.\n const switched = signal<Query<TData, TError> | undefined>(undefined)\n\n // The observed query, resolved lazily: on the first read of a result signal\n // or the first effect run, whichever comes first. Resolving it calls\n // optionsFn, which may read inputs or fields that don't exist yet while the\n // owner is being constructed. A read before the key effect's first run\n // resolves the current key on the spot, so it already sees cached data and\n // initialData; from then on the key and follow effects switch queries.\n const query = computed(\n () => switched() ?? untracked(() => resolve(defaultedOptions().queryKey)),\n )\n\n // Data of the last query that had any, fed to the placeholderData function\n // on a switch: a key change, or the key coming back after a removal\n // (mirrors TanStack's lastQueryWithDefinedData). Captured synchronously\n // before the switch so it can't miss a just-resolved value.\n const lastData = signal<TData | undefined>(undefined)\n\n // Switches the observer to q, first keeping the data of the query it\n // leaves for the placeholderData function.\n const switchTo = (q: Query<TData, TError>): void => {\n untracked(() => {\n const prev = switched()\n\n if (prev && prev !== q && prev.state().data !== undefined) {\n lastData.set(prev.state().data)\n }\n })\n switched.set(q)\n }\n\n track(() => {\n const key = defaultedOptions().queryKey\n\n switchTo(untracked(() => resolve(key)))\n })\n\n // The query cached under the key right now, read reactively: undefined once\n // removeQueries drops it, and the new entry once something brings the key\n // back.\n const cached = computed(() =>\n cache.find<TData, TError>(defaultedOptions().queryKey),\n )\n\n // After removeQueries the observer keeps the query the cache dropped and\n // shows what it had: nothing here brings the key back, as in TanStack, where\n // a removal doesn't refetch. Whatever does bring it back (a write, a refetch,\n // another component, a poll), the observer follows it there as on a key\n // change: resolve() seeds initialData into an entry still pending. Without\n // this, it would see the new entry only once its options change.\n track(() => {\n const entry = cached()\n\n if (!entry || entry === untracked(switched)) return\n\n switchTo(untracked(() => resolve(entry.key)))\n })\n\n // How this observer would fetch q right now, and when it wants q\n // refetched, from the live options; null while it is disabled, or once the\n // key has moved on. Before the key effect above catches up, queryFn already\n // fetches the next query's data, so q must not be fetched with it. Every\n // refetch made on our behalf goes by it: through q's subscriber handle the\n // invalidation one and the window focus and reconnect ones, and polling.\n const fetchOptionsFor = (\n q: Query<TData, TError>,\n ): ReturnType<QuerySubscriber<TData, TError>['fetchOptions']> => {\n const {\n queryKey,\n queryFn,\n retry,\n retryDelay,\n structuralSharing,\n staleTime,\n refetchOnWindowFocus,\n refetchOnReconnect,\n enabled,\n } = untracked(defaultedOptions)\n\n if (enabled === false || hashKey(queryKey) !== q.queryHash) {\n return null\n }\n\n return {\n queryFn,\n retry,\n retryDelay,\n structuralSharing,\n staleTime,\n refetchOnWindowFocus,\n refetchOnReconnect,\n }\n }\n\n track((cleanup) => {\n const q = query()\n\n q.updateGcTime(untracked(defaultedOptions).gcTime)\n\n // This observer as q sees it.\n const subscriber: QuerySubscriber<TData, TError> = {\n fetchOptions: () => fetchOptionsFor(q),\n structuralSharing: () => untracked(defaultedOptions).structuralSharing,\n }\n\n q.addObserver(subscriber)\n cleanup(() => q.removeObserver(subscriber))\n })\n\n // Memoized so options re-evaluations that leave the flag alone don't wake\n // the fetch and polling effects.\n const enabled = computed(() => defaultedOptions().enabled !== false)\n\n // Fetch when the observed query switches (key change) or when it becomes\n // enabled — not on every re-evaluation of the options. defaultQueryOptions()\n // builds a fresh object each time, so tracking it whole would refetch stale\n // data whenever any signal read in optionsFn changes, even one unrelated to\n // the key. queryFn, staleTime and the retry policy only parameterise the\n // fetch and are read untracked (TanStack's shouldFetchOptionally).\n // Invalidation isn't a trigger: invalidateQueries() refetches each active\n // query once itself. A query it skipped (unobserved, or its observers\n // disabled) stays invalidated, so it fetches here once observed or enabled:\n // shouldFetch sees the flag. The key and queryFn come from one read of the\n // options, so the fetch can't go to another key's query, whatever order the\n // effects run in.\n track(() => {\n query()\n\n if (!enabled()) return\n\n untracked(() => {\n const options = defaultedOptions()\n const q = resolve(options.queryKey)\n\n if (q.shouldFetch(options.staleTime)) q.fetch(options)\n })\n })\n\n // The polling interval this observer asks for, or false for none. Memoized,\n // so the polling effect wakes only when the value changes. The function form\n // is resolved against the query's state, so it is re-resolved on every\n // update of it, and a switch to false stops polling. 0 means no polling, and\n // so does a value no timer can hold: the timer would fire over and over.\n const interval = computed(() => {\n const { refetchInterval } = defaultedOptions()\n const value =\n typeof refetchInterval === 'function'\n ? refetchInterval({ state: query().state() })\n : refetchInterval\n\n return isValidTimeout(value) && value > 0 ? value : false\n })\n\n // Polling: refetch on an interval, independent of staleTime. The timer\n // restarts when the observed query switches, or when enabled or the interval\n // changes, as in TanStack's setOptions. It doesn't restart on every\n // re-evaluation of the options: defaultQueryOptions() builds a fresh object\n // each time, so tracking it whole would restart the timer whenever any\n // signal read in optionsFn changes. One that changes faster than the\n // interval would keep it from ever firing.\n //\n // Each poll comes ms after the query's last update, as in TanStack, whose\n // observer restarts its timer on every update of the query. So a fetch made\n // for any reason (another observer's poll, refetch(), an invalidation) or a\n // cache write pushes the next poll back. However many observers poll a key,\n // it's fetched once per interval. Unlike TanStack, the wait counts from\n // updatedAt, the last response or cache write, not from any change of\n // state: a fetch that starts or fails doesn't push it back.\n track((onCleanup) => {\n const q = query()\n\n if (!enabled()) return\n\n const ms = interval()\n\n if (!ms) return\n\n // Fetches the key with the options as they are when it fires, which may\n // have changed since the effect ran. The key's entry is q, unless\n // removeQueries dropped it: then the poll puts the key back, as TanStack's\n // observer does before every fetch, and the follow effect moves this\n // observer there.\n const poll = (): void => {\n const options = fetchOptionsFor(q)\n\n if (options) {\n resolve(q.key).fetch(options)\n }\n }\n\n onCleanup(startPolling(ms, () => q.state().updatedAt, poll))\n })\n\n // Placeholder layer: while the query is pending with no data, present\n // placeholderData as already-successful data. Purely presentational — the\n // cache entry stays 'pending' and the fetch proceeds, so isFetching keeps\n // reporting the real request and the placeholder is dropped on resolve.\n const resolved = computed<{\n data: TData | undefined\n status: QueryStatus\n isPlaceholderData: boolean\n }>(() => {\n const state = query().state()\n const { placeholderData } = defaultedOptions()\n\n if (\n placeholderData !== undefined &&\n state.data === undefined &&\n state.status === 'pending'\n ) {\n const data =\n typeof placeholderData === 'function'\n ? (placeholderData as PlaceholderDataFunction<TData>)(lastData())\n : placeholderData\n\n if (data !== undefined) {\n return { data, status: 'success', isPlaceholderData: true }\n }\n }\n\n return { data: state.data, status: state.status, isPlaceholderData: false }\n })\n\n const result: QueryResult<TData, TError> = {\n data: computed(() => resolved().data),\n status: computed(() => resolved().status),\n error: computed(() => query().state().error as TError | null),\n isFetching: computed(() => query().state().isFetching),\n // A fetch in flight with no data to show: the first one, or a new attempt\n // after a failure. An active placeholder counts as data — the UI shows it,\n // not a loading state.\n isLoading: computed(\n () => query().state().isFetching && resolved().status === 'pending',\n ),\n isPending: computed(() => resolved().status === 'pending'),\n isSuccess: computed(() => resolved().status === 'success'),\n isError: computed(() => resolved().status === 'error'),\n isPlaceholderData: computed(() => resolved().isPlaceholderData),\n failureCount: computed(() => query().state().failureCount),\n failureReason: computed(\n () => query().state().failureReason as TError | null,\n ),\n // Force a fresh fetch regardless of staleTime and enabled, cancelling\n // any in-flight request (explicit user intent — get current data).\n // Untracked, as the client's methods are: called from an effect, it\n // mustn't make the effect depend on the options or on the query. However\n // the fetch ends, the signals show it, so the promise resolves with their\n // data and error and never rejects.\n refetch: () =>\n untracked(() => {\n const options = defaultedOptions()\n\n return resolve(options.queryKey).fetch(options, {\n cancelRefetch: true,\n })\n })\n .catch(() => undefined)\n .then(() => ({ data: result.data(), error: result.error() })),\n }\n\n return {\n result,\n destroy: () => refs.forEach((ref) => ref.destroy()),\n }\n}\n","import {\n assertInInjectionContext,\n DestroyRef,\n inject,\n Injector,\n} from '@angular/core'\n\nimport { createQueryObserver } from './query-observer'\nimport type { QueryOptions, QueryResult } from './types'\n\n/**\n * Runs a cached, reactive query and exposes its state as signals.\n *\n * The query is keyed by `queryKey`: calls with the same key share a single\n * cache entry and in-flight request (deduplication). `optionsFn` is read in a\n * reactive context, so when a value it depends on changes (e.g. a route or\n * input signal in the key), the query automatically switches to the new key\n * and fetches. `optionsFn` isn't called before the query is first needed (its\n * first effect run or the first read of a result signal), so it can read\n * inputs, `input.required` included, and fields declared after the query. The\n * query is bound to the current injection context and cleans up its cache\n * observer when that context is destroyed.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by `queryFn`.\n * @typeParam TError - Type of the error thrown by `queryFn`.\n * @param optionsFn - Factory returning the {@link QueryOptions}. Re-evaluated\n * reactively: a new `queryKey` switches to that query and fetches it, and\n * turning `enabled` on starts the fetch. Re-evaluating with the same key\n * does not refetch, so every value `queryFn` reads belongs in the key.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A {@link QueryResult} of signals (`data`, `status`, `error`,\n * `isLoading`, `isPending`, …) plus a `refetch()` that forces a fresh fetch.\n *\n * @example\n * ```ts\n * @Component({\n * template: `\n * @if (todo.isPending()) { <p>Loading…</p> }\n * @if (todo.data(); as data) { <p>{{ data.title }}</p> }\n * `,\n * })\n * class TodoComponent {\n * readonly id = input.required<number>()\n * private readonly http = inject(HttpClient)\n *\n * // Refetches automatically whenever `id()` changes.\n * readonly todo = injectQuery(() => ({\n * queryKey: ['todo', this.id()],\n * queryFn: () => this.http.get<Todo>(`/api/todos/${this.id()}`),\n * }))\n * }\n * ```\n */\nexport function injectQuery<TData, TError = Error>(\n optionsFn: () => QueryOptions<TData, TError>,\n options?: { injector?: Injector },\n): QueryResult<TData, TError> {\n if (!options?.injector) assertInInjectionContext(injectQuery)\n\n const injector = options?.injector ?? inject(Injector)\n const { result, destroy } = createQueryObserver(optionsFn, injector)\n\n // The observation lives as long as the owning context (component or\n // injector): tear it down with it.\n injector.get(DestroyRef).onDestroy(destroy)\n\n return result\n}\n","import {\n type Signal,\n type WritableSignal,\n assertInInjectionContext,\n computed,\n DestroyRef,\n effect,\n inject,\n Injector,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { type QueryObserver, createQueryObserver } from './query-observer'\nimport type { QueryOptions, QueryResult } from './types'\nimport { hashKey } from './utils'\n\n/** Options for {@link injectQueries}. */\nexport interface InjectQueriesOptions<TData, TError = Error> {\n /**\n * One {@link QueryOptions} per query to run. The array may change between\n * evaluations: queries are matched to the previous set by `queryKey`, so a\n * new key starts a query and a missing key ends one.\n */\n queries: Array<QueryOptions<TData, TError>>\n}\n\n// A query kept alive by injectQueries: its observer plus the signal feeding it\n// options, written in place for as long as the key stays in the list.\ninterface Entry<TData, TError> {\n hash: string\n options: WritableSignal<QueryOptions<TData, TError>>\n observer: QueryObserver<TData, TError>\n}\n\n/**\n * Runs a dynamic number of queries in parallel and exposes their results as a\n * signal holding one {@link QueryResult} per entry of `queries`, in order.\n *\n * Reach for it when the set of queries depends on data — one query per id in\n * a list, say — where {@link injectQuery} can't be called in a loop. Each\n * query behaves exactly like a standalone `injectQuery`: its own cache entry,\n * `staleTime`, retries, error and observer. `optionsFn` is reactive: when the\n * array changes, queries whose `queryKey` is still present are kept (with\n * their options updated), new keys start fetching, and dropped keys release\n * their observer. As with `injectQuery`, `optionsFn` isn't called before the\n * results are first needed, so it can read inputs, `input.required` included,\n * and fields declared after the call. Aggregate across the results with\n * `computed`.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by each `queryFn`.\n * @typeParam TError - Type of the error thrown by each `queryFn`.\n * @param optionsFn - Factory returning the {@link InjectQueriesOptions}.\n * Re-evaluated reactively, so reading signals inside it re-syncs the set.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A signal of {@link QueryResult}s, one per query. The array identity\n * changes only when the set of queries changes, not on every data update.\n *\n * @example\n * ```ts\n * class TodoListComponent {\n * readonly #queries = inject(TodoQueries)\n *\n * readonly todoIds = input.required<number[]>()\n *\n * readonly todos = injectQueries(() => ({\n * queries: this.todoIds().map((id) => this.#queries.detail(id)),\n * }))\n *\n * readonly isPending = computed(() =>\n * this.todos().some((todo) => todo.isPending()),\n * )\n * }\n * ```\n */\nexport function injectQueries<TData, TError = Error>(\n optionsFn: () => InjectQueriesOptions<TData, TError>,\n options?: { injector?: Injector },\n): Signal<Array<QueryResult<TData, TError>>> {\n if (!options?.injector) assertInInjectionContext(injectQueries)\n\n const injector = options?.injector ?? inject(Injector)\n\n let entries: Array<Entry<TData, TError>> = []\n let current: Array<QueryResult<TData, TError>> = []\n let destroyed = false\n\n // Reconciles the entries with a new list, matching by key hash the way\n // TanStack's QueriesObserver does: a matching entry is reused and handed the\n // new options, an unmatched query gets a fresh observer, and whatever is\n // left over is destroyed. Duplicate keys are paired up one-to-one in order.\n const sync = (\n queries: Array<QueryOptions<TData, TError>>,\n ): Array<QueryResult<TData, TError>> => {\n const pool = new Map<string, Array<Entry<TData, TError>>>()\n\n for (const entry of entries) {\n const list = pool.get(entry.hash) ?? []\n\n list.push(entry)\n pool.set(entry.hash, list)\n }\n\n const next = queries.map((queryOptions) => {\n const hash = hashKey(queryOptions.queryKey)\n const match = pool.get(hash)?.shift()\n\n if (match) {\n match.options.set(queryOptions)\n\n return match\n }\n\n const optionsSignal = signal(queryOptions)\n\n return {\n hash,\n options: optionsSignal,\n observer: createQueryObserver(() => optionsSignal(), injector),\n }\n })\n\n for (const leftovers of pool.values()) {\n leftovers.forEach((entry) => entry.observer.destroy())\n }\n\n // Replace the result array only on a structural change, so a computed\n // over it doesn't recompute when merely the options were refreshed.\n const changed =\n next.length !== entries.length ||\n next.some((entry, index) => entry !== entries[index])\n\n entries = next\n\n if (changed) current = entries.map((entry) => entry.observer.result)\n\n return current\n }\n\n // The results of the effect's latest sync; unset until its first run.\n const synced = signal<Array<QueryResult<TData, TError>> | undefined>(\n undefined,\n )\n\n effect(\n () => {\n const { queries } = optionsFn()\n\n untracked(() => synced.set(sync(queries)))\n },\n { injector },\n )\n\n injector.get(DestroyRef).onDestroy(() => {\n destroyed = true\n entries.forEach((entry) => entry.observer.destroy())\n })\n\n // Nothing is synced until first needed: on the first read or the effect's\n // first run, whichever comes first. Syncing calls optionsFn, which may read\n // inputs or fields that don't exist yet while the owner is being\n // constructed. A read before the effect's first run syncs on the spot, so\n // it already sees the queries; once destroyed, it creates nothing.\n return computed(\n () =>\n synced() ?? (destroyed ? [] : untracked(() => sync(optionsFn().queries))),\n )\n}\n","import {\n assertInInjectionContext,\n computed,\n DestroyRef,\n inject,\n Injector,\n runInInjectionContext,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport {\n type Mutation,\n type MutationOptions,\n type MutationResult,\n getInitialState,\n} from './mutation'\n\n/**\n * Creates a mutation for imperative writes (create/update/delete) and exposes\n * its state as signals.\n *\n * Unlike queries, a mutation does not run on its own — call `mutate(variables)`\n * to trigger `mutationFn`. The `onMutate` / `onSuccess` / `onError` /\n * `onSettled` lifecycle hooks make optimistic updates and cache invalidation\n * straightforward. A hook may return a promise; the mutation stays pending\n * until it settles. Mutations do not retry by default (a retried write is not\n * idempotent); opt in via `options.retry`. Whatever of `retry`, `retryDelay`\n * and the `onSuccess` / `onError` / `onSettled` hooks a mutation leaves unset\n * comes from {@link withDefaultOptions}. `mutateAsync(variables)` runs it\n * the same way and returns a promise of the run's data. `mutate()`,\n * `mutateAsync()` and `reset()` are safe to call from an effect: none makes\n * the effect depend on what it reads, such as the options or the previous\n * run. Bound to the current injection\n * context. Destroying it doesn't cancel a run in flight: the write has most\n * likely reached the server, so the run finishes and fires its hooks.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by `mutationFn`.\n * @typeParam TError - Type of the error thrown by `mutationFn`.\n * @typeParam TVariables - Type of the argument passed to `mutate()`.\n * @typeParam TContext - Type returned by `onMutate`, passed to later hooks.\n * @param optionsFn - Factory returning the {@link MutationOptions}.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A {@link MutationResult}: `mutate()`, `mutateAsync()`, `reset()`,\n * and state signals (`status`, `data`, `error`, `isPending`, …).\n *\n * @example\n * ```ts\n * const client = injectQueryClient()\n *\n * const addTodo = injectMutation(() => ({\n * mutationFn: (title: string) => http.post<Todo>('/api/todos', { title }),\n * onSuccess: () => client.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * // <button (click)=\"addTodo.mutate('Buy milk')\" [disabled]=\"addTodo.isPending()\">Add</button>\n * ```\n */\nexport function injectMutation<\n TData,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n optionsFn: () => MutationOptions<TData, TError, TVariables, TContext>,\n options?: { injector?: Injector },\n): MutationResult<TData, TError, TVariables> {\n if (!options?.injector) assertInInjectionContext(injectMutation)\n\n const injector = options?.injector ?? inject(Injector)\n\n return runInInjectionContext(injector, () => {\n const client = inject(QueryClient)\n const cache = client.getMutationCache()\n\n // Every mutate() builds its own Mutation. Sharing one across calls meant a\n // second call overwrote the first's subscription (orphaning the request)\n // and its state (so the slower run, not the latest one, decided the result).\n const current = signal<Mutation<\n TData,\n TError,\n TVariables,\n TContext\n > | null>(null)\n\n // Detaching is all we do on destroy. A run still in flight keeps going —\n // the write has most likely reached the server already, so cancelling it\n // would only skip onSuccess and leave the cache out of sync. It drops\n // itself from the cache once it settles with nobody watching.\n inject(DestroyRef).onDestroy(() => untracked(current)?.removeObserver())\n\n const state = computed(\n () =>\n current()?.state() ??\n getInitialState<TData, TError, TVariables, TContext>(),\n )\n\n // mutate(), mutateAsync() and reset() run untracked, as the QueryClient's\n // methods do. A call made from an effect mustn't make the effect depend on\n // what they read to do their job: the previous run's state, the options,\n // or what onMutate and mutationFn read. Otherwise a change to any of them\n // re-runs the effect, and the effect repeats the call.\n //\n // Starts a run for mutate() and mutateAsync(), makes it the run the\n // signals below follow, and returns its promise.\n const start = (variables: TVariables): Promise<TData> =>\n untracked(() => {\n // Stop observing the previous run. It isn't cancelled — if it's\n // still in flight it finishes and fires its hooks; it just no longer\n // feeds the signals below.\n current()?.removeObserver()\n\n // Options are read per call, so a signal used in them stays live.\n const run = cache.build(client.defaultMutationOptions(optionsFn()))\n\n run.addObserver()\n current.set(run)\n\n return run.execute(variables)\n })\n\n return {\n // The outcome shows in the signals; a failure mustn't surface as an\n // unhandled rejection too.\n mutate: (variables) => {\n start(variables).catch(() => undefined)\n },\n mutateAsync: start,\n reset: () =>\n untracked(() => {\n // \"Forget the result\", not \"stop the request\". A run still in\n // flight keeps going and fires its hooks, so the cache stays in step\n // with the server — cancelling could not un-send the write anyway,\n // it could only hide the fact that it happened.\n current()?.removeObserver()\n\n current.set(null)\n }),\n data: computed(() => state().data),\n error: computed(() => state().error as TError | null),\n variables: computed(() => state().variables),\n status: computed(() => state().status),\n isIdle: computed(() => state().status === 'idle'),\n isPending: computed(() => state().status === 'pending'),\n isSuccess: computed(() => state().status === 'success'),\n isError: computed(() => state().status === 'error'),\n failureCount: computed(() => state().failureCount),\n failureReason: computed(() => state().failureReason as TError | null),\n }\n })\n}\n","import {\n type Injector,\n type Signal,\n assertInInjectionContext,\n computed,\n inject,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport type { QueryFilters } from './types'\n\n/**\n * Returns a signal with the number of queries currently fetching — useful for a\n * global loading indicator.\n *\n * Pass {@link QueryFilters} to count only matching queries; omit them to count\n * every fetching query in the cache.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param filters - Optional filters (e.g. `{ queryKey: ['todos'] }`) to narrow\n * the count.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A `Signal<number>` of active fetches.\n *\n * @example\n * ```ts\n * readonly isFetching = injectIsFetching()\n * // <app-spinner *ngIf=\"isFetching() > 0\" />\n * ```\n */\nexport function injectIsFetching(\n filters?: QueryFilters,\n options?: { injector?: Injector },\n): Signal<number> {\n if (!options?.injector) assertInInjectionContext(injectIsFetching)\n\n const client = options?.injector?.get(QueryClient) ?? inject(QueryClient)\n const cache = client.getQueryCache()\n\n return computed(\n () =>\n cache.findAll(filters).filter((query) => query.state().isFetching).length,\n )\n}\n","import {\n type Injector,\n type Signal,\n assertInInjectionContext,\n computed,\n inject,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\n\n/**\n * Returns a signal with the number of mutations currently pending, including\n * those still running their hooks — useful for a global \"saving…\" indicator.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A `Signal<number>` of in-flight mutations.\n *\n * @example\n * ```ts\n * readonly isMutating = injectIsMutating()\n * // <p *ngIf=\"isMutating() > 0\">Saving…</p>\n * ```\n */\nexport function injectIsMutating(options?: {\n injector?: Injector\n}): Signal<number> {\n if (!options?.injector) assertInInjectionContext(injectIsMutating)\n\n const client = options?.injector?.get(QueryClient) ?? inject(QueryClient)\n const cache = client.getMutationCache()\n\n return computed(() => cache.findAll({ status: 'pending' }).length)\n}\n","import type { QueryOptions } from './types'\n\n/**\n * Identity helper that defines a typed, reusable set of {@link QueryOptions}.\n *\n * Returns the options unchanged at runtime, but anchors type inference so the\n * same definition can be shared across {@link injectQuery},\n * {@link QueryClient.setQueryData}, and friends without re-declaring generics.\n * Keeping query definitions in a service (rather than inline) makes them easy\n * to reuse and unit-test.\n *\n * @typeParam TData - Type of the data resolved by `queryFn`.\n * @typeParam TError - Type of the error thrown by `queryFn`.\n * @param options - The {@link QueryOptions} to define.\n * @returns The same `options`, typed.\n *\n * @example\n * ```ts\n * @Injectable({ providedIn: 'root' })\n * class TodoQueries {\n * private readonly http = inject(HttpClient)\n *\n * todos() {\n * return queryOptions({\n * queryKey: ['todos'],\n * queryFn: () => this.http.get<Todo[]>('/api/todos'),\n * })\n * }\n * }\n *\n * // const todos = injectQuery(() => inject(TodoQueries).todos())\n * ```\n */\nexport function queryOptions<TData, TError = Error>(\n options: QueryOptions<TData, TError>,\n): QueryOptions<TData, TError> {\n return options\n}\n","/**\n * Placeholder function that keeps the previous query's data visible while the\n * next one loads — pass as `placeholderData` to avoid flicker when the query\n * key changes (e.g. pagination, search).\n *\n * While the placeholder is shown, `status` reads `'success'` and\n * `isPlaceholderData()` is `true`; `isFetching()` stays `true` so the UI can\n * indicate the data is stale.\n *\n * @example\n * ```ts\n * readonly todos = injectQuery(() => ({\n * queryKey: ['todos', this.page()],\n * queryFn: () => this.http.get<Todo[]>(`/api/todos?page=${this.page()}`),\n * placeholderData: keepPreviousData,\n * }))\n * ```\n */\nexport function keepPreviousData<TData>(\n previousData: TData | undefined,\n): TData | undefined {\n return previousData\n}\n","import type { MutationOptions } from './mutation'\n\n/**\n * Identity helper that defines a typed, reusable set of {@link MutationOptions}.\n *\n * Returns the options unchanged at runtime; its job is to anchor type inference\n * (notably linking `TContext` returned by `onMutate` to the later hooks) so a\n * mutation can be defined once in a service and passed to {@link injectMutation}.\n *\n * @typeParam TData - Type of the data resolved by `mutationFn`.\n * @typeParam TError - Type of the error thrown by `mutationFn`.\n * @typeParam TVariables - Type of the argument passed to `mutate()`.\n * @typeParam TContext - Type returned by `onMutate`, passed to later hooks.\n * @param options - The {@link MutationOptions} to define.\n * @returns The same `options`, typed.\n *\n * @example\n * ```ts\n * addTodo() {\n * return mutationOptions({\n * mutationFn: (title: string) => this.http.post<Todo>('/api/todos', { title }),\n * onSuccess: () => this.client.invalidateQueries({ queryKey: ['todos'] }),\n * })\n * }\n * ```\n */\nexport function mutationOptions<\n TData,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n): MutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n","import { QUERY_CLIENT_CONFIG } from '../core/injection-tokens'\nimport type { DefaultOptions } from '../core/types'\nimport {\n type QueryClientFeature,\n QueryClientFeatureKind,\n queryClientFeature,\n} from './feature'\n\n/**\n * Feature for {@link provideQueryClient} that sets application-wide default\n * query and mutation options. A query's or mutation's own options take\n * precedence, field by field.\n *\n * @param options - The {@link DefaultOptions} to apply.\n * @returns A {@link QueryClientFeature} to pass to {@link provideQueryClient}.\n *\n * @example\n * ```ts\n * provideQueryClient(\n * withDefaultOptions({\n * queries: { staleTime: 60_000, retry: 1 },\n * mutations: {\n * onError: (error) => inject(ErrorHandler).handleError(error),\n * },\n * }),\n * )\n * ```\n */\nexport function withDefaultOptions(\n options: DefaultOptions,\n): QueryClientFeature<QueryClientFeatureKind.DefaultOptions> {\n return queryClientFeature(QueryClientFeatureKind.DefaultOptions, [\n { provide: QUERY_CLIENT_CONFIG, useValue: { defaultOptions: options } },\n ])\n}\n","/*\n * Public API Surface of ngx-query\n */\n\nexport * from './lib/core/query-client'\nexport * from './lib/core/provider'\nexport * from './lib/core/inject-query-client'\nexport * from './lib/core/types'\nexport * from './lib/core/inject-query'\nexport * from './lib/core/inject-queries'\nexport * from './lib/core/inject-mutation'\nexport * from './lib/core/inject-is-fetching'\nexport * from './lib/core/inject-is-mutating'\nexport * from './lib/core/query-options'\nexport * from './lib/core/keep-previous-data'\nexport * from './lib/core/mutation-options'\nexport * from './lib/core/cancelled-error'\nexport type {\n MutationFilters,\n MutationOptions,\n MutationResult,\n MutationState,\n MutationStatus,\n} from './lib/core/mutation'\nexport { QueryClientFeatureKind } from './lib/features/feature'\nexport type { QueryClientFeature } from './lib/features/feature'\nexport { withDefaultOptions } from './lib/features/with-default-options'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["retry","retryOperator"],"mappings":";;;;;;AAGA;;;;;;;AAOG;SACa,SAAS,GAAA;AACvB,IAAA,OAAO,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/C;;ACNA;;;;;;;;;;;AAWG;AACG,SAAU,aAAa,CAAC,QAAoB,EAAA;IAChD,IAAI,CAAC,SAAS,EAAE;QAAE;AAElB,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAEjC,IAAA,SAAS,CAAC,QAAQ,EAAE,kBAAkB;AACnC,SAAA,IAAI,CACH,MAAM,CAAC,MAAM,QAAQ,CAAC,eAAe,KAAK,QAAQ,CAAC,EACnD,kBAAkB,EAAE;AAErB,SAAA,SAAS,CAAC,MAAM,QAAQ,EAAE,CAAC;AAChC;AAEA;;;;;;;;;AASG;AACG,SAAU,WAAW,CAAC,QAAoB,EAAA;IAC9C,IAAI,CAAC,SAAS,EAAE;QAAE;IAElB,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,WAAW;AAE3C,IAAA,IAAI,CAAC,MAAM;QAAE;AAEb,IAAA,SAAS,CAAC,MAAM,EAAE,QAAQ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AAC,cAAc,EAAE;QAC/D,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE;AACxE,KAAA,CAAC;AACJ;;AClCA;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ngx-signal-query.mjs","sources":["../../../projects/ngx-signal-query/src/lib/core/platform.ts","../../../projects/ngx-signal-query/src/lib/core/browser-events.ts","../../../projects/ngx-signal-query/src/lib/core/cache.ts","../../../projects/ngx-signal-query/src/lib/core/utils.ts","../../../projects/ngx-signal-query/src/lib/core/cancelled-error.ts","../../../projects/ngx-signal-query/src/lib/core/retryer.ts","../../../projects/ngx-signal-query/src/lib/core/query.ts","../../../projects/ngx-signal-query/src/lib/core/query-cache.ts","../../../projects/ngx-signal-query/src/lib/core/mutation.ts","../../../projects/ngx-signal-query/src/lib/core/mutation-cache.ts","../../../projects/ngx-signal-query/src/lib/core/injection-tokens.ts","../../../projects/ngx-signal-query/src/lib/core/query-client.ts","../../../projects/ngx-signal-query/src/lib/features/feature.ts","../../../projects/ngx-signal-query/src/lib/core/provider.ts","../../../projects/ngx-signal-query/src/lib/core/inject-query-client.ts","../../../projects/ngx-signal-query/src/lib/core/polling.ts","../../../projects/ngx-signal-query/src/lib/core/query-observer.ts","../../../projects/ngx-signal-query/src/lib/core/inject-query.ts","../../../projects/ngx-signal-query/src/lib/core/inject-queries.ts","../../../projects/ngx-signal-query/src/lib/core/inject-mutation.ts","../../../projects/ngx-signal-query/src/lib/core/inject-is-fetching.ts","../../../projects/ngx-signal-query/src/lib/core/inject-is-mutating.ts","../../../projects/ngx-signal-query/src/lib/core/query-options.ts","../../../projects/ngx-signal-query/src/lib/core/keep-previous-data.ts","../../../projects/ngx-signal-query/src/lib/core/mutation-options.ts","../../../projects/ngx-signal-query/src/lib/features/with-default-options.ts","../../../projects/ngx-signal-query/src/public-api.ts","../../../projects/ngx-signal-query/src/ngx-signal-query.ts"],"sourcesContent":["import { isPlatformBrowser } from '@angular/common'\nimport { PLATFORM_ID, inject } from '@angular/core'\n\n/**\n * Whether the app runs in the browser rather than on the server. On the\n * server, DOCUMENT is an emulated document that has listeners, a window and\n * no visibilityState: only the platform tells. Must run in an injection\n * context.\n *\n * @internal\n */\nexport function inBrowser(): boolean {\n return isPlatformBrowser(inject(PLATFORM_ID))\n}\n","import { DOCUMENT } from '@angular/common'\nimport { inject } from '@angular/core'\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop'\nimport { filter, fromEvent } from 'rxjs'\n\nimport { inBrowser } from './platform'\n\n/**\n * Calls `listener` whenever the user comes back to the page, as the tab or\n * the window turns visible again. The window's `focus` event isn't used: it\n * also fires when an alert or a file picker closes, or on coming back from\n * DevTools, with the user on the page all along.\n *\n * Listens until the current injector is destroyed, and only in the browser:\n * on the server there is no page to come back to. Must run in an injection\n * context.\n *\n * @internal\n */\nexport function onWindowFocus(listener: () => void): void {\n if (!inBrowser()) return\n\n const document = inject(DOCUMENT)\n\n fromEvent(document, 'visibilitychange')\n .pipe(\n filter(() => document.visibilityState !== 'hidden'),\n takeUntilDestroyed(),\n )\n .subscribe(() => listener())\n}\n\n/**\n * Calls `listener` whenever the browser reports that the network is back\n * (`online`). Each such event means it was off: the browser fires it only\n * when going from offline to online, a page opened offline included.\n *\n * Listens until the current injector is destroyed, and only in the browser.\n * Must run in an injection context.\n *\n * @internal\n */\nexport function onReconnect(listener: () => void): void {\n if (!inBrowser()) return\n\n const window = inject(DOCUMENT).defaultView\n\n if (!window) return\n\n fromEvent(window, 'online')\n .pipe(takeUntilDestroyed())\n .subscribe(() => listener())\n}\n","import { signal } from '@angular/core'\n\n/** @internal */\nexport abstract class Cache<TEntry> {\n readonly #entries = signal<TEntry[]>([])\n\n // Reactive snapshot of all entries; updated on add/remove/clear so that\n // findAll() (and its computed consumers like isFetching) react to the\n // collection. Protected: only subclasses read it, never external code.\n protected readonly entries = this.#entries.asReadonly()\n\n readonly #entriesMap = new Map<string, TEntry>()\n\n getAll(): TEntry[] {\n return Array.from(this.#entriesMap.values())\n }\n\n clear(): void {\n this.#entriesMap.clear()\n this.#sync()\n }\n\n protected addEntry(key: string, entry: TEntry): TEntry {\n this.#entriesMap.set(key, entry)\n this.#sync()\n\n return entry\n }\n\n protected getEntry(key: string): TEntry | undefined {\n return this.#entriesMap.get(key)\n }\n\n protected removeEntry(key: string): boolean {\n const removed = this.#entriesMap.delete(key)\n\n if (removed) this.#sync()\n\n return removed\n }\n\n #sync(): void {\n this.#entries.set(Array.from(this.#entriesMap.values()))\n }\n}\n","import type { QueryKey, StructuralSharingValue, Updater } from './types'\n\n// Resolves an updater: calls it with the previous value if it's a function,\n// otherwise uses it as the value directly.\n/** @internal */\nexport function functionalUpdate<TInput, TOutput>(\n updater: Updater<TInput, TOutput>,\n input: TInput,\n): TOutput {\n return typeof updater === 'function'\n ? (updater as (input: TInput) => TOutput)(input)\n : updater\n}\n\n// True when `filter` is a (deep) prefix of `key`, e.g. ['app'] matches\n// ['app', 1]. Used to invalidate/find groups of queries by partial key.\n/** @internal */\nexport function partialMatchKey(key: QueryKey, filter: QueryKey): boolean {\n return partialDeepEqual(key, filter)\n}\n\nfunction partialDeepEqual(a: unknown, b: unknown): boolean {\n if (a === b) return true\n if (typeof a !== typeof b) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n // An array longer than the key's can't be a prefix of it, even when what\n // it adds is undefined, which an item the key lacks would equal.\n if (Array.isArray(a) && Array.isArray(b) && b.length > a.length) {\n return false\n }\n\n return Object.keys(b).every((key) =>\n partialDeepEqual(\n (a as Record<string, unknown>)[key],\n (b as Record<string, unknown>)[key],\n ),\n )\n }\n\n return false\n}\n\n/** @internal */\nexport function hashKey(key: QueryKey): string {\n return JSON.stringify(key, (_, value) =>\n isPlainObject(value)\n ? Object.keys(value)\n .sort()\n .reduce<Record<string, unknown>>((result, k) => {\n result[k] = value[k]\n\n return result\n }, {})\n : value,\n )\n}\n\n// Copied from: https://github.com/jonschlinkert/is-plain-object\n/** @internal */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isPlainObject(o: any): o is Record<PropertyKey, unknown> {\n if (!hasObjectPrototype(o)) {\n return false\n }\n\n // If has no constructor. Read from the prototype, not the object: JSON data\n // can have its own `constructor` field, even a null one.\n const objectPrototype = Object.getPrototypeOf(o)\n const ctor = objectPrototype?.constructor\n\n if (ctor === undefined) {\n return true\n }\n\n if (typeof ctor !== 'function') {\n return false\n }\n\n // If has modified prototype\n const prot = ctor.prototype\n\n if (!hasObjectPrototype(prot)) {\n return false\n }\n\n // If constructor does not have an Object-specific method\n if (!Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf')) {\n return false\n }\n\n // Handles Objects created by Object.create(<arbitrary prototype>)\n if (objectPrototype !== Object.prototype) {\n return false\n }\n\n // Most likely a plain Object\n return true\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction hasObjectPrototype(o: any): boolean {\n return Object.prototype.toString.call(o) === '[object Object]'\n}\n\n// Past this many levels replaceEqualDeep takes the new value as is.\nconst MAX_SHARING_DEPTH = 500\n\n// Returns `prev` when `next` is deeply equal to it. Otherwise returns `next`\n// with every deeply equal part replaced by the one from `prev`, so whatever\n// didn't change keeps its reference. Only plain objects and arrays are\n// compared, as JSON parsing makes them: any other value (a Date, a class\n// instance, a Map) counts as changed. A value that references itself can't\n// overflow the stack: past MAX_SHARING_DEPTH levels `next` is taken as is.\n// The same algorithm as TanStack Query's replaceEqualDeep.\n/** @internal */\nexport function replaceEqualDeep<T>(prev: unknown, next: T, depth?: number): T\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function replaceEqualDeep(prev: any, next: any, depth = 0): any {\n if (prev === next) return prev\n if (depth > MAX_SHARING_DEPTH) return next\n\n const array = isPlainArray(prev) && isPlainArray(next)\n\n if (!array && !(isPlainObject(prev) && isPlainObject(next))) return next\n\n const prevItems = array ? prev : Object.keys(prev)\n const prevSize = prevItems.length\n const nextItems = array ? next : Object.keys(next)\n const nextSize = nextItems.length\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const copy: any = array ? new Array(nextSize) : {}\n\n let equalItems = 0\n\n for (let i = 0; i < nextSize; i++) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const key: any = array ? i : nextItems[i]\n const prevItem = prev[key]\n const nextItem = next[key]\n\n if (prevItem === nextItem) {\n copy[key] = prevItem\n if (array ? i < prevSize : Object.hasOwn(prev, key)) equalItems++\n continue\n }\n\n if (\n prevItem === null ||\n nextItem === null ||\n typeof prevItem !== 'object' ||\n typeof nextItem !== 'object'\n ) {\n copy[key] = nextItem\n continue\n }\n\n const shared = replaceEqualDeep(prevItem, nextItem, depth + 1)\n\n copy[key] = shared\n if (shared === prevItem) equalItems++\n }\n\n return prevSize === nextSize && equalItems === prevSize ? prev : copy\n}\n\n// An array without holes or extra properties, as JSON parsing makes.\nfunction isPlainArray(value: unknown): value is unknown[] {\n return Array.isArray(value) && value.length === Object.keys(value).length\n}\n\n// Merges new data into the data a query holds, as its structuralSharing\n// option says: shared, as is, or by the option's own function.\n/** @internal */\nexport function replaceData<TData>(\n prevData: TData | undefined,\n data: TData,\n structuralSharing: StructuralSharingValue<TData>,\n): TData {\n if (typeof structuralSharing === 'function') {\n return structuralSharing(prevData, data)\n }\n\n return structuralSharing ? replaceEqualDeep(prevData, data) : data\n}\n\n// The longest delay a browser timer holds, in ms. A longer one overflows and\n// the timer fires at once.\nconst MAX_TIMEOUT = 2 ** 31 - 1\n\n// True for a delay a timer can hold. For anything else, Infinity and negative\n// numbers included, a browser runs the timer at once. TanStack's\n// isValidTimeout checks the same, without the upper bound.\n/** @internal */\nexport function isValidTimeout(value: unknown): value is number {\n return typeof value === 'number' && value >= 0 && value <= MAX_TIMEOUT\n}\n\n// True for a promise, or for anything else with a then method.\n/** @internal */\nexport function isPromiseLike(value: unknown): value is PromiseLike<unknown> {\n return typeof (value as PromiseLike<unknown> | null)?.then === 'function'\n}\n\n// Resolves once every promise has settled, and never rejects. It resolves\n// with nothing: what the promises brought isn't the caller's to see.\n/** @internal */\nexport function whenAllSettled(\n promises: Array<Promise<unknown> | undefined>,\n): Promise<void> {\n return Promise.allSettled(promises).then(() => undefined)\n}\n\n// A promise with the functions that settle it. TODO: use\n// Promise.withResolvers() instead once every browser the supported Angular\n// versions target has it: Safari 17.4, Chrome 119, Firefox 121 (Angular 20\n// still targets Safari 16).\n/** @internal */\nexport interface Deferred<T> {\n promise: Promise<T>\n resolve: (value: T | PromiseLike<T>) => void\n reject: (reason: unknown) => void\n}\n\n/** @internal */\nexport function deferred<T = void>(): Deferred<T> {\n let resolve!: Deferred<T>['resolve']\n let reject!: Deferred<T>['reject']\n const promise = new Promise<T>((res, rej) => {\n resolve = res\n reject = rej\n })\n\n return { promise, resolve, reject }\n}\n","/**\n * The error a promise of a query's data rejects with when the fetch stops\n * with no data to give: it was cancelled before the query had any\n * (`cancelQueries()`, or the last component showing the query went away\n * during an `Observable` fetch), or the query was removed\n * (`removeQueries()`, e.g. on sign-out). The request didn't fail, so tell\n * the two apart with `instanceof CancelledError`.\n *\n * A mutation's `mutateAsync()` rejects with one too, when the mutation cache\n * is cleared while its run is in flight.\n */\nexport class CancelledError extends Error {\n constructor(message = 'The query fetch was cancelled') {\n super(message)\n this.name = 'CancelledError'\n }\n}\n","import type { RetryDelayValue, RetryValue } from './types'\n\n// Exponential backoff capped at 30s, matching TanStack's default.\n/** @internal */\nexport function defaultRetryDelay(failureCount: number): number {\n return Math.min(1000 * 2 ** failureCount, 30000)\n}\n\n/** @internal */\nexport function shouldRetry<TError>(\n retry: RetryValue<TError>,\n failureCount: number,\n error: TError,\n): boolean {\n if (typeof retry === 'function') return retry(failureCount, error)\n if (typeof retry === 'number') return failureCount < retry\n\n return retry\n}\n\n/** @internal */\nexport function resolveRetryDelay<TError>(\n retryDelay: RetryDelayValue<TError>,\n failureCount: number,\n error: TError,\n): number {\n return typeof retryDelay === 'function'\n ? retryDelay(failureCount, error)\n : retryDelay\n}\n","import { signal } from '@angular/core'\nimport {\n defer,\n from,\n isObservable,\n map,\n retry as retryOperator,\n take,\n tap,\n throwIfEmpty,\n timer,\n Subscription,\n} from 'rxjs'\n\nimport { CancelledError } from './cancelled-error'\nimport type { QueryCache } from './query-cache'\nimport { defaultRetryDelay, resolveRetryDelay, shouldRetry } from './retryer'\nimport { type Deferred, deferred, isValidTimeout, replaceData } from './utils'\nimport type {\n DefaultedQueryOptions,\n QueryKey,\n QueryOptions,\n QueryState,\n StructuralSharingValue,\n} from './types'\n\n/**\n * An observer of a query, as the query sees it: the query asks its observers\n * how to fetch it when it refetches on their behalf (after invalidation, on\n * window focus or reconnect), and how data written into it by hand merges.\n *\n * @internal\n */\nexport interface QuerySubscriber<TData, TError = Error> {\n /**\n * How this observer would fetch the query right now, and when it wants it\n * refetched, read from its live options; `null` while it doesn't want the\n * query fetched: it is disabled, or its key has already moved on to another\n * query.\n */\n fetchOptions(): Pick<\n DefaultedQueryOptions<TData, TError>,\n | 'queryFn'\n | 'retry'\n | 'retryDelay'\n | 'structuralSharing'\n | 'staleTime'\n | 'refetchOnWindowFocus'\n | 'refetchOnReconnect'\n > | null\n\n /**\n * How this observer merges data written into the query by hand, read from\n * its live options, whether it's enabled or not.\n */\n structuralSharing(): StructuralSharingValue<TData>\n}\n\n/**\n * What a query is created with: its key and the key's hash, the cache it\n * lives in, and how long it stays there once nothing uses it.\n *\n * @internal\n */\nexport interface QueryConfig {\n key: QueryKey\n queryHash: string\n cache: QueryCache\n gcTime: number\n}\n\n// The fetch in flight, from its first attempt until it lands, fails or is\n// stopped. What it needs lives here and goes with it, so nothing carries over\n// to the next fetch.\ninterface InFlightFetch<TData, TError> {\n // Settles the promise that every caller joining the fetch shares.\n readonly outcome: Deferred<TData>\n // Its attempts: unsubscribing stops them.\n readonly subscription: Subscription\n // The state the fetch started from, or the last write made during it:\n // stopping the fetch with nothing in its place goes back to it (see\n // #stop).\n before: QueryState<TData, TError>\n // The queryFn of whoever asked for the fetch last: the caller that started\n // it, or one that joined it since. A retry falls back to it (see\n // #retryQueryFn).\n queryFn: QueryOptions<TData, TError>['queryFn']\n // Whether stopping the fetch aborts its request: unsubscribing tears an\n // Observable down (HttpClient aborts the request), while a promise runs to\n // the end anyway. Each attempt sets it, so while the fetch waits to retry,\n // the last attempt decides.\n abortable: boolean\n // Set once the last observer leaves while the request runs on: the request\n // lands as usual, but a failure isn't tried again. Whoever joins the fetch\n // wants its data, so joining clears it.\n retriesStopped: boolean\n}\n\n/** @internal */\nexport class Query<TData, TError = Error> {\n readonly key: QueryKey\n readonly queryHash: string\n\n readonly #state = signal<QueryState<TData, TError>>({\n data: undefined,\n status: 'pending',\n error: null,\n isFetching: false,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt: 0,\n })\n\n // `state` must follow `#state`: a public field can't precede the private\n // field it reads during initialization (field init order).\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly state = this.#state.asReadonly()\n\n // The fetch in flight; null while nothing is.\n #inFlight: InFlightFetch<TData, TError> | null = null\n // The structuralSharing of the fetch whose response the query holds.\n #fetchedStructuralSharing: StructuralSharingValue<TData> | undefined\n readonly #observers = new Set<QuerySubscriber<TData, TError>>()\n #gcTime = 0\n #gcTimer: ReturnType<typeof setTimeout> | null = null\n readonly #cache: QueryCache\n\n constructor({ key, queryHash, cache, gcTime }: QueryConfig) {\n this.key = key\n this.queryHash = queryHash\n this.#cache = cache\n this.updateGcTime(gcTime)\n // A new query has nothing using it yet: its creator is about to, and if\n // nothing ever does, gc removes it.\n this.#scheduleGc()\n }\n\n get observerCount(): number {\n return this.#observers.size\n }\n\n // Keeps the longest gcTime asked for by anything that used the query, as\n // in TanStack: whoever created it, each component that showed it, each\n // fetchQuery. A shorter one doesn't cut short a longer one asked for\n // before. Never below 0.\n updateGcTime(ms: number): void {\n this.#gcTime = Math.max(this.#gcTime, ms)\n }\n\n addObserver(observer: QuerySubscriber<TData, TError>): void {\n this.#observers.add(observer)\n this.#clearGcTimer()\n }\n\n removeObserver(observer: QuerySubscriber<TData, TError>): void {\n // An observer this query doesn't have changes nothing: it mustn't cancel\n // the fetch or schedule gc while others still watch.\n if (!this.#observers.delete(observer)) return\n\n // No observers left: nobody waits for the fetch in flight any more. Stop\n // it if that aborts its request; a request that runs on anyway is let\n // land, so its response isn't thrown away, but nobody is left to want a\n // failure tried again. Then schedule gc to dispose the query if no\n // observer returns.\n if (this.#observers.size === 0) {\n if (this.#inFlight?.abortable) this.cancel()\n else if (this.#inFlight) this.#inFlight.retriesStopped = true\n this.#scheduleGc()\n }\n }\n\n // Refetches the query if a component shows it: the first observer that\n // wants it fetched decides how, as in TanStack. A fetch in flight is\n // replaced, as it may predate the change the caller is after. Returns the\n // fetch's promise, or undefined if no observer wants the query fetched.\n refetchIfActive(): Promise<TData> | undefined {\n for (const observer of this.#observers) {\n const options = observer.fetchOptions()\n\n if (options) return this.fetch(options, { cancelRefetch: true })\n }\n\n return\n }\n\n // Refetches the query now that the user is back on the page, if one of its\n // observers wants that: its refetchOnWindowFocus is 'always', or true while\n // the data is stale for its staleTime. The first such observer decides\n // how, as in TanStack.\n onFocus(): void {\n this.#refetchOn('refetchOnWindowFocus')\n }\n\n // The same once the network is back, by refetchOnReconnect.\n onOnline(): void {\n this.#refetchOn('refetchOnReconnect')\n }\n\n // How data written into the query by hand merges with what it holds: as\n // its first observer says, enabled or not; with none, the way its data was\n // fetched; undefined if neither has a say.\n structuralSharing(): StructuralSharingValue<TData> | undefined {\n const [observer] = this.#observers\n\n return observer\n ? observer.structuralSharing()\n : this.#fetchedStructuralSharing\n }\n\n // Without a structuralSharing setting the response is stored as is: the\n // default is the client's to resolve.\n //\n // Returns a promise of the data as the query stores it, which every caller\n // that joins the fetch shares. A fetch that replaces this one settles it\n // with its own outcome; one stopped with nothing in its place settles it as\n // cancel() or destroy() says. Nobody has to wait for it.\n fetch(\n {\n queryFn,\n retry = 0,\n retryDelay = defaultRetryDelay,\n structuralSharing = false,\n }: Pick<\n QueryOptions<TData, TError>,\n 'queryFn' | 'retry' | 'retryDelay' | 'structuralSharing'\n >,\n { cancelRefetch = false }: { cancelRefetch?: boolean } = {},\n ): Promise<TData> {\n const running = this.#inFlight\n\n if (running) {\n // Already in-flight: dedupe unless the caller explicitly wants a fresh\n // fetch (e.g. invalidate/refetch) — then replace the old one. A caller\n // that joins hands its queryFn over for the retries to come, and wants\n // them made, even after the observers the fetch was started for left.\n if (!cancelRefetch) {\n running.queryFn = queryFn\n running.retriesStopped = false\n\n return running.outcome.promise\n }\n\n running.subscription.unsubscribe()\n }\n\n const outcome = deferred<TData>()\n\n // Its result or error lands in the state either way, so a caller may\n // ignore the promise: handled here, a failure doesn't surface as an\n // unhandled rejection, and whoever awaits the promise still gets it.\n outcome.promise.catch(() => undefined)\n // Whoever waits for the fetch this one replaces gets this one's outcome.\n running?.outcome.resolve(outcome.promise)\n\n const inFlight: InFlightFetch<TData, TError> = {\n outcome,\n subscription: new Subscription(),\n // A fetch that replaces one in flight keeps the state the first one\n // started from.\n before: running?.before ?? this.state(),\n queryFn,\n abortable: false,\n retriesStopped: false,\n }\n\n this.#inFlight = inFlight\n\n // A query with no data reads like a first load while it fetches, even\n // after a failure: 'pending' with no error, so a loading state and\n // placeholderData show rather than the old error. One with data keeps\n // its status and error until the response, as in TanStack.\n this.#state.update((state) => ({\n ...state,\n ...(state.data === undefined && { status: 'pending', error: null }),\n isFetching: true,\n failureCount: 0,\n failureReason: null,\n }))\n\n // The first attempt runs the caller's queryFn, each retry the one\n // #retryQueryFn picks. defer + from: normalize Observable/Promise and\n // make a fresh request for each attempt (a Promise is one-shot).\n let firstAttempt = true\n\n const attempts = defer(() => {\n const attemptQueryFn = firstAttempt\n ? queryFn\n : this.#retryQueryFn(inFlight)\n\n firstAttempt = false\n\n const request = attemptQueryFn()\n\n inFlight.abortable = isObservable(request)\n\n return from(request)\n }).pipe(\n take(1),\n retryOperator({\n delay: (error, retryCount) => {\n // retryCount (1-based) is the number of failures so far; the retry\n // predicate/delay take a 0-based attempt index (0 = first retry).\n this.#state.update((state) => ({\n ...state,\n failureCount: retryCount,\n failureReason: error as TError,\n }))\n\n const attemptIndex = retryCount - 1\n\n // Once the last observer left, the failure ends the fetch at once.\n if (\n inFlight.retriesStopped ||\n !shouldRetry(retry, attemptIndex, error as TError)\n ) {\n throw error\n }\n\n // The retry goes out when the wait is over. If the last observer\n // left during the wait, an error thrown when the timer fires ends\n // the fetch with this error instead, as in TanStack; whoever joins\n // meanwhile clears the flag, and the retry goes out on time.\n return timer(\n resolveRetryDelay(retryDelay, attemptIndex, error as TError),\n ).pipe(\n tap(() => {\n if (inFlight.retriesStopped) throw error\n }),\n )\n },\n }),\n throwIfEmpty(\n () => new Error('Query function completed without emitting a value'),\n ),\n // Keeps what didn't change from the data the query holds when the\n // response lands, a write made during the fetch included. After the\n // retries: a structuralSharing function that throws fails the fetch\n // rather than retrying it, or leaving it in flight.\n map((data) => replaceData(this.state().data, data, structuralSharing)),\n )\n\n inFlight.subscription.add(\n attempts.subscribe({\n next: (data) => {\n this.#inFlight = null\n this.#fetchedStructuralSharing = structuralSharing\n this.#state.set({\n data,\n status: 'success',\n error: null,\n isFetching: false,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt: Date.now(),\n })\n outcome.resolve(data)\n this.#scheduleGc()\n },\n error: (err) => {\n this.#inFlight = null\n this.#state.update((state) => ({\n ...state,\n status: 'error',\n error: err,\n isFetching: false,\n }))\n outcome.reject(err)\n this.#scheduleGc()\n },\n }),\n )\n\n return outcome.promise\n }\n\n // Without a structuralSharing setting the data is stored as is: which one\n // a write uses is the client's to resolve.\n setData(\n data: TData,\n {\n updatedAt = Date.now(),\n structuralSharing = false,\n }: {\n updatedAt?: number\n structuralSharing?: StructuralSharingValue<TData>\n } = {},\n ): void {\n this.#state.update((state) => ({\n ...state,\n data: replaceData(state.data, data, structuralSharing),\n status: 'success',\n error: null,\n isInvalidated: false,\n failureCount: 0,\n failureReason: null,\n updatedAt,\n }))\n\n // A write made during a fetch is what stopping the fetch goes back to.\n if (this.#inFlight) this.#inFlight.before = this.state()\n\n // A write counts as use: a query nobody observes is kept for another\n // gcTime, so a setQueryData write isn't collected before anyone shows it.\n this.#scheduleGc()\n }\n\n invalidate(): void {\n this.#state.update((state) => ({ ...state, isInvalidated: true }))\n }\n\n shouldFetch(staleTime: number): boolean {\n const state = this.state()\n\n return (\n state.status !== 'success' ||\n state.isInvalidated ||\n this.#isStale(staleTime)\n )\n }\n\n // Stops the fetch in flight. Whoever waits for it gets the data the query\n // holds, as in TanStack, or a CancelledError if it holds none.\n cancel(): void {\n const { data } = this.state()\n const fetching = this.#inFlight !== null\n\n this.#stop((outcome) =>\n data === undefined\n ? outcome.reject(new CancelledError())\n : outcome.resolve(data),\n )\n\n // Only a fetch that stops can leave the query unused: cancelling none\n // mustn't put off its gc.\n if (fetching) this.#scheduleGc()\n }\n\n // The query is thrown away with its data, so whoever waits for its fetch\n // gets a CancelledError, as in TanStack.\n destroy(): void {\n this.#stop((outcome) => outcome.reject(new CancelledError()))\n this.#clearGcTimer()\n }\n\n // Inclusive: data fetched exactly `staleTime` ago is already stale. This\n // matters for seeded data (initialData is stamped with the current time), so\n // the default staleTime of 0 still means \"stale at once\" → background\n // refetch, rather than depending on whether a millisecond happened to pass.\n #isStale(staleTime: number): boolean {\n return Date.now() - this.state().updatedAt >= staleTime\n }\n\n // Stops the fetch in flight, if any, and settles its promise with settle.\n #stop(settle: (outcome: Deferred<TData>) => void): void {\n const inFlight = this.#inFlight\n\n if (!inFlight) return\n\n inFlight.subscription.unsubscribe()\n this.#inFlight = null\n settle(inFlight.outcome)\n\n const { before } = inFlight\n\n // The fetch is no longer running, so isFetching mustn't stay stuck true,\n // and what the fetch wrote over goes back to how it was: a query that\n // failed shows its error again, as in TanStack. Data and the stale mark\n // aren't the fetch's to put back: they stay as written meanwhile, so an\n // invalidation made during the fetch still holds.\n this.#state.update((state) => ({\n ...state,\n status: before.status,\n error: before.error,\n failureCount: before.failureCount,\n failureReason: before.failureReason,\n isFetching: false,\n }))\n }\n\n // A fetch in flight is kept, as in TanStack, and the observers aren't even\n // asked: fetch() would drop the refetch anyway.\n #refetchOn(option: 'refetchOnWindowFocus' | 'refetchOnReconnect'): void {\n if (this.#inFlight) return\n\n for (const observer of this.#observers) {\n const options = observer.fetchOptions()\n\n if (!options || options[option] === false) continue\n\n if (options[option] === 'always' || this.shouldFetch(options.staleTime)) {\n this.fetch(options)\n\n return\n }\n }\n }\n\n // The queryFn a retry runs: that of the first observer that wants the\n // query fetched, as for a refetch, else that of whoever asked for the\n // fetch last. Not simply the one the fetch started with: a queryFn may\n // read its key's value only when it runs, as `() => api(this.id())` does,\n // and by the retry its component may have moved on to another key. An\n // observer whose key moved on doesn't want this query fetched.\n #retryQueryFn(\n inFlight: InFlightFetch<TData, TError>,\n ): QueryOptions<TData, TError>['queryFn'] {\n for (const observer of this.#observers) {\n const options = observer.fetchOptions()\n\n if (options) return options.queryFn\n }\n\n return inFlight.queryFn\n }\n\n // Removes the query gcTime from now, unless something uses it by then: an\n // observer, or a fetch of it in flight. Called whenever the query may have\n // become unused: when it's created, when its last observer leaves, when a\n // fetch of it ends, when data is written into it by hand.\n #scheduleGc(): void {\n this.#clearGcTimer()\n\n // While observed, the query is in use: the last observer leaving calls\n // this again. Infinity, or a gcTime no timer can hold, keeps the query\n // until something removes it: a browser would run the timer at once.\n if (this.#observers.size > 0 || !isValidTimeout(this.#gcTime)) return\n\n this.#gcTimer = setTimeout(() => {\n this.#gcTimer = null\n\n // A fetch still in flight keeps it: the fetch's end calls this again.\n if (!this.#inFlight) this.#cache.remove(this)\n }, this.#gcTime)\n }\n\n #clearGcTimer(): void {\n if (this.#gcTimer === null) return\n\n clearTimeout(this.#gcTimer)\n this.#gcTimer = null\n }\n}\n","import { Injectable } from '@angular/core'\n\nimport { Cache } from './cache'\nimport { hashKey, partialMatchKey } from './utils'\nimport { Query } from './query'\nimport type { QueryFilters, QueryKey } from './types'\n\n/** @internal */\n@Injectable()\nexport class QueryCache extends Cache<Query<unknown, unknown>> {\n getOrCreate<TData, TError = Error>(\n key: QueryKey,\n gcTime: number,\n ): Query<TData, TError> {\n const queryHash = hashKey(key)\n const exist = this.getEntry(queryHash)\n\n if (exist) return exist as Query<TData, TError>\n\n return this.addEntry(\n queryHash,\n new Query({ key, queryHash, cache: this, gcTime }),\n ) as Query<TData, TError>\n }\n\n get<TData, TError = Error>(key: QueryKey): Query<TData, TError> | undefined {\n return this.getEntry(hashKey(key)) as Query<TData, TError> | undefined\n }\n\n /**\n * Like get(), but reactive, as findAll() is: a computed or an effect that\n * calls it re-runs when an entry is added or removed.\n */\n find<TData, TError = Error>(key: QueryKey): Query<TData, TError> | undefined {\n this.entries()\n\n return this.get<TData, TError>(key)\n }\n\n findAll(filters: QueryFilters = {}): Array<Query<unknown, unknown>> {\n const { queryKey, exact } = filters\n\n // Reads the reactive `entries()` so findAll() works inside computed().\n const all = this.entries()\n\n if (!queryKey) return all\n\n if (exact) {\n const queryHash = hashKey(queryKey)\n\n return all.filter((query) => query.queryHash === queryHash)\n }\n\n return all.filter((query) => partialMatchKey(query.key, queryKey))\n }\n\n // Generic: a query is invariant in TError (its observers' retry options take\n // the error as an argument), so a typed one isn't a Query<unknown, unknown>.\n remove<TData, TError>(query: Query<TData, TError>): void {\n // Guard on identity, not just the hash: a stale instance (already removed\n // and recreated under the same key) must not evict the current query.\n if (this.getEntry(query.queryHash) === query) {\n // Whoever removes it, gc or removeQueries, it leaves cleaned up: its\n // fetch cancelled and its gc timer cleared.\n query.destroy()\n this.removeEntry(query.queryHash)\n }\n }\n\n override clear(): void {\n this.getAll().forEach((query) => query.destroy())\n super.clear()\n }\n}\n","import { type Signal, signal } from '@angular/core'\nimport {\n catchError,\n concat,\n concatMap,\n defer,\n EMPTY,\n endWith,\n from,\n ignoreElements,\n map,\n of,\n retry as retryOperator,\n take,\n tap,\n throwIfEmpty,\n timer,\n type Observable,\n type Subscription,\n} from 'rxjs'\n\nimport { CancelledError } from './cancelled-error'\nimport type { MutationCache } from './mutation-cache'\nimport { defaultRetryDelay, resolveRetryDelay, shouldRetry } from './retryer'\nimport type { RetryDelayValue, RetryValue } from './types'\nimport { type Deferred, deferred, isPromiseLike } from './utils'\n\n/** Lifecycle status of a mutation: not yet run, running (hooks included), succeeded, or failed. */\nexport type MutationStatus = 'idle' | 'pending' | 'success' | 'error'\n\n/** Selects which mutations an operation applies to (e.g. `injectIsMutating`). */\nexport type MutationFilters = {\n /** Match mutations in this status. */\n status?: MutationStatus\n}\n\n/** Full state snapshot of a mutation (the reactive source behind {@link MutationResult}). */\nexport type MutationState<TData, TError, TVariables, TContext> = {\n /** Current {@link MutationStatus}. */\n status: MutationStatus\n /** Data resolved by the last successful run, or `undefined`. */\n data: TData | undefined\n /** Error of the last failed run, or `null`. */\n error: TError | null\n /** Variables passed to the most recent `mutate()` call. */\n variables: TVariables | undefined\n /** Value returned by `onMutate` for the current run, or what its promise resolved to. */\n context: TContext | undefined\n /** Number of consecutive failed attempts in the current run. */\n failureCount: number\n /** Error of the most recent failed attempt, or `null`. */\n failureReason: TError | null\n /** Timestamp (ms) when the current run was submitted; `0` if never. */\n submittedAt: number\n}\n\n/**\n * What a run's write came to: its data, or the error it failed with. A\n * success also clears the failed attempts that came before it.\n */\ntype Outcome<TData, TError> =\n | {\n status: 'success'\n data: TData\n error: null\n failureCount: 0\n failureReason: null\n }\n | { status: 'error'; data: undefined; error: TError }\n\n/**\n * Configuration for a mutation, passed to {@link injectMutation} /\n * {@link mutationOptions}. The hooks fire in order: `onMutate` →\n * (`onSuccess` | `onError`) → `onSettled`. The value returned by `onMutate`\n * is passed as `context` to the later hooks — handy for rollback.\n *\n * A hook may return a promise: the next step waits for it, and the mutation\n * stays pending until the last hook is done. A hook that fails doesn't change\n * the outcome: its error is rethrown as an unhandled rejection, and the hooks\n * after it still run. Only a failing `onMutate` fails the mutation, before the\n * write is sent.\n */\nexport type MutationOptions<TData, TError, TVariables, TContext> = {\n /** Performs the write; receives `mutate()`'s argument. Returns `Observable`/`Promise`. */\n mutationFn: (variables: TVariables) => Observable<TData> | Promise<TData>\n /** Retry policy. Defaults to no retry (writes are not idempotent). */\n retry?: RetryValue<TError>\n /** Delay between retries. See {@link RetryDelayValue}. */\n retryDelay?: RetryDelayValue<TError>\n /**\n * Runs before `mutationFn`; what it returns becomes `context` (e.g. for\n * optimistic rollback). If it returns a promise, the write waits for it,\n * and `context` is what it resolves to. If it fails, the mutation fails\n * without sending the write.\n */\n onMutate?: (\n variables: TVariables,\n ) => Promise<TContext | undefined> | TContext | undefined\n /** Runs after a successful `mutationFn`. If it returns a promise, `onSettled` waits for it. */\n onSuccess?: (\n data: TData,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n /** Runs after a failed `mutationFn` or `onMutate`. If it returns a promise, `onSettled` waits for it. */\n onError?: (\n error: TError,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n /**\n * Runs after success or error — for cleanup that should happen either way.\n * If it returns a promise, the mutation stays pending until it settles.\n */\n onSettled?: (\n data: TData | undefined,\n error: TError | null,\n variables: TVariables,\n context: TContext | undefined,\n ) => Promise<unknown> | unknown\n}\n\n/** Reactive result returned by {@link injectMutation}; state fields are signals. */\nexport type MutationResult<TData, TError, TVariables> = {\n /** Triggers the mutation with the given variables. */\n mutate: (variables: TVariables) => void\n /**\n * Triggers the mutation as `mutate()` does, and returns a promise of that\n * run: it resolves with the data once the last hook is done, or rejects\n * with the error once `onError` and `onSettled` are. Unlike `mutate()`, a\n * failure nobody catches surfaces as an unhandled rejection, as with any\n * async call.\n */\n mutateAsync: (variables: TVariables) => Promise<TData>\n /**\n * Resets the state to `idle`. It forgets the result and doesn't stop the\n * request: a run in flight finishes and fires its hooks.\n */\n reset: () => void\n /** Data from the last successful run, or `undefined`. */\n data: Signal<TData | undefined>\n /** Error from the last failed run, or `null`. */\n error: Signal<TError | null>\n /** Variables from the most recent `mutate()` call. */\n variables: Signal<TVariables | undefined>\n /** Current {@link MutationStatus}. */\n status: Signal<MutationStatus>\n /** Whether the mutation has not been run yet. */\n isIdle: Signal<boolean>\n /** Whether the mutation is running, its hooks included. */\n isPending: Signal<boolean>\n /** Whether the last run succeeded. */\n isSuccess: Signal<boolean>\n /** Whether the last run failed. */\n isError: Signal<boolean>\n /** Consecutive failures in the current run. */\n failureCount: Signal<number>\n /** Error of the most recent failed attempt, or `null`. */\n failureReason: Signal<TError | null>\n}\n\n/** @internal */\nexport function getInitialState<\n TData,\n TError,\n TVariables,\n TContext,\n>(): MutationState<TData, TError, TVariables, TContext> {\n return {\n status: 'idle',\n data: undefined,\n error: null,\n variables: undefined,\n context: undefined,\n failureCount: 0,\n failureReason: null,\n submittedAt: 0,\n }\n}\n\n/** @internal */\nexport class Mutation<\n TData = unknown,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n> {\n readonly #state =\n signal<MutationState<TData, TError, TVariables, TContext>>(\n getInitialState(),\n )\n\n // `state` must follow `#state`: a public field can't precede the private\n // field it reads during initialization (field init order).\n // eslint-disable-next-line @typescript-eslint/member-ordering\n readonly state = this.#state.asReadonly()\n\n #subscription: Subscription | null = null\n // The promise of the run in flight and how to settle it; null once it has\n // settled, or before the run.\n #run: Deferred<TData> | null = null\n #observers = 0\n readonly #options: MutationOptions<TData, TError, TVariables, TContext>\n readonly #cache: MutationCache\n\n constructor(\n readonly mutationId: number,\n options: MutationOptions<TData, TError, TVariables, TContext>,\n cache: MutationCache,\n ) {\n this.#options = options\n this.#cache = cache\n }\n\n get observerCount(): number {\n return this.#observers\n }\n\n addObserver(): void {\n this.#observers++\n }\n\n /**\n * Unlike a query, losing its last observer does not cancel a mutation: the\n * write has most likely reached the server already, so it must be allowed to\n * land and run its hooks. It is only dropped from the cache once it has both\n * settled and been abandoned — whichever of the two happens last.\n */\n removeObserver(): void {\n if (this.#observers === 0) return\n\n this.#observers--\n\n this.#disposeIfDone()\n }\n\n /**\n * Runs the mutation once. `variables` are passed straight to `mutationFn`.\n * Returns a promise of the run, settled as the state is, once its last hook\n * is done: with the data, or with the error.\n */\n execute(variables: TVariables): Promise<TData> {\n const run = deferred<TData>()\n\n this.#run = run\n this.#state.set({\n status: 'pending',\n data: undefined,\n error: null,\n variables,\n context: undefined,\n failureCount: 0,\n failureReason: null,\n submittedAt: Date.now(),\n })\n\n // The outcome is fixed before the hooks that report it run: by onMutate,\n // whose failure calls off the write, then by the write. A hook that fails\n // after that can't turn a write that went through into an error. The run\n // stays pending, and in the cache, until its last hook is done.\n this.#subscription = awaitHook(() => this.#options.onMutate?.(variables))\n .pipe(\n tap((context) =>\n this.#state.update((state) => ({ ...state, context })),\n ),\n concatMap(() => this.#request(variables)),\n map(\n (data): Outcome<TData, TError> => ({\n status: 'success',\n data,\n error: null,\n failureCount: 0,\n failureReason: null,\n }),\n ),\n catchError((error: TError) =>\n of<Outcome<TData, TError>>({\n status: 'error',\n data: undefined,\n error,\n }),\n ),\n concatMap((outcome) =>\n this.#runHooks(outcome, variables).pipe(endWith(outcome)),\n ),\n )\n .subscribe((outcome) => {\n this.#state.update((state) => ({ ...state, ...outcome }))\n this.#run = null\n this.#disposeIfDone()\n\n if (outcome.status === 'success') {\n run.resolve(outcome.data)\n } else {\n run.reject(outcome.error)\n }\n })\n\n return run.promise\n }\n\n // Whoever waits for the run hears that it was cancelled, so its promise\n // doesn't hang.\n cancel(): void {\n this.#subscription?.unsubscribe()\n this.#subscription = null\n this.#run?.reject(new CancelledError('The mutation was cancelled'))\n this.#run = null\n }\n\n /** Sends the write, retrying as `retry` allows, and emits its data once. */\n #request(variables: TVariables): Observable<TData> {\n // Mutations default to no retry (not idempotent — a retried POST could\n // create a duplicate); opt in explicitly via options.retry.\n const retry = this.#options.retry ?? 0\n const retryDelay = this.#options.retryDelay ?? defaultRetryDelay\n\n // defer + from: normalize Observable/Promise and re-invoke mutationFn on\n // each retry (a Promise is one-shot, so retry must produce a fresh one).\n return defer(() => from(this.#options.mutationFn(variables))).pipe(\n take(1),\n retryOperator({\n delay: (error, retryCount) => {\n this.#state.update((state) => ({\n ...state,\n failureCount: retryCount,\n failureReason: error as TError,\n }))\n\n const attemptIndex = retryCount - 1\n\n if (!shouldRetry(retry, attemptIndex, error as TError)) throw error\n\n return timer(\n resolveRetryDelay(retryDelay, attemptIndex, error as TError),\n )\n },\n }),\n throwIfEmpty(\n () => new Error('Mutation function completed without emitting a value'),\n ),\n )\n }\n\n /**\n * Runs the hooks that report an outcome, in order: onSuccess or onError,\n * then onSettled. A hook that returns a promise holds the next one until it\n * settles. One that fails is reported, and the next still runs.\n */\n #runHooks(\n outcome: Outcome<TData, TError>,\n variables: TVariables,\n ): Observable<never> {\n const { context } = this.state()\n\n return concat(\n runHook(() =>\n outcome.status === 'success'\n ? this.#options.onSuccess?.(outcome.data, variables, context)\n : this.#options.onError?.(outcome.error, variables, context),\n ),\n runHook(() =>\n this.#options.onSettled?.(\n outcome.data,\n outcome.error,\n variables,\n context,\n ),\n ),\n )\n }\n\n /**\n * A run nobody observes any more, and which is no longer in flight, has\n * nothing left to report — drop it. Called from both ends, since the two\n * conditions can be met in either order: a superseded run may settle later,\n * and a settled run may be abandoned later.\n */\n #disposeIfDone(): void {\n if (this.#observers > 0) return\n if (this.state().status === 'pending') return\n\n this.#cache.remove(this)\n }\n}\n\n// Calls a hook and waits for the promise it returns, if any. Anything else\n// it returns doesn't wait, so a run whose mutationFn emits synchronously\n// still settles inside mutate().\nfunction awaitHook<T>(hook: () => T | PromiseLike<T>): Observable<T> {\n return defer(() => {\n const result = hook()\n\n return isPromiseLike(result) ? from(result) : of(result)\n })\n}\n\n// Runs a hook that reports an outcome. Only its end matters: what it\n// returns is dropped, and an error it throws is rethrown as an unhandled\n// rejection, so the app's error handling sees it while the run carries on.\nfunction runHook(hook: () => unknown): Observable<never> {\n return awaitHook(hook).pipe(\n ignoreElements(),\n catchError((error: unknown) => {\n void Promise.reject(error)\n\n return EMPTY\n }),\n )\n}\n","import { Injectable } from '@angular/core'\n\nimport { Cache } from './cache'\nimport {\n type MutationFilters,\n type MutationOptions,\n Mutation,\n} from './mutation'\n\n/** @internal */\n@Injectable()\nexport class MutationCache extends Cache<\n Mutation<unknown, unknown, unknown, unknown>\n> {\n #lastId = 0\n\n build<TData, TError, TVariables, TContext>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n ): Mutation<TData, TError, TVariables, TContext> {\n const mutation = new Mutation(++this.#lastId, options, this)\n\n this.addEntry(\n String(mutation.mutationId),\n mutation as Mutation<unknown, unknown, unknown, unknown>,\n )\n\n return mutation\n }\n\n findAll(\n filters: MutationFilters = {},\n ): Array<Mutation<unknown, unknown, unknown, unknown>> {\n // Reads the reactive `entries()` so findAll() works inside computed().\n const all = this.entries()\n\n if (!filters.status) return all\n\n return all.filter((mutation) => mutation.state().status === filters.status)\n }\n\n remove<TData, TError, TVariables, TContext>(\n mutation: Mutation<TData, TError, TVariables, TContext>,\n ): void {\n this.removeEntry(String(mutation.mutationId))\n }\n\n override clear(): void {\n this.getAll().forEach((mutation) => mutation.cancel())\n super.clear()\n }\n}\n","import { InjectionToken } from '@angular/core'\n\nimport type { DefaultOptions } from './types'\n\n/** @internal */\nexport interface QueryClientConfig {\n defaultOptions?: DefaultOptions\n}\n\n/** @internal */\nexport const QUERY_CLIENT_CONFIG = new InjectionToken<QueryClientConfig>(\n 'QUERY_CLIENT_CONFIG',\n)\n","import {\n DestroyRef,\n EnvironmentInjector,\n inject,\n Injectable,\n runInInjectionContext,\n untracked,\n} from '@angular/core'\nimport type { Observable } from 'rxjs'\n\nimport { onReconnect, onWindowFocus } from './browser-events'\nimport { inBrowser } from './platform'\nimport { QueryCache } from './query-cache'\nimport { MutationCache } from './mutation-cache'\nimport type { MutationOptions } from './mutation'\nimport { defaultRetryDelay } from './retryer'\nimport { functionalUpdate, whenAllSettled } from './utils'\nimport type {\n DefaultedQueryOptions,\n InvalidateQueryFilters,\n QueryFilters,\n QueryKey,\n QueryOptions,\n RetryDelayValue,\n RetryValue,\n StructuralSharingValue,\n Updater,\n} from './types'\nimport { QUERY_CLIENT_CONFIG } from './injection-tokens'\n\nconst DEFAULT_GC_TIME = 5 * 60 * 1000\n\n/**\n * Central registry and cache for queries and mutations.\n *\n * Provided by {@link provideQueryClient} and retrieved with\n * {@link injectQueryClient}. Offers imperative cache access — reading and\n * writing data, and invalidating, cancelling, or removing queries — that\n * complements the reactive {@link injectQuery} / {@link injectMutation} APIs.\n *\n * Its methods aren't reactive. Called from an effect, a method doesn't make\n * the effect depend on the cache, on a query's state, or on what `queryFn` or\n * an updater reads: the effect re-runs only when what it reads itself\n * changes. A read is a snapshot, in a template or a `computed` too; for state\n * that updates, use {@link injectQuery}, {@link injectIsFetching} and\n * {@link injectIsMutating}.\n */\n@Injectable()\nexport class QueryClient {\n // Every method that reads or writes the cache runs its body untracked. A\n // call made from an effect mustn't make the effect depend on what the\n // method reads to do its job: the cache, a query's state, or what queryFn\n // or an updater reads. Otherwise a change to any of them re-runs the effect,\n // and the effect repeats the call.\n readonly #cache = inject(QueryCache)\n readonly #mutationCache = inject(MutationCache)\n readonly #config = inject(QUERY_CLIENT_CONFIG, { optional: true }) ?? {}\n readonly #onServer = !inBrowser()\n /** @internal */\n readonly #injector = inject(EnvironmentInjector)\n /**\n * Set once #injector is destroyed. TODO: read DestroyRef.destroyed instead\n * once the minimum supported Angular is 20.1, where it became public.\n *\n * @internal\n */\n #destroyed = false\n\n /** @internal */\n constructor() {\n inject(DestroyRef).onDestroy(() => (this.#destroyed = true))\n\n // When the user comes back to the page, or the network comes back, each\n // query refetches if one of its observers wants that. Untracked like the\n // methods: an event fired from an effect mustn't make the effect depend\n // on what the refetch reads.\n onWindowFocus(() =>\n untracked(() => this.#cache.getAll().forEach((query) => query.onFocus())),\n )\n onReconnect(() =>\n untracked(() =>\n this.#cache.getAll().forEach((query) => query.onOnline()),\n ),\n )\n }\n\n /** Returns the underlying query cache. Advanced/internal use. */\n getQueryCache(): QueryCache {\n return this.#cache\n }\n\n /** Returns the underlying mutation cache. Advanced/internal use. */\n getMutationCache(): MutationCache {\n return this.#mutationCache\n }\n\n /**\n * Merges per-query options with the configured defaults, filling in\n * `staleTime`, `gcTime`, `retry`, `retryDelay`, `structuralSharing`,\n * `refetchOnWindowFocus` and `refetchOnReconnect`. Used internally by\n * {@link injectQuery}.\n */\n defaultQueryOptions<TData, TError = Error>(\n options: QueryOptions<TData, TError>,\n ): DefaultedQueryOptions<TData, TError> {\n const defaults = this.#config.defaultOptions?.queries\n\n return {\n ...options,\n staleTime: options.staleTime ?? defaults?.staleTime ?? 0,\n gcTime: this.#gcTime(options.gcTime),\n retry: options.retry ?? defaults?.retry ?? 3,\n retryDelay:\n options.retryDelay ?? defaults?.retryDelay ?? defaultRetryDelay,\n structuralSharing:\n options.structuralSharing ?? this.#defaultStructuralSharing(),\n refetchOnWindowFocus:\n options.refetchOnWindowFocus ?? defaults?.refetchOnWindowFocus ?? true,\n refetchOnReconnect:\n options.refetchOnReconnect ?? defaults?.refetchOnReconnect ?? true,\n }\n }\n\n /**\n * Fills in what a mutation leaves unset from the configured mutation\n * defaults, field by field. A field set to `undefined` counts as unset. A\n * default hook runs in the injection context of the injector that provides\n * the client.\n *\n * @internal\n */\n defaultMutationOptions<TData, TError, TVariables, TContext>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n ): MutationOptions<TData, TError, TVariables, TContext> {\n const defaults = this.#config.defaultOptions?.mutations\n\n return {\n ...options,\n retry: options.retry ?? defaults?.retry,\n retryDelay: options.retryDelay ?? defaults?.retryDelay,\n onSuccess: options.onSuccess ?? this.#inContext(defaults?.onSuccess),\n onError: options.onError ?? this.#inContext(defaults?.onError),\n onSettled: options.onSettled ?? this.#inContext(defaults?.onSettled),\n }\n }\n\n /**\n * Imperatively fetches and caches a query, unless fresh data already exists\n * (governed by `staleTime`). Prefer {@link injectQuery} in components; use\n * this to prefetch, from an event handler or an effect, or to wait for the\n * data, e.g. in a route resolver.\n *\n * Resolves with the data as the cache holds it: at once if it's fresh,\n * otherwise once the fetch lands. A key already fetching is waited for,\n * not fetched again, unless `cancelRefetch` is set. Rejects with the error\n * if the fetch fails. A cancelled fetch resolves with the data the cache\n * holds, or rejects with a {@link CancelledError} if it holds none; a\n * removed query always rejects with one. Nothing has to wait for the\n * promise: a prefetch that fails only leaves the query in `'error'`.\n *\n * Unlike a component's query, it doesn't retry a failure unless `retry` is\n * set here or in {@link withDefaultOptions}, so whoever waits for the data\n * hears of the failure at once.\n *\n * A query no component shows is removed `gcTime` after the fetch lands (the\n * configured default, or 5 minutes), as any unused query is.\n *\n * @param key - The query key to fetch and cache under.\n * @param queryFn - Function returning the data as an `Observable` or `Promise`.\n * @param options - Fetch tuning (`staleTime`, `retry`, `retryDelay`,\n * `structuralSharing`, `cancelRefetch`).\n * @returns A promise of the data.\n *\n * @example\n * ```ts\n * export const todoResolver: ResolveFn<Todo> = (route) => {\n * const http = inject(HttpClient)\n * const id = Number(route.paramMap.get('id'))\n *\n * return injectQueryClient().fetchQuery(['todos', id], () =>\n * http.get<Todo>(`/api/todos/${id}`),\n * )\n * }\n * ```\n */\n fetchQuery<TData>(\n key: QueryKey,\n queryFn: () => Observable<TData> | Promise<TData>,\n options: {\n staleTime?: number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n retry?: RetryValue<any>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n retryDelay?: RetryDelayValue<any>\n structuralSharing?: StructuralSharingValue<TData>\n cancelRefetch?: boolean\n } = {},\n ): Promise<TData> {\n return untracked(() => {\n // Resolved as a query's options are, so one set of defaults serves\n // both, except that a failure isn't retried unless asked: whoever waits\n // for the data hears of it at once. cancelRefetch is about this call,\n // not an option of the query.\n const { cancelRefetch, ...queryOptions } = options\n const defaulted = this.defaultQueryOptions<TData>({\n ...queryOptions,\n queryKey: key,\n queryFn,\n retry:\n queryOptions.retry ??\n this.#config.defaultOptions?.queries?.retry ??\n false,\n })\n const query = this.#cache.getOrCreate<TData>(key, defaulted.gcTime)\n\n // A query already in the cache keeps this call's gcTime if it's\n // longer, as it does for each component showing it.\n query.updateGcTime(defaulted.gcTime)\n\n return query.shouldFetch(defaulted.staleTime)\n ? query.fetch(defaulted, { cancelRefetch })\n : Promise.resolve(query.state().data as TData)\n })\n }\n\n /**\n * Reads the current cached data for a query key, or `undefined` if the query\n * is not cached yet. A snapshot: it doesn't update a template, a `computed`\n * or an effect when the data changes. For data that updates, use\n * {@link injectQuery}.\n *\n * @param key - The query key to read.\n * @returns The cached data, or `undefined`.\n */\n getQueryData<TData>(key: QueryKey): TData | undefined {\n return untracked(() => this.#cache.get<TData>(key)?.state().data)\n }\n\n /**\n * Writes data into the cache for a query key, creating the entry if needed.\n * The `updater` may be a value or a function of the previous data; returning\n * `undefined` from the function is a no-op. Useful for optimistic updates.\n *\n * The data is merged like a response (see `structuralSharing`): what didn't\n * change keeps its reference, so writing what the cache holds changes\n * nothing. It merges as the query showing the key asks; with none showing\n * it, the way the cached data was fetched; otherwise by the default.\n *\n * A key no component shows is kept for `gcTime` after the last write, then\n * removed.\n *\n * @param key - The query key to write.\n * @param updater - The new data, or a function `(prev) => next`.\n *\n * @example\n * ```ts\n * client.setQueryData<Todo[]>(['todos'], (prev = []) => [...prev, newTodo])\n * ```\n */\n setQueryData<TData>(\n key: QueryKey,\n updater: Updater<TData | undefined, TData>,\n ): void {\n untracked(() => {\n const query = this.#cache.getOrCreate<TData>(key, this.#gcTime())\n const data = functionalUpdate(updater, query.state().data)\n\n // Matches TanStack: an updater returning undefined is a no-op.\n if (data === undefined) return\n\n // It has no options of its own: it merges the way the query's data was\n // fetched, or by the default before any fetch.\n query.setData(data, {\n structuralSharing:\n query.structuralSharing() ?? this.#defaultStructuralSharing<TData>(),\n })\n })\n }\n\n /**\n * Marks matching queries as stale and refetches the actively observed ones,\n * once per query however many components observe it. The refetch starts\n * right away and replaces a fetch already in flight, which may predate the\n * change. A query with no enabled observer keeps the stale mark and\n * refetches as soon as one appears. Commonly called after a mutation\n * succeeds.\n *\n * Resolves once those refetches have settled, so a mutation hook that\n * returns it keeps the mutation pending until the data is fresh. It never\n * rejects: a refetch that fails shows in its query's `error`.\n *\n * @param filters - Which queries to invalidate; omit to invalidate all.\n * `refetchType: 'none'` only marks them, and resolves at once.\n *\n * @example\n * ```ts\n * client.invalidateQueries({ queryKey: ['todos'] })\n * ```\n */\n invalidateQueries(filters?: InvalidateQueryFilters): Promise<void> {\n return untracked(() => {\n const queries = this.#cache.findAll(filters)\n\n queries.forEach((query) => query.invalidate())\n\n // An inactive query refetches when next observed, as shouldFetch sees\n // the flag.\n return filters?.refetchType === 'none'\n ? Promise.resolve()\n : whenAllSettled(queries.map((query) => query.refetchIfActive()))\n })\n }\n\n /**\n * Refetches the matching queries that a component shows, whether their\n * data is stale or not, once per query however many components show it. A\n * fetch already in flight is replaced. Queries nobody shows are left as\n * they are, not even marked stale: to have them refetch once they're shown,\n * invalidate them with `invalidateQueries()`.\n *\n * Resolves once the refetches have settled. It never rejects: a refetch\n * that fails shows in its query's `error`.\n *\n * @param filters - Which queries to refetch; omit to refetch all.\n *\n * @example\n * ```ts\n * await client.refetchQueries({ queryKey: ['todos'] })\n * ```\n */\n refetchQueries(filters?: QueryFilters): Promise<void> {\n return untracked(() =>\n whenAllSettled(\n this.#cache.findAll(filters).map((query) => query.refetchIfActive()),\n ),\n )\n }\n\n /**\n * Cancels any in-flight fetches for matching queries. Each query goes back\n * to how it was before its fetch: one that failed and was being tried\n * again shows its error again. Data written meanwhile stays, and so does a\n * stale mark from `invalidateQueries()`.\n *\n * @param filters - Which queries to cancel; omit to cancel all.\n */\n cancelQueries(filters?: QueryFilters): void {\n untracked(() =>\n this.#cache.findAll(filters).forEach((query) => query.cancel()),\n )\n }\n\n /**\n * Removes matching queries from the cache entirely, discarding their data\n * and cancelling their fetches. Nothing is refetched: a component still\n * showing a removed key keeps what it shows until something puts the key\n * back in the cache (a write, a refetch, another component, its own\n * polling), then shows what the cache holds, as after a key change.\n *\n * @param filters - Which queries to remove; omit to remove all.\n */\n removeQueries(filters?: QueryFilters): void {\n untracked(() =>\n this.#cache\n .findAll(filters)\n .forEach((query) => this.#cache.remove(query)),\n )\n }\n\n /**\n * Returns the number of matching queries currently fetching. A snapshot: it\n * doesn't update a template, a `computed` or an effect. For a count that\n * updates, use {@link injectIsFetching}.\n *\n * @param filters - Which queries to count; omit to count all.\n */\n isFetching(filters?: QueryFilters): number {\n return untracked(() => {\n const fetching = this.#cache\n .findAll(filters)\n .filter((query) => query.state().isFetching)\n\n return fetching.length\n })\n }\n\n /**\n * Returns the number of mutations currently pending. A snapshot: it doesn't\n * update a template, a `computed` or an effect. For a count that updates,\n * use {@link injectIsMutating}.\n */\n isMutating(): number {\n return untracked(\n () => this.#mutationCache.findAll({ status: 'pending' }).length,\n )\n }\n\n /**\n * How long a query stays in the cache once nothing uses it: the gcTime it\n * asks for, else the configured default, else 5 minutes. Every path that\n * puts a query into the cache takes it from here.\n *\n * On the server it's Infinity, whatever was asked: the cache lives as long\n * as the app that renders the request, and a pending timer would hold up a\n * render with zone.js.\n *\n * @internal\n */\n #gcTime(time?: number): number {\n if (this.#onServer) return Infinity\n\n return (\n time ?? this.#config.defaultOptions?.queries?.gcTime ?? DEFAULT_GC_TIME\n )\n }\n\n /**\n * The configured default structuralSharing, or `true`. One default serves\n * every query whatever its data, so a function there takes and returns\n * `unknown`; it's typed as the query's own here.\n *\n * @internal\n */\n #defaultStructuralSharing<TData>(): StructuralSharingValue<TData> {\n return (this.#config.defaultOptions?.queries?.structuralSharing ??\n true) as StructuralSharingValue<TData>\n }\n\n /**\n * Runs a default hook in the injection context of the injector that\n * provides the client, so it can call inject(). The defaults belong to the\n * app, so it's this injector, not the component that started the run.\n *\n * @internal\n */\n #inContext<TArgs extends unknown[]>(\n hook: ((...args: TArgs) => unknown) | undefined,\n ): ((...args: TArgs) => unknown) | undefined {\n if (!hook) return\n\n return (...args) => {\n // Once that injector is destroyed, the app the defaults belong to is\n // gone: a run that lands after it, e.g. after its test has ended,\n // skips them.\n if (this.#destroyed) return\n\n return runInInjectionContext(this.#injector, () => hook(...args))\n }\n }\n}\n","import type { Provider } from '@angular/core'\n\n/**\n * Discriminator identifying each kind of {@link QueryClientFeature}.\n *\n * @internal\n */\nexport enum QueryClientFeatureKind {\n DefaultOptions,\n}\n\n/**\n * An opaque feature passed to {@link provideQueryClient}. Create one with a\n * `with*` helper such as {@link withDefaultOptions} rather than constructing it\n * directly; the `ɵ`-prefixed members are internal.\n */\nexport interface QueryClientFeature<\n K extends QueryClientFeatureKind = QueryClientFeatureKind,\n> {\n ɵkind: K\n ɵproviders: Provider[]\n}\n\n/** @internal */\nexport function queryClientFeature<K extends QueryClientFeatureKind>(\n kind: K,\n providers: Provider[],\n): QueryClientFeature<K> {\n return { ɵkind: kind, ɵproviders: providers }\n}\n","import {\n type EnvironmentProviders,\n makeEnvironmentProviders,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport { QueryCache } from './query-cache'\nimport { MutationCache } from './mutation-cache'\nimport {\n type QueryClientFeature,\n QueryClientFeatureKind,\n} from '../features/feature'\n\n/**\n * Registers the {@link QueryClient} and its caches for the application.\n *\n * Call once at the app root (in `ApplicationConfig.providers` or a root\n * `bootstrapApplication`). Pass features such as {@link withDefaultOptions} to\n * configure defaults. Registering the same feature twice throws.\n *\n * @param features - Optional {@link QueryClientFeature}s (e.g.\n * {@link withDefaultOptions}).\n * @returns Environment providers to add to the app's provider list.\n *\n * @example\n * ```ts\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideHttpClient(),\n * provideQueryClient(\n * withDefaultOptions({ queries: { staleTime: 30_000 } }),\n * ),\n * ],\n * }\n * ```\n */\nexport function provideQueryClient(\n ...features: QueryClientFeature[]\n): EnvironmentProviders {\n const seenKinds = new Set<QueryClientFeatureKind>()\n\n for (const feature of features) {\n if (seenKinds.has(feature.ɵkind)) {\n throw new Error(\n `provideQueryClient: feature \"${QueryClientFeatureKind[feature.ɵkind]}\" is registered more than once`,\n )\n }\n seenKinds.add(feature.ɵkind)\n }\n\n return makeEnvironmentProviders([\n QueryCache,\n MutationCache,\n QueryClient,\n ...features.flatMap((feature) => feature.ɵproviders),\n ])\n}\n","import { type Injector, assertInInjectionContext, inject } from '@angular/core'\n\nimport { QueryClient } from './query-client'\n\n/**\n * Returns the application's {@link QueryClient} for imperative cache access.\n *\n * Use it to read or write cached data (`getQueryData`, `setQueryData`) and to\n * invalidate, cancel, or remove queries — typically from mutation hooks or\n * event handlers. Requires {@link provideQueryClient} to be registered.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param options - Optional `injector` to use outside an injection context.\n * @returns The shared {@link QueryClient} instance.\n *\n * @example\n * ```ts\n * const client = injectQueryClient()\n * client.setQueryData<Todo[]>(['todos'], (prev = []) => [...prev, newTodo])\n * client.invalidateQueries({ queryKey: ['todos'] })\n * ```\n */\nexport function injectQueryClient(options?: {\n injector?: Injector\n}): QueryClient {\n if (!options?.injector) assertInInjectionContext(injectQueryClient)\n\n return options?.injector?.get(QueryClient) ?? inject(QueryClient)\n}\n","/**\n * Calls `poll` every `ms`, but never sooner than `ms` after `updatedAt()`:\n * when the timer comes due earlier, it waits out the rest of the interval\n * from then. Returns a function that stops polling.\n *\n * @internal\n */\nexport function startPolling(\n ms: number,\n updatedAt: () => number,\n poll: () => void,\n): () => void {\n let timer: ReturnType<typeof setTimeout>\n\n const wait = (delay: number): void => {\n timer = setTimeout(() => {\n const elapsed = Date.now() - updatedAt()\n\n if (elapsed < ms) {\n wait(ms - elapsed)\n\n return\n }\n\n poll()\n wait(ms)\n }, delay)\n }\n\n wait(ms)\n\n return () => clearTimeout(timer)\n}\n","import {\n type EffectCleanupRegisterFn,\n type EffectRef,\n type Injector,\n computed,\n effect,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { startPolling } from './polling'\nimport { QueryClient } from './query-client'\nimport type { Query, QuerySubscriber } from './query'\nimport type {\n PlaceholderDataFunction,\n QueryKey,\n QueryOptions,\n QueryResult,\n QueryStatus,\n} from './types'\nimport { hashKey, isValidTimeout } from './utils'\n\n/**\n * One observed query: its reactive {@link QueryResult} and a `destroy()` that\n * ends the observation (drops the cache observer, stops polling).\n *\n * @internal\n */\nexport interface QueryObserver<TData, TError = Error> {\n result: QueryResult<TData, TError>\n destroy: () => void\n}\n\n/**\n * Observes a single query and exposes its state as signals — the engine behind\n * {@link injectQuery} and {@link injectQueries}.\n *\n * Nothing is evaluated on creation: `optionsFn` is first called by the first\n * effect run or the first read of a result signal, so it may depend on state\n * that isn't ready while the owner is being constructed (inputs, fields\n * declared later).\n *\n * Effects are created on `injector` with `manualCleanup` so the observer can be\n * torn down on its own via `destroy()`, independently of the injector's\n * lifetime (a component may drop one query out of many). In a component\n * injector they run as view effects, elsewhere as root effects — the same as\n * `effect()` called directly in that context.\n *\n * @internal\n */\nexport function createQueryObserver<TData, TError = Error>(\n optionsFn: () => QueryOptions<TData, TError>,\n injector: Injector,\n): QueryObserver<TData, TError> {\n const client = injector.get(QueryClient)\n const cache = client.getQueryCache()\n\n // Every effect is registered here so destroy() covers all of them.\n const refs: EffectRef[] = []\n const track = (fn: (onCleanup: EffectCleanupRegisterFn) => void): void => {\n refs.push(effect(fn, { injector, manualCleanup: true }))\n }\n\n // Single source of truth for defaulted options; resolves config defaults\n // (staleTime, gcTime) once instead of scattering the logic across effects.\n const defaultedOptions = computed(() =>\n client.defaultQueryOptions(optionsFn()),\n )\n\n // Seed a fresh query (status 'pending', no data yet) with initialData so\n // it renders immediately as 'success'. Without an explicit\n // initialDataUpdatedAt the seed is treated as fetched right now, so\n // staleTime applies to it as it would to any other data (a staleTime of 0\n // still means \"stale immediately\" → background refetch). A function that\n // returns undefined has nothing to seed, so the query stays 'pending' and\n // fetches; it is asked again whenever the key is resolved while the query\n // is still pending, and seeds it if it has data by then, as in TanStack.\n const applyInitialData = (q: Query<TData, TError>): void => {\n const { initialData, initialDataUpdatedAt } = untracked(defaultedOptions)\n\n if (initialData === undefined || q.state().status !== 'pending') return\n\n const data =\n typeof initialData === 'function'\n ? (initialData as () => TData | undefined)()\n : initialData\n\n if (data === undefined) return\n\n const updatedAt =\n typeof initialDataUpdatedAt === 'function'\n ? initialDataUpdatedAt()\n : (initialDataUpdatedAt ?? Date.now())\n\n q.setData(data, { updatedAt })\n }\n\n // Resolves the query for a key, seeding a fresh one with initialData. It\n // writes signals (the cache's entries, the query's state), so callers run it\n // untracked: reached from a computed, a tracked write throws NG0600.\n const resolve = (key: QueryKey): Query<TData, TError> => {\n const q = cache.getOrCreate<TData, TError>(\n key,\n untracked(defaultedOptions).gcTime,\n )\n\n applyInitialData(q)\n\n return q\n }\n\n // The query the observer last switched to, by the key effect or the follow\n // effect below; unset until the key effect first runs.\n const switched = signal<Query<TData, TError> | undefined>(undefined)\n\n // The observed query, resolved lazily: on the first read of a result signal\n // or the first effect run, whichever comes first. Resolving it calls\n // optionsFn, which may read inputs or fields that don't exist yet while the\n // owner is being constructed. A read before the key effect's first run\n // resolves the current key on the spot, so it already sees cached data and\n // initialData; from then on the key and follow effects switch queries.\n const query = computed(\n () => switched() ?? untracked(() => resolve(defaultedOptions().queryKey)),\n )\n\n // Data of the last query that had any, fed to the placeholderData function\n // on a switch: a key change, or the key coming back after a removal\n // (mirrors TanStack's lastQueryWithDefinedData). Captured synchronously\n // before the switch so it can't miss a just-resolved value.\n const lastData = signal<TData | undefined>(undefined)\n\n // Switches the observer to q, first keeping the data of the query it\n // leaves for the placeholderData function.\n const switchTo = (q: Query<TData, TError>): void => {\n untracked(() => {\n const prev = switched()\n\n if (prev && prev !== q && prev.state().data !== undefined) {\n lastData.set(prev.state().data)\n }\n })\n switched.set(q)\n }\n\n track(() => {\n const key = defaultedOptions().queryKey\n\n switchTo(untracked(() => resolve(key)))\n })\n\n // The query cached under the key right now, read reactively: undefined once\n // removeQueries drops it, and the new entry once something brings the key\n // back.\n const cached = computed(() =>\n cache.find<TData, TError>(defaultedOptions().queryKey),\n )\n\n // After removeQueries the observer keeps the query the cache dropped and\n // shows what it had: nothing here brings the key back, as in TanStack, where\n // a removal doesn't refetch. Whatever does bring it back (a write, a refetch,\n // another component, a poll), the observer follows it there as on a key\n // change: resolve() seeds initialData into an entry still pending. Without\n // this, it would see the new entry only once its options change.\n track(() => {\n const entry = cached()\n\n if (!entry || entry === untracked(switched)) return\n\n switchTo(untracked(() => resolve(entry.key)))\n })\n\n // How this observer would fetch q right now, and when it wants q\n // refetched, from the live options; null while it is disabled, or once the\n // key has moved on. Before the key effect above catches up, queryFn already\n // fetches the next query's data, so q must not be fetched with it. Every\n // refetch made on our behalf goes by it: through q's subscriber handle the\n // invalidation one and the window focus and reconnect ones, and polling.\n const fetchOptionsFor = (\n q: Query<TData, TError>,\n ): ReturnType<QuerySubscriber<TData, TError>['fetchOptions']> => {\n const {\n queryKey,\n queryFn,\n retry,\n retryDelay,\n structuralSharing,\n staleTime,\n refetchOnWindowFocus,\n refetchOnReconnect,\n enabled,\n } = untracked(defaultedOptions)\n\n if (enabled === false || hashKey(queryKey) !== q.queryHash) {\n return null\n }\n\n return {\n queryFn,\n retry,\n retryDelay,\n structuralSharing,\n staleTime,\n refetchOnWindowFocus,\n refetchOnReconnect,\n }\n }\n\n track((cleanup) => {\n const q = query()\n\n q.updateGcTime(untracked(defaultedOptions).gcTime)\n\n // This observer as q sees it.\n const subscriber: QuerySubscriber<TData, TError> = {\n fetchOptions: () => fetchOptionsFor(q),\n structuralSharing: () => untracked(defaultedOptions).structuralSharing,\n }\n\n q.addObserver(subscriber)\n cleanup(() => q.removeObserver(subscriber))\n })\n\n // Memoized so options re-evaluations that leave the flag alone don't wake\n // the fetch and polling effects.\n const enabled = computed(() => defaultedOptions().enabled !== false)\n\n // Fetch when the observed query switches (key change) or when it becomes\n // enabled — not on every re-evaluation of the options. defaultQueryOptions()\n // builds a fresh object each time, so tracking it whole would refetch stale\n // data whenever any signal read in optionsFn changes, even one unrelated to\n // the key. queryFn, staleTime and the retry policy only parameterise the\n // fetch and are read untracked (TanStack's shouldFetchOptionally).\n // Invalidation isn't a trigger: invalidateQueries() refetches each active\n // query once itself. A query it skipped (unobserved, or its observers\n // disabled) stays invalidated, so it fetches here once observed or enabled:\n // shouldFetch sees the flag. The key and queryFn come from one read of the\n // options, so the fetch can't go to another key's query, whatever order the\n // effects run in.\n track(() => {\n query()\n\n if (!enabled()) return\n\n untracked(() => {\n const options = defaultedOptions()\n const q = resolve(options.queryKey)\n\n if (q.shouldFetch(options.staleTime)) q.fetch(options)\n })\n })\n\n // The polling interval this observer asks for, or false for none. Memoized,\n // so the polling effect wakes only when the value changes. The function form\n // is resolved against the query's state, so it is re-resolved on every\n // update of it, and a switch to false stops polling. 0 means no polling, and\n // so does a value no timer can hold: the timer would fire over and over.\n const interval = computed(() => {\n const { refetchInterval } = defaultedOptions()\n const value =\n typeof refetchInterval === 'function'\n ? refetchInterval({ state: query().state() })\n : refetchInterval\n\n return isValidTimeout(value) && value > 0 ? value : false\n })\n\n // Polling: refetch on an interval, independent of staleTime. The timer\n // restarts when the observed query switches, or when enabled or the interval\n // changes, as in TanStack's setOptions. It doesn't restart on every\n // re-evaluation of the options: defaultQueryOptions() builds a fresh object\n // each time, so tracking it whole would restart the timer whenever any\n // signal read in optionsFn changes. One that changes faster than the\n // interval would keep it from ever firing.\n //\n // Each poll comes ms after the query's last update, as in TanStack, whose\n // observer restarts its timer on every update of the query. So a fetch made\n // for any reason (another observer's poll, refetch(), an invalidation) or a\n // cache write pushes the next poll back. However many observers poll a key,\n // it's fetched once per interval. Unlike TanStack, the wait counts from\n // updatedAt, the last response or cache write, not from any change of\n // state: a fetch that starts or fails doesn't push it back.\n track((onCleanup) => {\n const q = query()\n\n if (!enabled()) return\n\n const ms = interval()\n\n if (!ms) return\n\n // Fetches the key with the options as they are when it fires, which may\n // have changed since the effect ran. The key's entry is q, unless\n // removeQueries dropped it: then the poll puts the key back, as TanStack's\n // observer does before every fetch, and the follow effect moves this\n // observer there.\n const poll = (): void => {\n const options = fetchOptionsFor(q)\n\n if (options) {\n resolve(q.key).fetch(options)\n }\n }\n\n onCleanup(startPolling(ms, () => q.state().updatedAt, poll))\n })\n\n // Placeholder layer: while the query is pending with no data, present\n // placeholderData as already-successful data. Purely presentational — the\n // cache entry stays 'pending' and the fetch proceeds, so isFetching keeps\n // reporting the real request and the placeholder is dropped on resolve.\n const resolved = computed<{\n data: TData | undefined\n status: QueryStatus\n isPlaceholderData: boolean\n }>(() => {\n const state = query().state()\n const { placeholderData } = defaultedOptions()\n\n if (\n placeholderData !== undefined &&\n state.data === undefined &&\n state.status === 'pending'\n ) {\n const data =\n typeof placeholderData === 'function'\n ? (placeholderData as PlaceholderDataFunction<TData>)(lastData())\n : placeholderData\n\n if (data !== undefined) {\n return { data, status: 'success', isPlaceholderData: true }\n }\n }\n\n return { data: state.data, status: state.status, isPlaceholderData: false }\n })\n\n const result: QueryResult<TData, TError> = {\n data: computed(() => resolved().data),\n status: computed(() => resolved().status),\n error: computed(() => query().state().error as TError | null),\n isFetching: computed(() => query().state().isFetching),\n // A fetch in flight with no data to show: the first one, or a new attempt\n // after a failure. An active placeholder counts as data — the UI shows it,\n // not a loading state.\n isLoading: computed(\n () => query().state().isFetching && resolved().status === 'pending',\n ),\n isPending: computed(() => resolved().status === 'pending'),\n isSuccess: computed(() => resolved().status === 'success'),\n isError: computed(() => resolved().status === 'error'),\n isPlaceholderData: computed(() => resolved().isPlaceholderData),\n failureCount: computed(() => query().state().failureCount),\n failureReason: computed(\n () => query().state().failureReason as TError | null,\n ),\n // Force a fresh fetch regardless of staleTime and enabled, cancelling\n // any in-flight request (explicit user intent — get current data).\n // Untracked, as the client's methods are: called from an effect, it\n // mustn't make the effect depend on the options or on the query. However\n // the fetch ends, the signals show it, so the promise resolves with their\n // data and error and never rejects.\n refetch: () =>\n untracked(() => {\n const options = defaultedOptions()\n\n return resolve(options.queryKey).fetch(options, {\n cancelRefetch: true,\n })\n })\n .catch(() => undefined)\n .then(() => ({ data: result.data(), error: result.error() })),\n }\n\n return {\n result,\n destroy: () => refs.forEach((ref) => ref.destroy()),\n }\n}\n","import {\n assertInInjectionContext,\n DestroyRef,\n inject,\n Injector,\n} from '@angular/core'\n\nimport { createQueryObserver } from './query-observer'\nimport type { QueryOptions, QueryResult } from './types'\n\n/**\n * Runs a cached, reactive query and exposes its state as signals.\n *\n * The query is keyed by `queryKey`: calls with the same key share a single\n * cache entry and in-flight request (deduplication). `optionsFn` is read in a\n * reactive context, so when a value it depends on changes (e.g. a route or\n * input signal in the key), the query automatically switches to the new key\n * and fetches. `optionsFn` isn't called before the query is first needed (its\n * first effect run or the first read of a result signal), so it can read\n * inputs, `input.required` included, and fields declared after the query. The\n * query is bound to the current injection context and cleans up its cache\n * observer when that context is destroyed.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by `queryFn`.\n * @typeParam TError - Type of the error thrown by `queryFn`.\n * @param optionsFn - Factory returning the {@link QueryOptions}. Re-evaluated\n * reactively: a new `queryKey` switches to that query and fetches it, and\n * turning `enabled` on starts the fetch. Re-evaluating with the same key\n * does not refetch, so every value `queryFn` reads belongs in the key.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A {@link QueryResult} of signals (`data`, `status`, `error`,\n * `isLoading`, `isPending`, …) plus a `refetch()` that forces a fresh fetch.\n *\n * @example\n * ```ts\n * @Component({\n * template: `\n * @if (todo.isPending()) { <p>Loading…</p> }\n * @if (todo.data(); as data) { <p>{{ data.title }}</p> }\n * `,\n * })\n * class TodoComponent {\n * readonly id = input.required<number>()\n * private readonly http = inject(HttpClient)\n *\n * // Refetches automatically whenever `id()` changes.\n * readonly todo = injectQuery(() => ({\n * queryKey: ['todo', this.id()],\n * queryFn: () => this.http.get<Todo>(`/api/todos/${this.id()}`),\n * }))\n * }\n * ```\n */\nexport function injectQuery<TData, TError = Error>(\n optionsFn: () => QueryOptions<TData, TError>,\n options?: { injector?: Injector },\n): QueryResult<TData, TError> {\n if (!options?.injector) assertInInjectionContext(injectQuery)\n\n const injector = options?.injector ?? inject(Injector)\n const { result, destroy } = createQueryObserver(optionsFn, injector)\n\n // The observation lives as long as the owning context (component or\n // injector): tear it down with it.\n injector.get(DestroyRef).onDestroy(destroy)\n\n return result\n}\n","import {\n type Signal,\n type WritableSignal,\n assertInInjectionContext,\n computed,\n DestroyRef,\n effect,\n inject,\n Injector,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { type QueryObserver, createQueryObserver } from './query-observer'\nimport type { QueryOptions, QueryResult } from './types'\nimport { hashKey } from './utils'\n\n/** Options for {@link injectQueries}. */\nexport interface InjectQueriesOptions<TData, TError = Error> {\n /**\n * One {@link QueryOptions} per query to run. The array may change between\n * evaluations: queries are matched to the previous set by `queryKey`, so a\n * new key starts a query and a missing key ends one.\n */\n queries: Array<QueryOptions<TData, TError>>\n}\n\n// A query kept alive by injectQueries: its observer plus the signal feeding it\n// options, written in place for as long as the key stays in the list.\ninterface Entry<TData, TError> {\n hash: string\n options: WritableSignal<QueryOptions<TData, TError>>\n observer: QueryObserver<TData, TError>\n}\n\n/**\n * Runs a dynamic number of queries in parallel and exposes their results as a\n * signal holding one {@link QueryResult} per entry of `queries`, in order.\n *\n * Reach for it when the set of queries depends on data — one query per id in\n * a list, say — where {@link injectQuery} can't be called in a loop. Each\n * query behaves exactly like a standalone `injectQuery`: its own cache entry,\n * `staleTime`, retries, error and observer. `optionsFn` is reactive: when the\n * array changes, queries whose `queryKey` is still present are kept (with\n * their options updated), new keys start fetching, and dropped keys release\n * their observer. As with `injectQuery`, `optionsFn` isn't called before the\n * results are first needed, so it can read inputs, `input.required` included,\n * and fields declared after the call. Aggregate across the results with\n * `computed`.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by each `queryFn`.\n * @typeParam TError - Type of the error thrown by each `queryFn`.\n * @param optionsFn - Factory returning the {@link InjectQueriesOptions}.\n * Re-evaluated reactively, so reading signals inside it re-syncs the set.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A signal of {@link QueryResult}s, one per query. The array identity\n * changes only when the set of queries changes, not on every data update.\n *\n * @example\n * ```ts\n * class TodoListComponent {\n * readonly #queries = inject(TodoQueries)\n *\n * readonly todoIds = input.required<number[]>()\n *\n * readonly todos = injectQueries(() => ({\n * queries: this.todoIds().map((id) => this.#queries.detail(id)),\n * }))\n *\n * readonly isPending = computed(() =>\n * this.todos().some((todo) => todo.isPending()),\n * )\n * }\n * ```\n */\nexport function injectQueries<TData, TError = Error>(\n optionsFn: () => InjectQueriesOptions<TData, TError>,\n options?: { injector?: Injector },\n): Signal<Array<QueryResult<TData, TError>>> {\n if (!options?.injector) assertInInjectionContext(injectQueries)\n\n const injector = options?.injector ?? inject(Injector)\n\n let entries: Array<Entry<TData, TError>> = []\n let current: Array<QueryResult<TData, TError>> = []\n let destroyed = false\n\n // Reconciles the entries with a new list, matching by key hash the way\n // TanStack's QueriesObserver does: a matching entry is reused and handed the\n // new options, an unmatched query gets a fresh observer, and whatever is\n // left over is destroyed. Duplicate keys are paired up one-to-one in order.\n const sync = (\n queries: Array<QueryOptions<TData, TError>>,\n ): Array<QueryResult<TData, TError>> => {\n const pool = new Map<string, Array<Entry<TData, TError>>>()\n\n for (const entry of entries) {\n const list = pool.get(entry.hash) ?? []\n\n list.push(entry)\n pool.set(entry.hash, list)\n }\n\n const next = queries.map((queryOptions) => {\n const hash = hashKey(queryOptions.queryKey)\n const match = pool.get(hash)?.shift()\n\n if (match) {\n match.options.set(queryOptions)\n\n return match\n }\n\n const optionsSignal = signal(queryOptions)\n\n return {\n hash,\n options: optionsSignal,\n observer: createQueryObserver(() => optionsSignal(), injector),\n }\n })\n\n for (const leftovers of pool.values()) {\n leftovers.forEach((entry) => entry.observer.destroy())\n }\n\n // Replace the result array only on a structural change, so a computed\n // over it doesn't recompute when merely the options were refreshed.\n const changed =\n next.length !== entries.length ||\n next.some((entry, index) => entry !== entries[index])\n\n entries = next\n\n if (changed) current = entries.map((entry) => entry.observer.result)\n\n return current\n }\n\n // The results of the effect's latest sync; unset until its first run.\n const synced = signal<Array<QueryResult<TData, TError>> | undefined>(\n undefined,\n )\n\n effect(\n () => {\n const { queries } = optionsFn()\n\n untracked(() => synced.set(sync(queries)))\n },\n { injector },\n )\n\n injector.get(DestroyRef).onDestroy(() => {\n destroyed = true\n entries.forEach((entry) => entry.observer.destroy())\n })\n\n // Nothing is synced until first needed: on the first read or the effect's\n // first run, whichever comes first. Syncing calls optionsFn, which may read\n // inputs or fields that don't exist yet while the owner is being\n // constructed. A read before the effect's first run syncs on the spot, so\n // it already sees the queries; once destroyed, it creates nothing.\n return computed(\n () =>\n synced() ?? (destroyed ? [] : untracked(() => sync(optionsFn().queries))),\n )\n}\n","import {\n assertInInjectionContext,\n computed,\n DestroyRef,\n inject,\n Injector,\n runInInjectionContext,\n signal,\n untracked,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport {\n type Mutation,\n type MutationOptions,\n type MutationResult,\n getInitialState,\n} from './mutation'\n\n/**\n * Creates a mutation for imperative writes (create/update/delete) and exposes\n * its state as signals.\n *\n * Unlike queries, a mutation does not run on its own — call `mutate(variables)`\n * to trigger `mutationFn`. The `onMutate` / `onSuccess` / `onError` /\n * `onSettled` lifecycle hooks make optimistic updates and cache invalidation\n * straightforward. A hook may return a promise; the mutation stays pending\n * until it settles. Mutations do not retry by default (a retried write is not\n * idempotent); opt in via `options.retry`. Whatever of `retry`, `retryDelay`\n * and the `onSuccess` / `onError` / `onSettled` hooks a mutation leaves unset\n * comes from {@link withDefaultOptions}. `mutateAsync(variables)` runs it\n * the same way and returns a promise of the run's data. `mutate()`,\n * `mutateAsync()` and `reset()` are safe to call from an effect: none makes\n * the effect depend on what it reads, such as the options or the previous\n * run. Bound to the current injection\n * context. Destroying it doesn't cancel a run in flight: the write has most\n * likely reached the server, so the run finishes and fires its hooks.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @typeParam TData - Type of the data resolved by `mutationFn`.\n * @typeParam TError - Type of the error thrown by `mutationFn`.\n * @typeParam TVariables - Type of the argument passed to `mutate()`.\n * @typeParam TContext - Type returned by `onMutate`, passed to later hooks.\n * @param optionsFn - Factory returning the {@link MutationOptions}.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A {@link MutationResult}: `mutate()`, `mutateAsync()`, `reset()`,\n * and state signals (`status`, `data`, `error`, `isPending`, …).\n *\n * @example\n * ```ts\n * const client = injectQueryClient()\n *\n * const addTodo = injectMutation(() => ({\n * mutationFn: (title: string) => http.post<Todo>('/api/todos', { title }),\n * onSuccess: () => client.invalidateQueries({ queryKey: ['todos'] }),\n * }))\n *\n * // <button (click)=\"addTodo.mutate('Buy milk')\" [disabled]=\"addTodo.isPending()\">Add</button>\n * ```\n */\nexport function injectMutation<\n TData,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n optionsFn: () => MutationOptions<TData, TError, TVariables, TContext>,\n options?: { injector?: Injector },\n): MutationResult<TData, TError, TVariables> {\n if (!options?.injector) assertInInjectionContext(injectMutation)\n\n const injector = options?.injector ?? inject(Injector)\n\n return runInInjectionContext(injector, () => {\n const client = inject(QueryClient)\n const cache = client.getMutationCache()\n\n // Every mutate() builds its own Mutation. Sharing one across calls meant a\n // second call overwrote the first's subscription (orphaning the request)\n // and its state (so the slower run, not the latest one, decided the result).\n const current = signal<Mutation<\n TData,\n TError,\n TVariables,\n TContext\n > | null>(null)\n\n // Detaching is all we do on destroy. A run still in flight keeps going —\n // the write has most likely reached the server already, so cancelling it\n // would only skip onSuccess and leave the cache out of sync. It drops\n // itself from the cache once it settles with nobody watching.\n inject(DestroyRef).onDestroy(() => untracked(current)?.removeObserver())\n\n const state = computed(\n () =>\n current()?.state() ??\n getInitialState<TData, TError, TVariables, TContext>(),\n )\n\n // mutate(), mutateAsync() and reset() run untracked, as the QueryClient's\n // methods do. A call made from an effect mustn't make the effect depend on\n // what they read to do their job: the previous run's state, the options,\n // or what onMutate and mutationFn read. Otherwise a change to any of them\n // re-runs the effect, and the effect repeats the call.\n //\n // Starts a run for mutate() and mutateAsync(), makes it the run the\n // signals below follow, and returns its promise.\n const start = (variables: TVariables): Promise<TData> =>\n untracked(() => {\n // Stop observing the previous run. It isn't cancelled — if it's\n // still in flight it finishes and fires its hooks; it just no longer\n // feeds the signals below.\n current()?.removeObserver()\n\n // Options are read per call, so a signal used in them stays live.\n const run = cache.build(client.defaultMutationOptions(optionsFn()))\n\n run.addObserver()\n current.set(run)\n\n return run.execute(variables)\n })\n\n return {\n // The outcome shows in the signals; a failure mustn't surface as an\n // unhandled rejection too.\n mutate: (variables) => {\n start(variables).catch(() => undefined)\n },\n mutateAsync: start,\n reset: () =>\n untracked(() => {\n // \"Forget the result\", not \"stop the request\". A run still in\n // flight keeps going and fires its hooks, so the cache stays in step\n // with the server — cancelling could not un-send the write anyway,\n // it could only hide the fact that it happened.\n current()?.removeObserver()\n\n current.set(null)\n }),\n data: computed(() => state().data),\n error: computed(() => state().error as TError | null),\n variables: computed(() => state().variables),\n status: computed(() => state().status),\n isIdle: computed(() => state().status === 'idle'),\n isPending: computed(() => state().status === 'pending'),\n isSuccess: computed(() => state().status === 'success'),\n isError: computed(() => state().status === 'error'),\n failureCount: computed(() => state().failureCount),\n failureReason: computed(() => state().failureReason as TError | null),\n }\n })\n}\n","import {\n type Injector,\n type Signal,\n assertInInjectionContext,\n computed,\n inject,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\nimport type { QueryFilters } from './types'\n\n/**\n * Returns a signal with the number of queries currently fetching — useful for a\n * global loading indicator.\n *\n * Pass {@link QueryFilters} to count only matching queries; omit them to count\n * every fetching query in the cache.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param filters - Optional filters (e.g. `{ queryKey: ['todos'] }`) to narrow\n * the count.\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A `Signal<number>` of active fetches.\n *\n * @example\n * ```ts\n * readonly isFetching = injectIsFetching()\n * // <app-spinner *ngIf=\"isFetching() > 0\" />\n * ```\n */\nexport function injectIsFetching(\n filters?: QueryFilters,\n options?: { injector?: Injector },\n): Signal<number> {\n if (!options?.injector) assertInInjectionContext(injectIsFetching)\n\n const client = options?.injector?.get(QueryClient) ?? inject(QueryClient)\n const cache = client.getQueryCache()\n\n return computed(\n () =>\n cache.findAll(filters).filter((query) => query.state().isFetching).length,\n )\n}\n","import {\n type Injector,\n type Signal,\n assertInInjectionContext,\n computed,\n inject,\n} from '@angular/core'\n\nimport { QueryClient } from './query-client'\n\n/**\n * Returns a signal with the number of mutations currently pending, including\n * those still running their hooks — useful for a global \"saving…\" indicator.\n *\n * Must run in an injection context, or be given an explicit `injector`.\n *\n * @param options - Optional `injector` to use outside an injection context.\n * @returns A `Signal<number>` of in-flight mutations.\n *\n * @example\n * ```ts\n * readonly isMutating = injectIsMutating()\n * // <p *ngIf=\"isMutating() > 0\">Saving…</p>\n * ```\n */\nexport function injectIsMutating(options?: {\n injector?: Injector\n}): Signal<number> {\n if (!options?.injector) assertInInjectionContext(injectIsMutating)\n\n const client = options?.injector?.get(QueryClient) ?? inject(QueryClient)\n const cache = client.getMutationCache()\n\n return computed(() => cache.findAll({ status: 'pending' }).length)\n}\n","import type { QueryOptions } from './types'\n\n/**\n * Identity helper that defines a typed, reusable set of {@link QueryOptions}.\n *\n * Returns the options unchanged at runtime, but anchors type inference so the\n * same definition can be shared across {@link injectQuery},\n * {@link QueryClient.setQueryData}, and friends without re-declaring generics.\n * Keeping query definitions in a service (rather than inline) makes them easy\n * to reuse and unit-test.\n *\n * @typeParam TData - Type of the data resolved by `queryFn`.\n * @typeParam TError - Type of the error thrown by `queryFn`.\n * @param options - The {@link QueryOptions} to define.\n * @returns The same `options`, typed.\n *\n * @example\n * ```ts\n * @Injectable({ providedIn: 'root' })\n * class TodoQueries {\n * private readonly http = inject(HttpClient)\n *\n * todos() {\n * return queryOptions({\n * queryKey: ['todos'],\n * queryFn: () => this.http.get<Todo[]>('/api/todos'),\n * })\n * }\n * }\n *\n * // const todos = injectQuery(() => inject(TodoQueries).todos())\n * ```\n */\nexport function queryOptions<TData, TError = Error>(\n options: QueryOptions<TData, TError>,\n): QueryOptions<TData, TError> {\n return options\n}\n","/**\n * Placeholder function that keeps the previous query's data visible while the\n * next one loads — pass as `placeholderData` to avoid flicker when the query\n * key changes (e.g. pagination, search).\n *\n * While the placeholder is shown, `status` reads `'success'` and\n * `isPlaceholderData()` is `true`; `isFetching()` stays `true` so the UI can\n * indicate the data is stale.\n *\n * @example\n * ```ts\n * readonly todos = injectQuery(() => ({\n * queryKey: ['todos', this.page()],\n * queryFn: () => this.http.get<Todo[]>(`/api/todos?page=${this.page()}`),\n * placeholderData: keepPreviousData,\n * }))\n * ```\n */\nexport function keepPreviousData<TData>(\n previousData: TData | undefined,\n): TData | undefined {\n return previousData\n}\n","import type { MutationOptions } from './mutation'\n\n/**\n * Identity helper that defines a typed, reusable set of {@link MutationOptions}.\n *\n * Returns the options unchanged at runtime; its job is to anchor type inference\n * (notably linking `TContext` returned by `onMutate` to the later hooks) so a\n * mutation can be defined once in a service and passed to {@link injectMutation}.\n *\n * @typeParam TData - Type of the data resolved by `mutationFn`.\n * @typeParam TError - Type of the error thrown by `mutationFn`.\n * @typeParam TVariables - Type of the argument passed to `mutate()`.\n * @typeParam TContext - Type returned by `onMutate`, passed to later hooks.\n * @param options - The {@link MutationOptions} to define.\n * @returns The same `options`, typed.\n *\n * @example\n * ```ts\n * addTodo() {\n * return mutationOptions({\n * mutationFn: (title: string) => this.http.post<Todo>('/api/todos', { title }),\n * onSuccess: () => this.client.invalidateQueries({ queryKey: ['todos'] }),\n * })\n * }\n * ```\n */\nexport function mutationOptions<\n TData,\n TError = Error,\n TVariables = void,\n TContext = unknown,\n>(\n options: MutationOptions<TData, TError, TVariables, TContext>,\n): MutationOptions<TData, TError, TVariables, TContext> {\n return options\n}\n","import { QUERY_CLIENT_CONFIG } from '../core/injection-tokens'\nimport type { DefaultOptions } from '../core/types'\nimport {\n type QueryClientFeature,\n QueryClientFeatureKind,\n queryClientFeature,\n} from './feature'\n\n/**\n * Feature for {@link provideQueryClient} that sets application-wide default\n * query and mutation options. A query's or mutation's own options take\n * precedence, field by field.\n *\n * @param options - The {@link DefaultOptions} to apply.\n * @returns A {@link QueryClientFeature} to pass to {@link provideQueryClient}.\n *\n * @example\n * ```ts\n * provideQueryClient(\n * withDefaultOptions({\n * queries: { staleTime: 60_000, retry: 1 },\n * mutations: {\n * onError: (error) => inject(ErrorHandler).handleError(error),\n * },\n * }),\n * )\n * ```\n */\nexport function withDefaultOptions(\n options: DefaultOptions,\n): QueryClientFeature<QueryClientFeatureKind.DefaultOptions> {\n return queryClientFeature(QueryClientFeatureKind.DefaultOptions, [\n { provide: QUERY_CLIENT_CONFIG, useValue: { defaultOptions: options } },\n ])\n}\n","/*\n * Public API Surface of ngx-query\n */\n\nexport * from './lib/core/query-client'\nexport * from './lib/core/provider'\nexport * from './lib/core/inject-query-client'\nexport * from './lib/core/types'\nexport * from './lib/core/inject-query'\nexport * from './lib/core/inject-queries'\nexport * from './lib/core/inject-mutation'\nexport * from './lib/core/inject-is-fetching'\nexport * from './lib/core/inject-is-mutating'\nexport * from './lib/core/query-options'\nexport * from './lib/core/keep-previous-data'\nexport * from './lib/core/mutation-options'\nexport * from './lib/core/cancelled-error'\nexport type {\n MutationFilters,\n MutationOptions,\n MutationResult,\n MutationState,\n MutationStatus,\n} from './lib/core/mutation'\nexport { QueryClientFeatureKind } from './lib/features/feature'\nexport type { QueryClientFeature } from './lib/features/feature'\nexport { withDefaultOptions } from './lib/features/with-default-options'\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["retry","retryOperator"],"mappings":";;;;;;AAGA;;;;;;;AAOG;SACa,SAAS,GAAA;AACvB,IAAA,OAAO,iBAAiB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/C;;ACNA;;;;;;;;;;;AAWG;AACG,SAAU,aAAa,CAAC,QAAoB,EAAA;IAChD,IAAI,CAAC,SAAS,EAAE;QAAE;AAElB,IAAA,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;AAEjC,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BAAkB,CAAC,sBAAsB,CAAC,cAAc,EAAE;QAC/D,EAAE,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,EAAE;AACxE,KAAA,CAAC;AACJ;;AClCA;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -106,7 +106,12 @@ type StructuralSharingValue<TData> = boolean | ((oldData: TData | undefined, new
|
|
|
106
106
|
type QueryOptions<TData, TError = Error> = {
|
|
107
107
|
/** Unique cache key for this query. See {@link QueryKey}. */
|
|
108
108
|
queryKey: QueryKey;
|
|
109
|
-
/**
|
|
109
|
+
/**
|
|
110
|
+
* Fetcher returning the data as an `Observable` or `Promise`. Once no
|
|
111
|
+
* component shows the query, an `Observable` fetch in flight is
|
|
112
|
+
* unsubscribed, which aborts an `HttpClient` request; a `Promise` one runs
|
|
113
|
+
* to the end, and its response is kept.
|
|
114
|
+
*/
|
|
110
115
|
queryFn: () => Observable<TData> | Promise<TData>;
|
|
111
116
|
/** How long fetched data stays fresh before refetching, in ms. Default `0`. */
|
|
112
117
|
staleTime?: number;
|
|
@@ -1024,9 +1029,10 @@ declare function mutationOptions<TData, TError = Error, TVariables = void, TCont
|
|
|
1024
1029
|
/**
|
|
1025
1030
|
* The error a promise of a query's data rejects with when the fetch stops
|
|
1026
1031
|
* with no data to give: it was cancelled before the query had any
|
|
1027
|
-
* (`cancelQueries()`, or the last component showing the query went away
|
|
1028
|
-
*
|
|
1029
|
-
* didn't fail, so tell
|
|
1032
|
+
* (`cancelQueries()`, or the last component showing the query went away
|
|
1033
|
+
* during an `Observable` fetch), or the query was removed
|
|
1034
|
+
* (`removeQueries()`, e.g. on sign-out). The request didn't fail, so tell
|
|
1035
|
+
* the two apart with `instanceof CancelledError`.
|
|
1030
1036
|
*
|
|
1031
1037
|
* A mutation's `mutateAsync()` rejects with one too, when the mutation cache
|
|
1032
1038
|
* is cleared while its run is in flight.
|
package/package.json
CHANGED