@tanstack/angular-query 5.0.0-rc.3 → 5.0.0-rc.5
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/hydration-state-key.mjs +10 -13
- package/hydration-state-key.mjs.map +1 -1
- package/index.mjs +8 -20
- package/index.mjs.map +1 -1
- package/infinite-query-options.d.ts +7 -18
- package/infinite-query-options.mjs +6 -5
- package/infinite-query-options.mjs.map +1 -1
- package/inject-base-query.d.ts +3 -0
- package/inject-base-query.mjs +62 -58
- package/inject-base-query.mjs.map +1 -1
- package/inject-infinite-query.d.ts +7 -11
- package/inject-infinite-query.mjs +16 -32
- package/inject-infinite-query.mjs.map +1 -1
- package/inject-is-fetching.d.ts +1 -1
- package/inject-is-fetching.mjs +22 -15
- package/inject-is-fetching.mjs.map +1 -1
- package/inject-is-mutating.d.ts +1 -1
- package/inject-is-mutating.mjs +22 -15
- package/inject-is-mutating.mjs.map +1 -1
- package/inject-is-restoring.d.ts +2 -0
- package/inject-is-restoring.mjs +28 -17
- package/inject-is-restoring.mjs.map +1 -1
- package/inject-mutation-state.d.ts +9 -0
- package/inject-mutation-state.mjs +25 -23
- package/inject-mutation-state.mjs.map +1 -1
- package/inject-mutation.d.ts +2 -4
- package/inject-mutation.mjs +87 -67
- package/inject-mutation.mjs.map +1 -1
- package/inject-queries.d.ts +1 -3
- package/inject-queries.mjs +122 -114
- package/inject-queries.mjs.map +1 -1
- package/inject-queries.types.d.ts +17 -1
- package/inject-query.d.ts +7 -13
- package/inject-query.mjs +11 -14
- package/inject-query.mjs.map +1 -1
- package/internal.mjs +2 -7
- package/mutation-options.d.ts +2 -6
- package/mutation-options.mjs +6 -5
- package/mutation-options.mjs.map +1 -1
- package/package.json +2 -2
- package/providers.d.ts +16 -14
- package/providers.mjs +138 -75
- package/providers.mjs.map +1 -1
- package/query-options.d.ts +6 -16
- package/query-options.mjs +6 -5
- package/query-options.mjs.map +1 -1
- package/query-resource.d.ts +4 -3
- package/query-resource.mjs +72 -63
- package/query-resource.mjs.map +1 -1
- package/schematics/migrate-from-experimental/index.js +38 -9
- package/schematics/migrate-from-experimental/workspace.js +48 -12
- package/schematics/ng-add/index.js +1 -1
- package/types.d.ts +76 -16
- package/utils/inject-external-store.d.ts +3 -0
- package/utils/inject-external-store.mjs +54 -38
- package/utils/inject-external-store.mjs.map +1 -1
- package/utils/inject-pending-tasks-lifecycle.d.ts +13 -1
- package/utils/inject-pending-tasks-lifecycle.mjs +32 -29
- package/utils/inject-pending-tasks-lifecycle.mjs.map +1 -1
- package/utils/inject-query-zone.d.ts +4 -1
- package/utils/inject-query-zone.mjs +12 -7
- package/utils/inject-query-zone.mjs.map +1 -1
- package/utils/resource-types.d.ts +3 -0
- package/utils/result-fields.d.ts +9 -0
- package/utils/result-fields.mjs +55 -62
- package/utils/result-fields.mjs.map +1 -1
- package/utils/signal-proxy.d.ts +6 -0
- package/utils/signal-proxy.mjs +16 -9
- package/utils/signal-proxy.mjs.map +1 -1
- package/internal.mjs.map +0 -1
|
@@ -1,41 +1,57 @@
|
|
|
1
|
-
import { assertInInjectionContext, inject, DestroyRef, signal, computed, effect, untracked } from "@angular/core";
|
|
2
1
|
import { injectQueryZone } from "./inject-query-zone.mjs";
|
|
2
|
+
import { DestroyRef, assertInInjectionContext, computed, effect, inject, signal, untracked } from "@angular/core";
|
|
3
|
+
//#region src/utils/inject-external-store.ts
|
|
4
|
+
/**
|
|
5
|
+
* Creates a readonly Angular signal backed by a synchronous external store.
|
|
6
|
+
*
|
|
7
|
+
* Store access, subscription setup, and cleanup run outside NgZone so background
|
|
8
|
+
* timers do not hold Angular stability open.
|
|
9
|
+
*
|
|
10
|
+
* Reads evaluate snapshots without subscribing. An effect owns the subscription
|
|
11
|
+
* and invalidates the snapshot after setup, closing the gap between an early
|
|
12
|
+
* read and connection. The next read recomputes the snapshot; equality prevents
|
|
13
|
+
* unchanged values from propagating. Unread snapshots stay lazy.
|
|
14
|
+
*
|
|
15
|
+
* Notifications invalidate snapshots synchronously once connected. Snapshot-only
|
|
16
|
+
* dependencies do not reinstall the subscription. Subscription setup and cleanup
|
|
17
|
+
* may read the returned signal; factories and snapshot readers must not recurse.
|
|
18
|
+
*
|
|
19
|
+
* Only factory/snapshot errors are exposed on reads. Subscription and cleanup
|
|
20
|
+
* errors follow Angular's normal effect error handling; the helper does not store
|
|
21
|
+
* them or implement retries. Destruction stops observation without changing the
|
|
22
|
+
* cached snapshot.
|
|
23
|
+
* @param binding - Produces the current snapshot reader and optional subscription.
|
|
24
|
+
* @param options - Optional equality comparison for snapshots.
|
|
25
|
+
* @returns A readonly signal containing the latest external snapshot.
|
|
26
|
+
*/
|
|
3
27
|
function injectExternalStore(binding, options) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
return computed(
|
|
31
|
-
() => {
|
|
32
|
-
revision();
|
|
33
|
-
return outsideZone(() => requested().getSnapshot());
|
|
34
|
-
},
|
|
35
|
-
(options == null ? void 0 : options.equal) ? { equal: options.equal } : void 0
|
|
36
|
-
);
|
|
28
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) assertInInjectionContext(injectExternalStore);
|
|
29
|
+
const owner = inject(DestroyRef);
|
|
30
|
+
const outsideZone = injectQueryZone();
|
|
31
|
+
const revision = signal(0);
|
|
32
|
+
const requested = computed(() => outsideZone(binding));
|
|
33
|
+
const invalidate = () => untracked(() => revision.update((n) => n + 1));
|
|
34
|
+
effect((onCleanup) => {
|
|
35
|
+
if (owner.destroyed) return;
|
|
36
|
+
const current = requested();
|
|
37
|
+
outsideZone(() => untracked(() => {
|
|
38
|
+
try {
|
|
39
|
+
const unsubscribe = current.subscribe?.(invalidate);
|
|
40
|
+
if (unsubscribe) {
|
|
41
|
+
if (owner.destroyed) unsubscribe();
|
|
42
|
+
else onCleanup(() => outsideZone(unsubscribe));
|
|
43
|
+
}
|
|
44
|
+
} finally {
|
|
45
|
+
invalidate();
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
});
|
|
49
|
+
return computed(() => {
|
|
50
|
+
revision();
|
|
51
|
+
return outsideZone(() => requested().getSnapshot());
|
|
52
|
+
}, options?.equal ? { equal: options.equal } : void 0);
|
|
37
53
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=inject-external-store.mjs.map
|
|
54
|
+
//#endregion
|
|
55
|
+
export { injectExternalStore };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=inject-external-store.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-external-store.mjs","sources":["../../src/utils/inject-external-store.ts"],"sourcesContent":["import {\n DestroyRef,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport { injectQueryZone } from './inject-query-zone'\nimport type { Signal, ValueEqualityFn } from '@angular/core'\n\ninterface ExternalBinding<T> {\n /** Synchronous snapshot. Angular signals read here are tracked dependencies. */\n readonly getSnapshot: () => T\n /** Omit to pause observation; changing eligibility requires a new descriptor. */\n readonly subscribe?: ((notify: () => void) => () => void) | undefined\n}\n\ninterface ExternalStoreOptions<T> {\n /** Snapshot equality, defaulting to Object.is. Does not control connection identity. */\n readonly equal?: ValueEqualityFn<T> | undefined\n}\n\n/**\n * Creates a readonly Angular signal backed by a synchronous external store.\n *\n * Store access, subscription setup, and cleanup run outside NgZone so background\n * timers do not hold Angular stability open.\n *\n * Reads evaluate snapshots without subscribing. An effect owns the subscription\n * and invalidates the snapshot after setup, closing the gap between an early\n * read and connection. The next read recomputes the snapshot; equality prevents\n * unchanged values from propagating. Unread snapshots stay lazy.\n *\n * Notifications invalidate snapshots synchronously once connected. Snapshot-only\n * dependencies do not reinstall the subscription. Subscription setup and cleanup\n * may read the returned signal; factories and snapshot readers must not recurse.\n *\n * Only factory/snapshot errors are exposed on reads. Subscription and cleanup\n * errors follow Angular's normal effect error handling; the helper does not store\n * them or implement retries. Destruction stops observation without changing the\n * cached snapshot.\n */\nexport function injectExternalStore<T>(\n binding: () => ExternalBinding<T>,\n options?: ExternalStoreOptions<T>,\n): Signal<T> {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertInInjectionContext(injectExternalStore)\n }\n const owner = inject(DestroyRef)\n const outsideZone = injectQueryZone()\n const revision = signal(0)\n const requested = computed(() => outsideZone(binding))\n const invalidate = () => untracked(() => revision.update((n) => n + 1))\n\n effect((onCleanup) => {\n // The previous subscription's cleanup may have destroyed the owner.\n if (owner.destroyed) return\n const current = requested()\n outsideZone(() =>\n untracked(() => {\n try {\n const unsubscribe = current.subscribe?.(invalidate)\n if (unsubscribe) {\n // subscribe() can trigger component/injector destruction before returning.\n // Registering cleanup afterward misses that destruction.\n if (owner.destroyed) unsubscribe()\n else onCleanup(() => outsideZone(unsubscribe))\n }\n } finally {\n // Invalidate after subscribing so an early cached snapshot cannot miss\n // changes before or during setup. Do not eagerly read the snapshot.\n invalidate()\n }\n }),\n )\n })\n\n return computed(\n () => {\n revision()\n return outsideZone(() => requested().getSnapshot())\n },\n options?.equal ? { equal: options.equal } : undefined,\n )\n}\n"],"
|
|
1
|
+
{"version":3,"file":"inject-external-store.mjs","names":[],"sources":["../../src/utils/inject-external-store.ts"],"sourcesContent":["import {\n DestroyRef,\n assertInInjectionContext,\n computed,\n effect,\n inject,\n signal,\n untracked,\n} from '@angular/core'\nimport { injectQueryZone } from './inject-query-zone'\nimport type { Signal, ValueEqualityFn } from '@angular/core'\n\ninterface ExternalBinding<T> {\n /** Synchronous snapshot. Angular signals read here are tracked dependencies. */\n readonly getSnapshot: () => T\n /** Omit to pause observation; changing eligibility requires a new descriptor. */\n readonly subscribe?: ((notify: () => void) => () => void) | undefined\n}\n\ninterface ExternalStoreOptions<T> {\n /** Snapshot equality, defaulting to Object.is. Does not control connection identity. */\n readonly equal?: ValueEqualityFn<T> | undefined\n}\n\n/**\n * Creates a readonly Angular signal backed by a synchronous external store.\n *\n * Store access, subscription setup, and cleanup run outside NgZone so background\n * timers do not hold Angular stability open.\n *\n * Reads evaluate snapshots without subscribing. An effect owns the subscription\n * and invalidates the snapshot after setup, closing the gap between an early\n * read and connection. The next read recomputes the snapshot; equality prevents\n * unchanged values from propagating. Unread snapshots stay lazy.\n *\n * Notifications invalidate snapshots synchronously once connected. Snapshot-only\n * dependencies do not reinstall the subscription. Subscription setup and cleanup\n * may read the returned signal; factories and snapshot readers must not recurse.\n *\n * Only factory/snapshot errors are exposed on reads. Subscription and cleanup\n * errors follow Angular's normal effect error handling; the helper does not store\n * them or implement retries. Destruction stops observation without changing the\n * cached snapshot.\n * @param binding - Produces the current snapshot reader and optional subscription.\n * @param options - Optional equality comparison for snapshots.\n * @returns A readonly signal containing the latest external snapshot.\n */\nexport function injectExternalStore<T>(\n binding: () => ExternalBinding<T>,\n options?: ExternalStoreOptions<T>,\n): Signal<T> {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n assertInInjectionContext(injectExternalStore)\n }\n const owner = inject(DestroyRef)\n const outsideZone = injectQueryZone()\n const revision = signal(0)\n const requested = computed(() => outsideZone(binding))\n const invalidate = () => untracked(() => revision.update((n) => n + 1))\n\n effect((onCleanup) => {\n // The previous subscription's cleanup may have destroyed the owner.\n if (owner.destroyed) return\n const current = requested()\n outsideZone(() =>\n untracked(() => {\n try {\n const unsubscribe = current.subscribe?.(invalidate)\n if (unsubscribe) {\n // subscribe() can trigger component/injector destruction before returning.\n // Registering cleanup afterward misses that destruction.\n if (owner.destroyed) unsubscribe()\n else onCleanup(() => outsideZone(unsubscribe))\n }\n } finally {\n // Invalidate after subscribing so an early cached snapshot cannot miss\n // changes before or during setup. Do not eagerly read the snapshot.\n invalidate()\n }\n }),\n )\n })\n\n return computed(\n () => {\n revision()\n return outsideZone(() => requested().getSnapshot())\n },\n options?.equal ? { equal: options.equal } : undefined,\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,SAAgB,oBACd,SACA,SACW;CACX,IAAI,OAAO,cAAc,eAAe,WACtC,yBAAyB,mBAAmB;CAE9C,MAAM,QAAQ,OAAO,UAAU;CAC/B,MAAM,cAAc,gBAAgB;CACpC,MAAM,WAAW,OAAO,CAAC;CACzB,MAAM,YAAY,eAAe,YAAY,OAAO,CAAC;CACrD,MAAM,mBAAmB,gBAAgB,SAAS,QAAQ,MAAM,IAAI,CAAC,CAAC;CAEtE,QAAQ,cAAc;EAEpB,IAAI,MAAM,WAAW;EACrB,MAAM,UAAU,UAAU;EAC1B,kBACE,gBAAgB;GACd,IAAI;IACF,MAAM,cAAc,QAAQ,YAAY,UAAU;IAClD,IAAI,aAAa;KAGf,IAAI,MAAM,WAAW,YAAY;UAC5B,gBAAgB,YAAY,WAAW,CAAC;IAC/C;GACF,UAAU;IAGR,WAAW;GACb;EACF,CAAC,CACH;CACF,CAAC;CAED,OAAO,eACC;EACJ,SAAS;EACT,OAAO,kBAAkB,UAAU,CAAC,CAAC,YAAY,CAAC;CACpD,GACA,SAAS,QAAQ,EAAE,OAAO,QAAQ,MAAM,IAAI,KAAA,CAC9C;AACF"}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks ownership and pending work for the current Angular injection context.
|
|
3
|
+
*/
|
|
1
4
|
export interface QueryLifecycle {
|
|
5
|
+
/**
|
|
6
|
+
* Whether Angular has destroyed the injection context that owns this query.
|
|
7
|
+
*/
|
|
2
8
|
readonly destroyed: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Adds or releases the task that keeps Angular unstable while owned work is pending.
|
|
11
|
+
*/
|
|
3
12
|
setPending: (pending: boolean) => void;
|
|
4
13
|
}
|
|
5
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Tracks pending work for the lifetime of the current injection context.
|
|
16
|
+
* @returns The destruction state and pending-task controller for this context.
|
|
17
|
+
*/
|
|
6
18
|
export declare function injectPendingTasksLifecycle(): QueryLifecycle;
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DestroyRef, NgZone, PendingTasks, inject } from "@angular/core";
|
|
2
|
+
//#region src/utils/inject-pending-tasks-lifecycle.ts
|
|
3
|
+
/**
|
|
4
|
+
* Tracks pending work for the lifetime of the current injection context.
|
|
5
|
+
* @returns The destruction state and pending-task controller for this context.
|
|
6
|
+
*/
|
|
2
7
|
function injectPendingTasksLifecycle() {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
26
|
-
return lifecycle;
|
|
8
|
+
const destroyRef = inject(DestroyRef);
|
|
9
|
+
const pendingTasks = inject(PendingTasks);
|
|
10
|
+
const ngZone = inject(NgZone);
|
|
11
|
+
let taskCleanup;
|
|
12
|
+
const lifecycle = {
|
|
13
|
+
get destroyed() {
|
|
14
|
+
return destroyRef.destroyed;
|
|
15
|
+
},
|
|
16
|
+
setPending(pending) {
|
|
17
|
+
if (pending) {
|
|
18
|
+
if (!destroyRef.destroyed && !taskCleanup) taskCleanup = pendingTasks.add();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const cleanup = taskCleanup;
|
|
22
|
+
taskCleanup = void 0;
|
|
23
|
+
if (cleanup) ngZone.run(cleanup);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
destroyRef.onDestroy(() => {
|
|
27
|
+
lifecycle.setPending(false);
|
|
28
|
+
});
|
|
29
|
+
return lifecycle;
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=inject-pending-tasks-lifecycle.mjs.map
|
|
31
|
+
//#endregion
|
|
32
|
+
export { injectPendingTasksLifecycle };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=inject-pending-tasks-lifecycle.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-pending-tasks-lifecycle.mjs","sources":["../../src/utils/inject-pending-tasks-lifecycle.ts"],"sourcesContent":["import { DestroyRef, NgZone, PendingTasks, inject } from '@angular/core'\n\nexport interface QueryLifecycle {\n readonly destroyed: boolean\n setPending: (pending: boolean) => void\n}\n\n
|
|
1
|
+
{"version":3,"file":"inject-pending-tasks-lifecycle.mjs","names":[],"sources":["../../src/utils/inject-pending-tasks-lifecycle.ts"],"sourcesContent":["import { DestroyRef, NgZone, PendingTasks, inject } from '@angular/core'\n\n/**\n * Tracks ownership and pending work for the current Angular injection context.\n */\nexport interface QueryLifecycle {\n /**\n * Whether Angular has destroyed the injection context that owns this query.\n */\n readonly destroyed: boolean\n /**\n * Adds or releases the task that keeps Angular unstable while owned work is pending.\n */\n setPending: (pending: boolean) => void\n}\n\n/**\n * Tracks pending work for the lifetime of the current injection context.\n * @returns The destruction state and pending-task controller for this context.\n */\nexport function injectPendingTasksLifecycle(): QueryLifecycle {\n const destroyRef = inject(DestroyRef)\n const pendingTasks = inject(PendingTasks)\n const ngZone = inject(NgZone)\n let taskCleanup: (() => void) | undefined\n\n const lifecycle: QueryLifecycle = {\n get destroyed() {\n return destroyRef.destroyed\n },\n setPending(pending) {\n if (pending) {\n if (!destroyRef.destroyed && !taskCleanup) {\n taskCleanup = pendingTasks.add()\n }\n return\n }\n\n const cleanup = taskCleanup\n taskCleanup = undefined\n // Enter NgZone while our task is still held to avoid transient stability\n // before dependent queries are scheduled.\n // In zoneless apps, NgZone.run simply invokes the cleanup.\n if (cleanup) ngZone.run(cleanup)\n },\n }\n\n destroyRef.onDestroy(() => {\n lifecycle.setPending(false)\n })\n\n return lifecycle\n}\n"],"mappings":";;;;;;AAoBA,SAAgB,8BAA8C;CAC5D,MAAM,aAAa,OAAO,UAAU;CACpC,MAAM,eAAe,OAAO,YAAY;CACxC,MAAM,SAAS,OAAO,MAAM;CAC5B,IAAI;CAEJ,MAAM,YAA4B;EAChC,IAAI,YAAY;GACd,OAAO,WAAW;EACpB;EACA,WAAW,SAAS;GAClB,IAAI,SAAS;IACX,IAAI,CAAC,WAAW,aAAa,CAAC,aAC5B,cAAc,aAAa,IAAI;IAEjC;GACF;GAEA,MAAM,UAAU;GAChB,cAAc,KAAA;GAId,IAAI,SAAS,OAAO,IAAI,OAAO;EACjC;CACF;CAEA,WAAW,gBAAgB;EACzB,UAAU,WAAW,KAAK;CAC5B,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Keeps Query's background timers out of Angular's stability tracking.
|
|
3
|
+
* @returns A function that runs callbacks outside the injected NgZone.
|
|
4
|
+
*/
|
|
2
5
|
export declare function injectQueryZone(): <T>(fn: () => T) => T;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NgZone, inject } from "@angular/core";
|
|
2
|
+
//#region src/utils/inject-query-zone.ts
|
|
3
|
+
/**
|
|
4
|
+
* Keeps Query's background timers out of Angular's stability tracking.
|
|
5
|
+
* @returns A function that runs callbacks outside the injected NgZone.
|
|
6
|
+
*/
|
|
2
7
|
function injectQueryZone() {
|
|
3
|
-
|
|
4
|
-
|
|
8
|
+
const ngZone = inject(NgZone);
|
|
9
|
+
return (fn) => ngZone.runOutsideAngular(fn);
|
|
5
10
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
//# sourceMappingURL=inject-query-zone.mjs.map
|
|
11
|
+
//#endregion
|
|
12
|
+
export { injectQueryZone };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=inject-query-zone.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject-query-zone.mjs","sources":["../../src/utils/inject-query-zone.ts"],"sourcesContent":["import { NgZone, inject } from '@angular/core'\n\n
|
|
1
|
+
{"version":3,"file":"inject-query-zone.mjs","names":[],"sources":["../../src/utils/inject-query-zone.ts"],"sourcesContent":["import { NgZone, inject } from '@angular/core'\n\n/**\n * Keeps Query's background timers out of Angular's stability tracking.\n * @returns A function that runs callbacks outside the injected NgZone.\n */\nexport function injectQueryZone() {\n const ngZone = inject(NgZone)\n return <T>(fn: () => T): T => ngZone.runOutsideAngular(fn)\n}\n"],"mappings":";;;;;;AAMA,SAAgB,kBAAkB;CAChC,MAAM,SAAS,OAAO,MAAM;CAC5B,QAAW,OAAmB,OAAO,kBAAkB,EAAE;AAC3D"}
|
package/utils/result-fields.d.ts
CHANGED
|
@@ -72,9 +72,18 @@ declare const mutationFields: {
|
|
|
72
72
|
isSuccess: true;
|
|
73
73
|
};
|
|
74
74
|
export declare const queryResultFields: Array<keyof typeof queryFields>;
|
|
75
|
+
/**
|
|
76
|
+
* The query observer value fields exposed as Angular signals.
|
|
77
|
+
*/
|
|
75
78
|
export type QueryResultFields = (typeof queryResultFields)[number];
|
|
76
79
|
export declare const infiniteQueryResultFields: Array<keyof typeof infiniteQueryFields>;
|
|
80
|
+
/**
|
|
81
|
+
* The paginated query observer value fields exposed as Angular signals.
|
|
82
|
+
*/
|
|
77
83
|
export type InfiniteQueryResultFields = (typeof infiniteQueryResultFields)[number];
|
|
78
84
|
export declare const mutationResultFields: Array<keyof typeof mutationFields>;
|
|
85
|
+
/**
|
|
86
|
+
* The mutation observer value fields exposed as Angular signals.
|
|
87
|
+
*/
|
|
79
88
|
export type MutationResultFields = (typeof mutationResultFields)[number];
|
|
80
89
|
export {};
|
package/utils/result-fields.mjs
CHANGED
|
@@ -1,65 +1,58 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
//#region src/utils/result-fields.ts
|
|
2
|
+
var queryFields = {
|
|
3
|
+
data: true,
|
|
4
|
+
dataUpdatedAt: true,
|
|
5
|
+
error: true,
|
|
6
|
+
errorUpdatedAt: true,
|
|
7
|
+
failureCount: true,
|
|
8
|
+
failureReason: true,
|
|
9
|
+
errorUpdateCount: true,
|
|
10
|
+
isError: true,
|
|
11
|
+
isFetched: true,
|
|
12
|
+
isFetchedAfterMount: true,
|
|
13
|
+
isFetching: true,
|
|
14
|
+
isLoading: true,
|
|
15
|
+
isPending: true,
|
|
16
|
+
isLoadingError: true,
|
|
17
|
+
isInitialLoading: true,
|
|
18
|
+
isPaused: true,
|
|
19
|
+
isPlaceholderData: true,
|
|
20
|
+
isRefetchError: true,
|
|
21
|
+
isRefetching: true,
|
|
22
|
+
isStale: true,
|
|
23
|
+
isSuccess: true,
|
|
24
|
+
isEnabled: true,
|
|
25
|
+
status: true,
|
|
26
|
+
fetchStatus: true
|
|
26
27
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
var infiniteQueryFields = {
|
|
29
|
+
...queryFields,
|
|
30
|
+
hasNextPage: true,
|
|
31
|
+
hasPreviousPage: true,
|
|
32
|
+
isFetchNextPageError: true,
|
|
33
|
+
isFetchingNextPage: true,
|
|
34
|
+
isFetchPreviousPageError: true,
|
|
35
|
+
isFetchingPreviousPage: true
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
var mutationFields = {
|
|
38
|
+
context: true,
|
|
39
|
+
data: true,
|
|
40
|
+
error: true,
|
|
41
|
+
failureCount: true,
|
|
42
|
+
failureReason: true,
|
|
43
|
+
isPaused: true,
|
|
44
|
+
status: true,
|
|
45
|
+
variables: true,
|
|
46
|
+
submittedAt: true,
|
|
47
|
+
isError: true,
|
|
48
|
+
isIdle: true,
|
|
49
|
+
isPending: true,
|
|
50
|
+
isSuccess: true
|
|
50
51
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
mutationFields
|
|
59
|
-
);
|
|
60
|
-
export {
|
|
61
|
-
infiniteQueryResultFields,
|
|
62
|
-
mutationResultFields,
|
|
63
|
-
queryResultFields
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=result-fields.mjs.map
|
|
52
|
+
var queryResultFields = /* #__PURE__ */ Object.keys(queryFields);
|
|
53
|
+
var infiniteQueryResultFields = /* #__PURE__ */ Object.keys(infiniteQueryFields);
|
|
54
|
+
var mutationResultFields = /* #__PURE__ */ Object.keys(mutationFields);
|
|
55
|
+
//#endregion
|
|
56
|
+
export { infiniteQueryResultFields, mutationResultFields, queryResultFields };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=result-fields.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result-fields.mjs","sources":["../../src/utils/result-fields.ts"],"sourcesContent":["import type {\n InfiniteQueryObserverResult,\n MutationObserverResult,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { MethodKeys } from './signal-proxy'\n\ntype Fields<T> = { [K in Exclude<keyof T, MethodKeys<T>>]: true }\n\n// Exhaustive maps keep the field surface aligned with query-core at compile time.\nconst queryFields = {\n data: true,\n dataUpdatedAt: true,\n error: true,\n errorUpdatedAt: true,\n failureCount: true,\n failureReason: true,\n errorUpdateCount: true,\n isError: true,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: true,\n isLoading: true,\n isPending: true,\n isLoadingError: true,\n isInitialLoading: true,\n isPaused: true,\n isPlaceholderData: true,\n isRefetchError: true,\n isRefetching: true,\n isStale: true,\n isSuccess: true,\n isEnabled: true,\n status: true,\n fetchStatus: true,\n} satisfies Fields<QueryObserverResult>\n\nconst infiniteQueryFields = {\n ...queryFields,\n hasNextPage: true,\n hasPreviousPage: true,\n isFetchNextPageError: true,\n isFetchingNextPage: true,\n isFetchPreviousPageError: true,\n isFetchingPreviousPage: true,\n} satisfies Fields<InfiniteQueryObserverResult>\n\nconst mutationFields = {\n context: true,\n data: true,\n error: true,\n failureCount: true,\n failureReason: true,\n isPaused: true,\n status: true,\n variables: true,\n submittedAt: true,\n isError: true,\n isIdle: true,\n isPending: true,\n isSuccess: true,\n} satisfies Fields<MutationObserverResult>\n\nexport const queryResultFields = /*
|
|
1
|
+
{"version":3,"file":"result-fields.mjs","names":[],"sources":["../../src/utils/result-fields.ts"],"sourcesContent":["import type {\n InfiniteQueryObserverResult,\n MutationObserverResult,\n QueryObserverResult,\n} from '@tanstack/query-core'\nimport type { MethodKeys } from './signal-proxy'\n\ntype Fields<T> = { [K in Exclude<keyof T, MethodKeys<T>>]: true }\n\n// Exhaustive maps keep the field surface aligned with query-core at compile time.\nconst queryFields = {\n data: true,\n dataUpdatedAt: true,\n error: true,\n errorUpdatedAt: true,\n failureCount: true,\n failureReason: true,\n errorUpdateCount: true,\n isError: true,\n isFetched: true,\n isFetchedAfterMount: true,\n isFetching: true,\n isLoading: true,\n isPending: true,\n isLoadingError: true,\n isInitialLoading: true,\n isPaused: true,\n isPlaceholderData: true,\n isRefetchError: true,\n isRefetching: true,\n isStale: true,\n isSuccess: true,\n isEnabled: true,\n status: true,\n fetchStatus: true,\n} satisfies Fields<QueryObserverResult>\n\nconst infiniteQueryFields = {\n ...queryFields,\n hasNextPage: true,\n hasPreviousPage: true,\n isFetchNextPageError: true,\n isFetchingNextPage: true,\n isFetchPreviousPageError: true,\n isFetchingPreviousPage: true,\n} satisfies Fields<InfiniteQueryObserverResult>\n\nconst mutationFields = {\n context: true,\n data: true,\n error: true,\n failureCount: true,\n failureReason: true,\n isPaused: true,\n status: true,\n variables: true,\n submittedAt: true,\n isError: true,\n isIdle: true,\n isPending: true,\n isSuccess: true,\n} satisfies Fields<MutationObserverResult>\n\nexport const queryResultFields = /* #__PURE__ */ Object.keys(\n queryFields,\n) as Array<keyof typeof queryFields>\n/**\n * The query observer value fields exposed as Angular signals.\n */\nexport type QueryResultFields = (typeof queryResultFields)[number]\n\nexport const infiniteQueryResultFields = /* #__PURE__ */ Object.keys(\n infiniteQueryFields,\n) as Array<keyof typeof infiniteQueryFields>\n/**\n * The paginated query observer value fields exposed as Angular signals.\n */\nexport type InfiniteQueryResultFields =\n (typeof infiniteQueryResultFields)[number]\n\nexport const mutationResultFields = /* #__PURE__ */ Object.keys(\n mutationFields,\n) as Array<keyof typeof mutationFields>\n/**\n * The mutation observer value fields exposed as Angular signals.\n */\nexport type MutationResultFields = (typeof mutationResultFields)[number]\n"],"mappings":";AAUA,IAAM,cAAc;CAClB,MAAM;CACN,eAAe;CACf,OAAO;CACP,gBAAgB;CAChB,cAAc;CACd,eAAe;CACf,kBAAkB;CAClB,SAAS;CACT,WAAW;CACX,qBAAqB;CACrB,YAAY;CACZ,WAAW;CACX,WAAW;CACX,gBAAgB;CAChB,kBAAkB;CAClB,UAAU;CACV,mBAAmB;CACnB,gBAAgB;CAChB,cAAc;CACd,SAAS;CACT,WAAW;CACX,WAAW;CACX,QAAQ;CACR,aAAa;AACf;AAEA,IAAM,sBAAsB;CAC1B,GAAG;CACH,aAAa;CACb,iBAAiB;CACjB,sBAAsB;CACtB,oBAAoB;CACpB,0BAA0B;CAC1B,wBAAwB;AAC1B;AAEA,IAAM,iBAAiB;CACrB,SAAS;CACT,MAAM;CACN,OAAO;CACP,cAAc;CACd,eAAe;CACf,UAAU;CACV,QAAQ;CACR,WAAW;CACX,aAAa;CACb,SAAS;CACT,QAAQ;CACR,WAAW;CACX,WAAW;AACb;AAEA,IAAa,oBAAoC,uBAAO,KACtD,WACF;AAMA,IAAa,4BAA4C,uBAAO,KAC9D,mBACF;AAOA,IAAa,uBAAuC,uBAAO,KACzD,cACF"}
|
package/utils/signal-proxy.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { Signal } from '@angular/core';
|
|
2
|
+
/**
|
|
3
|
+
* Names of object properties whose values are callable.
|
|
4
|
+
*/
|
|
2
5
|
export type MethodKeys<T> = {
|
|
3
6
|
[K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never;
|
|
4
7
|
}[keyof T];
|
|
8
|
+
/**
|
|
9
|
+
* Exposes selected object fields as Angular signals and leaves all other fields unchanged.
|
|
10
|
+
*/
|
|
5
11
|
export type MapToSignals<T, TSignalFields extends keyof any = never> = {
|
|
6
12
|
[K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>;
|
|
7
13
|
} & {
|
package/utils/signal-proxy.mjs
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { computed } from "@angular/core";
|
|
2
|
+
//#region src/utils/signal-proxy.ts
|
|
3
|
+
/**
|
|
4
|
+
* Maps known result fields to lazy computed signals on an ordinary object.
|
|
5
|
+
* Creating or enumerating the fields never evaluates the source. Imperative
|
|
6
|
+
* methods are defined by each adapter, outside this mapping.
|
|
7
|
+
* @param inputSignal - The source snapshot.
|
|
8
|
+
* @param fields - The fields exposed as signals.
|
|
9
|
+
* @returns An object containing one stable signal per field.
|
|
10
|
+
*/
|
|
2
11
|
function signalProxy(inputSignal, fields) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
return result;
|
|
12
|
+
const result = {};
|
|
13
|
+
for (const field of fields) result[field] = computed(() => inputSignal()[field]);
|
|
14
|
+
return result;
|
|
8
15
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//# sourceMappingURL=signal-proxy.mjs.map
|
|
16
|
+
//#endregion
|
|
17
|
+
export { signalProxy };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=signal-proxy.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signal-proxy.mjs","sources":["../../src/utils/signal-proxy.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\nexport type MethodKeys<T> = {\n [K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never\n}[keyof T]\n\nexport type MapToSignals<T, TSignalFields extends keyof any = never> = {\n [K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>\n} & {\n [K in keyof T as K extends TSignalFields ? never : K]: T[K]\n}\n\n/**\n * Maps known result fields to lazy computed signals on an ordinary object.\n * Creating or enumerating the fields never evaluates the source. Imperative\n * methods are defined by each adapter, outside this mapping.\n * @param inputSignal - The source snapshot.\n * @param fields - The fields exposed as signals.\n * @returns An object containing one stable signal per field.\n */\nexport function signalProxy<T, TField extends keyof T>(\n inputSignal: Signal<T>,\n fields: ReadonlyArray<TField>,\n): { [P in TField]: Signal<T[P]> } {\n const result = {} as { [P in TField]: Signal<T[P]> }\n for (const field of fields) {\n result[field] = computed(() => inputSignal()[field])\n }\n return result\n}\n"],"
|
|
1
|
+
{"version":3,"file":"signal-proxy.mjs","names":[],"sources":["../../src/utils/signal-proxy.ts"],"sourcesContent":["import { computed } from '@angular/core'\nimport type { Signal } from '@angular/core'\n\n/**\n * Names of object properties whose values are callable.\n */\nexport type MethodKeys<T> = {\n [K in keyof T]: T[K] extends (...args: Array<any>) => any ? K : never\n}[keyof T]\n\n/**\n * Exposes selected object fields as Angular signals and leaves all other fields unchanged.\n */\nexport type MapToSignals<T, TSignalFields extends keyof any = never> = {\n [K in keyof T as K extends TSignalFields ? K : never]: Signal<T[K]>\n} & {\n [K in keyof T as K extends TSignalFields ? never : K]: T[K]\n}\n\n/**\n * Maps known result fields to lazy computed signals on an ordinary object.\n * Creating or enumerating the fields never evaluates the source. Imperative\n * methods are defined by each adapter, outside this mapping.\n * @param inputSignal - The source snapshot.\n * @param fields - The fields exposed as signals.\n * @returns An object containing one stable signal per field.\n */\nexport function signalProxy<T, TField extends keyof T>(\n inputSignal: Signal<T>,\n fields: ReadonlyArray<TField>,\n): { [P in TField]: Signal<T[P]> } {\n const result = {} as { [P in TField]: Signal<T[P]> }\n for (const field of fields) {\n result[field] = computed(() => inputSignal()[field])\n }\n return result\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,YACd,aACA,QACiC;CACjC,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,SAAS,QAClB,OAAO,SAAS,eAAe,YAAY,CAAC,CAAC,MAAM;CAErD,OAAO;AACT"}
|
package/internal.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|